source stringlengths 17 118 | lean4 stringlengths 0 335k |
|---|---|
.lake/packages/mathlib/Mathlib/GroupTheory/Rank.lean | import Mathlib.GroupTheory.Finiteness
import Mathlib.SetTheory.Cardinal.Finite
/-!
# Rank of a group
This file defines the rank of a group, namely the minimum size of a generating set.
## TODO
Should we define `erank G : ℕ∞` the rank of a not necessarily finitely generated group `G`,
then redefine `rank G` as `(erank G).toNat`? Maybe a `Cardinal`-valued version too?
-/
open Function Group
variable {G H : Type*} [Group G] [Group H]
namespace Group
variable (G) in
/-- The minimum number of generators of a group. -/
@[to_additive /-- The minimum number of generators of an additive group. -/]
noncomputable def rank [h : FG G] : ℕ := @Nat.find _ (Classical.decPred _) (fg_iff'.mp h)
variable (G) in
@[to_additive]
lemma rank_spec [h : FG G] : ∃ S : Finset G, S.card = rank G ∧ .closure S = (⊤ : Subgroup G) :=
@Nat.find_spec _ (Classical.decPred _) (fg_iff'.mp h)
@[to_additive]
lemma rank_le [h : FG G] {S : Finset G} (hS : .closure S = (⊤ : Subgroup G)) : rank G ≤ S.card :=
@Nat.find_le _ _ (Classical.decPred _) (fg_iff'.mp h) ⟨S, rfl, hS⟩
@[to_additive]
lemma rank_le_of_surjective [FG G] [FG H] (f : G →* H) (hf : Surjective f) : rank H ≤ rank G := by
classical
obtain ⟨S, hS1, hS2⟩ := rank_spec G
trans (S.image f).card
· apply rank_le
rw [Finset.coe_image, ← MonoidHom.map_closure, hS2, Subgroup.map_top_of_surjective f hf]
· exact Finset.card_image_le.trans_eq hS1
@[to_additive]
lemma rank_range_le [FG G] {f : G →* H} : rank f.range ≤ rank G :=
rank_le_of_surjective f.rangeRestrict f.rangeRestrict_surjective
@[to_additive]
lemma rank_congr [FG G] [FG H] (e : G ≃* H) : rank G = rank H :=
le_antisymm (rank_le_of_surjective e.symm e.symm.surjective)
(rank_le_of_surjective e e.surjective)
end Group
namespace Subgroup
@[to_additive]
lemma rank_congr {H K : Subgroup G} [Group.FG H] [Group.FG K] (h : H = K) : rank H = rank K := by
subst h; rfl
@[to_additive]
lemma rank_closure_finset_le_card (s : Finset G) : rank (closure (s : Set G)) ≤ s.card := by
classical
let t : Finset (closure (s : Set G)) := s.preimage Subtype.val Subtype.coe_injective.injOn
have ht : closure (t : Set (closure (s : Set G))) = ⊤ := by
rw [Finset.coe_preimage]
exact closure_preimage_eq_top (s : Set G)
apply (rank_le ht).trans
suffices H : Set.InjOn Subtype.val (t : Set (closure (s : Set G))) by
rw [← Finset.card_image_of_injOn H, Finset.image_preimage]
apply Finset.card_filter_le
apply Subtype.coe_injective.injOn
@[to_additive]
lemma rank_closure_finite_le_nat_card (s : Set G) [Finite s] : rank (closure s) ≤ Nat.card s := by
haveI := Fintype.ofFinite s
rw [Nat.card_eq_fintype_card, ← s.toFinset_card, ← rank_congr (congr_arg _ s.coe_toFinset)]
exact rank_closure_finset_le_card s.toFinset
lemma nat_card_centralizer_nat_card_stabilizer (g : G) :
Nat.card (centralizer {g}) = Nat.card (MulAction.stabilizer (ConjAct G) g) := by
rw [centralizer_eq_comap_stabilizer]; rfl
end Subgroup |
.lake/packages/mathlib/Mathlib/GroupTheory/FixedPointFree.lean | import Mathlib.GroupTheory.Perm.Cycle.Type
/-!
# Fixed-point-free automorphisms
This file defines fixed-point-free automorphisms and proves some basic properties.
An automorphism `φ` of a group `G` is fixed-point-free if `1 : G` is the only fixed point of `φ`.
-/
namespace MonoidHom
variable {F G : Type*}
section Definitions
variable (φ : G → G)
/-- A function `φ : G → G` is fixed-point-free if `1 : G` is the only fixed point of `φ`. -/
def FixedPointFree [One G] := ∀ g, φ g = g → g = 1
/-- The commutator map `g ↦ g / φ g`. If `φ g = h * g * h⁻¹`, then `g / φ g` is exactly the
commutator `[g, h] = g * h * g⁻¹ * h⁻¹`. -/
def commutatorMap [Div G] (g : G) := g / φ g
@[simp] theorem commutatorMap_apply [Div G] (g : G) : commutatorMap φ g = g / φ g := rfl
end Definitions
namespace FixedPointFree
variable [Group G] [FunLike F G G] [MonoidHomClass F G G] {φ : F}
theorem commutatorMap_injective (hφ : FixedPointFree φ) : Function.Injective (commutatorMap φ) := by
refine fun x y h ↦ inv_mul_eq_one.mp <| hφ _ ?_
rwa [map_mul, map_inv, eq_inv_mul_iff_mul_eq, ← mul_assoc, ← eq_div_iff_mul_eq', ← division_def]
variable [Finite G]
theorem commutatorMap_surjective (hφ : FixedPointFree φ) : Function.Surjective (commutatorMap φ) :=
Finite.surjective_of_injective hφ.commutatorMap_injective
theorem prod_pow_eq_one (hφ : FixedPointFree φ) {n : ℕ} (hn : φ^[n] = _root_.id) (g : G) :
((List.range n).map (fun k ↦ φ^[k] g)).prod = 1 := by
obtain ⟨g, rfl⟩ := commutatorMap_surjective hφ g
simp only [commutatorMap_apply, iterate_map_div, ← Function.iterate_succ_apply]
rw [List.prod_range_div', Function.iterate_zero_apply, hn, Function.id_def, div_self']
theorem coe_eq_inv_of_sq_eq_one (hφ : FixedPointFree φ) (h2 : φ^[2] = _root_.id) : ⇑φ = (·⁻¹) := by
ext g
have key : g * φ g = 1 := by simpa [List.range_succ] using hφ.prod_pow_eq_one h2 g
rwa [← inv_eq_iff_mul_eq_one, eq_comm] at key
section Involutive
theorem coe_eq_inv_of_involutive (hφ : FixedPointFree φ) (h2 : Function.Involutive φ) :
⇑φ = (·⁻¹) :=
coe_eq_inv_of_sq_eq_one hφ (funext h2)
theorem commute_all_of_involutive (hφ : FixedPointFree φ) (h2 : Function.Involutive φ) (g h : G) :
Commute g h := by
have key := map_mul φ g h
rwa [hφ.coe_eq_inv_of_involutive h2, inv_eq_iff_eq_inv, mul_inv_rev, inv_inv, inv_inv] at key
/-- If a finite group admits a fixed-point-free involution, then it is commutative. -/
def commGroupOfInvolutive (hφ : FixedPointFree φ) (h2 : Function.Involutive φ) :
CommGroup G := .mk (hφ.commute_all_of_involutive h2)
theorem orderOf_ne_two_of_involutive (hφ : FixedPointFree φ) (h2 : Function.Involutive φ) (g : G) :
orderOf g ≠ 2 := by
intro hg
have key : φ g = g := by
rw [hφ.coe_eq_inv_of_involutive h2, inv_eq_iff_mul_eq_one, ← sq, ← hg, pow_orderOf_eq_one]
rw [hφ g key, orderOf_one] at hg
contradiction
theorem odd_card_of_involutive (hφ : FixedPointFree φ) (h2 : Function.Involutive φ) :
Odd (Nat.card G) := by
have := Fintype.ofFinite G
by_contra h
rw [Nat.not_odd_iff_even, even_iff_two_dvd, Nat.card_eq_fintype_card] at h
obtain ⟨g, hg⟩ := exists_prime_orderOf_dvd_card 2 h
exact hφ.orderOf_ne_two_of_involutive h2 g hg
theorem odd_orderOf_of_involutive (hφ : FixedPointFree φ) (h2 : Function.Involutive φ) (g : G) :
Odd (orderOf g) :=
Odd.of_dvd_nat (hφ.odd_card_of_involutive h2) (orderOf_dvd_natCard g)
end Involutive
end FixedPointFree
end MonoidHom |
.lake/packages/mathlib/Mathlib/GroupTheory/ClassEquation.lean | import Mathlib.Algebra.BigOperators.Finprod
import Mathlib.Algebra.Group.ConjFinite
import Mathlib.Algebra.Group.Subgroup.Finite
import Mathlib.Data.Set.Card
import Mathlib.GroupTheory.Subgroup.Center
/-!
# Class Equation
This file establishes the class equation for finite groups.
## Main statements
* `Group.card_center_add_sum_card_noncenter_eq_card`: The **class equation** for finite groups.
The cardinality of a group is equal to the size of its center plus the sum of the size of all its
nontrivial conjugacy classes. Also `Group.nat_card_center_add_sum_card_noncenter_eq_card`.
-/
open MulAction ConjClasses
variable (G : Type*) [Group G]
/-- Conjugacy classes form a partition of G, stated in terms of cardinality. -/
theorem sum_conjClasses_card_eq_card [Fintype <| ConjClasses G] [Fintype G]
[∀ x : ConjClasses G, Fintype x.carrier] :
∑ x : ConjClasses G, x.carrier.toFinset.card = Fintype.card G := by
suffices (Σ x : ConjClasses G, x.carrier) ≃ G by simpa using (Fintype.card_congr this)
simpa [carrier_eq_preimage_mk] using Equiv.sigmaFiberEquiv ConjClasses.mk
/-- Conjugacy classes form a partition of G, stated in terms of cardinality. -/
theorem Group.sum_card_conj_classes_eq_card [Finite G] :
∑ᶠ x : ConjClasses G, x.carrier.ncard = Nat.card G := by
classical
cases nonempty_fintype G
rw [Nat.card_eq_fintype_card, ← sum_conjClasses_card_eq_card, finsum_eq_sum_of_fintype]
simp [Set.ncard_eq_toFinset_card']
/-- The **class equation** for finite groups. The cardinality of a group is equal to the size
of its center plus the sum of the size of all its nontrivial conjugacy classes. -/
theorem Group.nat_card_center_add_sum_card_noncenter_eq_card [Finite G] :
Nat.card (Subgroup.center G) + ∑ᶠ x ∈ noncenter G, Nat.card x.carrier = Nat.card G := by
classical
cases nonempty_fintype G
rw [@Nat.card_eq_fintype_card G, ← sum_conjClasses_card_eq_card, ←
Finset.sum_sdiff (ConjClasses.noncenter G).toFinset.subset_univ]
simp only [Nat.card_eq_fintype_card, Set.toFinset_card]
congr 1
swap
· convert finsum_cond_eq_sum_of_cond_iff _ _
simp [Set.mem_toFinset]
calc
Fintype.card (Subgroup.center G) = Fintype.card ((noncenter G)ᶜ : Set _) :=
Fintype.card_congr ((mk_bijOn G).equiv _)
_ = Finset.card (Finset.univ \ (noncenter G).toFinset) := by
rw [← Set.toFinset_card, Set.toFinset_compl, Finset.compl_eq_univ_sdiff]
_ = _ := ?_
rw [Finset.card_eq_sum_ones]
refine Finset.sum_congr rfl ?_
rintro ⟨g⟩ hg
simp only [noncenter, Set.toFinset_setOf, Finset.mem_univ, true_and,
Finset.mem_sdiff, Finset.mem_filter, Set.not_nontrivial_iff] at hg
rw [eq_comm, ← Set.toFinset_card, Finset.card_eq_one]
exact ⟨g, Finset.coe_injective <| by simpa using hg.eq_singleton_of_mem mem_carrier_mk⟩
theorem Group.card_center_add_sum_card_noncenter_eq_card (G) [Group G]
[∀ x : ConjClasses G, Fintype x.carrier] [Fintype G] [Fintype <| Subgroup.center G]
[Fintype <| noncenter G] : Fintype.card (Subgroup.center G) +
∑ x ∈ (noncenter G).toFinset, x.carrier.toFinset.card = Fintype.card G := by
convert Group.nat_card_center_add_sum_card_noncenter_eq_card G using 2
· simp
· rw [← finsum_set_coe_eq_finsum_mem (noncenter G), finsum_eq_sum_of_fintype,
← Finset.sum_set_coe]
simp
· simp |
.lake/packages/mathlib/Mathlib/GroupTheory/CosetCover.lean | import Mathlib.Algebra.Order.Ring.Rat
import Mathlib.GroupTheory.Complement
import Mathlib.LinearAlgebra.Basis.VectorSpace
/-! # Lemma of B. H. Neumann on coverings of a group by cosets.
Let the group $G$ be the union of finitely many, let us say $n$, left cosets
of subgroups $C₁$, $C₂$, ..., $Cₙ$: $$ G = ⋃_{i = 1}^n C_i g_i. $$
* `Subgroup.exists_finiteIndex_of_leftCoset_cover`
at least one subgroup $C_i$ has finite index in $G$.
* `Subgroup.leftCoset_cover_filter_FiniteIndex`
the cosets of subgroups of infinite index may be omitted from the covering.
* `Subgroup.exists_index_le_card_of_leftCoset_cover` :
the index of (at least) one of these subgroups does not exceed $n$.
* `Subgroup.one_le_sum_inv_index_of_leftCoset_cover` :
the sum of the inverses of the indexes of the $C_i$ is greater than or equal to 1.
* `Subgroup.pairwiseDisjoint_leftCoset_cover_of_sum_inv_index_eq_one`
If the sum of the inverses of the indexes of the subgroups $C_i$ is equal to 1,
then the cosets of the subgroups of finite index are pairwise disjoint.
A corollary of `Subgroup.exists_finiteIndex_of_leftCoset_cover` is:
* `Subspace.biUnion_ne_univ_of_ne_top` :
a vector space over an infinite field cannot be a finite union of proper subspaces.
This can be used to show that an algebraic extension of fields is determined by the
set of all minimal polynomials (not proved here).
[1] [Neumann-1954], *Groups Covered By Permutable Subsets*, Lemma 4.1
[2] <https://mathoverflow.net/a/17398/3332>
[3] <http://alpha.math.uga.edu/~pete/Neumann54.pdf>
-/
open scoped Pointwise
namespace Subgroup
variable {G : Type*} [Group G]
section leftCoset_cover_const
@[to_additive]
theorem exists_leftTransversal_of_FiniteIndex
{D H : Subgroup G} [D.FiniteIndex] (hD_le_H : D ≤ H) :
∃ t : Finset H,
IsComplement (t : Set H) (D.subgroupOf H) ∧
⋃ g ∈ t, (g : G) • (D : Set G) = H := by
have ⟨t, ht⟩ := (D.subgroupOf H).exists_isComplement_left 1
have hf : t.Finite := ht.1.finite_left_iff.mpr inferInstance
refine ⟨hf.toFinset, hf.coe_toFinset.symm ▸ ht.1, ?_⟩
ext x
suffices (∃ y ∈ t, ∃ d ∈ D, y * d = x) ↔ x ∈ H by simpa using this
constructor
· rintro ⟨⟨y, hy⟩, -, d, h, rfl⟩
exact H.mul_mem hy (hD_le_H h)
· intro hx
exact ⟨_, (ht.1.toLeftFun ⟨x, hx⟩).2, _,
ht.1.inv_toLeftFun_mul_mem ⟨x, hx⟩, mul_inv_cancel_left _ _⟩
variable {ι : Type*} {s : Finset ι} {H : Subgroup G} {g : ι → G}
@[to_additive]
theorem leftCoset_cover_const_iff_surjOn :
⋃ i ∈ s, g i • (H : Set G) = Set.univ ↔ Set.SurjOn (g · : ι → G ⧸ H) s Set.univ := by
simp [Set.eq_univ_iff_forall, mem_leftCoset_iff, Set.SurjOn,
QuotientGroup.forall_mk, QuotientGroup.eq]
variable (hcovers : ⋃ i ∈ s, g i • (H : Set G) = Set.univ)
include hcovers
/-- If `H` is a subgroup of `G` and `G` is the union of a finite family of left cosets of `H`
then `H` has finite index. -/
@[to_additive]
theorem finiteIndex_of_leftCoset_cover_const : H.FiniteIndex := by
simp_rw [leftCoset_cover_const_iff_surjOn] at hcovers
have := Set.finite_univ_iff.mp <| Set.Finite.of_surjOn _ hcovers s.finite_toSet
exact H.finiteIndex_of_finite_quotient
@[to_additive]
theorem index_le_of_leftCoset_cover_const : H.index ≤ s.card := by
cases H.index.eq_zero_or_pos with
| inl h => exact h ▸ s.card.zero_le
| inr h =>
rw [leftCoset_cover_const_iff_surjOn, Set.surjOn_iff_surjective] at hcovers
exact (Nat.card_le_card_of_surjective _ hcovers).trans_eq (Nat.card_eq_finsetCard _)
@[to_additive]
theorem pairwiseDisjoint_leftCoset_cover_const_of_index_eq (hind : H.index = s.card) :
Set.PairwiseDisjoint s (g · • (H : Set G)) := by
have : Fintype (G ⧸ H) := fintypeOfIndexNeZero fun h => by
rw [hind, Finset.card_eq_zero] at h
rw [h, ← Finset.set_biUnion_coe, Finset.coe_empty, Set.biUnion_empty] at hcovers
exact Set.empty_ne_univ hcovers
suffices Function.Bijective (g · : s → G ⧸ H) by
intro i hi j hj h' c hi' hj' x hx
specialize hi' hx
specialize hj' hx
rw [mem_leftCoset_iff, SetLike.mem_coe, ← QuotientGroup.eq] at hi' hj'
rw [ne_eq, ← Subtype.mk.injEq (p := (· ∈ (s : Set ι))) i hi j hj] at h'
exact h' <| this.injective <| by simp only [hi', hj']
rw [Fintype.bijective_iff_surjective_and_card]
constructor
· rwa [leftCoset_cover_const_iff_surjOn, Set.surjOn_iff_surjective] at hcovers
· simp only [Fintype.card_coe, ← hind, index_eq_card, Nat.card_eq_fintype_card]
end leftCoset_cover_const
section
variable {ι : Type*} {H : ι → Subgroup G} {g : ι → G} {s : Finset ι}
(hcovers : ⋃ i ∈ s, (g i) • (H i : Set G) = Set.univ)
include hcovers
-- Inductive inner part of `Subgroup.exists_finiteIndex_of_leftCoset_cover`
@[to_additive]
theorem exists_finiteIndex_of_leftCoset_cover_aux [DecidableEq (Subgroup G)]
(j : ι) (hj : j ∈ s) (hcovers' : ⋃ i ∈ s.filter (H · = H j), g i • (H i : Set G) ≠ Set.univ) :
∃ i ∈ s, H i ≠ H j ∧ (H i).FiniteIndex := by
classical
have ⟨n, hn⟩ : ∃ n, n = (s.image H).card := exists_eq
induction n using Nat.strongRec generalizing ι with
| ind n ih =>
-- Every left coset of `H j` is contained in a finite union of
-- left cosets of the other subgroups `H k ≠ H j` of the covering.
have ⟨x, hx⟩ : ∃ (x : G), ∀ i ∈ s, H i = H j → (g i : G ⧸ H i) ≠ ↑x := by
simpa [Set.eq_univ_iff_forall, mem_leftCoset_iff, ← QuotientGroup.eq] using hcovers'
replace hx : ∀ (y : G), y • (H j : Set G) ⊆
⋃ i ∈ s.filter (H · ≠ H j), (y * x⁻¹ * g i) • (H i : Set G) := by
intro y z hz
simp_rw [Finset.mem_filter, Set.mem_iUnion]
have ⟨i, hi, hmem⟩ : ∃ i ∈ s, x * (y⁻¹ * z) ∈ g i • (H i : Set G) := by
simpa using Set.eq_univ_iff_forall.mp hcovers (x * (y⁻¹ * z))
rw [mem_leftCoset_iff, SetLike.mem_coe, ← QuotientGroup.eq] at hmem
refine ⟨i, ⟨hi, fun hij => hx i hi hij ?_⟩, ?_⟩
· rwa [hmem, eq_comm, QuotientGroup.eq, hij, inv_mul_cancel_left,
← SetLike.mem_coe, ← mem_leftCoset_iff]
· simpa [mem_leftCoset_iff, SetLike.mem_coe, QuotientGroup.eq, mul_assoc] using hmem
-- Thus `G` can also be covered by a finite union `U k, f k • K k` of left cosets
-- of the subgroups `H k ≠ H j`.
let κ := ↥(s.filter (H · ≠ H j)) × Option ↥(s.filter (H · = H j))
let f : κ → G
| ⟨k₁, some k₂⟩ => g k₂ * x⁻¹ * g k₁
| ⟨k₁, none⟩ => g k₁
let K (k : κ) : Subgroup G := H k.1.val
have hK' (k : κ) : K k ∈ (s.image H).erase (H j) := by
have := Finset.mem_filter.mp k.1.property
exact Finset.mem_erase.mpr ⟨this.2, Finset.mem_image_of_mem H this.1⟩
have hK (k : κ) : K k ≠ H j := ((Finset.mem_erase.mp (hK' k)).left ·)
replace hcovers : ⋃ k ∈ Finset.univ, f k • (K k : Set G) = Set.univ :=
Set.iUnion₂_eq_univ_iff.mpr fun y => by
rw [← s.filter_union_filter_neg_eq (H · = H j), Finset.set_biUnion_union] at hcovers
cases (Set.mem_union _ _ _).mp (hcovers.superset (Set.mem_univ y)) with
| inl hy =>
have ⟨k, hk, hy⟩ := Set.mem_iUnion₂.mp hy
have hk' : H k = H j := And.right <| by simpa using hk
have ⟨i, hi, hy⟩ := Set.mem_iUnion₂.mp (hx (g k) (hk' ▸ hy))
exact ⟨⟨⟨i, hi⟩, some ⟨k, hk⟩⟩, Finset.mem_univ _, hy⟩
| inr hy =>
have ⟨i, hi, hy⟩ := Set.mem_iUnion₂.mp hy
exact ⟨⟨⟨i, hi⟩, none⟩, Finset.mem_univ _, hy⟩
-- Let `H k` be one of the subgroups in this covering.
have ⟨k⟩ : Nonempty κ := not_isEmpty_iff.mp fun hempty => by
rw [Set.iUnion_of_empty] at hcovers
exact Set.empty_ne_univ hcovers
-- If `G` is the union of the cosets of `H k` in the new covering, we are done.
by_cases hcovers' : ⋃ i ∈ Finset.filter (K · = K k) Finset.univ, f i • (K i : Set G) = Set.univ
· rw [Set.iUnion₂_congr fun i hi => by rw [(Finset.mem_filter.mp hi).right]] at hcovers'
exact ⟨k.1, Finset.mem_of_mem_filter k.1.1 k.1.2, hK k,
finiteIndex_of_leftCoset_cover_const hcovers'⟩
-- Otherwise, by the induction hypothesis, one of the subgroups `H k ≠ H j` has finite index.
have hn' : (Finset.univ.image K).card < n := hn ▸ by
refine ((Finset.card_le_card fun x => ?_).trans_lt <|
Finset.card_erase_lt_of_mem (Finset.mem_image_of_mem H hj))
rw [mem_image_univ_iff_mem_range, Set.mem_range]
exact fun ⟨k, hk⟩ => hk ▸ hK' k
have ⟨k', hk'⟩ := ih _ hn' hcovers k (Finset.mem_univ k) hcovers' rfl
exact ⟨k'.1.1, Finset.mem_of_mem_filter k'.1.1 k'.1.2, hK k', hk'.2.2⟩
/-- Let the group `G` be the union of finitely many left cosets `g i • H i`.
Then at least one subgroup `H i` has finite index in `G`. -/
@[to_additive]
theorem exists_finiteIndex_of_leftCoset_cover : ∃ k ∈ s, (H k).FiniteIndex := by
classical
have ⟨j, hj⟩ : s.Nonempty := Finset.nonempty_iff_ne_empty.mpr fun hempty => by
rw [hempty, ← Finset.set_biUnion_coe, Finset.coe_empty, Set.biUnion_empty] at hcovers
exact Set.empty_ne_univ hcovers
by_cases hcovers' : ⋃ i ∈ s.filter (H · = H j), g i • (H i : Set G) = Set.univ
· rw [Set.iUnion₂_congr fun i hi => by rw [(Finset.mem_filter.mp hi).right]] at hcovers'
exact ⟨j, hj, finiteIndex_of_leftCoset_cover_const hcovers'⟩
· have ⟨i, hi, _, hfi⟩ :=
exists_finiteIndex_of_leftCoset_cover_aux hcovers j hj hcovers'
exact ⟨i, hi, hfi⟩
-- Auxiliary to `leftCoset_cover_filter_FiniteIndex` and `one_le_sum_inv_index_of_leftCoset_cover`.
@[to_additive]
theorem leftCoset_cover_filter_FiniteIndex_aux
[DecidablePred (FiniteIndex : Subgroup G → Prop)] :
(⋃ k ∈ s.filter (fun i => (H i).FiniteIndex), g k • (H k : Set G) = Set.univ) ∧
(1 ≤ ∑ i ∈ s, ((H i).index : ℚ)⁻¹) ∧
(∑ i ∈ s, ((H i).index : ℚ)⁻¹ = 1 → Set.PairwiseDisjoint
(s.filter (fun i => (H i).FiniteIndex)) (fun i ↦ g i • (H i : Set G))) := by
classical
let D := ⨅ k ∈ s.filter (fun i => (H i).FiniteIndex), H k
-- `D`, as the finite intersection of subgroups of finite index, also has finite index.
have hD : D.FiniteIndex := finiteIndex_iInf' _ <| by simp
have hD_le {i} (hi : i ∈ s) (hfi : (H i).FiniteIndex) : D ≤ H i :=
iInf₂_le i (Finset.mem_filter.mpr ⟨hi, hfi⟩)
-- Each subgroup of finite index in the covering is the union of finitely many cosets of `D`.
choose t ht using fun i hi hfi =>
exists_leftTransversal_of_FiniteIndex (H := H i) (hD_le hi hfi)
-- We construct a cover of `G` by the cosets of subgroups of infinite index and of `D`.
let κ := (i : s) × { x // x ∈ if h : (H i.1).FiniteIndex then t i.1 i.2 h else {1} }
let f (k : κ) : G := g k.1 * k.2.val
let K (k : κ) : Subgroup G := if (H k.1).FiniteIndex then D else H k.1
have hcovers' : ⋃ k ∈ Finset.univ, f k • (K k : Set G) = Set.univ := by
rw [← s.filter_union_filter_neg_eq (fun i => (H i).FiniteIndex)] at hcovers
rw [← hcovers, ← Finset.univ.filter_union_filter_neg_eq (fun k => (H k.1).FiniteIndex),
Finset.set_biUnion_union, Finset.set_biUnion_union]
apply congrArg₂ (· ∪ ·) <;> rw [Set.iUnion_sigma, Set.iUnion_subtype] <;>
refine Set.iUnion_congr fun i => ?_
· by_cases hfi : (H i).FiniteIndex <;>
simp [← Set.smul_set_iUnion₂, Set.iUnion_subtype, ← leftCoset_assoc, f, K, ht, hfi]
· by_cases hfi : (H i).FiniteIndex <;>
simp [Set.iUnion_subtype, f, K, hfi]
-- There is at least one coset of a subgroup of finite index in the original covering.
-- Therefore a coset of `D` occurs in the new covering.
have ⟨k, hkfi, hk⟩ : ∃ k, (H k.1.1).FiniteIndex ∧ K k = D :=
have ⟨j, hj, hjfi⟩ := exists_finiteIndex_of_leftCoset_cover hcovers
have ⟨x, hx⟩ : (t j hj hjfi).Nonempty := Finset.nonempty_coe_sort.mp
(ht j hj hjfi).1.leftQuotientEquiv.symm.nonempty
⟨⟨⟨j, hj⟩, ⟨x, dif_pos hjfi ▸ hx⟩⟩, hjfi, if_pos hjfi⟩
-- Since `D` is the unique subgroup of finite index whose cosets occur in the new covering,
-- the cosets of the other subgroups can be omitted.
replace hcovers' : ⋃ i ∈ Finset.univ.filter (K · = D), f i • (D : Set G) = Set.univ := by
rw [← hk, Set.iUnion₂_congr fun i hi => by rw [← (Finset.mem_filter.mp hi).2]]
by_contra! h
obtain ⟨i, -, hi⟩ :=
exists_finiteIndex_of_leftCoset_cover_aux hcovers' k (Finset.mem_univ k) h
by_cases hfi : (H i.1.1).FiniteIndex <;> simp [K, hfi, hkfi] at hi
-- The result follows by restoring the original cosets of subgroups of finite index
-- from the cosets of `D` into which they have been decomposed.
have hHD (i) : ¬(H i).FiniteIndex → H i ≠ D := fun hfi hD' => (hD' ▸ hfi) hD
have hdensity : ∑ i ∈ s, ((H i).index : ℚ)⁻¹ =
(Finset.univ.filter (K · = D)).card * (D.index : ℚ)⁻¹ := by
rw [eq_mul_inv_iff_mul_eq₀ (Nat.cast_ne_zero.mpr hD.index_ne_zero), Finset.sum_mul,
← Finset.sum_attach, eq_comm, Finset.card_filter, Nat.cast_sum, ← Finset.univ_sigma_univ,
Finset.sum_sigma, Finset.sum_coe_sort_eq_attach]
refine Finset.sum_congr rfl fun i _ => ?_
by_cases hfi : (H i).FiniteIndex
· rw [← relIndex_mul_index (hD_le i.2 hfi), Nat.cast_mul, mul_comm,
mul_inv_cancel_right₀ (Nat.cast_ne_zero.mpr hfi.index_ne_zero)]
simpa [K, hfi] using (ht i.1 i.2 hfi).1.card_left
· rw [of_not_not (FiniteIndex.mk.mt hfi), Nat.cast_zero, inv_zero, zero_mul]
simpa [K, hfi] using hHD i hfi
refine ⟨?_, ?_, ?_⟩
· rw [← hcovers', Set.iUnion_sigma, Set.iUnion_subtype]
refine Set.iUnion_congr fun i => ?_
rw [Finset.mem_filter, Set.iUnion_and]
refine Set.iUnion_congr fun hi => ?_
by_cases hfi : (H i).FiniteIndex <;>
simp [Set.smul_set_iUnion, Set.iUnion_subtype, ← leftCoset_assoc,
f, K, hHD, ← (ht i hi _).2, hfi]
· rw [hdensity]
refine le_of_mul_le_mul_right ?_ (Nat.cast_pos.mpr (Nat.pos_of_ne_zero hD.index_ne_zero))
rw [one_mul, mul_assoc, inv_mul_cancel₀ (Nat.cast_ne_zero.mpr hD.index_ne_zero), mul_one,
Nat.cast_le]
exact index_le_of_leftCoset_cover_const hcovers'
· rw [hdensity, mul_inv_eq_one₀ (Nat.cast_ne_zero.mpr hD.index_ne_zero),
Nat.cast_inj, Finset.coe_filter]
intro h i hi j hj hij c hi' hj' x hx
have hdisjoint := pairwiseDisjoint_leftCoset_cover_const_of_index_eq hcovers' h.symm
-- We know the `f k • K k` are pairwise disjoint and need to prove that the `g i • H i` are.
rw [Set.mem_setOf_eq] at hi hj
have hk' (i) (hi : i ∈ s ∧ (H i).FiniteIndex) (hi' : c ≤ g i • (H i : Set G)) :
∃ (k : κ), k.1.1 = i ∧ K k = D ∧ x ∈ f k • (D : Set G) := by
rw [← (ht i hi.1 hi.2).2] at hi'
suffices ∃ r : H i, r ∈ t i hi.1 hi.2 ∧ x ∈ (g i * r) • (D : Set G) by
have ⟨r, hr, hxr⟩ := this
refine ⟨⟨⟨i, hi.1⟩, ⟨r, dif_pos hi.2 ▸ hr⟩⟩, rfl, ?_⟩
simpa [K, f, if_pos hi.2] using hxr
simpa [Set.mem_smul_set_iff_inv_smul_mem, smul_eq_mul, mul_assoc] using hi' hx
have ⟨k₁, hik₁, hk₁, hxk₁⟩ := hk' i hi hi'
have ⟨k₂, hjk₂, hk₂, hxk₂⟩ := hk' j hj hj'
rw [← Set.singleton_subset_iff, ← Set.le_iff_subset] at hxk₁ hxk₂ ⊢
exact hdisjoint
(Finset.mem_filter.mpr ⟨Finset.mem_univ k₁, hk₁⟩)
(Finset.mem_filter.mpr ⟨Finset.mem_univ k₂, hk₂⟩)
(ne_of_apply_ne Sigma.fst (ne_of_apply_ne Subtype.val (hik₁ ▸ hjk₂ ▸ hij)))
hxk₁ hxk₂
/-- Let the group `G` be the union of finitely many left cosets `g i • H i`.
Then the cosets of subgroups of infinite index may be omitted from the covering. -/
@[to_additive]
theorem leftCoset_cover_filter_FiniteIndex
[DecidablePred (FiniteIndex : Subgroup G → Prop)] :
⋃ k ∈ s.filter (fun i => (H i).FiniteIndex), g k • (H k : Set G) = Set.univ :=
(leftCoset_cover_filter_FiniteIndex_aux hcovers).1
/-- Let the group `G` be the union of finitely many left cosets `g i • H i`. Then the
sum of the inverses of the indexes of the subgroups `H i` is greater than or equal to 1. -/
@[to_additive one_le_sum_inv_index_of_leftCoset_cover]
theorem one_le_sum_inv_index_of_leftCoset_cover :
1 ≤ ∑ i ∈ s, ((H i).index : ℚ)⁻¹ :=
have := Classical.decPred (FiniteIndex : Subgroup G → Prop)
(leftCoset_cover_filter_FiniteIndex_aux hcovers).2.1
/-- Let the group `G` be the union of finitely many left cosets `g i • H i`.
If the sum of the inverses of the indexes of the subgroups `H i` is equal to 1,
then the cosets of the subgroups of finite index are pairwise disjoint. -/
@[to_additive]
theorem pairwiseDisjoint_leftCoset_cover_of_sum_inv_index_eq_one
[DecidablePred (FiniteIndex : Subgroup G → Prop)] :
∑ i ∈ s, ((H i).index : ℚ)⁻¹ = 1 →
Set.PairwiseDisjoint (s.filter (fun i => (H i).FiniteIndex))
(fun i ↦ g i • (H i : Set G)) :=
(leftCoset_cover_filter_FiniteIndex_aux hcovers).2.2
/-- B. H. Neumann Lemma :
If a finite family of cosets of subgroups covers the group, then at least one
of these subgroups has index not exceeding the number of cosets. -/
@[to_additive]
theorem exists_index_le_card_of_leftCoset_cover :
∃ i ∈ s, (H i).FiniteIndex ∧ (H i).index ≤ s.card := by
by_contra! h
apply (one_le_sum_inv_index_of_leftCoset_cover hcovers).not_gt
cases s.eq_empty_or_nonempty with
| inl hs => simp only [hs, Finset.sum_empty, zero_lt_one]
| inr hs =>
have hs' : 0 < s.card := hs.card_pos
have hlt : ∀ i ∈ s, ((H i).index : ℚ)⁻¹ < (s.card : ℚ)⁻¹ := fun i hi ↦ by
cases eq_or_ne (H i).index 0 with
| inl hindex =>
rwa [hindex, Nat.cast_zero, inv_zero, inv_pos, Nat.cast_pos]
| inr hindex =>
exact inv_strictAnti₀ (by exact_mod_cast hs') (by exact_mod_cast h i hi ⟨hindex⟩)
apply (Finset.sum_lt_sum_of_nonempty hs hlt).trans_eq
rw [Finset.sum_const, nsmul_eq_mul, mul_inv_cancel₀ (Nat.cast_ne_zero.mpr hs'.ne')]
end
end Subgroup
section Submodule
variable {R M ι : Type*} [Ring R] [AddCommGroup M] [Module R M]
{p : ι → Submodule R M} {s : Finset ι}
theorem Submodule.exists_finiteIndex_of_cover (hcovers : ⋃ i ∈ s, (p i : Set M) = Set.univ) :
∃ k ∈ s, (p k).toAddSubgroup.FiniteIndex :=
have hcovers' : ⋃ i ∈ s, (0 : M) +ᵥ ((p i).toAddSubgroup : Set M) = Set.univ := by
simpa only [zero_vadd] using hcovers
AddSubgroup.exists_finiteIndex_of_leftCoset_cover hcovers'
end Submodule
section Subspace
variable {k E : Type*} [DivisionRing k] [Infinite k] [AddCommGroup E] [Module k E]
{s : Finset (Subspace k E)}
/- A vector space over an infinite field cannot be a finite union of proper subspaces. -/
theorem Subspace.biUnion_ne_univ_of_top_notMem (hs : ⊤ ∉ s) :
⋃ p ∈ s, (p : Set E) ≠ Set.univ := by
intro hcovers
have ⟨p, hp, hfi⟩ := Submodule.exists_finiteIndex_of_cover hcovers
have : Finite (E ⧸ p) := AddSubgroup.finite_quotient_of_finiteIndex
have : Nontrivial (E ⧸ p) :=
Submodule.Quotient.nontrivial_of_lt_top p (ne_of_mem_of_not_mem hp hs).lt_top
have : Infinite (E ⧸ p) := Module.Free.infinite k (E ⧸ p)
exact not_finite (E ⧸ p)
@[deprecated (since := "2025-05-24")]
alias Subspace.biUnion_ne_univ_of_top_nmem := Subspace.biUnion_ne_univ_of_top_notMem
/- A vector space over an infinite field cannot be a finite union of proper subspaces. -/
theorem Subspace.top_mem_of_biUnion_eq_univ (hcovers : ⋃ p ∈ s, (p : Set E) = Set.univ) :
⊤ ∈ s := by
contrapose! hcovers
exact Subspace.biUnion_ne_univ_of_top_notMem hcovers
theorem Subspace.exists_eq_top_of_iUnion_eq_univ {ι} [Finite ι] {p : ι → Subspace k E}
(hcovers : ⋃ i, (p i : Set E) = Set.univ) : ∃ i, p i = ⊤ := by
have := Fintype.ofFinite (Set.range p)
simp_rw [← Set.biUnion_range (f := p), ← Set.mem_toFinset] at hcovers
apply Set.mem_toFinset.mp (Subspace.top_mem_of_biUnion_eq_univ hcovers)
end Subspace |
.lake/packages/mathlib/Mathlib/GroupTheory/Index.lean | import Mathlib.Algebra.BigOperators.GroupWithZero.Finset
import Mathlib.Algebra.GroupWithZero.Subgroup
import Mathlib.Data.Finite.Card
import Mathlib.Data.Finite.Prod
import Mathlib.Data.Set.Card
import Mathlib.GroupTheory.Coset.Card
import Mathlib.GroupTheory.GroupAction.Quotient
import Mathlib.GroupTheory.QuotientGroup.Basic
/-!
# Index of a Subgroup
In this file we define the index of a subgroup, and prove several divisibility properties.
Several theorems proved in this file are known as Lagrange's theorem.
## Main definitions
- `H.index` : the index of `H : Subgroup G` as a natural number,
and returns 0 if the index is infinite.
- `H.relIndex K` : the relative index of `H : Subgroup G` in `K : Subgroup G` as a natural number,
and returns 0 if the relative index is infinite.
## Main results
- `card_mul_index` : `Nat.card H * H.index = Nat.card G`
- `index_mul_card` : `H.index * Nat.card H = Nat.card G`
- `index_dvd_card` : `H.index ∣ Nat.card G`
- `relIndex_mul_index` : If `H ≤ K`, then `H.relindex K * K.index = H.index`
- `index_dvd_of_le` : If `H ≤ K`, then `K.index ∣ H.index`
- `relIndex_mul_relIndex` : `relIndex` is multiplicative in towers
- `MulAction.index_stabilizer`: the index of the stabilizer is the cardinality of the orbit
-/
assert_not_exists Field
open scoped Pointwise
namespace Subgroup
open Cardinal Function
variable {G G' : Type*} [Group G] [Group G'] (H K L : Subgroup G)
/-- The index of a subgroup as a natural number. Returns `0` if the index is infinite. -/
@[to_additive /-- The index of an additive subgroup as a natural number.
Returns 0 if the index is infinite. -/]
noncomputable def index : ℕ :=
Nat.card (G ⧸ H)
/-- If `H` and `K` are subgroups of a group `G`, then `relIndex H K : ℕ` is the index
of `H ∩ K` in `K`. The function returns `0` if the index is infinite. -/
@[to_additive /-- If `H` and `K` are subgroups of an additive group `G`, then `relIndex H K : ℕ`
is the index of `H ∩ K` in `K`. The function returns `0` if the index is infinite. -/]
noncomputable def relIndex : ℕ :=
(H.subgroupOf K).index
@[deprecated (since := "2025-08-12")] alias relindex := relIndex
@[to_additive]
theorem index_comap_of_surjective {f : G' →* G} (hf : Function.Surjective f) :
(H.comap f).index = H.index := by
have key : ∀ x y : G',
QuotientGroup.leftRel (H.comap f) x y ↔ QuotientGroup.leftRel H (f x) (f y) := by
simp only [QuotientGroup.leftRel_apply]
exact fun x y => iff_of_eq (congr_arg (· ∈ H) (by rw [f.map_mul, f.map_inv]))
refine Cardinal.toNat_congr (Equiv.ofBijective (Quotient.map' f fun x y => (key x y).mp) ⟨?_, ?_⟩)
· simp_rw [← Quotient.eq''] at key
refine Quotient.ind' fun x => ?_
refine Quotient.ind' fun y => ?_
exact (key x y).mpr
· refine Quotient.ind' fun x => ?_
obtain ⟨y, hy⟩ := hf x
exact ⟨y, (Quotient.map'_mk'' f _ y).trans (congr_arg Quotient.mk'' hy)⟩
@[to_additive]
theorem index_comap (f : G' →* G) :
(H.comap f).index = H.relIndex f.range :=
Eq.trans (congr_arg index (by rfl))
((H.subgroupOf f.range).index_comap_of_surjective f.rangeRestrict_surjective)
@[to_additive]
theorem relIndex_comap (f : G' →* G) (K : Subgroup G') :
relIndex (comap f H) K = relIndex H (map f K) := by
rw [relIndex, subgroupOf, comap_comap, index_comap, ← f.map_range, K.range_subtype]
@[deprecated (since := "2025-08-12")] alias relindex_comap := relIndex_comap
@[to_additive]
theorem relIndex_map_map_of_injective {f : G →* G'} (H K : Subgroup G) (hf : Function.Injective f) :
relIndex (map f H) (map f K) = relIndex H K := by
rw [← Subgroup.relIndex_comap, Subgroup.comap_map_eq_self_of_injective hf]
@[deprecated (since := "2025-08-12")]
alias relindex_map_map_of_injective := relIndex_map_map_of_injective
@[to_additive]
theorem relIndex_map_map (f : G →* G') (H K : Subgroup G) :
(map f H).relIndex (map f K) = (H ⊔ f.ker).relIndex (K ⊔ f.ker) := by
rw [← comap_map_eq, ← comap_map_eq, relIndex_comap, (gc_map_comap f).l_u_l_eq_l]
variable {H K L}
@[to_additive relIndex_mul_index]
theorem relIndex_mul_index (h : H ≤ K) : H.relIndex K * K.index = H.index :=
((mul_comm _ _).trans (Cardinal.toNat_mul _ _).symm).trans
(congr_arg Cardinal.toNat (Equiv.cardinal_eq (quotientEquivProdOfLE h))).symm
@[deprecated (since := "2025-08-12")] alias relindex_mul_index := relIndex_mul_index
@[to_additive]
theorem index_dvd_of_le (h : H ≤ K) : K.index ∣ H.index :=
dvd_of_mul_left_eq (H.relIndex K) (relIndex_mul_index h)
@[to_additive]
theorem relIndex_dvd_index_of_le (h : H ≤ K) : H.relIndex K ∣ H.index :=
dvd_of_mul_right_eq K.index (relIndex_mul_index h)
@[deprecated (since := "2025-08-12")] alias relindex_dvd_index_of_le := relIndex_dvd_index_of_le
@[to_additive]
theorem relIndex_subgroupOf (hKL : K ≤ L) :
(H.subgroupOf L).relIndex (K.subgroupOf L) = H.relIndex K :=
((index_comap (H.subgroupOf L) (inclusion hKL)).trans (congr_arg _ (inclusion_range hKL))).symm
@[deprecated (since := "2025-08-12")] alias relindex_subgroupOf := relIndex_subgroupOf
variable (H K L)
@[to_additive relIndex_mul_relIndex]
theorem relIndex_mul_relIndex (hHK : H ≤ K) (hKL : K ≤ L) :
H.relIndex K * K.relIndex L = H.relIndex L := by
rw [← relIndex_subgroupOf hKL]
exact relIndex_mul_index fun x hx => hHK hx
@[deprecated (since := "2025-08-12")] alias relindex_mul_relindex := relIndex_mul_relIndex
@[to_additive]
theorem inf_relIndex_right : (H ⊓ K).relIndex K = H.relIndex K := by
rw [relIndex, relIndex, inf_subgroupOf_right]
@[deprecated (since := "2025-08-12")] alias inf_relindex_right := inf_relIndex_right
@[to_additive]
theorem inf_relIndex_left : (H ⊓ K).relIndex H = K.relIndex H := by
rw [inf_comm, inf_relIndex_right]
@[deprecated (since := "2025-08-12")] alias inf_relindex_left := inf_relIndex_left
@[to_additive relIndex_inf_mul_relIndex]
theorem relIndex_inf_mul_relIndex : H.relIndex (K ⊓ L) * K.relIndex L = (H ⊓ K).relIndex L := by
rw [← inf_relIndex_right H (K ⊓ L), ← inf_relIndex_right K L, ← inf_relIndex_right (H ⊓ K) L,
inf_assoc, relIndex_mul_relIndex (H ⊓ (K ⊓ L)) (K ⊓ L) L inf_le_right inf_le_right]
@[deprecated (since := "2025-08-12")] alias relindex_inf_mul_relindex := relIndex_inf_mul_relIndex
@[to_additive (attr := simp)]
theorem relIndex_sup_right [K.Normal] : K.relIndex (H ⊔ K) = K.relIndex H :=
Nat.card_congr (QuotientGroup.quotientInfEquivProdNormalQuotient H K).toEquiv.symm
@[deprecated (since := "2025-08-12")] alias relindex_sup_right := relIndex_sup_right
@[to_additive (attr := simp)]
theorem relIndex_sup_left [K.Normal] : K.relIndex (K ⊔ H) = K.relIndex H := by
rw [sup_comm, relIndex_sup_right]
@[deprecated (since := "2025-08-12")] alias relindex_sup_left := relIndex_sup_left
@[to_additive]
theorem relIndex_dvd_index_of_normal [H.Normal] : H.relIndex K ∣ H.index :=
relIndex_sup_right K H ▸ relIndex_dvd_index_of_le le_sup_right
@[deprecated (since := "2025-08-12")]
alias relindex_dvd_index_of_normal := relIndex_dvd_index_of_normal
variable {H K}
@[to_additive]
theorem relIndex_dvd_of_le_left (hHK : H ≤ K) : K.relIndex L ∣ H.relIndex L :=
inf_of_le_left hHK ▸ dvd_of_mul_left_eq _ (relIndex_inf_mul_relIndex _ _ _)
@[deprecated (since := "2025-08-12")] alias relindex_dvd_of_le_left := relIndex_dvd_of_le_left
/-- A subgroup has index two if and only if there exists `a` such that for all `b`, exactly one
of `b * a` and `b` belong to `H`. -/
@[to_additive /-- An additive subgroup has index two if and only if there exists `a` such that
for all `b`, exactly one of `b + a` and `b` belong to `H`. -/]
theorem index_eq_two_iff : H.index = 2 ↔ ∃ a, ∀ b, Xor' (b * a ∈ H) (b ∈ H) := by
simp only [index, Nat.card_eq_two_iff' ((1 : G) : G ⧸ H), ExistsUnique, inv_mem_iff,
QuotientGroup.exists_mk, QuotientGroup.forall_mk, Ne, QuotientGroup.eq, mul_one,
xor_iff_iff_not]
refine exists_congr fun a =>
⟨fun ha b => ⟨fun hba hb => ?_, fun hb => ?_⟩, fun ha => ⟨?_, fun b hb => ?_⟩⟩
· exact ha.1 ((mul_mem_cancel_left hb).1 hba)
· exact inv_inv b ▸ ha.2 _ (mt (inv_mem_iff (x := b)).1 hb)
· rw [← inv_mem_iff (x := a), ← ha, inv_mul_cancel]
exact one_mem _
· rwa [ha, inv_mem_iff (x := b)]
/-- A subgroup has index two if and only if there exists `a` such that for all `b`, exactly one
of `a * b` and `b` belong to `H`. -/
@[to_additive /-- An additive subgroup has index two if and only if there exists `a` such that
for all `b`, exactly one of `a + b` and `b` belong to `H`. -/]
theorem index_eq_two_iff' : H.index = 2 ↔ ∃ a, ∀ b, Xor' (a * b ∈ H) (b ∈ H) := by
rw [index_eq_two_iff, (Equiv.inv G).exists_congr]
refine fun a ↦ (Equiv.inv G).forall_congr fun b ↦ ?_
simp only [Equiv.inv_apply, inv_mem_iff, ← mul_inv_rev]
/-- A subgroup `H` has index two if and only if there exists `a ∉ H` such that for all `b`, one
of `b * a` and `b` belongs to `H`. -/
@[to_additive /-- An additive subgroup `H` has index two if and only if there exists `a ∉ H` such
that for all `b`, one of `b + a` and `b` belongs to `H`. -/]
lemma index_eq_two_iff_exists_notMem_and :
H.index = 2 ↔ ∃ a, a ∉ H ∧ ∀ b, (b * a ∈ H) ∨ (b ∈ H) := by
simp only [index_eq_two_iff, xor_iff_or_and_not_and]
exact exists_congr fun a ↦ ⟨fun h ↦ ⟨fun ha ↦ ((h a)).2 ⟨mul_mem ha ha, ha⟩, fun b ↦ (h b).1⟩,
fun h b ↦ ⟨h.2 b, fun h' ↦ h.1 (by simpa using mul_mem (inv_mem h'.2) h'.1)⟩⟩
/-- A subgroup `H` has index two if and only if there exists `a ∉ H` such that for all `b`, one
of `a * b` and `b` belongs to `H`. -/
@[to_additive /-- An additive subgroup has index two if and only if there exists `a ∉ H` such that
for all `b`, one of `a + b` and `b` belongs to `H`. -/]
lemma index_eq_two_iff_exists_notMem_and' :
H.index = 2 ↔ ∃ a, a ∉ H ∧ ∀ b, (a * b ∈ H) ∨ (b ∈ H) := by
simp only [index_eq_two_iff', xor_iff_or_and_not_and]
exact exists_congr fun a ↦ ⟨fun h ↦ ⟨fun ha ↦ ((h a)).2 ⟨mul_mem ha ha, ha⟩, fun b ↦ (h b).1⟩,
fun h b ↦ ⟨h.2 b, fun h' ↦ h.1 (by simpa using mul_mem h'.1 (inv_mem h'.2))⟩⟩
/-- Relative version of `Subgroup.index_eq_two_iff`. -/
@[to_additive /-- Relative version of `AddSubgroup.index_eq_two_iff`. -/]
theorem relIndex_eq_two_iff : H.relIndex K = 2 ↔ ∃ a ∈ K, ∀ b ∈ K, Xor' (b * a ∈ H) (b ∈ H) := by
simp [Subgroup.relIndex, Subgroup.index_eq_two_iff, mem_subgroupOf]
/-- Relative version of `Subgroup.index_eq_two_iff'`. -/
@[to_additive /-- Relative version of `AddSubgroup.index_eq_two_iff'`. -/]
theorem relIindex_eq_two_iff' : H.relIndex K = 2 ↔ ∃ a ∈ K, ∀ b ∈ K, Xor' (a * b ∈ H) (b ∈ H) := by
simp [Subgroup.relIndex, Subgroup.index_eq_two_iff', mem_subgroupOf]
/-- Relative version of `Subgroup.index_eq_two_iff_exists_notMem_and`. -/
@[to_additive /-- Relative version of `AddSubgroup.index_eq_two_iff_exists_notMem_and`. -/]
lemma relIndex_eq_two_iff_exists_notMem_and :
H.relIndex K = 2 ↔ ∃ a ∈ K, a ∉ H ∧ ∀ b ∈ K, (b * a ∈ H) ∨ (b ∈ H) := by
rw [Subgroup.relIndex, Subgroup.index_eq_two_iff_exists_notMem_and]
simp only [mem_subgroupOf, coe_mul, Subtype.forall, Subtype.exists, exists_and_left, exists_prop]
refine exists_congr fun g ↦ ?_
simp only [and_left_comm]
/-- Relative version of `Subgroup.index_eq_two_iff_exists_notMem_and'`. -/
@[to_additive /-- Relative version of `AddSubgroup.index_eq_two_iff_exists_notMem_and'`. -/]
lemma relIndex_eq_two_iff_exists_notMem_and' :
H.relIndex K = 2 ↔ ∃ a ∈ K, a ∉ H ∧ ∀ b ∈ K, (a * b ∈ H) ∨ (b ∈ H) := by
rw [Subgroup.relIndex, Subgroup.index_eq_two_iff_exists_notMem_and']
simp only [mem_subgroupOf, coe_mul, Subtype.forall, Subtype.exists, exists_and_left, exists_prop]
refine exists_congr fun g ↦ ?_
simp only [and_left_comm]
@[to_additive]
theorem mul_mem_iff_of_index_two (h : H.index = 2) {a b : G} : a * b ∈ H ↔ (a ∈ H ↔ b ∈ H) := by
by_cases ha : a ∈ H; · simp only [ha, true_iff, mul_mem_cancel_left ha]
by_cases hb : b ∈ H; · simp only [hb, iff_true, mul_mem_cancel_right hb]
simp only [ha, hb, iff_true]
rcases index_eq_two_iff.1 h with ⟨c, hc⟩
refine (hc _).or.resolve_left ?_
rwa [mul_assoc, mul_mem_cancel_right ((hc _).or.resolve_right hb)]
@[to_additive]
theorem mul_self_mem_of_index_two (h : H.index = 2) (a : G) : a * a ∈ H := by
rw [mul_mem_iff_of_index_two h]
@[to_additive two_smul_mem_of_index_two]
theorem sq_mem_of_index_two (h : H.index = 2) (a : G) : a ^ 2 ∈ H :=
(pow_two a).symm ▸ mul_self_mem_of_index_two h a
variable (H K) {f : G →* G'}
@[to_additive (attr := simp)]
theorem index_top : (⊤ : Subgroup G).index = 1 :=
Nat.card_eq_one_iff_unique.mpr ⟨QuotientGroup.subsingleton_quotient_top, ⟨1⟩⟩
@[to_additive (attr := simp)]
theorem index_bot : (⊥ : Subgroup G).index = Nat.card G :=
Cardinal.toNat_congr QuotientGroup.quotientBot.toEquiv
@[to_additive (attr := simp)]
theorem relIndex_top_left : (⊤ : Subgroup G).relIndex H = 1 :=
index_top
@[deprecated (since := "2025-08-12")] alias relindex_top_left := relIndex_top_left
@[to_additive (attr := simp)]
theorem relIndex_top_right : H.relIndex ⊤ = H.index := by
rw [← relIndex_mul_index (show H ≤ ⊤ from le_top), index_top, mul_one]
@[deprecated (since := "2025-08-12")] alias relindex_top_right := relIndex_top_right
@[to_additive (attr := simp)]
theorem relIndex_bot_left : (⊥ : Subgroup G).relIndex H = Nat.card H := by
rw [relIndex, bot_subgroupOf, index_bot]
@[deprecated (since := "2025-08-12")] alias relindex_bot_left := relIndex_bot_left
@[to_additive (attr := simp)]
theorem relIndex_bot_right : H.relIndex ⊥ = 1 := by rw [relIndex, subgroupOf_bot_eq_top, index_top]
@[deprecated (since := "2025-08-12")] alias relindex_bot_right := relIndex_bot_right
@[to_additive (attr := simp)]
theorem relIndex_self : H.relIndex H = 1 := by rw [relIndex, subgroupOf_self, index_top]
@[deprecated (since := "2025-08-12")] alias relindex_self := relIndex_self
@[to_additive]
theorem index_ker (f : G →* G') : f.ker.index = Nat.card f.range := by
rw [← MonoidHom.comap_bot, index_comap, relIndex_bot_left]
@[to_additive]
theorem relIndex_ker (f : G →* G') : f.ker.relIndex K = Nat.card (K.map f) := by
rw [← MonoidHom.comap_bot, relIndex_comap, relIndex_bot_left]
@[deprecated (since := "2025-08-12")] alias relindex_ker := relIndex_ker
@[to_additive (attr := simp) card_mul_index]
theorem card_mul_index : Nat.card H * H.index = Nat.card G := by
rw [← relIndex_bot_left, ← index_bot]
exact relIndex_mul_index bot_le
@[to_additive]
theorem card_dvd_of_surjective (f : G →* G') (hf : Function.Surjective f) :
Nat.card G' ∣ Nat.card G := by
rw [← Nat.card_congr (QuotientGroup.quotientKerEquivOfSurjective f hf).toEquiv]
exact Dvd.intro_left (Nat.card f.ker) f.ker.card_mul_index
@[to_additive]
theorem card_range_dvd (f : G →* G') : Nat.card f.range ∣ Nat.card G :=
card_dvd_of_surjective f.rangeRestrict f.rangeRestrict_surjective
@[to_additive]
theorem card_map_dvd (f : G →* G') : Nat.card (H.map f) ∣ Nat.card H :=
card_dvd_of_surjective (f.subgroupMap H) (f.subgroupMap_surjective H)
@[to_additive]
theorem index_map (f : G →* G') :
(H.map f).index = (H ⊔ f.ker).index * f.range.index := by
rw [← comap_map_eq, index_comap, relIndex_mul_index (H.map_le_range f)]
@[to_additive]
theorem index_map_dvd {f : G →* G'} (hf : Function.Surjective f) :
(H.map f).index ∣ H.index := by
rw [index_map, f.range_eq_top_of_surjective hf, index_top, mul_one]
exact index_dvd_of_le le_sup_left
@[to_additive]
theorem dvd_index_map {f : G →* G'} (hf : f.ker ≤ H) :
H.index ∣ (H.map f).index := by
rw [index_map, sup_of_le_left hf]
apply dvd_mul_right
@[to_additive]
theorem index_map_eq (hf1 : Surjective f) (hf2 : f.ker ≤ H) : (H.map f).index = H.index :=
Nat.dvd_antisymm (H.index_map_dvd hf1) (H.dvd_index_map hf2)
@[to_additive]
lemma index_map_of_bijective (hf : Bijective f) (H : Subgroup G) : (H.map f).index = H.index :=
index_map_eq _ hf.2 (by rw [f.ker_eq_bot_iff.2 hf.1]; exact bot_le)
@[to_additive (attr := simp)]
theorem index_map_equiv (e : G ≃* G') : (map (e : G →* G') H).index = H.index :=
index_map_of_bijective e.bijective H
@[to_additive]
theorem index_map_of_injective {f : G →* G'} (hf : Function.Injective f) :
(H.map f).index = H.index * f.range.index := by
rw [H.index_map, f.ker_eq_bot_iff.mpr hf, sup_bot_eq]
@[to_additive]
theorem index_map_subtype {H : Subgroup G} (K : Subgroup H) :
(K.map H.subtype).index = K.index * H.index := by
rw [K.index_map_of_injective H.subtype_injective, H.range_subtype]
@[to_additive]
theorem index_eq_card : H.index = Nat.card (G ⧸ H) :=
rfl
@[to_additive index_mul_card]
theorem index_mul_card : H.index * Nat.card H = Nat.card G := by
rw [mul_comm, card_mul_index]
@[to_additive]
theorem index_dvd_card : H.index ∣ Nat.card G :=
⟨Nat.card H, H.index_mul_card.symm⟩
@[to_additive]
theorem relIndex_dvd_card : H.relIndex K ∣ Nat.card K :=
(H.subgroupOf K).index_dvd_card
@[deprecated (since := "2025-08-12")] alias relindex_dvd_card := relIndex_dvd_card
variable {H K L}
@[to_additive]
theorem relIndex_eq_zero_of_le_left (hHK : H ≤ K) (hKL : K.relIndex L = 0) : H.relIndex L = 0 :=
eq_zero_of_zero_dvd (hKL ▸ relIndex_dvd_of_le_left L hHK)
@[deprecated (since := "2025-08-12")]
alias relindex_eq_zero_of_le_left := relIndex_eq_zero_of_le_left
@[to_additive]
theorem relIndex_eq_zero_of_le_right (hKL : K ≤ L) (hHK : H.relIndex K = 0) : H.relIndex L = 0 :=
Finite.card_eq_zero_of_embedding (quotientSubgroupOfEmbeddingOfLE H hKL) hHK
@[deprecated (since := "2025-08-12")]
alias relindex_eq_zero_of_le_right := relIndex_eq_zero_of_le_right
/-- If `J` has finite index in `K`, then the same holds for their comaps under any group hom. -/
@[to_additive /-- If `J` has finite index in `K`, then the same holds for their comaps under any
additive group hom. -/]
lemma relIndex_comap_ne_zero (f : G →* G') {J K : Subgroup G'} (hJK : J.relIndex K ≠ 0) :
(J.comap f).relIndex (K.comap f) ≠ 0 := by
rw [relIndex_comap]
exact fun h ↦ hJK <| relIndex_eq_zero_of_le_right (map_comap_le _ _) h
@[deprecated (since := "2025-08-12")] alias relindex_comap_ne_zero := relIndex_comap_ne_zero
@[to_additive]
theorem index_eq_zero_of_relIndex_eq_zero (h : H.relIndex K = 0) : H.index = 0 :=
H.relIndex_top_right.symm.trans (relIndex_eq_zero_of_le_right le_top h)
@[deprecated (since := "2025-08-12")]
alias index_eq_zero_of_relindex_eq_zero := index_eq_zero_of_relIndex_eq_zero
@[to_additive]
theorem relIndex_le_of_le_left (hHK : H ≤ K) (hHL : H.relIndex L ≠ 0) :
K.relIndex L ≤ H.relIndex L :=
Nat.le_of_dvd (Nat.pos_of_ne_zero hHL) (relIndex_dvd_of_le_left L hHK)
@[deprecated (since := "2025-08-12")] alias relindex_le_of_le_left := relIndex_le_of_le_left
@[to_additive]
theorem relIndex_le_of_le_right (hKL : K ≤ L) (hHL : H.relIndex L ≠ 0) :
H.relIndex K ≤ H.relIndex L :=
Finite.card_le_of_embedding' (quotientSubgroupOfEmbeddingOfLE H hKL) fun h => (hHL h).elim
@[deprecated (since := "2025-08-12")] alias relindex_le_of_le_right := relIndex_le_of_le_right
@[to_additive]
theorem relIndex_ne_zero_trans (hHK : H.relIndex K ≠ 0) (hKL : K.relIndex L ≠ 0) :
H.relIndex L ≠ 0 := fun h =>
mul_ne_zero (mt (relIndex_eq_zero_of_le_right (show K ⊓ L ≤ K from inf_le_left)) hHK) hKL
((relIndex_inf_mul_relIndex H K L).trans (relIndex_eq_zero_of_le_left inf_le_left h))
@[deprecated (since := "2025-08-12")] alias relindex_ne_zero_trans := relIndex_ne_zero_trans
@[to_additive]
theorem relIndex_inf_ne_zero (hH : H.relIndex L ≠ 0) (hK : K.relIndex L ≠ 0) :
(H ⊓ K).relIndex L ≠ 0 := by
replace hH : H.relIndex (K ⊓ L) ≠ 0 := mt (relIndex_eq_zero_of_le_right inf_le_right) hH
rw [← inf_relIndex_right] at hH hK ⊢
rw [inf_assoc]
exact relIndex_ne_zero_trans hH hK
@[deprecated (since := "2025-08-12")] alias relindex_inf_ne_zero := relIndex_inf_ne_zero
@[to_additive]
theorem index_inf_ne_zero (hH : H.index ≠ 0) (hK : K.index ≠ 0) : (H ⊓ K).index ≠ 0 := by
rw [← relIndex_top_right] at hH hK ⊢
exact relIndex_inf_ne_zero hH hK
/-- If `J` has finite index in `K`, then `J ⊓ L` has finite index in `K ⊓ L` for any `L`. -/
@[to_additive /-- If `J` has finite index in `K`, then `J ⊓ L` has finite index in `K ⊓ L` for any
`L`. -/]
lemma relIndex_inter_ne_zero {J K : Subgroup G} (hJK : J.relIndex K ≠ 0) (L : Subgroup G) :
(J ⊓ L).relIndex (K ⊓ L) ≠ 0 := by
rw [← range_subtype L, inf_comm, ← map_comap_eq, inf_comm, ← map_comap_eq, ← relIndex_comap,
comap_map_eq_self_of_injective (subtype_injective L)]
exact relIndex_comap_ne_zero _ hJK
@[deprecated (since := "2025-08-12")] alias relindex_inter_ne_zero := relIndex_inter_ne_zero
@[to_additive]
theorem relIndex_inf_le : (H ⊓ K).relIndex L ≤ H.relIndex L * K.relIndex L := by
by_cases h : H.relIndex L = 0
· exact (le_of_eq (relIndex_eq_zero_of_le_left inf_le_left h)).trans (zero_le _)
rw [← inf_relIndex_right, inf_assoc, ← relIndex_mul_relIndex _ _ L inf_le_right inf_le_right,
inf_relIndex_right, inf_relIndex_right]
grw [relIndex_le_of_le_right inf_le_right h]
@[deprecated (since := "2025-08-12")] alias relindex_inf_le := relIndex_inf_le
@[to_additive]
theorem index_inf_le : (H ⊓ K).index ≤ H.index * K.index := by
simp_rw [← relIndex_top_right, relIndex_inf_le]
@[to_additive]
theorem relIndex_iInf_ne_zero {ι : Type*} [_hι : Finite ι] {f : ι → Subgroup G}
(hf : ∀ i, (f i).relIndex L ≠ 0) : (⨅ i, f i).relIndex L ≠ 0 :=
haveI := Fintype.ofFinite ι
(Finset.prod_ne_zero_iff.mpr fun i _hi => hf i) ∘
Nat.card_pi.symm.trans ∘
Finite.card_eq_zero_of_embedding (quotientiInfSubgroupOfEmbedding f L)
@[deprecated (since := "2025-08-12")] alias relindex_iInf_ne_zero := relIndex_iInf_ne_zero
@[to_additive]
theorem relIndex_iInf_le {ι : Type*} [Fintype ι] (f : ι → Subgroup G) :
(⨅ i, f i).relIndex L ≤ ∏ i, (f i).relIndex L :=
le_of_le_of_eq
(Finite.card_le_of_embedding' (quotientiInfSubgroupOfEmbedding f L) fun h =>
let ⟨i, _hi, h⟩ := Finset.prod_eq_zero_iff.mp (Nat.card_pi.symm.trans h)
relIndex_eq_zero_of_le_left (iInf_le f i) h)
Nat.card_pi
@[deprecated (since := "2025-08-12")] alias relindex_iInf_le := relIndex_iInf_le
@[to_additive]
theorem index_iInf_ne_zero {ι : Type*} [Finite ι] {f : ι → Subgroup G}
(hf : ∀ i, (f i).index ≠ 0) : (⨅ i, f i).index ≠ 0 := by
simp_rw [← relIndex_top_right] at hf ⊢
exact relIndex_iInf_ne_zero hf
@[to_additive]
theorem index_iInf_le {ι : Type*} [Fintype ι] (f : ι → Subgroup G) :
(⨅ i, f i).index ≤ ∏ i, (f i).index := by simp_rw [← relIndex_top_right, relIndex_iInf_le]
@[to_additive (attr := simp) index_eq_one]
theorem index_eq_one : H.index = 1 ↔ H = ⊤ :=
⟨fun h =>
QuotientGroup.subgroup_eq_top_of_subsingleton H (Nat.card_eq_one_iff_unique.mp h).1,
fun h => (congr_arg index h).trans index_top⟩
@[to_additive (attr := simp) relIndex_eq_one]
theorem relIndex_eq_one : H.relIndex K = 1 ↔ K ≤ H :=
index_eq_one.trans subgroupOf_eq_top
@[deprecated (since := "2025-08-12")] alias relindex_eq_one := relIndex_eq_one
@[to_additive (attr := simp) card_eq_one]
theorem card_eq_one : Nat.card H = 1 ↔ H = ⊥ :=
H.relIndex_bot_left ▸ relIndex_eq_one.trans le_bot_iff
/-- A subgroup has index dividing 2 if and only if there exists `a` such that for all `b`, at least
one of `b * a` and `b` belongs to `H`. -/
@[to_additive /-- An additive subgroup has index dividing 2 if and only if there exists `a` such
that for all `b`, at least one of `b + a` and `b` belongs to `H`. -/]
theorem index_dvd_two_iff : H.index ∣ 2 ↔ ∃ a, ∀ b, (b * a ∈ H) ∨ (b ∈ H) where
mp hH := by
obtain (hH | hH) : H.index = 1 ∨ H.index = 2 := by
-- This is just showing that 2 is prime, but we do it "longhand" to avoid making any
-- dependence on number theory files.
have := Nat.le_succ_iff.mp (Nat.le_of_dvd two_pos hH)
rw [Nat.le_one_iff_eq_zero_or_eq_one, or_assoc] at this
exact this.resolve_left fun h ↦ (two_ne_zero <| Nat.zero_dvd.mp (h ▸ hH)).elim
· simp [index_eq_one.mp hH]
· exact match index_eq_two_iff.mp hH with | ⟨a, ha⟩ => ⟨a, fun b ↦ (ha b).or⟩
mpr := by
rintro ⟨a, ha⟩
by_cases ha' : a ∈ H
· suffices ∀ b, b ∈ H by simp [(eq_top_iff' _).mpr this]
exact fun b ↦ (ha b).elim (fun h ↦ by simpa using mul_mem h (inv_mem ha')) id
· refine dvd_of_eq (index_eq_two_iff.mpr
⟨a, fun b ↦ (xor_iff_or_and_not_and _ _).mpr ⟨ha b, fun h ↦ ha' ?_⟩⟩)
simpa using mul_mem (inv_mem h.2) h.1
/-- A subgroup has index dividing 2 if and only if there exists `a` such that for all `b`, at least
one of `a * b` and `b` belongs to `H`. -/
@[to_additive /-- An additive subgroup has index dividing 2 if and only if there exists `a` such
that for all `b`, at least one of `a + b` and `b` belongs to `H`. -/]
theorem index_dvd_two_iff' : H.index ∣ 2 ↔ ∃ a, ∀ b, (a * b ∈ H) ∨ (b ∈ H) := by
rw [index_dvd_two_iff, (Equiv.inv G).exists_congr]
refine fun a ↦ (Equiv.inv G).forall_congr fun b ↦ ?_
simp only [Equiv.inv_apply, inv_mem_iff, ← mul_inv_rev]
/-- Relative version of `Subgroup.index_dvd_two_iff`. -/
@[to_additive /-- Relative version of `AddSubgroup.index_dvd_two_iff`. -/]
theorem relIndex_dvd_two_iff : H.relIndex K ∣ 2 ↔ ∃ a ∈ K, ∀ b ∈ K, (b * a ∈ H) ∨ (b ∈ H) := by
simp [Subgroup.relIndex, Subgroup.index_dvd_two_iff, mem_subgroupOf]
/-- Relative version of `Subgroup.index_dvd_two_iff'`. -/
@[to_additive /-- Relative version of `AddSubgroup.index_dvd_two_iff'`. -/]
theorem relIindex_dvd_two_iff' : H.relIndex K ∣ 2 ↔ ∃ a ∈ K, ∀ b ∈ K, (a * b ∈ H) ∨ (b ∈ H) := by
simp [Subgroup.relIndex, Subgroup.index_dvd_two_iff', mem_subgroupOf]
@[to_additive]
lemma inf_eq_bot_of_coprime (h : Nat.Coprime (Nat.card H) (Nat.card K)) : H ⊓ K = ⊥ :=
card_eq_one.1 <| Nat.eq_one_of_dvd_coprimes h
(card_dvd_of_le inf_le_left) (card_dvd_of_le inf_le_right)
@[to_additive]
theorem index_ne_zero_of_finite [hH : Finite (G ⧸ H)] : H.index ≠ 0 := by
cases nonempty_fintype (G ⧸ H)
rw [index_eq_card]
exact Nat.card_pos.ne'
/-- Finite index implies finite quotient. -/
@[to_additive /-- Finite index implies finite quotient. -/]
noncomputable def fintypeOfIndexNeZero (hH : H.index ≠ 0) : Fintype (G ⧸ H) :=
@Fintype.ofFinite _ (Nat.finite_of_card_ne_zero hH)
@[to_additive]
lemma index_eq_zero_iff_infinite : H.index = 0 ↔ Infinite (G ⧸ H) := by
simp [index_eq_card, Nat.card_eq_zero]
@[to_additive]
lemma index_ne_zero_iff_finite : H.index ≠ 0 ↔ Finite (G ⧸ H) := by
simp [index_eq_zero_iff_infinite]
@[to_additive one_lt_index_of_ne_top]
theorem one_lt_index_of_ne_top [Finite (G ⧸ H)] (hH : H ≠ ⊤) : 1 < H.index :=
Nat.one_lt_iff_ne_zero_and_ne_one.mpr ⟨index_ne_zero_of_finite, mt index_eq_one.mp hH⟩
@[to_additive]
lemma finite_quotient_of_finite_quotient_of_index_ne_zero {X : Type*} [MulAction G X]
[Finite <| MulAction.orbitRel.Quotient G X] (hi : H.index ≠ 0) :
Finite <| MulAction.orbitRel.Quotient H X := by
have := fintypeOfIndexNeZero hi
exact MulAction.finite_quotient_of_finite_quotient_of_finite_quotient
@[to_additive]
lemma finite_quotient_of_pretransitive_of_index_ne_zero {X : Type*} [MulAction G X]
[MulAction.IsPretransitive G X] (hi : H.index ≠ 0) :
Finite <| MulAction.orbitRel.Quotient H X := by
have := (MulAction.pretransitive_iff_subsingleton_quotient G X).1 inferInstance
exact finite_quotient_of_finite_quotient_of_index_ne_zero hi
@[to_additive]
lemma exists_pow_mem_of_index_ne_zero (h : H.index ≠ 0) (a : G) :
∃ n, 0 < n ∧ n ≤ H.index ∧ a ^ n ∈ H := by
suffices ∃ n₁ n₂, n₁ < n₂ ∧ n₂ ≤ H.index ∧ ((a ^ n₂ : G) : G ⧸ H) = ((a ^ n₁ : G) : G ⧸ H) by
rcases this with ⟨n₁, n₂, hlt, hle, he⟩
refine ⟨n₂ - n₁, by cutsat, by cutsat, ?_⟩
rw [eq_comm, QuotientGroup.eq, ← zpow_natCast, ← zpow_natCast, ← zpow_neg, ← zpow_add,
add_comm] at he
rw [← zpow_natCast]
convert he
cutsat
suffices ∃ n₁ n₂, n₁ ≠ n₂ ∧ n₁ ≤ H.index ∧ n₂ ≤ H.index ∧
((a ^ n₂ : G) : G ⧸ H) = ((a ^ n₁ : G) : G ⧸ H) by
rcases this with ⟨n₁, n₂, hne, hle₁, hle₂, he⟩
rcases hne.lt_or_gt with hlt | hlt
· exact ⟨n₁, n₂, hlt, hle₂, he⟩
· exact ⟨n₂, n₁, hlt, hle₁, he.symm⟩
by_contra hc
simp_rw [not_exists] at hc
let f : (Set.Icc 0 H.index) → G ⧸ H := fun n ↦ (a ^ (n : ℕ) : G)
have hf : Function.Injective f := by
rintro ⟨n₁, h₁, hle₁⟩ ⟨n₂, h₂, hle₂⟩ he
have hc' := hc n₁ n₂
dsimp only [f] at he
simpa [hle₁, hle₂, he] using hc'
have := (fintypeOfIndexNeZero h).finite
have hcard := Nat.card_le_card_of_injective f hf
simp [← index_eq_card] at hcard
@[to_additive]
lemma exists_pow_mem_of_relIndex_ne_zero (h : H.relIndex K ≠ 0) {a : G} (ha : a ∈ K) :
∃ n, 0 < n ∧ n ≤ H.relIndex K ∧ a ^ n ∈ H ⊓ K := by
rcases exists_pow_mem_of_index_ne_zero h ⟨a, ha⟩ with ⟨n, hlt, hle, he⟩
refine ⟨n, hlt, hle, ?_⟩
simpa [pow_mem ha, mem_subgroupOf] using he
@[deprecated (since := "2025-08-12")]
alias exists_pow_mem_of_relindex_ne_zero := exists_pow_mem_of_relIndex_ne_zero
@[to_additive]
lemma pow_mem_of_index_ne_zero_of_dvd (h : H.index ≠ 0) (a : G) {n : ℕ}
(hn : ∀ m, 0 < m → m ≤ H.index → m ∣ n) : a ^ n ∈ H := by
rcases exists_pow_mem_of_index_ne_zero h a with ⟨m, hlt, hle, he⟩
rcases hn m hlt hle with ⟨k, rfl⟩
rw [pow_mul]
exact pow_mem he _
@[to_additive]
lemma pow_mem_of_relIndex_ne_zero_of_dvd (h : H.relIndex K ≠ 0) {a : G} (ha : a ∈ K) {n : ℕ}
(hn : ∀ m, 0 < m → m ≤ H.relIndex K → m ∣ n) : a ^ n ∈ H ⊓ K := by
convert pow_mem_of_index_ne_zero_of_dvd h ⟨a, ha⟩ hn
simp [pow_mem ha, mem_subgroupOf]
@[deprecated (since := "2025-08-12")]
alias pow_mem_of_relindex_ne_zero_of_dvd := pow_mem_of_relIndex_ne_zero_of_dvd
@[to_additive (attr := simp) index_prod]
lemma index_prod (H : Subgroup G) (K : Subgroup G') : (H.prod K).index = H.index * K.index := by
simp_rw [index, ← Nat.card_prod]
refine Nat.card_congr
((Quotient.congrRight (fun x y ↦ ?_)).trans (Setoid.prodQuotientEquiv _ _).symm)
rw [QuotientGroup.leftRel_prod]
@[to_additive (attr := simp)]
lemma index_pi {ι : Type*} [Fintype ι] (H : ι → Subgroup G) :
(Subgroup.pi Set.univ H).index = ∏ i, (H i).index := by
simp_rw [index, ← Nat.card_pi]
refine Nat.card_congr
((Quotient.congrRight (fun x y ↦ ?_)).trans (Setoid.piQuotientEquiv _).symm)
rw [QuotientGroup.leftRel_pi]
@[simp]
lemma index_toAddSubgroup : (Subgroup.toAddSubgroup H).index = H.index :=
rfl
@[simp]
lemma _root_.AddSubgroup.index_toSubgroup {G : Type*} [AddGroup G] (H : AddSubgroup G) :
(AddSubgroup.toSubgroup H).index = H.index :=
rfl
@[simp]
lemma relIndex_toAddSubgroup :
(Subgroup.toAddSubgroup H).relIndex (Subgroup.toAddSubgroup K) = H.relIndex K :=
rfl
@[deprecated (since := "2025-08-12")] alias relindex_toAddSubgroup := relIndex_toAddSubgroup
@[simp]
lemma _root_.AddSubgroup.relIndex_toSubgroup {G : Type*} [AddGroup G] (H K : AddSubgroup G) :
(AddSubgroup.toSubgroup H).relIndex (AddSubgroup.toSubgroup K) = H.relIndex K :=
rfl
@[deprecated (since := "2025-08-12")]
alias _root_.AddSubgroup.relindex_toSubgroup := _root_.AddSubgroup.relIndex_toSubgroup
section FiniteIndex
/-- Typeclass for finite index subgroups. -/
class _root_.AddSubgroup.FiniteIndex {G : Type*} [AddGroup G] (H : AddSubgroup G) : Prop where
/-- The additive subgroup has finite index;
recall that `AddSubgroup.index` returns 0 when the index is infinite. -/
index_ne_zero : H.index ≠ 0
variable (H) in
/-- Typeclass for finite index subgroups. -/
@[to_additive] class FiniteIndex : Prop where
/-- The subgroup has finite index;
recall that `Subgroup.index` returns 0 when the index is infinite. -/
index_ne_zero : H.index ≠ 0
/-- Typeclass for a subgroup `H` to have finite index in a subgroup `K`. -/
class _root_.AddSubgroup.IsFiniteRelIndex {G : Type*} [AddGroup G] (H K : AddSubgroup G) :
Prop where
protected relIndex_ne_zero : H.relIndex K ≠ 0
variable (H K) in
/-- Typeclass for a subgroup `H` to have finite index in a subgroup `K`. -/
@[to_additive] class IsFiniteRelIndex : Prop where
protected relIndex_ne_zero : H.relIndex K ≠ 0
@[to_additive] lemma relIndex_ne_zero [H.IsFiniteRelIndex K] : H.relIndex K ≠ 0 :=
IsFiniteRelIndex.relIndex_ne_zero
@[deprecated (since := "2025-08-12")] alias relindex_ne_zero := relIndex_ne_zero
@[to_additive]
instance IsFiniteRelIndex.to_finiteIndex_subgroupOf [H.IsFiniteRelIndex K] :
(H.subgroupOf K).FiniteIndex where
index_ne_zero := relIndex_ne_zero
@[to_additive]
theorem finiteIndex_iff : H.FiniteIndex ↔ H.index ≠ 0 :=
⟨fun h ↦ h.index_ne_zero, fun h ↦ ⟨h⟩⟩
@[to_additive]
theorem not_finiteIndex_iff {G : Type*} [Group G] {H : Subgroup G} :
¬ H.FiniteIndex ↔ H.index = 0 := by simp [finiteIndex_iff]
/-- A finite index subgroup has finite quotient. -/
@[to_additive /-- A finite index subgroup has finite quotient -/]
noncomputable def fintypeQuotientOfFiniteIndex [FiniteIndex H] : Fintype (G ⧸ H) :=
fintypeOfIndexNeZero FiniteIndex.index_ne_zero
@[to_additive]
instance finite_quotient_of_finiteIndex [FiniteIndex H] : Finite (G ⧸ H) :=
fintypeQuotientOfFiniteIndex.finite
@[to_additive]
theorem finiteIndex_of_finite_quotient [Finite (G ⧸ H)] : FiniteIndex H :=
⟨index_ne_zero_of_finite⟩
@[to_additive]
theorem finiteIndex_iff_finite_quotient : FiniteIndex H ↔ Finite (G ⧸ H) :=
⟨fun _ ↦ inferInstance, fun _ ↦ finiteIndex_of_finite_quotient⟩
@[to_additive]
instance (priority := 100) finiteIndex_of_finite [Finite G] : FiniteIndex H :=
finiteIndex_of_finite_quotient
variable (H) in
@[to_additive]
theorem finite_iff_finite_and_finiteIndex : Finite G ↔ Finite H ∧ H.FiniteIndex where
mp _ := ⟨inferInstance, inferInstance⟩
mpr := fun ⟨_, _⟩ ↦ Nat.finite_of_card_ne_zero <|
H.card_mul_index ▸ mul_ne_zero Nat.card_pos.ne' FiniteIndex.index_ne_zero
@[to_additive]
theorem _root_.MonoidHom.finite_iff_finite_ker_range (f : G →* G') :
Finite G ↔ Finite f.ker ∧ Finite f.range := by
rw [finite_iff_finite_and_finiteIndex f.ker, ← (QuotientGroup.quotientKerEquivRange f).finite_iff,
finiteIndex_iff_finite_quotient]
@[to_additive]
instance : FiniteIndex (⊤ : Subgroup G) :=
⟨ne_of_eq_of_ne index_top one_ne_zero⟩
@[to_additive]
instance [FiniteIndex H] [FiniteIndex K] : FiniteIndex (H ⊓ K) :=
⟨index_inf_ne_zero FiniteIndex.index_ne_zero FiniteIndex.index_ne_zero⟩
@[to_additive]
theorem finiteIndex_iInf {ι : Type*} [Finite ι] {f : ι → Subgroup G}
(hf : ∀ i, (f i).FiniteIndex) : (⨅ i, f i).FiniteIndex :=
⟨index_iInf_ne_zero fun i => (hf i).index_ne_zero⟩
@[to_additive]
theorem finiteIndex_iInf' {ι : Type*} {s : Finset ι}
(f : ι → Subgroup G) (hs : ∀ i ∈ s, (f i).FiniteIndex) :
(⨅ i ∈ s, f i).FiniteIndex := by
rw [iInf_subtype']
exact finiteIndex_iInf fun ⟨i, hi⟩ => hs i hi
@[to_additive]
instance instFiniteIndex_subgroupOf (H K : Subgroup G) [H.FiniteIndex] :
(H.subgroupOf K).FiniteIndex :=
⟨fun h => H.index_ne_zero_of_finite <| H.index_eq_zero_of_relIndex_eq_zero h⟩
@[to_additive]
theorem finiteIndex_of_le [FiniteIndex H] (h : H ≤ K) : FiniteIndex K :=
⟨ne_zero_of_dvd_ne_zero FiniteIndex.index_ne_zero (index_dvd_of_le h)⟩
@[to_additive (attr := gcongr)]
lemma index_antitone (h : H ≤ K) [H.FiniteIndex] : K.index ≤ H.index :=
Nat.le_of_dvd (Nat.zero_lt_of_ne_zero FiniteIndex.index_ne_zero) (index_dvd_of_le h)
@[to_additive (attr := gcongr)]
lemma index_strictAnti (h : H < K) [H.FiniteIndex] : K.index < H.index := by
have h0 : K.index ≠ 0 := (finiteIndex_of_le h.le).index_ne_zero
apply lt_of_le_of_ne (index_antitone h.le)
rw [← relIndex_mul_index h.le, Ne, eq_comm, mul_eq_right₀ h0, relIndex_eq_one]
exact h.not_ge
variable (H K)
@[to_additive]
instance finiteIndex_ker {G' : Type*} [Group G'] (f : G →* G') [Finite f.range] :
f.ker.FiniteIndex :=
@finiteIndex_of_finite_quotient G _ f.ker
(Finite.of_equiv f.range (QuotientGroup.quotientKerEquivRange f).symm)
instance finiteIndex_normalCore [H.FiniteIndex] : H.normalCore.FiniteIndex := by
rw [normalCore_eq_ker]
infer_instance
@[to_additive]
theorem index_range {f : G →* G} [hf : f.ker.FiniteIndex] :
f.range.index = Nat.card f.ker := by
rw [← mul_left_inj' hf.index_ne_zero, card_mul_index, index_ker, index_mul_card]
end FiniteIndex
end Subgroup
section Pointwise
open Pointwise
variable {G H : Type*} [Group H] (h : H)
-- NB: `to_additive` does not work to generate the second lemma from the first here, because it
-- would need to additivize `G`, but not `H`.
lemma Subgroup.relIndex_pointwise_smul [Group G] [MulDistribMulAction H G] (J K : Subgroup G) :
(h • J).relIndex (h • K) = J.relIndex K := by
rw [pointwise_smul_def K, ← relIndex_comap, pointwise_smul_def,
comap_map_eq_self_of_injective (by intro a b; simp)]
@[deprecated (since := "2025-08-12")]
alias Subgroup.relindex_pointwise_smul := Subgroup.relIndex_pointwise_smul
lemma AddSubgroup.relIndex_pointwise_smul [AddGroup G] [DistribMulAction H G]
(J K : AddSubgroup G) : (h • J).relIndex (h • K) = J.relIndex K := by
rw [pointwise_smul_def K, ← relIndex_comap, pointwise_smul_def,
comap_map_eq_self_of_injective (by intro a b; simp)]
@[deprecated (since := "2025-08-12")]
alias AddSubgroup.relindex_pointwise_smul := AddSubgroup.relIndex_pointwise_smul
end Pointwise
namespace MulAction
variable (G : Type*) {X : Type*} [Group G] [MulAction G X] (x : X)
@[to_additive] theorem index_stabilizer :
(stabilizer G x).index = (orbit G x).ncard :=
(Nat.card_congr (MulAction.orbitEquivQuotientStabilizer G x)).symm.trans
(Nat.card_coe_set_eq (orbit G x))
@[to_additive] theorem index_stabilizer_of_transitive [IsPretransitive G X] :
(stabilizer G x).index = Nat.card X := by
rw [index_stabilizer, orbit_eq_univ, Set.ncard_univ]
end MulAction
namespace MonoidHom
@[to_additive AddMonoidHom.surjective_of_card_ker_le_div]
lemma surjective_of_card_ker_le_div {G M : Type*} [Group G] [Group M] [Finite G] [Finite M]
(f : G →* M) (h : Nat.card f.ker ≤ Nat.card G / Nat.card M) : Function.Surjective f := by
refine range_eq_top.1 <| SetLike.ext' <| Set.eq_of_subset_of_ncard_le (Set.subset_univ _) ?_
rw [Subgroup.coe_top, Set.ncard_univ, ← Nat.card_coe_set_eq, SetLike.coe_sort_coe,
← Nat.card_congr (QuotientGroup.quotientKerEquivRange f).toEquiv]
exact Nat.le_of_mul_le_mul_left (f.ker.card_mul_index ▸ Nat.mul_le_of_le_div _ _ _ h) Nat.card_pos
open Finset
variable {G M F : Type*} [Group G] [Fintype G] [Monoid M] [DecidableEq M]
[FunLike F G M] [MonoidHomClass F G M]
@[to_additive]
lemma card_fiber_eq_of_mem_range (f : F) {x y : M} (hx : x ∈ Set.range f) (hy : y ∈ Set.range f) :
#{g | f g = x} = #{g | f g = y} := by
rcases hx with ⟨x, rfl⟩
rcases hy with ⟨y, rfl⟩
rcases mul_left_surjective x y with ⟨y, rfl⟩
conv_lhs =>
rw [← map_univ_equiv (Equiv.mulRight y⁻¹), filter_map, card_map]
congr 2 with g
simp only [Function.comp, Equiv.toEmbedding_apply, Equiv.coe_mulRight, map_mul]
let f' := MonoidHomClass.toMonoidHom f
change f' g * f' y⁻¹ = f' x ↔ f' g = f' x * f' y
rw [← f'.coe_toHomUnits y⁻¹, map_inv, Units.mul_inv_eq_iff_eq_mul, f'.coe_toHomUnits]
end MonoidHom
namespace AddSubgroup
variable {G A : Type*} [Group G] [AddGroup A] [DistribMulAction G A]
@[simp]
lemma index_smul (a : G) (S : AddSubgroup A) : (a • S).index = S.index :=
index_map_of_bijective (MulAction.bijective _) _
end AddSubgroup |
.lake/packages/mathlib/Mathlib/GroupTheory/Archimedean.lean | import Mathlib.Algebra.Group.Subgroup.Order
import Mathlib.Algebra.Order.Archimedean.Basic
/-!
# Archimedean groups
This file proves a few facts about ordered groups which satisfy the `Archimedean` property, that is:
`class Archimedean (α) [OrderedAddCommMonoid α] : Prop :=`
`(arch : ∀ (x : α) {y}, 0 < y → ∃ n : ℕ, x ≤ n • y)`
They are placed here in a separate file (rather than incorporated as a continuation of
`Algebra.Order.Archimedean`) because they rely on some imports from `GroupTheory` -- bundled
subgroups in particular.
The main result is `AddSubgroup.cyclic_of_min`: a subgroup of a decidable archimedean abelian
group is cyclic, if its set of positive elements has a minimal element.
This result is used in this file to deduce `Int.subgroup_cyclic`, proving that every subgroup of `ℤ`
is cyclic. (There are several other methods one could use to prove this fact, including more purely
algebraic methods, but none seem to exist in mathlib as of writing. The closest is
`Subgroup.is_cyclic`, but that has not been transferred to `AddSubgroup`.)
The file also supports multiplicative groups via `MulArchimedean`.
The result is also used in `Topology.Instances.Real` as an ingredient in the classification of
subgroups of `ℝ`.
-/
assert_not_exists Finset
open Set
variable {G : Type*} [CommGroup G] [LinearOrder G] [IsOrderedMonoid G] [MulArchimedean G]
/-- Given a subgroup `H` of a decidable linearly ordered mul-archimedean abelian group `G`, if there
exists a minimal element `a` of `H ∩ G_{>1}` then `H` is generated by `a`. -/
@[to_additive AddSubgroup.cyclic_of_min /-- Given a subgroup `H` of a decidable linearly ordered
archimedean abelian group `G`, if there exists a minimal element `a` of `H ∩ G_{>0}` then `H` is
generated by `a`. -/]
theorem Subgroup.cyclic_of_min {H : Subgroup G} {a : G}
(ha : IsLeast { g : G | g ∈ H ∧ 1 < g } a) : H = closure {a} := by
obtain ⟨⟨a_in, a_pos⟩, a_min⟩ := ha
refine le_antisymm ?_ (H.closure_le.mpr <| by simp [a_in])
intro g g_in
obtain ⟨k, ⟨nonneg, lt⟩, _⟩ := existsUnique_zpow_near_of_one_lt a_pos g
have h_zero : g / (a ^ k) = 1 := by
by_contra h
have h : a ≤ g / (a ^ k) := by
refine a_min ⟨?_, ?_⟩
· exact Subgroup.div_mem H g_in (Subgroup.zpow_mem H a_in k)
· exact lt_of_le_of_ne (by simpa using nonneg) (Ne.symm h)
have h' : ¬a ≤ g / (a ^ k) := not_le.mpr (by simpa [zpow_add_one, div_lt_iff_lt_mul'] using lt)
contradiction
simp [div_eq_one.mp h_zero, mem_closure_singleton]
/-- If a nontrivial subgroup of a linear ordered commutative group is disjoint
with the interval `Set.Ioo 1 a` for some `1 < a`, then the set of elements greater than 1 of this
group admits the least element. -/
@[to_additive /-- If a nontrivial additive subgroup of a linear ordered additive commutative group
is disjoint with the interval `Set.Ioo 0 a` for some positive `a`, then the set of positive
elements of this group admits the least element. -/]
theorem Subgroup.exists_isLeast_one_lt {H : Subgroup G} (hbot : H ≠ ⊥) {a : G} (h₀ : 1 < a)
(hd : Disjoint (H : Set G) (Ioo 1 a)) : ∃ b, IsLeast { g : G | g ∈ H ∧ 1 < g } b := by
-- todo: move to a lemma?
have hex : ∀ g > 1, ∃ n : ℕ, g ∈ Ioc (a ^ n) (a ^ (n + 1)) := fun g hg => by
rcases existsUnique_mul_zpow_mem_Ico h₀ 1 (g / a) with ⟨m, ⟨hm, hm'⟩, -⟩
simp only [one_mul, div_le_iff_le_mul, div_mul_cancel, ← zpow_add_one] at hm hm'
lift m to ℕ
· rw [← Int.lt_add_one_iff, ← zpow_lt_zpow_iff_right h₀, zpow_zero]
exact hg.trans_le hm
· simp only [← Nat.cast_succ, zpow_natCast] at hm hm'
exact ⟨m, hm', hm⟩
have : ∃ n : ℕ, Set.Nonempty (H ∩ Ioc (a ^ n) (a ^ (n + 1))) := by
rcases (bot_or_exists_ne_one H).resolve_left hbot with ⟨g, hgH, hg₀⟩
rcases hex |g|ₘ (one_lt_mabs.2 hg₀) with ⟨n, hn⟩
exact ⟨n, _, (@mabs_mem_iff (Subgroup G) G _ _).2 hgH, hn⟩
classical rcases Nat.findX this with ⟨n, ⟨x, hxH, hnx, hxn⟩, hmin⟩
by_contra hxmin
simp only [IsLeast, not_and, mem_setOf_eq, mem_lowerBounds, not_exists, not_forall,
not_le] at hxmin
rcases hxmin x ⟨hxH, (one_le_pow_of_one_le' h₀.le _).trans_lt hnx⟩ with ⟨y, ⟨hyH, hy₀⟩, hxy⟩
obtain ⟨m, hm, hya⟩ := hex y hy₀
rcases lt_or_ge m n with hmn | hnm
· exact hmin m hmn ⟨y, hyH, hm, hya⟩
· refine disjoint_left.1 hd (div_mem hxH hyH) ⟨one_lt_div'.2 hxy, div_lt_iff_lt_mul'.2 ?_⟩
calc x ≤ a^ (n + 1) := hxn
_ ≤ a ^ (m + 1) := by grw [hnm]; exact h₀.le
_ = a ^ m * a := pow_succ _ _
_ < y * a := by gcongr
/-- If a subgroup of a linear ordered commutative group is disjoint with the
interval `Set.Ioo 1 a` for some `1 < a`, then this is a cyclic subgroup. -/
@[to_additive AddSubgroup.cyclic_of_isolated_zero /-- If an additive subgroup of a linear ordered
additive commutative group is disjoint with the interval `Set.Ioo 0 a` for some positive `a`, then
this is a cyclic subgroup. -/]
theorem Subgroup.cyclic_of_isolated_one {H : Subgroup G} {a : G} (h₀ : 1 < a)
(hd : Disjoint (H : Set G) (Ioo 1 a)) : ∃ b, H = closure {b} := by
rcases eq_or_ne H ⊥ with rfl | hbot
· exact ⟨1, closure_singleton_one.symm⟩
· exact (exists_isLeast_one_lt hbot h₀ hd).imp fun _ => cyclic_of_min
/-- Every subgroup of `ℤ` is cyclic. -/
theorem Int.subgroup_cyclic (H : AddSubgroup ℤ) : ∃ a, H = AddSubgroup.closure {a} :=
have : Ioo (0 : ℤ) 1 = ∅ := eq_empty_of_forall_notMem fun _ hm =>
hm.1.not_ge (lt_add_one_iff.1 hm.2)
AddSubgroup.cyclic_of_isolated_zero one_pos <| by simp [this] |
.lake/packages/mathlib/Mathlib/GroupTheory/EckmannHilton.lean | import Mathlib.Algebra.Group.Defs
/-!
# Eckmann-Hilton argument
The Eckmann-Hilton argument says that if a type carries two monoid structures that distribute
over one another, then they are equal, and in addition commutative.
The main application lies in proving that higher homotopy groups (`πₙ` for `n ≥ 2`) are commutative.
## Main declarations
* `EckmannHilton.commMonoid`: If a type carries a unital magma structure that distributes
over a unital binary operation, then the magma is a commutative monoid.
* `EckmannHilton.commGroup`: If a type carries a group structure that distributes
over a unital binary operation, then the group is commutative.
-/
universe u
namespace EckmannHilton
variable {X : Type u}
/-- Local notation for `m a b`. -/
local notation a " <" m:51 "> " b => m a b
/-- `IsUnital m e` expresses that `e : X` is a left and right unit
for the binary operation `m : X → X → X`. -/
structure IsUnital (m : X → X → X) (e : X) : Prop extends Std.LawfulIdentity m e
@[to_additive EckmannHilton.AddZeroClass.IsUnital]
theorem MulOneClass.isUnital [_G : MulOneClass X] : IsUnital (· * ·) (1 : X) :=
IsUnital.mk { left_id := MulOneClass.one_mul,
right_id := MulOneClass.mul_one }
variable {m₁ m₂ : X → X → X} {e₁ e₂ : X}
variable (h₁ : IsUnital m₁ e₁) (h₂ : IsUnital m₂ e₂)
variable (distrib : ∀ a b c d, ((a <m₂> b) <m₁> c <m₂> d) = (a <m₁> c) <m₂> b <m₁> d)
include h₁ h₂ distrib
/-- If a type carries two unital binary operations that distribute over each other,
then they have the same unit elements.
In fact, the two operations are the same, and give a commutative monoid structure,
see `eckmann_hilton.CommMonoid`. -/
theorem one : e₁ = e₂ := by
simpa only [h₁.left_id, h₁.right_id, h₂.left_id, h₂.right_id] using distrib e₂ e₁ e₁ e₂
/-- If a type carries two unital binary operations that distribute over each other,
then these operations are equal.
In fact, they give a commutative monoid structure, see `eckmann_hilton.CommMonoid`. -/
theorem mul : m₁ = m₂ := by
funext a b
calc
m₁ a b = m₁ (m₂ a e₁) (m₂ e₁ b) := by
{ simp only [one h₁ h₂ distrib, h₂.left_id, h₂.right_id] }
_ = m₂ a b := by simp only [distrib, h₁.left_id, h₁.right_id]
/-- If a type carries two unital binary operations that distribute over each other,
then these operations are commutative.
In fact, they give a commutative monoid structure, see `eckmann_hilton.CommMonoid`. -/
theorem mul_comm : Std.Commutative m₂ :=
⟨fun a b => by simpa [mul h₁ h₂ distrib, h₂.left_id, h₂.right_id] using distrib e₂ a b e₂⟩
/-- If a type carries two unital binary operations that distribute over each other,
then these operations are associative.
In fact, they give a commutative monoid structure, see `eckmann_hilton.CommMonoid`. -/
theorem mul_assoc : Std.Associative m₂ :=
⟨fun a b c => by simpa [mul h₁ h₂ distrib, h₂.left_id, h₂.right_id] using distrib a b e₂ c⟩
/-- If a type carries a unital magma structure that distributes over a unital binary
operation, then the magma structure is a commutative monoid. -/
@[to_additive
/-- If a type carries a unital additive magma structure that distributes over a unital binary
operation, then the additive magma structure is a commutative additive monoid. -/]
abbrev commMonoid [h : MulOneClass X]
(distrib : ∀ a b c d, ((a * b) <m₁> c * d) = (a <m₁> c) * b <m₁> d) : CommMonoid X :=
{ h with
mul_comm := (mul_comm h₁ MulOneClass.isUnital distrib).comm,
mul_assoc := (mul_assoc h₁ MulOneClass.isUnital distrib).assoc }
/-- If a type carries a group structure that distributes over a unital binary operation,
then the group is commutative. -/
@[to_additive
/-- If a type carries an additive group structure that distributes over a unital binary
operation, then the additive group is commutative. -/]
abbrev commGroup [G : Group X]
(distrib : ∀ a b c d, ((a * b) <m₁> c * d) = (a <m₁> c) * b <m₁> d) : CommGroup X :=
{ EckmannHilton.commMonoid h₁ distrib, G with .. }
end EckmannHilton |
.lake/packages/mathlib/Mathlib/GroupTheory/Divisible.lean | import Mathlib.Algebra.Group.ULift
import Mathlib.Algebra.GroupWithZero.Subgroup
import Mathlib.Algebra.Module.NatInt
import Mathlib.GroupTheory.QuotientGroup.Defs
import Mathlib.Tactic.NormNum.Eq
/-!
# Divisible Group and rootable group
In this file, we define a divisible additive monoid and a rootable monoid with some basic
properties.
## Main definition
* `DivisibleBy A α`: An additive monoid `A` is said to be divisible by `α` iff for all `n ≠ 0 ∈ α`
and `y ∈ A`, there is an `x ∈ A` such that `n • x = y`. In this file, we adopt a constructive
approach, i.e. we ask for an explicit `div : A → α → A` function such that `div a 0 = 0` and
`n • div a n = a` for all `n ≠ 0 ∈ α`.
* `RootableBy A α`: A monoid `A` is said to be rootable by `α` iff for all `n ≠ 0 ∈ α` and `y ∈ A`,
there is an `x ∈ A` such that `x^n = y`. In this file, we adopt a constructive approach, i.e. we
ask for an explicit `root : A → α → A` function such that `root a 0 = 1` and `(root a n)ⁿ = a` for
all `n ≠ 0 ∈ α`.
## Main results
For additive monoids and groups:
* `divisibleByOfSMulRightSurj` : the constructive definition of divisibility is implied by
the condition that `n • x = a` has solutions for all `n ≠ 0` and `a ∈ A`.
* `smul_right_surj_of_divisibleBy` : the constructive definition of divisibility implies
the condition that `n • x = a` has solutions for all `n ≠ 0` and `a ∈ A`.
* `Prod.divisibleBy` : `A × B` is divisible for any two divisible additive monoids.
* `Pi.divisibleBy` : any product of divisible additive monoids is divisible.
* `AddGroup.divisibleByIntOfDivisibleByNat` : for additive groups, int divisibility is implied
by nat divisibility.
* `AddGroup.divisibleByNatOfDivisibleByInt` : for additive groups, nat divisibility is implied
by int divisibility.
* `AddCommGroup.divisibleByIntOfSMulTopEqTop`: the constructive definition of divisibility
is implied by the condition that `n • A = A` for all `n ≠ 0`.
* `AddCommGroup.smul_top_eq_top_of_divisibleBy_int`: the constructive definition of divisibility
implies the condition that `n • A = A` for all `n ≠ 0`.
* `divisibleByIntOfCharZero` : any field of characteristic zero is divisible.
* `QuotientAddGroup.divisibleBy` : quotient group of divisible group is divisible.
* `Function.Surjective.divisibleBy` : if `A` is divisible and `A →+ B` is surjective, then `B`
is divisible.
and their multiplicative counterparts:
* `rootableByOfPowLeftSurj` : the constructive definition of rootability is implied by the
condition that `xⁿ = y` has solutions for all `n ≠ 0` and `a ∈ A`.
* `pow_left_surj_of_rootableBy` : the constructive definition of rootability implies the
condition that `xⁿ = y` has solutions for all `n ≠ 0` and `a ∈ A`.
* `Prod.rootableBy` : any product of two rootable monoids is rootable.
* `Pi.rootableBy` : any product of rootable monoids is rootable.
* `Group.rootableByIntOfRootableByNat` : in groups, int rootability is implied by nat
rootability.
* `Group.rootableByNatOfRootableByInt` : in groups, nat rootability is implied by int
rootability.
* `QuotientGroup.rootableBy` : quotient group of rootable group is rootable.
* `Function.Surjective.rootableBy` : if `A` is rootable and `A →* B` is surjective, then `B` is
rootable.
TODO: Show that divisibility implies injectivity in the category of `AddCommGroup`.
-/
open Pointwise
section AddMonoid
variable (A α : Type*) [AddMonoid A] [SMul α A] [Zero α]
/--
An `AddMonoid A` is `α`-divisible iff `n • x = a` has a solution for all `n ≠ 0 ∈ α` and `a ∈ A`.
Here we adopt a constructive approach where we ask an explicit `div : A → α → A` function such that
* `div a 0 = 0` for all `a ∈ A`
* `n • div a n = a` for all `n ≠ 0 ∈ α` and `a ∈ A`.
-/
class DivisibleBy where
/-- The division function -/
div : A → α → A
div_zero : ∀ a, div a 0 = 0
div_cancel : ∀ {n : α} (a : A), n ≠ 0 → n • div a n = a
end AddMonoid
section Monoid
variable (A α : Type*) [Monoid A] [Pow A α] [Zero α]
/-- A `Monoid A` is `α`-rootable iff `xⁿ = a` has a solution for all `n ≠ 0 ∈ α` and `a ∈ A`.
Here we adopt a constructive approach where we ask an explicit `root : A → α → A` function such that
* `root a 0 = 1` for all `a ∈ A`
* `(root a n)ⁿ = a` for all `n ≠ 0 ∈ α` and `a ∈ A`.
-/
@[to_additive]
class RootableBy where
/-- The root function -/
root : A → α → A
root_zero : ∀ a, root a 0 = 1
root_cancel : ∀ {n : α} (a : A), n ≠ 0 → root a n ^ n = a
@[to_additive smul_right_surj_of_divisibleBy]
theorem pow_left_surj_of_rootableBy [RootableBy A α] {n : α} (hn : n ≠ 0) :
Function.Surjective (fun a => a ^ n : A → A) := fun x =>
⟨RootableBy.root x n, RootableBy.root_cancel _ hn⟩
/--
A `Monoid A` is `α`-rootable iff the `pow _ n` function is surjective, i.e. the constructive version
implies the textbook approach.
-/
@[to_additive divisibleByOfSMulRightSurj /-- An `AddMonoid A` is `α`-divisible iff `n • _` is a
surjective function, i.e. the constructive version implies the textbook approach. -/]
noncomputable def rootableByOfPowLeftSurj
(H : ∀ {n : α}, n ≠ 0 → Function.Surjective (fun a => a ^ n : A → A)) : RootableBy A α where
root a n := @dite _ (n = 0) (Classical.dec _) (fun _ => (1 : A)) fun hn => (H hn a).choose
root_zero _ := by classical exact dif_pos rfl
root_cancel a hn := by
dsimp only
rw [dif_neg hn]
exact (H hn a).choose_spec
section Pi
variable {ι β : Type*} (B : ι → Type*) [∀ i : ι, Pow (B i) β]
variable [Zero β] [∀ i : ι, Monoid (B i)] [∀ i, RootableBy (B i) β]
@[to_additive]
instance Pi.rootableBy : RootableBy (∀ i, B i) β where
root x n i := RootableBy.root (x i) n
root_zero _x := funext fun _i => RootableBy.root_zero _
root_cancel _x hn := funext fun _i => RootableBy.root_cancel _ hn
end Pi
section Prod
variable {β B B' : Type*} [Pow B β] [Pow B' β]
variable [Zero β] [Monoid B] [Monoid B'] [RootableBy B β] [RootableBy B' β]
@[to_additive]
instance Prod.rootableBy : RootableBy (B × B') β where
root p n := (RootableBy.root p.1 n, RootableBy.root p.2 n)
root_zero _p := Prod.ext (RootableBy.root_zero _) (RootableBy.root_zero _)
root_cancel _p hn := Prod.ext (RootableBy.root_cancel _ hn) (RootableBy.root_cancel _ hn)
end Prod
section ULift
@[to_additive]
instance ULift.instRootableBy [RootableBy A α] : RootableBy (ULift A) α where
root x a := ULift.up <| RootableBy.root x.down a
root_zero x := ULift.ext _ _ <| RootableBy.root_zero x.down
root_cancel _ h := ULift.ext _ _ <| RootableBy.root_cancel _ h
end ULift
end Monoid
namespace AddCommGroup
variable (A : Type*) [AddCommGroup A]
theorem smul_top_eq_top_of_divisibleBy_int [DivisibleBy A ℤ] {n : ℤ} (hn : n ≠ 0) :
n • (⊤ : AddSubgroup A) = ⊤ :=
AddSubgroup.map_top_of_surjective _ fun a => ⟨DivisibleBy.div a n, DivisibleBy.div_cancel _ hn⟩
/-- If for all `n ≠ 0 ∈ ℤ`, `n • A = A`, then `A` is divisible.
-/
noncomputable def divisibleByIntOfSMulTopEqTop
(H : ∀ {n : ℤ} (_hn : n ≠ 0), n • (⊤ : AddSubgroup A) = ⊤) : DivisibleBy A ℤ where
div a n :=
if hn : n = 0 then 0 else (show a ∈ n • (⊤ : AddSubgroup A) by rw [H hn]; trivial).choose
div_zero _ := dif_pos rfl
div_cancel a hn := by
simp_rw [dif_neg hn]
generalize_proofs h1
exact h1.choose_spec.2
end AddCommGroup
instance (priority := 100) divisibleByIntOfCharZero {𝕜} [DivisionRing 𝕜] [CharZero 𝕜] :
DivisibleBy 𝕜 ℤ where
div q n := q / n
div_zero q := by simp
div_cancel {n} q hn := by
rw [zsmul_eq_mul, (Int.cast_commute n _).eq, div_mul_cancel₀ q (Int.cast_ne_zero.mpr hn)]
namespace Group
variable (A : Type*) [Group A]
open Int in
/-- A group is `ℤ`-rootable if it is `ℕ`-rootable.
-/
@[to_additive /-- An additive group is `ℤ`-divisible if it is `ℕ`-divisible. -/]
def rootableByIntOfRootableByNat [RootableBy A ℕ] : RootableBy A ℤ where
root a z :=
match z with
| (n : ℕ) => RootableBy.root a n
| -[n+1] => (RootableBy.root a (n + 1))⁻¹
root_zero a := RootableBy.root_zero a
root_cancel {n} a hn := by
cases n
· rw [Int.ofNat_eq_coe, Nat.cast_ne_zero] at hn
simp [RootableBy.root_cancel _ hn]
· simp [RootableBy.root_cancel _ (Nat.add_one_ne_zero _)]
/-- A group is `ℕ`-rootable if it is `ℤ`-rootable
-/
@[to_additive /-- An additive group is `ℕ`-divisible if it `ℤ`-divisible. -/]
def rootableByNatOfRootableByInt [RootableBy A ℤ] : RootableBy A ℕ where
root a n := RootableBy.root a (n : ℤ)
root_zero a := RootableBy.root_zero a
root_cancel {n} a hn := by
have := RootableBy.root_cancel a (show (n : ℤ) ≠ 0 from mod_cast hn)
norm_num at this
exact this
end Group
section Hom
variable {A B α : Type*}
variable [Zero α] [Monoid A] [Monoid B] [Pow A α] [Pow B α] [RootableBy A α]
variable (f : A → B)
/--
If `f : A → B` is a surjective homomorphism and `A` is `α`-rootable, then `B` is also `α`-rootable.
-/
@[to_additive
/-- If `f : A → B` is a surjective homomorphism and `A` is `α`-divisible, then `B` is also
`α`-divisible. -/]
noncomputable def Function.Surjective.rootableBy (hf : Function.Surjective f)
(hpow : ∀ (a : A) (n : α), f (a ^ n) = f a ^ n) : RootableBy B α :=
rootableByOfPowLeftSurj _ _ fun {n} hn x =>
let ⟨y, hy⟩ := hf x
⟨f <| RootableBy.root y n,
(by rw [← hpow (RootableBy.root y n) n, RootableBy.root_cancel _ hn, hy] : _ ^ n = x)⟩
@[to_additive DivisibleBy.surjective_smul]
theorem RootableBy.surjective_pow (A α : Type*) [Monoid A] [Pow A α] [Zero α] [RootableBy A α]
{n : α} (hn : n ≠ 0) : Function.Surjective fun a : A => a ^ n := fun a =>
⟨RootableBy.root a n, RootableBy.root_cancel a hn⟩
end Hom
section Quotient
variable (α : Type*) {A : Type*} [CommGroup A] (B : Subgroup A)
/-- Any quotient group of a rootable group is rootable. -/
@[to_additive /-- Any quotient group of a divisible group is divisible -/]
noncomputable instance QuotientGroup.rootableBy [RootableBy A ℕ] : RootableBy (A ⧸ B) ℕ :=
QuotientGroup.mk_surjective.rootableBy _ fun _ _ => rfl
end Quotient |
.lake/packages/mathlib/Mathlib/GroupTheory/DoubleCoset.lean | import Mathlib.Algebra.Group.Subgroup.Pointwise
import Mathlib.GroupTheory.Coset.Basic
/-!
# Double cosets
This file defines double cosets for two subgroups `H K` of a group `G` and the quotient of `G` by
the double coset relation, i.e. `H \ G / K`. We also prove that `G` can be written as a disjoint
union of the double cosets and that if one of `H` or `K` is the trivial group (i.e. `⊥` ) then
this is the usual left or right quotient of a group by a subgroup.
## Main definitions
* `setoid`: The double coset relation defined by two subgroups `H K` of `G`.
* `DoubleCoset.quotient`: The quotient of `G` by the double coset relation, i.e, `H \ G / K`.
-/
assert_not_exists MonoidWithZero
variable {G : Type*} [Group G] {α : Type*} [Mul α]
open MulOpposite
open scoped Pointwise
namespace DoubleCoset
/-- The double coset as an element of `Set α` corresponding to `s a t` -/
def doubleCoset (a : α) (s t : Set α) : Set α :=
s * {a} * t
@[deprecated (since := "2025-07-12")] alias _root_.Doset.doset := doubleCoset
lemma doubleCoset_eq_image2 (a : α) (s t : Set α) :
doubleCoset a s t = Set.image2 (· * a * ·) s t := by
simp_rw [doubleCoset, Set.mul_singleton, ← Set.image2_mul, Set.image2_image_left]
@[deprecated (since := "2025-07-12")] alias _root_.Doset.doset_eq_image2 := doubleCoset_eq_image2
theorem mem_doubleCoset {s t : Set α} {a b : α} :
b ∈ doubleCoset a s t ↔ ∃ x ∈ s, ∃ y ∈ t, b = x * a * y := by
simp only [doubleCoset_eq_image2, Set.mem_image2, eq_comm]
@[deprecated (since := "2025-07-12")] alias _root_.Doset.mem_doset := mem_doubleCoset
theorem mem_doubleCoset_self (H K : Subgroup G) (a : G) : a ∈ doubleCoset a H K :=
mem_doubleCoset.mpr ⟨1, H.one_mem, 1, K.one_mem, (one_mul a).symm.trans (mul_one (1 * a)).symm⟩
@[deprecated (since := "2025-07-12")] alias _root_.Doset.mem_doset_self := mem_doubleCoset_self
theorem doubleCoset_eq_of_mem {H K : Subgroup G} {a b : G} (hb : b ∈ doubleCoset a H K) :
doubleCoset b H K = doubleCoset a H K := by
obtain ⟨h, hh, k, hk, rfl⟩ := mem_doubleCoset.1 hb
rw [doubleCoset, doubleCoset, ← Set.singleton_mul_singleton, ← Set.singleton_mul_singleton,
mul_assoc, mul_assoc, Subgroup.singleton_mul_subgroup hk, ← mul_assoc, ← mul_assoc,
Subgroup.subgroup_mul_singleton hh]
@[deprecated (since := "2025-07-12")] alias _root_.Doset.doset_eq_of_mem := doubleCoset_eq_of_mem
theorem mem_doubleCoset_of_not_disjoint {H K : Subgroup G} {a b : G}
(h : ¬Disjoint (doubleCoset a H K) (doubleCoset b H K)) : b ∈ doubleCoset a H K := by
rw [Set.not_disjoint_iff] at h
simp only [mem_doubleCoset] at *
obtain ⟨x, ⟨l, hl, r, hr, hrx⟩, y, hy, ⟨r', hr', rfl⟩⟩ := h
refine ⟨y⁻¹ * l, H.mul_mem (H.inv_mem hy) hl, r * r'⁻¹, K.mul_mem hr (K.inv_mem hr'), ?_⟩
rwa [mul_assoc, mul_assoc, eq_inv_mul_iff_mul_eq, ← mul_assoc, ← mul_assoc, eq_mul_inv_iff_mul_eq]
@[deprecated (since := "2025-07-12")]
alias _root_.Doset.mem_doset_of_not_disjoint := mem_doubleCoset_of_not_disjoint
theorem eq_of_not_disjoint {H K : Subgroup G} {a b : G}
(h : ¬Disjoint (doubleCoset a H K) (doubleCoset b H K)) :
doubleCoset a H K = doubleCoset b H K := by
rw [disjoint_comm] at h
have ha : a ∈ doubleCoset b H K := mem_doubleCoset_of_not_disjoint h
apply doubleCoset_eq_of_mem ha
@[deprecated (since := "2025-07-12")]
alias _root_.Doset.eq_of_not_disjoint := eq_of_not_disjoint
/-- The setoid defined by the double_coset relation -/
def setoid (H K : Set G) : Setoid G :=
Setoid.ker fun x => doubleCoset x H K
@[deprecated (since := "2025-07-12")]
alias _root_.Doset.setoid := setoid
/-- Quotient of `G` by the double coset relation, i.e. `H \ G / K` -/
def Quotient (H K : Set G) : Type _ :=
_root_.Quotient (setoid H K)
@[deprecated (since := "2025-07-12")]
alias _root_.Doset.Quotient := Quotient
theorem rel_iff {H K : Subgroup G} {x y : G} :
setoid ↑H ↑K x y ↔ ∃ a ∈ H, ∃ b ∈ K, y = a * x * b :=
Iff.trans
⟨fun (hxy : doubleCoset x H K = doubleCoset y H K) => hxy ▸ mem_doubleCoset_self H K y,
fun hxy => (doubleCoset_eq_of_mem hxy).symm⟩ mem_doubleCoset
@[deprecated (since := "2025-07-12")]
alias _root_.Doset.rel_iff := rel_iff
theorem bot_rel_eq_leftRel (H : Subgroup G) :
⇑(setoid ↑(⊥ : Subgroup G) ↑H) = ⇑(QuotientGroup.leftRel H) := by
ext a b
rw [rel_iff, QuotientGroup.leftRel_apply]
constructor
· rintro ⟨a, rfl : a = 1, b, hb, rfl⟩
rwa [one_mul, inv_mul_cancel_left]
· rintro (h : a⁻¹ * b ∈ H)
exact ⟨1, rfl, a⁻¹ * b, h, by rw [one_mul, mul_inv_cancel_left]⟩
@[deprecated (since := "2025-07-12")]
alias _root_.Doset.bot_rel_eq_leftRel := bot_rel_eq_leftRel
theorem rel_bot_eq_right_group_rel (H : Subgroup G) :
⇑(setoid ↑H ↑(⊥ : Subgroup G)) = ⇑(QuotientGroup.rightRel H) := by
ext a b
rw [rel_iff, QuotientGroup.rightRel_apply]
constructor
· rintro ⟨b, hb, a, rfl : a = 1, rfl⟩
rwa [mul_one, mul_inv_cancel_right]
· rintro (h : b * a⁻¹ ∈ H)
exact ⟨b * a⁻¹, h, 1, rfl, by rw [mul_one, inv_mul_cancel_right]⟩
@[deprecated (since := "2025-07-12")]
alias _root_.Doset.rel_bot_eq_right_group_rel := rel_bot_eq_right_group_rel
/-- Create a double coset out of an element of `H \ G / K` -/
def quotToDoubleCoset (H K : Subgroup G) (q : Quotient (H : Set G) K) : Set G :=
doubleCoset q.out H K
@[deprecated (since := "2025-07-12")] alias _root_.Doset.quotToDoset := quotToDoubleCoset
/-- Map from `G` to `H \ G / K` -/
abbrev mk (H K : Subgroup G) (a : G) : Quotient (H : Set G) K :=
Quotient.mk'' a
@[deprecated (since := "2025-07-12")] alias _root_.Doset.mk := mk
instance (H K : Subgroup G) : Inhabited (Quotient (H : Set G) K) :=
⟨mk H K (1 : G)⟩
theorem eq (H K : Subgroup G) (a b : G) :
mk H K a = mk H K b ↔ ∃ h ∈ H, ∃ k ∈ K, b = h * a * k := by
rw [Quotient.eq'']
apply rel_iff
@[deprecated (since := "2025-07-12")] alias _root_.Doset.eq := eq
theorem out_eq' (H K : Subgroup G) (q : Quotient ↑H ↑K) : mk H K q.out = q :=
Quotient.out_eq' q
@[deprecated (since := "2025-07-12")] alias _root_.Doset.out_eq' := out_eq'
theorem mk_out_eq_mul (H K : Subgroup G) (g : G) :
∃ h k : G, h ∈ H ∧ k ∈ K ∧ (mk H K g : Quotient ↑H ↑K).out = h * g * k := by
have := eq H K (mk H K g : Quotient ↑H ↑K).out g
rw [out_eq'] at this
obtain ⟨h, h_h, k, hk, T⟩ := this.1 rfl
refine ⟨h⁻¹, k⁻¹, H.inv_mem h_h, K.inv_mem hk, eq_mul_inv_of_mul_eq (eq_inv_mul_of_mul_eq ?_)⟩
rw [← mul_assoc, ← T]
@[deprecated (since := "2025-07-12")] alias _root_.Doset.mk_out_eq_mul := mk_out_eq_mul
theorem mk_eq_of_doubleCoset_eq {H K : Subgroup G} {a b : G}
(h : doubleCoset a H K = doubleCoset b H K) : mk H K a = mk H K b := by
rw [eq]
exact mem_doubleCoset.mp (h.symm ▸ mem_doubleCoset_self H K b)
@[deprecated (since := "2025-07-12")]
alias _root_.Doset.mk_eq_of_doset_eq := mk_eq_of_doubleCoset_eq
theorem disjoint_out {H K : Subgroup G} {a b : Quotient H K} :
a ≠ b → Disjoint (doubleCoset a.out H K) (doubleCoset b.out (H : Set G) K) := by
contrapose!
intro h
simpa [out_eq'] using mk_eq_of_doubleCoset_eq (eq_of_not_disjoint h)
@[deprecated (since := "2025-07-12")] alias _root_.Doset.disjoint_out := disjoint_out
theorem union_quotToDoubleCoset (H K : Subgroup G) : ⋃ q, quotToDoubleCoset H K q = Set.univ := by
ext x
simp only [Set.mem_iUnion, quotToDoubleCoset, mem_doubleCoset, SetLike.mem_coe, Set.mem_univ,
iff_true]
use mk H K x
obtain ⟨h, k, h3, h4, h5⟩ := mk_out_eq_mul H K x
refine ⟨h⁻¹, H.inv_mem h3, k⁻¹, K.inv_mem h4, ?_⟩
simp only [h5, ← mul_assoc, one_mul, inv_mul_cancel, mul_inv_cancel_right]
@[deprecated (since := "2025-07-12")]
alias _root_.Doset.union_quotToDoset := union_quotToDoubleCoset
theorem doubleCoset_union_rightCoset (H K : Subgroup G) (a : G) :
⋃ k : K, op (a * k) • ↑H = doubleCoset a H K := by
ext x
simp only [mem_rightCoset_iff, mul_inv_rev, Set.mem_iUnion, mem_doubleCoset,
SetLike.mem_coe]
constructor
· rintro ⟨y, h_h⟩
refine ⟨x * (y⁻¹ * a⁻¹), h_h, y, y.2, ?_⟩
simp only [← mul_assoc, inv_mul_cancel_right, InvMemClass.coe_inv]
· rintro ⟨x, hx, y, hy, hxy⟩
refine ⟨⟨y, hy⟩, ?_⟩
simp only [hxy, ← mul_assoc, hx, mul_inv_cancel_right]
@[deprecated (since := "2025-07-12")]
alias _root_.Doset.doset_union_rightCoset := doubleCoset_union_rightCoset
theorem doubleCoset_union_leftCoset (H K : Subgroup G) (a : G) :
⋃ h : H, (h * a : G) • ↑K = doubleCoset a H K := by
ext x
simp only [mem_leftCoset_iff, mul_inv_rev, Set.mem_iUnion, mem_doubleCoset]
constructor
· rintro ⟨y, h_h⟩
refine ⟨y, y.2, a⁻¹ * y⁻¹ * x, h_h, ?_⟩
simp only [← mul_assoc, one_mul, mul_inv_cancel, mul_inv_cancel_right, InvMemClass.coe_inv]
· rintro ⟨x, hx, y, hy, hxy⟩
refine ⟨⟨x, hx⟩, ?_⟩
simp only [hxy, ← mul_assoc, hy, one_mul, inv_mul_cancel, inv_mul_cancel_right]
@[deprecated (since := "2025-07-12")]
alias _root_.Doset.doset_union_leftCoset := doubleCoset_union_leftCoset
theorem left_bot_eq_left_quot (H : Subgroup G) :
Quotient (⊥ : Subgroup G) (H : Set G) = (G ⧸ H) := by
unfold Quotient
congr
ext
simp_rw [← bot_rel_eq_leftRel H]
@[deprecated (since := "2025-07-12")]
alias _root_.Doset.left_bot_eq_left_quot := left_bot_eq_left_quot
theorem right_bot_eq_right_quot (H : Subgroup G) :
Quotient (H : Set G) (⊥ : Subgroup G) = _root_.Quotient (QuotientGroup.rightRel H) := by
unfold Quotient
congr
ext
simp_rw [← rel_bot_eq_right_group_rel H]
@[deprecated (since := "2025-07-12")]
alias _root_.Doset.right_bot_eq_right_quot := right_bot_eq_right_quot
end DoubleCoset |
.lake/packages/mathlib/Mathlib/GroupTheory/SchurZassenhaus.lean | import Mathlib.GroupTheory.Transfer
/-!
# The Schur-Zassenhaus Theorem
In this file we prove the Schur-Zassenhaus theorem.
## Main results
- `Subgroup.exists_right_complement'_of_coprime`: The **Schur-Zassenhaus** theorem:
If `H : Subgroup G` is normal and has order coprime to its index,
then there exists a subgroup `K` which is a (right) complement of `H`.
- `Subgroup.exists_left_complement'_of_coprime`: The **Schur-Zassenhaus** theorem:
If `H : Subgroup G` is normal and has order coprime to its index,
then there exists a subgroup `K` which is a (left) complement of `H`.
-/
namespace Subgroup
section SchurZassenhausAbelian
open MulOpposite MulAction Subgroup.leftTransversals
variable {G : Type*} [Group G] (H : Subgroup G) [IsMulCommutative H] [FiniteIndex H]
(α β : H.LeftTransversal)
/-- The quotient of the transversals of an abelian normal `N` by the `diff` relation. -/
def QuotientDiff :=
Quotient
(Setoid.mk (fun α β => diff (MonoidHom.id H) α β = 1)
⟨fun α => diff_self (MonoidHom.id H) α, fun h => by rw [← diff_inv, h, inv_one],
fun h h' => by rw [← diff_mul_diff, h, h', one_mul]⟩)
instance : Inhabited H.QuotientDiff :=
inferInstanceAs (Inhabited <| Quotient _)
theorem smul_diff_smul' [hH : Normal H] (g : Gᵐᵒᵖ) :
diff (MonoidHom.id H) (g • α) (g • β) =
⟨g.unop⁻¹ * (diff (MonoidHom.id H) α β : H) * g.unop,
hH.mem_comm ((congr_arg (· ∈ H) (mul_inv_cancel_left _ _)).mpr (SetLike.coe_mem _))⟩ := by
letI := H.fintypeQuotientOfFiniteIndex
let ϕ : H →* H :=
{ toFun := fun h =>
⟨g.unop⁻¹ * h * g.unop,
hH.mem_comm ((congr_arg (· ∈ H) (mul_inv_cancel_left _ _)).mpr (SetLike.coe_mem _))⟩
map_one' := by rw [Subtype.ext_iff, coe_mk, coe_one, mul_one, inv_mul_cancel]
map_mul' := fun h₁ h₂ => by
simp only [Subtype.ext_iff, coe_mul, mul_assoc, mul_inv_cancel_left] }
refine (Fintype.prod_equiv (MulAction.toPerm g).symm _ _ fun x ↦ ?_).trans (map_prod ϕ _ _).symm
simp only [ϕ, smul_apply_eq_smul_apply_inv_smul, smul_eq_mul_unop, mul_inv_rev, mul_assoc,
MonoidHom.id_apply, toPerm_symm_apply, MonoidHom.coe_mk, OneHom.coe_mk]
variable {H}
variable [Normal H]
noncomputable instance : MulAction G H.QuotientDiff where
smul g :=
Quotient.map' (fun α => op g⁻¹ • α) fun α β h =>
Subtype.ext
(by
rwa [smul_diff_smul', coe_mk, coe_one, mul_eq_one_iff_eq_inv, mul_eq_left, ←
coe_one, ← Subtype.ext_iff])
mul_smul g₁ g₂ q :=
Quotient.inductionOn' q fun T =>
congr_arg Quotient.mk'' (by rw [mul_inv_rev]; exact mul_smul (op g₁⁻¹) (op g₂⁻¹) T)
one_smul q :=
Quotient.inductionOn' q fun T =>
congr_arg Quotient.mk'' (by rw [inv_one]; apply one_smul Gᵐᵒᵖ T)
theorem smul_diff' (h : H) :
diff (MonoidHom.id H) α (op (h : G) • β) = diff (MonoidHom.id H) α β * h ^ H.index := by
letI := H.fintypeQuotientOfFiniteIndex
rw [diff, diff, index_eq_card, Nat.card_eq_fintype_card,
← Finset.card_univ, ← Finset.prod_const, ← Finset.prod_mul_distrib]
refine Finset.prod_congr rfl fun q _ => ?_
simp_rw [Subtype.ext_iff, MonoidHom.id_apply, coe_mul, mul_assoc, mul_right_inj]
rw [smul_apply_eq_smul_apply_inv_smul, smul_eq_mul_unop, MulOpposite.unop_op, mul_left_inj,
← Subtype.ext_iff, Equiv.apply_eq_iff_eq, inv_smul_eq_iff]
exact left_eq_mul.mpr ((QuotientGroup.eq_one_iff _).mpr h.2)
theorem eq_one_of_smul_eq_one (hH : Nat.Coprime (Nat.card H) H.index) (α : H.QuotientDiff)
(h : H) : h • α = α → h = 1 :=
Quotient.inductionOn' α fun α hα =>
(powCoprime hH).injective <|
calc
h ^ H.index = diff (MonoidHom.id H) (op ((h⁻¹ : H) : G) • α) α := by
rw [← diff_inv, smul_diff', diff_self, one_mul, inv_pow, inv_inv]
_ = 1 ^ H.index := (Quotient.exact' hα).trans (one_pow H.index).symm
theorem exists_smul_eq (hH : Nat.Coprime (Nat.card H) H.index) (α β : H.QuotientDiff) :
∃ h : H, h • α = β :=
Quotient.inductionOn' α
(Quotient.inductionOn' β fun β α =>
Exists.imp (fun _ => Quotient.sound')
⟨(powCoprime hH).symm (diff (MonoidHom.id H) β α),
(diff_inv _ _ _).symm.trans
(inv_eq_one.mpr
((smul_diff' β α ((powCoprime hH).symm (diff (MonoidHom.id H) β α))⁻¹).trans
(by rw [inv_pow, ← powCoprime_apply hH, Equiv.apply_symm_apply, mul_inv_cancel])))⟩)
theorem isComplement'_stabilizer_of_coprime {α : H.QuotientDiff}
(hH : Nat.Coprime (Nat.card H) H.index) : IsComplement' H (stabilizer G α) :=
isComplement'_stabilizer α (eq_one_of_smul_eq_one hH α) fun g => exists_smul_eq hH (g • α) α
/-- Do not use this lemma: It is made obsolete by `exists_right_complement'_of_coprime` -/
private theorem exists_right_complement'_of_coprime_aux (hH : Nat.Coprime (Nat.card H) H.index) :
∃ K : Subgroup G, IsComplement' H K :=
have ne : Nonempty (QuotientDiff H) := inferInstance
ne.elim fun α => ⟨stabilizer G α, isComplement'_stabilizer_of_coprime hH⟩
end SchurZassenhausAbelian
universe u
namespace SchurZassenhausInduction
/-! ## Proof of the Schur-Zassenhaus theorem
In this section, we prove the Schur-Zassenhaus theorem.
The proof is by contradiction. We assume that `G` is a minimal counterexample to the theorem.
-/
variable {G : Type u} [Group G] {N : Subgroup G} [Normal N]
(h1 : Nat.Coprime (Nat.card N) N.index)
(h2 : ∀ (G' : Type u) [Group G'] [Finite G'],
Nat.card G' < Nat.card G → ∀ {N' : Subgroup G'} [N'.Normal],
Nat.Coprime (Nat.card N') N'.index → ∃ H' : Subgroup G', IsComplement' N' H')
(h3 : ∀ H : Subgroup G, ¬IsComplement' N H)
include h1 h3
/-! We will arrive at a contradiction via the following steps:
* step 0: `N` (the normal Hall subgroup) is nontrivial.
* step 1: If `K` is a subgroup of `G` with `K ⊔ N = ⊤`, then `K = ⊤`.
* step 2: `N` is a minimal normal subgroup, phrased in terms of subgroups of `G`.
* step 3: `N` is a minimal normal subgroup, phrased in terms of subgroups of `N`.
* step 4: `p` (`min_fact (Fintype.card N)`) is prime (follows from step0).
* step 5: `P` (a Sylow `p`-subgroup of `N`) is nontrivial.
* step 6: `N` is a `p`-group (applies step 1 to the normalizer of `P` in `G`).
* step 7: `N` is abelian (applies step 3 to the center of `N`).
-/
/-- Do not use this lemma: It is made obsolete by `exists_right_complement'_of_coprime` -/
private theorem step0 : N ≠ ⊥ := by
rintro rfl
exact h3 ⊤ isComplement'_bot_top
variable [Finite G]
include h2 in
/-- Do not use this lemma: It is made obsolete by `exists_right_complement'_of_coprime` -/
private theorem step1 (K : Subgroup G) (hK : K ⊔ N = ⊤) : K = ⊤ := by
contrapose! h3
have h4 : (N.comap K.subtype).index = N.index := by
rw [← N.relIndex_top_right, ← hK]
exact (relIndex_sup_right K N).symm
have h5 : Nat.card K < Nat.card G := by
rw [← K.index_mul_card]
exact lt_mul_of_one_lt_left Nat.card_pos (one_lt_index_of_ne_top h3)
have h6 : Nat.Coprime (Nat.card (N.comap K.subtype)) (N.comap K.subtype).index := by
rw [h4]
exact h1.coprime_dvd_left (card_comap_dvd_of_injective N K.subtype Subtype.coe_injective)
obtain ⟨H, hH⟩ := h2 K h5 h6
replace hH : Nat.card (H.map K.subtype) = N.index := by
rw [← relIndex_bot_left, ← relIndex_comap, MonoidHom.comap_bot, Subgroup.ker_subtype,
relIndex_bot_left, ← IsComplement'.index_eq_card (IsComplement'.symm hH), index_comap,
range_subtype, ← relIndex_sup_right, hK, relIndex_top_right]
have h7 : Nat.card N * Nat.card (H.map K.subtype) = Nat.card G := by
rw [hH, ← N.index_mul_card, mul_comm]
have h8 : (Nat.card N).Coprime (Nat.card (H.map K.subtype)) := by
rwa [hH]
exact ⟨H.map K.subtype, isComplement'_of_coprime h7 h8⟩
include h2 in
/-- Do not use this lemma: It is made obsolete by `exists_right_complement'_of_coprime` -/
private theorem step2 (K : Subgroup G) [K.Normal] (hK : K ≤ N) : K = ⊥ ∨ K = N := by
have : Function.Surjective (QuotientGroup.mk' K) := Quotient.mk''_surjective
have h4 := step1 h1 h2 h3
contrapose! h4
have h5 : Nat.card (G ⧸ K) < Nat.card G := by
rw [← index_eq_card, ← K.index_mul_card]
refine
lt_mul_of_one_lt_right (Nat.pos_of_ne_zero index_ne_zero_of_finite)
(K.one_lt_card_iff_ne_bot.mpr h4.1)
have h6 :
(Nat.card (N.map (QuotientGroup.mk' K))).Coprime (N.map (QuotientGroup.mk' K)).index := by
have index_map := N.index_map_eq this (by rwa [QuotientGroup.ker_mk'])
have index_pos : 0 < N.index := Nat.pos_of_ne_zero index_ne_zero_of_finite
rw [index_map]
refine h1.coprime_dvd_left ?_
rw [← Nat.mul_dvd_mul_iff_left index_pos, index_mul_card, ← index_map, index_mul_card]
exact K.card_quotient_dvd_card
obtain ⟨H, hH⟩ := h2 (G ⧸ K) h5 h6
refine ⟨H.comap (QuotientGroup.mk' K), ?_, ?_⟩
· have key : (N.map (QuotientGroup.mk' K)).comap (QuotientGroup.mk' K) = N := by
refine comap_map_eq_self ?_
rwa [QuotientGroup.ker_mk']
rwa [← key, comap_sup_eq, hH.symm.sup_eq_top, comap_top]
· rw [← comap_top (QuotientGroup.mk' K)]
intro hH'
rw [comap_injective this hH', isComplement'_top_right, map_eq_bot_iff,
QuotientGroup.ker_mk'] at hH
exact h4.2 (le_antisymm hK hH)
include h2 in
/-- Do not use this lemma: It is made obsolete by `exists_right_complement'_of_coprime` -/
private theorem step3 (K : Subgroup N) [(K.map N.subtype).Normal] : K = ⊥ ∨ K = ⊤ := by
have key := step2 h1 h2 h3 (K.map N.subtype) (map_subtype_le K)
rw [← map_bot N.subtype] at key
conv at key =>
rhs
rhs
rw [← N.range_subtype, N.subtype.range_eq_map]
have inj := map_injective N.subtype_injective
rwa [inj.eq_iff, inj.eq_iff] at key
/-- Do not use this lemma: It is made obsolete by `exists_right_complement'_of_coprime` -/
private theorem step4 : (Nat.card N).minFac.Prime :=
Nat.minFac_prime (N.one_lt_card_iff_ne_bot.mpr (step0 h1 h3)).ne'
/-- Do not use this lemma: It is made obsolete by `exists_right_complement'_of_coprime` -/
private theorem step5 {P : Sylow (Nat.card N).minFac N} : P.1 ≠ ⊥ := by
haveI : Fact (Nat.card N).minFac.Prime := ⟨step4 h1 h3⟩
apply P.ne_bot_of_dvd_card
exact (Nat.card N).minFac_dvd
include h2 in
/-- Do not use this lemma: It is made obsolete by `exists_right_complement'_of_coprime` -/
private theorem step6 : IsPGroup (Nat.card N).minFac N := by
haveI : Fact (Nat.card N).minFac.Prime := ⟨step4 h1 h3⟩
refine Sylow.nonempty.elim fun P => P.2.of_surjective P.1.subtype ?_
rw [← MonoidHom.range_eq_top, range_subtype]
haveI : (P.1.map N.subtype).Normal :=
normalizer_eq_top_iff.mp (step1 h1 h2 h3 (P.map N.subtype).normalizer P.normalizer_sup_eq_top)
exact (step3 h1 h2 h3 P.1).resolve_left (step5 h1 h3)
include h2 in
/-- Do not use this lemma: It is made obsolete by `exists_right_complement'_of_coprime` -/
theorem step7 : IsMulCommutative N := by
haveI := N.bot_or_nontrivial.resolve_left (step0 h1 h3)
haveI : Fact (Nat.card N).minFac.Prime := ⟨step4 h1 h3⟩
exact
⟨⟨fun g h => ((eq_top_iff.mp ((step3 h1 h2 h3 (center N)).resolve_left
(step6 h1 h2 h3).bot_lt_center.ne') (mem_top h)).comm g).symm⟩⟩
end SchurZassenhausInduction
variable {n : ℕ} {G : Type u} [Group G]
/-- Do not use this lemma: It is made obsolete by `exists_right_complement'_of_coprime` -/
private theorem exists_right_complement'_of_coprime_aux' [Finite G] (hG : Nat.card G = n)
{N : Subgroup G} [N.Normal] (hN : Nat.Coprime (Nat.card N) N.index) :
∃ H : Subgroup G, IsComplement' N H := by
revert G
induction n using Nat.strongRecOn with | ind n ih => ?_
rintro G _ _ rfl N _ hN
refine not_forall_not.mp fun h3 => ?_
haveI := SchurZassenhausInduction.step7 hN (fun G' _ _ hG' => by apply ih _ hG'; rfl) h3
exact not_exists_of_forall_not h3 (exists_right_complement'_of_coprime_aux hN)
/-- **Schur-Zassenhaus** for normal subgroups:
If `H : Subgroup G` is normal, and has order coprime to its index, then there exists a
subgroup `K` which is a (right) complement of `H`. -/
theorem exists_right_complement'_of_coprime {N : Subgroup G} [N.Normal]
(hN : Nat.Coprime (Nat.card N) N.index) : ∃ H : Subgroup G, IsComplement' N H := by
by_cases hN1 : Nat.card N = 0
· rw [hN1, Nat.coprime_zero_left, index_eq_one] at hN
rw [hN]
exact ⟨⊥, isComplement'_top_bot⟩
by_cases hN2 : N.index = 0
· rw [hN2, Nat.coprime_zero_right] at hN
haveI := (Cardinal.toNat_eq_one_iff_unique.mp hN).1
rw [N.eq_bot_of_subsingleton]
exact ⟨⊤, isComplement'_bot_top⟩
have hN3 : Nat.card G ≠ 0 := by
rw [← N.card_mul_index]
exact mul_ne_zero hN1 hN2
haveI := (Cardinal.lt_aleph0_iff_fintype.mp
(lt_of_not_ge (mt Cardinal.toNat_apply_of_aleph0_le hN3))).some
exact exists_right_complement'_of_coprime_aux' rfl hN
/-- **Schur-Zassenhaus** for normal subgroups:
If `H : Subgroup G` is normal, and has order coprime to its index, then there exists a
subgroup `K` which is a (left) complement of `H`. -/
theorem exists_left_complement'_of_coprime {N : Subgroup G} [N.Normal]
(hN : Nat.Coprime (Nat.card N) N.index) : ∃ H : Subgroup G, IsComplement' H N :=
Exists.imp (fun _ => IsComplement'.symm) (exists_right_complement'_of_coprime hN)
end Subgroup |
.lake/packages/mathlib/Mathlib/GroupTheory/PresentedGroup.lean | import Mathlib.Algebra.Group.Subgroup.Basic
import Mathlib.GroupTheory.FreeGroup.Basic
import Mathlib.GroupTheory.QuotientGroup.Defs
/-!
# Defining a group given by generators and relations
Given a subset `rels` of relations of the free group on a type `α`, this file constructs the group
given by generators `x : α` and relations `r ∈ rels`.
## Main definitions
* `PresentedGroup rels`: the quotient group of the free group on a type `α` by a subset `rels` of
relations of the free group on `α`.
* `of`: The canonical map from `α` to a presented group with generators `α`.
* `toGroup f`: the canonical group homomorphism `PresentedGroup rels → G`, given a function
`f : α → G` from a type `α` to a group `G` which satisfies the relations `rels`.
## Tags
generators, relations, group presentations
-/
variable {α : Type*}
/-- Given a set of relations, `rels`, over a type `α`, `PresentedGroup` constructs the group with
generators `x : α` and relations `rels` as a quotient of `FreeGroup α`. -/
def PresentedGroup (rels : Set (FreeGroup α)) :=
FreeGroup α ⧸ Subgroup.normalClosure rels
namespace PresentedGroup
instance (rels : Set (FreeGroup α)) : Group (PresentedGroup rels) :=
QuotientGroup.Quotient.group _
/-- The canonical map from the free group on `α` to a presented group with generators `x : α`,
where `x` is mapped to its equivalence class under the given set of relations `rels` -/
def mk (rels : Set (FreeGroup α)) : FreeGroup α →* PresentedGroup rels :=
⟨⟨QuotientGroup.mk, rfl⟩, fun _ _ => rfl⟩
theorem mk_surjective (rels : Set (FreeGroup α)) : Function.Surjective <| mk rels :=
QuotientGroup.mk_surjective
/-- `of` is the canonical map from `α` to a presented group with generators `x : α`. The term `x` is
mapped to the equivalence class of the image of `x` in `FreeGroup α`. -/
def of {rels : Set (FreeGroup α)} (x : α) : PresentedGroup rels :=
mk rels (FreeGroup.of x)
lemma mk_eq_one_iff {rels : Set (FreeGroup α)} {x : FreeGroup α} :
mk rels x = 1 ↔ x ∈ Subgroup.normalClosure rels :=
QuotientGroup.eq_one_iff _
lemma one_of_mem {rels : Set (FreeGroup α)} {x : FreeGroup α} (hx : x ∈ rels) :
mk rels x = 1 :=
mk_eq_one_iff.mpr <| Subgroup.subset_normalClosure hx
lemma mk_eq_mk_of_mul_inv_mem {rels : Set (FreeGroup α)} {x y : FreeGroup α}
(hx : x * y⁻¹ ∈ rels) : mk rels x = mk rels y :=
eq_of_mul_inv_eq_one <| one_of_mem hx
lemma mk_eq_mk_of_inv_mul_mem {rels : Set (FreeGroup α)} {x y : FreeGroup α}
(hx : x⁻¹ * y ∈ rels) : mk rels x = mk rels y :=
eq_of_inv_mul_eq_one <| one_of_mem hx
/-- The generators of a presented group generate the presented group. That is, the subgroup closure
of the set of generators equals `⊤`. -/
@[simp]
theorem closure_range_of (rels : Set (FreeGroup α)) :
Subgroup.closure (Set.range (PresentedGroup.of : α → PresentedGroup rels)) = ⊤ := by
have : (PresentedGroup.of : α → PresentedGroup rels) = QuotientGroup.mk' _ ∘ FreeGroup.of := rfl
rw [this, Set.range_comp, ← MonoidHom.map_closure (QuotientGroup.mk' _),
FreeGroup.closure_range_of, ← MonoidHom.range_eq_map]
exact MonoidHom.range_eq_top.2 (QuotientGroup.mk'_surjective _)
@[induction_eliminator]
theorem induction_on {rels : Set (FreeGroup α)} {C : PresentedGroup rels → Prop}
(x : PresentedGroup rels) (H : ∀ z, C (mk rels z)) : C x :=
Quotient.inductionOn' x H
theorem generated_by (rels : Set (FreeGroup α)) (H : Subgroup (PresentedGroup rels))
(h : ∀ j : α, PresentedGroup.of j ∈ H) (x : PresentedGroup rels) : x ∈ H := by
obtain ⟨z⟩ := x
induction z
· exact one_mem H
· exact h _
· exact (Subgroup.inv_mem_iff H).mpr (by assumption)
rename_i h1 h2
change QuotientGroup.mk _ ∈ H.carrier
rw [QuotientGroup.mk_mul]
exact Subgroup.mul_mem _ h1 h2
section ToGroup
/-
Presented groups satisfy a universal property. If `G` is a group and `f : α → G` is a map such that
the images of `f` satisfy all the given relations, then `f` extends uniquely to a group homomorphism
from `PresentedGroup rels` to `G`.
-/
variable {G : Type*} [Group G] {f : α → G} {rels : Set (FreeGroup α)}
local notation "F" => FreeGroup.lift f
theorem closure_rels_subset_ker (h : ∀ r ∈ rels, FreeGroup.lift f r = 1) :
Subgroup.normalClosure rels ≤ MonoidHom.ker F :=
Subgroup.normalClosure_le_normal fun x w ↦ MonoidHom.mem_ker.2 (h x w)
theorem to_group_eq_one_of_mem_closure (h : ∀ r ∈ rels, FreeGroup.lift f r = 1) :
∀ x ∈ Subgroup.normalClosure rels, F x = 1 :=
fun _ w ↦ MonoidHom.mem_ker.1 <| closure_rels_subset_ker h w
/-- The extension of a map `f : α → G` that satisfies the given relations to a group homomorphism
from `PresentedGroup rels → G`. -/
def toGroup (h : ∀ r ∈ rels, FreeGroup.lift f r = 1) : PresentedGroup rels →* G :=
QuotientGroup.lift (Subgroup.normalClosure rels) F (to_group_eq_one_of_mem_closure h)
@[simp]
theorem toGroup.of (h : ∀ r ∈ rels, FreeGroup.lift f r = 1) {x : α} : toGroup h (of x) = f x :=
FreeGroup.lift_apply_of
theorem toGroup.unique (h : ∀ r ∈ rels, FreeGroup.lift f r = 1) (g : PresentedGroup rels →* G)
(hg : ∀ x : α, g (PresentedGroup.of x) = f x) : ∀ {x}, g x = toGroup h x := by
intro x
refine QuotientGroup.induction_on x ?_
exact fun _ ↦ FreeGroup.lift_unique (g.comp (QuotientGroup.mk' _)) hg
@[ext]
theorem ext {φ ψ : PresentedGroup rels →* G} (hx : ∀ (x : α), φ (.of x) = ψ (.of x)) : φ = ψ := by
unfold PresentedGroup
ext
apply hx
variable {β : Type*}
/-- Presented groups of isomorphic types are isomorphic. -/
def equivPresentedGroup (rels : Set (FreeGroup α)) (e : α ≃ β) :
PresentedGroup rels ≃* PresentedGroup (FreeGroup.freeGroupCongr e '' rels) :=
QuotientGroup.congr (Subgroup.normalClosure rels)
(Subgroup.normalClosure ((FreeGroup.freeGroupCongr e) '' rels)) (FreeGroup.freeGroupCongr e)
(Subgroup.map_normalClosure rels (FreeGroup.freeGroupCongr e).toMonoidHom
(FreeGroup.freeGroupCongr e).surjective)
theorem equivPresentedGroup_apply_of (x : α) (rels : Set (FreeGroup α)) (e : α ≃ β) :
equivPresentedGroup rels e (PresentedGroup.of x) =
PresentedGroup.of (rels := FreeGroup.freeGroupCongr e '' rels) (e x) := rfl
theorem equivPresentedGroup_symm_apply_of (x : β) (rels : Set (FreeGroup α)) (e : α ≃ β) :
(equivPresentedGroup rels e).symm (PresentedGroup.of x) =
PresentedGroup.of (rels := rels) (e.symm x) := rfl
end ToGroup
instance (rels : Set (FreeGroup α)) : Inhabited (PresentedGroup rels) :=
⟨1⟩
end PresentedGroup |
.lake/packages/mathlib/Mathlib/GroupTheory/CommutingProbability.lean | import Mathlib.Algebra.BigOperators.Fin
import Mathlib.GroupTheory.Abelianization.Finite
import Mathlib.GroupTheory.SpecificGroups.Dihedral
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.LinearCombination
import Mathlib.Tactic.Qify
/-!
# Commuting Probability
This file introduces the commuting probability of finite groups.
## Main definitions
* `commProb`: The commuting probability of a finite type with a multiplication operation.
## TODO
* Neumann's theorem.
-/
assert_not_exists Ideal TwoSidedIdeal
noncomputable section
open Fintype
variable (M : Type*) [Mul M]
/-- The commuting probability of a finite type with a multiplication operation. -/
def commProb : ℚ :=
Nat.card { p : M × M // Commute p.1 p.2 } / (Nat.card M : ℚ) ^ 2
theorem commProb_def :
commProb M = Nat.card { p : M × M // Commute p.1 p.2 } / (Nat.card M : ℚ) ^ 2 :=
rfl
theorem commProb_prod (M' : Type*) [Mul M'] : commProb (M × M') = commProb M * commProb M' := by
simp_rw [commProb_def, div_mul_div_comm, Nat.card_prod, Nat.cast_mul, mul_pow, ← Nat.cast_mul,
← Nat.card_prod, Commute, SemiconjBy, Prod.ext_iff]
congr 2
exact Nat.card_congr ⟨fun x => ⟨⟨⟨x.1.1.1, x.1.2.1⟩, x.2.1⟩, ⟨⟨x.1.1.2, x.1.2.2⟩, x.2.2⟩⟩,
fun x => ⟨⟨⟨x.1.1.1, x.2.1.1⟩, ⟨x.1.1.2, x.2.1.2⟩⟩, ⟨x.1.2, x.2.2⟩⟩, fun x => rfl, fun x => rfl⟩
theorem commProb_pi {α : Type*} (i : α → Type*) [Fintype α] [∀ a, Mul (i a)] :
commProb (∀ a, i a) = ∏ a, commProb (i a) := by
simp_rw [commProb_def, Finset.prod_div_distrib, Finset.prod_pow, ← Nat.cast_prod,
← Nat.card_pi, Commute, SemiconjBy, funext_iff]
congr 2
exact Nat.card_congr ⟨fun x a => ⟨⟨x.1.1 a, x.1.2 a⟩, x.2 a⟩, fun x => ⟨⟨fun a => (x a).1.1,
fun a => (x a).1.2⟩, fun a => (x a).2⟩, fun x => rfl, fun x => rfl⟩
theorem commProb_function {α β : Type*} [Fintype α] [Mul β] :
commProb (α → β) = (commProb β) ^ Fintype.card α := by
rw [commProb_pi, Finset.prod_const, Finset.card_univ]
@[simp]
theorem commProb_eq_zero_of_infinite [Infinite M] : commProb M = 0 :=
div_eq_zero_iff.2 (Or.inl (Nat.cast_eq_zero.2 Nat.card_eq_zero_of_infinite))
variable [Finite M]
theorem commProb_pos [h : Nonempty M] : 0 < commProb M :=
h.elim fun x ↦
div_pos (Nat.cast_pos.mpr (Finite.card_pos_iff.mpr ⟨⟨(x, x), rfl⟩⟩))
(pow_pos (Nat.cast_pos.mpr Finite.card_pos) 2)
theorem commProb_le_one : commProb M ≤ 1 := by
refine div_le_one_of_le₀ ?_ (sq_nonneg (Nat.card M : ℚ))
rw [← Nat.cast_pow, Nat.cast_le, sq, ← Nat.card_prod]
apply Finite.card_subtype_le
variable {M}
theorem commProb_eq_one_iff [h : Nonempty M] :
commProb M = 1 ↔ Std.Commutative ((· * ·) : M → M → M) := by
classical
haveI := Fintype.ofFinite M
rw [commProb, ← Set.coe_setOf, Nat.card_eq_fintype_card, Nat.card_eq_fintype_card]
rw [div_eq_one_iff_eq, ← Nat.cast_pow, Nat.cast_inj, sq, ← card_prod,
set_fintype_card_eq_univ_iff, Set.eq_univ_iff_forall]
· exact ⟨fun h ↦ ⟨fun x y ↦ h (x, y)⟩, fun h x ↦ h.comm x.1 x.2⟩
· exact pow_ne_zero 2 (Nat.cast_ne_zero.mpr card_ne_zero)
variable (G : Type*) [Group G]
theorem commProb_def' : commProb G = Nat.card (ConjClasses G) / Nat.card G := by
rw [commProb, card_comm_eq_card_conjClasses_mul_card, Nat.cast_mul, sq]
by_cases h : (Nat.card G : ℚ) = 0
· rw [h, zero_mul, div_zero, div_zero]
· exact mul_div_mul_right _ _ h
variable {G}
variable [Finite G] (H : Subgroup G)
theorem Subgroup.commProb_subgroup_le : commProb H ≤ commProb G * (H.index : ℚ) ^ 2 := by
/- After rewriting with `commProb_def`, we reduce to showing that `G` has at least as many
commuting pairs as `H`. -/
rw [commProb_def, commProb_def, div_le_iff₀, mul_assoc, ← mul_pow, ← Nat.cast_mul,
mul_comm H.index, H.card_mul_index, div_mul_cancel₀, Nat.cast_le]
· refine Nat.card_le_card_of_injective (fun p ↦ ⟨⟨p.1.1, p.1.2⟩, Subtype.ext_iff.mp p.2⟩) ?_
exact fun p q h ↦ by simpa only [Subtype.ext_iff, Prod.ext_iff] using h
· exact pow_ne_zero 2 (Nat.cast_ne_zero.mpr Finite.card_pos.ne')
· exact pow_pos (Nat.cast_pos.mpr Finite.card_pos) 2
theorem Subgroup.commProb_quotient_le [H.Normal] : commProb (G ⧸ H) ≤ commProb G * Nat.card H := by
/- After rewriting with `commProb_def'`, we reduce to showing that `G` has at least as many
conjugacy classes as `G ⧸ H`. -/
rw [commProb_def', commProb_def', div_le_iff₀, mul_assoc, ← Nat.cast_mul, ← Subgroup.index,
H.card_mul_index, div_mul_cancel₀, Nat.cast_le]
· apply Nat.card_le_card_of_surjective
show Function.Surjective (ConjClasses.map (QuotientGroup.mk' H))
exact ConjClasses.map_surjective Quotient.mk''_surjective
· exact Nat.cast_ne_zero.mpr Finite.card_pos.ne'
· exact Nat.cast_pos.mpr Finite.card_pos
variable (G)
theorem inv_card_commutator_le_commProb : (↑(Nat.card (commutator G)))⁻¹ ≤ commProb G :=
(inv_le_iff_one_le_mul₀ (Nat.cast_pos.mpr Finite.card_pos)).mpr
(le_trans (ge_of_eq (commProb_eq_one_iff.mpr ⟨(Abelianization.commGroup G).mul_comm⟩))
(commutator G).commProb_quotient_le)
-- Construction of group with commuting probability 1/n
namespace DihedralGroup
lemma commProb_odd {n : ℕ} (hn : Odd n) :
commProb (DihedralGroup n) = (n + 3) / (4 * n) := by
rw [commProb_def', DihedralGroup.card_conjClasses_odd hn, nat_card]
qify [show 2 ∣ n + 3 by rw [Nat.dvd_iff_mod_eq_zero, Nat.add_mod, Nat.odd_iff.mp hn]]
rw [div_div, ← mul_assoc]
congr
norm_num
private lemma div_two_lt {n : ℕ} (h0 : n ≠ 0) : n / 2 < n :=
Nat.div_lt_self (Nat.pos_of_ne_zero h0) (lt_add_one 1)
private lemma div_four_lt : {n : ℕ} → (h0 : n ≠ 0) → (h1 : n ≠ 1) → n / 4 + 1 < n
| 0 | 1 | 2 | 3 => by decide
| n + 4 => by cutsat
/-- A list of Dihedral groups whose product will have commuting probability `1 / n`. -/
def reciprocalFactors (n : ℕ) : List ℕ :=
if _ : n = 0 then [0]
else if _ : n = 1 then []
else if Even n then
3 :: reciprocalFactors (n / 2)
else
n % 4 * n :: reciprocalFactors (n / 4 + 1)
@[simp] lemma reciprocalFactors_zero : reciprocalFactors 0 = [0] := by
unfold reciprocalFactors; rfl
@[simp] lemma reciprocalFactors_one : reciprocalFactors 1 = [] := by
unfold reciprocalFactors; rfl
lemma reciprocalFactors_even {n : ℕ} (h0 : n ≠ 0) (h2 : Even n) :
reciprocalFactors n = 3 :: reciprocalFactors (n / 2) := by
have h1 : n ≠ 1 := by
rintro rfl
norm_num at h2
rw [reciprocalFactors, dif_neg h0, dif_neg h1, if_pos h2]
lemma reciprocalFactors_odd {n : ℕ} (h1 : n ≠ 1) (h2 : Odd n) :
reciprocalFactors n = n % 4 * n :: reciprocalFactors (n / 4 + 1) := by
have h0 : n ≠ 0 := by
rintro rfl
norm_num [← Nat.not_even_iff_odd] at h2
rw [reciprocalFactors, dif_neg h0, dif_neg h1, if_neg (Nat.not_even_iff_odd.2 h2)]
/-- A finite product of Dihedral groups. -/
abbrev Product (l : List ℕ) : Type :=
∀ i : Fin l.length, DihedralGroup l[i]
lemma commProb_nil : commProb (Product []) = 1 := by
simp [Product, commProb_pi]
lemma commProb_cons (n : ℕ) (l : List ℕ) :
commProb (Product (n :: l)) = commProb (DihedralGroup n) * commProb (Product l) := by
simp only [commProb_pi, Fin.prod_univ_succ, Fin.getElem_fin, Fin.val_succ, Fin.val_zero,
List.getElem_cons_zero, List.length_cons, List.getElem_cons_succ]
/-- Construction of a group with commuting probability `1 / n`. -/
theorem commProb_reciprocal (n : ℕ) :
commProb (Product (reciprocalFactors n)) = 1 / n := by
by_cases h0 : n = 0
· rw [h0, reciprocalFactors_zero, commProb_cons, commProb_nil, mul_one, Nat.cast_zero, div_zero]
apply commProb_eq_zero_of_infinite
by_cases h1 : n = 1
· rw [h1, reciprocalFactors_one, commProb_nil, Nat.cast_one, div_one]
rcases Nat.even_or_odd n with h2 | h2
· have := div_two_lt h0
rw [reciprocalFactors_even h0 h2, commProb_cons, commProb_reciprocal (n / 2),
commProb_odd (by decide)]
simp [field, h2.two_dvd]
norm_num
· have := div_four_lt h0 h1
rw [reciprocalFactors_odd h1 h2, commProb_cons, commProb_reciprocal (n / 4 + 1)]
have key : n % 4 = 1 ∨ n % 4 = 3 := Nat.odd_mod_four_iff.mp (Nat.odd_iff.mp h2)
have hn : Odd (n % 4) := by rcases key with h | h <;> rw [h] <;> decide
rw [commProb_odd (hn.mul h2), div_mul_div_comm, mul_one, div_eq_div_iff, one_mul] <;> norm_cast
· have h0 : (n % 4) ^ 2 + 3 = n % 4 * 4 := by rcases key with h | h <;> rw [h] <;> norm_num
have h1 := (Nat.div_add_mod n 4).symm
zify at h0 h1 ⊢
linear_combination (h0 + h1 * (n % 4)) * n
· positivity [hn.pos.ne']
end DihedralGroup |
.lake/packages/mathlib/Mathlib/GroupTheory/Sylow.lean | import Mathlib.Algebra.Order.Archimedean.Basic
import Mathlib.Data.SetLike.Fintype
import Mathlib.GroupTheory.PGroup
import Mathlib.GroupTheory.NoncommPiCoprod
/-!
# Sylow theorems
The Sylow theorems are the following results for every finite group `G` and every prime number `p`.
* There exists a Sylow `p`-subgroup of `G`.
* All Sylow `p`-subgroups of `G` are conjugate to each other.
* Let `nₚ` be the number of Sylow `p`-subgroups of `G`, then `nₚ` divides the index of the Sylow
`p`-subgroup, `nₚ ≡ 1 [MOD p]`, and `nₚ` is equal to the index of the normalizer of the Sylow
`p`-subgroup in `G`.
## Main definitions
* `Sylow p G` : The type of Sylow `p`-subgroups of `G`.
## Main statements
* `Sylow.exists_subgroup_card_pow_prime`: A generalization of Sylow's first theorem:
For every prime power `pⁿ` dividing the cardinality of `G`,
there exists a subgroup of `G` of order `pⁿ`.
* `IsPGroup.exists_le_sylow`: A generalization of Sylow's first theorem:
Every `p`-subgroup is contained in a Sylow `p`-subgroup.
* `Sylow.card_eq_multiplicity`: The cardinality of a Sylow subgroup is `p ^ n`
where `n` is the multiplicity of `p` in the group order.
* `Sylow.isPretransitive_of_finite`: a generalization of Sylow's second theorem:
If the number of Sylow `p`-subgroups is finite, then all Sylow `p`-subgroups are conjugate.
* `card_sylow_modEq_one`: a generalization of Sylow's third theorem:
If the number of Sylow `p`-subgroups is finite, then it is congruent to `1` modulo `p`.
-/
open MulAction Subgroup
section InfiniteSylow
variable (p : ℕ) (G : Type*) [Group G]
/-- A Sylow `p`-subgroup is a maximal `p`-subgroup. -/
structure Sylow extends Subgroup G where
isPGroup' : IsPGroup p toSubgroup
is_maximal' : ∀ {Q : Subgroup G}, IsPGroup p Q → toSubgroup ≤ Q → Q = toSubgroup
variable {p} {G}
namespace Sylow
attribute [coe] toSubgroup
instance : CoeOut (Sylow p G) (Subgroup G) :=
⟨toSubgroup⟩
@[ext]
theorem ext {P Q : Sylow p G} (h : (P : Subgroup G) = Q) : P = Q := by cases P; cases Q; congr
instance : SetLike (Sylow p G) G where
coe := (↑)
coe_injective' _ _ h := ext (SetLike.coe_injective h)
instance : SubgroupClass (Sylow p G) G where
mul_mem := Subgroup.mul_mem _
one_mem _ := Subgroup.one_mem _
inv_mem := Subgroup.inv_mem _
/-- A `p`-subgroup with index indivisible by `p` is a Sylow subgroup. -/
def _root_.IsPGroup.toSylow [Fact p.Prime] {P : Subgroup G}
(hP1 : IsPGroup p P) (hP2 : ¬ p ∣ P.index) : Sylow p G :=
{ P with
isPGroup' := hP1
is_maximal' := by
intro Q hQ hPQ
have : P.FiniteIndex := ⟨fun h ↦ hP2 (h ▸ (dvd_zero p))⟩
obtain ⟨k, hk⟩ := (hQ.to_quotient (P.normalCore.subgroupOf Q)).exists_card_eq
have h := hk ▸ Nat.Prime.coprime_pow_of_not_dvd (m := k) Fact.out hP2
exact le_antisymm (Subgroup.relIndex_eq_one.mp
(Nat.eq_one_of_dvd_coprimes h (Subgroup.relIndex_dvd_index_of_le hPQ)
(Subgroup.relIndex_dvd_of_le_left Q P.normalCore_le))) hPQ }
@[simp] theorem _root_.IsPGroup.toSylow_coe [Fact p.Prime] {P : Subgroup G}
(hP1 : IsPGroup p P) (hP2 : ¬ p ∣ P.index) : (hP1.toSylow hP2) = P :=
rfl
@[simp] theorem _root_.IsPGroup.mem_toSylow [Fact p.Prime] {P : Subgroup G}
(hP1 : IsPGroup p P) (hP2 : ¬ p ∣ P.index) {g : G} : g ∈ hP1.toSylow hP2 ↔ g ∈ P :=
.rfl
/-- A subgroup with cardinality `p ^ n` is a Sylow subgroup
where `n` is the multiplicity of `p` in the group order. -/
def ofCard [Finite G] {p : ℕ} [Fact p.Prime] (H : Subgroup G)
(card_eq : Nat.card H = p ^ (Nat.card G).factorization p) : Sylow p G :=
(IsPGroup.of_card card_eq).toSylow (by
rw [← mul_dvd_mul_iff_left (Nat.card_pos (α := H)).ne', card_mul_index, card_eq, ← pow_succ]
exact Nat.pow_succ_factorization_not_dvd Nat.card_pos.ne' Fact.out)
@[simp, norm_cast]
theorem coe_ofCard [Finite G] {p : ℕ} [Fact p.Prime] (H : Subgroup G)
(card_eq : Nat.card H = p ^ (Nat.card G).factorization p) : ofCard H card_eq = H :=
rfl
variable (P : Sylow p G)
variable {K : Type*} [Group K] (ϕ : K →* G) {N : Subgroup G}
/-- The preimage of a Sylow subgroup under a p-group-kernel homomorphism is a Sylow subgroup. -/
def comapOfKerIsPGroup (hϕ : IsPGroup p ϕ.ker) (h : P ≤ ϕ.range) : Sylow p K :=
{ P.1.comap ϕ with
isPGroup' := P.2.comap_of_ker_isPGroup ϕ hϕ
is_maximal' := fun {Q} hQ hle => by
show Q = P.1.comap ϕ
rw [← P.3 (hQ.map ϕ) (le_trans (ge_of_eq (map_comap_eq_self h)) (map_mono hle))]
exact (comap_map_eq_self ((P.1.ker_le_comap ϕ).trans hle)).symm }
@[simp]
theorem coe_comapOfKerIsPGroup (hϕ : IsPGroup p ϕ.ker) (h : P ≤ ϕ.range) :
P.comapOfKerIsPGroup ϕ hϕ h = P.comap ϕ :=
rfl
/-- The preimage of a Sylow subgroup under an injective homomorphism is a Sylow subgroup. -/
def comapOfInjective (hϕ : Function.Injective ϕ) (h : P ≤ ϕ.range) : Sylow p K :=
P.comapOfKerIsPGroup ϕ (IsPGroup.ker_isPGroup_of_injective hϕ) h
@[simp]
theorem coe_comapOfInjective (hϕ : Function.Injective ϕ) (h : P ≤ ϕ.range) :
P.comapOfInjective ϕ hϕ h = P.comap ϕ :=
rfl
/-- A sylow subgroup of G is also a sylow subgroup of a subgroup of G. -/
protected def subtype (h : P ≤ N) : Sylow p N :=
P.comapOfInjective N.subtype Subtype.coe_injective (by rwa [range_subtype])
@[simp]
theorem coe_subtype (h : P ≤ N) : P.subtype h = subgroupOf P N :=
rfl
theorem subtype_injective {P Q : Sylow p G} {hP : P ≤ N} {hQ : Q ≤ N}
(h : P.subtype hP = Q.subtype hQ) : P = Q := by
rw [SetLike.ext_iff] at h ⊢
exact fun g => ⟨fun hg => (h ⟨g, hP hg⟩).mp hg, fun hg => (h ⟨g, hQ hg⟩).mpr hg⟩
end Sylow
/-- A generalization of **Sylow's first theorem**.
Every `p`-subgroup is contained in a Sylow `p`-subgroup. -/
theorem IsPGroup.exists_le_sylow {P : Subgroup G} (hP : IsPGroup p P) : ∃ Q : Sylow p G, P ≤ Q :=
Exists.elim
(zorn_le_nonempty₀ { Q : Subgroup G | IsPGroup p Q }
(fun c hc1 hc2 Q hQ =>
⟨{ carrier := ⋃ R : c, R
one_mem' := ⟨Q, ⟨⟨Q, hQ⟩, rfl⟩, Q.one_mem⟩
inv_mem' := fun {_} ⟨_, ⟨R, rfl⟩, hg⟩ => ⟨R, ⟨R, rfl⟩, R.1.inv_mem hg⟩
mul_mem' := fun {_} _ ⟨_, ⟨R, rfl⟩, hg⟩ ⟨_, ⟨S, rfl⟩, hh⟩ =>
(hc2.total R.2 S.2).elim (fun T => ⟨S, ⟨S, rfl⟩, S.1.mul_mem (T hg) hh⟩) fun T =>
⟨R, ⟨R, rfl⟩, R.1.mul_mem hg (T hh)⟩ },
fun ⟨g, _, ⟨S, rfl⟩, hg⟩ => by
refine Exists.imp (fun k hk => ?_) (hc1 S.2 ⟨g, hg⟩)
rwa [Subtype.ext_iff, coe_pow] at hk ⊢, fun M hM _ hg => ⟨M, ⟨⟨M, hM⟩, rfl⟩, hg⟩⟩)
P hP)
fun {Q} h => ⟨⟨Q, h.2.prop, h.2.eq_of_ge⟩, h.1⟩
namespace Sylow
instance nonempty : Nonempty (Sylow p G) :=
IsPGroup.of_bot.exists_le_sylow.nonempty
noncomputable instance inhabited : Inhabited (Sylow p G) :=
Classical.inhabited_of_nonempty nonempty
theorem exists_comap_eq_of_ker_isPGroup {H : Type*} [Group H] (P : Sylow p H) {f : H →* G}
(hf : IsPGroup p f.ker) : ∃ Q : Sylow p G, Q.comap f = P :=
Exists.imp (fun Q hQ => P.3 (Q.2.comap_of_ker_isPGroup f hf) (map_le_iff_le_comap.mp hQ))
(P.2.map f).exists_le_sylow
theorem exists_comap_eq_of_injective {H : Type*} [Group H] (P : Sylow p H) {f : H →* G}
(hf : Function.Injective f) : ∃ Q : Sylow p G, Q.comap f = P :=
P.exists_comap_eq_of_ker_isPGroup (IsPGroup.ker_isPGroup_of_injective hf)
theorem exists_comap_subtype_eq {H : Subgroup G} (P : Sylow p H) :
∃ Q : Sylow p G, Q.comap H.subtype = P :=
P.exists_comap_eq_of_injective Subtype.coe_injective
/-- If the kernel of `f : H →* G` is a `p`-group,
then `Finite (Sylow p G)` implies `Finite (Sylow p H)`. -/
theorem finite_of_ker_is_pGroup {H : Type*} [Group H] {f : H →* G}
(hf : IsPGroup p f.ker) [Finite (Sylow p G)] : Finite (Sylow p H) :=
let h_exists := fun P : Sylow p H => P.exists_comap_eq_of_ker_isPGroup hf
let g : Sylow p H → Sylow p G := fun P => Classical.choose (h_exists P)
have hg : ∀ P : Sylow p H, (g P).1.comap f = P := fun P => Classical.choose_spec (h_exists P)
Finite.of_injective g fun P Q h => ext (by rw [← hg, h]; exact (h_exists Q).choose_spec)
/-- If `f : H →* G` is injective, then `Finite (Sylow p G)` implies `Finite (Sylow p H)`. -/
theorem finite_of_injective {H : Type*} [Group H] {f : H →* G}
(hf : Function.Injective f) [Finite (Sylow p G)] : Finite (Sylow p H) :=
finite_of_ker_is_pGroup (IsPGroup.ker_isPGroup_of_injective hf)
/-- If `H` is a subgroup of `G`, then `Finite (Sylow p G)` implies `Finite (Sylow p H)`. -/
instance (H : Subgroup G) [Finite (Sylow p G)] : Finite (Sylow p H) :=
finite_of_injective H.subtype_injective
open Pointwise
/-- `Subgroup.pointwiseMulAction` preserves Sylow subgroups. -/
instance pointwiseMulAction {α : Type*} [Group α] [MulDistribMulAction α G] :
MulAction α (Sylow p G) where
smul g P :=
⟨g • P.toSubgroup, P.2.map _, fun {Q} hQ hS =>
inv_smul_eq_iff.mp
(P.3 (hQ.map _) fun s hs =>
(congr_arg (· ∈ g⁻¹ • Q) (inv_smul_smul g s)).mp
(smul_mem_pointwise_smul (g • s) g⁻¹ Q (hS (smul_mem_pointwise_smul s g P hs))))⟩
one_smul P := ext (one_smul α P.toSubgroup)
mul_smul g h P := ext (mul_smul g h P.toSubgroup)
theorem pointwise_smul_def {α : Type*} [Group α] [MulDistribMulAction α G] {g : α}
{P : Sylow p G} : ↑(g • P) = g • (P : Subgroup G) :=
rfl
instance mulAction : MulAction G (Sylow p G) :=
compHom _ MulAut.conj
theorem smul_def {g : G} {P : Sylow p G} : g • P = MulAut.conj g • P :=
rfl
theorem coe_subgroup_smul {g : G} {P : Sylow p G} :
↑(g • P) = MulAut.conj g • (P : Subgroup G) :=
rfl
theorem coe_smul {g : G} {P : Sylow p G} : ↑(g • P) = MulAut.conj g • (P : Set G) :=
rfl
theorem smul_le {P : Sylow p G} {H : Subgroup G} (hP : P ≤ H) (h : H) : ↑(h • P) ≤ H :=
Subgroup.conj_smul_le_of_le hP h
theorem smul_subtype {P : Sylow p G} {H : Subgroup G} (hP : P ≤ H) (h : H) :
h • P.subtype hP = (h • P).subtype (smul_le hP h) :=
ext (Subgroup.conj_smul_subgroupOf hP h)
theorem smul_eq_iff_mem_normalizer {g : G} {P : Sylow p G} :
g • P = P ↔ g ∈ P.normalizer := by
rw [eq_comm, SetLike.ext_iff, ← inv_mem_iff (G := G) (H := normalizer P.toSubgroup),
mem_normalizer_iff, inv_inv]
exact
forall_congr' fun h =>
iff_congr Iff.rfl
⟨fun ⟨a, b, c⟩ => c ▸ by simpa [mul_assoc] using b,
fun hh => ⟨(MulAut.conj g)⁻¹ h, hh, MulAut.apply_inv_self G (MulAut.conj g) h⟩⟩
theorem smul_eq_of_normal {g : G} {P : Sylow p G} [h : P.Normal] :
g • P = P := by simp only [smul_eq_iff_mem_normalizer, P.normalizer_eq_top, mem_top]
end Sylow
theorem Subgroup.sylow_mem_fixedPoints_iff (H : Subgroup G) {P : Sylow p G} :
P ∈ fixedPoints H (Sylow p G) ↔ H ≤ P.normalizer := by
simp_rw [SetLike.le_def, ← Sylow.smul_eq_iff_mem_normalizer]; exact Subtype.forall
theorem IsPGroup.inf_normalizer_sylow {P : Subgroup G} (hP : IsPGroup p P) (Q : Sylow p G) :
P ⊓ Q.normalizer = P ⊓ Q :=
le_antisymm
(le_inf inf_le_left
(sup_eq_right.mp
(Q.3 (hP.to_inf_left.to_sup_of_normal_right' Q.2 inf_le_right) le_sup_right)))
(inf_le_inf_left P le_normalizer)
theorem IsPGroup.sylow_mem_fixedPoints_iff {P : Subgroup G} (hP : IsPGroup p P) {Q : Sylow p G} :
Q ∈ fixedPoints P (Sylow p G) ↔ P ≤ Q := by
rw [P.sylow_mem_fixedPoints_iff, ← inf_eq_left, hP.inf_normalizer_sylow, inf_eq_left]
/-- A generalization of **Sylow's second theorem**.
If the number of Sylow `p`-subgroups is finite, then all Sylow `p`-subgroups are conjugate. -/
instance Sylow.isPretransitive_of_finite [hp : Fact p.Prime] [Finite (Sylow p G)] :
IsPretransitive G (Sylow p G) :=
⟨fun P Q => by
classical
have H := fun {R : Sylow p G} {S : orbit G P} =>
calc
S ∈ fixedPoints R (orbit G P) ↔ S.1 ∈ fixedPoints R (Sylow p G) :=
forall_congr' fun a => Subtype.ext_iff
_ ↔ R.1 ≤ S := R.2.sylow_mem_fixedPoints_iff
_ ↔ S.1.1 = R := ⟨fun h => R.3 S.1.2 h, ge_of_eq⟩
suffices Set.Nonempty (fixedPoints Q (orbit G P)) by
exact Exists.elim this fun R hR => by
rw [← Sylow.ext (H.mp hR)]
exact R.2
apply Q.2.nonempty_fixed_point_of_prime_not_dvd_card
refine fun h => hp.out.not_dvd_one (Nat.modEq_zero_iff_dvd.mp ?_)
calc
1 = Nat.card (fixedPoints P (orbit G P)) := ?_
_ ≡ Nat.card (orbit G P) [MOD p] := (P.2.card_modEq_card_fixedPoints (orbit G P)).symm
_ ≡ 0 [MOD p] := Nat.modEq_zero_iff_dvd.mpr h
rw [← Nat.card_unique (α := ({⟨P, mem_orbit_self P⟩} : Set (orbit G P))), eq_comm]
congr
rw [Set.eq_singleton_iff_unique_mem]
exact ⟨H.mpr rfl, fun R h => Subtype.ext (Sylow.ext (H.mp h))⟩⟩
variable (p) (G)
/-- A generalization of **Sylow's third theorem**.
If the number of Sylow `p`-subgroups is finite, then it is congruent to `1` modulo `p`. -/
theorem card_sylow_modEq_one [Fact p.Prime] [Finite (Sylow p G)] :
Nat.card (Sylow p G) ≡ 1 [MOD p] := by
refine Sylow.nonempty.elim fun P : Sylow p G => ?_
have : fixedPoints P.1 (Sylow p G) = {P} :=
Set.ext fun Q : Sylow p G =>
calc
Q ∈ fixedPoints P (Sylow p G) ↔ P.1 ≤ Q := P.2.sylow_mem_fixedPoints_iff
_ ↔ Q.1 = P.1 := ⟨P.3 Q.2, ge_of_eq⟩
_ ↔ Q ∈ {P} := Sylow.ext_iff.symm.trans Set.mem_singleton_iff.symm
have : Nat.card (fixedPoints P.1 (Sylow p G)) = 1 := by simp [this]
exact (P.2.card_modEq_card_fixedPoints (Sylow p G)).trans (by rw [this])
theorem not_dvd_card_sylow [hp : Fact p.Prime] [Finite (Sylow p G)] : ¬p ∣ Nat.card (Sylow p G) :=
fun h =>
hp.1.ne_one
(Nat.dvd_one.mp
((Nat.modEq_iff_dvd' zero_le_one).mp
((Nat.modEq_zero_iff_dvd.mpr h).symm.trans (card_sylow_modEq_one p G))))
variable {p} {G}
namespace Sylow
/-- Sylow subgroups are isomorphic -/
nonrec def equivSMul (P : Sylow p G) (g : G) : P ≃* (g • P : Sylow p G) :=
equivSMul (MulAut.conj g) P.toSubgroup
/-- Sylow subgroups are isomorphic -/
noncomputable def equiv [Fact p.Prime] [Finite (Sylow p G)] (P Q : Sylow p G) : P ≃* Q := by
rw [← Classical.choose_spec (exists_smul_eq G P Q)]
exact P.equivSMul (Classical.choose (exists_smul_eq G P Q))
@[simp]
theorem orbit_eq_top [Fact p.Prime] [Finite (Sylow p G)] (P : Sylow p G) : orbit G P = ⊤ :=
top_le_iff.mp fun Q _ => exists_smul_eq G P Q
theorem stabilizer_eq_normalizer (P : Sylow p G) :
stabilizer G P = P.normalizer := by
ext; simp [smul_eq_iff_mem_normalizer]
theorem conj_eq_normalizer_conj_of_mem_centralizer [Fact p.Prime] [Finite (Sylow p G)]
(P : Sylow p G) (x g : G) (hx : x ∈ centralizer P)
(hy : g⁻¹ * x * g ∈ centralizer P) :
∃ n ∈ P.normalizer, g⁻¹ * x * g = n⁻¹ * x * n := by
have h1 : P ≤ centralizer (zpowers x : Set G) := by rwa [le_centralizer_iff, zpowers_le]
have h2 : ↑(g • P) ≤ centralizer (zpowers x : Set G) := by
rw [le_centralizer_iff, zpowers_le]
rintro - ⟨z, hz, rfl⟩
specialize hy z hz
rwa [← mul_assoc, ← eq_mul_inv_iff_mul_eq, mul_assoc, mul_assoc, mul_assoc, ← mul_assoc,
eq_inv_mul_iff_mul_eq, ← mul_assoc, ← mul_assoc] at hy
obtain ⟨h, hh⟩ :=
exists_smul_eq (centralizer (zpowers x : Set G)) ((g • P).subtype h2) (P.subtype h1)
simp_rw [smul_subtype, Subgroup.smul_def, smul_smul] at hh
refine ⟨h * g, smul_eq_iff_mem_normalizer.mp (subtype_injective hh), ?_⟩
rw [← mul_assoc, Commute.right_comm (h.prop x (mem_zpowers x)), mul_inv_rev, inv_mul_cancel_right]
theorem conj_eq_normalizer_conj_of_mem [Fact p.Prime] [Finite (Sylow p G)] (P : Sylow p G)
[_hP : IsMulCommutative P] (x g : G) (hx : x ∈ P) (hy : g⁻¹ * x * g ∈ P) :
∃ n ∈ P.normalizer, g⁻¹ * x * g = n⁻¹ * x * n :=
P.conj_eq_normalizer_conj_of_mem_centralizer x g
(P.le_centralizer hx) (P.le_centralizer hy)
/-- Sylow `p`-subgroups are in bijection with cosets of the normalizer of a Sylow `p`-subgroup -/
noncomputable def equivQuotientNormalizer [Fact p.Prime] [Finite (Sylow p G)]
(P : Sylow p G) : Sylow p G ≃ G ⧸ P.normalizer :=
calc
Sylow p G ≃ (⊤ : Set (Sylow p G)) := (Equiv.Set.univ (Sylow p G)).symm
_ ≃ orbit G P := Equiv.setCongr P.orbit_eq_top.symm
_ ≃ G ⧸ stabilizer G P := orbitEquivQuotientStabilizer G P
_ ≃ G ⧸ P.normalizer := by rw [P.stabilizer_eq_normalizer]
instance [Fact p.Prime] [Finite (Sylow p G)] (P : Sylow p G) :
Finite (G ⧸ P.normalizer) :=
Finite.of_equiv (Sylow p G) P.equivQuotientNormalizer
theorem card_eq_card_quotient_normalizer [Fact p.Prime] [Finite (Sylow p G)]
(P : Sylow p G) : Nat.card (Sylow p G) = Nat.card (G ⧸ P.normalizer) :=
Nat.card_congr P.equivQuotientNormalizer
theorem card_eq_index_normalizer [Fact p.Prime] [Finite (Sylow p G)] (P : Sylow p G) :
Nat.card (Sylow p G) = P.normalizer.index :=
P.card_eq_card_quotient_normalizer
theorem card_dvd_index [Fact p.Prime] [Finite (Sylow p G)] (P : Sylow p G) :
Nat.card (Sylow p G) ∣ P.index :=
((congr_arg _ P.card_eq_index_normalizer).mp dvd_rfl).trans
(index_dvd_of_le le_normalizer)
/-- Auxiliary lemma for `Sylow.not_dvd_index` which is strictly stronger. -/
private theorem not_dvd_index_aux [hp : Fact p.Prime] (P : Sylow p G) [P.Normal]
[P.FiniteIndex] : ¬ p ∣ P.index := by
intro h
rw [P.index_eq_card] at h
obtain ⟨x, hx⟩ := exists_prime_orderOf_dvd_card' (G := G ⧸ (P : Subgroup G)) p h
have h := IsPGroup.of_card (((Nat.card_zpowers x).trans hx).trans (pow_one p).symm)
let Q := (zpowers x).comap (QuotientGroup.mk' (P : Subgroup G))
have hQ : IsPGroup p Q := by
apply h.comap_of_ker_isPGroup
rw [QuotientGroup.ker_mk']
exact P.2
replace hp := mt orderOf_eq_one_iff.mpr (ne_of_eq_of_ne hx hp.1.ne_one)
rw [← zpowers_eq_bot, ← Ne, ← bot_lt_iff_ne_bot, ←
comap_lt_comap_of_surjective (QuotientGroup.mk'_surjective _), MonoidHom.comap_bot,
QuotientGroup.ker_mk'] at hp
exact hp.ne' (P.3 hQ hp.le)
/-- A Sylow p-subgroup has index indivisible by `p`, assuming [N(P) : P] < ∞. -/
theorem not_dvd_index' [hp : Fact p.Prime] [Finite (Sylow p G)] (P : Sylow p G)
(hP : P.relIndex P.normalizer ≠ 0) : ¬ p ∣ P.index := by
rw [← relIndex_mul_index le_normalizer, ← card_eq_index_normalizer]
haveI : (P.subtype le_normalizer).Normal :=
Subgroup.normal_in_normalizer
haveI : (P.subtype le_normalizer).FiniteIndex := ⟨hP⟩
replace hP := not_dvd_index_aux (P.subtype le_normalizer)
exact hp.1.not_dvd_mul hP (not_dvd_card_sylow p G)
/-- A Sylow p-subgroup has index indivisible by `p`. -/
theorem not_dvd_index [Fact p.Prime] [Finite (Sylow p G)] (P : Sylow p G) [P.FiniteIndex] :
¬ p ∣ P.index :=
P.not_dvd_index' Nat.card_pos.ne'
section mapSurjective
variable [Finite G] {G' : Type*} [Group G'] {f : G →* G'} (hf : Function.Surjective f)
/-- Surjective group homomorphisms map Sylow subgroups to Sylow subgroups. -/
def mapSurjective [Fact p.Prime] (P : Sylow p G) : Sylow p G' :=
{ P.1.map f with
isPGroup' := P.2.map f
is_maximal' := fun hQ hPQ ↦ ((P.2.map f).toSylow
(fun h ↦ P.not_dvd_index (h.trans (P.index_map_dvd hf)))).3 hQ hPQ }
@[simp] theorem coe_mapSurjective [Fact p.Prime] (P : Sylow p G) : P.mapSurjective hf = P.map f :=
rfl
theorem mapSurjective_surjective (p : ℕ) [Fact p.Prime] :
Function.Surjective (Sylow.mapSurjective hf : Sylow p G → Sylow p G') := by
have : Finite G' := Finite.of_surjective f hf
intro P
let Q₀ : Sylow p (P.comap f) := Sylow.nonempty.some
let Q : Subgroup G := Q₀.map (P.comap f).subtype
have hPQ : Q.map f ≤ P := Subgroup.map_le_iff_le_comap.mpr (Subgroup.map_subtype_le Q₀.1)
have hpQ : IsPGroup p Q := Q₀.2.map (P.comap f).subtype
have hQ : ¬ p ∣ Q.index := by
rw [Subgroup.index_map_subtype Q₀.1, P.index_comap_of_surjective hf]
exact Nat.Prime.not_dvd_mul Fact.out Q₀.not_dvd_index P.not_dvd_index
use hpQ.toSylow hQ
rw [Sylow.ext_iff, Sylow.coe_mapSurjective, eq_comm]
exact ((hpQ.map f).toSylow (fun h ↦ hQ (h.trans (Q.index_map_dvd hf)))).3 P.2 hPQ
end mapSurjective
/-- **Frattini's Argument**: If `N` is a normal subgroup of `G`, and if `P` is a Sylow `p`-subgroup
of `N`, then `N_G(P) ⊔ N = G`. -/
theorem normalizer_sup_eq_top {p : ℕ} [Fact p.Prime] {N : Subgroup G} [N.Normal]
[Finite (Sylow p N)] (P : Sylow p N) :
(P.map N.subtype).normalizer ⊔ N = ⊤ := by
refine top_le_iff.mp fun g _ => ?_
obtain ⟨n, hn⟩ := exists_smul_eq N ((MulAut.conjNormal g : MulAut N) • P) P
rw [← inv_mul_cancel_left (↑n) g, sup_comm]
apply mul_mem_sup (N.inv_mem n.2)
rw [smul_def, ← mul_smul, ← MulAut.conjNormal_val, ← MulAut.conjNormal.map_mul,
Sylow.ext_iff, pointwise_smul_def, Subgroup.pointwise_smul_def] at hn
have : Function.Injective (MulAut.conj (n * g)).toMonoidHom := (MulAut.conj (n * g)).injective
refine fun x ↦ (mem_map_iff_mem this).symm.trans ?_
rw [map_map, ← congr_arg (map N.subtype) hn, map_map]
rfl
/-- **Frattini's Argument**: If `N` is a normal subgroup of `G`, and if `P` is a Sylow `p`-subgroup
of `N`, then `N_G(P) ⊔ N = G`. -/
theorem normalizer_sup_eq_top' {p : ℕ} [Fact p.Prime] {N : Subgroup G} [N.Normal]
[Finite (Sylow p N)] (P : Sylow p G) (hP : P ≤ N) : P.normalizer ⊔ N = ⊤ := by
rw [← normalizer_sup_eq_top (P.subtype hP), P.coe_subtype, subgroupOf_map_subtype,
inf_of_le_left hP]
end Sylow
end InfiniteSylow
open Equiv Equiv.Perm Finset Function List QuotientGroup
universe u
variable {G : Type u} [Group G]
theorem QuotientGroup.card_preimage_mk (s : Subgroup G) (t : Set (G ⧸ s)) :
Nat.card (QuotientGroup.mk ⁻¹' t) = Nat.card s * Nat.card t := by
rw [← Nat.card_prod, Nat.card_congr (preimageMkEquivSubgroupProdSet _ _)]
namespace Sylow
theorem mem_fixedPoints_mul_left_cosets_iff_mem_normalizer {H : Subgroup G} [Finite (H : Set G)]
{x : G} : (x : G ⧸ H) ∈ MulAction.fixedPoints H (G ⧸ H) ↔ x ∈ normalizer H :=
⟨fun hx =>
have ha : ∀ {y : G ⧸ H}, y ∈ orbit H (x : G ⧸ H) → y = x := mem_fixedPoints'.1 hx _
(inv_mem_iff (G := G)).1
(mem_normalizer_fintype fun n (hn : n ∈ H) =>
have : (n⁻¹ * x)⁻¹ * x ∈ H := QuotientGroup.eq.1 (ha ⟨⟨n⁻¹, inv_mem hn⟩, rfl⟩)
show _ ∈ H by
rw [mul_inv_rev, inv_inv] at this
convert this
rw [inv_inv]),
fun hx : ∀ n : G, n ∈ H ↔ x * n * x⁻¹ ∈ H =>
mem_fixedPoints'.2 fun y =>
Quotient.inductionOn' y fun y hy =>
QuotientGroup.eq.2
(let ⟨⟨b, hb₁⟩, hb₂⟩ := hy
have hb₂ : (b * x)⁻¹ * y ∈ H := QuotientGroup.eq.1 hb₂
(inv_mem_iff (G := G)).1 <|
(hx _).2 <|
(mul_mem_cancel_left (inv_mem hb₁)).1 <| by
rw [hx] at hb₂; simpa [mul_inv_rev, mul_assoc] using hb₂)⟩
/-- The fixed points of the action of `H` on its cosets correspond to `normalizer H / H`. -/
def fixedPointsMulLeftCosetsEquivQuotient (H : Subgroup G) [Finite (H : Set G)] :
MulAction.fixedPoints H (G ⧸ H) ≃
normalizer H ⧸ Subgroup.comap ((normalizer H).subtype : normalizer H →* G) H :=
@subtypeQuotientEquivQuotientSubtype G (normalizer H : Set G) (_) (_)
(MulAction.fixedPoints H (G ⧸ H))
(fun _ => (@mem_fixedPoints_mul_left_cosets_iff_mem_normalizer _ _ _ ‹_› _).symm)
(by
intros
unfold_projs
rw [leftRel_apply (α := normalizer H), leftRel_apply]
rfl)
/-- If `H` is a `p`-subgroup of `G`, then the index of `H` inside its normalizer is congruent
mod `p` to the index of `H`. -/
theorem card_quotient_normalizer_modEq_card_quotient [Finite G] {p : ℕ} {n : ℕ} [hp : Fact p.Prime]
{H : Subgroup G} (hH : Nat.card H = p ^ n) :
Nat.card (normalizer H ⧸ Subgroup.comap ((normalizer H).subtype : normalizer H →* G) H) ≡
Nat.card (G ⧸ H) [MOD p] := by
rw [← Nat.card_congr (fixedPointsMulLeftCosetsEquivQuotient H)]
exact ((IsPGroup.of_card hH).card_modEq_card_fixedPoints _).symm
/-- If `H` is a subgroup of `G` of cardinality `p ^ n`, then the cardinality of the
normalizer of `H` is congruent mod `p ^ (n + 1)` to the cardinality of `G`. -/
theorem card_normalizer_modEq_card [Finite G] {p : ℕ} {n : ℕ} [hp : Fact p.Prime] {H : Subgroup G}
(hH : Nat.card H = p ^ n) : Nat.card (normalizer H) ≡ Nat.card G [MOD p ^ (n + 1)] := by
have : H.subgroupOf (normalizer H) ≃ H := (subgroupOfEquivOfLe le_normalizer).toEquiv
rw [card_eq_card_quotient_mul_card_subgroup H,
card_eq_card_quotient_mul_card_subgroup (H.subgroupOf (normalizer H)), Nat.card_congr this,
hH, pow_succ']
exact (card_quotient_normalizer_modEq_card_quotient hH).mul_right' _
/-- If `H` is a `p`-subgroup but not a Sylow `p`-subgroup, then `p` divides the
index of `H` inside its normalizer. -/
theorem prime_dvd_card_quotient_normalizer [Finite G] {p : ℕ} {n : ℕ} [Fact p.Prime]
(hdvd : p ^ (n + 1) ∣ Nat.card G) {H : Subgroup G} (hH : Nat.card H = p ^ n) :
p ∣ Nat.card (normalizer H ⧸ Subgroup.comap ((normalizer H).subtype : normalizer H →* G) H) :=
let ⟨s, hs⟩ := exists_eq_mul_left_of_dvd hdvd
have hcard : Nat.card (G ⧸ H) = s * p :=
(mul_left_inj' (show Nat.card H ≠ 0 from Nat.card_pos.ne')).1
(by
rw [← card_eq_card_quotient_mul_card_subgroup H, hH, hs, pow_succ', mul_assoc, mul_comm p])
have hm :
s * p % p =
Nat.card (normalizer H ⧸ Subgroup.comap ((normalizer H).subtype : normalizer H →* G) H) % p :=
hcard ▸ (card_quotient_normalizer_modEq_card_quotient hH).symm
Nat.dvd_of_mod_eq_zero (by rwa [Nat.mod_eq_zero_of_dvd (dvd_mul_left _ _), eq_comm] at hm)
/-- If `H` is a `p`-subgroup but not a Sylow `p`-subgroup of cardinality `p ^ n`,
then `p ^ (n + 1)` divides the cardinality of the normalizer of `H`. -/
theorem prime_pow_dvd_card_normalizer [Finite G] {p : ℕ} {n : ℕ} [_hp : Fact p.Prime]
(hdvd : p ^ (n + 1) ∣ Nat.card G) {H : Subgroup G} (hH : Nat.card H = p ^ n) :
p ^ (n + 1) ∣ Nat.card (normalizer H) :=
Nat.modEq_zero_iff_dvd.1 ((card_normalizer_modEq_card hH).trans hdvd.modEq_zero_nat)
/-- If `H` is a subgroup of `G` of cardinality `p ^ n`,
then `H` is contained in a subgroup of cardinality `p ^ (n + 1)`
if `p ^ (n + 1)` divides the cardinality of `G` -/
theorem exists_subgroup_card_pow_succ [Finite G] {p : ℕ} {n : ℕ} [hp : Fact p.Prime]
(hdvd : p ^ (n + 1) ∣ Nat.card G) {H : Subgroup G} (hH : Nat.card H = p ^ n) :
∃ K : Subgroup G, Nat.card K = p ^ (n + 1) ∧ H ≤ K :=
let ⟨s, hs⟩ := exists_eq_mul_left_of_dvd hdvd
have hcard : Nat.card (G ⧸ H) = s * p :=
(mul_left_inj' (show Nat.card H ≠ 0 from Nat.card_pos.ne')).1
(by
rw [← card_eq_card_quotient_mul_card_subgroup H, hH, hs, pow_succ', mul_assoc, mul_comm p])
have hm : s * p % p = Nat.card (normalizer H ⧸ H.subgroupOf H.normalizer) % p :=
Nat.card_congr (fixedPointsMulLeftCosetsEquivQuotient H) ▸
hcard ▸ (IsPGroup.of_card hH).card_modEq_card_fixedPoints _
have hm' : p ∣ Nat.card (normalizer H ⧸ H.subgroupOf H.normalizer) :=
Nat.dvd_of_mod_eq_zero (by rwa [Nat.mod_eq_zero_of_dvd (dvd_mul_left _ _), eq_comm] at hm)
let ⟨x, hx⟩ := @exists_prime_orderOf_dvd_card' _ (QuotientGroup.Quotient.group _) _ _ hp hm'
have hequiv : H ≃ H.subgroupOf H.normalizer := (subgroupOfEquivOfLe le_normalizer).symm.toEquiv
⟨Subgroup.map (normalizer H).subtype
(Subgroup.comap (mk' (H.subgroupOf H.normalizer)) (zpowers x)), by
show Nat.card (Subgroup.map H.normalizer.subtype
(comap (mk' (H.subgroupOf H.normalizer)) (Subgroup.zpowers x))) = p ^ (n + 1)
suffices Nat.card (Subtype.val ''
(Subgroup.comap (mk' (H.subgroupOf H.normalizer)) (zpowers x) : Set H.normalizer)) =
p ^ (n + 1)
by convert this using 2
rw [Nat.card_image_of_injective Subtype.val_injective
(Subgroup.comap (mk' (H.subgroupOf H.normalizer)) (zpowers x) : Set H.normalizer),
pow_succ, ← hH, Nat.card_congr hequiv, ← hx, ← Nat.card_zpowers, ←
Nat.card_prod]
exact Nat.card_congr
(preimageMkEquivSubgroupProdSet (H.subgroupOf H.normalizer) (zpowers x)), by
intro y hy
simp only [Subgroup.coe_subtype, mk'_apply, Subgroup.mem_map, Subgroup.mem_comap]
refine ⟨⟨y, le_normalizer hy⟩, ⟨0, ?_⟩, rfl⟩
dsimp only
rw [zpow_zero, eq_comm, QuotientGroup.eq_one_iff]
simpa using hy⟩
/-- If `H` is a subgroup of `G` of cardinality `p ^ n`,
then `H` is contained in a subgroup of cardinality `p ^ m`
if `n ≤ m` and `p ^ m` divides the cardinality of `G` -/
theorem exists_subgroup_card_pow_prime_le [Finite G] (p : ℕ) :
∀ {n m : ℕ} [_hp : Fact p.Prime] (_hdvd : p ^ m ∣ Nat.card G) (H : Subgroup G)
(_hH : Nat.card H = p ^ n) (_hnm : n ≤ m), ∃ K : Subgroup G, Nat.card K = p ^ m ∧ H ≤ K
| n, m => fun {hdvd H hH hnm} =>
(lt_or_eq_of_le hnm).elim
(fun hnm : n < m =>
have h0m : 0 < m := lt_of_le_of_lt n.zero_le hnm
have hnm1 : n ≤ m - 1 := le_tsub_of_add_le_right hnm
let ⟨K, hK⟩ :=
@exists_subgroup_card_pow_prime_le _ _ n (m - 1) _
(Nat.pow_dvd_of_le_of_pow_dvd tsub_le_self hdvd) H hH hnm1
have hdvd' : p ^ (m - 1 + 1) ∣ Nat.card G := by rwa [tsub_add_cancel_of_le h0m.nat_succ_le]
let ⟨K', hK'⟩ := @exists_subgroup_card_pow_succ _ _ _ _ _ _ hdvd' K hK.1
⟨K', by rw [hK'.1, tsub_add_cancel_of_le h0m.nat_succ_le], le_trans hK.2 hK'.2⟩)
fun hnm : n = m => ⟨H, by simp [hH, hnm]⟩
/-- A generalisation of **Sylow's first theorem**. If `p ^ n` divides
the cardinality of `G`, then there is a subgroup of cardinality `p ^ n` -/
theorem exists_subgroup_card_pow_prime [Finite G] (p : ℕ) {n : ℕ} [Fact p.Prime]
(hdvd : p ^ n ∣ Nat.card G) : ∃ K : Subgroup G, Nat.card K = p ^ n :=
let ⟨K, hK⟩ := exists_subgroup_card_pow_prime_le p hdvd ⊥
(by rw [card_bot, pow_zero]) n.zero_le
⟨K, hK.1⟩
/-- A special case of **Sylow's first theorem**. If `G` is a `p`-group of size at least `p ^ n`
then there is a subgroup of cardinality `p ^ n`. -/
lemma exists_subgroup_card_pow_prime_of_le_card {n p : ℕ} (hp : p.Prime) (h : IsPGroup p G)
(hn : p ^ n ≤ Nat.card G) : ∃ H : Subgroup G, Nat.card H = p ^ n := by
have : Fact p.Prime := ⟨hp⟩
have : Finite G := Nat.finite_of_card_ne_zero <| by linarith [Nat.one_le_pow n p hp.pos]
obtain ⟨m, hm⟩ := h.exists_card_eq
refine exists_subgroup_card_pow_prime _ ?_
rw [hm] at hn ⊢
exact pow_dvd_pow _ <| (Nat.pow_le_pow_iff_right hp.one_lt).1 hn
/-- A special case of **Sylow's first theorem**. If `G` is a `p`-group and `H` a subgroup of size at
least `p ^ n` then there is a subgroup of `H` of cardinality `p ^ n`. -/
lemma exists_subgroup_le_card_pow_prime_of_le_card {n p : ℕ} (hp : p.Prime) (h : IsPGroup p G)
{H : Subgroup G} (hn : p ^ n ≤ Nat.card H) : ∃ H' ≤ H, Nat.card H' = p ^ n := by
obtain ⟨H', H'card⟩ := exists_subgroup_card_pow_prime_of_le_card hp (h.to_subgroup H) hn
refine ⟨H'.map H.subtype, map_subtype_le _, ?_⟩
rw [← H'card]
let e : H' ≃* H'.map H.subtype := H'.equivMapOfInjective (Subgroup.subtype H) H.subtype_injective
exact Nat.card_congr e.symm.toEquiv
/-- A special case of **Sylow's first theorem**. If `G` is a `p`-group and `H` a subgroup of size at
least `k` then there is a subgroup of `H` of cardinality between `k / p` and `k`. -/
lemma exists_subgroup_le_card_le {k p : ℕ} (hp : p.Prime) (h : IsPGroup p G) {H : Subgroup G}
(hk : k ≤ Nat.card H) (hk₀ : k ≠ 0) : ∃ H' ≤ H, Nat.card H' ≤ k ∧ k < p * Nat.card H' := by
obtain ⟨m, hmk, hkm⟩ : ∃ s, p ^ s ≤ k ∧ k < p ^ (s + 1) :=
exists_nat_pow_near (Nat.one_le_iff_ne_zero.2 hk₀) hp.one_lt
obtain ⟨H', H'H, H'card⟩ := exists_subgroup_le_card_pow_prime_of_le_card hp h (hmk.trans hk)
refine ⟨H', H'H, ?_⟩
simpa only [pow_succ', H'card] using And.intro hmk hkm
theorem pow_dvd_card_of_pow_dvd_card [Finite G] {p n : ℕ} [hp : Fact p.Prime] (P : Sylow p G)
(hdvd : p ^ n ∣ Nat.card G) : p ^ n ∣ Nat.card P := by
rw [← index_mul_card P.1] at hdvd
exact (hp.1.coprime_pow_of_not_dvd P.not_dvd_index).symm.dvd_of_dvd_mul_left hdvd
theorem dvd_card_of_dvd_card [Finite G] {p : ℕ} [Fact p.Prime] (P : Sylow p G)
(hdvd : p ∣ Nat.card G) : p ∣ Nat.card P := by
rw [← pow_one p] at hdvd
have key := P.pow_dvd_card_of_pow_dvd_card hdvd
rwa [pow_one] at key
/-- Sylow subgroups are Hall subgroups. -/
theorem card_coprime_index [Finite G] {p : ℕ} [hp : Fact p.Prime] (P : Sylow p G) :
(Nat.card P).Coprime P.index :=
let ⟨_n, hn⟩ := IsPGroup.iff_card.mp P.2
hn.symm ▸ (hp.1.coprime_pow_of_not_dvd P.not_dvd_index).symm
theorem ne_bot_of_dvd_card [Finite G] {p : ℕ} [hp : Fact p.Prime] (P : Sylow p G)
(hdvd : p ∣ Nat.card G) : (P : Subgroup G) ≠ ⊥ := by
refine fun h => hp.out.not_dvd_one ?_
have key : p ∣ Nat.card P := P.dvd_card_of_dvd_card hdvd
rwa [h, card_bot] at key
/-- The cardinality of a Sylow subgroup is `p ^ n`
where `n` is the multiplicity of `p` in the group order. -/
theorem card_eq_multiplicity [Finite G] {p : ℕ} [hp : Fact p.Prime] (P : Sylow p G) :
Nat.card P = p ^ Nat.factorization (Nat.card G) p := by
obtain ⟨n, heq : Nat.card P = _⟩ := IsPGroup.iff_card.mp P.isPGroup'
refine Nat.dvd_antisymm ?_ (P.pow_dvd_card_of_pow_dvd_card (Nat.ordProj_dvd _ p))
rw [heq, ← hp.out.pow_dvd_iff_dvd_ordProj (show Nat.card G ≠ 0 from Nat.card_pos.ne'), ← heq]
exact P.1.card_subgroup_dvd_card
/-- If `G` has a normal Sylow `p`-subgroup, then it is the only Sylow `p`-subgroup. -/
noncomputable def unique_of_normal {p : ℕ} [Fact p.Prime] [Finite (Sylow p G)] (P : Sylow p G)
(h : P.Normal) : Unique (Sylow p G) := by
refine { uniq := fun Q ↦ ?_ }
obtain ⟨x, h1⟩ := exists_smul_eq G P Q
obtain ⟨x, h2⟩ := exists_smul_eq G P default
rw [smul_eq_of_normal] at h1 h2
rw [← h1, ← h2]
instance characteristic_of_subsingleton {p : ℕ} [Subsingleton (Sylow p G)] (P : Sylow p G) :
P.Characteristic := by
refine Subgroup.characteristic_iff_map_eq.mpr fun ϕ ↦ ?_
have h := Subgroup.pointwise_smul_def (a := ϕ) (P : Subgroup G)
rwa [← pointwise_smul_def, Subsingleton.elim (ϕ • P) P, eq_comm] at h
theorem normal_of_subsingleton {p : ℕ} [Subsingleton (Sylow p G)] (P : Sylow p G) :
P.Normal :=
Subgroup.normal_of_characteristic _
theorem characteristic_of_normal {p : ℕ} [Fact p.Prime] [Finite (Sylow p G)] (P : Sylow p G)
(h : P.Normal) : P.Characteristic := by
have _ := unique_of_normal P h
exact characteristic_of_subsingleton _
theorem normal_of_normalizer_normal {p : ℕ} [Fact p.Prime] [Finite (Sylow p G)] (P : Sylow p G)
(hn : P.normalizer.Normal) : P.Normal := by
rw [← normalizer_eq_top_iff, ← normalizer_sup_eq_top' P le_normalizer, sup_idem]
@[simp]
theorem normalizer_normalizer {p : ℕ} [Fact p.Prime] [Finite (Sylow p G)] (P : Sylow p G) :
P.normalizer.normalizer = P.normalizer := by
have := normal_of_normalizer_normal (P.subtype (le_normalizer.trans le_normalizer))
rw [coe_subtype, normal_subgroupOf_iff_le_normalizer (le_normalizer.trans le_normalizer),
← subgroupOf_normalizer_eq (le_normalizer.trans le_normalizer)] at this
exact le_antisymm (this normal_in_normalizer) le_normalizer
theorem normal_of_all_max_subgroups_normal [Finite G]
(hnc : ∀ H : Subgroup G, IsCoatom H → H.Normal) {p : ℕ} [Fact p.Prime] [Finite (Sylow p G)]
(P : Sylow p G) : P.Normal :=
normalizer_eq_top_iff.mp
(by
rcases eq_top_or_exists_le_coatom P.normalizer with (heq | ⟨K, hK, hNK⟩)
· exact heq
· haveI := hnc _ hK
have hPK : P ≤ K := le_trans le_normalizer hNK
refine (hK.1 ?_).elim
rw [← sup_of_le_right hNK, P.normalizer_sup_eq_top' hPK])
theorem normal_of_normalizerCondition (hnc : NormalizerCondition G) {p : ℕ} [Fact p.Prime]
[Finite (Sylow p G)] (P : Sylow p G) : P.Normal :=
normalizer_eq_top_iff.mp <|
normalizerCondition_iff_only_full_group_self_normalizing.mp hnc _ <| normalizer_normalizer _
/-- If all its Sylow subgroups are normal, then a finite group is isomorphic to the direct product
of these Sylow subgroups.
-/
noncomputable def directProductOfNormal [Finite G]
(hn : ∀ {p : ℕ} [Fact p.Prime] (P : Sylow p G), P.Normal) :
(∀ p : (Nat.card G).primeFactors, ∀ P : Sylow p G, P) ≃* G := by
have := Fintype.ofFinite G
set ps := (Nat.card G).primeFactors
-- “The” Sylow subgroup for p
let P : ∀ p, Sylow p G := default
have : ∀ p, Fintype (P p) := fun p ↦ Fintype.ofFinite (P p)
have hcomm : Pairwise fun p₁ p₂ : ps => ∀ x y : G, x ∈ P p₁ → y ∈ P p₂ → Commute x y := by
rintro ⟨p₁, hp₁⟩ ⟨p₂, hp₂⟩ hne
haveI hp₁' := Fact.mk (Nat.prime_of_mem_primeFactors hp₁)
haveI hp₂' := Fact.mk (Nat.prime_of_mem_primeFactors hp₂)
have hne' : p₁ ≠ p₂ := by simpa using hne
apply Subgroup.commute_of_normal_of_disjoint _ _ (hn (P p₁)) (hn (P p₂))
apply IsPGroup.disjoint_of_ne p₁ p₂ hne' _ _ (P p₁).isPGroup' (P p₂).isPGroup'
refine MulEquiv.trans (N := ∀ p : ps, P p) ?_ ?_
-- There is only one Sylow subgroup for each p, so the inner product is trivial
· -- here we need to help the elaborator with an explicit instantiation
apply @MulEquiv.piCongrRight ps (fun p => ∀ P : Sylow p G, P) (fun p => P p) _ _
rintro ⟨p, hp⟩
haveI hp' := Fact.mk (Nat.prime_of_mem_primeFactors hp)
letI := unique_of_normal _ (hn (P p))
apply MulEquiv.piUnique
apply MulEquiv.ofBijective (Subgroup.noncommPiCoprod hcomm)
apply (Fintype.bijective_iff_injective_and_card _).mpr
constructor
· apply Subgroup.injective_noncommPiCoprod_of_iSupIndep
apply independent_of_coprime_order hcomm
rintro ⟨p₁, hp₁⟩ ⟨p₂, hp₂⟩ hne
haveI hp₁' := Fact.mk (Nat.prime_of_mem_primeFactors hp₁)
haveI hp₂' := Fact.mk (Nat.prime_of_mem_primeFactors hp₂)
have hne' : p₁ ≠ p₂ := by simpa using hne
simp only [← Nat.card_eq_fintype_card]
apply IsPGroup.coprime_card_of_ne p₁ p₂ hne' _ _ (P p₁).isPGroup' (P p₂).isPGroup'
· simp only [← Nat.card_eq_fintype_card]
calc
Nat.card (∀ p : ps, P p) = ∏ p : ps, Nat.card (P p) := Nat.card_pi
_ = ∏ p : ps, p.1 ^ (Nat.card G).factorization p.1 := by
congr 1 with ⟨p, hp⟩
exact @card_eq_multiplicity _ _ _ p ⟨Nat.prime_of_mem_primeFactors hp⟩ (P p)
_ = ∏ p ∈ ps, p ^ (Nat.card G).factorization p :=
(Finset.prod_finset_coe (fun p => p ^ (Nat.card G).factorization p) _)
_ = (Nat.card G).factorization.prod (· ^ ·) := rfl
_ = Nat.card G := Nat.factorization_prod_pow_eq_self Nat.card_pos.ne'
end Sylow |
.lake/packages/mathlib/Mathlib/GroupTheory/Torsion.lean | import Mathlib.GroupTheory.PGroup
import Mathlib.LinearAlgebra.Quotient.Defs
/-!
# Torsion groups
This file defines torsion groups, i.e. groups where all elements have finite order.
## Main definitions
* `Monoid.IsTorsion` a predicate asserting `G` is torsion, i.e. that all
elements are of finite order.
* `CommGroup.torsion G`, the torsion subgroup of an abelian group `G`
* `CommMonoid.torsion G`, the above stated for commutative monoids
* `Monoid.IsTorsionFree`, asserting no nontrivial elements have finite order in `G`
* `AddMonoid.IsTorsion` and `AddMonoid.IsTorsionFree` the additive versions of the above
## Implementation
All torsion monoids are really groups (which is proven here as `Monoid.IsTorsion.group`), but since
the definition can be stated on monoids it is implemented on `Monoid` to match other declarations in
the group theory library.
## Tags
periodic group, aperiodic group, torsion subgroup, torsion abelian group
## Future work
* generalize to π-torsion(-free) groups for a set of primes π
* free, free solvable and free abelian groups are torsion free
* complete direct and free products of torsion free groups are torsion free
* groups which are residually finite p-groups with respect to 2 distinct primes are torsion free
-/
variable {G H : Type*}
namespace Monoid
variable (G) [Monoid G]
/-- A predicate on a monoid saying that all elements are of finite order. -/
@[to_additive
/-- A predicate on an additive monoid saying that all elements are of finite order. -/]
def IsTorsion :=
∀ g : G, IsOfFinOrder g
/-- A monoid is not a torsion monoid if it has an element of infinite order. -/
@[to_additive (attr := simp) /-- An additive monoid is not a torsion monoid if it
has an element of infinite order. -/]
theorem not_isTorsion_iff : ¬IsTorsion G ↔ ∃ g : G, ¬IsOfFinOrder g := by
rw [IsTorsion, not_forall]
end Monoid
open Monoid
/-- Torsion monoids are really groups. -/
@[to_additive /-- Torsion additive monoids are really additive groups -/]
noncomputable def IsTorsion.group [Monoid G] (tG : IsTorsion G) : Group G :=
{ ‹Monoid G› with
inv := fun g => g ^ (orderOf g - 1)
inv_mul_cancel := fun g => by
rw [← pow_succ, tsub_add_cancel_of_le, pow_orderOf_eq_one]
exact (tG g).orderOf_pos }
section Group
variable [Group G] {N : Subgroup G} [Group H]
/-- Subgroups of torsion groups are torsion groups. -/
@[to_additive /-- Subgroups of additive torsion groups are additive torsion groups. -/]
theorem IsTorsion.subgroup (tG : IsTorsion G) (H : Subgroup G) : IsTorsion H := fun h =>
Submonoid.isOfFinOrder_coe.1 <| tG h
/-- The image of a surjective torsion group homomorphism is torsion. -/
@[to_additive AddIsTorsion.of_surjective
/-- The image of a surjective additive torsion group homomorphism is torsion. -/]
theorem IsTorsion.of_surjective {f : G →* H} (hf : Function.Surjective f) (tG : IsTorsion G) :
IsTorsion H := fun h => by
obtain ⟨g, hg⟩ := hf h
rw [← hg]
exact f.isOfFinOrder (tG g)
/-- Torsion groups are closed under extensions. -/
@[to_additive AddIsTorsion.extension_closed
/-- Additive torsion groups are closed under extensions. -/]
theorem IsTorsion.extension_closed {f : G →* H} (hN : N = f.ker) (tH : IsTorsion H)
(tN : IsTorsion N) : IsTorsion G := fun g => by
obtain ⟨ngn, ngnpos, hngn⟩ := (tH <| f g).exists_pow_eq_one
have hmem := MonoidHom.mem_ker.mpr ((f.map_pow g ngn).trans hngn)
lift g ^ ngn to N using hN.symm ▸ hmem with gn h
obtain ⟨nn, nnpos, hnn⟩ := (tN gn).exists_pow_eq_one
exact isOfFinOrder_iff_pow_eq_one.mpr <| ⟨ngn * nn, mul_pos ngnpos nnpos, by
rw [pow_mul, ← h, ← Subgroup.coe_pow, hnn, Subgroup.coe_one]⟩
/-- The image of a quotient is torsion iff the group is torsion. -/
@[to_additive AddIsTorsion.quotient_iff
/-- The image of a quotient is additively torsion iff the group is torsion. -/]
theorem IsTorsion.quotient_iff {f : G →* H} (hf : Function.Surjective f) (hN : N = f.ker)
(tN : IsTorsion N) : IsTorsion H ↔ IsTorsion G :=
⟨fun tH => IsTorsion.extension_closed hN tH tN, fun tG => IsTorsion.of_surjective hf tG⟩
/-- If a group exponent exists, the group is torsion. -/
@[to_additive ExponentExists.is_add_torsion
/-- If a group exponent exists, the group is additively torsion. -/]
theorem ExponentExists.isTorsion (h : ExponentExists G) : IsTorsion G := fun g => by
obtain ⟨n, npos, hn⟩ := h
exact isOfFinOrder_iff_pow_eq_one.mpr ⟨n, npos, hn g⟩
/-- The group exponent exists for any bounded torsion group. -/
@[to_additive IsAddTorsion.exponentExists
/-- The group exponent exists for any bounded additive torsion group. -/]
theorem IsTorsion.exponentExists (tG : IsTorsion G)
(bounded : (Set.range fun g : G => orderOf g).Finite) : ExponentExists G :=
exponent_ne_zero.mp <|
(exponent_ne_zero_iff_range_orderOf_finite fun g => (tG g).orderOf_pos).mpr bounded
/-- Finite groups are torsion groups. -/
@[to_additive is_add_torsion_of_finite /-- Finite additive groups are additive torsion groups. -/]
theorem isTorsion_of_finite [Finite G] : IsTorsion G :=
ExponentExists.isTorsion .of_finite
end Group
section CommGroup
variable [CommGroup G]
/-- A nontrivial torsion abelian group is not torsion-free. -/
@[to_additive /-- A nontrivial additive torsion abelian group is not torsion-free. -/]
lemma not_isMulTorsionFree_of_isTorsion [Nontrivial G] (hG : IsTorsion G) : ¬ IsMulTorsionFree G :=
not_isMulTorsionFree_iff_isOfFinOrder.2 <| let ⟨x, hx⟩ := exists_ne (1 : G); ⟨x, hx, hG x⟩
/-- A nontrivial torsion-free abelian group is not torsion. -/
@[to_additive /-- A nontrivial additive torsion-free abelian group is not torsion. -/]
lemma not_isTorsion_of_isMulTorsionFree [Nontrivial G] [IsMulTorsionFree G] : ¬ IsTorsion G :=
(not_isMulTorsionFree_of_isTorsion · ‹_›)
end CommGroup
section Module
-- A (semi/)ring of scalars and a commutative monoid of elements
variable (R M : Type*) [AddCommMonoid M]
namespace AddMonoid
/-- A module whose scalars are additively torsion is additively torsion. -/
theorem IsTorsion.module_of_torsion [Semiring R] [Module R M] (tR : IsTorsion R) : IsTorsion M :=
fun f =>
isOfFinAddOrder_iff_nsmul_eq_zero.mpr <| by
obtain ⟨n, npos, hn⟩ := (tR 1).exists_nsmul_eq_zero
exact ⟨n, npos, by simp only [← Nat.cast_smul_eq_nsmul R _ f, ← nsmul_one, hn, zero_smul]⟩
/-- A module with a finite ring of scalars is additively torsion. -/
theorem IsTorsion.module_of_finite [Ring R] [Finite R] [Module R M] : IsTorsion M :=
(is_add_torsion_of_finite : IsTorsion R).module_of_torsion _ _
end AddMonoid
end Module
section CommMonoid
variable (G) [CommMonoid G]
namespace CommMonoid
/-- The torsion submonoid of a commutative monoid.
(Note that by `Monoid.IsTorsion.group` torsion monoids are truthfully groups.)
-/
@[to_additive addTorsion /-- The torsion submonoid of an additive commutative monoid. -/]
def torsion : Submonoid G where
carrier := { x | IsOfFinOrder x }
one_mem' := IsOfFinOrder.one
mul_mem' hx hy := hx.mul hy
variable {G}
/-- Torsion submonoids are torsion. -/
@[to_additive /-- Additive torsion submonoids are additively torsion. -/]
theorem torsion.isTorsion : IsTorsion <| torsion G := fun ⟨x, n, npos, hn⟩ =>
⟨n, npos,
Subtype.ext <| by
dsimp
rw [mul_left_iterate]
change _ * 1 = 1
rw [_root_.mul_one, SubmonoidClass.coe_pow, Subtype.coe_mk,
(isPeriodicPt_mul_iff_pow_eq_one _).mp hn]⟩
variable (G) (p : ℕ) [hp : Fact p.Prime]
/-- The `p`-primary component is the submonoid of elements with order prime-power of `p`. -/
@[to_additive (attr := simps)
/-- The `p`-primary component is the submonoid of elements with additive
order prime-power of `p`. -/]
def primaryComponent : Submonoid G where
carrier := { g | ∃ n : ℕ, orderOf g = p ^ n }
one_mem' := ⟨0, by rw [pow_zero, orderOf_one]⟩
mul_mem' hg₁ hg₂ :=
exists_orderOf_eq_prime_pow_iff.mpr <| by
obtain ⟨m, hm⟩ := exists_orderOf_eq_prime_pow_iff.mp hg₁
obtain ⟨n, hn⟩ := exists_orderOf_eq_prime_pow_iff.mp hg₂
exact
⟨m + n, by
rw [mul_pow, pow_add, pow_mul, hm, one_pow, Monoid.one_mul, mul_comm, pow_mul, hn,
one_pow]⟩
variable {G} {p}
/-- Elements of the `p`-primary component have order `p^n` for some `n`. -/
@[to_additive primaryComponent.exists_orderOf_eq_prime_nsmul
/-- Elements of the `p`-primary component have additive order `p^n` for some `n` -/]
theorem primaryComponent.exists_orderOf_eq_prime_pow (g : CommMonoid.primaryComponent G p) :
∃ n : ℕ, orderOf g = p ^ n := by
obtain ⟨_, hn⟩ := g.property
rw [orderOf_submonoid g] at hn
exact ⟨_, hn⟩
/-- The `p`- and `q`-primary components are disjoint for `p ≠ q`. -/
@[to_additive /-- The `p`- and `q`-primary components are disjoint for `p ≠ q`. -/]
theorem primaryComponent.disjoint {p' : ℕ} [hp' : Fact p'.Prime] (hne : p ≠ p') :
Disjoint (CommMonoid.primaryComponent G p) (CommMonoid.primaryComponent G p') :=
Submonoid.disjoint_def.mpr <| by
rintro g ⟨_ | n, hn⟩ ⟨n', hn'⟩
· rwa [pow_zero, orderOf_eq_one_iff] at hn
· exact
absurd (eq_of_prime_pow_eq hp.out.prime hp'.out.prime n.succ_pos (hn.symm.trans hn')) hne
end CommMonoid
open CommMonoid (torsion)
namespace Monoid.IsTorsion
variable {G}
/-- The torsion submonoid of a torsion monoid is `⊤`. -/
@[to_additive (attr := simp)
/-- The additive torsion submonoid of an additive torsion monoid is `⊤`. -/]
theorem torsion_eq_top (tG : IsTorsion G) : torsion G = ⊤ := by ext; tauto
/-- A torsion monoid is isomorphic to its torsion submonoid. -/
@[to_additive /-- An additive torsion monoid is isomorphic to its torsion submonoid. -/]
def torsionMulEquiv (tG : IsTorsion G) : torsion G ≃* G :=
(MulEquiv.submonoidCongr tG.torsion_eq_top).trans Submonoid.topEquiv
@[to_additive]
theorem torsionMulEquiv_apply (tG : IsTorsion G) (a : torsion G) :
tG.torsionMulEquiv a = MulEquiv.submonoidCongr tG.torsion_eq_top a :=
rfl
@[to_additive]
theorem torsionMulEquiv_symm_apply_coe (tG : IsTorsion G) (a : G) :
tG.torsionMulEquiv.symm a = ⟨Submonoid.topEquiv.symm a, tG _⟩ :=
rfl
end Monoid.IsTorsion
/-- Torsion submonoids of a torsion submonoid are isomorphic to the submonoid. -/
@[to_additive (attr := simp) AddCommMonoid.Torsion.ofTorsion
/-- Additive torsion submonoids of an additive torsion submonoid are
isomorphic to the submonoid. -/]
def Torsion.ofTorsion : torsion (torsion G) ≃* torsion G :=
Monoid.IsTorsion.torsionMulEquiv CommMonoid.torsion.isTorsion
end CommMonoid
section CommGroup
variable (G) [CommGroup G]
namespace CommGroup
/-- The torsion subgroup of an abelian group. -/
@[to_additive /-- The torsion subgroup of an additive abelian group. -/]
def torsion : Subgroup G :=
{ CommMonoid.torsion G with inv_mem' := fun hx => IsOfFinOrder.inv hx }
/-- The torsion submonoid of an abelian group equals the torsion subgroup as a submonoid. -/
@[to_additive add_torsion_eq_add_torsion_submonoid
/-- The additive torsion submonoid of an abelian group equals the torsion
subgroup as a submonoid. -/]
theorem torsion_eq_torsion_submonoid : CommMonoid.torsion G = (torsion G).toSubmonoid :=
rfl
@[to_additive]
theorem mem_torsion (g : G) : g ∈ torsion G ↔ IsOfFinOrder g := Iff.rfl
@[to_additive]
lemma isMulTorsionFree_iff_torsion_eq_bot : IsMulTorsionFree G ↔ CommGroup.torsion G = ⊥ := by
rw [isMulTorsionFree_iff_not_isOfFinOrder, eq_bot_iff, SetLike.le_def]
simp [not_imp_not, CommGroup.mem_torsion]
variable (p : ℕ) [hp : Fact p.Prime]
/-- The `p`-primary component is the subgroup of elements with order prime-power of `p`. -/
@[to_additive (attr := simps!)
/-- The `p`-primary component is the subgroup of elements with additive order
prime-power of `p`. -/]
def primaryComponent : Subgroup G :=
{ CommMonoid.primaryComponent G p with
inv_mem' := fun {g} ⟨n, hn⟩ => ⟨n, (orderOf_inv g).trans hn⟩ }
variable {G} {p}
/-- The `p`-primary component is a `p` group. -/
theorem primaryComponent.isPGroup : IsPGroup p <| primaryComponent G p := fun g =>
(propext exists_orderOf_eq_prime_pow_iff.symm).mpr
(CommMonoid.primaryComponent.exists_orderOf_eq_prime_pow g)
end CommGroup
end CommGroup
namespace Monoid
section Monoid
variable (G) [Monoid G]
/-- A predicate on a monoid saying that only 1 is of finite order.
This definition is mathematically incorrect for monoids which are not groups.
Please use `IsMulTorsionFree` instead. -/
@[to_additive /-- A predicate on an additive monoid saying that only 0 is of finite order.
This definition is mathematically incorrect for monoids which are not groups.
Please use `IsAddTorsionFree` instead. -/]
def IsTorsionFree :=
∀ g : G, g ≠ 1 → ¬IsOfFinOrder g
attribute [deprecated IsMulTorsionFree (since := "2025-04-23")] Monoid.IsTorsionFree
attribute [deprecated IsAddTorsionFree (since := "2025-04-23")] AddMonoid.IsTorsionFree
variable {G}
set_option linter.deprecated false in
/-- A nontrivial monoid is not torsion-free if any nontrivial element has finite order. -/
@[to_additive (attr := deprecated not_isMulTorsionFree_iff_isOfFinOrder (since := "2025-04-23"))
/-- An additive monoid is not torsion free if any nontrivial element has finite order. -/]
theorem not_isTorsionFree_iff : ¬IsTorsionFree G ↔ ∃ g : G, g ≠ 1 ∧ IsOfFinOrder g := by
simp_rw [IsTorsionFree, Ne, not_forall, Classical.not_not, exists_prop]
set_option linter.deprecated false in
@[to_additive (attr := deprecated Subsingleton.to_isMulTorsionFree (since := "2025-04-23"))]
lemma isTorsionFree_of_subsingleton [Subsingleton G] : IsTorsionFree G :=
fun _a ha _ => ha <| Subsingleton.elim _ _
set_option linter.deprecated false in
@[to_additive
(attr := deprecated CommGroup.isMulTorsionFree_iff_torsion_eq_bot (since := "2025-04-23"))]
lemma isTorsionFree_iff_torsion_eq_bot {G} [CommGroup G] :
IsTorsionFree G ↔ CommGroup.torsion G = ⊥ := by
rw [IsTorsionFree, eq_bot_iff, SetLike.le_def]
simp [not_imp_not, CommGroup.mem_torsion]
end Monoid
section Group
variable [Group G]
set_option linter.deprecated false in
/-- A nontrivial torsion group is not torsion-free. -/
@[to_additive (attr := deprecated not_isMulTorsionFree_of_isTorsion (since := "2025-04-23"))
/-- A nontrivial additive torsion group is not torsion-free. -/]
theorem IsTorsion.not_torsion_free [hN : Nontrivial G] : IsTorsion G → ¬IsTorsionFree G := fun tG =>
not_isTorsionFree_iff.mpr <| by
obtain ⟨x, hx⟩ := (nontrivial_iff_exists_ne (1 : G)).mp hN
exact ⟨x, hx, tG x⟩
set_option linter.deprecated false in
/-- A nontrivial torsion-free group is not torsion. -/
@[to_additive (attr := deprecated not_isTorsion_of_isMulTorsionFree (since := "2025-04-23"))
/-- A nontrivial torsion-free additive group is not torsion. -/]
theorem IsTorsionFree.not_torsion [hN : Nontrivial G] : IsTorsionFree G → ¬IsTorsion G := fun tfG =>
(not_isTorsion_iff _).mpr <| by
obtain ⟨x, hx⟩ := (nontrivial_iff_exists_ne (1 : G)).mp hN
exact ⟨x, (tfG x) hx⟩
set_option linter.deprecated false in
/-- Subgroups of torsion-free groups are torsion-free. -/
@[to_additive (attr := deprecated Subgroup.instIsMulTorsionFree (since := "2025-04-23"))
/-- Subgroups of additive torsion-free groups are additively torsion-free. -/]
theorem IsTorsionFree.subgroup (tG : IsTorsionFree G) (H : Subgroup G) : IsTorsionFree H :=
fun h hne ↦ Submonoid.isOfFinOrder_coe.not.1 <| tG h <| by norm_cast
set_option linter.deprecated false in
/-- Direct products of torsion free groups are torsion free. -/
@[to_additive (attr := deprecated Pi.instIsMulTorsionFree (since := "2025-04-23"))
AddMonoid.IsTorsionFree.prod
/-- Direct products of additive torsion free groups are torsion free. -/]
theorem IsTorsionFree.prod {η : Type*} {Gs : η → Type*} [∀ i, Group (Gs i)]
(tfGs : ∀ i, IsTorsionFree (Gs i)) : IsTorsionFree <| ∀ i, Gs i := fun w hne h =>
hne <|
funext fun i => Classical.not_not.mp <| mt (tfGs i (w i)) <| Classical.not_not.mpr <| h.apply i
end Group
section CommGroup
open Monoid (IsTorsionFree)
open CommGroup (torsion)
variable (G) [CommGroup G]
/-- Quotienting a group by its torsion subgroup yields a torsion-free group. -/
@[to_additive
/-- Quotienting a group by its additive torsion subgroup yields an additive torsion-free group. -/]
instance _root_.QuotientGroup.instIsMulTorsionFree : IsMulTorsionFree <| G ⧸ torsion G := by
refine .of_not_isOfFinOrder fun g hne hfin ↦ hne ?_
obtain ⟨g⟩ := g
obtain ⟨m, mpos, hm⟩ := hfin.exists_pow_eq_one
obtain ⟨n, npos, hn⟩ := ((QuotientGroup.eq_one_iff _).mp hm).exists_pow_eq_one
exact (QuotientGroup.eq_one_iff g).mpr
(isOfFinOrder_iff_pow_eq_one.mpr ⟨m * n, mul_pos mpos npos, (pow_mul g m n).symm ▸ hn⟩)
set_option linter.deprecated false in
/-- Quotienting a group by its torsion subgroup yields a torsion free group. -/
@[to_additive
(attr := deprecated QuotientGroup.instIsMulTorsionFree (since := "2025-04-23"))
/-- Quotienting a group by its additive torsion subgroup yields an additive torsion free group. -/]
theorem IsTorsionFree.quotient_torsion : IsTorsionFree <| G ⧸ torsion G := fun g hne hfin =>
hne <| by
obtain ⟨g⟩ := g
obtain ⟨m, mpos, hm⟩ := hfin.exists_pow_eq_one
obtain ⟨n, npos, hn⟩ := ((QuotientGroup.eq_one_iff _).mp hm).exists_pow_eq_one
exact
(QuotientGroup.eq_one_iff g).mpr
(isOfFinOrder_iff_pow_eq_one.mpr ⟨m * n, mul_pos mpos npos, (pow_mul g m n).symm ▸ hn⟩)
end CommGroup
end Monoid
namespace AddMonoid
set_option linter.deprecated false in
@[deprecated noZeroSMulDivisors_nat_iff_isAddTorsionFree (since := "2025-04-23")]
lemma isTorsionFree_iff_noZeroSMulDivisors_nat {M : Type*} [AddMonoid M] :
IsTorsionFree M ↔ NoZeroSMulDivisors ℕ M := by
simp_rw [AddMonoid.IsTorsionFree, isOfFinAddOrder_iff_nsmul_eq_zero, not_exists, not_and,
pos_iff_ne_zero, noZeroSMulDivisors_iff, forall_swap (β := ℕ)]
exact forall₂_congr fun _ _ ↦ by tauto
set_option linter.deprecated false in
@[deprecated noZeroSMulDivisors_int_iff_isAddTorsionFree (since := "2025-04-23")]
lemma isTorsionFree_iff_noZeroSMulDivisors_int [SubtractionMonoid G] :
IsTorsionFree G ↔ NoZeroSMulDivisors ℤ G := by
simp_rw [AddMonoid.IsTorsionFree, isOfFinAddOrder_iff_zsmul_eq_zero, not_exists, not_and,
noZeroSMulDivisors_iff, forall_swap (β := ℤ)]
exact forall₂_congr fun _ _ ↦ by tauto
set_option linter.deprecated false in
@[deprecated IsAddTorsionFree.of_noZeroSMulDivisors_nat (since := "2025-04-23")]
lemma IsTorsionFree.of_noZeroSMulDivisors {M : Type*} [AddMonoid M] [NoZeroSMulDivisors ℕ M] :
IsTorsionFree M := isTorsionFree_iff_noZeroSMulDivisors_nat.2 ‹_›
@[deprecated IsAddTorsionFree.to_noZeroSMulDivisors_nat (since := "2025-04-23")]
alias ⟨IsTorsionFree.noZeroSMulDivisors_nat, _⟩ := isTorsionFree_iff_noZeroSMulDivisors_nat
@[deprecated IsAddTorsionFree.to_noZeroSMulDivisors_int (since := "2025-04-23")]
alias ⟨IsTorsionFree.noZeroSMulDivisors_int, _⟩ := isTorsionFree_iff_noZeroSMulDivisors_int
end AddMonoid
section AddCommGroup
instance {R M : Type*} [Ring R] [AddCommGroup M] [Module R M] :
Module R (M ⧸ AddCommGroup.torsion M) :=
letI : Submodule R M := { AddCommGroup.torsion M with smul_mem' := fun r m ⟨n, hn, hn'⟩ ↦
⟨n, hn, by { simp only [Function.IsPeriodicPt, Function.IsFixedPt, add_left_iterate, add_zero,
smul_comm n] at hn' ⊢; simp only [hn', smul_zero] }⟩ }
inferInstanceAs (Module R (M ⧸ this))
end AddCommGroup
section
variable {M : Type*} [CommMonoid M] [HasDistribNeg M]
theorem neg_one_mem_torsion : -1 ∈ CommMonoid.torsion M :=
⟨2, zero_lt_two, (isPeriodicPt_mul_iff_pow_eq_one _).mpr (by simp)⟩
end |
.lake/packages/mathlib/Mathlib/GroupTheory/HNNExtension.lean | import Mathlib.Algebra.Ring.CharZero
import Mathlib.Algebra.Ring.Int.Units
import Mathlib.GroupTheory.Coprod.Basic
import Mathlib.GroupTheory.Complement
/-!
## HNN Extensions of Groups
This file defines the HNN extension of a group `G`, `HNNExtension G A B φ`. Given a group `G`,
subgroups `A` and `B` and an isomorphism `φ` of `A` and `B`, we adjoin a letter `t` to `G`, such
that for any `a ∈ A`, the conjugate of `of a` by `t` is `of (φ a)`, where `of` is the canonical map
from `G` into the `HNNExtension`. This construction is named after Graham Higman, Bernhard Neumann
and Hanna Neumann.
## Main definitions
- `HNNExtension G A B φ` : The HNN Extension of a group `G`, where `A` and `B` are subgroups and `φ`
is an isomorphism between `A` and `B`.
- `HNNExtension.of` : The canonical embedding of `G` into `HNNExtension G A B φ`.
- `HNNExtension.t` : The stable letter of the HNN extension.
- `HNNExtension.lift` : Define a function `HNNExtension G A B φ →* H`, by defining it on `G` and `t`
- `HNNExtension.of_injective` : The canonical embedding `G →* HNNExtension G A B φ` is injective.
- `HNNExtension.ReducedWord.toList_eq_nil_of_mem_of_range` : Britton's Lemma. If an element of
`G` is represented by a reduced word, then this reduced word does not contain `t`.
-/
assert_not_exists Field
open Monoid Coprod Multiplicative Subgroup Function
/-- The relation we quotient the coproduct by to form an `HNNExtension`. -/
def HNNExtension.con (G : Type*) [Group G] (A B : Subgroup G) (φ : A ≃* B) :
Con (G ∗ Multiplicative ℤ) :=
conGen (fun x y => ∃ (a : A),
x = inr (ofAdd 1) * inl (a : G) ∧
y = inl (φ a : G) * inr (ofAdd 1))
/-- The HNN Extension of a group `G`, `HNNExtension G A B φ`. Given a group `G`, subgroups `A` and
`B` and an isomorphism `φ` of `A` and `B`, we adjoin a letter `t` to `G`, such that for
any `a ∈ A`, the conjugate of `of a` by `t` is `of (φ a)`, where `of` is the canonical
map from `G` into the `HNNExtension`. -/
def HNNExtension (G : Type*) [Group G] (A B : Subgroup G) (φ : A ≃* B) : Type _ :=
(HNNExtension.con G A B φ).Quotient
variable {G : Type*} [Group G] {A B : Subgroup G} {φ : A ≃* B} {H : Type*}
[Group H] {M : Type*} [Monoid M]
instance : Group (HNNExtension G A B φ) := by
delta HNNExtension; infer_instance
namespace HNNExtension
/-- The canonical embedding `G →* HNNExtension G A B φ` -/
def of : G →* HNNExtension G A B φ :=
(HNNExtension.con G A B φ).mk'.comp inl
/-- The stable letter of the `HNNExtension` -/
def t : HNNExtension G A B φ :=
(HNNExtension.con G A B φ).mk'.comp inr (ofAdd 1)
theorem t_mul_of (a : A) :
t * (of (a : G) : HNNExtension G A B φ) = of (φ a : G) * t :=
(Con.eq _).2 <| ConGen.Rel.of _ _ <| ⟨a, by simp⟩
theorem of_mul_t (b : B) :
(of (b : G) : HNNExtension G A B φ) * t = t * of (φ.symm b : G) := by
rw [t_mul_of]; simp
theorem equiv_eq_conj (a : A) :
(of (φ a : G) : HNNExtension G A B φ) = t * of (a : G) * t⁻¹ := by
rw [t_mul_of]; simp
theorem equiv_symm_eq_conj (b : B) :
(of (φ.symm b : G) : HNNExtension G A B φ) = t⁻¹ * of (b : G) * t := by
rw [mul_assoc, of_mul_t]; simp
theorem inv_t_mul_of (b : B) :
t⁻¹ * (of (b : G) : HNNExtension G A B φ) = of (φ.symm b : G) * t⁻¹ := by
rw [equiv_symm_eq_conj]; simp
theorem of_mul_inv_t (a : A) :
(of (a : G) : HNNExtension G A B φ) * t⁻¹ = t⁻¹ * of (φ a : G) := by
rw [equiv_eq_conj]; simp [mul_assoc]
/-- Define a function `HNNExtension G A B φ →* H`, by defining it on `G` and `t` -/
def lift (f : G →* H) (x : H) (hx : ∀ a : A, x * f ↑a = f (φ a : G) * x) :
HNNExtension G A B φ →* H :=
Con.lift _ (Coprod.lift f (zpowersHom H x)) (Con.conGen_le <| by
rintro _ _ ⟨a, rfl, rfl⟩
simp [hx])
@[simp]
theorem lift_t (f : G →* H) (x : H) (hx : ∀ a : A, x * f ↑a = f (φ a : G) * x) :
lift f x hx t = x := by
delta HNNExtension; simp [lift, t]
@[simp]
theorem lift_of (f : G →* H) (x : H) (hx : ∀ a : A, x * f ↑a = f (φ a : G) * x) (g : G) :
lift f x hx (of g) = f g := by
delta HNNExtension; simp [lift, of]
@[ext high]
theorem hom_ext {f g : HNNExtension G A B φ →* M}
(hg : f.comp of = g.comp of) (ht : f t = g t) : f = g :=
(MonoidHom.cancel_right Con.mk'_surjective).mp <|
Coprod.hom_ext hg (MonoidHom.ext_mint ht)
@[elab_as_elim]
theorem induction_on {motive : HNNExtension G A B φ → Prop}
(x : HNNExtension G A B φ) (of : ∀ g, motive (of g))
(t : motive t) (mul : ∀ x y, motive x → motive y → motive (x * y))
(inv : ∀ x, motive x → motive x⁻¹) : motive x := by
let S : Subgroup (HNNExtension G A B φ) :=
{ carrier := setOf motive
one_mem' := by simpa using of 1
mul_mem' := mul _ _
inv_mem' := inv _ }
let f : HNNExtension G A B φ →* S :=
lift (HNNExtension.of.codRestrict S of)
⟨HNNExtension.t, t⟩ (by intro a; ext; simp [equiv_eq_conj, mul_assoc])
have hf : S.subtype.comp f = MonoidHom.id _ :=
hom_ext (by ext; simp [f]) (by simp [f])
change motive (MonoidHom.id _ x)
rw [← hf]
exact (f x).2
variable (A B φ)
/-- To avoid duplicating code, we define `toSubgroup A B u` and `toSubgroupEquiv u`
where `u : ℤˣ` is `1` or `-1`. `toSubgroup A B u` is `A` when `u = 1` and `B` when `u = -1`,
and `toSubgroupEquiv` is `φ` when `u = 1` and `φ⁻¹` when `u = -1`. `toSubgroup u` is the subgroup
such that for any `a ∈ toSubgroup u`, `t ^ (u : ℤ) * a = toSubgroupEquiv a * t ^ (u : ℤ)`. -/
def toSubgroup (u : ℤˣ) : Subgroup G :=
if u = 1 then A else B
@[simp]
theorem toSubgroup_one : toSubgroup A B 1 = A := rfl
@[simp]
theorem toSubgroup_neg_one : toSubgroup A B (-1) = B := rfl
variable {A B}
/-- To avoid duplicating code, we define `toSubgroup A B u` and `toSubgroupEquiv u`
where `u : ℤˣ` is `1` or `-1`. `toSubgroup A B u` is `A` when `u = 1` and `B` when `u = -1`,
and `toSubgroupEquiv` is the group isomorphism from `toSubgroup A B u` to `toSubgroup A B (-u)`.
It is defined to be `φ` when `u = 1` and `φ⁻¹` when `u = -1`. -/
def toSubgroupEquiv (u : ℤˣ) : toSubgroup A B u ≃* toSubgroup A B (-u) :=
if hu : u = 1 then hu ▸ φ else by
convert φ.symm <;>
cases Int.units_eq_one_or u <;> simp_all
@[simp]
theorem toSubgroupEquiv_one : toSubgroupEquiv φ 1 = φ := rfl
@[simp]
theorem toSubgroupEquiv_neg_one : toSubgroupEquiv φ (-1) = φ.symm := rfl
@[simp]
theorem toSubgroupEquiv_neg_apply (u : ℤˣ) (a : toSubgroup A B u) :
(toSubgroupEquiv φ (-u) (toSubgroupEquiv φ u a) : G) = a := by
rcases Int.units_eq_one_or u with rfl | rfl
· simp [toSubgroup]
· simp only [toSubgroup_neg_one, toSubgroupEquiv_neg_one, SetLike.coe_eq_coe]
exact φ.apply_symm_apply a
namespace NormalWord
variable (G A B)
/-- To put word in the HNN Extension into a normal form, we must choose an element of each right
coset of both `A` and `B`, such that the chosen element of the subgroup itself is `1`. -/
structure TransversalPair : Type _ where
/-- The transversal of each subgroup -/
set : ℤˣ → Set G
/-- We have exactly one element of each coset of the subgroup -/
compl : ∀ u, IsComplement (toSubgroup A B u : Subgroup G) (set u)
instance TransversalPair.nonempty : Nonempty (TransversalPair G A B) := by
choose t ht using fun u ↦ (toSubgroup A B u).exists_isComplement_right 1
exact ⟨⟨t, fun i ↦ (ht i).1⟩⟩
/-- A reduced word is a `head`, which is an element of `G`, followed by the product list of pairs.
There should also be no sequences of the form `t^u * g * t^-u`, where `g` is in
`toSubgroup A B u` This is a less strict condition than required for `NormalWord`. -/
structure ReducedWord : Type _ where
/-- Every `ReducedWord` is the product of an element of the group and a word made up
of letters each of which is in the transversal. `head` is that element of the base group. -/
head : G
/-- The list of pairs `(ℤˣ × G)`, where each pair `(u, g)` represents the element `t^u * g` of
`HNNExtension G A B φ` -/
toList : List (ℤˣ × G)
/-- There are no sequences of the form `t^u * g * t^-u` where `g ∈ toSubgroup A B u` -/
chain : toList.IsChain (fun a b => a.2 ∈ toSubgroup A B a.1 → a.1 = b.1)
/-- The empty reduced word. -/
@[simps]
def ReducedWord.empty : ReducedWord G A B :=
{ head := 1
toList := []
chain := List.isChain_nil }
variable {G A B}
/-- The product of a `ReducedWord` as an element of the `HNNExtension` -/
def ReducedWord.prod : ReducedWord G A B → HNNExtension G A B φ :=
fun w => of w.head * (w.toList.map (fun x => t ^ (x.1 : ℤ) * of x.2)).prod
/-- Given a `TransversalPair`, we can make a normal form for words in the `HNNExtension G A B φ`.
The normal form is a `head`, which is an element of `G`, followed by the product list of pairs,
`t ^ u * g`, where `u` is `1` or `-1` and `g` is the chosen element of its right coset of
`toSubgroup A B u`. There should also be no sequences of the form `t^u * g * t^-u`
where `g ∈ toSubgroup A B u` -/
structure _root_.HNNExtension.NormalWord (d : TransversalPair G A B) : Type _
extends ReducedWord G A B where
/-- Every element `g : G` in the list is the chosen element of its coset -/
mem_set : ∀ (u : ℤˣ) (g : G), (u, g) ∈ toList → g ∈ d.set u
variable {d : TransversalPair G A B}
@[ext]
theorem ext {w w' : NormalWord d}
(h1 : w.head = w'.head) (h2 : w.toList = w'.toList) : w = w' := by
rcases w with ⟨⟨⟩, _⟩; cases w'; simp_all
/-- The empty word -/
@[simps]
def empty : NormalWord d :=
{ head := 1
toList := []
mem_set := by simp
chain := List.isChain_nil }
/-- The `NormalWord` representing an element `g` of the group `G`, which is just the element `g`
itself. -/
@[simps]
def ofGroup (g : G) : NormalWord d :=
{ head := g
toList := []
mem_set := by simp
chain := List.isChain_nil }
instance : Inhabited (NormalWord d) := ⟨empty⟩
instance : MulAction G (NormalWord d) :=
{ smul := fun g w => { w with head := g * w.head }
one_smul := by simp [instHSMul]
mul_smul := by simp [instHSMul, mul_assoc] }
theorem group_smul_def (g : G) (w : NormalWord d) :
g • w = { w with head := g * w.head } := rfl
@[simp]
theorem group_smul_head (g : G) (w : NormalWord d) : (g • w).head = g * w.head := rfl
@[simp]
theorem group_smul_toList (g : G) (w : NormalWord d) : (g • w).toList = w.toList := rfl
instance : FaithfulSMul G (NormalWord d) := ⟨by simp [group_smul_def]⟩
/-- A constructor to append an element `g` of `G` and `u : ℤˣ` to a word `w` with sufficient
hypotheses that no normalization or cancellation need take place for the result to be in normal form
-/
@[simps]
def cons (g : G) (u : ℤˣ) (w : NormalWord d) (h1 : w.head ∈ d.set u)
(h2 : ∀ u' ∈ Option.map Prod.fst w.toList.head?, w.head ∈ toSubgroup A B u → u = u') :
NormalWord d :=
{ head := g,
toList := (u, w.head) :: w.toList,
mem_set := by
intro u' g' h'
simp only [List.mem_cons, Prod.mk.injEq] at h'
rcases h' with ⟨rfl, rfl⟩ | h'
· exact h1
· exact w.mem_set _ _ h'
chain := by
refine List.isChain_cons.2 ⟨?_, w.chain⟩
rintro ⟨u', g'⟩ hu' hw1
exact h2 _ (by simp_all) hw1 }
/-- A recursor to induct on a `NormalWord`, by proving the property is preserved under `cons` -/
@[elab_as_elim]
def consRecOn {motive : NormalWord d → Sort*} (w : NormalWord d)
(ofGroup : ∀ g, motive (ofGroup g))
(cons : ∀ (g : G) (u : ℤˣ) (w : NormalWord d) (h1 : w.head ∈ d.set u)
(h2 : ∀ u' ∈ Option.map Prod.fst w.toList.head?,
w.head ∈ toSubgroup A B u → u = u'),
motive w → motive (cons g u w h1 h2)) : motive w := by
rcases w with ⟨⟨g, l, chain⟩, mem_set⟩
induction l generalizing g with
| nil => exact ofGroup _
| cons a l ih =>
exact cons g a.1
{ head := a.2
toList := l
mem_set := fun _ _ h => mem_set _ _ (List.mem_cons_of_mem _ h),
chain := (List.isChain_cons.1 chain).2 }
(mem_set a.1 a.2 List.mem_cons_self)
(by simpa using (List.isChain_cons.1 chain).1)
(ih _ _ _)
@[simp]
theorem consRecOn_ofGroup {motive : NormalWord d → Sort*}
(g : G) (ofGroup : ∀ g, motive (ofGroup g))
(cons : ∀ (g : G) (u : ℤˣ) (w : NormalWord d) (h1 : w.head ∈ d.set u)
(h2 : ∀ u' ∈ Option.map Prod.fst w.toList.head?, w.head
∈ toSubgroup A B u → u = u'),
motive w → motive (cons g u w h1 h2)) :
consRecOn (.ofGroup g) ofGroup cons = ofGroup g := rfl
@[simp]
theorem consRecOn_cons {motive : NormalWord d → Sort*}
(g : G) (u : ℤˣ) (w : NormalWord d) (h1 : w.head ∈ d.set u)
(h2 : ∀ u' ∈ Option.map Prod.fst w.toList.head?, w.head ∈ toSubgroup A B u → u = u')
(ofGroup : ∀ g, motive (ofGroup g))
(cons : ∀ (g : G) (u : ℤˣ) (w : NormalWord d) (h1 : w.head ∈ d.set u)
(h2 : ∀ u' ∈ Option.map Prod.fst w.toList.head?,
w.head ∈ toSubgroup A B u → u = u'),
motive w → motive (cons g u w h1 h2)) :
consRecOn (.cons g u w h1 h2) ofGroup cons = cons g u w h1 h2
(consRecOn w ofGroup cons) := rfl
@[simp]
theorem smul_cons (g₁ g₂ : G) (u : ℤˣ) (w : NormalWord d) (h1 : w.head ∈ d.set u)
(h2 : ∀ u' ∈ Option.map Prod.fst w.toList.head?, w.head ∈ toSubgroup A B u → u = u') :
g₁ • cons g₂ u w h1 h2 = cons (g₁ * g₂) u w h1 h2 :=
rfl
@[simp]
theorem smul_ofGroup (g₁ g₂ : G) :
g₁ • (ofGroup g₂ : NormalWord d) = ofGroup (g₁ * g₂) := rfl
variable (d)
/-- The action of `t^u` on `ofGroup g`. The normal form will be
`a * t^u * g'` where `a ∈ toSubgroup A B (-u)` -/
noncomputable def unitsSMulGroup (u : ℤˣ) (g : G) :
(toSubgroup A B (-u)) × d.set u :=
let g' := (d.compl u).equiv g
(toSubgroupEquiv φ u g'.1, g'.2)
theorem unitsSMulGroup_snd (u : ℤˣ) (g : G) :
(unitsSMulGroup φ d u g).2 = ((d.compl u).equiv g).2 := by
rcases Int.units_eq_one_or u with rfl | rfl <;> rfl
variable {d}
/-- `Cancels u w` is a predicate expressing whether `t^u` cancels with some occurrence
of `t^-u` when we multiply `t^u` by `w`. -/
def Cancels (u : ℤˣ) (w : NormalWord d) : Prop :=
(w.head ∈ (toSubgroup A B u : Subgroup G)) ∧ w.toList.head?.map Prod.fst = some (-u)
/-- Multiplying `t^u` by `w` in the special case where cancellation happens -/
def unitsSMulWithCancel (u : ℤˣ) (w : NormalWord d) : Cancels u w → NormalWord d :=
consRecOn w
(by simp [Cancels, ofGroup]; tauto)
(fun g _ w _ _ _ can =>
(toSubgroupEquiv φ u ⟨g, can.1⟩ : G) • w)
/-- Multiplying `t^u` by a `NormalWord`, `w` and putting the result in normal form. -/
noncomputable def unitsSMul (u : ℤˣ) (w : NormalWord d) : NormalWord d :=
letI := Classical.dec
if h : Cancels u w
then unitsSMulWithCancel φ u w h
else let g' := unitsSMulGroup φ d u w.head
cons g'.1 u ((g'.2 * w.head⁻¹ : G) • w)
(by simp)
(by
simp only [g', group_smul_toList, Option.mem_def, Option.map_eq_some_iff, Prod.exists,
exists_and_right, exists_eq_right, group_smul_head, inv_mul_cancel_right,
forall_exists_index, unitsSMulGroup]
simp only [Cancels, Option.map_eq_some_iff, Prod.exists, exists_and_right, exists_eq_right,
not_and, not_exists] at h
intro u' x hx hmem
have : w.head ∈ toSubgroup A B u := by
have := (d.compl u).rightCosetEquivalence_equiv_snd w.head
rw [RightCosetEquivalence, rightCoset_eq_iff, mul_mem_cancel_left hmem] at this
simp_all
have := h this x
simp_all [Int.units_ne_iff_eq_neg])
/-- A condition for not cancelling whose hypotheses are the same as those of the `cons` function. -/
theorem not_cancels_of_cons_hyp (u : ℤˣ) (w : NormalWord d)
(h2 : ∀ u' ∈ Option.map Prod.fst w.toList.head?,
w.head ∈ toSubgroup A B u → u = u') :
¬ Cancels u w := by
simp only [Cancels, Option.map_eq_some_iff, Prod.exists,
exists_and_right, exists_eq_right, not_and, not_exists]
intro hw x hx
rw [hx] at h2
simpa using h2 (-u) rfl hw
theorem unitsSMul_cancels_iff (u : ℤˣ) (w : NormalWord d) :
Cancels (-u) (unitsSMul φ u w) ↔ ¬ Cancels u w := by
by_cases h : Cancels u w
· simp only [unitsSMul, h, dite_true, not_true_eq_false, iff_false]
induction w using consRecOn with
| ofGroup => simp [Cancels, unitsSMulWithCancel]
| cons g u' w h1 h2 _ =>
intro hc
apply not_cancels_of_cons_hyp _ _ h2
simp only [Cancels, cons_head, cons_toList, List.head?_cons,
Option.map_some, Option.some.injEq] at h
cases h.2
simpa [Cancels, unitsSMulWithCancel,
Subgroup.mul_mem_cancel_left] using hc
· simp only [unitsSMul, dif_neg h]
simpa [Cancels] using h
theorem unitsSMul_neg (u : ℤˣ) (w : NormalWord d) :
unitsSMul φ (-u) (unitsSMul φ u w) = w := by
rw [unitsSMul]
split_ifs with hcan
· have hncan : ¬ Cancels u w := (unitsSMul_cancels_iff _ _ _).1 hcan
unfold unitsSMul
simp only [dif_neg hncan]
simp [unitsSMulWithCancel, unitsSMulGroup, (d.compl u).equiv_snd_eq_inv_mul,
-SetLike.coe_sort_coe]
· have hcan2 : Cancels u w := not_not.1 (mt (unitsSMul_cancels_iff _ _ _).2 hcan)
unfold unitsSMul at hcan ⊢
simp only [dif_pos hcan2] at hcan ⊢
cases w using consRecOn with
| ofGroup => simp [Cancels] at hcan2
| cons g u' w h1 h2 ih =>
clear ih
simp only [unitsSMulGroup, SetLike.coe_sort_coe, unitsSMulWithCancel, id_eq, consRecOn_cons,
group_smul_head,
mul_inv_rev]
cases hcan2.2
have : ((d.compl (-u)).equiv w.head).1 = 1 :=
(d.compl (-u)).equiv_fst_eq_one_of_mem_of_one_mem _ h1
apply NormalWord.ext
· -- This used to `simp [this]` before https://github.com/leanprover/lean4/pull/2644
dsimp
conv_lhs => erw [IsComplement.equiv_mul_left]
rw [map_mul, Submonoid.coe_mul, toSubgroupEquiv_neg_apply, this]
simp
· -- The next two lines were not needed before https://github.com/leanprover/lean4/pull/2644
dsimp
conv_lhs => erw [IsComplement.equiv_mul_left]
simp [Units.ext_iff, (d.compl (-u)).equiv_snd_eq_inv_mul, this,
-SetLike.coe_sort_coe]
/-- the equivalence given by multiplication on the left by `t` -/
@[simps]
noncomputable def unitsSMulEquiv : NormalWord d ≃ NormalWord d :=
{ toFun := unitsSMul φ 1
invFun := unitsSMul φ (-1),
left_inv := fun _ => by rw [unitsSMul_neg]
right_inv := fun w => by convert unitsSMul_neg _ _ w; simp }
theorem unitsSMul_one_group_smul (g : A) (w : NormalWord d) :
unitsSMul φ 1 ((g : G) • w) = (φ g : G) • (unitsSMul φ 1 w) := by
unfold unitsSMul
have : Cancels 1 ((g : G) • w) ↔ Cancels 1 w := by
simp [Cancels, Subgroup.mul_mem_cancel_left]
by_cases hcan : Cancels 1 w
· simp only [unitsSMulWithCancel, toSubgroup_one, id_eq, toSubgroup_neg_one, toSubgroupEquiv_one,
group_smul_head, mul_inv_rev, dif_pos (this.2 hcan), dif_pos hcan]
cases w using consRecOn
· simp [Cancels] at hcan
· simp only [smul_cons, consRecOn_cons]
rw [← mul_smul, ← Subgroup.coe_mul, ← map_mul φ]
rfl
· rw [dif_neg (mt this.1 hcan), dif_neg hcan]
-- Before https://github.com/leanprover/lean4/pull/2644, all this was just
-- `simp [← mul_smul, mul_assoc, unitsSMulGroup]`
simp only [toSubgroup_neg_one, unitsSMulGroup, toSubgroup_one, toSubgroupEquiv_one,
SetLike.coe_sort_coe, group_smul_head, mul_inv_rev, ← mul_smul, mul_assoc, inv_mul_cancel,
mul_one, smul_cons]
-- This used to be the end of the proof before https://github.com/leanprover/lean4/pull/2644
congr 1
· conv_lhs => erw [IsComplement.equiv_mul_left]
simp_rw [toSubgroup_one]
simp only [SetLike.coe_sort_coe, map_mul, Subgroup.coe_mul]
conv_lhs => erw [IsComplement.equiv_mul_left]
rfl
noncomputable instance : MulAction (HNNExtension G A B φ) (NormalWord d) :=
MulAction.ofEndHom <| (MulAction.toEndHom (M := Equiv.Perm (NormalWord d))).comp
(HNNExtension.lift (MulAction.toPermHom _ _) (unitsSMulEquiv φ) <| by
intro a
ext : 1
simp [unitsSMul_one_group_smul])
@[simp]
theorem prod_group_smul (g : G) (w : NormalWord d) :
(g • w).prod φ = of g * (w.prod φ) := by
simp [ReducedWord.prod, mul_assoc]
theorem of_smul_eq_smul (g : G) (w : NormalWord d) :
(of g : HNNExtension G A B φ) • w = g • w := by
simp [instHSMul, SMul.smul, MulAction.toEndHom]
theorem t_smul_eq_unitsSMul (w : NormalWord d) :
(t : HNNExtension G A B φ) • w = unitsSMul φ 1 w := by
simp [instHSMul, SMul.smul, MulAction.toEndHom]
theorem t_pow_smul_eq_unitsSMul (u : ℤˣ) (w : NormalWord d) :
(t ^ (u : ℤ) : HNNExtension G A B φ) • w = unitsSMul φ u w := by
rcases Int.units_eq_one_or u with (rfl | rfl) <;>
simp [instHSMul, SMul.smul, MulAction.toEndHom, Equiv.Perm.inv_def]
@[simp]
theorem prod_cons (g : G) (u : ℤˣ) (w : NormalWord d) (h1 : w.head ∈ d.set u)
(h2 : ∀ u' ∈ Option.map Prod.fst w.toList.head?,
w.head ∈ toSubgroup A B u → u = u') :
(cons g u w h1 h2).prod φ = of g * (t ^ (u : ℤ) * w.prod φ) := by
simp [ReducedWord.prod, cons, mul_assoc]
theorem prod_unitsSMul (u : ℤˣ) (w : NormalWord d) :
(unitsSMul φ u w).prod φ = (t ^ (u : ℤ) * w.prod φ : HNNExtension G A B φ) := by
rw [unitsSMul]
split_ifs with hcan
· cases w using consRecOn
· simp [Cancels] at hcan
· cases hcan.2
simp only [unitsSMulWithCancel, id_eq, consRecOn_cons, prod_group_smul, prod_cons, zpow_neg]
rcases Int.units_eq_one_or u with (rfl | rfl)
· simp [equiv_eq_conj, mul_assoc]
· -- Before https://github.com/leanprover/lean4/pull/2644, this proof was just
-- simp [equiv_symm_eq_conj, mul_assoc].
simp only [toSubgroup_neg_one, toSubgroupEquiv_neg_one, Units.val_neg, Units.val_one,
Int.reduceNeg, zpow_neg, zpow_one, inv_inv]
grind [equiv_symm_eq_conj, mul_assoc]
· simp only [unitsSMulGroup, SetLike.coe_sort_coe, prod_cons, prod_group_smul, map_mul, map_inv]
rcases Int.units_eq_one_or u with (rfl | rfl)
· -- Before https://github.com/leanprover/lean4/pull/2644, this proof was just
-- simp [equiv_eq_conj, mul_assoc, (d.compl _).equiv_snd_eq_inv_mul].
simp only [toSubgroup_neg_one, toSubgroup_one, toSubgroupEquiv_one, equiv_eq_conj, mul_assoc,
Units.val_one, zpow_one, inv_mul_cancel_left, mul_right_inj]
erw [(d.compl 1).equiv_snd_eq_inv_mul]
simp [mul_assoc]
· -- Before https://github.com/leanprover/lean4/pull/2644, this proof was just
-- simp [equiv_symm_eq_conj, mul_assoc, (d.compl _).equiv_snd_eq_inv_mul]
simp only [toSubgroup_neg_one, toSubgroupEquiv_neg_one, Units.val_neg, Units.val_one,
Int.reduceNeg, zpow_neg, zpow_one, mul_assoc]
erw [equiv_symm_eq_conj, (d.compl (-1)).equiv_snd_eq_inv_mul]
simp [mul_assoc]
@[simp]
theorem prod_empty : (empty : NormalWord d).prod φ = 1 := by
simp [ReducedWord.prod]
@[simp]
theorem prod_smul (g : HNNExtension G A B φ) (w : NormalWord d) :
(g • w).prod φ = g * w.prod φ := by
induction g using induction_on generalizing w with
| of => simp [of_smul_eq_smul]
| t => simp [t_smul_eq_unitsSMul, prod_unitsSMul]
| mul => simp_all [mul_smul, mul_assoc]
| inv x ih =>
rw [← mul_right_inj x, ← ih]
simp
@[simp]
theorem prod_smul_empty (w : NormalWord d) :
(w.prod φ) • empty = w := by
induction w using consRecOn with
| ofGroup => simp [ofGroup, ReducedWord.prod, of_smul_eq_smul, group_smul_def]
| cons g u w h1 h2 ih =>
rw [prod_cons, ← mul_assoc, mul_smul, ih, mul_smul, t_pow_smul_eq_unitsSMul,
of_smul_eq_smul, unitsSMul]
rw [dif_neg (not_cancels_of_cons_hyp u w h2)]
-- Before https://github.com/leanprover/lean4/pull/2644, this was just
-- simp [unitsSMulGroup, (d.compl _).equiv_fst_eq_one_of_mem_of_one_mem (one_mem _) h1,
-- -SetLike.coe_sort_coe]
-- ext <;> simp [-SetLike.coe_sort_coe]
simp only [unitsSMulGroup, (d.compl _).equiv_fst_eq_one_of_mem_of_one_mem (one_mem _) h1,
smul_cons]
ext <;> simp [-SetLike.coe_sort_coe]
rw [(d.compl _).equiv_snd_eq_inv_mul,
(d.compl _).equiv_fst_eq_one_of_mem_of_one_mem (one_mem _) h1]
simp
variable (d)
/-- The equivalence between elements of the HNN extension and words in normal form. -/
noncomputable def equiv : HNNExtension G A B φ ≃ NormalWord d :=
{ toFun := fun g => g • empty,
invFun := fun w => w.prod φ,
left_inv := fun g => by simp [prod_smul]
right_inv := fun w => by simp }
theorem prod_injective : Injective
(fun w => w.prod φ : NormalWord d → HNNExtension G A B φ) :=
(equiv φ d).symm.injective
instance : FaithfulSMul (HNNExtension G A B φ) (NormalWord d) :=
⟨fun h => by simpa using congr_arg (fun w => w.prod φ) (h empty)⟩
end NormalWord
open NormalWord
theorem of_injective : Function.Injective (of : G → HNNExtension G A B φ) := by
rcases TransversalPair.nonempty G A B with ⟨d⟩
refine Function.Injective.of_comp
(f := ((· • ·) : HNNExtension G A B φ → NormalWord d → NormalWord d)) ?_
intro _ _ h
exact eq_of_smul_eq_smul (fun w : NormalWord d =>
by simp_all [funext_iff, of_smul_eq_smul])
namespace ReducedWord
theorem exists_normalWord_prod_eq
(d : TransversalPair G A B) (w : ReducedWord G A B) :
∃ w' : NormalWord d, w'.prod φ = w.prod φ ∧
w'.toList.map Prod.fst = w.toList.map Prod.fst ∧
∀ u ∈ w.toList.head?.map Prod.fst,
w'.head⁻¹ * w.head ∈ toSubgroup A B (-u) := by
suffices ∀ w : ReducedWord G A B,
w.head = 1 → ∃ w' : NormalWord d, w'.prod φ = w.prod φ ∧
w'.toList.map Prod.fst = w.toList.map Prod.fst ∧
∀ u ∈ w.toList.head?.map Prod.fst,
w'.head ∈ toSubgroup A B (-u) by
by_cases hw1 : w.head = 1
· simp only [hw1, inv_mem_iff, mul_one]
exact this w hw1
· rcases this ⟨1, w.toList, w.chain⟩ rfl with ⟨w', hw'⟩
exact ⟨w.head • w', by
simpa [ReducedWord.prod, mul_assoc] using hw'⟩
intro w hw1
rcases w with ⟨g, l, chain⟩
dsimp at hw1; subst hw1
induction l with
| nil =>
exact
⟨{ head := 1
toList := []
mem_set := by simp
chain := List.isChain_nil }, by simp⟩
| cons a l ih =>
rcases ih (List.isChain_cons.1 chain).2 with ⟨w', hw'1, hw'2, hw'3⟩
clear ih
refine ⟨(t^(a.1 : ℤ) * of a.2 : HNNExtension G A B φ) • w', ?_, ?_⟩
· rw [prod_smul, hw'1]
simp [ReducedWord.prod]
· have : ¬ Cancels a.1 (a.2 • w') := by
simp only [Cancels, group_smul_head, group_smul_toList, Option.map_eq_some_iff,
Prod.exists, exists_and_right, exists_eq_right, not_and, not_exists]
intro hS x hx
have hx' := congr_arg (Option.map Prod.fst) hx
rw [← List.head?_map, hw'2, List.head?_map, Option.map_some] at hx'
have : w'.head ∈ toSubgroup A B a.fst := by
simpa using hw'3 _ hx'
rw [mul_mem_cancel_right this] at hS
have : a.fst = -a.fst := by
have hl : l ≠ [] := by rintro rfl; simp_all
have : a.fst = (l.head hl).fst := (List.isChain_cons.1 chain).1 (l.head hl)
(List.head?_eq_head _) hS
rwa [List.head?_eq_head hl, Option.map_some, ← this, Option.some_inj] at hx'
simp at this
rw [List.map_cons, mul_smul, of_smul_eq_smul, NormalWord.group_smul_def,
t_pow_smul_eq_unitsSMul, unitsSMul]
erw [dif_neg this]
rw [← hw'2]
simp [mul_assoc, unitsSMulGroup]
/-- Two reduced words representing the same element of the `HNNExtension G A B φ` have the same
length corresponding list, with the same pattern of occurrences of `t^1` and `t^(-1)`,
and also the `head` is in the same left coset of `toSubgroup A B (-u)`, where `u : ℤˣ`
is the exponent of the first occurrence of `t` in the word. -/
theorem map_fst_eq_and_of_prod_eq {w₁ w₂ : ReducedWord G A B}
(hprod : w₁.prod φ = w₂.prod φ) :
w₁.toList.map Prod.fst = w₂.toList.map Prod.fst ∧
∀ u ∈ w₁.toList.head?.map Prod.fst,
w₁.head⁻¹ * w₂.head ∈ toSubgroup A B (-u) := by
rcases TransversalPair.nonempty G A B with ⟨d⟩
rcases exists_normalWord_prod_eq φ d w₁ with ⟨w₁', hw₁'1, hw₁'2, hw₁'3⟩
rcases exists_normalWord_prod_eq φ d w₂ with ⟨w₂', hw₂'1, hw₂'2, hw₂'3⟩
have : w₁' = w₂' :=
NormalWord.prod_injective φ d (by dsimp only; rw [hw₁'1, hw₂'1, hprod])
subst this
refine ⟨by rw [← hw₁'2, hw₂'2], ?_⟩
simp only [← leftCoset_eq_iff] at *
intro u hu
rw [← hw₁'3 _ hu, ← hw₂'3 _]
rwa [← List.head?_map, ← hw₂'2, hw₁'2, List.head?_map]
/-- **Britton's Lemma**. Any reduced word whose product is an element of `G`, has no
occurrences of `t`. -/
theorem toList_eq_nil_of_mem_of_range (w : ReducedWord G A B)
(hw : w.prod φ ∈ (of.range : Subgroup (HNNExtension G A B φ))) :
w.toList = [] := by
rcases hw with ⟨g, hg⟩
let w' : ReducedWord G A B := { ReducedWord.empty G A B with head := g }
have : w.prod φ = w'.prod φ := by simp [w', ReducedWord.prod, hg]
simpa [w'] using (map_fst_eq_and_of_prod_eq φ this).1
end ReducedWord
end HNNExtension |
.lake/packages/mathlib/Mathlib/GroupTheory/Schreier.lean | import Mathlib.Algebra.Group.Pointwise.Finset.Basic
import Mathlib.GroupTheory.Abelianization.Defs
import Mathlib.GroupTheory.Commutator.Finite
import Mathlib.GroupTheory.Transfer
/-!
# Schreier's Lemma
In this file we prove Schreier's lemma.
## Main results
- `closure_mul_image_eq` : **Schreier's Lemma**: If `R : Set G` is a right_transversal
of `H : Subgroup G` with `1 ∈ R`, and if `G` is generated by `S : Set G`,
then `H` is generated by the `Set` `(R * S).image (fun g ↦ g * (hR.toRightFun g)⁻¹)`.
- `fg_of_index_ne_zero` : **Schreier's Lemma**: A finite index subgroup of a finitely generated
group is finitely generated.
- `card_commutator_le_of_finite_commutatorSet`: A theorem of Schur: The size of the commutator
subgroup is bounded in terms of the number of commutators.
-/
open scoped Finset Pointwise
section CommGroup
open Subgroup
variable (G : Type*) [CommGroup G] [Group.FG G]
@[to_additive]
theorem card_dvd_exponent_pow_rank : Nat.card G ∣ Monoid.exponent G ^ Group.rank G := by
classical
obtain ⟨S, hS1, hS2⟩ := Group.rank_spec G
rw [← hS1, ← Fintype.card_coe, ← Finset.card_univ, ← Finset.prod_const]
let f : (∀ g : S, zpowers (g : G)) →* G := noncommPiCoprod fun s t _ x y _ _ => mul_comm x _
have hf : Function.Surjective f := by
rw [← MonoidHom.range_eq_top, eq_top_iff, ← hS2, closure_le]
exact fun g hg => ⟨Pi.mulSingle ⟨g, hg⟩ ⟨g, mem_zpowers g⟩, noncommPiCoprod_mulSingle _ _⟩
replace hf := card_dvd_of_surjective f hf
rw [Nat.card_pi] at hf
refine hf.trans (Finset.prod_dvd_prod_of_dvd _ _ fun g _ => ?_)
rw [Nat.card_zpowers]
exact Monoid.order_dvd_exponent (g : G)
@[to_additive]
theorem card_dvd_exponent_pow_rank' {n : ℕ} (hG : ∀ g : G, g ^ n = 1) :
Nat.card G ∣ n ^ Group.rank G :=
(card_dvd_exponent_pow_rank G).trans
(pow_dvd_pow_of_dvd (Monoid.exponent_dvd_of_forall_pow_eq_one hG) (Group.rank G))
end CommGroup
namespace Subgroup
variable {G : Type*} [Group G] {H : Subgroup G} {R S : Set G}
theorem closure_mul_image_mul_eq_top
(hR : IsComplement H R) (hR1 : (1 : G) ∈ R) (hS : closure S = ⊤) :
(closure ((R * S).image fun g => g * (hR.toRightFun g : G)⁻¹)) * R = ⊤ := by
let f : G → R := hR.toRightFun
let U : Set G := (R * S).image fun g => g * (f g : G)⁻¹
change (closure U : Set G) * R = ⊤
refine top_le_iff.mp fun g _ => ?_
refine closure_induction_right ?_ ?_ ?_ (eq_top_iff.mp hS (mem_top g))
· exact ⟨1, (closure U).one_mem, 1, hR1, one_mul 1⟩
· rintro - - s hs ⟨u, hu, r, hr, rfl⟩
rw [show u * r * s = u * (r * s * (f (r * s) : G)⁻¹) * f (r * s) by group]
refine Set.mul_mem_mul ((closure U).mul_mem hu ?_) (f (r * s)).coe_prop
exact subset_closure ⟨r * s, Set.mul_mem_mul hr hs, rfl⟩
· rintro - - s hs ⟨u, hu, r, hr, rfl⟩
rw [show u * r * s⁻¹ = u * (f (r * s⁻¹) * s * r⁻¹)⁻¹ * f (r * s⁻¹) by group]
refine Set.mul_mem_mul ((closure U).mul_mem hu ((closure U).inv_mem ?_)) (f (r * s⁻¹)).2
refine subset_closure ⟨f (r * s⁻¹) * s, Set.mul_mem_mul (f (r * s⁻¹)).2 hs, ?_⟩
rw [mul_right_inj, inv_inj, ← Subtype.coe_mk r hr, ← Subtype.ext_iff, Subtype.coe_mk]
apply (isComplement_iff_existsUnique_mul_inv_mem.mp hR (f (r * s⁻¹) * s)).unique
(hR.mul_inv_toRightFun_mem (f (r * s⁻¹) * s))
rw [mul_assoc, ← inv_inv s, ← mul_inv_rev, inv_inv]
exact hR.toRightFun_mul_inv_mem (r * s⁻¹)
/-- **Schreier's Lemma**: If `R : Set G` is a `rightTransversal` of `H : Subgroup G`
with `1 ∈ R`, and if `G` is generated by `S : Set G`, then `H` is generated by the `Set`
`(R * S).image (fun g ↦ g * (hR.toRightFun g)⁻¹)`. -/
theorem closure_mul_image_eq (hR : IsComplement H R) (hR1 : (1 : G) ∈ R)
(hS : closure S = ⊤) : closure ((R * S).image fun g => g * (hR.toRightFun g : G)⁻¹) = H := by
have hU : closure ((R * S).image fun g => g * (hR.toRightFun g : G)⁻¹) ≤ H := by
rw [closure_le]
rintro - ⟨g, -, rfl⟩
exact hR.mul_inv_toRightFun_mem g
refine le_antisymm hU fun h hh => ?_
obtain ⟨g, hg, r, hr, rfl⟩ :=
show h ∈ _ from eq_top_iff.mp (closure_mul_image_mul_eq_top hR hR1 hS) (mem_top h)
suffices (⟨r, hr⟩ : R) = (⟨1, hR1⟩ : R) by
simpa only [show r = 1 from Subtype.ext_iff.mp this, mul_one]
apply (isComplement_iff_existsUnique_mul_inv_mem.mp hR r).unique
· rw [Subtype.coe_mk, mul_inv_cancel]
exact H.one_mem
· rw [Subtype.coe_mk, inv_one, mul_one]
exact (H.mul_mem_cancel_left (hU hg)).mp hh
/-- **Schreier's Lemma**: If `R : Set G` is a `rightTransversal` of `H : Subgroup G`
with `1 ∈ R`, and if `G` is generated by `S : Set G`, then `H` is generated by the `Set`
`(R * S).image (fun g ↦ g * (hR.toRightFun g)⁻¹)`. -/
theorem closure_mul_image_eq_top (hR : IsComplement H R) (hR1 : (1 : G) ∈ R)
(hS : closure S = ⊤) : closure ((R * S).image fun g =>
⟨g * (hR.toRightFun g : G)⁻¹, hR.mul_inv_toRightFun_mem g⟩ : Set H) = ⊤ := by
rw [eq_top_iff, ← map_subtype_le_map_subtype, MonoidHom.map_closure, Set.image_image]
exact (map_subtype_le ⊤).trans (ge_of_eq (closure_mul_image_eq hR hR1 hS))
/-- **Schreier's Lemma**: If `R : Finset G` is a `rightTransversal` of `H : Subgroup G`
with `1 ∈ R`, and if `G` is generated by `S : Finset G`, then `H` is generated by the `Finset`
`(R * S).image (fun g ↦ g * (hR.toRightFun g)⁻¹)`. -/
theorem closure_mul_image_eq_top' [DecidableEq G] {R S : Finset G}
(hR : IsComplement (H : Set G) R) (hR1 : (1 : G) ∈ R)
(hS : closure (S : Set G) = ⊤) :
closure (((R * S).image fun g => ⟨_, hR.mul_inv_toRightFun_mem g⟩ : Finset H) : Set H) = ⊤ := by
rw [Finset.coe_image, Finset.coe_mul]
exact closure_mul_image_eq_top hR hR1 hS
variable (H)
theorem exists_finset_card_le_mul [FiniteIndex H] {S : Finset G} (hS : closure (S : Set G) = ⊤) :
∃ T : Finset H, #T ≤ H.index * #S ∧ closure (T : Set H) = ⊤ := by
letI := H.fintypeQuotientOfFiniteIndex
haveI : DecidableEq G := Classical.decEq G
obtain ⟨R₀, hR, hR1⟩ := H.exists_isComplement_right 1
haveI : Fintype R₀ := Fintype.ofEquiv _ hR.rightQuotientEquiv
let R : Finset G := Set.toFinset R₀
replace hR : IsComplement (H : Set G) R := by rwa [Set.coe_toFinset]
replace hR1 : (1 : G) ∈ R := by rwa [Set.mem_toFinset]
refine ⟨_, ?_, closure_mul_image_eq_top' hR hR1 hS⟩
calc
_ ≤ #(R * S) := Finset.card_image_le
_ ≤ #R * #S := Finset.card_mul_le
_ = H.index * S.card := congr_arg (· * S.card) ?_
calc
#R = Fintype.card R := (Fintype.card_coe R).symm
_ = _ := (Fintype.card_congr hR.rightQuotientEquiv).symm
_ = Fintype.card (G ⧸ H) := QuotientGroup.card_quotient_rightRel H
_ = H.index := by rw [index_eq_card, Nat.card_eq_fintype_card]
/-- **Schreier's Lemma**: A finite index subgroup of a finitely generated
group is finitely generated. -/
instance fg_of_index_ne_zero [hG : Group.FG G] [FiniteIndex H] : Group.FG H := by
obtain ⟨S, hS⟩ := hG.1
obtain ⟨T, -, hT⟩ := exists_finset_card_le_mul H hS
exact ⟨⟨T, hT⟩⟩
theorem rank_le_index_mul_rank [hG : Group.FG G] [FiniteIndex H] :
Group.rank H ≤ H.index * Group.rank G := by
haveI := H.fg_of_index_ne_zero
obtain ⟨S, hS₀, hS⟩ := Group.rank_spec G
obtain ⟨T, hT₀, hT⟩ := exists_finset_card_le_mul H hS
calc
Group.rank H ≤ #T := Group.rank_le hT
_ ≤ H.index * #S := hT₀
_ = H.index * Group.rank G := congr_arg (H.index * ·) hS₀
variable (G)
/-- If `G` has `n` commutators `[g₁, g₂]`, then `|G'| ∣ [G : Z(G)] ^ ([G : Z(G)] * n + 1)`,
where `G'` denotes the commutator of `G`. -/
theorem card_commutator_dvd_index_center_pow [Finite (commutatorSet G)] :
Nat.card (_root_.commutator G) ∣
(center G).index ^ ((center G).index * Nat.card (commutatorSet G) + 1) := by
-- First handle the case when `Z(G)` has infinite index and `[G : Z(G)]` is defined to be `0`
by_cases hG : (center G).index = 0
· simp_rw [hG, zero_mul, zero_add, pow_one, dvd_zero]
haveI : FiniteIndex (center G) := ⟨hG⟩
-- Rewrite as `|Z(G) ∩ G'| * [G' : Z(G) ∩ G'] ∣ [G : Z(G)] ^ ([G : Z(G)] * n) * [G : Z(G)]`
rw [← ((center G).subgroupOf (_root_.commutator G)).card_mul_index, pow_succ]
-- We have `h1 : [G' : Z(G) ∩ G'] ∣ [G : Z(G)]`
have h1 := relIndex_dvd_index_of_normal (center G) (_root_.commutator G)
-- So we can reduce to proving `|Z(G) ∩ G'| ∣ [G : Z(G)] ^ ([G : Z(G)] * n)`
refine mul_dvd_mul ?_ h1
-- We know that `[G' : Z(G) ∩ G'] < ∞` by `h1` and `hG`
haveI : FiniteIndex ((center G).subgroupOf (_root_.commutator G)) :=
⟨ne_zero_of_dvd_ne_zero hG h1⟩
-- We have `h2 : rank (Z(G) ∩ G') ≤ [G' : Z(G) ∩ G'] * rank G'` by Schreier's lemma
have h2 := rank_le_index_mul_rank ((center G).subgroupOf (_root_.commutator G))
-- We have `h3 : [G' : Z(G) ∩ G'] * rank G' ≤ [G : Z(G)] * n` by `h1` and `rank G' ≤ n`
have h3 := Nat.mul_le_mul (Nat.le_of_dvd (Nat.pos_of_ne_zero hG) h1) (rank_commutator_le_card G)
-- So we can reduce to proving `|Z(G) ∩ G'| ∣ [G : Z(G)] ^ rank (Z(G) ∩ G')`
refine dvd_trans ?_ (pow_dvd_pow (center G).index (h2.trans h3))
-- `Z(G) ∩ G'` is abelian, so it enough to prove that `g ^ [G : Z(G)] = 1` for `g ∈ Z(G) ∩ G'`
apply card_dvd_exponent_pow_rank'
intro g
-- `Z(G)` is abelian, so `g ∈ Z(G) ∩ G' ≤ G' ≤ ker (transfer : G → Z(G))`
have := Abelianization.commutator_subset_ker (MonoidHom.transferCenterPow G) g.1.2
-- `transfer g` is defeq to `g ^ [G : Z(G)]`, so we are done
simpa only [MonoidHom.mem_ker, Subtype.ext_iff] using this
/-- A bound for the size of the commutator subgroup in terms of the number of commutators. -/
def cardCommutatorBound (n : ℕ) :=
(n ^ (2 * n)) ^ (n ^ (2 * n + 1) + 1)
/-- A theorem of Schur: The size of the commutator subgroup is bounded in terms of the number of
commutators. -/
theorem card_commutator_le_of_finite_commutatorSet [Finite (commutatorSet G)] :
Nat.card (_root_.commutator G) ≤ cardCommutatorBound (Nat.card (commutatorSet G)) := by
have h1 := index_center_le_pow (closureCommutatorRepresentatives G)
have h2 := card_commutator_dvd_index_center_pow (closureCommutatorRepresentatives G)
rw [card_commutatorSet_closureCommutatorRepresentatives] at h1 h2
rw [card_commutator_closureCommutatorRepresentatives] at h2
replace h1 :=
h1.trans
(Nat.pow_le_pow_right Finite.card_pos (rank_closureCommutatorRepresentatives_le G))
replace h2 := h2.trans (pow_dvd_pow _ (add_le_add_right (mul_le_mul_right' h1 _) 1))
rw [← pow_succ] at h2
refine (Nat.le_of_dvd ?_ h2).trans (Nat.pow_le_pow_left h1 _)
exact pow_pos (Nat.pos_of_ne_zero FiniteIndex.index_ne_zero) _
/-- A theorem of Schur: A group with finitely many commutators has finite commutator subgroup. -/
instance [Finite (commutatorSet G)] : Finite (_root_.commutator G) := by
have h2 := card_commutator_dvd_index_center_pow (closureCommutatorRepresentatives G)
refine Nat.finite_of_card_ne_zero fun h => ?_
rw [card_commutator_closureCommutatorRepresentatives, h, zero_dvd_iff] at h2
exact FiniteIndex.index_ne_zero (eq_zero_of_pow_eq_zero h2)
end Subgroup |
.lake/packages/mathlib/Mathlib/GroupTheory/NoncommCoprod.lean | import Mathlib.Algebra.Group.Commute.Hom
import Mathlib.Algebra.Group.Prod
import Mathlib.Algebra.Group.Subgroup.Ker
import Mathlib.Algebra.Group.Subgroup.Lattice
import Mathlib.Order.Disjoint
/-!
# Canonical homomorphism from a pair of monoids
This file defines the construction of the canonical homomorphism from a pair of monoids.
Given two morphisms of monoids `f : M →* P` and `g : N →* P` where elements in the images
of the two morphisms commute, we obtain a canonical morphism
`MonoidHom.noncommCoprod : M × N →* P` whose composition with `inl M N` coincides with `f`
and whose composition with `inr M N` coincides with `g`.
There is an analogue `MulHom.noncommCoprod` when `f` and `g` are only `MulHom`s.
## Main theorems:
* `noncommCoprod_comp_inr` and `noncommCoprod_comp_inl` prove that the compositions
of `MonoidHom.noncommCoprod f g _` with `inl M N` and `inr M N` coincide with `f` and `g`.
* `comp_noncommCoprod` proves that the composition of a morphism of monoids `h`
with `noncommCoprod f g _` coincides with `noncommCoprod (h.comp f) (h.comp g)`.
For a product of a family of morphisms of monoids, see `MonoidHom.noncommPiCoprod`.
-/
assert_not_exists MonoidWithZero
namespace MulHom
variable {M N P : Type*} [Mul M] [Mul N] [Semigroup P]
(f : M →ₙ* P) (g : N →ₙ* P)
/-- Coproduct of two `MulHom`s with the same codomain with `Commute` assumption:
`f.noncommCoprod g _ (p : M × N) = f p.1 * g p.2`.
(For the commutative case, use `MulHom.coprod`) -/
@[to_additive (attr := simps)
/-- Coproduct of two `AddHom`s with the same codomain with `AddCommute` assumption:
`f.noncommCoprod g _ (p : M × N) = f p.1 + g p.2`.
(For the commutative case, use `AddHom.coprod`) -/]
def noncommCoprod (comm : ∀ m n, Commute (f m) (g n)) : M × N →ₙ* P where
toFun mn := f mn.fst * g mn.snd
map_mul' mn mn' := by simpa using (comm _ _).mul_mul_mul_comm _ _
/-- Variant of `MulHom.noncommCoprod_apply` with the product written in the other direction. -/
@[to_additive
/-- Variant of `AddHom.noncommCoprod_apply`, with the sum written in the other direction -/]
theorem noncommCoprod_apply' (comm) (mn : M × N) :
(f.noncommCoprod g comm) mn = g mn.2 * f mn.1 := by
rw [← comm, noncommCoprod_apply]
@[to_additive]
theorem comp_noncommCoprod {Q : Type*} [Semigroup Q] (h : P →ₙ* Q)
(comm : ∀ m n, Commute (f m) (g n)) :
h.comp (f.noncommCoprod g comm) =
(h.comp f).noncommCoprod (h.comp g) (fun m n ↦ (comm m n).map h) :=
ext fun _ => map_mul h _ _
end MulHom
namespace MonoidHom
variable {M N P : Type*} [MulOneClass M] [MulOneClass N] [Monoid P]
(f : M →* P) (g : N →* P) (comm : ∀ m n, Commute (f m) (g n))
/-- Coproduct of two `MonoidHom`s with the same codomain,
with a commutation assumption:
`f.noncommCoprod g _ (p : M × N) = f p.1 * g p.2`.
(Noncommutative case; in the commutative case, use `MonoidHom.coprod`.) -/
@[to_additive (attr := simps)
/-- Coproduct of two `AddMonoidHom`s with the same codomain,
with a commutation assumption:
`f.noncommCoprod g (p : M × N) = f p.1 + g p.2`.
(Noncommutative case; in the commutative case, use `AddHom.coprod`.) -/]
def noncommCoprod : M × N →* P where
toFun := fun mn ↦ (f mn.fst) * (g mn.snd)
map_one' := by simp only [Prod.fst_one, Prod.snd_one, map_one, mul_one]
__ := f.toMulHom.noncommCoprod g.toMulHom comm
/-- Variant of `MonoidHom.noncomCoprod_apply` with the product written in the other direction. -/
@[to_additive
/-- Variant of `AddMonoidHom.noncomCoprod_apply` with the sum written in the other direction -/]
theorem noncommCoprod_apply' (comm) (mn : M × N) :
(f.noncommCoprod g comm) mn = g mn.2 * f mn.1 := by
rw [← comm, MonoidHom.noncommCoprod_apply]
@[to_additive (attr := simp)]
theorem noncommCoprod_comp_inl : (f.noncommCoprod g comm).comp (inl M N) = f :=
ext fun x => by simp
@[to_additive (attr := simp)]
theorem noncommCoprod_comp_inr : (f.noncommCoprod g comm).comp (inr M N) = g :=
ext fun x => by simp
@[to_additive (attr := simp)]
theorem noncommCoprod_unique (f : M × N →* P) :
(f.comp (inl M N)).noncommCoprod (f.comp (inr M N)) (fun _ _ => (commute_inl_inr _ _).map f)
= f :=
ext fun x => by simp [inl_apply, inr_apply, ← map_mul]
@[to_additive (attr := simp)]
theorem noncommCoprod_inl_inr {M N : Type*} [Monoid M] [Monoid N] :
(inl M N).noncommCoprod (inr M N) commute_inl_inr = id (M × N) :=
noncommCoprod_unique <| .id (M × N)
@[to_additive]
theorem comp_noncommCoprod {Q : Type*} [Monoid Q] (h : P →* Q) :
h.comp (f.noncommCoprod g comm) =
(h.comp f).noncommCoprod (h.comp g) (fun m n ↦ (comm m n).map h) :=
ext fun x => by simp
section group
open Subgroup
lemma noncommCoprod_injective {M N P : Type*} [Group M] [Group N] [Group P]
(f : M →* P) (g : N →* P) (comm : ∀ (m : M) (n : N), Commute (f m) (g n)) :
Function.Injective (noncommCoprod f g comm) ↔
(Function.Injective f ∧ Function.Injective g ∧ _root_.Disjoint f.range g.range) := by
simp only [injective_iff_map_eq_one, disjoint_iff_inf_le,
noncommCoprod_apply, Prod.forall, Prod.mk_eq_one]
refine ⟨fun h ↦ ⟨fun x ↦ ?_, fun x ↦ ?_, ?_⟩, ?_⟩
· simpa using h x 1
· simpa using h 1 x
· intro x ⟨⟨y, hy⟩, z, hz⟩
rwa [(h y z⁻¹ (by rw [map_inv, hy, hz, mul_inv_cancel])).1, map_one, eq_comm] at hy
· intro ⟨hf, hg, hp⟩ a b h
have key := hp ⟨⟨a⁻¹, by rwa [map_inv, inv_eq_iff_mul_eq_one]⟩, b, rfl⟩
exact ⟨hf a (by rwa [key, mul_one] at h), hg b key⟩
lemma noncommCoprod_range {M N P : Type*} [Group M] [Group N] [Group P]
(f : M →* P) (g : N →* P) (comm : ∀ (m : M) (n : N), Commute (f m) (g n)) :
(noncommCoprod f g comm).range = f.range ⊔ g.range := by
apply le_antisymm
· rintro - ⟨a, rfl⟩
exact mul_mem (mem_sup_left ⟨a.1, rfl⟩) (mem_sup_right ⟨a.2, rfl⟩)
· rw [sup_le_iff]
constructor
· rintro - ⟨a, rfl⟩
exact ⟨(a, 1), by rw [noncommCoprod_apply, map_one, mul_one]⟩
· rintro - ⟨a, rfl⟩
exact ⟨(1, a), by rw [noncommCoprod_apply, map_one, one_mul]⟩
end group
end MonoidHom |
.lake/packages/mathlib/Mathlib/GroupTheory/RegularWreathProduct.lean | import Mathlib.GroupTheory.Sylow
import Mathlib.Algebra.Group.PUnit
import Mathlib.Data.Finite.Perm
import Mathlib.Algebra.Group.End
/-!
# Regular wreath product
This file defines the regular wreath product of groups, and the canonical maps in and out of the
product. The regular wreath product of `D` and `Q` is the product `(Q → D) × Q` with the group
operation `⟨a₁, a₂⟩ * ⟨b₁, b₂⟩ = ⟨a₁ * (fun x ↦ b₁ (a₂⁻¹ * x)), a₂ * b₂⟩`.
## Main definitions
* `RegularWreathProduct D Q` : The regular wreath product of groups `D` and `Q`.
* `rightHom` : The canonical projection `D ≀ᵣ Q →* Q`.
* `inl` : The canonical map `Q →* D ≀ᵣ Q`.
* `toPerm` : The homomorphism from `D ≀ᵣ Q` to `Equiv.Perm (Λ × Q)`, where `Λ` is a `D`-set.
* `IteratedWreathProduct G n` : The iterated wreath product of a group `G` `n` times.
* `Sylow.mulEquivIteratedWreathProduct` : The isomorphism between the Sylow `p`-subgroup of `Perm
p^n` and the iterated wreath product of the cyclic group of order `p` `n` times.
## Notation
This file introduces the global notation `D ≀ᵣ Q` for `RegularWreathProduct D Q`.
## Tags
group, regular wreath product, sylow p-subgroup
-/
variable (D Q : Type*) [Group D] [Group Q]
/-- The regular wreath product of groups `Q` and `D`. It is the product `(Q → D) × Q` with the group
operation `⟨a₁, a₂⟩ * ⟨b₁, b₂⟩ = ⟨a₁ * (fun x ↦ b₁ (a₂⁻¹ * x)), a₂ * b₂⟩`. -/
@[ext]
structure RegularWreathProduct where
/-- The function of Q → D -/
left : Q → D
/-- The element of Q -/
right : Q
@[inherit_doc] infix:65 " ≀ᵣ " => RegularWreathProduct
namespace RegularWreathProduct
variable {D Q}
instance : Mul (D ≀ᵣ Q) where
mul a b := ⟨a.1 * (fun x ↦ b.1 (a.2⁻¹ * x)), a.2 * b.2⟩
lemma mul_def (a b : D ≀ᵣ Q) : a * b = ⟨a.1 * fun x ↦ b.1 (a.2⁻¹ * x), a.2 * b.2⟩ := rfl
@[simp]
theorem mul_left (a b : D ≀ᵣ Q) : (a * b).1 = a.1 * fun x ↦ b.1 (a.2⁻¹ * x) := rfl
@[simp]
theorem mul_right (a b : D ≀ᵣ Q) : (a * b).right = a.right * b.right := rfl
instance : One (RegularWreathProduct D Q) where one := ⟨1, 1⟩
@[simp]
theorem one_left : (1 : D ≀ᵣ Q).left = 1 := rfl
@[simp]
theorem one_right : (1 : D ≀ᵣ Q).right = 1 := rfl
instance : Inv (RegularWreathProduct D Q) where
inv x := ⟨fun k ↦ x.1⁻¹ (x.2 * k), x.2⁻¹⟩
@[simp]
theorem inv_left (a : D ≀ᵣ Q) : a⁻¹.left = fun x ↦ a.left⁻¹ (a.right * x) := rfl
@[simp]
theorem inv_right (a : D ≀ᵣ Q) : a⁻¹.right = a.right⁻¹ := rfl
instance : Group (RegularWreathProduct D Q) where
mul_assoc a b c := by ext <;> simp [mul_assoc]
one_mul a := by ext <;> simp
mul_one a := by ext <;> simp
inv_mul_cancel a := by ext <;> simp
instance : Inhabited (RegularWreathProduct D Q) := ⟨1⟩
/-- The canonical projection map `D ≀ᵣ Q →* Q`, as a group hom. -/
def rightHom : D ≀ᵣ Q →* Q where
toFun := RegularWreathProduct.right
map_one' := rfl
map_mul' _ _ := rfl
/-- The canonical map `Q →* D ≀ᵣ Q` sending `q` to `⟨1, q⟩` -/
def inl : Q →* D ≀ᵣ Q where
toFun q := ⟨1, q⟩
map_one' := rfl
map_mul' _ _ := by ext <;> simp
@[simp]
theorem left_inl (q : Q) : (inl q : D ≀ᵣ Q).left = 1 := rfl
@[simp]
theorem right_inl (q : Q) : (inl q : D ≀ᵣ Q).right = q := rfl
@[simp]
theorem rightHom_eq_right : (rightHom : D ≀ᵣ Q → Q) = right := rfl
@[simp]
theorem rightHom_comp_inl_eq_id : (rightHom : D ≀ᵣ Q →* Q).comp inl = MonoidHom.id _ := by ext; simp
@[simp]
theorem fun_id (q : Q) : rightHom (inl q : D ≀ᵣ Q) = q := by simp
/-- The equivalence map for the representation as a product. -/
def equivProd D Q : D ≀ᵣ Q ≃ (Q → D) × Q where
toFun := fun ⟨d, q⟩ => ⟨d, q⟩
invFun := fun ⟨d, q⟩ => ⟨d, q⟩
left_inv := fun _ => rfl
right_inv := fun _ => rfl
instance [Finite D] [Finite Q] : Finite (D ≀ᵣ Q) :=
Finite.of_equiv _ (equivProd D Q).symm
omit [Group D] [Group Q] in
theorem card [Finite Q] : Nat.card (D ≀ᵣ Q) = Nat.card D ^ Nat.card Q * Nat.card Q := by
rw [Nat.card_congr (equivProd D Q), Nat.card_prod (Q → D) Q, Nat.card_fun]
/-- Define an isomorphism from `D₁ ≀ᵣ Q₁` to `D₂ ≀ᵣ Q₂`
given isomorphisms `D₁ ≀ᵣ Q₁` and `Q₁ ≃* Q₂`. -/
def congr {D₁ Q₁ D₂ Q₂ : Type*} [Group D₁] [Group Q₁] [Group D₂] [Group Q₂]
(f : D₁ ≃* D₂) (g : Q₁ ≃* Q₂) :
D₁ ≀ᵣ Q₁ ≃* D₂ ≀ᵣ Q₂ where
toFun x := ⟨f ∘ (x.left ∘ g.symm), g x.right⟩
invFun x := ⟨(f.symm ∘ x.left) ∘ g, g.symm x.right⟩
left_inv x := by ext <;> simp
right_inv x := by ext <;> simp
map_mul' x y := by ext <;> simp
section perm
variable (D Q) (Λ : Type*) [MulAction D Λ]
instance : SMul (D ≀ᵣ Q) (Λ × Q) where
smul w p := ⟨(w.left (w.right * p.2)) • p.1, w.right * p.2⟩
@[simp]
lemma smul_def {w : D ≀ᵣ Q} {p : Λ × Q} : w • p = ⟨(w.1 (w.2 * p.2)) • p.1, w.2 * p.2⟩ := rfl
instance : MulAction (D ≀ᵣ Q) (Λ × Q) where
one_smul := by simp
mul_smul := by simp [smul_smul, mul_assoc]
variable [FaithfulSMul D Λ]
instance [Nonempty Q] [Nonempty Λ] : FaithfulSMul (D ≀ᵣ Q) (Λ × Q) where
eq_of_smul_eq_smul := by
simp only [smul_def, Prod.mk.injEq, mul_left_inj, Prod.forall]
intro m₁ m₂ h
let ⟨a⟩ := ‹Nonempty Λ›
let ⟨b⟩ := ‹Nonempty Q›
ext q
· have hh := fun a => (h a (m₁.right⁻¹ * q)).1
rw [← (h a b).2] at hh
group at hh
exact FaithfulSMul.eq_of_smul_eq_smul hh
· exact (h a b).2
/-- The map sending the wreath product `D ≀ᵣ Q` to its representation as a permutation of `Λ × Q`
given `D`-set `Λ`. -/
def toPerm : D ≀ᵣ Q →* Equiv.Perm (Λ × Q) :=
MulAction.toPermHom (D ≀ᵣ Q) (Λ × Q)
theorem toPermInj [Nonempty Λ] : Function.Injective (toPerm D Q Λ) := MulAction.toPerm_injective
end perm
end RegularWreathProduct
section iterated
universe u
/-- The wreath product of group `G` iterated `n` times. -/
def IteratedWreathProduct (G : Type u) : (n : ℕ) → Type u
| 0 => PUnit
| n + 1 => (IteratedWreathProduct G n) ≀ᵣ G
variable (G : Type u) (n : ℕ)
@[simp]
lemma IteratedWreathProduct_zero : IteratedWreathProduct G 0 = PUnit := rfl
@[simp]
lemma IteratedWreathProduct_succ :
IteratedWreathProduct G (n + 1) = (IteratedWreathProduct G n) ≀ᵣ G := rfl
instance [Finite G] : Finite (IteratedWreathProduct G n) := by
induction n with
| zero => rw [IteratedWreathProduct_zero]; infer_instance
| succ n h => rw [IteratedWreathProduct_succ]; infer_instance
theorem IteratedWreathProduct.card [Finite G] : Nat.card (IteratedWreathProduct G n) =
Nat.card G ^ (∑ i ∈ Finset.range n, Nat.card G ^ i) := by
induction n with
| zero => simp
| succ n h => rw [IteratedWreathProduct_succ, RegularWreathProduct.card,
h, geom_sum_succ, pow_succ, pow_mul']
variable [Group G]
instance : Group (IteratedWreathProduct G n) := by
induction n with
| zero => rw [IteratedWreathProduct_zero]; infer_instance
| succ n ih => rw [IteratedWreathProduct_succ]; infer_instance
/-- The homomorphism from `IteratedWreathProduct G n` to `Perm (Fin n → G)`. -/
def iteratedWreathToPermHom (G : Type*) [Group G] :
(n : ℕ) → (IteratedWreathProduct G n →* Equiv.Perm (Fin n → G))
| 0 => 1
| n + 1 => by
let _ := MulAction.compHom (Fin n → G) (iteratedWreathToPermHom G n)
exact (Fin.succFunEquiv G n).symm.permCongrHom.toMonoidHom.comp
(RegularWreathProduct.toPerm (IteratedWreathProduct G n) G (Fin n → G))
lemma iteratedWreathToPermHomInj (G : Type*) [Group G] :
(n : ℕ) → Function.Injective (iteratedWreathToPermHom G n)
| 0 => by
simp only [IteratedWreathProduct_zero]
apply Function.injective_of_subsingleton
| n + 1 => by
let _ := MulAction.compHom (Fin n → G) (iteratedWreathToPermHom G n)
have : FaithfulSMul (IteratedWreathProduct G n) (Fin n → G) :=
⟨fun h ↦ iteratedWreathToPermHomInj G n (Equiv.ext h)⟩
exact ((Fin.succFunEquiv G n).symm.permCongrHom.toEquiv.comp_injective _).mpr
(RegularWreathProduct.toPermInj (IteratedWreathProduct G n) G (Fin n → G))
/-- The encoding of the Sylow `p`-subgroups of `Perm α` as an iterated wreath product. -/
noncomputable def Sylow.mulEquivIteratedWreathProduct (p : ℕ) [hp : Fact (Nat.Prime p)] (n : ℕ)
(α : Type*) [Finite α] (hα : Nat.card α = p ^ n)
(G : Type*) [Group G] [Finite G] (hG : Nat.card G = p)
(P : Sylow p (Equiv.Perm α)) :
P ≃* IteratedWreathProduct G n := by
let e1 : α ≃ (Fin n → G) := (Finite.equivFinOfCardEq hα).trans
(Finite.equivFinOfCardEq (by rw [Nat.card_fun, Nat.card_fin, hG])).symm
let f := e1.symm.permCongrHom.toMonoidHom.comp (iteratedWreathToPermHom G n)
have hf : Function.Injective f :=
(e1.symm.permCongrHom.comp_injective _).mpr (iteratedWreathToPermHomInj G n)
let g := (MonoidHom.ofInjective hf).symm
let P' : Sylow p (Equiv.Perm α) := Sylow.ofCard (MonoidHom.range f) (by
rw [Nat.card_congr g.toEquiv, IteratedWreathProduct.card, hG, Nat.card_perm, hα,
← Nat.multiplicity_eq_factorization hp.out (p ^ n).factorial_ne_zero,
Nat.Prime.multiplicity_factorial_pow hp.out])
exact (P.equiv P').trans g
end iterated |
.lake/packages/mathlib/Mathlib/GroupTheory/Exponent.lean | import Mathlib.Algebra.GCDMonoid.Finset
import Mathlib.Algebra.GCDMonoid.Nat
import Mathlib.Algebra.Order.BigOperators.Ring.Finset
import Mathlib.Data.Nat.Factorization.LCM
import Mathlib.GroupTheory.OrderOfElement
import Mathlib.Tactic.Peel
/-!
# Exponent of a group
This file defines the exponent of a group, or more generally a monoid. For a group `G` it is defined
to be the minimal `n≥1` such that `g ^ n = 1` for all `g ∈ G`. For a finite group `G`,
it is equal to the lowest common multiple of the order of all elements of the group `G`.
## Main definitions
* `Monoid.ExponentExists` is a predicate on a monoid `G` saying that there is some positive `n`
such that `g ^ n = 1` for all `g ∈ G`.
* `Monoid.exponent` defines the exponent of a monoid `G` as the minimal positive `n` such that
`g ^ n = 1` for all `g ∈ G`, by convention it is `0` if no such `n` exists.
* `AddMonoid.ExponentExists` the additive version of `Monoid.ExponentExists`.
* `AddMonoid.exponent` the additive version of `Monoid.exponent`.
## Main results
* `Monoid.lcm_order_eq_exponent`: For a finite left cancel monoid `G`, the exponent is equal to the
`Finset.lcm` of the order of its elements.
* `Monoid.exponent_eq_iSup_orderOf(')`: For a commutative cancel monoid, the exponent is
equal to `⨆ g : G, orderOf g` (or zero if it has any order-zero elements).
* `Monoid.exponent_pi` and `Monoid.exponent_prod`: The exponent of a finite product of monoids is
the least common multiple (`Finset.lcm` and `lcm`, respectively) of the exponents of the
constituent monoids.
* `MonoidHom.exponent_dvd`: If `f : M₁ →⋆ M₂` is surjective, then the exponent of `M₂` divides the
exponent of `M₁`.
## TODO
* Refactor the characteristic of a ring to be the exponent of its underlying additive group.
-/
universe u
variable {G : Type u}
namespace Monoid
section Monoid
variable (G) [Monoid G]
/-- A predicate on a monoid saying that there is a positive integer `n` such that `g ^ n = 1`
for all `g`. -/
@[to_additive
/-- A predicate on an additive monoid saying that there is a positive integer `n` such that
`n • g = 0` for all `g`. -/]
def ExponentExists :=
∃ n, 0 < n ∧ ∀ g : G, g ^ n = 1
open scoped Classical in
/-- The exponent of a group is the smallest positive integer `n` such that `g ^ n = 1` for all
`g ∈ G` if it exists, otherwise it is zero by convention. -/
@[to_additive
/-- The exponent of an additive group is the smallest positive integer `n` such that
`n • g = 0` for all `g ∈ G` if it exists, otherwise it is zero by convention. -/]
noncomputable def exponent :=
if h : ExponentExists G then Nat.find h else 0
variable {G}
@[simp]
theorem _root_.AddMonoid.exponent_additive :
AddMonoid.exponent (Additive G) = exponent G := rfl
@[simp]
theorem exponent_multiplicative {G : Type*} [AddMonoid G] :
exponent (Multiplicative G) = AddMonoid.exponent G := rfl
open MulOpposite in
@[to_additive (attr := simp)]
theorem _root_.MulOpposite.exponent : exponent (MulOpposite G) = exponent G := by
simp only [Monoid.exponent, ExponentExists]
congr!
all_goals exact ⟨(op_injective <| · <| op ·), (unop_injective <| · <| unop ·)⟩
@[to_additive]
theorem ExponentExists.isOfFinOrder (h : ExponentExists G) {g : G} : IsOfFinOrder g :=
isOfFinOrder_iff_pow_eq_one.mpr <| by peel 2 h; exact this g
@[to_additive]
theorem ExponentExists.orderOf_pos (h : ExponentExists G) (g : G) : 0 < orderOf g :=
h.isOfFinOrder.orderOf_pos
@[to_additive]
theorem exponent_ne_zero : exponent G ≠ 0 ↔ ExponentExists G := by
rw [exponent]
split_ifs with h
· simp [h]
--if this isn't done this way, `to_additive` freaks
· tauto
@[to_additive]
protected alias ⟨_, ExponentExists.exponent_ne_zero⟩ := exponent_ne_zero
@[to_additive]
theorem exponent_pos : 0 < exponent G ↔ ExponentExists G :=
pos_iff_ne_zero.trans exponent_ne_zero
@[to_additive]
protected alias ⟨_, ExponentExists.exponent_pos⟩ := exponent_pos
@[to_additive]
theorem exponent_eq_zero_iff : exponent G = 0 ↔ ¬ExponentExists G :=
exponent_ne_zero.not_right
@[to_additive exponent_eq_zero_addOrder_zero]
theorem exponent_eq_zero_of_order_zero {g : G} (hg : orderOf g = 0) : exponent G = 0 :=
exponent_eq_zero_iff.mpr fun h ↦ h.orderOf_pos g |>.ne' hg
@[to_additive]
theorem exponent_eq_sInf :
Monoid.exponent G = sInf {d : ℕ | 0 < d ∧ ∀ x : G, x ^ d = 1} := by
by_cases h : Monoid.ExponentExists G
· have h' : {d : ℕ | 0 < d ∧ ∀ x : G, x ^ d = 1}.Nonempty := h
rw [Monoid.exponent, dif_pos h, Nat.sInf_def h']
congr
· have : {d | 0 < d ∧ ∀ (x : G), x ^ d = 1} = ∅ :=
Set.eq_empty_of_forall_notMem fun n hn ↦ h ⟨n, hn⟩
rw [Monoid.exponent_eq_zero_iff.mpr h, this, Nat.sInf_empty]
/-- The exponent is zero iff for all nonzero `n`, one can find a `g` such that `g ^ n ≠ 1`. -/
@[to_additive /-- The exponent is zero iff for all nonzero `n`, one can find a `g` such that
`n • g ≠ 0`. -/]
theorem exponent_eq_zero_iff_forall : exponent G = 0 ↔ ∀ n > 0, ∃ g : G, g ^ n ≠ 1 := by
rw [exponent_eq_zero_iff, ExponentExists]
push_neg
rfl
@[to_additive exponent_nsmul_eq_zero]
theorem pow_exponent_eq_one (g : G) : g ^ exponent G = 1 := by
classical
by_cases h : ExponentExists G
· simp_rw [exponent, dif_pos h]
exact (Nat.find_spec h).2 g
· simp_rw [exponent, dif_neg h, pow_zero]
@[to_additive]
theorem pow_eq_mod_exponent {n : ℕ} (g : G) : g ^ n = g ^ (n % exponent G) :=
calc
g ^ n = g ^ (n % exponent G + exponent G * (n / exponent G)) := by rw [Nat.mod_add_div]
_ = g ^ (n % exponent G) := by simp [pow_add, pow_mul, pow_exponent_eq_one]
@[to_additive]
theorem exponent_pos_of_exists (n : ℕ) (hpos : 0 < n) (hG : ∀ g : G, g ^ n = 1) :
0 < exponent G :=
ExponentExists.exponent_pos ⟨n, hpos, hG⟩
@[to_additive]
theorem exponent_min' (n : ℕ) (hpos : 0 < n) (hG : ∀ g : G, g ^ n = 1) : exponent G ≤ n := by
classical
rw [exponent, dif_pos]
· apply Nat.find_min'
exact ⟨hpos, hG⟩
· exact ⟨n, hpos, hG⟩
@[to_additive]
theorem exponent_min (m : ℕ) (hpos : 0 < m) (hm : m < exponent G) : ∃ g : G, g ^ m ≠ 1 := by
by_contra! h
have hcon : exponent G ≤ m := exponent_min' m hpos h
cutsat
@[to_additive AddMonoid.exp_eq_one_iff]
theorem exp_eq_one_iff : exponent G = 1 ↔ Subsingleton G := by
refine ⟨fun eq_one => ⟨fun a b => ?a_eq_b⟩, fun h => le_antisymm ?le ?ge⟩
· rw [← pow_one a, ← pow_one b, ← eq_one, Monoid.pow_exponent_eq_one, Monoid.pow_exponent_eq_one]
· apply exponent_min' _ Nat.one_pos
simp [eq_iff_true_of_subsingleton]
· apply Nat.succ_le_of_lt
apply exponent_pos_of_exists 1 Nat.one_pos
simp [eq_iff_true_of_subsingleton]
@[to_additive (attr := simp) AddMonoid.exp_eq_one_of_subsingleton]
theorem exp_eq_one_of_subsingleton [hs : Subsingleton G] : exponent G = 1 :=
exp_eq_one_iff.mpr hs
@[to_additive addOrder_dvd_exponent]
theorem order_dvd_exponent (g : G) : orderOf g ∣ exponent G :=
orderOf_dvd_of_pow_eq_one <| pow_exponent_eq_one g
@[to_additive]
theorem orderOf_le_exponent (h : ExponentExists G) (g : G) : orderOf g ≤ exponent G :=
Nat.le_of_dvd h.exponent_pos (order_dvd_exponent g)
@[to_additive]
theorem exponent_dvd_iff_forall_pow_eq_one {n : ℕ} : exponent G ∣ n ↔ ∀ g : G, g ^ n = 1 := by
rcases n.eq_zero_or_pos with (rfl | hpos)
· simp
constructor
· intro h g
rw [Nat.dvd_iff_mod_eq_zero] at h
rw [pow_eq_mod_exponent, h, pow_zero]
· intro hG
by_contra h
rw [Nat.dvd_iff_mod_eq_zero, ← Ne, ← pos_iff_ne_zero] at h
have h₂ : n % exponent G < exponent G := Nat.mod_lt _ (exponent_pos_of_exists n hpos hG)
have h₃ : exponent G ≤ n % exponent G := by
apply exponent_min' _ h
simp_rw [← pow_eq_mod_exponent]
exact hG
exact h₂.not_ge h₃
@[to_additive]
alias ⟨_, exponent_dvd_of_forall_pow_eq_one⟩ := exponent_dvd_iff_forall_pow_eq_one
@[to_additive]
theorem exponent_dvd {n : ℕ} : exponent G ∣ n ↔ ∀ g : G, orderOf g ∣ n := by
simp_rw [exponent_dvd_iff_forall_pow_eq_one, orderOf_dvd_iff_pow_eq_one]
variable (G)
@[to_additive]
theorem lcm_orderOf_dvd_exponent [Fintype G] :
(Finset.univ : Finset G).lcm orderOf ∣ exponent G := by
apply Finset.lcm_dvd
intro g _
exact order_dvd_exponent g
@[to_additive exists_addOrderOf_eq_pow_padic_val_nat_add_exponent]
theorem _root_.Nat.Prime.exists_orderOf_eq_pow_factorization_exponent {p : ℕ} (hp : p.Prime) :
∃ g : G, orderOf g = p ^ (exponent G).factorization p := by
haveI := Fact.mk hp
rcases eq_or_ne ((exponent G).factorization p) 0 with (h | h)
· refine ⟨1, by rw [h, pow_zero, orderOf_one]⟩
have he : 0 < exponent G :=
Ne.bot_lt fun ht => by
rw [ht] at h
apply h
rw [bot_eq_zero, Nat.factorization_zero, Finsupp.zero_apply]
rw [← Finsupp.mem_support_iff] at h
obtain ⟨g, hg⟩ : ∃ g : G, g ^ (exponent G / p) ≠ 1 := by
suffices key : ¬exponent G ∣ exponent G / p by
rwa [exponent_dvd_iff_forall_pow_eq_one, not_forall] at key
exact fun hd =>
hp.one_lt.not_ge
((mul_le_iff_le_one_left he).mp <|
Nat.le_of_dvd he <| Nat.mul_dvd_of_dvd_div (Nat.dvd_of_mem_primeFactors h) hd)
obtain ⟨k, hk : exponent G = p ^ _ * k⟩ := Nat.ordProj_dvd _ _
obtain ⟨t, ht⟩ := Nat.exists_eq_succ_of_ne_zero (Finsupp.mem_support_iff.mp h)
refine ⟨g ^ k, ?_⟩
rw [ht]
apply orderOf_eq_prime_pow
· rwa [hk, mul_comm, ht, pow_succ, ← mul_assoc, Nat.mul_div_cancel _ hp.pos, pow_mul] at hg
· rw [← Nat.succ_eq_add_one, ← ht, ← pow_mul, mul_comm, ← hk]
exact pow_exponent_eq_one g
variable {G} in
open Nat in
/-- If two commuting elements `x` and `y` of a monoid have order `n` and `m`, there is an element
of order `lcm n m`. The result actually gives an explicit (computable) element, written as the
product of a power of `x` and a power of `y`. See also the result below if you don't need the
explicit formula. -/
@[to_additive /-- If two commuting elements `x` and `y` of an additive monoid have order `n` and
`m`, there is an element of order `lcm n m`. The result actually gives an explicit (computable)
element, written as the sum of a multiple of `x` and a multiple of `y`. See also the result below
if you don't need the explicit formula. -/]
lemma _root_.Commute.orderOf_mul_pow_eq_lcm {x y : G} (h : Commute x y) (hx : orderOf x ≠ 0)
(hy : orderOf y ≠ 0) :
orderOf (x ^ (orderOf x / (factorizationLCMLeft (orderOf x) (orderOf y))) *
y ^ (orderOf y / factorizationLCMRight (orderOf x) (orderOf y))) =
Nat.lcm (orderOf x) (orderOf y) := by
rw [(h.pow_pow _ _).orderOf_mul_eq_mul_orderOf_of_coprime]
all_goals iterate 2 rw [orderOf_pow_orderOf_div]; try rw [Coprime]
all_goals simp [factorizationLCMLeft_mul_factorizationLCMRight, factorizationLCMLeft_dvd_left,
factorizationLCMRight_dvd_right, coprime_factorizationLCMLeft_factorizationLCMRight, hx, hy]
open Submonoid in
/-- If two commuting elements `x` and `y` of a monoid have order `n` and `m`, then there is an
element of order `lcm n m` that lies in the subgroup generated by `x` and `y`. -/
@[to_additive /-- If two commuting elements `x` and `y` of an additive monoid have order `n` and
`m`, then there is an element of order `lcm n m` that lies in the additive subgroup generated by `x`
and `y`. -/]
theorem _root_.Commute.exists_orderOf_eq_lcm {x y : G} (h : Commute x y) :
∃ z ∈ closure {x, y}, orderOf z = Nat.lcm (orderOf x) (orderOf y) := by
by_cases hx : orderOf x = 0 <;> by_cases hy : orderOf y = 0
· exact ⟨x, subset_closure (by simp), by simp [hx]⟩
· exact ⟨x, subset_closure (by simp), by simp [hx]⟩
· exact ⟨y, subset_closure (by simp), by simp [hy]⟩
· exact ⟨_, mul_mem (pow_mem (subset_closure (by simp)) _) (pow_mem (subset_closure (by simp)) _),
h.orderOf_mul_pow_eq_lcm hx hy⟩
/-- A nontrivial monoid has prime exponent `p` if and only if every non-identity element has
order `p`. -/
@[to_additive]
lemma exponent_eq_prime_iff {G : Type*} [Monoid G] [Nontrivial G] {p : ℕ} (hp : p.Prime) :
Monoid.exponent G = p ↔ ∀ g : G, g ≠ 1 → orderOf g = p := by
refine ⟨fun hG g hg ↦ ?_, fun h ↦ dvd_antisymm ?_ ?_⟩
· rw [Ne, ← orderOf_eq_one_iff] at hg
exact Eq.symm <| (hp.dvd_iff_eq hg).mp <| hG ▸ Monoid.order_dvd_exponent g
· rw [exponent_dvd]
intro g
by_cases hg : g = 1
· simp [hg]
· rw [h g hg]
· obtain ⟨g, hg⟩ := exists_ne (1 : G)
simpa [h g hg] using Monoid.order_dvd_exponent g
variable {G}
@[to_additive]
theorem exponent_ne_zero_iff_range_orderOf_finite (h : ∀ g : G, 0 < orderOf g) :
exponent G ≠ 0 ↔ (Set.range (orderOf : G → ℕ)).Finite := by
refine ⟨fun he => ?_, fun he => ?_⟩
· by_contra h
obtain ⟨m, ⟨t, rfl⟩, het⟩ := Set.Infinite.exists_gt h (exponent G)
exact pow_ne_one_of_lt_orderOf he het (pow_exponent_eq_one t)
· lift Set.range (orderOf (G := G)) to Finset ℕ using he with t ht
have htpos : 0 < t.prod id := by
refine Finset.prod_pos fun a ha => ?_
rw [← Finset.mem_coe, ht] at ha
obtain ⟨k, rfl⟩ := ha
exact h k
suffices exponent G ∣ t.prod id by
intro h
rw [h, zero_dvd_iff] at this
exact htpos.ne' this
rw [exponent_dvd]
intro g
apply Finset.dvd_prod_of_mem id (?_ : orderOf g ∈ _)
rw [← Finset.mem_coe, ht]
exact Set.mem_range_self g
@[to_additive]
theorem exponent_eq_zero_iff_range_orderOf_infinite (h : ∀ g : G, 0 < orderOf g) :
exponent G = 0 ↔ (Set.range (orderOf : G → ℕ)).Infinite := by
have := exponent_ne_zero_iff_range_orderOf_finite h
rwa [Ne, not_iff_comm, Iff.comm] at this
@[to_additive]
theorem lcm_orderOf_eq_exponent [Fintype G] : (Finset.univ : Finset G).lcm orderOf = exponent G :=
Nat.dvd_antisymm
(lcm_orderOf_dvd_exponent G)
(exponent_dvd.mpr fun g => Finset.dvd_lcm (Finset.mem_univ g))
variable {H : Type*} [Monoid H]
/--
If there exists an injective, multiplication-preserving map from `G` to `H`,
then the exponent of `G` divides the exponent of `H`.
-/
@[to_additive /-- If there exists an injective, addition-preserving map from `G` to `H`,
then the exponent of `G` divides the exponent of `H`. -/]
theorem exponent_dvd_of_monoidHom (e : G →* H) (e_inj : Function.Injective e) :
Monoid.exponent G ∣ Monoid.exponent H :=
exponent_dvd_of_forall_pow_eq_one fun g => e_inj (by
rw [map_pow, pow_exponent_eq_one, map_one])
/--
If there exists a multiplication-preserving equivalence between `G` and `H`,
then the exponent of `G` is equal to the exponent of `H`.
-/
@[to_additive /-- If there exists a addition-preserving equivalence between `G` and `H`,
then the exponent of `G` is equal to the exponent of `H`. -/]
theorem exponent_eq_of_mulEquiv (e : G ≃* H) : Monoid.exponent G = Monoid.exponent H :=
Nat.dvd_antisymm
(exponent_dvd_of_monoidHom e e.injective)
(exponent_dvd_of_monoidHom e.symm e.symm.injective)
end Monoid
section Submonoid
variable [Monoid G]
variable (G) in
@[to_additive (attr := simp)]
theorem _root_.Submonoid.exponent_top :
Monoid.exponent (⊤ : Submonoid G) = Monoid.exponent G :=
exponent_eq_of_mulEquiv Submonoid.topEquiv
@[to_additive]
theorem _root_.Submonoid.pow_exponent_eq_one {S : Submonoid G} {g : G} (g_in_s : g ∈ S) :
g ^ (Monoid.exponent S) = 1 := by
have := Monoid.pow_exponent_eq_one (⟨g, g_in_s⟩ : S)
rwa [SubmonoidClass.mk_pow, ← OneMemClass.coe_eq_one] at this
end Submonoid
section LeftCancelMonoid
variable [LeftCancelMonoid G] [Finite G]
@[to_additive]
theorem ExponentExists.of_finite : ExponentExists G := by
let _inst := Fintype.ofFinite G
simp only [Monoid.ExponentExists]
refine ⟨(Finset.univ : Finset G).lcm orderOf, ?_, fun g => ?_⟩
· simpa [pos_iff_ne_zero, Finset.lcm_eq_zero_iff] using fun x => (_root_.orderOf_pos x).ne'
· rw [← orderOf_dvd_iff_pow_eq_one, lcm_orderOf_eq_exponent]
exact order_dvd_exponent g
@[to_additive]
theorem exponent_ne_zero_of_finite : exponent G ≠ 0 :=
ExponentExists.of_finite.exponent_ne_zero
@[to_additive AddMonoid.one_lt_exponent]
lemma one_lt_exponent [Nontrivial G] : 1 < Monoid.exponent G := by
rw [Nat.one_lt_iff_ne_zero_and_ne_one]
exact ⟨exponent_ne_zero_of_finite, mt exp_eq_one_iff.mp (not_subsingleton G)⟩
@[to_additive]
instance neZero_exponent_of_finite : NeZero <| Monoid.exponent G :=
⟨Monoid.exponent_ne_zero_of_finite⟩
end LeftCancelMonoid
section CommMonoid
variable [CommMonoid G]
@[to_additive]
theorem exists_orderOf_eq_exponent (hG : ExponentExists G) : ∃ g : G, orderOf g = exponent G := by
have he := hG.exponent_ne_zero
have hne : (Set.range (orderOf : G → ℕ)).Nonempty := ⟨1, 1, orderOf_one⟩
have hfin : (Set.range (orderOf : G → ℕ)).Finite := by
rwa [← exponent_ne_zero_iff_range_orderOf_finite hG.orderOf_pos]
obtain ⟨t, ht⟩ := hne.csSup_mem hfin
use t
apply Nat.dvd_antisymm (order_dvd_exponent _)
refine Nat.dvd_of_primeFactorsList_subperm he ?_
rw [List.subperm_ext_iff]
by_contra! h
obtain ⟨p, hp, hpe⟩ := h
replace hp := Nat.prime_of_mem_primeFactorsList hp
simp only [Nat.primeFactorsList_count_eq] at hpe
set k := (orderOf t).factorization p with hk
obtain ⟨g, hg⟩ := hp.exists_orderOf_eq_pow_factorization_exponent G
suffices orderOf t < orderOf (t ^ p ^ k * g) by
rw [ht] at this
exact this.not_ge (le_csSup hfin.bddAbove <| Set.mem_range_self _)
have hpk : p ^ k ∣ orderOf t := Nat.ordProj_dvd _ _
have hpk' : orderOf (t ^ p ^ k) = orderOf t / p ^ k := by
rw [orderOf_pow' t (pow_ne_zero k hp.ne_zero), Nat.gcd_eq_right hpk]
obtain ⟨a, ha⟩ := Nat.exists_eq_add_of_lt hpe
have hcoprime : (orderOf (t ^ p ^ k)).Coprime (orderOf g) := by
rw [hg, Nat.coprime_pow_right_iff (pos_of_gt hpe), Nat.coprime_comm]
apply Or.resolve_right (Nat.coprime_or_dvd_of_prime hp _)
nth_rw 1 [← pow_one p]
have : 1 = (Nat.factorization (orderOf (t ^ p ^ k))) p + 1 := by
rw [hpk', Nat.factorization_div hpk]
simp [k, hp]
rw [this]
-- Porting note: convert made to_additive complain
exact Nat.pow_succ_factorization_not_dvd (hG.orderOf_pos <| t ^ p ^ k).ne' hp
rw [(Commute.all _ g).orderOf_mul_eq_mul_orderOf_of_coprime hcoprime, hpk',
hg, ha, hk, pow_add, pow_add, pow_one, ← mul_assoc, ← mul_assoc,
Nat.div_mul_cancel, mul_assoc, lt_mul_iff_one_lt_right <| hG.orderOf_pos t, ← pow_succ]
· exact one_lt_pow₀ hp.one_lt a.succ_ne_zero
· exact hpk
@[to_additive]
theorem exponent_eq_iSup_orderOf (h : ∀ g : G, 0 < orderOf g) :
exponent G = ⨆ g : G, orderOf g := by
rw [iSup]
by_cases ExponentExists G
case neg he =>
rw [← exponent_eq_zero_iff] at he
rw [he, Set.Infinite.Nat.sSup_eq_zero <| (exponent_eq_zero_iff_range_orderOf_infinite h).1 he]
case pos he =>
rw [csSup_eq_of_forall_le_of_forall_lt_exists_gt (Set.range_nonempty _)]
· simp_rw [Set.mem_range, forall_exists_index, forall_apply_eq_imp_iff]
exact orderOf_le_exponent he
intro x hx
obtain ⟨g, hg⟩ := exists_orderOf_eq_exponent he
rw [← hg] at hx
simp_rw [Set.mem_range, exists_exists_eq_and]
exact ⟨g, hx⟩
open scoped Classical in
@[to_additive]
theorem exponent_eq_iSup_orderOf' :
exponent G = if ∃ g : G, orderOf g = 0 then 0 else ⨆ g : G, orderOf g := by
split_ifs with h
· obtain ⟨g, hg⟩ := h
exact exponent_eq_zero_of_order_zero hg
· have := not_exists.mp h
exact exponent_eq_iSup_orderOf fun g => Ne.bot_lt <| this g
end CommMonoid
section CancelCommMonoid
variable [CancelCommMonoid G]
@[to_additive]
theorem exponent_eq_max'_orderOf [Fintype G] :
exponent G = ((@Finset.univ G _).image orderOf).max' ⟨1, by simp⟩ := by
rw [← Finset.Nonempty.csSup_eq_max', Finset.coe_image, Finset.coe_univ, Set.image_univ, ← iSup]
exact exponent_eq_iSup_orderOf orderOf_pos
end CancelCommMonoid
end Monoid
section Group
variable [Group G] {n m : ℤ}
@[to_additive]
theorem Group.exponent_dvd_card [Fintype G] : Monoid.exponent G ∣ Fintype.card G :=
Monoid.exponent_dvd.mpr <| fun _ => orderOf_dvd_card
@[to_additive]
theorem Group.exponent_dvd_nat_card : Monoid.exponent G ∣ Nat.card G :=
Monoid.exponent_dvd.mpr orderOf_dvd_natCard
@[to_additive]
theorem Subgroup.exponent_toSubmonoid (H : Subgroup G) :
Monoid.exponent H.toSubmonoid = Monoid.exponent H :=
Monoid.exponent_eq_of_mulEquiv (MulEquiv.subgroupCongr rfl)
@[to_additive (attr := simp)]
theorem Subgroup.exponent_top : Monoid.exponent (⊤ : Subgroup G) = Monoid.exponent G :=
Monoid.exponent_eq_of_mulEquiv topEquiv
@[to_additive]
theorem Subgroup.pow_exponent_eq_one {H : Subgroup G} {g : G} (g_in_H : g ∈ H) :
g ^ Monoid.exponent H = 1 := exponent_toSubmonoid H ▸ Submonoid.pow_exponent_eq_one g_in_H
@[to_additive]
theorem Group.exponent_dvd_iff_forall_zpow_eq_one :
(Monoid.exponent G : ℤ) ∣ n ↔ ∀ g : G, g ^ n = 1 := by
simp_rw [Int.natCast_dvd, Monoid.exponent_dvd_iff_forall_pow_eq_one, pow_natAbs_eq_one]
@[to_additive]
theorem Group.exponent_dvd_sub_iff_zpow_eq_zpow :
(Monoid.exponent G : ℤ) ∣ n - m ↔ ∀ g : G, g ^ n = g ^ m := by
simp_rw [Group.exponent_dvd_iff_forall_zpow_eq_one, zpow_sub, mul_inv_eq_one]
end Group
section PiProd
open Finset Monoid
@[to_additive]
theorem Monoid.exponent_pi_eq_zero {ι : Type*} {M : ι → Type*} [∀ i, Monoid (M i)] {j : ι}
(hj : exponent (M j) = 0) : exponent ((i : ι) → M i) = 0 := by
classical
rw [@exponent_eq_zero_iff, ExponentExists] at hj ⊢
push_neg at hj ⊢
peel hj with n hn _
obtain ⟨m, hm⟩ := this
refine ⟨Pi.mulSingle j m, fun h ↦ hm ?_⟩
simpa using congr_fun h j
/-- If `f : M₁ →⋆ M₂` is surjective, then the exponent of `M₂` divides the exponent of `M₁`. -/
@[to_additive]
theorem MonoidHom.exponent_dvd {F M₁ M₂ : Type*} [Monoid M₁] [Monoid M₂]
[FunLike F M₁ M₂] [MonoidHomClass F M₁ M₂]
{f : F} (hf : Function.Surjective f) : exponent M₂ ∣ exponent M₁ := by
refine Monoid.exponent_dvd_of_forall_pow_eq_one fun m₂ ↦ ?_
obtain ⟨m₁, rfl⟩ := hf m₂
rw [← map_pow, pow_exponent_eq_one, map_one]
/-- The exponent of finite product of monoids is the `Finset.lcm` of the exponents of the
constituent monoids. -/
@[to_additive /-- The exponent of finite product of additive monoids is the `Finset.lcm` of the
exponents of the constituent additive monoids. -/]
theorem Monoid.exponent_pi {ι : Type*} [Fintype ι] {M : ι → Type*} [∀ i, Monoid (M i)] :
exponent ((i : ι) → M i) = lcm univ (exponent <| M ·) := by
refine dvd_antisymm ?_ ?_
· refine exponent_dvd_of_forall_pow_eq_one fun m ↦ ?_
ext i
rw [Pi.pow_apply, Pi.one_apply, ← orderOf_dvd_iff_pow_eq_one]
apply dvd_trans (Monoid.order_dvd_exponent (m i))
exact Finset.dvd_lcm (mem_univ i)
· apply Finset.lcm_dvd fun i _ ↦ ?_
exact MonoidHom.exponent_dvd (f := Pi.evalMonoidHom (M ·) i) (Function.surjective_eval i)
/-- The exponent of product of two monoids is the `lcm` of the exponents of the
individual monoids. -/
@[to_additive AddMonoid.exponent_prod /-- The exponent of product of two additive monoids is the
`lcm` of the exponents of the individual additive monoids. -/]
theorem Monoid.exponent_prod {M₁ M₂ : Type*} [Monoid M₁] [Monoid M₂] :
exponent (M₁ × M₂) = lcm (exponent M₁) (exponent M₂) := by
refine dvd_antisymm ?_ (lcm_dvd ?_ ?_)
· refine exponent_dvd_of_forall_pow_eq_one fun g ↦ ?_
ext1
· rw [Prod.pow_fst, Prod.fst_one, ← orderOf_dvd_iff_pow_eq_one]
exact dvd_trans (Monoid.order_dvd_exponent (g.1)) <| dvd_lcm_left _ _
· rw [Prod.pow_snd, Prod.snd_one, ← orderOf_dvd_iff_pow_eq_one]
exact dvd_trans (Monoid.order_dvd_exponent (g.2)) <| dvd_lcm_right _ _
· exact MonoidHom.exponent_dvd (f := MonoidHom.fst M₁ M₂) Prod.fst_surjective
· exact MonoidHom.exponent_dvd (f := MonoidHom.snd M₁ M₂) Prod.snd_surjective
end PiProd
/-! ### Properties of monoids with exponent two -/
section ExponentTwo
section Monoid
variable [Monoid G]
@[to_additive]
lemma orderOf_eq_two_iff (hG : Monoid.exponent G = 2) {x : G} :
orderOf x = 2 ↔ x ≠ 1 :=
⟨by rintro hx rfl; norm_num at hx, orderOf_eq_prime (hG ▸ Monoid.pow_exponent_eq_one x)⟩
@[to_additive]
theorem Commute.of_orderOf_dvd_two [IsCancelMul G] (h : ∀ g : G, orderOf g ∣ 2) (a b : G) :
Commute a b := by
simp_rw [orderOf_dvd_iff_pow_eq_one] at h
rw [commute_iff_eq, ← mul_right_inj a, ← mul_left_inj b]
-- We avoid `group` here to minimize imports while low in the hierarchy;
-- typically it would be better to invoke the tactic.
calc
a * (a * b) * b = a ^ 2 * b ^ 2 := by simp [pow_two, mul_assoc]
_ = 1 := by rw [h, h, mul_one]
_ = (a * b) ^ 2 := by rw [h]
_ = a * (b * a) * b := by simp [pow_two, mul_assoc]
/-- In a cancellative monoid of exponent two, all elements commute. -/
@[to_additive]
lemma mul_comm_of_exponent_two [IsCancelMul G] (hG : Monoid.exponent G = 2) (a b : G) :
a * b = b * a :=
Commute.of_orderOf_dvd_two (fun g => hG ▸ Monoid.order_dvd_exponent g) a b
/-- Any cancellative monoid of exponent two is abelian. -/
@[to_additive /-- Any additive group of exponent two is abelian. -/]
abbrev commMonoidOfExponentTwo [IsCancelMul G] (hG : Monoid.exponent G = 2) : CommMonoid G where
mul_comm := mul_comm_of_exponent_two hG
end Monoid
section Group
variable [Group G]
/-- In a group of exponent two, every element is its own inverse. -/
@[to_additive]
lemma inv_eq_self_of_exponent_two (hG : Monoid.exponent G = 2) (x : G) :
x⁻¹ = x :=
inv_eq_of_mul_eq_one_left <| pow_two (a := x) ▸ hG ▸ Monoid.pow_exponent_eq_one x
/-- If an element in a group has order two, then it is its own inverse. -/
@[to_additive]
lemma inv_eq_self_of_orderOf_eq_two {x : G} (hx : orderOf x = 2) :
x⁻¹ = x :=
inv_eq_of_mul_eq_one_left <| pow_two (a := x) ▸ hx ▸ pow_orderOf_eq_one x
@[to_additive]
lemma mul_notMem_of_orderOf_eq_two {x y : G} (hx : orderOf x = 2)
(hy : orderOf y = 2) (hxy : x ≠ y) : x * y ∉ ({x, y, 1} : Set G) := by
simp only [Set.mem_singleton_iff, Set.mem_insert_iff, mul_eq_left, mul_eq_right,
mul_eq_one_iff_eq_inv, inv_eq_self_of_orderOf_eq_two hy, not_or]
aesop
@[deprecated (since := "2025-05-23")]
alias add_not_mem_of_addOrderOf_eq_two := add_notMem_of_addOrderOf_eq_two
@[to_additive existing, deprecated (since := "2025-05-23")]
alias mul_not_mem_of_orderOf_eq_two := mul_notMem_of_orderOf_eq_two
@[to_additive]
lemma mul_notMem_of_exponent_two (h : Monoid.exponent G = 2) {x y : G}
(hx : x ≠ 1) (hy : y ≠ 1) (hxy : x ≠ y) : x * y ∉ ({x, y, 1} : Set G) :=
mul_notMem_of_orderOf_eq_two (orderOf_eq_prime (h ▸ Monoid.pow_exponent_eq_one x) hx)
(orderOf_eq_prime (h ▸ Monoid.pow_exponent_eq_one y) hy) hxy
@[deprecated (since := "2025-05-23")]
alias add_not_mem_of_exponent_two := add_notMem_of_exponent_two
@[to_additive existing, deprecated (since := "2025-05-23")]
alias mul_not_mem_of_exponent_two := mul_notMem_of_exponent_two
end Group
end ExponentTwo |
.lake/packages/mathlib/Mathlib/GroupTheory/Commensurable.lean | import Mathlib.GroupTheory.Index
/-!
# Commensurability for subgroups
Two subgroups `H` and `K` of a group `G` are commensurable if `H ∩ K` has finite index in both `H`
and `K`.
This file defines commensurability for subgroups of a group `G`. It goes on to prove that
commensurability defines an equivalence relation on subgroups of `G` and finally defines the
commensurator of a subgroup `H` of `G`, which is the elements `g` of `G` such that `gHg⁻¹` is
commensurable with `H`.
## Main definitions
* `Commensurable H K`: the statement that the subgroups `H` and `K` of `G` are commensurable.
* `commensurator H`: the commensurator of a subgroup `H` of `G`.
## Implementation details
We define the commensurator of a subgroup `H` of `G` by first defining it as a subgroup of
`(conjAct G)`, which we call `commensurator'` and then taking the pre-image under
the map `G → (conjAct G)` to obtain our commensurator as a subgroup of `G`.
We define `Commensurable` both for additive and multiplicative groups (in the `AddSubgroup` and
`Subgroup` namespaces respectively); but `Commensurator` is not additivized, since it is not an
interesting concept for abelian groups, and it would be unusual to write a non-abelian group
additively.
-/
open Pointwise
variable {G : Type*} [Group G]
/-- Equivalence of `K / (H ⊓ K)` with `gKg⁻¹/ (gHg⁻¹ ⊓ gKg⁻¹)` -/
def Subgroup.quotConjEquiv (H K : Subgroup G) (g : ConjAct G) :
K ⧸ H.subgroupOf K ≃ (g • K : Subgroup G) ⧸ (g • H).subgroupOf (g • K) :=
Quotient.congr (K.equivSMul g).toEquiv fun a b ↦ by
dsimp
rw [← Quotient.eq'', ← Quotient.eq'', QuotientGroup.eq, QuotientGroup.eq,
mem_subgroupOf, mem_subgroupOf, ← map_inv, ← map_mul, equivSMul_apply_coe]
exact smul_mem_pointwise_smul_iff.symm
@[deprecated (since := "2025-09-17")] alias Commensurable.quotConjEquiv := Subgroup.quotConjEquiv
/-- Two subgroups `H K` of `G` are commensurable if `H ⊓ K` has finite index in both `H` and `K`. -/
@[to_additive /-- Two subgroups `H K` of `G` are commensurable if `H ⊓ K` has finite index in both
`H` and `K`. -/]
def Subgroup.Commensurable (H K : Subgroup G) : Prop :=
H.relIndex K ≠ 0 ∧ K.relIndex H ≠ 0
@[deprecated (since := "2025-09-17")] alias Commensurable := Subgroup.Commensurable
namespace Subgroup.Commensurable
@[to_additive (attr := refl)]
protected theorem refl (H : Subgroup G) : Commensurable H H := by simp [Commensurable]
@[to_additive]
theorem comm {H K : Subgroup G} : Commensurable H K ↔ Commensurable K H := and_comm
@[to_additive (attr := symm)]
theorem symm {H K : Subgroup G} : Commensurable H K → Commensurable K H := And.symm
@[to_additive (attr := trans)]
theorem trans {H K L : Subgroup G} (hhk : Commensurable H K) (hkl : Commensurable K L) :
Commensurable H L :=
⟨Subgroup.relIndex_ne_zero_trans hhk.1 hkl.1, Subgroup.relIndex_ne_zero_trans hkl.2 hhk.2⟩
@[to_additive]
theorem equivalence : Equivalence (@Commensurable G _) :=
⟨Commensurable.refl, fun h => Commensurable.symm h, fun h₁ h₂ => Commensurable.trans h₁ h₂⟩
theorem commensurable_conj {H K : Subgroup G} (g : ConjAct G) :
Commensurable H K ↔ Commensurable (g • H) (g • K) :=
and_congr (not_iff_not.mpr (Eq.congr_left (Cardinal.toNat_congr (quotConjEquiv H K g))))
(not_iff_not.mpr (Eq.congr_left (Cardinal.toNat_congr (quotConjEquiv K H g))))
/-- Alias for the forward direction of `commensurable_conj` to allow dot-notation -/
theorem conj {H K : Subgroup G} (h : Commensurable H K) (g : ConjAct G) :
Commensurable (g • H) (g • K) :=
(commensurable_conj g).mp h
theorem commensurable_inv (H : Subgroup G) (g : ConjAct G) :
Commensurable (g • H) H ↔ Commensurable H (g⁻¹ • H) := by rw [commensurable_conj, inv_smul_smul]
/-- For `H` a subgroup of `G`, this is the subgroup of all elements `g : conjAut G`
such that `Commensurable (g • H) H` -/
def commensurator' (H : Subgroup G) : Subgroup (ConjAct G) where
carrier := { g : ConjAct G | Commensurable (g • H) H }
one_mem' := by rw [Set.mem_setOf_eq, one_smul]
mul_mem' ha hb := by
rw [Set.mem_setOf_eq, mul_smul]
exact trans ((commensurable_conj _).mp hb) ha
inv_mem' _ := by rwa [Set.mem_setOf_eq, comm, ← commensurable_inv]
/-- For `H` a subgroup of `G`, this is the subgroup of all elements `g : G`
such that `Commensurable (g H g⁻¹) H` -/
def commensurator (H : Subgroup G) : Subgroup G :=
(commensurator' H).comap ConjAct.toConjAct.toMonoidHom
@[simp]
theorem commensurator'_mem_iff (H : Subgroup G) (g : ConjAct G) :
g ∈ commensurator' H ↔ Commensurable (g • H) H := Iff.rfl
@[simp]
theorem commensurator_mem_iff (H : Subgroup G) (g : G) :
g ∈ commensurator H ↔ Commensurable (ConjAct.toConjAct g • H) H := Iff.rfl
theorem eq {H K : Subgroup G} (hk : Commensurable H K) : commensurator H = commensurator K :=
Subgroup.ext fun x =>
let hx := (commensurable_conj x).1 hk
⟨fun h => hx.symm.trans (h.trans hk), fun h => hx.trans (h.trans hk.symm)⟩
end Subgroup.Commensurable |
.lake/packages/mathlib/Mathlib/GroupTheory/Transfer.lean | import Mathlib.GroupTheory.Complement
import Mathlib.GroupTheory.Sylow
/-!
# The Transfer Homomorphism
In this file we construct the transfer homomorphism.
## Main definitions
- `diff ϕ S T` : The difference of two left transversals `S` and `T` under the homomorphism `ϕ`.
- `transfer ϕ` : The transfer homomorphism induced by `ϕ`.
- `transferCenterPow`: The transfer homomorphism `G →* center G`.
## Main results
- `transferCenterPow_apply`:
The transfer homomorphism `G →* center G` is given by `g ↦ g ^ (center G).index`.
- `ker_transferSylow_isComplement'`: Burnside's transfer (or normal `p`-complement) theorem:
If `hP : N(P) ≤ C(P)`, then `(transfer P hP).ker` is a normal `p`-complement.
-/
variable {G : Type*} [Group G] {H : Subgroup G} {A : Type*} [CommGroup A] (ϕ : H →* A)
namespace Subgroup
namespace leftTransversals
open Finset MulAction
open scoped Pointwise
variable (R S T : H.LeftTransversal) [FiniteIndex H]
/-- The difference of two left transversals -/
@[to_additive /-- The difference of two left transversals -/]
noncomputable def diff : A :=
let α := S.2.leftQuotientEquiv
let β := T.2.leftQuotientEquiv
let _ := H.fintypeQuotientOfFiniteIndex
∏ q : G ⧸ H, ϕ
⟨(α q : G)⁻¹ * β q,
QuotientGroup.leftRel_apply.mp <|
Quotient.exact' ((α.symm_apply_apply q).trans (β.symm_apply_apply q).symm)⟩
@[to_additive]
theorem diff_mul_diff : diff ϕ R S * diff ϕ S T = diff ϕ R T :=
prod_mul_distrib.symm.trans
(prod_congr rfl fun q _ =>
(ϕ.map_mul _ _).symm.trans
(congr_arg ϕ
(by simp_rw [Subtype.ext_iff, coe_mul, mul_assoc, mul_inv_cancel_left])))
@[to_additive]
theorem diff_self : diff ϕ T T = 1 :=
mul_eq_left.mp (diff_mul_diff ϕ T T T)
@[to_additive]
theorem diff_inv : (diff ϕ S T)⁻¹ = diff ϕ T S :=
inv_eq_of_mul_eq_one_right <| (diff_mul_diff ϕ S T S).trans <| diff_self ϕ S
@[to_additive]
theorem smul_diff_smul (g : G) : diff ϕ (g • S) (g • T) = diff ϕ S T :=
let _ := H.fintypeQuotientOfFiniteIndex
Fintype.prod_equiv (MulAction.toPerm g).symm _ _ fun _ ↦ by
simp only [smul_apply_eq_smul_apply_inv_smul, smul_eq_mul, mul_inv_rev, mul_assoc,
inv_mul_cancel_left, toPerm_symm_apply]
end leftTransversals
open Equiv Function MulAction ZMod
variable (g : G)
variable (H) in
/-- The transfer transversal as a function. Given a `⟨g⟩`-orbit `q₀, g • q₀, ..., g ^ (m - 1) • q₀`
in `G ⧸ H`, an element `g ^ k • q₀` is mapped to `g ^ k • g₀` for a fixed choice of
representative `g₀` of `q₀`. -/
noncomputable def transferFunction : G ⧸ H → G := fun q =>
g ^ (cast (quotientEquivSigmaZMod H g q).2 : ℤ) * (quotientEquivSigmaZMod H g q).1.out.out
lemma transferFunction_apply (q : G ⧸ H) :
transferFunction H g q =
g ^ (cast (quotientEquivSigmaZMod H g q).2 : ℤ) *
(quotientEquivSigmaZMod H g q).1.out.out := rfl
lemma coe_transferFunction (q : G ⧸ H) : ↑(transferFunction H g q) = q := by
rw [transferFunction_apply, ← smul_eq_mul, Quotient.coe_smul_out,
← quotientEquivSigmaZMod_symm_apply, Sigma.eta, symm_apply_apply]
variable (H) in
/-- The transfer transversal as a set. Contains elements of the form `g ^ k • g₀` for fixed choices
of representatives `g₀` of fixed choices of representatives `q₀` of `⟨g⟩`-orbits in `G ⧸ H`. -/
def transferSet : Set G := Set.range (transferFunction H g)
lemma mem_transferSet (q : G ⧸ H) : transferFunction H g q ∈ transferSet H g := ⟨q, rfl⟩
variable (H) in
/-- The transfer transversal. Contains elements of the form `g ^ k • g₀` for fixed choices
of representatives `g₀` of fixed choices of representatives `q₀` of `⟨g⟩`-orbits in `G ⧸ H`. -/
def transferTransversal : H.LeftTransversal :=
⟨transferSet H g, isComplement_range_left (coe_transferFunction g)⟩
lemma transferTransversal_apply (q : G ⧸ H) :
↑((transferTransversal H g).2.leftQuotientEquiv q) = transferFunction H g q :=
IsComplement.leftQuotientEquiv_apply (coe_transferFunction g) q
lemma transferTransversal_apply' (q : orbitRel.Quotient (zpowers g) (G ⧸ H))
(k : ZMod (minimalPeriod (g • ·) q.out)) :
↑((transferTransversal H g).2.leftQuotientEquiv (g ^ (cast k : ℤ) • q.out)) =
g ^ (cast k : ℤ) * q.out.out := by
rw [transferTransversal_apply, transferFunction_apply, ← quotientEquivSigmaZMod_symm_apply,
apply_symm_apply]
lemma transferTransversal_apply'' (q : orbitRel.Quotient (zpowers g) (G ⧸ H))
(k : ZMod (minimalPeriod (g • ·) q.out)) :
↑((g • transferTransversal H g).2.leftQuotientEquiv (g ^ (cast k : ℤ) • q.out)) =
if k = 0 then g ^ minimalPeriod (g • ·) q.out * q.out.out
else g ^ (cast k : ℤ) * q.out.out := by
rw [smul_apply_eq_smul_apply_inv_smul, transferTransversal_apply, transferFunction_apply, ←
mul_smul, ← zpow_neg_one, ← zpow_add, quotientEquivSigmaZMod_apply, smul_eq_mul, ← mul_assoc,
← zpow_one_add, Int.cast_add, Int.cast_neg, Int.cast_one, intCast_cast, cast_id', id, ←
sub_eq_neg_add, cast_sub_one, add_sub_cancel]
by_cases hk : k = 0
· rw [if_pos hk, if_pos hk, zpow_natCast]
· rw [if_neg hk, if_neg hk]
end Subgroup
namespace MonoidHom
open MulAction Subgroup Subgroup.leftTransversals
/-- Given `ϕ : H →* A` from `H : Subgroup G` to a commutative group `A`,
the transfer homomorphism is `transfer ϕ : G →* A`. -/
@[to_additive /-- Given `ϕ : H →+ A` from `H : AddSubgroup G` to an additive commutative group `A`,
the transfer homomorphism is `transfer ϕ : G →+ A`. -/]
noncomputable def transfer [FiniteIndex H] : G →* A :=
let T : H.LeftTransversal := default
{ toFun := fun g => diff ϕ T (g • T)
map_one' := by rw [one_smul, diff_self]
map_mul' := fun g h => by rw [mul_smul, ← diff_mul_diff, smul_diff_smul] }
variable (T : H.LeftTransversal)
@[to_additive]
theorem transfer_def [FiniteIndex H] (g : G) : transfer ϕ g = diff ϕ T (g • T) := by
rw [transfer, ← diff_mul_diff, ← smul_diff_smul, mul_comm, diff_mul_diff] <;> rfl
/-- Explicit computation of the transfer homomorphism. -/
theorem transfer_eq_prod_quotient_orbitRel_zpowers_quot [FiniteIndex H] (g : G)
[Fintype (Quotient (orbitRel (zpowers g) (G ⧸ H)))] :
transfer ϕ g =
∏ q : Quotient (orbitRel (zpowers g) (G ⧸ H)),
ϕ
⟨q.out.out⁻¹ * g ^ Function.minimalPeriod (g • ·) q.out * q.out.out,
QuotientGroup.out_conj_pow_minimalPeriod_mem H g q.out⟩ := by
classical
letI := H.fintypeQuotientOfFiniteIndex
calc
transfer ϕ g = ∏ q : G ⧸ H, _ := transfer_def ϕ (transferTransversal H g) g
_ = _ := ((quotientEquivSigmaZMod H g).symm.prod_comp _).symm
_ = _ := Finset.prod_sigma _ _ _
_ = _ := by
refine Fintype.prod_congr _ _ (fun q => ?_)
simp only [quotientEquivSigmaZMod_symm_apply, transferTransversal_apply',
transferTransversal_apply'']
rw [Fintype.prod_eq_single (0 : ZMod (Function.minimalPeriod (g • ·) q.out)) _]
· simp only [if_pos, ZMod.cast_zero, zpow_zero, one_mul, mul_assoc]
· intro k hk
simp only [if_neg hk, inv_mul_cancel]
exact map_one ϕ
/-- Auxiliary lemma in order to state `transfer_eq_pow`. -/
theorem transfer_eq_pow_aux (g : G)
(key : ∀ (k : ℕ) (g₀ : G), g₀⁻¹ * g ^ k * g₀ ∈ H → g₀⁻¹ * g ^ k * g₀ = g ^ k) :
g ^ H.index ∈ H := by
by_cases hH : H.index = 0
· rw [hH, pow_zero]
exact H.one_mem
letI := fintypeOfIndexNeZero hH
classical
replace key : ∀ (k : ℕ) (g₀ : G), g₀⁻¹ * g ^ k * g₀ ∈ H → g ^ k ∈ H := fun k g₀ hk =>
(congr_arg (· ∈ H) (key k g₀ hk)).mp hk
replace key : ∀ q : G ⧸ H, g ^ Function.minimalPeriod (g • ·) q ∈ H := fun q =>
key (Function.minimalPeriod (g • ·) q) q.out
(QuotientGroup.out_conj_pow_minimalPeriod_mem H g q)
let f : Quotient (orbitRel (zpowers g) (G ⧸ H)) → zpowers g := fun q =>
(⟨g, mem_zpowers g⟩ : zpowers g) ^ Function.minimalPeriod (g • ·) q.out
have hf : ∀ q, f q ∈ H.subgroupOf (zpowers g) := fun q => key q.out
replace key :=
Subgroup.prod_mem (H.subgroupOf (zpowers g)) fun q (_ : q ∈ Finset.univ) => hf q
simpa only [f, minimalPeriod_eq_card, Finset.prod_pow_eq_pow_sum, Fintype.card_sigma,
Fintype.card_congr (selfEquivSigmaOrbits (zpowers g) (G ⧸ H)), index_eq_card,
Nat.card_eq_fintype_card] using key
theorem transfer_eq_pow [FiniteIndex H] (g : G)
(key : ∀ (k : ℕ) (g₀ : G), g₀⁻¹ * g ^ k * g₀ ∈ H → g₀⁻¹ * g ^ k * g₀ = g ^ k) :
transfer ϕ g = ϕ ⟨g ^ H.index, transfer_eq_pow_aux g key⟩ := by
classical
letI := H.fintypeQuotientOfFiniteIndex
change ∀ (k g₀) (hk : g₀⁻¹ * g ^ k * g₀ ∈ H), ↑(⟨g₀⁻¹ * g ^ k * g₀, hk⟩ : H) = g ^ k at key
rw [transfer_eq_prod_quotient_orbitRel_zpowers_quot, ← Finset.prod_map_toList,
← Function.comp_def ϕ, List.prod_map_hom]
refine congrArg ϕ (Subtype.coe_injective ?_)
dsimp only
rw [H.coe_mk, ← (zpowers g).coe_mk g (mem_zpowers g), ← (zpowers g).coe_pow, index_eq_card,
Nat.card_eq_fintype_card, Fintype.card_congr (selfEquivSigmaOrbits (zpowers g) (G ⧸ H)),
Fintype.card_sigma, ← Finset.prod_pow_eq_pow_sum, ← Finset.prod_map_toList]
simp only [Subgroup.val_list_prod, List.map_map, ← minimalPeriod_eq_card]
congr 2
funext
apply key
theorem transfer_center_eq_pow [FiniteIndex (center G)] (g : G) :
transfer (MonoidHom.id (center G)) g = ⟨g ^ (center G).index, (center G).pow_index_mem g⟩ :=
transfer_eq_pow (id (center G)) g fun k _ hk => by rw [← mul_right_inj, ← hk.comm,
mul_inv_cancel_right]
variable (G) in
/-- The transfer homomorphism `G →* center G`. -/
noncomputable def transferCenterPow [FiniteIndex (center G)] : G →* center G where
toFun g := ⟨g ^ (center G).index, (center G).pow_index_mem g⟩
map_one' := Subtype.ext (one_pow (center G).index)
map_mul' a b := by simp_rw [← show ∀ _, (_ : center G) = _ from transfer_center_eq_pow, map_mul]
@[simp]
theorem transferCenterPow_apply [FiniteIndex (center G)] (g : G) :
↑(transferCenterPow G g) = g ^ (center G).index :=
rfl
section BurnsideTransfer
variable {p : ℕ} (P : Sylow p G) (hP : (P : Subgroup G).normalizer ≤ centralizer (P : Set G))
include hP
/-- The homomorphism `G →* P` in Burnside's transfer theorem. -/
noncomputable def transferSylow [FiniteIndex (P : Subgroup G)] : G →* (P : Subgroup G) :=
@transfer G _ P P
(@CommGroup.ofIsMulCommutative P _ ⟨⟨fun a b => Subtype.ext (hP (le_normalizer b.2) a a.2)⟩⟩)
(MonoidHom.id P) _
variable [Fact p.Prime] [Finite (Sylow p G)]
/-- Auxiliary lemma in order to state `transferSylow_eq_pow`. -/
theorem transferSylow_eq_pow_aux (g : G) (hg : g ∈ P) (k : ℕ) (g₀ : G)
(h : g₀⁻¹ * g ^ k * g₀ ∈ P) : g₀⁻¹ * g ^ k * g₀ = g ^ k := by
haveI : IsMulCommutative (P : Subgroup G) :=
⟨⟨fun a b => Subtype.ext (hP (le_normalizer b.2) a a.2)⟩⟩
replace hg := (P : Subgroup G).pow_mem hg k
obtain ⟨n, hn, h⟩ := P.conj_eq_normalizer_conj_of_mem (g ^ k) g₀ hg h
exact h.trans (Commute.inv_mul_cancel (hP hn (g ^ k) hg).symm)
variable [FiniteIndex (P : Subgroup G)]
theorem transferSylow_eq_pow (g : G) (hg : g ∈ P) :
transferSylow P hP g =
⟨g ^ (P : Subgroup G).index, transfer_eq_pow_aux g (transferSylow_eq_pow_aux P hP g hg)⟩ :=
haveI : IsMulCommutative P := ⟨⟨fun a b => Subtype.ext (hP (le_normalizer b.2) a a.2)⟩⟩
transfer_eq_pow _ _ <| transferSylow_eq_pow_aux P hP g hg
theorem transferSylow_restrict_eq_pow : ⇑((transferSylow P hP).restrict (P : Subgroup G)) =
(fun x : P => x ^ (P : Subgroup G).index) :=
funext fun g => transferSylow_eq_pow P hP g g.2
/-- **Burnside's normal p-complement theorem**: If `N(P) ≤ C(P)`, then `P` has a normal
complement. -/
theorem ker_transferSylow_isComplement' : IsComplement' (transferSylow P hP).ker P := by
have hf : Function.Bijective ((transferSylow P hP).restrict (P : Subgroup G)) :=
(transferSylow_restrict_eq_pow P hP).symm ▸ (P.2.powEquiv' P.not_dvd_index).bijective
rw [Function.Bijective, ← range_eq_top, restrict_range] at hf
have := range_eq_top.mp (top_le_iff.mp (hf.2.ge.trans
(map_le_range (transferSylow P hP) P)))
rw [← (comap_injective this).eq_iff, comap_top, comap_map_eq, sup_comm, SetLike.ext'_iff,
normal_mul, ← ker_eq_bot_iff, ← (map_injective (P : Subgroup G).subtype_injective).eq_iff,
ker_restrict, subgroupOf_map_subtype, Subgroup.map_bot, coe_top] at hf
exact isComplement'_of_disjoint_and_mul_eq_univ (disjoint_iff.2 hf.1) hf.2
theorem not_dvd_card_ker_transferSylow : ¬p ∣ Nat.card (transferSylow P hP).ker :=
(ker_transferSylow_isComplement' P hP).index_eq_card ▸ P.not_dvd_index
theorem ker_transferSylow_disjoint (Q : Subgroup G) (hQ : IsPGroup p Q) :
Disjoint (transferSylow P hP).ker Q :=
disjoint_iff.mpr <|
card_eq_one.mp <|
(hQ.to_le inf_le_right).card_eq_or_dvd.resolve_right fun h =>
not_dvd_card_ker_transferSylow P hP <| h.trans <| card_dvd_of_le inf_le_left
end BurnsideTransfer
end MonoidHom
namespace IsCyclic
open Subgroup
-- we could suppress the variable `p`, but that might introduce `motive not type correct` issues.
variable {G : Type*} [Group G] [Finite G] {p : ℕ} (hp : (Nat.card G).minFac = p) {P : Sylow p G}
include hp in
theorem normalizer_le_centralizer (hP : IsCyclic P) : P.normalizer ≤ centralizer (P : Set G) := by
subst hp
by_cases hn : Nat.card G = 1
· have := (Nat.card_eq_one_iff_unique.mp hn).1
rw [Subsingleton.elim P.normalizer (centralizer P)]
have := Fact.mk (Nat.minFac_prime hn)
have key := card_dvd_of_injective _ (QuotientGroup.kerLift_injective P.normalizerMonoidHom)
rw [normalizerMonoidHom_ker, ← index, ← relIndex] at key
refine relIndex_eq_one.mp (Nat.eq_one_of_dvd_coprimes ?_ dvd_rfl key)
obtain ⟨k, hk⟩ := P.2.exists_card_eq
rcases eq_zero_or_pos k with h0 | h0
· rw [hP.card_mulAut, hk, h0, pow_zero, Nat.totient_one]
apply Nat.coprime_one_right
rw [hP.card_mulAut, hk, Nat.totient_prime_pow Fact.out h0]
refine (Nat.Coprime.pow_right _ ?_).mul_right ?_
· apply Nat.Coprime.coprime_dvd_left (relIndex_dvd_of_le_left P.normalizer P.le_centralizer)
apply Nat.Coprime.coprime_dvd_left (relIndex_dvd_index_of_le P.le_normalizer)
rw [Nat.coprime_comm, Nat.Prime.coprime_iff_not_dvd Fact.out]
exact P.not_dvd_index
· apply Nat.Coprime.coprime_dvd_left (relIndex_dvd_card (centralizer P) P.normalizer)
apply Nat.Coprime.coprime_dvd_left (card_subgroup_dvd_card P.normalizer)
have h1 := Nat.gcd_dvd_left (Nat.card G) ((Nat.card G).minFac - 1)
have h2 := Nat.gcd_le_right (n := (Nat.card G).minFac - 1) (Nat.card G)
(tsub_pos_iff_lt.mpr (Nat.minFac_prime hn).one_lt)
contrapose! h2
refine Nat.sub_one_lt_of_le (Nat.card G).minFac_pos (Nat.minFac_le_of_dvd ?_ h1)
exact (Nat.two_le_iff _).mpr ⟨ne_zero_of_dvd_ne_zero Nat.card_pos.ne' h1, h2⟩
include hp in
/-- A cyclic Sylow subgroup for the smallest prime has a normal complement. -/
theorem isComplement' (hP : IsCyclic P) :
(MonoidHom.transferSylow P (hP.normalizer_le_centralizer hp)).ker.IsComplement' P := by
subst hp
by_cases hn : Nat.card G = 1
· have := (Nat.card_eq_one_iff_unique.mp hn).1
rw [Subsingleton.elim (MonoidHom.transferSylow P (hP.normalizer_le_centralizer rfl)).ker ⊥,
Subsingleton.elim P.1 ⊤]
exact isComplement'_bot_top
have := Fact.mk (Nat.minFac_prime hn)
exact MonoidHom.ker_transferSylow_isComplement' P (hP.normalizer_le_centralizer rfl)
end IsCyclic |
.lake/packages/mathlib/Mathlib/GroupTheory/Goursat.lean | import Mathlib.Algebra.Group.Graph
import Mathlib.Algebra.Group.Subgroup.Basic
import Mathlib.GroupTheory.QuotientGroup.Defs
/-!
# Goursat's lemma for subgroups
This file proves Goursat's lemma for subgroups.
If `I` is a subgroup of `G × H` which projects fully on both factors, then there exist normal
subgroups `G' ≤ G` and `H' ≤ H` such that `G' × H' ≤ I` and the image of `I` in `G ⧸ G' × H ⧸ H'` is
the graph of an isomorphism `G ⧸ G' ≃ H ⧸ H'`.
`G'` and `H'` can be explicitly constructed as `Subgroup.goursatFst I` and `Subgroup.goursatSnd I`
respectively.
-/
open Function Set
namespace Subgroup
variable {G H : Type*} [Group G] [Group H] {I : Subgroup (G × H)}
(hI₁ : Surjective (Prod.fst ∘ I.subtype)) (hI₂ : Surjective (Prod.snd ∘ I.subtype))
variable (I) in
/-- For `I` a subgroup of `G × H`, `I.goursatFst` is the kernel of the projection map `I → H`,
considered as a subgroup of `G`.
This is the first subgroup appearing in Goursat's lemma. See `Subgroup.goursat`. -/
@[to_additive
/-- For `I` a subgroup of `G × H`, `I.goursatFst` is the kernel of the projection map `I → H`,
considered as a subgroup of `G`.
This is the first subgroup appearing in Goursat's lemma. See `AddSubgroup.goursat`. -/]
def goursatFst : Subgroup G :=
((MonoidHom.snd G H).comp I.subtype).ker.map ((MonoidHom.fst G H).comp I.subtype)
variable (I) in
/-- For `I` a subgroup of `G × H`, `I.goursatSnd` is the kernel of the projection map `I → G`,
considered as a subgroup of `H`.
This is the second subgroup appearing in Goursat's lemma. See `Subgroup.goursat`. -/
@[to_additive
/-- For `I` a subgroup of `G × H`, `I.goursatSnd` is the kernel of the projection map `I → G`,
considered as a subgroup of `H`.
This is the second subgroup appearing in Goursat's lemma. See `AddSubgroup.goursat`. -/]
def goursatSnd : Subgroup H :=
((MonoidHom.fst G H).comp I.subtype).ker.map ((MonoidHom.snd G H).comp I.subtype)
@[to_additive (attr := simp)]
lemma mem_goursatFst {g : G} : g ∈ I.goursatFst ↔ (g, 1) ∈ I := by simp [goursatFst]
@[to_additive (attr := simp)]
lemma mem_goursatSnd {h : H} : h ∈ I.goursatSnd ↔ (1, h) ∈ I := by simp [goursatSnd]
include hI₁ in
@[to_additive] lemma normal_goursatFst : I.goursatFst.Normal := .map inferInstance _ hI₁
include hI₂ in
@[to_additive] lemma normal_goursatSnd : I.goursatSnd.Normal := .map inferInstance _ hI₂
include hI₁ hI₂ in
@[to_additive]
lemma mk_goursatFst_eq_iff_mk_goursatSnd_eq {x y : G × H} (hx : x ∈ I) (hy : y ∈ I) :
(x.1 : G ⧸ I.goursatFst) = y.1 ↔ (x.2 : H ⧸ I.goursatSnd) = y.2 := by
have := normal_goursatFst hI₁
have := normal_goursatSnd hI₂
rw [eq_comm]
simp only [QuotientGroup.eq_iff_div_mem, mem_goursatFst, mem_goursatSnd]
constructor <;> intro h
· simpa [Prod.mul_def, Prod.div_def] using div_mem (mul_mem h hx) hy
· simpa [Prod.mul_def, Prod.div_def] using div_mem (mul_mem h hy) hx
variable (I) in
@[to_additive AddSubgroup.goursatFst_prod_goursatSnd_le]
lemma goursatFst_prod_goursatSnd_le : I.goursatFst.prod I.goursatSnd ≤ I := by
rintro ⟨g, h⟩ ⟨hg, hh⟩
simpa using mul_mem (mem_goursatFst.1 hg) (mem_goursatSnd.1 hh)
/-- **Goursat's lemma** for a subgroup of a product with surjective projections.
If `I` is a subgroup of `G × H` which projects fully on both factors, then there exist normal
subgroups `M ≤ G` and `N ≤ H` such that `G' × H' ≤ I` and the image of `I` in `G ⧸ M × H ⧸ N` is the
graph of an isomorphism `G ⧸ M ≃ H ⧸ N'`.
`G'` and `H'` can be explicitly constructed as `I.goursatFst` and `I.goursatSnd` respectively. -/
@[to_additive
/-- **Goursat's lemma** for a subgroup of a product with surjective projections.
If `I` is a subgroup of `G × H` which projects fully on both factors, then there exist normal
subgroups `M ≤ G` and `N ≤ H` such that `G' × H' ≤ I` and the image of `I` in `G ⧸ M × H ⧸ N` is the
graph of an isomorphism `G ⧸ M ≃ H ⧸ N'`.
`G'` and `H'` can be explicitly constructed as `I.goursatFst` and `I.goursatSnd` respectively. -/]
lemma goursat_surjective :
have := normal_goursatFst hI₁
have := normal_goursatSnd hI₂
∃ e : G ⧸ I.goursatFst ≃* H ⧸ I.goursatSnd,
(((QuotientGroup.mk' _).prodMap (QuotientGroup.mk' _)).comp I.subtype).range =
e.toMonoidHom.graph := by
have := normal_goursatFst hI₁
have := normal_goursatSnd hI₂
exact (((QuotientGroup.mk' I.goursatFst).prodMap
(QuotientGroup.mk' I.goursatSnd)).comp I.subtype).exists_mulEquiv_range_eq_graph
((QuotientGroup.mk'_surjective _).comp hI₁) ((QuotientGroup.mk'_surjective _).comp hI₂)
fun ⟨x, hx⟩ ⟨y, hy⟩ ↦ mk_goursatFst_eq_iff_mk_goursatSnd_eq hI₁ hI₂ hx hy
/-- **Goursat's lemma** for an arbitrary subgroup.
If `I` is a subgroup of `G × H`, then there exist subgroups `G' ≤ G`, `H' ≤ H` and normal subgroups
`M ⊴ G'` and `N ⊴ H'` such that `M × N ≤ I` and the image of `I` in `G' ⧸ M × H' ⧸ N` is the graph
of an isomorphism `G' ⧸ M ≃ H' ⧸ N`. -/
@[to_additive
/-- **Goursat's lemma** for an arbitrary subgroup.
If `I` is a subgroup of `G × H`, then there exist subgroups `G' ≤ G`, `H' ≤ H` and normal subgroups
`M ≤ G'` and `N ≤ H'` such that `M × N ≤ I` and the image of `I` in `G' ⧸ M × H' ⧸ N` is the graph
of an isomorphism `G ⧸ G' ≃ H ⧸ H'`. -/]
lemma goursat :
∃ (G' : Subgroup G) (H' : Subgroup H) (M : Subgroup G') (N : Subgroup H') (_ : M.Normal)
(_ : N.Normal) (e : G' ⧸ M ≃* H' ⧸ N),
I = (e.toMonoidHom.graph.comap <| (QuotientGroup.mk' M).prodMap (QuotientGroup.mk' N)).map
(G'.subtype.prodMap H'.subtype) := by
let G' := I.map (MonoidHom.fst ..)
let H' := I.map (MonoidHom.snd ..)
let P : I →* G' := (MonoidHom.fst ..).subgroupMap I
let Q : I →* H' := (MonoidHom.snd ..).subgroupMap I
let I' : Subgroup (G' × H') := (P.prod Q).range
have hI₁' : Surjective (Prod.fst ∘ I'.subtype) := by
simp only [← MonoidHom.coe_fst, ← MonoidHom.coe_comp, ← MonoidHom.range_eq_top,
MonoidHom.range_comp, Subgroup.range_subtype, I']
simp only [← MonoidHom.range_comp, MonoidHom.fst_comp_prod, MonoidHom.range_eq_top]
exact (MonoidHom.fst ..).subgroupMap_surjective I
have hI₂' : Surjective (Prod.snd ∘ I'.subtype) := by
simp only [← MonoidHom.coe_snd, ← MonoidHom.coe_comp, ← MonoidHom.range_eq_top,
MonoidHom.range_comp, Subgroup.range_subtype, I']
simp only [← MonoidHom.range_comp, MonoidHom.range_eq_top]
exact (MonoidHom.snd ..).subgroupMap_surjective I
have := normal_goursatFst hI₁'
have := normal_goursatSnd hI₂'
obtain ⟨e, he⟩ := goursat_surjective hI₁' hI₂'
refine ⟨I.map (MonoidHom.fst ..), I.map (MonoidHom.snd ..),
I'.goursatFst, I'.goursatSnd, inferInstance, inferInstance, e, ?_⟩
rw [← he]
simp only [MonoidHom.range_comp, Subgroup.range_subtype, I']
rw [comap_map_eq_self]
· ext ⟨g, h⟩
constructor
· intro hgh
simpa only [G', H', mem_map, MonoidHom.mem_range, MonoidHom.prod_apply, Subtype.exists,
Prod.exists, MonoidHom.coe_prodMap, coe_subtype, Prod.mk.injEq, Prod.map_apply,
MonoidHom.coe_snd, exists_eq_right, exists_and_right, exists_eq_right_right,
MonoidHom.coe_fst]
using ⟨⟨h, hgh⟩, ⟨g, hgh⟩, g, h, hgh, ⟨rfl, rfl⟩⟩
· simp only [G', H', mem_map, MonoidHom.mem_range, MonoidHom.prod_apply, Subtype.exists,
Prod.exists, MonoidHom.coe_prodMap, coe_subtype, Prod.mk.injEq, Prod.map_apply,
MonoidHom.coe_snd, exists_eq_right, exists_and_right, exists_eq_right_right,
MonoidHom.coe_fst, forall_exists_index, and_imp]
rintro h₁ hgh₁ g₁ hg₁h g₂ h₂ hg₂h₂ hP hQ
simp only [Subtype.ext_iff] at hP hQ
rwa [← hP, ← hQ]
· convert goursatFst_prod_goursatSnd_le (P.prod Q).range
ext ⟨g, h⟩
simp_rw [G', H', MonoidHom.mem_ker, MonoidHom.coe_prodMap, Prod.map_apply, Subgroup.mem_prod,
Prod.one_eq_mk, Prod.ext_iff, ← MonoidHom.mem_ker, QuotientGroup.ker_mk']
end Subgroup |
.lake/packages/mathlib/Mathlib/GroupTheory/Frattini.lean | import Mathlib.GroupTheory.Nilpotent
import Mathlib.Order.Radical
/-!
# The Frattini subgroup
We give the definition of the Frattini subgroup of a group, and three elementary results:
* The Frattini subgroup is characteristic.
* If every subgroup of a group is contained in a maximal subgroup, then
the Frattini subgroup consists of the non-generating elements of the group.
* The Frattini subgroup of a finite group is nilpotent.
-/
/-- The Frattini subgroup of a group is the intersection of the maximal subgroups. -/
def frattini (G : Type*) [Group G] : Subgroup G :=
Order.radical (Subgroup G)
variable {G H : Type*} [Group G] [Group H] {φ : G →* H}
lemma frattini_le_coatom {K : Subgroup G} (h : IsCoatom K) : frattini G ≤ K :=
Order.radical_le_coatom h
open Subgroup
lemma frattini_le_comap_frattini_of_surjective (hφ : Function.Surjective φ) :
frattini G ≤ (frattini H).comap φ := by
simp_rw [frattini, Order.radical, comap_iInf, le_iInf_iff]
intro M hM
apply biInf_le
exact isCoatom_comap_of_surjective hφ hM
/-- The Frattini subgroup is characteristic. -/
instance frattini_characteristic : (frattini G).Characteristic := by
rw [characteristic_iff_comap_eq]
intro φ
apply φ.comapSubgroup.map_radical
/--
The Frattini subgroup consists of "non-generating" elements in the following sense:
If a subgroup together with the Frattini subgroup generates the whole group,
then the subgroup is already the whole group.
-/
theorem frattini_nongenerating [IsCoatomic (Subgroup G)] {K : Subgroup G}
(h : K ⊔ frattini G = ⊤) : K = ⊤ :=
Order.radical_nongenerating h
/-- When `G` is finite, the Frattini subgroup is nilpotent. -/
theorem frattini_nilpotent [Finite G] : Group.IsNilpotent (frattini G) := by
-- We use the characterisation of nilpotency in terms of all Sylow subgroups being normal.
have q := (isNilpotent_of_finite_tfae (G := frattini G)).out 0 3
rw [q]; clear q
-- Consider each prime `p` and Sylow `p`-subgroup `P` of `frattini G`.
intro p p_prime P
-- The Frattini argument shows that the normalizer of `P` in `G`
-- together with `frattini G` generates `G`.
have frattini_argument := Sylow.normalizer_sup_eq_top P
-- and hence by the nongenerating property of the Frattini subgroup that
-- the normalizer of `P` in `G` is `G`.
have normalizer_P := frattini_nongenerating frattini_argument
-- This means that `P` is normal as a subgroup of `G`
have P_normal_in_G : (map (frattini G).subtype P).Normal := normalizer_eq_top_iff.mp normalizer_P
-- and hence also as a subgroup of `frattini G`, which was the remaining goal.
exact P_normal_in_G.of_map_subtype |
.lake/packages/mathlib/Mathlib/GroupTheory/IndexNormal.lean | import Mathlib.Data.Finite.Perm
import Mathlib.Data.Nat.Prime.Factorial
import Mathlib.GroupTheory.Index
/-! # Subgroups of small index are normal
* `Subgroup.normal_of_index_eq_smallest_prime_factor`: in a finite group `G`,
a subgroup of index equal to the smallest prime factor of `Nat.card G` is normal.
* `Subgroup.normal_of_index_two`: in a group `G`, a subgroup of index 2 is normal
(This does not require `G` to be finite.)
-/
assert_not_exists Field
open MulAction MonoidHom Nat
variable {G : Type*} [Group G] {H : Subgroup G} {p : ℕ}
namespace Subgroup
/-- A subgroup of index 1 is normal (does not require finiteness of G) -/
theorem normal_of_index_eq_one (hH : H.index = 1) : H.Normal := by
rw [index_eq_one] at hH
rw [hH]
infer_instance
/-- A subgroup of index 2 is normal (does not require finiteness of G) -/
theorem normal_of_index_eq_two (hH : H.index = 2) : H.Normal where
conj_mem x hxH g := by simp_rw [mul_mem_iff_of_index_two hH, hxH, iff_true, inv_mem_iff]
/-- A subgroup of a finite group whose index is the smallest prime factor is normal.
Note : if `G` is infinite, then `Nat.card G = 0` and `(Nat.card G).minFac = 2` -/
theorem normal_of_index_eq_minFac_card (hHp : H.index = (Nat.card G).minFac) :
H.Normal := by
by_cases hG0 : Nat.card G = 0
· rw [hG0, minFac_zero] at hHp
exact normal_of_index_eq_two hHp
by_cases hG1 : Nat.card G = 1
· rw [hG1, minFac_one] at hHp
exact normal_of_index_eq_one hHp
suffices H.normalCore.relIndex H = 1 by
convert H.normalCore_normal
exact le_antisymm (relIndex_eq_one.mp this) (normalCore_le H)
have : Finite G := finite_of_card_ne_zero hG0
have index_ne_zero : H.index ≠ 0 := index_ne_zero_of_finite
rw [← mul_left_inj' index_ne_zero, one_mul, relIndex_mul_index H.normalCore_le]
have hp : Nat.Prime H.index := hHp ▸ minFac_prime hG1
have h : H.normalCore.index ∣ H.index ! := by
rw [normalCore_eq_ker, index_ker, index_eq_card, ← Nat.card_perm]
exact card_subgroup_dvd_card (toPermHom G (G ⧸ H)).range
apply dvd_antisymm _ (index_dvd_of_le H.normalCore_le)
rwa [← Coprime.dvd_mul_right, mul_factorial_pred hp.ne_zero]
have hr1 : H.normalCore.index ≠ 1 := fun hr1 ↦ hp.ne_one <|
Nat.eq_one_of_dvd_one (hr1 ▸ H.normalCore.index_dvd_of_le H.normalCore_le)
rw [Nat.coprime_factorial_iff hr1]
exact lt_of_lt_of_le (Nat.sub_one_lt hp.ne_zero) <|
hHp ▸ minFac_le_of_dvd (Nat.minFac_prime hr1).two_le
(dvd_trans (minFac_dvd H.normalCore.index) (H.normalCore.index_dvd_card))
end Subgroup |
.lake/packages/mathlib/Mathlib/GroupTheory/PushoutI.lean | import Mathlib.GroupTheory.CoprodI
import Mathlib.GroupTheory.Coprod.Basic
import Mathlib.GroupTheory.Complement
/-!
## Pushouts of Monoids and Groups
This file defines wide pushouts of monoids and groups and proves some properties
of the amalgamated product of groups (i.e. the special case where all the maps
in the diagram are injective).
## Main definitions
- `Monoid.PushoutI`: the pushout of a diagram of monoids indexed by a type `ι`
- `Monoid.PushoutI.base`: the map from the amalgamating monoid to the pushout
- `Monoid.PushoutI.of`: the map from each Monoid in the family to the pushout
- `Monoid.PushoutI.lift`: the universal property used to define homomorphisms out of the pushout.
- `Monoid.PushoutI.NormalWord`: a normal form for words in the pushout
- `Monoid.PushoutI.of_injective`: if all the maps in the diagram are injective in a pushout of
groups then so is `of`
- `Monoid.PushoutI.Reduced.eq_empty_of_mem_range`: For any word `w` in the coproduct,
if `w` is reduced (i.e none its letters are in the image of the base monoid), and nonempty, then
`w` itself is not in the image of the base monoid.
## References
* The normal form theorem follows these [notes](https://webspace.maths.qmul.ac.uk/i.m.chiswell/ggt/lecture_notes/lecture2.pdf)
from Queen Mary University
## Tags
amalgamated product, pushout, group
-/
namespace Monoid
open CoprodI Subgroup Coprod Function List
variable {ι : Type*} {G : ι → Type*} {H : Type*} {K : Type*} [Monoid K]
/-- The relation we quotient by to form the pushout -/
def PushoutI.con [∀ i, Monoid (G i)] [Monoid H] (φ : ∀ i, H →* G i) :
Con (Coprod (CoprodI G) H) :=
conGen (fun x y : Coprod (CoprodI G) H =>
∃ i x', x = inl (of (φ i x')) ∧ y = inr x')
/-- The indexed pushout of monoids, which is the pushout in the category of monoids,
or the category of groups. -/
def PushoutI [∀ i, Monoid (G i)] [Monoid H] (φ : ∀ i, H →* G i) : Type _ :=
(PushoutI.con φ).Quotient
namespace PushoutI
section Monoid
variable [∀ i, Monoid (G i)] [Monoid H] {φ : ∀ i, H →* G i}
protected instance mul : Mul (PushoutI φ) := by
delta PushoutI; infer_instance
protected instance one : One (PushoutI φ) := by
delta PushoutI; infer_instance
instance monoid : Monoid (PushoutI φ) :=
{ Con.monoid _ with
toMul := PushoutI.mul
toOne := PushoutI.one }
/-- The map from each indexing group into the pushout -/
def of (i : ι) : G i →* PushoutI φ :=
(Con.mk' _).comp <| inl.comp CoprodI.of
variable (φ) in
/-- The map from the base monoid into the pushout -/
def base : H →* PushoutI φ :=
(Con.mk' _).comp inr
theorem of_comp_eq_base (i : ι) : (of i).comp (φ i) = (base φ) := by
ext x
apply (Con.eq _).2
refine ConGen.Rel.of _ _ ?_
simp only [MonoidHom.comp_apply]
exact ⟨_, _, rfl, rfl⟩
variable (φ) in
theorem of_apply_eq_base (i : ι) (x : H) : of i (φ i x) = base φ x := by
rw [← MonoidHom.comp_apply, of_comp_eq_base]
/-- Define a homomorphism out of the pushout of monoids be defining it on each object in the
diagram -/
def lift (f : ∀ i, G i →* K) (k : H →* K)
(hf : ∀ i, (f i).comp (φ i) = k) :
PushoutI φ →* K :=
Con.lift _ (Coprod.lift (CoprodI.lift f) k) <| by
apply Con.conGen_le fun x y => ?_
rintro ⟨i, x', rfl, rfl⟩
simp only [DFunLike.ext_iff, MonoidHom.coe_comp, comp_apply] at hf
simp [hf]
@[simp]
theorem lift_of (f : ∀ i, G i →* K) (k : H →* K)
(hf : ∀ i, (f i).comp (φ i) = k)
{i : ι} (g : G i) : (lift f k hf) (of i g : PushoutI φ) = f i g := by
delta PushoutI lift of
simp only [MonoidHom.coe_comp, Con.coe_mk', comp_apply, Con.lift_coe,
lift_apply_inl, CoprodI.lift_of]
@[simp]
theorem lift_base (f : ∀ i, G i →* K) (k : H →* K)
(hf : ∀ i, (f i).comp (φ i) = k)
(g : H) : (lift f k hf) (base φ g : PushoutI φ) = k g := by
delta PushoutI lift base
simp only [MonoidHom.coe_comp, Con.coe_mk', comp_apply, Con.lift_coe, lift_apply_inr]
-- `ext` attribute should be lower priority then `hom_ext_nonempty`
@[ext 1199]
theorem hom_ext {f g : PushoutI φ →* K}
(h : ∀ i, f.comp (of i : G i →* _) = g.comp (of i : G i →* _))
(hbase : f.comp (base φ) = g.comp (base φ)) : f = g :=
(MonoidHom.cancel_right Con.mk'_surjective).mp <|
Coprod.hom_ext
(CoprodI.ext_hom _ _ h)
hbase
@[ext high]
theorem hom_ext_nonempty [hn : Nonempty ι]
{f g : PushoutI φ →* K}
(h : ∀ i, f.comp (of i : G i →* _) = g.comp (of i : G i →* _)) : f = g :=
hom_ext h <| by
cases hn with
| intro i =>
ext
rw [← of_comp_eq_base i, ← MonoidHom.comp_assoc, h, MonoidHom.comp_assoc]
/-- The equivalence that is part of the universal property of the pushout. A hom out of
the pushout is just a morphism out of all groups in the pushout that satisfies a commutativity
condition. -/
@[simps]
def homEquiv :
(PushoutI φ →* K) ≃ { f : (Π i, G i →* K) × (H →* K) // ∀ i, (f.1 i).comp (φ i) = f.2 } :=
{ toFun := fun f => ⟨(fun i => f.comp (of i), f.comp (base φ)),
fun i => by rw [MonoidHom.comp_assoc, of_comp_eq_base]⟩
invFun := fun f => lift f.1.1 f.1.2 f.2,
left_inv := fun _ => hom_ext (by simp [DFunLike.ext_iff])
(by simp [DFunLike.ext_iff])
right_inv := fun ⟨⟨_, _⟩, _⟩ => by simp [DFunLike.ext_iff, funext_iff] }
/-- The map from the coproduct into the pushout -/
def ofCoprodI : CoprodI G →* PushoutI φ :=
CoprodI.lift of
@[simp]
theorem ofCoprodI_of (i : ι) (g : G i) :
(ofCoprodI (CoprodI.of g) : PushoutI φ) = of i g := by
simp [ofCoprodI]
theorem induction_on {motive : PushoutI φ → Prop}
(x : PushoutI φ)
(of : ∀ (i : ι) (g : G i), motive (of i g))
(base : ∀ h, motive (base φ h))
(mul : ∀ x y, motive x → motive y → motive (x * y)) : motive x := by
delta PushoutI PushoutI.of PushoutI.base at *
induction x using Con.induction_on with
| H x =>
induction x using Coprod.induction_on with
| inl g =>
induction g using CoprodI.induction_on with
| of i g => exact of i g
| mul x y ihx ihy =>
rw [map_mul]
exact mul _ _ ihx ihy
| one => simpa using base 1
| inr h => exact base h
| mul x y ihx ihy => exact mul _ _ ihx ihy
end Monoid
variable [∀ i, Group (G i)] [Group H] {φ : ∀ i, H →* G i}
instance : Group (PushoutI φ) :=
{ Con.group (PushoutI.con φ) with
toMonoid := PushoutI.monoid }
namespace NormalWord
/-
In this section we show that there is a normal form for words in the amalgamated product. To have a
normal form, we need to pick canonical choice of element of each right coset of the base group. The
choice of element in the base group itself is `1`. Given a choice of element of each right coset,
given by the type `Transversal φ` we can find a normal form. The normal form for an element is an
element of the base group, multiplied by a word in the coproduct, where each letter in the word is
the canonical choice of element of its coset. We then show that all groups in the diagram act
faithfully on the normal form. This implies that the maps into the coproduct are injective.
We demonstrate the action is faithful using the equivalence `equivPair`. We show that `G i` acts
faithfully on `Pair d i` and that `Pair d i` is isomorphic to `NormalWord d`. Here, `d` is a
`Transversal`. A `Pair d i` is a word in the coproduct, `Coprod G`, the `tail`, and an element
of the group `G i`, the `head`. The first letter of the `tail` must not be an element of `G i`.
Note that the `head` may be `1` Every letter in the `tail` must be in the transversal given by `d`.
We then show that the equivalence between `NormalWord` and `PushoutI`, between the set of normal
words and the elements of the amalgamated product. The key to this is the theorem `prod_smul_empty`,
which says that going from `NormalWord` to `PushoutI` and back is the identity. This is proven
by induction on the word using `consRecOn`.
-/
variable (φ)
/-- The data we need to pick a normal form for words in the pushout. We need to pick a
canonical element of each coset. We also need all the maps in the diagram to be injective -/
structure Transversal : Type _ where
/-- All maps in the diagram are injective -/
injective : ∀ i, Injective (φ i)
/-- The underlying set, containing exactly one element of each coset of the base group -/
set : ∀ i, Set (G i)
/-- The chosen element of the base group itself is the identity -/
one_mem : ∀ i, 1 ∈ set i
/-- We have exactly one element of each coset of the base group -/
compl : ∀ i, IsComplement (φ i).range (set i)
theorem transversal_nonempty (hφ : ∀ i, Injective (φ i)) : Nonempty (Transversal φ) := by
choose t ht using fun i => (φ i).range.exists_isComplement_right 1
apply Nonempty.intro
exact
{ injective := hφ
set := t
one_mem := fun i => (ht i).2
compl := fun i => (ht i).1 }
variable {φ}
/-- The normal form for words in the pushout. Every element of the pushout is the product of an
element of the base group and a word made up of letters each of which is in the transversal. -/
structure _root_.Monoid.PushoutI.NormalWord (d : Transversal φ) extends CoprodI.Word G where
/-- Every `NormalWord` is the product of an element of the base group and a word made up
of letters each of which is in the transversal. `head` is that element of the base group. -/
head : H
/-- All letter in the word are in the transversal. -/
normalized : ∀ i g, ⟨i, g⟩ ∈ toList → g ∈ d.set i
/--
A `Pair d i` is a word in the coproduct, `Coprod G`, the `tail`, and an element of the group `G i`,
the `head`. The first letter of the `tail` must not be an element of `G i`.
Note that the `head` may be `1` Every letter in the `tail` must be in the transversal given by `d`.
Similar to `Monoid.CoprodI.Pair` except every letter must be in the transversal
(not including the head letter). -/
structure Pair (d : Transversal φ) (i : ι) extends CoprodI.Word.Pair G i where
/-- All letters in the word are in the transversal. -/
normalized : ∀ i g, ⟨i, g⟩ ∈ tail.toList → g ∈ d.set i
variable {d : Transversal φ}
/-- The empty normalized word, representing the identity element of the group. -/
@[simps!]
def empty : NormalWord d := ⟨CoprodI.Word.empty, 1, fun i g => by simp [CoprodI.Word.empty]⟩
instance : Inhabited (NormalWord d) := ⟨NormalWord.empty⟩
instance (i : ι) : Inhabited (Pair d i) :=
⟨{ (empty : NormalWord d) with
head := 1, tail := _,
fstIdx_ne := fun h => by cases h }⟩
@[ext]
theorem ext {w₁ w₂ : NormalWord d} (hhead : w₁.head = w₂.head)
(hlist : w₁.toList = w₂.toList) : w₁ = w₂ := by
rcases w₁ with ⟨⟨_, _, _⟩, _, _⟩
rcases w₂ with ⟨⟨_, _, _⟩, _, _⟩
simp_all
open Subgroup.IsComplement
instance baseAction : MulAction H (NormalWord d) :=
{ smul := fun h w => { w with head := h * w.head },
one_smul := by simp [instHSMul]
mul_smul := by simp [instHSMul, mul_assoc] }
theorem base_smul_def' (h : H) (w : NormalWord d) :
h • w = { w with head := h * w.head } := rfl
/-- Take the product of a normal word as an element of the `PushoutI`. We show that this is
bijective, in `NormalWord.equiv`. -/
def prod (w : NormalWord d) : PushoutI φ :=
base φ w.head * ofCoprodI (w.toWord).prod
@[simp]
theorem prod_base_smul (h : H) (w : NormalWord d) :
(h • w).prod = base φ h * w.prod := by
simp only [base_smul_def', prod, map_mul, mul_assoc]
@[simp]
theorem prod_empty : (empty : NormalWord d).prod = 1 := by
simp [prod, empty]
/-- A constructor that multiplies a `NormalWord` by an element, with condition to make
sure the underlying list does get longer. -/
@[simps!]
noncomputable def cons {i} (g : G i) (w : NormalWord d) (hmw : w.fstIdx ≠ some i)
(hgr : g ∉ (φ i).range) : NormalWord d :=
letI n := (d.compl i).equiv (g * (φ i w.head))
letI w' := Word.cons (n.2 : G i) w.toWord hmw
(mt (coe_equiv_snd_eq_one_iff_mem _ (d.one_mem _)).1
(mt (mul_mem_cancel_right (by simp)).1 hgr))
{ toWord := w'
head := (MonoidHom.ofInjective (d.injective i)).symm n.1
normalized := fun i g hg => by
simp only [w', Word.cons, mem_cons, Sigma.mk.inj_iff] at hg
rcases hg with ⟨rfl, hg | hg⟩
· simp
· exact w.normalized _ _ (by assumption) }
@[simp]
theorem prod_cons {i} (g : G i) (w : NormalWord d) (hmw : w.fstIdx ≠ some i)
(hgr : g ∉ (φ i).range) : (cons g w hmw hgr).prod = of i g * w.prod := by
simp [prod, cons, ← of_apply_eq_base φ i, equiv_fst_eq_mul_inv, mul_assoc]
variable [DecidableEq ι] [∀ i, DecidableEq (G i)]
/-- Given a word in `CoprodI`, if every letter is in the transversal and when
we multiply by an element of the base group it still has this property,
then the element of the base group we multiplied by was one. -/
theorem eq_one_of_smul_normalized (w : CoprodI.Word G) {i : ι} (h : H)
(hw : ∀ i g, ⟨i, g⟩ ∈ w.toList → g ∈ d.set i)
(hφw : ∀ j g, ⟨j, g⟩ ∈ (CoprodI.of (φ i h) • w).toList → g ∈ d.set j) :
h = 1 := by
simp only [← (d.compl _).equiv_snd_eq_self_iff_mem (one_mem _)] at hw hφw
have hhead : ((d.compl i).equiv (Word.equivPair i w).head).2 =
(Word.equivPair i w).head := by
rw [Word.equivPair_head]
split_ifs with h
· rcases h with ⟨_, rfl⟩
exact hw _ _ (List.head_mem _)
· rw [equiv_one (d.compl i) (one_mem _) (d.one_mem _)]
by_contra hh1
have := hφw i (φ i h * (Word.equivPair i w).head) ?_
· apply hh1
rw [equiv_mul_left_of_mem (d.compl i) ⟨_, rfl⟩, hhead] at this
simpa [((injective_iff_map_eq_one' _).1 (d.injective i))] using this
· simp only [Word.mem_smul_iff, not_true, false_and, ne_eq, Option.mem_def, mul_right_inj,
exists_eq_right', mul_eq_left, exists_prop, true_and, false_or]
constructor
· intro h
apply_fun (d.compl i).equiv at h
simp only [Prod.ext_iff, equiv_one (d.compl i) (one_mem _) (d.one_mem _),
equiv_mul_left_of_mem (d.compl i) ⟨_, rfl⟩, hhead, Subtype.ext_iff,
Prod.ext_iff] at h
rcases h with ⟨h₁, h₂⟩
rw [h₂, equiv_one (d.compl i) (one_mem _) (d.one_mem _)] at h₁
erw [mul_one] at h₁
simp only [((injective_iff_map_eq_one' _).1 (d.injective i))] at h₁
contradiction
· rw [Word.equivPair_head]
dsimp
split_ifs with hep
· rcases hep with ⟨hnil, rfl⟩
rw [head?_eq_head hnil]
simp_all
· push_neg at hep
by_cases hw : w.toList = []
· simp [hw, Word.fstIdx]
· simp [head?_eq_head hw, Word.fstIdx, hep hw]
theorem ext_smul {w₁ w₂ : NormalWord d} (i : ι)
(h : CoprodI.of (φ i w₁.head) • w₁.toWord =
CoprodI.of (φ i w₂.head) • w₂.toWord) :
w₁ = w₂ := by
rcases w₁ with ⟨w₁, h₁, hw₁⟩
rcases w₂ with ⟨w₂, h₂, hw₂⟩
dsimp at *
rw [smul_eq_iff_eq_inv_smul, ← mul_smul] at h
subst h
simp only [← map_inv, ← map_mul] at hw₁
have : h₁⁻¹ * h₂ = 1 := eq_one_of_smul_normalized w₂ (h₁⁻¹ * h₂) hw₂ hw₁
rw [inv_mul_eq_one] at this; subst this
simp
/-- Given a pair `(head, tail)`, we can form a word by prepending `head` to `tail`, but
putting head into normal form first, by making sure it is expressed as an element
of the base group multiplied by an element of the transversal. -/
noncomputable def rcons (i : ι) (p : Pair d i) : NormalWord d :=
letI n := (d.compl i).equiv p.head
let w := (Word.equivPair i).symm { p.toPair with head := n.2 }
{ toWord := w
head := (MonoidHom.ofInjective (d.injective i)).symm n.1
normalized := fun i g hg => by
dsimp [w] at hg
rw [Word.equivPair_symm, Word.mem_rcons_iff] at hg
rcases hg with hg | ⟨_, rfl, rfl⟩
· exact p.normalized _ _ hg
· simp }
theorem rcons_injective {i : ι} : Function.Injective (rcons (d := d) i) := by
rintro ⟨⟨head₁, tail₁⟩, _⟩ ⟨⟨head₂, tail₂⟩, _⟩
simp only [rcons, NormalWord.mk.injEq, EmbeddingLike.apply_eq_iff_eq,
Word.Pair.mk.injEq, Pair.mk.injEq, and_imp]
intro h₁ h₂ h₃
subst h₂
rw [← equiv_fst_mul_equiv_snd (d.compl i) head₁,
← equiv_fst_mul_equiv_snd (d.compl i) head₂,
h₁, h₃]
simp
/-- The equivalence between `NormalWord`s and pairs. We can turn a `NormalWord` into a
pair by taking the head of the `List` if it is in `G i` and multiplying it by the element of the
base group. -/
noncomputable def equivPair (i) : NormalWord d ≃ Pair d i :=
letI toFun : NormalWord d → Pair d i :=
fun w =>
letI p := Word.equivPair i (CoprodI.of (φ i w.head) • w.toWord)
{ toPair := p
normalized := fun j g hg => by
dsimp only [p] at hg
rw [Word.of_smul_def, ← Word.equivPair_symm, Equiv.apply_symm_apply] at hg
dsimp at hg
exact w.normalized _ _ (Word.mem_of_mem_equivPair_tail _ hg) }
haveI leftInv : Function.LeftInverse (rcons i) toFun :=
fun w => ext_smul i <| by
simp only [toFun, rcons, Word.equivPair_symm,
Word.equivPair_smul_same, Word.equivPair_tail_eq_inv_smul, Word.rcons_eq_smul,
MonoidHom.apply_ofInjective_symm, equiv_fst_eq_mul_inv, mul_assoc, map_mul, map_inv,
mul_smul, inv_smul_smul, smul_inv_smul]
{ toFun := toFun
invFun := rcons i
left_inv := leftInv
right_inv := fun _ => rcons_injective (leftInv _) }
noncomputable instance summandAction (i : ι) : MulAction (G i) (NormalWord d) :=
{ smul := fun g w => (equivPair i).symm
{ equivPair i w with
head := g * (equivPair i w).head }
one_smul := fun _ => by
dsimp [instHSMul]
rw [one_mul]
exact (equivPair i).symm_apply_apply _
mul_smul := fun _ _ _ => by
dsimp [instHSMul]
simp [mul_assoc, Equiv.apply_symm_apply] }
theorem summand_smul_def' {i : ι} (g : G i) (w : NormalWord d) :
g • w = (equivPair i).symm
{ equivPair i w with
head := g * (equivPair i w).head } := rfl
noncomputable instance mulAction : MulAction (PushoutI φ) (NormalWord d) :=
MulAction.ofEndHom <|
lift
(fun _ => MulAction.toEndHom)
MulAction.toEndHom <| by
intro i
simp only [MulAction.toEndHom, DFunLike.ext_iff, MonoidHom.coe_comp, MonoidHom.coe_mk,
OneHom.coe_mk, comp_apply]
intro h
funext w
apply NormalWord.ext_smul i
simp only [summand_smul_def', equivPair, rcons, Word.equivPair_symm, Equiv.coe_fn_mk,
Equiv.coe_fn_symm_mk, Word.equivPair_smul_same, Word.equivPair_tail_eq_inv_smul,
Word.rcons_eq_smul, equiv_fst_eq_mul_inv, map_mul, map_inv, mul_smul, inv_smul_smul,
smul_inv_smul, base_smul_def', MonoidHom.apply_ofInjective_symm]
theorem base_smul_def (h : H) (w : NormalWord d) :
base φ h • w = { w with head := h * w.head } := rfl
theorem summand_smul_def {i : ι} (g : G i) (w : NormalWord d) :
of (φ := φ) i g • w = (equivPair i).symm
{ equivPair i w with
head := g * (equivPair i w).head } := rfl
theorem of_smul_eq_smul {i : ι} (g : G i) (w : NormalWord d) :
of (φ := φ) i g • w = g • w := by
rw [summand_smul_def, summand_smul_def']
theorem base_smul_eq_smul (h : H) (w : NormalWord d) :
base φ h • w = h • w := by
rw [base_smul_def, base_smul_def']
/-- Induction principle for `NormalWord`, that corresponds closely to inducting on
the underlying list. -/
@[elab_as_elim]
noncomputable def consRecOn {motive : NormalWord d → Sort _} (w : NormalWord d)
(empty : motive empty)
(cons : ∀ (i : ι) (g : G i) (w : NormalWord d) (hmw : w.fstIdx ≠ some i)
(_hgn : g ∈ d.set i) (hgr : g ∉ (φ i).range) (_hw1 : w.head = 1),
motive w → motive (cons g w hmw hgr))
(base : ∀ (h : H) (w : NormalWord d), w.head = 1 → motive w → motive
(base φ h • w)) : motive w := by
rcases w with ⟨w, head, h3⟩
convert base head ⟨w, 1, h3⟩ rfl ?_
· simp [base_smul_def]
· induction w using Word.consRecOn with
| empty => exact empty
| cons i g w h1 hg1 ih =>
convert cons i g ⟨w, 1, fun _ _ h => h3 _ _ (List.mem_cons_of_mem _ h)⟩
h1 (h3 _ _ List.mem_cons_self) ?_ rfl
(ih ?_)
· simp only [Word.cons, NormalWord.cons, map_one, mul_one,
(equiv_snd_eq_self_iff_mem (d.compl i) (one_mem _)).2
(h3 _ _ List.mem_cons_self)]
· apply d.injective i
simp only [NormalWord.cons, equiv_fst_eq_mul_inv, MonoidHom.apply_ofInjective_symm,
map_one, mul_one, mul_inv_cancel, (equiv_snd_eq_self_iff_mem (d.compl i) (one_mem _)).2
(h3 _ _ List.mem_cons_self)]
· rwa [← SetLike.mem_coe,
← coe_equiv_snd_eq_one_iff_mem (d.compl i) (d.one_mem _),
(equiv_snd_eq_self_iff_mem (d.compl i) (one_mem _)).2
(h3 _ _ List.mem_cons_self)]
theorem cons_eq_smul {i : ι} (g : G i)
(w : NormalWord d) (hmw : w.fstIdx ≠ some i)
(hgr : g ∉ (φ i).range) : cons g w hmw hgr = of (φ := φ) i g • w := by
apply ext_smul i
simp only [cons, Word.cons_eq_smul, MonoidHom.apply_ofInjective_symm,
equiv_fst_eq_mul_inv, mul_assoc, map_mul, map_inv, mul_smul, inv_smul_smul, summand_smul_def,
equivPair, rcons, Word.equivPair_symm, Word.rcons_eq_smul, Equiv.coe_fn_mk,
Word.equivPair_tail_eq_inv_smul, Equiv.coe_fn_symm_mk, smul_inv_smul]
@[simp]
theorem prod_summand_smul {i : ι} (g : G i) (w : NormalWord d) :
(g • w).prod = of i g * w.prod := by
simp only [prod, summand_smul_def', equivPair, rcons, Word.equivPair_symm,
Equiv.coe_fn_mk, Equiv.coe_fn_symm_mk, Word.equivPair_smul_same,
Word.equivPair_tail_eq_inv_smul, Word.rcons_eq_smul, ← of_apply_eq_base φ i,
MonoidHom.apply_ofInjective_symm, equiv_fst_eq_mul_inv, mul_assoc, map_mul, map_inv,
Word.prod_smul, ofCoprodI_of, inv_mul_cancel_left, mul_inv_cancel_left]
@[simp]
theorem prod_smul (g : PushoutI φ) (w : NormalWord d) :
(g • w).prod = g * w.prod := by
induction g using PushoutI.induction_on generalizing w with
| of i g => rw [of_smul_eq_smul, prod_summand_smul]
| base h => rw [base_smul_eq_smul, prod_base_smul]
| mul x y ihx ihy => rw [mul_smul, ihx, ihy, mul_assoc]
theorem prod_smul_empty (w : NormalWord d) : w.prod • empty = w := by
induction w using consRecOn with
| empty => simp
| cons i g w _ _ _ _ ih =>
rw [prod_cons, mul_smul, ih, cons_eq_smul]
| base h w _ ih =>
rw [prod_smul, mul_smul, ih]
/-- The equivalence between normal forms and elements of the pushout -/
noncomputable def equiv : PushoutI φ ≃ NormalWord d :=
{ toFun := fun g => g • .empty
invFun := fun w => w.prod
left_inv := fun g => by
simp only [prod_smul, prod_empty, mul_one]
right_inv := fun w => prod_smul_empty w }
theorem prod_injective {ι : Type*} {G : ι → Type*} [(i : ι) → Group (G i)] {φ : (i : ι) → H →* G i}
{d : Transversal φ} : Function.Injective (prod : NormalWord d → PushoutI φ) := by
letI := Classical.decEq ι
letI := fun i => Classical.decEq (G i)
classical exact equiv.symm.injective
instance : FaithfulSMul (PushoutI φ) (NormalWord d) :=
⟨fun h => by simpa using congr_arg prod (h empty)⟩
instance (i : ι) : FaithfulSMul (G i) (NormalWord d) :=
⟨by simp [summand_smul_def']⟩
instance : FaithfulSMul H (NormalWord d) :=
⟨by simp [base_smul_def']⟩
end NormalWord
open NormalWord
/-- All maps into the `PushoutI`, or amalgamated product of groups are injective,
provided all maps in the diagram are injective.
See also `base_injective` -/
theorem of_injective (hφ : ∀ i, Function.Injective (φ i)) (i : ι) :
Function.Injective (of (φ := φ) i) := by
rcases transversal_nonempty φ hφ with ⟨d⟩
let _ := Classical.decEq ι
let _ := fun i => Classical.decEq (G i)
refine Function.Injective.of_comp
(f := ((· • ·) : PushoutI φ → NormalWord d → NormalWord d)) ?_
intro _ _ h
exact eq_of_smul_eq_smul (fun w : NormalWord d =>
by simp_all [funext_iff, of_smul_eq_smul])
theorem base_injective (hφ : ∀ i, Function.Injective (φ i)) :
Function.Injective (base φ) := by
rcases transversal_nonempty φ hφ with ⟨d⟩
let _ := Classical.decEq ι
let _ := fun i => Classical.decEq (G i)
refine Function.Injective.of_comp
(f := ((· • ·) : PushoutI φ → NormalWord d → NormalWord d)) ?_
intro _ _ h
exact eq_of_smul_eq_smul (fun w : NormalWord d =>
by simp_all [funext_iff, base_smul_eq_smul])
section Reduced
variable (φ) in
/-- A word in `CoprodI` is reduced if none of its letters are in the base group. -/
def Reduced (w : Word G) : Prop :=
∀ g, g ∈ w.toList → g.2 ∉ (φ g.1).range
theorem Reduced.exists_normalWord_prod_eq (d : Transversal φ) {w : Word G} (hw : Reduced φ w) :
∃ w' : NormalWord d, w'.prod = ofCoprodI w.prod ∧
w'.toList.map Sigma.fst = w.toList.map Sigma.fst := by
classical
induction w using Word.consRecOn with
| empty => exact ⟨empty, by simp, rfl⟩
| cons i g w hIdx hg1 ih =>
rcases ih (fun _ hg => hw _ (List.mem_cons_of_mem _ hg)) with
⟨w', hw'prod, hw'map⟩
refine ⟨cons g w' ?_ ?_, ?_⟩
· rwa [Word.fstIdx, ← List.head?_map, hw'map, List.head?_map]
· exact hw _ List.mem_cons_self
· simp [hw'prod, hw'map]
/-- For any word `w` in the coproduct,
if `w` is reduced (i.e none its letters are in the image of the base monoid), and nonempty, then
`w` itself is not in the image of the base group. -/
theorem Reduced.eq_empty_of_mem_range
(hφ : ∀ i, Injective (φ i)) {w : Word G} (hw : Reduced φ w)
(h : ofCoprodI w.prod ∈ (base φ).range) : w = .empty := by
rcases transversal_nonempty φ hφ with ⟨d⟩
rcases hw.exists_normalWord_prod_eq d with ⟨w', hw'prod, hw'map⟩
rcases h with ⟨h, heq⟩
have : (NormalWord.prod (d := d) ⟨.empty, h, by simp⟩) = base φ h := by
simp [NormalWord.prod]
rw [← hw'prod, ← this] at heq
suffices w'.toWord = .empty by
simp [this, @eq_comm _ []] at hw'map
ext
simp [hw'map]
rw [← prod_injective heq]
end Reduced
/-- The intersection of the images of the maps from any two distinct groups in the diagram
into the amalgamated product is the image of the map from the base group in the diagram. -/
theorem inf_of_range_eq_base_range
(hφ : ∀ i, Injective (φ i)) {i j : ι} (hij : i ≠ j) :
(of i).range ⊓ (of j).range = (base φ).range :=
le_antisymm
(by
intro x ⟨⟨g₁, hg₁⟩, ⟨g₂, hg₂⟩⟩
by_contra hx
have hx1 : x ≠ 1 := by rintro rfl; simp_all only [ne_eq, one_mem, not_true_eq_false]
have hg₁1 : g₁ ≠ 1 :=
ne_of_apply_ne (of (φ := φ) i) (by simp_all)
have hg₂1 : g₂ ≠ 1 :=
ne_of_apply_ne (of (φ := φ) j) (by simp_all)
have hg₁r : g₁ ∉ (φ i).range := by
rintro ⟨y, rfl⟩
subst hg₁
exact hx (of_apply_eq_base φ i y ▸ MonoidHom.mem_range.2 ⟨y, rfl⟩)
have hg₂r : g₂ ∉ (φ j).range := by
rintro ⟨y, rfl⟩
subst hg₂
exact hx (of_apply_eq_base φ j y ▸ MonoidHom.mem_range.2 ⟨y, rfl⟩)
let w : Word G := ⟨[⟨_, g₁⟩, ⟨_, g₂⁻¹⟩], by simp_all, by simp_all⟩
have hw : Reduced φ w := by
simp only [w, Reduced, List.mem_cons,
forall_eq_or_imp, not_false_eq_true,
hg₁r, hg₂r, List.mem_nil_iff, false_imp_iff, imp_true_iff, and_true,
inv_mem_iff]
have := hw.eq_empty_of_mem_range hφ (by
simp only [w, Word.prod, List.map_cons, List.prod_cons, List.prod_nil,
List.map_nil, map_mul, ofCoprodI_of, hg₁, hg₂, map_inv, mul_one,
mul_inv_cancel, one_mem])
simp [w, Word.empty] at this)
(le_inf
(by rw [← of_comp_eq_base i]
rintro _ ⟨h, rfl⟩
exact MonoidHom.mem_range.2 ⟨φ i h, rfl⟩)
(by rw [← of_comp_eq_base j]
rintro _ ⟨h, rfl⟩
exact MonoidHom.mem_range.2 ⟨φ j h, rfl⟩))
end PushoutI
end Monoid |
.lake/packages/mathlib/Mathlib/GroupTheory/Finiteness.lean | import Mathlib.Algebra.Group.Pointwise.Set.Finite
import Mathlib.Algebra.Group.Subgroup.Pointwise
import Mathlib.Algebra.Group.Submonoid.BigOperators
import Mathlib.GroupTheory.FreeGroup.Basic
import Mathlib.GroupTheory.QuotientGroup.Defs
/-!
# Finitely generated monoids and groups
We define finitely generated monoids and groups. See also `Submodule.FG` and `Module.Finite` for
finitely-generated modules.
## Main definition
* `Submonoid.FG S`, `AddSubmonoid.FG S` : A submonoid `S` is finitely generated.
* `Monoid.FG M`, `AddMonoid.FG M` : A typeclass indicating a type `M` is finitely generated as a
monoid.
* `Subgroup.FG S`, `AddSubgroup.FG S` : A subgroup `S` is finitely generated.
* `Group.FG M`, `AddGroup.FG M` : A typeclass indicating a type `M` is finitely generated as a
group.
-/
assert_not_exists MonoidWithZero
/-! ### Monoids and submonoids -/
open Pointwise
variable {M N : Type*} [Monoid M]
section Submonoid
variable [Monoid N] {P : Submonoid M} {Q : Submonoid N}
/-- A submonoid of `M` is finitely generated if it is the closure of a finite subset of `M`. -/
@[to_additive /-- An additive submonoid of `N` is finitely generated if it is the closure of a
finite subset of `M`. -/]
def Submonoid.FG (P : Submonoid M) : Prop :=
∃ S : Finset M, Submonoid.closure ↑S = P
/-- An equivalent expression of `Submonoid.FG` in terms of `Set.Finite` instead of `Finset`. -/
@[to_additive /-- An equivalent expression of `AddSubmonoid.FG` in terms of `Set.Finite` instead of
`Finset`. -/]
theorem Submonoid.fg_iff (P : Submonoid M) :
Submonoid.FG P ↔ ∃ S : Set M, Submonoid.closure S = P ∧ S.Finite :=
⟨fun ⟨S, hS⟩ => ⟨S, hS, Finset.finite_toSet S⟩, fun ⟨S, hS, hf⟩ =>
⟨Set.Finite.toFinset hf, by simp [hS]⟩⟩
/-- A finitely generated submonoid has a minimal generating set. -/
@[to_additive /-- A finitely generated submonoid has a minimal generating set. -/]
lemma Submonoid.FG.exists_minimal_closure_eq (hP : P.FG) :
∃ S : Finset M, Minimal (fun S : Finset M ↦ closure S = P) S :=
exists_minimal_of_wellFoundedLT _ hP
theorem Submonoid.fg_iff_add_fg (P : Submonoid M) : P.FG ↔ P.toAddSubmonoid.FG :=
⟨fun h =>
let ⟨S, hS, hf⟩ := (Submonoid.fg_iff _).1 h
(AddSubmonoid.fg_iff _).mpr
⟨Additive.toMul ⁻¹' S, by simp [← Submonoid.toAddSubmonoid_closure, hS], hf⟩,
fun h =>
let ⟨T, hT, hf⟩ := (AddSubmonoid.fg_iff _).1 h
(Submonoid.fg_iff _).mpr
⟨Additive.ofMul ⁻¹' T, by simp [← AddSubmonoid.toSubmonoid'_closure, hT], hf⟩⟩
theorem AddSubmonoid.fg_iff_mul_fg {M : Type*} [AddMonoid M] (P : AddSubmonoid M) :
P.FG ↔ P.toSubmonoid.FG := by
convert (Submonoid.fg_iff_add_fg (toSubmonoid P)).symm
@[to_additive]
theorem Submonoid.FG.bot : FG (⊥ : Submonoid M) :=
⟨∅, by simp⟩
@[to_additive]
theorem Submonoid.FG.sup {Q : Submonoid M} (hP : P.FG) (hQ : Q.FG) : (P ⊔ Q).FG := by
classical
rcases hP with ⟨s, rfl⟩
rcases hQ with ⟨t, rfl⟩
exact ⟨s ∪ t, by simp [closure_union]⟩
@[to_additive]
theorem Submonoid.FG.finset_sup {ι : Type*} (s : Finset ι) (P : ι → Submonoid M)
(hP : ∀ i ∈ s, (P i).FG) : (s.sup P).FG :=
Finset.sup_induction bot (fun _ ha _ hb => ha.sup hb) hP
@[to_additive]
theorem Submonoid.FG.biSup_finset {ι : Type*} (s : Finset ι) (P : ι → Submonoid M)
(hP : ∀ i ∈ s, (P i).FG) : (⨆ i ∈ s, P i).FG := by
simpa only [Finset.sup_eq_iSup] using finset_sup s P hP
@[to_additive]
theorem Submonoid.FG.biSup {ι : Type*} {s : Set ι} (hs : s.Finite) (P : ι → Submonoid M)
(hP : ∀ i ∈ s, (P i).FG) : (⨆ i ∈ s, P i).FG := by
simpa using biSup_finset hs.toFinset P (by simpa)
@[to_additive]
theorem Submonoid.FG.iSup {ι : Sort*} [Finite ι] (P : ι → Submonoid M) (hP : ∀ i, (P i).FG) :
(iSup P).FG := by
simpa [iSup_plift_down] using biSup Set.finite_univ (P ∘ PLift.down) fun i _ => hP i.down
/-- The product of two finitely generated submonoids is finitely generated. -/
@[to_additive prod
/-- The product of two finitely generated additive submonoids is finitely generated. -/]
theorem Submonoid.FG.prod (hP : P.FG) (hQ : Q.FG) : (P.prod Q).FG := by
classical
obtain ⟨bM, hbM⟩ := hP
obtain ⟨bN, hbN⟩ := hQ
refine ⟨bM ×ˢ singleton 1 ∪ singleton 1 ×ˢ bN, ?_⟩
push_cast
simp [closure_union, hbM, hbN]
@[deprecated (since := "2025-08-28")] alias AddSubmonoid.FG.sum := AddSubmonoid.FG.prod
section Pi
variable {ι : Type*} [Finite ι] {M : ι → Type*} [∀ i, Monoid (M i)] {P : ∀ i, Submonoid (M i)}
@[to_additive]
theorem Submonoid.iSup_map_mulSingle [DecidableEq ι] :
⨆ i, map (MonoidHom.mulSingle M i) (P i) = pi Set.univ P := by
haveI := Fintype.ofFinite ι
refine iSup_map_mulSingle_le.antisymm fun x hx => ?_
rw [← Finset.noncommProd_mul_single x]
exact noncommProd_mem _ _ _ _ fun i _ => mem_iSup_of_mem _ (mem_map_of_mem _ (hx i trivial))
/-- Finite product of finitely generated submonoids is finitely generated. -/
@[to_additive
/-- Finite product of finitely generated additive submonoids is finitely generated. -/]
theorem Submonoid.FG.pi (hP : ∀ i, (P i).FG) : (pi Set.univ P).FG := by
classical
haveI := Fintype.ofFinite ι
choose s hs using hP
refine ⟨Finset.univ.biUnion fun i => (s i).image (MonoidHom.mulSingle M i), ?_⟩
simp_rw [Finset.coe_biUnion, Finset.coe_univ, Set.biUnion_univ, closure_iUnion, Finset.coe_image,
← MonoidHom.map_mclosure, hs, iSup_map_mulSingle]
end Pi
end Submonoid
section Monoid
/-- An additive monoid is finitely generated if it is finitely generated as an additive submonoid of
itself. -/
@[mk_iff]
class AddMonoid.FG (M : Type*) [AddMonoid M] : Prop where
fg_top : (⊤ : AddSubmonoid M).FG
variable (M) in
/-- A monoid is finitely generated if it is finitely generated as a submonoid of itself. -/
@[to_additive]
class Monoid.FG : Prop where
fg_top : (⊤ : Submonoid M).FG
@[to_additive]
theorem Monoid.fg_def : Monoid.FG M ↔ (⊤ : Submonoid M).FG :=
⟨fun h => h.1, fun h => ⟨h⟩⟩
/-- An equivalent expression of `Monoid.FG` in terms of `Set.Finite` instead of `Finset`. -/
@[to_additive
/-- An equivalent expression of `AddMonoid.FG` in terms of `Set.Finite` instead of `Finset`. -/]
theorem Monoid.fg_iff :
Monoid.FG M ↔ ∃ S : Set M, Submonoid.closure S = (⊤ : Submonoid M) ∧ S.Finite :=
⟨fun _ => (Submonoid.fg_iff ⊤).1 FG.fg_top, fun h => ⟨(Submonoid.fg_iff ⊤).2 h⟩⟩
/-- A monoid is finitely generated iff there exists a surjective homomorphism from a `FreeMonoid`
on finitely many generators. -/
@[to_additive /-- An additive monoid is finitely generated iff there exists a surjective
homomorphism from a `FreeAddMonoid` on finitely many generators.-/]
theorem Monoid.fg_iff_exists_freeMonoid_hom_surjective :
Monoid.FG M ↔ ∃ (S : Set M) (_ : S.Finite) (φ : FreeMonoid S →* M), Function.Surjective φ := by
refine ⟨fun ⟨S, hS⟩ ↦ ⟨S, S.finite_toSet, FreeMonoid.lift Subtype.val, ?_⟩, ?_⟩
· rwa [← MonoidHom.mrange_eq_top, ← Submonoid.closure_eq_mrange]
· rintro ⟨S, hfin : Finite S, φ, hφ⟩
refine fg_iff.mpr ⟨φ '' Set.range FreeMonoid.of, ?_, Set.toFinite _⟩
simp [← MonoidHom.map_mclosure, hφ, FreeMonoid.closure_range_of, ← MonoidHom.mrange_eq_map]
variable (M) in
/-- A finitely generated monoid has a minimal generating set. -/
@[to_additive /-- A finitely generated monoid has a minimal generating set. -/]
lemma Submonoid.exists_minimal_closure_eq_top [Monoid.FG M] :
∃ S : Finset M, Minimal (fun S ↦ Submonoid.closure (SetLike.coe S) = ⊤) S :=
Monoid.FG.fg_top.exists_minimal_closure_eq
theorem Monoid.fg_iff_add_fg : Monoid.FG M ↔ AddMonoid.FG (Additive M) where
mp _ := ⟨(Submonoid.fg_iff_add_fg ⊤).1 FG.fg_top⟩
mpr h := ⟨(Submonoid.fg_iff_add_fg ⊤).2 h.fg_top⟩
theorem AddMonoid.fg_iff_mul_fg {M : Type*} [AddMonoid M] :
AddMonoid.FG M ↔ Monoid.FG (Multiplicative M) where
mp _ := ⟨(AddSubmonoid.fg_iff_mul_fg ⊤).1 FG.fg_top⟩
mpr h := ⟨(AddSubmonoid.fg_iff_mul_fg ⊤).2 h.fg_top⟩
instance AddMonoid.fg_of_monoid_fg [Monoid.FG M] : AddMonoid.FG (Additive M) :=
Monoid.fg_iff_add_fg.1 ‹_›
instance Monoid.fg_of_addMonoid_fg {M : Type*} [AddMonoid M] [AddMonoid.FG M] :
Monoid.FG (Multiplicative M) :=
AddMonoid.fg_iff_mul_fg.1 ‹_›
-- This was previously a global instance,
-- but it doesn't appear to be used and has been implicated in slow typeclass resolutions.
@[to_additive]
lemma Monoid.fg_of_finite [Finite M] : Monoid.FG M := by
cases nonempty_fintype M
exact ⟨⟨Finset.univ, by rw [Finset.coe_univ]; exact Submonoid.closure_univ⟩⟩
end Monoid
@[to_additive]
theorem Submonoid.FG.map {M' : Type*} [Monoid M'] {P : Submonoid M} (h : P.FG) (e : M →* M') :
(P.map e).FG := by
classical
obtain ⟨s, rfl⟩ := h
exact ⟨s.image e, by rw [Finset.coe_image, MonoidHom.map_mclosure]⟩
@[to_additive]
theorem Submonoid.FG.map_injective {M' : Type*} [Monoid M'] {P : Submonoid M} (e : M →* M')
(he : Function.Injective e) (h : (P.map e).FG) : P.FG := by
obtain ⟨s, hs⟩ := h
use s.preimage e he.injOn
apply Submonoid.map_injective_of_injective he
rw [← hs, MonoidHom.map_mclosure e, Finset.coe_preimage]
congr
rw [Set.image_preimage_eq_iff, ← MonoidHom.coe_mrange e, ← Submonoid.closure_le, hs,
MonoidHom.mrange_eq_map e]
exact Submonoid.monotone_map le_top
@[to_additive (attr := simp)]
theorem Monoid.fg_iff_submonoid_fg (N : Submonoid M) : Monoid.FG N ↔ N.FG := by
conv_rhs => rw [← N.mrange_subtype, MonoidHom.mrange_eq_map]
exact ⟨fun h ↦ h.fg_top.map N.subtype, fun h => ⟨h.map_injective N.subtype Subtype.coe_injective⟩⟩
@[to_additive]
theorem Monoid.fg_of_surjective {M' : Type*} [Monoid M'] [Monoid.FG M] (f : M →* M')
(hf : Function.Surjective f) : Monoid.FG M' := by
classical
obtain ⟨s, hs⟩ := Monoid.fg_def.mp ‹_›
use s.image f
rwa [Finset.coe_image, ← MonoidHom.map_mclosure, hs, ← MonoidHom.mrange_eq_map,
MonoidHom.mrange_eq_top]
@[to_additive]
instance Monoid.fg_range {M' : Type*} [Monoid M'] [Monoid.FG M] (f : M →* M') :
Monoid.FG (MonoidHom.mrange f) :=
Monoid.fg_of_surjective f.mrangeRestrict f.mrangeRestrict_surjective
@[to_additive]
theorem Submonoid.powers_fg (r : M) : (Submonoid.powers r).FG :=
⟨{r}, (Finset.coe_singleton r).symm ▸ (Submonoid.powers_eq_closure r).symm⟩
@[to_additive]
instance Monoid.powers_fg (r : M) : Monoid.FG (Submonoid.powers r) :=
(Monoid.fg_iff_submonoid_fg _).mpr (Submonoid.powers_fg r)
@[to_additive]
instance Monoid.closure_finset_fg (s : Finset M) : Monoid.FG (Submonoid.closure (s : Set M)) := by
refine ⟨⟨s.preimage Subtype.val Subtype.coe_injective.injOn, ?_⟩⟩
rw [Finset.coe_preimage, Submonoid.closure_closure_coe_preimage]
@[to_additive]
instance Monoid.closure_finite_fg (s : Set M) [Finite s] : Monoid.FG (Submonoid.closure s) :=
haveI := Fintype.ofFinite s
s.coe_toFinset ▸ Monoid.closure_finset_fg s.toFinset
/-! ### Groups and subgroups -/
variable {G H : Type*} [Group G] [AddGroup H]
section Subgroup
/-- A subgroup of `G` is finitely generated if it is the closure of a finite subset of `G`. -/
@[to_additive]
def Subgroup.FG (P : Subgroup G) : Prop :=
∃ S : Finset G, Subgroup.closure ↑S = P
/-- An additive subgroup of `H` is finitely generated if it is the closure of a finite subset of
`H`. -/
add_decl_doc AddSubgroup.FG
/-- An equivalent expression of `Subgroup.FG` in terms of `Set.Finite` instead of `Finset`. -/
@[to_additive /-- An equivalent expression of `AddSubgroup.fg` in terms of `Set.Finite` instead of
`Finset`. -/]
theorem Subgroup.fg_iff (P : Subgroup G) :
Subgroup.FG P ↔ ∃ S : Set G, Subgroup.closure S = P ∧ S.Finite :=
⟨fun ⟨S, hS⟩ => ⟨S, hS, Finset.finite_toSet S⟩, fun ⟨S, hS, hf⟩ =>
⟨Set.Finite.toFinset hf, by simp [hS]⟩⟩
/-- A subgroup is finitely generated if and only if it is finitely generated as a submonoid. -/
@[to_additive /-- An additive subgroup is finitely generated if
and only if it is finitely generated as an additive submonoid. -/]
theorem Subgroup.fg_iff_submonoid_fg (P : Subgroup G) : P.FG ↔ P.toSubmonoid.FG := by
constructor
· rintro ⟨S, rfl⟩
rw [Submonoid.fg_iff]
refine ⟨S ∪ S⁻¹, ?_, S.finite_toSet.union S.finite_toSet.inv⟩
exact (Subgroup.closure_toSubmonoid _).symm
· rintro ⟨S, hS⟩
refine ⟨S, le_antisymm ?_ ?_⟩
· rw [Subgroup.closure_le, ← Subgroup.coe_toSubmonoid, ← hS]
exact Submonoid.subset_closure
· rw [← Subgroup.toSubmonoid_le, ← hS, Submonoid.closure_le]
exact Subgroup.subset_closure
theorem Subgroup.fg_iff_add_fg (P : Subgroup G) : P.FG ↔ P.toAddSubgroup.FG := by
rw [Subgroup.fg_iff_submonoid_fg, AddSubgroup.fg_iff_addSubmonoid_fg]
exact (Subgroup.toSubmonoid P).fg_iff_add_fg
theorem AddSubgroup.fg_iff_mul_fg (P : AddSubgroup H) : P.FG ↔ P.toSubgroup.FG := by
rw [AddSubgroup.fg_iff_addSubmonoid_fg, Subgroup.fg_iff_submonoid_fg]
exact AddSubmonoid.fg_iff_mul_fg (AddSubgroup.toAddSubmonoid P)
@[to_additive]
theorem Subgroup.FG.bot : FG (⊥ : Subgroup G) :=
⟨∅, by simp⟩
@[to_additive]
theorem Subgroup.FG.sup {P Q : Subgroup G} (hP : P.FG) (hQ : Q.FG) : (P ⊔ Q).FG := by
classical
rcases hP with ⟨s, rfl⟩
rcases hQ with ⟨t, rfl⟩
exact ⟨s ∪ t, by simp [closure_union]⟩
@[to_additive]
theorem Subgroup.FG.finset_sup {ι : Type*} (s : Finset ι) (P : ι → Subgroup G)
(hP : ∀ i ∈ s, (P i).FG) : (s.sup P).FG :=
Finset.sup_induction bot (fun _ ha _ hb => ha.sup hb) hP
@[to_additive]
theorem Subgroup.FG.biSup_finset {ι : Type*} (s : Finset ι) (P : ι → Subgroup G)
(hP : ∀ i ∈ s, (P i).FG) : (⨆ i ∈ s, P i).FG := by
simpa only [Finset.sup_eq_iSup] using finset_sup s P hP
@[to_additive]
theorem Subgroup.FG.biSup {ι : Type*} {s : Set ι} (hs : s.Finite) (P : ι → Subgroup G)
(hP : ∀ i ∈ s, (P i).FG) : (⨆ i ∈ s, P i).FG := by
simpa using biSup_finset hs.toFinset P (by simpa)
@[to_additive]
theorem Subgroup.FG.iSup {ι : Sort*} [Finite ι] (P : ι → Subgroup G) (hP : ∀ i, (P i).FG) :
(iSup P).FG := by
simpa [iSup_plift_down] using biSup Set.finite_univ (P ∘ PLift.down) fun i _ => hP i.down
/-- The product of two finitely generated subgroups is finitely generated. -/
@[to_additive prod
/-- The product of two finitely generated additive subgroups is finitely generated. -/]
theorem Subgroup.FG.prod {G' : Type*} [Group G'] {P : Subgroup G} {Q : Subgroup G'}
(hP : P.FG) (hQ : Q.FG) : (P.prod Q).FG := by
rw [fg_iff_submonoid_fg] at *
exact hP.prod hQ
/-- Finite product of finitely generated subgroups is finitely generated. -/
@[to_additive /-- Finite product of finitely generated additive subgroups is finitely generated. -/]
theorem Subgroup.FG.pi {ι : Type*} [Finite ι] {G : ι → Type*} [∀ i, Group (G i)]
{P : ∀ i, Subgroup (G i)} (hP : ∀ i, (P i).FG) : (pi Set.univ P).FG := by
simp_rw [fg_iff_submonoid_fg] at *
exact .pi hP
end Subgroup
section Group
variable (G H)
/-- A group is finitely generated if it is finitely generated as a subgroup of itself. -/
class Group.FG : Prop where
out : (⊤ : Subgroup G).FG
/-- An additive group is finitely generated if it is finitely generated as an additive subgroup of
itself. -/
class AddGroup.FG : Prop where
out : (⊤ : AddSubgroup H).FG
attribute [to_additive] Group.FG
variable {G H}
theorem Group.fg_def : Group.FG G ↔ (⊤ : Subgroup G).FG :=
⟨fun h => h.1, fun h => ⟨h⟩⟩
theorem AddGroup.fg_def : AddGroup.FG H ↔ (⊤ : AddSubgroup H).FG :=
⟨fun h => h.1, fun h => ⟨h⟩⟩
/-- An equivalent expression of `Group.FG` in terms of `Set.Finite` instead of `Finset`. -/
@[to_additive
/-- An equivalent expression of `AddGroup.fg` in terms of `Set.Finite` instead of `Finset`. -/]
theorem Group.fg_iff : Group.FG G ↔ ∃ S : Set G, Subgroup.closure S = (⊤ : Subgroup G) ∧ S.Finite :=
⟨fun h => (Subgroup.fg_iff ⊤).1 h.out, fun h => ⟨(Subgroup.fg_iff ⊤).2 h⟩⟩
@[to_additive]
theorem Group.fg_iff' :
Group.FG G ↔ ∃ (n : _) (S : Finset G), S.card = n ∧ Subgroup.closure (S : Set G) = ⊤ :=
Group.fg_def.trans ⟨fun ⟨S, hS⟩ => ⟨S.card, S, rfl, hS⟩, fun ⟨_n, S, _hn, hS⟩ => ⟨S, hS⟩⟩
/-- A group is finitely generated iff there exists a surjective homomorphism from a `FreeGroup`
on finitely many generators. -/
@[to_additive /-- An additive group is finitely generated iff there exists a surjective homomorphism
from a `FreeAddGroup` on finitely many generators. -/]
theorem Group.fg_iff_exists_freeGroup_hom_surjective :
Group.FG G ↔ ∃ (S : Set G) (_ : S.Finite) (φ : FreeGroup S →* G), Function.Surjective φ := by
refine ⟨fun ⟨S, hS⟩ ↦ ⟨S, S.finite_toSet, FreeGroup.lift Subtype.val, ?_⟩, ?_⟩
· rwa [← MonoidHom.range_eq_top, ← FreeGroup.closure_eq_range]
· rintro ⟨S, hfin : Finite S, φ, hφ⟩
refine fg_iff.mpr ⟨φ '' Set.range FreeGroup.of, ?_, Set.toFinite _⟩
simp [← MonoidHom.map_closure, hφ, FreeGroup.closure_range_of, ← MonoidHom.range_eq_map]
/-- A group is finitely generated if and only if it is finitely generated as a monoid. -/
@[to_additive /-- An additive group is finitely generated if and only
if it is finitely generated as an additive monoid. -/]
theorem Group.fg_iff_monoid_fg : Group.FG G ↔ Monoid.FG G :=
⟨fun h => Monoid.fg_def.2 <| (Subgroup.fg_iff_submonoid_fg ⊤).1 (Group.fg_def.1 h), fun h =>
Group.fg_def.2 <| (Subgroup.fg_iff_submonoid_fg ⊤).2 (Monoid.fg_def.1 h)⟩
@[to_additive]
instance Monoid.fg_of_group_fg [Group.FG G] : Monoid.FG G :=
Group.fg_iff_monoid_fg.1 ‹_›
@[to_additive (attr := simp)]
theorem Group.fg_iff_subgroup_fg (H : Subgroup G) : Group.FG H ↔ H.FG :=
(fg_iff_monoid_fg.trans (Monoid.fg_iff_submonoid_fg _)).trans
(Subgroup.fg_iff_submonoid_fg _).symm
theorem GroupFG.iff_add_fg : Group.FG G ↔ AddGroup.FG (Additive G) :=
⟨fun h => ⟨(Subgroup.fg_iff_add_fg ⊤).1 h.out⟩, fun h => ⟨(Subgroup.fg_iff_add_fg ⊤).2 h.out⟩⟩
theorem AddGroup.fg_iff_mul_fg : AddGroup.FG H ↔ Group.FG (Multiplicative H) :=
⟨fun h => ⟨(AddSubgroup.fg_iff_mul_fg ⊤).1 h.out⟩, fun h =>
⟨(AddSubgroup.fg_iff_mul_fg ⊤).2 h.out⟩⟩
instance AddGroup.fg_of_group_fg [Group.FG G] : AddGroup.FG (Additive G) :=
GroupFG.iff_add_fg.1 ‹_›
instance Group.fg_of_mul_group_fg [AddGroup.FG H] : Group.FG (Multiplicative H) :=
AddGroup.fg_iff_mul_fg.1 ‹_›
@[to_additive]
instance (priority := 100) Group.fg_of_finite [Finite G] : Group.FG G := by
cases nonempty_fintype G
exact ⟨⟨Finset.univ, by rw [Finset.coe_univ]; exact Subgroup.closure_univ⟩⟩
@[to_additive]
theorem Group.fg_of_surjective {G' : Type*} [Group G'] [hG : Group.FG G] {f : G →* G'}
(hf : Function.Surjective f) : Group.FG G' :=
Group.fg_iff_monoid_fg.mpr <|
@Monoid.fg_of_surjective G _ G' _ (Group.fg_iff_monoid_fg.mp hG) f hf
@[to_additive]
instance Group.fg_range {G' : Type*} [Group G'] [Group.FG G] (f : G →* G') : Group.FG f.range :=
Group.fg_of_surjective f.rangeRestrict_surjective
@[to_additive]
instance Group.closure_finset_fg (s : Finset G) : Group.FG (Subgroup.closure (s : Set G)) := by
refine ⟨⟨s.preimage Subtype.val Subtype.coe_injective.injOn, ?_⟩⟩
rw [Finset.coe_preimage, ← Subgroup.coe_subtype, Subgroup.closure_preimage_eq_top]
@[to_additive]
instance Group.closure_finite_fg (s : Set G) [Finite s] : Group.FG (Subgroup.closure s) :=
haveI := Fintype.ofFinite s
s.coe_toFinset ▸ Group.closure_finset_fg s.toFinset
end Group
section QuotientGroup
@[to_additive]
instance QuotientGroup.fg [Group.FG G] (N : Subgroup G) [Subgroup.Normal N] : Group.FG <| G ⧸ N :=
Group.fg_of_surjective <| QuotientGroup.mk'_surjective N
end QuotientGroup
namespace Prod
variable [Monoid N] {G' : Type*} [Group G']
open Monoid in
/-- The product of two finitely generated monoids is finitely generated. -/
@[to_additive /-- The product of two finitely generated additive monoids is finitely generated. -/]
instance instMonoidFG [FG M] [FG N] : FG (M × N) where
fg_top := by
rw [← Submonoid.top_prod_top]
exact ‹FG M›.fg_top.prod ‹FG N›.fg_top
open Group in
/-- The product of two finitely generated groups is finitely generated. -/
@[to_additive /-- The product of two finitely generated additive groups is finitely generated. -/]
instance instGroupFG [FG G] [FG G'] : FG (G × G') where
out := by
rw [← Subgroup.top_prod_top]
exact ‹FG G›.out.prod ‹FG G'›.out
end Prod
namespace Pi
variable {ι : Type*} [Finite ι]
/-- Finite product of finitely generated monoids is finitely generated. -/
@[to_additive /-- Finite product of finitely generated additive monoids is finitely generated. -/]
instance instMonoidFG {M : ι → Type*} [∀ i, Monoid (M i)] [∀ i, Monoid.FG (M i)] :
Monoid.FG (∀ i, M i) where
fg_top := by
rw [← Submonoid.pi_top Set.univ]
exact .pi fun i => Monoid.FG.fg_top
/-- Finite product of finitely generated groups is finitely generated. -/
@[to_additive /-- Finite product of finitely generated additive groups is finitely generated. -/]
instance instGroupFG {G : ι → Type*} [∀ i, Group (G i)] [∀ i, Group.FG (G i)] :
Group.FG (∀ i, G i) where
out := by
rw [← Subgroup.pi_top Set.univ]
exact .pi fun i => Group.FG.out
end Pi
namespace AddMonoid
instance : FG ℕ where
fg_top := ⟨{1}, by simp⟩
end AddMonoid
namespace AddGroup
instance : FG ℤ where
out := ⟨{1}, by simp⟩
end AddGroup
section WellQuasiOrderedLE
variable {M N : Type*} [CommMonoid M] [PartialOrder M] [WellQuasiOrderedLE M]
[IsOrderedCancelMonoid M] [CanonicallyOrderedMul M]
/-- In a canonically ordered and well-quasi-ordered monoid, any divisive submonoid is finitely
generated. -/
@[to_additive fg_of_subtractive /-- In a canonically ordered and well-quasi-ordered additive monoid
(typical example is `ℕ ^ k`), any subtractive submonoid is finitely generated. -/]
theorem Submonoid.fg_of_divisive {P : Submonoid M} (hP : ∀ x ∈ P, ∀ y, x * y ∈ P → y ∈ P) :
P.FG := by
have hpwo := Set.isPWO_of_wellQuasiOrderedLE { x | x ∈ P ∧ x ≠ 1 }
rw [fg_iff]
refine ⟨_, ?_, (setOf_minimal_antichain _).finite_of_partiallyWellOrderedOn
(hpwo.mono (setOf_minimal_subset _))⟩
ext x
constructor
· intro hx
rw [← P.closure_eq]
exact closure_mono ((setOf_minimal_subset _).trans fun _ => And.left) hx
· intro hx₁
by_cases hx₂ : x = 1
· simp [hx₂]
refine hpwo.wellFoundedOn.induction ⟨hx₁, hx₂⟩ fun y ⟨hy₁, hy₂⟩ ih => ?_
simp only [Set.mem_setOf_eq, and_imp] at ih
by_cases hy₃ : Minimal (· ∈ { x | x ∈ P ∧ x ≠ 1 }) y
· exact mem_closure_of_mem hy₃
rcases exists_lt_of_not_minimal ⟨hy₁, hy₂⟩ hy₃ with ⟨z, hz₁, hz₂, hz₃⟩
rcases exists_mul_of_le hz₁.le with ⟨y, rfl⟩
apply mul_mem
· exact ih _ hz₂ hz₃ hz₁.le hz₁.not_ge
apply ih
· exact hP _ hz₂ _ hy₁
· exact (one_lt_of_lt_mul_right hz₁).ne.symm
· exact le_mul_self
· rw [mul_le_iff_le_one_left']
exact (one_lt_of_ne_one hz₃).not_ge
/-- A canonically ordered and well-quasi-ordered monoid must be finitely generated. -/
@[to_additive /-- A canonically ordered and well-quasi-ordered additive monoid must be finitely
generated. -/]
theorem CommMonoid.fg_of_wellQuasiOrderedLE : Monoid.FG M where
fg_top := Submonoid.fg_of_divisive (by simp)
/-- If `f` `g` are homomorphisms from a canonically ordered and well-quasi-ordered monoid `M` to a
cancellative monoid `N`, the submonoid of `M` on which `f` and `g` agree is finitely generated. -/
@[to_additive /-- If `f` `g` are homomorphisms from a canonically ordered and well-quasi-ordered
additive monoid `M` to a cancellative additive monoid `N`, the submonoid of `M` on which `f` and `g`
agree is finitely generated. When `M` and `N` are `ℕ ^ k`, this is also known as a version of
**Gordan's lemma**. -/]
theorem Submonoid.fg_eqLocusM [Monoid N] [IsCancelMul N] (f g : M →* N) : (f.eqLocusM g).FG :=
fg_of_divisive (by simp_all)
end WellQuasiOrderedLE |
.lake/packages/mathlib/Mathlib/GroupTheory/SemidirectProduct.lean | import Mathlib.GroupTheory.Complement
/-!
# Semidirect product
This file defines semidirect products of groups, and the canonical maps in and out of the
semidirect product. The semidirect product of `N` and `G` given a hom `φ` from
`G` to the automorphism group of `N` is the product of sets with the group
`⟨n₁, g₁⟩ * ⟨n₂, g₂⟩ = ⟨n₁ * φ g₁ n₂, g₁ * g₂⟩`
## Key definitions
There are two homs into the semidirect product `inl : N →* N ⋊[φ] G` and
`inr : G →* N ⋊[φ] G`, and `lift` can be used to define maps `N ⋊[φ] G →* H`
out of the semidirect product given maps `fn : N →* H` and `fg : G →* H` that satisfy the
condition `∀ n g, fn (φ g n) = fg g * fn n * fg g⁻¹`
## Notation
This file introduces the global notation `N ⋊[φ] G` for `SemidirectProduct N G φ`
## Tags
group, semidirect product
-/
open Subgroup
variable (N : Type*) (G : Type*) {H : Type*} [Group N] [Group G] [Group H]
-- Don't generate sizeOf and injectivity lemmas, which the `simpNF` linter will complain about.
set_option genSizeOfSpec false in
set_option genInjectivity false in
/-- The semidirect product of groups `N` and `G`, given a map `φ` from `G` to the automorphism
group of `N`. It the product of sets with the group operation
`⟨n₁, g₁⟩ * ⟨n₂, g₂⟩ = ⟨n₁ * φ g₁ n₂, g₁ * g₂⟩` -/
@[ext]
structure SemidirectProduct (φ : G →* MulAut N) where
/-- The element of N -/
left : N
/-- The element of G -/
right : G
deriving DecidableEq
attribute [pp_using_anonymous_constructor] SemidirectProduct
@[inherit_doc]
notation:35 N " ⋊[" φ:35 "] " G:35 => SemidirectProduct N G φ
namespace SemidirectProduct
variable {N G}
variable {φ : G →* MulAut N}
instance : Mul (SemidirectProduct N G φ) where
mul a b := ⟨a.1 * φ a.2 b.1, a.2 * b.2⟩
lemma mul_def (a b : SemidirectProduct N G φ) : a * b = ⟨a.1 * φ a.2 b.1, a.2 * b.2⟩ := rfl
@[simp]
theorem mul_left (a b : N ⋊[φ] G) : (a * b).left = a.left * φ a.right b.left := rfl
@[simp]
theorem mul_right (a b : N ⋊[φ] G) : (a * b).right = a.right * b.right := rfl
instance : One (SemidirectProduct N G φ) where one := ⟨1, 1⟩
@[simp]
theorem one_left : (1 : N ⋊[φ] G).left = 1 := rfl
@[simp]
theorem one_right : (1 : N ⋊[φ] G).right = 1 := rfl
instance : Inv (SemidirectProduct N G φ) where
inv x := ⟨φ x.2⁻¹ x.1⁻¹, x.2⁻¹⟩
@[simp]
theorem inv_left (a : N ⋊[φ] G) : a⁻¹.left = φ a.right⁻¹ a.left⁻¹ := rfl
@[simp]
theorem inv_right (a : N ⋊[φ] G) : a⁻¹.right = a.right⁻¹ := rfl
instance : Group (N ⋊[φ] G) where
mul_assoc a b c := SemidirectProduct.ext (by simp [mul_assoc]) (by simp [mul_assoc])
one_mul a := SemidirectProduct.ext (by simp) (one_mul a.2)
mul_one a := SemidirectProduct.ext (by simp) (mul_one _)
inv_mul_cancel a := SemidirectProduct.ext (by simp) (by simp)
instance : Inhabited (N ⋊[φ] G) := ⟨1⟩
/-- The canonical map `N →* N ⋊[φ] G` sending `n` to `⟨n, 1⟩` -/
def inl : N →* N ⋊[φ] G where
toFun n := ⟨n, 1⟩
map_one' := rfl
map_mul' := by intros; ext <;>
simp only [mul_left, map_one, MulAut.one_apply, mul_right, mul_one]
@[simp]
theorem left_inl (n : N) : (inl n : N ⋊[φ] G).left = n := rfl
@[simp]
theorem right_inl (n : N) : (inl n : N ⋊[φ] G).right = 1 := rfl
theorem inl_injective : Function.Injective (inl : N → N ⋊[φ] G) :=
Function.injective_iff_hasLeftInverse.2 ⟨left, left_inl⟩
@[simp]
theorem inl_inj {n₁ n₂ : N} : (inl n₁ : N ⋊[φ] G) = inl n₂ ↔ n₁ = n₂ :=
inl_injective.eq_iff
/-- The canonical map `G →* N ⋊[φ] G` sending `g` to `⟨1, g⟩` -/
def inr : G →* N ⋊[φ] G where
toFun g := ⟨1, g⟩
map_one' := rfl
map_mul' := by intros; ext <;> simp
@[simp]
theorem left_inr (g : G) : (inr g : N ⋊[φ] G).left = 1 := rfl
@[simp]
theorem right_inr (g : G) : (inr g : N ⋊[φ] G).right = g := rfl
theorem inr_injective : Function.Injective (inr : G → N ⋊[φ] G) :=
Function.injective_iff_hasLeftInverse.2 ⟨right, right_inr⟩
@[simp]
theorem inr_inj {g₁ g₂ : G} : (inr g₁ : N ⋊[φ] G) = inr g₂ ↔ g₁ = g₂ :=
inr_injective.eq_iff
theorem inl_aut (g : G) (n : N) : (inl (φ g n) : N ⋊[φ] G) = inr g * inl n * inr g⁻¹ := by
ext <;> simp
theorem inl_aut_inv (g : G) (n : N) : (inl ((φ g)⁻¹ n) : N ⋊[φ] G) = inr g⁻¹ * inl n * inr g := by
rw [← MonoidHom.map_inv, inl_aut, inv_inv]
@[simp]
theorem mk_eq_inl_mul_inr (g : G) (n : N) : (⟨n, g⟩ : N ⋊[φ] G) = inl n * inr g := by ext <;> simp
@[simp]
theorem inl_left_mul_inr_right (x : N ⋊[φ] G) : inl x.left * inr x.right = x := by ext <;> simp
/-- The canonical projection map `N ⋊[φ] G →* G`, as a group hom. -/
def rightHom : N ⋊[φ] G →* G where
toFun := SemidirectProduct.right
map_one' := rfl
map_mul' _ _ := rfl
@[simp]
theorem rightHom_eq_right : (rightHom : N ⋊[φ] G → G) = right := rfl
@[simp]
theorem rightHom_comp_inl : (rightHom : N ⋊[φ] G →* G).comp inl = 1 := by ext; simp [rightHom]
@[simp]
theorem rightHom_comp_inr : (rightHom : N ⋊[φ] G →* G).comp inr = MonoidHom.id _ := by
ext; simp [rightHom]
@[simp]
theorem rightHom_inl (n : N) : rightHom (inl n : N ⋊[φ] G) = 1 := by simp [rightHom]
@[simp]
theorem rightHom_inr (g : G) : rightHom (inr g : N ⋊[φ] G) = g := by simp [rightHom]
theorem rightHom_surjective : Function.Surjective (rightHom : N ⋊[φ] G → G) :=
Function.surjective_iff_hasRightInverse.2 ⟨inr, rightHom_inr⟩
theorem range_inl_eq_ker_rightHom : (inl : N →* N ⋊[φ] G).range = rightHom.ker :=
le_antisymm (fun _ ↦ by simp +contextual [MonoidHom.mem_ker, eq_comm])
fun x hx ↦ ⟨x.left, by ext <;> simp_all [MonoidHom.mem_ker]⟩
/-- The bijection between the semidirect product and the product. -/
@[simps]
def equivProd : N ⋊[φ] G ≃ N × G where
toFun x := ⟨x.1, x.2⟩
invFun x := ⟨x.1, x.2⟩
/-- The group isomorphism between a semidirect product with respect to the trivial map
and the product. -/
@[simps (rhsMd := .default)]
def mulEquivProd : N ⋊[1] G ≃* N × G :=
{ equivProd with map_mul' _ _ := rfl }
section lift
variable (fn : N →* H) (fg : G →* H)
(h : ∀ g, fn.comp (φ g).toMonoidHom = (MulAut.conj (fg g)).toMonoidHom.comp fn)
/-- Define a group hom `N ⋊[φ] G →* H`, by defining maps `N →* H` and `G →* H` -/
def lift : N ⋊[φ] G →* H where
toFun a := fn a.1 * fg a.2
map_one' := by simp
map_mul' a b := by
have := fun n g ↦ DFunLike.ext_iff.1 (h n) g
simp only [MulAut.conj_apply, MonoidHom.comp_apply, MulEquiv.coe_toMonoidHom] at this
simp only [mul_left, mul_right, map_mul, this, mul_assoc, inv_mul_cancel_left]
@[simp]
theorem lift_inl (n : N) : lift fn fg h (inl n) = fn n := by simp [lift]
@[simp]
theorem lift_comp_inl : (lift fn fg h).comp inl = fn := by ext; simp
@[simp]
theorem lift_inr (g : G) : lift fn fg h (inr g) = fg g := by simp [lift]
@[simp]
theorem lift_comp_inr : (lift fn fg h).comp inr = fg := by ext; simp
theorem lift_unique (F : N ⋊[φ] G →* H) :
F = lift (F.comp inl) (F.comp inr) fun _ ↦ by ext; simp [inl_aut] := by
rw [DFunLike.ext_iff]
simp only [lift, MonoidHom.comp_apply, MonoidHom.coe_mk, OneHom.coe_mk, ← map_mul,
inl_left_mul_inr_right, forall_const]
/-- Two maps out of the semidirect product are equal if they're equal after composition
with both `inl` and `inr` -/
theorem hom_ext {f g : N ⋊[φ] G →* H} (hl : f.comp inl = g.comp inl)
(hr : f.comp inr = g.comp inr) : f = g := by
rw [lift_unique f, lift_unique g]
simp only [*]
/-- The homomorphism from a semidirect product of subgroups to the ambient group. -/
@[simps!]
def monoidHomSubgroup {H K : Subgroup G} (h : K ≤ H.normalizer) :
H ⋊[(H.normalizerMonoidHom).comp (inclusion h)] K →* G :=
lift H.subtype K.subtype (by simp [DFunLike.ext_iff])
/-- The isomorphism from a semidirect product of complementary subgroups to the ambient group. -/
@[simps!]
noncomputable def mulEquivSubgroup {H K : Subgroup G} [H.Normal] (h : H.IsComplement' K) :
H ⋊[(H.normalizerMonoidHom).comp (inclusion (H.normalizer_eq_top ▸ le_top))] K ≃* G :=
MulEquiv.ofBijective (monoidHomSubgroup _) ((equivProd.bijective_comp _).mpr h)
end lift
section Map
variable {N₁ G₁ N₂ G₂ : Type*} [Group N₁] [Group G₁] [Group N₂] [Group G₂]
{φ₁ : G₁ →* MulAut N₁} {φ₂ : G₂ →* MulAut N₂}
(fn : N₁ →* N₂) (fg : G₁ →* G₂)
(h : ∀ g : G₁, fn.comp (φ₁ g).toMonoidHom = (φ₂ (fg g)).toMonoidHom.comp fn)
/-- Define a map from `N₁ ⋊[φ₁] G₁` to `N₂ ⋊[φ₂] G₂` given maps `N₁ →* N₂` and `G₁ →* G₂` that
satisfy a commutativity condition `∀ n g, fn (φ₁ g n) = φ₂ (fg g) (fn n)`. -/
def map : N₁ ⋊[φ₁] G₁ →* N₂ ⋊[φ₂] G₂ where
toFun x := ⟨fn x.1, fg x.2⟩
map_one' := by simp
map_mul' x y := by
replace h := DFunLike.ext_iff.1 (h x.right) y.left
ext <;> simp_all
@[simp]
theorem map_left (g : N₁ ⋊[φ₁] G₁) : (map fn fg h g).left = fn g.left := rfl
@[simp]
theorem map_right (g : N₁ ⋊[φ₁] G₁) : (map fn fg h g).right = fg g.right := rfl
@[simp]
theorem rightHom_comp_map : rightHom.comp (map fn fg h) = fg.comp rightHom := rfl
@[simp]
theorem map_inl (n : N₁) : map fn fg h (inl n) = inl (fn n) := by simp [map]
@[simp]
theorem map_comp_inl : (map fn fg h).comp inl = inl.comp fn := by ext <;> simp
@[simp]
theorem map_inr (g : G₁) : map fn fg h (inr g) = inr (fg g) := by simp [map]
@[simp]
theorem map_comp_inr : (map fn fg h).comp inr = inr.comp fg := by ext <;> simp [map]
end Map
section Congr
variable {N₁ G₁ N₂ G₂ : Type*} [Group N₁] [Group G₁] [Group N₂] [Group G₂]
{φ₁ : G₁ →* MulAut N₁} {φ₂ : G₂ →* MulAut N₂}
(fn : N₁ ≃* N₂) (fg : G₁ ≃* G₂)
(h : ∀ g : G₁, (φ₁ g).trans fn = fn.trans (φ₂ (fg g)))
/-- Define an isomorphism from `N₁ ⋊[φ₁] G₁` to `N₂ ⋊[φ₂] G₂` given isomorphisms `N₁ ≃* N₂` and
`G₁ ≃* G₂` that satisfy a commutativity condition `∀ n g, fn (φ₁ g n) = φ₂ (fg g) (fn n)`. -/
@[simps]
def congr : N₁ ⋊[φ₁] G₁ ≃* N₂ ⋊[φ₂] G₂ where
toFun x := ⟨fn x.1, fg x.2⟩
invFun x := ⟨fn.symm x.1, fg.symm x.2⟩
left_inv _ := by simp
right_inv _ := by simp
map_mul' x y := by
replace h := DFunLike.ext_iff.1 (h x.right) y.left
ext <;> simp_all
/-- Define a isomorphism from `N₁ ⋊[φ₁] G₁` to `N₂ ⋊[φ₂] G₂` without specifying `φ₂`. -/
@[simps!]
def congr' :
N₁ ⋊[φ₁] G₁ ≃* N₂ ⋊[MonoidHom.comp (MulAut.congr fn) (φ₁.comp fg.symm)] G₂ :=
congr fn fg (fun _ ↦ by ext; simp)
end Congr
@[simp]
lemma card : Nat.card (N ⋊[φ] G) = Nat.card N * Nat.card G :=
Nat.card_prod _ _ ▸ Nat.card_congr equivProd
end SemidirectProduct |
.lake/packages/mathlib/Mathlib/GroupTheory/OrderOfElement.lean | import Mathlib.Algebra.CharP.Defs
import Mathlib.Algebra.Group.Commute.Basic
import Mathlib.Algebra.Group.Pointwise.Set.Finite
import Mathlib.Algebra.Group.Subgroup.Finite
import Mathlib.Algebra.Module.NatInt
import Mathlib.Algebra.Order.Group.Action
import Mathlib.Algebra.Order.Ring.Abs
import Mathlib.Data.Int.ModEq
import Mathlib.Dynamics.PeriodicPts.Lemmas
import Mathlib.GroupTheory.Index
import Mathlib.NumberTheory.Divisors
import Mathlib.Order.Interval.Set.Infinite
/-!
# Order of an element
This file defines the order of an element of a finite group. For a finite group `G` the order of
`x ∈ G` is the minimal `n ≥ 1` such that `x ^ n = 1`.
## Main definitions
* `IsOfFinOrder` is a predicate on an element `x` of a monoid `G` saying that `x` is of finite
order.
* `IsOfFinAddOrder` is the additive analogue of `IsOfFinOrder`.
* `orderOf x` defines the order of an element `x` of a monoid `G`, by convention its value is `0`
if `x` has infinite order.
* `addOrderOf` is the additive analogue of `orderOf`.
## Tags
order of an element
-/
assert_not_exists Field
open Function Fintype Nat Pointwise Subgroup Submonoid
open scoped Finset
variable {G H A α β : Type*}
section Monoid
variable [Monoid G] {a b x y : G} {n m : ℕ}
section IsOfFinOrder
@[to_additive]
theorem isPeriodicPt_mul_iff_pow_eq_one (x : G) : IsPeriodicPt (x * ·) n 1 ↔ x ^ n = 1 := by
rw [IsPeriodicPt, IsFixedPt, mul_left_iterate_apply_one]
/-- `IsOfFinOrder` is a predicate on an element `x` of a monoid to be of finite order, i.e. there
exists `n ≥ 1` such that `x ^ n = 1`. -/
@[to_additive /-- `IsOfFinAddOrder` is a predicate on an element `a` of an
additive monoid to be of finite order, i.e. there exists `n ≥ 1` such that `n • a = 0`. -/]
def IsOfFinOrder (x : G) : Prop :=
(1 : G) ∈ periodicPts (x * ·)
theorem isOfFinAddOrder_ofMul_iff : IsOfFinAddOrder (Additive.ofMul x) ↔ IsOfFinOrder x :=
Iff.rfl
theorem isOfFinOrder_ofAdd_iff {α : Type*} [AddMonoid α] {x : α} :
IsOfFinOrder (Multiplicative.ofAdd x) ↔ IsOfFinAddOrder x := Iff.rfl
@[to_additive]
theorem isOfFinOrder_iff_pow_eq_one : IsOfFinOrder x ↔ ∃ n, 0 < n ∧ x ^ n = 1 := by
simp [IsOfFinOrder, mem_periodicPts, isPeriodicPt_mul_iff_pow_eq_one]
@[to_additive] alias ⟨IsOfFinOrder.exists_pow_eq_one, _⟩ := isOfFinOrder_iff_pow_eq_one
@[to_additive]
lemma isOfFinOrder_iff_zpow_eq_one {G} [DivisionMonoid G] {x : G} :
IsOfFinOrder x ↔ ∃ (n : ℤ), n ≠ 0 ∧ x ^ n = 1 := by
rw [isOfFinOrder_iff_pow_eq_one]
refine ⟨fun ⟨n, hn, hn'⟩ ↦ ⟨n, Int.natCast_ne_zero_iff_pos.mpr hn, zpow_natCast x n ▸ hn'⟩,
fun ⟨n, hn, hn'⟩ ↦ ⟨n.natAbs, Int.natAbs_pos.mpr hn, ?_⟩⟩
rcases (Int.natAbs_eq_iff (a := n)).mp rfl with h | h
· rwa [h, zpow_natCast] at hn'
· rwa [h, zpow_neg, inv_eq_one, zpow_natCast] at hn'
/-- See also `injective_pow_iff_not_isOfFinOrder`. -/
@[to_additive /-- See also `injective_nsmul_iff_not_isOfFinAddOrder`. -/]
theorem not_isOfFinOrder_of_injective_pow {x : G} (h : Injective fun n : ℕ => x ^ n) :
¬IsOfFinOrder x := by
simp_rw [isOfFinOrder_iff_pow_eq_one, not_exists, not_and]
intro n hn_pos hnx
rw [← pow_zero x] at hnx
rw [h hnx] at hn_pos
exact irrefl 0 hn_pos
/-- 1 is of finite order in any monoid. -/
@[to_additive (attr := simp) /-- 0 is of finite order in any additive monoid. -/]
theorem IsOfFinOrder.one : IsOfFinOrder (1 : G) :=
isOfFinOrder_iff_pow_eq_one.mpr ⟨1, Nat.one_pos, one_pow 1⟩
@[to_additive]
lemma IsOfFinOrder.pow {n : ℕ} : IsOfFinOrder a → IsOfFinOrder (a ^ n) := by
simp_rw [isOfFinOrder_iff_pow_eq_one]
rintro ⟨m, hm, ha⟩
exact ⟨m, hm, by simp [pow_right_comm _ n, ha]⟩
@[to_additive]
lemma IsOfFinOrder.of_pow {n : ℕ} (h : IsOfFinOrder (a ^ n)) (hn : n ≠ 0) : IsOfFinOrder a := by
rw [isOfFinOrder_iff_pow_eq_one] at *
rcases h with ⟨m, hm, ha⟩
exact ⟨n * m, mul_pos hn.bot_lt hm, by rwa [pow_mul]⟩
@[to_additive (attr := simp)]
lemma isOfFinOrder_pow {n : ℕ} : IsOfFinOrder (a ^ n) ↔ IsOfFinOrder a ∨ n = 0 := by
rcases Decidable.eq_or_ne n 0 with rfl | hn
· simp
· exact ⟨fun h ↦ .inl <| h.of_pow hn, fun h ↦ (h.resolve_right hn).pow⟩
@[to_additive]
lemma not_isOfFinOrder_of_isMulTorsionFree [IsMulTorsionFree G] (ha : a ≠ 1) :
¬ IsOfFinOrder a := by
rw [isOfFinOrder_iff_pow_eq_one]
rintro ⟨n, hn, han⟩
exact ha <| pow_left_injective hn.ne' <| by simpa using han
/-- Elements of finite order are of finite order in submonoids. -/
@[to_additive /-- Elements of finite order are of finite order in submonoids. -/]
theorem Submonoid.isOfFinOrder_coe {H : Submonoid G} {x : H} :
IsOfFinOrder (x : G) ↔ IsOfFinOrder x := by
rw [isOfFinOrder_iff_pow_eq_one, isOfFinOrder_iff_pow_eq_one]
norm_cast
theorem IsConj.isOfFinOrder (h : IsConj x y) : IsOfFinOrder x → IsOfFinOrder y := by
simp_rw [isOfFinOrder_iff_pow_eq_one]
rintro ⟨n, n_gt_0, eq'⟩
exact ⟨n, n_gt_0, by rw [← isConj_one_right, ← eq']; exact h.pow n⟩
/-- The image of an element of finite order has finite order. -/
@[to_additive /-- The image of an element of finite additive order has finite additive order. -/]
theorem MonoidHom.isOfFinOrder [Monoid H] (f : G →* H) {x : G} (h : IsOfFinOrder x) :
IsOfFinOrder <| f x :=
isOfFinOrder_iff_pow_eq_one.mpr <| by
obtain ⟨n, npos, hn⟩ := h.exists_pow_eq_one
exact ⟨n, npos, by rw [← f.map_pow, hn, f.map_one]⟩
/-- If a direct product has finite order then so does each component. -/
@[to_additive /-- If a direct product has finite additive order then so does each component. -/]
theorem IsOfFinOrder.apply {η : Type*} {Gs : η → Type*} [∀ i, Monoid (Gs i)] {x : ∀ i, Gs i}
(h : IsOfFinOrder x) : ∀ i, IsOfFinOrder (x i) := by
obtain ⟨n, npos, hn⟩ := h.exists_pow_eq_one
exact fun _ => isOfFinOrder_iff_pow_eq_one.mpr ⟨n, npos, (congr_fun hn.symm _).symm⟩
/-- The submonoid generated by an element is a group if that element has finite order. -/
@[to_additive /-- The additive submonoid generated by an element is
an additive group if that element has finite order. -/]
noncomputable abbrev IsOfFinOrder.groupPowers (hx : IsOfFinOrder x) :
Group (Submonoid.powers x) := by
obtain ⟨hpos, hx⟩ := hx.exists_pow_eq_one.choose_spec
exact Submonoid.groupPowers hpos hx
end IsOfFinOrder
/-- `orderOf x` is the order of the element `x`, i.e. the `n ≥ 1`, s.t. `x ^ n = 1` if it exists.
Otherwise, i.e. if `x` is of infinite order, then `orderOf x` is `0` by convention. -/
@[to_additive
/-- `addOrderOf a` is the order of the element `a`, i.e. the `n ≥ 1`, s.t. `n • a = 0` if it
exists. Otherwise, i.e. if `a` is of infinite order, then `addOrderOf a` is `0` by convention. -/]
noncomputable def orderOf (x : G) : ℕ :=
minimalPeriod (x * ·) 1
@[to_additive (attr := nontriviality)]
theorem Subsingleton.orderOf_eq [Subsingleton G] (x : G) : orderOf x = 1 := by
simp [orderOf, nontriviality]
@[simp]
theorem addOrderOf_ofMul_eq_orderOf (x : G) : addOrderOf (Additive.ofMul x) = orderOf x :=
rfl
@[simp]
lemma orderOf_ofAdd_eq_addOrderOf {α : Type*} [AddMonoid α] (a : α) :
orderOf (Multiplicative.ofAdd a) = addOrderOf a := rfl
@[to_additive]
protected lemma IsOfFinOrder.orderOf_pos (h : IsOfFinOrder x) : 0 < orderOf x :=
minimalPeriod_pos_of_mem_periodicPts h
@[to_additive (attr := simp) addOrderOf_nsmul_eq_zero]
theorem pow_orderOf_eq_one (x : G) : x ^ orderOf x = 1 := by
convert Eq.trans _ (isPeriodicPt_minimalPeriod (x * ·) 1)
rw [orderOf, mul_left_iterate_apply_one]
@[to_additive]
theorem orderOf_eq_zero (h : ¬IsOfFinOrder x) : orderOf x = 0 := by
rwa [orderOf, minimalPeriod, dif_neg]
@[to_additive (attr := simp)]
theorem orderOf_eq_zero_iff : orderOf x = 0 ↔ ¬IsOfFinOrder x :=
⟨fun h H ↦ H.orderOf_pos.ne' h, orderOf_eq_zero⟩
@[to_additive]
theorem orderOf_eq_zero_iff' : orderOf x = 0 ↔ ∀ n : ℕ, 0 < n → x ^ n ≠ 1 := by
simp_rw [orderOf_eq_zero_iff, isOfFinOrder_iff_pow_eq_one, not_exists, not_and]
@[to_additive]
lemma orderOf_ne_zero_iff : orderOf x ≠ 0 ↔ IsOfFinOrder x := orderOf_eq_zero_iff.not_left
/-- In a nontrivial monoid with zero, the order of the zero element is zero. -/
@[simp]
lemma orderOf_zero (M₀ : Type*) [MonoidWithZero M₀] [Nontrivial M₀] : orderOf (0 : M₀) = 0 := by
rw [orderOf_eq_zero_iff, isOfFinOrder_iff_pow_eq_one]
simp +contextual [ne_of_gt]
@[to_additive]
theorem orderOf_eq_iff {n} (h : 0 < n) :
orderOf x = n ↔ x ^ n = 1 ∧ ∀ m, m < n → 0 < m → x ^ m ≠ 1 := by
simp_rw [Ne, ← isPeriodicPt_mul_iff_pow_eq_one, orderOf, minimalPeriod]
split_ifs with h1
· classical
rw [find_eq_iff]
simp only [h, true_and, not_and]
· rw [iff_false_left h.ne]
rintro ⟨h', -⟩
exact h1 ⟨n, h, h'⟩
/-- A group element has finite order iff its order is positive. -/
@[to_additive (attr := simp)
/-- A group element has finite additive order iff its order is positive. -/]
theorem orderOf_pos_iff : 0 < orderOf x ↔ IsOfFinOrder x := by
rw [iff_not_comm.mp orderOf_eq_zero_iff, pos_iff_ne_zero]
@[to_additive]
theorem IsOfFinOrder.mono [Monoid β] {y : β} (hx : IsOfFinOrder x) (h : orderOf y ∣ orderOf x) :
IsOfFinOrder y := by rw [← orderOf_pos_iff] at hx ⊢; exact Nat.pos_of_dvd_of_pos h hx
@[to_additive]
theorem pow_ne_one_of_lt_orderOf (n0 : n ≠ 0) (h : n < orderOf x) : x ^ n ≠ 1 := fun j =>
not_isPeriodicPt_of_pos_of_lt_minimalPeriod n0 h ((isPeriodicPt_mul_iff_pow_eq_one x).mpr j)
@[to_additive]
theorem orderOf_le_of_pow_eq_one (hn : 0 < n) (h : x ^ n = 1) : orderOf x ≤ n :=
IsPeriodicPt.minimalPeriod_le hn (by rwa [isPeriodicPt_mul_iff_pow_eq_one])
@[to_additive (attr := simp)]
theorem orderOf_one : orderOf (1 : G) = 1 := by
rw [orderOf, ← minimalPeriod_id (x := (1 : G)), ← one_mul_eq_id]
@[to_additive (attr := simp) AddMonoid.addOrderOf_eq_one_iff]
theorem orderOf_eq_one_iff : orderOf x = 1 ↔ x = 1 := by
rw [orderOf, minimalPeriod_eq_one_iff_isFixedPt, IsFixedPt, mul_one]
@[to_additive (attr := simp) mod_addOrderOf_nsmul]
lemma pow_mod_orderOf (x : G) (n : ℕ) : x ^ (n % orderOf x) = x ^ n :=
calc
x ^ (n % orderOf x) = x ^ (n % orderOf x + orderOf x * (n / orderOf x)) := by
simp [pow_add, pow_mul, pow_orderOf_eq_one]
_ = x ^ n := by rw [Nat.mod_add_div]
@[to_additive]
theorem orderOf_dvd_of_pow_eq_one (h : x ^ n = 1) : orderOf x ∣ n :=
IsPeriodicPt.minimalPeriod_dvd ((isPeriodicPt_mul_iff_pow_eq_one _).mpr h)
@[to_additive]
theorem orderOf_dvd_iff_pow_eq_one {n : ℕ} : orderOf x ∣ n ↔ x ^ n = 1 :=
⟨fun h => by rw [← pow_mod_orderOf, Nat.mod_eq_zero_of_dvd h, _root_.pow_zero],
orderOf_dvd_of_pow_eq_one⟩
@[to_additive addOrderOf_smul_dvd]
theorem orderOf_pow_dvd (n : ℕ) : orderOf (x ^ n) ∣ orderOf x := by
rw [orderOf_dvd_iff_pow_eq_one, pow_right_comm, pow_orderOf_eq_one, one_pow]
@[to_additive]
lemma pow_injOn_Iio_orderOf : (Set.Iio <| orderOf x).InjOn (x ^ ·) := by
simpa only [mul_left_iterate_apply_one]
using iterate_injOn_Iio_minimalPeriod (f := (x * ·)) (x := 1)
@[to_additive]
protected lemma IsOfFinOrder.mem_powers_iff_mem_range_orderOf [DecidableEq G]
(hx : IsOfFinOrder x) :
y ∈ Submonoid.powers x ↔ y ∈ (Finset.range (orderOf x)).image (x ^ ·) :=
Finset.mem_range_iff_mem_finset_range_of_mod_eq' hx.orderOf_pos <| pow_mod_orderOf _
@[to_additive]
protected lemma IsOfFinOrder.powers_eq_image_range_orderOf [DecidableEq G] (hx : IsOfFinOrder x) :
(Submonoid.powers x : Set G) = (Finset.range (orderOf x)).image (x ^ ·) :=
Set.ext fun _ ↦ hx.mem_powers_iff_mem_range_orderOf
@[to_additive]
theorem pow_eq_one_iff_modEq : x ^ n = 1 ↔ n ≡ 0 [MOD orderOf x] := by
rw [modEq_zero_iff_dvd, orderOf_dvd_iff_pow_eq_one]
@[to_additive]
theorem orderOf_map_dvd {H : Type*} [Monoid H] (ψ : G →* H) (x : G) :
orderOf (ψ x) ∣ orderOf x := by
apply orderOf_dvd_of_pow_eq_one
rw [← map_pow, pow_orderOf_eq_one]
apply map_one
@[to_additive]
theorem exists_pow_eq_self_of_coprime (h : n.Coprime (orderOf x)) : ∃ m : ℕ, (x ^ n) ^ m = x := by
by_cases h0 : orderOf x = 0
· rw [h0, coprime_zero_right] at h
exact ⟨1, by rw [h, pow_one, pow_one]⟩
by_cases h1 : orderOf x = 1
· exact ⟨0, by rw [orderOf_eq_one_iff.mp h1, one_pow, one_pow]⟩
obtain ⟨m, h⟩ := exists_mul_emod_eq_one_of_coprime h (one_lt_iff_ne_zero_and_ne_one.mpr ⟨h0, h1⟩)
exact ⟨m, by rw [← pow_mul, ← pow_mod_orderOf, h, pow_one]⟩
/-- If `x^n = 1`, but `x^(n/p) ≠ 1` for all prime factors `p` of `n`,
then `x` has order `n` in `G`. -/
@[to_additive addOrderOf_eq_of_nsmul_and_div_prime_nsmul /-- If `n * x = 0`, but `n/p * x ≠ 0` for
all prime factors `p` of `n`, then `x` has order `n` in `G`. -/]
theorem orderOf_eq_of_pow_and_pow_div_prime (hn : 0 < n) (hx : x ^ n = 1)
(hd : ∀ p : ℕ, p.Prime → p ∣ n → x ^ (n / p) ≠ 1) : orderOf x = n := by
-- Let `a` be `n/(orderOf x)`, and show `a = 1`
obtain ⟨a, ha⟩ := exists_eq_mul_right_of_dvd (orderOf_dvd_of_pow_eq_one hx)
suffices a = 1 by simp [this, ha]
-- Assume `a` is not one...
by_contra h
have a_min_fac_dvd_p_sub_one : a.minFac ∣ n := by
obtain ⟨b, hb⟩ : ∃ b : ℕ, a = b * a.minFac := exists_eq_mul_left_of_dvd a.minFac_dvd
rw [hb, ← mul_assoc] at ha
exact Dvd.intro_left (orderOf x * b) ha.symm
-- Use the minimum prime factor of `a` as `p`.
refine hd a.minFac (Nat.minFac_prime h) a_min_fac_dvd_p_sub_one ?_
rw [← orderOf_dvd_iff_pow_eq_one, Nat.dvd_div_iff_mul_dvd a_min_fac_dvd_p_sub_one, ha, mul_comm,
Nat.mul_dvd_mul_iff_left (IsOfFinOrder.orderOf_pos _)]
· exact Nat.minFac_dvd a
· rw [isOfFinOrder_iff_pow_eq_one]
exact Exists.intro n (id ⟨hn, hx⟩)
@[to_additive]
theorem orderOf_eq_orderOf_iff {H : Type*} [Monoid H] {y : H} :
orderOf x = orderOf y ↔ ∀ n : ℕ, x ^ n = 1 ↔ y ^ n = 1 := by
simp_rw [← isPeriodicPt_mul_iff_pow_eq_one, ← minimalPeriod_eq_minimalPeriod_iff, orderOf]
/-- An injective homomorphism of monoids preserves orders of elements. -/
@[to_additive /-- An injective homomorphism of additive monoids preserves orders of elements. -/]
theorem orderOf_injective {H : Type*} [Monoid H] (f : G →* H) (hf : Function.Injective f) (x : G) :
orderOf (f x) = orderOf x := by
simp_rw [orderOf_eq_orderOf_iff, ← f.map_pow, ← f.map_one, hf.eq_iff, forall_const]
/-- A multiplicative equivalence preserves orders of elements. -/
@[to_additive (attr := simp) /-- An additive equivalence preserves orders of elements. -/]
lemma MulEquiv.orderOf_eq {H : Type*} [Monoid H] (e : G ≃* H) (x : G) :
orderOf (e x) = orderOf x :=
orderOf_injective e.toMonoidHom e.injective x
@[to_additive]
theorem Function.Injective.isOfFinOrder_iff [Monoid H] {f : G →* H} (hf : Injective f) :
IsOfFinOrder (f x) ↔ IsOfFinOrder x := by
rw [← orderOf_pos_iff, orderOf_injective f hf x, ← orderOf_pos_iff]
@[to_additive (attr := norm_cast, simp)]
theorem orderOf_submonoid {H : Submonoid G} (y : H) : orderOf (y : G) = orderOf y :=
orderOf_injective H.subtype Subtype.coe_injective y
@[to_additive (attr := norm_cast)]
theorem orderOf_units {y : Gˣ} : orderOf (y : G) = orderOf y :=
orderOf_injective (Units.coeHom G) Units.val_injective y
@[to_additive]
lemma IsUnit.orderOf_eq_one [Subsingleton Gˣ] {x : G} (h : IsUnit x) :
orderOf x = 1 := by
simp [isUnit_iff_eq_one.mp h]
@[to_additive (attr := norm_cast)]
theorem Units.isOfFinOrder_val {u : Gˣ} : IsOfFinOrder (u : G) ↔ IsOfFinOrder u :=
Units.coeHom_injective.isOfFinOrder_iff
/-- If the order of `x` is finite, then `x` is a unit with inverse `x ^ (orderOf x - 1)`. -/
@[to_additive (attr := simps) /-- If the additive order of `x` is finite, then `x` is an additive
unit with inverse `(addOrderOf x - 1) • x`. -/]
noncomputable def IsOfFinOrder.unit {M} [Monoid M] {x : M} (hx : IsOfFinOrder x) : Mˣ :=
⟨x, x ^ (orderOf x - 1),
by rw [← _root_.pow_succ', tsub_add_cancel_of_le (by exact hx.orderOf_pos), pow_orderOf_eq_one],
by rw [← _root_.pow_succ, tsub_add_cancel_of_le (by exact hx.orderOf_pos), pow_orderOf_eq_one]⟩
@[to_additive]
lemma IsOfFinOrder.isUnit {M} [Monoid M] {x : M} (hx : IsOfFinOrder x) : IsUnit x := ⟨hx.unit, rfl⟩
variable (x)
@[to_additive]
theorem orderOf_pow' (h : n ≠ 0) : orderOf (x ^ n) = orderOf x / gcd (orderOf x) n := by
unfold orderOf
rw [← minimalPeriod_iterate_eq_div_gcd h, mul_left_iterate]
@[to_additive]
lemma orderOf_pow_of_dvd {x : G} {n : ℕ} (hn : n ≠ 0) (dvd : n ∣ orderOf x) :
orderOf (x ^ n) = orderOf x / n := by rw [orderOf_pow' _ hn, Nat.gcd_eq_right dvd]
@[to_additive]
lemma orderOf_pow_orderOf_div {x : G} {n : ℕ} (hx : orderOf x ≠ 0) (hn : n ∣ orderOf x) :
orderOf (x ^ (orderOf x / n)) = n := by
rw [orderOf_pow_of_dvd _ (Nat.div_dvd_of_dvd hn), Nat.div_div_self hn hx]
rw [← Nat.div_mul_cancel hn] at hx; exact left_ne_zero_of_mul hx
variable (n)
@[to_additive]
protected lemma IsOfFinOrder.orderOf_pow (h : IsOfFinOrder x) :
orderOf (x ^ n) = orderOf x / gcd (orderOf x) n := by
unfold orderOf
rw [← minimalPeriod_iterate_eq_div_gcd' h, mul_left_iterate]
@[to_additive]
lemma Nat.Coprime.orderOf_pow (h : (orderOf y).Coprime m) : orderOf (y ^ m) = orderOf y := by
by_cases hg : IsOfFinOrder y
· rw [hg.orderOf_pow y m, h.gcd_eq_one, Nat.div_one]
· rw [m.coprime_zero_left.1 (orderOf_eq_zero hg ▸ h), pow_one]
@[to_additive]
lemma IsOfFinOrder.natCard_powers_le_orderOf (ha : IsOfFinOrder a) :
Nat.card (powers a : Set G) ≤ orderOf a := by
classical
simpa [ha.powers_eq_image_range_orderOf, Finset.card_range, Nat.Iio_eq_range]
using Finset.card_image_le (s := Finset.range (orderOf a))
@[to_additive]
lemma IsOfFinOrder.finite_powers (ha : IsOfFinOrder a) : (powers a : Set G).Finite := by
classical rw [ha.powers_eq_image_range_orderOf]; exact Finset.finite_toSet _
namespace Commute
variable {x}
@[to_additive]
theorem orderOf_mul_dvd_lcm (h : Commute x y) :
orderOf (x * y) ∣ Nat.lcm (orderOf x) (orderOf y) := by
rw [orderOf, ← comp_mul_left]
exact Function.Commute.minimalPeriod_of_comp_dvd_lcm h.function_commute_mul_left
@[to_additive]
theorem orderOf_dvd_lcm_mul (h : Commute x y) :
orderOf y ∣ Nat.lcm (orderOf x) (orderOf (x * y)) := by
by_cases h0 : orderOf x = 0
· rw [h0, lcm_zero_left]
apply dvd_zero
conv_lhs =>
rw [← one_mul y, ← pow_orderOf_eq_one x, ← succ_pred_eq_of_pos (Nat.pos_of_ne_zero h0),
_root_.pow_succ, mul_assoc]
exact
(((Commute.refl x).mul_right h).pow_left _).orderOf_mul_dvd_lcm.trans
(lcm_dvd_iff.2 ⟨(orderOf_pow_dvd _).trans (dvd_lcm_left _ _), dvd_lcm_right _ _⟩)
@[to_additive addOrderOf_add_dvd_mul_addOrderOf]
theorem orderOf_mul_dvd_mul_orderOf (h : Commute x y) :
orderOf (x * y) ∣ orderOf x * orderOf y :=
dvd_trans h.orderOf_mul_dvd_lcm (lcm_dvd_mul _ _)
@[to_additive addOrderOf_add_eq_mul_addOrderOf_of_coprime]
theorem orderOf_mul_eq_mul_orderOf_of_coprime (h : Commute x y)
(hco : (orderOf x).Coprime (orderOf y)) : orderOf (x * y) = orderOf x * orderOf y := by
rw [orderOf, ← comp_mul_left]
exact h.function_commute_mul_left.minimalPeriod_of_comp_eq_mul_of_coprime hco
/-- Commuting elements of finite order are closed under multiplication. -/
@[to_additive /-- Commuting elements of finite additive order are closed under addition. -/]
theorem isOfFinOrder_mul (h : Commute x y) (hx : IsOfFinOrder x) (hy : IsOfFinOrder y) :
IsOfFinOrder (x * y) :=
orderOf_pos_iff.mp <|
pos_of_dvd_of_pos h.orderOf_mul_dvd_mul_orderOf <| mul_pos hx.orderOf_pos hy.orderOf_pos
/-- If each prime factor of `orderOf x` has higher multiplicity in `orderOf y`, and `x` commutes
with `y`, then `x * y` has the same order as `y`. -/
@[to_additive addOrderOf_add_eq_right_of_forall_prime_mul_dvd
/-- If each prime factor of
`addOrderOf x` has higher multiplicity in `addOrderOf y`, and `x` commutes with `y`,
then `x + y` has the same order as `y`. -/]
theorem orderOf_mul_eq_right_of_forall_prime_mul_dvd (h : Commute x y) (hy : IsOfFinOrder y)
(hdvd : ∀ p : ℕ, p.Prime → p ∣ orderOf x → p * orderOf x ∣ orderOf y) :
orderOf (x * y) = orderOf y := by
have hoy := hy.orderOf_pos
have hxy := dvd_of_forall_prime_mul_dvd hdvd
apply orderOf_eq_of_pow_and_pow_div_prime hoy <;> simp only [Ne, ← orderOf_dvd_iff_pow_eq_one]
· exact h.orderOf_mul_dvd_lcm.trans (lcm_dvd hxy dvd_rfl)
refine fun p hp hpy hd => hp.ne_one ?_
rw [← Nat.dvd_one, ← mul_dvd_mul_iff_right hoy.ne', one_mul, ← dvd_div_iff_mul_dvd hpy]
refine (orderOf_dvd_lcm_mul h).trans (lcm_dvd ((dvd_div_iff_mul_dvd hpy).2 ?_) hd)
by_cases h : p ∣ orderOf x
exacts [hdvd p hp h, (hp.coprime_iff_not_dvd.2 h).mul_dvd_of_dvd_of_dvd hpy hxy]
end Commute
section PPrime
variable {x n} {p : ℕ} [hp : Fact p.Prime]
@[to_additive]
theorem orderOf_eq_prime_iff : orderOf x = p ↔ x ^ p = 1 ∧ x ≠ 1 := by
rw [orderOf, minimalPeriod_eq_prime_iff, isPeriodicPt_mul_iff_pow_eq_one, IsFixedPt, mul_one]
/-- The backward direction of `orderOf_eq_prime_iff`. -/
@[to_additive /-- The backward direction of `addOrderOf_eq_prime_iff`. -/]
theorem orderOf_eq_prime (hg : x ^ p = 1) (hg1 : x ≠ 1) : orderOf x = p :=
orderOf_eq_prime_iff.mpr ⟨hg, hg1⟩
@[to_additive addOrderOf_eq_prime_pow]
theorem orderOf_eq_prime_pow (hnot : ¬x ^ p ^ n = 1) (hfin : x ^ p ^ (n + 1) = 1) :
orderOf x = p ^ (n + 1) := by
apply minimalPeriod_eq_prime_pow <;> rwa [isPeriodicPt_mul_iff_pow_eq_one]
@[to_additive exists_addOrderOf_eq_prime_pow_iff]
theorem exists_orderOf_eq_prime_pow_iff :
(∃ k : ℕ, orderOf x = p ^ k) ↔ ∃ m : ℕ, x ^ (p : ℕ) ^ m = 1 :=
⟨fun ⟨k, hk⟩ => ⟨k, by rw [← hk, pow_orderOf_eq_one]⟩, fun ⟨_, hm⟩ => by
obtain ⟨k, _, hk⟩ := (Nat.dvd_prime_pow hp.elim).mp (orderOf_dvd_of_pow_eq_one hm)
exact ⟨k, hk⟩⟩
end PPrime
/-- The equivalence between `Fin (orderOf x)` and `Submonoid.powers x`, sending `i` to `x ^ i` -/
@[to_additive /-- The equivalence between `Fin (addOrderOf a)` and
`AddSubmonoid.multiples a`, sending `i` to `i • a` -/]
noncomputable def finEquivPowers {x : G} (hx : IsOfFinOrder x) : Fin (orderOf x) ≃ powers x :=
Equiv.ofBijective (fun n ↦ ⟨x ^ (n : ℕ), ⟨n, rfl⟩⟩) ⟨fun ⟨_, h₁⟩ ⟨_, h₂⟩ ij ↦
Fin.ext (pow_injOn_Iio_orderOf h₁ h₂ (Subtype.mk_eq_mk.1 ij)), fun ⟨_, i, rfl⟩ ↦
⟨⟨i % orderOf x, mod_lt _ hx.orderOf_pos⟩, Subtype.eq <| pow_mod_orderOf _ _⟩⟩
@[to_additive (attr := simp)]
lemma finEquivPowers_apply {x : G} (hx : IsOfFinOrder x) {n : Fin (orderOf x)} :
finEquivPowers hx n = ⟨x ^ (n : ℕ), n, rfl⟩ := rfl
@[to_additive (attr := simp)]
lemma finEquivPowers_symm_apply {x : G} (hx : IsOfFinOrder x) (n : ℕ) :
(finEquivPowers hx).symm ⟨x ^ n, _, rfl⟩ = ⟨n % orderOf x, Nat.mod_lt _ hx.orderOf_pos⟩ := by
rw [Equiv.symm_apply_eq, finEquivPowers_apply, Subtype.mk_eq_mk, ← pow_mod_orderOf, Fin.val_mk]
variable {x n} (hx : IsOfFinOrder x)
include hx
@[to_additive]
theorem IsOfFinOrder.pow_eq_pow_iff_modEq : x ^ n = x ^ m ↔ n ≡ m [MOD orderOf x] := by
wlog hmn : m ≤ n generalizing m n
· rw [eq_comm, ModEq.comm, this (le_of_not_ge hmn)]
obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_le hmn
rw [pow_add, (hx.isUnit.pow _).mul_eq_left, pow_eq_one_iff_modEq]
exact ⟨fun h ↦ Nat.ModEq.add_left _ h, fun h ↦ Nat.ModEq.add_left_cancel' _ h⟩
@[to_additive]
lemma IsOfFinOrder.pow_inj_mod {n m : ℕ} : x ^ n = x ^ m ↔ n % orderOf x = m % orderOf x :=
hx.pow_eq_pow_iff_modEq
end Monoid
section CancelMonoid
variable [LeftCancelMonoid G] {x y : G} {a : G} {m n : ℕ}
@[to_additive]
theorem pow_eq_pow_iff_modEq : x ^ n = x ^ m ↔ n ≡ m [MOD orderOf x] := by
wlog hmn : m ≤ n generalizing m n
· rw [eq_comm, ModEq.comm, this (le_of_not_ge hmn)]
obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_le hmn
rw [← mul_one (x ^ m), pow_add, mul_left_cancel_iff, pow_eq_one_iff_modEq]
exact ⟨fun h => Nat.ModEq.add_left _ h, fun h => Nat.ModEq.add_left_cancel' _ h⟩
@[to_additive (attr := simp)]
lemma injective_pow_iff_not_isOfFinOrder : Injective (fun n : ℕ ↦ x ^ n) ↔ ¬IsOfFinOrder x := by
refine ⟨fun h => not_isOfFinOrder_of_injective_pow h, fun h n m hnm => ?_⟩
rwa [pow_eq_pow_iff_modEq, orderOf_eq_zero_iff.mpr h, modEq_zero_iff] at hnm
@[to_additive]
lemma pow_inj_mod {n m : ℕ} : x ^ n = x ^ m ↔ n % orderOf x = m % orderOf x := pow_eq_pow_iff_modEq
@[to_additive]
theorem pow_inj_iff_of_orderOf_eq_zero (h : orderOf x = 0) {n m : ℕ} : x ^ n = x ^ m ↔ n = m := by
rw [pow_eq_pow_iff_modEq, h, modEq_zero_iff]
@[to_additive]
theorem infinite_not_isOfFinOrder {x : G} (h : ¬IsOfFinOrder x) :
{ y : G | ¬IsOfFinOrder y }.Infinite := by
let s := { n | 0 < n }.image fun n : ℕ => x ^ n
have hs : s ⊆ { y : G | ¬IsOfFinOrder y } := by
rintro - ⟨n, hn : 0 < n, rfl⟩ (contra : IsOfFinOrder (x ^ n))
apply h
rw [isOfFinOrder_iff_pow_eq_one] at contra ⊢
obtain ⟨m, hm, hm'⟩ := contra
exact ⟨n * m, mul_pos hn hm, by rwa [pow_mul]⟩
suffices s.Infinite by exact this.mono hs
contrapose! h
have : ¬Injective fun n : ℕ => x ^ n := by
have := Set.not_injOn_infinite_finite_image (Set.Ioi_infinite 0) (Set.not_infinite.mp h)
contrapose! this
exact Set.injOn_of_injective this
rwa [injective_pow_iff_not_isOfFinOrder, Classical.not_not] at this
@[to_additive (attr := simp)]
lemma finite_powers : (powers a : Set G).Finite ↔ IsOfFinOrder a := by
refine ⟨fun h ↦ ?_, IsOfFinOrder.finite_powers⟩
obtain ⟨m, n, hmn, ha⟩ := h.exists_lt_map_eq_of_forall_mem (f := fun n : ℕ ↦ a ^ n)
(fun n ↦ by simp [mem_powers_iff])
refine isOfFinOrder_iff_pow_eq_one.2 ⟨n - m, tsub_pos_iff_lt.2 hmn, ?_⟩
rw [← mul_left_cancel_iff (a := a ^ m), ← pow_add, add_tsub_cancel_of_le hmn.le, ha, mul_one]
@[to_additive (attr := simp)]
lemma infinite_powers : (powers a : Set G).Infinite ↔ ¬ IsOfFinOrder a := finite_powers.not
/-- See also `orderOf_eq_card_powers`. -/
@[to_additive /-- See also `addOrder_eq_card_multiples`. -/]
lemma Nat.card_submonoidPowers : Nat.card (powers a) = orderOf a := by
classical
by_cases ha : IsOfFinOrder a
· exact (Nat.card_congr (finEquivPowers ha).symm).trans <| by simp
· have := (infinite_powers.2 ha).to_subtype
rw [orderOf_eq_zero ha, Nat.card_eq_zero_of_infinite]
end CancelMonoid
section Group
variable [Group G] {x y : G} {i : ℤ}
/-- Inverses of elements of finite order have finite order. -/
@[to_additive (attr := simp) /-- Inverses of elements of finite additive order
have finite additive order. -/]
theorem isOfFinOrder_inv_iff {x : G} : IsOfFinOrder x⁻¹ ↔ IsOfFinOrder x := by
simp [isOfFinOrder_iff_pow_eq_one]
@[to_additive] alias ⟨IsOfFinOrder.of_inv, IsOfFinOrder.inv⟩ := isOfFinOrder_inv_iff
@[to_additive]
theorem orderOf_dvd_iff_zpow_eq_one : (orderOf x : ℤ) ∣ i ↔ x ^ i = 1 := by
rcases Int.eq_nat_or_neg i with ⟨i, rfl | rfl⟩
· rw [Int.natCast_dvd_natCast, orderOf_dvd_iff_pow_eq_one, zpow_natCast]
· rw [dvd_neg, Int.natCast_dvd_natCast, zpow_neg, inv_eq_one, zpow_natCast,
orderOf_dvd_iff_pow_eq_one]
@[to_additive (attr := simp)]
theorem orderOf_inv (x : G) : orderOf x⁻¹ = orderOf x := by simp [orderOf_eq_orderOf_iff]
@[to_additive]
theorem orderOf_dvd_sub_iff_zpow_eq_zpow {a b : ℤ} : (orderOf x : ℤ) ∣ a - b ↔ x ^ a = x ^ b := by
rw [orderOf_dvd_iff_zpow_eq_one, zpow_sub, mul_inv_eq_one]
namespace Subgroup
variable {H : Subgroup G}
@[to_additive (attr := norm_cast)]
lemma orderOf_coe (a : H) : orderOf (a : G) = orderOf a :=
orderOf_injective H.subtype Subtype.coe_injective _
@[to_additive (attr := simp)]
lemma orderOf_mk (a : G) (ha) : orderOf (⟨a, ha⟩ : H) = orderOf a := (orderOf_coe _).symm
end Subgroup
@[to_additive mod_addOrderOf_zsmul]
lemma zpow_mod_orderOf (x : G) (z : ℤ) : x ^ (z % (orderOf x : ℤ)) = x ^ z :=
calc
x ^ (z % (orderOf x : ℤ)) = x ^ (z % orderOf x + orderOf x * (z / orderOf x) : ℤ) := by
simp [zpow_add, zpow_mul, pow_orderOf_eq_one]
_ = x ^ z := by rw [Int.emod_add_mul_ediv]
@[to_additive (attr := simp) zsmul_smul_addOrderOf]
theorem zpow_pow_orderOf : (x ^ i) ^ orderOf x = 1 := by
by_cases h : IsOfFinOrder x
· rw [← zpow_natCast, ← zpow_mul, mul_comm, zpow_mul, zpow_natCast, pow_orderOf_eq_one, one_zpow]
· rw [orderOf_eq_zero h, _root_.pow_zero]
@[to_additive]
theorem IsOfFinOrder.zpow (h : IsOfFinOrder x) {i : ℤ} : IsOfFinOrder (x ^ i) :=
isOfFinOrder_iff_pow_eq_one.mpr ⟨orderOf x, h.orderOf_pos, zpow_pow_orderOf⟩
@[to_additive]
theorem IsOfFinOrder.of_mem_zpowers (h : IsOfFinOrder x) (h' : y ∈ Subgroup.zpowers x) :
IsOfFinOrder y := by
obtain ⟨k, rfl⟩ := Subgroup.mem_zpowers_iff.mp h'
exact h.zpow
@[to_additive]
theorem orderOf_dvd_of_mem_zpowers (h : y ∈ Subgroup.zpowers x) : orderOf y ∣ orderOf x := by
obtain ⟨k, rfl⟩ := Subgroup.mem_zpowers_iff.mp h
rw [orderOf_dvd_iff_pow_eq_one]
exact zpow_pow_orderOf
theorem smul_eq_self_of_mem_zpowers {α : Type*} [MulAction G α] (hx : x ∈ Subgroup.zpowers y)
{a : α} (hs : y • a = a) : x • a = a := by
obtain ⟨k, rfl⟩ := Subgroup.mem_zpowers_iff.mp hx
rw [← MulAction.toPerm_apply, ← MulAction.toPermHom_apply, MonoidHom.map_zpow _ y k,
MulAction.toPermHom_apply]
exact Function.IsFixedPt.perm_zpow (by exact hs) k -- Porting note: help elab'n with `by exact`
theorem vadd_eq_self_of_mem_zmultiples {G : Type*} [AddGroup G] {x y : G} {α : Type*}
[AddAction G α] (hx : x ∈ AddSubgroup.zmultiples y) {a : α} (hs : y +ᵥ a = a) : x +ᵥ a = a :=
@smul_eq_self_of_mem_zpowers (Multiplicative G) _ _ _ α _ hx a hs
attribute [to_additive existing] smul_eq_self_of_mem_zpowers
@[to_additive]
lemma IsOfFinOrder.mem_powers_iff_mem_zpowers (hx : IsOfFinOrder x) :
y ∈ powers x ↔ y ∈ zpowers x :=
⟨fun ⟨n, hn⟩ ↦ ⟨n, by simp_all⟩, fun ⟨i, hi⟩ ↦ ⟨(i % orderOf x).natAbs, by
dsimp only
rwa [← zpow_natCast, Int.natAbs_of_nonneg <| Int.emod_nonneg _ <|
Int.natCast_ne_zero_iff_pos.2 <| hx.orderOf_pos, zpow_mod_orderOf]⟩⟩
@[to_additive]
lemma IsOfFinOrder.powers_eq_zpowers (hx : IsOfFinOrder x) : (powers x : Set G) = zpowers x :=
Set.ext fun _ ↦ hx.mem_powers_iff_mem_zpowers
@[to_additive]
lemma IsOfFinOrder.mem_zpowers_iff_mem_range_orderOf [DecidableEq G] (hx : IsOfFinOrder x) :
y ∈ zpowers x ↔ y ∈ (Finset.range (orderOf x)).image (x ^ ·) :=
hx.mem_powers_iff_mem_zpowers.symm.trans hx.mem_powers_iff_mem_range_orderOf
/-- See `Subgroup.closure_toSubmonoid_of_finite` for a version for finite groups. -/
@[to_additive
/-- See `AddSubgroup.closure_toAddSubmonoid_of_finite` for a version for finite additive groups. -/]
lemma Subgroup.closure_toSubmonoid_of_isOfFinOrder {s : Set G} (hs : ∀ x ∈ s, IsOfFinOrder x) :
(closure s).toSubmonoid = Submonoid.closure s := by
refine le_antisymm ?_ (le_closure_toSubmonoid s)
rw [closure_toSubmonoid]
refine Submonoid.closure_le.mpr <| Set.union_subset Submonoid.subset_closure
fun x (hx : x⁻¹ ∈ s) ↦ ?_
apply Submonoid.powers_le.mpr (Submonoid.subset_closure hx)
simp [(hs _ hx).mem_powers_iff_mem_zpowers]
/-- The equivalence between `Fin (orderOf x)` and `Subgroup.zpowers x`, sending `i` to `x ^ i`. -/
@[to_additive /-- The equivalence between `Fin (addOrderOf a)` and
`Subgroup.zmultiples a`, sending `i` to `i • a`. -/]
noncomputable def finEquivZPowers (hx : IsOfFinOrder x) :
Fin (orderOf x) ≃ zpowers x :=
(finEquivPowers hx).trans <| Equiv.setCongr hx.powers_eq_zpowers
@[to_additive]
lemma finEquivZPowers_apply (hx : IsOfFinOrder x) {n : Fin (orderOf x)} :
finEquivZPowers hx n = ⟨x ^ (n : ℕ), n, zpow_natCast x n⟩ := rfl
@[to_additive]
lemma finEquivZPowers_symm_apply (hx : IsOfFinOrder x) (n : ℕ) :
(finEquivZPowers hx).symm ⟨x ^ n, ⟨n, by simp⟩⟩ =
⟨n % orderOf x, Nat.mod_lt _ hx.orderOf_pos⟩ := by
rw [finEquivZPowers, Equiv.symm_trans_apply]; exact finEquivPowers_symm_apply _ n
@[to_additive]
lemma pow_finEquivZPowers_symm_apply (hx : IsOfFinOrder x) (a : Subgroup.zpowers x) :
x ^ ((finEquivZPowers hx).symm a : ℕ) = a := by
simpa only [finEquivZPowers_apply] using
congr_arg Subtype.val ((finEquivZPowers hx).apply_symm_apply a)
end Group
section CommMonoid
variable [CommMonoid G] {x y : G}
/-- Elements of finite order are closed under multiplication. -/
@[to_additive /-- Elements of finite additive order are closed under addition. -/]
theorem IsOfFinOrder.mul (hx : IsOfFinOrder x) (hy : IsOfFinOrder y) : IsOfFinOrder (x * y) :=
(Commute.all x y).isOfFinOrder_mul hx hy
end CommMonoid
section CommGroup
variable [CommGroup G]
@[to_additive]
lemma isMulTorsionFree_iff_not_isOfFinOrder :
IsMulTorsionFree G ↔ ∀ ⦃a : G⦄, a ≠ 1 → ¬ IsOfFinOrder a where
mp _ _ := not_isOfFinOrder_of_isMulTorsionFree
mpr hG := by
refine ⟨fun n hn a b hab ↦ ?_⟩
rw [← div_eq_one] at hab ⊢
simp only [← div_pow, isOfFinOrder_iff_pow_eq_one] at hab hG
exact of_not_not fun hab' ↦ hG hab' ⟨n, hn.bot_lt, hab⟩
@[to_additive]
alias ⟨_, IsMulTorsionFree.of_not_isOfFinOrder⟩ := isMulTorsionFree_iff_not_isOfFinOrder
@[to_additive]
lemma not_isMulTorsionFree_iff_isOfFinOrder :
¬ IsMulTorsionFree G ↔ ∃ a ≠ (1 : G), IsOfFinOrder a := by
simp [isMulTorsionFree_iff_not_isOfFinOrder]
@[to_additive (attr := simp)]
lemma zpowers_mabs [LinearOrder G] [IsOrderedMonoid G] (g : G) : zpowers |g|ₘ = zpowers g := by
rcases mabs_cases g with h | h <;> simp only [h, zpowers_inv]
end CommGroup
section FiniteMonoid
variable [Monoid G] {x : G} {n : ℕ}
@[to_additive]
theorem sum_card_orderOf_eq_card_pow_eq_one [Fintype G] [DecidableEq G] (hn : n ≠ 0) :
∑ m ∈ divisors n, #{x : G | orderOf x = m} = #{x : G | x ^ n = 1} := by
refine (Finset.card_biUnion ?_).symm.trans ?_
· simp +contextual [Set.PairwiseDisjoint, Set.Pairwise, disjoint_iff, Finset.ext_iff]
· congr; ext; simp [hn, orderOf_dvd_iff_pow_eq_one]
@[to_additive]
theorem orderOf_le_card_univ [Fintype G] : orderOf x ≤ Fintype.card G :=
Finset.le_card_of_inj_on_range (x ^ ·) (fun _ _ ↦ Finset.mem_univ _) pow_injOn_Iio_orderOf
@[to_additive]
theorem orderOf_le_card [Finite G] : orderOf x ≤ Nat.card G := by
obtain ⟨⟩ := nonempty_fintype G
simpa using orderOf_le_card_univ
end FiniteMonoid
section FiniteCancelMonoid
variable [LeftCancelMonoid G]
-- TODO: Of course everything also works for `RightCancelMonoid`.
section Finite
variable [Finite G] {x y : G} {n : ℕ}
-- TODO: Use this to show that a finite left cancellative monoid is a group.
@[to_additive]
lemma isOfFinOrder_of_finite (x : G) : IsOfFinOrder x := by
by_contra h; exact infinite_not_isOfFinOrder h <| Set.toFinite _
/-- This is the same as `IsOfFinOrder.orderOf_pos` but with one fewer explicit assumption since this
is automatic in case of a finite cancellative monoid. -/
@[to_additive /-- This is the same as `IsOfFinAddOrder.addOrderOf_pos` but with one fewer explicit
assumption since this is automatic in case of a finite cancellative additive monoid. -/]
lemma orderOf_pos (x : G) : 0 < orderOf x := (isOfFinOrder_of_finite x).orderOf_pos
/-- This is the same as `orderOf_pow'` and `orderOf_pow''` but with one assumption less which is
automatic in the case of a finite cancellative monoid. -/
@[to_additive /-- This is the same as `addOrderOf_nsmul'` and
`addOrderOf_nsmul` but with one assumption less which is automatic in the case of a
finite cancellative additive monoid. -/]
theorem orderOf_pow (x : G) : orderOf (x ^ n) = orderOf x / gcd (orderOf x) n :=
(isOfFinOrder_of_finite _).orderOf_pow ..
@[to_additive]
theorem mem_powers_iff_mem_range_orderOf [DecidableEq G] :
y ∈ powers x ↔ y ∈ (Finset.range (orderOf x)).image (x ^ ·) :=
Finset.mem_range_iff_mem_finset_range_of_mod_eq' (orderOf_pos x) <| pow_mod_orderOf _
/-- The equivalence between `Submonoid.powers` of two elements `x, y` of the same order, mapping
`x ^ i` to `y ^ i`. -/
@[to_additive
/-- The equivalence between `Submonoid.multiples` of two elements `a, b` of the same additive
order, mapping `i • a` to `i • b`. -/]
noncomputable def powersEquivPowers (h : orderOf x = orderOf y) : powers x ≃ powers y :=
(finEquivPowers <| isOfFinOrder_of_finite _).symm.trans <|
(finCongr h).trans <| finEquivPowers <| isOfFinOrder_of_finite _
@[to_additive (attr := simp)]
theorem powersEquivPowers_apply (h : orderOf x = orderOf y) (n : ℕ) :
powersEquivPowers h ⟨x ^ n, n, rfl⟩ = ⟨y ^ n, n, rfl⟩ := by
rw [powersEquivPowers, Equiv.trans_apply, Equiv.trans_apply, finEquivPowers_symm_apply, ←
Equiv.eq_symm_apply, finEquivPowers_symm_apply]
simp [h]
end Finite
variable [Fintype G] {x : G}
@[to_additive]
lemma orderOf_eq_card_powers : orderOf x = Fintype.card (powers x : Submonoid G) :=
(Fintype.card_fin (orderOf x)).symm.trans <|
Fintype.card_eq.2 ⟨finEquivPowers <| isOfFinOrder_of_finite _⟩
end FiniteCancelMonoid
lemma isOfFinOrder_iff_isUnit [Monoid G] [Finite Gˣ] {x : G} : IsOfFinOrder x ↔ IsUnit x := by
use IsOfFinOrder.isUnit
rintro ⟨u, rfl⟩
rw [Units.isOfFinOrder_val]
apply isOfFinOrder_of_finite
alias ⟨_, IsUnit.isOfFinOrder⟩ := isOfFinOrder_iff_isUnit
lemma orderOf_eq_zero_iff_eq_zero {G₀ : Type*} [GroupWithZero G₀] [Finite G₀] {a : G₀} :
orderOf a = 0 ↔ a = 0 := by
-- Prove an instance inline to avoid extra imports.
-- TODO: move this instance elsewhere?
have : Finite G₀ˣ := .of_injective _ Units.val_injective
simp [isOfFinOrder_iff_isUnit]
section FiniteGroup
variable [Group G] {x y : G}
@[to_additive]
theorem zpow_eq_one_iff_modEq {n : ℤ} : x ^ n = 1 ↔ n ≡ 0 [ZMOD orderOf x] := by
rw [Int.modEq_zero_iff_dvd, orderOf_dvd_iff_zpow_eq_one]
@[to_additive]
theorem zpow_eq_zpow_iff_modEq {m n : ℤ} : x ^ m = x ^ n ↔ m ≡ n [ZMOD orderOf x] := by
rw [← mul_inv_eq_one, ← zpow_sub, zpow_eq_one_iff_modEq, Int.modEq_iff_dvd, Int.modEq_iff_dvd,
zero_sub, neg_sub]
@[to_additive (attr := simp)]
theorem injective_zpow_iff_not_isOfFinOrder : (Injective fun n : ℤ => x ^ n) ↔ ¬IsOfFinOrder x := by
refine ⟨?_, fun h n m hnm => ?_⟩
· simp_rw [isOfFinOrder_iff_pow_eq_one]
rintro h ⟨n, hn, hx⟩
exact Nat.cast_ne_zero.2 hn.ne' (h <| by simpa using hx)
rwa [zpow_eq_zpow_iff_modEq, orderOf_eq_zero_iff.2 h, Nat.cast_zero, Int.modEq_zero_iff] at hnm
@[to_additive]
lemma Subgroup.zpowers_eq_zpowers_iff {x y : G} (hx : ¬IsOfFinOrder x) :
zpowers x = zpowers y ↔ x = y ∨ x⁻¹ = y := by
refine ⟨fun h ↦ ?_, by rintro (rfl | rfl) <;> simp⟩
have hx_mem : x ∈ zpowers y := by simp [← h]
have hy_mem : y ∈ zpowers x := by simp [h]
obtain ⟨k, rfl⟩ := mem_zpowers_iff.mp hy_mem
obtain ⟨l, hl⟩ := mem_zpowers_iff.mp hx_mem
rw [← zpow_mul] at hl
nth_rewrite 2 [← zpow_one x] at hl
have h1 := (injective_zpow_iff_not_isOfFinOrder.mpr hx) hl
rcases (Int.mul_eq_one_iff_eq_one_or_neg_one).mp h1 with (h | h) <;> simp [h.1]
section Finite
variable [Finite G]
@[to_additive]
theorem exists_zpow_eq_one (x : G) : ∃ (i : ℤ) (_ : i ≠ 0), x ^ (i : ℤ) = 1 := by
obtain ⟨w, hw1, hw2⟩ := isOfFinOrder_of_finite x
refine ⟨w, Int.natCast_ne_zero.mpr (_root_.ne_of_gt hw1), ?_⟩
rw [zpow_natCast]
exact (isPeriodicPt_mul_iff_pow_eq_one _).mp hw2
@[to_additive]
lemma mem_powers_iff_mem_zpowers : y ∈ powers x ↔ y ∈ zpowers x :=
(isOfFinOrder_of_finite _).mem_powers_iff_mem_zpowers
@[to_additive]
lemma powers_eq_zpowers (x : G) : (powers x : Set G) = zpowers x :=
(isOfFinOrder_of_finite _).powers_eq_zpowers
@[to_additive]
lemma mem_zpowers_iff_mem_range_orderOf [DecidableEq G] :
y ∈ zpowers x ↔ y ∈ (Finset.range (orderOf x)).image (x ^ ·) :=
(isOfFinOrder_of_finite _).mem_zpowers_iff_mem_range_orderOf
/-- The equivalence between `Subgroup.zpowers` of two elements `x, y` of the same order, mapping
`x ^ i` to `y ^ i`. -/
@[to_additive
/-- The equivalence between `Subgroup.zmultiples` of two elements `a, b` of the same additive
order, mapping `i • a` to `i • b`. -/]
noncomputable def zpowersEquivZPowers (h : orderOf x = orderOf y) :
Subgroup.zpowers x ≃ Subgroup.zpowers y :=
(finEquivZPowers <| isOfFinOrder_of_finite _).symm.trans <| (finCongr h).trans <|
finEquivZPowers <| isOfFinOrder_of_finite _
@[to_additive (attr := simp) zmultiples_equiv_zmultiples_apply]
theorem zpowersEquivZPowers_apply (h : orderOf x = orderOf y) (n : ℕ) :
zpowersEquivZPowers h ⟨x ^ n, n, zpow_natCast x n⟩ = ⟨y ^ n, n, zpow_natCast y n⟩ := by
rw [zpowersEquivZPowers, Equiv.trans_apply, Equiv.trans_apply, finEquivZPowers_symm_apply, ←
Equiv.eq_symm_apply, finEquivZPowers_symm_apply]
simp [h]
/-- See `Subgroup.closure_toSubmonoid_of_isOfFinOrder` for a version with weaker assumptions. -/
@[to_additive
/-- See `AddSubgroup.closure_toAddSubmonoid_of_isOfFinOrder` for a version with weaker
assumptions. -/]
lemma Subgroup.closure_toSubmonoid_of_finite {s : Set G} :
(closure s).toSubmonoid = Submonoid.closure s :=
closure_toSubmonoid_of_isOfFinOrder <| by simp [isOfFinOrder_of_finite]
end Finite
variable [Fintype G] {x : G} {n : ℕ}
/-- See also `Nat.card_zpowers`. -/
@[to_additive /-- See also `Nat.card_zmultiples`. -/]
theorem Fintype.card_zpowers : Fintype.card (zpowers x) = orderOf x :=
(Fintype.card_eq.2 ⟨finEquivZPowers <| isOfFinOrder_of_finite _⟩).symm.trans <|
Fintype.card_fin (orderOf x)
@[to_additive]
theorem card_zpowers_le (a : G) {k : ℕ} (k_pos : k ≠ 0)
(ha : a ^ k = 1) : Fintype.card (Subgroup.zpowers a) ≤ k := by
rw [Fintype.card_zpowers]
apply orderOf_le_of_pow_eq_one k_pos.bot_lt ha
open QuotientGroup
@[to_additive]
theorem orderOf_dvd_card : orderOf x ∣ Fintype.card G := by
use Fintype.card (G ⧸ zpowers x)
rw [← card_zpowers, mul_comm, ← Fintype.card_prod,
← Fintype.card_congr groupEquivQuotientProdSubgroup]
@[to_additive]
theorem orderOf_dvd_natCard {G : Type*} [Group G] (x : G) : orderOf x ∣ Nat.card G := by
obtain h | h := fintypeOrInfinite G
· simp only [Nat.card_eq_fintype_card, orderOf_dvd_card]
· simp only [card_eq_zero_of_infinite, dvd_zero]
@[to_additive]
nonrec lemma Subgroup.orderOf_dvd_natCard {G : Type*} [Group G] (s : Subgroup G) {x} (hx : x ∈ s) :
orderOf x ∣ Nat.card s := by
simpa using orderOf_dvd_natCard (⟨x, hx⟩ : s)
@[to_additive]
lemma Subgroup.orderOf_le_card {G : Type*} [Group G] (s : Subgroup G) (hs : (s : Set G).Finite)
{x} (hx : x ∈ s) : orderOf x ≤ Nat.card s :=
le_of_dvd (Nat.card_pos_iff.2 <| ⟨s.coe_nonempty.to_subtype, hs.to_subtype⟩) <|
s.orderOf_dvd_natCard hx
@[to_additive]
lemma Submonoid.orderOf_le_card {G : Type*} [Group G] (s : Submonoid G) (hs : (s : Set G).Finite)
{x} (hx : x ∈ s) : orderOf x ≤ Nat.card s := by
rw [← Nat.card_submonoidPowers]; exact Nat.card_mono hs <| powers_le.2 hx
@[to_additive (attr := simp) card_nsmul_eq_zero']
theorem pow_card_eq_one' {G : Type*} [Group G] {x : G} : x ^ Nat.card G = 1 :=
orderOf_dvd_iff_pow_eq_one.mp <| orderOf_dvd_natCard _
@[to_additive (attr := simp) card_nsmul_eq_zero]
theorem pow_card_eq_one : x ^ Fintype.card G = 1 := by
rw [← Nat.card_eq_fintype_card, pow_card_eq_one']
@[to_additive]
theorem Subgroup.pow_index_mem {G : Type*} [Group G] (H : Subgroup G) [Normal H] (g : G) :
g ^ index H ∈ H := by rw [← eq_one_iff, QuotientGroup.mk_pow H, index, pow_card_eq_one']
@[to_additive (attr := simp) mod_card_nsmul]
lemma pow_mod_card (a : G) (n : ℕ) : a ^ (n % card G) = a ^ n := by
rw [eq_comm, ← pow_mod_orderOf, ← Nat.mod_mod_of_dvd n orderOf_dvd_card, pow_mod_orderOf]
@[to_additive (attr := simp) mod_card_zsmul]
theorem zpow_mod_card (a : G) (n : ℤ) : a ^ (n % Fintype.card G : ℤ) = a ^ n := by
rw [eq_comm, ← zpow_mod_orderOf, ← Int.emod_emod_of_dvd n
(Int.natCast_dvd_natCast.2 orderOf_dvd_card), zpow_mod_orderOf]
@[to_additive (attr := simp) mod_natCard_nsmul]
lemma pow_mod_natCard {G} [Group G] (a : G) (n : ℕ) : a ^ (n % Nat.card G) = a ^ n := by
rw [eq_comm, ← pow_mod_orderOf, ← Nat.mod_mod_of_dvd n <| orderOf_dvd_natCard _, pow_mod_orderOf]
@[to_additive (attr := simp) mod_natCard_zsmul]
lemma zpow_mod_natCard {G} [Group G] (a : G) (n : ℤ) : a ^ (n % Nat.card G : ℤ) = a ^ n := by
rw [eq_comm, ← zpow_mod_orderOf, ← Int.emod_emod_of_dvd n <|
Int.natCast_dvd_natCast.2 <| orderOf_dvd_natCard _, zpow_mod_orderOf]
/-- If `gcd(|G|,n)=1` then the `n`th power map is a bijection -/
@[to_additive (attr := simps) /-- If `gcd(|G|,n)=1` then the smul by `n` is a bijection -/]
noncomputable def powCoprime {G : Type*} [Group G] (h : (Nat.card G).Coprime n) : G ≃ G where
toFun g := g ^ n
invFun g := g ^ (Nat.card G).gcdB n
left_inv g := by
have key := congr_arg (g ^ ·) ((Nat.card G).gcd_eq_gcd_ab n)
dsimp only at key
rwa [zpow_add, zpow_mul, zpow_mul, zpow_natCast, zpow_natCast, zpow_natCast, h.gcd_eq_one,
pow_one, pow_card_eq_one', one_zpow, one_mul, eq_comm] at key
right_inv g := by
have key := congr_arg (g ^ ·) ((Nat.card G).gcd_eq_gcd_ab n)
dsimp only at key
rwa [zpow_add, zpow_mul, zpow_mul', zpow_natCast, zpow_natCast, zpow_natCast, h.gcd_eq_one,
pow_one, pow_card_eq_one', one_zpow, one_mul, eq_comm] at key
@[to_additive]
theorem powCoprime_one {G : Type*} [Group G] (h : (Nat.card G).Coprime n) : powCoprime h 1 = 1 :=
one_pow n
@[to_additive]
theorem powCoprime_inv {G : Type*} [Group G] (h : (Nat.card G).Coprime n) {g : G} :
powCoprime h g⁻¹ = (powCoprime h g)⁻¹ :=
inv_pow g n
@[to_additive Nat.Coprime.nsmul_right_bijective]
lemma Nat.Coprime.pow_left_bijective {G} [Group G] (hn : (Nat.card G).Coprime n) :
Bijective (· ^ n : G → G) :=
(powCoprime hn).bijective
/- TODO: Generalise to `Submonoid.powers`. -/
@[to_additive]
theorem image_range_orderOf [DecidableEq G] :
letI : Fintype (zpowers x) := (Subgroup.zpowers x).instFintypeSubtypeMemOfDecidablePred
Finset.image (fun i => x ^ i) (Finset.range (orderOf x)) = (zpowers x : Set G).toFinset := by
letI : Fintype (zpowers x) := (Subgroup.zpowers x).instFintypeSubtypeMemOfDecidablePred
ext x
rw [Set.mem_toFinset, SetLike.mem_coe, mem_zpowers_iff_mem_range_orderOf]
/- TODO: Generalise to `Finite` + `CancelMonoid`. -/
@[to_additive gcd_nsmul_card_eq_zero_iff]
theorem pow_gcd_card_eq_one_iff : x ^ n = 1 ↔ x ^ gcd n (Fintype.card G) = 1 :=
⟨fun h => pow_gcd_eq_one _ h <| pow_card_eq_one, fun h => by
let ⟨m, hm⟩ := gcd_dvd_left n (Fintype.card G)
rw [hm, pow_mul, h, one_pow]⟩
lemma smul_eq_of_le_smul
{G : Type*} [Group G] [Finite G] {α : Type*} [PartialOrder α] {g : G} {a : α}
[MulAction G α] [CovariantClass G α HSMul.hSMul LE.le] (h : a ≤ g • a) : g • a = a := by
have key := smul_mono_right g (le_pow_smul h (Nat.card G - 1))
rw [smul_smul, ← _root_.pow_succ',
Nat.sub_one_add_one_eq_of_pos Nat.card_pos, pow_card_eq_one', one_smul] at key
exact le_antisymm key h
lemma smul_eq_of_smul_le
{G : Type*} [Group G] [Finite G] {α : Type*} [PartialOrder α] {g : G} {a : α}
[MulAction G α] [CovariantClass G α HSMul.hSMul LE.le] (h : g • a ≤ a) : g • a = a := by
have key := smul_mono_right g (pow_smul_le h (Nat.card G - 1))
rw [smul_smul, ← _root_.pow_succ',
Nat.sub_one_add_one_eq_of_pos Nat.card_pos, pow_card_eq_one', one_smul] at key
exact le_antisymm h key
end FiniteGroup
section PowIsSubgroup
/-- A nonempty idempotent subset of a finite cancellative monoid is a submonoid -/
@[to_additive
/-- A nonempty idempotent subset of a finite cancellative additive monoid is a submonoid -/]
def submonoidOfIdempotent {M : Type*} [LeftCancelMonoid M] [Finite M] (S : Set M)
(hS1 : S.Nonempty) (hS2 : S * S = S) : Submonoid M :=
have pow_mem (a : M) (ha : a ∈ S) (n : ℕ) : a ^ (n + 1) ∈ S := by
induction n with
| zero => rwa [zero_add, pow_one]
| succ n ih =>
rw [← hS2, pow_succ]
exact Set.mul_mem_mul ih ha
{ carrier := S
one_mem' := by
obtain ⟨a, ha⟩ := hS1
rw [← pow_orderOf_eq_one a, ← tsub_add_cancel_of_le (succ_le_of_lt (orderOf_pos a))]
exact pow_mem a ha (orderOf a - 1)
mul_mem' := fun ha hb => (congr_arg₂ (· ∈ ·) rfl hS2).mp (Set.mul_mem_mul ha hb) }
/-- A nonempty idempotent subset of a finite group is a subgroup -/
@[to_additive /-- A nonempty idempotent subset of a finite additive group is a subgroup -/]
def subgroupOfIdempotent {G : Type*} [Group G] [Finite G] (S : Set G) (hS1 : S.Nonempty)
(hS2 : S * S = S) : Subgroup G :=
{ submonoidOfIdempotent S hS1 hS2 with
carrier := S
inv_mem' := fun {a} ha => show a⁻¹ ∈ submonoidOfIdempotent S hS1 hS2 by
rw [← one_mul a⁻¹, ← pow_one a, ← pow_orderOf_eq_one a, ← pow_sub a (orderOf_pos a)]
exact pow_mem ha (orderOf a - 1) }
/-- If `S` is a nonempty subset of a finite group `G`, then `S ^ |G|` is a subgroup -/
@[to_additive (attr := simps!) smulCardAddSubgroup
/-- If `S` is a nonempty subset of a finite additive group `G`, then `|G| • S` is a subgroup -/]
def powCardSubgroup {G : Type*} [Group G] [Fintype G] (S : Set G) (hS : S.Nonempty) : Subgroup G :=
have one_mem : (1 : G) ∈ S ^ Fintype.card G := by
obtain ⟨a, ha⟩ := hS
rw [← pow_card_eq_one]
exact Set.pow_mem_pow ha
subgroupOfIdempotent (S ^ Fintype.card G) ⟨1, one_mem⟩ <| by
classical
apply (Set.eq_of_subset_of_card_le (Set.subset_mul_left _ one_mem) (ge_of_eq _)).symm
simp_rw [← pow_add,
Group.card_pow_eq_card_pow_card_univ S (Fintype.card G + Fintype.card G) le_add_self]
end PowIsSubgroup
section LinearOrderedSemiring
variable [Semiring G] [LinearOrder G] [IsStrictOrderedRing G] {a : G}
protected lemma IsOfFinOrder.eq_one (ha₀ : 0 ≤ a) (ha : IsOfFinOrder a) : a = 1 := by
obtain ⟨n, hn, ha⟩ := ha.exists_pow_eq_one
exact (pow_eq_one_iff_of_nonneg ha₀ hn.ne').1 ha
end LinearOrderedSemiring
section LinearOrderedRing
variable [Ring G] [LinearOrder G] [IsStrictOrderedRing G] {a x : G}
protected lemma IsOfFinOrder.eq_neg_one (ha₀ : a ≤ 0) (ha : IsOfFinOrder a) : a = -1 :=
(sq_eq_one_iff.1 <| ha.pow.eq_one <| sq_nonneg a).resolve_left <| by
rintro rfl; exact one_pos.not_ge ha₀
theorem orderOf_abs_ne_one (h : |x| ≠ 1) : orderOf x = 0 := by
rw [orderOf_eq_zero_iff']
intro n hn hx
replace hx : |x| ^ n = 1 := by simpa only [abs_one, abs_pow] using congr_arg abs hx
rcases h.lt_or_gt with h | h
· exact ((pow_lt_one₀ (abs_nonneg x) h hn.ne').ne hx).elim
· exact ((one_lt_pow₀ h hn.ne').ne' hx).elim
theorem LinearOrderedRing.orderOf_le_two : orderOf x ≤ 2 := by
rcases ne_or_eq |x| 1 with h | h
· simp [orderOf_abs_ne_one h]
rcases eq_or_eq_neg_of_abs_eq h with (rfl | rfl)
· simp
exact orderOf_le_of_pow_eq_one zero_lt_two (by simp)
end LinearOrderedRing
section Prod
variable [Monoid α] [Monoid β] {x : α × β} {a : α} {b : β}
@[to_additive]
protected theorem Prod.orderOf (x : α × β) : orderOf x = (orderOf x.1).lcm (orderOf x.2) :=
minimalPeriod_prodMap _ _ _
@[to_additive]
theorem orderOf_fst_dvd_orderOf : orderOf x.1 ∣ orderOf x :=
minimalPeriod_fst_dvd
@[to_additive]
theorem orderOf_snd_dvd_orderOf : orderOf x.2 ∣ orderOf x :=
minimalPeriod_snd_dvd
@[to_additive]
theorem IsOfFinOrder.fst {x : α × β} (hx : IsOfFinOrder x) : IsOfFinOrder x.1 :=
hx.mono orderOf_fst_dvd_orderOf
@[to_additive]
theorem IsOfFinOrder.snd {x : α × β} (hx : IsOfFinOrder x) : IsOfFinOrder x.2 :=
hx.mono orderOf_snd_dvd_orderOf
@[to_additive IsOfFinAddOrder.prod_mk]
theorem IsOfFinOrder.prod_mk : IsOfFinOrder a → IsOfFinOrder b → IsOfFinOrder (a, b) := by
simpa only [← orderOf_pos_iff, Prod.orderOf] using Nat.lcm_pos
@[to_additive]
lemma Prod.orderOf_mk : orderOf (a, b) = Nat.lcm (orderOf a) (orderOf b) :=
(a, b).orderOf
end Prod
-- TODO: Corresponding `pi` lemmas. We cannot currently state them here because of import cycles
@[simp]
lemma Nat.cast_card_eq_zero (R) [AddGroupWithOne R] [Fintype R] : (Fintype.card R : R) = 0 := by
rw [← nsmul_one, card_nsmul_eq_zero]
section NonAssocRing
variable (R : Type*) [NonAssocRing R] (p : ℕ)
lemma CharP.addOrderOf_one : CharP R (addOrderOf (1 : R)) where
cast_eq_zero_iff n := by rw [← Nat.smul_one_eq_cast, addOrderOf_dvd_iff_nsmul_eq_zero]
variable [Fintype R]
variable {R} in
lemma charP_of_ne_zero (hn : card R = p) (hR : ∀ i < p, (i : R) = 0 → i = 0) : CharP R p where
cast_eq_zero_iff n := by
have H : (p : R) = 0 := by rw [← hn, Nat.cast_card_eq_zero]
constructor
· intro h
rw [← Nat.mod_add_div n p, Nat.cast_add, Nat.cast_mul, H, zero_mul, add_zero] at h
rw [Nat.dvd_iff_mod_eq_zero]
apply hR _ (Nat.mod_lt _ _) h
rw [← hn, Fintype.card_pos_iff]
exact ⟨0⟩
· rintro ⟨n, rfl⟩
rw [Nat.cast_mul, H, zero_mul]
end NonAssocRing
lemma charP_of_prime_pow_injective (R) [Ring R] [Fintype R] (p n : ℕ) [hp : Fact p.Prime]
(hn : card R = p ^ n) (hR : ∀ i ≤ n, (p : R) ^ i = 0 → i = n) : CharP R (p ^ n) := by
obtain ⟨c, hc⟩ := CharP.exists R
have hcpn : c ∣ p ^ n := by rw [← CharP.cast_eq_zero_iff R c, ← hn, Nat.cast_card_eq_zero]
obtain ⟨i, hi, rfl⟩ : ∃ i ≤ n, c = p ^ i := by rwa [Nat.dvd_prime_pow hp.1] at hcpn
obtain rfl : i = n := hR i hi <| by rw [← Nat.cast_pow, CharP.cast_eq_zero]
assumption
namespace SemiconjBy
@[to_additive]
lemma orderOf_eq [Group G] (a : G) {x y : G} (h : SemiconjBy a x y) : orderOf x = orderOf y := by
rw [orderOf_eq_orderOf_iff]
intro n
exact (h.pow_right n).eq_one_iff
end SemiconjBy
section single
lemma orderOf_piMulSingle {ι : Type*} [DecidableEq ι] {M : ι → Type*} [(i : ι) → Monoid (M i)]
(i : ι) (g : M i) :
orderOf (Pi.mulSingle i g) = orderOf g :=
orderOf_injective (MonoidHom.mulSingle M i) (Pi.mulSingle_injective i) g
end single |
.lake/packages/mathlib/Mathlib/GroupTheory/Order/Min.lean | import Mathlib.Algebra.Group.Torsion
import Mathlib.Data.ENat.Lattice
import Mathlib.Data.ZMod.QuotientGroup
/-!
# Minimum order of an element
This file defines the minimum order of an element of a monoid.
## Main declarations
* `Monoid.minOrder`: The minimum order of an element of a given monoid.
* `Monoid.minOrder_eq_top`: The minimum order is infinite iff the monoid is torsion-free.
* `ZMod.minOrder`: The minimum order of $$ℤ/nℤ$$ is the smallest factor of `n`, unless `n = 0, 1`.
-/
open Subgroup
variable {G α : Type*}
namespace Monoid
section Monoid
variable (α) [Monoid α]
/-- The minimum order of a non-identity element. Also the minimum size of a nontrivial subgroup, see
`Monoid.le_minOrder_iff_forall_subgroup`. Returns `∞` if the monoid is torsion-free. -/
@[to_additive /-- The minimum order of a non-identity element. Also the minimum size of a nontrivial
subgroup, see `AddMonoid.le_minOrder_iff_forall_addSubgroup`. Returns `∞` if the monoid is
torsion-free. -/]
noncomputable def minOrder : ℕ∞ := ⨅ (a : α) (_ha : a ≠ 1) (_ha' : IsOfFinOrder a), orderOf a
variable {α} {a : α}
@[to_additive (attr := simp)]
lemma le_minOrder {n : ℕ∞} :
n ≤ minOrder α ↔ ∀ ⦃a : α⦄, a ≠ 1 → IsOfFinOrder a → n ≤ orderOf a := by simp [minOrder]
@[to_additive]
lemma minOrder_le_orderOf (ha : a ≠ 1) (ha' : IsOfFinOrder a) : minOrder α ≤ orderOf a :=
le_minOrder.1 le_rfl ha ha'
end Monoid
section Group
variable [Group G] {s : Subgroup G}
@[to_additive]
lemma le_minOrder_iff_forall_subgroup {n : ℕ∞} :
n ≤ minOrder G ↔ ∀ ⦃s : Subgroup G⦄, s ≠ ⊥ → (s : Set G).Finite → n ≤ Nat.card s := by
rw [le_minOrder]
refine ⟨fun h s hs hs' ↦ ?_, fun h a ha ha' ↦ ?_⟩
· obtain ⟨a, has, ha⟩ := s.bot_or_exists_ne_one.resolve_left hs
exact
(h ha <| finite_zpowers.1 <| hs'.subset <| zpowers_le.2 has).trans
(WithTop.coe_le_coe.2 <| s.orderOf_le_card hs' has)
· simpa using h (zpowers_ne_bot.2 ha) ha'.finite_zpowers
@[to_additive]
lemma minOrder_le_natCard (hs : s ≠ ⊥) (hs' : (s : Set G).Finite) : minOrder G ≤ Nat.card s :=
le_minOrder_iff_forall_subgroup.1 le_rfl hs hs'
@[to_additive (attr := simp)]
lemma minOrder_eq_top [IsMulTorsionFree G] : minOrder G = ⊤ := by
simpa [minOrder] using fun _ ↦ not_isOfFinOrder_of_isMulTorsionFree
end Group
section CommGroup
variable [CommGroup G] {s : Subgroup G}
@[to_additive (attr := simp)]
lemma minOrder_eq_top_iff : minOrder G = ⊤ ↔ IsMulTorsionFree G := by
simp [minOrder, isMulTorsionFree_iff_not_isOfFinOrder]
end CommGroup
end Monoid
open AddMonoid AddSubgroup Nat Set
namespace ZMod
@[simp]
protected lemma minOrder {n : ℕ} (hn : n ≠ 0) (hn₁ : n ≠ 1) : minOrder (ZMod n) = n.minFac := by
have : Fact (1 < n) := ⟨one_lt_iff_ne_zero_and_ne_one.mpr ⟨hn, hn₁⟩⟩
classical
have : (↑(n / n.minFac) : ZMod n) ≠ 0 := by
rw [Ne, ringChar.spec, ringChar.eq (ZMod n) n]
exact
not_dvd_of_pos_of_lt (Nat.div_pos (minFac_le hn.bot_lt) n.minFac_pos)
(div_lt_self hn.bot_lt (minFac_prime hn₁).one_lt)
refine ((minOrder_le_natCard (zmultiples_eq_bot.not.2 this) <| toFinite _).trans ?_).antisymm <|
le_minOrder_iff_forall_addSubgroup.2 fun s hs _ ↦ ?_
· rw [Nat.card_zmultiples, ZMod.addOrderOf_coe _ hn,
gcd_eq_right (div_dvd_of_dvd n.minFac_dvd), Nat.div_div_self n.minFac_dvd hn]
· haveI : Nontrivial s := s.bot_or_nontrivial.resolve_left hs
exact WithTop.coe_le_coe.2 <| minFac_le_of_dvd Finite.one_lt_card <|
(card_addSubgroup_dvd_card _).trans n.card_zmod.dvd
@[simp]
lemma minOrder_of_prime {p : ℕ} (hp : p.Prime) : minOrder (ZMod p) = p := by
rw [ZMod.minOrder hp.ne_zero hp.ne_one, hp.minFac_eq]
end ZMod |
.lake/packages/mathlib/Mathlib/GroupTheory/Coset/Card.lean | import Mathlib.GroupTheory.Coset.Basic
import Mathlib.SetTheory.Cardinal.Finite
/-!
# Lagrange's theorem: the order of a subgroup divides the order of the group.
* `Subgroup.card_subgroup_dvd_card`: Lagrange's theorem (for multiplicative groups);
there is an analogous version for additive groups
-/
assert_not_exists Field
open scoped Pointwise
variable {α : Type*} [Group α] {s : Subgroup α}
namespace QuotientGroup
@[to_additive]
instance fintype [Fintype α] (s : Subgroup α) [DecidableRel (leftRel s).r] : Fintype (α ⧸ s) :=
Quotient.fintype (leftRel s)
@[to_additive]
instance (priority := 100) finite [Finite α] : Finite (α ⧸ s) :=
Quotient.finite _
@[to_additive]
instance fintypeQuotientRightRel [Fintype (α ⧸ s)] :
Fintype (Quotient (QuotientGroup.rightRel s)) :=
.ofEquiv (α ⧸ s) (QuotientGroup.quotientRightRelEquivQuotientLeftRel s).symm
variable (s) in
@[to_additive]
lemma card_quotient_rightRel [Fintype (α ⧸ s)] :
Fintype.card (Quotient (QuotientGroup.rightRel s)) = Fintype.card (α ⧸ s) :=
Fintype.ofEquiv_card (QuotientGroup.quotientRightRelEquivQuotientLeftRel s).symm
end QuotientGroup
namespace Subgroup
@[to_additive AddSubgroup.card_eq_card_quotient_mul_card_addSubgroup]
theorem card_eq_card_quotient_mul_card_subgroup (s : Subgroup α) :
Nat.card α = Nat.card (α ⧸ s) * Nat.card s := by
rw [← Nat.card_prod]; exact Nat.card_congr Subgroup.groupEquivQuotientProdSubgroup
@[to_additive]
lemma card_mul_eq_card_subgroup_mul_card_quotient (s : Subgroup α) (t : Set α) :
Nat.card (t * s : Set α) = Nat.card s * Nat.card (t.image (↑) : Set (α ⧸ s)) := by
rw [← Nat.card_prod, Nat.card_congr]
apply Equiv.trans _ (QuotientGroup.preimageMkEquivSubgroupProdSet _ _)
rw [QuotientGroup.preimage_image_mk]
convert Equiv.refl ↑(t * s)
aesop (add simp [Set.mem_mul])
/-- **Lagrange's Theorem**: The order of a subgroup divides the order of its ambient group. -/
@[to_additive /-- **Lagrange's Theorem**: The order of an additive subgroup divides the order of its
ambient additive group. -/]
theorem card_subgroup_dvd_card (s : Subgroup α) : Nat.card s ∣ Nat.card α := by
classical simp [card_eq_card_quotient_mul_card_subgroup s, @dvd_mul_left ℕ]
@[to_additive]
theorem card_quotient_dvd_card (s : Subgroup α) : Nat.card (α ⧸ s) ∣ Nat.card α := by
simp [card_eq_card_quotient_mul_card_subgroup s, @dvd_mul_right ℕ]
variable {H : Type*} [Group H]
@[to_additive]
theorem card_dvd_of_injective (f : α →* H) (hf : Function.Injective f) :
Nat.card α ∣ Nat.card H := by
classical calc
Nat.card α = Nat.card (f.range : Subgroup H) := Nat.card_congr (Equiv.ofInjective f hf)
_ ∣ Nat.card H := card_subgroup_dvd_card _
@[to_additive]
theorem card_dvd_of_le {H K : Subgroup α} (hHK : H ≤ K) : Nat.card H ∣ Nat.card K :=
card_dvd_of_injective (inclusion hHK) (inclusion_injective hHK)
@[to_additive]
theorem card_comap_dvd_of_injective (K : Subgroup H) (f : α →* H)
(hf : Function.Injective f) : Nat.card (K.comap f) ∣ Nat.card K :=
calc Nat.card (K.comap f) = Nat.card ((K.comap f).map f) :=
Nat.card_congr (equivMapOfInjective _ _ hf).toEquiv
_ ∣ Nat.card K := card_dvd_of_le (map_comap_le _ _)
end Subgroup |
.lake/packages/mathlib/Mathlib/GroupTheory/Coset/Basic.lean | import Mathlib.Algebra.Group.Action.Pointwise.Set.Basic
import Mathlib.Algebra.Group.Subgroup.Basic
import Mathlib.Data.Setoid.Basic
import Mathlib.GroupTheory.Coset.Defs
/-!
# Cosets
This file develops the basic theory of left and right cosets.
When `G` is a group and `a : G`, `s : Set G`, with `open scoped Pointwise` we can write:
* the left coset of `s` by `a` as `a • s`
* the right coset of `s` by `a` as `MulOpposite.op a • s` (or `op a • s` with `open MulOpposite`)
If instead `G` is an additive group, we can write (with `open scoped Pointwise` still)
* the left coset of `s` by `a` as `a +ᵥ s`
* the right coset of `s` by `a` as `AddOpposite.op a +ᵥ s` (or `op a • s` with `open AddOpposite`)
## Main definitions
* `Subgroup.leftCosetEquivSubgroup`: the natural bijection between a left coset and the subgroup,
for an `AddGroup` this is `AddSubgroup.leftCosetEquivAddSubgroup`.
## Notation
* `G ⧸ H` is the quotient of the (additive) group `G` by the (additive) subgroup `H`
## TODO
Properly merge with pointwise actions on sets, by renaming and deduplicating lemmas as appropriate.
-/
assert_not_exists Cardinal Multiset
open Function MulOpposite Set
open scoped Pointwise
variable {α : Type*}
section CosetMul
variable [Mul α]
@[to_additive mem_leftAddCoset]
theorem mem_leftCoset {s : Set α} {x : α} (a : α) (hxS : x ∈ s) : a * x ∈ a • s :=
mem_image_of_mem (fun b : α => a * b) hxS
@[to_additive mem_rightAddCoset]
theorem mem_rightCoset {s : Set α} {x : α} (a : α) (hxS : x ∈ s) : x * a ∈ op a • s :=
mem_image_of_mem (fun b : α => b * a) hxS
/-- Equality of two left cosets `a * s` and `b * s`. -/
@[to_additive LeftAddCosetEquivalence /-- Equality of two left cosets `a + s` and `b + s`. -/]
def LeftCosetEquivalence (s : Set α) (a b : α) :=
a • s = b • s
@[to_additive leftAddCosetEquivalence_rel]
theorem leftCosetEquivalence_rel (s : Set α) : Equivalence (LeftCosetEquivalence s) :=
@Equivalence.mk _ (LeftCosetEquivalence s) (fun _ => rfl) Eq.symm Eq.trans
/-- Equality of two right cosets `s * a` and `s * b`. -/
@[to_additive RightAddCosetEquivalence /-- Equality of two right cosets `s + a` and `s + b`. -/]
def RightCosetEquivalence (s : Set α) (a b : α) :=
op a • s = op b • s
@[to_additive rightAddCosetEquivalence_rel]
theorem rightCosetEquivalence_rel (s : Set α) : Equivalence (RightCosetEquivalence s) :=
@Equivalence.mk _ (RightCosetEquivalence s) (fun _a => rfl) Eq.symm Eq.trans
end CosetMul
section CosetSemigroup
variable [Semigroup α]
@[to_additive leftAddCoset_assoc]
theorem leftCoset_assoc (s : Set α) (a b : α) : a • (b • s) = (a * b) • s := by
simp [← image_smul, (image_comp _ _ _).symm, Function.comp, mul_assoc]
@[to_additive rightAddCoset_assoc]
theorem rightCoset_assoc (s : Set α) (a b : α) : op b • op a • s = op (a * b) • s := by
simp [← image_smul, (image_comp _ _ _).symm, Function.comp, mul_assoc]
@[to_additive leftAddCoset_rightAddCoset]
theorem leftCoset_rightCoset (s : Set α) (a b : α) : op b • a • s = a • (op b • s) := by
simp [← image_smul, (image_comp _ _ _).symm, Function.comp, mul_assoc]
end CosetSemigroup
section CosetMonoid
variable [Monoid α] (s : Set α)
@[to_additive zero_leftAddCoset]
theorem one_leftCoset : (1 : α) • s = s :=
Set.ext <| by simp
@[to_additive rightAddCoset_zero]
theorem rightCoset_one : op (1 : α) • s = s :=
Set.ext <| by simp
end CosetMonoid
section CosetSubmonoid
open Submonoid
variable [Monoid α] (s : Submonoid α)
@[to_additive mem_own_leftAddCoset]
theorem mem_own_leftCoset (a : α) : a ∈ a • (s : Set α) :=
suffices a * 1 ∈ a • (s : Set α) by simpa
mem_leftCoset a (one_mem s : 1 ∈ s)
@[to_additive mem_own_rightAddCoset]
theorem mem_own_rightCoset (a : α) : a ∈ op a • (s : Set α) :=
suffices 1 * a ∈ op a • (s : Set α) by simpa
mem_rightCoset a (one_mem s : 1 ∈ s)
@[to_additive mem_leftAddCoset_leftAddCoset]
theorem mem_leftCoset_leftCoset {a : α} (ha : a • (s : Set α) = s) : a ∈ s := by
rw [← SetLike.mem_coe, ← ha]; exact mem_own_leftCoset s a
@[to_additive mem_rightAddCoset_rightAddCoset]
theorem mem_rightCoset_rightCoset {a : α} (ha : op a • (s : Set α) = s) : a ∈ s := by
rw [← SetLike.mem_coe, ← ha]; exact mem_own_rightCoset s a
end CosetSubmonoid
section CosetGroup
variable [Group α] {s : Set α} {x : α}
@[to_additive mem_leftAddCoset_iff]
theorem mem_leftCoset_iff (a : α) : x ∈ a • s ↔ a⁻¹ * x ∈ s :=
Iff.intro (fun ⟨b, hb, Eq⟩ => by simp [Eq.symm, hb]) fun h => ⟨a⁻¹ * x, h, by simp⟩
@[to_additive mem_rightAddCoset_iff]
theorem mem_rightCoset_iff (a : α) : x ∈ op a • s ↔ x * a⁻¹ ∈ s :=
Iff.intro (fun ⟨b, hb, Eq⟩ => by simp [Eq.symm, hb]) fun h => ⟨x * a⁻¹, h, by simp⟩
end CosetGroup
section CosetSubgroup
open Subgroup
variable [Group α] (s : Subgroup α)
@[to_additive leftAddCoset_mem_leftAddCoset]
theorem leftCoset_mem_leftCoset {a : α} (ha : a ∈ s) : a • (s : Set α) = s :=
Set.ext <| by simp [mem_leftCoset_iff, mul_mem_cancel_left (s.inv_mem ha)]
@[to_additive rightAddCoset_mem_rightAddCoset]
theorem rightCoset_mem_rightCoset {a : α} (ha : a ∈ s) : op a • (s : Set α) = s :=
Set.ext fun b => by simp [mem_rightCoset_iff, mul_mem_cancel_right (s.inv_mem ha)]
@[to_additive]
theorem orbit_subgroup_eq_rightCoset (a : α) : MulAction.orbit s a = op a • s :=
Set.ext fun _b => ⟨fun ⟨c, d⟩ => ⟨c, c.2, d⟩, fun ⟨c, d, e⟩ => ⟨⟨c, d⟩, e⟩⟩
@[to_additive]
theorem orbit_subgroup_eq_self_of_mem {a : α} (ha : a ∈ s) : MulAction.orbit s a = s :=
(orbit_subgroup_eq_rightCoset s a).trans (rightCoset_mem_rightCoset s ha)
@[to_additive]
theorem orbit_subgroup_one_eq_self : MulAction.orbit s (1 : α) = s :=
orbit_subgroup_eq_self_of_mem s s.one_mem
@[to_additive eq_addCosets_of_normal]
theorem eq_cosets_of_normal (N : s.Normal) (g : α) : g • (s : Set α) = op g • s :=
Set.ext fun a => by simp [mem_leftCoset_iff, mem_rightCoset_iff, N.mem_comm_iff]
@[to_additive normal_of_eq_addCosets]
theorem normal_of_eq_cosets (h : ∀ g : α, g • (s : Set α) = op g • s) : s.Normal :=
⟨fun a ha g =>
show g * a * g⁻¹ ∈ (s : Set α) by rw [← mem_rightCoset_iff, ← h]; exact mem_leftCoset g ha⟩
@[to_additive normal_iff_eq_addCosets]
theorem normal_iff_eq_cosets : s.Normal ↔ ∀ g : α, g • (s : Set α) = op g • s :=
⟨@eq_cosets_of_normal _ _ s, normal_of_eq_cosets s⟩
@[to_additive leftAddCoset_eq_iff]
theorem leftCoset_eq_iff {x y : α} : x • (s : Set α) = y • s ↔ x⁻¹ * y ∈ s := by
rw [Set.ext_iff]
simp_rw [mem_leftCoset_iff, SetLike.mem_coe]
constructor
· intro h
apply (h y).mpr
rw [inv_mul_cancel]
exact s.one_mem
· intro h z
rw [← mul_inv_cancel_right x⁻¹ y]
rw [mul_assoc]
exact s.mul_mem_cancel_left h
@[to_additive rightAddCoset_eq_iff]
theorem rightCoset_eq_iff {x y : α} : op x • (s : Set α) = op y • s ↔ y * x⁻¹ ∈ s := by
rw [Set.ext_iff]
simp_rw [mem_rightCoset_iff, SetLike.mem_coe]
constructor
· intro h
apply (h y).mpr
rw [mul_inv_cancel]
exact s.one_mem
· intro h z
rw [← inv_mul_cancel_left y x⁻¹]
rw [← mul_assoc]
exact s.mul_mem_cancel_right h
end CosetSubgroup
namespace QuotientGroup
variable [Group α] (s : Subgroup α)
theorem leftRel_r_eq_leftCosetEquivalence :
⇑(QuotientGroup.leftRel s) = LeftCosetEquivalence s := by
ext
rw [leftRel_eq]
exact (leftCoset_eq_iff s).symm
@[to_additive leftRel_prod]
lemma leftRel_prod {β : Type*} [Group β] (s' : Subgroup β) :
leftRel (s.prod s') = (leftRel s).prod (leftRel s') := by
refine Setoid.ext fun x y ↦ ?_
rw [Setoid.prod_apply]
simp_rw [leftRel_apply]
rfl
@[to_additive]
lemma leftRel_pi {ι : Type*} {β : ι → Type*} [∀ i, Group (β i)] (s' : ∀ i, Subgroup (β i)) :
leftRel (Subgroup.pi Set.univ s') = @piSetoid _ _ fun i ↦ leftRel (s' i) := by
refine Setoid.ext fun x y ↦ ?_
simp [Setoid.piSetoid_apply, leftRel_apply, Subgroup.mem_pi]
theorem rightRel_r_eq_rightCosetEquivalence :
⇑(QuotientGroup.rightRel s) = RightCosetEquivalence s := by
ext
rw [rightRel_eq]
exact (rightCoset_eq_iff s).symm
@[to_additive rightRel_prod]
lemma rightRel_prod {β : Type*} [Group β] (s' : Subgroup β) :
rightRel (s.prod s') = (rightRel s).prod (rightRel s') := by
refine Setoid.ext fun x y ↦ ?_
rw [Setoid.prod_apply]
simp_rw [rightRel_apply]
rfl
@[to_additive]
lemma rightRel_pi {ι : Type*} {β : ι → Type*} [∀ i, Group (β i)] (s' : ∀ i, Subgroup (β i)) :
rightRel (Subgroup.pi Set.univ s') = @piSetoid _ _ fun i ↦ rightRel (s' i) := by
refine Setoid.ext fun x y ↦ ?_
simp [Setoid.piSetoid_apply, rightRel_apply, Subgroup.mem_pi]
end QuotientGroup
namespace QuotientGroup
variable [Group α] {s : Subgroup α}
variable (s)
/-- Given a subgroup `s`, the function that sends a subgroup `t` to the pair consisting of
its intersection with `s` and its image in the quotient `α ⧸ s` is strictly monotone, even though
it is not injective in general. -/
@[to_additive QuotientAddGroup.strictMono_comap_prod_image /-- Given an additive subgroup `s`,
the function that sends an additive subgroup `t` to the pair consisting of
its intersection with `s` and its image in the quotient `α ⧸ s`
is strictly monotone, even though it is not injective in general. -/]
theorem strictMono_comap_prod_image :
StrictMono fun t : Subgroup α ↦ (t.comap s.subtype, mk (s := s) '' t) := by
refine fun t₁ t₂ h ↦ ⟨⟨Subgroup.comap_mono h.1, Set.image_mono h.1⟩,
mt (fun ⟨le1, le2⟩ a ha ↦ ?_) h.2⟩
obtain ⟨a', h', eq⟩ := le2 ⟨_, ha, rfl⟩
convert ← t₁.mul_mem h' (@le1 ⟨_, QuotientGroup.eq.1 eq⟩ <| t₂.mul_mem (t₂.inv_mem <| h.1 h') ha)
apply mul_inv_cancel_left
variable {s} {a b : α}
@[to_additive]
theorem eq_class_eq_leftCoset (s : Subgroup α) (g : α) :
{ x : α | (x : α ⧸ s) = g } = g • s :=
Set.ext fun z => by
rw [mem_leftCoset_iff, Set.mem_setOf_eq, eq_comm, QuotientGroup.eq, SetLike.mem_coe]
open MulAction in
@[to_additive]
lemma orbit_mk_eq_smul (x : α) : MulAction.orbitRel.Quotient.orbit (x : α ⧸ s) = x • s := by
ext
rw [orbitRel.Quotient.mem_orbit]
simpa [mem_smul_set_iff_inv_smul_mem, ← leftRel_apply, Quotient.eq''] using Setoid.comm' _
@[to_additive]
lemma orbit_eq_out_smul (x : α ⧸ s) : MulAction.orbitRel.Quotient.orbit x = x.out • s := by
induction x using QuotientGroup.induction_on
simp only [orbit_mk_eq_smul, ← eq_class_eq_leftCoset, Quotient.out_eq']
end QuotientGroup
namespace Subgroup
open QuotientGroup
variable [Group α] {s : Subgroup α}
/-- The natural bijection between a left coset `g * s` and `s`. -/
@[to_additive /-- The natural bijection between the cosets `g + s` and `s`. -/]
def leftCosetEquivSubgroup (g : α) : (g • s : Set α) ≃ s :=
⟨fun x => ⟨g⁻¹ * x.1, (mem_leftCoset_iff _).1 x.2⟩, fun x => ⟨g * x.1, x.1, x.2, rfl⟩,
fun ⟨x, _⟩ => Subtype.eq <| by simp, fun ⟨g, _⟩ => Subtype.eq <| by simp⟩
/-- The natural bijection between a right coset `s * g` and `s`. -/
@[to_additive /-- The natural bijection between the cosets `s + g` and `s`. -/]
def rightCosetEquivSubgroup (g : α) : (op g • s : Set α) ≃ s :=
⟨fun x => ⟨x.1 * g⁻¹, (mem_rightCoset_iff _).1 x.2⟩, fun x => ⟨x.1 * g, x.1, x.2, rfl⟩,
fun ⟨x, _⟩ => Subtype.eq <| by simp, fun ⟨g, _⟩ => Subtype.eq <| by simp⟩
/-- A (non-canonical) bijection between a group `α` and the product `(α/s) × s` -/
@[to_additive addGroupEquivQuotientProdAddSubgroup
/-- A (non-canonical) bijection between an add_group `α` and the product `(α/s) × s` -/]
noncomputable def groupEquivQuotientProdSubgroup : α ≃ (α ⧸ s) × s :=
calc
α ≃ Σ L : α ⧸ s, { x : α // (x : α ⧸ s) = L } := (Equiv.sigmaFiberEquiv QuotientGroup.mk).symm
_ ≃ Σ L : α ⧸ s, (Quotient.out L • s : Set α) :=
Equiv.sigmaCongrRight fun L => by
rw [← eq_class_eq_leftCoset]
change
(_root_.Subtype fun x : α => Quotient.mk'' x = L) ≃
_root_.Subtype fun x : α => Quotient.mk'' x = Quotient.mk'' _
simp
rfl
_ ≃ Σ _L : α ⧸ s, s := Equiv.sigmaCongrRight fun _ => leftCosetEquivSubgroup _
_ ≃ (α ⧸ s) × s := Equiv.sigmaEquivProd _ _
variable {t : Subgroup α}
/-- If `H ≤ K`, then `G/H ≃ G/K × K/H` constructively, using the provided right inverse
of the quotient map `G → G/K`. The classical version is `Subgroup.quotientEquivProdOfLE`. -/
@[to_additive (attr := simps) quotientEquivProdOfLE'
/-- If `H ≤ K`, then `G/H ≃ G/K × K/H` constructively, using the provided right inverse
of the quotient map `G → G/K`. The classical version is `AddSubgroup.quotientEquivProdOfLE`. -/]
def quotientEquivProdOfLE' (h_le : s ≤ t) (f : α ⧸ t → α)
(hf : Function.RightInverse f QuotientGroup.mk) : α ⧸ s ≃ (α ⧸ t) × t ⧸ s.subgroupOf t where
toFun a :=
⟨a.map' id fun _ _ h => leftRel_apply.mpr (h_le (leftRel_apply.mp h)),
a.map' (fun g : α => ⟨(f (Quotient.mk'' g))⁻¹ * g, leftRel_apply.mp (Quotient.exact' (hf g))⟩)
fun b c h => by
rw [leftRel_apply]
change ((f b)⁻¹ * b)⁻¹ * ((f c)⁻¹ * c) ∈ s
have key : f b = f c :=
congr_arg f (Quotient.sound' (leftRel_apply.mpr (h_le (leftRel_apply.mp h))))
rwa [key, mul_inv_rev, inv_inv, mul_assoc, mul_inv_cancel_left, ← leftRel_apply]⟩
invFun a := by
refine a.2.map' (fun (b : { x // x ∈ t}) => f a.1 * b) fun b c h => by
rw [leftRel_apply] at h ⊢
change (f a.1 * b)⁻¹ * (f a.1 * c) ∈ s
rwa [mul_inv_rev, mul_assoc, inv_mul_cancel_left]
left_inv := by
refine Quotient.ind' fun a => ?_
simp_rw [Quotient.map'_mk'', id, mul_inv_cancel_left]
right_inv := by
refine Prod.rec ?_
refine Quotient.ind' fun a => ?_
refine Quotient.ind' fun b => ?_
have key : Quotient.mk'' (f (Quotient.mk'' a) * b) = Quotient.mk'' a :=
(QuotientGroup.mk_mul_of_mem (f a) b.2).trans (hf a)
simp_rw [Quotient.map'_mk'', id, key, inv_mul_cancel_left]
/-- If `H ≤ K`, then `G/H ≃ G/K × K/H` nonconstructively.
The constructive version is `quotientEquivProdOfLE'`. -/
@[to_additive (attr := simps!) quotientEquivProdOfLE
/-- If `H ≤ K`, then `G/H ≃ G/K × K/H` nonconstructively. The
constructive version is `quotientEquivProdOfLE'`. -/]
noncomputable def quotientEquivProdOfLE (h_le : s ≤ t) : α ⧸ s ≃ (α ⧸ t) × t ⧸ s.subgroupOf t :=
quotientEquivProdOfLE' h_le Quotient.out Quotient.out_eq'
/-- If `s ≤ t`, then there is an embedding `s ⧸ H.subgroupOf s ↪ t ⧸ H.subgroupOf t`. -/
@[to_additive
/-- If `s ≤ t`, there is an embedding `s ⧸ H.addSubgroupOf s ↪ t ⧸ H.addSubgroupOf t`. -/]
def quotientSubgroupOfEmbeddingOfLE (H : Subgroup α) (h : s ≤ t) :
s ⧸ H.subgroupOf s ↪ t ⧸ H.subgroupOf t where
toFun :=
Quotient.map' (inclusion h) fun a b => by
simp_rw [leftRel_eq]
exact id
inj' :=
Quotient.ind₂' <| by
intro a b h
simpa only [Quotient.map'_mk'', QuotientGroup.eq] using h
@[to_additive (attr := simp)]
theorem quotientSubgroupOfEmbeddingOfLE_apply_mk (H : Subgroup α) (h : s ≤ t) (g : s) :
quotientSubgroupOfEmbeddingOfLE H h (QuotientGroup.mk g) = QuotientGroup.mk (inclusion h g) :=
rfl
/-- If `s ≤ t`, then there is a map `H ⧸ s.subgroupOf H → H ⧸ t.subgroupOf H`. -/
@[to_additive
/-- If `s ≤ t`, then there is a map `H ⧸ s.addSubgroupOf H → H ⧸ t.addSubgroupOf H`. -/]
def quotientSubgroupOfMapOfLE (H : Subgroup α) (h : s ≤ t) :
H ⧸ s.subgroupOf H → H ⧸ t.subgroupOf H :=
Quotient.map' id fun a b => by
simp_rw [leftRel_eq]
apply h
@[to_additive (attr := simp)]
theorem quotientSubgroupOfMapOfLE_apply_mk (H : Subgroup α) (h : s ≤ t) (g : H) :
quotientSubgroupOfMapOfLE H h (QuotientGroup.mk g) = QuotientGroup.mk g :=
rfl
/-- If `s ≤ t`, then there is a map `α ⧸ s → α ⧸ t`. -/
@[to_additive /-- If `s ≤ t`, then there is a map `α ⧸ s → α ⧸ t`. -/]
def quotientMapOfLE (h : s ≤ t) : α ⧸ s → α ⧸ t :=
Quotient.map' id fun a b => by
simp_rw [leftRel_eq]
apply h
@[to_additive (attr := simp)]
theorem quotientMapOfLE_apply_mk (h : s ≤ t) (g : α) :
quotientMapOfLE h (QuotientGroup.mk g) = QuotientGroup.mk g :=
rfl
/-- The natural embedding `H ⧸ (⨅ i, f i).subgroupOf H ↪ Π i, H ⧸ (f i).subgroupOf H`. -/
@[to_additive (attr := simps) /-- The natural embedding
`H ⧸ (⨅ i, f i).addSubgroupOf H) ↪ Π i, H ⧸ (f i).addSubgroupOf H`. -/]
def quotientiInfSubgroupOfEmbedding {ι : Type*} (f : ι → Subgroup α) (H : Subgroup α) :
H ⧸ (⨅ i, f i).subgroupOf H ↪ ∀ i, H ⧸ (f i).subgroupOf H where
toFun q i := quotientSubgroupOfMapOfLE H (iInf_le f i) q
inj' :=
Quotient.ind₂' <| by
simp_rw [funext_iff, quotientSubgroupOfMapOfLE_apply_mk, QuotientGroup.eq, mem_subgroupOf,
mem_iInf, imp_self, forall_const]
@[to_additive (attr := simp)]
theorem quotientiInfSubgroupOfEmbedding_apply_mk {ι : Type*} (f : ι → Subgroup α) (H : Subgroup α)
(g : H) (i : ι) :
quotientiInfSubgroupOfEmbedding f H (QuotientGroup.mk g) i = QuotientGroup.mk g :=
rfl
/-- The natural embedding `α ⧸ (⨅ i, f i) ↪ Π i, α ⧸ f i`. -/
@[to_additive (attr := simps) /-- The natural embedding `α ⧸ (⨅ i, f i) ↪ Π i, α ⧸ f i`. -/]
def quotientiInfEmbedding {ι : Type*} (f : ι → Subgroup α) : (α ⧸ ⨅ i, f i) ↪ ∀ i, α ⧸ f i where
toFun q i := quotientMapOfLE (iInf_le f i) q
inj' :=
Quotient.ind₂' <| by
simp_rw [funext_iff, quotientMapOfLE_apply_mk, QuotientGroup.eq, mem_iInf, imp_self,
forall_const]
@[to_additive (attr := simp)]
theorem quotientiInfEmbedding_apply_mk {ι : Type*} (f : ι → Subgroup α) (g : α) (i : ι) :
quotientiInfEmbedding f (QuotientGroup.mk g) i = QuotientGroup.mk g :=
rfl
end Subgroup
namespace MonoidHom
variable [Group α] {H : Type*} [Group H]
/-- An equivalence between any non-empty fiber of a `MonoidHom` and its kernel. -/
@[to_additive
/-- An equivalence between any non-empty fiber of an `AddMonoidHom` and its kernel. -/]
def fiberEquivKer (f : α →* H) (a : α) : f ⁻¹' {f a} ≃ f.ker :=
.trans
(Equiv.setCongr <| Set.ext fun _ => by
rw [mem_preimage, mem_singleton_iff, mem_smul_set_iff_inv_smul_mem, SetLike.mem_coe, mem_ker,
smul_eq_mul, map_mul, map_inv, inv_mul_eq_one, eq_comm])
(Subgroup.leftCosetEquivSubgroup a)
@[to_additive (attr := simp)]
lemma fiberEquivKer_apply (f : α →* H) (a : α) (g : f ⁻¹' {f a}) : f.fiberEquivKer a g = a⁻¹ * g :=
rfl
@[to_additive (attr := simp)]
lemma fiberEquivKer_symm_apply (f : α →* H) (a : α) (g : f.ker) :
(f.fiberEquivKer a).symm g = a * g :=
rfl
/-- An equivalence between any fiber of a surjective `MonoidHom` and its kernel. -/
@[to_additive
/-- An equivalence between any fiber of a surjective `AddMonoidHom` and its kernel. -/]
noncomputable def fiberEquivKerOfSurjective {f : α →* H} (hf : Function.Surjective f) (h : H) :
f ⁻¹' {h} ≃ f.ker :=
(hf h).choose_spec ▸ f.fiberEquivKer (hf h).choose
/-- An equivalence between any two non-empty fibers of a `MonoidHom`. -/
@[to_additive /-- An equivalence between any two non-empty fibers of an `AddMonoidHom`. -/]
def fiberEquiv (f : α →* H) (a b : α) : f ⁻¹' {f a} ≃ f ⁻¹' {f b} :=
(f.fiberEquivKer a).trans (f.fiberEquivKer b).symm
@[to_additive (attr := simp)]
lemma fiberEquiv_apply (f : α →* H) (a b : α) (g : f ⁻¹' {f a}) :
f.fiberEquiv a b g = b * (a⁻¹ * g) :=
rfl
@[to_additive (attr := simp)]
lemma fiberEquiv_symm_apply (f : α →* H) (a b : α) (g : f ⁻¹' {f b}) :
(f.fiberEquiv a b).symm g = a * (b⁻¹ * g) :=
rfl
/-- An equivalence between any two fibers of a surjective `MonoidHom`. -/
@[to_additive /-- An equivalence between any two fibers of a surjective `AddMonoidHom`. -/]
noncomputable def fiberEquivOfSurjective {f : α →* H} (hf : Function.Surjective f) (h h' : H) :
f ⁻¹' {h} ≃ f ⁻¹' {h'} :=
(fiberEquivKerOfSurjective hf h).trans (fiberEquivKerOfSurjective hf h').symm
end MonoidHom
namespace QuotientGroup
variable [Group α]
/-- If `s` is a subgroup of the group `α`, and `t` is a subset of `α ⧸ s`, then there is a
(typically non-canonical) bijection between the preimage of `t` in `α` and the product `s × t`. -/
@[to_additive preimageMkEquivAddSubgroupProdSet
/-- If `s` is a subgroup of the additive group `α`, and `t` is a subset of `α ⧸ s`, then
there is a (typically non-canonical) bijection between the preimage of `t` in `α` and the product
`s × t`. -/]
noncomputable def preimageMkEquivSubgroupProdSet (s : Subgroup α) (t : Set (α ⧸ s)) :
QuotientGroup.mk ⁻¹' t ≃ s × t where
toFun a :=
⟨⟨((Quotient.out (QuotientGroup.mk a)) : α)⁻¹ * a,
leftRel_apply.mp (@Quotient.exact' _ (leftRel s) _ _ <| Quotient.out_eq' _)⟩,
⟨QuotientGroup.mk a, a.2⟩⟩
invFun a :=
⟨Quotient.out a.2.1 * a.1.1,
show QuotientGroup.mk _ ∈ t by
rw [mk_mul_of_mem _ a.1.2, out_eq']
exact a.2.2⟩
left_inv := fun ⟨a, _⟩ => Subtype.eq <| show _ * _ = a by simp
right_inv := fun ⟨⟨a, ha⟩, ⟨x, hx⟩⟩ => by ext <;> simp [ha]
open MulAction in
/-- A group is made up of a disjoint union of cosets of a subgroup. -/
@[to_additive /-- An additive group is made up of a disjoint union of cosets of an additive
subgroup. -/]
lemma univ_eq_iUnion_smul (H : Subgroup α) :
(Set.univ (α := α)) = ⋃ x : α ⧸ H, x.out • (H : Set _) := by
simp_rw [univ_eq_iUnion_orbit H.op, orbit_eq_out_smul]
rfl
variable (α) in
/-- `α ⧸ ⊥` is in bijection with `α`. See `QuotientGroup.quotientBot` for a multiplicative
version. -/
@[to_additive /-- `α ⧸ ⊥` is in bijection with `α`. See `QuotientAddGroup.quotientBot` for an
additive version. -/]
def quotientEquivSelf : α ⧸ (⊥ : Subgroup α) ≃ α where
toFun := Quotient.lift id <| fun x y (h : leftRel ⊥ x y) ↦
eq_of_inv_mul_eq_one <| by rwa [leftRel_apply, Subgroup.mem_bot] at h
invFun := QuotientGroup.mk
left_inv x := by induction x using Quotient.inductionOn; simp
right_inv x := by simp
end QuotientGroup |
.lake/packages/mathlib/Mathlib/GroupTheory/Coset/Defs.lean | import Mathlib.Algebra.Quotient
import Mathlib.Algebra.Group.Action.Opposite
import Mathlib.Algebra.Group.Subgroup.MulOpposite
import Mathlib.GroupTheory.GroupAction.Defs
import Mathlib.Algebra.Group.Pointwise.Set.Basic
/-!
# Cosets
This file develops the basic theory of left and right cosets.
When `G` is a group and `a : G`, `s : Set G`, with `open scoped Pointwise` we can write:
* the left coset of `s` by `a` as `a • s`
* the right coset of `s` by `a` as `MulOpposite.op a • s` (or `op a • s` with `open MulOpposite`)
If instead `G` is an additive group, we can write (with `open scoped Pointwise` still)
* the left coset of `s` by `a` as `a +ᵥ s`
* the right coset of `s` by `a` as `AddOpposite.op a +ᵥ s` (or `op a • s` with `open AddOpposite`)
## Main definitions
* `QuotientGroup.quotient s`: the quotient type representing the left cosets with respect to a
subgroup `s`, for an `AddGroup` this is `QuotientAddGroup.quotient s`.
* `QuotientGroup.mk`: the canonical map from `α` to `α/s` for a subgroup `s` of `α`, for an
`AddGroup` this is `QuotientAddGroup.mk`.
## Notation
* `G ⧸ H` is the quotient of the (additive) group `G` by the (additive) subgroup `H`
## TODO
Properly merge with pointwise actions on sets, by renaming and deduplicating lemmas as appropriate.
-/
assert_not_exists Cardinal
open Function Set
open scoped Pointwise
variable {α : Type*}
/- Ensure that `@[to_additive]` uses the right namespace. -/
insert_to_additive_translation QuotientGroup QuotientAddGroup
namespace QuotientGroup
variable [Group α] (s : Subgroup α)
/-- The equivalence relation corresponding to the partition of a group by left cosets
of a subgroup. -/
@[to_additive /-- The equivalence relation corresponding to the partition of a group by left cosets
of a subgroup. -/]
def leftRel : Setoid α :=
MulAction.orbitRel s.op α
variable {s} in
@[to_additive]
theorem leftRel_apply {x y : α} : leftRel s x y ↔ x⁻¹ * y ∈ s :=
calc
(∃ a : s.op, y * MulOpposite.unop a = x) ↔ ∃ a : s, y * a = x :=
s.equivOp.symm.exists_congr_left
_ ↔ ∃ a : s, x⁻¹ * y = a⁻¹ := by
simp only [inv_mul_eq_iff_eq_mul, Subgroup.coe_inv, eq_mul_inv_iff_mul_eq]
_ ↔ x⁻¹ * y ∈ s := by simp [exists_inv_mem_iff_exists_mem]
@[to_additive]
theorem leftRel_eq : ⇑(leftRel s) = fun x y => x⁻¹ * y ∈ s :=
funext₂ <| by
simp only [eq_iff_iff]
apply leftRel_apply
@[to_additive]
instance leftRelDecidable [DecidablePred (· ∈ s)] : DecidableRel (leftRel s).r := fun x y => by
rw [leftRel_eq]
exact ‹DecidablePred (· ∈ s)› _
/-- `α ⧸ s` is the quotient type representing the left cosets of `s`. If `s` is a normal subgroup,
`α ⧸ s` is a group -/
@[to_additive /-- `α ⧸ s` is the quotient type representing the left cosets of `s`. If `s` is a
normal subgroup, `α ⧸ s` is a group -/]
instance instHasQuotientSubgroup : HasQuotient α (Subgroup α) :=
⟨fun s => Quotient (leftRel s)⟩
@[to_additive]
instance [DecidablePred (· ∈ s)] : DecidableEq (α ⧸ s) :=
@Quotient.decidableEq _ _ (leftRelDecidable _)
/-- The equivalence relation corresponding to the partition of a group by right cosets of a
subgroup. -/
@[to_additive /-- The equivalence relation corresponding to the partition of a group by right cosets
of a subgroup. -/]
def rightRel : Setoid α :=
MulAction.orbitRel s α
variable {s} in
@[to_additive]
theorem rightRel_apply {x y : α} : rightRel s x y ↔ y * x⁻¹ ∈ s :=
calc
(∃ a : s, (a : α) * y = x) ↔ ∃ a : s, y * x⁻¹ = a⁻¹ := by
simp only [mul_inv_eq_iff_eq_mul, Subgroup.coe_inv, eq_inv_mul_iff_mul_eq]
_ ↔ y * x⁻¹ ∈ s := by simp [exists_inv_mem_iff_exists_mem]
@[to_additive]
theorem rightRel_eq : ⇑(rightRel s) = fun x y => y * x⁻¹ ∈ s :=
funext₂ <| by
simp only [eq_iff_iff]
apply rightRel_apply
@[to_additive]
instance rightRelDecidable [DecidablePred (· ∈ s)] : DecidableRel (rightRel s).r := fun x y => by
rw [rightRel_eq]
exact ‹DecidablePred (· ∈ s)› _
/-- Right cosets are in bijection with left cosets. -/
@[to_additive /-- Right cosets are in bijection with left cosets. -/]
def quotientRightRelEquivQuotientLeftRel : Quotient (QuotientGroup.rightRel s) ≃ α ⧸ s where
toFun :=
Quotient.map' (fun g => g⁻¹) fun a b => by
rw [leftRel_apply, rightRel_apply]
exact fun h => (congr_arg (· ∈ s) (by simp)).mp (s.inv_mem h)
invFun :=
Quotient.map' (fun g => g⁻¹) fun a b => by
rw [leftRel_apply, rightRel_apply]
exact fun h => (congr_arg (· ∈ s) (by simp)).mp (s.inv_mem h)
left_inv g :=
Quotient.inductionOn' g fun g =>
Quotient.sound'
(by
simp only [inv_inv]
exact Quotient.exact' rfl)
right_inv g :=
Quotient.inductionOn' g fun g =>
Quotient.sound'
(by
simp only [inv_inv]
exact Quotient.exact' rfl)
end QuotientGroup
namespace QuotientGroup
variable [Group α] {s : Subgroup α}
/-- The canonical map from a group `α` to the quotient `α ⧸ s`. -/
@[to_additive (attr := coe)
/-- The canonical map from an `AddGroup` `α` to the quotient `α ⧸ s`. -/]
abbrev mk (a : α) : α ⧸ s :=
Quotient.mk'' a
@[to_additive]
theorem mk_surjective : Function.Surjective <| @mk _ _ s :=
Quotient.mk''_surjective
@[to_additive (attr := simp)]
lemma range_mk : range (QuotientGroup.mk (s := s)) = univ := range_eq_univ.mpr mk_surjective
@[to_additive (attr := elab_as_elim)]
theorem induction_on {C : α ⧸ s → Prop} (x : α ⧸ s) (H : ∀ z, C (QuotientGroup.mk z)) : C x :=
Quotient.inductionOn' x H
@[to_additive]
instance : Coe α (α ⧸ s) :=
⟨mk⟩
@[to_additive] alias induction_on' := induction_on
@[to_additive (attr := simp)]
theorem quotient_liftOn_mk {β} (f : α → β) (h) (x : α) : Quotient.liftOn' (x : α ⧸ s) f h = f x :=
rfl
@[to_additive]
theorem forall_mk {C : α ⧸ s → Prop} : (∀ x : α ⧸ s, C x) ↔ ∀ x : α, C x :=
mk_surjective.forall
@[to_additive]
theorem exists_mk {C : α ⧸ s → Prop} : (∃ x : α ⧸ s, C x) ↔ ∃ x : α, C x :=
mk_surjective.exists
@[to_additive]
instance (s : Subgroup α) : Inhabited (α ⧸ s) :=
⟨((1 : α) : α ⧸ s)⟩
@[to_additive]
protected theorem eq {a b : α} : (a : α ⧸ s) = b ↔ a⁻¹ * b ∈ s :=
calc
_ ↔ leftRel s a b := Quotient.eq''
_ ↔ _ := by rw [leftRel_apply]
@[to_additive]
theorem out_eq' (a : α ⧸ s) : mk a.out = a :=
Quotient.out_eq' a
variable (s)
/- It can be useful to write `obtain ⟨h, H⟩ := mk_out_eq_mul ...`, and then `rw [H]` or
`simp_rw [H]` or `simp only [H]`. In order for `simp_rw` and `simp only` to work, this lemma is
stated in terms of an arbitrary `h : s`, rather than the specific `h = g⁻¹ * (mk g).out`. -/
@[to_additive QuotientAddGroup.mk_out_eq_mul]
theorem mk_out_eq_mul (g : α) : ∃ h : s, (mk g : α ⧸ s).out = g * h :=
⟨⟨g⁻¹ * (mk g).out, QuotientGroup.eq.mp (mk g).out_eq'.symm⟩, by rw [mul_inv_cancel_left]⟩
variable {s} {a b : α}
@[to_additive (attr := simp)]
theorem mk_mul_of_mem (a : α) (hb : b ∈ s) : (mk (a * b) : α ⧸ s) = mk a := by
rwa [QuotientGroup.eq, mul_inv_rev, inv_mul_cancel_right, s.inv_mem_iff]
@[to_additive]
theorem preimage_image_mk (N : Subgroup α) (s : Set α) :
mk ⁻¹' ((mk : α → α ⧸ N) '' s) = ⋃ x : N, (· * (x : α)) ⁻¹' s := by
ext x
simp only [QuotientGroup.eq, SetLike.exists, exists_prop, Set.mem_preimage, Set.mem_iUnion,
Set.mem_image]
exact
⟨fun ⟨y, hs, hN⟩ => ⟨_, N.inv_mem hN, by simpa using hs⟩, fun ⟨z, hz, hxz⟩ =>
⟨x * z, hxz, by simpa using hz⟩⟩
@[to_additive]
theorem preimage_image_mk_eq_iUnion_image (N : Subgroup α) (s : Set α) :
mk ⁻¹' ((mk : α → α ⧸ N) '' s) = ⋃ x : N, (· * (x : α)) '' s := by
rw [preimage_image_mk, iUnion_congr_of_surjective (·⁻¹) inv_surjective]
exact fun x ↦ image_mul_right'
@[to_additive]
theorem preimage_image_mk_eq_mul (N : Subgroup α) (s : Set α) :
mk ⁻¹' ((mk : α → α ⧸ N) '' s) = s * N := by
rw [preimage_image_mk_eq_iUnion_image, iUnion_subtype, ← image2_mul, ← iUnion_image_right]
simp only [SetLike.mem_coe]
@[to_additive]
theorem preimage_mk_one (N : Subgroup α) :
mk ⁻¹' {(mk : α → α ⧸ N) 1} = N := by
rw [← image_singleton, preimage_image_mk_eq_mul]
simp
end QuotientGroup
namespace Subgroup
open QuotientGroup
variable [Group α] {s : Subgroup α}
variable {t : Subgroup α}
/-- If two subgroups `M` and `N` of `G` are equal, their quotients are in bijection. -/
@[to_additive
/-- If two subgroups `M` and `N` of `G` are equal, their quotients are in bijection. -/]
def quotientEquivOfEq (h : s = t) : α ⧸ s ≃ α ⧸ t where
toFun := Quotient.map' id fun _a _b h' => h ▸ h'
invFun := Quotient.map' id fun _a _b h' => h.symm ▸ h'
left_inv q := induction_on q fun _g => rfl
right_inv q := induction_on q fun _g => rfl
theorem quotientEquivOfEq_mk (h : s = t) (a : α) :
quotientEquivOfEq h (QuotientGroup.mk a) = QuotientGroup.mk a :=
rfl
end Subgroup |
.lake/packages/mathlib/Mathlib/GroupTheory/Commutator/Finite.lean | import Mathlib.Algebra.Group.Subgroup.Finite
import Mathlib.GroupTheory.Commutator.Basic
import Mathlib.GroupTheory.Rank
import Mathlib.GroupTheory.Index
/-!
The commutator of a finite direct product is contained in the direct product of the commutators.
-/
variable {G : Type*} [Group G]
namespace Subgroup
/-- The commutator of a finite direct product is contained in the direct product of the commutators.
-/
theorem commutator_pi_pi_of_finite {η : Type*} [Finite η] {Gs : η → Type*} [∀ i, Group (Gs i)]
(H K : ∀ i, Subgroup (Gs i)) : ⁅Subgroup.pi Set.univ H, Subgroup.pi Set.univ K⁆ =
Subgroup.pi Set.univ fun i => ⁅H i, K i⁆ := by
classical
apply le_antisymm (commutator_pi_pi_le H K)
rw [pi_le_iff]
intro i hi
rw [map_commutator]
apply commutator_mono <;>
· rw [le_pi_iff]
intro j _hj
rintro _ ⟨x, hx, rfl⟩
by_cases h : j = i
· subst h
simpa using hx
· simp [h, one_mem]
variable [Finite (commutatorSet G)]
instance : Group.FG (_root_.commutator G) := by
rw [commutator_eq_closure]; apply Group.closure_finite_fg
variable (G) in
lemma rank_commutator_le_card : Group.rank (_root_.commutator G) ≤ Nat.card (commutatorSet G) := by
rw [Subgroup.rank_congr (commutator_eq_closure G)]
apply Subgroup.rank_closure_finite_le_nat_card
variable [Group.FG G]
instance finiteIndex_center : FiniteIndex (center G) := by
obtain ⟨S, -, hS⟩ := Group.rank_spec G
exact ⟨mt (Finite.card_eq_zero_of_embedding (quotientCenterEmbedding hS)) Finite.card_pos.ne'⟩
variable (G) in
lemma index_center_le_pow : (center G).index ≤ Nat.card (commutatorSet G) ^ Group.rank G := by
obtain ⟨S, hS1, hS2⟩ := Group.rank_spec G
rw [← hS1, ← Fintype.card_coe, ← Nat.card_eq_fintype_card, ← Finset.coe_sort_coe, ← Nat.card_fun]
exact Finite.card_le_of_embedding (quotientCenterEmbedding hS2)
end Subgroup
section commutatorRepresentatives
open Subgroup
lemma card_commutatorSet_closureCommutatorRepresentatives :
Nat.card (commutatorSet (closureCommutatorRepresentatives G)) = Nat.card (commutatorSet G) := by
rw [← image_commutatorSet_closureCommutatorRepresentatives G]
exact Nat.card_congr (Equiv.Set.image _ _ (subtype_injective _))
lemma card_commutator_closureCommutatorRepresentatives :
Nat.card (commutator (closureCommutatorRepresentatives G)) = Nat.card (commutator G) := by
rw [commutator_eq_closure G, ← image_commutatorSet_closureCommutatorRepresentatives, ←
MonoidHom.map_closure, ← commutator_eq_closure]
exact Nat.card_congr (Equiv.Set.image _ _ (subtype_injective _))
variable [Finite (commutatorSet G)]
instance : Finite (commutatorRepresentatives G) := Set.finite_coe_iff.mpr (Set.finite_range _)
instance closureCommutatorRepresentatives_fg : Group.FG (closureCommutatorRepresentatives G) :=
Group.closure_finite_fg _
variable (G) in
lemma rank_closureCommutatorRepresentatives_le :
Group.rank (closureCommutatorRepresentatives G) ≤ 2 * Nat.card (commutatorSet G) := by
rw [two_mul]
exact
(Subgroup.rank_closure_finite_le_nat_card _).trans
((Set.card_union_le _ _).trans
(add_le_add ((Finite.card_image_le _).trans (Finite.card_range_le _))
((Finite.card_image_le _).trans (Finite.card_range_le _))))
instance : Finite (commutatorSet (closureCommutatorRepresentatives G)) := by
apply Nat.finite_of_card_ne_zero
rw [card_commutatorSet_closureCommutatorRepresentatives]
exact Finite.card_pos.ne'
end commutatorRepresentatives |
.lake/packages/mathlib/Mathlib/GroupTheory/Commutator/Basic.lean | import Mathlib.Algebra.Group.Commutator
import Mathlib.GroupTheory.Subgroup.Centralizer
import Mathlib.GroupTheory.QuotientGroup.Defs
/-!
# Commutators of Subgroups
If `G` is a group and `H₁ H₂ : Subgroup G` then the commutator `⁅H₁, H₂⁆ : Subgroup G`
is the subgroup of `G` generated by the commutators `h₁ * h₂ * h₁⁻¹ * h₂⁻¹`.
## Main definitions
* `⁅g₁, g₂⁆` : the commutator of the elements `g₁` and `g₂`
(defined by `commutatorElement` elsewhere).
* `⁅H₁, H₂⁆` : the commutator of the subgroups `H₁` and `H₂`.
* `commutator`: defines the commutator of a group `G` as a subgroup of `G`.
-/
assert_not_exists Cardinal Multiset Ring
variable {G G' F : Type*} [Group G] [Group G'] [FunLike F G G'] [MonoidHomClass F G G']
variable (f : F) {g₁ g₂ g₃ g : G}
theorem commutatorElement_eq_one_iff_mul_comm : ⁅g₁, g₂⁆ = 1 ↔ g₁ * g₂ = g₂ * g₁ := by
rw [commutatorElement_def, mul_inv_eq_one, mul_inv_eq_iff_eq_mul]
theorem commutatorElement_eq_one_iff_commute : ⁅g₁, g₂⁆ = 1 ↔ Commute g₁ g₂ :=
commutatorElement_eq_one_iff_mul_comm
theorem Commute.commutator_eq (h : Commute g₁ g₂) : ⁅g₁, g₂⁆ = 1 :=
commutatorElement_eq_one_iff_commute.mpr h
variable (g₁ g₂ g₃ g)
@[simp]
theorem commutatorElement_one_right : ⁅g, (1 : G)⁆ = 1 :=
(Commute.one_right g).commutator_eq
@[simp]
theorem commutatorElement_one_left : ⁅(1 : G), g⁆ = 1 :=
(Commute.one_left g).commutator_eq
@[simp]
theorem commutatorElement_self : ⁅g, g⁆ = 1 :=
(Commute.refl g).commutator_eq
@[simp]
theorem commutatorElement_inv : ⁅g₁, g₂⁆⁻¹ = ⁅g₂, g₁⁆ := by
simp_rw [commutatorElement_def, mul_inv_rev, inv_inv, mul_assoc]
theorem map_commutatorElement : (f ⁅g₁, g₂⁆ : G') = ⁅f g₁, f g₂⁆ := by
simp_rw [commutatorElement_def, map_mul f, map_inv f]
theorem conjugate_commutatorElement : g₃ * ⁅g₁, g₂⁆ * g₃⁻¹ = ⁅g₃ * g₁ * g₃⁻¹, g₃ * g₂ * g₃⁻¹⁆ :=
map_commutatorElement (MulAut.conj g₃).toMonoidHom g₁ g₂
namespace Subgroup
/-- The commutator of two subgroups `H₁` and `H₂`. -/
instance commutator : Bracket (Subgroup G) (Subgroup G) :=
⟨fun H₁ H₂ => closure { g | ∃ g₁ ∈ H₁, ∃ g₂ ∈ H₂, ⁅g₁, g₂⁆ = g }⟩
theorem commutator_def (H₁ H₂ : Subgroup G) :
⁅H₁, H₂⁆ = closure { g | ∃ g₁ ∈ H₁, ∃ g₂ ∈ H₂, ⁅g₁, g₂⁆ = g } :=
rfl
variable {g₁ g₂ g₃} {H₁ H₂ H₃ K₁ K₂ : Subgroup G}
theorem commutator_mem_commutator (h₁ : g₁ ∈ H₁) (h₂ : g₂ ∈ H₂) : ⁅g₁, g₂⁆ ∈ ⁅H₁, H₂⁆ :=
subset_closure ⟨g₁, h₁, g₂, h₂, rfl⟩
theorem commutator_le : ⁅H₁, H₂⁆ ≤ H₃ ↔ ∀ g₁ ∈ H₁, ∀ g₂ ∈ H₂, ⁅g₁, g₂⁆ ∈ H₃ :=
H₃.closure_le.trans
⟨fun h a b c d => h ⟨a, b, c, d, rfl⟩, fun h _g ⟨a, b, c, d, h_eq⟩ => h_eq ▸ h a b c d⟩
theorem commutator_mono (h₁ : H₁ ≤ K₁) (h₂ : H₂ ≤ K₂) : ⁅H₁, H₂⁆ ≤ ⁅K₁, K₂⁆ :=
commutator_le.mpr fun _g₁ hg₁ _g₂ hg₂ => commutator_mem_commutator (h₁ hg₁) (h₂ hg₂)
theorem commutator_eq_bot_iff_le_centralizer : ⁅H₁, H₂⁆ = ⊥ ↔ H₁ ≤ centralizer H₂ := by
rw [eq_bot_iff, commutator_le]
refine forall_congr' fun p =>
forall_congr' fun _hp => forall_congr' fun q => forall_congr' fun hq => ?_
rw [mem_bot, commutatorElement_eq_one_iff_mul_comm, eq_comm]
/-- **The Three Subgroups Lemma** (via the Hall-Witt identity) -/
theorem commutator_commutator_eq_bot_of_rotate (h1 : ⁅⁅H₂, H₃⁆, H₁⁆ = ⊥) (h2 : ⁅⁅H₃, H₁⁆, H₂⁆ = ⊥) :
⁅⁅H₁, H₂⁆, H₃⁆ = ⊥ := by
simp_rw [commutator_eq_bot_iff_le_centralizer, commutator_le,
mem_centralizer_iff_commutator_eq_one, ← commutatorElement_def] at h1 h2 ⊢
intro x hx y hy z hz
trans x * z * ⁅y, ⁅z⁻¹, x⁻¹⁆⁆⁻¹ * z⁻¹ * y * ⁅x⁻¹, ⁅y⁻¹, z⁆⁆⁻¹ * y⁻¹ * x⁻¹
-- We avoid `group` here to minimize imports while low in the hierarchy;
-- typically it would be better to invoke the tactic.
· simp [commutatorElement_def, mul_assoc]
· rw [h1 _ (H₂.inv_mem hy) _ hz _ (H₁.inv_mem hx), h2 _ (H₃.inv_mem hz) _ (H₁.inv_mem hx) _ hy]
simp [mul_assoc]
variable (H₁ H₂)
theorem commutator_comm_le : ⁅H₁, H₂⁆ ≤ ⁅H₂, H₁⁆ :=
commutator_le.mpr fun g₁ h₁ g₂ h₂ =>
commutatorElement_inv g₂ g₁ ▸ ⁅H₂, H₁⁆.inv_mem_iff.mpr (commutator_mem_commutator h₂ h₁)
theorem commutator_comm : ⁅H₁, H₂⁆ = ⁅H₂, H₁⁆ :=
le_antisymm (commutator_comm_le H₁ H₂) (commutator_comm_le H₂ H₁)
section Normal
instance commutator_normal [h₁ : H₁.Normal] [h₂ : H₂.Normal] : Normal ⁅H₁, H₂⁆ := by
let base : Set G := { x | ∃ g₁ ∈ H₁, ∃ g₂ ∈ H₂, ⁅g₁, g₂⁆ = x }
change (closure base).Normal
suffices h_base : base = Group.conjugatesOfSet base by
rw [h_base]
exact Subgroup.normalClosure_normal
refine Set.Subset.antisymm Group.subset_conjugatesOfSet fun a h => ?_
simp_rw [Group.mem_conjugatesOfSet_iff, isConj_iff] at h
rcases h with ⟨b, ⟨c, hc, e, he, rfl⟩, d, rfl⟩
exact ⟨_, h₁.conj_mem c hc d, _, h₂.conj_mem e he d, (conjugate_commutatorElement c e d).symm⟩
theorem commutator_def' [H₁.Normal] [H₂.Normal] :
⁅H₁, H₂⁆ = normalClosure { g | ∃ g₁ ∈ H₁, ∃ g₂ ∈ H₂, ⁅g₁, g₂⁆ = g } :=
le_antisymm closure_le_normalClosure (normalClosure_le_normal subset_closure)
theorem commutator_le_right [h : H₂.Normal] : ⁅H₁, H₂⁆ ≤ H₂ :=
commutator_le.mpr fun g₁ _h₁ g₂ h₂ => H₂.mul_mem (h.conj_mem g₂ h₂ g₁) (H₂.inv_mem h₂)
theorem commutator_le_left [H₁.Normal] : ⁅H₁, H₂⁆ ≤ H₁ :=
commutator_comm H₂ H₁ ▸ commutator_le_right H₂ H₁
@[simp]
theorem commutator_bot_left : ⁅(⊥ : Subgroup G), H₁⁆ = ⊥ :=
le_bot_iff.mp (commutator_le_left ⊥ H₁)
@[simp]
theorem commutator_bot_right : ⁅H₁, ⊥⁆ = (⊥ : Subgroup G) :=
le_bot_iff.mp (commutator_le_right H₁ ⊥)
theorem commutator_le_inf [Normal H₁] [Normal H₂] : ⁅H₁, H₂⁆ ≤ H₁ ⊓ H₂ :=
le_inf (commutator_le_left H₁ H₂) (commutator_le_right H₁ H₂)
end Normal
theorem map_commutator (f : G →* G') : map f ⁅H₁, H₂⁆ = ⁅map f H₁, map f H₂⁆ := by
simp_rw [le_antisymm_iff, map_le_iff_le_comap, commutator_le, mem_comap, map_commutatorElement]
constructor
· intro p hp q hq
exact commutator_mem_commutator (mem_map_of_mem _ hp) (mem_map_of_mem _ hq)
· rintro _ ⟨p, hp, rfl⟩ _ ⟨q, hq, rfl⟩
rw [← map_commutatorElement]
exact mem_map_of_mem _ (commutator_mem_commutator hp hq)
variable {H₁ H₂}
theorem commutator_le_map_commutator {f : G →* G'} {K₁ K₂ : Subgroup G'} (h₁ : K₁ ≤ H₁.map f)
(h₂ : K₂ ≤ H₂.map f) : ⁅K₁, K₂⁆ ≤ ⁅H₁, H₂⁆.map f :=
(commutator_mono h₁ h₂).trans (ge_of_eq (map_commutator H₁ H₂ f))
variable (H₁ H₂)
instance commutator_characteristic [h₁ : Characteristic H₁] [h₂ : Characteristic H₂] :
Characteristic ⁅H₁, H₂⁆ :=
characteristic_iff_le_map.mpr fun ϕ =>
commutator_le_map_commutator (characteristic_iff_le_map.mp h₁ ϕ)
(characteristic_iff_le_map.mp h₂ ϕ)
theorem commutator_prod_prod (K₁ K₂ : Subgroup G') :
⁅H₁.prod K₁, H₂.prod K₂⁆ = ⁅H₁, H₂⁆.prod ⁅K₁, K₂⁆ := by
apply le_antisymm
· rw [commutator_le]
rintro ⟨p₁, p₂⟩ ⟨hp₁, hp₂⟩ ⟨q₁, q₂⟩ ⟨hq₁, hq₂⟩
exact ⟨commutator_mem_commutator hp₁ hq₁, commutator_mem_commutator hp₂ hq₂⟩
· rw [prod_le_iff]
constructor <;>
· rw [map_commutator]
apply commutator_mono <;>
simp [le_prod_iff, map_map, MonoidHom.fst_comp_inl, MonoidHom.snd_comp_inl,
MonoidHom.fst_comp_inr, MonoidHom.snd_comp_inr]
/-- The commutator of direct product is contained in the direct product of the commutators.
See `commutator_pi_pi_of_finite` for equality given `Fintype η`.
-/
theorem commutator_pi_pi_le {η : Type*} {Gs : η → Type*} [∀ i, Group (Gs i)]
(H K : ∀ i, Subgroup (Gs i)) :
⁅Subgroup.pi Set.univ H, Subgroup.pi Set.univ K⁆ ≤ Subgroup.pi Set.univ fun i => ⁅H i, K i⁆ :=
commutator_le.mpr fun _p hp _q hq i hi => commutator_mem_commutator (hp i hi) (hq i hi)
end Subgroup
open Subgroup hiding commutator
variable (G)
/-- The set of commutator elements `⁅g₁, g₂⁆` in `G`. -/
def commutatorSet : Set G :=
{ g | ∃ g₁ g₂ : G, ⁅g₁, g₂⁆ = g }
theorem commutatorSet_def : commutatorSet G = { g | ∃ g₁ g₂ : G, ⁅g₁, g₂⁆ = g } :=
rfl
theorem one_mem_commutatorSet : (1 : G) ∈ commutatorSet G :=
⟨1, 1, commutatorElement_self 1⟩
instance : Nonempty (commutatorSet G) :=
⟨⟨1, one_mem_commutatorSet G⟩⟩
variable {G g}
theorem mem_commutatorSet_iff : g ∈ commutatorSet G ↔ ∃ g₁ g₂ : G, ⁅g₁, g₂⁆ = g :=
Iff.rfl
theorem commutator_mem_commutatorSet : ⁅g₁, g₂⁆ ∈ commutatorSet G :=
⟨g₁, g₂, rfl⟩
variable (G)
/-- The commutator subgroup of a group G is the normal subgroup
generated by the commutators [p,q]=`p*q*p⁻¹*q⁻¹`. -/
def commutator : Subgroup G := ⁅(⊤ : Subgroup G), ⊤⁆
deriving Subgroup.Normal, Subgroup.Characteristic
lemma commutator_def : commutator G = ⁅(⊤ : Subgroup G), ⊤⁆ :=
rfl
lemma commutator_eq_closure : commutator G = Subgroup.closure (commutatorSet G) := by
simp [commutator, Subgroup.commutator_def, commutatorSet]
lemma commutator_eq_normalClosure : commutator G = Subgroup.normalClosure (commutatorSet G) := by
simp [commutator, Subgroup.commutator_def', commutatorSet]
variable {G} in
lemma Subgroup.map_subtype_commutator (H : Subgroup G) :
(_root_.commutator H).map H.subtype = ⁅H, H⁆ := by
rw [_root_.commutator_def, map_commutator, ← MonoidHom.range_eq_map, H.range_subtype]
variable {G} in
lemma Subgroup.commutator_le_self (H : Subgroup G) : ⁅H, H⁆ ≤ H :=
H.map_subtype_commutator.symm.trans_le (map_subtype_le _)
theorem commutator_eq_bot_iff_center_eq_top : commutator G = ⊥ ↔ Subgroup.center G = ⊤ := by
simp [commutator, Subgroup.commutator_eq_bot_iff_le_centralizer]
lemma commutator_centralizer_commutator_le_center :
⁅centralizer (commutator G : Set G), centralizer (commutator G)⁆ ≤ Subgroup.center G := by
rw [← Subgroup.centralizer_univ, ← Subgroup.coe_top, ←
Subgroup.commutator_eq_bot_iff_le_centralizer]
suffices ⁅⁅⊤, centralizer (commutator G : Set G)⁆, centralizer (commutator G : Set G)⁆ = ⊥ by
refine Subgroup.commutator_commutator_eq_bot_of_rotate ?_ this
rwa [Subgroup.commutator_comm (centralizer (commutator G : Set G))]
rw [Subgroup.commutator_comm, Subgroup.commutator_eq_bot_iff_le_centralizer]
exact Set.centralizer_subset (Subgroup.commutator_mono le_top le_top)
/-- If g is conjugate to g ^ 2, then g is a commutator -/
lemma mem_commutatorSet_of_isConj_sq {g : G} (hg : IsConj g (g ^ 2)) : g ∈ commutatorSet G := by
obtain ⟨h, hg⟩ := hg
use h, g
rw [commutatorElement_def, hg]
simp only [IsUnit.mul_inv_cancel_right, Units.isUnit, mul_inv_eq_iff_eq_mul, pow_two]
lemma map_commutator_eq {H : Type*} [Group H] (f : G →* H) :
(commutator G).map f = ⁅f.range, f.range⁆ := by
rw [_root_.commutator_def, Subgroup.map_commutator]
apply congr_arg₂ <;>
· rw [Subgroup.map_eq_range_iff]
rw [codisjoint_iff, top_sup_eq]
section commutatorRepresentatives
open Subgroup
/-- Representatives `(g₁, g₂) : G × G` of commutators `⁅g₁, g₂⁆ ∈ G`. -/
def commutatorRepresentatives : Set (G × G) :=
Set.range fun g : commutatorSet G => (g.2.choose, g.2.choose_spec.choose)
/-- Subgroup generated by representatives `g₁ g₂ : G` of commutators `⁅g₁, g₂⁆ ∈ G`. -/
def closureCommutatorRepresentatives : Subgroup G :=
closure (Prod.fst '' commutatorRepresentatives G ∪ Prod.snd '' commutatorRepresentatives G)
lemma image_commutatorSet_closureCommutatorRepresentatives :
(closureCommutatorRepresentatives G).subtype ''
commutatorSet (closureCommutatorRepresentatives G) =
commutatorSet G := by
apply Set.Subset.antisymm
· rintro - ⟨-, ⟨g₁, g₂, rfl⟩, rfl⟩
exact ⟨g₁, g₂, rfl⟩
· exact fun g hg ↦
⟨_, ⟨⟨_, subset_closure <| .inl ⟨_, ⟨⟨g, hg⟩, rfl⟩, rfl⟩⟩,
⟨_, subset_closure <| .inr ⟨_, ⟨⟨g, hg⟩, rfl⟩, rfl⟩⟩, rfl⟩,
hg.choose_spec.choose_spec⟩
end commutatorRepresentatives
variable {G}
theorem Subgroup.Normal.quotient_commutative_iff_commutator_le {N : Subgroup G} [N.Normal] :
Std.Commutative (· * · : G ⧸ N → _ → _) ↔ _root_.commutator G ≤ N := by
constructor
· intro hcomm
rw [commutator_eq_normalClosure]
rw [← Subgroup.normalClosure_subset_iff]
rintro x ⟨p, q, rfl⟩
rw [SetLike.mem_coe, ← QuotientGroup.eq_one_iff, commutatorElement_def]
simp only [QuotientGroup.mk_mul, QuotientGroup.mk_inv]
simp only [← commutatorElement_def, commutatorElement_eq_one_iff_mul_comm]
apply hcomm.comm
· intro hGN
apply Std.Commutative.mk
rintro x'; obtain ⟨x, rfl⟩ := QuotientGroup.mk'_surjective N x'
intro y'; obtain ⟨y, rfl⟩ := QuotientGroup.mk'_surjective N y'
rw [← commutatorElement_eq_one_iff_mul_comm, ← map_commutatorElement,
QuotientGroup.mk'_apply, QuotientGroup.eq_one_iff]
apply hGN
rw [commutator_eq_closure]
exact Subgroup.subset_closure (commutator_mem_commutatorSet x y)
/-- If `N` is a normal subgroup of `G` and `H` a commutative subgroup such that `H ⊔ N = ⊤`,
then `N` contains `commutator G`. -/
theorem Subgroup.Normal.commutator_le_of_self_sup_commutative_eq_top {N : Subgroup G} [N.Normal]
{H : Subgroup G} (hHN : N ⊔ H = ⊤) (hH : IsMulCommutative H) :
_root_.commutator G ≤ N := by
-- It is enough to prove that Q = G ⧸ N is commutative
rw [← quotient_commutative_iff_commutator_le]
-- Q is a quotient of H
let φ : H →ₙ* G ⧸ N := MonoidHom.comp (QuotientGroup.mk' N) (Subgroup.subtype H)
-- It is enough to prove that φ is surjective
apply Function.Surjective.mul_comm (f := φ) _ hH.is_comm
rw [MulHom.coe_coe, ← MonoidHom.range_eq_top]
-- We have to prove that `MonoidHom.range φ = ⊤`
simp only [MonoidHom.range_eq_map, ← Subgroup.map_map]
have : Subgroup.map (QuotientGroup.mk' N) ⊤ = ⊤ := by
rw [← MonoidHom.range_eq_map, MonoidHom.range_eq_top]
exact QuotientGroup.mk'_surjective N
simp only [← this, Subgroup.map_eq_map_iff, QuotientGroup.ker_mk', sup_comm, ← hHN]
simp [← MonoidHom.range_eq_map] |
.lake/packages/mathlib/Mathlib/GroupTheory/QuotientGroup/Finite.lean | -- This file is to a certain extent based on `quotient_module.lean` by Johannes Hölzl.
import Mathlib.Algebra.Group.Subgroup.Finite
import Mathlib.Data.Finite.Prod
import Mathlib.GroupTheory.QuotientGroup.Basic
/-!
# Deducing finiteness of a group.
-/
open Function QuotientGroup Subgroup
open scoped Pointwise
variable {F G H : Type*} [Group F] [Group G] [Group H] [Fintype F] [Fintype H]
variable (f : F →* G) (g : G →* H)
namespace Group
open scoped Classical in
/-- If `F` and `H` are finite such that `ker(G →* H) ≤ im(F →* G)`, then `G` is finite. -/
@[to_additive
/-- If `F` and `H` are finite such that `ker(G →+ H) ≤ im(F →+ G)`, then `G` is finite. -/]
noncomputable def fintypeOfKerLeRange (h : g.ker ≤ f.range) : Fintype G :=
@Fintype.ofEquiv _ _
(@instFintypeProd _ _ (Fintype.ofInjective _ <| kerLift_injective g) <|
Fintype.ofInjective _ <| inclusion_injective h)
groupEquivQuotientProdSubgroup.symm
/-- If `F` and `H` are finite such that `ker(G →* H) = im(F →* G)`, then `G` is finite. -/
@[to_additive
/-- If `F` and `H` are finite such that `ker(G →+ H) = im(F →+ G)`, then `G` is finite. -/]
noncomputable def fintypeOfKerEqRange (h : g.ker = f.range) : Fintype G :=
fintypeOfKerLeRange _ _ h.le
/-- If `ker(G →* H)` and `H` are finite, then `G` is finite. -/
@[to_additive /-- If `ker(G →+ H)` and `H` are finite, then `G` is finite. -/]
noncomputable def fintypeOfKerOfCodom [Fintype g.ker] : Fintype G :=
fintypeOfKerLeRange ((topEquiv : _ ≃* G).toMonoidHom.comp <| inclusion le_top) g fun x hx =>
⟨⟨x, hx⟩, rfl⟩
/-- If `F` and `coker(F →* G)` are finite, then `G` is finite. -/
@[to_additive /-- If `F` and `coker(F →+ G)` are finite, then `G` is finite. -/]
noncomputable def fintypeOfDomOfCoker [Normal f.range] [Fintype <| G ⧸ f.range] : Fintype G :=
fintypeOfKerLeRange _ (mk' f.range) fun x => (eq_one_iff x).mp
end Group
@[to_additive]
lemma finite_iff_subgroup_quotient (H : Subgroup G) : Finite G ↔ Finite H ∧ Finite (G ⧸ H) := by
rw [(groupEquivQuotientProdSubgroup (s := H)).finite_iff, Prod.finite_iff, and_comm]
@[to_additive]
lemma Finite.of_subgroup_quotient (H : Subgroup G) [Finite H] [Finite (G ⧸ H)] : Finite G := by
rw [finite_iff_subgroup_quotient]; constructor <;> assumption
@[deprecated (since := "2025-11-11")]
alias Finite.of_finite_quot_finite_subgroup := Finite.of_subgroup_quotient
@[deprecated (since := "2025-11-11")]
alias Finite.of_finite_quot_finite_addSubgroup := Finite.of_addSubgroup_quotient |
.lake/packages/mathlib/Mathlib/GroupTheory/QuotientGroup/Basic.lean | -- This file is to a certain extent based on `quotient_module.lean` by Johannes Hölzl.
import Mathlib.Algebra.Group.Subgroup.Pointwise
import Mathlib.Data.Int.Cast.Lemmas
import Mathlib.GroupTheory.Congruence.Hom
import Mathlib.GroupTheory.Coset.Basic
import Mathlib.GroupTheory.QuotientGroup.Defs
import Mathlib.Algebra.BigOperators.Group.Finset.Defs
/-!
# Quotients of groups by normal subgroups
This file develops the basic theory of quotients of groups by normal subgroups. In particular, it
proves Noether's first and second isomorphism theorems.
## Main statements
* `QuotientGroup.quotientKerEquivRange`: Noether's first isomorphism theorem, an explicit
isomorphism `G/ker φ → range φ` for every group homomorphism `φ : G →* H`.
* `QuotientGroup.quotientInfEquivProdNormalizerQuotient`: Noether's second isomorphism
theorem, an explicit isomorphism between `H/(H ∩ N)` and `(HN)/N` given a subgroup `H`
that lies in the normalizer `N_G(N)` of a subgroup `N` of a group `G`.
* `QuotientGroup.quotientQuotientEquivQuotient`: Noether's third isomorphism theorem,
the canonical isomorphism between `(G / N) / (M / N)` and `G / M`, where `N ≤ M`.
* `QuotientGroup.comapMk'OrderIso`: The correspondence theorem, a lattice
isomorphism between the lattice of subgroups of `G ⧸ N` and the sublattice
of subgroups of `G` containing `N`.
## Tags
isomorphism theorems, quotient groups
-/
open Function
open scoped Pointwise
universe u v w x
namespace QuotientGroup
variable {G : Type u} [Group G] (N : Subgroup G) [nN : N.Normal] {H : Type v} [Group H]
{M : Type x} [Monoid M]
open scoped Pointwise in
@[to_additive]
theorem sound (U : Set (G ⧸ N)) (g : N.op) :
g • (mk' N) ⁻¹' U = (mk' N) ⁻¹' U := by
ext x
simp only [Set.mem_preimage, Set.mem_smul_set_iff_inv_smul_mem]
congr! 1
exact Quotient.sound ⟨g⁻¹, rfl⟩
-- for commutative groups we don't need normality assumption
local notation " Q " => G ⧸ N
@[to_additive (attr := simp)]
theorem mk_prod {G ι : Type*} [CommGroup G] (N : Subgroup G) (s : Finset ι) {f : ι → G} :
((Finset.prod s f : G) : G ⧸ N) = Finset.prod s (fun i => (f i : G ⧸ N)) :=
map_prod (QuotientGroup.mk' N) _ _
@[to_additive QuotientAddGroup.strictMono_comap_prod_map]
theorem strictMono_comap_prod_map :
StrictMono fun H : Subgroup G ↦ (H.comap N.subtype, H.map (mk' N)) :=
strictMono_comap_prod_image N
variable (φ : G →* H)
open MonoidHom
/-- The induced map from the quotient by the kernel to the codomain. -/
@[to_additive /-- The induced map from the quotient by the kernel to the codomain. -/]
def kerLift : G ⧸ ker φ →* H :=
lift _ φ fun _g => mem_ker.mp
@[to_additive (attr := simp)]
theorem kerLift_mk (g : G) : (kerLift φ) g = φ g :=
rfl
@[deprecated (since := "2025-10-28")]
alias _root_.QuotientAddGroup.kerLift_mk' := _root_.QuotientAddGroup.kerLift_mk
@[to_additive existing, deprecated (since := "2025-10-28")]
alias kerLift_mk' := kerLift_mk
@[to_additive]
theorem kerLift_injective : Injective (kerLift φ) := fun a b =>
Quotient.inductionOn₂' a b fun a b (h : φ a = φ b) =>
Quotient.sound' <| by rw [leftRel_apply, mem_ker, φ.map_mul, ← h, φ.map_inv, inv_mul_cancel]
-- Note that `ker φ` isn't definitionally `ker (φ.rangeRestrict)`
-- so there is a bit of annoying code duplication here
/-- The induced map from the quotient by the kernel to the range. -/
@[to_additive /-- The induced map from the quotient by the kernel to the range. -/]
def rangeKerLift : G ⧸ ker φ →* φ.range :=
lift _ φ.rangeRestrict fun g hg => mem_ker.mp <| by rwa [ker_rangeRestrict]
@[to_additive]
theorem rangeKerLift_injective : Injective (rangeKerLift φ) := fun a b =>
Quotient.inductionOn₂' a b fun a b (h : φ.rangeRestrict a = φ.rangeRestrict b) =>
Quotient.sound' <| by
rw [leftRel_apply, ← ker_rangeRestrict, mem_ker, φ.rangeRestrict.map_mul, ← h,
φ.rangeRestrict.map_inv, inv_mul_cancel]
@[to_additive]
theorem rangeKerLift_surjective : Surjective (rangeKerLift φ) := by
rintro ⟨_, g, rfl⟩
use mk g
rfl
/-- **Noether's first isomorphism theorem** (a definition): the canonical isomorphism between
`G/(ker φ)` to `range φ`. -/
@[to_additive /-- The first isomorphism theorem (a definition): the canonical isomorphism between
`G/(ker φ)` to `range φ`. -/]
noncomputable def quotientKerEquivRange : G ⧸ ker φ ≃* range φ :=
MulEquiv.ofBijective (rangeKerLift φ) ⟨rangeKerLift_injective φ, rangeKerLift_surjective φ⟩
/-- The canonical isomorphism `G/(ker φ) ≃* H` induced by a homomorphism `φ : G →* H`
with a right inverse `ψ : H → G`. -/
@[to_additive (attr := simps) /-- The canonical isomorphism `G/(ker φ) ≃+ H` induced by a
homomorphism `φ : G →+ H` with a right inverse `ψ : H → G`. -/]
def quotientKerEquivOfRightInverse (ψ : H → G) (hφ : RightInverse ψ φ) : G ⧸ ker φ ≃* H :=
{ kerLift φ with
toFun := kerLift φ
invFun := mk ∘ ψ
left_inv := fun x => kerLift_injective φ (by rw [Function.comp_apply, kerLift_mk, hφ])
right_inv := hφ }
/-- The canonical isomorphism `G/⊥ ≃* G`. -/
@[to_additive (attr := simps!) /-- The canonical isomorphism `G/⊥ ≃+ G`. -/]
def quotientBot : G ⧸ (⊥ : Subgroup G) ≃* G :=
quotientKerEquivOfRightInverse (MonoidHom.id G) id fun _x => rfl
/-- The canonical isomorphism `G/(ker φ) ≃* H` induced by a surjection `φ : G →* H`.
For a `computable` version, see `QuotientGroup.quotientKerEquivOfRightInverse`.
-/
@[to_additive /-- The canonical isomorphism `G/(ker φ) ≃+ H` induced by a surjection `φ : G →+ H`.
For a `computable` version, see `QuotientAddGroup.quotientKerEquivOfRightInverse`. -/]
noncomputable def quotientKerEquivOfSurjective (hφ : Surjective φ) : G ⧸ ker φ ≃* H :=
quotientKerEquivOfRightInverse φ _ hφ.hasRightInverse.choose_spec
/-- If two normal subgroups `M` and `N` of `G` are the same, their quotient groups are
isomorphic. -/
@[to_additive /-- If two normal subgroups `M` and `N` of `G` are the same, their quotient groups are
isomorphic. -/]
def quotientMulEquivOfEq {M N : Subgroup G} [M.Normal] [N.Normal] (h : M = N) : G ⧸ M ≃* G ⧸ N :=
{ Subgroup.quotientEquivOfEq h with
map_mul' := fun q r => Quotient.inductionOn₂' q r fun _g _h => rfl }
@[to_additive (attr := simp)]
theorem quotientMulEquivOfEq_mk {M N : Subgroup G} [M.Normal] [N.Normal] (h : M = N) (x : G) :
QuotientGroup.quotientMulEquivOfEq h (QuotientGroup.mk x) = QuotientGroup.mk x :=
rfl
/-- Let `A', A, B', B` be subgroups of `G`. If `A' ≤ B'` and `A ≤ B`,
then there is a map `A / (A' ⊓ A) →* B / (B' ⊓ B)` induced by the inclusions. -/
@[to_additive /-- Let `A', A, B', B` be subgroups of `G`. If `A' ≤ B'` and `A ≤ B`, then there is a
map `A / (A' ⊓ A) →+ B / (B' ⊓ B)` induced by the inclusions. -/]
def quotientMapSubgroupOfOfLe {A' A B' B : Subgroup G} [_hAN : (A'.subgroupOf A).Normal]
[_hBN : (B'.subgroupOf B).Normal] (h' : A' ≤ B') (h : A ≤ B) :
A ⧸ A'.subgroupOf A →* B ⧸ B'.subgroupOf B :=
map _ _ (Subgroup.inclusion h) <| Subgroup.comap_mono h'
@[to_additive (attr := simp)]
theorem quotientMapSubgroupOfOfLe_mk {A' A B' B : Subgroup G} [_hAN : (A'.subgroupOf A).Normal]
[_hBN : (B'.subgroupOf B).Normal] (h' : A' ≤ B') (h : A ≤ B) (x : A) :
quotientMapSubgroupOfOfLe h' h x = ↑(Subgroup.inclusion h x : B) :=
rfl
/-- Let `A', A, B', B` be subgroups of `G`.
If `A' = B'` and `A = B`, then the quotients `A / (A' ⊓ A)` and `B / (B' ⊓ B)` are isomorphic.
Applying this equiv is nicer than rewriting along the equalities, since the type of
`(A'.subgroupOf A : Subgroup A)` depends on `A`.
-/
@[to_additive /-- Let `A', A, B', B` be subgroups of `G`. If `A' = B'` and `A = B`, then the
quotients `A / (A' ⊓ A)` and `B / (B' ⊓ B)` are isomorphic. Applying this equiv is nicer than
rewriting along the equalities, since the type of `(A'.addSubgroupOf A : AddSubgroup A)` depends on
`A`. -/]
def equivQuotientSubgroupOfOfEq {A' A B' B : Subgroup G} [hAN : (A'.subgroupOf A).Normal]
[hBN : (B'.subgroupOf B).Normal] (h' : A' = B') (h : A = B) :
A ⧸ A'.subgroupOf A ≃* B ⧸ B'.subgroupOf B :=
(quotientMapSubgroupOfOfLe h'.le h.le).toMulEquiv (quotientMapSubgroupOfOfLe h'.ge h.ge)
(by ext ⟨x, hx⟩; rfl)
(by ext ⟨x, hx⟩; rfl)
section ZPow
variable {A B C : Type u} [CommGroup A] [CommGroup B] [CommGroup C]
variable (f : A →* B) (g : B →* A) (e : A ≃* B) (d : B ≃* C) (n : ℤ)
/-- The map of quotients by powers of an integer induced by a group homomorphism. -/
@[to_additive /-- The map of quotients by multiples of an integer induced by an additive group
homomorphism. -/]
def homQuotientZPowOfHom :
A ⧸ (zpowGroupHom n : A →* A).range →* B ⧸ (zpowGroupHom n : B →* B).range :=
lift _ ((mk' _).comp f) fun g ⟨h, (hg : h ^ n = g)⟩ =>
(eq_one_iff _).mpr ⟨f h, by
simp only [← hg, map_zpow, zpowGroupHom_apply]⟩
@[to_additive (attr := simp)]
theorem homQuotientZPowOfHom_id : homQuotientZPowOfHom (MonoidHom.id A) n = MonoidHom.id _ :=
monoidHom_ext _ rfl
@[to_additive (attr := simp)]
theorem homQuotientZPowOfHom_comp :
homQuotientZPowOfHom (f.comp g) n =
(homQuotientZPowOfHom f n).comp (homQuotientZPowOfHom g n) :=
monoidHom_ext _ rfl
@[to_additive (attr := simp)]
theorem homQuotientZPowOfHom_comp_of_rightInverse (i : Function.RightInverse g f) :
(homQuotientZPowOfHom f n).comp (homQuotientZPowOfHom g n) = MonoidHom.id _ :=
monoidHom_ext _ <| MonoidHom.ext fun x => congrArg _ <| i x
/-- The equivalence of quotients by powers of an integer induced by a group isomorphism. -/
@[to_additive /-- The equivalence of quotients by multiples of an integer induced by an additive
group isomorphism. -/]
def equivQuotientZPowOfEquiv :
A ⧸ (zpowGroupHom n : A →* A).range ≃* B ⧸ (zpowGroupHom n : B →* B).range :=
MonoidHom.toMulEquiv _ _
(homQuotientZPowOfHom_comp_of_rightInverse (e.symm : B →* A) (e : A →* B) n e.left_inv)
(homQuotientZPowOfHom_comp_of_rightInverse (e : A →* B) (e.symm : B →* A) n e.right_inv)
-- Porting note: had to explicitly coerce the `MulEquiv`s to `MonoidHom`s
@[to_additive (attr := simp)]
theorem equivQuotientZPowOfEquiv_refl :
MulEquiv.refl (A ⧸ (zpowGroupHom n : A →* A).range) =
equivQuotientZPowOfEquiv (MulEquiv.refl A) n := by
ext x
rw [← Quotient.out_eq' x]
rfl
@[to_additive (attr := simp)]
theorem equivQuotientZPowOfEquiv_symm :
(equivQuotientZPowOfEquiv e n).symm = equivQuotientZPowOfEquiv e.symm n :=
rfl
@[to_additive (attr := simp)]
theorem equivQuotientZPowOfEquiv_trans :
(equivQuotientZPowOfEquiv e n).trans (equivQuotientZPowOfEquiv d n) =
equivQuotientZPowOfEquiv (e.trans d) n := by
ext x
rw [← Quotient.out_eq' x]
rfl
end ZPow
section SndIsomorphismThm
open Subgroup
/-- **Noether's second isomorphism theorem**: given a subgroup `N` of `G` and a
subgroup `H` of the normalizer of `N` in `G`,
defines an isomorphism between `H/(H ∩ N)` and `(HN)/N`. -/
@[to_additive /-- Noether's second isomorphism theorem: given a subgroup `N` of `G` and a
subgroup `H` of the normalizer of `N` in `G`,
defines an isomorphism between `H/(H ∩ N)` and `(H + N)/N` -/]
noncomputable def quotientInfEquivProdNormalizerQuotient (H N : Subgroup G)
(hLE : H ≤ N.normalizer) :
letI := Subgroup.normal_subgroupOf_of_le_normalizer hLE
letI := Subgroup.normal_subgroupOf_sup_of_le_normalizer hLE
H ⧸ N.subgroupOf H ≃* (H ⊔ N : Subgroup G) ⧸ N.subgroupOf (H ⊔ N) :=
letI := Subgroup.normal_subgroupOf_of_le_normalizer hLE
letI := Subgroup.normal_subgroupOf_sup_of_le_normalizer hLE
let
φ :-- φ is the natural homomorphism H →* (HN)/N.
H →*
_ ⧸ N.subgroupOf (H ⊔ N) :=
(mk' <| N.subgroupOf (H ⊔ N)).comp (inclusion le_sup_left)
have φ_surjective : Surjective φ := fun x =>
x.inductionOn' <| by
rintro ⟨y, hy : y ∈ (H ⊔ N)⟩
rw [← SetLike.mem_coe] at hy
rw [coe_mul_of_left_le_normalizer_right H N hLE] at hy
rcases hy with ⟨h, hh, n, hn, rfl⟩
use ⟨h, hh⟩
refine Quotient.eq.mpr ?_
change leftRel _ _ _
rw [leftRel_apply]
change h⁻¹ * (h * n) ∈ N
rwa [← mul_assoc, inv_mul_cancel, one_mul]
(quotientMulEquivOfEq (by simp [φ, ← comap_ker])).trans
(quotientKerEquivOfSurjective φ φ_surjective)
/-- **Noether's second isomorphism theorem**: given two subgroups `H` and `N` of a group `G`,
where `N` is normal, defines an isomorphism between `H/(H ∩ N)` and `(HN)/N`. -/
@[to_additive /-- Noether's second isomorphism theorem: given two subgroups `H` and `N` of a group
`G`, where `N` is normal, defines an isomorphism between `H/(H ∩ N)` and `(H + N)/N`. -/]
noncomputable def quotientInfEquivProdNormalQuotient (H N : Subgroup G) [hN : N.Normal] :
H ⧸ N.subgroupOf H ≃* (H ⊔ N : Subgroup G) ⧸ N.subgroupOf (H ⊔ N) :=
quotientInfEquivProdNormalizerQuotient H N le_normalizer_of_normal
end SndIsomorphismThm
section ThirdIsoThm
variable (M : Subgroup G) [nM : M.Normal]
@[to_additive]
instance map_normal : (M.map (QuotientGroup.mk' N)).Normal :=
nM.map _ mk_surjective
variable (h : N ≤ M)
/-- The map from the third isomorphism theorem for groups: `(G / N) / (M / N) → G / M`. -/
@[to_additive /-- The map from the third isomorphism theorem for additive groups:
`(A / N) / (M / N) → A / M`. -/]
def quotientQuotientEquivQuotientAux : (G ⧸ N) ⧸ M.map (mk' N) →* G ⧸ M :=
lift (M.map (mk' N)) (map N M (MonoidHom.id G) h)
(by
rintro _ ⟨x, hx, rfl⟩
rw [mem_ker, map_mk' N M _ _ x]
exact (QuotientGroup.eq_one_iff _).mpr hx)
@[to_additive (attr := simp)]
theorem quotientQuotientEquivQuotientAux_mk (x : G ⧸ N) :
quotientQuotientEquivQuotientAux N M h x = QuotientGroup.map N M (MonoidHom.id G) h x :=
QuotientGroup.lift_mk' _ _ x
@[to_additive]
theorem quotientQuotientEquivQuotientAux_mk_mk (x : G) :
quotientQuotientEquivQuotientAux N M h (x : G ⧸ N) = x :=
QuotientGroup.lift_mk' (M.map (mk' N)) _ x
/-- **Noether's third isomorphism theorem** for groups: `(G / N) / (M / N) ≃* G / M`. -/
@[to_additive
/-- **Noether's third isomorphism theorem** for additive groups: `(A / N) / (M / N) ≃+ A / M`. -/]
def quotientQuotientEquivQuotient : (G ⧸ N) ⧸ M.map (QuotientGroup.mk' N) ≃* G ⧸ M :=
MonoidHom.toMulEquiv (quotientQuotientEquivQuotientAux N M h)
(QuotientGroup.map _ _ (QuotientGroup.mk' N) (Subgroup.le_comap_map _ _))
(by ext; simp)
(by ext; simp)
end ThirdIsoThm
section CorrespTheorem
-- All these theorems are primed because `QuotientGroup.mk'` is.
set_option linter.docPrime false
@[to_additive]
theorem le_comap_mk' (N : Subgroup G) [N.Normal] (H : Subgroup (G ⧸ N)) :
N ≤ Subgroup.comap (QuotientGroup.mk' N) H := by
simpa using Subgroup.comap_mono (f := mk' N) bot_le
@[to_additive (attr := simp)]
theorem comap_map_mk' (N H : Subgroup G) [N.Normal] :
Subgroup.comap (mk' N) (Subgroup.map (mk' N) H) = N ⊔ H := by
simp [Subgroup.comap_map_eq, sup_comm]
/-- The **correspondence theorem**, or lattice theorem,
or fourth isomorphism theorem for multiplicative groups -/
@[to_additive /-- The **correspondence theorem**, or lattice theorem,
or fourth isomorphism theorem for additive groups -/]
def comapMk'OrderIso (N : Subgroup G) [hn : N.Normal] :
Subgroup (G ⧸ N) ≃o { H : Subgroup G // N ≤ H } where
toFun H' := ⟨Subgroup.comap (mk' N) H', le_comap_mk' N _⟩
invFun H := Subgroup.map (mk' N) H
left_inv H' := Subgroup.map_comap_eq_self <| by simp
right_inv := fun ⟨H, hH⟩ => Subtype.ext <| by simpa
map_rel_iff' := Subgroup.comap_le_comap_of_surjective <| mk'_surjective _
end CorrespTheorem
section trivial
@[to_additive]
theorem subsingleton_quotient_top : Subsingleton (G ⧸ (⊤ : Subgroup G)) := by
dsimp [HasQuotient.Quotient, QuotientGroup.instHasQuotientSubgroup, Quotient]
rw [leftRel_eq]
exact Trunc.instSubsingletonTrunc
/-- If the quotient by a subgroup gives a singleton then the subgroup is the whole group. -/
@[to_additive /-- If the quotient by an additive subgroup gives a singleton then the additive
subgroup is the whole additive group. -/]
theorem subgroup_eq_top_of_subsingleton (H : Subgroup G) (h : Subsingleton (G ⧸ H)) : H = ⊤ :=
top_unique fun x _ => by
have this : 1⁻¹ * x ∈ H := QuotientGroup.eq.1 (Subsingleton.elim _ _)
rwa [inv_one, one_mul] at this
end trivial
@[to_additive]
theorem comap_comap_center {H₁ : Subgroup G} [H₁.Normal] {H₂ : Subgroup (G ⧸ H₁)} [H₂.Normal] :
((Subgroup.center ((G ⧸ H₁) ⧸ H₂)).comap (mk' H₂)).comap (mk' H₁) =
(Subgroup.center (G ⧸ H₂.comap (mk' H₁))).comap (mk' (H₂.comap (mk' H₁))) := by
ext x
simp only [mk'_apply, Subgroup.mem_comap, Subgroup.mem_center_iff, forall_mk, ← mk_mul,
eq_iff_div_mem, mk_div]
end QuotientGroup
namespace QuotientAddGroup
variable {R : Type*} [NonAssocRing R] (N : AddSubgroup R) [N.Normal]
@[simp]
theorem mk_nat_mul (n : ℕ) (a : R) : ((n * a : R) : R ⧸ N) = n • ↑a := by
rw [← nsmul_eq_mul, mk_nsmul N a n]
@[simp]
theorem mk_int_mul (n : ℤ) (a : R) : ((n * a : R) : R ⧸ N) = n • ↑a := by
rw [← zsmul_eq_mul, mk_zsmul N a n]
end QuotientAddGroup |
.lake/packages/mathlib/Mathlib/GroupTheory/QuotientGroup/Defs.lean | -- This file is to a certain extent based on `quotient_module.lean` by Johannes Hölzl.
import Mathlib.Algebra.Group.Subgroup.Ker
import Mathlib.GroupTheory.Congruence.Hom
import Mathlib.GroupTheory.Coset.Defs
/-!
# Quotients of groups by normal subgroups
This file defines the group structure on the quotient by a normal subgroup.
## Main definitions
* `QuotientGroup.Quotient.Group`: the group structure on `G/N` given a normal subgroup `N` of `G`.
* `mk'`: the canonical group homomorphism `G →* G/N` given a normal subgroup `N` of `G`.
* `lift φ`: the group homomorphism `G/N →* H` given a group homomorphism `φ : G →* H` such that
`N ⊆ ker φ`.
* `map f`: the group homomorphism `G/N →* H/M` given a group homomorphism `f : G →* H` such that
`N ⊆ f⁻¹(M)`.
## Tags
quotient groups
-/
open Function
open scoped Pointwise
universe u v w x
namespace QuotientGroup
variable {G : Type u} [Group G] (N : Subgroup G) [nN : N.Normal] {H : Type v} [Group H]
{M : Type x} [Monoid M]
/-- The congruence relation generated by a normal subgroup. -/
@[to_additive /-- The additive congruence relation generated by a normal additive subgroup. -/]
protected def con : Con G where
toSetoid := leftRel N
mul' := fun {a b c d} hab hcd => by
rw [leftRel_eq] at hab hcd ⊢
dsimp only
calc
c⁻¹ * (a⁻¹ * b) * c⁻¹⁻¹ * (c⁻¹ * d) ∈ N := N.mul_mem (nN.conj_mem _ hab _) hcd
_ = (a * c)⁻¹ * (b * d) := by
simp only [mul_inv_rev, mul_assoc, inv_mul_cancel_left]
@[to_additive]
instance Quotient.group : Group (G ⧸ N) :=
(QuotientGroup.con N).group
/--
The congruence relation defined by the kernel of a group homomorphism is equal to its kernel
as a congruence relation.
-/
@[to_additive QuotientAddGroup.con_ker_eq_addConKer
/-- The additive congruence relation defined by the kernel of an additive group homomorphism is
equal to its kernel as an additive congruence relation. -/]
theorem con_ker_eq_conKer (f : G →* M) : QuotientGroup.con f.ker = Con.ker f := by
ext
rw [QuotientGroup.con, Con.rel_mk, Setoid.comm', leftRel_apply, Con.ker_rel, MonoidHom.eq_iff]
/-- The group homomorphism from `G` to `G/N`. -/
@[to_additive /-- The additive group homomorphism from `G` to `G/N`. -/]
def mk' : G →* G ⧸ N :=
MonoidHom.mk' QuotientGroup.mk fun _ _ => rfl
@[to_additive (attr := simp)]
theorem coe_mk' : (mk' N : G → G ⧸ N) = mk :=
rfl
@[to_additive (attr := simp)]
theorem mk'_apply (x : G) : mk' N x = x :=
rfl
@[to_additive]
theorem mk'_surjective : Surjective <| mk' N :=
@mk_surjective _ _ N
@[to_additive]
theorem mk'_eq_mk' {x y : G} : mk' N x = mk' N y ↔ ∃ z ∈ N, x * z = y :=
QuotientGroup.eq.trans <| by
simp only [← _root_.eq_inv_mul_iff_mul_eq, exists_eq_right]
/-- Two `MonoidHom`s from a quotient group are equal if their compositions with
`QuotientGroup.mk'` are equal.
See note [partially-applied ext lemmas]. -/
@[to_additive (attr := ext 1100) /-- Two `AddMonoidHom`s from an additive quotient group are equal
if their compositions with `AddQuotientGroup.mk'` are equal.
See note [partially-applied ext lemmas]. -/]
theorem monoidHom_ext ⦃f g : G ⧸ N →* M⦄ (h : f.comp (mk' N) = g.comp (mk' N)) : f = g :=
MonoidHom.ext fun x => QuotientGroup.induction_on x <| (DFunLike.congr_fun h :)
@[to_additive (attr := simp)]
theorem eq_one_iff {N : Subgroup G} [N.Normal] (x : G) : (x : G ⧸ N) = 1 ↔ x ∈ N := by
refine QuotientGroup.eq.trans ?_
rw [mul_one, Subgroup.inv_mem_iff]
@[to_additive (attr := simp)]
lemma mk'_comp_subtype : (mk' N).comp N.subtype = 1 := by ext; simp
/- Note: `range_mk'` is a lemma about the primed constructor `QuotientGroup.mk'`, not a
modified version of some `range_mk`. -/
set_option linter.docPrime false in
@[to_additive (attr := simp)]
theorem range_mk' : (QuotientGroup.mk' N).range = ⊤ :=
MonoidHom.range_eq_top.mpr (mk'_surjective N)
@[to_additive]
theorem ker_le_range_iff {I : Type w} [MulOneClass I] (f : G →* H) [f.range.Normal] (g : H →* I) :
g.ker ≤ f.range ↔ (mk' f.range).comp g.ker.subtype = 1 :=
⟨fun h => MonoidHom.ext fun ⟨_, hx⟩ => (eq_one_iff _).mpr <| h hx,
fun h x hx => (eq_one_iff _).mp <| by exact DFunLike.congr_fun h ⟨x, hx⟩⟩
@[to_additive (attr := simp)]
theorem ker_mk' : MonoidHom.ker (QuotientGroup.mk' N : G →* G ⧸ N) = N :=
Subgroup.ext eq_one_iff
@[to_additive]
theorem eq_iff_div_mem {N : Subgroup G} [nN : N.Normal] {x y : G} :
(x : G ⧸ N) = y ↔ x / y ∈ N := by
refine eq_comm.trans (QuotientGroup.eq.trans ?_)
rw [nN.mem_comm_iff, div_eq_mul_inv]
-- for commutative groups we don't need normality assumption
@[to_additive]
instance Quotient.commGroup {G : Type*} [CommGroup G] (N : Subgroup G) : CommGroup (G ⧸ N) :=
{ toGroup := have := N.normal_of_comm; QuotientGroup.Quotient.group N
mul_comm := fun a b => Quotient.inductionOn₂' a b fun a b => congr_arg mk (mul_comm a b) }
local notation " Q " => G ⧸ N
@[to_additive (attr := simp)]
theorem mk_one : ((1 : G) : Q) = 1 :=
rfl
@[to_additive (attr := simp)]
theorem mk_mul (a b : G) : ((a * b : G) : Q) = a * b :=
rfl
@[to_additive (attr := simp)]
theorem mk_inv (a : G) : ((a⁻¹ : G) : Q) = (a : Q)⁻¹ :=
rfl
@[to_additive (attr := simp)]
theorem mk_div (a b : G) : ((a / b : G) : Q) = a / b :=
rfl
@[to_additive (attr := simp)]
theorem mk_pow (a : G) (n : ℕ) : ((a ^ n : G) : Q) = (a : Q) ^ n :=
rfl
@[to_additive (attr := simp)]
theorem mk_zpow (a : G) (n : ℤ) : ((a ^ n : G) : Q) = (a : Q) ^ n :=
rfl
@[to_additive (attr := simp)] lemma map_mk'_self : N.map (mk' N) = ⊥ := by aesop
/--
The subgroup defined by the class of `1` for a congruence relation on a group.
-/
@[to_additive
/-- The `AddSubgroup` defined by the class of `0` for an additive congruence relation
on an `AddGroup`. -/]
protected def _root_.Con.subgroup (c : Con G) : Subgroup G where
carrier := { x | c x 1 }
one_mem' := c.refl 1
mul_mem' hx hy := by simpa using c.mul hx hy
inv_mem' h := by simpa using c.inv h
@[to_additive (attr := simp)]
theorem _root_.Con.mem_subgroup_iff {c : Con G} {x : G} :
x ∈ c.subgroup ↔ c x 1 := Iff.rfl
@[to_additive]
instance (c : Con G) : c.subgroup.Normal :=
⟨fun x hx g ↦ by simpa using (c.mul (c.mul (c.refl g) hx) (c.refl g⁻¹))⟩
@[to_additive (attr := simp)]
theorem _root_.Con.subgroup_quotientGroupCon (H : Subgroup G) [H.Normal] :
(QuotientGroup.con H).subgroup = H := by
ext
simp [QuotientGroup.con, leftRel_apply]
@[to_additive (attr := simp)]
theorem con_subgroup (c : Con G) :
QuotientGroup.con c.subgroup = c := by
ext x y
rw [QuotientGroup.con, Con.rel_mk, leftRel_apply, Con.mem_subgroup_iff]
exact ⟨fun h ↦ by simpa using c.mul (c.refl x) (c.symm h),
fun h ↦ by simpa using c.mul (c.refl x⁻¹) (c.symm h)⟩
/--
The normal subgroups correspond to the congruence relations on a group.
-/
@[to_additive (attr := simps) AddSubgroup.orderIsoAddCon
/-- The normal subgroups correspond to the additive congruence relations on an `AddGroup`. -/]
def _root_.Subgroup.orderIsoCon :
{ N : Subgroup G // N.Normal } ≃o Con G where
toFun N := letI : N.val.Normal := N.prop; QuotientGroup.con N
invFun c := ⟨c.subgroup, inferInstance⟩
left_inv := fun ⟨N, _⟩ ↦ Subtype.mk_eq_mk.mpr (Con.subgroup_quotientGroupCon N)
right_inv c := QuotientGroup.con_subgroup c
map_rel_iff' := by
simp only [QuotientGroup.con, Equiv.coe_fn_mk, Con.le_def, Con.rel_mk, leftRel_apply]
refine ⟨fun h x _ ↦ ?_, fun hle _ _ h ↦ hle h⟩
specialize @h 1 x
simp_all
@[to_additive (attr := simp)]
lemma con_le_iff {N M : Subgroup G} [N.Normal] [M.Normal] :
QuotientGroup.con N ≤ QuotientGroup.con M ↔ N ≤ M :=
(Subgroup.orderIsoCon.map_rel_iff (a := ⟨N, inferInstance⟩) (b := ⟨M, inferInstance⟩))
@[to_additive (attr := gcongr)]
lemma con_mono {N M : Subgroup G} [hN : N.Normal] [hM : M.Normal] (h : N ≤ M) :
QuotientGroup.con N ≤ QuotientGroup.con M :=
con_le_iff.mpr h
/-- A group homomorphism `φ : G →* M` with `N ⊆ ker(φ)` descends (i.e. `lift`s) to a
group homomorphism `G/N →* M`. -/
@[to_additive /-- An `AddGroup` homomorphism `φ : G →+ M` with `N ⊆ ker(φ)` descends (i.e. `lift`s)
to a group homomorphism `G/N →* M`. -/]
def lift (φ : G →* M) (HN : N ≤ φ.ker) : Q →* M :=
(QuotientGroup.con N).lift φ <| con_ker_eq_conKer φ ▸ con_mono HN
@[to_additive (attr := simp)]
theorem lift_mk {φ : G →* M} (HN : N ≤ φ.ker) (g : G) : lift N φ HN (g : Q) = φ g :=
rfl
@[to_additive (attr := simp)]
theorem lift_mk' {φ : G →* M} (HN : N ≤ φ.ker) (g : G) : lift N φ HN (mk g : Q) = φ g :=
rfl
-- TODO: replace `mk` with `mk'`)
@[to_additive (attr := simp)]
theorem lift_comp_mk' (φ : G →* M) (HN : N ≤ φ.ker) :
(QuotientGroup.lift N φ HN).comp (QuotientGroup.mk' N) = φ :=
rfl
@[to_additive (attr := simp)]
theorem lift_quot_mk {φ : G →* M} (HN : N ≤ φ.ker) (g : G) :
lift N φ HN (Quot.mk _ g : Q) = φ g :=
rfl
@[to_additive]
theorem lift_surjective_of_surjective (φ : G →* M) (hφ : Function.Surjective φ) (HN : N ≤ φ.ker) :
Function.Surjective (QuotientGroup.lift N φ HN) :=
Quotient.lift_surjective _ _ hφ
@[to_additive]
theorem ker_lift (φ : G →* M) (HN : N ≤ φ.ker) :
(QuotientGroup.lift N φ HN).ker = Subgroup.map (QuotientGroup.mk' N) φ.ker := by
rw [← congrArg MonoidHom.ker (lift_comp_mk' N φ HN), ← MonoidHom.comap_ker,
Subgroup.map_comap_eq_self_of_surjective (mk'_surjective N)]
/-- A group homomorphism `f : G →* H` induces a map `G/N →* H/M` if `N ⊆ f⁻¹(M)`. -/
@[to_additive
/-- An `AddGroup` homomorphism `f : G →+ H` induces a map `G/N →+ H/M` if `N ⊆ f⁻¹(M)`. -/]
def map (M : Subgroup H) [M.Normal] (f : G →* H) (h : N ≤ M.comap f) : G ⧸ N →* H ⧸ M := by
refine QuotientGroup.lift N ((mk' M).comp f) ?_
intro x hx
refine QuotientGroup.eq.2 ?_
rw [mul_one, Subgroup.inv_mem_iff]
exact h hx
@[to_additive (attr := simp)]
theorem map_mk (M : Subgroup H) [M.Normal] (f : G →* H) (h : N ≤ M.comap f) (x : G) :
map N M f h ↑x = ↑(f x) :=
rfl
@[to_additive]
theorem map_mk' (M : Subgroup H) [M.Normal] (f : G →* H) (h : N ≤ M.comap f) (x : G) :
map N M f h (mk' _ x) = ↑(f x) :=
rfl
@[to_additive]
theorem map_surjective_of_surjective (M : Subgroup H) [M.Normal] (f : G →* H)
(hf : Function.Surjective (mk ∘ f : G → H ⧸ M)) (h : N ≤ M.comap f) :
Function.Surjective (map N M f h) :=
lift_surjective_of_surjective _ _ hf _
@[to_additive]
theorem ker_map (M : Subgroup H) [M.Normal] (f : G →* H) (h : N ≤ Subgroup.comap f M) :
(map N M f h).ker = Subgroup.map (mk' N) (M.comap f) := by
simp_rw [← ker_mk' M, MonoidHom.comap_ker]
exact QuotientGroup.ker_lift _ _ _
@[to_additive]
theorem map_id_apply (h : N ≤ Subgroup.comap (MonoidHom.id _) N := (Subgroup.comap_id N).le) (x) :
map N N (MonoidHom.id _) h x = x :=
induction_on x fun _x => rfl
@[to_additive (attr := simp)]
theorem map_id (h : N ≤ Subgroup.comap (MonoidHom.id _) N := (Subgroup.comap_id N).le) :
map N N (MonoidHom.id _) h = MonoidHom.id _ :=
MonoidHom.ext (map_id_apply N h)
@[to_additive (attr := simp)]
theorem map_map {I : Type*} [Group I] (M : Subgroup H) (O : Subgroup I) [M.Normal] [O.Normal]
(f : G →* H) (g : H →* I) (hf : N ≤ Subgroup.comap f M) (hg : M ≤ Subgroup.comap g O)
(hgf : N ≤ Subgroup.comap (g.comp f) O :=
hf.trans ((Subgroup.comap_mono hg).trans_eq (Subgroup.comap_comap _ _ _)))
(x : G ⧸ N) : map M O g hg (map N M f hf x) = map N O (g.comp f) hgf x := by
refine induction_on x fun x => ?_
simp only [map_mk, MonoidHom.comp_apply]
@[to_additive (attr := simp)]
theorem map_comp_map {I : Type*} [Group I] (M : Subgroup H) (O : Subgroup I) [M.Normal] [O.Normal]
(f : G →* H) (g : H →* I) (hf : N ≤ Subgroup.comap f M) (hg : M ≤ Subgroup.comap g O)
(hgf : N ≤ Subgroup.comap (g.comp f) O :=
hf.trans ((Subgroup.comap_mono hg).trans_eq (Subgroup.comap_comap _ _ _))) :
(map M O g hg).comp (map N M f hf) = map N O (g.comp f) hgf :=
MonoidHom.ext (map_map N M O f g hf hg hgf)
section Pointwise
open Set
@[to_additive (attr := simp)] lemma image_coe : ((↑) : G → Q) '' N = 1 :=
congr_arg ((↑) : Subgroup Q → Set Q) <| map_mk'_self N
@[to_additive]
lemma preimage_image_coe (s : Set G) : ((↑) : G → Q) ⁻¹' ((↑) '' s) = N * s := by
ext a
constructor
· rintro ⟨b, hb, h⟩
refine ⟨a / b, (QuotientGroup.eq_one_iff _).1 ?_, b, hb, div_mul_cancel _ _⟩
simp only [h, QuotientGroup.mk_div, div_self']
· rintro ⟨a, ha, b, hb, rfl⟩
refine ⟨b, hb, ?_⟩
simpa only [QuotientGroup.mk_mul, right_eq_mul, QuotientGroup.eq_one_iff]
@[to_additive]
lemma image_coe_inj {s t : Set G} : ((↑) : G → Q) '' s = ((↑) : G → Q) '' t ↔ ↑N * s = N * t := by
simp_rw [← preimage_image_coe]
exact QuotientGroup.mk_surjective.preimage_injective.eq_iff.symm
end Pointwise
section congr
variable (G' : Subgroup G) (H' : Subgroup H) [Subgroup.Normal G'] [Subgroup.Normal H']
/-- `QuotientGroup.congr` lifts the isomorphism `e : G ≃ H` to `G ⧸ G' ≃ H ⧸ H'`,
given that `e` maps `G` to `H`. -/
@[to_additive /-- `QuotientAddGroup.congr` lifts the isomorphism `e : G ≃ H` to `G ⧸ G' ≃ H ⧸ H'`,
given that `e` maps `G` to `H`. -/]
def congr (e : G ≃* H) (he : G'.map e = H') : G ⧸ G' ≃* H ⧸ H' :=
{ map G' H' e (he ▸ G'.le_comap_map (e : G →* H)) with
toFun := map G' H' e (he ▸ G'.le_comap_map (e : G →* H))
invFun := map H' G' e.symm (he ▸ (G'.map_equiv_eq_comap_symm e).le)
left_inv := fun x => by
rw [map_map G' H' G' e e.symm (he ▸ G'.le_comap_map (e : G →* H))
(he ▸ (G'.map_equiv_eq_comap_symm e).le)]
simp only [← MulEquiv.coe_monoidHom_trans, MulEquiv.self_trans_symm,
MulEquiv.coe_monoidHom_refl, map_id_apply]
right_inv := fun x => by
rw [map_map H' G' H' e.symm e (he ▸ (G'.map_equiv_eq_comap_symm e).le)
(he ▸ G'.le_comap_map (e : G →* H)) ]
simp only [← MulEquiv.coe_monoidHom_trans, MulEquiv.symm_trans_self,
MulEquiv.coe_monoidHom_refl, map_id_apply] }
@[simp]
theorem congr_mk (e : G ≃* H) (he : G'.map ↑e = H') (x) : congr G' H' e he (mk x) = e x :=
rfl
theorem congr_mk' (e : G ≃* H) (he : G'.map ↑e = H') (x) :
congr G' H' e he (mk' G' x) = mk' H' (e x) :=
rfl
@[simp]
theorem congr_apply (e : G ≃* H) (he : G'.map ↑e = H') (x : G) :
congr G' H' e he x = mk' H' (e x) :=
rfl
@[simp]
theorem congr_refl (he : G'.map (MulEquiv.refl G : G →* G) = G' := Subgroup.map_id G') :
congr G' G' (MulEquiv.refl G) he = MulEquiv.refl (G ⧸ G') := by
ext ⟨x⟩
rfl
@[simp]
theorem congr_symm (e : G ≃* H) (he : G'.map ↑e = H') :
(congr G' H' e he).symm = congr H' G' e.symm ((Subgroup.map_symm_eq_iff_map_eq _).mpr he) :=
rfl
end congr
end QuotientGroup |
.lake/packages/mathlib/Mathlib/GroupTheory/Perm/Finite.lean | import Mathlib.Data.Finite.Sum
import Mathlib.GroupTheory.OrderOfElement
import Mathlib.GroupTheory.Perm.Support
import Mathlib.Logic.Equiv.Fintype
/-!
# Permutations on `Fintype`s
This file contains miscellaneous lemmas about `Equiv.Perm` and `Equiv.swap`, building on top
of those in `Mathlib/Logic/Equiv/Basic.lean` and other files in `Mathlib/GroupTheory/Perm/*`.
-/
universe u v
open Equiv Function Fintype Finset
variable {α : Type u} {β : Type v}
-- An example on how to determine the order of an element of a finite group.
-- import Mathlib.Data.Int.Order.Units
-- example : orderOf (-1 : ℤˣ) = 2 :=
-- orderOf_eq_prime (Int.units_sq _) (by decide)
namespace Equiv.Perm
section Conjugation
variable [DecidableEq α] [Fintype α] {σ τ : Perm α}
theorem isConj_of_support_equiv
(f : { x // x ∈ (σ.support : Set α) } ≃ { x // x ∈ (τ.support : Set α) })
(hf : ∀ (x : α) (hx : x ∈ (σ.support : Set α)),
(f ⟨σ x, apply_mem_support.2 hx⟩ : α) = τ ↑(f ⟨x, hx⟩)) :
IsConj σ τ := by
refine isConj_iff.2 ⟨Equiv.extendSubtype f, ?_⟩
rw [mul_inv_eq_iff_eq_mul]
ext x
simp only [Perm.mul_apply]
by_cases hx : x ∈ σ.support
· rw [Equiv.extendSubtype_apply_of_mem, Equiv.extendSubtype_apply_of_mem]
· exact hf x (Finset.mem_coe.2 hx)
· rwa [Classical.not_not.1 ((not_congr mem_support).1 (Equiv.extendSubtype_not_mem f _ _)),
Classical.not_not.1 ((not_congr mem_support).mp hx)]
end Conjugation
theorem perm_inv_on_of_perm_on_finset {s : Finset α} {f : Perm α} (h : ∀ x ∈ s, f x ∈ s) {y : α}
(hy : y ∈ s) : f⁻¹ y ∈ s := by
have h0 : ∀ y ∈ s, ∃ (x : _) (hx : x ∈ s), y = (fun i (_ : i ∈ s) => f i) x hx :=
Finset.surj_on_of_inj_on_of_card_le (fun x hx => (fun i _ => f i) x hx) (fun a ha => h a ha)
(fun a₁ a₂ ha₁ ha₂ heq => (Equiv.apply_eq_iff_eq f).mp heq) rfl.ge
obtain ⟨y2, hy2, rfl⟩ := h0 y hy
simpa using hy2
theorem perm_inv_mapsTo_of_mapsTo (f : Perm α) {s : Set α} [Finite s] (h : Set.MapsTo f s s) :
Set.MapsTo (f⁻¹ :) s s := by
cases nonempty_fintype s
exact fun x hx =>
Set.mem_toFinset.mp <|
perm_inv_on_of_perm_on_finset
(fun a ha => Set.mem_toFinset.mpr (h (Set.mem_toFinset.mp ha)))
(Set.mem_toFinset.mpr hx)
@[simp]
theorem perm_inv_mapsTo_iff_mapsTo {f : Perm α} {s : Set α} [Finite s] :
Set.MapsTo (f⁻¹ :) s s ↔ Set.MapsTo f s s :=
⟨perm_inv_mapsTo_of_mapsTo f⁻¹, perm_inv_mapsTo_of_mapsTo f⟩
theorem perm_inv_on_of_perm_on_finite {f : Perm α} {p : α → Prop} [Finite { x // p x }]
(h : ∀ x, p x → p (f x)) {x : α} (hx : p x) : p (f⁻¹ x) := by
have : Finite { x | p x } := by simpa
simpa using perm_inv_mapsTo_of_mapsTo (s := {x | p x}) f h hx
/-- If the permutation `f` maps `{x // p x}` into itself, then this returns the permutation
on `{x // p x}` induced by `f`. Note that the `h` hypothesis is weaker than for
`Equiv.Perm.subtypePerm`. -/
abbrev subtypePermOfFintype (f : Perm α) {p : α → Prop} [Finite { x // p x }]
(h : ∀ x, p x → p (f x)) : Perm { x // p x } :=
f.subtypePerm fun x => ⟨fun h₂ => f.inv_apply_self x ▸ perm_inv_on_of_perm_on_finite h h₂, h x⟩
@[simp]
theorem subtypePermOfFintype_apply (f : Perm α) {p : α → Prop} [Finite { x // p x }]
(h : ∀ x, p x → p (f x)) (x : { x // p x }) : subtypePermOfFintype f h x = ⟨f x, h x x.2⟩ :=
rfl
theorem subtypePermOfFintype_one (p : α → Prop) [Finite { x // p x }]
(h : ∀ x, p x → p ((1 : Perm α) x)) : @subtypePermOfFintype α 1 p _ h = 1 :=
rfl
theorem perm_mapsTo_inl_iff_mapsTo_inr {m n : Type*} [Finite m] [Finite n] (σ : Perm (m ⊕ n)) :
Set.MapsTo σ (Set.range Sum.inl) (Set.range Sum.inl) ↔
Set.MapsTo σ (Set.range Sum.inr) (Set.range Sum.inr) := by
constructor <;>
( intro h
classical
rw [← perm_inv_mapsTo_iff_mapsTo] at h
intro x
rcases hx : σ x with l | r)
· rintro ⟨a, rfl⟩
obtain ⟨y, hy⟩ := h ⟨l, rfl⟩
rw [← hx, σ.inv_apply_self] at hy
exact absurd hy Sum.inl_ne_inr
· rintro _; exact ⟨r, rfl⟩
· rintro _; exact ⟨l, rfl⟩
· rintro ⟨a, rfl⟩
obtain ⟨y, hy⟩ := h ⟨r, rfl⟩
rw [← hx, σ.inv_apply_self] at hy
exact absurd hy Sum.inr_ne_inl
theorem mem_sumCongrHom_range_of_perm_mapsTo_inl {m n : Type*} [Finite m] [Finite n]
{σ : Perm (m ⊕ n)} (h : Set.MapsTo σ (Set.range Sum.inl) (Set.range Sum.inl)) :
σ ∈ (sumCongrHom m n).range := by
classical
have h1 : ∀ x : m ⊕ n, (∃ a : m, Sum.inl a = x) → ∃ a : m, Sum.inl a = σ x := by
rintro _ ⟨a, rfl⟩; exact h ⟨a, rfl⟩
have h3 : ∀ x : m ⊕ n, (∃ b : n, Sum.inr b = x) → ∃ b : n, Sum.inr b = σ x := by
rintro _ ⟨b, rfl⟩; exact (perm_mapsTo_inl_iff_mapsTo_inr σ).mp h ⟨b, rfl⟩
let σ₁' := subtypePermOfFintype σ h1
let σ₂' := subtypePermOfFintype σ h3
let σ₁ := permCongr (Equiv.ofInjective _ Sum.inl_injective).symm σ₁'
let σ₂ := permCongr (Equiv.ofInjective _ Sum.inr_injective).symm σ₂'
rw [MonoidHom.mem_range, Prod.exists]
use σ₁, σ₂
rw [Perm.sumCongrHom_apply]
ext (a | b)
· rw [Equiv.sumCongr_apply, Sum.map_inl, permCongr_apply, Equiv.symm_symm,
apply_ofInjective_symm Sum.inl_injective]
rw [ofInjective_apply, Subtype.coe_mk, Subtype.coe_mk]
dsimp [Set.range]
rw [subtypePerm_apply]
· rw [Equiv.sumCongr_apply, Sum.map_inr, permCongr_apply, Equiv.symm_symm,
apply_ofInjective_symm Sum.inr_injective, ofInjective_apply]
dsimp [Set.range]
rw [subtypePerm_apply]
nonrec theorem Disjoint.orderOf {σ τ : Perm α} (hστ : Disjoint σ τ) :
orderOf (σ * τ) = Nat.lcm (orderOf σ) (orderOf τ) :=
haveI h : ∀ n : ℕ, (σ * τ) ^ n = 1 ↔ σ ^ n = 1 ∧ τ ^ n = 1 := fun n => by
rw [hστ.commute.mul_pow, Disjoint.mul_eq_one_iff (hστ.pow_disjoint_pow n n)]
Nat.dvd_antisymm hστ.commute.orderOf_mul_dvd_lcm
(Nat.lcm_dvd
(orderOf_dvd_of_pow_eq_one ((h (orderOf (σ * τ))).mp (pow_orderOf_eq_one (σ * τ))).1)
(orderOf_dvd_of_pow_eq_one ((h (orderOf (σ * τ))).mp (pow_orderOf_eq_one (σ * τ))).2))
theorem Disjoint.extendDomain {p : β → Prop} [DecidablePred p] (f : α ≃ Subtype p)
{σ τ : Perm α} (h : Disjoint σ τ) : Disjoint (σ.extendDomain f) (τ.extendDomain f) := by
intro b
by_cases pb : p b
· refine (h (f.symm ⟨b, pb⟩)).imp ?_ ?_ <;>
· intro h
rw [extendDomain_apply_subtype _ _ pb, h, apply_symm_apply, Subtype.coe_mk]
· left
rw [extendDomain_apply_not_subtype _ _ pb]
theorem Disjoint.isConj_mul [Finite α] {σ τ π ρ : Perm α} (hc1 : IsConj σ π)
(hc2 : IsConj τ ρ) (hd1 : Disjoint σ τ) (hd2 : Disjoint π ρ) : IsConj (σ * τ) (π * ρ) := by
classical
cases nonempty_fintype α
obtain ⟨f, rfl⟩ := isConj_iff.1 hc1
obtain ⟨g, rfl⟩ := isConj_iff.1 hc2
have hd1' := coe_inj.2 hd1.support_mul
have hd2' := coe_inj.2 hd2.support_mul
rw [coe_union] at *
have hd1'' := disjoint_coe.2 (disjoint_iff_disjoint_support.1 hd1)
have hd2'' := disjoint_coe.2 (disjoint_iff_disjoint_support.1 hd2)
refine isConj_of_support_equiv ?_ ?_
· refine ((Equiv.setCongr hd1').trans (Equiv.Set.union hd1'')).trans <|
(Equiv.sumCongr (subtypeEquiv f fun a => ?_) <| subtypeEquiv g fun a => ?_).trans
((Equiv.setCongr hd2').trans (Equiv.Set.union hd2'')).symm <;>
simp only [Set.mem_image, toEmbedding_apply, exists_eq_right, support_conj, coe_map,
apply_eq_iff_eq]
intro x hx
simp only [trans_apply, symm_trans_apply, Equiv.setCongr_apply, Equiv.setCongr_symm_apply,
Equiv.sumCongr_apply]
rw [hd1', Set.mem_union] at hx
rcases hx with hxσ | hxτ
· rw [mem_coe, mem_support] at hxσ
rw [Set.union_apply_left, Set.union_apply_left]
· simp only [subtypeEquiv_apply, Perm.coe_mul, Sum.map_inl, comp_apply,
Set.union_symm_apply_left, Subtype.coe_mk, apply_eq_iff_eq]
have h := (hd2 (f x)).resolve_left ?_
· rw [mul_apply, mul_apply] at h
rw [h, inv_apply_self, (hd1 x).resolve_left hxσ]
· rwa [mul_apply, mul_apply, inv_apply_self, apply_eq_iff_eq]
· rwa [Subtype.coe_mk, mem_coe, mem_support]
· rwa [Subtype.coe_mk, Perm.mul_apply, (hd1 x).resolve_left hxσ, mem_coe,
apply_mem_support, mem_support]
· rw [mem_coe, ← apply_mem_support, mem_support] at hxτ
rw [Set.union_apply_right, Set.union_apply_right]
· simp only [subtypeEquiv_apply, Perm.coe_mul, Sum.map_inr, comp_apply,
Set.union_symm_apply_right, Subtype.coe_mk]
have h := (hd2 (g (τ x))).resolve_right ?_
· rw [mul_apply, mul_apply] at h
rw [inv_apply_self, h, (hd1 (τ x)).resolve_right hxτ]
· rwa [mul_apply, mul_apply, inv_apply_self, apply_eq_iff_eq]
· rwa [Subtype.coe_mk, mem_coe, ← apply_mem_support, mem_support]
· rwa [Subtype.coe_mk, Perm.mul_apply, (hd1 (τ x)).resolve_right hxτ,
mem_coe, mem_support]
theorem apply_mem_fixedPoints_iff_mem_of_mem_centralizer {g p : Perm α}
(hp : p ∈ Subgroup.centralizer {g}) {x : α} :
p x ∈ Function.fixedPoints g ↔ x ∈ Function.fixedPoints g := by
simp only [Subgroup.mem_centralizer_singleton_iff] at hp
simp only [Function.mem_fixedPoints_iff]
rw [← mul_apply, ← hp, mul_apply, EmbeddingLike.apply_eq_iff_eq]
@[deprecated (since := "2025-05-19")]
alias mem_fixedPoints_iff_apply_mem_of_mem_centralizer :=
apply_mem_fixedPoints_iff_mem_of_mem_centralizer
variable [DecidableEq α]
lemma disjoint_ofSubtype_of_memFixedPoints_self {g : Perm α}
(u : Perm (Function.fixedPoints g)) :
Disjoint (ofSubtype u) g := by
rw [disjoint_iff_eq_or_eq]
intro x
by_cases hx : x ∈ Function.fixedPoints g
· right; exact hx
· left; rw [ofSubtype_apply_of_not_mem u hx]
section Fintype
variable [Fintype α]
theorem support_pow_coprime {σ : Perm α} {n : ℕ} (h : Nat.Coprime n (orderOf σ)) :
(σ ^ n).support = σ.support := by
obtain ⟨m, hm⟩ := exists_pow_eq_self_of_coprime h
exact
le_antisymm (support_pow_le σ n)
(le_trans (ge_of_eq (congr_arg support hm)) (support_pow_le (σ ^ n) m))
lemma ofSubtype_support_disjoint {σ : Perm α} (x : Perm (Function.fixedPoints σ)) :
_root_.Disjoint x.ofSubtype.support σ.support := by
rw [Finset.disjoint_iff_ne]
rintro a ha b hb rfl
rw [mem_support] at ha hb
exact ha (ofSubtype_apply_of_not_mem x (mt Function.mem_fixedPoints_iff.mp hb))
open Subgroup
lemma disjoint_of_disjoint_support {H K : Subgroup (Perm α)}
(h : ∀ a ∈ H, ∀ b ∈ K, _root_.Disjoint a.support b.support) :
_root_.Disjoint H K := by
rw [disjoint_iff_inf_le]
intro x ⟨hx1, hx2⟩
specialize h x hx1 x hx2
rwa [disjoint_self, Finset.bot_eq_empty, support_eq_empty_iff] at h
lemma support_closure_subset_union (S : Set (Perm α)) :
∀ a ∈ closure S, (a.support : Set α) ⊆ ⋃ b ∈ S, b.support := by
apply closure_induction
· exact fun x hx ↦ Set.subset_iUnion₂_of_subset x hx subset_rfl
· simp only [support_one, Finset.coe_empty, Set.empty_subset]
· intro a b ha hb hc hd
refine (Finset.coe_subset.mpr (support_mul_le a b)).trans ?_
rw [Finset.sup_eq_union, Finset.coe_union, Set.union_subset_iff]
exact ⟨hc, hd⟩
· simp only [support_inv, imp_self, implies_true]
lemma disjoint_support_closure_of_disjoint_support {S T : Set (Perm α)}
(h : ∀ a ∈ S, ∀ b ∈ T, _root_.Disjoint a.support b.support) :
∀ a ∈ closure S, ∀ b ∈ closure T, _root_.Disjoint a.support b.support := by
intro a ha b hb
have key1 := support_closure_subset_union S a ha
have key2 := support_closure_subset_union T b hb
have key := Set.disjoint_of_subset key1 key2
simp_rw [Set.disjoint_iUnion_left, Set.disjoint_iUnion_right, Finset.disjoint_coe] at key
exact key h
lemma disjoint_closure_of_disjoint_support {S T : Set (Perm α)}
(h : ∀ a ∈ S, ∀ b ∈ T, _root_.Disjoint a.support b.support) :
_root_.Disjoint (closure S) (closure T) := by
apply disjoint_of_disjoint_support
apply disjoint_support_closure_of_disjoint_support
exact h
end Fintype
end Equiv.Perm |
.lake/packages/mathlib/Mathlib/GroupTheory/Perm/ClosureSwap.lean | import Mathlib.Algebra.Group.Subgroup.Ker
import Mathlib.GroupTheory.GroupAction.Basic
import Mathlib.GroupTheory.GroupAction.FixedPoints
import Mathlib.GroupTheory.Perm.Support
import Mathlib.Data.Set.Finite.Basic
/-!
# Subgroups generated by transpositions
This file studies subgroups generated by transpositions.
## Main results
- `swap_mem_closure_isSwap` : If a subgroup is generated by transpositions, then a transposition
`swap x y` lies in the subgroup if and only if `x` lies in the same orbit as `y`.
- `mem_closure_isSwap` : If a subgroup is generated by transpositions, then a permutation `f`
lies in the subgroup if and only if `f` has finite support and `f x` always lies in the same
orbit as `x`.
-/
open Equiv List MulAction Pointwise Set Subgroup
variable {G α : Type*} [Group G] [MulAction G α]
/-- If the support of each element in a generating set of a permutation group is finite,
then the support of every element in the group is finite. -/
theorem finite_compl_fixedBy_closure_iff {S : Set G} :
(∀ g ∈ closure S, (fixedBy α g)ᶜ.Finite) ↔ ∀ g ∈ S, (fixedBy α g)ᶜ.Finite :=
⟨fun h g hg ↦ h g (subset_closure hg), fun h g hg ↦ by
refine closure_induction h (by simp) (fun g g' _ _ hg hg' ↦ (hg.union hg').subset ?_)
(by simp) hg
simp_rw [← compl_inter, compl_subset_compl, fixedBy_mul]⟩
/-- Given a symmetric generating set of a permutation group, if T is a nonempty proper subset of
an orbit, then there exists a generator that sends some element of T into the complement of T. -/
theorem exists_smul_notMem_of_subset_orbit_closure (S : Set G) (T : Set α) {a : α}
(hS : ∀ g ∈ S, g⁻¹ ∈ S) (subset : T ⊆ orbit (closure S) a) (notMem : a ∉ T)
(nonempty : T.Nonempty) : ∃ σ ∈ S, ∃ a ∈ T, σ • a ∉ T := by
have key0 : ¬ closure S ≤ stabilizer G T := by
have ⟨b, hb⟩ := nonempty
obtain ⟨σ, rfl⟩ := subset hb
contrapose! notMem with h
exact smul_mem_smul_set_iff.mp ((h σ.2).symm ▸ hb)
contrapose! key0
refine (closure_le _).mpr fun σ hσ ↦ ?_
simp_rw [SetLike.mem_coe, mem_stabilizer_iff, Set.ext_iff, mem_smul_set_iff_inv_smul_mem]
exact fun a ↦ ⟨fun h ↦ smul_inv_smul σ a ▸ key0 σ hσ (σ⁻¹ • a) h, key0 σ⁻¹ (hS σ hσ) a⟩
@[deprecated (since := "2025-05-23")]
alias exists_smul_not_mem_of_subset_orbit_closure := exists_smul_notMem_of_subset_orbit_closure
variable [DecidableEq α]
theorem finite_compl_fixedBy_swap {x y : α} : (fixedBy α (swap x y))ᶜ.Finite :=
Set.Finite.subset (s := {x, y}) (by simp)
(compl_subset_comm.mp fun z h ↦ by apply swap_apply_of_ne_of_ne <;> rintro rfl <;> simp at h)
theorem Equiv.Perm.IsSwap.finite_compl_fixedBy {σ : Perm α} (h : σ.IsSwap) :
(fixedBy α σ)ᶜ.Finite := by
obtain ⟨x, y, -, rfl⟩ := h
exact finite_compl_fixedBy_swap
-- this result cannot be moved to Perm/Basic since Perm/Basic is not allowed to import Submonoid
theorem SubmonoidClass.swap_mem_trans {a b c : α} {C} [SetLike C (Perm α)]
[SubmonoidClass C (Perm α)] (M : C) (hab : swap a b ∈ M) (hbc : swap b c ∈ M) :
swap a c ∈ M := by
obtain rfl | hab' := eq_or_ne a b
· exact hbc
obtain rfl | hac := eq_or_ne a c
· exact swap_self a ▸ one_mem M
rw [swap_comm, ← swap_mul_swap_mul_swap hab' hac]
exact mul_mem (mul_mem hbc hab) hbc
/-- If a subgroup is generated by transpositions, then a transposition `swap x y` lies in the
subgroup if and only if `x` lies in the same orbit as `y`. -/
theorem swap_mem_closure_isSwap {S : Set (Perm α)} (hS : ∀ f ∈ S, f.IsSwap) {x y : α} :
swap x y ∈ closure S ↔ x ∈ orbit (closure S) y := by
refine ⟨fun h ↦ ⟨⟨swap x y, h⟩, swap_apply_right x y⟩, fun hf ↦ ?_⟩
by_contra h
have := exists_smul_notMem_of_subset_orbit_closure S {x | swap x y ∈ closure S}
(fun f hf ↦ ?_) (fun z hz ↦ ?_) h ⟨y, ?_⟩
· obtain ⟨σ, hσ, a, ha, hσa⟩ := this
obtain ⟨z, w, hzw, rfl⟩ := hS σ hσ
have := ne_of_mem_of_not_mem ha hσa
rw [Perm.smul_def, ne_comm, swap_apply_ne_self_iff, and_iff_right hzw] at this
refine hσa (SubmonoidClass.swap_mem_trans (closure S) ?_ ha)
obtain rfl | rfl := this <;> simpa [swap_comm] using subset_closure hσ
· obtain ⟨x, y, -, rfl⟩ := hS f hf; rwa [swap_inv]
· exact orbit_eq_iff.mpr hf ▸ ⟨⟨swap z y, hz⟩, swap_apply_right z y⟩
· rw [mem_setOf, swap_self]; apply one_mem
/-- If a subgroup is generated by transpositions, then a permutation `f` lies in the subgroup if
and only if `f` has finite support and `f x` always lies in the same orbit as `x`. -/
theorem mem_closure_isSwap {S : Set (Perm α)} (hS : ∀ f ∈ S, f.IsSwap) {f : Perm α} :
f ∈ closure S ↔ (fixedBy α f)ᶜ.Finite ∧ ∀ x, f x ∈ orbit (closure S) x := by
refine ⟨fun hf ↦ ⟨?_, fun x ↦ mem_orbit_iff.mpr ⟨⟨f, hf⟩, rfl⟩⟩, ?_⟩
· exact finite_compl_fixedBy_closure_iff.mpr (fun f hf ↦ (hS f hf).finite_compl_fixedBy) _ hf
rintro ⟨fin, hf⟩
set supp := (fixedBy α f)ᶜ with supp_eq
suffices h : (fixedBy α f)ᶜ ⊆ supp → f ∈ closure S from h supp_eq.symm.subset
clear_value supp; clear supp_eq; revert f
apply fin.induction_on ..
· rintro f - emp; convert (closure S).one_mem; ext; by_contra h; exact emp h
rintro a s - - ih f hf supp_subset
refine (mul_mem_cancel_left ((swap_mem_closure_isSwap hS).2 (hf a))).1
(ih (fun b ↦ ?_) fun b hb ↦ ?_)
· rw [Perm.mul_apply, swap_apply_def]; split_ifs with h1 h2
· rw [← orbit_eq_iff.mpr (hf b), h1, orbit_eq_iff.mpr (hf a)]; apply mem_orbit_self
· rw [← orbit_eq_iff.mpr (hf b), h2]; apply hf
· exact hf b
· contrapose! hb
simp_rw [notMem_compl_iff, mem_fixedBy, Perm.smul_def, Perm.mul_apply, swap_apply_def,
apply_eq_iff_eq]
by_cases hb' : f b = b
· rw [hb']; split_ifs with h <;> simp only [h]
simp [show b = a by simpa [hb] using supp_subset hb']
/-- A permutation is a product of transpositions if and only if it has finite support. -/
theorem mem_closure_isSwap' {f : Perm α} :
f ∈ closure {σ : Perm α | σ.IsSwap} ↔ (fixedBy α f)ᶜ.Finite := by
refine (mem_closure_isSwap fun _ ↦ id).trans
(and_iff_left fun x ↦ ⟨⟨swap x (f x), ?_⟩, swap_apply_left x (f x)⟩)
by_cases h : x = f x
· rw [← h, swap_self]
apply Subgroup.one_mem
· exact subset_closure ⟨x, f x, h, rfl⟩
/-- A transitive permutation group generated by transpositions must be the whole symmetric group -/
theorem closure_of_isSwap_of_isPretransitive [Finite α] {S : Set (Perm α)} (hS : ∀ σ ∈ S, σ.IsSwap)
[MulAction.IsPretransitive (Subgroup.closure S) α] : Subgroup.closure S = ⊤ := by
simp [eq_top_iff', mem_closure_isSwap hS, orbit_eq_univ, Set.toFinite]
/-- A transitive permutation group generated by transpositions must be the whole symmetric group -/
theorem surjective_of_isSwap_of_isPretransitive [Finite α] (S : Set G)
(hS1 : ∀ σ ∈ S, Perm.IsSwap (MulAction.toPermHom G α σ)) (hS2 : Subgroup.closure S = ⊤)
[h : MulAction.IsPretransitive G α] : Function.Surjective (MulAction.toPermHom G α) := by
rw [← MonoidHom.range_eq_top]
have := MulAction.IsPretransitive.of_compHom (α := α) (MulAction.toPermHom G α).rangeRestrict
rw [MonoidHom.range_eq_map, ← hS2, MonoidHom.map_closure] at this ⊢
exact closure_of_isSwap_of_isPretransitive (Set.forall_mem_image.2 hS1) |
.lake/packages/mathlib/Mathlib/GroupTheory/Perm/Fin.lean | import Mathlib.GroupTheory.Perm.Cycle.Type
import Mathlib.GroupTheory.Perm.Option
import Mathlib.Logic.Equiv.Fin.Rotate
/-!
# Permutations of `Fin n`
-/
assert_not_exists LinearMap
open Equiv
/-- Permutations of `Fin (n + 1)` are equivalent to fixing a single
`Fin (n + 1)` and permuting the remaining with a `Perm (Fin n)`.
The fixed `Fin (n + 1)` is swapped with `0`. -/
def Equiv.Perm.decomposeFin {n : ℕ} : Perm (Fin n.succ) ≃ Fin n.succ × Perm (Fin n) :=
((Equiv.permCongr <| finSuccEquiv n).trans Equiv.Perm.decomposeOption).trans
(Equiv.prodCongr (finSuccEquiv n).symm (Equiv.refl _))
@[simp]
theorem Equiv.Perm.decomposeFin_symm_of_refl {n : ℕ} (p : Fin (n + 1)) :
Equiv.Perm.decomposeFin.symm (p, Equiv.refl _) = swap 0 p := by
simp [Equiv.Perm.decomposeFin, Equiv.permCongr_def]
@[simp]
theorem Equiv.Perm.decomposeFin_symm_of_one {n : ℕ} (p : Fin (n + 1)) :
Equiv.Perm.decomposeFin.symm (p, 1) = swap 0 p :=
Equiv.Perm.decomposeFin_symm_of_refl p
@[simp]
theorem Equiv.Perm.decomposeFin_symm_apply_zero {n : ℕ} (p : Fin (n + 1)) (e : Perm (Fin n)) :
Equiv.Perm.decomposeFin.symm (p, e) 0 = p := by simp [Equiv.Perm.decomposeFin]
@[simp]
theorem Equiv.Perm.decomposeFin_symm_apply_succ {n : ℕ} (e : Perm (Fin n)) (p : Fin (n + 1))
(x : Fin n) : Equiv.Perm.decomposeFin.symm (p, e) x.succ = swap 0 p (e x).succ := by
refine Fin.cases ?_ ?_ p
· simp [Equiv.Perm.decomposeFin]
· intro i
by_cases h : i = e x
· simp [h, Equiv.Perm.decomposeFin]
· simp [Equiv.Perm.decomposeFin, swap_apply_def, Ne.symm h]
@[simp]
theorem Equiv.Perm.decomposeFin_symm_apply_one {n : ℕ} (e : Perm (Fin (n + 1))) (p : Fin (n + 2)) :
Equiv.Perm.decomposeFin.symm (p, e) 1 = swap 0 p (e 0).succ := by
rw [← Fin.succ_zero_eq_one, Equiv.Perm.decomposeFin_symm_apply_succ e p 0]
@[simp]
theorem Equiv.Perm.decomposeFin.symm_sign {n : ℕ} (p : Fin (n + 1)) (e : Perm (Fin n)) :
Perm.sign (Equiv.Perm.decomposeFin.symm (p, e)) = ite (p = 0) 1 (-1) * Perm.sign e := by
refine Fin.cases ?_ ?_ p <;> simp [Equiv.Perm.decomposeFin]
/-- The set of all permutations of `Fin (n + 1)` can be constructed by augmenting the set of
permutations of `Fin n` by each element of `Fin (n + 1)` in turn. -/
theorem Finset.univ_perm_fin_succ {n : ℕ} :
@Finset.univ (Perm <| Fin n.succ) _ =
(Finset.univ : Finset <| Fin n.succ × Perm (Fin n)).map
Equiv.Perm.decomposeFin.symm.toEmbedding :=
(Finset.univ_map_equiv_to_embedding _).symm
section CycleRange
/-! ### `cycleRange` section
Define the permutations `Fin.cycleRange i`, the cycle `(0 1 2 ... i)`.
-/
open Equiv.Perm
theorem finRotate_succ_eq_decomposeFin {n : ℕ} :
finRotate n.succ = decomposeFin.symm (1, finRotate n) := by
ext i
cases n; · simp
refine Fin.cases ?_ (fun i => ?_) i
· simp
rw [coe_finRotate, decomposeFin_symm_apply_succ, if_congr i.succ_eq_last_succ rfl rfl]
split_ifs with h
· simp [h]
· rw [Fin.val_succ, Function.Injective.map_swap Fin.val_injective, Fin.val_succ, coe_finRotate,
if_neg h, Fin.val_zero, Fin.val_one,
swap_apply_of_ne_of_ne (Nat.succ_ne_zero _) (Nat.succ_succ_ne_one _)]
@[simp]
theorem sign_finRotate (n : ℕ) : Perm.sign (finRotate (n + 1)) = (-1) ^ n := by
induction n with
| zero => simp
| succ n ih =>
rw [finRotate_succ_eq_decomposeFin]
simp [ih, pow_succ]
@[simp]
theorem support_finRotate {n : ℕ} : support (finRotate (n + 2)) = Finset.univ := by
ext
simp
theorem support_finRotate_of_le {n : ℕ} (h : 2 ≤ n) : support (finRotate n) = Finset.univ := by
obtain ⟨m, rfl⟩ := exists_add_of_le h
rw [add_comm, support_finRotate]
theorem isCycle_finRotate {n : ℕ} : IsCycle (finRotate (n + 2)) := by
refine ⟨0, by simp, fun x hx' => ⟨x, ?_⟩⟩
clear hx'
obtain ⟨x, hx⟩ := x
rw [zpow_natCast, Fin.ext_iff, Fin.val_mk]
induction x with
| zero => rfl
| succ x ih =>
rw [pow_succ', Perm.mul_apply, coe_finRotate_of_ne_last, ih (lt_trans x.lt_succ_self hx)]
rw [Ne, Fin.ext_iff, ih (lt_trans x.lt_succ_self hx), Fin.val_last]
exact ne_of_lt (Nat.lt_of_succ_lt_succ hx)
theorem isCycle_finRotate_of_le {n : ℕ} (h : 2 ≤ n) : IsCycle (finRotate n) := by
obtain ⟨m, rfl⟩ := exists_add_of_le h
rw [add_comm]
exact isCycle_finRotate
@[simp]
theorem cycleType_finRotate {n : ℕ} : cycleType (finRotate (n + 2)) = {n + 2} := by
rw [isCycle_finRotate.cycleType, support_finRotate, ← Fintype.card, Fintype.card_fin]
theorem cycleType_finRotate_of_le {n : ℕ} (h : 2 ≤ n) : cycleType (finRotate n) = {n} := by
obtain ⟨m, rfl⟩ := exists_add_of_le h
rw [add_comm, cycleType_finRotate]
namespace Fin
variable {n : ℕ} {i j : Fin n}
/-- `Fin.cycleRange i` is the cycle `(0 1 2 ... i)` leaving `(i+1 ... (n-1))` unchanged. -/
def cycleRange {n : ℕ} (i : Fin n) : Perm (Fin n) :=
(finRotate (i + 1)).extendDomain (castLEEmb (by cutsat)).toEquivRange
theorem cycleRange_of_gt (h : i < j) : cycleRange i j = j := by
rw [cycleRange, Perm.extendDomain_apply_not_subtype]
simpa using h
theorem cycleRange_of_le [NeZero n] (h : i ≤ j) :
cycleRange j i = if i = j then 0 else i + 1 := by
have iin : i ∈ Set.range (castLEEmb (n := j + 1) (by cutsat)) := by
simpa using by cutsat
have : (castLEEmb (by cutsat)).toEquivRange (castLT i (by cutsat)) = ⟨i, iin⟩ := by
simpa only [coe_castLEEmb] using by rfl
rw [cycleRange,
(finRotate (j + 1)).extendDomain_apply_subtype (castLEEmb (by cutsat)).toEquivRange iin,
Function.Embedding.toEquivRange_apply]
split_ifs with ch
· have : ((castLEEmb (by cutsat)).toEquivRange.symm ⟨i, iin⟩) = last j := by
simpa only [coe_castLEEmb, ← this, symm_apply_apply] using eq_of_val_eq (by simp [ch])
rw [this, finRotate_last]
rfl
· have hj1 : (i + 1).1 = i.1 + 1 := val_add_one_of_lt' (by cutsat)
have hj2 : (i.castLT (by cutsat) + 1 : Fin (j + 1)).1 =
(i.castLT (by cutsat) : Fin (j + 1)) + 1 := val_add_one_of_lt' (by simpa using by cutsat)
exact eq_of_val_eq (by simp [← this, hj1, hj2])
theorem coe_cycleRange_of_le (h : i ≤ j) :
(cycleRange j i : ℕ) = if i = j then 0 else (i : ℕ) + 1 := by
rcases n with - | n
· exact absurd le_rfl j.pos.not_ge
rw [cycleRange_of_le h]
split_ifs with h'
· rfl
exact
val_add_one_of_lt
(calc
(i : ℕ) < j := Fin.lt_iff_val_lt_val.mp (lt_of_le_of_ne h h')
_ ≤ n := Nat.lt_succ_iff.mp j.2)
theorem cycleRange_of_lt [NeZero n] (h : i < j) : cycleRange j i = i + 1 := by
rw [cycleRange_of_le h.le, if_neg h.ne]
theorem coe_cycleRange_of_lt (h : i < j) : (cycleRange j i : ℕ) = i + 1 := by
rw [coe_cycleRange_of_le h.le, if_neg h.ne]
theorem cycleRange_of_eq [NeZero n] (h : i = j) : cycleRange j i = 0 := by
rw [cycleRange_of_le h.le, if_pos h]
@[simp]
theorem cycleRange_self [NeZero n] (i : Fin n) : cycleRange i i = 0 :=
cycleRange_of_eq rfl
theorem cycleRange_apply [NeZero n] (i j : Fin n) :
cycleRange i j = if j < i then j + 1 else if j = i then 0 else j := by
split_ifs with h₁ h₂
· exact cycleRange_of_lt h₁
· exact cycleRange_of_eq h₂
· exact cycleRange_of_gt (lt_of_le_of_ne (le_of_not_gt h₁) (Ne.symm h₂))
@[simp]
theorem cycleRange_zero (n : ℕ) [NeZero n] : cycleRange (0 : Fin n) = 1 := by
ext j
rcases (Fin.zero_le j).eq_or_lt with rfl | hj
· simp
· rw [cycleRange_of_gt hj, one_apply]
@[simp]
theorem cycleRange_last (n : ℕ) : cycleRange (last n) = finRotate (n + 1) := by
ext i
rw [coe_cycleRange_of_le (le_last _), coe_finRotate]
@[simp]
theorem cycleRange_mk_zero (h : 0 < n) : cycleRange ⟨0, h⟩ = 1 :=
have : NeZero n := .of_pos h
cycleRange_zero n
@[simp]
theorem sign_cycleRange (i : Fin n) : Perm.sign (cycleRange i) = (-1) ^ (i : ℕ) := by
simp [cycleRange]
@[simp]
theorem succAbove_cycleRange (i j : Fin n) :
i.succ.succAbove (i.cycleRange j) = swap 0 i.succ j.succ := by
cases n
· rcases j with ⟨_, ⟨⟩⟩
rcases lt_trichotomy j i with (hlt | heq | hgt)
· have : castSucc (j + 1) = j.succ := by
ext
rw [coe_castSucc, val_succ, Fin.val_add_one_of_lt (lt_of_lt_of_le hlt i.le_last)]
rw [Fin.cycleRange_of_lt hlt, Fin.succAbove_of_castSucc_lt, this, swap_apply_of_ne_of_ne]
· apply Fin.succ_ne_zero
· exact (Fin.succ_injective _).ne hlt.ne
· rw [Fin.lt_iff_val_lt_val]
simpa [this] using hlt
· rw [heq, Fin.cycleRange_self, Fin.succAbove_of_castSucc_lt, swap_apply_right, Fin.castSucc_zero]
· rw [Fin.castSucc_zero]
apply Fin.succ_pos
· rw [Fin.cycleRange_of_gt hgt, Fin.succAbove_of_le_castSucc, swap_apply_of_ne_of_ne]
· apply Fin.succ_ne_zero
· apply (Fin.succ_injective _).ne hgt.ne.symm
· simpa [Fin.le_iff_val_le_val] using hgt
@[simp]
theorem cycleRange_succAbove (i : Fin (n + 1)) (j : Fin n) :
i.cycleRange (i.succAbove j) = j.succ := by
rcases lt_or_ge (castSucc j) i with h | h
· rw [Fin.succAbove_of_castSucc_lt _ _ h, Fin.cycleRange_of_lt h, Fin.coeSucc_eq_succ]
· rw [Fin.succAbove_of_le_castSucc _ _ h, Fin.cycleRange_of_gt (Fin.le_castSucc_iff.mp h)]
@[simp]
theorem cycleRange_symm_zero [NeZero n] (i : Fin n) : i.cycleRange.symm 0 = i :=
i.cycleRange.injective (by simp)
@[simp]
theorem cycleRange_symm_succ (i : Fin (n + 1)) (j : Fin n) :
i.cycleRange.symm j.succ = i.succAbove j :=
i.cycleRange.injective (by simp)
@[simp]
theorem insertNth_apply_cycleRange_symm {α : Type*} (p : Fin (n + 1)) (a : α) (x : Fin n → α)
(j : Fin (n + 1)) :
(p.insertNth a x : _ → α) (p.cycleRange.symm j) = (Fin.cons a x : _ → α) j := by
cases j using Fin.cases <;> simp
@[simp]
theorem insertNth_comp_cycleRange_symm {α : Type*} (p : Fin (n + 1)) (a : α) (x : Fin n → α) :
(p.insertNth a x ∘ p.cycleRange.symm : _ → α) = Fin.cons a x := by
ext j
simp
@[simp]
theorem cons_apply_cycleRange {α : Type*} (a : α) (x : Fin n → α) (p j : Fin (n + 1)) :
(Fin.cons a x : _ → α) (p.cycleRange j) = (p.insertNth a x : _ → α) j := by
rw [← insertNth_apply_cycleRange_symm, Equiv.symm_apply_apply]
@[simp]
theorem cons_comp_cycleRange {α : Type*} (a : α) (x : Fin n → α) (p : Fin (n + 1)) :
(Fin.cons a x : _ → α) ∘ p.cycleRange = p.insertNth a x := by
ext; simp
theorem isCycle_cycleRange [NeZero n] (h0 : i ≠ 0) : IsCycle (cycleRange i) := by
obtain ⟨i, hi⟩ := i
cases i
· exact (h0 rfl).elim
exact isCycle_finRotate.extendDomain _
@[simp]
theorem cycleType_cycleRange [NeZero n] (h0 : i ≠ 0) :
cycleType (cycleRange i) = {(i + 1 : ℕ)} := by
obtain ⟨i, hi⟩ := i
cases i
· exact (h0 rfl).elim
simp [cycleRange]
theorem isThreeCycle_cycleRange_two : IsThreeCycle (cycleRange 2 : Perm (Fin (n + 3))) := by
rw [IsThreeCycle, cycleType_cycleRange two_ne_zero]
simp
end Fin
end CycleRange
section cycleIcc
/-! ### The permutation `cycleIcc`
In this section, we define the permutation `cycleIcc i j`, which is the cycle `(i i+1 .... j)`
leaving `(0 ... i-1)` and `(j+1 ... n-1)` unchanged when `i ≤ j` and returning the dummy value `id`
when `i > j`. In other words, it rotates elements in `[i, j]` one step to the right.
-/
namespace Fin
local instance {n : ℕ} {i : Fin n} : NeZero (n - i) := NeZero.of_pos (by cutsat)
variable {n : ℕ} {i j k : Fin n}
/-- `cycleIcc i j` is the cycle `(i i+1 ... j)` leaving `(0 ... i-1)` and `(j+1 ... n-1)`
unchanged when `i < j` and returning the dummy value `id` when `i > j`.
In other words, it rotates elements in `[i, j]` one step to the right.
-/
/- `cycleIcc` is defined in two steps:
1. The first part is `cycleRange ((j - i).castLT (sub_val_lt_sub hij))`, which is an element of
`Perm (Fin (n - i))`. It rotates the sequence `(0 1 ... j-i)` while leaving `(j-i+1 ... n-i)`
unchanged.
2. Since `natAdd_castLEEmb (Nat.sub_le n i) : Fin (n - i) ↪ Fin n` maps each `x` to `x + i`, we can
embed the first part into `Fin n` using `extendDomain` to obtain an element of `Perm (Fin n)`.
This yields the cycle `(i i+1 ... j)` while leaving `(0 ... i-1)` and `(j+1 ... n-1)` unchanged.
-/
def cycleIcc (i j : Fin n) : Perm (Fin n) := if hij : i ≤ j then (cycleRange ((j - i).castLT
(sub_val_lt_sub hij))).extendDomain (natAdd_castLEEmb (Nat.sub_le n i)).toEquivRange else 1
@[simp]
lemma cycleIcc_def_le {i j : Fin n} (hij : i ≤ j) : cycleIcc i j =
(cycleRange ((j - i).castLT (sub_val_lt_sub hij))).extendDomain
(natAdd_castLEEmb (Nat.sub_le n i)).toEquivRange := by simp [cycleIcc, hij]
@[simp]
theorem cycleIcc_def_gt (hij : i < j) : cycleIcc j i = 1 := by
simp [cycleIcc, hij]
@[simp]
theorem cycleIcc_def_gt' (hij : ¬ j ≤ i) : cycleIcc j i = 1 := by
simp [cycleIcc, hij]
theorem cycleIcc_of_lt (h : k < i) : (cycleIcc i j) k = k := by
by_cases hij : i ≤ j
· simpa [hij] using Perm.extendDomain_apply_not_subtype _ _ (by
simpa [range_natAdd_castLEEmb] using by cutsat)
· simp [hij]
lemma cycleIcc_to_cycleRange (hij : i ≤ j)
(kin : k ∈ Set.range (natAdd_castLEEmb (Nat.sub_le n i))) : (cycleIcc i j) k =
(natAdd_castLEEmb (Nat.sub_le n i)) (((j - i).castLT (sub_val_lt_sub hij)).cycleRange
((natAdd_castLEEmb (Nat.sub_le n i)).toEquivRange.symm ⟨k, kin⟩)) := by
simp [hij, ((j - i).castLT (sub_val_lt_sub hij)).cycleRange.extendDomain_apply_subtype
(natAdd_castLEEmb _).toEquivRange kin]
theorem cycleIcc_of_gt (h : j < k) : (cycleIcc i j) k = k := by
by_cases hij : i ≤ j
· have kin : k ∈ Set.range (natAdd_castLEEmb (Nat.sub_le n i)) := by
simpa [range_natAdd_castLEEmb] using by cutsat
have : (((addNatEmb (n - (n - i.1))).trans (finCongr _).toEmbedding).toEquivRange.symm ⟨k, kin⟩)
= subNat i.1 (k.cast (by cutsat)) (by simpa using by cutsat) := by
simpa [symm_apply_eq] using eq_of_val_eq (by simpa using by cutsat)
simp only [cycleIcc_to_cycleRange hij kin, natAdd_castLEEmb, this,
Function.Embedding.trans_apply, addNatEmb_apply, coe_toEmbedding, finCongr_apply]
rw [cycleRange_of_gt]
· exact eq_of_val_eq (by simpa using by cutsat)
· exact lt_def.mpr (by simpa [sub_val_of_le hij] using by cutsat)
· simp [hij]
@[simp]
theorem cycleIcc_of_le_of_le (hik : i ≤ k) (hkj : k ≤ j) [NeZero n] :
(cycleIcc i j) k = if k = j then i else k + 1 := by
have hij : i ≤ j := le_trans hik hkj
have kin : k ∈ Set.range (natAdd_castLEEmb (Nat.sub_le n i)) := by
simpa [range_natAdd_castLEEmb] using by cutsat
have : (((addNatEmb (n - (n - i.1))).trans (finCongr _).toEmbedding).toEquivRange.symm ⟨k, kin⟩)
= subNat i.1 (k.cast (by cutsat)) (by simpa using by cutsat) := by
simpa [symm_apply_eq] using eq_of_val_eq (by simpa using by cutsat)
simp only [cycleIcc_to_cycleRange hij kin, natAdd_castLEEmb, this, Function.Embedding.trans_apply,
addNatEmb_apply, coe_toEmbedding, finCongr_apply]
refine eq_of_val_eq ?_
split_ifs with ch
· have : subNat i.1 (j.cast (by cutsat)) (by simp [hij]) = (j - i).castLT (sub_val_lt_sub hij) :=
eq_of_val_eq (by simp [sub_val_of_le hij])
simpa [ch, cycleRange_of_eq this] using by cutsat
· have : subNat i.1 (k.cast (by cutsat)) (by simp [hik]) < (j - i).castLT (sub_val_lt_sub hij) :=
by simpa [lt_iff_val_lt_val, sub_val_of_le hij] using by cutsat
rw [cycleRange_of_lt this, subNat]
simp only [coe_cast, add_def, val_one', Nat.add_mod_mod, addNat_mk, cast_mk]
rw [Nat.mod_eq_of_lt (by cutsat), Nat.mod_eq_of_lt (by cutsat)]
cutsat
theorem cycleIcc_of_ge_of_lt (hik : i ≤ k) (hkj : k < j) [NeZero n] : (cycleIcc i j) k = k + 1 := by
simp [cycleIcc_of_le_of_le hik (le_of_lt hkj), Fin.ne_of_lt hkj]
theorem cycleIcc_of_last (hij : i ≤ j) [NeZero n] : (cycleIcc i j) j = i := by
simp [cycleIcc_of_le_of_le hij (ge_of_eq rfl)]
theorem cycleIcc_eq [NeZero n] : cycleIcc i i = 1 := by
ext k
simp only [Perm.coe_one, id_eq]
rcases lt_trichotomy k i with ch | ch | ch
· simp [-cycleIcc_def_le, cycleIcc_of_lt, ch]
· simp [-cycleIcc_def_le, ch]
· simp [-cycleIcc_def_le, cycleIcc_of_gt, ch]
@[simp]
theorem cycleIcc_ge (hij : i ≤ j) [NeZero n] : cycleIcc j i = 1 := by
rcases Fin.lt_or_eq_of_le hij with hij | hij
· simp [hij]
· rw [hij, ← cycleIcc_eq]
theorem sign_cycleIcc_of_le (hij : i ≤ j) : Perm.sign (cycleIcc i j) = (-1) ^ (j - i : ℕ) := by
simp [hij, sub_val_of_le hij]
theorem sign_cycleIcc_of_eq : Perm.sign (cycleIcc i i) = 1 := by
rw [sign_cycleIcc_of_le (Fin.ge_of_eq rfl), tsub_self, pow_zero]
theorem sign_cycleIcc_of_ge (hij : i ≤ j) : Perm.sign (cycleIcc j i) = 1 := by
rcases Fin.lt_or_eq_of_le hij with hij | hij
· simp [Fin.not_le.mpr hij]
· rw [hij, sign_cycleIcc_of_eq]
theorem isCycle_cycleIcc (hij : i < j) : (cycleIcc i j).IsCycle := by
simpa [le_of_lt hij] using Equiv.Perm.IsCycle.extendDomain
(natAdd_castLEEmb _).toEquivRange (isCycle_cycleRange (castLT_sub_nezero hij))
theorem cycleType_cycleIcc_of_lt (hij : i < j) :
Perm.cycleType (cycleIcc i j) = {(j - i + 1: ℕ)} := by
simpa [le_of_lt hij, cycleType_cycleRange (castLT_sub_nezero hij)] using sub_val_of_le
(le_of_lt hij)
theorem cycleType_cycleIcc_of_ge (hij : i ≤ j) [NeZero n] : Perm.cycleType (cycleIcc j i) = ∅ := by
simpa using cycleIcc_ge hij
theorem cycleIcc_zero_eq_cycleRange (i : Fin n) [NeZero n] : cycleIcc 0 i = cycleRange i := by
ext x
rcases lt_trichotomy x i with ch | ch | ch
· simp [-cycleIcc_def_le, cycleIcc_of_ge_of_lt (zero_le x) ch, cycleRange_of_lt ch]
· simp [-cycleIcc_def_le, ch]
· simp [-cycleIcc_def_le, cycleIcc_of_gt ch, cycleRange_of_gt ch]
theorem cycleIcc.trans [NeZero n] (hij : i ≤ j) (hjk : j ≤ k) :
(cycleIcc i j) ∘ (cycleIcc j k) = (cycleIcc i k) := by
ext x
rcases lt_or_ge x i with ch | ch
· simp [cycleIcc_of_lt (lt_of_lt_of_le ch hij), cycleIcc_of_lt ch]
rcases lt_or_ge k x with ch | ch1
· simp [cycleIcc_of_gt (lt_of_le_of_lt hjk ch), cycleIcc_of_gt ch]
rcases lt_or_ge x j with ch2 | ch2
· simp [cycleIcc_of_lt ch2, cycleIcc_of_le_of_le ch ch1, cycleIcc_of_le_of_le ch (le_of_lt ch2)]
split_ifs
repeat cutsat
· simp [cycleIcc_of_le_of_le ch2 ch1, cycleIcc_of_le_of_le ch ch1]
split_ifs with h
· exact val_eq_of_eq (cycleIcc_of_last hij)
· simp [cycleIcc_of_gt (lt_of_le_of_lt ch2 (lt_add_one_of_succ_lt (by cutsat)))]
theorem cycleIcc.trans_left_one [NeZero n] (hij : i ≤ j) :
(cycleIcc j i) ∘ (cycleIcc i k) = cycleIcc i k := by
simp [hij]
theorem cycleIcc.trans_right_one [NeZero n] (hjk : j ≤ k) :
(cycleIcc i k) ∘ (cycleIcc k j) = cycleIcc i k := by
simp [hjk]
end Fin
end cycleIcc
section Sign
variable {n : ℕ}
theorem Equiv.Perm.sign_eq_prod_prod_Iio (σ : Equiv.Perm (Fin n)) :
σ.sign = ∏ j, ∏ i ∈ Finset.Iio j, (if σ i < σ j then 1 else -1) := by
suffices h : σ.sign = σ.signAux by
rw [h, Finset.prod_sigma', Equiv.Perm.signAux]
convert rfl using 2 with x hx
· simp [Finset.ext_iff, Equiv.Perm.mem_finPairsLT]
simp [← ite_not (p := _ ≤ _)]
refine σ.swap_induction_on (by simp) fun π i j hne h_eq ↦ ?_
rw [Equiv.Perm.signAux_mul, Equiv.Perm.sign_mul, h_eq, Equiv.Perm.sign_swap hne,
Equiv.Perm.signAux_swap hne]
theorem Equiv.Perm.sign_eq_prod_prod_Ioi (σ : Equiv.Perm (Fin n)) :
σ.sign = ∏ i, ∏ j ∈ Finset.Ioi i, (if σ i < σ j then 1 else -1) := by
rw [σ.sign_eq_prod_prod_Iio]
apply Finset.prod_comm' (by simp)
theorem Equiv.Perm.prod_Iio_comp_eq_sign_mul_prod {R : Type*} [CommRing R]
(σ : Equiv.Perm (Fin n)) {f : Fin n → Fin n → R} (hf : ∀ i j, f i j = -f j i) :
∏ j, ∏ i ∈ Finset.Iio j, f (σ i) (σ j) = σ.sign * ∏ j, ∏ i ∈ Finset.Iio j, f i j := by
simp_rw [← σ.sign_inv, σ⁻¹.sign_eq_prod_prod_Iio, Finset.prod_sigma', Units.coe_prod,
Int.cast_prod, ← Finset.prod_mul_distrib]
set D := (Finset.univ : Finset (Fin n)).sigma Finset.Iio with hD
have hφD : D.image (fun x ↦ ⟨σ x.1 ⊔ σ x.2, σ x.1 ⊓ σ x.2⟩) = D := by
ext ⟨x1, x2⟩
suffices (∃ a, ∃ b < a, σ a ⊔ σ b = x1 ∧ σ a ⊓ σ b = x2) ↔ x2 < x1 by simpa [hD]
refine ⟨?_, fun hlt ↦ ?_⟩
· rintro ⟨i, j, hij, rfl, rfl⟩
exact inf_le_sup.lt_of_ne <| by simp [hij.ne.symm]
obtain hlt' | hle := lt_or_ge (σ.symm x1) (σ.symm x2)
· exact ⟨_, _, hlt', by simp [hlt.le]⟩
exact ⟨_, _, hle.lt_of_ne (by simp [hlt.ne]), by simp [hlt.le]⟩
nth_rw 2 [← hφD]
rw [Finset.prod_image fun x hx y hy ↦ Finset.injOn_of_card_image_eq (by rw [hφD]) hx hy]
refine Finset.prod_congr rfl fun ⟨x₁, x₂⟩ hx ↦ ?_
replace hx : x₂ < x₁ := by simpa [hD] using hx
obtain hlt | hle := lt_or_ge (σ x₁) (σ x₂)
· simp [inf_eq_left.2 hlt.le, sup_eq_right.2 hlt.le, hx.not_gt, ← hf]
simp [inf_eq_right.2 hle, sup_eq_left.2 hle, hx]
theorem Equiv.Perm.prod_Ioi_comp_eq_sign_mul_prod {R : Type*} [CommRing R]
(σ : Equiv.Perm (Fin n)) {f : Fin n → Fin n → R} (hf : ∀ i j, f i j = -f j i) :
∏ i, ∏ j ∈ Finset.Ioi i, f (σ i) (σ j) = σ.sign * ∏ i, ∏ j ∈ Finset.Ioi i, f i j := by
convert σ.prod_Iio_comp_eq_sign_mul_prod hf using 1
· apply Finset.prod_comm' (by simp)
convert rfl using 2
apply Finset.prod_comm' (by simp)
end Sign |
.lake/packages/mathlib/Mathlib/GroupTheory/Perm/Sign.lean | import Mathlib.Algebra.Group.Conj
import Mathlib.Algebra.Group.Subgroup.Lattice
import Mathlib.Algebra.Group.Submonoid.BigOperators
import Mathlib.Data.Finset.Fin
import Mathlib.Data.Finset.Sort
import Mathlib.Data.Fintype.Perm
import Mathlib.Data.Fintype.Prod
import Mathlib.Data.Fintype.Sum
import Mathlib.Data.Int.Order.Units
import Mathlib.GroupTheory.Perm.Support
import Mathlib.Logic.Equiv.Fintype
import Mathlib.Tactic.NormNum.Ineq
import Mathlib.Data.Finset.Sigma
/-!
# Sign of a permutation
The main definition of this file is `Equiv.Perm.sign`,
associating a `ℤˣ` sign with a permutation.
Other lemmas have been moved to `Mathlib/GroupTheory/Perm/Fintype.lean`
-/
universe u v
open Equiv Function Fintype Finset
variable {α : Type u} [DecidableEq α] {β : Type v}
namespace Equiv.Perm
/-- `modSwap i j` contains permutations up to swapping `i` and `j`.
We use this to partition permutations in `Matrix.det_zero_of_row_eq`, such that each partition
sums up to `0`.
-/
def modSwap (i j : α) : Setoid (Perm α) :=
⟨fun σ τ => σ = τ ∨ σ = swap i j * τ, fun σ => Or.inl (refl σ), fun {σ τ} h =>
Or.casesOn h (fun h => Or.inl h.symm) fun h => Or.inr (by rw [h, swap_mul_self_mul]),
fun {σ τ υ} hστ hτυ => by
rcases hστ with hστ | hστ <;> rcases hτυ with hτυ | hτυ <;>
(try rw [hστ, hτυ, swap_mul_self_mul]) <;>
simp [hστ, hτυ]⟩
noncomputable instance {α : Type*} [Fintype α] [DecidableEq α] (i j : α) :
DecidableRel (modSwap i j).r :=
fun _ _ => inferInstanceAs (Decidable (_ ∨ _))
/-- Given a list `l : List α` and a permutation `f : Perm α` such that the nonfixed points of `f`
are in `l`, recursively factors `f` as a product of transpositions. -/
def swapFactorsAux :
∀ (l : List α) (f : Perm α),
(∀ {x}, f x ≠ x → x ∈ l) → { l : List (Perm α) // l.prod = f ∧ ∀ g ∈ l, IsSwap g }
| [] => fun f h =>
⟨[],
Equiv.ext fun x => by
rw [List.prod_nil]
exact (Classical.not_not.1 (mt h List.not_mem_nil)).symm,
by simp⟩
| x::l => fun f h =>
if hfx : x = f x then
swapFactorsAux l f fun {y} hy =>
List.mem_of_ne_of_mem (fun h : y = x => by simp [h, hfx.symm] at hy) (h hy)
else
let m :=
swapFactorsAux l (swap x (f x) * f) fun {y} hy =>
have : f y ≠ y ∧ y ≠ x := ne_and_ne_of_swap_mul_apply_ne_self hy
List.mem_of_ne_of_mem this.2 (h this.1)
⟨swap x (f x)::m.1, by
rw [List.prod_cons, m.2.1, ← mul_assoc, mul_def (swap x (f x)), swap_swap, ← one_def,
one_mul],
fun {_} hg => ((List.mem_cons).1 hg).elim (fun h => ⟨x, f x, hfx, h⟩) (m.2.2 _)⟩
/-- `swapFactors` represents a permutation as a product of a list of transpositions.
The representation is nonunique and depends on the linear order structure.
For types without linear order `truncSwapFactors` can be used. -/
def swapFactors [Fintype α] [LinearOrder α] (f : Perm α) :
{ l : List (Perm α) // l.prod = f ∧ ∀ g ∈ l, IsSwap g } :=
swapFactorsAux ((@univ α _).sort) f fun {_ _} => (mem_sort _).2 (mem_univ _)
/-- This computably represents the fact that any permutation can be represented as the product of
a list of transpositions. -/
def truncSwapFactors [Fintype α] (f : Perm α) :
Trunc { l : List (Perm α) // l.prod = f ∧ ∀ g ∈ l, IsSwap g } :=
Quotient.recOnSubsingleton (@univ α _).1 (fun l h => Trunc.mk (swapFactorsAux l f (h _)))
(show ∀ x, f x ≠ x → x ∈ (@univ α _).1 from fun _ _ => mem_univ _)
/-- An induction principle for permutations. If `P` holds for the identity permutation, and
is preserved under composition with a non-trivial swap, then `P` holds for all permutations. -/
@[elab_as_elim]
theorem swap_induction_on [Finite α] {motive : Perm α → Prop} (f : Perm α)
(one : motive 1) (swap_mul : ∀ f x y, x ≠ y → motive f → motive (swap x y * f)) : motive f := by
cases nonempty_fintype α
obtain ⟨l, hl⟩ := (truncSwapFactors f).out
induction l generalizing f with
| nil =>
simp only [one, hl.left.symm, List.prod_nil]
| cons g l ih =>
rcases hl.2 g (by simp) with ⟨x, y, hxy⟩
rw [← hl.1, List.prod_cons, hxy.2]
exact swap_mul _ _ _ hxy.1 (ih _ ⟨rfl, fun v hv => hl.2 _ (List.mem_cons_of_mem _ hv)⟩)
theorem mclosure_isSwap [Finite α] : Submonoid.closure { σ : Perm α | IsSwap σ } = ⊤ := by
cases nonempty_fintype α
refine top_unique fun x _ ↦ ?_
obtain ⟨h1, h2⟩ := Subtype.mem (truncSwapFactors x).out
rw [← h1]
exact Submonoid.list_prod_mem _ fun y hy ↦ Submonoid.subset_closure (h2 y hy)
theorem closure_isSwap [Finite α] : Subgroup.closure { σ : Perm α | IsSwap σ } = ⊤ :=
Subgroup.closure_eq_top_of_mclosure_eq_top mclosure_isSwap
/-- Every finite symmetric group is generated by transpositions of adjacent elements. -/
theorem mclosure_swap_castSucc_succ (n : ℕ) :
Submonoid.closure (Set.range fun i : Fin n ↦ swap i.castSucc i.succ) = ⊤ := by
apply top_unique
rw [← mclosure_isSwap, Submonoid.closure_le]
rintro _ ⟨i, j, ne, rfl⟩
wlog lt : i < j generalizing i j
· rw [swap_comm]; exact this _ _ ne.symm (ne.lt_or_gt.resolve_left lt)
induction j using Fin.induction with
| zero => cases lt
| succ j ih =>
have mem : swap j.castSucc j.succ ∈ Submonoid.closure
(Set.range fun (i : Fin n) ↦ swap i.castSucc i.succ) := Submonoid.subset_closure ⟨_, rfl⟩
obtain rfl | lts := (Fin.le_castSucc_iff.mpr lt).eq_or_lt
· exact mem
rw [swap_comm, ← swap_mul_swap_mul_swap (y := Fin.castSucc j) lts.ne lt.ne]
exact mul_mem (mul_mem mem <| ih lts.ne lts) mem
/-- Like `swap_induction_on`, but with the composition on the right of `f`.
An induction principle for permutations. If `motive` holds for the identity permutation, and
is preserved under composition with a non-trivial swap, then `motive` holds for all permutations. -/
@[elab_as_elim]
theorem swap_induction_on' [Finite α] {motive : Perm α → Prop} (f : Perm α) (one : motive 1)
(mul_swap : ∀ f x y, x ≠ y → motive f → motive (f * swap x y)) : motive f :=
inv_inv f ▸ swap_induction_on f⁻¹ one fun f => mul_swap f⁻¹
theorem isConj_swap {w x y z : α} (hwx : w ≠ x) (hyz : y ≠ z) : IsConj (swap w x) (swap y z) :=
isConj_iff.2
(have h :
∀ {y z : α},
y ≠ z → w ≠ z → swap w y * swap x z * swap w x * (swap w y * swap x z)⁻¹ = swap y z :=
fun {y z} hyz hwz => by
rw [mul_inv_rev, swap_inv, swap_inv, mul_assoc (swap w y), mul_assoc (swap w y), ←
mul_assoc _ (swap x z), swap_mul_swap_mul_swap hwx hwz, ← mul_assoc,
swap_mul_swap_mul_swap hwz.symm hyz.symm]
if hwz : w = z then
have hwy : w ≠ y := by rw [hwz]; exact hyz.symm
⟨swap w z * swap x y, by rw [swap_comm y z, h hyz.symm hwy]⟩
else ⟨swap w y * swap x z, h hyz hwz⟩)
/-- set of all pairs (⟨a, b⟩ : Σ a : fin n, fin n) such that b < a -/
def finPairsLT (n : ℕ) : Finset (Σ _ : Fin n, Fin n) :=
(univ : Finset (Fin n)).sigma fun a => (range a).attachFin fun _ hm => (mem_range.1 hm).trans a.2
theorem mem_finPairsLT {n : ℕ} {a : Σ _ : Fin n, Fin n} : a ∈ finPairsLT n ↔ a.2 < a.1 := by
simp only [finPairsLT, Fin.lt_iff_val_lt_val, true_and, mem_attachFin, mem_range, mem_univ,
mem_sigma]
/-- `signAux σ` is the sign of a permutation on `Fin n`, defined as the parity of the number of
pairs `(x₁, x₂)` such that `x₂ < x₁` but `σ x₁ ≤ σ x₂` -/
def signAux {n : ℕ} (a : Perm (Fin n)) : ℤˣ :=
∏ x ∈ finPairsLT n, if a x.1 ≤ a x.2 then -1 else 1
@[simp]
theorem signAux_one (n : ℕ) : signAux (1 : Perm (Fin n)) = 1 := by
unfold signAux
conv => rhs; rw [← @Finset.prod_const_one _ _ (finPairsLT n)]
exact Finset.prod_congr rfl fun a ha => if_neg (mem_finPairsLT.1 ha).not_ge
/-- `signBijAux f ⟨a, b⟩` returns the pair consisting of `f a` and `f b` in decreasing order. -/
def signBijAux {n : ℕ} (f : Perm (Fin n)) (a : Σ _ : Fin n, Fin n) : Σ _ : Fin n, Fin n :=
if _ : f a.2 < f a.1 then ⟨f a.1, f a.2⟩ else ⟨f a.2, f a.1⟩
theorem signBijAux_injOn {n : ℕ} {f : Perm (Fin n)} :
(finPairsLT n : Set (Σ _, Fin n)).InjOn (signBijAux f) := by
rintro ⟨a₁, a₂⟩ ha ⟨b₁, b₂⟩ hb h
dsimp [signBijAux] at h
rw [Finset.mem_coe, mem_finPairsLT] at *
have : ¬b₁ < b₂ := hb.le.not_gt
split_ifs at h <;>
simp_all only [not_lt, Sigma.mk.inj_iff, (Equiv.injective f).eq_iff, heq_eq_eq]
· exact absurd this (not_le.mpr ha)
· exact absurd this (not_le.mpr ha)
theorem signBijAux_surj {n : ℕ} {f : Perm (Fin n)} :
∀ a ∈ finPairsLT n, ∃ b ∈ finPairsLT n, signBijAux f b = a :=
fun ⟨a₁, a₂⟩ ha =>
if hxa : f.symm a₂ < f.symm a₁ then
⟨⟨f.symm a₁, f.symm a₂⟩, mem_finPairsLT.2 hxa, by
simp [signBijAux, if_pos (mem_finPairsLT.1 ha)]⟩
else
⟨⟨f.symm a₂, f.symm a₁⟩,
mem_finPairsLT.2 <|
(le_of_not_gt hxa).lt_of_ne fun h => by
simp [mem_finPairsLT, f⁻¹.injective h] at ha, by
simp [signBijAux, if_neg (mem_finPairsLT.1 ha).le.not_gt]⟩
theorem signBijAux_mem {n : ℕ} {f : Perm (Fin n)} :
∀ a : Σ _ : Fin n, Fin n, a ∈ finPairsLT n → signBijAux f a ∈ finPairsLT n :=
fun ⟨a₁, a₂⟩ ha => by
unfold signBijAux
split_ifs with h
· exact mem_finPairsLT.2 h
· exact mem_finPairsLT.2
((le_of_not_gt h).lt_of_ne fun h => (mem_finPairsLT.1 ha).ne (f.injective h.symm))
@[simp]
theorem signAux_inv {n : ℕ} (f : Perm (Fin n)) : signAux f⁻¹ = signAux f :=
prod_nbij (signBijAux f⁻¹) signBijAux_mem signBijAux_injOn signBijAux_surj fun ⟨a, b⟩ hab ↦ by
by_cases h : f⁻¹ b < f⁻¹ a
· simp_all [signBijAux, (mem_finPairsLT.1 hab).not_ge]
· simp_all [signBijAux, dif_neg h, (mem_finPairsLT.1 hab).le]
theorem signAux_mul {n : ℕ} (f g : Perm (Fin n)) : signAux (f * g) = signAux f * signAux g := by
rw [← signAux_inv g]
unfold signAux
rw [← prod_mul_distrib]
refine prod_nbij (signBijAux g) signBijAux_mem signBijAux_injOn signBijAux_surj ?_
rintro ⟨a, b⟩ hab
dsimp only [signBijAux]
rw [mul_apply, mul_apply]
rw [mem_finPairsLT] at hab
by_cases hg : g b < g a
· simp [*]
obtain hf | hf := (f.injective.ne <| g.injective.ne hab.ne).lt_or_gt <;>
simp_all [le_of_lt, not_le_of_gt, not_lt_of_ge]
private theorem signAux_swap_zero_one' (n : ℕ) : signAux (swap (0 : Fin (n + 2)) 1) = -1 :=
show _ = ∏ x ∈ {(⟨1, 0⟩ : Σ _ : Fin (n + 2), Fin (n + 2))},
if (Equiv.swap 0 1) x.1 ≤ swap 0 1 x.2 then (-1 : ℤˣ) else 1 by
refine Eq.symm (prod_subset (fun ⟨x₁, x₂⟩ => by
simp +contextual [mem_finPairsLT, Fin.one_pos]) fun a ha₁ ha₂ => ?_)
rcases a with ⟨a₁, a₂⟩
replace ha₁ : a₂ < a₁ := mem_finPairsLT.1 ha₁
dsimp only
rcases a₁.zero_le.eq_or_lt with (rfl | H)
· exact absurd a₂.zero_le ha₁.not_ge
rcases a₂.zero_le.eq_or_lt with (rfl | H')
· simp only [and_true, heq_iff_eq, mem_singleton, Sigma.mk.inj_iff] at ha₂
have : 1 < a₁ := lt_of_le_of_ne' (Nat.succ_le_of_lt ha₁) ha₂
have h01 : Equiv.swap (0 : Fin (n + 2)) 1 0 = 1 := by simp
rw [swap_apply_of_ne_of_ne (ne_of_gt H) ha₂, h01, if_neg this.not_ge]
· have le : 1 ≤ a₂ := Nat.succ_le_of_lt H'
have lt : 1 < a₁ := le.trans_lt ha₁
have h01 : Equiv.swap (0 : Fin (n + 2)) 1 1 = 0 := by simp only [swap_apply_right]
rcases le.eq_or_lt with (rfl | lt')
· rw [swap_apply_of_ne_of_ne H.ne' lt.ne', h01, if_neg H.not_ge]
· rw [swap_apply_of_ne_of_ne (ne_of_gt H) (ne_of_gt lt),
swap_apply_of_ne_of_ne (ne_of_gt H') (ne_of_gt lt'), if_neg ha₁.not_ge]
private theorem signAux_swap_zero_one {n : ℕ} (hn : 2 ≤ n) :
signAux (swap (⟨0, lt_of_lt_of_le (by decide) hn⟩ : Fin n) ⟨1, lt_of_lt_of_le (by decide) hn⟩) =
-1 := by
rcases n with (_ | _ | n)
· norm_num at hn
· norm_num at hn
· exact signAux_swap_zero_one' n
theorem signAux_swap : ∀ {n : ℕ} {x y : Fin n} (_hxy : x ≠ y), signAux (swap x y) = -1
| 0, x, y => by intro; exact Fin.elim0 x
| 1, x, y => by
dsimp [signAux, swap, swapCore]
simp only [eq_iff_true_of_subsingleton, not_true, ite_true, le_refl, prod_const,
IsEmpty.forall_iff]
| n + 2, x, y => fun hxy => by
have h2n : 2 ≤ n + 2 := by exact le_add_self
rw [← isConj_iff_eq, ← signAux_swap_zero_one h2n]
exact (MonoidHom.mk' signAux signAux_mul).map_isConj
(isConj_swap hxy (by exact of_decide_eq_true rfl))
/-- When the list `l : List α` contains all nonfixed points of the permutation `f : Perm α`,
`signAux2 l f` recursively calculates the sign of `f`. -/
def signAux2 : List α → Perm α → ℤˣ
| [], _ => 1
| x::l, f => if x = f x then signAux2 l f else -signAux2 l (swap x (f x) * f)
theorem signAux_eq_signAux2 {n : ℕ} :
∀ (l : List α) (f : Perm α) (e : α ≃ Fin n) (_h : ∀ x, f x ≠ x → x ∈ l),
signAux ((e.symm.trans f).trans e) = signAux2 l f
| [], f, e, h => by
have : f = 1 := Equiv.ext fun y => Classical.not_not.1 (mt (h y) List.not_mem_nil)
rw [this, one_def, Equiv.trans_refl, Equiv.symm_trans_self, ← one_def, signAux_one, signAux2]
| x::l, f, e, h => by
rw [signAux2]
by_cases hfx : x = f x
· rw [if_pos hfx]
exact
signAux_eq_signAux2 l f _ fun y (hy : f y ≠ y) =>
List.mem_of_ne_of_mem (fun h : y = x => by simp [h, hfx.symm] at hy) (h y hy)
· have hy : ∀ y : α, (swap x (f x) * f) y ≠ y → y ∈ l := fun y hy =>
have : f y ≠ y ∧ y ≠ x := ne_and_ne_of_swap_mul_apply_ne_self hy
List.mem_of_ne_of_mem this.2 (h _ this.1)
have : (e.symm.trans (swap x (f x) * f)).trans e =
swap (e x) (e (f x)) * (e.symm.trans f).trans e := by
ext
rw [← Equiv.symm_trans_swap_trans, mul_def, Equiv.symm_trans_swap_trans, mul_def]
repeat (rw [trans_apply])
simp [swap, swapCore]
split_ifs <;> rfl
have hefx : e x ≠ e (f x) := mt e.injective.eq_iff.1 hfx
rw [if_neg hfx, ← signAux_eq_signAux2 _ _ e hy, this, signAux_mul, signAux_swap hefx]
simp only [neg_neg, one_mul, neg_mul]
/-- When the multiset `s : Multiset α` contains all nonfixed points of the permutation `f : Perm α`,
`signAux2 f _` recursively calculates the sign of `f`. -/
def signAux3 [Finite α] (f : Perm α) {s : Multiset α} : (∀ x, x ∈ s) → ℤˣ :=
Quotient.hrecOn s (fun l _ => signAux2 l f) fun l₁ l₂ h ↦ by
rcases Finite.exists_equiv_fin α with ⟨n, ⟨e⟩⟩
refine Function.hfunext (forall_congr fun _ ↦ propext h.mem_iff) fun h₁ h₂ _ ↦ ?_
rw [← signAux_eq_signAux2 _ _ e fun _ _ => h₁ _, ← signAux_eq_signAux2 _ _ e fun _ _ => h₂ _]
theorem signAux3_mul_and_swap [Finite α] (f g : Perm α) (s : Multiset α) (hs : ∀ x, x ∈ s) :
signAux3 (f * g) hs = signAux3 f hs * signAux3 g hs ∧
Pairwise fun x y => signAux3 (swap x y) hs = -1 := by
obtain ⟨n, ⟨e⟩⟩ := Finite.exists_equiv_fin α
induction s using Quotient.inductionOn with | _ l => ?_
change
signAux2 l (f * g) = signAux2 l f * signAux2 l g ∧
Pairwise fun x y => signAux2 l (swap x y) = -1
have hfg : (e.symm.trans (f * g)).trans e = (e.symm.trans f).trans e * (e.symm.trans g).trans e :=
Equiv.ext fun h => by simp [mul_apply]
constructor
· rw [← signAux_eq_signAux2 _ _ e fun _ _ => hs _, ←
signAux_eq_signAux2 _ _ e fun _ _ => hs _, ← signAux_eq_signAux2 _ _ e fun _ _ => hs _,
hfg, signAux_mul]
· intro x y hxy
rw [← e.injective.ne_iff] at hxy
rw [← signAux_eq_signAux2 _ _ e fun _ _ => hs _, symm_trans_swap_trans, signAux_swap hxy]
theorem signAux3_symm_trans_trans [Finite α] [DecidableEq β] [Finite β] (f : Perm α) (e : α ≃ β)
{s : Multiset α} {t : Multiset β} (hs : ∀ x, x ∈ s) (ht : ∀ x, x ∈ t) :
signAux3 ((e.symm.trans f).trans e) ht = signAux3 f hs := by
induction t, s using Quotient.inductionOn₂
change signAux2 _ _ = signAux2 _ _
rcases Finite.exists_equiv_fin β with ⟨n, ⟨e'⟩⟩
rw [← signAux_eq_signAux2 _ _ e' fun _ _ => ht _,
← signAux_eq_signAux2 _ _ (e.trans e') fun _ _ => hs _]
exact congr_arg signAux
(Equiv.ext fun x => by simp [symm_trans_apply])
/-- `SignType.sign` of a permutation returns the signature or parity of a permutation, `1` for even
permutations, `-1` for odd permutations. It is the unique surjective group homomorphism from
`Perm α` to the group with two elements. -/
def sign [Fintype α] : Perm α →* ℤˣ :=
MonoidHom.mk' (fun f => signAux3 f mem_univ) fun f g => (signAux3_mul_and_swap f g _ mem_univ).1
section SignType.sign
variable [Fintype α]
@[simp]
theorem sign_mul (f g : Perm α) : sign (f * g) = sign f * sign g :=
MonoidHom.map_mul sign f g
@[simp]
theorem sign_trans (f g : Perm α) : sign (f.trans g) = sign g * sign f := by
rw [← mul_def, sign_mul]
@[simp]
theorem sign_one : sign (1 : Perm α) = 1 :=
MonoidHom.map_one sign
@[simp]
theorem sign_refl : sign (Equiv.refl α) = 1 :=
MonoidHom.map_one sign
@[simp]
theorem sign_inv (f : Perm α) : sign f⁻¹ = sign f := by
rw [MonoidHom.map_inv sign f, Int.units_inv_eq_self]
@[simp]
theorem sign_symm (e : Perm α) : sign e.symm = sign e :=
sign_inv e
theorem sign_swap {x y : α} (h : x ≠ y) : sign (swap x y) = -1 :=
(signAux3_mul_and_swap 1 1 _ mem_univ).2 h
@[simp]
theorem sign_swap' {x y : α} : sign (swap x y) = if x = y then 1 else -1 :=
if H : x = y then by simp [H, swap_self] else by simp [sign_swap H, H]
theorem IsSwap.sign_eq {f : Perm α} (h : f.IsSwap) : sign f = -1 :=
let ⟨_, _, hxy⟩ := h
hxy.2.symm ▸ sign_swap hxy.1
@[simp]
theorem sign_symm_trans_trans [DecidableEq β] [Fintype β] (f : Perm α) (e : α ≃ β) :
sign ((e.symm.trans f).trans e) = sign f :=
signAux3_symm_trans_trans f e mem_univ mem_univ
@[simp]
theorem sign_trans_trans_symm [DecidableEq β] [Fintype β] (f : Perm β) (e : α ≃ β) :
sign ((e.trans f).trans e.symm) = sign f :=
sign_symm_trans_trans f e.symm
theorem sign_prod_list_swap {l : List (Perm α)} (hl : ∀ g ∈ l, IsSwap g) :
sign l.prod = (-1) ^ l.length := by
have h₁ : l.map sign = List.replicate l.length (-1) :=
List.eq_replicate_iff.2
⟨by simp, fun u hu =>
let ⟨g, hg⟩ := List.mem_map.1 hu
hg.2 ▸ (hl _ hg.1).sign_eq⟩
rw [← List.prod_replicate, ← h₁, List.prod_hom _ (@sign α _ _)]
@[simp]
theorem sign_abs (f : Perm α) :
|(Equiv.Perm.sign f : ℤ)| = 1 := by
rw [Int.abs_eq_natAbs, Int.units_natAbs, Nat.cast_one]
variable (α) in
theorem sign_surjective [Nontrivial α] : Function.Surjective (sign : Perm α → ℤˣ) := fun a =>
(Int.units_eq_one_or a).elim (fun h => ⟨1, by simp [h]⟩) fun h =>
let ⟨x, y, hxy⟩ := exists_pair_ne α
⟨swap x y, by rw [sign_swap hxy, h]⟩
theorem eq_sign_of_surjective_hom {s : Perm α →* ℤˣ} (hs : Surjective s) : s = sign :=
have : ∀ {f}, IsSwap f → s f = -1 := fun {f} ⟨x, y, hxy, hxy'⟩ =>
hxy'.symm ▸
by_contradiction fun h => by
have : ∀ f, IsSwap f → s f = 1 := fun f ⟨a, b, hab, hab'⟩ => by
rw [← isConj_iff_eq, ← Or.resolve_right (Int.units_eq_one_or _) h, hab']
exact s.map_isConj (isConj_swap hab hxy)
let ⟨g, hg⟩ := hs (-1)
let ⟨l, hl⟩ := (truncSwapFactors g).out
have : ∀ a ∈ l.map s, a = (1 : ℤˣ) := fun a ha =>
let ⟨g, hg⟩ := List.mem_map.1 ha
hg.2 ▸ this _ (hl.2 _ hg.1)
have : s l.prod = 1 := by
rw [← l.prod_hom s, List.eq_replicate_length.2 this, List.prod_replicate, one_pow]
rw [hl.1, hg] at this
exact absurd this (by simp_all)
MonoidHom.ext fun f => by
let ⟨l, hl₁, hl₂⟩ := (truncSwapFactors f).out
have hsl : ∀ a ∈ l.map s, a = (-1 : ℤˣ) := fun a ha =>
let ⟨g, hg⟩ := List.mem_map.1 ha
hg.2 ▸ this (hl₂ _ hg.1)
rw [← hl₁, ← l.prod_hom s, List.eq_replicate_length.2 hsl, List.length_map, List.prod_replicate,
sign_prod_list_swap hl₂]
theorem sign_subtypePerm (f : Perm α) {p : α → Prop} [DecidablePred p] (h₁ : ∀ x, p (f x) ↔ p x)
(h₂ : ∀ x, f x ≠ x → p x) : sign (subtypePerm f h₁) = sign f := by
let l := (truncSwapFactors (subtypePerm f h₁)).out
have hl' : ∀ g' ∈ l.1.map ofSubtype, IsSwap g' := fun g' hg' =>
let ⟨g, hg⟩ := List.mem_map.1 hg'
hg.2 ▸ (l.2.2 _ hg.1).of_subtype_isSwap
have hl'₂ : (l.1.map ofSubtype).prod = f := by
rw [l.1.prod_hom ofSubtype, l.2.1, ofSubtype_subtypePerm _ h₂]
conv =>
congr
rw [← l.2.1]
simp_rw [← hl'₂]
rw [sign_prod_list_swap l.2.2, sign_prod_list_swap hl', List.length_map]
theorem sign_eq_sign_of_equiv [DecidableEq β] [Fintype β] (f : Perm α) (g : Perm β) (e : α ≃ β)
(h : ∀ x, e (f x) = g (e x)) : sign f = sign g := by
have hg : g = (e.symm.trans f).trans e := Equiv.ext <| by simp [h]
rw [hg, sign_symm_trans_trans]
theorem sign_bij [DecidableEq β] [Fintype β] {f : Perm α} {g : Perm β} (i : ∀ x : α, f x ≠ x → β)
(h : ∀ x hx hx', i (f x) hx' = g (i x hx)) (hi : ∀ x₁ x₂ hx₁ hx₂, i x₁ hx₁ = i x₂ hx₂ → x₁ = x₂)
(hg : ∀ y, g y ≠ y → ∃ x hx, i x hx = y) : sign f = sign g :=
calc
sign f = sign (subtypePerm f <| by simp : Perm { x // f x ≠ x }) :=
(sign_subtypePerm _ _ fun _ => id).symm
_ = sign (subtypePerm g <| by simp : Perm { x // g x ≠ x }) :=
sign_eq_sign_of_equiv _ _
(Equiv.ofBijective
(fun x : { x // f x ≠ x } =>
(⟨i x.1 x.2, by
have : f (f x) ≠ f x := mt (fun h => f.injective h) x.2
rw [← h _ x.2 this]
exact mt (hi _ _ this x.2) x.2⟩ :
{ y // g y ≠ y }))
⟨fun ⟨_, _⟩ ⟨_, _⟩ h => Subtype.eq (hi _ _ _ _ (Subtype.mk.inj h)), fun ⟨y, hy⟩ =>
let ⟨x, hfx, hx⟩ := hg y hy
⟨⟨x, hfx⟩, Subtype.eq hx⟩⟩)
fun ⟨x, _⟩ => Subtype.eq (h x _ _)
_ = sign g := sign_subtypePerm _ _ fun _ => id
/-- If we apply `prod_extendRight a (σ a)` for all `a : α` in turn,
we get `prod_congrRight σ`. -/
theorem prod_prodExtendRight {α : Type*} [DecidableEq α] (σ : α → Perm β) {l : List α}
(hl : l.Nodup) (mem_l : ∀ a, a ∈ l) :
(l.map fun a => prodExtendRight a (σ a)).prod = prodCongrRight σ := by
ext ⟨a, b⟩ : 1
-- We'll use induction on the list of elements,
-- but we have to keep track of whether we already passed `a` in the list.
suffices a ∈ l ∧ (l.map fun a => prodExtendRight a (σ a)).prod (a, b) = (a, σ a b) ∨
a ∉ l ∧ (l.map fun a => prodExtendRight a (σ a)).prod (a, b) = (a, b) by
obtain ⟨_, prod_eq⟩ := Or.resolve_right this (not_and.mpr fun h _ => h (mem_l a))
rw [prod_eq, prodCongrRight_apply]
clear mem_l
induction l with
| nil =>
refine Or.inr ⟨List.not_mem_nil, ?_⟩
rw [List.map_nil, List.prod_nil, one_apply]
| cons a' l ih =>
rw [List.map_cons, List.prod_cons, mul_apply]
rcases ih (List.nodup_cons.mp hl).2 with (⟨mem_l, prod_eq⟩ | ⟨notMem_l, prod_eq⟩) <;>
rw [prod_eq]
· refine Or.inl ⟨List.mem_cons_of_mem _ mem_l, ?_⟩
rw [prodExtendRight_apply_ne _ fun h : a = a' => (List.nodup_cons.mp hl).1 (h ▸ mem_l)]
by_cases ha' : a = a'
· rw [← ha'] at *
refine Or.inl ⟨l.mem_cons_self, ?_⟩
rw [prodExtendRight_apply_eq]
· refine Or.inr ⟨fun h => not_or_intro ha' notMem_l ((List.mem_cons).mp h), ?_⟩
rw [prodExtendRight_apply_ne _ ha']
section congr
variable [DecidableEq β] [Fintype β]
@[simp]
theorem sign_prodExtendRight (a : α) (σ : Perm β) : sign (prodExtendRight a σ) = sign σ :=
sign_bij (fun (ab : α × β) _ => ab.snd)
(fun ⟨a', b⟩ hab _ => by simp [eq_of_prodExtendRight_ne hab])
(fun ⟨a₁, b₁⟩ ⟨a₂, b₂⟩ hab₁ hab₂ h => by
simpa [eq_of_prodExtendRight_ne hab₁, eq_of_prodExtendRight_ne hab₂] using h)
fun y hy => ⟨(a, y), by simpa, by simp⟩
theorem sign_prodCongrRight (σ : α → Perm β) : sign (prodCongrRight σ) = ∏ k, sign (σ k) := by
obtain ⟨l, hl, mem_l⟩ := Finite.exists_univ_list α
have l_to_finset : l.toFinset = Finset.univ := by
apply eq_top_iff.mpr
intro b _
exact List.mem_toFinset.mpr (mem_l b)
rw [← prod_prodExtendRight σ hl mem_l, map_list_prod sign, List.map_map, ← l_to_finset,
List.prod_toFinset _ hl]
simp_rw [← fun a => sign_prodExtendRight a (σ a), Function.comp_def]
theorem sign_prodCongrLeft (σ : α → Perm β) : sign (prodCongrLeft σ) = ∏ k, sign (σ k) := by
refine (sign_eq_sign_of_equiv _ _ (prodComm β α) ?_).trans (sign_prodCongrRight σ)
rintro ⟨b, α⟩
rfl
@[simp]
theorem sign_permCongr (e : α ≃ β) (p : Perm α) : sign (e.permCongr p) = sign p :=
sign_eq_sign_of_equiv _ _ e.symm (by simp)
@[simp]
theorem sign_sumCongr (σa : Perm α) (σb : Perm β) : sign (sumCongr σa σb) = sign σa * sign σb := by
suffices sign (sumCongr σa (1 : Perm β)) = sign σa ∧ sign (sumCongr (1 : Perm α) σb) = sign σb
by rw [← this.1, ← this.2, ← sign_mul, sumCongr_mul, one_mul, mul_one]
constructor
· induction σa using swap_induction_on with
| one => simp
| swap_mul σa' a₁ a₂ ha ih =>
rw [← one_mul (1 : Perm β), ← sumCongr_mul, sign_mul, sign_mul, ih, sumCongr_swap_one,
sign_swap ha, sign_swap (Sum.inl_injective.ne_iff.mpr ha)]
· induction σb using swap_induction_on with
| one => simp
| swap_mul σb' b₁ b₂ hb ih =>
rw [← one_mul (1 : Perm α), ← sumCongr_mul, sign_mul, sign_mul, ih, sumCongr_one_swap,
sign_swap hb, sign_swap (Sum.inr_injective.ne_iff.mpr hb)]
@[simp]
theorem sign_subtypeCongr {p : α → Prop} [DecidablePred p] (ep : Perm { a // p a })
(en : Perm { a // ¬p a }) : sign (ep.subtypeCongr en) = sign ep * sign en := by
simp [subtypeCongr]
@[simp]
theorem sign_extendDomain (e : Perm α) {p : β → Prop} [DecidablePred p] (f : α ≃ Subtype p) :
Equiv.Perm.sign (e.extendDomain f) = Equiv.Perm.sign e := by
simp only [Equiv.Perm.extendDomain, sign_subtypeCongr, sign_permCongr, sign_refl, mul_one]
@[simp]
theorem sign_ofSubtype {p : α → Prop} [DecidablePred p] (f : Equiv.Perm (Subtype p)) :
sign (ofSubtype f) = sign f :=
sign_extendDomain f (Equiv.refl (Subtype p))
end congr
end SignType.sign
@[simp]
theorem viaFintypeEmbedding_sign
[Fintype α] [Fintype β] [DecidableEq β] (e : Equiv.Perm α) (f : α ↪ β) :
sign (e.viaFintypeEmbedding f) = sign e := by
simp [viaFintypeEmbedding]
section Finset
variable [Fintype α]
/-- Permutations of a given sign. -/
def ofSign (s : ℤˣ) : Finset (Perm α) := univ.filter (sign · = s)
@[simp]
lemma mem_ofSign {s : ℤˣ} {σ : Perm α} : σ ∈ ofSign s ↔ σ.sign = s := by
rw [ofSign, mem_filter, and_iff_right (mem_univ σ)]
lemma ofSign_disjoint : _root_.Disjoint (ofSign 1 : Finset (Perm α)) (ofSign (-1)) := by
rw [Finset.disjoint_iff_ne]
rintro σ hσ τ hτ rfl
rw [mem_ofSign] at hσ hτ
have := hσ.symm.trans hτ
contradiction
lemma ofSign_disjUnion :
(ofSign 1).disjUnion (ofSign (-1)) ofSign_disjoint = (univ : Finset (Perm α)) := by
ext σ
simp_rw [mem_disjUnion, mem_ofSign, Int.units_eq_one_or, mem_univ]
end Finset
end Equiv.Perm |
.lake/packages/mathlib/Mathlib/GroupTheory/Perm/Option.lean | import Mathlib.Data.Fintype.Option
import Mathlib.GroupTheory.Perm.Sign
/-!
# Permutations of `Option α`
-/
open Equiv
@[simp]
theorem Equiv.optionCongr_one {α : Type*} : (1 : Perm α).optionCongr = 1 :=
Equiv.optionCongr_refl
@[simp]
theorem Equiv.optionCongr_swap {α : Type*} [DecidableEq α] (x y : α) :
optionCongr (swap x y) = swap (some x) (some y) := by
ext (_ | i)
· simp [swap_apply_of_ne_of_ne]
· by_cases hx : i = x
· simp only [hx, optionCongr_apply, Option.map_some, swap_apply_left,
Option.some.injEq]
by_cases hy : i = y <;> simp [hx, hy, swap_apply_of_ne_of_ne]
@[simp]
theorem Equiv.optionCongr_sign {α : Type*} [DecidableEq α] [Fintype α] (e : Perm α) :
Perm.sign e.optionCongr = Perm.sign e := by
induction e using Perm.swap_induction_on with
| one => simp [Perm.one_def]
| swap_mul f x y hne h =>
simp [h, hne, Perm.mul_def]
@[simp]
theorem map_equiv_removeNone {α : Type*} [DecidableEq α] (σ : Perm (Option α)) :
(removeNone σ).optionCongr = swap none (σ none) * σ := by
ext1 x
have : Option.map (⇑(removeNone σ)) x = (swap none (σ none)) (σ x) := by
obtain - | x := x
· simp
· cases h : σ (some _)
· simp [removeNone_none _ h]
· have hn : σ (some x) ≠ none := by simp [h]
have hσn : σ (some x) ≠ σ none := σ.injective.ne (by simp)
simp [removeNone_some _ ⟨_, h⟩, ← h, swap_apply_of_ne_of_ne hn hσn]
simpa using this
/-- Permutations of `Option α` are equivalent to fixing an
`Option α` and permuting the remaining with a `Perm α`.
The fixed `Option α` is swapped with `none`. -/
@[simps]
def Equiv.Perm.decomposeOption {α : Type*} [DecidableEq α] :
Perm (Option α) ≃ Option α × Perm α where
toFun σ := (σ none, removeNone σ)
invFun i := swap none i.1 * i.2.optionCongr
left_inv σ := by simp
right_inv := fun ⟨x, σ⟩ => by
have : removeNone (swap none x * σ.optionCongr) = σ :=
Equiv.optionCongr_injective (by simp [← mul_assoc])
simp [this]
theorem Equiv.Perm.decomposeOption_symm_of_none_apply {α : Type*} [DecidableEq α] (e : Perm α)
(i : Option α) : Equiv.Perm.decomposeOption.symm (none, e) i = i.map e := by simp
theorem Equiv.Perm.decomposeOption_symm_sign {α : Type*} [DecidableEq α] [Fintype α] (e : Perm α) :
Perm.sign (Equiv.Perm.decomposeOption.symm (none, e)) = Perm.sign e := by simp
/-- The set of all permutations of `Option α` can be constructed by augmenting the set of
permutations of `α` by each element of `Option α` in turn. -/
theorem Finset.univ_perm_option {α : Type*} [DecidableEq α] [Fintype α] :
@Finset.univ (Perm <| Option α) _ =
(Finset.univ : Finset <| Option α × Perm α).map Equiv.Perm.decomposeOption.symm.toEmbedding :=
(Finset.univ_map_equiv_to_embedding _).symm |
.lake/packages/mathlib/Mathlib/GroupTheory/Perm/Support.lean | import Mathlib.Data.Fintype.Card
import Mathlib.Algebra.Group.Commute.Basic
import Mathlib.Algebra.Group.End
import Mathlib.Data.Finset.NoncommProd
/-!
# support of a permutation
## Main definitions
In the following, `f g : Equiv.Perm α`.
* `Equiv.Perm.Disjoint`: two permutations `f` and `g` are `Disjoint` if every element is fixed
either by `f`, or by `g`.
Equivalently, `f` and `g` are `Disjoint` iff their `support` are disjoint.
* `Equiv.Perm.IsSwap`: `f = swap x y` for `x ≠ y`.
* `Equiv.Perm.support`: the elements `x : α` that are not fixed by `f`.
Assume `α` is a Fintype:
* `Equiv.Perm.fixed_point_card_lt_of_ne_one f` says that `f` has
strictly less than `Fintype.card α - 1` fixed points, unless `f = 1`.
(Equivalently, `f.support` has at least 2 elements.)
-/
open Equiv Finset Function
namespace Equiv.Perm
variable {α : Type*}
section Disjoint
/-- Two permutations `f` and `g` are `Disjoint` if their supports are disjoint, i.e.,
every element is fixed either by `f`, or by `g`. -/
def Disjoint (f g : Perm α) :=
∀ x, f x = x ∨ g x = x
variable {f g h : Perm α}
@[symm]
theorem Disjoint.symm : Disjoint f g → Disjoint g f := by simp only [Disjoint, or_comm, imp_self]
theorem Disjoint.symmetric : Symmetric (@Disjoint α) := fun _ _ => Disjoint.symm
instance : IsSymm (Perm α) Disjoint :=
⟨Disjoint.symmetric⟩
theorem disjoint_comm : Disjoint f g ↔ Disjoint g f :=
⟨Disjoint.symm, Disjoint.symm⟩
theorem Disjoint.commute (h : Disjoint f g) : Commute f g :=
Equiv.ext fun x =>
(h x).elim
(fun hf =>
(h (g x)).elim (fun hg => by simp [mul_apply, hf, hg]) fun hg => by
simp [mul_apply, hf, g.injective hg])
fun hg =>
(h (f x)).elim (fun hf => by simp [mul_apply, f.injective hf, hg]) fun hf => by
simp [mul_apply, hf, hg]
@[simp]
theorem disjoint_one_left (f : Perm α) : Disjoint 1 f := fun _ => Or.inl rfl
@[simp]
theorem disjoint_one_right (f : Perm α) : Disjoint f 1 := fun _ => Or.inr rfl
theorem disjoint_iff_eq_or_eq : Disjoint f g ↔ ∀ x : α, f x = x ∨ g x = x :=
Iff.rfl
@[simp]
theorem disjoint_refl_iff : Disjoint f f ↔ f = 1 := by
refine ⟨fun h => ?_, fun h => h.symm ▸ disjoint_one_left 1⟩
ext x
rcases h x with hx | hx <;> simp [hx]
theorem Disjoint.inv_left (h : Disjoint f g) : Disjoint f⁻¹ g := by
intro x
rw [inv_eq_iff_eq, eq_comm]
exact h x
theorem Disjoint.inv_right (h : Disjoint f g) : Disjoint f g⁻¹ :=
h.symm.inv_left.symm
@[simp]
theorem disjoint_inv_left_iff : Disjoint f⁻¹ g ↔ Disjoint f g := by
refine ⟨fun h => ?_, Disjoint.inv_left⟩
convert h.inv_left
@[simp]
theorem disjoint_inv_right_iff : Disjoint f g⁻¹ ↔ Disjoint f g := by
rw [disjoint_comm, disjoint_inv_left_iff, disjoint_comm]
theorem Disjoint.mul_left (H1 : Disjoint f h) (H2 : Disjoint g h) : Disjoint (f * g) h := fun x =>
by cases H1 x <;> cases H2 x <;> simp [*]
theorem Disjoint.mul_right (H1 : Disjoint f g) (H2 : Disjoint f h) : Disjoint f (g * h) := by
rw [disjoint_comm]
exact H1.symm.mul_left H2.symm
@[simp]
theorem disjoint_conj (h : Perm α) : Disjoint (h * f * h⁻¹) (h * g * h⁻¹) ↔ Disjoint f g :=
(h⁻¹).forall_congr fun {_} ↦ by simp only [mul_apply, eq_inv_iff_eq]
theorem Disjoint.conj (H : Disjoint f g) (h : Perm α) : Disjoint (h * f * h⁻¹) (h * g * h⁻¹) :=
(disjoint_conj h).2 H
theorem disjoint_prod_right (l : List (Perm α)) (h : ∀ g ∈ l, Disjoint f g) :
Disjoint f l.prod := by
induction l with
| nil => exact disjoint_one_right _
| cons g l ih =>
rw [List.prod_cons]
exact (h _ List.mem_cons_self).mul_right (ih fun g hg => h g (List.mem_cons_of_mem _ hg))
theorem disjoint_noncommProd_right {ι : Type*} {k : ι → Perm α} {s : Finset ι}
(hs : Set.Pairwise s fun i j ↦ Commute (k i) (k j))
(hg : ∀ i ∈ s, g.Disjoint (k i)) :
Disjoint g (s.noncommProd k (hs)) :=
noncommProd_induction s k hs g.Disjoint (fun _ _ ↦ Disjoint.mul_right) (disjoint_one_right g) hg
open scoped List in
theorem disjoint_prod_perm {l₁ l₂ : List (Perm α)} (hl : l₁.Pairwise Disjoint) (hp : l₁ ~ l₂) :
l₁.prod = l₂.prod :=
hp.prod_eq' <| hl.imp Disjoint.commute
theorem nodup_of_pairwise_disjoint {l : List (Perm α)} (h1 : (1 : Perm α) ∉ l)
(h2 : l.Pairwise Disjoint) : l.Nodup := by
refine List.Pairwise.imp_of_mem ?_ h2
intro τ σ h_mem _ h_disjoint _
subst τ
suffices (σ : Perm α) = 1 by
rw [this] at h_mem
exact h1 h_mem
exact ext fun a => or_self_iff.mp (h_disjoint a)
theorem pow_apply_eq_self_of_apply_eq_self {x : α} (hfx : f x = x) : ∀ n : ℕ, (f ^ n) x = x
| 0 => rfl
| n + 1 => by rw [pow_succ, mul_apply, hfx, pow_apply_eq_self_of_apply_eq_self hfx n]
theorem zpow_apply_eq_self_of_apply_eq_self {x : α} (hfx : f x = x) : ∀ n : ℤ, (f ^ n) x = x
| (n : ℕ) => pow_apply_eq_self_of_apply_eq_self hfx n
| Int.negSucc n => by rw [zpow_negSucc, inv_eq_iff_eq, pow_apply_eq_self_of_apply_eq_self hfx]
theorem pow_apply_eq_of_apply_apply_eq_self {x : α} (hffx : f (f x) = x) :
∀ n : ℕ, (f ^ n) x = x ∨ (f ^ n) x = f x
| 0 => Or.inl rfl
| n + 1 =>
(pow_apply_eq_of_apply_apply_eq_self hffx n).elim
(fun h => Or.inr (by rw [pow_succ', mul_apply, h]))
fun h => Or.inl (by rw [pow_succ', mul_apply, h, hffx])
theorem zpow_apply_eq_of_apply_apply_eq_self {x : α} (hffx : f (f x) = x) :
∀ i : ℤ, (f ^ i) x = x ∨ (f ^ i) x = f x
| (n : ℕ) => pow_apply_eq_of_apply_apply_eq_self hffx n
| Int.negSucc n => by
rw [zpow_negSucc, inv_eq_iff_eq, ← f.injective.eq_iff, ← mul_apply, ← pow_succ', eq_comm,
inv_eq_iff_eq, ← mul_apply, ← pow_succ, @eq_comm _ x, or_comm]
exact pow_apply_eq_of_apply_apply_eq_self hffx _
theorem Disjoint.mul_apply_eq_iff {σ τ : Perm α} (hστ : Disjoint σ τ) {a : α} :
(σ * τ) a = a ↔ σ a = a ∧ τ a = a := by
refine ⟨fun h => ?_, fun h => by rw [mul_apply, h.2, h.1]⟩
rcases hστ a with hσ | hτ
· exact ⟨hσ, σ.injective (h.trans hσ.symm)⟩
· exact ⟨(congr_arg σ hτ).symm.trans h, hτ⟩
theorem Disjoint.mul_eq_one_iff {σ τ : Perm α} (hστ : Disjoint σ τ) :
σ * τ = 1 ↔ σ = 1 ∧ τ = 1 := by
simp_rw [Perm.ext_iff, one_apply, hστ.mul_apply_eq_iff, forall_and]
theorem Disjoint.zpow_disjoint_zpow {σ τ : Perm α} (hστ : Disjoint σ τ) (m n : ℤ) :
Disjoint (σ ^ m) (τ ^ n) := fun x =>
Or.imp (fun h => zpow_apply_eq_self_of_apply_eq_self h m)
(fun h => zpow_apply_eq_self_of_apply_eq_self h n) (hστ x)
theorem Disjoint.pow_disjoint_pow {σ τ : Perm α} (hστ : Disjoint σ τ) (m n : ℕ) :
Disjoint (σ ^ m) (τ ^ n) :=
hστ.zpow_disjoint_zpow m n
end Disjoint
section IsSwap
variable [DecidableEq α]
/-- `f.IsSwap` indicates that the permutation `f` is a transposition of two elements. -/
def IsSwap (f : Perm α) : Prop :=
∃ x y, x ≠ y ∧ f = swap x y
@[simp]
theorem ofSubtype_swap_eq {p : α → Prop} [DecidablePred p] (x y : Subtype p) :
ofSubtype (Equiv.swap x y) = Equiv.swap ↑x ↑y :=
Equiv.ext fun z => by
by_cases hz : p z
· rw [swap_apply_def, ofSubtype_apply_of_mem _ hz]
split_ifs with hzx hzy
· simp_rw [hzx, Subtype.coe_eta, swap_apply_left]
· simp_rw [hzy, Subtype.coe_eta, swap_apply_right]
· rw [swap_apply_of_ne_of_ne] <;>
simp [Subtype.ext_iff, *]
· rw [ofSubtype_apply_of_not_mem _ hz, swap_apply_of_ne_of_ne] <;> grind
theorem IsSwap.of_subtype_isSwap {p : α → Prop} [DecidablePred p] {f : Perm (Subtype p)}
(h : f.IsSwap) : (ofSubtype f).IsSwap :=
let ⟨⟨x, hx⟩, ⟨y, hy⟩, hxy⟩ := h
⟨x, y, by
simp only [Ne, Subtype.ext_iff] at hxy
exact hxy.1, by
rw [hxy.2, ofSubtype_swap_eq]⟩
theorem ne_and_ne_of_swap_mul_apply_ne_self {f : Perm α} {x y : α} (hy : (swap x (f x) * f) y ≠ y) :
f y ≠ y ∧ y ≠ x := by
simp only [swap_apply_def, mul_apply, f.injective.eq_iff] at *
grind
end IsSwap
section support
section Set
variable (p q : Perm α)
theorem set_support_inv_eq : {x | p⁻¹ x ≠ x} = {x | p x ≠ x} := by
ext; simp [inv_def, eq_symm_apply, eq_comm]
theorem set_support_apply_mem {p : Perm α} {a : α} :
p a ∈ { x | p x ≠ x } ↔ a ∈ { x | p x ≠ x } := by simp
theorem set_support_zpow_subset (n : ℤ) : { x | (p ^ n) x ≠ x } ⊆ { x | p x ≠ x } := by
intro x
simp only [Set.mem_setOf_eq, Ne]
intro hx H
simp [zpow_apply_eq_self_of_apply_eq_self H] at hx
theorem set_support_mul_subset : { x | (p * q) x ≠ x } ⊆ { x | p x ≠ x } ∪ { x | q x ≠ x } := by
intro x
simp only [Perm.coe_mul, Function.comp_apply, Ne, Set.mem_union, Set.mem_setOf_eq]
by_cases hq : q x = x <;> simp [hq]
end Set
@[simp]
theorem apply_pow_apply_eq_iff (f : Perm α) (n : ℕ) {x : α} :
f ((f ^ n) x) = (f ^ n) x ↔ f x = x := by
rw [← mul_apply, Commute.self_pow f, mul_apply, apply_eq_iff_eq]
@[simp]
theorem apply_zpow_apply_eq_iff (f : Perm α) (n : ℤ) {x : α} :
f ((f ^ n) x) = (f ^ n) x ↔ f x = x := by
rw [← mul_apply, Commute.self_zpow f, mul_apply, apply_eq_iff_eq]
variable [DecidableEq α] [Fintype α] {f g : Perm α}
/-- The `Finset` of nonfixed points of a permutation. -/
def support (f : Perm α) : Finset α := {x | f x ≠ x}
@[simp]
theorem mem_support {x : α} : x ∈ f.support ↔ f x ≠ x := by
rw [support, mem_filter, and_iff_right (mem_univ x)]
theorem notMem_support {x : α} : x ∉ f.support ↔ f x = x := by simp
@[deprecated (since := "2025-05-23")] alias not_mem_support := notMem_support
theorem coe_support_eq_set_support (f : Perm α) : (f.support : Set α) = { x | f x ≠ x } := by
ext
simp
@[simp]
theorem support_eq_empty_iff {σ : Perm α} : σ.support = ∅ ↔ σ = 1 := by
simp_rw [Finset.ext_iff, mem_support, Finset.notMem_empty, iff_false, not_not,
Equiv.Perm.ext_iff, one_apply]
@[simp]
theorem support_one : (1 : Perm α).support = ∅ := by rw [support_eq_empty_iff]
@[simp]
theorem support_refl : support (Equiv.refl α) = ∅ :=
support_one
theorem support_congr (h : f.support ⊆ g.support) (h' : ∀ x ∈ g.support, f x = g x) : f = g := by
ext x
by_cases hx : x ∈ g.support
· exact h' x hx
· rw [notMem_support.mp hx, ← notMem_support]
exact fun H => hx (h H)
/-- If g and c commute, then g stabilizes the support of c -/
theorem mem_support_iff_of_commute {g c : Perm α} (hgc : Commute g c) (x : α) :
g x ∈ c.support ↔ x ∈ c.support := by
simp only [mem_support, not_iff_not, ← mul_apply]
rw [← hgc, mul_apply, Equiv.apply_eq_iff_eq]
theorem support_mul_le (f g : Perm α) : (f * g).support ≤ f.support ⊔ g.support := fun x => by
simp only [sup_eq_union]
rw [mem_union, mem_support, mem_support, mem_support, mul_apply, ← not_and_or, not_imp_not]
rintro ⟨hf, hg⟩
rw [hg, hf]
theorem exists_mem_support_of_mem_support_prod {l : List (Perm α)} {x : α}
(hx : x ∈ l.prod.support) : ∃ f : Perm α, f ∈ l ∧ x ∈ f.support := by
contrapose! hx
simp_rw [mem_support, not_not] at hx ⊢
induction l with
| nil => rfl
| cons f l ih =>
rw [List.prod_cons, mul_apply, ih, hx]
· simp only [List.mem_cons, true_or]
grind
theorem support_pow_le (σ : Perm α) (n : ℕ) : (σ ^ n).support ≤ σ.support := fun _ h1 =>
mem_support.mpr fun h2 => mem_support.mp h1 (pow_apply_eq_self_of_apply_eq_self h2 n)
@[simp]
theorem support_inv (σ : Perm α) : support σ⁻¹ = σ.support := by
simp_rw [Finset.ext_iff, mem_support, not_iff_not, inv_eq_iff_eq.trans eq_comm, imp_true_iff]
theorem apply_mem_support {x : α} : f x ∈ f.support ↔ x ∈ f.support := by
rw [mem_support, mem_support, Ne, Ne, apply_eq_iff_eq]
/-- The support of a permutation is invariant -/
theorem isInvariant_of_support_le {c : Perm α} {s : Finset α} (hcs : c.support ≤ s) (x : α) :
c x ∈ s ↔ x ∈ s := by
by_cases hx' : x ∈ c.support
· simp only [hcs hx', hcs (apply_mem_support.mpr hx')]
· rw [notMem_support.mp hx']
/-- A permutation c is the extension of a restriction of g to s
iff its support is contained in s and its restriction is that of g -/
lemma ofSubtype_eq_iff {g c : Equiv.Perm α} {s : Finset α}
(hg : ∀ x, g x ∈ s ↔ x ∈ s) :
ofSubtype (g.subtypePerm hg) = c ↔
c.support ≤ s ∧
∀ (hc' : ∀ x, c x ∈ s ↔ x ∈ s), c.subtypePerm hc' = g.subtypePerm hg := by
simp only [Equiv.ext_iff, subtypePerm_apply, Subtype.mk.injEq, Subtype.forall]
constructor
· intro h
constructor
· intro a ha
by_contra ha'
rw [mem_support, ← h a, ofSubtype_apply_of_not_mem (p := (· ∈ s)) _ ha'] at ha
exact ha rfl
· intro _ a ha
rw [← h a, ofSubtype_apply_of_mem (p := (· ∈ s)) _ ha, subtypePerm_apply]
· rintro ⟨hc, h⟩ a
specialize h (isInvariant_of_support_le hc)
by_cases ha : a ∈ s
· rw [h a ha, ofSubtype_apply_of_mem (p := (· ∈ s)) _ ha, subtypePerm_apply]
· rw [ofSubtype_apply_of_not_mem (p := (· ∈ s)) _ ha, eq_comm, ← notMem_support]
exact Finset.notMem_mono hc ha
theorem support_ofSubtype {p : α → Prop} [DecidablePred p] (u : Perm (Subtype p)) :
(ofSubtype u).support = u.support.map (Function.Embedding.subtype p) := by
ext x
simp only [mem_support, ne_eq, Finset.mem_map, Function.Embedding.coe_subtype, Subtype.exists,
exists_and_right, exists_eq_right, not_iff_comm, not_exists, not_not]
by_cases hx : p x
· simp only [forall_prop_of_true hx, ofSubtype_apply_of_mem u hx, ← Subtype.coe_inj]
· simp only [forall_prop_of_false hx, ofSubtype_apply_of_not_mem u hx]
theorem mem_support_of_mem_noncommProd_support {α β : Type*} [DecidableEq β] [Fintype β]
{s : Finset α} {f : α → Perm β}
{comm : (s : Set α).Pairwise (Commute on f)} {x : β} (hx : x ∈ (s.noncommProd f comm).support) :
∃ a ∈ s, x ∈ (f a).support := by
contrapose! hx
classical
revert hx comm s
apply Finset.induction
· simp
· intro a s ha ih comm hs
rw [Finset.noncommProd_insert_of_notMem s a f comm ha]
apply mt (Finset.mem_of_subset (support_mul_le _ _))
rw [Finset.sup_eq_union, Finset.notMem_union]
exact ⟨hs a (s.mem_insert_self a), ih (fun a ha ↦ hs a (Finset.mem_insert_of_mem ha))⟩
theorem pow_apply_mem_support {n : ℕ} {x : α} : (f ^ n) x ∈ f.support ↔ x ∈ f.support := by
simp only [mem_support, ne_eq, apply_pow_apply_eq_iff]
theorem zpow_apply_mem_support {n : ℤ} {x : α} : (f ^ n) x ∈ f.support ↔ x ∈ f.support := by
simp only [mem_support, ne_eq, apply_zpow_apply_eq_iff]
theorem pow_eq_on_of_mem_support (h : ∀ x ∈ f.support ∩ g.support, f x = g x) (k : ℕ) :
∀ x ∈ f.support ∩ g.support, (f ^ k) x = (g ^ k) x := by
induction k with
| zero => simp
| succ k hk =>
intro x hx
rw [pow_succ, mul_apply, pow_succ, mul_apply, h _ hx, hk]
rwa [mem_inter, apply_mem_support, ← h _ hx, apply_mem_support, ← mem_inter]
theorem disjoint_iff_disjoint_support : Disjoint f g ↔ _root_.Disjoint f.support g.support := by
simp [disjoint_iff_eq_or_eq, disjoint_iff, disjoint_iff, Finset.ext_iff,
imp_iff_not_or]
theorem Disjoint.disjoint_support (h : Disjoint f g) : _root_.Disjoint f.support g.support :=
disjoint_iff_disjoint_support.1 h
theorem Disjoint.support_mul (h : Disjoint f g) : (f * g).support = f.support ∪ g.support := by
refine le_antisymm (support_mul_le _ _) fun a => ?_
rw [mem_union, mem_support, mem_support, mem_support, mul_apply, ← not_and_or, not_imp_not]
exact
(h a).elim (fun hf h => ⟨hf, f.apply_eq_iff_eq.mp (h.trans hf.symm)⟩) fun hg h =>
⟨(congr_arg f hg).symm.trans h, hg⟩
theorem support_prod_of_pairwise_disjoint (l : List (Perm α)) (h : l.Pairwise Disjoint) :
l.prod.support = (l.map support).foldr (· ⊔ ·) ⊥ := by
induction l with
| nil => simp
| cons hd tl hl =>
rw [List.pairwise_cons] at h
have : Disjoint hd tl.prod := disjoint_prod_right _ h.left
simp [this.support_mul, hl h.right]
theorem support_noncommProd {ι : Type*} {k : ι → Perm α} {s : Finset ι}
(hs : Set.Pairwise s fun i j ↦ Disjoint (k i) (k j)) :
(s.noncommProd k (hs.imp (fun _ _ ↦ Perm.Disjoint.commute))).support =
s.biUnion fun i ↦ (k i).support := by
classical
induction s using Finset.induction_on with
| empty => simp
| insert i s hi hrec =>
have hs' : (s : Set ι).Pairwise fun i j ↦ Disjoint (k i) (k j) :=
hs.mono (by simp only [Finset.coe_insert, Set.subset_insert])
rw [Finset.noncommProd_insert_of_notMem _ _ _ _ hi, Finset.biUnion_insert]
rw [Equiv.Perm.Disjoint.support_mul, hrec hs']
apply disjoint_noncommProd_right
intro j hj
apply hs _ _ (ne_of_mem_of_not_mem hj hi).symm <;>
simp only [Finset.coe_insert, Set.mem_insert_iff, Finset.mem_coe, hj, or_true, true_or]
theorem support_prod_le (l : List (Perm α)) : l.prod.support ≤ (l.map support).foldr (· ⊔ ·) ⊥ := by
induction l with
| nil => simp
| cons hd tl hl =>
rw [List.prod_cons, List.map_cons, List.foldr_cons]
refine (support_mul_le hd tl.prod).trans ?_
exact sup_le_sup le_rfl hl
theorem support_zpow_le (σ : Perm α) (n : ℤ) : (σ ^ n).support ≤ σ.support := fun _ h1 =>
mem_support.mpr fun h2 => mem_support.mp h1 (zpow_apply_eq_self_of_apply_eq_self h2 n)
@[simp]
theorem support_swap {x y : α} (h : x ≠ y) : support (swap x y) = {x, y} := by
ext z
by_cases hx : z = x
any_goals simpa [hx] using h.symm
by_cases hy : z = y
· simpa [swap_apply_of_ne_of_ne, hx, hy] using h
· simp [swap_apply_of_ne_of_ne, hx, hy]
theorem support_swap_iff (x y : α) : support (swap x y) = {x, y} ↔ x ≠ y := by
refine ⟨fun h => ?_, fun h => support_swap h⟩
rintro rfl
simp [Finset.ext_iff] at h
theorem support_swap_mul_swap {x y z : α} (h : List.Nodup [x, y, z]) :
support (swap x y * swap y z) = {x, y, z} := by
simp only [List.not_mem_nil, and_true, List.mem_cons, not_false_iff, List.nodup_cons,
and_self_iff, List.nodup_nil] at h
push_neg at h
apply le_antisymm
· convert support_mul_le (swap x y) (swap y z) using 1
rw [support_swap h.left.left, support_swap h.right.left]
simp [-Finset.union_singleton]
· intro
simp only [mem_insert, mem_singleton]
rintro (rfl | rfl | rfl | _) <;>
simp [swap_apply_of_ne_of_ne, h.left.left, h.left.left.symm, h.left.right.symm,
h.left.right.left.symm, h.right.left.symm]
theorem support_swap_mul_ge_support_diff (f : Perm α) (x y : α) :
f.support \ {x, y} ≤ (swap x y * f).support := by
intro
simp only [and_imp, Perm.coe_mul, Function.comp_apply, Ne, mem_support, mem_insert, mem_sdiff,
mem_singleton]
push_neg
rintro ha ⟨hx, hy⟩ H
rw [swap_apply_eq_iff, swap_apply_of_ne_of_ne hx hy] at H
exact ha H
theorem support_swap_mul_eq (f : Perm α) (x : α) (h : f (f x) ≠ x) :
(swap x (f x) * f).support = f.support \ {x} := by
by_cases hx : f x = x
· simp [hx, sdiff_singleton_eq_erase, notMem_support.mpr hx, erase_eq_of_notMem]
ext z
by_cases hzx : z = x
· simp [hzx]
by_cases hzf : z = f x
· simp [hzf, hx, h, swap_apply_of_ne_of_ne]
by_cases hzfx : f z = x
· simp [Ne.symm hzx, hzx, Ne.symm hzf, hzfx]
· simp [hzx, hzfx, f.injective.ne hzx, swap_apply_of_ne_of_ne]
theorem mem_support_swap_mul_imp_mem_support_ne {x y : α} (hy : y ∈ support (swap x (f x) * f)) :
y ∈ support f ∧ y ≠ x := by
simp only [mem_support, swap_apply_def, mul_apply, f.injective.eq_iff] at *
grind
theorem Disjoint.mem_imp (h : Disjoint f g) {x : α} (hx : x ∈ f.support) : x ∉ g.support :=
disjoint_left.mp h.disjoint_support hx
theorem eq_on_support_mem_disjoint {l : List (Perm α)} (h : f ∈ l) (hl : l.Pairwise Disjoint) :
∀ x ∈ f.support, f x = l.prod x := by
induction l with
| nil => simp at h
| cons hd tl IH =>
intro x hx
rw [List.pairwise_cons] at hl
rw [List.mem_cons] at h
rcases h with (rfl | h)
· rw [List.prod_cons, mul_apply,
notMem_support.mp ((disjoint_prod_right tl hl.left).mem_imp hx)]
· rw [List.prod_cons, mul_apply, ← IH h hl.right _ hx, eq_comm, ← notMem_support]
refine (hl.left _ h).symm.mem_imp ?_
simpa using hx
theorem Disjoint.mono {x y : Perm α} (h : Disjoint f g) (hf : x.support ≤ f.support)
(hg : y.support ≤ g.support) : Disjoint x y := by
rw [disjoint_iff_disjoint_support] at h ⊢
exact h.mono hf hg
theorem support_le_prod_of_mem {l : List (Perm α)} (h : f ∈ l) (hl : l.Pairwise Disjoint) :
f.support ≤ l.prod.support := by
intro x hx
rwa [mem_support, ← eq_on_support_mem_disjoint h hl _ hx, ← mem_support]
section ExtendDomain
variable {β : Type*} [DecidableEq β] [Fintype β] {p : β → Prop} [DecidablePred p]
@[simp]
theorem support_extend_domain (f : α ≃ Subtype p) {g : Perm α} :
support (g.extendDomain f) = g.support.map f.asEmbedding := by
ext b
simp only [mem_map, Ne,
mem_support]
by_cases pb : p b
· rw [extendDomain_apply_subtype _ _ pb]
constructor
· rintro h
refine ⟨f.symm ⟨b, pb⟩, ?_, by simp⟩
contrapose! h
simp [h]
· rintro ⟨a, ha, hb⟩
contrapose! ha
obtain rfl : a = f.symm ⟨b, pb⟩ := by
rw [eq_symm_apply]
exact Subtype.coe_injective hb
rw [eq_symm_apply]
exact Subtype.coe_injective ha
· rw [extendDomain_apply_not_subtype _ _ pb]
simp only [not_exists, false_iff, not_and, not_true]
rintro a _ rfl
exact pb (Subtype.prop _)
theorem card_support_extend_domain (f : α ≃ Subtype p) {g : Perm α} :
#(g.extendDomain f).support = #g.support := by simp
end ExtendDomain
section Card
theorem card_support_eq_zero {f : Perm α} : #f.support = 0 ↔ f = 1 := by
rw [Finset.card_eq_zero, support_eq_empty_iff]
theorem one_lt_card_support_of_ne_one {f : Perm α} (h : f ≠ 1) : 1 < #f.support := by
simp_rw [one_lt_card_iff, mem_support, ← not_or]
contrapose! h
ext a
specialize h (f a) a
rwa [apply_eq_iff_eq, or_self_iff, or_self_iff] at h
theorem card_support_ne_one (f : Perm α) : #f.support ≠ 1 := by
by_cases h : f = 1
· exact ne_of_eq_of_ne (card_support_eq_zero.mpr h) zero_ne_one
· exact ne_of_gt (one_lt_card_support_of_ne_one h)
@[simp]
theorem card_support_le_one {f : Perm α} : #f.support ≤ 1 ↔ f = 1 := by
rw [le_iff_lt_or_eq, Nat.lt_succ_iff, Nat.le_zero, card_support_eq_zero, or_iff_not_imp_right,
imp_iff_right f.card_support_ne_one]
theorem two_le_card_support_of_ne_one {f : Perm α} (h : f ≠ 1) : 2 ≤ #f.support :=
one_lt_card_support_of_ne_one h
theorem card_support_swap_mul {f : Perm α} {x : α} (hx : f x ≠ x) :
#(swap x (f x) * f).support < #f.support :=
Finset.card_lt_card
⟨fun _ hz => (mem_support_swap_mul_imp_mem_support_ne hz).left, fun h =>
absurd (h (mem_support.2 hx)) (mt mem_support.1 (by simp))⟩
theorem card_support_swap {x y : α} (hxy : x ≠ y) : #(swap x y).support = 2 :=
show #(swap x y).support = #⟨x ::ₘ y ::ₘ 0, by simp [hxy]⟩ from
congr_arg card <| by simp [support_swap hxy, *, Finset.ext_iff]
@[simp]
theorem card_support_eq_two {f : Perm α} : #f.support = 2 ↔ IsSwap f := by
constructor <;> intro h
· obtain ⟨x, t, hmem, hins, ht⟩ := card_eq_succ.1 h
obtain ⟨y, rfl⟩ := card_eq_one.1 ht
rw [mem_singleton] at hmem
refine ⟨x, y, hmem, ?_⟩
ext a
have key : ∀ b, f b ≠ b ↔ _ := fun b => by rw [← mem_support, ← hins, mem_insert, mem_singleton]
by_cases ha : f a = a
· have ha' := not_or.mp (mt (key a).mpr (not_not.mpr ha))
rw [ha, swap_apply_of_ne_of_ne ha'.1 ha'.2]
· have ha' := (key (f a)).mp (mt f.apply_eq_iff_eq.mp ha)
obtain rfl | rfl := (key a).mp ha
· rw [Or.resolve_left ha' ha, swap_apply_left]
· rw [Or.resolve_right ha' ha, swap_apply_right]
· obtain ⟨x, y, hxy, rfl⟩ := h
exact card_support_swap hxy
theorem Disjoint.card_support_mul (h : Disjoint f g) :
#(f * g).support = #f.support + #g.support := by
rw [← Finset.card_union_of_disjoint]
· congr
ext
simp [h.support_mul]
· simpa using h.disjoint_support
theorem card_support_prod_list_of_pairwise_disjoint {l : List (Perm α)} (h : l.Pairwise Disjoint) :
#l.prod.support = (l.map (card ∘ support)).sum := by
induction l with
| nil => exact card_support_eq_zero.mpr rfl
| cons a t ih =>
obtain ⟨ha, ht⟩ := List.pairwise_cons.1 h
rw [List.prod_cons, List.map_cons, List.sum_cons, ← ih ht]
exact (disjoint_prod_right _ ha).card_support_mul
end Card
end support
@[simp]
theorem support_subtypePerm [DecidableEq α] {s : Finset α} (f : Perm α) (h) :
(f.subtypePerm h : Perm s).support = ({x | f x ≠ x} : Finset s) := by
ext; simp [Subtype.ext_iff]
@[deprecated (since := "2025-05-19")] alias support_subtype_perm := support_subtypePerm
end Equiv.Perm
section FixedPoints
namespace Equiv.Perm
/-!
### Fixed points
-/
variable {α : Type*}
theorem fixed_point_card_lt_of_ne_one [DecidableEq α] [Fintype α] {σ : Perm α} (h : σ ≠ 1) :
#{x | σ x = x} < Fintype.card α - 1 := by
rw [Nat.lt_sub_iff_add_lt, ← Nat.lt_sub_iff_add_lt', ← Finset.card_compl, Finset.compl_filter]
exact one_lt_card_support_of_ne_one h
end Equiv.Perm
end FixedPoints
section Conjugation
namespace Equiv.Perm
variable {α : Type*} [Fintype α] [DecidableEq α] {σ τ : Perm α}
@[simp]
theorem support_conj : (σ * τ * σ⁻¹).support = τ.support.map σ.toEmbedding := by
ext
simp only [mem_map_equiv, Perm.coe_mul, Function.comp_apply, Ne, Perm.mem_support,
Equiv.eq_symm_apply, inv_def]
theorem card_support_conj : #(σ * τ * σ⁻¹).support = #τ.support := by simp
end Equiv.Perm
end Conjugation |
.lake/packages/mathlib/Mathlib/GroupTheory/Perm/ConjAct.lean | import Mathlib.Algebra.Group.Action.Pointwise.Finset
import Mathlib.GroupTheory.Perm.Cycle.Factors
/-!
# Some lemmas pertaining to the action of `ConjAct (Perm α)` on `Perm α`
We prove some lemmas related to the action of `ConjAct (Perm α)` on `Perm α`:
Let `α` be a decidable fintype.
* `conj_support_eq` relates the support of `k • g` with that of `g`
* `cycleFactorsFinset_conj_eq`, `mem_cycleFactorsFinset_conj'`
and `cycleFactorsFinset_conj` relate the set of cycles of `g`, `g.cycleFactorsFinset`,
with that for `k • g`
-/
namespace Equiv.Perm
open scoped Pointwise
variable {α : Type*} [DecidableEq α] [Fintype α]
/-- `a : α` belongs to the support of `k • g` iff
`k⁻¹ * a` belongs to the support of `g` -/
theorem mem_conj_support (k : ConjAct (Perm α)) (g : Perm α) (a : α) :
a ∈ (k • g).support ↔ ConjAct.ofConjAct k⁻¹ a ∈ g.support := by
simp only [mem_support, ConjAct.smul_def, not_iff_not, coe_mul,
Function.comp_apply, ConjAct.ofConjAct_inv]
apply Equiv.apply_eq_iff_eq_symm_apply
theorem cycleFactorsFinset_conj (g k : Perm α) :
(ConjAct.toConjAct k • g).cycleFactorsFinset =
Finset.map (MulAut.conj k).toEquiv.toEmbedding g.cycleFactorsFinset := by
ext c
rw [ConjAct.smul_def, ConjAct.ofConjAct_toConjAct, Finset.mem_map_equiv,
← mem_cycleFactorsFinset_conj g k]
-- We avoid `group` here to minimize imports while low in the hierarchy;
-- typically it would be better to invoke the tactic.
simp [mul_assoc]
/-- A permutation `c` is a cycle of `g` iff `k • c` is a cycle of `k • g` -/
@[simp]
theorem mem_cycleFactorsFinset_conj'
(k : ConjAct (Perm α)) (g c : Perm α) :
k • c ∈ (k • g).cycleFactorsFinset ↔ c ∈ g.cycleFactorsFinset := by
simp only [ConjAct.smul_def]
apply mem_cycleFactorsFinset_conj g k
theorem cycleFactorsFinset_conj_eq
(k : ConjAct (Perm α)) (g : Perm α) :
cycleFactorsFinset (k • g) = k • cycleFactorsFinset g := by
ext c
rw [← mem_cycleFactorsFinset_conj' k⁻¹ (k • g) c]
simp only [inv_smul_smul]
exact Finset.inv_smul_mem_iff
end Equiv.Perm |
.lake/packages/mathlib/Mathlib/GroupTheory/Perm/List.lean | import Mathlib.Algebra.Order.Group.Nat
import Mathlib.Data.List.Rotate
import Mathlib.GroupTheory.Perm.Support
/-!
# Permutations from a list
A list `l : List α` can be interpreted as an `Equiv.Perm α` where each element in the list
is permuted to the next one, defined as `formPerm`. When we have that `Nodup l`,
we prove that `Equiv.Perm.support (formPerm l) = l.toFinset`, and that
`formPerm l` is rotationally invariant, in `formPerm_rotate`.
When there are duplicate elements in `l`, how and in what arrangement with respect to the other
elements they appear in the list determines the formed permutation.
This is because `List.formPerm` is implemented as a product of `Equiv.swap`s.
That means that presence of a sublist of two adjacent duplicates like `[..., x, x, ...]`
will produce the same permutation as if the adjacent duplicates were not present.
The `List.formPerm` definition is meant to primarily be used with `Nodup l`, so that
the resulting permutation is cyclic (if `l` has at least two elements).
The presence of duplicates in a particular placement can lead `List.formPerm` to produce a
nontrivial permutation that is noncyclic.
-/
namespace List
variable {α β : Type*}
section FormPerm
variable [DecidableEq α] (l : List α)
open Equiv Equiv.Perm
/-- A list `l : List α` can be interpreted as an `Equiv.Perm α` where each element in the list
is permuted to the next one, defined as `formPerm`. When we have that `Nodup l`,
we prove that `Equiv.Perm.support (formPerm l) = l.toFinset`, and that
`formPerm l` is rotationally invariant, in `formPerm_rotate`.
-/
def formPerm : Equiv.Perm α :=
(zipWith Equiv.swap l l.tail).prod
@[simp]
theorem formPerm_nil : formPerm ([] : List α) = 1 :=
rfl
@[simp]
theorem formPerm_singleton (x : α) : formPerm [x] = 1 :=
rfl
@[simp]
theorem formPerm_cons_cons (x y : α) (l : List α) :
formPerm (x :: y :: l) = swap x y * formPerm (y :: l) :=
rfl
theorem formPerm_pair (x y : α) : formPerm [x, y] = swap x y :=
rfl
theorem mem_or_mem_of_zipWith_swap_prod_ne : ∀ {l l' : List α} {x : α},
(zipWith swap l l').prod x ≠ x → x ∈ l ∨ x ∈ l'
| [], _, _ => by simp
| _, [], _ => by simp
| a::l, b::l', x => fun hx ↦
if h : (zipWith swap l l').prod x = x then
(eq_or_eq_of_swap_apply_ne_self (a := a) (b := b) (x := x) (by simpa [h] using hx)).imp
(by rintro rfl; exact .head _) (by rintro rfl; exact .head _)
else
(mem_or_mem_of_zipWith_swap_prod_ne h).imp (.tail _) (.tail _)
theorem zipWith_swap_prod_support' (l l' : List α) :
{ x | (zipWith swap l l').prod x ≠ x } ≤ l.toFinset ⊔ l'.toFinset := fun _ h ↦ by
simpa using mem_or_mem_of_zipWith_swap_prod_ne h
theorem zipWith_swap_prod_support [Fintype α] (l l' : List α) :
(zipWith swap l l').prod.support ≤ l.toFinset ⊔ l'.toFinset := by
intro x hx
have hx' : x ∈ { x | (zipWith swap l l').prod x ≠ x } := by simpa using hx
simpa using zipWith_swap_prod_support' _ _ hx'
theorem support_formPerm_le' : { x | formPerm l x ≠ x } ≤ l.toFinset := by
refine (zipWith_swap_prod_support' l l.tail).trans ?_
simpa [Finset.subset_iff] using tail_subset l
theorem support_formPerm_le [Fintype α] : support (formPerm l) ≤ l.toFinset := by
intro x hx
have hx' : x ∈ { x | formPerm l x ≠ x } := by simpa using hx
simpa using support_formPerm_le' _ hx'
variable {l} {x : α}
theorem mem_of_formPerm_apply_ne (h : l.formPerm x ≠ x) : x ∈ l := by
simpa [or_iff_left_of_imp mem_of_mem_tail] using mem_or_mem_of_zipWith_swap_prod_ne h
theorem formPerm_apply_of_notMem (h : x ∉ l) : formPerm l x = x :=
not_imp_comm.1 mem_of_formPerm_apply_ne h
@[deprecated (since := "2025-05-23")] alias formPerm_apply_of_not_mem := formPerm_apply_of_notMem
theorem formPerm_apply_mem_of_mem (h : x ∈ l) : formPerm l x ∈ l := by
rcases l with - | ⟨y, l⟩
· simp at h
induction l generalizing x y with
| nil => simpa using h
| cons z l IH =>
by_cases hx : x ∈ z :: l
· rw [formPerm_cons_cons, mul_apply, swap_apply_def]
split_ifs
· simp
· simp
· simp [*]
· replace h : x = y := Or.resolve_right (mem_cons.1 h) hx
simp [formPerm_apply_of_notMem hx, ← h]
theorem mem_of_formPerm_apply_mem (h : l.formPerm x ∈ l) : x ∈ l := by
contrapose h
rwa [formPerm_apply_of_notMem h]
@[simp]
theorem formPerm_mem_iff_mem : l.formPerm x ∈ l ↔ x ∈ l :=
⟨l.mem_of_formPerm_apply_mem, l.formPerm_apply_mem_of_mem⟩
@[simp]
theorem formPerm_cons_concat_apply_last (x y : α) (xs : List α) :
formPerm (x :: (xs ++ [y])) y = x := by
induction xs generalizing x y with
| nil => simp
| cons z xs IH => simp [IH]
@[simp]
theorem formPerm_apply_getLast (x : α) (xs : List α) :
formPerm (x :: xs) ((x :: xs).getLast (cons_ne_nil x xs)) = x := by
induction xs using List.reverseRecOn generalizing x <;> simp
@[simp]
theorem formPerm_apply_getElem_length (x : α) (xs : List α) :
formPerm (x :: xs) (x :: xs)[xs.length] = x := by
rw [getElem_cons_length rfl, formPerm_apply_getLast]
theorem formPerm_apply_head (x y : α) (xs : List α) (h : Nodup (x :: y :: xs)) :
formPerm (x :: y :: xs) x = y := by simp [formPerm_apply_of_notMem h.notMem]
theorem formPerm_apply_getElem_zero (l : List α) (h : Nodup l) (hl : 1 < l.length) :
formPerm l l[0] = l[1] := by
rcases l with (_ | ⟨x, _ | ⟨y, tl⟩⟩)
· simp at hl
· simp at hl
· rw [getElem_cons_zero, formPerm_apply_head _ _ _ h, getElem_cons_succ, getElem_cons_zero]
variable (l)
theorem formPerm_eq_head_iff_eq_getLast (x y : α) :
formPerm (y :: l) x = y ↔ x = getLast (y :: l) (cons_ne_nil _ _) :=
Iff.trans (by rw [formPerm_apply_getLast]) (formPerm (y :: l)).injective.eq_iff
theorem formPerm_apply_lt_getElem (xs : List α) (h : Nodup xs) (n : ℕ) (hn : n + 1 < xs.length) :
formPerm xs xs[n] = xs[n + 1] := by
induction n generalizing xs with
| zero => simpa using formPerm_apply_getElem_zero _ h _
| succ n IH =>
rcases xs with (_ | ⟨x, _ | ⟨y, l⟩⟩)
· simp at hn
· rw [formPerm_singleton, getElem_singleton, getElem_singleton, one_apply]
· specialize IH (y :: l) h.of_cons _
· simpa [Nat.succ_lt_succ_iff] using hn
simp only [swap_apply_eq_iff, coe_mul, formPerm_cons_cons, Function.comp]
simp only [getElem_cons_succ] at *
rw [← IH, swap_apply_of_ne_of_ne] <;>
· intro hx
rw [← hx, IH] at h
simp [getElem_mem] at h
theorem formPerm_apply_getElem (xs : List α) (w : Nodup xs) (i : ℕ) (h : i < xs.length) :
formPerm xs xs[i] =
xs[(i + 1) % xs.length]'(Nat.mod_lt _ (i.zero_le.trans_lt h)) := by
rcases xs with - | ⟨x, xs⟩
· simp at h
· have : i ≤ xs.length := by
refine Nat.le_of_lt_succ ?_
simpa using h
rcases this.eq_or_lt with (rfl | hn')
· simp
· rw [formPerm_apply_lt_getElem (x :: xs) w _ (Nat.succ_lt_succ hn')]
congr
rw [Nat.mod_eq_of_lt]; simpa [Nat.succ_eq_add_one]
theorem support_formPerm_of_nodup' (l : List α) (h : Nodup l) (h' : ∀ x : α, l ≠ [x]) :
{ x | formPerm l x ≠ x } = l.toFinset := by
apply _root_.le_antisymm
· exact support_formPerm_le' l
· intro x hx
simp only [Finset.mem_coe, mem_toFinset] at hx
obtain ⟨n, hn, rfl⟩ := getElem_of_mem hx
rw [Set.mem_setOf_eq, formPerm_apply_getElem _ h]
intro H
rw [nodup_iff_injective_get, Function.Injective] at h
specialize h H
rcases (Nat.succ_le_of_lt hn).eq_or_lt with hn' | hn'
· simp only [← hn', Nat.mod_self] at h
refine not_exists.mpr h' ?_
rw [← length_eq_one_iff, ← hn', (Fin.mk.inj_iff.mp h).symm]
· simp [Nat.mod_eq_of_lt hn'] at h
theorem support_formPerm_of_nodup [Fintype α] (l : List α) (h : Nodup l) (h' : ∀ x : α, l ≠ [x]) :
support (formPerm l) = l.toFinset := by
rw [← Finset.coe_inj]
convert support_formPerm_of_nodup' _ h h'
simp [Set.ext_iff]
theorem formPerm_rotate_one (l : List α) (h : Nodup l) : formPerm (l.rotate 1) = formPerm l := by
have h' : Nodup (l.rotate 1) := by simpa using h
ext x
by_cases hx : x ∈ l.rotate 1
· obtain ⟨k, hk, rfl⟩ := getElem_of_mem hx
rw [formPerm_apply_getElem _ h', getElem_rotate l, getElem_rotate l, formPerm_apply_getElem _ h]
simp
· rw [formPerm_apply_of_notMem hx, formPerm_apply_of_notMem]
simpa using hx
theorem formPerm_rotate (l : List α) (h : Nodup l) (n : ℕ) :
formPerm (l.rotate n) = formPerm l := by
induction n with
| zero => simp
| succ n hn =>
rw [← rotate_rotate, formPerm_rotate_one, hn]
rwa [IsRotated.nodup_iff]
exact IsRotated.forall l n
theorem formPerm_eq_of_isRotated {l l' : List α} (hd : Nodup l) (h : l ~r l') :
formPerm l = formPerm l' := by
obtain ⟨n, rfl⟩ := h
exact (formPerm_rotate l hd n).symm
theorem formPerm_append_pair : ∀ (l : List α) (a b : α),
formPerm (l ++ [a, b]) = formPerm (l ++ [a]) * swap a b
| [], _, _ => rfl
| [_], _, _ => rfl
| x::y::l, a, b => by
simpa [mul_assoc] using formPerm_append_pair (y::l) a b
theorem formPerm_reverse : ∀ l : List α, formPerm l.reverse = (formPerm l)⁻¹
| [] => rfl
| [_] => rfl
| a::b::l => by
simp [formPerm_append_pair, swap_comm, ← formPerm_reverse (b::l)]
theorem formPerm_pow_apply_getElem (l : List α) (w : Nodup l) (n : ℕ) (i : ℕ) (h : i < l.length) :
(formPerm l ^ n) l[i] =
l[(i + n) % l.length]'(Nat.mod_lt _ (i.zero_le.trans_lt h)) := by
induction n with
| zero => simp [Nat.mod_eq_of_lt h]
| succ n hn =>
simp [pow_succ', mul_apply, hn, formPerm_apply_getElem _ w,
← Nat.add_assoc]
theorem formPerm_pow_apply_head (x : α) (l : List α) (h : Nodup (x :: l)) (n : ℕ) :
(formPerm (x :: l) ^ n) x =
(x :: l)[(n % (x :: l).length)]'(Nat.mod_lt _ (Nat.zero_lt_succ _)) := by
convert formPerm_pow_apply_getElem _ h n 0 (Nat.succ_pos _)
simp
theorem formPerm_ext_iff {x y x' y' : α} {l l' : List α} (hd : Nodup (x :: y :: l))
(hd' : Nodup (x' :: y' :: l')) :
formPerm (x :: y :: l) = formPerm (x' :: y' :: l') ↔ (x :: y :: l) ~r (x' :: y' :: l') := by
refine ⟨fun h => ?_, fun hr => formPerm_eq_of_isRotated hd hr⟩
rw [Equiv.Perm.ext_iff] at h
have hx : x' ∈ x :: y :: l := by
have : x' ∈ { z | formPerm (x :: y :: l) z ≠ z } := by
rw [Set.mem_setOf_eq, h x', formPerm_apply_head _ _ _ hd']
simp only [mem_cons, nodup_cons] at hd'
push_neg at hd'
exact hd'.left.left.symm
simpa using support_formPerm_le' _ this
obtain ⟨⟨n, hn⟩, hx'⟩ := get_of_mem hx
have hl : (x :: y :: l).length = (x' :: y' :: l').length := by
rw [← dedup_eq_self.mpr hd, ← dedup_eq_self.mpr hd', ← card_toFinset, ← card_toFinset]
refine congr_arg Finset.card ?_
rw [← Finset.coe_inj, ← support_formPerm_of_nodup' _ hd (by simp), ←
support_formPerm_of_nodup' _ hd' (by simp)]
simp only [h]
use n
apply List.ext_getElem
· rw [length_rotate, hl]
· intro k hk hk'
rw [getElem_rotate]
induction k with
| zero =>
refine Eq.trans ?_ hx'
congr
simpa using hn
| succ k IH =>
conv => congr <;> · arg 2; (rw [← Nat.mod_eq_of_lt hk'])
rw [← formPerm_apply_getElem _ hd' k (k.lt_succ_self.trans hk'),
← IH (k.lt_succ_self.trans hk), ← h, formPerm_apply_getElem _ hd]
congr 1
rw [hl, Nat.mod_eq_of_lt hk', add_right_comm]
apply Nat.add_mod
theorem formPerm_apply_mem_eq_self_iff (hl : Nodup l) (x : α) (hx : x ∈ l) :
formPerm l x = x ↔ length l ≤ 1 := by
obtain ⟨k, hk, rfl⟩ := getElem_of_mem hx
rw [formPerm_apply_getElem _ hl k hk, hl.getElem_inj_iff]
cases hn : l.length
· exact absurd k.zero_le (hk.trans_le hn.le).not_ge
· rw [hn] at hk
rcases (Nat.le_of_lt_succ hk).eq_or_lt with hk' | hk'
· simp [← hk', eq_comm]
· simpa [Nat.mod_eq_of_lt (Nat.succ_lt_succ hk'), Nat.succ_lt_succ_iff] using
(k.zero_le.trans_lt hk').ne.symm
theorem formPerm_apply_mem_ne_self_iff (hl : Nodup l) (x : α) (hx : x ∈ l) :
formPerm l x ≠ x ↔ 2 ≤ l.length := by
rw [Ne, formPerm_apply_mem_eq_self_iff _ hl x hx, not_le]
exact ⟨Nat.succ_le_of_lt, Nat.lt_of_succ_le⟩
@[deprecated (since := "2025-10-06")]
alias mem_of_formPerm_ne_self := mem_of_formPerm_apply_ne
@[deprecated (since := "2025-10-06")]
alias formPerm_eq_self_of_notMem := List.formPerm_apply_of_notMem
@[deprecated (since := "2025-05-23")]
alias formPerm_eq_self_of_not_mem := List.formPerm_apply_of_notMem
theorem formPerm_eq_one_iff (hl : Nodup l) : formPerm l = 1 ↔ l.length ≤ 1 := by
rcases l with - | ⟨hd, tl⟩
· simp
· rw [← formPerm_apply_mem_eq_self_iff _ hl hd mem_cons_self]
constructor
· simp +contextual
· intro h
simp only [(hd :: tl).formPerm_apply_mem_eq_self_iff hl hd mem_cons_self,
add_le_iff_nonpos_left, length, nonpos_iff_eq_zero, length_eq_zero_iff] at h
simp [h]
theorem formPerm_eq_formPerm_iff {l l' : List α} (hl : l.Nodup) (hl' : l'.Nodup) :
l.formPerm = l'.formPerm ↔ l ~r l' ∨ l.length ≤ 1 ∧ l'.length ≤ 1 := by
rcases l with (_ | ⟨x, _ | ⟨y, l⟩⟩)
· suffices l'.length ≤ 1 ↔ l' = nil ∨ l'.length ≤ 1 by
simpa [eq_comm, formPerm_eq_one_iff, hl, hl', length_eq_zero_iff]
refine ⟨fun h => Or.inr h, ?_⟩
rintro (rfl | h)
· simp
· exact h
· suffices l'.length ≤ 1 ↔ [x] ~r l' ∨ l'.length ≤ 1 by
simpa [eq_comm, formPerm_eq_one_iff, hl, hl', length_eq_zero_iff, le_rfl]
refine ⟨fun h => Or.inr h, ?_⟩
rintro (h | h)
· simp [← h.perm.length_eq]
· exact h
· rcases l' with (_ | ⟨x', _ | ⟨y', l'⟩⟩)
· simp [formPerm_eq_one_iff _ hl, -formPerm_cons_cons]
· simp [formPerm_eq_one_iff _ hl, -formPerm_cons_cons]
· simp [-formPerm_cons_cons, formPerm_ext_iff hl hl']
theorem form_perm_zpow_apply_mem_imp_mem (l : List α) (x : α) (hx : x ∈ l) (n : ℤ) :
(formPerm l ^ n) x ∈ l := by
by_cases h : (l.formPerm ^ n) x = x
· simpa [h] using hx
· have h : x ∈ { x | (l.formPerm ^ n) x ≠ x } := h
rw [← set_support_apply_mem] at h
replace h := set_support_zpow_subset _ _ h
simpa using support_formPerm_le' _ h
theorem formPerm_pow_length_eq_one_of_nodup (hl : Nodup l) : formPerm l ^ length l = 1 := by
ext x
by_cases hx : x ∈ l
· obtain ⟨k, hk, rfl⟩ := getElem_of_mem hx
simp [formPerm_pow_apply_getElem _ hl, Nat.mod_eq_of_lt hk]
· have : x ∉ { x | (l.formPerm ^ l.length) x ≠ x } := by
intro H
refine hx ?_
replace H := set_support_zpow_subset l.formPerm l.length H
simpa using support_formPerm_le' _ H
simpa using this
end FormPerm
end List |
.lake/packages/mathlib/Mathlib/GroupTheory/Perm/Closure.lean | import Mathlib.GroupTheory.Perm.Cycle.Basic
/-!
# Closure results for permutation groups
* This file contains several closure results:
* `closure_isCycle` : The symmetric group is generated by cycles
* `closure_cycle_adjacent_swap` : The symmetric group is generated by
a cycle and an adjacent transposition
* `closure_cycle_coprime_swap` : The symmetric group is generated by
a cycle and a coprime transposition
* `closure_prime_cycle_swap` : The symmetric group is generated by
a prime cycle and a transposition
-/
open Equiv Function Finset
variable {ι α β : Type*}
namespace Equiv.Perm
section Generation
variable [Finite β]
open Subgroup
theorem closure_isCycle : closure { σ : Perm β | IsCycle σ } = ⊤ := by
classical
cases nonempty_fintype β
exact
top_le_iff.mp (le_trans (ge_of_eq closure_isSwap) (closure_mono fun _ => IsSwap.isCycle))
variable [DecidableEq α] [Fintype α]
theorem closure_cycle_adjacent_swap {σ : Perm α} (h1 : IsCycle σ) (h2 : σ.support = univ) (x : α) :
closure ({σ, swap x (σ x)} : Set (Perm α)) = ⊤ := by
let H := closure ({σ, swap x (σ x)} : Set (Perm α))
have h3 : σ ∈ H := subset_closure (Set.mem_insert σ _)
have h4 : swap x (σ x) ∈ H := subset_closure (Set.mem_insert_of_mem _ (Set.mem_singleton _))
have step1 : ∀ n : ℕ, swap ((σ ^ n) x) ((σ ^ (n + 1) : Perm α) x) ∈ H := by
intro n
induction n with
| zero => exact subset_closure (Set.mem_insert_of_mem _ (Set.mem_singleton _))
| succ n ih =>
convert H.mul_mem (H.mul_mem h3 ih) (H.inv_mem h3)
simp_rw [mul_swap_eq_swap_mul, mul_inv_cancel_right, pow_succ', coe_mul, comp_apply]
have step2 : ∀ n : ℕ, swap x ((σ ^ n) x) ∈ H := by
intro n
induction n with
| zero =>
simp only [pow_zero, coe_one, id_eq, swap_self]
convert H.one_mem
| succ n ih =>
by_cases h5 : x = (σ ^ n) x
· rw [pow_succ', mul_apply, ← h5]
exact h4
by_cases h6 : x = (σ ^ (n + 1) : Perm α) x
· rw [← h6, swap_self]
exact H.one_mem
rw [swap_comm, ← swap_mul_swap_mul_swap h5 h6]
exact H.mul_mem (H.mul_mem (step1 n) ih) (step1 n)
have step3 : ∀ y : α, swap x y ∈ H := by
intro y
have hx : x ∈ univ := Finset.mem_univ x
rw [← h2, mem_support] at hx
have hy : y ∈ univ := Finset.mem_univ y
rw [← h2, mem_support] at hy
obtain ⟨n, hn⟩ := IsCycle.exists_pow_eq h1 hx hy
rw [← hn]
exact step2 n
have step4 : ∀ y z : α, swap y z ∈ H := by
intro y z
by_cases h5 : z = x
· rw [h5, swap_comm]
exact step3 y
by_cases h6 : z = y
· rw [h6, swap_self]
exact H.one_mem
rw [← swap_mul_swap_mul_swap h5 h6, swap_comm z x]
exact H.mul_mem (H.mul_mem (step3 y) (step3 z)) (step3 y)
rw [eq_top_iff, ← closure_isSwap, closure_le]
rintro τ ⟨y, z, _, h6⟩
rw [h6]
exact step4 y z
theorem closure_cycle_coprime_swap {n : ℕ} {σ : Perm α} (h0 : Nat.Coprime n (Fintype.card α))
(h1 : IsCycle σ) (h2 : σ.support = Finset.univ) (x : α) :
closure ({σ, swap x ((σ ^ n) x)} : Set (Perm α)) = ⊤ := by
rw [← Finset.card_univ, ← h2, ← h1.orderOf] at h0
obtain ⟨m, hm⟩ := exists_pow_eq_self_of_coprime h0
have h2' : (σ ^ n).support = univ := Eq.trans (support_pow_coprime h0) h2
have h1' : IsCycle ((σ ^ n) ^ (m : ℤ)) := by rwa [← hm] at h1
replace h1' : IsCycle (σ ^ n) :=
h1'.of_pow (le_trans (support_pow_le σ n) (ge_of_eq (congr_arg support hm)))
rw [eq_top_iff, ← closure_cycle_adjacent_swap h1' h2' x, closure_le, Set.insert_subset_iff]
exact
⟨Subgroup.pow_mem (closure _) (subset_closure (Set.mem_insert σ _)) n,
Set.singleton_subset_iff.mpr (subset_closure (Set.mem_insert_of_mem _ (Set.mem_singleton _)))⟩
theorem closure_prime_cycle_swap {σ τ : Perm α} (h0 : (Fintype.card α).Prime) (h1 : IsCycle σ)
(h2 : σ.support = Finset.univ) (h3 : IsSwap τ) : closure ({σ, τ} : Set (Perm α)) = ⊤ := by
obtain ⟨x, y, h4, h5⟩ := h3
obtain ⟨i, hi⟩ :=
h1.exists_pow_eq (mem_support.mp ((Finset.ext_iff.mp h2 x).mpr (Finset.mem_univ x)))
(mem_support.mp ((Finset.ext_iff.mp h2 y).mpr (Finset.mem_univ y)))
rw [h5, ← hi]
refine closure_cycle_coprime_swap
(Nat.Coprime.symm (h0.coprime_iff_not_dvd.mpr fun h => h4 ?_)) h1 h2 x
obtain ⟨m, hm⟩ := h
rwa [hm, pow_mul, ← Finset.card_univ, ← h2, ← h1.orderOf, pow_orderOf_eq_one, one_pow,
one_apply] at hi
end Generation
end Perm
end Equiv |
.lake/packages/mathlib/Mathlib/GroupTheory/Perm/Basic.lean | import Mathlib.Algebra.Group.Action.Defs
import Mathlib.Algebra.Group.End
import Mathlib.Logic.Equiv.Set
import Mathlib.Tactic.Common
/-!
# Extra lemmas about permutations
This file proves miscellaneous lemmas about `Equiv.Perm`.
## TODO
Most of the content of this file was moved to `Algebra.Group.End` in
https://github.com/leanprover-community/mathlib4/pull/22141.
It would be good to merge the remaining lemmas with other files, e.g.
`GroupTheory.Perm.ViaEmbedding` looks like it could benefit from such a treatment (splitting into
the algebra and non-algebra parts).
-/
universe u v
namespace Equiv
variable {α : Type u} {β : Type v}
namespace Perm
@[simp] lemma image_inv (f : Perm α) (s : Set α) : ↑f⁻¹ '' s = f ⁻¹' s := f.image_symm_eq_preimage _
@[simp] lemma preimage_inv (f : Perm α) (s : Set α) : ↑f⁻¹ ⁻¹' s = f '' s :=
(f.image_eq_preimage_symm _).symm
end Perm
section Swap
variable [DecidableEq α]
@[simp]
theorem swap_smul_self_smul [MulAction (Perm α) β] (i j : α) (x : β) :
swap i j • swap i j • x = x := by simp [smul_smul]
theorem swap_smul_involutive [MulAction (Perm α) β] (i j : α) :
Function.Involutive (swap i j • · : β → β) := swap_smul_self_smul i j
end Swap
end Equiv
open Equiv Function
namespace Set
variable {α : Type*} {f : Perm α} {s : Set α}
lemma BijOn.perm_inv (hf : BijOn f s s) : BijOn ↑(f⁻¹) s s := hf.symm f.invOn
lemma MapsTo.perm_pow : MapsTo f s s → ∀ n : ℕ, MapsTo (f ^ n) s s := by
simp_rw [Equiv.Perm.coe_pow]; exact MapsTo.iterate
lemma SurjOn.perm_pow : SurjOn f s s → ∀ n : ℕ, SurjOn (f ^ n) s s := by
simp_rw [Equiv.Perm.coe_pow]; exact SurjOn.iterate
lemma BijOn.perm_pow : BijOn f s s → ∀ n : ℕ, BijOn (f ^ n) s s := by
simp_rw [Equiv.Perm.coe_pow]; exact BijOn.iterate
lemma BijOn.perm_zpow (hf : BijOn f s s) : ∀ n : ℤ, BijOn (f ^ n) s s
| Int.ofNat n => hf.perm_pow n
| Int.negSucc n => (hf.perm_pow (n + 1)).perm_inv
end Set |
.lake/packages/mathlib/Mathlib/GroupTheory/Perm/MaximalSubgroups.lean | import Mathlib.GroupTheory.GroupAction.Jordan
import Mathlib.GroupTheory.SpecificGroups.Cyclic
import Mathlib.GroupTheory.Subgroup.Simple
import Mathlib.GroupTheory.GroupAction.SubMulAction.OfFixingSubgroup
/-! # Maximal subgroups of the symmetric groups
* `Equiv.Perm.isCoatom_stabilizer`:
if neither `s : set α` nor its complementary subset is empty,
and the cardinality of `s` is not half of that of `α`,
then `MulAction.stabilizer (Equiv.Perm α) s` is
a maximal subgroup of the symmetric group `Equiv.Perm α`.
This is the *intransitive case* of the O'Nan-Scott classification.
## TODO
* Application to primitivity of the action
of `Equiv.Perm α` on finite combinations of `α`.
* Formalize the other cases of the classification.
The next one should be the *imprimitive case*.
## Reference
The argument is taken from [M. Liebeck, C. Praeger, J. Saxl,
*A classification of the maximal subgroups of the finite
alternating and symmetric groups*, 1987][LiebeckPraegerSaxl-1987].
-/
open scoped Pointwise
open Set
namespace Equiv.Perm
open MulAction
variable (G : Type*) [Group G] {α : Type*} [MulAction G α]
theorem IsPretransitive.of_partition {s : Set α}
(hs : ∀ a ∈ s, ∀ b ∈ s, ∃ g : G, g • a = b)
(hs' : ∀ a ∈ sᶜ, ∀ b ∈ sᶜ, ∃ g : G, g • a = b)
(hG : stabilizer G s ≠ ⊤) :
IsPretransitive G α := by
suffices ∃ (a b : α) (g : G), a ∈ s ∧ b ∈ sᶜ ∧ g • a = b by
obtain ⟨a, b, g, ha, hb, hgab⟩ := this
rw [isPretransitive_iff_base a]
intro x
by_cases hx : x ∈ s
· exact hs a ha x hx
· rw [← Set.mem_compl_iff] at hx
obtain ⟨k, hk⟩ := hs' b hb x hx
use k * g
rw [mul_smul, hgab, hk]
contrapose! hG
rw [eq_top_iff, le_stabilizer_iff_smul_le]
rintro g _ b ⟨a, ha, hgab⟩
by_contra hb
exact hG a b g ha (Set.mem_compl hb) hgab
theorem swap_mem_stabilizer [DecidableEq α]
{a b : α} {s : Set α} (ha : a ∈ s) (hb : b ∈ s) :
swap a b ∈ stabilizer (Perm α) s := by
suffices swap a b • s ⊆ s by
rw [mem_stabilizer_iff]
apply Set.Subset.antisymm this
exact Set.subset_smul_set_iff.mpr this
rintro _ ⟨x, hx, rfl⟩
by_cases h : x ∈ ({a, b} : Set α)
· aesop
· have := swap_apply_of_ne_of_ne (a := a) (b := b) (x := x)
aesop
theorem moves_in
(G : Subgroup (Perm α)) (t : Set α) (hGt : stabilizer (Perm α) t ≤ G) :
∀ a ∈ t, ∀ b ∈ t, ∃ g : G, g • a = b := by
classical
intro a ha b hb
use ⟨swap a b, hGt (swap_mem_stabilizer ha hb)⟩
rw [Subgroup.mk_smul, Perm.smul_def, swap_apply_left]
theorem stabilizer_ne_top_of_nonempty_of_nonempty_compl
{s : Set α} (hs : s.Nonempty) (hsc : sᶜ.Nonempty) :
stabilizer (Perm α) s ≠ ⊤ := by
classical
obtain ⟨a, ha⟩ := hs
obtain ⟨b, hb⟩ := hsc
intro h
rw [Set.mem_compl_iff] at hb; apply hb
have hg : swap a b ∈ stabilizer (Perm α) s := by simp_all
rw [mem_stabilizer_iff] at hg
rw [← hg, Set.mem_smul_set]
aesop
theorem has_swap_mem_of_lt_stabilizer [DecidableEq α]
(s : Set α) (G : Subgroup (Perm α))
(hG : stabilizer (Perm α) s < G) :
∃ g : Perm α, g.IsSwap ∧ g ∈ G := by
have : ∀ (t : Set α) (_ : 1 < t.encard), ∃ (g : Perm α),
g.IsSwap ∧ g ∈ stabilizer (Perm α) t := by
intro t ht
rw [Set.one_lt_encard_iff] at ht
obtain ⟨a, b, ha, hb, h⟩ := ht
use swap a b, Perm.swap_isSwap_iff.mpr h, swap_mem_stabilizer ha hb
rcases lt_or_ge 1 s.encard with h1 | h1'
· obtain ⟨g, hg, hg'⟩ := this s h1
exact ⟨g, hg, le_of_lt hG hg'⟩
rcases lt_or_ge 1 sᶜ.encard with h1c | h1c'
· obtain ⟨g, hg, hg'⟩ := this sᶜ h1c
use g, hg
rw [stabilizer_compl] at hg'
exact le_of_lt hG hg'
have hα : Set.encard (_root_.Set.univ : Set α) = 2 := by
rw [← Set.encard_add_encard_compl s]
have : (1 + 1 : ENat) = 2 := by norm_num
convert this <;>
· apply le_antisymm
· assumption
rw [one_le_encard_iff_nonempty, Set.nonempty_iff_ne_empty]
aesop
have _ : Finite α := by
rw [finite_iff_nonempty_fintype]
refine univ_finite_iff_nonempty_fintype.mp ?_
exact finite_of_encard_eq_coe hα
have hα : Nat.card α = 2 := by
rw [← ENat.card_coe_set_eq, ENat.card_eq_coe_natCard, Nat.card_coe_set_eq, ncard_univ] at hα
exact ENat.coe_inj.mp hα
have hα2 : Fact (Nat.card (Perm α)).Prime := by
apply Fact.mk
rw [Nat.card_perm, hα, Nat.factorial_two]
exact Nat.prime_two
cases G.eq_bot_or_eq_top_of_prime_card with
| inl h =>
exfalso; exact ne_bot_of_gt hG h
| inr h =>
rw [h, ← stabilizer_univ_eq_top (Perm α) α]
apply this
simp_all
theorem ofSubtype_mem_stabilizer {s : Set α} [DecidablePred fun x ↦ x ∈ s]
(g : Perm s) :
g.ofSubtype ∈ stabilizer (Perm α) s := by
rw [mem_stabilizer_iff]
ext g'
simp_rw [mem_smul_set, Perm.smul_def]
refine ⟨?_, fun a ↦ ?_⟩
· rintro ⟨w, hs, rfl⟩
simp [ofSubtype_apply_of_mem _ hs]
· use (g⁻¹ ⟨g', a⟩)
simp
open SubMulAction
lemma _root_.Subgroup.isPretransitive_of_stabilizer_lt
{s : Set α} {G : Subgroup (Perm α)} (hG : stabilizer (Perm α) s < G) :
IsPretransitive G α := by
apply IsPretransitive.of_partition G (s := s)
· apply moves_in; exact le_of_lt hG
· apply moves_in; rw [stabilizer_compl]; exact le_of_lt hG
· intro h
apply lt_irrefl G; apply lt_of_le_of_lt _ hG
-- `G ≤ stabilizer (Equiv.Perm α) s`
have : G = Subgroup.map G.subtype ⊤ := by
rw [← MonoidHom.range_eq_map, Subgroup.range_subtype]
rw [this, Subgroup.map_le_iff_le_comap]
rw [show Subgroup.comap G.subtype (stabilizer (Perm α) s) = stabilizer G s from rfl, h]
lemma _root_.IsBlock.subsingleton_of_ssubset_compl_of_stabilizer_le
{s B : Set α} {G : Subgroup (Perm α)}
(hB_ss_sc : B ⊂ sᶜ) (hG : stabilizer (Perm α) s ≤ G) (hB : IsBlock G B) :
B.Subsingleton := by
rw [← inter_eq_self_of_subset_right (subset_of_ssubset hB_ss_sc), ← Subtype.image_preimage_val]
apply Set.Subsingleton.image
suffices IsTrivialBlock (Subtype.val ⁻¹' B : Set (sᶜ : Set α)) by
apply Or.resolve_right this
intro hB'
apply ne_of_lt hB_ss_sc
apply subset_antisymm (by grind)
intro x hx
rw [← Subtype.coe_mk x hx, ← Set.mem_preimage, hB']
apply Set.mem_univ
suffices IsPreprimitive (stabilizer G (sᶜ : Set α)) (sᶜ : Set α) by
apply this.isTrivialBlock_of_isBlock
let φ' : stabilizer G (sᶜ : Set α) → G := Subtype.val
let f' : (sᶜ : Set α) →ₑ[φ'] α := {
toFun := Subtype.val
map_smul' := fun ⟨m, _⟩ x => by
simp only [SMul.smul_stabilizer_def, φ'] }
exact hB.preimage f'
let φ : stabilizer G (sᶜ : Set α) → Perm (sᶜ : Set α) := MulAction.toPerm
let f : (sᶜ : Set α) →ₑ[φ] (sᶜ : Set α) := {
toFun := id
map_smul' := fun g x => by
simp only [φ, id, Perm.smul_def, toPerm_apply] }
have hf : Function.Bijective f := Function.bijective_id
rw [isPreprimitive_congr _ hf]
· infer_instance
-- Function.Surjective φ,
classical
intro g
use! g.ofSubtype
· apply hG
rw [← stabilizer_compl]
exact ofSubtype_mem_stabilizer g
· rw [mem_stabilizer_iff, Subgroup.mk_smul, ← mem_stabilizer_iff]
exact ofSubtype_mem_stabilizer g
· ext ⟨x, hx⟩
trans ofSubtype g x
· simp [φ]
· exact ofSubtype_apply_of_mem g hx
lemma _root_.IsBlock.subsingleton_of_stabilizer_lt_of_subset
{s B : Set α} {G : Subgroup (Perm α)}
(hB_not_le_sc : ∀ (B : Set α), IsBlock G B → B ⊆ sᶜ → B.Subsingleton)
(hG : stabilizer (Perm α) s < G) (hBs : B ⊆ s) (hB : IsBlock G B) :
B.Subsingleton := by
suffices IsTrivialBlock (Subtype.val ⁻¹' B : Set s) by
rcases this with hB' | hB'
· -- trivial case
rw [← inter_eq_self_of_subset_right hBs, ← Subtype.image_preimage_val]
apply Set.Subsingleton.image hB'
· -- `Subtype.val ⁻¹' B = s`
have hBs' : B = s := Set.Subset.antisymm hBs (by aesop)
have : ∃ g' : G, g' • s ≠ s := by
by_contra! h
apply ne_of_lt hG
apply le_antisymm (le_of_lt hG)
aesop
obtain ⟨g', hg's⟩ := this
rcases MulAction.isBlock_iff_smul_eq_or_disjoint.mp hB g' with h | h
· -- case `g' • B = B` : absurd, since `B = s` and choice of `g'`
absurd hg's
rw [← hBs', h]
· -- case `g' • B` disjoint from `B`
apply Set.subsingleton_of_image (MulAction.injective g') B
apply hB_not_le_sc (g' • B) (hB.translate g')
rw [← hBs']
apply Disjoint.subset_compl_right h
-- `IsTrivialBlock (Subtype.val ⁻¹' B : Set s)`
suffices IsPreprimitive (stabilizer G s) s by
apply this.isTrivialBlock_of_isBlock
-- `IsBlock (Subtype.val ⁻¹' B : Set s)`
let φ' : stabilizer G s → G := Subtype.val
let f' : s →ₑ[φ'] α := {
toFun := Subtype.val
map_smul' := fun ⟨m, _⟩ x => by
simp only [SMul.smul_stabilizer_def, φ'] }
apply MulAction.IsBlock.preimage f' hB
-- `IsPreprimitive (stabilizer G s) s`
let φ : stabilizer G s → Perm s := toPerm
let f : s →ₑ[φ] s := {
toFun := id
map_smul' := fun g x => by
simp only [φ, id, Perm.smul_def, toPerm_apply] }
have hf : Function.Bijective f := Function.bijective_id
rw [isPreprimitive_congr _ hf]
· infer_instance
-- Function.Surjective φ
classical
intro g
use! Perm.ofSubtype g
· apply le_of_lt hG
apply ofSubtype_mem_stabilizer
· apply ofSubtype_mem_stabilizer
· ext ⟨x, hx⟩
simp [φ, ← ofSubtype_apply_of_mem]
variable [Finite α]
lemma _root_.IsBlock.compl_subset_of_stabilizer_le_of_not_subset_of_not_subset_compl
{s B : Set α} {G : Subgroup (Perm α)}
(hG : stabilizer (Perm α) s ≤ G)
(hBs : ¬ B ⊆ s) (hBsc : ¬ B ⊆ sᶜ) (hB : IsBlock G B) :
sᶜ ⊆ B := by
have : ∃ a : α, a ∈ B ∧ a ∈ s := by grind
obtain ⟨a, ha, ha'⟩ := this
have : ∃ b : α, b ∈ B ∧ b ∈ sᶜ := by grind
obtain ⟨b, hb, hb'⟩ := this
intro x hx'
suffices ∃ k : fixingSubgroup (Perm α) s, k • b = x by
obtain ⟨⟨k, hk⟩, hkbx : k • b = x⟩ := this
suffices k • B = B by
rw [← hkbx, ← this, Set.smul_mem_smul_set_iff]
exact hb
-- `k • B = B`
apply isBlock_iff_smul_eq_of_nonempty.mp hB (g := ⟨k, ?_⟩)
· refine ⟨a, ⟨?_, ha⟩⟩
rw [mem_fixingSubgroup_iff] at hk
rw [← hk a ha']
exact Set.smul_mem_smul_set ha
· -- `k ∈ G`
apply hG
exact MulAction.fixingSubgroup_le_stabilizer _ _ hk
· -- `∃ (k : fixingSubgroup (Perm α) s), k • b = x`
suffices
IsPretransitive (fixingSubgroup (Perm α) s) (ofFixingSubgroup (Perm α) s) by
obtain ⟨k, hk⟩ :=
exists_smul_eq (fixingSubgroup (Perm α) s)
(⟨b, hb'⟩ : ofFixingSubgroup (Perm α) s) ⟨x, hx'⟩
use k
rw [← Subtype.coe_inj, val_smul] at hk
exact hk
-- Prove pretransitivity…
rw [← is_one_pretransitive_iff]
have _ : IsMultiplyPretransitive (Perm α) α (s.ncard + 1) :=
isMultiplyPretransitive α (s.ncard + 1)
apply ofFixingSubgroup.isMultiplyPretransitive (Perm α) s rfl
theorem isCoatom_stabilizer_of_ncard_lt_ncard_compl
{s : Set α} (h0 : s.Nonempty) (hα : s.ncard < sᶜ.ncard) :
IsCoatom (stabilizer (Perm α) s) := by
classical
have h1 : sᶜ.Nonempty := nonempty_iff_ne_empty.mpr (by aesop)
have : Fintype α := Fintype.ofFinite α
-- To prove that `stabilizer (Perm α) s` is maximal,
-- we need to prove that it is `≠ ⊤`
refine ⟨stabilizer_ne_top_of_nonempty_of_nonempty_compl h0 h1, fun G hG ↦ ?_⟩
-- … and that every strict over-subgroup `G` is equal to `⊤`
-- We know that `G` contains a swap
obtain ⟨g, hg_swap, hg⟩ := has_swap_mem_of_lt_stabilizer s G hG
-- By Jordan's theorem `subgroup_eq_top_of_isPreprimitive_of_isSwap_mem`,
-- it suffices to prove that `G` acts primitively
apply subgroup_eq_top_of_isPreprimitive_of_isSwap_mem _ g hg_swap hg
-- First, we prove that `G` acts transitively
have : IsPretransitive G α := by
exact G.isPretransitive_of_stabilizer_lt hG
apply IsPreprimitive.mk
-- We now have to prove that all blocks of `G` are trivial
-- The proof needs 4 steps
/- Step 1 : `sᶜ` is not a block.
This uses that `Nat.card s < Nat.card sᶜ`.
In the equality case, `Nat.card s` = Nat.card sᶜ`,
it would be possible that `sᶜ` is a block,
and then `G` would be a wreath product,
— this is case (b) of the O'Nan-Scott classification
of maximal subgroups of the symmetric group -/
have not_isBlock_sc : ¬ IsBlock G sᶜ := fun hsc ↦ by
rcases lt_or_ge (Nat.card α) (sᶜ.ncard * 2) with hB' | hB'
· apply h0.ne_empty
rw [← compl_univ_iff]
exact hsc.eq_univ_of_card_lt hB'
· rw [← not_lt] at hB'
apply hB'
rwa [← Set.ncard_add_ncard_compl sᶜ, mul_two, add_lt_add_iff_left, compl_compl]
-- Step 2 : A block contained in sᶜ is a subsingleton
have hB_not_le_sc (B : Set α) (hB : IsBlock G B) (hBsc : B ⊆ sᶜ) :
B.Subsingleton := by
apply IsBlock.subsingleton_of_ssubset_compl_of_stabilizer_le ?_ (le_of_lt hG) hB (s := s)
exact HasSubset.Subset.ssubset_of_ne hBsc (by aesop)
-- Step 3 : A block contained in `s` is a subsingleton
have hB_not_le_s (B : Set α) (hB : IsBlock G B) (hBs : B ⊆ s ) :
B.Subsingleton :=
IsBlock.subsingleton_of_stabilizer_lt_of_subset hB_not_le_sc hG hBs hB
-- Conclusion : we reduce to proving that a block which is not a subsingleton is `univ`.
intro B hB
unfold IsTrivialBlock
rw [or_iff_not_imp_left]
intro hB'
-- NB: `grind` proves the two arguments
have hsc_le_B : sᶜ ⊆ B :=
IsBlock.compl_subset_of_stabilizer_le_of_not_subset_of_not_subset_compl (le_of_lt hG)
(fun h ↦ hB' (hB_not_le_s B hB h)) (fun h ↦ hB' (hB_not_le_sc B hB h)) hB
rw [← Set.top_eq_univ, eq_top_iff]
intro x _
obtain ⟨b, hb⟩ := h1
obtain ⟨g, hgbx : g • b = x⟩ := exists_smul_eq G b x
suffices g • B = B by
rw [← hgbx, ← this, Set.smul_mem_smul_set_iff]
exact hsc_le_B hb
-- `g • B = B`
apply isBlock_iff_smul_eq_of_nonempty.mp hB (g := g)
apply nonempty_inter_of_lt_ncard_add_ncard
calc Nat.card α = s.ncard + sᶜ.ncard := by rw [Set.ncard_add_ncard_compl]
_ < sᶜ.ncard + sᶜ.ncard := by rw [Nat.add_lt_add_iff_right]; exact hα
_ = 2 * sᶜ.ncard := by rw [two_mul]
_ ≤ 2 * B.ncard := by have := Set.ncard_le_ncard hsc_le_B; gcongr
_ = _ := by simp only [Set.ncard_smul_set, ← two_mul]
/-- `MulAction.stabilizer (Perm α) s` is a maximal subgroup of `Perm α`,
provided `s` and `sᶜ` are nonempty, and `Nat.card α ≠ 2 * Nat.card s`. -/
theorem isCoatom_stabilizer {s : Set α}
(hs_nonempty : s.Nonempty) (hsc_nonempty : sᶜ.Nonempty)
(hα : Nat.card α ≠ 2 * s.ncard) :
IsCoatom (stabilizer (Perm α) s) := by
obtain h | h | h := Nat.lt_trichotomy s.ncard sᶜ.ncard
· exact isCoatom_stabilizer_of_ncard_lt_ncard_compl hs_nonempty h
· contrapose! hα
rw [← Set.ncard_add_ncard_compl s, two_mul, ← h]
· rw [← stabilizer_compl]
apply isCoatom_stabilizer_of_ncard_lt_ncard_compl hsc_nonempty
rwa [compl_compl]
end Equiv.Perm |
.lake/packages/mathlib/Mathlib/GroupTheory/Perm/ViaEmbedding.lean | import Mathlib.Algebra.Group.End
import Mathlib.Logic.Embedding.Basic
import Mathlib.Logic.Equiv.Set
/-!
# `Equiv.Perm.viaEmbedding`, a noncomputable analogue of `Equiv.Perm.viaFintypeEmbedding`.
-/
variable {α β : Type*}
namespace Equiv
namespace Perm
variable (e : Perm α) (ι : α ↪ β)
open scoped Classical in
/-- Noncomputable version of `Equiv.Perm.viaFintypeEmbedding` that does not assume `Fintype` -/
noncomputable def viaEmbedding : Perm β :=
extendDomain e (ofInjective ι.1 ι.2)
open scoped Classical in
theorem viaEmbedding_apply (x : α) : e.viaEmbedding ι (ι x) = ι (e x) :=
extendDomain_apply_image e (ofInjective ι.1 ι.2) x
open scoped Classical in
theorem viaEmbedding_apply_of_notMem (x : β) (hx : x ∉ Set.range ι) : e.viaEmbedding ι x = x :=
extendDomain_apply_not_subtype e (ofInjective ι.1 ι.2) hx
@[deprecated (since := "2025-05-23")]
alias viaEmbedding_apply_of_not_mem := viaEmbedding_apply_of_notMem
open scoped Classical in
/-- `viaEmbedding` as a group homomorphism -/
noncomputable def viaEmbeddingHom : Perm α →* Perm β :=
extendDomainHom (ofInjective ι.1 ι.2)
theorem viaEmbeddingHom_apply : viaEmbeddingHom ι e = viaEmbedding e ι :=
rfl
open scoped Classical in
theorem viaEmbeddingHom_injective : Function.Injective (viaEmbeddingHom ι) :=
extendDomainHom_injective (ofInjective ι.1 ι.2)
end Perm
end Equiv |
.lake/packages/mathlib/Mathlib/GroupTheory/Perm/Subgroup.lean | import Mathlib.Algebra.Group.Action.End
import Mathlib.Algebra.Group.Subgroup.Finite
import Mathlib.Data.Fintype.Perm
/-!
# Lemmas about subgroups within the permutations (self-equivalences) of a type `α`
This file provides extra lemmas about some `Subgroup`s that exist within `Equiv.Perm α`.
`GroupTheory.Subgroup` depends on `GroupTheory.Perm.Basic`, so these need to be in a separate
file.
It also provides decidable instances on membership in these subgroups, since
`MonoidHom.decidableMemRange` cannot be inferred without the help of a lambda.
The presence of these instances induces a `Fintype` instance on the `QuotientGroup.Quotient` of
these subgroups.
-/
assert_not_exists Field
namespace Equiv
namespace Perm
universe u
instance sumCongrHom.decidableMemRange {α β : Type*} [DecidableEq α] [DecidableEq β] [Fintype α]
[Fintype β] : DecidablePred (· ∈ (sumCongrHom α β).range) := fun _ => inferInstance
@[simp]
theorem sumCongrHom.card_range {α β : Type*} [Fintype (sumCongrHom α β).range]
[Fintype (Perm α × Perm β)] :
Fintype.card (sumCongrHom α β).range = Fintype.card (Perm α × Perm β) :=
Fintype.card_eq.mpr ⟨(ofInjective (sumCongrHom α β) sumCongrHom_injective).symm⟩
instance sigmaCongrRightHom.decidableMemRange {α : Type*} {β : α → Type*} [DecidableEq α]
[∀ a, DecidableEq (β a)] [Fintype α] [∀ a, Fintype (β a)] :
DecidablePred (· ∈ (sigmaCongrRightHom β).range) := fun _ => inferInstance
@[simp]
theorem sigmaCongrRightHom.card_range {α : Type*} {β : α → Type*}
[Fintype (sigmaCongrRightHom β).range] [Fintype (∀ a, Perm (β a))] :
Fintype.card (sigmaCongrRightHom β).range = Fintype.card (∀ a, Perm (β a)) :=
Fintype.card_eq.mpr ⟨(ofInjective (sigmaCongrRightHom β) sigmaCongrRightHom_injective).symm⟩
instance subtypeCongrHom.decidableMemRange {α : Type*} (p : α → Prop) [DecidablePred p]
[Fintype (Perm { a // p a } × Perm { a // ¬p a })] [DecidableEq (Perm α)] :
DecidablePred (· ∈ (subtypeCongrHom p).range) := fun _ => inferInstance
@[simp]
theorem subtypeCongrHom.card_range {α : Type*} (p : α → Prop) [DecidablePred p]
[Fintype (subtypeCongrHom p).range] [Fintype (Perm { a // p a } × Perm { a // ¬p a })] :
Fintype.card (subtypeCongrHom p).range =
Fintype.card (Perm { a // p a } × Perm { a // ¬p a }) :=
Fintype.card_eq.mpr ⟨(ofInjective (subtypeCongrHom p) (subtypeCongrHom_injective p)).symm⟩
/-- **Cayley's theorem**: Every group G is isomorphic to a subgroup of the symmetric group acting on
`G`. Note that we generalize this to an arbitrary "faithful" group action by `G`. Setting `H = G`
recovers the usual statement of Cayley's theorem via `RightCancelMonoid.faithfulSMul` -/
noncomputable def subgroupOfMulAction (G H : Type*) [Group G] [MulAction G H] [FaithfulSMul G H] :
G ≃* (MulAction.toPermHom G H).range :=
MulEquiv.ofLeftInverse' _ (Classical.choose_spec MulAction.toPerm_injective.hasLeftInverse)
end Perm
end Equiv |
.lake/packages/mathlib/Mathlib/GroupTheory/Perm/DomMulAct.lean | import Mathlib.Algebra.Group.Action.End
import Mathlib.Data.Fintype.Perm
import Mathlib.Data.Set.Card
import Mathlib.GroupTheory.GroupAction.Defs
import Mathlib.GroupTheory.GroupAction.DomAct.Basic
/-!
# Subgroup of `Equiv.Perm α` preserving a function
Let `α` and `ι` by types and let `f : α → ι`
* `DomMulAct.mem_stabilizer_iff` proves that the stabilizer of `f : α → ι`
in `(Equiv.Perm α)ᵈᵐᵃ` is the set of `g : (Equiv.Perm α)ᵈᵐᵃ` such that `f ∘ (mk.symm g) = f`.
The natural equivalence from `stabilizer (Perm α)ᵈᵐᵃ f` to `{ g : Perm α // p ∘ g = f }`
can be obtained as `subtypeEquiv mk.symm (fun _ => mem_stabilizer_iff)`
* `DomMulAct.stabilizerMulEquiv` is the `MulEquiv` from
the MulOpposite of this stabilizer to the product,
for `i : ι`, of `Equiv.Perm {a // f a = i}`.
* Under `Fintype α` and `Fintype ι`, `DomMulAct.stabilizer_card p` computes
the cardinality of the type of permutations preserving `p` :
`Fintype.card {g : Perm α // f ∘ g = f} = ∏ i, (Fintype.card {a // f a = i})!`.
* Without `Fintype ι`, `DomMulAct.stabilizer_card' p` gives an equivalent
formula, where the product is restricted to `Finset.univ.image f`.
-/
assert_not_exists Field
open Equiv MulAction
variable {α ι : Type*} {f : α → ι}
namespace DomMulAct
lemma mem_stabilizer_iff {g : (Perm α)ᵈᵐᵃ} :
g ∈ stabilizer (Perm α)ᵈᵐᵃ f ↔ f ∘ (mk.symm g :) = f := by
simp only [MulAction.mem_stabilizer_iff]; rfl
/-- The `invFun` component of `MulEquiv` from `MulAction.stabilizer (Perm α) f`
to the product of the `Equiv.Perm {a // f a = i}`. -/
def stabilizerEquiv_invFun (g : ∀ i, Perm {a // f a = i}) (a : α) : α := g (f a) ⟨a, rfl⟩
lemma stabilizerEquiv_invFun_eq (g : ∀ i, Perm {a // f a = i}) {a : α} {i : ι} (h : f a = i) :
stabilizerEquiv_invFun g a = g i ⟨a, h⟩ := by subst h; rfl
lemma comp_stabilizerEquiv_invFun (g : ∀ i, Perm {a // f a = i}) (a : α) :
f (stabilizerEquiv_invFun g a) = f a :=
(g (f a) ⟨a, rfl⟩).prop
/-- The `invFun` component of `MulEquiv` from `MulAction.stabilizer (Perm α) p`
to the product of the `Equiv.Perm {a | f a = i}` (as an `Equiv.Perm α`). -/
def stabilizerEquiv_invFun_aux (g : ∀ i, Perm {a // f a = i}) : Perm α where
toFun := stabilizerEquiv_invFun g
invFun := stabilizerEquiv_invFun (fun i ↦ (g i).symm)
left_inv a := by
rw [stabilizerEquiv_invFun_eq _ (comp_stabilizerEquiv_invFun g a)]
exact congr_arg Subtype.val ((g <| f a).left_inv _)
right_inv a := by
rw [stabilizerEquiv_invFun_eq _ (comp_stabilizerEquiv_invFun _ a)]
exact congr_arg Subtype.val ((g <| f a).right_inv _)
variable (f) in
/-- The `MulEquiv` from the `MulOpposite` of `MulAction.stabilizer (Perm α)ᵈᵐᵃ f`
to the product of the `Equiv.Perm {a // f a = i}` -/
def stabilizerMulEquiv : (stabilizer (Perm α)ᵈᵐᵃ f)ᵐᵒᵖ ≃* (∀ i, Perm {a // f a = i}) where
toFun g i := Perm.subtypePerm (mk.symm g.unop) fun a ↦ by
rw [← Function.comp_apply (f := f), mem_stabilizer_iff.mp g.unop.prop]
invFun g := ⟨mk (stabilizerEquiv_invFun_aux g), by
ext a
rw [smul_apply, symm_apply_apply, Perm.smul_def]
apply comp_stabilizerEquiv_invFun⟩
right_inv g := by ext i a; apply stabilizerEquiv_invFun_eq
map_mul' _ _ := rfl
lemma stabilizerMulEquiv_apply (g : (stabilizer (Perm α)ᵈᵐᵃ f)ᵐᵒᵖ) {a : α} {i : ι} (h : f a = i) :
((stabilizerMulEquiv f)) g i ⟨a, h⟩ = (mk.symm g.unop : Equiv.Perm α) a := rfl
section Fintype
variable [Fintype α]
open Nat
variable (f)
/-- The cardinality of the type of permutations preserving a function -/
theorem stabilizer_card [DecidableEq α] [DecidableEq ι] [Fintype ι] :
Fintype.card {g : Perm α // f ∘ g = f} = ∏ i, (Fintype.card {a // f a = i})! := by
-- rewriting via Nat.card because Fintype instance is not found
rw [← Nat.card_eq_fintype_card,
Nat.card_congr (subtypeEquiv mk fun _ ↦ ?_),
Nat.card_congr MulOpposite.opEquiv,
Nat.card_congr (DomMulAct.stabilizerMulEquiv f).toEquiv, Nat.card_pi]
· exact Finset.prod_congr rfl fun i _ ↦ by rw [Nat.card_eq_fintype_card, Fintype.card_perm]
· rfl
omit [Fintype α] in
/-- The cardinality of the set of permutations preserving a function -/
theorem stabilizer_ncard [Finite α] [Fintype ι] :
Set.ncard {g : Perm α | f ∘ g = f} = ∏ i, (Set.ncard {a | f a = i})! := by
classical
cases nonempty_fintype α
simp only [← Nat.card_coe_set_eq, Set.coe_setOf, card_eq_fintype_card]
exact stabilizer_card f
variable [DecidableEq α] [DecidableEq ι]
/-- The cardinality of the type of permutations preserving a function
(without the finiteness assumption on target) -/
theorem stabilizer_card' :
Fintype.card {g : Perm α // f ∘ g = f} =
∏ i ∈ Finset.univ.image f, (Fintype.card ({a // f a = i}))! := by
set φ : α → Finset.univ.image f :=
Set.codRestrict f (Finset.univ.image f) (fun a => by simp)
suffices ∀ g : Perm α, f ∘ g = f ↔ φ ∘ g = φ by
simp only [this, stabilizer_card]
apply Finset.prod_bij (fun g _ => g.val)
· exact fun g _ => Finset.coe_mem g
· exact fun g _ g' _ => SetCoe.ext
· simp
· intro i _
apply congr_arg
apply Fintype.card_congr
apply Equiv.subtypeEquiv (Equiv.refl α)
intro a
rw [refl_apply, ← Subtype.coe_inj]
simp only [φ, Set.val_codRestrict_apply]
· intro g
simp only [funext_iff]
apply forall_congr'
intro a
simp only [Function.comp_apply, φ, ← Subtype.coe_inj, Set.val_codRestrict_apply]
end Fintype
end DomMulAct |
.lake/packages/mathlib/Mathlib/GroupTheory/Perm/Centralizer.lean | import Mathlib.Algebra.Order.BigOperators.GroupWithZero.Multiset
import Mathlib.Algebra.Order.BigOperators.Ring.Finset
import Mathlib.GroupTheory.NoncommCoprod
import Mathlib.GroupTheory.Perm.ConjAct
import Mathlib.GroupTheory.Perm.Cycle.PossibleTypes
import Mathlib.GroupTheory.Perm.DomMulAct
import Mathlib.GroupTheory.Rank
/-!
# Centralizer of a permutation and cardinality of conjugacy classes in the symmetric groups
Let `α : Type` with `Fintype α` (and `DecidableEq α`).
The main goal of this file is to compute the cardinality of
conjugacy classes in `Equiv.Perm α`.
Every `g : Equiv.Perm α` has a `g.cycleType : Multiset ℕ`.
By `Equiv.Perm.isConj_iff_cycleType_eq`,
two permutations are conjugate in `Equiv.Perm α` iff
their cycle types are equal.
To compute the cardinality of the conjugacy classes, we could use
a purely combinatorial approach and compute the number of permutations
with given cycle type but we resorted to a more algebraic approach
based on the study of the centralizer of a permutation `g`.
Given `g : Equiv.Perm α`, the conjugacy class of `g` is the orbit
of `g` under the action `ConjAct (Equiv.Perm α)`, and we use the
orbit-stabilizer theorem
(`MulAction.card_orbit_mul_card_stabilizer_eq_card_group`) to reduce
the computation to the computation of the centralizer of `g`, the
subgroup of `Equiv.Perm α` consisting of all permutations which
commute with `g`. It is accessed here as `MulAction.stabilizer
(ConjAct (Equiv.Perm α)) g` and `Subgroup.centralizer_eq_comap_stabilizer`.
We compute this subgroup as follows.
* If `h : Subgroup.centralizer {g}`, then the action of `ConjAct.toConjAct h`
by conjugation on `Equiv.Perm α` stabilizes `g.cycleFactorsFinset`.
That induces an action of `Subgroup.centralizer {g}` on
`g.cycleFactorsFinset` which is defined as an instance.
* This action defines a group morphism `Equiv.Perm.OnCycleFactors.toPermHom g`
from `Subgroup.centralizer {g}` to `Equiv.Perm g.cycleFactorsFinset`.
* `Equiv.Perm.OnCycleFactors.range_toPermHom'` is the subgroup of
`Equiv.Perm g.cycleFactorsFinset` consisting of permutations that
preserve the cardinality of the support.
* `Equiv.Perm.OnCycleFactors.range_toPermHom_eq_range_toPermHom'` shows that
the range of `Equiv.Perm.OnCycleFactors.toPermHom g`
is the subgroup `Equiv.Perm.OnCycleFactors.toPermHom_range' g`
of `Equiv.Perm g.cycleFactorsFinset`.
This is shown by constructing a right inverse
`Equiv.Perm.Basis.toCentralizer`, as established by
`Equiv.Perm.Basis.toPermHom_apply_toCentralizer`.
* `Equiv.Perm.OnCycleFactors.nat_card_range_toPermHom` computes the
cardinality of `(Equiv.Perm.OnCycleFactors.toPermHom g).range`
as a product of factorials.
* `Equiv.Perm.OnCycleFactors.mem_ker_toPermHom_iff` proves that
`k : Subgroup.centralizer {g}` belongs to the kernel of
`Equiv.Perm.OnCycleFactors.toPermHom g` if and only if it commutes with
each cycle of `g`. This is equivalent to the conjunction of two properties:
* `k` preserves the set of fixed points of `g`;
* on each cycle `c`, `k` acts as a power of that cycle.
This allows to give a description of the kernel of
`Equiv.Perm.OnCycleFactors.toPermHom g` as the product of a
symmetric group and of a product of cyclic groups. This analysis
starts with the morphism `Equiv.Perm.OnCycleFactors.kerParam`, its
injectivity `Equiv.Perm.OnCycleFactors.kerParam_injective`, its range
`Equiv.Perm.OnCycleFactors.kerParam_range_eq`, and its cardinality
`Equiv.Perm.OnCycleFactors.kerParam_range_card`.
* `Equiv.Perm.OnCycleFactors.sign_kerParam_apply_apply` computes the signature
of the permutation induced given by `Equiv.Perm.OnCycleFactors.kerParam`.
* `Equiv.Perm.nat_card_centralizer g` computes the cardinality
of the centralizer of `g`.
* `Equiv.Perm.card_isConj_mul_eq g`computes the cardinality
of the conjugacy class of `g`.
* We now can compute the cardinality of the set of permutations with given cycle type.
The condition for this cardinality to be zero is given by
`Equiv.Perm.card_of_cycleType_eq_zero_iff`
which is itself derived from `Equiv.Perm.exists_with_cycleType_iff`.
* `Equiv.Perm.card_of_cycleType_mul_eq m` and `Equiv.Perm.card_of_cycleType m`
compute this cardinality.
-/
open scoped Finset Pointwise
namespace Equiv.Perm
open MulAction Equiv Subgroup
variable {α : Type*} [DecidableEq α] [Fintype α] {g : Equiv.Perm α}
namespace OnCycleFactors
variable (g)
variable {g} in
lemma Subgroup.Centralizer.toConjAct_smul_mem_cycleFactorsFinset {k c : Perm α}
(k_mem : k ∈ centralizer {g}) (c_mem : c ∈ g.cycleFactorsFinset) :
ConjAct.toConjAct k • c ∈ g.cycleFactorsFinset := by
suffices (g.cycleFactorsFinset : Set (Perm α)) =
(ConjAct.toConjAct k) • g.cycleFactorsFinset by
rw [← Finset.mem_coe, this]
simp only [Set.smul_mem_smul_set_iff, Finset.mem_coe, c_mem]
have this := cycleFactorsFinset_conj_eq (ConjAct.toConjAct (k : Perm α)) g
rw [ConjAct.toConjAct_smul, mem_centralizer_singleton_iff.mp k_mem, mul_assoc] at this
simp only [mul_inv_cancel, mul_one] at this
conv_lhs => rw [this]
simp only [Finset.coe_smul_finset]
/-- The action by conjugation of `Subgroup.centralizer {g}`
on the cycles of a given permutation -/
def Subgroup.Centralizer.cycleFactorsFinset_mulAction :
MulAction (centralizer {g}) g.cycleFactorsFinset where
smul k c := ⟨ConjAct.toConjAct (k : Perm α) • c.val,
Subgroup.Centralizer.toConjAct_smul_mem_cycleFactorsFinset k.prop c.prop⟩
one_smul c := by
rw [← Subtype.coe_inj]
change ConjAct.toConjAct (1 : Perm α) • c.val = c
simp only [map_one, one_smul]
mul_smul k l c := by
simp only [← Subtype.coe_inj]
change ConjAct.toConjAct (k * l : Perm α) • c.val =
ConjAct.toConjAct (k : Perm α) • (ConjAct.toConjAct (l : Perm α)) • c.val
simp only [map_mul, mul_smul]
/-- The conjugation action of `Subgroup.centralizer {g}` on `g.cycleFactorsFinset` -/
scoped instance : MulAction (centralizer {g}) (g.cycleFactorsFinset) :=
(Subgroup.Centralizer.cycleFactorsFinset_mulAction g)
/-- The canonical morphism from `Subgroup.centralizer {g}`
to the group of permutations of `g.cycleFactorsFinset` -/
def toPermHom := MulAction.toPermHom (centralizer {g}) g.cycleFactorsFinset
theorem centralizer_smul_def (k : centralizer {g}) (c : g.cycleFactorsFinset) :
k • c = ⟨k * c * k⁻¹,
Subgroup.Centralizer.toConjAct_smul_mem_cycleFactorsFinset k.prop c.prop⟩ :=
rfl
@[simp]
theorem val_centralizer_smul (k : Subgroup.centralizer {g}) (c : g.cycleFactorsFinset) :
((k • c :) : Perm α) = k * c * k⁻¹ :=
rfl
theorem toPermHom_apply (k : centralizer {g}) (c : g.cycleFactorsFinset) :
(toPermHom g k c) = k • c := rfl
theorem coe_toPermHom (k : centralizer {g}) (c : g.cycleFactorsFinset) :
(toPermHom g k c : Perm α) = k * c * (k : Perm α)⁻¹ := rfl
/-- The range of `Equiv.Perm.OnCycleFactors.toPermHom`.
The equality is proved by `Equiv.Perm.OnCycleFactors.range_toPermHom_eq_range_toPermHom'`. -/
def range_toPermHom' : Subgroup (Perm g.cycleFactorsFinset) where
carrier := {τ | ∀ c, #(τ c).val.support = #c.val.support}
one_mem' := by simp
mul_mem' hσ hτ := by
simp only [Subtype.forall, Set.mem_setOf_eq, coe_mul, Function.comp_apply]
simp only [Subtype.forall, Set.mem_setOf_eq] at hσ hτ
intro c hc
rw [hσ, hτ]
inv_mem' hσ := by
simp only [Subtype.forall, Set.mem_setOf_eq] at hσ ⊢
intro c hc
rw [← hσ _ (by simp)]
simp
variable {g} in
theorem mem_range_toPermHom'_iff {τ : Perm g.cycleFactorsFinset} :
τ ∈ range_toPermHom' g ↔ ∀ c, #(τ c).val.support = #c.val.support :=
Iff.rfl
variable (k : centralizer {g})
/-- `k : Subgroup.centralizer {g}` belongs to the kernel of `toPermHom g`
iff it commutes with each cycle of `g` -/
theorem mem_ker_toPermHom_iff :
k ∈ (toPermHom g).ker ↔ ∀ c ∈ g.cycleFactorsFinset, Commute (k : Perm α) c := by
simp only [toPermHom, MonoidHom.mem_ker, DFunLike.ext_iff, Subtype.forall]
refine forall₂_congr (fun _ _ ↦ ?_)
simp [← Subtype.coe_inj, commute_iff_eq, mul_inv_eq_iff_eq_mul]
end OnCycleFactors
open OnCycleFactors
/-- A `Basis` of a permutation is a choice of an element in each of its cycles -/
structure Basis (g : Equiv.Perm α) where
/-- A choice of elements in each cycle -/
(toFun : g.cycleFactorsFinset → α)
/-- For each cycle, the chosen element belongs to the cycle -/
(mem_support_self' : ∀ (c : g.cycleFactorsFinset), toFun c ∈ c.val.support)
instance (g : Perm α) : FunLike (Basis g) g.cycleFactorsFinset α where
coe a := a.toFun
coe_injective' a a' _ := by cases a; cases a'; congr
namespace Basis
theorem nonempty (g : Perm α) : Nonempty (Basis g) := by
have (c : g.cycleFactorsFinset) : c.val.support.Nonempty :=
IsCycle.nonempty_support (mem_cycleFactorsFinset_iff.mp c.prop).1
exact ⟨fun c ↦ (this c).choose, fun c ↦ (this c).choose_spec⟩
variable (a : Basis g) (c : g.cycleFactorsFinset)
theorem mem_support_self :
a c ∈ c.val.support := a.mem_support_self' c
theorem injective : Function.Injective a := by
intro c d h
rw [← Subtype.coe_inj]
apply g.cycleFactorsFinset_pairwise_disjoint.eq c.prop d.prop
simp only [Disjoint, not_forall, not_or]
use a c
conv_rhs => rw [h]
simp only [← Perm.mem_support, a.mem_support_self c, a.mem_support_self d, and_self]
theorem cycleOf_eq : g.cycleOf (a c) = c :=
(cycle_is_cycleOf (a.mem_support_self c) c.prop).symm
theorem sameCycle {x : α} (hx : g.cycleOf x ∈ g.cycleFactorsFinset) :
g.SameCycle (a ⟨g.cycleOf x, hx⟩) x :=
(mem_support_cycleOf_iff.mp (a.mem_support_self ⟨g.cycleOf x, hx⟩)).1.symm
variable (τ : range_toPermHom' g)
/-- The function that will provide a right inverse `toCentralizer` to `toPermHom` -/
def ofPermHomFun (x : α) : α :=
if hx : g.cycleOf x ∈ g.cycleFactorsFinset
then
(g ^ (Nat.find (a.sameCycle hx).exists_nat_pow_eq))
(a ((τ : Perm g.cycleFactorsFinset) ⟨g.cycleOf x, hx⟩))
else x
theorem mem_fixedPoints_or_exists_zpow_eq (x : α) :
x ∈ Function.fixedPoints g ∨
∃ (c : g.cycleFactorsFinset) (_ : x ∈ c.val.support) (m : ℤ), (g ^ m) (a c) = x := by
rw [Classical.or_iff_not_imp_left]
intro hx
rw [Function.mem_fixedPoints_iff, ← ne_eq, ← mem_support,
← cycleOf_mem_cycleFactorsFinset_iff] at hx
refine ⟨⟨g.cycleOf x, hx⟩, ?_, (a.sameCycle hx)⟩
rw [mem_support_cycleOf_iff, ← cycleOf_mem_cycleFactorsFinset_iff]
simp [SameCycle.rfl, hx, and_self]
theorem ofPermHomFun_apply_of_cycleOf_mem {x : α} {c : g.cycleFactorsFinset}
(hx : x ∈ c.val.support) {m : ℤ} (hm : (g ^ m) (a c) = x) :
ofPermHomFun a τ x = (g ^ m) (a ((τ : Perm g.cycleFactorsFinset) c)) := by
have hx' : c = g.cycleOf x := cycle_is_cycleOf hx (Subtype.prop c)
have hx'' : g.cycleOf x ∈ g.cycleFactorsFinset := hx' ▸ c.prop
set n := Nat.find (a.sameCycle hx'').exists_nat_pow_eq
have hn : (g ^ (n : ℤ)) (a c) = x := by
rw [← Nat.find_spec (a.sameCycle hx'').exists_nat_pow_eq, zpow_natCast]
congr
rw [← Subtype.coe_inj, hx']
suffices ofPermHomFun a τ x = (g ^ (n : ℤ)) (a ((τ : Perm g.cycleFactorsFinset) c)) by
rw [this, IsCycleOn.zpow_apply_eq_zpow_apply
(isCycleOn_support_of_mem_cycleFactorsFinset ((τ : Perm g.cycleFactorsFinset) c).prop)
(mem_support_self a ((τ : Perm g.cycleFactorsFinset) c))]
simp only [τ.prop c]
rw [← IsCycleOn.zpow_apply_eq_zpow_apply
(isCycleOn_support_of_mem_cycleFactorsFinset c.prop) (mem_support_self a c)]
rw [hn, hm]
simp only [ofPermHomFun, dif_pos hx'']
congr
exact hx'.symm
theorem ofPermHomFun_apply_of_mem_fixedPoints {x : α} (hx : x ∈ Function.fixedPoints g) :
ofPermHomFun a τ x = x := by
rw [ofPermHomFun, dif_neg]
rw [cycleOf_mem_cycleFactorsFinset_iff, notMem_support]
exact hx
theorem ofPermHomFun_apply_mem_support_cycle_iff {x : α} {c : g.cycleFactorsFinset} :
ofPermHomFun a τ x ∈ ((τ : Perm g.cycleFactorsFinset) c : Perm α).support ↔
x ∈ c.val.support := by
rcases mem_fixedPoints_or_exists_zpow_eq a x with (hx | ⟨d, hd, m, hm⟩)
· simp only [ofPermHomFun_apply_of_mem_fixedPoints a τ hx]
suffices ∀ (d : g.cycleFactorsFinset), x ∉ (d : Perm α).support by
simp only [this]
intro d hx'
rw [Function.mem_fixedPoints_iff, ← notMem_support] at hx
apply hx
exact mem_cycleFactorsFinset_support_le d.prop hx'
· rw [ofPermHomFun_apply_of_cycleOf_mem a τ hd hm] --
rw [zpow_apply_mem_support_of_mem_cycleFactorsFinset_iff]
by_cases h : c = d
· simp only [h, hd, mem_support_self]
· have H : Disjoint c.val d.val :=
cycleFactorsFinset_pairwise_disjoint g c.prop d.prop (Subtype.coe_ne_coe.mpr h)
have H' : Disjoint ((τ : Perm g.cycleFactorsFinset) c : Perm α)
((τ : Perm g.cycleFactorsFinset) d : Perm α) :=
cycleFactorsFinset_pairwise_disjoint g ((τ : Perm g.cycleFactorsFinset) c).prop
((τ : Perm g.cycleFactorsFinset) d).prop (by
intro h'; apply h
simpa only [Subtype.coe_inj, EmbeddingLike.apply_eq_iff_eq] using h')
rw [disjoint_iff_disjoint_support, Finset.disjoint_right] at H H'
simp only [H hd, H' (mem_support_self a _)]
theorem ofPermHomFun_commute_zpow_apply (x : α) (j : ℤ) :
ofPermHomFun a τ ((g ^ j) x) = (g ^ j) (ofPermHomFun a τ x) := by
rcases mem_fixedPoints_or_exists_zpow_eq a x with (hx | hx)
· rw [ofPermHomFun_apply_of_mem_fixedPoints a τ hx, ofPermHomFun_apply_of_mem_fixedPoints]
rw [Function.mem_fixedPoints_iff]
simp only [← mul_apply, ← zpow_one_add, add_comm]
conv_rhs => rw [← hx, ← mul_apply, ← zpow_add_one]
· obtain ⟨c, hc, m, hm⟩ := hx
have hm' : (g ^ (j + m)) (a c) = (g ^ j) x := by rw [zpow_add, mul_apply, hm]
rw [ofPermHomFun_apply_of_cycleOf_mem a τ hc hm, ofPermHomFun_apply_of_cycleOf_mem a τ _ hm',
← mul_apply, ← zpow_add]
exact zpow_apply_mem_support_of_mem_cycleFactorsFinset_iff.mpr hc
theorem ofPermHomFun_mul (σ τ : range_toPermHom' g) (x) :
ofPermHomFun a (σ * τ) x = (ofPermHomFun a σ) (ofPermHomFun a τ x) := by
rcases mem_fixedPoints_or_exists_zpow_eq a x with (hx | ⟨c, hc, m, hm⟩)
· simp only [ofPermHomFun_apply_of_mem_fixedPoints a _ hx]
· simp only [ofPermHomFun_apply_of_cycleOf_mem a _ hc hm]
rw [ofPermHomFun_apply_of_cycleOf_mem a _ _ rfl]
· rfl
· rw [zpow_apply_mem_support_of_mem_cycleFactorsFinset_iff]
apply mem_support_self
theorem ofPermHomFun_one (x : α) : (ofPermHomFun a 1) x = x := by
rcases mem_fixedPoints_or_exists_zpow_eq a x with (hx | ⟨c, hc, m, hm⟩)
· rw [ofPermHomFun_apply_of_mem_fixedPoints a _ hx]
· rw [ofPermHomFun_apply_of_cycleOf_mem a _ hc hm, OneMemClass.coe_one, coe_one, id_eq, hm]
/-- Given `a : g.Basis` and a permutation of `g.cycleFactorsFinset` that
preserve the lengths of the cycles, a permutation of `α` that
moves the `Basis` and commutes with `g` -/
noncomputable def ofPermHom : range_toPermHom' g →* Perm α where
toFun τ := {
toFun := ofPermHomFun a τ
invFun := ofPermHomFun a τ⁻¹
left_inv := fun x ↦ by rw [← ofPermHomFun_mul, inv_mul_cancel, ofPermHomFun_one]
right_inv := fun x ↦ by rw [← ofPermHomFun_mul, mul_inv_cancel, ofPermHomFun_one] }
map_one' := ext fun x ↦ ofPermHomFun_one a x
map_mul' := fun σ τ ↦ ext fun x ↦ by simp [mul_apply, ofPermHomFun_mul a σ τ x]
theorem ofPermHom_apply (τ) (x) : a.ofPermHom τ x = a.ofPermHomFun τ x := rfl
theorem ofPermHom_support :
(ofPermHom a τ).support =
(τ : Perm g.cycleFactorsFinset).support.biUnion (fun c ↦ c.val.support) := by
ext x
simp only [mem_support, Finset.mem_biUnion, ofPermHom_apply]
rcases mem_fixedPoints_or_exists_zpow_eq a x with (hx | ⟨c, hc, m, hm⟩)
· simp only [ofPermHomFun_apply_of_mem_fixedPoints a τ hx, ne_eq, not_true_eq_false, false_iff,
← mem_support]
rintro ⟨c, -, hc⟩
rw [Function.mem_fixedPoints_iff] at hx
exact mem_support.mp ((mem_cycleFactorsFinset_support_le c.prop) hc) hx
· rw [ofPermHomFun_apply_of_cycleOf_mem a τ hc hm]
conv_lhs => rw [← hm]
rw [(g ^ m).injective.ne_iff, a.injective.ne_iff, not_iff_comm]
by_cases H : (τ : Perm g.cycleFactorsFinset) c = c
· simp only [H, iff_true]
push_neg
intro d hd
rw [← notMem_support]
have := g.cycleFactorsFinset_pairwise_disjoint c.prop d.prop
rw [disjoint_iff_disjoint_support, Finset.disjoint_left] at this
exact this (by aesop) hc
· simpa only [H, iff_false, not_not] using ⟨c, H, mem_support.mp hc⟩
theorem card_ofPermHom_support :
#(ofPermHom a τ).support = ∑ c ∈ (τ : Perm g.cycleFactorsFinset).support, #c.val.support := by
rw [ofPermHom_support, Finset.card_biUnion]
intro c _ d _ h
apply Equiv.Perm.Disjoint.disjoint_support
apply g.cycleFactorsFinset_pairwise_disjoint c.prop d.prop (Subtype.coe_ne_coe.mpr h)
theorem ofPermHom_mem_centralizer :
a.ofPermHom τ ∈ centralizer {g} := by
rw [mem_centralizer_singleton_iff]
ext x
simp only [mul_apply]
exact ofPermHomFun_commute_zpow_apply a τ x 1
/-- Given `a : Equiv.Perm.Basis g`,
we define a right inverse of `Equiv.Perm.OnCycleFactors.toPermHom`,
on `range_toPermHom' g` -/
noncomputable def toCentralizer :
range_toPermHom' g →* centralizer {g} where
toFun τ := ⟨ofPermHom a τ, ofPermHom_mem_centralizer a τ⟩
map_one' := by simp only [map_one, mk_eq_one]
map_mul' σ τ := by simp only [map_mul, MulMemClass.mk_mul_mk]
theorem toCentralizer_apply (x) : (toCentralizer a τ : Perm α) x = ofPermHomFun a τ x := rfl
theorem toCentralizer_equivariant :
(toCentralizer a τ) • c = (τ : Perm g.cycleFactorsFinset) c := by
simp only [← Subtype.coe_inj, val_centralizer_smul, InvMemClass.coe_inv, mul_inv_eq_iff_eq_mul]
ext x
simp only [mul_apply, toCentralizer_apply]
by_cases hx : x ∈ c.val.support
· rw [(mem_cycleFactorsFinset_iff.mp c.prop).2 x hx]
have := ofPermHomFun_commute_zpow_apply a τ x 1
simp only [zpow_one] at this
rw [this, ← (mem_cycleFactorsFinset_iff.mp ((τ : Perm g.cycleFactorsFinset) c).prop).2]
rw [ofPermHomFun_apply_mem_support_cycle_iff]
exact hx
· rw [notMem_support.mp hx, eq_comm, ← notMem_support,
ofPermHomFun_apply_mem_support_cycle_iff]
exact hx
theorem toPermHom_apply_toCentralizer :
(toPermHom g) (toCentralizer a τ) = (τ : Perm g.cycleFactorsFinset) := by
apply ext
intro c
rw [OnCycleFactors.toPermHom_apply, toCentralizer_equivariant]
end Basis
namespace OnCycleFactors
open Basis BigOperators Nat Equiv.Perm
theorem mem_range_toPermHom_iff {τ} : τ ∈ (toPermHom g).range ↔
∀ c, #(τ c).val.support = #c.val.support := by
constructor
· rintro ⟨k, rfl⟩ c
rw [coe_toPermHom, Equiv.Perm.support_conj]
apply Finset.card_map
· obtain ⟨a⟩ := Basis.nonempty g
exact fun hτ ↦ ⟨toCentralizer a ⟨τ, hτ⟩, toPermHom_apply_toCentralizer a ⟨τ, hτ⟩⟩
/-- Unapplied variant of `Equiv.Perm.mem_range_toPermHom_iff` -/
theorem mem_range_toPermHom_iff' {τ} : τ ∈ (toPermHom g).range ↔
(fun (c : g.cycleFactorsFinset) ↦ #c.val.support) ∘ τ =
fun (c : g.cycleFactorsFinset) ↦ #c.val.support := by
rw [mem_range_toPermHom_iff, funext_iff]
simp only [Subtype.forall, Function.comp_apply]
/-- Computes the range of `Equiv.Perm.toPermHom g` -/
theorem range_toPermHom_eq_range_toPermHom' :
(toPermHom g).range = range_toPermHom' g := by
ext τ
rw [mem_range_toPermHom_iff, mem_range_toPermHom'_iff]
theorem nat_card_range_toPermHom :
Nat.card (toPermHom g).range =
∏ n ∈ g.cycleType.toFinset, (g.cycleType.count n)! := by
classical
set sc := fun (c : g.cycleFactorsFinset) ↦ #c.val.support with hsc
suffices Fintype.card (toPermHom g).range =
Fintype.card { k : Perm g.cycleFactorsFinset | sc ∘ k = sc } by
simp only [Nat.card_eq_fintype_card, this, Set.coe_setOf, DomMulAct.stabilizer_card', hsc,
Finset.univ_eq_attach]
simp_rw [← CycleType.count_def]
apply Finset.prod_congr _ (fun _ _ => rfl)
ext n
simp only [Finset.mem_image, Finset.mem_attach,
true_and, Subtype.exists, exists_prop, Multiset.mem_toFinset]
simp only [cycleType_def, Function.comp_apply, Multiset.mem_map, Finset.mem_val]
simp only [Fintype.card_eq_nat_card]
congr
ext
rw [mem_range_toPermHom_iff', Set.mem_setOf_eq]
section Kernel
/- Here, we describe the kernel of `g.OnCycleFactors.toPermHom` -/
variable (g) in
/-- The parametrization of the kernel of `toPermHom` -/
def kerParam : (Perm (Function.fixedPoints g)) ×
((c : g.cycleFactorsFinset) → Subgroup.zpowers c.val) →* Perm α :=
MonoidHom.noncommCoprod ofSubtype (Subgroup.noncommPiCoprod g.pairwise_commute_of_mem_zpowers)
g.commute_ofSubtype_noncommPiCoprod
theorem kerParam_apply {u : Perm (Function.fixedPoints g)}
{v : (c : g.cycleFactorsFinset) → Subgroup.zpowers c.val} {x : α} :
kerParam g (u, v) x =
if hx : g.cycleOf x ∈ g.cycleFactorsFinset
then (v ⟨g.cycleOf x, hx⟩ : Perm α) x
else ofSubtype u x := by
split_ifs with hx
· have hx' := hx
rw [cycleOf_mem_cycleFactorsFinset_iff, mem_support, Ne, ← Function.mem_fixedPoints_iff] at hx'
rw [kerParam, MonoidHom.noncommCoprod_apply', mul_apply, ofSubtype_apply_of_not_mem u hx',
noncommPiCoprod_apply, ← Finset.noncommProd_erase_mul _ (Finset.mem_univ ⟨g.cycleOf x, hx⟩),
mul_apply, ← notMem_support]
contrapose! hx'
obtain ⟨a, ha1, ha2⟩ := mem_support_of_mem_noncommProd_support hx'
simp only [Finset.mem_erase, Finset.mem_univ, and_true, Ne, Subtype.ext_iff] at ha1
have key := cycleFactorsFinset_pairwise_disjoint g a.2 hx ha1
rw [disjoint_iff_disjoint_support, Finset.disjoint_left] at key
obtain ⟨k, hk⟩ := mem_zpowers_iff.mp (v a).2
replace ha2 := key (support_zpow_le a.1 k (hk ▸ ha2))
obtain ⟨k, hk⟩ := mem_zpowers_iff.mp (v ⟨g.cycleOf x, hx⟩).2
rwa [← hk, zpow_apply_mem_support, notMem_support, cycleOf_apply_self] at ha2
· rw [cycleOf_mem_cycleFactorsFinset_iff] at hx
rw [kerParam, MonoidHom.noncommCoprod_apply, mul_apply, Equiv.apply_eq_iff_eq,
← notMem_support]
contrapose! hx
obtain ⟨a, -, ha⟩ := mem_support_of_mem_noncommProd_support
(comm := fun a ha b hb h ↦ g.pairwise_commute_of_mem_zpowers h (v a) (v b) (v a).2 (v b).2) hx
exact support_zpowers_of_mem_cycleFactorsFinset_le (v a) ha
theorem kerParam_injective (g : Perm α) : Function.Injective (kerParam g) := by
rw [kerParam, MonoidHom.noncommCoprod_injective]
refine ⟨ofSubtype_injective, ?_, ?_⟩
· apply MonoidHom.injective_noncommPiCoprod_of_iSupIndep
· intro a
simp only [range_subtype, ne_eq]
simp only [zpowers_eq_closure, ← closure_iUnion]
apply disjoint_closure_of_disjoint_support
rintro - ⟨-⟩ - ⟨-, ⟨b, rfl⟩, -, ⟨h, rfl⟩, ⟨-⟩⟩
rw [← disjoint_iff_disjoint_support]
apply cycleFactorsFinset_pairwise_disjoint g a.2 b.2
simp only [ne_eq, ← Subtype.ext_iff]
exact ne_comm.mp h
· exact fun i ↦ subtype_injective _
· rw [noncommPiCoprod_range, ← ofSubtype.range.closure_eq]
simp only [zpowers_eq_closure, ← closure_iUnion]
apply disjoint_closure_of_disjoint_support
rintro - ⟨a, rfl⟩ - ⟨-, ⟨b, rfl⟩, ⟨-⟩⟩
exact (ofSubtype_support_disjoint a).mono_right (mem_cycleFactorsFinset_support_le b.2)
theorem kerParam_range_eq :
(kerParam g).range = (toPermHom g).ker.map (Subgroup.subtype _) := by
apply le_antisymm
· rw [kerParam, MonoidHom.noncommCoprod_range, sup_le_iff, noncommPiCoprod_range, iSup_le_iff]
simp only [zpowers_le]
constructor
· rintro - ⟨a, rfl⟩
refine ⟨⟨ofSubtype a, ?_⟩, ?_, rfl⟩
· rw [mem_centralizer_singleton_iff]
exact Disjoint.commute (disjoint_iff_disjoint_support.mpr (ofSubtype_support_disjoint a))
· exact Perm.ext fun x ↦ Subtype.ext (disjoint_iff_disjoint_support.mpr
((ofSubtype_support_disjoint a).mono_right
(mem_cycleFactorsFinset_support_le x.2))).commute.mul_inv_cancel
· intro i
refine ⟨⟨i, mem_centralizer_singleton_iff.mpr (self_mem_cycle_factors_commute i.2)⟩, ?_, rfl⟩
exact Perm.ext fun x ↦ Subtype.ext (cycleFactorsFinset_mem_commute' g i.2 x.2).mul_inv_cancel
· rintro - ⟨p, hp, rfl⟩
simp only [coe_subtype]
set u : Perm (Function.fixedPoints g) :=
subtypePerm p (fun x ↦ apply_mem_fixedPoints_iff_mem_of_mem_centralizer p.2)
simp only [SetLike.mem_coe, mem_ker_toPermHom_iff, IsCycle.forall_commute_iff] at hp
set v : (c : g.cycleFactorsFinset) → (Subgroup.zpowers c.val) :=
fun c => ⟨ofSubtype
(p.1.subtypePerm (Classical.choose (hp c.val c.prop))),
Classical.choose_spec (hp c.val c.prop)⟩
use (u, v)
ext x
rw [kerParam_apply]
split_ifs with hx
· rw [cycleOf_mem_cycleFactorsFinset_iff, mem_support] at hx
rw [ofSubtype_apply_of_mem, subtypePerm_apply]
rwa [mem_support, cycleOf_apply_self, ne_eq]
· rw [cycleOf_mem_cycleFactorsFinset_iff, notMem_support] at hx
rwa [ofSubtype_apply_of_mem, subtypePerm_apply]
theorem kerParam_range_le_centralizer :
(kerParam g).range ≤ Subgroup.centralizer {g} := by
rw [kerParam_range_eq]
exact map_subtype_le (toPermHom g).ker
theorem kerParam_range_card (g : Equiv.Perm α) :
Fintype.card (kerParam g).range = (Fintype.card α - g.cycleType.sum)! * g.cycleType.prod := by
rw [Fintype.card_coeSort_range (kerParam_injective g)]
rw [Fintype.card_prod, Fintype.card_perm, Fintype.card_pi, card_fixedPoints]
apply congr_arg
rw [Finset.univ_eq_attach, g.cycleFactorsFinset.prod_attach (fun i ↦ Fintype.card (zpowers i)),
cycleType, Finset.prod_map_val]
refine Finset.prod_congr rfl (fun x hx ↦ ?_)
rw [Fintype.card_zpowers, (mem_cycleFactorsFinset_iff.mp hx).1.orderOf, Function.comp_apply]
end Kernel
section Sign
open Function
variable {a : Type*} (g : Perm α) (k : Perm (fixedPoints g))
(v : (c : g.cycleFactorsFinset) → Subgroup.zpowers (c : Perm α))
theorem sign_kerParam_apply_apply :
sign (kerParam g ⟨k, v⟩) = sign k * ∏ c, sign (v c).val := by
rw [kerParam, MonoidHom.noncommCoprod_apply, ← Prod.fst_mul_snd ⟨k, v⟩, Prod.mk_mul_mk, mul_one,
one_mul, map_mul, sign_ofSubtype, Finset.univ_eq_attach, mul_right_inj, ← MonoidHom.comp_apply,
Subgroup.noncommPiCoprod, MonoidHom.comp_noncommPiCoprod _, MonoidHom.noncommPiCoprod_apply,
Finset.univ_eq_attach, Finset.noncommProd_eq_prod]
simp
theorem cycleType_kerParam_apply_apply :
cycleType (kerParam g ⟨k, v⟩) = cycleType k + ∑ c, (v c).val.cycleType := by
let U := SetLike.coe (Finset.univ : Finset { x // x ∈ g.cycleFactorsFinset })
have hU : U.Pairwise fun i j ↦ (v i).val.Disjoint (v j).val := fun c _ d _ h ↦ by
obtain ⟨m, hm⟩ := (v c).prop
obtain ⟨n, hn⟩ := (v d).prop
simp only [← hm, ← hn]
apply Disjoint.zpow_disjoint_zpow
apply cycleFactorsFinset_pairwise_disjoint g c.prop d.prop
exact Subtype.coe_ne_coe.mpr h
rw [kerParam, MonoidHom.noncommCoprod_apply, ← Prod.fst_mul_snd ⟨k, v⟩, Prod.mk_mul_mk, mul_one,
one_mul, Finset.univ_eq_attach,
Disjoint.cycleType_mul (disjoint_ofSubtype_noncommPiCoprod g k v),
Subgroup.noncommPiCoprod_apply, Disjoint.cycleType_noncommProd hU, Finset.univ_eq_attach]
exact congr_arg₂ _ cycleType_ofSubtype rfl
end Sign
end OnCycleFactors
open Nat
variable (g : Perm α)
-- Should one parenthesize the product ?
/-- Cardinality of the centralizer in `Equiv.Perm α` of a permutation given `cycleType` -/
theorem nat_card_centralizer :
Nat.card (centralizer {g}) =
(Fintype.card α - g.cycleType.sum)! * g.cycleType.prod *
(∏ n ∈ g.cycleType.toFinset, (g.cycleType.count n)!) := by
rw [← (toPermHom g).ker.card_mul_index, index_ker, nat_card_range_toPermHom,
← kerParam_range_card, ← Nat.card_eq_fintype_card, kerParam_range_eq, card_subtype]
theorem card_isConj_mul_eq :
Nat.card {h : Perm α | IsConj g h} *
((Fintype.card α - g.cycleType.sum)! *
g.cycleType.prod *
(∏ n ∈ g.cycleType.toFinset, (g.cycleType.count n)!)) =
(Fintype.card α)! := by
classical
rw [Nat.card_eq_fintype_card, ← nat_card_centralizer g]
rw [Subgroup.nat_card_centralizer_nat_card_stabilizer, Nat.card_eq_fintype_card]
convert MulAction.card_orbit_mul_card_stabilizer_eq_card_group (ConjAct (Perm α)) g
· ext h
simp only [Set.mem_setOf_eq, ConjAct.mem_orbit_conjAct, isConj_comm]
· rw [ConjAct.card, Fintype.card_perm]
/-- Cardinality of a conjugacy class in `Equiv.Perm α` of a given `cycleType` -/
theorem card_isConj_eq :
Nat.card {h : Perm α | IsConj g h} =
(Fintype.card α)! /
((Fintype.card α - g.cycleType.sum)! *
g.cycleType.prod *
(∏ n ∈ g.cycleType.toFinset, (g.cycleType.count n)!)) := by
rw [← card_isConj_mul_eq g, Nat.div_eq_of_eq_mul_left _]
· rfl
-- This is the cardinal of the centralizer
· rw [← nat_card_centralizer g]
apply Nat.card_pos
variable (α)
theorem card_of_cycleType_eq_zero_iff {m : Multiset ℕ} :
#({g | g.cycleType = m} : Finset (Perm α)) = 0
↔ ¬ ((m.sum ≤ Fintype.card α ∧ ∀ a ∈ m, 2 ≤ a)) := by
rw [Finset.card_eq_zero, Finset.filter_eq_empty_iff,
← exists_with_cycleType_iff, not_exists]
simp
theorem card_of_cycleType_mul_eq (m : Multiset ℕ) :
#({g | g.cycleType = m} : Finset (Perm α)) *
((Fintype.card α - m.sum)! * m.prod * (∏ n ∈ m.toFinset, (m.count n)!)) =
if (m.sum ≤ Fintype.card α ∧ ∀ a ∈ m, 2 ≤ a) then (Fintype.card α)! else 0 := by
split_ifs with hm
· -- nonempty case
classical
obtain ⟨g, rfl⟩ := (exists_with_cycleType_iff α).mpr hm
convert card_isConj_mul_eq g
simp_rw [Set.coe_setOf, Nat.card_eq_fintype_card, ← Fintype.card_coe, Finset.mem_filter,
Finset.mem_univ, true_and, ← isConj_iff_cycleType_eq, isConj_comm (g := g)]
· -- empty case
rw [(card_of_cycleType_eq_zero_iff α).mpr hm, zero_mul]
/-- Cardinality of the `Finset` of `Equiv.Perm α` of given `cycleType` -/
theorem card_of_cycleType (m : Multiset ℕ) :
#({g | g.cycleType = m} : Finset (Perm α)) =
if m.sum ≤ Fintype.card α ∧ ∀ a ∈ m, 2 ≤ a then
(Fintype.card α)! /
((Fintype.card α - m.sum)! * m.prod * (∏ n ∈ m.toFinset, (m.count n)!))
else 0 := by
split_ifs with hm
· -- nonempty case
apply symm
apply Nat.div_eq_of_eq_mul_left
· have : 0 < m.prod := Multiset.prod_pos <| fun a ha => zero_lt_two.trans_le (hm.2 a ha)
positivity
rw [card_of_cycleType_mul_eq, if_pos hm]
· -- empty case
exact (card_of_cycleType_eq_zero_iff α).mpr hm
open Fintype in
variable {α} in
/-- The number of cycles of given length -/
lemma card_of_cycleType_singleton {n : ℕ} (hn' : 2 ≤ n) (hα : n ≤ card α) :
#({g | g.cycleType = {n}} : Finset (Perm α)) = (n - 1)! * (choose (card α) n) := by
have hn₀ : n ≠ 0 := by omega
have aux : n ! = (n - 1)! * n := by rw [mul_comm, mul_factorial_pred hn₀]
rw [mul_comm, ← Nat.mul_left_inj hn₀, mul_assoc, ← aux, ← Nat.mul_left_inj (factorial_ne_zero _),
Nat.choose_mul_factorial_mul_factorial hα, mul_assoc]
simpa [ite_and, if_pos hα, if_pos hn', mul_comm _ n, mul_assoc]
using card_of_cycleType_mul_eq α {n}
end Equiv.Perm |
.lake/packages/mathlib/Mathlib/GroupTheory/Perm/Cycle/Factors.lean | import Mathlib.Data.List.Iterate
import Mathlib.Data.Set.Pairwise.List
import Mathlib.GroupTheory.Perm.Cycle.Basic
import Mathlib.GroupTheory.NoncommPiCoprod
import Mathlib.Tactic.Group
/-!
# Cycle factors of a permutation
Let `β` be a `Fintype` and `f : Equiv.Perm β`.
* `Equiv.Perm.cycleOf`: `f.cycleOf x` is the cycle of `f` that `x` belongs to.
* `Equiv.Perm.cycleFactors`: `f.cycleFactors` is a list of disjoint cyclic permutations
that multiply to `f`.
-/
open Equiv Function Finset
variable {ι α β : Type*}
namespace Equiv.Perm
/-!
### `cycleOf`
-/
section CycleOf
variable {f g : Perm α} {x y : α}
/-- `f.cycleOf x` is the cycle of the permutation `f` to which `x` belongs. -/
def cycleOf (f : Perm α) [DecidableRel f.SameCycle] (x : α) : Perm α :=
ofSubtype (subtypePerm f fun _ => sameCycle_apply_right : Perm { y // SameCycle f x y })
theorem cycleOf_apply (f : Perm α) [DecidableRel f.SameCycle] (x y : α) :
cycleOf f x y = if SameCycle f x y then f y else y := by
dsimp only [cycleOf]
split_ifs with h
· apply ofSubtype_apply_of_mem
exact h
· apply ofSubtype_apply_of_not_mem
exact h
theorem cycleOf_inv (f : Perm α) [DecidableRel f.SameCycle] (x : α) :
(cycleOf f x)⁻¹ = cycleOf f⁻¹ x :=
Equiv.ext fun y => by
rw [inv_eq_iff_eq, cycleOf_apply, cycleOf_apply]
split_ifs <;> simp_all [sameCycle_inv, sameCycle_inv_apply_right]
@[simp]
theorem cycleOf_pow_apply_self (f : Perm α) [DecidableRel f.SameCycle] (x : α) :
∀ n : ℕ, (cycleOf f x ^ n) x = (f ^ n) x := by
intro n
induction n with
| zero => rfl
| succ n hn =>
rw [pow_succ', mul_apply, cycleOf_apply, hn, if_pos, pow_succ', mul_apply]
exact ⟨n, rfl⟩
@[simp]
theorem cycleOf_zpow_apply_self (f : Perm α) [DecidableRel f.SameCycle] (x : α) :
∀ n : ℤ, (cycleOf f x ^ n) x = (f ^ n) x := by
intro z
cases z with
| ofNat z => exact cycleOf_pow_apply_self f x z
| negSucc z =>
rw [zpow_negSucc, ← inv_pow, cycleOf_inv, zpow_negSucc, ← inv_pow, cycleOf_pow_apply_self]
theorem SameCycle.cycleOf_apply [DecidableRel f.SameCycle] :
SameCycle f x y → cycleOf f x y = f y :=
ofSubtype_apply_of_mem _
theorem cycleOf_apply_of_not_sameCycle [DecidableRel f.SameCycle] :
¬SameCycle f x y → cycleOf f x y = y :=
ofSubtype_apply_of_not_mem _
theorem SameCycle.cycleOf_eq [DecidableRel f.SameCycle] (h : SameCycle f x y) :
cycleOf f x = cycleOf f y := by
ext z
rw [Equiv.Perm.cycleOf_apply]
split_ifs with hz
· exact (h.symm.trans hz).cycleOf_apply.symm
· exact (cycleOf_apply_of_not_sameCycle (mt h.trans hz)).symm
@[simp]
theorem cycleOf_apply_apply_zpow_self (f : Perm α) [DecidableRel f.SameCycle] (x : α) (k : ℤ) :
cycleOf f x ((f ^ k) x) = (f ^ (k + 1) : Perm α) x := by
rw [SameCycle.cycleOf_apply]
· rw [add_comm, zpow_add, zpow_one, mul_apply]
· exact ⟨k, rfl⟩
@[simp]
theorem cycleOf_apply_apply_pow_self (f : Perm α) [DecidableRel f.SameCycle] (x : α) (k : ℕ) :
cycleOf f x ((f ^ k) x) = (f ^ (k + 1) : Perm α) x := by
convert cycleOf_apply_apply_zpow_self f x k using 1
@[simp]
theorem cycleOf_apply_apply_self (f : Perm α) [DecidableRel f.SameCycle] (x : α) :
cycleOf f x (f x) = f (f x) := by
convert cycleOf_apply_apply_pow_self f x 1 using 1
@[simp]
theorem cycleOf_apply_self (f : Perm α) [DecidableRel f.SameCycle] (x : α) : cycleOf f x x = f x :=
SameCycle.rfl.cycleOf_apply
theorem IsCycle.cycleOf_eq [DecidableRel f.SameCycle]
(hf : IsCycle f) (hx : f x ≠ x) : cycleOf f x = f :=
Equiv.ext fun y =>
if h : SameCycle f x y then by rw [h.cycleOf_apply]
else by
rw [cycleOf_apply_of_not_sameCycle h,
Classical.not_not.1 (mt ((isCycle_iff_sameCycle hx).1 hf).2 h)]
@[simp]
theorem cycleOf_eq_one_iff (f : Perm α) [DecidableRel f.SameCycle] : cycleOf f x = 1 ↔ f x = x := by
simp_rw [Perm.ext_iff, cycleOf_apply, one_apply]
refine ⟨fun h => (if_pos (SameCycle.refl f x)).symm.trans (h x), fun h y => ?_⟩
by_cases hy : f y = y
· rw [hy, ite_self]
· exact if_neg (mt SameCycle.apply_eq_self_iff (by tauto))
@[simp]
theorem cycleOf_self_apply (f : Perm α) [DecidableRel f.SameCycle] (x : α) :
cycleOf f (f x) = cycleOf f x :=
(sameCycle_apply_right.2 SameCycle.rfl).symm.cycleOf_eq
@[simp]
theorem cycleOf_self_apply_pow (f : Perm α) [DecidableRel f.SameCycle] (n : ℕ) (x : α) :
cycleOf f ((f ^ n) x) = cycleOf f x :=
SameCycle.rfl.pow_left.cycleOf_eq
@[simp]
theorem cycleOf_self_apply_zpow (f : Perm α) [DecidableRel f.SameCycle] (n : ℤ) (x : α) :
cycleOf f ((f ^ n) x) = cycleOf f x :=
SameCycle.rfl.zpow_left.cycleOf_eq
protected theorem IsCycle.cycleOf [DecidableRel f.SameCycle] [DecidableEq α]
(hf : IsCycle f) : cycleOf f x = if f x = x then 1 else f := by
by_cases hx : f x = x
· rwa [if_pos hx, cycleOf_eq_one_iff]
· rwa [if_neg hx, hf.cycleOf_eq]
theorem cycleOf_one [DecidableRel (1 : Perm α).SameCycle] (x : α) :
cycleOf 1 x = 1 := (cycleOf_eq_one_iff 1).mpr rfl
theorem isCycle_cycleOf (f : Perm α) [DecidableRel f.SameCycle] (hx : f x ≠ x) :
IsCycle (cycleOf f x) :=
have : cycleOf f x x ≠ x := by rwa [SameCycle.rfl.cycleOf_apply]
(isCycle_iff_sameCycle this).2 @fun y =>
⟨fun h => mt h.apply_eq_self_iff.2 this, fun h =>
if hxy : SameCycle f x y then
let ⟨i, hi⟩ := hxy
⟨i, by rw [cycleOf_zpow_apply_self, hi]⟩
else by
rw [cycleOf_apply_of_not_sameCycle hxy] at h
exact (h rfl).elim⟩
theorem pow_mod_orderOf_cycleOf_apply (f : Perm α) [DecidableRel f.SameCycle] (n : ℕ) (x : α) :
(f ^ (n % orderOf (cycleOf f x))) x = (f ^ n) x := by
rw [← cycleOf_pow_apply_self f, ← cycleOf_pow_apply_self f, pow_mod_orderOf]
theorem cycleOf_mul_of_apply_right_eq_self [DecidableRel f.SameCycle]
[DecidableRel (f * g).SameCycle]
(h : Commute f g) (x : α) (hx : g x = x) : (f * g).cycleOf x = f.cycleOf x := by
ext y
by_cases hxy : (f * g).SameCycle x y
· obtain ⟨z, rfl⟩ := hxy
rw [cycleOf_apply_apply_zpow_self]
simp [h.mul_zpow, zpow_apply_eq_self_of_apply_eq_self hx]
· rw [cycleOf_apply_of_not_sameCycle hxy, cycleOf_apply_of_not_sameCycle]
contrapose! hxy
obtain ⟨z, rfl⟩ := hxy
refine ⟨z, ?_⟩
simp [h.mul_zpow, zpow_apply_eq_self_of_apply_eq_self hx]
theorem Disjoint.cycleOf_mul_distrib [DecidableRel f.SameCycle] [DecidableRel g.SameCycle]
[DecidableRel (f * g).SameCycle] [DecidableRel (g * f).SameCycle] (h : f.Disjoint g) (x : α) :
(f * g).cycleOf x = f.cycleOf x * g.cycleOf x := by
rcases (disjoint_iff_eq_or_eq.mp h) x with hfx | hgx
· simp [h.commute.eq, cycleOf_mul_of_apply_right_eq_self h.symm.commute, hfx]
· simp [cycleOf_mul_of_apply_right_eq_self h.commute, hgx]
private theorem mem_support_cycleOf_iff_aux [DecidableRel f.SameCycle] [DecidableEq α] [Fintype α] :
y ∈ support (f.cycleOf x) ↔ SameCycle f x y ∧ x ∈ support f := by
by_cases hx : f x = x
· rw [(cycleOf_eq_one_iff _).mpr hx]
simp [hx]
· rw [mem_support, cycleOf_apply]
split_ifs with hy
· simp only [hx, hy, Ne, not_false_iff, and_self_iff, mem_support]
rcases hy with ⟨k, rfl⟩
rw [← notMem_support]
simpa using hx
· simpa [hx] using hy
private theorem mem_support_cycleOf_iff'_aux (hx : f x ≠ x)
[DecidableRel f.SameCycle] [DecidableEq α] [Fintype α] :
y ∈ support (f.cycleOf x) ↔ SameCycle f x y := by
rw [mem_support_cycleOf_iff_aux, and_iff_left (mem_support.2 hx)]
/-- `x` is in the support of `f` iff `Equiv.Perm.cycle_of f x` is a cycle. -/
theorem isCycle_cycleOf_iff (f : Perm α) [DecidableRel f.SameCycle] :
IsCycle (cycleOf f x) ↔ f x ≠ x := by
refine ⟨fun hx => ?_, f.isCycle_cycleOf⟩
rw [Ne, ← cycleOf_eq_one_iff f]
exact hx.ne_one
private theorem isCycleOn_support_cycleOf_aux [DecidableEq α] [Fintype α] (f : Perm α)
[DecidableRel f.SameCycle] (x : α) : f.IsCycleOn (f.cycleOf x).support :=
⟨f.bijOn <| by
refine fun _ ↦
⟨fun h ↦ mem_support_cycleOf_iff_aux.2 ?_, fun h ↦ mem_support_cycleOf_iff_aux.2 ?_⟩
· exact ⟨sameCycle_apply_right.1 (mem_support_cycleOf_iff_aux.1 h).1,
(mem_support_cycleOf_iff_aux.1 h).2⟩
· exact ⟨sameCycle_apply_right.2 (mem_support_cycleOf_iff_aux.1 h).1,
(mem_support_cycleOf_iff_aux.1 h).2⟩,
fun a ha b hb ↦ by
rw [mem_coe, mem_support_cycleOf_iff_aux] at ha hb
exact ha.1.symm.trans hb.1⟩
private theorem SameCycle.exists_pow_eq_of_mem_support_aux {f} [DecidableEq α] [Fintype α]
[DecidableRel f.SameCycle] (h : SameCycle f x y) (hx : x ∈ f.support) :
∃ i < #(f.cycleOf x).support, (f ^ i) x = y := by
rw [mem_support] at hx
exact Equiv.Perm.IsCycleOn.exists_pow_eq (b := y) (f.isCycleOn_support_cycleOf_aux x)
(by rw [mem_support_cycleOf_iff'_aux hx]) (by rwa [mem_support_cycleOf_iff'_aux hx])
instance instDecidableRelSameCycle [DecidableEq α] [Fintype α] (f : Perm α) :
DecidableRel (SameCycle f) := fun x y =>
decidable_of_iff (y ∈ List.iterate f x (Fintype.card α)) <| by
simp only [List.mem_iterate, iterate_eq_pow, eq_comm (a := y)]
constructor
· rintro ⟨n, _, hn⟩
exact ⟨n, hn⟩
· intro hxy
by_cases hx : x ∈ f.support
case pos =>
-- we can't invoke the aux lemmas above without obtaining the decidable instance we are
-- already building; but now we've left the data, so we can do this non-constructively
-- without sacrificing computability.
let _inst (f : Perm α) : DecidableRel (SameCycle f) := Classical.decRel _
rcases hxy.exists_pow_eq_of_mem_support_aux hx with ⟨i, hixy, hi⟩
refine ⟨i, lt_of_lt_of_le hixy (card_le_univ _), hi⟩
case neg =>
haveI : Nonempty α := ⟨x⟩
rw [notMem_support] at hx
exact ⟨0, Fintype.card_pos, hxy.eq_of_left hx⟩
@[simp]
theorem two_le_card_support_cycleOf_iff [DecidableEq α] [Fintype α] :
2 ≤ #(cycleOf f x).support ↔ f x ≠ x := by
refine ⟨fun h => ?_, fun h => by simpa using (isCycle_cycleOf _ h).two_le_card_support⟩
contrapose! h
rw [← cycleOf_eq_one_iff] at h
simp [h]
@[simp] lemma support_cycleOf_nonempty [DecidableEq α] [Fintype α] :
(cycleOf f x).support.Nonempty ↔ f x ≠ x := by
rw [← two_le_card_support_cycleOf_iff, ← card_pos, ← Nat.succ_le_iff]
exact ⟨fun h => Or.resolve_left h.eq_or_lt (card_support_ne_one _).symm, zero_lt_two.trans_le⟩
theorem mem_support_cycleOf_iff [DecidableEq α] [Fintype α] :
y ∈ support (f.cycleOf x) ↔ SameCycle f x y ∧ x ∈ support f :=
mem_support_cycleOf_iff_aux
theorem mem_support_cycleOf_iff' (hx : f x ≠ x) [DecidableEq α] [Fintype α] :
y ∈ support (f.cycleOf x) ↔ SameCycle f x y :=
mem_support_cycleOf_iff'_aux hx
theorem sameCycle_iff_cycleOf_eq_of_mem_support [DecidableEq α] [Fintype α]
{g : Perm α} {x y : α} (hx : x ∈ g.support) (hy : y ∈ g.support) :
g.SameCycle x y ↔ g.cycleOf x = g.cycleOf y := by
refine ⟨SameCycle.cycleOf_eq, fun h ↦ ?_⟩
rw [← mem_support_cycleOf_iff' (mem_support.mp hx), h,
mem_support_cycleOf_iff' (mem_support.mp hy)]
theorem support_cycleOf_eq_nil_iff [DecidableEq α] [Fintype α] :
(f.cycleOf x).support = ∅ ↔ x ∉ f.support := by simp
theorem isCycleOn_support_cycleOf [DecidableEq α] [Fintype α] (f : Perm α) (x : α) :
f.IsCycleOn (f.cycleOf x).support :=
isCycleOn_support_cycleOf_aux f x
theorem SameCycle.exists_pow_eq_of_mem_support {f} [DecidableEq α] [Fintype α] (h : SameCycle f x y)
(hx : x ∈ f.support) : ∃ i < #(f.cycleOf x).support, (f ^ i) x = y :=
h.exists_pow_eq_of_mem_support_aux hx
theorem support_cycleOf_le [DecidableEq α] [Fintype α] (f : Perm α) (x : α) :
support (f.cycleOf x) ≤ support f := by
intro y hy
rw [mem_support, cycleOf_apply] at hy
split_ifs at hy
· exact mem_support.mpr hy
· exact absurd rfl hy
theorem SameCycle.mem_support_iff {f} [DecidableEq α] [Fintype α] (h : SameCycle f x y) :
x ∈ support f ↔ y ∈ support f :=
⟨fun hx => support_cycleOf_le f x (mem_support_cycleOf_iff.mpr ⟨h, hx⟩), fun hy =>
support_cycleOf_le f y (mem_support_cycleOf_iff.mpr ⟨h.symm, hy⟩)⟩
theorem pow_mod_card_support_cycleOf_self_apply [DecidableEq α] [Fintype α]
(f : Perm α) (n : ℕ) (x : α) : (f ^ (n % #(f.cycleOf x).support)) x = (f ^ n) x := by
by_cases hx : f x = x
· rw [pow_apply_eq_self_of_apply_eq_self hx, pow_apply_eq_self_of_apply_eq_self hx]
· rw [← cycleOf_pow_apply_self, ← cycleOf_pow_apply_self f, ← (isCycle_cycleOf f hx).orderOf,
pow_mod_orderOf]
theorem SameCycle.exists_pow_eq [DecidableEq α] [Fintype α] (f : Perm α) (h : SameCycle f x y) :
∃ i : ℕ, 0 < i ∧ i ≤ #(f.cycleOf x).support + 1 ∧ (f ^ i) x = y := by
by_cases hx : x ∈ f.support
· obtain ⟨k, hk, hk'⟩ := h.exists_pow_eq_of_mem_support hx
rcases k with - | k
· refine ⟨#(f.cycleOf x).support, hk, self_le_add_right _ _, ?_⟩
simp only [pow_zero, coe_one, id_eq] at hk'
subst hk'
rw [← (isCycle_cycleOf _ <| mem_support.1 hx).orderOf, ← cycleOf_pow_apply_self,
pow_orderOf_eq_one, one_apply]
· exact ⟨k + 1, by simp, Nat.le_succ_of_le hk.le, hk'⟩
· refine ⟨1, zero_lt_one, by simp, ?_⟩
obtain ⟨k, rfl⟩ := h
rw [notMem_support] at hx
rw [pow_apply_eq_self_of_apply_eq_self hx, zpow_apply_eq_self_of_apply_eq_self hx]
theorem zpow_eq_zpow_on_iff [DecidableEq α] [Fintype α]
(g : Perm α) {m n : ℤ} {x : α} (hx : g x ≠ x) :
(g ^ m) x = (g ^ n) x ↔ m % #(g.cycleOf x).support = n % #(g.cycleOf x).support := by
rw [Int.emod_eq_emod_iff_emod_sub_eq_zero]
conv_lhs => rw [← Int.sub_add_cancel m n, Int.add_comm, zpow_add]
simp only [coe_mul, Function.comp_apply, EmbeddingLike.apply_eq_iff_eq]
rw [← Int.dvd_iff_emod_eq_zero]
rw [← cycleOf_zpow_apply_self g x, cycle_zpow_mem_support_iff]
· rw [← Int.dvd_iff_emod_eq_zero]
· exact isCycle_cycleOf g hx
· simp only [cycleOf_apply_self]; exact hx
end CycleOf
/-!
### `cycleFactors`
-/
section cycleFactors
open scoped List in
/-- Given a list `l : List α` and a permutation `f : Perm α` whose nonfixed points are all in `l`,
recursively factors `f` into cycles. -/
def cycleFactorsAux [DecidableEq α] [Fintype α]
(l : List α) (f : Perm α) (h : ∀ {x}, f x ≠ x → x ∈ l) :
{ pl : List (Perm α) // pl.prod = f ∧ (∀ g ∈ pl, IsCycle g) ∧ pl.Pairwise Disjoint } :=
go l f h (fun _ => rfl)
where
/-- The auxiliary of `cycleFactorsAux`. This functions separates cycles from `f` instead of `g`
to prevent the process of a cycle gets complex. -/
go (l : List α) (g : Perm α) (hg : ∀ {x}, g x ≠ x → x ∈ l)
(hfg : ∀ {x}, g x ≠ x → cycleOf f x = cycleOf g x) :
{ pl : List (Perm α) // pl.prod = g ∧ (∀ g' ∈ pl, IsCycle g') ∧ pl.Pairwise Disjoint } :=
match l with
| [] => ⟨[], by
{ simp only [imp_false, List.Pairwise.nil, List.not_mem_nil, forall_const, and_true,
forall_prop_of_false, Classical.not_not, not_false_iff, List.prod_nil] at *
ext
simp [*]}⟩
| x :: l =>
if hx : g x = x then go l g (by
intro y hy; exact List.mem_of_ne_of_mem (fun h => hy (by rwa [h])) (hg hy)) hfg
else
let ⟨m, hm⟩ :=
go l ((cycleOf f x)⁻¹ * g) (by
rw [hfg hx]
intro y hy
exact List.mem_of_ne_of_mem
(fun h : y = x => by
rw [h, mul_apply, Ne, inv_eq_iff_eq, cycleOf_apply_self] at hy
exact hy rfl)
(hg fun h : g y = y => by
rw [mul_apply, h, Ne, inv_eq_iff_eq, cycleOf_apply] at hy
split_ifs at hy <;> tauto))
(by
rw [hfg hx]
intro y hy
simp [inv_eq_iff_eq, cycleOf_apply, eq_comm (a := g y)] at hy
rw [hfg (Ne.symm hy.right), ← mul_inv_eq_one (a := g.cycleOf y), cycleOf_inv]
simp_rw [mul_inv_rev]
rw [inv_inv, cycleOf_mul_of_apply_right_eq_self, ← cycleOf_inv, mul_inv_eq_one]
· rw [Commute.inv_left_iff, commute_iff_eq]
ext z; by_cases hz : SameCycle g x z
· simp [cycleOf_apply, hz]
· simp [cycleOf_apply_of_not_sameCycle, hz]
· exact cycleOf_apply_of_not_sameCycle hy.left)
⟨cycleOf f x :: m, by
obtain ⟨hm₁, hm₂, hm₃⟩ := hm
rw [hfg hx] at hm₁ ⊢
rw [List.pairwise_cons]
refine ⟨?_, fun g' hg' ↦ ?_, fun g' hg' y ↦ ?_, hm₃⟩
· simp [List.prod_cons, hm₁]
· exact ((List.mem_cons).1 hg').elim (fun hg' => hg'.symm ▸ isCycle_cycleOf _ hx) (hm₂ g')
by_contra!
obtain ⟨hgy, hg'y⟩ := this
have hxy : SameCycle g x y := not_imp_comm.1 cycleOf_apply_of_not_sameCycle hgy
have hg'm : g' :: m.erase g' ~ m := List.cons_perm_iff_perm_erase.2 ⟨hg', .refl _⟩
have : ∀ h ∈ m.erase g', Disjoint g' h :=
(List.pairwise_cons.1 ((hg'm.pairwise_iff Disjoint.symm).2 hm₃)).1
refine hg'y <| (disjoint_prod_right _ this y).resolve_right ?_
have hsc : SameCycle g⁻¹ x (g y) := by rwa [sameCycle_inv, sameCycle_apply_right]
rw [disjoint_prod_perm hm₃ hg'm.symm, List.prod_cons, ← eq_inv_mul_iff_mul_eq] at hm₁
simpa [hm₁, cycleOf_inv, hsc.cycleOf_apply, Perm.eq_inv_iff_eq, eq_comm] using hg'y⟩
theorem mem_list_cycles_iff {α : Type*} [Finite α] {l : List (Perm α)}
(h1 : ∀ σ : Perm α, σ ∈ l → σ.IsCycle) (h2 : l.Pairwise Disjoint) {σ : Perm α} :
σ ∈ l ↔ σ.IsCycle ∧ ∀ a, σ a ≠ a → σ a = l.prod a := by
suffices σ.IsCycle → (σ ∈ l ↔ ∀ a, σ a ≠ a → σ a = l.prod a) by
exact ⟨fun hσ => ⟨h1 σ hσ, (this (h1 σ hσ)).mp hσ⟩, fun hσ => (this hσ.1).mpr hσ.2⟩
intro h3
classical
cases nonempty_fintype α
constructor
· intro h a ha
exact eq_on_support_mem_disjoint h h2 _ (mem_support.mpr ha)
· intro h
have hσl : σ.support ⊆ l.prod.support := by
intro x hx
rw [mem_support] at hx
rwa [mem_support, ← h _ hx]
obtain ⟨a, ha, -⟩ := id h3
rw [← mem_support] at ha
obtain ⟨τ, hτ, hτa⟩ := exists_mem_support_of_mem_support_prod (hσl ha)
have hτl : ∀ x ∈ τ.support, τ x = l.prod x := eq_on_support_mem_disjoint hτ h2
have key : ∀ x ∈ σ.support ∩ τ.support, σ x = τ x := by
intro x hx
rw [h x (mem_support.mp (mem_of_mem_inter_left hx)), hτl x (mem_of_mem_inter_right hx)]
convert hτ
refine h3.eq_on_support_inter_nonempty_congr (h1 _ hτ) key ?_ ha
exact key a (mem_inter_of_mem ha hτa)
open scoped List in
theorem list_cycles_perm_list_cycles {α : Type*} [Finite α] {l₁ l₂ : List (Perm α)}
(h₀ : l₁.prod = l₂.prod) (h₁l₁ : ∀ σ : Perm α, σ ∈ l₁ → σ.IsCycle)
(h₁l₂ : ∀ σ : Perm α, σ ∈ l₂ → σ.IsCycle) (h₂l₁ : l₁.Pairwise Disjoint)
(h₂l₂ : l₂.Pairwise Disjoint) : l₁ ~ l₂ := by
classical
refine
(List.perm_ext_iff_of_nodup (nodup_of_pairwise_disjoint_cycles h₁l₁ h₂l₁)
(nodup_of_pairwise_disjoint_cycles h₁l₂ h₂l₂)).mpr
fun σ => ?_
by_cases hσ : σ.IsCycle
· obtain _ := not_forall.mp (mt ext hσ.ne_one)
rw [mem_list_cycles_iff h₁l₁ h₂l₁, mem_list_cycles_iff h₁l₂ h₂l₂, h₀]
· exact iff_of_false (mt (h₁l₁ σ) hσ) (mt (h₁l₂ σ) hσ)
/-- Factors a permutation `f` into a list of disjoint cyclic permutations that multiply to `f`. -/
def cycleFactors [Fintype α] [LinearOrder α] (f : Perm α) :
{ l : List (Perm α) // l.prod = f ∧ (∀ g ∈ l, IsCycle g) ∧ l.Pairwise Disjoint } :=
cycleFactorsAux (sort (α := α) univ) f (fun {_ _} ↦ (mem_sort _).2 (mem_univ _))
/-- Factors a permutation `f` into a list of disjoint cyclic permutations that multiply to `f`,
without a linear order. -/
def truncCycleFactors [DecidableEq α] [Fintype α] (f : Perm α) :
Trunc { l : List (Perm α) // l.prod = f ∧ (∀ g ∈ l, IsCycle g) ∧ l.Pairwise Disjoint } :=
Quotient.recOnSubsingleton (@univ α _).1 (fun l h => Trunc.mk (cycleFactorsAux l f (h _)))
(show ∀ x, f x ≠ x → x ∈ (@univ α _).1 from fun _ _ => mem_univ _)
section CycleFactorsFinset
variable [DecidableEq α] [Fintype α] (f : Perm α)
/-- Factors a permutation `f` into a `Finset` of disjoint cyclic permutations that multiply to `f`.
-/
def cycleFactorsFinset : Finset (Perm α) :=
(truncCycleFactors f).lift
(fun l : { l : List (Perm α) // l.prod = f ∧ (∀ g ∈ l, IsCycle g) ∧ l.Pairwise Disjoint } =>
⟨↑l.val, nodup_of_pairwise_disjoint (fun h1 => not_isCycle_one <| l.2.2.1 _ h1) l.2.2.2⟩)
fun ⟨_, hl⟩ ⟨_, hl'⟩ =>
Finset.eq_of_veq <| Multiset.coe_eq_coe.mpr <|
list_cycles_perm_list_cycles (hl'.left.symm ▸ hl.left) hl.right.left hl'.right.left
hl.right.right hl'.right.right
open scoped List in
theorem cycleFactorsFinset_eq_list_toFinset {σ : Perm α} {l : List (Perm α)} (hn : l.Nodup) :
σ.cycleFactorsFinset = l.toFinset ↔
(∀ f : Perm α, f ∈ l → f.IsCycle) ∧ l.Pairwise Disjoint ∧ l.prod = σ := by
obtain ⟨⟨l', hp', hc', hd'⟩, hl⟩ := Trunc.exists_rep σ.truncCycleFactors
have ht : cycleFactorsFinset σ = l'.toFinset := by
rw [cycleFactorsFinset, ← hl, Trunc.lift_mk, Multiset.toFinset_eq, List.toFinset_coe]
rw [ht]
constructor
· intro h
have hn' : l'.Nodup := nodup_of_pairwise_disjoint_cycles hc' hd'
have hperm : l ~ l' := List.perm_of_nodup_nodup_toFinset_eq hn hn' h.symm
refine ⟨?_, ?_, ?_⟩
· exact fun _ h => hc' _ (hperm.subset h)
· have := List.Perm.pairwise_iff (@Disjoint.symmetric _) hperm
rwa [this]
· rw [← hp', hperm.symm.prod_eq']
refine hd'.imp ?_
exact Disjoint.commute
· rintro ⟨hc, hd, hp⟩
refine List.toFinset_eq_of_perm _ _ ?_
refine list_cycles_perm_list_cycles ?_ hc' hc hd' hd
rw [hp, hp']
theorem cycleFactorsFinset_eq_finset {σ : Perm α} {s : Finset (Perm α)} :
σ.cycleFactorsFinset = s ↔
(∀ f : Perm α, f ∈ s → f.IsCycle) ∧
∃ h : (s : Set (Perm α)).Pairwise Disjoint,
s.noncommProd id (h.mono' fun _ _ => Disjoint.commute) = σ := by
obtain ⟨l, hl, rfl⟩ := s.exists_list_nodup_eq
simp [cycleFactorsFinset_eq_list_toFinset, hl]
theorem cycleFactorsFinset_pairwise_disjoint :
(cycleFactorsFinset f : Set (Perm α)).Pairwise Disjoint :=
(cycleFactorsFinset_eq_finset.mp rfl).2.choose
/-- Two cycles of a permutation commute. -/
theorem cycleFactorsFinset_mem_commute : (cycleFactorsFinset f : Set (Perm α)).Pairwise Commute :=
(cycleFactorsFinset_pairwise_disjoint _).mono' fun _ _ => Disjoint.commute
/-- Two cycles of a permutation commute. -/
theorem cycleFactorsFinset_mem_commute' {g1 g2 : Perm α}
(h1 : g1 ∈ f.cycleFactorsFinset) (h2 : g2 ∈ f.cycleFactorsFinset) :
Commute g1 g2 := by
rcases eq_or_ne g1 g2 with rfl | h
· apply Commute.refl
· exact Equiv.Perm.cycleFactorsFinset_mem_commute f h1 h2 h
/-- The product of cycle factors is equal to the original `f : perm α`. -/
theorem cycleFactorsFinset_noncommProd
(comm : (cycleFactorsFinset f : Set (Perm α)).Pairwise Commute :=
cycleFactorsFinset_mem_commute f) :
f.cycleFactorsFinset.noncommProd id comm = f :=
(cycleFactorsFinset_eq_finset.mp rfl).2.choose_spec
theorem mem_cycleFactorsFinset_iff {f p : Perm α} :
p ∈ cycleFactorsFinset f ↔ p.IsCycle ∧ ∀ a ∈ p.support, p a = f a := by
obtain ⟨l, hl, hl'⟩ := f.cycleFactorsFinset.exists_list_nodup_eq
rw [← hl']
rw [eq_comm, cycleFactorsFinset_eq_list_toFinset hl] at hl'
simpa [List.mem_toFinset, Ne, ← hl'.right.right] using
mem_list_cycles_iff hl'.left hl'.right.left
theorem cycleOf_mem_cycleFactorsFinset_iff {f : Perm α} {x : α} :
cycleOf f x ∈ cycleFactorsFinset f ↔ x ∈ f.support := by
rw [mem_cycleFactorsFinset_iff]
constructor
· rintro ⟨hc, _⟩
contrapose! hc
rw [notMem_support, ← cycleOf_eq_one_iff] at hc
simp [hc]
· intro hx
refine ⟨isCycle_cycleOf _ (mem_support.mp hx), ?_⟩
intro y hy
rw [mem_support] at hy
rw [cycleOf_apply]
split_ifs with H
· rfl
· rw [cycleOf_apply_of_not_sameCycle H] at hy
contradiction
lemma cycleOf_ne_one_iff_mem_cycleFactorsFinset {g : Equiv.Perm α} {x : α} :
g.cycleOf x ≠ 1 ↔ g.cycleOf x ∈ g.cycleFactorsFinset := by
rw [cycleOf_mem_cycleFactorsFinset_iff, mem_support, ne_eq, cycleOf_eq_one_iff]
theorem mem_cycleFactorsFinset_support_le {p f : Perm α} (h : p ∈ cycleFactorsFinset f) :
p.support ≤ f.support := by
rw [mem_cycleFactorsFinset_iff] at h
intro x hx
rwa [mem_support, ← h.right x hx, ← mem_support]
lemma support_zpowers_of_mem_cycleFactorsFinset_le {g : Perm α}
{c : g.cycleFactorsFinset} (v : Subgroup.zpowers (c : Perm α)) :
(v : Perm α).support ≤ g.support := by
obtain ⟨m, hm⟩ := v.prop
simp only [← hm]
exact le_trans (support_zpow_le _ _) (mem_cycleFactorsFinset_support_le c.prop)
theorem pairwise_disjoint_of_mem_zpowers :
Pairwise fun (i j : f.cycleFactorsFinset) ↦
∀ (x y : Perm α), x ∈ Subgroup.zpowers ↑i → y ∈ Subgroup.zpowers ↑j → Disjoint x y :=
fun c d hcd ↦ fun x y hx hy ↦ by
obtain ⟨m, hm⟩ := hx; obtain ⟨n, hn⟩ := hy
simp only [← hm, ← hn]
apply Disjoint.zpow_disjoint_zpow
exact f.cycleFactorsFinset_pairwise_disjoint c.prop d.prop (Subtype.coe_ne_coe.mpr hcd)
lemma pairwise_commute_of_mem_zpowers :
Pairwise fun (i j : f.cycleFactorsFinset) ↦
∀ (x y : Perm α), x ∈ Subgroup.zpowers ↑i → y ∈ Subgroup.zpowers ↑j → Commute x y :=
f.pairwise_disjoint_of_mem_zpowers.mono
(fun _ _ ↦ forall₂_imp (fun _ _ h hx hy ↦ (h hx hy).commute))
lemma disjoint_ofSubtype_noncommPiCoprod (u : Perm (Function.fixedPoints f))
(v : (c : { x // x ∈ f.cycleFactorsFinset }) → (Subgroup.zpowers (c : Perm α))) :
Disjoint (ofSubtype u) ((Subgroup.noncommPiCoprod f.pairwise_commute_of_mem_zpowers) v) := by
apply Finset.noncommProd_induction
· intro a _ b _ h
apply f.pairwise_commute_of_mem_zpowers h <;> simp only [Subgroup.coe_subtype, SetLike.coe_mem]
· intro x y
exact Disjoint.mul_right
· exact disjoint_one_right _
· intro c _
simp only [Subgroup.coe_subtype]
exact Disjoint.mono (disjoint_ofSubtype_of_memFixedPoints_self u)
le_rfl (support_zpowers_of_mem_cycleFactorsFinset_le (v c))
lemma commute_ofSubtype_noncommPiCoprod (u : Perm (Function.fixedPoints f))
(v : (c : { x // x ∈ f.cycleFactorsFinset }) → (Subgroup.zpowers (c : Perm α))) :
Commute (ofSubtype u) ((Subgroup.noncommPiCoprod f.pairwise_commute_of_mem_zpowers) v) :=
Disjoint.commute (f.disjoint_ofSubtype_noncommPiCoprod u v)
theorem mem_support_iff_mem_support_of_mem_cycleFactorsFinset {g : Equiv.Perm α} {x : α} :
x ∈ g.support ↔ ∃ c ∈ g.cycleFactorsFinset, x ∈ c.support := by
constructor
· intro h
use g.cycleOf x, cycleOf_mem_cycleFactorsFinset_iff.mpr h
rw [mem_support_cycleOf_iff]
exact ⟨SameCycle.refl g x, h⟩
· rintro ⟨c, hc, hx⟩
exact mem_cycleFactorsFinset_support_le hc hx
theorem cycleFactorsFinset_eq_empty_iff {f : Perm α} : cycleFactorsFinset f = ∅ ↔ f = 1 := by
simpa [cycleFactorsFinset_eq_finset] using eq_comm
@[simp]
theorem cycleFactorsFinset_one : cycleFactorsFinset (1 : Perm α) = ∅ := by
simp [cycleFactorsFinset_eq_empty_iff]
@[simp]
theorem cycleFactorsFinset_eq_singleton_self_iff {f : Perm α} :
f.cycleFactorsFinset = {f} ↔ f.IsCycle := by simp [cycleFactorsFinset_eq_finset]
theorem IsCycle.cycleFactorsFinset_eq_singleton {f : Perm α} (hf : IsCycle f) :
f.cycleFactorsFinset = {f} :=
cycleFactorsFinset_eq_singleton_self_iff.mpr hf
theorem cycleFactorsFinset_eq_singleton_iff {f g : Perm α} :
f.cycleFactorsFinset = {g} ↔ f.IsCycle ∧ f = g := by
suffices f = g → (g.IsCycle ↔ f.IsCycle) by
rw [cycleFactorsFinset_eq_finset]
simpa [eq_comm]
rintro rfl
exact Iff.rfl
/-- Two permutations `f g : Perm α` have the same cycle factors iff they are the same. -/
theorem cycleFactorsFinset_injective : Function.Injective (@cycleFactorsFinset α _ _) := by
intro f g h
rw [← cycleFactorsFinset_noncommProd f]
simpa [h] using cycleFactorsFinset_noncommProd g
theorem Disjoint.disjoint_cycleFactorsFinset {f g : Perm α} (h : Disjoint f g) :
_root_.Disjoint (cycleFactorsFinset f) (cycleFactorsFinset g) := by
rw [disjoint_iff_disjoint_support] at h
rw [Finset.disjoint_left]
intro x hx hy
simp only [mem_cycleFactorsFinset_iff, mem_support] at hx hy
obtain ⟨⟨⟨a, ha, -⟩, hf⟩, -, hg⟩ := hx, hy
have := h.le_bot (by simp [ha, ← hf a ha, ← hg a ha] : a ∈ f.support ∩ g.support)
tauto
theorem Disjoint.cycleFactorsFinset_mul_eq_union {f g : Perm α} (h : Disjoint f g) :
cycleFactorsFinset (f * g) = cycleFactorsFinset f ∪ cycleFactorsFinset g := by
rw [cycleFactorsFinset_eq_finset]
refine ⟨?_, ?_, ?_⟩
· simp [or_imp, mem_cycleFactorsFinset_iff, forall_swap]
· rw [coe_union, Set.pairwise_union_of_symmetric Disjoint.symmetric]
exact
⟨cycleFactorsFinset_pairwise_disjoint _, cycleFactorsFinset_pairwise_disjoint _,
fun x hx y hy _ =>
h.mono (mem_cycleFactorsFinset_support_le hx) (mem_cycleFactorsFinset_support_le hy)⟩
· rw [noncommProd_union_of_disjoint h.disjoint_cycleFactorsFinset]
rw [cycleFactorsFinset_noncommProd, cycleFactorsFinset_noncommProd]
theorem disjoint_mul_inv_of_mem_cycleFactorsFinset {f g : Perm α} (h : f ∈ cycleFactorsFinset g) :
Disjoint (g * f⁻¹) f := by
rw [mem_cycleFactorsFinset_iff] at h
intro x
by_cases hx : f x = x
· exact Or.inr hx
rw [mul_apply, ← h.right _ (by simpa [Perm.eq_inv_iff_eq])]
simp
/-- If c is a cycle, a ∈ c.support and c is a cycle of f, then `c = f.cycleOf a` -/
theorem cycle_is_cycleOf {f c : Equiv.Perm α} {a : α} (ha : a ∈ c.support)
(hc : c ∈ f.cycleFactorsFinset) : c = f.cycleOf a := by
suffices f.cycleOf a = c.cycleOf a by
rw [this]
apply symm
exact
Equiv.Perm.IsCycle.cycleOf_eq (Equiv.Perm.mem_cycleFactorsFinset_iff.mp hc).left
(Equiv.Perm.mem_support.mp ha)
let hfc := (Equiv.Perm.disjoint_mul_inv_of_mem_cycleFactorsFinset hc).symm
let hfc2 := Perm.Disjoint.commute hfc
rw [← Equiv.Perm.cycleOf_mul_of_apply_right_eq_self hfc2]
· simp only [hfc2.eq, inv_mul_cancel_right]
-- `a` is in the support of `c`, hence it is not in the support of `g c⁻¹`
exact
Equiv.Perm.notMem_support.mp
(Finset.disjoint_left.mp (Equiv.Perm.Disjoint.disjoint_support hfc) ha)
theorem isCycleOn_support_of_mem_cycleFactorsFinset {g c : Equiv.Perm α}
(hc : c ∈ g.cycleFactorsFinset) :
IsCycleOn g c.support := by
obtain ⟨x, hx⟩ := IsCycle.nonempty_support (mem_cycleFactorsFinset_iff.mp hc).1
rw [cycle_is_cycleOf hx hc]
exact isCycleOn_support_cycleOf g x
theorem eq_cycleOf_of_mem_cycleFactorsFinset_iff
(g c : Perm α) (hc : c ∈ g.cycleFactorsFinset) (x : α) :
c = g.cycleOf x ↔ x ∈ c.support := by
refine ⟨?_, (cycle_is_cycleOf · hc)⟩
rintro rfl
rw [mem_support, cycleOf_apply_self, ne_eq, ← cycleOf_eq_one_iff]
exact (mem_cycleFactorsFinset_iff.mp hc).left.ne_one
theorem zpow_apply_mem_support_of_mem_cycleFactorsFinset_iff {g : Perm α}
{x : α} {m : ℤ} {c : g.cycleFactorsFinset} :
(g ^ m) x ∈ (c : Perm α).support ↔ x ∈ (c : Perm α).support := by
rw [← g.eq_cycleOf_of_mem_cycleFactorsFinset_iff _ c.prop, cycleOf_self_apply_zpow,
eq_cycleOf_of_mem_cycleFactorsFinset_iff _ _ c.prop]
/-- A permutation `c` is a cycle of `g` iff `k * c * k⁻¹` is a cycle of `k * g * k⁻¹` -/
theorem mem_cycleFactorsFinset_conj (g k c : Perm α) :
k * c * k⁻¹ ∈ (k * g * k⁻¹).cycleFactorsFinset ↔ c ∈ g.cycleFactorsFinset := by
suffices imp_lemma : ∀ {g k c : Perm α},
c ∈ g.cycleFactorsFinset → k * c * k⁻¹ ∈ (k * g * k⁻¹).cycleFactorsFinset by
refine ⟨fun h ↦ ?_, imp_lemma⟩
have aux : ∀ h : Perm α, h = k⁻¹ * (k * h * k⁻¹) * k := fun _ ↦ by group
rw [aux g, aux c]
exact imp_lemma h
intro g k c
simp only [mem_cycleFactorsFinset_iff]
apply And.imp IsCycle.conj
intro hc a ha
simp only [coe_mul, Function.comp_apply, EmbeddingLike.apply_eq_iff_eq]
apply hc
simpa [inv_def, eq_symm_apply] using ha
/-- If a permutation commutes with every cycle of `g`, then it commutes with `g`
NB. The converse is false. Commuting with every cycle of `g` means that we belong
to the kernel of the action of `Equiv.Perm α` on `g.cycleFactorsFinset` -/
theorem commute_of_mem_cycleFactorsFinset_commute (k g : Perm α)
(hk : ∀ c ∈ g.cycleFactorsFinset, Commute k c) :
Commute k g := by
rw [← cycleFactorsFinset_noncommProd g (cycleFactorsFinset_mem_commute g)]
apply Finset.noncommProd_commute
simpa only [id_eq] using hk
/-- The cycles of a permutation commute with it -/
theorem self_mem_cycle_factors_commute {g c : Perm α}
(hc : c ∈ g.cycleFactorsFinset) : Commute c g := by
apply commute_of_mem_cycleFactorsFinset_commute
intro c' hc'
by_cases hcc' : c = c'
· rw [hcc']
· apply g.cycleFactorsFinset_mem_commute hc hc'; exact hcc'
/-- If `c` and `d` are cycles of `g`, then `d` stabilizes the support of `c` -/
theorem mem_support_cycle_of_cycle {g d c : Perm α}
(hc : c ∈ g.cycleFactorsFinset) (hd : d ∈ g.cycleFactorsFinset) :
∀ x : α, d x ∈ c.support ↔ x ∈ c.support := by
intro x
simp only [mem_support, not_iff_not]
by_cases h : c = d
· rw [← h, EmbeddingLike.apply_eq_iff_eq]
· rw [← Perm.mul_apply,
Commute.eq (cycleFactorsFinset_mem_commute g hc hd h),
mul_apply, EmbeddingLike.apply_eq_iff_eq]
/-- If a permutation is a cycle of `g`, then its support is invariant under `g`. -/
theorem mem_cycleFactorsFinset_support {g c : Perm α} (hc : c ∈ g.cycleFactorsFinset) (a : α) :
g a ∈ c.support ↔ a ∈ c.support :=
mem_support_iff_of_commute (self_mem_cycle_factors_commute hc).symm a
end CycleFactorsFinset
@[elab_as_elim]
theorem cycle_induction_on [Finite β] (P : Perm β → Prop) (σ : Perm β) (base_one : P 1)
(base_cycles : ∀ σ : Perm β, σ.IsCycle → P σ)
(induction_disjoint : ∀ σ τ : Perm β,
Disjoint σ τ → IsCycle σ → P σ → P τ → P (σ * τ)) : P σ := by
cases nonempty_fintype β
suffices ∀ l : List (Perm β),
(∀ τ : Perm β, τ ∈ l → τ.IsCycle) → l.Pairwise Disjoint → P l.prod by
classical
let x := σ.truncCycleFactors.out
exact (congr_arg P x.2.1).mp (this x.1 x.2.2.1 x.2.2.2)
intro l
induction l with
| nil => exact fun _ _ => base_one
| cons σ l ih =>
intro h1 h2
rw [List.prod_cons]
exact
induction_disjoint σ l.prod (disjoint_prod_right _ (List.pairwise_cons.mp h2).1)
(h1 _ List.mem_cons_self) (base_cycles σ (h1 σ List.mem_cons_self))
(ih (fun τ hτ => h1 τ (List.mem_cons_of_mem σ hτ)) h2.of_cons)
theorem cycleFactorsFinset_mul_inv_mem_eq_sdiff [DecidableEq α] [Fintype α] {f g : Perm α}
(h : f ∈ cycleFactorsFinset g) : cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f} := by
revert f
refine
cycle_induction_on (P := fun {g : Perm α} ↦
∀ {f}, (f ∈ cycleFactorsFinset g)
→ cycleFactorsFinset (g * f⁻¹) = cycleFactorsFinset g \ {f}) _ ?_ ?_ ?_
· simp
· intro σ hσ f hf
simp only [cycleFactorsFinset_eq_singleton_self_iff.mpr hσ, mem_singleton] at hf ⊢
simp [hf]
· intro σ τ hd _ hσ hτ f
simp_rw [hd.cycleFactorsFinset_mul_eq_union, mem_union]
-- if only `wlog` could work here...
rintro (hf | hf)
· rw [hd.commute.eq, union_comm, union_sdiff_distrib, sdiff_singleton_eq_erase,
erase_eq_of_notMem, mul_assoc, Disjoint.cycleFactorsFinset_mul_eq_union, hσ hf]
· rw [mem_cycleFactorsFinset_iff] at hf
intro x
rcases hd.symm x with hx | hx
· exact Or.inl hx
· refine Or.inr ?_
by_cases hfx : f x = x
· rw [← hfx]
simpa [hx] using hfx.symm
· rw [mul_apply]
rw [← hf.right _ (mem_support.mpr hfx)] at hx
contradiction
· exact fun H =>
notMem_empty _ (hd.disjoint_cycleFactorsFinset.le_bot (mem_inter_of_mem hf H))
· rw [union_sdiff_distrib, sdiff_singleton_eq_erase, erase_eq_of_notMem, mul_assoc,
Disjoint.cycleFactorsFinset_mul_eq_union, hτ hf]
· rw [mem_cycleFactorsFinset_iff] at hf
intro x
rcases hd x with hx | hx
· exact Or.inl hx
· refine Or.inr ?_
by_cases hfx : f x = x
· rw [← hfx]
simpa [hx] using hfx.symm
· rw [mul_apply]
rw [← hf.right _ (mem_support.mpr hfx)] at hx
contradiction
· exact fun H =>
notMem_empty _ (hd.disjoint_cycleFactorsFinset.le_bot (mem_inter_of_mem H hf))
theorem IsCycle.forall_commute_iff [DecidableEq α] [Fintype α] (g z : Perm α) :
(∀ c ∈ g.cycleFactorsFinset, Commute z c) ↔
∀ c ∈ g.cycleFactorsFinset,
∃ (hc : ∀ x : α, z x ∈ c.support ↔ x ∈ c.support),
ofSubtype (subtypePerm z hc) ∈ Subgroup.zpowers c := by
apply forall_congr'
intro c
apply imp_congr_right
intro hc
exact IsCycle.commute_iff (mem_cycleFactorsFinset_iff.mp hc).1
/-- A permutation restricted to the support of a cycle factor is that cycle factor -/
theorem subtypePerm_on_cycleFactorsFinset [DecidableEq α] [Fintype α]
{g c : Perm α} (hc : c ∈ g.cycleFactorsFinset) :
g.subtypePerm (mem_cycleFactorsFinset_support hc) = c.subtypePermOfSupport := by
ext ⟨x, hx⟩
simp only [subtypePerm_apply, Subtype.coe_mk, subtypePermOfSupport]
exact ((mem_cycleFactorsFinset_iff.mp hc).2 x hx).symm
theorem commute_iff_of_mem_cycleFactorsFinset [DecidableEq α] [Fintype α] {g k c : Equiv.Perm α}
(hc : c ∈ g.cycleFactorsFinset) :
Commute k c ↔
∃ hc' : ∀ x : α, k x ∈ c.support ↔ x ∈ c.support,
k.subtypePerm hc' ∈ Subgroup.zpowers
(g.subtypePerm (mem_cycleFactorsFinset_support hc)) := by
rw [IsCycle.commute_iff' (mem_cycleFactorsFinset_iff.mp hc).1]
apply exists_congr
intro hc'
simp only [Subgroup.mem_zpowers_iff]
apply exists_congr
intro n
rw [Equiv.Perm.subtypePerm_on_cycleFactorsFinset hc]
end cycleFactors
end Perm
end Equiv |
.lake/packages/mathlib/Mathlib/GroupTheory/Perm/Cycle/Type.lean | import Mathlib.Algebra.GCDMonoid.Multiset
import Mathlib.Algebra.GCDMonoid.Nat
import Mathlib.Algebra.Group.TypeTags.Finite
import Mathlib.Combinatorics.Enumerative.Partition.Basic
import Mathlib.Data.List.Rotate
import Mathlib.GroupTheory.Perm.Closure
import Mathlib.GroupTheory.Perm.Cycle.Factors
import Mathlib.Tactic.NormNum.GCD
/-!
# Cycle Types
In this file we define the cycle type of a permutation.
## Main definitions
- `Equiv.Perm.cycleType σ` where `σ` is a permutation of a `Fintype`
- `Equiv.Perm.partition σ` where `σ` is a permutation of a `Fintype`
## Main results
- `sum_cycleType` : The sum of `σ.cycleType` equals `σ.support.card`
- `lcm_cycleType` : The lcm of `σ.cycleType` equals `orderOf σ`
- `isConj_iff_cycleType_eq` : Two permutations are conjugate if and only if they have the same
cycle type.
- `exists_prime_orderOf_dvd_card`: For every prime `p` dividing the order of a finite group `G`
there exists an element of order `p` in `G`. This is known as Cauchy's theorem.
-/
open scoped Finset
namespace Equiv.Perm
open List (Vector)
open Equiv List Multiset
variable {α : Type*} [Fintype α]
section CycleType
variable [DecidableEq α]
/-- The cycle type of a permutation -/
def cycleType (σ : Perm α) : Multiset ℕ :=
σ.cycleFactorsFinset.1.map (Finset.card ∘ support)
theorem cycleType_def (σ : Perm α) :
σ.cycleType = σ.cycleFactorsFinset.1.map (Finset.card ∘ support) :=
rfl
theorem cycleType_eq' {σ : Perm α} (s : Finset (Perm α)) (h1 : ∀ f : Perm α, f ∈ s → f.IsCycle)
(h2 : (s : Set (Perm α)).Pairwise Disjoint)
(h0 : s.noncommProd id (h2.imp fun _ _ => Disjoint.commute) = σ) :
σ.cycleType = s.1.map (Finset.card ∘ support) := by
rw [cycleType_def]
congr
rw [cycleFactorsFinset_eq_finset]
exact ⟨h1, h2, h0⟩
theorem cycleType_eq {σ : Perm α} (l : List (Perm α)) (h0 : l.prod = σ)
(h1 : ∀ σ : Perm α, σ ∈ l → σ.IsCycle) (h2 : l.Pairwise Disjoint) :
σ.cycleType = l.map (Finset.card ∘ support) := by
have hl : l.Nodup := nodup_of_pairwise_disjoint_cycles h1 h2
rw [cycleType_eq' l.toFinset]
· simp [List.dedup_eq_self.mpr hl, Function.comp_def]
· simpa using h1
· simpa [hl] using h2
· simp [hl, h0]
theorem CycleType.count_def {σ : Perm α} (n : ℕ) :
σ.cycleType.count n =
Fintype.card {c : σ.cycleFactorsFinset // #(c : Perm α).support = n } := by
-- work on the LHS
rw [cycleType, Multiset.count_eq_card_filter_eq]
-- rewrite the `Fintype.card` as a `Finset.card`
rw [Fintype.subtype_card, Finset.univ_eq_attach, Finset.filter_attach',
Finset.card_map, Finset.card_attach]
simp only [Function.comp_apply, Finset.card, Finset.filter_val,
Multiset.filter_map, Multiset.card_map]
congr 1
apply Multiset.filter_congr
intro d h
simp only [eq_comm, Finset.mem_val.mp h, exists_const]
@[simp]
theorem cycleType_eq_zero {σ : Perm α} : σ.cycleType = 0 ↔ σ = 1 := by
simp [cycleType_def, cycleFactorsFinset_eq_empty_iff]
@[simp]
theorem cycleType_one : (1 : Perm α).cycleType = 0 := cycleType_eq_zero.2 rfl
theorem card_cycleType_eq_zero {σ : Perm α} : Multiset.card σ.cycleType = 0 ↔ σ = 1 := by
rw [card_eq_zero, cycleType_eq_zero]
theorem card_cycleType_pos {σ : Perm α} : 0 < Multiset.card σ.cycleType ↔ σ ≠ 1 :=
pos_iff_ne_zero.trans card_cycleType_eq_zero.not
theorem two_le_of_mem_cycleType {σ : Perm α} {n : ℕ} (h : n ∈ σ.cycleType) : 2 ≤ n := by
simp only [cycleType_def, ← Finset.mem_def, Function.comp_apply, Multiset.mem_map,
mem_cycleFactorsFinset_iff] at h
obtain ⟨_, ⟨hc, -⟩, rfl⟩ := h
exact hc.two_le_card_support
theorem one_lt_of_mem_cycleType {σ : Perm α} {n : ℕ} (h : n ∈ σ.cycleType) : 1 < n :=
two_le_of_mem_cycleType h
theorem IsCycle.cycleType {σ : Perm α} (hσ : IsCycle σ) : σ.cycleType = {#σ.support} :=
cycleType_eq [σ] (mul_one σ) (fun _τ hτ => (congr_arg IsCycle (List.mem_singleton.mp hτ)).mpr hσ)
(List.pairwise_singleton Disjoint σ)
theorem card_cycleType_eq_one {σ : Perm α} : Multiset.card σ.cycleType = 1 ↔ σ.IsCycle := by
rw [card_eq_one]
simp_rw [cycleType_def, Multiset.map_eq_singleton, ← Finset.singleton_val, Finset.val_inj,
cycleFactorsFinset_eq_singleton_iff]
grind
theorem Disjoint.cycleType_mul {σ τ : Perm α} (h : Disjoint σ τ) :
(σ * τ).cycleType = σ.cycleType + τ.cycleType := by
rw [cycleType_def, cycleType_def, cycleType_def, h.cycleFactorsFinset_mul_eq_union, ←
Multiset.map_add, Finset.union_val, Multiset.add_eq_union_iff_disjoint.mpr _]
exact Finset.disjoint_val.2 h.disjoint_cycleFactorsFinset
@[deprecated (since := "2025-08-26")] alias Disjoint.cycleType := Disjoint.cycleType_mul
@[simp]
theorem cycleType_inv (σ : Perm α) : σ⁻¹.cycleType = σ.cycleType :=
cycle_induction_on (P := fun τ : Perm α => τ⁻¹.cycleType = τ.cycleType) σ rfl
(fun σ hσ => by simp only [hσ.cycleType, hσ.inv.cycleType, support_inv])
fun σ τ hστ _ hσ hτ => by
simp only [mul_inv_rev, hστ.cycleType_mul, hστ.symm.inv_left.inv_right.cycleType_mul, hσ, hτ,
add_comm]
@[simp]
theorem cycleType_conj {σ τ : Perm α} : (τ * σ * τ⁻¹).cycleType = σ.cycleType := by
induction σ using cycle_induction_on with
| base_one => simp
| base_cycles σ hσ => rw [hσ.cycleType, hσ.conj.cycleType, card_support_conj]
| induction_disjoint σ π hd _ hσ hπ =>
rw [← conj_mul, hd.cycleType_mul, (hd.conj _).cycleType_mul, hσ, hπ]
theorem sum_cycleType (σ : Perm α) : σ.cycleType.sum = #σ.support := by
induction σ using cycle_induction_on with
| base_one => simp
| base_cycles σ hσ => rw [hσ.cycleType, Multiset.sum_singleton]
| induction_disjoint σ τ hd _ hσ hτ => rw [hd.cycleType_mul, sum_add, hσ, hτ, hd.card_support_mul]
theorem card_fixedPoints (σ : Equiv.Perm α) :
Fintype.card (Function.fixedPoints σ) = Fintype.card α - σ.cycleType.sum := by
rw [Equiv.Perm.sum_cycleType, ← Finset.card_compl, Fintype.card_ofFinset]
congr; aesop
theorem sign_of_cycleType' (σ : Perm α) :
sign σ = (σ.cycleType.map fun n => -(-1 : ℤˣ) ^ n).prod := by
induction σ using cycle_induction_on with
| base_one => simp
| base_cycles σ hσ => simp [hσ.cycleType, hσ.sign]
| induction_disjoint σ τ hd _ hσ hτ => simp [hσ, hτ, hd.cycleType_mul]
theorem sign_of_cycleType (f : Perm α) :
sign f = (-1 : ℤˣ) ^ (f.cycleType.sum + Multiset.card f.cycleType) := by
rw [sign_of_cycleType']
induction f.cycleType using Multiset.induction_on with
| empty => rfl
| cons a s ihs =>
rw [Multiset.map_cons, Multiset.prod_cons, Multiset.sum_cons, Multiset.card_cons, ihs]
simp only [pow_add, pow_one, neg_mul, mul_neg, mul_assoc, mul_one]
@[simp]
theorem lcm_cycleType (σ : Perm α) : σ.cycleType.lcm = orderOf σ := by
induction σ using cycle_induction_on with
| base_one => simp
| base_cycles σ hσ => simp [hσ.cycleType, hσ.orderOf]
| induction_disjoint σ τ hd _ hσ hτ => simp [hd.cycleType_mul, hd.orderOf, lcm_eq_nat_lcm, hσ, hτ]
theorem dvd_of_mem_cycleType {σ : Perm α} {n : ℕ} (h : n ∈ σ.cycleType) : n ∣ orderOf σ := by
rw [← lcm_cycleType]
exact dvd_lcm h
theorem orderOf_cycleOf_dvd_orderOf (f : Perm α) (x : α) : orderOf (cycleOf f x) ∣ orderOf f := by
by_cases hx : f x = x
· rw [← cycleOf_eq_one_iff] at hx
simp [hx]
· refine dvd_of_mem_cycleType ?_
rw [cycleType, Multiset.mem_map]
refine ⟨f.cycleOf x, ?_, ?_⟩
· rwa [← Finset.mem_def, cycleOf_mem_cycleFactorsFinset_iff, mem_support]
· simp [(isCycle_cycleOf _ hx).orderOf]
theorem two_dvd_card_support {σ : Perm α} (hσ : σ ^ 2 = 1) : 2 ∣ #σ.support :=
(congr_arg (Dvd.dvd 2) σ.sum_cycleType).mp
(Multiset.dvd_sum fun n hn => by
rw [_root_.le_antisymm
(Nat.le_of_dvd zero_lt_two <|
(dvd_of_mem_cycleType hn).trans <| orderOf_dvd_of_pow_eq_one hσ)
(two_le_of_mem_cycleType hn)])
theorem cycleType_prime_order {σ : Perm α} (hσ : (orderOf σ).Prime) :
∃ n : ℕ, σ.cycleType = Multiset.replicate (n + 1) (orderOf σ) := by
refine ⟨Multiset.card σ.cycleType - 1, eq_replicate.2 ⟨?_, fun n hn ↦ ?_⟩⟩
· rw [tsub_add_cancel_of_le]
rw [Nat.succ_le_iff, card_cycleType_pos, Ne, ← orderOf_eq_one_iff]
exact hσ.ne_one
· exact (hσ.eq_one_or_self_of_dvd n (dvd_of_mem_cycleType hn)).resolve_left
(one_lt_of_mem_cycleType hn).ne'
theorem pow_prime_eq_one_iff {σ : Perm α} {p : ℕ} [hp : Fact (Nat.Prime p)] :
σ ^ p = 1 ↔ ∀ c ∈ σ.cycleType, c = p := by
rw [← orderOf_dvd_iff_pow_eq_one, ← lcm_cycleType, Multiset.lcm_dvd]
apply forall_congr'
exact fun c ↦ ⟨fun hc h ↦ Or.resolve_left (hp.elim.eq_one_or_self_of_dvd c (hc h))
(Nat.ne_of_lt' (one_lt_of_mem_cycleType h)),
fun hc h ↦ by rw [hc h]⟩
theorem isCycle_of_prime_order {σ : Perm α} (h1 : (orderOf σ).Prime)
(h2 : #σ.support < 2 * orderOf σ) : σ.IsCycle := by
obtain ⟨n, hn⟩ := cycleType_prime_order h1
rw [← σ.sum_cycleType, hn, Multiset.sum_replicate, nsmul_eq_mul, Nat.cast_id,
mul_lt_mul_iff_left₀ (orderOf_pos σ), Nat.succ_lt_succ_iff, Nat.lt_succ_iff, Nat.le_zero] at h2
rw [← card_cycleType_eq_one, hn, card_replicate, h2]
theorem cycleType_le_of_mem_cycleFactorsFinset {f g : Perm α} (hf : f ∈ g.cycleFactorsFinset) :
f.cycleType ≤ g.cycleType := by
have hf' := mem_cycleFactorsFinset_iff.1 hf
rw [cycleType_def, cycleType_def, hf'.left.cycleFactorsFinset_eq_singleton]
refine map_le_map ?_
simpa only [Finset.singleton_val, singleton_le, Finset.mem_val] using hf
theorem Disjoint.cycleType_noncommProd {ι : Type*} {k : ι → Perm α} {s : Finset ι}
(hs : Set.Pairwise s fun i j ↦ Disjoint (k i) (k j))
(hs' : Set.Pairwise s fun i j ↦ Commute (k i) (k j) :=
hs.imp (fun _ _ ↦ Perm.Disjoint.commute)) :
(s.noncommProd k hs').cycleType = s.sum fun i ↦ (k i).cycleType := by
classical
induction s using Finset.induction_on with
| empty => simp
| insert i s hi hrec =>
have hs' : (s : Set ι).Pairwise fun i j ↦ Disjoint (k i) (k j) :=
hs.mono (by simp only [Finset.coe_insert, Set.subset_insert])
rw [Finset.noncommProd_insert_of_notMem _ _ _ _ hi, Finset.sum_insert hi]
rw [Disjoint.cycleType_mul, hrec hs']
apply disjoint_noncommProd_right
intro j hj
apply hs _ _ (ne_of_mem_of_not_mem hj hi).symm <;>
simp only [Finset.coe_insert, Set.mem_insert_iff, Finset.mem_coe, hj, or_true, true_or]
theorem cycleType_mul_inv_mem_cycleFactorsFinset_eq_sub
{f g : Perm α} (hf : f ∈ g.cycleFactorsFinset) :
(g * f⁻¹).cycleType = g.cycleType - f.cycleType :=
add_right_cancel (b := f.cycleType) <| by
rw [← (disjoint_mul_inv_of_mem_cycleFactorsFinset hf).cycleType_mul, inv_mul_cancel_right,
tsub_add_cancel_of_le (cycleType_le_of_mem_cycleFactorsFinset hf)]
theorem isConj_of_cycleType_eq {σ τ : Perm α} (h : cycleType σ = cycleType τ) : IsConj σ τ := by
induction σ using cycle_induction_on generalizing τ with
| base_one =>
rw [cycleType_one, eq_comm, cycleType_eq_zero] at h
rw [h]
| base_cycles σ hσ =>
have hτ := card_cycleType_eq_one.2 hσ
rw [h, card_cycleType_eq_one] at hτ
apply hσ.isConj hτ
rwa [hσ.cycleType, hτ.cycleType, Multiset.singleton_inj] at h
| induction_disjoint σ π hd hc hσ hπ =>
rw [hd.cycleType_mul] at h
have h' : #σ.support ∈ τ.cycleType := by
simp [← h, hc.cycleType]
obtain ⟨σ', hσ'l, hσ'⟩ := Multiset.mem_map.mp h'
have key : IsConj (σ' * τ * σ'⁻¹) τ := (isConj_iff.2 ⟨σ', rfl⟩).symm
refine IsConj.trans ?_ key
rw [mul_assoc]
have hs : σ.cycleType = σ'.cycleType := by
rw [← Finset.mem_def, mem_cycleFactorsFinset_iff] at hσ'l
rw [hc.cycleType, ← hσ', hσ'l.left.cycleType]; rfl
refine hd.isConj_mul (hσ hs) (hπ ?_) ?_
· rw [cycleType_mul_inv_mem_cycleFactorsFinset_eq_sub, ← h, add_comm, hs,
add_tsub_cancel_right]
rwa [Finset.mem_def]
· exact (disjoint_mul_inv_of_mem_cycleFactorsFinset hσ'l).symm
theorem isConj_iff_cycleType_eq {σ τ : Perm α} : IsConj σ τ ↔ σ.cycleType = τ.cycleType :=
⟨fun h => by
obtain ⟨π, rfl⟩ := isConj_iff.1 h
rw [cycleType_conj], isConj_of_cycleType_eq⟩
@[simp]
theorem cycleType_extendDomain {β : Type*} [Fintype β] [DecidableEq β] {p : β → Prop}
[DecidablePred p] (f : α ≃ Subtype p) {g : Perm α} :
cycleType (g.extendDomain f) = cycleType g := by
induction g using cycle_induction_on with
| base_one => rw [extendDomain_one, cycleType_one, cycleType_one]
| base_cycles σ hσ =>
rw [(hσ.extendDomain f).cycleType, hσ.cycleType, card_support_extend_domain]
| induction_disjoint σ τ hd _ hσ hτ =>
rw [hd.cycleType_mul, ← extendDomain_mul, (hd.extendDomain f).cycleType_mul, hσ, hτ]
theorem cycleType_ofSubtype {p : α → Prop} [DecidablePred p] {g : Perm (Subtype p)} :
cycleType (ofSubtype g) = cycleType g :=
cycleType_extendDomain (Equiv.refl (Subtype p))
theorem mem_cycleType_iff {n : ℕ} {σ : Perm α} :
n ∈ cycleType σ ↔ ∃ c τ, σ = c * τ ∧ Disjoint c τ ∧ IsCycle c ∧ c.support.card = n := by
constructor
· intro h
obtain ⟨l, rfl, hlc, hld⟩ := truncCycleFactors σ
rw [cycleType_eq _ rfl hlc hld, Multiset.mem_coe, List.mem_map] at h
obtain ⟨c, cl, rfl⟩ := h
rw [(List.perm_cons_erase cl).pairwise_iff @(Disjoint.symmetric)] at hld
refine ⟨c, (l.erase c).prod, ?_, ?_, hlc _ cl, rfl⟩
· rw [← List.prod_cons, (List.perm_cons_erase cl).symm.prod_eq' (hld.imp Disjoint.commute)]
· exact disjoint_prod_right _ fun g => List.rel_of_pairwise_cons hld
· rintro ⟨c, t, rfl, hd, hc, rfl⟩
simp [hd.cycleType_mul, hc.cycleType]
theorem le_card_support_of_mem_cycleType {n : ℕ} {σ : Perm α} (h : n ∈ cycleType σ) :
n ≤ #σ.support :=
(le_sum_of_mem h).trans (le_of_eq σ.sum_cycleType)
theorem cycleType_of_card_le_mem_cycleType_add_two {n : ℕ} {g : Perm α}
(hn2 : Fintype.card α < n + 2) (hng : n ∈ g.cycleType) : g.cycleType = {n} := by
obtain ⟨c, g', rfl, hd, hc, rfl⟩ := mem_cycleType_iff.1 hng
suffices g'1 : g' = 1 by
rw [hd.cycleType_mul, hc.cycleType, g'1, cycleType_one, add_zero]
contrapose! hn2 with g'1
grw [← (c * g').support.card_le_univ, hd.card_support_mul, two_le_card_support_of_ne_one g'1]
end CycleType
theorem card_compl_support_modEq [DecidableEq α] {p n : ℕ} [hp : Fact p.Prime] {σ : Perm α}
(hσ : σ ^ p ^ n = 1) : σ.supportᶜ.card ≡ Fintype.card α [MOD p] := by
rw [Nat.modEq_iff_dvd', ← Finset.card_compl, compl_compl, ← sum_cycleType]
· refine Multiset.dvd_sum fun k hk => ?_
obtain ⟨m, -, hm⟩ := (Nat.dvd_prime_pow hp.out).mp (orderOf_dvd_of_pow_eq_one hσ)
obtain ⟨l, -, rfl⟩ := (Nat.dvd_prime_pow hp.out).mp
((congr_arg _ hm).mp (dvd_of_mem_cycleType hk))
exact dvd_pow_self _ fun h => (one_lt_of_mem_cycleType hk).ne <| by rw [h, pow_zero]
· exact Finset.card_le_univ _
open Function in
/-- The number of fixed points of a `p ^ n`-th root of the identity function over a finite set
and the set's cardinality have the same residue modulo `p`, where `p` is a prime. -/
theorem card_fixedPoints_modEq [DecidableEq α] {f : Function.End α} {p n : ℕ}
[hp : Fact p.Prime] (hf : f ^ p ^ n = 1) :
Fintype.card α ≡ Fintype.card f.fixedPoints [MOD p] := by
let σ : α ≃ α := ⟨f, f ^ (p ^ n - 1),
leftInverse_iff_comp.mpr ((pow_sub_mul_pow f (Nat.one_le_pow n p hp.out.pos)).trans hf),
leftInverse_iff_comp.mpr ((pow_mul_pow_sub f (Nat.one_le_pow n p hp.out.pos)).trans hf)⟩
have hσ : σ ^ p ^ n = 1 := by
rw [DFunLike.ext'_iff, coe_pow]
exact (hom_coe_pow (fun g : Function.End α ↦ g) rfl (fun g h ↦ rfl) f (p ^ n)).symm.trans hf
suffices Fintype.card f.fixedPoints = (support σ)ᶜ.card from
this ▸ (card_compl_support_modEq hσ).symm
suffices f.fixedPoints = (support σ)ᶜ by
simp only [this]; apply Fintype.card_coe
simp [σ, Set.ext_iff, IsFixedPt]
theorem exists_fixed_point_of_prime {p n : ℕ} [hp : Fact p.Prime] (hα : ¬p ∣ Fintype.card α)
{σ : Perm α} (hσ : σ ^ p ^ n = 1) : ∃ a : α, σ a = a := by
classical
contrapose! hα
simp_rw [← mem_support, ← Finset.eq_univ_iff_forall] at hα
exact Nat.modEq_zero_iff_dvd.1 ((congr_arg _ (Finset.card_eq_zero.2 (compl_eq_bot.2 hα))).mp
(card_compl_support_modEq hσ).symm)
theorem exists_fixed_point_of_prime' {p n : ℕ} [hp : Fact p.Prime] (hα : p ∣ Fintype.card α)
{σ : Perm α} (hσ : σ ^ p ^ n = 1) {a : α} (ha : σ a = a) : ∃ b : α, σ b = b ∧ b ≠ a := by
classical
have h : ∀ b : α, b ∈ σ.supportᶜ ↔ σ b = b := fun b => by
rw [Finset.mem_compl, mem_support, Classical.not_not]
obtain ⟨b, hb1, hb2⟩ := Finset.exists_mem_ne (hp.out.one_lt.trans_le
(Nat.le_of_dvd (Finset.card_pos.mpr ⟨a, (h a).mpr ha⟩) (Nat.modEq_zero_iff_dvd.mp
((card_compl_support_modEq hσ).trans (Nat.modEq_zero_iff_dvd.mpr hα))))) a
exact ⟨b, (h b).mp hb1, hb2⟩
theorem isCycle_of_prime_order' {σ : Perm α} (h1 : (orderOf σ).Prime)
(h2 : Fintype.card α < 2 * orderOf σ) : σ.IsCycle := by
classical exact isCycle_of_prime_order h1 (lt_of_le_of_lt σ.support.card_le_univ h2)
theorem isCycle_of_prime_order'' {σ : Perm α} (h1 : (Fintype.card α).Prime)
(h2 : orderOf σ = Fintype.card α) : σ.IsCycle :=
isCycle_of_prime_order' ((congr_arg Nat.Prime h2).mpr h1) <| by
rw [← one_mul (Fintype.card α), ← h2, mul_lt_mul_iff_left₀ (orderOf_pos σ)]
exact one_lt_two
section Cauchy
variable (G : Type*) [Group G] (n : ℕ)
/-- The type of vectors with terms from `G`, length `n`, and product equal to `1:G`. -/
def vectorsProdEqOne : Set (List.Vector G n) :=
{ v | v.toList.prod = 1 }
namespace VectorsProdEqOne
theorem mem_iff {n : ℕ} (v : List.Vector G n) : v ∈ vectorsProdEqOne G n ↔ v.toList.prod = 1 :=
Iff.rfl
theorem zero_eq : vectorsProdEqOne G 0 = {Vector.nil} :=
Set.eq_singleton_iff_unique_mem.mpr ⟨Eq.refl (1 : G), fun v _ => v.eq_nil⟩
theorem one_eq : vectorsProdEqOne G 1 = {Vector.nil.cons 1} := by
simp_rw [Set.eq_singleton_iff_unique_mem, mem_iff, List.Vector.toList_singleton,
List.prod_singleton, List.Vector.head_cons, true_and]
exact fun v hv => v.cons_head_tail.symm.trans (congr_arg₂ Vector.cons hv v.tail.eq_nil)
instance zeroUnique : Unique (vectorsProdEqOne G 0) := by
rw [zero_eq]
exact Set.uniqueSingleton Vector.nil
instance oneUnique : Unique (vectorsProdEqOne G 1) := by
rw [one_eq]
exact Set.uniqueSingleton (Vector.nil.cons 1)
/-- Given a vector `v` of length `n`, make a vector of length `n + 1` whose product is `1`,
by appending the inverse of the product of `v`. -/
@[simps]
def vectorEquiv : List.Vector G n ≃ vectorsProdEqOne G (n + 1) where
toFun v := ⟨v.toList.prod⁻¹ ::ᵥ v, by
rw [mem_iff, Vector.toList_cons, List.prod_cons, inv_mul_cancel]⟩
invFun v := v.1.tail
left_inv v := v.tail_cons v.toList.prod⁻¹
right_inv v := Subtype.ext <|
calc
v.1.tail.toList.prod⁻¹ ::ᵥ v.1.tail = v.1.head ::ᵥ v.1.tail :=
congr_arg (· ::ᵥ v.1.tail) <| Eq.symm <| eq_inv_of_mul_eq_one_left <| by
rw [← List.prod_cons, ← Vector.toList_cons, v.1.cons_head_tail]
exact v.2
_ = v.1 := v.1.cons_head_tail
/-- Given a vector `v` of length `n` whose product is 1, make a vector of length `n - 1`,
by deleting the last entry of `v`. -/
def equivVector : ∀ n, vectorsProdEqOne G n ≃ List.Vector G (n - 1)
| 0 => (ofUnique (vectorsProdEqOne G 0) (vectorsProdEqOne G 1)).trans (vectorEquiv G 0).symm
| (n + 1) => (vectorEquiv G n).symm
instance [Fintype G] : Fintype (vectorsProdEqOne G n) :=
Fintype.ofEquiv (List.Vector G (n - 1)) (equivVector G n).symm
theorem card [Fintype G] : Fintype.card (vectorsProdEqOne G n) = Fintype.card G ^ (n - 1) :=
(Fintype.card_congr (equivVector G n)).trans (card_vector (n - 1))
variable {G n} {g : G}
variable (v : vectorsProdEqOne G n) (j k : ℕ)
/-- Rotate a vector whose product is 1. -/
def rotate : vectorsProdEqOne G n :=
⟨⟨_, (v.1.1.length_rotate k).trans v.1.2⟩, List.prod_rotate_eq_one_of_prod_eq_one v.2 k⟩
theorem rotate_zero : rotate v 0 = v :=
Subtype.ext (Subtype.ext v.1.1.rotate_zero)
theorem rotate_rotate : rotate (rotate v j) k = rotate v (j + k) :=
Subtype.ext (Subtype.ext (v.1.1.rotate_rotate j k))
theorem rotate_length : rotate v n = v :=
Subtype.ext (Subtype.ext ((congr_arg _ v.1.2.symm).trans v.1.1.rotate_length))
end VectorsProdEqOne
-- TODO: Make the `Finite` version of this theorem the default
/-- For every prime `p` dividing the order of a finite group `G` there exists an element of order
`p` in `G`. This is known as Cauchy's theorem. -/
theorem _root_.exists_prime_orderOf_dvd_card {G : Type*} [Group G] [Fintype G] (p : ℕ)
[hp : Fact p.Prime] (hdvd : p ∣ Fintype.card G) : ∃ x : G, orderOf x = p := by
have hp' : p - 1 ≠ 0 := mt tsub_eq_zero_iff_le.mp (not_le_of_gt hp.out.one_lt)
have Scard :=
calc
p ∣ Fintype.card G ^ (p - 1) := hdvd.trans (dvd_pow (dvd_refl _) hp')
_ = Fintype.card (vectorsProdEqOne G p) := (VectorsProdEqOne.card G p).symm
let f : ℕ → vectorsProdEqOne G p → vectorsProdEqOne G p := fun k v =>
VectorsProdEqOne.rotate v k
have hf1 : ∀ v, f 0 v = v := VectorsProdEqOne.rotate_zero
have hf2 : ∀ j k v, f k (f j v) = f (j + k) v := fun j k v =>
VectorsProdEqOne.rotate_rotate v j k
have hf3 : ∀ v, f p v = v := VectorsProdEqOne.rotate_length
let σ :=
Equiv.mk (f 1) (f (p - 1)) (fun s => by rw [hf2, add_tsub_cancel_of_le hp.out.one_lt.le, hf3])
fun s => by rw [hf2, tsub_add_cancel_of_le hp.out.one_lt.le, hf3]
have hσ : ∀ k v, (σ ^ k) v = f k v := fun k =>
Nat.rec (fun v => (hf1 v).symm) (fun k hk v => by
rw [pow_succ, Perm.mul_apply, hk (σ v), Nat.succ_eq_one_add, ← hf2 1 k]
simp only [σ, coe_fn_mk]) k
replace hσ : σ ^ p ^ 1 = 1 := Perm.ext fun v => by rw [pow_one, hσ, hf3, one_apply]
let v₀ : vectorsProdEqOne G p :=
⟨List.Vector.replicate p 1, (List.prod_replicate p 1).trans (one_pow p)⟩
have hv₀ : σ v₀ = v₀ := Subtype.ext (Subtype.ext (List.rotate_replicate (1 : G) p 1))
obtain ⟨v, hv1, hv2⟩ := exists_fixed_point_of_prime' Scard hσ hv₀
refine
Exists.imp (fun g hg => orderOf_eq_prime ?_ fun hg' => hv2 ?_)
(List.rotate_one_eq_self_iff_eq_replicate.mp (Subtype.ext_iff.mp (Subtype.ext_iff.mp hv1)))
· rw [← List.prod_replicate, ← v.1.2, ← hg, show v.val.val.prod = 1 from v.2]
· rw [Subtype.ext_iff, Subtype.ext_iff, hg, hg', v.1.2]
simp only [v₀, List.Vector.replicate]
-- TODO: Make the `Finite` version of this theorem the default
/-- For every prime `p` dividing the order of a finite additive group `G` there exists an element of
order `p` in `G`. This is the additive version of Cauchy's theorem. -/
theorem _root_.exists_prime_addOrderOf_dvd_card {G : Type*} [AddGroup G] [Fintype G] (p : ℕ)
[Fact p.Prime] (hdvd : p ∣ Fintype.card G) : ∃ x : G, addOrderOf x = p :=
@exists_prime_orderOf_dvd_card (Multiplicative G) _ _ _ _ (by convert hdvd)
attribute [to_additive existing] exists_prime_orderOf_dvd_card
-- TODO: Make the `Finite` version of this theorem the default
/-- For every prime `p` dividing the order of a finite group `G` there exists an element of order
`p` in `G`. This is known as Cauchy's theorem. -/
@[to_additive]
theorem _root_.exists_prime_orderOf_dvd_card' {G : Type*} [Group G] [Finite G] (p : ℕ)
[hp : Fact p.Prime] (hdvd : p ∣ Nat.card G) : ∃ x : G, orderOf x = p := by
have := Fintype.ofFinite G
rw [Nat.card_eq_fintype_card] at hdvd
exact exists_prime_orderOf_dvd_card p hdvd
end Cauchy
theorem subgroup_eq_top_of_swap_mem [DecidableEq α] {H : Subgroup (Perm α)}
[d : DecidablePred (· ∈ H)] {τ : Perm α} (h0 : (Fintype.card α).Prime)
(h1 : Fintype.card α ∣ Fintype.card H) (h2 : τ ∈ H) (h3 : IsSwap τ) : H = ⊤ := by
haveI : Fact (Fintype.card α).Prime := ⟨h0⟩
obtain ⟨σ, hσ⟩ := exists_prime_orderOf_dvd_card (Fintype.card α) h1
have hσ1 : orderOf (σ : Perm α) = Fintype.card α := (Subgroup.orderOf_coe σ).trans hσ
have hσ2 : IsCycle ↑σ := isCycle_of_prime_order'' h0 hσ1
have hσ3 : (σ : Perm α).support = ⊤ :=
Finset.eq_univ_of_card (σ : Perm α).support (hσ2.orderOf.symm.trans hσ1)
have hσ4 : Subgroup.closure {↑σ, τ} = ⊤ := closure_prime_cycle_swap h0 hσ2 hσ3 h3
rw [eq_top_iff, ← hσ4, Subgroup.closure_le, Set.insert_subset_iff, Set.singleton_subset_iff]
exact ⟨Subtype.mem σ, h2⟩
section Partition
variable [DecidableEq α]
/-- The partition corresponding to a permutation -/
def partition (σ : Perm α) : (Fintype.card α).Partition where
parts := σ.cycleType + Multiset.replicate (Fintype.card α - #σ.support) 1
parts_pos {n hn} := by
rcases mem_add.mp hn with hn | hn
· exact zero_lt_one.trans (one_lt_of_mem_cycleType hn)
· exact lt_of_lt_of_le zero_lt_one (ge_of_eq (Multiset.eq_of_mem_replicate hn))
parts_sum := by
rw [sum_add, sum_cycleType, Multiset.sum_replicate, nsmul_eq_mul, Nat.cast_id, mul_one,
add_tsub_cancel_of_le σ.support.card_le_univ]
theorem parts_partition {σ : Perm α} :
σ.partition.parts = σ.cycleType + Multiset.replicate (Fintype.card α - #σ.support) 1 :=
rfl
theorem filter_parts_partition_eq_cycleType {σ : Perm α} :
((partition σ).parts.filter fun n => 2 ≤ n) = σ.cycleType := by
rw [parts_partition, filter_add, Multiset.filter_eq_self.2 fun _ => two_le_of_mem_cycleType,
Multiset.filter_eq_nil.2 fun a h => ?_, add_zero]
rw [Multiset.eq_of_mem_replicate h]
decide
theorem partition_eq_of_isConj {σ τ : Perm α} : IsConj σ τ ↔ σ.partition = τ.partition := by
rw [isConj_iff_cycleType_eq]
refine ⟨fun h => ?_, fun h => ?_⟩
· rw [Nat.Partition.ext_iff, parts_partition, parts_partition, ← sum_cycleType, ← sum_cycleType,
h]
· rw [← filter_parts_partition_eq_cycleType, ← filter_parts_partition_eq_cycleType, h]
end Partition
section IsSwap
variable [DecidableEq α]
theorem isSwap_iff_cycleType {σ : Perm α} : σ.IsSwap ↔ σ.cycleType = {2} := by
constructor
· intro h
simpa [h.isCycle.cycleType, card_support_eq_two] using h
· intro h
simp [← card_support_eq_two, ← sum_cycleType, h]
theorem IsSwap.orderOf {σ : Equiv.Perm α} (h : σ.IsSwap) :
orderOf σ = 2 := by
rw [← lcm_cycleType, isSwap_iff_cycleType.mp h, Multiset.lcm_singleton, normalize_eq]
end IsSwap
/-!
### 3-cycles
-/
/-- A three-cycle is a cycle of length 3. -/
def IsThreeCycle [DecidableEq α] (σ : Perm α) : Prop :=
σ.cycleType = {3}
namespace IsThreeCycle
variable [DecidableEq α] {σ : Perm α}
theorem cycleType (h : IsThreeCycle σ) : σ.cycleType = {3} :=
h
theorem card_support (h : IsThreeCycle σ) : #σ.support = 3 := by
rw [← sum_cycleType, h.cycleType, Multiset.sum_singleton]
theorem _root_.card_support_eq_three_iff : #σ.support = 3 ↔ σ.IsThreeCycle := by
refine ⟨fun h => ?_, IsThreeCycle.card_support⟩
by_cases h0 : σ.cycleType = 0
· rw [← sum_cycleType, h0, sum_zero] at h
exact (ne_of_lt zero_lt_three h).elim
obtain ⟨n, hn⟩ := exists_mem_of_ne_zero h0
by_cases h1 : σ.cycleType.erase n = 0
· rw [← sum_cycleType, ← cons_erase hn, h1, cons_zero, Multiset.sum_singleton] at h
rw [IsThreeCycle, ← cons_erase hn, h1, h, ← cons_zero]
obtain ⟨m, hm⟩ := exists_mem_of_ne_zero h1
rw [← sum_cycleType, ← cons_erase hn, ← cons_erase hm, Multiset.sum_cons, Multiset.sum_cons] at h
have : ∀ {k}, 2 ≤ m → 2 ≤ n → n + (m + k) = 3 → False := by omega
cases this (two_le_of_mem_cycleType (mem_of_mem_erase hm)) (two_le_of_mem_cycleType hn) h
theorem isCycle (h : IsThreeCycle σ) : IsCycle σ := by
rw [← card_cycleType_eq_one, h.cycleType, card_singleton]
theorem sign (h : IsThreeCycle σ) : sign σ = 1 := by
rw [Equiv.Perm.sign_of_cycleType, h.cycleType]
rfl
theorem inv {f : Perm α} (h : IsThreeCycle f) : IsThreeCycle f⁻¹ := by
rwa [IsThreeCycle, cycleType_inv]
@[simp]
theorem inv_iff {f : Perm α} : IsThreeCycle f⁻¹ ↔ IsThreeCycle f :=
⟨by
rw [← inv_inv f]
apply inv, inv⟩
theorem orderOf {g : Perm α} (ht : IsThreeCycle g) : orderOf g = 3 := by
rw [← lcm_cycleType, ht.cycleType, Multiset.lcm_singleton, normalize_eq]
theorem isThreeCycle_sq {g : Perm α} (ht : IsThreeCycle g) : IsThreeCycle (g * g) := by
rw [← pow_two, ← card_support_eq_three_iff, support_pow_coprime, ht.card_support]
rw [ht.orderOf]
norm_num
end IsThreeCycle
section
variable [DecidableEq α]
theorem isThreeCycle_swap_mul_swap_same {a b c : α} (ab : a ≠ b) (ac : a ≠ c) (bc : b ≠ c) :
IsThreeCycle (swap a b * swap a c) := by
suffices h : support (swap a b * swap a c) = {a, b, c} by
rw [← card_support_eq_three_iff, h]
simp [ab, ac, bc]
apply le_antisymm ((support_mul_le _ _).trans fun x => _) fun x hx => ?_
· simp [ab, ac]
· simp only [Finset.mem_insert, Finset.mem_singleton] at hx
rw [mem_support]
simp only [Perm.coe_mul, Function.comp_apply, Ne]
obtain rfl | rfl | rfl := hx
· rw [swap_apply_left, swap_apply_of_ne_of_ne ac.symm bc.symm]
exact ac.symm
· rw [swap_apply_of_ne_of_ne ab.symm bc, swap_apply_right]
exact ab
· rw [swap_apply_right, swap_apply_left]
exact bc
open Subgroup
theorem swap_mul_swap_same_mem_closure_three_cycles {a b c : α} (ab : a ≠ b) (ac : a ≠ c) :
swap a b * swap a c ∈ closure { σ : Perm α | IsThreeCycle σ } := by
by_cases bc : b = c
· subst bc
simp [one_mem]
exact subset_closure (isThreeCycle_swap_mul_swap_same ab ac bc)
theorem IsSwap.mul_mem_closure_three_cycles {σ τ : Perm α} (hσ : IsSwap σ) (hτ : IsSwap τ) :
σ * τ ∈ closure { σ : Perm α | IsThreeCycle σ } := by
obtain ⟨a, b, ab, rfl⟩ := hσ
obtain ⟨c, d, cd, rfl⟩ := hτ
by_cases ac : a = c
· subst ac
exact swap_mul_swap_same_mem_closure_three_cycles ab cd
have h' : swap a b * swap c d = swap a b * swap a c * (swap c a * swap c d) := by
simp [swap_comm c a, mul_assoc]
rw [h']
exact
mul_mem (swap_mul_swap_same_mem_closure_three_cycles ab ac)
(swap_mul_swap_same_mem_closure_three_cycles (Ne.symm ac) cd)
end
end Equiv.Perm |
.lake/packages/mathlib/Mathlib/GroupTheory/Perm/Cycle/Basic.lean | import Mathlib.Algebra.Module.BigOperators
import Mathlib.GroupTheory.Perm.Basic
import Mathlib.GroupTheory.Perm.Finite
import Mathlib.GroupTheory.Perm.List
import Mathlib.GroupTheory.Perm.Sign
/-!
# Cycles of a permutation
This file starts the theory of cycles in permutations.
## Main definitions
In the following, `f : Equiv.Perm β`.
* `Equiv.Perm.SameCycle`: `f.SameCycle x y` when `x` and `y` are in the same cycle of `f`.
* `Equiv.Perm.IsCycle`: `f` is a cycle if any two nonfixed points of `f` are related by repeated
applications of `f`, and `f` is not the identity.
* `Equiv.Perm.IsCycleOn`: `f` is a cycle on a set `s` when any two points of `s` are related by
repeated applications of `f`.
## Notes
`Equiv.Perm.IsCycle` and `Equiv.Perm.IsCycleOn` are different in three ways:
* `IsCycle` is about the entire type while `IsCycleOn` is restricted to a set.
* `IsCycle` forbids the identity while `IsCycleOn` allows it (if `s` is a subsingleton).
* `IsCycleOn` forbids fixed points on `s` (if `s` is nontrivial), while `IsCycle` allows them.
-/
open Equiv Function Finset
variable {ι α β : Type*}
namespace Equiv.Perm
/-! ### `SameCycle` -/
section SameCycle
variable {f g : Perm α} {p : α → Prop} {x y z : α}
/-- The equivalence relation indicating that two points are in the same cycle of a permutation. -/
def SameCycle (f : Perm α) (x y : α) : Prop :=
∃ i : ℤ, (f ^ i) x = y
@[refl]
theorem SameCycle.refl (f : Perm α) (x : α) : SameCycle f x x :=
⟨0, rfl⟩
theorem SameCycle.rfl : SameCycle f x x :=
SameCycle.refl _ _
protected theorem _root_.Eq.sameCycle (h : x = y) (f : Perm α) : f.SameCycle x y := by rw [h]
@[symm]
theorem SameCycle.symm : SameCycle f x y → SameCycle f y x := fun ⟨i, hi⟩ =>
⟨-i, by simp [zpow_neg, ← hi]⟩
theorem sameCycle_comm : SameCycle f x y ↔ SameCycle f y x :=
⟨SameCycle.symm, SameCycle.symm⟩
@[trans]
theorem SameCycle.trans : SameCycle f x y → SameCycle f y z → SameCycle f x z :=
fun ⟨i, hi⟩ ⟨j, hj⟩ => ⟨j + i, by rw [zpow_add, mul_apply, hi, hj]⟩
variable (f) in
theorem SameCycle.equivalence : Equivalence (SameCycle f) :=
⟨SameCycle.refl f, SameCycle.symm, SameCycle.trans⟩
/-- The setoid defined by the `SameCycle` relation. -/
def SameCycle.setoid (f : Perm α) : Setoid α where
r := f.SameCycle
iseqv := SameCycle.equivalence f
@[simp]
theorem sameCycle_one : SameCycle 1 x y ↔ x = y := by simp [SameCycle]
@[simp]
theorem sameCycle_inv : SameCycle f⁻¹ x y ↔ SameCycle f x y :=
(Equiv.neg _).exists_congr_left.trans <| by simp [SameCycle]
alias ⟨SameCycle.of_inv, SameCycle.inv⟩ := sameCycle_inv
@[simp]
theorem sameCycle_conj : SameCycle (g * f * g⁻¹) x y ↔ SameCycle f (g⁻¹ x) (g⁻¹ y) :=
exists_congr fun i => by simp [conj_zpow, eq_inv_iff_eq]
theorem SameCycle.conj : SameCycle f x y → SameCycle (g * f * g⁻¹) (g x) (g y) := by
simp [sameCycle_conj]
theorem SameCycle.apply_eq_self_iff : SameCycle f x y → (f x = x ↔ f y = y) := fun ⟨i, hi⟩ => by
rw [← hi, ← mul_apply, ← zpow_one_add, add_comm, zpow_add_one, mul_apply,
(f ^ i).injective.eq_iff]
theorem SameCycle.eq_of_left (h : SameCycle f x y) (hx : IsFixedPt f x) : x = y :=
let ⟨_, hn⟩ := h
(hx.perm_zpow _).eq.symm.trans hn
theorem SameCycle.eq_of_right (h : SameCycle f x y) (hy : IsFixedPt f y) : x = y :=
h.eq_of_left <| h.apply_eq_self_iff.2 hy
@[simp]
theorem sameCycle_apply_left : SameCycle f (f x) y ↔ SameCycle f x y :=
(Equiv.addRight 1).exists_congr_left.trans <| by
simp [zpow_sub, SameCycle, Int.add_neg_one, Function.comp]
@[simp]
theorem sameCycle_apply_right : SameCycle f x (f y) ↔ SameCycle f x y := by
rw [sameCycle_comm, sameCycle_apply_left, sameCycle_comm]
@[simp]
theorem sameCycle_inv_apply_left : SameCycle f (f⁻¹ x) y ↔ SameCycle f x y := by
rw [← sameCycle_apply_left, apply_inv_self]
@[simp]
theorem sameCycle_inv_apply_right : SameCycle f x (f⁻¹ y) ↔ SameCycle f x y := by
rw [← sameCycle_apply_right, apply_inv_self]
@[simp]
theorem sameCycle_zpow_left {n : ℤ} : SameCycle f ((f ^ n) x) y ↔ SameCycle f x y :=
(Equiv.addRight (n : ℤ)).exists_congr_left.trans <| by simp [SameCycle, zpow_add]
@[simp]
theorem sameCycle_zpow_right {n : ℤ} : SameCycle f x ((f ^ n) y) ↔ SameCycle f x y := by
rw [sameCycle_comm, sameCycle_zpow_left, sameCycle_comm]
@[simp]
theorem sameCycle_pow_left {n : ℕ} : SameCycle f ((f ^ n) x) y ↔ SameCycle f x y := by
rw [← zpow_natCast, sameCycle_zpow_left]
@[simp]
theorem sameCycle_pow_right {n : ℕ} : SameCycle f x ((f ^ n) y) ↔ SameCycle f x y := by
rw [← zpow_natCast, sameCycle_zpow_right]
alias ⟨SameCycle.of_apply_left, SameCycle.apply_left⟩ := sameCycle_apply_left
alias ⟨SameCycle.of_apply_right, SameCycle.apply_right⟩ := sameCycle_apply_right
alias ⟨SameCycle.of_inv_apply_left, SameCycle.inv_apply_left⟩ := sameCycle_inv_apply_left
alias ⟨SameCycle.of_inv_apply_right, SameCycle.inv_apply_right⟩ := sameCycle_inv_apply_right
alias ⟨SameCycle.of_pow_left, SameCycle.pow_left⟩ := sameCycle_pow_left
alias ⟨SameCycle.of_pow_right, SameCycle.pow_right⟩ := sameCycle_pow_right
alias ⟨SameCycle.of_zpow_left, SameCycle.zpow_left⟩ := sameCycle_zpow_left
alias ⟨SameCycle.of_zpow_right, SameCycle.zpow_right⟩ := sameCycle_zpow_right
theorem SameCycle.of_pow {n : ℕ} : SameCycle (f ^ n) x y → SameCycle f x y := fun ⟨m, h⟩ =>
⟨n * m, by simp [zpow_mul, h]⟩
theorem SameCycle.of_zpow {n : ℤ} : SameCycle (f ^ n) x y → SameCycle f x y := fun ⟨m, h⟩ =>
⟨n * m, by simp [zpow_mul, h]⟩
@[simp]
theorem sameCycle_subtypePerm {h} {x y : { x // p x }} :
(f.subtypePerm h).SameCycle x y ↔ f.SameCycle x y :=
exists_congr fun n => by simp [Subtype.ext_iff]
alias ⟨_, SameCycle.subtypePerm⟩ := sameCycle_subtypePerm
@[simp]
theorem sameCycle_extendDomain {p : β → Prop} [DecidablePred p] {f : α ≃ Subtype p} :
SameCycle (g.extendDomain f) (f x) (f y) ↔ g.SameCycle x y :=
exists_congr fun n => by
rw [← extendDomain_zpow, extendDomain_apply_image, Subtype.coe_inj, f.injective.eq_iff]
alias ⟨_, SameCycle.extendDomain⟩ := sameCycle_extendDomain
theorem SameCycle.exists_pow_eq' [Finite α] : SameCycle f x y → ∃ i < orderOf f, (f ^ i) x = y := by
rintro ⟨k, rfl⟩
use (k % orderOf f).natAbs
have h₀ := Int.natCast_pos.mpr (orderOf_pos f)
have h₁ := Int.emod_nonneg k h₀.ne'
rw [← zpow_natCast, Int.natAbs_of_nonneg h₁, zpow_mod_orderOf]
refine ⟨?_, by rfl⟩
rw [← Int.ofNat_lt, Int.natAbs_of_nonneg h₁]
exact Int.emod_lt_of_pos _ h₀
theorem SameCycle.exists_pow_eq'' [Finite α] (h : SameCycle f x y) :
∃ i : ℕ, 0 < i ∧ i ≤ orderOf f ∧ (f ^ i) x = y := by
obtain ⟨_ | i, hi, rfl⟩ := h.exists_pow_eq'
· refine ⟨orderOf f, orderOf_pos f, le_rfl, ?_⟩
rw [pow_orderOf_eq_one, pow_zero]
· exact ⟨i.succ, i.zero_lt_succ, hi.le, by rfl⟩
theorem SameCycle.exists_fin_pow_eq [Finite α] (h : SameCycle f x y) :
∃ i : Fin (orderOf f), (f ^ (i : ℕ)) x = y := by
obtain ⟨i, hi, hx⟩ := SameCycle.exists_pow_eq' h
exact ⟨⟨i, hi⟩, hx⟩
theorem SameCycle.exists_nat_pow_eq [Finite α] (h : SameCycle f x y) :
∃ i : ℕ, (f ^ i) x = y := by
obtain ⟨i, _, hi⟩ := h.exists_pow_eq'
exact ⟨i, hi⟩
instance (f : Perm α) [DecidableRel (SameCycle f)] :
DecidableRel (SameCycle f⁻¹) := fun x y =>
decidable_of_iff (f.SameCycle x y) (sameCycle_inv).symm
instance (priority := 100) [DecidableEq α] : DecidableRel (SameCycle (1 : Perm α)) := fun x y =>
decidable_of_iff (x = y) sameCycle_one.symm
end SameCycle
/-!
### `IsCycle`
-/
section IsCycle
variable {f g : Perm α} {x y : α}
/-- A cycle is a non-identity permutation where any two nonfixed points of the permutation are
related by repeated application of the permutation. -/
def IsCycle (f : Perm α) : Prop :=
∃ x, f x ≠ x ∧ ∀ ⦃y⦄, f y ≠ y → SameCycle f x y
theorem IsCycle.ne_one (h : IsCycle f) : f ≠ 1 := fun hf => by simp [hf, IsCycle] at h
@[simp]
theorem not_isCycle_one : ¬(1 : Perm α).IsCycle := fun H => H.ne_one rfl
protected theorem IsCycle.sameCycle (hf : IsCycle f) (hx : f x ≠ x) (hy : f y ≠ y) :
SameCycle f x y :=
let ⟨g, hg⟩ := hf
let ⟨a, ha⟩ := hg.2 hx
let ⟨b, hb⟩ := hg.2 hy
⟨b - a, by rw [← ha, ← mul_apply, ← zpow_add, sub_add_cancel, hb]⟩
theorem IsCycle.exists_zpow_eq : IsCycle f → f x ≠ x → f y ≠ y → ∃ i : ℤ, (f ^ i) x = y :=
IsCycle.sameCycle
theorem IsCycle.inv (hf : IsCycle f) : IsCycle f⁻¹ :=
hf.imp fun _ ⟨hx, h⟩ =>
⟨inv_eq_iff_eq.not.2 hx.symm, fun _ hy => (h <| inv_eq_iff_eq.not.2 hy.symm).inv⟩
@[simp]
theorem isCycle_inv : IsCycle f⁻¹ ↔ IsCycle f :=
⟨fun h => h.inv, IsCycle.inv⟩
theorem IsCycle.conj : IsCycle f → IsCycle (g * f * g⁻¹) := by
rintro ⟨x, hx, h⟩
refine ⟨g x, by simp [coe_mul, hx], fun y hy => ?_⟩
simpa using (h <| eq_inv_iff_eq.not.2 hy).conj (g := g)
protected theorem IsCycle.extendDomain {p : β → Prop} [DecidablePred p] (f : α ≃ Subtype p) :
IsCycle g → IsCycle (g.extendDomain f) := by
rintro ⟨a, ha, ha'⟩
refine ⟨f a, ?_, fun b hb => ?_⟩
· rw [extendDomain_apply_image]
exact Subtype.coe_injective.ne (f.injective.ne ha)
have h : b = f (f.symm ⟨b, of_not_not <| hb ∘ extendDomain_apply_not_subtype _ _⟩) := by
rw [apply_symm_apply, Subtype.coe_mk]
rw [h] at hb ⊢
simp only [extendDomain_apply_image, Subtype.coe_injective.ne_iff, f.injective.ne_iff] at hb
exact (ha' hb).extendDomain
theorem isCycle_iff_sameCycle (hx : f x ≠ x) : IsCycle f ↔ ∀ {y}, SameCycle f x y ↔ f y ≠ y :=
⟨fun hf y =>
⟨fun ⟨i, hi⟩ hy =>
hx <| by
rw [← zpow_apply_eq_self_of_apply_eq_self hy i, (f ^ i).injective.eq_iff] at hi
rw [hi, hy],
hf.exists_zpow_eq hx⟩,
fun h => ⟨x, hx, fun _ hy => h.2 hy⟩⟩
section Finite
variable [Finite α]
theorem IsCycle.exists_pow_eq (hf : IsCycle f) (hx : f x ≠ x) (hy : f y ≠ y) :
∃ i : ℕ, (f ^ i) x = y := by
let ⟨n, hn⟩ := hf.exists_zpow_eq hx hy
classical exact
⟨(n % orderOf f).toNat, by
{have := n.emod_nonneg (Int.natCast_ne_zero.mpr (ne_of_gt (orderOf_pos f)))
rwa [← zpow_natCast, Int.toNat_of_nonneg this, zpow_mod_orderOf]}⟩
end Finite
variable [DecidableEq α]
theorem isCycle_swap (hxy : x ≠ y) : IsCycle (swap x y) :=
⟨y, by rwa [swap_apply_right], fun a (ha : ite (a = x) y (ite (a = y) x a) ≠ a) =>
if hya : y = a then ⟨0, hya⟩
else
⟨1, by
rw [zpow_one, swap_apply_def]
split_ifs at * <;> tauto⟩⟩
protected theorem IsSwap.isCycle : IsSwap f → IsCycle f := by
rintro ⟨x, y, hxy, rfl⟩
exact isCycle_swap hxy
theorem swap_isSwap_iff {a b : α} :
(swap a b).IsSwap ↔ a ≠ b := by
constructor
· intro h hab
apply h.isCycle.ne_one
aesop
· intro h; use a, b
variable [Fintype α]
theorem IsCycle.two_le_card_support (h : IsCycle f) : 2 ≤ #f.support :=
two_le_card_support_of_ne_one h.ne_one
/-- The subgroup generated by a cycle is in bijection with its support -/
noncomputable def IsCycle.zpowersEquivSupport {σ : Perm α} (hσ : IsCycle σ) :
(Subgroup.zpowers σ) ≃ σ.support :=
Equiv.ofBijective
(fun (τ : ↥((Subgroup.zpowers σ) : Set (Perm α))) =>
⟨(τ : Perm α) (Classical.choose hσ), by
obtain ⟨τ, n, rfl⟩ := τ
rw [Subtype.coe_mk, zpow_apply_mem_support, mem_support]
exact (Classical.choose_spec hσ).1⟩)
(by
constructor
· rintro ⟨a, m, rfl⟩ ⟨b, n, rfl⟩ h
ext y
by_cases hy : σ y = y
· simp_rw [zpow_apply_eq_self_of_apply_eq_self hy]
· obtain ⟨i, rfl⟩ := (Classical.choose_spec hσ).2 hy
rw [Subtype.coe_mk, Subtype.coe_mk, zpow_apply_comm σ m i, zpow_apply_comm σ n i]
exact congr_arg _ (Subtype.ext_iff.mp h)
· rintro ⟨y, hy⟩
rw [mem_support] at hy
obtain ⟨n, rfl⟩ := (Classical.choose_spec hσ).2 hy
exact ⟨⟨σ ^ n, n, rfl⟩, rfl⟩)
@[simp]
theorem IsCycle.zpowersEquivSupport_apply {σ : Perm α} (hσ : IsCycle σ) {n : ℕ} :
hσ.zpowersEquivSupport ⟨σ ^ n, n, rfl⟩ =
⟨(σ ^ n) (Classical.choose hσ),
pow_apply_mem_support.2 (mem_support.2 (Classical.choose_spec hσ).1)⟩ :=
rfl
@[simp]
theorem IsCycle.zpowersEquivSupport_symm_apply {σ : Perm α} (hσ : IsCycle σ) (n : ℕ) :
hσ.zpowersEquivSupport.symm
⟨(σ ^ n) (Classical.choose hσ),
pow_apply_mem_support.2 (mem_support.2 (Classical.choose_spec hσ).1)⟩ =
⟨σ ^ n, n, rfl⟩ :=
(Equiv.symm_apply_eq _).2 hσ.zpowersEquivSupport_apply
protected theorem IsCycle.orderOf (hf : IsCycle f) : orderOf f = #f.support := by
rw [← Fintype.card_zpowers, ← Fintype.card_coe]
convert Fintype.card_congr (IsCycle.zpowersEquivSupport hf)
theorem isCycle_swap_mul_aux₁ {α : Type*} [DecidableEq α] :
∀ (n : ℕ) {b x : α} {f : Perm α} (_ : (swap x (f x) * f) b ≠ b) (_ : (f ^ n) (f x) = b),
∃ i : ℤ, ((swap x (f x) * f) ^ i) (f x) = b := by
intro n
induction n with
| zero => exact fun _ h => ⟨0, h⟩
| succ n hn =>
intro b x f hb h
obtain hfbx | hfbx := eq_or_ne (f x) b
· exact ⟨0, hfbx⟩
have : f b ≠ b ∧ b ≠ x := ne_and_ne_of_swap_mul_apply_ne_self hb
have hb' : (swap x (f x) * f) (f.symm b) ≠ f.symm b := by
simpa [swap_apply_of_ne_of_ne this.2 hfbx.symm, eq_symm_apply] using this.1
obtain ⟨i, hi⟩ := hn hb' <| f.injective <| by simpa [pow_succ'] using h
refine ⟨i + 1, ?_⟩
rw [add_comm, zpow_add, mul_apply, hi, zpow_one, mul_apply, apply_symm_apply,
swap_apply_of_ne_of_ne (ne_and_ne_of_swap_mul_apply_ne_self hb).2 hfbx.symm]
theorem isCycle_swap_mul_aux₂ {α : Type*} [DecidableEq α] :
∀ (n : ℤ) {b x : α} {f : Perm α}, (swap x (f x) * f) b ≠ b → (f ^ n) (f x) = b →
∃ i : ℤ, ((swap x (f x) * f) ^ i) (f x) = b
| (n : ℕ), _, _, _, hb, h => isCycle_swap_mul_aux₁ n hb h
| .negSucc n, b, x, f, hb, h => by
obtain hfxb | hfxb := eq_or_ne (f x) b
· exact ⟨0, hfxb⟩
obtain ⟨hfb, hbx⟩ : f b ≠ b ∧ b ≠ x := ne_and_ne_of_swap_mul_apply_ne_self hb
replace hb : (swap x (f.symm x) * f⁻¹) (f.symm b) ≠ f.symm b := by
rw [mul_apply, swap_apply_def]
split_ifs <;> simp [symm_apply_eq, eq_symm_apply] at * <;> tauto
obtain ⟨i, hi⟩ := isCycle_swap_mul_aux₁ n hb <| by
rw [← mul_apply, ← pow_succ]; simpa [pow_succ', eq_symm_apply] using h
refine ⟨-i, (swap x (f⁻¹ x) * f⁻¹).injective ?_⟩
convert hi using 1
· rw [zpow_neg, ← inv_zpow, ← mul_apply, mul_inv_rev, swap_inv, mul_swap_eq_swap_mul]
simp [swap_comm _ x, ← mul_apply, -coe_mul, ← inv_def, ← inv_def, mul_assoc _ f⁻¹,
← mul_zpow_mul, mul_assoc _ _ f]
simp
· refine swap_apply_of_ne_of_ne ?_ ?_
· simpa [eq_comm, Perm.eq_inv_iff_eq, Perm.inv_eq_iff_eq] using hfxb
· simpa [eq_comm, eq_symm_apply, symm_apply_eq]
theorem IsCycle.eq_swap_of_apply_apply_eq_self {α : Type*} [DecidableEq α] {f : Perm α}
(hf : IsCycle f) {x : α} (hfx : f x ≠ x) (hffx : f (f x) = x) : f = swap x (f x) :=
Equiv.ext fun y =>
let ⟨z, hz⟩ := hf
let ⟨i, hi⟩ := hz.2 hfx
if hyx : y = x then by simp [hyx]
else
if hfyx : y = f x then by simp [hfyx, hffx]
else by
rw [swap_apply_of_ne_of_ne hyx hfyx]
refine by_contradiction fun hy => ?_
obtain ⟨j, hj⟩ := hz.2 hy
rw [← sub_add_cancel j i, zpow_add, mul_apply, hi] at hj
rcases zpow_apply_eq_of_apply_apply_eq_self hffx (j - i) with hji | hji
· rw [← hj, hji] at hyx
tauto
· rw [← hj, hji] at hfyx
tauto
theorem IsCycle.swap_mul {α : Type*} [DecidableEq α] {f : Perm α} (hf : IsCycle f) {x : α}
(hx : f x ≠ x) (hffx : f (f x) ≠ x) : IsCycle (swap x (f x) * f) := by
refine ⟨f x, ?_, fun y hy ↦ ?_⟩
· simp [swap_apply_def, mul_apply, if_neg hffx, f.injective.eq_iff, hx]
obtain ⟨i, rfl⟩ := hf.exists_zpow_eq hx (ne_and_ne_of_swap_mul_apply_ne_self hy).1
exact isCycle_swap_mul_aux₂ (i - 1) hy (by simp [← mul_apply, -coe_mul, ← zpow_add_one])
theorem IsCycle.sign {f : Perm α} (hf : IsCycle f) : sign f = -(-1) ^ #f.support :=
let ⟨x, hx⟩ := hf
calc
Perm.sign f = Perm.sign (swap x (f x) * (swap x (f x) * f)) := by
{rw [← mul_assoc, mul_def, mul_def, swap_swap, trans_refl]}
_ = -(-1) ^ #f.support :=
if h1 : f (f x) = x then by
have h : swap x (f x) * f = 1 := by
simp only [mul_def, one_def]
rw [hf.eq_swap_of_apply_apply_eq_self hx.1 h1, swap_apply_left, swap_swap]
rw [sign_mul, sign_swap hx.1.symm, h, sign_one,
hf.eq_swap_of_apply_apply_eq_self hx.1 h1, card_support_swap hx.1.symm]
rfl
else by
have h : #(swap x (f x) * f).support + 1 = #f.support := by
rw [← insert_erase (mem_support.2 hx.1), support_swap_mul_eq _ _ h1,
card_insert_of_notMem (notMem_erase _ _), sdiff_singleton_eq_erase]
rw [sign_mul, sign_swap hx.1.symm, (hf.swap_mul hx.1 h1).sign, ← h]
simp only [mul_neg, neg_mul, one_mul, neg_neg, pow_add, pow_one, mul_one]
termination_by #f.support
theorem IsCycle.of_pow {n : ℕ} (h1 : IsCycle (f ^ n)) (h2 : f.support ⊆ (f ^ n).support) :
IsCycle f := by
have key : ∀ x : α, (f ^ n) x ≠ x ↔ f x ≠ x := by
simp_rw [← mem_support, ← Finset.ext_iff]
exact (support_pow_le _ n).antisymm h2
obtain ⟨x, hx1, hx2⟩ := h1
refine ⟨x, (key x).mp hx1, fun y hy => ?_⟩
obtain ⟨i, _⟩ := hx2 ((key y).mpr hy)
exact ⟨n * i, by rwa [zpow_mul]⟩
-- The lemma `support_zpow_le` is relevant. It means that `h2` is equivalent to
-- `σ.support = (σ ^ n).support`, as well as to `#σ.support ≤ #(σ ^ n).support`.
theorem IsCycle.of_zpow {n : ℤ} (h1 : IsCycle (f ^ n)) (h2 : f.support ⊆ (f ^ n).support) :
IsCycle f := by
cases n
· exact h1.of_pow h2
· simp only [zpow_negSucc, Perm.support_inv] at h1 h2
exact (inv_inv (f ^ _) ▸ h1.inv).of_pow h2
theorem nodup_of_pairwise_disjoint_cycles {l : List (Perm β)} (h1 : ∀ f ∈ l, IsCycle f)
(h2 : l.Pairwise Disjoint) : l.Nodup :=
nodup_of_pairwise_disjoint (fun h => (h1 1 h).ne_one rfl) h2
/-- Unlike `support_congr`, which assumes that `∀ (x ∈ g.support), f x = g x)`, here
we have the weaker assumption that `∀ (x ∈ f.support), f x = g x`. -/
theorem IsCycle.support_congr (hf : IsCycle f) (hg : IsCycle g) (h : f.support ⊆ g.support)
(h' : ∀ x ∈ f.support, f x = g x) : f = g := by
have : f.support = g.support := by
refine le_antisymm h ?_
intro z hz
obtain ⟨x, hx, _⟩ := id hf
have hx' : g x ≠ x := by rwa [← h' x (mem_support.mpr hx)]
obtain ⟨m, hm⟩ := hg.exists_pow_eq hx' (mem_support.mp hz)
have h'' : ∀ x ∈ f.support ∩ g.support, f x = g x := by
intro x hx
exact h' x (mem_of_mem_inter_left hx)
rwa [← hm, ←
pow_eq_on_of_mem_support h'' _ x
(mem_inter_of_mem (mem_support.mpr hx) (mem_support.mpr hx')),
pow_apply_mem_support, mem_support]
refine Equiv.Perm.support_congr h ?_
simpa [← this] using h'
/-- If two cyclic permutations agree on all terms in their intersection,
and that intersection is not empty, then the two cyclic permutations must be equal. -/
theorem IsCycle.eq_on_support_inter_nonempty_congr (hf : IsCycle f) (hg : IsCycle g)
(h : ∀ x ∈ f.support ∩ g.support, f x = g x)
(hx : f x = g x) (hx' : x ∈ f.support) : f = g := by
have hx'' : x ∈ g.support := by rwa [mem_support, ← hx, ← mem_support]
have : f.support ⊆ g.support := by
intro y hy
obtain ⟨k, rfl⟩ := hf.exists_pow_eq (mem_support.mp hx') (mem_support.mp hy)
rwa [pow_eq_on_of_mem_support h _ _ (mem_inter_of_mem hx' hx''), pow_apply_mem_support]
rw [inter_eq_left.mpr this] at h
exact hf.support_congr hg this h
theorem IsCycle.support_pow_eq_iff (hf : IsCycle f) {n : ℕ} :
support (f ^ n) = support f ↔ ¬orderOf f ∣ n := by
rw [orderOf_dvd_iff_pow_eq_one]
constructor
· intro h H
refine hf.ne_one ?_
rw [← support_eq_empty_iff, ← h, H, support_one]
· intro H
apply le_antisymm (support_pow_le _ n) _
intro x hx
contrapose! H
ext z
by_cases hz : f z = z
· rw [pow_apply_eq_self_of_apply_eq_self hz, one_apply]
· obtain ⟨k, rfl⟩ := hf.exists_pow_eq hz (mem_support.mp hx)
apply (f ^ k).injective
rw [← mul_apply, (Commute.pow_pow_self _ _ _).eq, mul_apply]
simpa using H
theorem IsCycle.support_pow_of_pos_of_lt_orderOf (hf : IsCycle f) {n : ℕ} (npos : 0 < n)
(hn : n < orderOf f) : (f ^ n).support = f.support :=
hf.support_pow_eq_iff.2 <| Nat.not_dvd_of_pos_of_lt npos hn
theorem IsCycle.pow_iff [Finite β] {f : Perm β} (hf : IsCycle f) {n : ℕ} :
IsCycle (f ^ n) ↔ n.Coprime (orderOf f) := by
classical
cases nonempty_fintype β
constructor
· intro h
have hr : support (f ^ n) = support f := by
rw [hf.support_pow_eq_iff]
rintro ⟨k, rfl⟩
refine h.ne_one ?_
simp [pow_mul, pow_orderOf_eq_one]
have : orderOf (f ^ n) = orderOf f := by rw [h.orderOf, hr, hf.orderOf]
rw [orderOf_pow, Nat.div_eq_self] at this
rcases this with h | _
· exact absurd h (orderOf_pos _).ne'
· rwa [Nat.coprime_iff_gcd_eq_one, Nat.gcd_comm]
· intro h
obtain ⟨m, hm⟩ := exists_pow_eq_self_of_coprime h
have hf' : IsCycle ((f ^ n) ^ m) := by rwa [hm]
refine hf'.of_pow fun x hx => ?_
rw [hm]
exact support_pow_le _ n hx
-- TODO: Define a `Set`-valued support to get rid of the `Finite β` assumption
theorem IsCycle.pow_eq_one_iff [Finite β] {f : Perm β} (hf : IsCycle f) {n : ℕ} :
f ^ n = 1 ↔ ∃ x, f x ≠ x ∧ (f ^ n) x = x := by
classical
cases nonempty_fintype β
constructor
· intro h
obtain ⟨x, hx, -⟩ := id hf
exact ⟨x, hx, by simp [h]⟩
· rintro ⟨x, hx, hx'⟩
by_cases h : support (f ^ n) = support f
· rw [← mem_support, ← h, mem_support] at hx
contradiction
· rw [hf.support_pow_eq_iff, Classical.not_not] at h
obtain ⟨k, rfl⟩ := h
rw [pow_mul, pow_orderOf_eq_one, one_pow]
-- TODO: Define a `Set`-valued support to get rid of the `Finite β` assumption
theorem IsCycle.pow_eq_one_iff' [Finite β] {f : Perm β} (hf : IsCycle f) {n : ℕ} {x : β}
(hx : f x ≠ x) : f ^ n = 1 ↔ (f ^ n) x = x :=
⟨fun h => DFunLike.congr_fun h x, fun h => hf.pow_eq_one_iff.2 ⟨x, hx, h⟩⟩
-- TODO: Define a `Set`-valued support to get rid of the `Finite β` assumption
theorem IsCycle.pow_eq_one_iff'' [Finite β] {f : Perm β} (hf : IsCycle f) {n : ℕ} :
f ^ n = 1 ↔ ∀ x, f x ≠ x → (f ^ n) x = x :=
⟨fun h _ hx => (hf.pow_eq_one_iff' hx).1 h, fun h =>
let ⟨_, hx, _⟩ := id hf
(hf.pow_eq_one_iff' hx).2 (h _ hx)⟩
-- TODO: Define a `Set`-valued support to get rid of the `Finite β` assumption
theorem IsCycle.pow_eq_pow_iff [Finite β] {f : Perm β} (hf : IsCycle f) {a b : ℕ} :
f ^ a = f ^ b ↔ ∃ x, f x ≠ x ∧ (f ^ a) x = (f ^ b) x := by
classical
cases nonempty_fintype β
constructor
· intro h
obtain ⟨x, hx, -⟩ := id hf
exact ⟨x, hx, by simp [h]⟩
· rintro ⟨x, hx, hx'⟩
wlog hab : a ≤ b generalizing a b
· exact (this hx'.symm (le_of_not_ge hab)).symm
suffices f ^ (b - a) = 1 by
rw [pow_sub _ hab, mul_inv_eq_one] at this
rw [this]
rw [hf.pow_eq_one_iff]
by_cases hfa : (f ^ a) x ∈ f.support
· refine ⟨(f ^ a) x, mem_support.mp hfa, ?_⟩
simp [pow_sub _ hab, ← hx']
· have h := @Equiv.Perm.zpow_apply_comm _ f 1 a x
simp only [zpow_one, zpow_natCast] at h
rw [notMem_support, h, Function.Injective.eq_iff (f ^ a).injective] at hfa
contradiction
theorem IsCycle.isCycle_pow_pos_of_lt_prime_order [Finite β] {f : Perm β} (hf : IsCycle f)
(hf' : (orderOf f).Prime) (n : ℕ) (hn : 0 < n) (hn' : n < orderOf f) : IsCycle (f ^ n) := by
classical
cases nonempty_fintype β
have : n.Coprime (orderOf f) := by
refine Nat.Coprime.symm ?_
rw [Nat.Prime.coprime_iff_not_dvd hf']
exact Nat.not_dvd_of_pos_of_lt hn hn'
obtain ⟨m, hm⟩ := exists_pow_eq_self_of_coprime this
have hf'' := hf
rw [← hm] at hf''
refine hf''.of_pow ?_
rw [hm]
exact support_pow_le f n
end IsCycle
open Equiv
theorem _root_.Int.addLeft_one_isCycle : (Equiv.addLeft 1 : Perm ℤ).IsCycle :=
⟨0, one_ne_zero, fun n _ => ⟨n, by simp⟩⟩
theorem _root_.Int.addRight_one_isCycle : (Equiv.addRight 1 : Perm ℤ).IsCycle :=
⟨0, one_ne_zero, fun n _ => ⟨n, by simp⟩⟩
section Conjugation
variable [Fintype α] [DecidableEq α] {σ τ : Perm α}
theorem IsCycle.isConj (hσ : IsCycle σ) (hτ : IsCycle τ) (h : #σ.support = #τ.support) :
IsConj σ τ := by
refine
isConj_of_support_equiv
(hσ.zpowersEquivSupport.symm.trans <|
(zpowersEquivZPowers <| by rw [hσ.orderOf, h, hτ.orderOf]).trans hτ.zpowersEquivSupport)
?_
intro x hx
simp only [Equiv.trans_apply]
obtain ⟨n, rfl⟩ := hσ.exists_pow_eq (Classical.choose_spec hσ).1 (mem_support.1 hx)
simp [← Perm.mul_apply, ← pow_succ']
theorem IsCycle.isConj_iff (hσ : IsCycle σ) (hτ : IsCycle τ) :
IsConj σ τ ↔ #σ.support = #τ.support where
mp h := by
obtain ⟨π, rfl⟩ := (_root_.isConj_iff).1 h
exact Finset.card_bij (fun a _ => π a) (fun _ ha => by simpa using ha)
(fun _ _ _ _ ab => π.injective ab) fun b hb ↦ ⟨π⁻¹ b, by simpa using hb, π.apply_symm_apply b⟩
mpr := hσ.isConj hτ
end Conjugation
/-! ### `IsCycleOn` -/
section IsCycleOn
variable {f g : Perm α} {s t : Set α} {a b x y : α}
/-- A permutation is a cycle on `s` when any two points of `s` are related by repeated application
of the permutation. Note that this means the identity is a cycle of subsingleton sets. -/
def IsCycleOn (f : Perm α) (s : Set α) : Prop :=
Set.BijOn f s s ∧ ∀ ⦃x⦄, x ∈ s → ∀ ⦃y⦄, y ∈ s → f.SameCycle x y
@[simp]
theorem isCycleOn_empty : f.IsCycleOn ∅ := by simp [IsCycleOn]
@[simp]
theorem isCycleOn_one : (1 : Perm α).IsCycleOn s ↔ s.Subsingleton := by
simp [IsCycleOn, Set.bijOn_id, Set.Subsingleton]
alias ⟨IsCycleOn.subsingleton, _root_.Set.Subsingleton.isCycleOn_one⟩ := isCycleOn_one
@[simp]
theorem isCycleOn_singleton : f.IsCycleOn {a} ↔ f a = a := by simp [IsCycleOn, SameCycle.rfl]
theorem isCycleOn_of_subsingleton [Subsingleton α] (f : Perm α) (s : Set α) : f.IsCycleOn s :=
⟨s.bijOn_of_subsingleton _, fun x _ y _ => (Subsingleton.elim x y).sameCycle _⟩
@[simp]
theorem isCycleOn_inv : f⁻¹.IsCycleOn s ↔ f.IsCycleOn s := by
simp only [IsCycleOn, sameCycle_inv, and_congr_left_iff]
exact fun _ ↦ ⟨fun h ↦ Set.BijOn.perm_inv h, fun h ↦ Set.BijOn.perm_inv h⟩
alias ⟨IsCycleOn.of_inv, IsCycleOn.inv⟩ := isCycleOn_inv
theorem IsCycleOn.conj (h : f.IsCycleOn s) : (g * f * g⁻¹).IsCycleOn ((g : Perm α) '' s) :=
⟨(g.bijOn_image.comp h.1).comp g.bijOn_symm_image, fun x hx y hy => by
rw [Equiv.image_eq_preimage_symm] at hx hy
convert Equiv.Perm.SameCycle.conj (h.2 hx hy) (g := g) <;> simp⟩
theorem isCycleOn_swap [DecidableEq α] (hab : a ≠ b) : (swap a b).IsCycleOn {a, b} :=
⟨bijOn_swap (by simp) (by simp), fun x hx y hy => by
rw [Set.mem_insert_iff, Set.mem_singleton_iff] at hx hy
obtain rfl | rfl := hx <;> obtain rfl | rfl := hy
· exact ⟨0, by rw [zpow_zero, coe_one, id]⟩
· exact ⟨1, by rw [zpow_one, swap_apply_left]⟩
· exact ⟨1, by rw [zpow_one, swap_apply_right]⟩
· exact ⟨0, by rw [zpow_zero, coe_one, id]⟩⟩
protected theorem IsCycleOn.apply_ne (hf : f.IsCycleOn s) (hs : s.Nontrivial) (ha : a ∈ s) :
f a ≠ a := by
obtain ⟨b, hb, hba⟩ := hs.exists_ne a
obtain ⟨n, rfl⟩ := hf.2 ha hb
exact fun h => hba (IsFixedPt.perm_zpow h n)
protected theorem IsCycle.isCycleOn (hf : f.IsCycle) : f.IsCycleOn { x | f x ≠ x } :=
⟨f.bijOn fun _ => f.apply_eq_iff_eq.not, fun _ ha _ => hf.sameCycle ha⟩
/-- This lemma demonstrates the relation between `Equiv.Perm.IsCycle` and `Equiv.Perm.IsCycleOn`
in non-degenerate cases. -/
theorem isCycle_iff_exists_isCycleOn :
f.IsCycle ↔ ∃ s : Set α, s.Nontrivial ∧ f.IsCycleOn s ∧ ∀ ⦃x⦄, ¬IsFixedPt f x → x ∈ s := by
refine ⟨fun hf => ⟨{ x | f x ≠ x }, ?_, hf.isCycleOn, fun _ => id⟩, ?_⟩
· obtain ⟨a, ha⟩ := hf
exact ⟨f a, f.injective.ne ha.1, a, ha.1, ha.1⟩
· rintro ⟨s, hs, hf, hsf⟩
obtain ⟨a, ha⟩ := hs.nonempty
exact ⟨a, hf.apply_ne hs ha, fun b hb => hf.2 ha <| hsf hb⟩
theorem IsCycleOn.apply_mem_iff (hf : f.IsCycleOn s) : f x ∈ s ↔ x ∈ s :=
⟨fun hx => by simpa using hf.1.perm_inv.1 hx, fun hx => hf.1.mapsTo hx⟩
/-- Note that the identity satisfies `IsCycleOn` for any subsingleton set, but not `IsCycle`. -/
theorem IsCycleOn.isCycle_subtypePerm (hf : f.IsCycleOn s) (hs : s.Nontrivial) :
(f.subtypePerm fun _ => hf.apply_mem_iff : Perm s).IsCycle := by
obtain ⟨a, ha⟩ := hs.nonempty
exact
⟨⟨a, ha⟩, ne_of_apply_ne ((↑) : s → α) (hf.apply_ne hs ha), fun b _ =>
(hf.2 (⟨a, ha⟩ : s).2 b.2).subtypePerm⟩
/-- Note that the identity is a cycle on any subsingleton set, but not a cycle. -/
protected theorem IsCycleOn.subtypePerm (hf : f.IsCycleOn s) :
(f.subtypePerm fun _ => hf.apply_mem_iff : Perm s).IsCycleOn _root_.Set.univ := by
obtain hs | hs := s.subsingleton_or_nontrivial
· haveI := hs.coe_sort
exact isCycleOn_of_subsingleton _ _
convert (hf.isCycle_subtypePerm hs).isCycleOn
rw [eq_comm, Set.eq_univ_iff_forall]
exact fun x => ne_of_apply_ne ((↑) : s → α) (hf.apply_ne hs x.2)
-- TODO: Theory of order of an element under an action
theorem IsCycleOn.pow_apply_eq {s : Finset α} (hf : f.IsCycleOn s) (ha : a ∈ s) {n : ℕ} :
(f ^ n) a = a ↔ #s ∣ n := by
obtain rfl | hs := Finset.eq_singleton_or_nontrivial ha
· rw [coe_singleton, isCycleOn_singleton] at hf
simpa using IsFixedPt.iterate hf n
classical
have h (x : s) : ¬f x = x := hf.apply_ne hs x.2
have := (hf.isCycle_subtypePerm hs).orderOf
simp only [coe_sort_coe, support_subtypePerm, ne_eq, h, not_false_eq_true, univ_eq_attach,
mem_attach, imp_self, implies_true, filter_true_of_mem, card_attach] at this
rw [← this, orderOf_dvd_iff_pow_eq_one,
(hf.isCycle_subtypePerm hs).pow_eq_one_iff'
(ne_of_apply_ne ((↑) : s → α) <| hf.apply_ne hs (⟨a, ha⟩ : s).2)]
simp [-SetLike.coe_sort_coe]
theorem IsCycleOn.zpow_apply_eq {s : Finset α} (hf : f.IsCycleOn s) (ha : a ∈ s) :
∀ {n : ℤ}, (f ^ n) a = a ↔ (#s : ℤ) ∣ n
| Int.ofNat _ => (hf.pow_apply_eq ha).trans Int.natCast_dvd_natCast.symm
| Int.negSucc n => by
rw [zpow_negSucc, ← inv_pow]
exact (hf.inv.pow_apply_eq ha).trans (dvd_neg.trans Int.natCast_dvd_natCast).symm
theorem IsCycleOn.pow_apply_eq_pow_apply {s : Finset α} (hf : f.IsCycleOn s) (ha : a ∈ s)
{m n : ℕ} : (f ^ m) a = (f ^ n) a ↔ m ≡ n [MOD #s] := by
rw [Nat.modEq_iff_dvd, ← hf.zpow_apply_eq ha]
simp [sub_eq_neg_add, zpow_add, eq_inv_iff_eq, eq_comm]
theorem IsCycleOn.zpow_apply_eq_zpow_apply {s : Finset α} (hf : f.IsCycleOn s) (ha : a ∈ s)
{m n : ℤ} : (f ^ m) a = (f ^ n) a ↔ m ≡ n [ZMOD #s] := by
rw [Int.modEq_iff_dvd, ← hf.zpow_apply_eq ha]
simp [sub_eq_neg_add, zpow_add, eq_inv_iff_eq, eq_comm]
theorem IsCycleOn.pow_card_apply {s : Finset α} (hf : f.IsCycleOn s) (ha : a ∈ s) :
(f ^ #s) a = a :=
(hf.pow_apply_eq ha).2 dvd_rfl
theorem IsCycleOn.exists_pow_eq {s : Finset α} (hf : f.IsCycleOn s) (ha : a ∈ s) (hb : b ∈ s) :
∃ n < #s, (f ^ n) a = b := by
classical
obtain ⟨n, rfl⟩ := hf.2 ha hb
obtain ⟨k, hk⟩ := (Int.mod_modEq n #s).symm.dvd
refine ⟨n.natMod #s, Int.natMod_lt (Nonempty.card_pos ⟨a, ha⟩).ne', ?_⟩
rw [← zpow_natCast, Int.natMod,
Int.toNat_of_nonneg (Int.emod_nonneg _ <| Nat.cast_ne_zero.2
(Nonempty.card_pos ⟨a, ha⟩).ne'), sub_eq_iff_eq_add'.1 hk, zpow_add, zpow_mul]
simp only [zpow_natCast, coe_mul, comp_apply, EmbeddingLike.apply_eq_iff_eq]
exact IsFixedPt.perm_zpow (hf.pow_card_apply ha) _
theorem IsCycleOn.exists_pow_eq' (hs : s.Finite) (hf : f.IsCycleOn s) (ha : a ∈ s) (hb : b ∈ s) :
∃ n : ℕ, (f ^ n) a = b := by
lift s to Finset α using hs
obtain ⟨n, -, hn⟩ := hf.exists_pow_eq ha hb
exact ⟨n, hn⟩
theorem IsCycleOn.range_pow (hs : s.Finite) (h : f.IsCycleOn s) (ha : a ∈ s) :
Set.range (fun n => (f ^ n) a : ℕ → α) = s :=
Set.Subset.antisymm (Set.range_subset_iff.2 fun _ => h.1.mapsTo.perm_pow _ ha) fun _ =>
h.exists_pow_eq' hs ha
theorem IsCycleOn.range_zpow (h : f.IsCycleOn s) (ha : a ∈ s) :
Set.range (fun n => (f ^ n) a : ℤ → α) = s :=
Set.Subset.antisymm (Set.range_subset_iff.2 fun _ => (h.1.perm_zpow _).mapsTo ha) <| h.2 ha
theorem IsCycleOn.of_pow {n : ℕ} (hf : (f ^ n).IsCycleOn s) (h : Set.BijOn f s s) : f.IsCycleOn s :=
⟨h, fun _ hx _ hy => (hf.2 hx hy).of_pow⟩
theorem IsCycleOn.of_zpow {n : ℤ} (hf : (f ^ n).IsCycleOn s) (h : Set.BijOn f s s) :
f.IsCycleOn s :=
⟨h, fun _ hx _ hy => (hf.2 hx hy).of_zpow⟩
theorem IsCycleOn.extendDomain {p : β → Prop} [DecidablePred p] (f : α ≃ Subtype p)
(h : g.IsCycleOn s) : (g.extendDomain f).IsCycleOn ((↑) ∘ f '' s) :=
⟨h.1.extendDomain, by
rintro _ ⟨a, ha, rfl⟩ _ ⟨b, hb, rfl⟩
exact (h.2 ha hb).extendDomain⟩
protected theorem IsCycleOn.countable (hs : f.IsCycleOn s) : s.Countable := by
obtain rfl | ⟨a, ha⟩ := s.eq_empty_or_nonempty
· exact Set.countable_empty
· exact (Set.countable_range fun n : ℤ => (⇑(f ^ n) : α → α) a).mono (hs.2 ha)
end IsCycleOn
end Equiv.Perm
namespace List
section
variable [DecidableEq α] {l : List α}
theorem Nodup.isCycleOn_formPerm (h : l.Nodup) :
l.formPerm.IsCycleOn { a | a ∈ l } := by
refine ⟨l.formPerm.bijOn fun _ => List.formPerm_mem_iff_mem, fun a ha b hb => ?_⟩
rw [Set.mem_setOf, ← List.idxOf_lt_length_iff] at ha hb
rw [← List.getElem_idxOf ha, ← List.getElem_idxOf hb]
refine ⟨l.idxOf b - l.idxOf a, ?_⟩
simp only [sub_eq_neg_add, zpow_add, zpow_neg, Equiv.Perm.inv_eq_iff_eq, zpow_natCast,
Equiv.Perm.coe_mul, List.formPerm_pow_apply_getElem _ h, Function.comp]
rw [add_comm]
end
end List
namespace Finset
variable [DecidableEq α] [Fintype α]
theorem exists_cycleOn (s : Finset α) :
∃ f : Perm α, f.IsCycleOn s ∧ f.support ⊆ s := by
refine ⟨s.toList.formPerm, ?_, fun x hx => by
simpa using List.mem_of_formPerm_apply_ne (Perm.mem_support.1 hx)⟩
convert s.nodup_toList.isCycleOn_formPerm
simp
end Finset
namespace Set
variable {f : Perm α} {s : Set α}
theorem Countable.exists_cycleOn (hs : s.Countable) :
∃ f : Perm α, f.IsCycleOn s ∧ { x | f x ≠ x } ⊆ s := by
classical
obtain hs' | hs' := s.finite_or_infinite
· refine ⟨hs'.toFinset.toList.formPerm, ?_, fun x hx => by
simpa using List.mem_of_formPerm_apply_ne hx⟩
convert hs'.toFinset.nodup_toList.isCycleOn_formPerm
simp
· haveI := hs.to_subtype
haveI := hs'.to_subtype
obtain ⟨f⟩ : Nonempty (ℤ ≃ s) := inferInstance
refine ⟨(Equiv.addRight 1).extendDomain f, ?_, fun x hx =>
of_not_not fun h => hx <| Perm.extendDomain_apply_not_subtype _ _ h⟩
convert Int.addRight_one_isCycle.isCycleOn.extendDomain f
rw [Set.image_comp, Equiv.image_eq_preimage_symm]
ext
simp
theorem prod_self_eq_iUnion_perm (hf : f.IsCycleOn s) :
s ×ˢ s = ⋃ n : ℤ, (fun a => (a, (f ^ n) a)) '' s := by
ext ⟨a, b⟩
simp only [Set.mem_prod, Set.mem_iUnion, Set.mem_image]
refine ⟨fun hx => ?_, ?_⟩
· obtain ⟨n, rfl⟩ := hf.2 hx.1 hx.2
exact ⟨_, _, hx.1, rfl⟩
· rintro ⟨n, a, ha, ⟨⟩⟩
exact ⟨ha, (hf.1.perm_zpow _).mapsTo ha⟩
end Set
namespace Finset
variable {f : Perm α} {s : Finset α}
theorem product_self_eq_disjiUnion_perm_aux (hf : f.IsCycleOn s) :
(range #s : Set ℕ).PairwiseDisjoint fun k =>
s.map ⟨fun i => (i, (f ^ k) i), fun _ _ => congr_arg Prod.fst⟩ := by
obtain hs | _ := (s : Set α).subsingleton_or_nontrivial
· refine Set.Subsingleton.pairwise ?_ _
simp_rw [Set.Subsingleton, mem_coe, ← card_le_one] at hs ⊢
rwa [card_range]
classical
rintro m hm n hn hmn
simp only [disjoint_left, Function.onFun, mem_map, Function.Embedding.coeFn_mk,
not_exists, not_and, forall_exists_index, and_imp, Prod.forall, Prod.mk_inj]
rintro _ _ _ - rfl rfl a ha rfl h
rw [hf.pow_apply_eq_pow_apply ha] at h
rw [mem_coe, mem_range] at hm hn
exact hmn.symm (h.eq_of_lt_of_lt hn hm)
/-- We can partition the square `s ×ˢ s` into shifted diagonals as such:
```
01234
40123
34012
23401
12340
```
The diagonals are given by the cycle `f`.
-/
theorem product_self_eq_disjiUnion_perm (hf : f.IsCycleOn s) :
s ×ˢ s =
(range #s).disjiUnion
(fun k => s.map ⟨fun i => (i, (f ^ k) i), fun _ _ => congr_arg Prod.fst⟩)
(product_self_eq_disjiUnion_perm_aux hf) := by
ext ⟨a, b⟩
simp only [mem_product, Equiv.Perm.coe_pow, mem_disjiUnion, mem_range, mem_map,
Function.Embedding.coeFn_mk, Prod.mk_inj]
refine ⟨fun hx => ?_, ?_⟩
· obtain ⟨n, hn, rfl⟩ := hf.exists_pow_eq hx.1 hx.2
exact ⟨n, hn, a, hx.1, rfl, by rw [f.iterate_eq_pow]⟩
· rintro ⟨n, -, a, ha, rfl, rfl⟩
exact ⟨ha, (hf.1.iterate _).mapsTo ha⟩
end Finset
namespace Finset
variable [Semiring α] [AddCommMonoid β] [Module α β] {s : Finset ι} {σ : Perm ι}
theorem sum_smul_sum_eq_sum_perm (hσ : σ.IsCycleOn s) (f : ι → α) (g : ι → β) :
(∑ i ∈ s, f i) • ∑ i ∈ s, g i = ∑ k ∈ range #s, ∑ i ∈ s, f i • g ((σ ^ k) i) := by
rw [sum_smul_sum, ← sum_product']
simp_rw [product_self_eq_disjiUnion_perm hσ, sum_disjiUnion, sum_map, Embedding.coeFn_mk]
theorem sum_mul_sum_eq_sum_perm (hσ : σ.IsCycleOn s) (f g : ι → α) :
((∑ i ∈ s, f i) * ∑ i ∈ s, g i) = ∑ k ∈ range #s, ∑ i ∈ s, f i * g ((σ ^ k) i) :=
sum_smul_sum_eq_sum_perm hσ f g
end Finset
namespace Equiv.Perm
theorem subtypePerm_apply_pow_of_mem {g : Perm α} {s : Finset α}
(hs : ∀ x : α, g x ∈ s ↔ x ∈ s) {n : ℕ} {x : α} (hx : x ∈ s) :
((g.subtypePerm hs ^ n) (⟨x, hx⟩ : s) : α) = (g ^ n) x := by
simp only [subtypePerm_pow, subtypePerm_apply]
theorem subtypePerm_apply_zpow_of_mem {g : Perm α} {s : Finset α}
(hs : ∀ x : α, g x ∈ s ↔ x ∈ s) {i : ℤ} {x : α} (hx : x ∈ s) :
((g.subtypePerm hs ^ i) (⟨x, hx⟩ : s) : α) = (g ^ i) x := by
simp only [subtypePerm_zpow, subtypePerm_apply]
variable [Fintype α] [DecidableEq α]
/-- Restrict a permutation to its support -/
def subtypePermOfSupport (c : Perm α) : Perm c.support :=
subtypePerm c fun _ : α => apply_mem_support
/-- Restrict a permutation to a Finset containing its support -/
def subtypePerm_of_support_le (c : Perm α) {s : Finset α}
(hcs : c.support ⊆ s) : Equiv.Perm s :=
subtypePerm c (isInvariant_of_support_le hcs)
/-- Support of a cycle is nonempty -/
theorem IsCycle.nonempty_support {g : Perm α} (hg : g.IsCycle) :
g.support.Nonempty := by
rw [Finset.nonempty_iff_ne_empty, ne_eq, support_eq_empty_iff]
exact IsCycle.ne_one hg
/-- Centralizer of a cycle is a power of that cycle on the cycle -/
theorem IsCycle.commute_iff' {g c : Perm α} (hc : c.IsCycle) :
Commute g c ↔
∃ hc' : ∀ x : α, g x ∈ c.support ↔ x ∈ c.support,
subtypePerm g hc' ∈ Subgroup.zpowers c.subtypePermOfSupport := by
constructor
· intro hgc
have hgc' := mem_support_iff_of_commute hgc
use hgc'
obtain ⟨a, ha⟩ := IsCycle.nonempty_support hc
obtain ⟨i, hi⟩ := hc.sameCycle (mem_support.mp ha) (mem_support.mp ((hgc' a).mpr ha))
use i
ext ⟨x, hx⟩
simp only [subtypePermOfSupport, Subtype.coe_mk, subtypePerm_apply]
rw [subtypePerm_apply_zpow_of_mem]
obtain ⟨j, rfl⟩ := hc.sameCycle (mem_support.mp ha) (mem_support.mp hx)
simp only [← mul_apply, Commute.eq (Commute.zpow_right hgc j)]
rw [← zpow_add, add_comm i j, zpow_add]
simp only [mul_apply, EmbeddingLike.apply_eq_iff_eq]
exact hi
· rintro ⟨hc', ⟨i, hi⟩⟩
ext x
simp only [coe_mul, Function.comp_apply]
by_cases hx : x ∈ c.support
· suffices hi' : ∀ x ∈ c.support, g x = (c ^ i) x by
rw [hi' x hx, hi' (c x) (apply_mem_support.mpr hx)]
simp only [← mul_apply, ← zpow_add_one, ← zpow_one_add, add_comm]
intro x hx
have hix := Perm.congr_fun hi ⟨x, hx⟩
simp only [← Subtype.coe_inj, subtypePermOfSupport, subtypePerm_apply,
subtypePerm_apply_zpow_of_mem] at hix
exact hix.symm
· rw [notMem_support.mp hx, eq_comm, ← notMem_support]
contrapose! hx
exact (hc' x).mp hx
/-- A permutation `g` commutes with a cycle `c` if and only if
`c.support` is invariant under `g`, and `g` acts on it as a power of `c`. -/
theorem IsCycle.commute_iff {g c : Perm α} (hc : c.IsCycle) :
Commute g c ↔
∃ hc' : ∀ x : α, g x ∈ c.support ↔ x ∈ c.support,
ofSubtype (subtypePerm g hc') ∈ Subgroup.zpowers c := by
simp_rw [hc.commute_iff', Subgroup.mem_zpowers_iff]
refine exists_congr fun hc' => exists_congr fun k => ?_
rw [subtypePermOfSupport, subtypePerm_zpow c k]
simp only [Perm.ext_iff, subtypePerm_apply, Subtype.mk.injEq, Subtype.forall]
apply forall_congr'
intro a
by_cases ha : a ∈ c.support
· rw [imp_iff_right ha, ofSubtype_subtypePerm_of_mem hc' ha]
· rw [iff_true_left (fun b ↦ (ha b).elim), ofSubtype_apply_of_not_mem, ← notMem_support]
· exact Finset.notMem_mono (support_zpow_le c k) ha
· exact ha
theorem zpow_eq_ofSubtype_subtypePerm_iff
{g c : Equiv.Perm α} {s : Finset α}
(hg : ∀ x, g x ∈ s ↔ x ∈ s) (hc : c.support ⊆ s) (n : ℤ) :
c ^ n = ofSubtype (g.subtypePerm hg) ↔
c.subtypePerm (isInvariant_of_support_le hc) ^ n = g.subtypePerm hg := by
constructor
· intro h
ext ⟨x, hx⟩
simp only [Perm.congr_fun h x, subtypePerm_apply_zpow_of_mem, Subtype.coe_mk, subtypePerm_apply]
rw [ofSubtype_apply_of_mem]
· simp only [Subtype.coe_mk, subtypePerm_apply]
· exact hx
· intro h; ext x
rw [← h]
by_cases hx : x ∈ s
· rw [ofSubtype_apply_of_mem (subtypePerm c _ ^ n) hx,
subtypePerm_zpow, subtypePerm_apply]
· rw [ofSubtype_apply_of_not_mem (subtypePerm c _ ^ n) hx,
← notMem_support]
exact fun hx' ↦ hx (hc (support_zpow_le _ _ hx'))
theorem cycle_zpow_mem_support_iff {g : Perm α}
(hg : g.IsCycle) {n : ℤ} {x : α} (hx : g x ≠ x) :
(g ^ n) x = x ↔ n % #g.support = 0 := by
set q := n / #g.support
set r := n % #g.support
have div_euc : r + #g.support * q = n ∧ 0 ≤ r ∧ r < #g.support := by
rw [← Int.ediv_emod_unique _]
· exact ⟨rfl, rfl⟩
simp only [Int.natCast_pos]
apply lt_of_lt_of_le _ (IsCycle.two_le_card_support hg); simp
simp only [← hg.orderOf] at div_euc
obtain ⟨m, hm⟩ := Int.eq_ofNat_of_zero_le div_euc.2.1
simp only [hm, Nat.cast_nonneg, Nat.cast_lt, true_and] at div_euc
rw [← div_euc.1, zpow_add g]
simp only [hm, Nat.cast_eq_zero, zpow_natCast, coe_mul, comp_apply, zpow_mul,
pow_orderOf_eq_one, one_zpow, coe_one, id_eq]
have : (g ^ m) x = x ↔ g ^ m = 1 := by
constructor
· intro hgm
simp only [IsCycle.pow_eq_one_iff hg]
use x
· intro hgm
simp only [hgm, coe_one, id_eq]
rw [this]
by_cases hm0 : m = 0
· simp only [hm0, pow_zero]
· simp only [hm0, iff_false]
exact pow_ne_one_of_lt_orderOf hm0 div_euc.2
end Perm
end Equiv |
.lake/packages/mathlib/Mathlib/GroupTheory/Perm/Cycle/Concrete.lean | import Mathlib.Data.List.Cycle
import Mathlib.GroupTheory.Perm.Cycle.Type
import Mathlib.GroupTheory.Perm.List
/-!
# Properties of cyclic permutations constructed from lists/cycles
In the following, `{α : Type*} [Fintype α] [DecidableEq α]`.
## Main definitions
* `Cycle.formPerm`: the cyclic permutation created by looping over a `Cycle α`
* `Equiv.Perm.toList`: the list formed by iterating application of a permutation
* `Equiv.Perm.toCycle`: the cycle formed by iterating application of a permutation
* `Equiv.Perm.isoCycle`: the equivalence between cyclic permutations `f : Perm α`
and the terms of `Cycle α` that correspond to them
* `Equiv.Perm.isoCycle'`: the same equivalence as `Equiv.Perm.isoCycle`
but with evaluation via choosing over fintypes
* The notation `c[1, 2, 3]` to emulate notation of cyclic permutations `(1 2 3)`
* A `Repr` instance for any `Perm α`, by representing the `Finset` of
`Cycle α` that correspond to the cycle factors.
## Main results
* `List.isCycle_formPerm`: a nontrivial list without duplicates, when interpreted as
a permutation, is cyclic
* `Equiv.Perm.IsCycle.existsUnique_cycle`: there is only one nontrivial `Cycle α`
corresponding to each cyclic `f : Perm α`
## Implementation details
The forward direction of `Equiv.Perm.isoCycle'` uses `Fintype.choose` of the uniqueness
result, relying on the `Fintype` instance of a `Cycle.Nodup` subtype.
It is unclear if this works faster than the `Equiv.Perm.toCycle`, which relies
on recursion over `Finset.univ`.
-/
open Equiv Equiv.Perm List
variable {α : Type*}
namespace List
variable [DecidableEq α] {l l' : List α}
theorem formPerm_disjoint_iff (hl : Nodup l) (hl' : Nodup l') (hn : 2 ≤ l.length)
(hn' : 2 ≤ l'.length) : Perm.Disjoint (formPerm l) (formPerm l') ↔ l.Disjoint l' := by
rw [disjoint_iff_eq_or_eq, List.Disjoint]
constructor
· rintro h x hx hx'
specialize h x
rw [formPerm_apply_mem_eq_self_iff _ hl _ hx, formPerm_apply_mem_eq_self_iff _ hl' _ hx'] at h
cutsat
· intro h x
by_cases hx : x ∈ l
on_goal 1 => by_cases hx' : x ∈ l'
· exact (h hx hx').elim
all_goals have := List.formPerm_apply_of_notMem ‹_›; tauto
theorem isCycle_formPerm (hl : Nodup l) (hn : 2 ≤ l.length) : IsCycle (formPerm l) := by
rcases l with - | ⟨x, l⟩
· norm_num at hn
induction l generalizing x with
| nil => norm_num at hn
| cons y l =>
use x
constructor
· rwa [formPerm_apply_mem_ne_self_iff _ hl _ mem_cons_self]
· intro w hw
have : w ∈ x::y::l := mem_of_formPerm_apply_ne hw
obtain ⟨k, hk, rfl⟩ := getElem_of_mem this
use k
simp only [zpow_natCast, formPerm_pow_apply_head _ _ hl k, Nat.mod_eq_of_lt hk]
theorem pairwise_sameCycle_formPerm (hl : Nodup l) (hn : 2 ≤ l.length) :
Pairwise l.formPerm.SameCycle l :=
Pairwise.imp_mem.mpr
(pairwise_of_forall fun _ _ hx hy =>
(isCycle_formPerm hl hn).sameCycle ((formPerm_apply_mem_ne_self_iff _ hl _ hx).mpr hn)
((formPerm_apply_mem_ne_self_iff _ hl _ hy).mpr hn))
theorem cycleOf_formPerm (hl : Nodup l) (hn : 2 ≤ l.length) (x) :
cycleOf l.attach.formPerm x = l.attach.formPerm :=
have hn : 2 ≤ l.attach.length := by rwa [← length_attach] at hn
have hl : l.attach.Nodup := by rwa [← nodup_attach] at hl
(isCycle_formPerm hl hn).cycleOf_eq
((formPerm_apply_mem_ne_self_iff _ hl _ (mem_attach _ _)).mpr hn)
theorem cycleType_formPerm (hl : Nodup l) (hn : 2 ≤ l.length) :
cycleType l.attach.formPerm = {l.length} := by
rw [← length_attach] at hn
rw [← nodup_attach] at hl
rw [cycleType_eq [l.attach.formPerm]]
· simp only [map, Function.comp_apply]
rw [support_formPerm_of_nodup _ hl, card_toFinset, dedup_eq_self.mpr hl]
· simp
· intro x h
simp [h] at hn
· simp
· simpa using isCycle_formPerm hl hn
· simp
theorem formPerm_apply_mem_eq_next (hl : Nodup l) (x : α) (hx : x ∈ l) :
formPerm l x = next l x hx := by
obtain ⟨k, hk, rfl⟩ := getElem_of_mem hx
rw [next_getElem _ hl, formPerm_apply_getElem _ hl]
end List
namespace Cycle
variable [DecidableEq α] (s : Cycle α)
/-- A cycle `s : Cycle α`, given `Nodup s` can be interpreted as an `Equiv.Perm α`
where each element in the list is permuted to the next one, defined as `formPerm`.
-/
def formPerm : ∀ s : Cycle α, Nodup s → Equiv.Perm α :=
fun s => Quotient.hrecOn s (fun l _ => List.formPerm l) fun l₁ l₂ (h : l₁ ~r l₂) => by
apply Function.hfunext
· ext
exact h.nodup_iff
· intro h₁ h₂ _
exact heq_of_eq (formPerm_eq_of_isRotated h₁ h)
@[simp]
theorem formPerm_coe (l : List α) (hl : l.Nodup) : formPerm (l : Cycle α) hl = l.formPerm :=
rfl
theorem formPerm_subsingleton (s : Cycle α) (h : Subsingleton s) : formPerm s h.nodup = 1 := by
obtain ⟨s⟩ := s
simp only [formPerm_coe, mk_eq_coe]
simp only [length_subsingleton_iff, length_coe, mk_eq_coe] at h
obtain - | ⟨hd, tl⟩ := s
· simp
· simp only [length_eq_zero_iff, add_le_iff_nonpos_left, List.length, nonpos_iff_eq_zero] at h
simp [h]
theorem isCycle_formPerm (s : Cycle α) (h : Nodup s) (hn : Nontrivial s) :
IsCycle (formPerm s h) := by
induction s using Quot.inductionOn
exact List.isCycle_formPerm h (length_nontrivial hn)
theorem support_formPerm [Fintype α] (s : Cycle α) (h : Nodup s) (hn : Nontrivial s) :
support (formPerm s h) = s.toFinset := by
obtain ⟨s⟩ := s
refine support_formPerm_of_nodup s h ?_
rintro _ rfl
simpa [Nat.succ_le_succ_iff] using length_nontrivial hn
theorem formPerm_eq_self_of_notMem (s : Cycle α) (h : Nodup s) (x : α) (hx : x ∉ s) :
formPerm s h x = x := by
induction s using Quot.inductionOn
simpa using List.formPerm_apply_of_notMem hx
@[deprecated (since := "2025-05-23")]
alias formPerm_eq_self_of_not_mem := formPerm_eq_self_of_notMem
theorem formPerm_apply_mem_eq_next (s : Cycle α) (h : Nodup s) (x : α) (hx : x ∈ s) :
formPerm s h x = next s h x hx := by
induction s using Quot.inductionOn
simpa using List.formPerm_apply_mem_eq_next h _ (by simp_all)
nonrec theorem formPerm_reverse (s : Cycle α) (h : Nodup s) :
formPerm s.reverse (nodup_reverse_iff.mpr h) = (formPerm s h)⁻¹ := by
induction s using Quot.inductionOn
simpa using formPerm_reverse _
nonrec theorem formPerm_eq_formPerm_iff {α : Type*} [DecidableEq α] {s s' : Cycle α} {hs : s.Nodup}
{hs' : s'.Nodup} :
s.formPerm hs = s'.formPerm hs' ↔ s = s' ∨ s.Subsingleton ∧ s'.Subsingleton := by
rw [Cycle.length_subsingleton_iff, Cycle.length_subsingleton_iff]
revert s s'
intro s s'
apply @Quotient.inductionOn₂' _ _ _ _ _ s s'
intro l l' hl hl'
simpa using formPerm_eq_formPerm_iff hl hl'
end Cycle
namespace Equiv.Perm
section Fintype
variable [Fintype α] [DecidableEq α] (p : Equiv.Perm α) (x : α)
/-- `Equiv.Perm.toList (f : Perm α) (x : α)` generates the list `[x, f x, f (f x), ...]`
until looping. That means when `f x = x`, `toList f x = []`.
-/
def toList : List α :=
List.iterate p x (cycleOf p x).support.card
@[simp]
theorem toList_one : toList (1 : Perm α) x = [] := by simp [toList, cycleOf_one]
@[simp]
theorem toList_eq_nil_iff {p : Perm α} {x} : toList p x = [] ↔ x ∉ p.support := by simp [toList]
@[simp]
theorem length_toList : length (toList p x) = (cycleOf p x).support.card := by simp [toList]
theorem toList_ne_singleton (y : α) : toList p x ≠ [y] := by
intro H
simpa [card_support_ne_one] using congr_arg length H
theorem two_le_length_toList_iff_mem_support {p : Perm α} {x : α} :
2 ≤ length (toList p x) ↔ x ∈ p.support := by simp
theorem length_toList_pos_of_mem_support (h : x ∈ p.support) : 0 < length (toList p x) :=
zero_lt_two.trans_le (two_le_length_toList_iff_mem_support.mpr h)
theorem getElem_toList (n : ℕ) (hn : n < length (toList p x)) :
(toList p x)[n] = (p ^ n) x := by simp [toList]
theorem toList_getElem_zero (h : x ∈ p.support) :
(toList p x)[0]'(length_toList_pos_of_mem_support _ _ h) = x := by simp [toList]
variable {p} {x}
theorem mem_toList_iff {y : α} : y ∈ toList p x ↔ SameCycle p x y ∧ x ∈ p.support := by
simp only [toList, mem_iterate, iterate_eq_pow, eq_comm (a := y)]
constructor
· rintro ⟨n, hx, rfl⟩
refine ⟨⟨n, rfl⟩, ?_⟩
contrapose! hx
rw [← support_cycleOf_eq_nil_iff] at hx
simp [hx]
· rintro ⟨h, hx⟩
simpa using h.exists_pow_eq_of_mem_support hx
theorem nodup_toList (p : Perm α) (x : α) : Nodup (toList p x) := by
by_cases hx : p x = x
· rw [← notMem_support, ← toList_eq_nil_iff] at hx
simp [hx]
have hc : IsCycle (cycleOf p x) := isCycle_cycleOf p hx
rw [nodup_iff_injective_getElem]
intro ⟨n, hn⟩ ⟨m, hm⟩
rw [length_toList, ← hc.orderOf] at hm hn
rw [← cycleOf_apply_self, ← Ne, ← mem_support] at hx
simp only [Fin.mk.injEq]
rw [getElem_toList, getElem_toList, ← cycleOf_pow_apply_self p x n, ←
cycleOf_pow_apply_self p x m]
rcases n with - | n <;> rcases m with - | m
· simp
· rw [← hc.support_pow_of_pos_of_lt_orderOf m.zero_lt_succ hm, mem_support,
cycleOf_pow_apply_self] at hx
simp [hx.symm]
· rw [← hc.support_pow_of_pos_of_lt_orderOf n.zero_lt_succ hn, mem_support,
cycleOf_pow_apply_self] at hx
simp [hx]
intro h
have hn' : ¬orderOf (p.cycleOf x) ∣ n.succ := Nat.not_dvd_of_pos_of_lt n.zero_lt_succ hn
have hm' : ¬orderOf (p.cycleOf x) ∣ m.succ := Nat.not_dvd_of_pos_of_lt m.zero_lt_succ hm
rw [← hc.support_pow_eq_iff] at hn' hm'
rw [← Nat.mod_eq_of_lt hn, ← Nat.mod_eq_of_lt hm, ← pow_inj_mod]
refine support_congr ?_ ?_
· rw [hm', hn']
· rw [hm']
intro y hy
obtain ⟨k, rfl⟩ := hc.exists_pow_eq (mem_support.mp hx) (mem_support.mp hy)
rw [← mul_apply, (Commute.pow_pow_self _ _ _).eq, mul_apply, h, ← mul_apply, ← mul_apply,
(Commute.pow_pow_self _ _ _).eq]
theorem next_toList_eq_apply (p : Perm α) (x y : α) (hy : y ∈ toList p x) :
next (toList p x) y hy = p y := by
rw [mem_toList_iff] at hy
obtain ⟨k, hk, hk'⟩ := hy.left.exists_pow_eq_of_mem_support hy.right
rw [← getElem_toList p x k (by simpa using hk)] at hk'
simp_rw [← hk']
rw [next_getElem _ (nodup_toList _ _), getElem_toList, getElem_toList, ← mul_apply, ← pow_succ']
simp_rw [length_toList]
rw [← pow_mod_orderOf_cycleOf_apply p (k + 1), IsCycle.orderOf]
exact isCycle_cycleOf _ (mem_support.mp hy.right)
theorem toList_pow_apply_eq_rotate (p : Perm α) (x : α) (k : ℕ) :
p.toList ((p ^ k) x) = (p.toList x).rotate k := by
apply ext_getElem
· simp only [length_toList, cycleOf_self_apply_pow, length_rotate]
· intro n hn hn'
rw [getElem_toList, getElem_rotate, getElem_toList, length_toList,
pow_mod_card_support_cycleOf_self_apply, pow_add, mul_apply]
theorem SameCycle.toList_isRotated {f : Perm α} {x y : α} (h : SameCycle f x y) :
toList f x ~r toList f y := by
by_cases hx : x ∈ f.support
· obtain ⟨_ | k, _, hy⟩ := h.exists_pow_eq_of_mem_support hx
· simp only [coe_one, id, pow_zero] at hy
-- Porting note: added `IsRotated.refl`
simp [hy, IsRotated.refl]
use k.succ
rw [← toList_pow_apply_eq_rotate, hy]
· rw [toList_eq_nil_iff.mpr hx, isRotated_nil_iff', eq_comm, toList_eq_nil_iff]
rwa [← h.mem_support_iff]
theorem pow_apply_mem_toList_iff_mem_support {n : ℕ} : (p ^ n) x ∈ p.toList x ↔ x ∈ p.support := by
rw [mem_toList_iff, and_iff_right_iff_imp]
refine fun _ => SameCycle.symm ?_
rw [sameCycle_pow_left]
theorem toList_formPerm_nil (x : α) : toList (formPerm ([] : List α)) x = [] := by simp
theorem toList_formPerm_singleton (x y : α) : toList (formPerm [x]) y = [] := by simp
theorem toList_formPerm_nontrivial (l : List α) (hl : 2 ≤ l.length) (hn : Nodup l) :
toList (formPerm l) (l.get ⟨0, (zero_lt_two.trans_le hl)⟩) = l := by
have hc : l.formPerm.IsCycle := List.isCycle_formPerm hn hl
have hs : l.formPerm.support = l.toFinset := by
refine support_formPerm_of_nodup _ hn ?_
rintro _ rfl
simp at hl
rw [toList, hc.cycleOf_eq (mem_support.mp _), hs, card_toFinset, dedup_eq_self.mpr hn]
· refine ext_getElem (by simp) fun k hk hk' => ?_
simp only [get_eq_getElem, getElem_iterate, iterate_eq_pow, formPerm_pow_apply_getElem _ hn,
zero_add, Nat.mod_eq_of_lt hk']
· simp [hs]
theorem toList_formPerm_isRotated_self (l : List α) (hl : 2 ≤ l.length) (hn : Nodup l) (x : α)
(hx : x ∈ l) : toList (formPerm l) x ~r l := by
obtain ⟨k, hk, rfl⟩ := get_of_mem hx
have hr : l ~r l.rotate k := ⟨k, rfl⟩
rw [formPerm_eq_of_isRotated hn hr]
rw [get_eq_get_rotate l k k]
simp only [Nat.mod_eq_of_lt k.2, tsub_add_cancel_of_le (le_of_lt k.2), Nat.mod_self]
rw [toList_formPerm_nontrivial]
· simp
· simpa using hl
· simpa using hn
theorem formPerm_toList (f : Perm α) (x : α) : formPerm (toList f x) = f.cycleOf x := by
by_cases hx : f x = x
· rw [(cycleOf_eq_one_iff f).mpr hx, toList_eq_nil_iff.mpr (notMem_support.mpr hx),
formPerm_nil]
ext y
by_cases hy : SameCycle f x y
· obtain ⟨k, _, rfl⟩ := hy.exists_pow_eq_of_mem_support (mem_support.mpr hx)
rw [cycleOf_apply_apply_pow_self, List.formPerm_apply_mem_eq_next (nodup_toList f x),
next_toList_eq_apply, pow_succ', mul_apply]
rw [mem_toList_iff]
exact ⟨⟨k, rfl⟩, mem_support.mpr hx⟩
· rw [cycleOf_apply_of_not_sameCycle hy, formPerm_apply_of_notMem]
simp [mem_toList_iff, hy]
/-- Given a cyclic `f : Perm α`, generate the `Cycle α` in the order
of application of `f`. Implemented by finding an element `x : α`
in the support of `f` in `Finset.univ`, and iterating on using
`Equiv.Perm.toList f x`.
-/
def toCycle (f : Perm α) (hf : IsCycle f) : Cycle α :=
Multiset.recOn (Finset.univ : Finset α).val (Quot.mk _ [])
(fun x _ l => if f x = x then l else toList f x)
(by
intro x y _ s
refine heq_of_eq ?_
split_ifs with hx hy hy <;> try rfl
have hc : SameCycle f x y := IsCycle.sameCycle hf hx hy
exact Quotient.sound' hc.toList_isRotated)
theorem toCycle_eq_toList (f : Perm α) (hf : IsCycle f) (x : α) (hx : f x ≠ x) :
toCycle f hf = toList f x := by
have key : (Finset.univ : Finset α).val = x ::ₘ Finset.univ.val.erase x := by simp
rw [toCycle, key]
simp [hx]
theorem nodup_toCycle (f : Perm α) (hf : IsCycle f) : (toCycle f hf).Nodup := by
obtain ⟨x, hx, -⟩ := id hf
simpa [toCycle_eq_toList f hf x hx] using nodup_toList _ _
theorem nontrivial_toCycle (f : Perm α) (hf : IsCycle f) : (toCycle f hf).Nontrivial := by
obtain ⟨x, hx, -⟩ := id hf
simp [toCycle_eq_toList f hf x hx, hx, Cycle.nontrivial_coe_nodup_iff (nodup_toList _ _)]
/-- Any cyclic `f : Perm α` is isomorphic to the nontrivial `Cycle α`
that corresponds to repeated application of `f`.
The forward direction is implemented by `Equiv.Perm.toCycle`.
-/
def isoCycle : { f : Perm α // IsCycle f } ≃ { s : Cycle α // s.Nodup ∧ s.Nontrivial } where
toFun f := ⟨toCycle (f : Perm α) f.prop, nodup_toCycle (f : Perm α) f.prop,
nontrivial_toCycle _ f.prop⟩
invFun s := ⟨(s : Cycle α).formPerm s.prop.left, (s : Cycle α).isCycle_formPerm _ s.prop.right⟩
left_inv f := by
obtain ⟨x, hx, -⟩ := id f.prop
simpa [toCycle_eq_toList (f : Perm α) f.prop x hx, formPerm_toList, Subtype.ext_iff] using
f.prop.cycleOf_eq hx
right_inv s := by
rcases s with ⟨⟨s⟩, hn, ht⟩
obtain ⟨x, -, -, hx, -⟩ := id ht
have hl : 2 ≤ s.length := by simpa using Cycle.length_nontrivial ht
simp only [Cycle.mk_eq_coe, Cycle.nodup_coe_iff, Cycle.mem_coe_iff,
Cycle.formPerm_coe] at hn hx ⊢
apply Subtype.ext
dsimp
rw [toCycle_eq_toList _ _ x]
· refine Quotient.sound' ?_
exact toList_formPerm_isRotated_self _ hl hn _ hx
· rw [← mem_support, support_formPerm_of_nodup _ hn]
· simpa using hx
· rintro _ rfl
simp at hl
end Fintype
section Finite
variable [Finite α] [DecidableEq α]
theorem IsCycle.existsUnique_cycle {f : Perm α} (hf : IsCycle f) :
∃! s : Cycle α, ∃ h : s.Nodup, s.formPerm h = f := by
cases nonempty_fintype α
obtain ⟨x, hx, hy⟩ := id hf
refine ⟨f.toList x, ⟨nodup_toList f x, ?_⟩, ?_⟩
· simp [formPerm_toList, hf.cycleOf_eq hx]
· rintro ⟨l⟩ ⟨hn, rfl⟩
simp only [Cycle.mk_eq_coe, Cycle.coe_eq_coe, Cycle.formPerm_coe]
refine (toList_formPerm_isRotated_self _ ?_ hn _ ?_).symm
· contrapose! hx
suffices formPerm l = 1 by simp [this]
rw [formPerm_eq_one_iff _ hn]
exact Nat.le_of_lt_succ hx
· rw [← mem_toFinset]
refine support_formPerm_le l ?_
simpa using hx
theorem IsCycle.existsUnique_cycle_subtype {f : Perm α} (hf : IsCycle f) :
∃! s : { s : Cycle α // s.Nodup }, (s : Cycle α).formPerm s.prop = f := by
obtain ⟨s, ⟨hs, rfl⟩, hs'⟩ := hf.existsUnique_cycle
refine ⟨⟨s, hs⟩, rfl, ?_⟩
rintro ⟨t, ht⟩ ht'
simpa using hs' _ ⟨ht, ht'⟩
theorem IsCycle.existsUnique_cycle_nontrivial_subtype {f : Perm α} (hf : IsCycle f) :
∃! s : { s : Cycle α // s.Nodup ∧ s.Nontrivial }, (s : Cycle α).formPerm s.prop.left = f := by
obtain ⟨⟨s, hn⟩, hs, hs'⟩ := hf.existsUnique_cycle_subtype
refine ⟨⟨s, hn, ?_⟩, ?_, ?_⟩
· rw [hn.nontrivial_iff]
subst f
intro H
refine hf.ne_one ?_
simpa using Cycle.formPerm_subsingleton _ H
· simpa using hs
· rintro ⟨t, ht, ht'⟩ ht''
simpa using hs' ⟨t, ht⟩ ht''
end Finite
variable [Fintype α] [DecidableEq α]
/-- Any cyclic `f : Perm α` is isomorphic to the nontrivial `Cycle α`
that corresponds to repeated application of `f`.
The forward direction is implemented by finding this `Cycle α` using `Fintype.choose`.
-/
def isoCycle' : { f : Perm α // IsCycle f } ≃ { s : Cycle α // s.Nodup ∧ s.Nontrivial } :=
let f : { s : Cycle α // s.Nodup ∧ s.Nontrivial } → { f : Perm α // IsCycle f } :=
fun s => ⟨(s : Cycle α).formPerm s.prop.left, (s : Cycle α).isCycle_formPerm _ s.prop.right⟩
{ toFun := Fintype.bijInv (show Function.Bijective f by
rw [Function.bijective_iff_existsUnique]
rintro ⟨f, hf⟩
simp only [Subtype.ext_iff]
exact hf.existsUnique_cycle_nontrivial_subtype)
invFun := f
left_inv := Fintype.rightInverse_bijInv _
right_inv := Fintype.leftInverse_bijInv _ }
-- mutes `'decide' tactic does nothing [linter.unusedTactic]`
set_option linter.unusedTactic false in
@[inherit_doc Cycle.formPerm]
notation3 (prettyPrint := false) "c[" (l", "* => foldr (h t => List.cons h t) List.nil) "]" =>
Cycle.formPerm (Cycle.ofList l) (Iff.mpr Cycle.nodup_coe_iff (by decide))
/-- Represents a permutation as product of disjoint cycles:
```
#eval (c[0, 1, 2, 3] : Perm (Fin 4))
-- c[0, 1, 2, 3]
#eval (c[3, 1] * c[0, 2] : Perm (Fin 4))
-- c[0, 2] * c[1, 3]
#eval (c[1, 2, 3] * c[0, 1, 2] : Perm (Fin 4))
-- c[0, 2] * c[1, 3]
#eval (c[1, 2, 3] * c[0, 1, 2] * c[3, 1] * c[0, 2] : Perm (Fin 4))
-- 1
```
-/
unsafe instance instRepr [Repr α] : Repr (Perm α) where
reprPrec f prec :=
-- Obtain a list of formats which represents disjoint cycles.
letI l := Quot.unquot <| Multiset.map repr <| Multiset.pmap toCycle
(Perm.cycleFactorsFinset f).val
fun _ hg => (mem_cycleFactorsFinset_iff.mp (Finset.mem_def.mpr hg)).left
-- And intercalate `*`s.
match l with
| [] => "1"
| [f] => f
| l =>
-- multiple terms, use `*` precedence
(if prec ≥ 70 then Lean.Format.paren else id)
(Lean.Format.fill
(Lean.Format.joinSep l (" *" ++ Lean.Format.line)))
end Equiv.Perm |
.lake/packages/mathlib/Mathlib/GroupTheory/Perm/Cycle/PossibleTypes.lean | import Mathlib.GroupTheory.Perm.Cycle.Concrete
/-! # Possible cycle types of permutations
* For `m : Multiset ℕ`, `Equiv.Perm.exists_with_cycleType_iff m`
proves that there are permutations with cycleType `m` if and only if
its sum is at most `Fintype.card α` and its members are at least 2.
-/
variable (α : Type*) [DecidableEq α] [Fintype α]
section Ranges
/-- For any `c : List ℕ` whose sum is at most `Fintype.card α`,
we can find `o : List (List α)` whose members have no duplicate,
whose lengths given by `c`, and which are pairwise disjoint -/
theorem List.exists_pw_disjoint_with_card {α : Type*} [Fintype α]
{c : List ℕ} (hc : c.sum ≤ Fintype.card α) :
∃ o : List (List α),
o.map length = c ∧ (∀ s ∈ o, s.Nodup) ∧ Pairwise List.Disjoint o := by
let klift (n : ℕ) (hn : n < Fintype.card α) : Fin (Fintype.card α) :=
(⟨n, hn⟩ : Fin (Fintype.card α))
let klift' (l : List ℕ) (hl : ∀ a ∈ l, a < Fintype.card α) :
List (Fin (Fintype.card α)) := List.pmap klift l hl
have hc'_lt : ∀ l ∈ c.ranges, ∀ n ∈ l, n < Fintype.card α := by
intro l hl n hn
apply lt_of_lt_of_le _ hc
rw [← mem_mem_ranges_iff_lt_sum]
exact ⟨l, hl, hn⟩
let l := (ranges c).pmap klift' hc'_lt
have hl : ∀ (a : List ℕ) (ha : a ∈ c.ranges),
(klift' a (hc'_lt a ha)).map Fin.valEmbedding = a := by
intro a ha
conv_rhs => rw [← List.map_id a]
rw [List.map_pmap]
simp [klift, Fin.valEmbedding_apply, List.pmap_eq_map, List.map_id']
use l.map (List.map (Fintype.equivFin α).symm)
constructor
· -- length
rw [← ranges_length c]
simp only [l, klift', map_pmap, length_pmap,
pmap_eq_map]
constructor
· -- nodup
intro s
rw [mem_map]
rintro ⟨t, ht, rfl⟩
apply Nodup.map (Equiv.injective _)
obtain ⟨u, hu, rfl⟩ := mem_pmap.mp ht
apply Nodup.of_map
rw [hl u hu]
exact ranges_nodup hu
· -- pairwise disjoint
refine Pairwise.map _ (fun s t ↦ disjoint_map (Equiv.injective _)) ?_
-- List.Pairwise List.disjoint l
apply Pairwise.pmap (List.ranges_disjoint c)
intro u hu v hv huv
apply disjoint_pmap
· intro a a' ha ha' h
simpa only [klift, Fin.mk_eq_mk] using h
exact huv
end Ranges
/-- There are permutations with cycleType `m` if and only if
its sum is at most `Fintype.card α` and its members are at least 2. -/
theorem Equiv.Perm.exists_with_cycleType_iff {m : Multiset ℕ} :
(∃ g : Equiv.Perm α, g.cycleType = m) ↔
(m.sum ≤ Fintype.card α ∧ ∀ a ∈ m, 2 ≤ a) := by
constructor
· -- empty case
intro h
obtain ⟨g, hg⟩ := h
constructor
· rw [← hg, Equiv.Perm.sum_cycleType]
exact (Equiv.Perm.support g).card_le_univ
· intro a
rw [← hg]
exact Equiv.Perm.two_le_of_mem_cycleType
· rintro ⟨hc, h2c⟩
have hc' : m.toList.sum ≤ Fintype.card α := by
simp only [Multiset.sum_toList]
exact hc
obtain ⟨p, hp_length, hp_nodup, hp_disj⟩ := List.exists_pw_disjoint_with_card hc'
use List.prod (List.map (fun l => List.formPerm l) p)
have hp2 : ∀ x ∈ p, 2 ≤ x.length := by
intro x hx
apply h2c x.length
rw [← Multiset.mem_toList, ← hp_length, List.mem_map]
exact ⟨x, hx, rfl⟩
rw [Equiv.Perm.cycleType_eq _ rfl]
· -- lengths
rw [← Multiset.coe_toList m]
apply congr_arg
rw [List.map_map]; rw [← hp_length]
apply List.map_congr_left
intro x hx; simp only [Function.comp_apply]
rw [List.support_formPerm_of_nodup x (hp_nodup x hx)]
·-- length
rw [List.toFinset_card_of_nodup (hp_nodup x hx)]
· -- length >= 1
grind
· -- cycles
intro g
rw [List.mem_map]
rintro ⟨x, hx, rfl⟩
have hx_nodup : x.Nodup := hp_nodup x hx
rw [← Cycle.formPerm_coe x hx_nodup]
apply Cycle.isCycle_formPerm
rw [Cycle.nontrivial_coe_nodup_iff hx_nodup]
exact hp2 x hx
· -- disjoint
rw [List.pairwise_map]
apply List.Pairwise.imp_of_mem _ hp_disj
intro a b ha hb hab
rw [List.formPerm_disjoint_iff (hp_nodup a ha) (hp_nodup b hb) (hp2 a ha) (hp2 b hb)]
exact hab |
.lake/packages/mathlib/Mathlib/GroupTheory/Coxeter/Length.lean | import Mathlib.Data.ZMod.Basic
import Mathlib.GroupTheory.Coxeter.Basic
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.Zify
/-!
# The length function, reduced words, and descents
Throughout this file, `B` is a type and `M : CoxeterMatrix B` is a Coxeter matrix.
`cs : CoxeterSystem M W` is a Coxeter system; that is, `W` is a group, and `cs` holds the data
of a group isomorphism `W ≃* M.group`, where `M.group` refers to the quotient of the free group on
`B` by the Coxeter relations given by the matrix `M`. See `Mathlib/GroupTheory/Coxeter/Basic.lean`
for more details.
Given any element $w \in W$, its *length* (`CoxeterSystem.length`), denoted $\ell(w)$, is the
minimum number $\ell$ such that $w$ can be written as a product of a sequence of $\ell$ simple
reflections:
$$w = s_{i_1} \cdots s_{i_\ell}.$$
We prove for all $w_1, w_2 \in W$ that $\ell (w_1 w_2) \leq \ell (w_1) + \ell (w_2)$
and that $\ell (w_1 w_2)$ has the same parity as $\ell (w_1) + \ell (w_2)$.
We define a *reduced word* (`CoxeterSystem.IsReduced`) for an element $w \in W$ to be a way of
writing $w$ as a product of exactly $\ell(w)$ simple reflections. Every element of $W$ has a reduced
word.
We say that $i \in B$ is a *left descent* (`CoxeterSystem.IsLeftDescent`) of $w \in W$ if
$\ell(s_i w) < \ell(w)$. We show that if $i$ is a left descent of $w$, then
$\ell(s_i w) + 1 = \ell(w)$. On the other hand, if $i$ is not a left descent of $w$, then
$\ell(s_i w) = \ell(w) + 1$. We similarly define right descents (`CoxeterSystem.IsRightDescent`) and
prove analogous results.
## Main definitions
* `cs.length`
* `cs.IsReduced`
* `cs.IsLeftDescent`
* `cs.IsRightDescent`
## References
* [A. Björner and F. Brenti, *Combinatorics of Coxeter Groups*](bjorner2005)
-/
assert_not_exists TwoSidedIdeal
namespace CoxeterSystem
open List Matrix Function
variable {B : Type*}
variable {W : Type*} [Group W]
variable {M : CoxeterMatrix B} (cs : CoxeterSystem M W)
local prefix:100 "s " => cs.simple
local prefix:100 "π " => cs.wordProd
/-! ### Length -/
private theorem exists_word_with_prod (w : W) : ∃ n ω, ω.length = n ∧ π ω = w := by
rcases cs.wordProd_surjective w with ⟨ω, rfl⟩
use ω.length, ω
open scoped Classical in
/-- The length of `w`; i.e., the minimum number of simple reflections that
must be multiplied to form `w`. -/
noncomputable def length (w : W) : ℕ := Nat.find (cs.exists_word_with_prod w)
local prefix:100 "ℓ " => cs.length
theorem exists_reduced_word (w : W) : ∃ ω, ω.length = ℓ w ∧ w = π ω := by
classical
have := Nat.find_spec (cs.exists_word_with_prod w)
tauto
open scoped Classical in
theorem length_wordProd_le (ω : List B) : ℓ (π ω) ≤ ω.length :=
Nat.find_min' (cs.exists_word_with_prod (π ω)) ⟨ω, by tauto⟩
@[simp] theorem length_one : ℓ (1 : W) = 0 := Nat.eq_zero_of_le_zero (cs.length_wordProd_le [])
@[simp]
theorem length_eq_zero_iff {w : W} : ℓ w = 0 ↔ w = 1 := by
constructor
· intro h
rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩
have : ω = [] := eq_nil_of_length_eq_zero (hω.trans h)
rw [this, wordProd_nil]
· rintro rfl
exact cs.length_one
@[simp]
theorem length_inv (w : W) : ℓ (w⁻¹) = ℓ w := by
apply Nat.le_antisymm
· rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩
have := cs.length_wordProd_le (List.reverse ω)
rwa [wordProd_reverse, length_reverse, hω] at this
· rcases cs.exists_reduced_word w⁻¹ with ⟨ω, hω, h'ω⟩
have := cs.length_wordProd_le (List.reverse ω)
rwa [wordProd_reverse, length_reverse, ← h'ω, hω, inv_inv] at this
theorem length_mul_le (w₁ w₂ : W) :
ℓ (w₁ * w₂) ≤ ℓ w₁ + ℓ w₂ := by
rcases cs.exists_reduced_word w₁ with ⟨ω₁, hω₁, rfl⟩
rcases cs.exists_reduced_word w₂ with ⟨ω₂, hω₂, rfl⟩
have := cs.length_wordProd_le (ω₁ ++ ω₂)
simpa [hω₁, hω₂, wordProd_append] using this
theorem length_mul_ge_length_sub_length (w₁ w₂ : W) :
ℓ w₁ - ℓ w₂ ≤ ℓ (w₁ * w₂) := by
simpa [Nat.sub_le_of_le_add] using cs.length_mul_le (w₁ * w₂) w₂⁻¹
theorem length_mul_ge_length_sub_length' (w₁ w₂ : W) :
ℓ w₂ - ℓ w₁ ≤ ℓ (w₁ * w₂) := by
simpa [Nat.sub_le_of_le_add, add_comm] using cs.length_mul_le w₁⁻¹ (w₁ * w₂)
theorem length_mul_ge_max (w₁ w₂ : W) :
max (ℓ w₁ - ℓ w₂) (ℓ w₂ - ℓ w₁) ≤ ℓ (w₁ * w₂) :=
max_le_iff.mpr ⟨length_mul_ge_length_sub_length _ _ _, length_mul_ge_length_sub_length' _ _ _⟩
/-- The homomorphism that sends each element `w : W` to the parity of the length of `w`.
(See `lengthParity_eq_ofAdd_length`.) -/
def lengthParity : W →* Multiplicative (ZMod 2) := cs.lift ⟨fun _ ↦ Multiplicative.ofAdd 1, by
simp_rw [CoxeterMatrix.IsLiftable, ← ofAdd_add, (by decide : (1 + 1 : ZMod 2) = 0)]
simp⟩
theorem lengthParity_simple (i : B) :
cs.lengthParity (s i) = Multiplicative.ofAdd 1 := cs.lift_apply_simple _ _
theorem lengthParity_comp_simple :
cs.lengthParity ∘ cs.simple = fun _ ↦ Multiplicative.ofAdd 1 := funext cs.lengthParity_simple
theorem lengthParity_eq_ofAdd_length (w : W) :
cs.lengthParity w = Multiplicative.ofAdd (↑(ℓ w)) := by
rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩
rw [← hω, wordProd, map_list_prod, List.map_map, lengthParity_comp_simple, map_const',
prod_replicate, ← ofAdd_nsmul, nsmul_one]
theorem length_mul_mod_two (w₁ w₂ : W) : ℓ (w₁ * w₂) % 2 = (ℓ w₁ + ℓ w₂) % 2 := by
rw [← ZMod.natCast_eq_natCast_iff', Nat.cast_add]
simpa only [lengthParity_eq_ofAdd_length, ofAdd_add] using map_mul cs.lengthParity w₁ w₂
@[simp]
theorem length_simple (i : B) : ℓ (s i) = 1 := by
apply Nat.le_antisymm
· simpa using cs.length_wordProd_le [i]
· by_contra! length_lt_one
have : cs.lengthParity (s i) = Multiplicative.ofAdd 0 := by
rw [lengthParity_eq_ofAdd_length, Nat.lt_one_iff.mp length_lt_one, Nat.cast_zero]
have : Multiplicative.ofAdd (0 : ZMod 2) = Multiplicative.ofAdd 1 :=
this.symm.trans (cs.lengthParity_simple i)
contradiction
theorem length_eq_one_iff {w : W} : ℓ w = 1 ↔ ∃ i : B, w = s i := by
constructor
· intro h
rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩
rcases List.length_eq_one_iff.mp (hω.trans h) with ⟨i, rfl⟩
exact ⟨i, cs.wordProd_singleton i⟩
· rintro ⟨i, rfl⟩
exact cs.length_simple i
theorem length_mul_simple_ne (w : W) (i : B) : ℓ (w * s i) ≠ ℓ w := by
intro eq
have length_mod_two := cs.length_mul_mod_two w (s i)
rw [eq, length_simple] at length_mod_two
cutsat
theorem length_simple_mul_ne (w : W) (i : B) : ℓ (s i * w) ≠ ℓ w := by
convert cs.length_mul_simple_ne w⁻¹ i using 1
· convert cs.length_inv ?_ using 2
simp
· simp
theorem length_mul_simple (w : W) (i : B) :
ℓ (w * s i) = ℓ w + 1 ∨ ℓ (w * s i) + 1 = ℓ w := by
rcases Nat.lt_or_gt_of_ne (cs.length_mul_simple_ne w i) with lt | gt
· -- lt : ℓ (w * s i) < ℓ w
right
have length_ge := cs.length_mul_ge_length_sub_length w (s i)
simp only [length_simple, tsub_le_iff_right] at length_ge
-- length_ge : ℓ w ≤ ℓ (w * s i) + 1
cutsat
· -- gt : ℓ w < ℓ (w * s i)
left
have length_le := cs.length_mul_le w (s i)
simp only [length_simple] at length_le
-- length_le : ℓ (w * s i) ≤ ℓ w + 1
cutsat
theorem length_simple_mul (w : W) (i : B) :
ℓ (s i * w) = ℓ w + 1 ∨ ℓ (s i * w) + 1 = ℓ w := by
have := cs.length_mul_simple w⁻¹ i
rwa [(by simp : w⁻¹ * (s i) = ((s i) * w)⁻¹), length_inv, length_inv] at this
/-! ### Reduced words -/
/-- The proposition that `ω` is reduced; that is, it has minimal length among all words that
represent the same element of `W`. -/
def IsReduced (ω : List B) : Prop := ℓ (π ω) = ω.length
@[simp]
theorem isReduced_reverse_iff (ω : List B) : cs.IsReduced (ω.reverse) ↔ cs.IsReduced ω := by
simp [IsReduced]
theorem IsReduced.reverse {cs : CoxeterSystem M W} {ω : List B}
(hω : cs.IsReduced ω) : cs.IsReduced (ω.reverse) :=
(cs.isReduced_reverse_iff ω).mpr hω
theorem exists_reduced_word' (w : W) : ∃ ω : List B, cs.IsReduced ω ∧ w = π ω := by
rcases cs.exists_reduced_word w with ⟨ω, hω, rfl⟩
use ω
tauto
private theorem isReduced_take_and_drop {ω : List B} (hω : cs.IsReduced ω) (j : ℕ) :
cs.IsReduced (ω.take j) ∧ cs.IsReduced (ω.drop j) := by
have h₁ : ℓ (π (ω.take j)) ≤ (ω.take j).length := cs.length_wordProd_le (ω.take j)
have h₂ : ℓ (π (ω.drop j)) ≤ (ω.drop j).length := cs.length_wordProd_le (ω.drop j)
have h₃ := calc
(ω.take j).length + (ω.drop j).length
_ = ω.length := by rw [← List.length_append, ω.take_append_drop j]
_ = ℓ (π ω) := hω.symm
_ = ℓ (π (ω.take j) * π (ω.drop j)) := by rw [← cs.wordProd_append, ω.take_append_drop j]
_ ≤ ℓ (π (ω.take j)) + ℓ (π (ω.drop j)) := cs.length_mul_le _ _
unfold IsReduced
cutsat
theorem IsReduced.take {cs : CoxeterSystem M W} {ω : List B} (hω : cs.IsReduced ω) (j : ℕ) :
cs.IsReduced (ω.take j) :=
(isReduced_take_and_drop _ hω _).1
theorem IsReduced.drop {cs : CoxeterSystem M W} {ω : List B} (hω : cs.IsReduced ω) (j : ℕ) :
cs.IsReduced (ω.drop j) :=
(isReduced_take_and_drop _ hω _).2
theorem not_isReduced_alternatingWord (i i' : B) {m : ℕ} (hM : M i i' ≠ 0) (hm : m > M i i') :
¬cs.IsReduced (alternatingWord i i' m) := by
induction hm with
| refl => -- Base case; m = M i i' + 1
suffices h : ℓ (π (alternatingWord i i' (M i i' + 1))) < M i i' + 1 by
unfold IsReduced
rw [Nat.succ_eq_add_one, length_alternatingWord]
cutsat
have : M i i' + 1 ≤ M i i' * 2 := by linarith [Nat.one_le_iff_ne_zero.mpr hM]
rw [cs.prod_alternatingWord_eq_prod_alternatingWord_sub i i' _ this]
have : M i i' * 2 - (M i i' + 1) = M i i' - 1 := by omega
rw [this]
calc
ℓ (π (alternatingWord i' i (M i i' - 1)))
_ ≤ (alternatingWord i' i (M i i' - 1)).length := cs.length_wordProd_le _
_ = M i i' - 1 := length_alternatingWord _ _ _
_ ≤ M i i' := Nat.sub_le _ _
_ < M i i' + 1 := Nat.lt_succ_self _
| step m ih => -- Inductive step
contrapose! ih
rw [alternatingWord_succ'] at ih
apply IsReduced.drop (j := 1) at ih
simpa using ih
/-! ### Descents -/
/-- The proposition that `i` is a left descent of `w`; that is, $\ell(s_i w) < \ell(w)$. -/
def IsLeftDescent (w : W) (i : B) : Prop := ℓ (s i * w) < ℓ w
/-- The proposition that `i` is a right descent of `w`; that is, $\ell(w s_i) < \ell(w)$. -/
def IsRightDescent (w : W) (i : B) : Prop := ℓ (w * s i) < ℓ w
theorem not_isLeftDescent_one (i : B) : ¬cs.IsLeftDescent 1 i := by simp [IsLeftDescent]
theorem not_isRightDescent_one (i : B) : ¬cs.IsRightDescent 1 i := by simp [IsRightDescent]
theorem isLeftDescent_inv_iff {w : W} {i : B} :
cs.IsLeftDescent w⁻¹ i ↔ cs.IsRightDescent w i := by
unfold IsLeftDescent IsRightDescent
nth_rw 1 [← length_inv]
simp
theorem isRightDescent_inv_iff {w : W} {i : B} :
cs.IsRightDescent w⁻¹ i ↔ cs.IsLeftDescent w i := by
simpa using (cs.isLeftDescent_inv_iff (w := w⁻¹)).symm
theorem exists_leftDescent_of_ne_one {w : W} (hw : w ≠ 1) : ∃ i : B, cs.IsLeftDescent w i := by
rcases cs.exists_reduced_word w with ⟨ω, h, rfl⟩
have h₁ : ω ≠ [] := by rintro rfl; simp at hw
rcases List.exists_cons_of_ne_nil h₁ with ⟨i, ω', rfl⟩
use i
rw [IsLeftDescent, ← h, wordProd_cons, simple_mul_simple_cancel_left]
calc
ℓ (π ω') ≤ ω'.length := cs.length_wordProd_le ω'
_ < (i :: ω').length := by simp
theorem exists_rightDescent_of_ne_one {w : W} (hw : w ≠ 1) : ∃ i : B, cs.IsRightDescent w i := by
simp only [← isLeftDescent_inv_iff]
apply exists_leftDescent_of_ne_one
simpa
theorem isLeftDescent_iff {w : W} {i : B} :
cs.IsLeftDescent w i ↔ ℓ (s i * w) + 1 = ℓ w := by
unfold IsLeftDescent
constructor
· intro _
exact (cs.length_simple_mul w i).resolve_left (by cutsat)
· cutsat
theorem not_isLeftDescent_iff {w : W} {i : B} :
¬cs.IsLeftDescent w i ↔ ℓ (s i * w) = ℓ w + 1 := by
unfold IsLeftDescent
constructor
· intro _
exact (cs.length_simple_mul w i).resolve_right (by cutsat)
· cutsat
theorem isRightDescent_iff {w : W} {i : B} :
cs.IsRightDescent w i ↔ ℓ (w * s i) + 1 = ℓ w := by
unfold IsRightDescent
constructor
· intro _
exact (cs.length_mul_simple w i).resolve_left (by cutsat)
· cutsat
theorem not_isRightDescent_iff {w : W} {i : B} :
¬cs.IsRightDescent w i ↔ ℓ (w * s i) = ℓ w + 1 := by
unfold IsRightDescent
constructor
· intro _
exact (cs.length_mul_simple w i).resolve_right (by cutsat)
· cutsat
theorem isLeftDescent_iff_not_isLeftDescent_mul {w : W} {i : B} :
cs.IsLeftDescent w i ↔ ¬cs.IsLeftDescent (s i * w) i := by
rw [isLeftDescent_iff, not_isLeftDescent_iff, simple_mul_simple_cancel_left]
tauto
theorem isRightDescent_iff_not_isRightDescent_mul {w : W} {i : B} :
cs.IsRightDescent w i ↔ ¬cs.IsRightDescent (w * s i) i := by
rw [isRightDescent_iff, not_isRightDescent_iff, simple_mul_simple_cancel_right]
tauto
end CoxeterSystem |
.lake/packages/mathlib/Mathlib/GroupTheory/Coxeter/Matrix.lean | import Mathlib.LinearAlgebra.Matrix.Notation
import Mathlib.LinearAlgebra.Matrix.Symmetric
/-!
# Coxeter matrices
Let us say that a matrix (possibly an infinite matrix) is a *Coxeter matrix* (`CoxeterMatrix`) if
its entries are natural numbers, it is symmetric, its diagonal entries are equal to 1, and its
off-diagonal entries are not equal to 1. In this file, we define Coxeter matrices and provide some
ways of constructing them.
We also define the Coxeter matrices `CoxeterMatrix.Aₙ` (`n : ℕ`), `CoxeterMatrix.Bₙ` (`n : ℕ`),
`CoxeterMatrix.Dₙ` (`n : ℕ`), `CoxeterMatrix.I₂ₘ` (`m : ℕ`), `CoxeterMatrix.E₆`, `CoxeterMatrix.E₇`,
`CoxeterMatrix.E₈`, `CoxeterMatrix.F₄`, `CoxeterMatrix.G₂`, `CoxeterMatrix.H₃`, and
`CoxeterMatrix.H₄`. Up to reindexing, these are exactly the Coxeter matrices whose corresponding
Coxeter group (`CoxeterMatrix.coxeterGroup`) is finite and irreducible, although we do not prove
that in this file.
## Implementation details
In some texts on Coxeter groups, each entry $M_{i,i'}$ of a Coxeter matrix can be either a
positive integer or $\infty$. In our treatment of Coxeter matrices, we use the value $0$ instead of
$\infty$. This will turn out to have some fortunate consequences when defining the Coxeter group of
a Coxeter matrix and the standard geometric representation of a Coxeter group.
## Main definitions
* `CoxeterMatrix` : The type of symmetric matrices of natural numbers, with rows and columns
indexed by a type `B`, whose diagonal entries are equal to 1 and whose off-diagonal entries are
not equal to 1.
* `CoxeterMatrix.reindex` : Reindexes a Coxeter matrix by a bijection on the index type.
* `CoxeterMatrix.Aₙ` : Coxeter matrix for the symmetry group of the regular n-simplex.
* `CoxeterMatrix.Bₙ` : Coxeter matrix for the symmetry group of the regular n-hypercube
and its dual, the regular n-orthoplex (or n-cross-polytope).
* `CoxeterMatrix.Dₙ` : Coxeter matrix for the symmetry group of the n-demicube.
* `CoxeterMatrix.I₂ₘ` : Coxeter matrix for the symmetry group of the regular (m + 2)-gon.
* `CoxeterMatrix.E₆` : Coxeter matrix for the symmetry group of the E₆ root polytope.
* `CoxeterMatrix.E₇` : Coxeter matrix for the symmetry group of the E₇ root polytope.
* `CoxeterMatrix.E₈` : Coxeter matrix for the symmetry group of the E₈ root polytope.
* `CoxeterMatrix.F₄` : Coxeter matrix for the symmetry group of the regular 4-polytope,
the 24-cell.
* `CoxeterMatrix.G₂` : Coxeter matrix for the symmetry group of the regular hexagon.
* `CoxeterMatrix.H₃` : Coxeter matrix for the symmetry group of the regular dodecahedron
and icosahedron.
* `CoxeterMatrix.H₄` : Coxeter matrix for the symmetry group of the regular 4-polytopes,
the 120-cell and 600-cell.
## References
* [N. Bourbaki, *Lie Groups and Lie Algebras, Chapters 4--6*](bourbaki1968) chapter IV
pages 4--5, 13--15
* [J. Baez, *Coxeter and Dynkin Diagrams*](https://math.ucr.edu/home/baez/twf_dynkin.pdf)
-/
/-- A *Coxeter matrix* is a symmetric matrix of natural numbers whose diagonal entries are equal to
1 and whose off-diagonal entries are not equal to 1. -/
@[ext]
structure CoxeterMatrix (B : Type*) where
/-- The underlying matrix of the Coxeter matrix. -/
M : Matrix B B ℕ
isSymm : M.IsSymm := by decide
diagonal i : M i i = 1 := by decide
off_diagonal i i' : i ≠ i' → M i i' ≠ 1 := by decide
namespace CoxeterMatrix
variable {B : Type*}
/-- A Coxeter matrix can be coerced to a matrix. -/
instance : CoeFun (CoxeterMatrix B) fun _ ↦ (Matrix B B ℕ) := ⟨M⟩
variable {B' : Type*} (e : B ≃ B') (M : CoxeterMatrix B)
attribute [simp] diagonal
theorem symmetric (i i' : B) : M i i' = M i' i := M.isSymm.apply i' i
/-- The Coxeter matrix formed by reindexing via the bijection `e : B ≃ B'`. -/
protected def reindex : CoxeterMatrix B' where
M := Matrix.reindex e e M
isSymm := M.isSymm.submatrix _
diagonal i := M.diagonal (e.symm i)
off_diagonal i i' h := M.off_diagonal (e.symm i) (e.symm i') (e.symm.injective.ne h)
theorem reindex_apply (i i' : B') : M.reindex e i i' = M (e.symm i) (e.symm i') := rfl
variable (n : ℕ)
/-- The Coxeter matrix of type Aₙ.
The corresponding Coxeter-Dynkin diagram is:
```
o --- o --- o ⬝ ⬝ ⬝ ⬝ o --- o
```
-/
def Aₙ : CoxeterMatrix (Fin n) where
M := Matrix.of fun i j : Fin n ↦
if i = j then 1
else (if (j : ℕ) + 1 = i ∨ (i : ℕ) + 1 = j then 3 else 2)
isSymm := by unfold Matrix.IsSymm; aesop
diagonal := by simp
off_diagonal := by aesop
/-- The Coxeter matrix of type Bₙ.
The corresponding Coxeter-Dynkin diagram is:
```
4
o --- o --- o ⬝ ⬝ ⬝ ⬝ o --- o
```
-/
def Bₙ : CoxeterMatrix (Fin n) where
M := Matrix.of fun i j : Fin n ↦
if i = j then 1
else (if i = n - 1 ∧ j = n - 2 ∨ j = n - 1 ∧ i = n - 2 then 4
else (if (j : ℕ) + 1 = i ∨ (i : ℕ) + 1 = j then 3 else 2))
isSymm := by unfold Matrix.IsSymm; aesop
diagonal := by simp
off_diagonal := by aesop
/-- The Coxeter matrix of type Dₙ.
The corresponding Coxeter-Dynkin diagram is:
```
o
\
o --- o ⬝ ⬝ ⬝ ⬝ o --- o
/
o
```
-/
def Dₙ : CoxeterMatrix (Fin n) where
M := Matrix.of fun i j : Fin n ↦
if i = j then 1
else (if i = n - 1 ∧ j = n - 3 ∨ j = n - 1 ∧ i = n - 3 then 3
else (if (j : ℕ) + 1 = i ∨ (i : ℕ) + 1 = j then 3 else 2))
isSymm := by unfold Matrix.IsSymm; aesop
diagonal := by simp
off_diagonal := by aesop
/-- The Coxeter matrix of type I₂(m).
The corresponding Coxeter-Dynkin diagram is:
```
m + 2
o --- o
```
-/
def I₂ₘ (m : ℕ) : CoxeterMatrix (Fin 2) where
M := Matrix.of fun i j => if i = j then 1 else m + 2
isSymm := by unfold Matrix.IsSymm; aesop
diagonal := by simp
off_diagonal := by simp
/-- The Coxeter matrix of type E₆.
The corresponding Coxeter-Dynkin diagram is:
```
o
|
o --- o --- o --- o --- o
```
-/
def E₆ : CoxeterMatrix (Fin 6) where
M := !![1, 2, 3, 2, 2, 2;
2, 1, 2, 3, 2, 2;
3, 2, 1, 3, 2, 2;
2, 3, 3, 1, 3, 2;
2, 2, 2, 3, 1, 3;
2, 2, 2, 2, 3, 1]
/-- The Coxeter matrix of type E₇.
The corresponding Coxeter-Dynkin diagram is:
```
o
|
o --- o --- o --- o --- o --- o
```
-/
def E₇ : CoxeterMatrix (Fin 7) where
M := !![1, 2, 3, 2, 2, 2, 2;
2, 1, 2, 3, 2, 2, 2;
3, 2, 1, 3, 2, 2, 2;
2, 3, 3, 1, 3, 2, 2;
2, 2, 2, 3, 1, 3, 2;
2, 2, 2, 2, 3, 1, 3;
2, 2, 2, 2, 2, 3, 1]
/-- The Coxeter matrix of type E₈.
The corresponding Coxeter-Dynkin diagram is:
```
o
|
o --- o --- o --- o --- o --- o --- o
```
-/
def E₈ : CoxeterMatrix (Fin 8) where
M := !![1, 2, 3, 2, 2, 2, 2, 2;
2, 1, 2, 3, 2, 2, 2, 2;
3, 2, 1, 3, 2, 2, 2, 2;
2, 3, 3, 1, 3, 2, 2, 2;
2, 2, 2, 3, 1, 3, 2, 2;
2, 2, 2, 2, 3, 1, 3, 2;
2, 2, 2, 2, 2, 3, 1, 3;
2, 2, 2, 2, 2, 2, 3, 1]
/-- The Coxeter matrix of type F₄.
The corresponding Coxeter-Dynkin diagram is:
```
4
o --- o --- o --- o
```
-/
def F₄ : CoxeterMatrix (Fin 4) where
M := !![1, 3, 2, 2;
3, 1, 4, 2;
2, 4, 1, 3;
2, 2, 3, 1]
/-- The Coxeter matrix of type G₂.
The corresponding Coxeter-Dynkin diagram is:
```
6
o --- o
```
-/
def G₂ : CoxeterMatrix (Fin 2) where
M := !![1, 6;
6, 1]
/-- The Coxeter matrix of type H₃.
The corresponding Coxeter-Dynkin diagram is:
```
5
o --- o --- o
```
-/
def H₃ : CoxeterMatrix (Fin 3) where
M := !![1, 3, 2;
3, 1, 5;
2, 5, 1]
/-- The Coxeter matrix of type H₄.
The corresponding Coxeter-Dynkin diagram is:
```
5
o --- o --- o --- o
```
-/
def H₄ : CoxeterMatrix (Fin 4) where
M := !![1, 3, 2, 2;
3, 1, 3, 2;
2, 3, 1, 5;
2, 2, 5, 1]
end CoxeterMatrix |
.lake/packages/mathlib/Mathlib/GroupTheory/Coxeter/Basic.lean | import Mathlib.Algebra.Group.Subgroup.Pointwise
import Mathlib.Algebra.Ring.Int.Parity
import Mathlib.GroupTheory.Coxeter.Matrix
import Mathlib.GroupTheory.PresentedGroup
import Mathlib.Tactic.NormNum.DivMod
import Mathlib.Tactic.Ring
import Mathlib.Tactic.Use
/-!
# Coxeter groups and Coxeter systems
This file defines Coxeter groups and Coxeter systems.
Let `B` be a (possibly infinite) type, and let $M = (M_{i,i'})_{i, i' \in B}$ be a matrix
of natural numbers. Further assume that $M$ is a *Coxeter matrix* (`CoxeterMatrix`); that is, $M$ is
symmetric and $M_{i,i'} = 1$ if and only if $i = i'$. The *Coxeter group* associated to $M$
(`CoxeterMatrix.Group`) has the presentation
$$\langle \{s_i\}_{i \in B} \vert \{(s_i s_{i'})^{M_{i, i'}}\}_{i, i' \in B} \rangle.$$
The elements $s_i$ are called the *simple reflections* (`CoxeterMatrix.simple`) of the Coxeter
group. Note that every simple reflection is an involution.
A *Coxeter system* (`CoxeterSystem`) is a group $W$, together with an isomorphism between $W$ and
the Coxeter group associated to some Coxeter matrix $M$. By abuse of language, we also say that $W$
is a Coxeter group (`IsCoxeterGroup`), and we may speak of the simple reflections $s_i \in W$
(`CoxeterSystem.simple`). We state all of our results about Coxeter groups in terms of Coxeter
systems where possible.
Let $W$ be a group equipped with a Coxeter system. For all monoids $G$ and all functions
$f \colon B \to G$ whose values satisfy the Coxeter relations, we may lift $f$ to a multiplicative
homomorphism $W \to G$ (`CoxeterSystem.lift`) in a unique way.
A *word* is a sequence of elements of $B$. The word $(i_1, \ldots, i_\ell)$ has a corresponding
product $s_{i_1} \cdots s_{i_\ell} \in W$ (`CoxeterSystem.wordProd`). Every element of $W$ is the
product of some word (`CoxeterSystem.wordProd_surjective`). The words that alternate between two
elements of $B$ (`CoxeterSystem.alternatingWord`) are particularly important.
## Implementation details
Much of the literature on Coxeter groups conflates the set $S = \{s_i : i \in B\} \subseteq W$ of
simple reflections with the set $B$ that indexes the simple reflections. This is usually permissible
because the simple reflections $s_i$ of any Coxeter group are all distinct (a nontrivial fact that
we do not prove in this file). In contrast, we try not to refer to the set $S$ of simple
reflections unless necessary; instead, we state our results in terms of $B$ wherever possible.
## Main definitions
* `CoxeterMatrix.Group`
* `CoxeterSystem`
* `IsCoxeterGroup`
* `CoxeterSystem.simple` : If `cs` is a Coxeter system on the group `W`, then `cs.simple i` is the
simple reflection of `W` at the index `i`.
* `CoxeterSystem.lift` : Extend a function `f : B → G` to a monoid homomorphism `f' : W → G`
satisfying `f' (cs.simple i) = f i` for all `i`.
* `CoxeterSystem.wordProd`
* `CoxeterSystem.alternatingWord`
## References
* [N. Bourbaki, *Lie Groups and Lie Algebras, Chapters 4--6*](bourbaki1968) chapter IV
pages 4--5, 13--15
* [J. Baez, *Coxeter and Dynkin Diagrams*](https://math.ucr.edu/home/baez/twf_dynkin.pdf)
## TODO
* The simple reflections of a Coxeter system are distinct.
* Introduce some ways to actually construct some Coxeter groups. For example, given a Coxeter matrix
$M : B \times B \to \mathbb{N}$, a real vector space $V$, a basis $\{\alpha_i : i \in B\}$
and a bilinear form $\langle \cdot, \cdot \rangle \colon V \times V \to \mathbb{R}$ satisfying
$$\langle \alpha_i, \alpha_{i'}\rangle = - \cos(\pi / M_{i,i'}),$$ one can form the subgroup of
$GL(V)$ generated by the reflections in the $\alpha_i$, and it is a Coxeter group. We can use this
to combinatorially describe the Coxeter groups of type $A$, $B$, $D$, and $I$.
* State and prove Matsumoto's theorem.
* Classify the finite Coxeter groups.
## Tags
coxeter system, coxeter group
-/
open Function Set List
/-! ### Coxeter groups -/
namespace CoxeterMatrix
variable {B B' : Type*} (M : CoxeterMatrix B) (e : B ≃ B')
/-- The Coxeter relation associated to a Coxeter matrix $M$ and two indices $i, i' \in B$.
That is, the relation $(s_i s_{i'})^{M_{i, i'}}$, considered as an element of the free group
on $\{s_i\}_{i \in B}$.
If $M_{i, i'} = 0$, then this is the identity, indicating that there is no relation between
$s_i$ and $s_{i'}$. -/
def relation (i i' : B) : FreeGroup B := (FreeGroup.of i * FreeGroup.of i') ^ M i i'
/-- The set of all Coxeter relations associated to the Coxeter matrix $M$. -/
def relationsSet : Set (FreeGroup B) := range <| uncurry M.relation
/-- The Coxeter group associated to a Coxeter matrix $M$; that is, the group
$$\langle \{s_i\}_{i \in B} \vert \{(s_i s_{i'})^{M_{i, i'}}\}_{i, i' \in B} \rangle.$$ -/
protected def Group : Type _ := PresentedGroup M.relationsSet
instance : Group M.Group := QuotientGroup.Quotient.group _
/-- The simple reflection of the Coxeter group `M.Group` at the index `i`. -/
def simple (i : B) : M.Group := PresentedGroup.of i
theorem reindex_relationsSet :
(M.reindex e).relationsSet =
FreeGroup.freeGroupCongr e '' M.relationsSet := let M' := M.reindex e; calc
Set.range (uncurry M'.relation)
_ = Set.range (uncurry M'.relation ∘ Prod.map e e) := by simp [Set.range_comp]
_ = Set.range (FreeGroup.freeGroupCongr e ∘ uncurry M.relation) := by
apply congrArg Set.range
ext ⟨i, i'⟩
simp [relation, reindex_apply, M']
_ = _ := by simp [Set.range_comp, relationsSet]
/-- The isomorphism between the Coxeter group associated to the reindexed matrix `M.reindex e` and
the Coxeter group associated to `M`. -/
def reindexGroupEquiv : (M.reindex e).Group ≃* M.Group :=
.symm <| QuotientGroup.congr
(Subgroup.normalClosure M.relationsSet)
(Subgroup.normalClosure (M.reindex e).relationsSet)
(FreeGroup.freeGroupCongr e)
(by
rw [reindex_relationsSet,
Subgroup.map_normalClosure _ _ (by simpa using (FreeGroup.freeGroupCongr e).surjective),
MonoidHom.coe_coe])
theorem reindexGroupEquiv_apply_simple (i : B') :
(M.reindexGroupEquiv e) ((M.reindex e).simple i) = M.simple (e.symm i) := rfl
theorem reindexGroupEquiv_symm_apply_simple (i : B) :
(M.reindexGroupEquiv e).symm (M.simple i) = (M.reindex e).simple (e i) := rfl
end CoxeterMatrix
/-! ### Coxeter systems -/
section
variable {B : Type*} (M : CoxeterMatrix B)
/-- A Coxeter system `CoxeterSystem M W` is a structure recording the isomorphism between
a group `W` and the Coxeter group associated to a Coxeter matrix `M`. -/
@[ext]
structure CoxeterSystem (W : Type*) [Group W] where
/-- The isomorphism between `W` and the Coxeter group associated to `M`. -/
mulEquiv : W ≃* M.Group
/-- A group is a Coxeter group if it admits a Coxeter system for some Coxeter matrix `M`. -/
class IsCoxeterGroup.{u} (W : Type u) [Group W] : Prop where
nonempty_system : ∃ B : Type u, ∃ M : CoxeterMatrix B, Nonempty (CoxeterSystem M W)
/-- The canonical Coxeter system on the Coxeter group associated to `M`. -/
def CoxeterMatrix.toCoxeterSystem : CoxeterSystem M M.Group := ⟨.refl _⟩
end
namespace CoxeterSystem
open CoxeterMatrix
variable {B B' : Type*} (e : B ≃ B')
variable {W H : Type*} [Group W] [Group H]
variable {M : CoxeterMatrix B} (cs : CoxeterSystem M W)
/-- Reindex a Coxeter system through a bijection of the indexing sets. -/
@[simps]
protected def reindex (e : B ≃ B') : CoxeterSystem (M.reindex e) W :=
⟨cs.mulEquiv.trans (M.reindexGroupEquiv e).symm⟩
/-- Push a Coxeter system through a group isomorphism. -/
@[simps]
protected def map (e : W ≃* H) : CoxeterSystem M H := ⟨e.symm.trans cs.mulEquiv⟩
/-! ### Simple reflections -/
/-- The simple reflection of `W` at the index `i`. -/
def simple (i : B) : W := cs.mulEquiv.symm (PresentedGroup.of i)
@[simp]
theorem _root_.CoxeterMatrix.toCoxeterSystem_simple (M : CoxeterMatrix B) :
M.toCoxeterSystem.simple = M.simple := rfl
@[simp] theorem reindex_simple (i' : B') : (cs.reindex e).simple i' = cs.simple (e.symm i') := rfl
@[simp] theorem map_simple (e : W ≃* H) (i : B) : (cs.map e).simple i = e (cs.simple i) := rfl
local prefix:100 "s" => cs.simple
@[simp]
theorem simple_mul_simple_self (i : B) : s i * s i = 1 := by
have : (FreeGroup.of i) * (FreeGroup.of i) ∈ M.relationsSet := ⟨(i, i), by simp [relation]⟩
have : (PresentedGroup.mk _ (FreeGroup.of i * FreeGroup.of i) : M.Group) = 1 :=
(QuotientGroup.eq_one_iff _).mpr (Subgroup.subset_normalClosure this)
unfold simple
rw [← map_mul, PresentedGroup.of, map_mul]
exact map_mul_eq_one cs.mulEquiv.symm this
@[simp]
theorem simple_mul_simple_cancel_right {w : W} (i : B) : w * s i * s i = w := by
simp [mul_assoc]
@[simp]
theorem simple_mul_simple_cancel_left {w : W} (i : B) : s i * (s i * w) = w := by
simp [← mul_assoc]
@[simp] theorem simple_sq (i : B) : s i ^ 2 = 1 := pow_two (s i) ▸ cs.simple_mul_simple_self i
@[simp]
theorem inv_simple (i : B) : (s i)⁻¹ = s i :=
(eq_inv_of_mul_eq_one_right (cs.simple_mul_simple_self i)).symm
@[simp]
theorem simple_mul_simple_pow (i i' : B) : (s i * s i') ^ M i i' = 1 := by
have : (FreeGroup.of i * FreeGroup.of i') ^ M i i' ∈ M.relationsSet := ⟨(i, i'), rfl⟩
have : (PresentedGroup.mk _ ((FreeGroup.of i * FreeGroup.of i') ^ M i i') : M.Group) = 1 :=
(QuotientGroup.eq_one_iff _).mpr (Subgroup.subset_normalClosure this)
unfold simple
rw [← map_mul, ← map_pow]
exact (MulEquiv.map_eq_one_iff cs.mulEquiv.symm).mpr this
@[simp] theorem simple_mul_simple_pow' (i i' : B) : (s i' * s i) ^ M i i' = 1 :=
M.symmetric i' i ▸ cs.simple_mul_simple_pow i' i
/-- The simple reflections of `W` generate `W` as a group. -/
theorem subgroup_closure_range_simple : Subgroup.closure (range cs.simple) = ⊤ := by
have : cs.simple = cs.mulEquiv.symm ∘ PresentedGroup.of := rfl
rw [this, Set.range_comp, ← MulEquiv.coe_toMonoidHom, ← MonoidHom.map_closure,
PresentedGroup.closure_range_of, ← MonoidHom.range_eq_map]
exact MonoidHom.range_eq_top.2 (MulEquiv.surjective _)
/-- The simple reflections of `W` generate `W` as a monoid. -/
theorem submonoid_closure_range_simple : Submonoid.closure (range cs.simple) = ⊤ := by
have : range cs.simple = range cs.simple ∪ (range cs.simple)⁻¹ := by
simp_rw [inv_range, inv_simple, union_self]
rw [this, ← Subgroup.closure_toSubmonoid, subgroup_closure_range_simple, Subgroup.top_toSubmonoid]
/-! ### Induction principles for Coxeter systems -/
/-- If `p : W → Prop` holds for all simple reflections, it holds for the identity, and it is
preserved under multiplication, then it holds for all elements of `W`. -/
theorem simple_induction {p : W → Prop} (w : W) (simple : ∀ i : B, p (s i)) (one : p 1)
(mul : ∀ w w' : W, p w → p w' → p (w * w')) : p w := by
have := cs.submonoid_closure_range_simple.symm ▸ Submonoid.mem_top w
exact Submonoid.closure_induction (fun x ⟨i, hi⟩ ↦ hi ▸ simple i) one (fun _ _ _ _ ↦ mul _ _)
this
/-- If `p : W → Prop` holds for the identity and it is preserved under multiplying on the left
by a simple reflection, then it holds for all elements of `W`. -/
theorem simple_induction_left {p : W → Prop} (w : W) (one : p 1)
(mul_simple_left : ∀ (w : W) (i : B), p w → p (s i * w)) : p w := by
let p' : (w : W) → w ∈ Submonoid.closure (Set.range cs.simple) → Prop :=
fun w _ ↦ p w
have := cs.submonoid_closure_range_simple.symm ▸ Submonoid.mem_top w
induction this using Submonoid.closure_induction_left with
| one => exact one
| mul_left i mi y my ih =>
rw [Set.mem_range] at mi
exact mi.choose_spec ▸ mul_simple_left _ _ ih
/-- If `p : W → Prop` holds for the identity and it is preserved under multiplying on the right
by a simple reflection, then it holds for all elements of `W`. -/
theorem simple_induction_right {p : W → Prop} (w : W) (one : p 1)
(mul_simple_right : ∀ (w : W) (i : B), p w → p (w * s i)) : p w := by
let p' : ((w : W) → w ∈ Submonoid.closure (Set.range cs.simple) → Prop) :=
fun w _ ↦ p w
have := cs.submonoid_closure_range_simple.symm ▸ Submonoid.mem_top w
induction this using Submonoid.closure_induction_right with
| one => exact one
| mul_right y my i mi ih =>
rw [Set.mem_range] at mi
exact mi.choose_spec ▸ mul_simple_right _ _ ih
/-! ### Homomorphisms from a Coxeter group -/
/-- If two homomorphisms with domain `W` agree on all simple reflections, then they are equal. -/
theorem ext_simple {G : Type*} [MulOneClass G] {φ₁ φ₂ : W →* G} (h : ∀ i : B, φ₁ (s i) = φ₂ (s i)) :
φ₁ = φ₂ :=
MonoidHom.eq_of_eqOn_denseM cs.submonoid_closure_range_simple (fun _ ⟨i, hi⟩ ↦ hi ▸ h i)
/-- The proposition that the values of the function `f : B → G` satisfy the Coxeter relations
corresponding to the matrix `M`. -/
def _root_.CoxeterMatrix.IsLiftable {G : Type*} [Monoid G] (M : CoxeterMatrix B) (f : B → G) :
Prop := ∀ i i', (f i * f i') ^ M i i' = 1
private theorem relations_liftable {G : Type*} [Group G] {f : B → G} (hf : IsLiftable M f)
(r : FreeGroup B) (hr : r ∈ M.relationsSet) : (FreeGroup.lift f) r = 1 := by
rcases hr with ⟨⟨i, i'⟩, rfl⟩
rw [uncurry, relation, map_pow, map_mul, FreeGroup.lift_apply_of, FreeGroup.lift_apply_of]
exact hf i i'
private def groupLift {G : Type*} [Group G] {f : B → G} (hf : IsLiftable M f) : W →* G :=
(PresentedGroup.toGroup (relations_liftable hf)).comp cs.mulEquiv.toMonoidHom
private def restrictUnit {G : Type*} [Monoid G] {f : B → G} (hf : IsLiftable M f) (i : B) :
Gˣ where
val := f i
inv := f i
val_inv := pow_one (f i * f i) ▸ M.diagonal i ▸ hf i i
inv_val := pow_one (f i * f i) ▸ M.diagonal i ▸ hf i i
private theorem toMonoidHom_apply_symm_apply (a : PresentedGroup (M.relationsSet)) :
(MulEquiv.toMonoidHom cs.mulEquiv : W →* PresentedGroup (M.relationsSet))
((MulEquiv.symm cs.mulEquiv) a) = a := calc
_ = cs.mulEquiv ((MulEquiv.symm cs.mulEquiv) a) := by rfl
_ = _ := by rw [MulEquiv.apply_symm_apply]
/-- The universal mapping property of Coxeter systems. For any monoid `G`,
functions `f : B → G` whose values satisfy the Coxeter relations are equivalent to
monoid homomorphisms `f' : W → G`. -/
def lift {G : Type*} [Monoid G] : {f : B → G // IsLiftable M f} ≃ (W →* G) where
toFun f := MonoidHom.comp (Units.coeHom G) (cs.groupLift
(show ∀ i i', ((restrictUnit f.property) i * (restrictUnit f.property) i') ^ M i i' = 1 from
fun i i' ↦ Units.ext (f.property i i')))
invFun ι := ⟨ι ∘ cs.simple, fun i i' ↦ by
rw [comp_apply, comp_apply, ← map_mul, ← map_pow, simple_mul_simple_pow, map_one]⟩
left_inv f := by
ext i
simp only [MonoidHom.comp_apply, comp_apply, groupLift, simple]
rw [← MonoidHom.toFun_eq_coe, toMonoidHom_apply_symm_apply, PresentedGroup.toGroup.of,
OneHom.toFun_eq_coe, MonoidHom.toOneHom_coe, Units.coeHom_apply, restrictUnit]
right_inv ι := by
apply cs.ext_simple
intro i
dsimp only
rw [groupLift, simple, MonoidHom.comp_apply, MonoidHom.comp_apply, toMonoidHom_apply_symm_apply,
PresentedGroup.toGroup.of, CoxeterSystem.restrictUnit, Units.coeHom_apply]
simp only [comp_apply, simple]
@[simp]
theorem lift_apply_simple {G : Type*} [Monoid G] {f : B → G} (hf : IsLiftable M f) (i : B) :
cs.lift ⟨f, hf⟩ (s i) = f i := congrFun (congrArg Subtype.val (cs.lift.left_inv ⟨f, hf⟩)) i
/-- If two Coxeter systems on the same group `W` have the same Coxeter matrix `M : Matrix B B ℕ`
and the same simple reflection map `B → W`, then they are identical. -/
theorem simple_determines_coxeterSystem :
Injective (simple : CoxeterSystem M W → B → W) := by
intro cs1 cs2 h
apply CoxeterSystem.ext
apply MulEquiv.toMonoidHom_injective
apply cs1.ext_simple
intro i
nth_rw 2 [h]
simp [simple]
/-! ### Words -/
/-- The product of the simple reflections of `W` corresponding to the indices in `ω`. -/
def wordProd (ω : List B) : W := prod (map cs.simple ω)
local prefix:100 "π " => cs.wordProd
@[simp] theorem wordProd_nil : π [] = 1 := by simp [wordProd]
theorem wordProd_cons (i : B) (ω : List B) : π (i :: ω) = s i * π ω := by simp [wordProd]
@[simp] theorem wordProd_singleton (i : B) : π ([i]) = s i := by simp [wordProd]
theorem wordProd_concat (i : B) (ω : List B) : π (ω.concat i) = π ω * s i := by simp [wordProd]
theorem wordProd_append (ω ω' : List B) : π (ω ++ ω') = π ω * π ω' := by simp [wordProd]
@[simp] theorem wordProd_reverse (ω : List B) : π (reverse ω) = (π ω)⁻¹ := by
induction ω with
| nil => simp
| cons x ω' ih => simpa [wordProd_cons, wordProd_append] using ih
theorem wordProd_surjective : Surjective cs.wordProd := by
intro w
apply cs.simple_induction_left w
· use []
rw [wordProd_nil]
· rintro _ i ⟨ω, rfl⟩
use i :: ω
rw [wordProd_cons]
/-- The word of length `m` that alternates between `i` and `i'`, ending with `i'`. -/
def alternatingWord (i i' : B) (m : ℕ) : List B :=
match m with
| 0 => []
| m + 1 => (alternatingWord i' i m).concat i'
/-- The word of length `M i i'` that alternates between `i` and `i'`, ending with `i'`. -/
abbrev braidWord (M : CoxeterMatrix B) (i i' : B) : List B := alternatingWord i i' (M i i')
theorem alternatingWord_succ (i i' : B) (m : ℕ) :
alternatingWord i i' (m + 1) = (alternatingWord i' i m).concat i' := rfl
theorem alternatingWord_succ' (i i' : B) (m : ℕ) :
alternatingWord i i' (m + 1) = (if Even m then i' else i) :: alternatingWord i i' m := by
induction m generalizing i i' with
| zero => simp [alternatingWord]
| succ m ih =>
rw [alternatingWord]
nth_rw 1 [ih i' i]
rw [alternatingWord]
simp [Nat.even_add_one, -Nat.not_even_iff_odd]
@[simp]
theorem length_alternatingWord (i i' : B) (m : ℕ) :
List.length (alternatingWord i i' m) = m := by
induction m generalizing i i' with
| zero => dsimp [alternatingWord]
| succ m ih => simpa [alternatingWord] using ih i' i
lemma getElem_alternatingWord (i j : B) (p k : ℕ) (hk : k < p) :
(alternatingWord i j p)[k]'(by simp [hk]) = (if Even (p + k) then i else j) := by
revert k
induction p with
| zero => grind [not_lt_zero']
| succ n h => grind [CoxeterSystem.alternatingWord_succ']
lemma getElem_alternatingWord_swapIndices (i j : B) (p k : ℕ) (h : k + 1 < p) :
(alternatingWord i j p)[k + 1]'(by simp [h]) =
(alternatingWord j i p)[k]'(by simp; cutsat) := by
rw [getElem_alternatingWord i j p (k + 1) (by cutsat),
getElem_alternatingWord j i p k (by cutsat)]
by_cases h_even : Even (p + k)
· rw [if_pos h_even, ← add_assoc]
simp only [ite_eq_right_iff, isEmpty_Prop, Nat.not_even_iff_odd, Even.add_one h_even,
IsEmpty.forall_iff]
· rw [if_neg h_even, ← add_assoc]
simp [Odd.add_one (Nat.not_even_iff_odd.mp h_even)]
lemma listTake_alternatingWord (i j : B) (p k : ℕ) (h : k < 2 * p) :
List.take k (alternatingWord i j (2 * p)) =
if Even k then alternatingWord i j k else alternatingWord j i k := by
induction k with
| zero =>
simp only [take_zero, Even.zero, ↓reduceIte, alternatingWord]
| succ k h' =>
have hk : k < 2 * p := by omega
apply h' at hk
by_cases h_even : Even k
· simp only [h_even, ↓reduceIte] at hk
simp only [Nat.not_even_iff_odd.mpr (Even.add_one h_even), ↓reduceIte]
rw [← List.take_concat_get (by simp; cutsat), alternatingWord_succ, ← hk]
apply congr_arg
rw [getElem_alternatingWord i j (2*p) k (by cutsat)]
simp [(by apply Nat.even_add.mpr; simp [h_even] : Even (2 * p + k))]
· simp only [h_even, ↓reduceIte] at hk
simp only [(by simp at h_even; exact Odd.add_one h_even : Even (k + 1)), ↓reduceIte]
rw [← List.take_concat_get (by simp; cutsat), alternatingWord_succ, hk]
apply congr_arg
rw [getElem_alternatingWord i j (2*p) k (by cutsat)]
simp [(by apply Nat.odd_add.mpr; simp [h_even] : Odd (2 * p + k))]
lemma listTake_succ_alternatingWord (i j : B) (p : ℕ) (k : ℕ) (h : k + 1 < 2 * p) :
List.take (k + 1) (alternatingWord i j (2 * p)) =
i :: (List.take k (alternatingWord j i (2 * p))) := by
rw [listTake_alternatingWord j i p k (by cutsat), listTake_alternatingWord i j p (k + 1) h]
by_cases h_even : Even k
· simp [Nat.not_even_iff_odd.mpr (Even.add_one h_even), alternatingWord_succ', h_even]
· simp [(by rw [Nat.not_even_iff_odd] at h_even; exact Odd.add_one h_even : Even (k + 1)),
alternatingWord_succ', h_even]
theorem prod_alternatingWord_eq_mul_pow (i i' : B) (m : ℕ) :
π (alternatingWord i i' m) = (if Even m then 1 else s i') * (s i * s i') ^ (m / 2) := by
induction m with
| zero => simp [alternatingWord]
| succ m ih =>
rw [alternatingWord_succ', wordProd_cons, ih]
by_cases hm : Even m
· have h₁ : ¬ Even (m + 1) := by simp [hm, parity_simps]
have h₂ : (m + 1) / 2 = m / 2 := Nat.succ_div_of_not_dvd <| by rwa [← even_iff_two_dvd]
simp [hm, h₁, h₂]
· have h₁ : Even (m + 1) := by simp [hm, parity_simps]
have h₂ : (m + 1) / 2 = m / 2 + 1 := Nat.succ_div_of_dvd h₁.two_dvd
simp [hm, h₁, h₂, ← pow_succ', ← mul_assoc]
theorem prod_alternatingWord_eq_prod_alternatingWord_sub (i i' : B) (m : ℕ) (hm : m ≤ M i i' * 2) :
π (alternatingWord i i' m) = π (alternatingWord i' i (M i i' * 2 - m)) := by
simp_rw [prod_alternatingWord_eq_mul_pow, ← Int.even_coe_nat]
/- Rewrite everything in terms of an integer m' which is equal to m.
The resulting equation holds for all integers m'. -/
simp_rw [← zpow_natCast, Int.natCast_ediv, Int.ofNat_sub hm]
generalize (m : ℤ) = m'
clear hm
push_cast
rcases Int.even_or_odd' m' with ⟨k, rfl | rfl⟩
· rw [if_pos (by use k; ring), if_pos (by use -k + (M i i'); ring), mul_comm 2 k, ← sub_mul]
repeat rw [Int.mul_ediv_cancel _ (by simp)]
rw [zpow_sub, zpow_natCast, simple_mul_simple_pow' cs i i', ← inv_zpow]
simp
· have : ¬Even (2 * k + 1) := Int.not_even_iff_odd.2 ⟨k, rfl⟩
rw [if_neg this]
have : ¬Even (↑(M i i') * 2 - (2 * k + 1)) :=
Int.not_even_iff_odd.2 ⟨↑(M i i') - k - 1, by ring⟩
rw [if_neg this]
rw [(by ring : ↑(M i i') * 2 - (2 * k + 1) = -1 + (-k + ↑(M i i')) * 2),
(by ring : 2 * k + 1 = 1 + k * 2)]
repeat rw [Int.add_mul_ediv_right _ _ (by simp)]
norm_num
rw [zpow_add, zpow_add, zpow_natCast, simple_mul_simple_pow', zpow_neg, ← inv_zpow, zpow_neg,
← inv_zpow]
simp [← mul_assoc]
/-- The two words of length `M i i'` that alternate between `i` and `i'` have the same product.
This is known as the "braid relation" or "Artin-Tits relation". -/
theorem wordProd_braidWord_eq (i i' : B) :
π (braidWord M i i') = π (braidWord M i' i) := by
have := cs.prod_alternatingWord_eq_prod_alternatingWord_sub i i' (M i i')
(Nat.le_mul_of_pos_right _ (by simp))
rw [tsub_eq_of_eq_add (mul_two (M i i'))] at this
nth_rw 2 [M.symmetric i i'] at this
exact this
end CoxeterSystem |
.lake/packages/mathlib/Mathlib/GroupTheory/Coxeter/Inversion.lean | import Mathlib.GroupTheory.Coxeter.Length
import Mathlib.Data.List.GetD
import Mathlib.Tactic.Group
/-!
# Reflections, inversions, and inversion sequences
Throughout this file, `B` is a type and `M : CoxeterMatrix B` is a Coxeter matrix.
`cs : CoxeterSystem M W` is a Coxeter system; that is, `W` is a group, and `cs` holds the data
of a group isomorphism `W ≃* M.group`, where `M.group` refers to the quotient of the free group on
`B` by the Coxeter relations given by the matrix `M`. See `Mathlib/GroupTheory/Coxeter/Basic.lean`
for more details.
We define a *reflection* (`CoxeterSystem.IsReflection`) to be an element of the form
$t = u s_i u^{-1}$, where $u \in W$ and $s_i$ is a simple reflection. We say that a reflection $t$
is a *left inversion* (`CoxeterSystem.IsLeftInversion`) of an element $w \in W$ if
$\ell(t w) < \ell(w)$, and we say it is a *right inversion* (`CoxeterSystem.IsRightInversion`) of
$w$ if $\ell(w t) > \ell(w)$. Here $\ell$ is the length function
(see `Mathlib/GroupTheory/Coxeter/Length.lean`).
Given a word, we define its *left inversion sequence* (`CoxeterSystem.leftInvSeq`) and its
*right inversion sequence* (`CoxeterSystem.rightInvSeq`). We prove that if a word is reduced, then
both of its inversion sequences contain no duplicates. In fact, the right (respectively, left)
inversion sequence of a reduced word for $w$ consists of all of the right (respectively, left)
inversions of $w$ in some order, but we do not prove that in this file.
## Main definitions
* `CoxeterSystem.IsReflection`
* `CoxeterSystem.IsLeftInversion`
* `CoxeterSystem.IsRightInversion`
* `CoxeterSystem.leftInvSeq`
* `CoxeterSystem.rightInvSeq`
## References
* [A. Björner and F. Brenti, *Combinatorics of Coxeter Groups*](bjorner2005)
-/
assert_not_exists TwoSidedIdeal
namespace CoxeterSystem
open List Matrix Function
variable {B : Type*}
variable {W : Type*} [Group W]
variable {M : CoxeterMatrix B} (cs : CoxeterSystem M W)
local prefix:100 "s " => cs.simple
local prefix:100 "π " => cs.wordProd
local prefix:100 "ℓ " => cs.length
/-- `t : W` is a *reflection* of the Coxeter system `cs` if it is of the form
$w s_i w^{-1}$, where $w \in W$ and $s_i$ is a simple reflection. -/
def IsReflection (t : W) : Prop := ∃ w i, t = w * s i * w⁻¹
theorem isReflection_simple (i : B) : cs.IsReflection (s i) := by use 1, i; simp
namespace IsReflection
variable {cs}
variable {t : W} (ht : cs.IsReflection t)
include ht
theorem pow_two : t ^ 2 = 1 := by
rcases ht with ⟨w, i, rfl⟩
simp
theorem mul_self : t * t = 1 := by
rcases ht with ⟨w, i, rfl⟩
simp
theorem inv : t⁻¹ = t := by
rcases ht with ⟨w, i, rfl⟩
simp [mul_assoc]
theorem isReflection_inv : cs.IsReflection t⁻¹ := by rwa [ht.inv]
theorem odd_length : Odd (ℓ t) := by
suffices cs.lengthParity t = Multiplicative.ofAdd 1 by
simpa [lengthParity_eq_ofAdd_length, ZMod.natCast_eq_one_iff_odd]
rcases ht with ⟨w, i, rfl⟩
simp [lengthParity_simple]
theorem length_mul_left_ne (w : W) : ℓ (w * t) ≠ ℓ w := by
suffices cs.lengthParity (w * t) ≠ cs.lengthParity w by
contrapose! this
simp only [lengthParity_eq_ofAdd_length, this]
rcases ht with ⟨w, i, rfl⟩
simp [lengthParity_simple]
theorem length_mul_right_ne (w : W) : ℓ (t * w) ≠ ℓ w := by
suffices cs.lengthParity (t * w) ≠ cs.lengthParity w by
contrapose! this
simp only [lengthParity_eq_ofAdd_length, this]
rcases ht with ⟨w, i, rfl⟩
simp [lengthParity_simple]
theorem conj (w : W) : cs.IsReflection (w * t * w⁻¹) := by
obtain ⟨u, i, rfl⟩ := ht
use w * u, i
group
end IsReflection
@[simp]
theorem isReflection_conj_iff (w t : W) :
cs.IsReflection (w * t * w⁻¹) ↔ cs.IsReflection t := by
constructor
· intro h
simpa [← mul_assoc] using h.conj w⁻¹
· exact IsReflection.conj (w := w)
/-- The proposition that `t` is a right inversion of `w`; i.e., `t` is a reflection and
$\ell (w t) < \ell(w)$. -/
def IsRightInversion (w t : W) : Prop := cs.IsReflection t ∧ ℓ (w * t) < ℓ w
/-- The proposition that `t` is a left inversion of `w`; i.e., `t` is a reflection and
$\ell (t w) < \ell(w)$. -/
def IsLeftInversion (w t : W) : Prop := cs.IsReflection t ∧ ℓ (t * w) < ℓ w
theorem isRightInversion_inv_iff {w t : W} :
cs.IsRightInversion w⁻¹ t ↔ cs.IsLeftInversion w t := by
apply and_congr_right
intro ht
rw [← length_inv, mul_inv_rev, inv_inv, ht.inv, cs.length_inv w]
theorem isLeftInversion_inv_iff {w t : W} :
cs.IsLeftInversion w⁻¹ t ↔ cs.IsRightInversion w t := by
convert cs.isRightInversion_inv_iff.symm
simp
namespace IsReflection
variable {cs}
variable {t : W} (ht : cs.IsReflection t)
include ht
theorem isRightInversion_mul_left_iff {w : W} :
cs.IsRightInversion (w * t) t ↔ ¬cs.IsRightInversion w t := by
unfold IsRightInversion
simp only [mul_assoc, ht.mul_self, mul_one, ht, true_and, not_lt]
constructor
· exact le_of_lt
· exact (lt_of_le_of_ne' · (ht.length_mul_left_ne w))
theorem not_isRightInversion_mul_left_iff {w : W} :
¬cs.IsRightInversion (w * t) t ↔ cs.IsRightInversion w t :=
ht.isRightInversion_mul_left_iff.not_left
theorem isLeftInversion_mul_right_iff {w : W} :
cs.IsLeftInversion (t * w) t ↔ ¬cs.IsLeftInversion w t := by
rw [← isRightInversion_inv_iff, ← isRightInversion_inv_iff, mul_inv_rev, ht.inv,
ht.isRightInversion_mul_left_iff]
theorem not_isLeftInversion_mul_right_iff {w : W} :
¬cs.IsLeftInversion (t * w) t ↔ cs.IsLeftInversion w t :=
ht.isLeftInversion_mul_right_iff.not_left
end IsReflection
@[simp]
theorem isRightInversion_simple_iff_isRightDescent (w : W) (i : B) :
cs.IsRightInversion w (s i) ↔ cs.IsRightDescent w i := by
simp [IsRightInversion, IsRightDescent, cs.isReflection_simple i]
@[simp]
theorem isLeftInversion_simple_iff_isLeftDescent (w : W) (i : B) :
cs.IsLeftInversion w (s i) ↔ cs.IsLeftDescent w i := by
simp [IsLeftInversion, IsLeftDescent, cs.isReflection_simple i]
/-- The right inversion sequence of `ω`. The right inversion sequence of a word
$s_{i_1} \cdots s_{i_\ell}$ is the sequence
$$s_{i_\ell}\cdots s_{i_1}\cdots s_{i_\ell}, \ldots,
s_{i_{\ell}}s_{i_{\ell - 1}}s_{i_{\ell - 2}}s_{i_{\ell - 1}}s_{i_\ell}, \ldots,
s_{i_{\ell}}s_{i_{\ell - 1}}s_{i_\ell}, s_{i_\ell}.$$
-/
def rightInvSeq (ω : List B) : List W :=
match ω with
| [] => []
| i :: ω => (π ω)⁻¹ * (s i) * (π ω) :: rightInvSeq ω
/-- The left inversion sequence of `ω`. The left inversion sequence of a word
$s_{i_1} \cdots s_{i_\ell}$ is the sequence
$$s_{i_1}, s_{i_1}s_{i_2}s_{i_1}, s_{i_1}s_{i_2}s_{i_3}s_{i_2}s_{i_1}, \ldots,
s_{i_1}\cdots s_{i_\ell}\cdots s_{i_1}.$$
-/
def leftInvSeq (ω : List B) : List W :=
match ω with
| [] => []
| i :: ω => s i :: List.map (MulAut.conj (s i)) (leftInvSeq ω)
local prefix:100 "ris " => cs.rightInvSeq
local prefix:100 "lis " => cs.leftInvSeq
@[simp] theorem rightInvSeq_nil : ris [] = [] := rfl
@[simp] theorem leftInvSeq_nil : lis [] = [] := rfl
@[simp] theorem rightInvSeq_singleton (i : B) : ris [i] = [s i] := by simp [rightInvSeq]
@[simp] theorem leftInvSeq_singleton (i : B) : lis [i] = [s i] := rfl
theorem rightInvSeq_concat (ω : List B) (i : B) :
ris (ω.concat i) = (List.map (MulAut.conj (s i)) (ris ω)).concat (s i) := by
induction ω with
| nil => simp
| cons j ω ih =>
dsimp [rightInvSeq, concat]
rw [ih]
simp only [concat_eq_append, wordProd_append, wordProd_cons, wordProd_nil, mul_one, mul_inv_rev,
inv_simple, cons.injEq, and_true]
group
private theorem leftInvSeq_eq_reverse_rightInvSeq_reverse (ω : List B) :
lis ω = (ris ω.reverse).reverse := by
induction ω with
| nil => simp
| cons i ω ih =>
rw [leftInvSeq, reverse_cons, ← concat_eq_append, rightInvSeq_concat, ih]
simp [map_reverse]
theorem leftInvSeq_concat (ω : List B) (i : B) :
lis (ω.concat i) = (lis ω).concat ((π ω) * (s i) * (π ω)⁻¹) := by
simp [leftInvSeq_eq_reverse_rightInvSeq_reverse, rightInvSeq]
theorem rightInvSeq_reverse (ω : List B) :
ris (ω.reverse) = (lis ω).reverse := by
simp [leftInvSeq_eq_reverse_rightInvSeq_reverse]
theorem leftInvSeq_reverse (ω : List B) :
lis (ω.reverse) = (ris ω).reverse := by
simp [leftInvSeq_eq_reverse_rightInvSeq_reverse]
@[simp] theorem length_rightInvSeq (ω : List B) : (ris ω).length = ω.length := by
induction ω with
| nil => simp
| cons i ω ih => simpa [rightInvSeq]
@[simp] theorem length_leftInvSeq (ω : List B) : (lis ω).length = ω.length := by
simp [leftInvSeq_eq_reverse_rightInvSeq_reverse]
theorem getD_rightInvSeq (ω : List B) (j : ℕ) :
(ris ω).getD j 1 =
(π (ω.drop (j + 1)))⁻¹
* (Option.map (cs.simple) ω[j]?).getD 1
* π (ω.drop (j + 1)) := by
induction ω generalizing j with
| nil => simp
| cons i ω ih =>
dsimp only [rightInvSeq]
rcases j with _ | j'
· simp
· simp only [getD_eq_getElem?_getD] at ih
simp [ih j']
lemma getElem_rightInvSeq (ω : List B) (j : ℕ) (h : j < ω.length) :
(ris ω)[j]'(by simp [h]) =
(π (ω.drop (j + 1)))⁻¹
* (Option.map (cs.simple) ω[j]?).getD 1
* π (ω.drop (j + 1)) := by
rw [← List.getD_eq_getElem (ris ω) 1, getD_rightInvSeq]
theorem getD_leftInvSeq (ω : List B) (j : ℕ) :
(lis ω).getD j 1 =
π (ω.take j)
* (Option.map (cs.simple) ω[j]?).getD 1
* (π (ω.take j))⁻¹ := by
induction ω generalizing j with
| nil => simp
| cons i ω ih =>
dsimp [leftInvSeq]
rcases j with _ | j'
· simp
· rw [getD_cons_succ]
rw [(by simp : 1 = ⇑(MulAut.conj (s i)) 1)]
rw [getD_map]
rw [ih j']
simp [← mul_assoc, wordProd_cons]
lemma getElem_leftInvSeq (ω : List B) (j : ℕ) (h : j < ω.length) :
(lis ω)[j]'(by simp [h]) =
cs.wordProd (List.take j ω) * s ω[j] * (cs.wordProd (List.take j ω))⁻¹ := by
rw [← List.getD_eq_getElem (lis ω) 1, getD_leftInvSeq]
simp [h]
theorem getD_rightInvSeq_mul_self (ω : List B) (j : ℕ) :
((ris ω).getD j 1) * ((ris ω).getD j 1) = 1 := by
simp_rw [getD_rightInvSeq, mul_assoc]
rcases em (j < ω.length) with hj | nhj
· rw [getElem?_eq_getElem hj]
simp [← mul_assoc]
· rw [getElem?_eq_none_iff.mpr (by cutsat)]
simp
theorem getD_leftInvSeq_mul_self (ω : List B) (j : ℕ) :
((lis ω).getD j 1) * ((lis ω).getD j 1) = 1 := by
simp_rw [getD_leftInvSeq, mul_assoc]
rcases em (j < ω.length) with hj | nhj
· rw [getElem?_eq_getElem hj]
simp [← mul_assoc]
· rw [getElem?_eq_none_iff.mpr (by cutsat)]
simp
theorem rightInvSeq_drop (ω : List B) (j : ℕ) :
ris (ω.drop j) = (ris ω).drop j := by
induction j generalizing ω with
| zero => simp
| succ j ih₁ =>
induction ω with
| nil => simp
| cons k ω _ => rw [drop_succ_cons, ih₁ ω, rightInvSeq, drop_succ_cons]
theorem leftInvSeq_take (ω : List B) (j : ℕ) :
lis (ω.take j) = (lis ω).take j := by
simp only [leftInvSeq_eq_reverse_rightInvSeq_reverse]
rw [List.take_reverse]
nth_rw 1 [← List.reverse_reverse ω]
rw [List.take_reverse]
simp [rightInvSeq_drop]
theorem isReflection_of_mem_rightInvSeq (ω : List B) {t : W} (ht : t ∈ ris ω) :
cs.IsReflection t := by
induction ω with
| nil => simp at ht
| cons i ω ih =>
dsimp [rightInvSeq] at ht
rcases ht with _ | ⟨_, mem⟩
· use (π ω)⁻¹, i
group
· exact ih mem
theorem isReflection_of_mem_leftInvSeq (ω : List B) {t : W} (ht : t ∈ lis ω) :
cs.IsReflection t := by
simp only [leftInvSeq_eq_reverse_rightInvSeq_reverse, mem_reverse] at ht
exact cs.isReflection_of_mem_rightInvSeq ω.reverse ht
theorem wordProd_mul_getD_rightInvSeq (ω : List B) (j : ℕ) :
π ω * ((ris ω).getD j 1) = π (ω.eraseIdx j) := by
rw [getD_rightInvSeq, eraseIdx_eq_take_drop_succ]
nth_rw 1 [← take_append_drop (j + 1) ω]
rw [take_succ]
obtain lt | le := lt_or_ge j ω.length
· simp only [getElem?_eq_getElem lt, wordProd_append, mul_assoc]
simp
· simp only [getElem?_eq_none le]
simp
theorem getD_leftInvSeq_mul_wordProd (ω : List B) (j : ℕ) :
((lis ω).getD j 1) * π ω = π (ω.eraseIdx j) := by
rw [getD_leftInvSeq, eraseIdx_eq_take_drop_succ]
nth_rw 4 [← take_append_drop (j + 1) ω]
rw [take_succ]
obtain lt | le := lt_or_ge j ω.length
· simp only [getElem?_eq_getElem lt, wordProd_append, mul_assoc]
simp
· simp only [getElem?_eq_none le]
simp
theorem isRightInversion_of_mem_rightInvSeq {ω : List B} (hω : cs.IsReduced ω) {t : W}
(ht : t ∈ ris ω) : cs.IsRightInversion (π ω) t := by
constructor
· exact cs.isReflection_of_mem_rightInvSeq ω ht
· obtain ⟨j, hj, rfl⟩ := List.mem_iff_getElem.mp ht
rw [← List.getD_eq_getElem _ 1 hj, wordProd_mul_getD_rightInvSeq]
rw [cs.length_rightInvSeq] at hj
calc
ℓ (π (ω.eraseIdx j))
_ ≤ (ω.eraseIdx j).length := cs.length_wordProd_le _
_ < ω.length := by rw [← List.length_eraseIdx_add_one hj]; exact lt_add_one _
_ = ℓ (π ω) := hω.symm
theorem isLeftInversion_of_mem_leftInvSeq {ω : List B} (hω : cs.IsReduced ω) {t : W}
(ht : t ∈ lis ω) : cs.IsLeftInversion (π ω) t := by
constructor
· exact cs.isReflection_of_mem_leftInvSeq ω ht
· obtain ⟨j, hj, rfl⟩ := List.mem_iff_getElem.mp ht
rw [← List.getD_eq_getElem _ 1 hj, getD_leftInvSeq_mul_wordProd]
rw [cs.length_leftInvSeq] at hj
calc
ℓ (π (ω.eraseIdx j))
_ ≤ (ω.eraseIdx j).length := cs.length_wordProd_le _
_ < ω.length := by rw [← List.length_eraseIdx_add_one hj]; exact lt_add_one _
_ = ℓ (π ω) := hω.symm
theorem prod_rightInvSeq (ω : List B) : prod (ris ω) = (π ω)⁻¹ := by
induction ω with
| nil => simp
| cons i ω ih => simp [rightInvSeq, ih, wordProd_cons]
theorem prod_leftInvSeq (ω : List B) : prod (lis ω) = (π ω)⁻¹ := by
simp only [leftInvSeq_eq_reverse_rightInvSeq_reverse, prod_reverse_noncomm, inv_inj]
have : List.map (fun x ↦ x⁻¹) (ris ω.reverse) = ris ω.reverse := calc
List.map (fun x ↦ x⁻¹) (ris ω.reverse)
_ = List.map id (ris ω.reverse) := by
apply List.map_congr_left
intro t ht
exact (cs.isReflection_of_mem_rightInvSeq _ ht).inv
_ = ris ω.reverse := map_id _
rw [this]
nth_rw 2 [← reverse_reverse ω]
rw [wordProd_reverse]
exact cs.prod_rightInvSeq _
theorem IsReduced.nodup_rightInvSeq {ω : List B} (rω : cs.IsReduced ω) : List.Nodup (ris ω) := by
apply List.nodup_iff_getElem?_ne_getElem?.mpr
intro j j' j_lt_j' j'_lt_length (dup : (rightInvSeq cs ω)[j]? = (rightInvSeq cs ω)[j']?)
show False
replace j'_lt_length : j' < List.length ω := by simpa using j'_lt_length
rw [getElem?_eq_getElem (by simp; cutsat), getElem?_eq_getElem (by simp; cutsat)] at dup
apply Option.some_injective at dup
rw [← getD_eq_getElem _ 1, ← getD_eq_getElem _ 1] at dup
set! t := (ris ω).getD j 1 with h₁
set! t' := (ris (ω.eraseIdx j)).getD (j' - 1) 1 with h₂
have h₃ : t' = (ris ω).getD j' 1 := by
rw [h₂, cs.getD_rightInvSeq, cs.getD_rightInvSeq,
(Nat.sub_add_cancel (by cutsat) : j' - 1 + 1 = j'), eraseIdx_eq_take_drop_succ,
drop_append, drop_of_length_le (by simp [j_lt_j'.le]), length_take, drop_drop,
nil_append, min_eq_left_of_lt (j_lt_j'.trans j'_lt_length), Nat.add_comm,
← add_assoc, Nat.sub_add_cancel (by cutsat), mul_left_inj, mul_right_inj]
congr 2
show (List.take j ω ++ List.drop (j + 1) ω)[j' - 1]? = ω[j']?
rw [getElem?_append_right (by simp [Nat.le_sub_one_of_lt j_lt_j']), getElem?_drop]
grind
have h₄ : t * t' = 1 := by
rw [h₁, h₃, dup]
exact cs.getD_rightInvSeq_mul_self _ _
have h₅ := calc
π ω = π ω * t * t' := by rw [mul_assoc, h₄]; group
_ = (π (ω.eraseIdx j)) * t' :=
congrArg (· * t') (cs.wordProd_mul_getD_rightInvSeq _ _)
_ = π ((ω.eraseIdx j).eraseIdx (j' - 1)) :=
cs.wordProd_mul_getD_rightInvSeq _ _
have h₆ := calc
ω.length = ℓ (π ω) := rω.symm
_ = ℓ (π ((ω.eraseIdx j).eraseIdx (j' - 1))) := congrArg cs.length h₅
_ ≤ ((ω.eraseIdx j).eraseIdx (j' - 1)).length := cs.length_wordProd_le _
grind
theorem IsReduced.nodup_leftInvSeq {ω : List B} (rω : cs.IsReduced ω) : List.Nodup (lis ω) := by
simp only [leftInvSeq_eq_reverse_rightInvSeq_reverse, nodup_reverse]
apply nodup_rightInvSeq
rwa [isReduced_reverse_iff]
lemma getElem_succ_leftInvSeq_alternatingWord
(i j : B) (p k : ℕ) (h : k + 1 < 2 * p) :
(lis (alternatingWord i j (2 * p)))[k + 1]'(by simpa using h) =
MulAut.conj (s i) ((lis (alternatingWord j i (2 * p)))[k]'(by simp; cutsat)) := by
rw [cs.getElem_leftInvSeq (alternatingWord i j (2 * p)) (k + 1) (by simp [h]),
cs.getElem_leftInvSeq (alternatingWord j i (2 * p)) k (by simp; cutsat)]
simp only [MulAut.conj, listTake_succ_alternatingWord i j p k h, cs.wordProd_cons, mul_assoc,
mul_inv_rev, inv_simple, MonoidHom.coe_mk, OneHom.coe_mk, MulEquiv.coe_mk, Equiv.coe_fn_mk,
mul_right_inj, mul_left_inj]
rw [getElem_alternatingWord_swapIndices i j (2 * p) k]
cutsat
theorem getElem_leftInvSeq_alternatingWord
(i j : B) (p k : ℕ) (h : k < 2 * p) :
(lis (alternatingWord i j (2 * p)))[k]'(by simp; cutsat) =
π alternatingWord j i (2 * k + 1) := by
induction k generalizing i j with
| zero =>
simp only [CoxeterSystem.getElem_leftInvSeq cs (alternatingWord i j (2 * p)) 0 (by simp [h]),
take_zero, wordProd_nil, one_mul, inv_one, mul_one, alternatingWord, concat_eq_append,
nil_append, wordProd_singleton]
apply congr_arg
simp only [getElem_alternatingWord i j (2 * p) 0 (by simp [h]), add_zero, even_two,
Even.mul_right, ↓reduceIte]
| succ k hk =>
simp only [getElem_succ_leftInvSeq_alternatingWord cs i j p k h, hk _ _ (by cutsat),
MulAut.conj_apply, inv_simple, alternatingWord_succ' j i, even_two, Even.mul_right,
↓reduceIte, wordProd_cons]
rw [(by ring: 2 * (k + 1) = 2 * k + 1 + 1), alternatingWord_succ j i, wordProd_concat]
simp [mul_assoc]
end CoxeterSystem |
.lake/packages/mathlib/Mathlib/GroupTheory/GroupAction/SubMulAction.lean | import Mathlib.Algebra.Module.Defs
import Mathlib.Data.SetLike.Basic
import Mathlib.Data.Setoid.Basic
import Mathlib.GroupTheory.GroupAction.Defs
import Mathlib.GroupTheory.GroupAction.Hom
/-!
# Sets invariant to a `MulAction`
In this file we define `SubMulAction R M`; a subset of a `MulAction R M` which is closed with
respect to scalar multiplication.
For most uses, typically `Submodule R M` is more powerful.
## Main definitions
* `SubMulAction.mulAction` - the `MulAction R M` transferred to the subtype.
* `SubMulAction.mulAction'` - the `MulAction S M` transferred to the subtype when
`IsScalarTower S R M`.
* `SubMulAction.isScalarTower` - the `IsScalarTower S R M` transferred to the subtype.
* `SubMulAction.inclusion` — the inclusion of a `SubMulAction`, as an equivariant map
## Tags
submodule, mul_action
-/
open Function
universe u u' u'' v
variable {S : Type u'} {T : Type u''} {R : Type u} {M : Type v}
/-- `SMulMemClass S R M` says `S` is a type of subsets `s ≤ M` that are closed under the
scalar action of `R` on `M`.
Note that only `R` is marked as an `outParam` here, since `M` is supplied by the `SetLike`
class instead.
-/
class SMulMemClass (S : Type*) (R : outParam Type*) (M : Type*) [SMul R M] [SetLike S M] :
Prop where
/-- Multiplication by a scalar on an element of the set remains in the set. -/
smul_mem : ∀ {s : S} (r : R) {m : M}, m ∈ s → r • m ∈ s
/-- `VAddMemClass S R M` says `S` is a type of subsets `s ≤ M` that are closed under the
additive action of `R` on `M`.
Note that only `R` is marked as an `outParam` here, since `M` is supplied by the `SetLike`
class instead. -/
class VAddMemClass (S : Type*) (R : outParam Type*) (M : Type*) [VAdd R M] [SetLike S M] :
Prop where
/-- Addition by a scalar with an element of the set remains in the set. -/
vadd_mem : ∀ {s : S} (r : R) {m : M}, m ∈ s → r +ᵥ m ∈ s
attribute [to_additive] SMulMemClass
attribute [aesop 90% (rule_sets := [SetLike])] SMulMemClass.smul_mem VAddMemClass.vadd_mem
/-- Not registered as an instance because `R` is an `outParam` in `SMulMemClass S R M`. -/
lemma AddSubmonoidClass.nsmulMemClass {S M : Type*} [AddMonoid M] [SetLike S M]
[AddSubmonoidClass S M] : SMulMemClass S ℕ M where
smul_mem n _x hx := nsmul_mem hx n
/-- Not registered as an instance because `R` is an `outParam` in `SMulMemClass S R M`. -/
lemma AddSubgroupClass.zsmulMemClass {S M : Type*} [SubNegMonoid M] [SetLike S M]
[AddSubgroupClass S M] : SMulMemClass S ℤ M where
smul_mem n _x hx := zsmul_mem hx n
namespace SetLike
open SMulMemClass
section SMul
variable [SMul R M] [SetLike S M] [hS : SMulMemClass S R M] (s : S)
-- lower priority so other instances are found first
/-- A subset closed under the scalar action inherits that action. -/
@[to_additive /-- A subset closed under the additive action inherits that action. -/]
instance (priority := 50) smul : SMul R s :=
⟨fun r x => ⟨r • x.1, smul_mem r x.2⟩⟩
@[to_additive] instance (priority := 50) [SMul T M] [SMulMemClass S T M] [SMulCommClass T R M] :
SMulCommClass T R s where
smul_comm _ _ _ := Subtype.ext (smul_comm ..)
/-- This can't be an instance because Lean wouldn't know how to find `N`, but we can still use
this to manually derive `SMulMemClass` on specific types. -/
@[to_additive] theorem _root_.SMulMemClass.ofIsScalarTower (S M N α : Type*) [SetLike S α]
[SMul M N] [SMul M α] [Monoid N] [MulAction N α] [SMulMemClass S N α] [IsScalarTower M N α] :
SMulMemClass S M α :=
{ smul_mem := fun m a ha => smul_one_smul N m a ▸ SMulMemClass.smul_mem _ ha }
instance instIsScalarTower [Mul M] [MulMemClass S M] [IsScalarTower R M M]
(s : S) : IsScalarTower R s s where
smul_assoc r x y := Subtype.ext <| smul_assoc r (x : M) (y : M)
instance instSMulCommClass [Mul M] [MulMemClass S M] [SMulCommClass R M M]
(s : S) : SMulCommClass R s s where
smul_comm r x y := Subtype.ext <| smul_comm r (x : M) (y : M)
@[to_additive (attr := simp, norm_cast)]
protected theorem val_smul (r : R) (x : s) : (↑(r • x) : M) = r • (x : M) :=
rfl
@[to_additive (attr := simp)]
theorem mk_smul_mk (r : R) (x : M) (hx : x ∈ s) : r • (⟨x, hx⟩ : s) = ⟨r • x, smul_mem r hx⟩ :=
rfl
@[to_additive]
theorem smul_def (r : R) (x : s) : r • x = ⟨r • x, smul_mem r x.2⟩ :=
rfl
@[simp]
theorem forall_smul_mem_iff {R M S : Type*} [Monoid R] [MulAction R M] [SetLike S M]
[SMulMemClass S R M] {N : S} {x : M} : (∀ a : R, a • x ∈ N) ↔ x ∈ N :=
⟨fun h => by simpa using h 1, fun h a => SMulMemClass.smul_mem a h⟩
end SMul
section OfTower
variable {N α : Type*} [SetLike S α] [SMul M N] [SMul M α] [Monoid N]
[MulAction N α] [SMulMemClass S N α] [IsScalarTower M N α] (s : S)
-- lower priority so other instances are found first
/-- A subset closed under the scalar action inherits that action. -/
@[to_additive /-- A subset closed under the additive action inherits that action. -/]
instance (priority := 50) smul' : SMul M s where
smul r x := ⟨r • x.1, smul_one_smul N r x.1 ▸ smul_mem _ x.2⟩
instance (priority := 50) : IsScalarTower M N s where
smul_assoc m n x := Subtype.ext (smul_assoc m n x.1)
@[to_additive (attr := simp, norm_cast)]
protected theorem val_smul_of_tower (r : M) (x : s) : (↑(r • x) : α) = r • (x : α) :=
rfl
@[to_additive (attr := simp)]
theorem mk_smul_of_tower_mk (r : M) (x : α) (hx : x ∈ s) :
r • (⟨x, hx⟩ : s) = ⟨r • x, smul_one_smul N r x ▸ smul_mem _ hx⟩ :=
rfl
@[to_additive]
theorem smul_of_tower_def (r : M) (x : s) :
r • x = ⟨r • x, smul_one_smul N r x.1 ▸ smul_mem _ x.2⟩ :=
rfl
@[to_additive] instance (priority := 50) [SMulCommClass M N α] : SMulCommClass M N s where
smul_comm _ _ _ := Subtype.ext (smul_comm ..)
@[to_additive] instance (priority := 50) [SMulCommClass N M α] : SMulCommClass N M s where
smul_comm _ _ _ := Subtype.ext (smul_comm ..)
end OfTower
end SetLike
/-- A SubAddAction is a set which is closed under scalar multiplication. -/
structure SubAddAction (R : Type u) (M : Type v) [VAdd R M] : Type v where
/-- The underlying set of a `SubAddAction`. -/
carrier : Set M
/-- The carrier set is closed under scalar multiplication. -/
vadd_mem' : ∀ (c : R) {x : M}, x ∈ carrier → c +ᵥ x ∈ carrier
/-- A SubMulAction is a set which is closed under scalar multiplication. -/
@[to_additive]
structure SubMulAction (R : Type u) (M : Type v) [SMul R M] : Type v where
/-- The underlying set of a `SubMulAction`. -/
carrier : Set M
/-- The carrier set is closed under scalar multiplication. -/
smul_mem' : ∀ (c : R) {x : M}, x ∈ carrier → c • x ∈ carrier
namespace SubMulAction
variable [SMul R M]
@[to_additive]
instance : SetLike (SubMulAction R M) M :=
⟨SubMulAction.carrier, fun p q h => by cases p; cases q; congr⟩
@[to_additive]
instance : SMulMemClass (SubMulAction R M) R M where smul_mem := smul_mem' _
@[to_additive (attr := simp)]
theorem mem_carrier {p : SubMulAction R M} {x : M} : x ∈ p.carrier ↔ x ∈ (p : Set M) :=
Iff.rfl
@[to_additive (attr := ext)]
theorem ext {p q : SubMulAction R M} (h : ∀ x, x ∈ p ↔ x ∈ q) : p = q :=
SetLike.ext h
/-- Copy of a sub_mul_action with a new `carrier` equal to the old one. Useful to fix definitional
equalities. -/
@[to_additive /-- Copy of a sub_mul_action with a new `carrier` equal to the old one.
Useful to fix definitional equalities. -/]
protected def copy (p : SubMulAction R M) (s : Set M) (hs : s = ↑p) : SubMulAction R M where
carrier := s
smul_mem' := hs.symm ▸ p.smul_mem'
@[to_additive (attr := simp)]
theorem coe_copy (p : SubMulAction R M) (s : Set M) (hs : s = ↑p) : (p.copy s hs : Set M) = s :=
rfl
@[to_additive]
theorem copy_eq (p : SubMulAction R M) (s : Set M) (hs : s = ↑p) : p.copy s hs = p :=
SetLike.coe_injective hs
@[to_additive]
instance : Bot (SubMulAction R M) :=
⟨⟨∅, by simp⟩⟩
@[to_additive]
instance : Inhabited (SubMulAction R M) :=
⟨⊥⟩
@[to_additive]
instance : Top (SubMulAction R M) :=
⟨⟨Set.univ, by simp⟩⟩
@[to_additive]
instance : Max (SubMulAction R M) :=
⟨fun s t => ⟨s ∪ t, by aesop⟩⟩
@[to_additive]
instance : Min (SubMulAction R M) :=
⟨fun s t => ⟨s ∩ t, by aesop⟩⟩
@[to_additive]
instance : SupSet (SubMulAction R M) :=
⟨fun S => ⟨⋃ s ∈ S, s, by aesop⟩⟩
@[to_additive]
instance : InfSet (SubMulAction R M) :=
⟨fun S => ⟨⋂ s ∈ S, ↑s, by aesop⟩⟩
@[to_additive]
instance : CompleteLattice (SubMulAction R M) :=
SetLike.coe_injective.completeLattice _ (fun _ _ => rfl) (fun _ _ => rfl) (fun _ => rfl)
(fun _ => rfl) rfl rfl
@[to_additive (attr := simp)]
theorem mem_iSup {ι : Sort*} {p : ι → SubMulAction R M} {x : M} :
x ∈ ⨆ i, p i ↔ ∃ i, x ∈ p i := by
change x ∈ ⋃ s ∈ Set.range p, s ↔ _
simp
@[to_additive (attr := simp)]
theorem mem_iInf {ι : Sort*} {p : ι → SubMulAction R M} {x : M} :
x ∈ ⨅ i, p i ↔ ∀ i, x ∈ p i := by
change x ∈ ⋂ s ∈ Set.range p, s ↔ _
simp
end SubMulAction
namespace SubMulAction
section SMul
variable [SMul R M]
variable (p : SubMulAction R M)
variable {r : R} {x : M}
@[to_additive]
theorem smul_mem (r : R) (h : x ∈ p) : r • x ∈ p :=
p.smul_mem' r h
@[to_additive]
instance : SMul R p where smul c x := ⟨c • x.1, smul_mem _ c x.2⟩
variable {p} in
@[to_additive (attr := norm_cast, simp)]
theorem val_smul (r : R) (x : p) : (↑(r • x) : M) = r • (x : M) :=
rfl
/-- Embedding of a submodule `p` to the ambient space `M`. -/
@[to_additive /-- Embedding of a submodule `p` to the ambient space `M`. -/]
protected def subtype : p →[R] M where
toFun := Subtype.val
map_smul' := by simp
variable {p} in
@[to_additive (attr := simp)]
theorem subtype_apply (x : p) : p.subtype x = x :=
rfl
lemma subtype_injective :
Function.Injective p.subtype :=
Subtype.coe_injective
@[to_additive]
theorem subtype_eq_val : (SubMulAction.subtype p : p → M) = Subtype.val :=
rfl
end SMul
namespace SMulMemClass
variable [Monoid R] [MulAction R M] {A : Type*} [SetLike A M]
variable [hA : SMulMemClass A R M] (S' : A)
-- Prefer subclasses of `MulAction` over `SMulMemClass`.
/-- A `SubMulAction` of a `MulAction` is a `MulAction`. -/
@[to_additive /-- A `SubAddAction` of an `AddAction` is an `AddAction`. -/]
instance (priority := 75) toMulAction : MulAction R S' :=
Subtype.coe_injective.mulAction Subtype.val (SetLike.val_smul S')
/-- The natural `MulActionHom` over `R` from a `SubMulAction` of `M` to `M`. -/
@[to_additive /-- The natural `AddActionHom` over `R` from a `SubAddAction` of `M` to `M`. -/]
protected def subtype : S' →[R] M where
toFun := Subtype.val; map_smul' _ _ := rfl
variable {S'} in
@[simp]
lemma subtype_apply (x : S') :
SMulMemClass.subtype S' x = x := rfl
lemma subtype_injective :
Function.Injective (SMulMemClass.subtype S') :=
Subtype.coe_injective
@[to_additive (attr := simp)]
protected theorem coe_subtype : (SMulMemClass.subtype S' : S' → M) = Subtype.val :=
rfl
end SMulMemClass
section MulActionMonoid
variable [Monoid R] [MulAction R M]
section
variable [SMul S R] [SMul S M] [IsScalarTower S R M]
variable (p : SubMulAction R M)
@[to_additive]
theorem smul_of_tower_mem (s : S) {x : M} (h : x ∈ p) : s • x ∈ p := by
rw [← one_smul R x, ← smul_assoc]
exact p.smul_mem _ h
@[to_additive]
instance smul' : SMul S p where smul c x := ⟨c • x.1, smul_of_tower_mem _ c x.2⟩
@[to_additive]
instance isScalarTower : IsScalarTower S R p where
smul_assoc s r x := Subtype.ext <| smul_assoc s r (x : M)
@[to_additive]
instance isScalarTower' {S' : Type*} [SMul S' R] [SMul S' S] [SMul S' M] [IsScalarTower S' R M]
[IsScalarTower S' S M] : IsScalarTower S' S p where
smul_assoc s r x := Subtype.ext <| smul_assoc s r (x : M)
@[to_additive (attr := norm_cast, simp)]
theorem val_smul_of_tower (s : S) (x : p) : ((s • x : p) : M) = s • (x : M) :=
rfl
@[to_additive (attr := simp)]
theorem smul_mem_iff' {G} [Group G] [SMul G R] [MulAction G M] [IsScalarTower G R M] (g : G)
{x : M} : g • x ∈ p ↔ x ∈ p :=
⟨fun h => inv_smul_smul g x ▸ p.smul_of_tower_mem g⁻¹ h, p.smul_of_tower_mem g⟩
@[to_additive]
instance isCentralScalar [SMul Sᵐᵒᵖ R] [SMul Sᵐᵒᵖ M] [IsScalarTower Sᵐᵒᵖ R M]
[IsCentralScalar S M] :
IsCentralScalar S p where
op_smul_eq_smul r x := Subtype.ext <| op_smul_eq_smul r (x : M)
end
section
variable [Monoid S] [SMul S R] [MulAction S M] [IsScalarTower S R M]
variable (p : SubMulAction R M)
/-- If the scalar product forms a `MulAction`, then the subset inherits this action -/
@[to_additive]
instance mulAction' : MulAction S p where
one_smul x := Subtype.ext <| one_smul _ (x : M)
mul_smul c₁ c₂ x := Subtype.ext <| mul_smul c₁ c₂ (x : M)
@[to_additive]
instance mulAction : MulAction R p :=
p.mulAction'
end
/-- Orbits in a `SubMulAction` coincide with orbits in the ambient space. -/
@[to_additive]
theorem val_image_orbit {p : SubMulAction R M} (m : p) :
Subtype.val '' MulAction.orbit R m = MulAction.orbit R (m : M) :=
(Set.range_comp _ _).symm
/- -- Previously, the relatively useless :
lemma orbit_of_sub_mul {p : SubMulAction R M} (m : p) :
(mul_action.orbit R m : set M) = MulAction.orbit R (m : M) := rfl
-/
@[to_additive]
theorem val_preimage_orbit {p : SubMulAction R M} (m : p) :
Subtype.val ⁻¹' MulAction.orbit R (m : M) = MulAction.orbit R m := by
rw [← val_image_orbit, Subtype.val_injective.preimage_image]
@[to_additive]
lemma mem_orbit_subMul_iff {p : SubMulAction R M} {x m : p} :
x ∈ MulAction.orbit R m ↔ (x : M) ∈ MulAction.orbit R (m : M) := by
rw [← val_preimage_orbit, Set.mem_preimage]
/-- Stabilizers in monoid SubMulAction coincide with stabilizers in the ambient space -/
@[to_additive]
theorem stabilizer_of_subMul.submonoid {p : SubMulAction R M} (m : p) :
MulAction.stabilizerSubmonoid R m = MulAction.stabilizerSubmonoid R (m : M) := by
ext
simp only [MulAction.mem_stabilizerSubmonoid_iff, ← SubMulAction.val_smul, SetLike.coe_eq_coe]
end MulActionMonoid
section MulActionGroup
variable [Group R] [MulAction R M]
@[to_additive]
lemma orbitRel_of_subMul (p : SubMulAction R M) :
MulAction.orbitRel R p = (MulAction.orbitRel R M).comap Subtype.val := by
refine Setoid.ext_iff.2 (fun x y ↦ ?_)
rw [Setoid.comap_rel]
exact mem_orbit_subMul_iff
/-- Stabilizers in group SubMulAction coincide with stabilizers in the ambient space -/
@[to_additive]
theorem stabilizer_of_subMul {p : SubMulAction R M} (m : p) :
MulAction.stabilizer R m = MulAction.stabilizer R (m : M) := by
rw [← Subgroup.toSubmonoid_inj]
exact stabilizer_of_subMul.submonoid m
/-- SubMulAction on the complement of an invariant subset -/
@[to_additive /-- SubAddAction on the complement of an invariant subset -/]
instance : HasCompl (SubMulAction R M) where
compl s := ⟨sᶜ, by simp⟩
@[to_additive]
theorem compl_def (s : SubMulAction R M) : sᶜ.carrier = (s : Set M)ᶜ := rfl
end MulActionGroup
section Module
variable [Semiring R] [AddCommMonoid M]
variable [Module R M]
variable (p : SubMulAction R M)
theorem zero_mem (h : (p : Set M).Nonempty) : (0 : M) ∈ p :=
let ⟨x, hx⟩ := h
zero_smul R (x : M) ▸ p.smul_mem 0 hx
/-- If the scalar product forms a `Module`, and the `SubMulAction` is not `⊥`, then the
subset inherits the zero. -/
instance [n_empty : Nonempty p] : Zero p where
zero := ⟨0, n_empty.elim fun x => p.zero_mem ⟨x, x.prop⟩⟩
end Module
section AddCommGroup
variable [Ring R] [AddCommGroup M]
variable [Module R M]
variable (p p' : SubMulAction R M)
variable {r : R} {x y : M}
theorem neg_mem (hx : x ∈ p) : -x ∈ p := by
rw [← neg_one_smul R]
exact p.smul_mem _ hx
@[simp]
theorem neg_mem_iff : -x ∈ p ↔ x ∈ p :=
⟨fun h => by
rw [← neg_neg x]
exact neg_mem _ h, neg_mem _⟩
instance : Neg p :=
⟨fun x => ⟨-x.1, neg_mem _ x.2⟩⟩
@[simp, norm_cast]
theorem val_neg (x : p) : ((-x : p) : M) = -x :=
rfl
end AddCommGroup
end SubMulAction
namespace SubMulAction
variable [GroupWithZero S] [Monoid R] [MulAction R M]
variable [SMul S R] [MulAction S M] [IsScalarTower S R M]
variable (p : SubMulAction R M) {s : S} {x y : M}
theorem smul_mem_iff (s0 : s ≠ 0) : s • x ∈ p ↔ x ∈ p :=
p.smul_mem_iff' (Units.mk0 s s0)
end SubMulAction
namespace SubMulAction
/- The inclusion of a `SubMulAction`, as an equivariant map -/
variable {M α : Type*} [Monoid M] [MulAction M α]
/-- The inclusion of a SubMulAction into the ambient set, as an equivariant map -/
@[to_additive /-- The inclusion of a SubAddAction into the ambient set, as an equivariant map. -/]
def inclusion (s : SubMulAction M α) : s →[M] α where
-- The inclusion map of the inclusion of a SubMulAction
toFun := Subtype.val
-- The commutation property
map_smul' _ _ := rfl
@[to_additive]
theorem inclusion.toFun_eq_coe (s : SubMulAction M α) :
s.inclusion.toFun = Subtype.val := rfl
@[to_additive]
theorem inclusion.coe_eq (s : SubMulAction M α) :
⇑s.inclusion = Subtype.val := rfl
@[to_additive]
lemma image_inclusion (s : SubMulAction M α) :
Set.range s.inclusion = s.carrier := by
rw [inclusion.coe_eq]
exact Subtype.range_coe
@[to_additive]
lemma inclusion_injective (s : SubMulAction M α) :
Function.Injective s.inclusion :=
Subtype.val_injective
end SubMulAction
namespace Units
variable (R M : Type*) [Monoid R] [AddCommMonoid M] [DistribMulAction R M]
/-- The non-zero elements of `M` are invariant under the action by the units of `R`. -/
def nonZeroSubMul : SubMulAction Rˣ M where
carrier := { x : M | x ≠ 0 }
smul_mem' := by simp [Units.smul_def]
instance : MulAction Rˣ { x : M // x ≠ 0 } :=
SubMulAction.mulAction' (nonZeroSubMul R M)
@[simp]
lemma smul_coe (a : Rˣ) (x : { x : M // x ≠ 0 }) :
(a • x).val = a • x.val :=
rfl
lemma orbitRel_nonZero_iff (x y : { v : M // v ≠ 0 }) :
MulAction.orbitRel Rˣ { v // v ≠ 0 } x y ↔ MulAction.orbitRel Rˣ M x y :=
⟨by rintro ⟨a, rfl⟩; exact ⟨a, by simp⟩, by intro ⟨a, ha⟩; exact ⟨a, by ext; simpa⟩⟩
end Units |
.lake/packages/mathlib/Mathlib/GroupTheory/GroupAction/MultiplePrimitivity.lean | import Mathlib.GroupTheory.GroupAction.MultipleTransitivity
import Mathlib.GroupTheory.GroupAction.SubMulAction.OfFixingSubgroup
/-! # Multiply preprimitive actions
Let `G` be a group acting on a type `α`.
* `MulAction.IsMultiplyPreprimitive` :
The action is said to be `n`-primitive if, for every subset `s :
Set α` with `n` elements, the actions f `stabilizer G s` on the
complement of `s` is primitive.
* `MulAction.is_zero_preprimitive` : any action is 0-primitive
* `MulAction.is_one_preprimitive_iff` : an action is 1-primitive if and only if it is primitive
* `MulAction.isMultiplyPreprimitive_ofStabilizer`: if an action is `n + 1`-primitive,
then the action of `stabilizer G a` on the complement of `{a}` is `n`-primitive.
* `MulAction.isMultiplyPreprimitive_succ_iff_ofStabilizer` :
for `1 ≤ n`, an action is `n + 1`-primitive, then the action
of `stabilizer G a` on the complement of `{a}` is `n`-primitive.
ofFixingSubgroup.isMultiplyPreprimitive
* `MulAction.ofFixingSubgroup.isMultiplyPreprimitive`:
If an action is `s.ncard + m`-primitive, then
the action of `FixingSubgroup G s` on the complement of `s`
is `m`-primitive.
-/
open scoped BigOperators Pointwise Cardinal
namespace MulAction
open SubMulAction
section Preprimitive
variable {G : Type*} [Group G] {α : Type*} [MulAction G α]
-- Rewriting lemmas for transitivity or primitivity
@[to_additive]
theorem isPreprimitive_of_fixingSubgroup_empty_iff :
IsPreprimitive ↥(fixingSubgroup G (∅ : Set α))
↥(ofFixingSubgroup G (∅ : Set α)) ↔ IsPreprimitive G α :=
isPreprimitive_congr
of_fixingSubgroupEmpty_mapScalars_surjective
ofFixingSubgroupEmpty_equivariantMap_bijective
@[to_additive]
theorem isPreprimitive_ofFixingSubgroup_conj_iff {s : Set α} {g : G} :
IsPreprimitive (fixingSubgroup G s) (ofFixingSubgroup G s) ↔
IsPreprimitive (fixingSubgroup G (g • s)) (ofFixingSubgroup G (g • s)) :=
isPreprimitive_congr
(fixingSubgroupEquivFixingSubgroup rfl).surjective
conjMap_ofFixingSubgroup_bijective
@[to_additive]
theorem isPreprimitive_fixingSubgroup_insert_iff {a : α} {t : Set (ofStabilizer G a)} :
IsPreprimitive ↥(fixingSubgroup G (insert a (Subtype.val '' t)))
↥(ofFixingSubgroup G (insert a (Subtype.val '' t))) ↔
IsPreprimitive (fixingSubgroup (stabilizer G a) t)
(ofFixingSubgroup (stabilizer G a) t) :=
isPreprimitive_congr (fixingSubgroupInsertEquiv a t).surjective
ofFixingSubgroup_insert_map_bijective
end Preprimitive
/-- An additive action is `n`-multiply preprimitive if it is `n`-multiply transitive
and if, when `n ≥ 1`, for every set `s` of cardinality `n - 1`,
the action of `fixingAddSubgroup M s` on the complement of `s` is preprimitive. -/
@[mk_iff]
class _root_.AddAction.IsMultiplyPreprimitive
(M α : Type*) [AddGroup M] [AddAction M α] (n : ℕ) where
/-- An `n`-preprimitive action is `n`-pretransitive -/
isMultiplyPretransitive (M α n) : AddAction.IsMultiplyPretransitive M α n
/-- In an `n`-preprimitive action, the action of `fixingAddSubgroup M s`
on `ofFixingAddSubgroup M s` is preprimitive, for all sets `s` such that `s.encard + 1 = n` -/
isPreprimitive_ofFixingAddSubgroup (M n) {s : Set α} (hs : s.encard + 1 = n) :
AddAction.IsPreprimitive (fixingAddSubgroup M s) (SubAddAction.ofFixingAddSubgroup M s)
/-- A group action is `n`-multiply preprimitive if it is `n`-multiply
transitive and if, when `n ≥ 1`, for every set `s` of cardinality
n - 1, the action of `fixingSubgroup M s` on the complement of `s`
is preprimitive. -/
@[mk_iff, to_additive existing]
class IsMultiplyPreprimitive (M α : Type*) [Group M] [MulAction M α] (n : ℕ) where
/-- An `n`-preprimitive action is `n`-pretransitive -/
isMultiplyPretransitive (M α n) : IsMultiplyPretransitive M α n
/-- In an `n`-preprimitive action, the action of `fixingSubgroup M s` on `ofFixingSubgroup M s`
is preprimitive, for all sets `s` such that `s.encard + 1 = n` -/
isPreprimitive_ofFixingSubgroup (M n) {s : Set α} (hs : s.encard + 1 = n) :
IsPreprimitive (fixingSubgroup M s) (ofFixingSubgroup M s)
variable (M α : Type*) [Group M] [MulAction M α]
@[to_additive]
instance (n : ℕ) [IsMultiplyPreprimitive M α n] :
IsMultiplyPretransitive M α n :=
IsMultiplyPreprimitive.isMultiplyPretransitive M α n
/-- Any action is `0`-preprimitive -/
@[to_additive]
theorem is_zero_preprimitive : IsMultiplyPreprimitive M α 0 where
isMultiplyPretransitive := MulAction.is_zero_pretransitive
isPreprimitive_ofFixingSubgroup hs := by simp at hs
/-- An action is preprimitive iff it is `1`-preprimitive -/
@[to_additive]
theorem is_one_preprimitive_iff :
IsMultiplyPreprimitive M α 1 ↔ IsPreprimitive M α := by
constructor
· intro H1
rw [← isPreprimitive_of_fixingSubgroup_empty_iff]
apply H1.isPreprimitive_ofFixingSubgroup (by simp)
· intro h
rw [isMultiplyPreprimitive_iff]
constructor
· exact is_one_pretransitive_iff.mpr h.toIsPretransitive
· intro s hs
suffices s = ∅ by
rwa [this, isPreprimitive_of_fixingSubgroup_empty_iff]
rw [← Set.encard_eq_zero]
suffices s.encard ≠ (⊤ : ℕ∞) by
obtain ⟨m, hm⟩ := ENat.ne_top_iff_exists.mp this
rw [← hm, ← Nat.cast_one, ← ENat.coe_add, Nat.cast_inj, Nat.add_eq_right] at hs
simp [← hm, hs]
exact fun h ↦ by simp [h] at hs
/-- The action of `stabilizer M a` is one-less preprimitive -/
@[to_additive /-- The action of `stabilizer M a` is one-less preprimitive. -/]
theorem isMultiplyPreprimitive_ofStabilizer
[IsPretransitive M α] {n : ℕ} {a : α} [IsMultiplyPreprimitive M α n.succ] :
IsMultiplyPreprimitive (stabilizer M a) (SubMulAction.ofStabilizer M a) n := by
rcases Nat.lt_or_ge n 1 with h0 | h1
· rw [Nat.lt_one_iff] at h0
rw [h0]
apply is_zero_preprimitive
rw [isMultiplyPreprimitive_iff]
constructor
· rw [← ofStabilizer.isMultiplyPretransitive]
exact IsMultiplyPreprimitive.isMultiplyPretransitive M α n.succ
· intro s hs
have : IsPreprimitive ↥(fixingSubgroup M (insert a (Subtype.val '' s)))
↥(ofFixingSubgroup M (insert a (Subtype.val '' s))) := by
apply IsMultiplyPreprimitive.isPreprimitive_ofFixingSubgroup M n.succ
rw [Set.encard_insert_of_notMem, Subtype.coe_injective.encard_image, hs, Nat.cast_succ]
aesop
exact IsPreprimitive.of_surjective ofFixingSubgroup_insert_map_bijective.surjective
/-- A pretransitive action is `n.succ-`preprimitive iff
the action of stabilizers is `n`-preprimitive. -/
@[to_additive]
theorem isMultiplyPreprimitive_succ_iff_ofStabilizer
[IsPretransitive M α] {n : ℕ} (hn : 1 ≤ n) {a : α} :
IsMultiplyPreprimitive M α n.succ ↔
IsMultiplyPreprimitive (stabilizer M a) (SubMulAction.ofStabilizer M a) n := by
constructor
· apply isMultiplyPreprimitive_ofStabilizer
· intro H
rw [isMultiplyPreprimitive_iff]
constructor
· exact ofStabilizer.isMultiplyPretransitive.mpr H.isMultiplyPretransitive
· intro s hs
have : ∃ b : α, b ∈ s := by
rw [← Set.nonempty_def, Set.nonempty_iff_ne_empty]
intro h
apply not_lt.mpr hn
rw [h, Set.encard_empty, zero_add, ← Nat.cast_one, Nat.cast_inj, Nat.succ_inj] at hs
simp only [← hs, zero_lt_one]
obtain ⟨b, hb⟩ := this
obtain ⟨g, hg : g • b = a⟩ := exists_smul_eq M b a
rw [isPreprimitive_ofFixingSubgroup_conj_iff (g := g)]
set s' := g • s with hs'
let t : Set (SubMulAction.ofStabilizer M a) := Subtype.val ⁻¹' s'
have hst : s' = insert a (Subtype.val '' t) := by
ext x
constructor
· intro hxs
by_cases hxa : x = a
· simp [hxa]
· exact Set.mem_insert_of_mem _
⟨⟨x, hxa⟩, by simp only [t, Set.mem_preimage]; exact hxs, rfl⟩
· rw [Set.mem_insert_iff]
rintro (⟨rfl⟩ | ⟨y, hy, rfl⟩)
· simpa [s', ← hg]
· simpa only using hy
rw [hst, isPreprimitive_fixingSubgroup_insert_iff]
apply IsMultiplyPreprimitive.isPreprimitive_ofFixingSubgroup _ n
apply ENat.add_left_injective_of_ne_top ENat.one_ne_top
simp only
rw [← Nat.cast_one, ← Nat.cast_add, ← hs]
apply congr_arg₂ _ _ rfl
rw [show s = g⁻¹ • s' from by simp [hs'],
← Set.image_smul, (MulAction.injective g⁻¹).encard_image, hst]
rw [Set.encard_insert_of_notMem, Subtype.coe_injective.encard_image, ENat.coe_one]
exact notMem_val_image M t
/-- The fixator of a subset of cardinal `d` in an `n`-primitive action
acts `n-d`-primitively on the remaining (`d ≤ n`) -/
@[to_additive]
theorem ofFixingSubgroup.isMultiplyPreprimitive
{m n : ℕ} [IsMultiplyPreprimitive M α n] {s : Set α} [Finite s] (hs : s.ncard + m = n) :
IsMultiplyPreprimitive (fixingSubgroup M s) (SubMulAction.ofFixingSubgroup M s) m where
isMultiplyPretransitive := by
apply ofFixingSubgroup.isMultiplyPretransitive _ s hs
isPreprimitive_ofFixingSubgroup {t} ht := by
let t' : Set α := Subtype.val '' t
have htt' : t = Subtype.val ⁻¹' t' :=
(Set.preimage_image_eq _ Subtype.coe_injective).symm
rw [htt']
suffices IsPreprimitive (fixingSubgroup M (s ∪ t')) (ofFixingSubgroup M (s ∪ t')) by
apply IsPreprimitive.of_surjective map_ofFixingSubgroupUnion_bijective.surjective
apply IsMultiplyPreprimitive.isPreprimitive_ofFixingSubgroup _ n
rw [Set.encard_union_eq _]
· rw [Subtype.coe_injective.encard_image, add_assoc, ht,
← hs, Nat.cast_add, Set.Finite.cast_ncard_eq]
exact Set.toFinite s
· apply disjoint_val_image
/-- `n.succ`-pretransitivity implies `n`-preprimitivity. -/
@[to_additive /-- `n.succ`-pretransitivity implies `n`-preprimitivity. -/]
theorem isMultiplyPreprimitive_of_isMultiplyPretransitive_succ {n : ℕ}
(hα : ↑n.succ ≤ ENat.card α) [IsMultiplyPretransitive M α n.succ] :
IsMultiplyPreprimitive M α n := by
rcases Nat.eq_zero_or_pos n with hn | hn
· rw [hn]
exact is_zero_preprimitive M α
rw [isMultiplyPreprimitive_iff]
constructor
· exact isMultiplyPretransitive_of_le' (Nat.le_succ n) hα
· intro s hs
obtain ⟨m, hm⟩ := Nat.exists_eq_add_of_le hn
apply isPreprimitive_of_is_two_pretransitive
have hs' : s.encard = m := by
simp [hm, add_comm 1] at hs
exact ENat.add_left_injective_of_ne_top ENat.one_ne_top hs
have : Finite s := Set.finite_of_encard_eq_coe hs'
apply ofFixingSubgroup.isMultiplyPretransitive (G := M) s (n := n.succ)
simp [Set.ncard, hs', hm, add_comm 1]
/-- An `n`-preprimitive action is `m`-preprimitive for `m ≤ n`. -/
@[to_additive /-- An `n`-preprimitive action is `m`-preprimitive for `m ≤ n`. -/]
theorem isMultiplyPreprimitive_of_le
{n : ℕ} (hn : IsMultiplyPreprimitive M α n)
{m : ℕ} (hmn : m ≤ n) (hα : ↑n ≤ ENat.card α) :
IsMultiplyPreprimitive M α m := by
induction n with
| zero => rw [Nat.eq_zero_of_le_zero hmn]; exact hn
| succ n hrec =>
rcases Nat.eq_or_lt_of_le hmn with hmn | hmn'
· rw [hmn]; exact hn
· apply hrec
(isMultiplyPreprimitive_of_isMultiplyPretransitive_succ M α hα)
(Nat.lt_succ_iff.mp hmn')
· refine le_trans ?_ hα; rw [ENat.coe_le_coe]; exact Nat.le_succ n
variable {M α}
@[to_additive]
theorem IsMultiplyPreprimitive.of_bijective_map
{N β : Type*} [Group N] [MulAction N β] {φ : M → N}
{f : α →ₑ[φ] β} (hf : Function.Bijective f) {n : ℕ}
(h : IsMultiplyPreprimitive M α n) :
IsMultiplyPreprimitive N β n where
isMultiplyPretransitive := IsPretransitive.of_embedding hf.surjective
isPreprimitive_ofFixingSubgroup {t} ht := by
let s := f ⁻¹' t
have hs' : f '' s = t := Set.image_preimage_eq t hf.surjective
let φ' : fixingSubgroup M s → fixingSubgroup N t := fun ⟨m, hm⟩ ↦
⟨φ m, fun ⟨y, hy⟩ => by
rw [← hs', Set.mem_image] at hy
obtain ⟨x, hx, hx'⟩ := hy
simp only
rw [← hx', ← map_smulₛₗ]
apply congr_arg
rw [mem_fixingSubgroup_iff] at hm
exact hm x hx⟩
let f' : SubMulAction.ofFixingSubgroup M s →ₑ[φ'] SubMulAction.ofFixingSubgroup N t :=
{ toFun := fun ⟨x, hx⟩ => ⟨f.toFun x, fun h => hx (Set.mem_preimage.mp h)⟩
map_smul' := fun ⟨m, hm⟩ ⟨x, hx⟩ =>
by
rw [← SetLike.coe_eq_coe]
exact f.map_smul' m x }
have hf' : Function.Surjective f' := by
rintro ⟨y, hy⟩
obtain ⟨x, hx⟩ := hf.right y
use ⟨x, ?_⟩
· simpa only [f', ← Subtype.coe_inj] using hx
· intro h
apply hy
rw [← hs']
exact ⟨x, h, hx⟩
have : IsPreprimitive (fixingSubgroup M s) (ofFixingSubgroup M s) :=
IsMultiplyPreprimitive.isPreprimitive_ofFixingSubgroup _ n
(by rw [← ht, ← hs', hf.injective.encard_image])
exact IsPreprimitive.of_surjective (f := f') (φ := φ') hf'
@[to_additive]
theorem isMultiplyPreprimitive_congr
{N β : Type*} [Group N] [MulAction N β] {φ : M → N} (hφ : Function.Surjective φ)
{f : α →ₑ[φ] β} (hf : Function.Bijective f) {n : ℕ} :
IsMultiplyPreprimitive M α n ↔ IsMultiplyPreprimitive N β n := by
refine ⟨IsMultiplyPreprimitive.of_bijective_map hf, ?_⟩
intro H
rw [isMultiplyPreprimitive_iff]
constructor
· exact (IsPretransitive.of_embedding_congr hφ hf).mpr H.isMultiplyPretransitive
· intro s hs
let t := f '' s
let ψ : fixingSubgroup M s → fixingSubgroup N t := fun ⟨g, hg⟩ ↦ ⟨φ g, by
simp only [mem_fixingSubgroup_iff] at hg ⊢
intro y hy
suffices ∃ x ∈ s, y = f x by
obtain ⟨x, hx, rfl⟩ := this
rwa [← map_smulₛₗ, hg]
obtain ⟨x, rfl⟩ := hf.surjective y
simpa only [Set.mem_image, t, eq_comm] using hy⟩
let g : ofFixingSubgroup M s →ₑ[ψ] ofFixingSubgroup N t := {
toFun x := ⟨f x.val, by
simp [mem_ofFixingSubgroup_iff, t, hf.injective.eq_iff]
exact x.prop⟩
map_smul' m x := by simp [subgroup_smul_def, map_smulₛₗ, ψ] }
rw [isPreprimitive_congr (f := g)]
· apply H.isPreprimitive_ofFixingSubgroup
simp [← hs, t, hf.injective.injOn.encard_image]
· rintro ⟨k, hk⟩
obtain ⟨k, rfl⟩ := hφ k
suffices k ∈ fixingSubgroup M s by
use ⟨k, this⟩
simp only [mem_fixingSubgroup_iff, t] at hk ⊢
intro y hy
apply hf.injective
rw [map_smulₛₗ, hk]
exact Set.mem_image_of_mem (⇑f) hy
· constructor
· rintro ⟨x, hx⟩ ⟨y, hy⟩ h
suffices f x = f y by
simpa [← Subtype.coe_inj, hf.injective.eq_iff] using this
simpa only [g, ← Subtype.coe_inj] using h
· rintro ⟨x, hx⟩
obtain ⟨y, rfl⟩ := hf.surjective x
suffices y ∈ ofFixingSubgroup M s by
exact ⟨⟨y, this⟩, rfl⟩
simp only [mem_ofFixingSubgroup_iff, Set.mem_image, not_exists, not_and, t] at hx ⊢
exact fun hy ↦ hx y hy rfl
end MulAction |
.lake/packages/mathlib/Mathlib/GroupTheory/GroupAction/MultipleTransitivity.lean | import Mathlib.GroupTheory.GroupAction.Primitive
import Mathlib.GroupTheory.SpecificGroups.Alternating
import Mathlib.GroupTheory.GroupAction.SubMulAction.OfFixingSubgroup
import Mathlib.SetTheory.Cardinal.Embedding
import Mathlib.SetTheory.Cardinal.Arithmetic
/-! # Multiple transitivity
* `MulAction.IsMultiplyPretransitive`:
A multiplicative action of a group `G` on a type `α` is n-transitive
if the action of `G` on `Fin n ↪ α` is pretransitive.
* `MulAction.is_zero_pretransitive` : any action is 0-pretransitive
* `MulAction.is_one_pretransitive_iff` :
An action is 1-pretransitive iff it is pretransitive
* `MulAction.is_two_pretransitive_iff` :
An action is 2-pretransitive if for any `a`, `b`, `c`, `d`, such that
`a ≠ b` and `c ≠ d`, there exist `g : G` such that `g • a = b` and `g • c = d`.
* `MulAction.isPreprimitive_of_is_two_pretransitive` :
A 2-transitive action is preprimitive
* `MulAction.isMultiplyPretransitive_of_le` :
If an action is `n`-pretransitive, then it is `m`-pretransitive for all `m ≤ n`,
provided `α` has at least `n` elements.
## Results for permutation groups
* The permutation group is pretransitive, is multiply pretransitive,
and is preprimitive (for its natural action)
* `Equiv.Perm.eq_top_if_isMultiplyPretransitive`:
a subgroup of `Equiv.Perm α` which is `Nat.card α - 1` pretransitive is equal to `⊤`.
## Remarks on implementation
These results are results about actions on types `n ↪ α` induced by an action
on `α`, and some results are developed in this context.
-/
open MulAction MulActionHom Function.Embedding Fin Set Nat
section Functoriality
variable {G α : Type*} [Group G] [MulAction G α]
variable {H β : Type*} [Group H] [MulAction H β]
variable {σ : G → H} {f : α →ₑ[σ] β} {ι : Type*}
variable (ι) in
/-- An injective equivariant map `α →ₑ[σ] β` induces
an equivariant map on embedding types `(ι ↪ α) → (ι ↪ β)`. -/
@[to_additive /-- An injective equivariant map `α →ₑ[σ] β` induces
an equivariant map on embedding types `(ι ↪ α) → (ι ↪ β)`. -/]
def Function.Injective.mulActionHom_embedding (hf : Function.Injective f) :
(ι ↪ α) →ₑ[σ] (ι ↪ β) where
toFun x := ⟨f.toFun ∘ x.toFun, hf.comp x.inj'⟩
map_smul' m x := by ext; simp [f.map_smul']
@[to_additive (attr := simp)]
theorem Function.Injective.mulActionHom_embedding_apply
(hf : Function.Injective f) {x : ι ↪ α} {i : ι} :
hf.mulActionHom_embedding ι x i = f (x i) := rfl
@[to_additive]
theorem Function.Injective.mulActionHom_embedding_isInjective
(hf : Function.Injective f) :
Function.Injective (hf.mulActionHom_embedding ι) := by
intro _ _ hxy
ext
apply hf
simp only [← hf.mulActionHom_embedding_apply, hxy]
variable (hf' : Function.Bijective f)
@[to_additive]
theorem Function.Bijective.mulActionHom_embedding_isBijective (hf : Function.Bijective f) :
Function.Bijective (hf.injective.mulActionHom_embedding ι) := by
refine ⟨hf.injective.mulActionHom_embedding_isInjective, ?_⟩
intro y
obtain ⟨g, _, hfg⟩ := Function.bijective_iff_has_inverse.mp hf
use ⟨g ∘ y, hfg.injective.comp (EmbeddingLike.injective y)⟩
ext
simp only [hf.injective.mulActionHom_embedding_apply, coeFn_mk, comp_apply]
exact hfg (y _)
end Functoriality
namespace MulAction
open scoped BigOperators Pointwise Cardinal
variable {G α : Type*} [Group G] [MulAction G α]
variable (G α) in
/-- An action of a group on a type `α` is `n`-pretransitive
if the associated action on `Fin n ↪ α` is pretransitive. -/
@[to_additive /-- An additive action of an additive group on a type `α`
is `n`-pretransitive if the associated action on `Fin n ↪ α` is pretransitive. -/]
abbrev IsMultiplyPretransitive (n : ℕ) := IsPretransitive G (Fin n ↪ α)
@[to_additive]
theorem isMultiplyPretransitive_iff {n : ℕ} :
IsMultiplyPretransitive G α n ↔ ∀ x y : Fin n ↪ α, ∃ g : G, g • x = y :=
isPretransitive_iff _ _
variable {H β : Type*} [Group H] [MulAction H β] {σ : G → H}
{f : α →ₑ[σ] β} (hf : Function.Injective f)
/- If there exists a surjective equivariant map `α →ₑ[σ] β`
then pretransitivity descends from `n ↪ α` to `n ↪ β`.
The subtlety is that if it is not injective, this map does not induce
an equivariant map from `n ↪ α` to `n ↪ β`. -/
@[to_additive]
theorem IsPretransitive.of_embedding {n : Type*}
(hf : Function.Surjective f) [IsPretransitive G (n ↪ α)] :
IsPretransitive H (n ↪ β) where
exists_smul_eq x y := by
let aux (x : n ↪ β) : (n ↪ α) :=
x.trans (Function.Embedding.ofSurjective (⇑f) hf)
have aux_apply (x : n ↪ β) (i : n) : f.toFun (aux x i) = x i := by
simp only [trans_apply, aux]
apply Function.surjInv_eq
obtain ⟨g, hg⟩ := exists_smul_eq (M := G) (aux x) (aux y)
use σ g
ext i
rw [DFunLike.ext_iff] at hg
rw [smul_apply]
simp [← aux_apply, ← hg, MulActionHom.map_smul']
@[to_additive]
theorem IsPretransitive.of_embedding_congr {n : Type*}
(hσ : Function.Surjective σ) (hf : Function.Bijective f) :
IsPretransitive G (n ↪ α) ↔ IsPretransitive H (n ↪ β) :=
isPretransitive_congr hσ hf.mulActionHom_embedding_isBijective
section Zero
/-- Any action is 0-pretransitive. -/
@[to_additive]
theorem is_zero_pretransitive {n : Type*} [IsEmpty n] :
IsPretransitive G (n ↪ α) := inferInstance
/-- Any action is 0-pretransitive. -/
@[to_additive]
theorem is_zero_pretransitive' :
IsMultiplyPretransitive G α 0 := inferInstance
end Zero
section One
variable {one : Type*} [Unique one]
/-- For `Unique one`, the equivariant map from `one ↪ α` to `α`. -/
@[to_additive /-- For `Unique one`, the equivariant map from `one ↪ α` to `α` -/]
def _root_.MulActionHom.oneEmbeddingMap :
(one ↪ α) →[G] α := {
oneEmbeddingEquiv with
map_smul' _ _ := rfl }
@[to_additive]
theorem _root_.MulActionHom.oneEmbeddingMap_bijective :
Function.Bijective (oneEmbeddingMap (one := one) (G := G) (α := α)) :=
oneEmbeddingEquiv.bijective
/-- An action is `1`-pretransitive iff it is pretransitive. -/
@[to_additive /-- An additive action is `1`-pretransitive iff it is pretransitive. -/]
theorem oneEmbedding_isPretransitive_iff :
IsPretransitive G (one ↪ α) ↔ IsPretransitive G α :=
isPretransitive_congr Function.surjective_id oneEmbeddingMap_bijective
/-- An action is `1`-pretransitive iff it is pretransitive. -/
@[to_additive /-- An additive action is `1`-pretransitive iff it is pretransitive. -/]
theorem is_one_pretransitive_iff :
IsMultiplyPretransitive G α 1 ↔ IsPretransitive G α :=
oneEmbedding_isPretransitive_iff
end One
section Two
/-- An action is `2`-pretransitive iff
it can move any two distinct elements to any two distinct elements. -/
@[to_additive /-- An additive action is `2`-pretransitive iff
it can move any two distinct elements to any two distinct elements. -/]
theorem is_two_pretransitive_iff :
IsMultiplyPretransitive G α 2 ↔
∀ {a b c d : α} (_ : a ≠ b) (_ : c ≠ d), ∃ g : G, g • a = c ∧ g • b = d := by
constructor
· intro _ a b c d h h'
obtain ⟨m, e⟩ := exists_smul_eq (M := G) (embFinTwo h) (embFinTwo h')
exact ⟨m,
by rw [← embFinTwo_apply_zero h, ← smul_apply, e, embFinTwo_apply_zero],
by rw [← embFinTwo_apply_one h, ← smul_apply, e, embFinTwo_apply_one]⟩
· intro H
constructor
intro j j'
obtain ⟨g, h, h'⟩ :=
H (j.injective.ne_iff.mpr Fin.zero_ne_one) (j'.injective.ne_iff.mpr Fin.zero_ne_one)
use g
ext i
by_cases hi : i = 0
· simp [hi, h]
· simp [eq_one_of_ne_zero i hi, h']
/-- A `2`-pretransitive action is pretransitive. -/
@[to_additive /-- A `2`-pretransitive additive action is pretransitive. -/]
theorem isPretransitive_of_is_two_pretransitive
[h2 : IsMultiplyPretransitive G α 2] : IsPretransitive G α where
exists_smul_eq a b := by
by_cases h : a = b
· exact ⟨1, by simp [h]⟩
· rw [is_two_pretransitive_iff] at h2
obtain ⟨g, h, _⟩ := h2 h (Ne.symm h)
exact ⟨g, h⟩
/-- A `2`-transitive action is primitive. -/
@[to_additive /-- A `2`-transitive additive action is primitive. -/]
theorem isPreprimitive_of_is_two_pretransitive
(h2 : IsMultiplyPretransitive G α 2) : IsPreprimitive G α := by
have : IsPretransitive G α := isPretransitive_of_is_two_pretransitive
apply IsPreprimitive.mk
intro B hB
rcases B.subsingleton_or_nontrivial with h | h
· left
exact h
· right
obtain ⟨a, ha, b, hb, h⟩ := h
rw [← top_eq_univ, eq_top_iff]
intro c _
by_cases h' : a = c
· rw [← h']; exact ha
· rw [is_two_pretransitive_iff] at h2
obtain ⟨g, hga, hgb⟩ := h2 h h'
rw [MulAction.isBlock_iff_smul_eq_of_mem] at hB
rw [← hB (g := g) ha (by rw [hga]; exact ha), ← hgb]
exact smul_mem_smul_set hb
end Two
section Higher
variable (G α) in
/-- The natural equivariant map from `n ↪ α` to `m ↪ α` given by an embedding
`e : m ↪ n`. -/
@[to_additive
/-- The natural equivariant map from `n ↪ α` to `m ↪ α` given by an embedding `e : m ↪ n`. -/]
def _root_.MulActionHom.embMap {m n : Type*} (e : m ↪ n) :
(n ↪ α) →[G] (m ↪ α) where
toFun i := e.trans i
map_smul' _ _ := rfl
/-- If `α` has at least `n` elements, then any `n`-pretransitive action on `α`
is `m`-pretransitive for any `m ≤ n`.
This version allows `α` to be infinite and uses `ENat.card`.
For `Finite α`, use `MulAction.isMultiplyPretransitive_of_le` -/
@[to_additive
/-- If `α` has at least `n` elements, then any `n`-pretransitive action on `α`
is `n`-pretransitive for any `m ≤ n`.
This version allows `α` to be infinite and uses `ENat.card`.
For `Finite α`, use `AddAction.isMultiplyPretransitive_of_le`. -/]
theorem isMultiplyPretransitive_of_le' {m n : ℕ} [IsMultiplyPretransitive G α n]
(hmn : m ≤ n) (hα : n ≤ ENat.card α) :
IsMultiplyPretransitive G α m := by
obtain ⟨p, rfl⟩ := Nat.exists_eq_add_of_le hmn
exact IsPretransitive.of_surjective_map
(f := embMap G α (castAddEmb p))
(Fin.Embedding.restrictSurjective_of_add_le_ENatCard hα) inferInstance
/-- If `α` has at least `n` elements, then an `n`-pretransitive action
is `m`-pretransitive for any `m ≤ n`.
For an infinite `α`, use `MulAction.isMultiplyPretransitive_of_le'`. -/
@[to_additive
/-- If `α` has at least `n` elements, then an `n`-pretransitive action
is `m`-pretransitive for any `m ≤ n`.
For an infinite `α`, use `MulAction.isMultiplyPretransitive_of_le'`. -/]
theorem isMultiplyPretransitive_of_le {m n : ℕ} [IsMultiplyPretransitive G α n]
(hmn : m ≤ n) (hα : n ≤ Nat.card α) [Finite α] :
IsMultiplyPretransitive G α m := by
obtain ⟨p, rfl⟩ := Nat.exists_eq_add_of_le hmn
exact IsPretransitive.of_surjective_map (f := embMap G α (castAddEmb p))
(Fin.Embedding.restrictSurjective_of_add_le_natCard hα) inferInstance
end Higher
end MulAction
namespace SubMulAction.ofStabilizer
variable {G α : Type*} [Group G] [MulAction G α]
open scoped BigOperators Pointwise Cardinal
@[to_additive]
theorem isMultiplyPretransitive_iff_of_conj
{n : ℕ} {a b : α} {g : G} (hg : b = g • a) :
IsMultiplyPretransitive (stabilizer G a) (ofStabilizer G a) n ↔
IsMultiplyPretransitive (stabilizer G b) (ofStabilizer G b) n :=
IsPretransitive.of_embedding_congr (MulEquiv.surjective _) (ofStabilizer.conjMap_bijective hg)
@[to_additive]
theorem isMultiplyPretransitive_iff [IsPretransitive G α] {n : ℕ} {a b : α} :
IsMultiplyPretransitive (stabilizer G a) (ofStabilizer G a) n ↔
IsMultiplyPretransitive (stabilizer G b) (ofStabilizer G b) n :=
let ⟨_, hg⟩ := exists_smul_eq G a b
isMultiplyPretransitive_iff_of_conj hg.symm
/-- Multiple transitivity of a pretransitive action
is equivalent to one less transitivity of stabilizer of a point
(Wielandt, th. 9.1, 1st part) -/
@[to_additive /-- Multiple transitivity of a pretransitive action
is equivalent to one less transitivity of stabilizer of a point
[Wielandt, th. 9.1, 1st part][Wielandt-1964]. -/]
theorem isMultiplyPretransitive [IsPretransitive G α] {n : ℕ} {a : α} :
IsMultiplyPretransitive G α n.succ ↔
IsMultiplyPretransitive (stabilizer G a) (SubMulAction.ofStabilizer G a) n := by
refine ⟨fun hn ↦ ⟨fun x y ↦ ?_⟩, fun hn ↦ ⟨fun x y ↦ ?_⟩⟩
· obtain ⟨g, hgxy⟩ := exists_smul_eq G (ofStabilizer.snoc x) (ofStabilizer.snoc y)
have hg : g ∈ stabilizer G a := by
rw [mem_stabilizer_iff]
rw [DFunLike.ext_iff] at hgxy
convert hgxy (last n) <;> simp [smul_apply, ofStabilizer.snoc_last]
use ⟨g, hg⟩
ext i
simp only [smul_apply, SubMulAction.val_smul_of_tower, subgroup_smul_def]
rw [← ofStabilizer.snoc_castSucc x, ← smul_apply, hgxy, ofStabilizer.snoc_castSucc]
· -- gx • x = x1 :: a
obtain ⟨gx, x1, hgx⟩ := exists_smul_of_last_eq G a x
-- gy • y = y1 :: a
obtain ⟨gy, y1, hgy⟩ := exists_smul_of_last_eq G a y
-- g • x1 = y1,
obtain ⟨g, hg⟩ := hn.exists_smul_eq x1 y1
use gy⁻¹ * g * gx
ext i
simp only [mul_smul, smul_apply, inv_smul_eq_iff]
simp only [← smul_apply _ _ i, hgy, hgx]
simp only [smul_apply]
rcases Fin.eq_castSucc_or_eq_last i with ⟨i, rfl⟩ | ⟨rfl⟩
· simp [ofStabilizer.snoc_castSucc, ← hg, SetLike.val_smul, subgroup_smul_def]
· simp only [ofStabilizer.snoc_last, ← hg]
exact g.prop
end ofStabilizer
namespace ofFixingSubgroup
variable {G α : Type*} [Group G] [MulAction G α]
open SubMulAction Fin.Embedding
variable (G) in
/-- The `fixingSubgroup` of a finite subset of cardinal `d`
in an `n`-transitive action acts `n-d`-transitively on the complement. -/
@[to_additive /-- The `fixingSubgroup` of a finite subset of cardinal `d`
in an `n`-transitive additive action acts `n-d`-transitively on the complement. -/]
theorem isMultiplyPretransitive {m n : ℕ} [Hn : IsMultiplyPretransitive G α n]
(s : Set α) [Finite s] (hmn : s.ncard + m = n) :
IsMultiplyPretransitive (fixingSubgroup G s) (ofFixingSubgroup G s) m where
exists_smul_eq x y := by
have : IsMultiplyPretransitive G α (s.ncard + m) := by rw [hmn]; infer_instance
have Hs : Nonempty (Fin (s.ncard) ≃ s) :=
Finite.card_eq.mp (by simp [Nat.card_coe_set_eq])
set x' := ofFixingSubgroup.append x with hx
set y' := ofFixingSubgroup.append y with hy
obtain ⟨g, hg⟩ := exists_smul_eq G x' y'
suffices g ∈ fixingSubgroup G s by
use ⟨g, this⟩
ext i
rw [smul_apply, SetLike.val_smul, Subgroup.mk_smul]
simp [← ofFixingSubgroup.append_right, ← smul_apply, ← hx, ← hy, hg]
intro a
set i := (Classical.choice Hs).symm a
have ha : (Classical.choice Hs) i = a := by simp [i]
rw [← ha]
nth_rewrite 1 [← ofFixingSubgroup.append_left x i]
rw [← ofFixingSubgroup.append_left y i, ← hy, ← hg, smul_apply, ← hx]
/-- The fixator of a finite subset of cardinal d in an n-transitive action
acts m transitively on the complement if d + m ≤ n. -/
@[to_additive /-- The fixator of a finite subset of cardinal d in an n-transitive additive action
acts m transitively on the complement if d + m ≤ n. -/]
theorem isMultiplyPretransitive'
{m n : ℕ} [IsMultiplyPretransitive G α n]
(s : Set α) [Finite s] (hmn : s.ncard + m ≤ n) (hn : (n : ENat) ≤ ENat.card α) :
IsMultiplyPretransitive (fixingSubgroup G s) (SubMulAction.ofFixingSubgroup G s) m :=
letI : IsMultiplyPretransitive G α (s.ncard + m) := isMultiplyPretransitive_of_le' hmn hn
isMultiplyPretransitive G s rfl
end ofFixingSubgroup
end SubMulAction
namespace MulAction
section Index
open SubMulAction
variable {G : Type*} [Group G] {α : Type*} [MulAction G α]
/-- For a multiply pretransitive action, computes the index
of the fixing_subgroup of a subset of adequate cardinality -/
theorem IsMultiplyPretransitive.index_of_fixingSubgroup_mul
[Finite α]
{k : ℕ} (Hk : IsMultiplyPretransitive G α k)
{s : Set α} (hs : s.ncard = k) :
(fixingSubgroup G s).index * (Nat.card α - k).factorial =
(Nat.card α).factorial := by
induction k generalizing G α with
| zero =>
rw [Set.ncard_eq_zero] at hs
simp [hs]
| succ k hrec =>
have hGX : IsPretransitive G α := by
rw [← is_one_pretransitive_iff]
apply isMultiplyPretransitive_of_le (n := k + 1)
· rw [Nat.succ_le_succ_iff]; apply Nat.zero_le
· rw [← hs, ← Set.ncard_univ]
exact ncard_le_ncard s.subset_univ finite_univ
have : s.Nonempty := by
rw [← Set.ncard_pos, hs]
exact succ_pos k
obtain ⟨a, has⟩ := this
let t : Set (SubMulAction.ofStabilizer G a) := Subtype.val ⁻¹' s
have hat : Subtype.val '' t = s \ {a} := by
rw [Set.image_preimage_eq_inter_range]
simp only [Subtype.range_coe_subtype]
rw [Set.diff_eq_compl_inter, Set.inter_comm]
congr
have hat' : s = insert a (Subtype.val '' t) := by
rw [hat, Set.insert_diff_singleton, Set.insert_eq_of_mem has]
have hfs := SubMulAction.fixingSubgroup_of_insert a t
rw [← hat'] at hfs
rw [hfs, Subgroup.index_map,
(MonoidHom.ker_eq_bot_iff (stabilizer G a).subtype).mpr
(by simp only [Subgroup.coe_subtype, Subtype.coe_injective])]
simp only [sup_bot_eq, Subgroup.range_subtype]
have htcard : t.ncard = k := by
rw [← Nat.succ_inj, Nat.succ_eq_add_one, Nat.succ_eq_add_one, ← hs, hat', eq_comm]
suffices ¬ a ∈ (Subtype.val '' t) by
convert Set.ncard_insert_of_notMem this ?_
· rw [Set.ncard_image_of_injective _ Subtype.coe_injective]
apply Set.toFinite
intro h
obtain ⟨⟨b, hb⟩, _, hb'⟩ := h
apply hb
simp only [← hb', Set.mem_singleton_iff]
suffices (fixingSubgroup (stabilizer G a) t).index *
(Nat.card α - 1 - k).factorial =
(Nat.card α - 1).factorial by
rw [add_comm k, Nat.mul_right_comm, ← Nat.sub_sub, this, mul_comm,
index_stabilizer_of_transitive G a]
exact Nat.mul_factorial_pred (card_ne_zero.mpr ⟨⟨a⟩, inferInstance⟩)
convert hrec (ofStabilizer.isMultiplyPretransitive.mp Hk) htcard
all_goals { rw [nat_card_ofStabilizer_eq G a] }
/-- For a multiply pretransitive action,
computes the index of the `fixingSubgroup` of a subset
of adequate cardinality. -/
theorem IsMultiplyPretransitive.index_of_fixingSubgroup_eq
[Finite α] (s : Set α) (hMk : IsMultiplyPretransitive G α s.ncard) :
(fixingSubgroup G s).index =
Nat.choose (Nat.card α) s.ncard * s.ncard.factorial := by
apply Nat.eq_of_mul_eq_mul_right (Nat.factorial_pos _)
rw [hMk.index_of_fixingSubgroup_mul rfl, Nat.choose_mul_factorial_mul_factorial]
rw [← ncard_univ]
exact ncard_le_ncard (subset_univ s)
end Index
end MulAction
namespace Equiv.Perm
open Equiv MulAction
variable {α : Type*}
variable (α) in
/-- The permutation group `Equiv.Perm α` acts `n`-pretransitively on `α` for all `n`. -/
theorem isMultiplyPretransitive (n : ℕ) :
IsMultiplyPretransitive (Perm α) α n := by
rw [isMultiplyPretransitive_iff]
classical
intro x y
have (x : Fin n ↪ α) : Cardinal.mk (range x) = n := by
simp [Finset.card_image_of_injective, PLift.down_injective]
have hxy : Cardinal.mk ((range x)ᶜ : Set α) = Cardinal.mk ((range y)ᶜ : Set α) := by
rw [← Cardinal.add_nat_inj n]
nth_rewrite 1 [← this x]
rw [← this y]
simp only [add_comm, Cardinal.mk_sum_compl]
rw [Cardinal.eq] at hxy
obtain ⟨φ⟩ := hxy
let φ' : α → α := Function.extend Subtype.val (fun a ↦ ↑(φ a)) id
set ψ : α → α := Function.extend x y φ'
have : Function.Bijective ψ := by
constructor
· intro a b hab
by_cases ha : a ∈ range x
· obtain ⟨i, rfl⟩ := ha
by_cases hb : b ∈ range x
· obtain ⟨j, rfl⟩ := hb
simp only [ψ, x.injective.extend_apply, y.injective.eq_iff] at hab
rw [hab]
· simp only [ψ, φ', x.injective.extend_apply] at hab
rw [Function.extend_apply' _ _ _ hb] at hab
rw [← Set.mem_compl_iff] at hb
rw [← Subtype.coe_mk b hb, Subtype.val_injective.extend_apply] at hab
exfalso
have : y i ∈ (range y)ᶜ := by
rw [hab]
exact Subtype.coe_prop (φ ⟨b, hb⟩)
rw [Set.mem_compl_iff] at this
apply this
exact mem_range_self i
· by_cases hb : b ∈ range x
· obtain ⟨j, rfl⟩ := hb
simp only [ψ, φ', x.injective.extend_apply] at hab
rw [Function.extend_apply' _ _ _ ha] at hab
rw [← Set.mem_compl_iff] at ha
rw [← Subtype.coe_mk a ha, Subtype.val_injective.extend_apply] at hab
exfalso
have : y j ∈ (range y)ᶜ := by
rw [← hab]
exact Subtype.coe_prop (φ ⟨a, ha⟩)
rw [Set.mem_compl_iff] at this
apply this
exact mem_range_self j
· simp only [ψ, Function.extend_apply' _ _ _ ha,
Function.extend_apply' _ _ _ hb, φ'] at hab
rw [← Set.mem_compl_iff] at ha hb
rw [← Subtype.coe_mk b hb, ← Subtype.coe_mk a ha] at hab
rw [Subtype.val_injective.extend_apply, Subtype.val_injective.extend_apply] at hab
rwa [← Subtype.coe_mk a ha, ← Subtype.coe_mk b hb,
Subtype.coe_inj, ← φ.injective.eq_iff, ← Subtype.coe_inj]
· intro b
by_cases hb : b ∈ range y
· obtain ⟨i, rfl⟩ := hb
use x i
simp only [ψ, x.injective.extend_apply]
· rw [← Set.mem_compl_iff] at hb
use φ.invFun ⟨b, hb⟩
simp only [ψ]
rw [Function.extend_apply' _ _ _ ?_]
· simp only [φ']
set a : α := (φ.invFun ⟨b, hb⟩ : α)
have ha : a ∈ (range x)ᶜ := Subtype.coe_prop (φ.invFun ⟨b, hb⟩)
rw [← Subtype.coe_mk a ha]
simp [a]
· rintro ⟨i, hi⟩
apply Subtype.coe_prop (φ.invFun ⟨b, hb⟩)
rw [← hi]
exact mem_range_self i
use Equiv.ofBijective ψ this
ext i
simp [ψ, x.injective.extend_apply]
/-- The action of the permutation group of `α` on `α` is preprimitive -/
instance : IsPreprimitive (Perm α) α :=
isPreprimitive_of_is_two_pretransitive (isMultiplyPretransitive _ _)
-- This is optimal, `AlternatingGroup α` is `Nat.card α - 2`-pretransitive.
/-- A subgroup of `Perm α` is `⊤` if(f) it is `(Nat.card α - 1)`-pretransitive. -/
theorem eq_top_of_isMultiplyPretransitive [Finite α] {G : Subgroup (Equiv.Perm α)}
(hmt : IsMultiplyPretransitive G α (Nat.card α - 1)) : G = ⊤ := by
have := Fintype.ofFinite α
simp only [Nat.card_eq_fintype_card] at hmt
let j : Fin (Fintype.card α - 1) ↪ Fin (Fintype.card α) :=
(Fin.castLEEmb ((Fintype.card α).sub_le 1))
rw [eq_top_iff]
intro k _
let x : Fin (Fintype.card α) ↪ α := (Fintype.equivFinOfCardEq rfl).symm.toEmbedding
let x' := j.trans x
obtain ⟨g, hg'⟩ := exists_smul_eq G x' (k • x')
suffices k = g by rw [this]; exact SetLike.coe_mem g
have hx (x : Fin (Fintype.card α) ↪ α) : Function.Surjective x.toFun := by
apply Function.Bijective.surjective
rw [Fintype.bijective_iff_injective_and_card]
exact ⟨EmbeddingLike.injective x, Fintype.card_fin (Fintype.card α)⟩
have hgk' (i : Fin (Fintype.card α)) (hi : i.val < Fintype.card α - 1) :
(g • x) i = (k • x) i :=
Function.Embedding.ext_iff.mp hg' ⟨i.val, hi⟩
have hgk (i : Fin (Fintype.card α)) : (g • x) i = (k • x) i := by
rcases lt_or_eq_of_le (le_sub_one_of_lt i.prop) with hi | hi
· exact hgk' i hi
· obtain ⟨j, hxj : (k • x) j = (g • x) i⟩ := hx (k • x) ((g • x) i)
rcases lt_or_eq_of_le (le_sub_one_of_lt j.prop) with hj | hj
· suffices i = j by
rw [← this, ← hi] at hj
exact (lt_irrefl _ hj).elim
apply EmbeddingLike.injective (g • x)
rw [hgk' j hj, hxj]
· rw [← hxj]
apply congr_arg
rw [Fin.ext_iff, hi, hj]
ext a
obtain ⟨i, rfl⟩ := (hx x) a
specialize hgk i
simp only [Function.Embedding.smul_apply, Equiv.Perm.smul_def] at hgk
simp [← hgk, Subgroup.smul_def, Perm.smul_def]
@[deprecated (since := "2025-10-03")]
alias eq_top_if_isMultiplyPretransitive := eq_top_of_isMultiplyPretransitive
end Equiv.Perm
namespace AlternatingGroup
variable (α : Type*) [Fintype α] [DecidableEq α]
/-- The `alternatingGroup` on α is (card α - 2)-pretransitive. -/
theorem isMultiplyPretransitive :
IsMultiplyPretransitive (alternatingGroup α) α (Nat.card α - 2) := by
rcases lt_or_ge (Nat.card α) 2 with h2 | h2
· rw [Nat.sub_eq_zero_of_le (le_of_lt h2)]
apply is_zero_pretransitive
have h2le : Nat.card α - 2 ≤ Nat.card α := sub_le (Nat.card α) 2
have := Equiv.Perm.isMultiplyPretransitive α (Nat.card α)
have : IsMultiplyPretransitive (Equiv.Perm α) α (Nat.card α - 2) :=
MulAction.isMultiplyPretransitive_of_le h2le le_rfl
refine ⟨fun x y ↦ ?_⟩
obtain ⟨g, hg⟩ := exists_smul_eq (Equiv.Perm α) x y
rcases Int.units_eq_one_or (Equiv.Perm.sign g) with h | h
· exact ⟨⟨g, h⟩, hg⟩
· have : (Finset.univ.image x)ᶜ.card = 2 := by
rw [Finset.card_compl, Finset.univ.card_image_of_injective (by exact x.2), Finset.card_univ,
← Nat.card_eq_fintype_card, Fintype.card_fin, tsub_tsub_cancel_of_le h2]
obtain ⟨a, b, hab, hs⟩ := Finset.card_eq_two.mp this
refine ⟨⟨g * Equiv.swap a b, by simp [h, hab]⟩, ?_⟩
ext i
have h : x i ∈ Finset.univ.image x := Finset.mem_image.mpr ⟨i, Finset.mem_univ i, rfl⟩
rw [← Finset.notMem_compl, hs, Finset.mem_insert, Finset.mem_singleton, not_or] at h
simp [Equiv.swap_apply_of_ne_of_ne h.1 h.2, ← hg]
/-- A subgroup of `Equiv.Perm α` which is (card α - 2)-pretransitive
contains `alternatingGroup α`. -/
theorem _root_.IsMultiplyPretransitive.alternatingGroup_le
(G : Subgroup (Equiv.Perm α))
(hmt : IsMultiplyPretransitive G α (Nat.card α - 2)) :
alternatingGroup α ≤ G := by
rcases Nat.lt_or_ge (Nat.card α) 2 with hα1 | hα
· -- Nat.card α < 2
rw [Nat.card_eq_fintype_card] at hα1
rw [alternatingGroup.eq_bot_of_card_le_two hα1.le]
exact bot_le
-- 2 ≤ Nat.card α
apply Equiv.Perm.alternatingGroup_le_of_index_le_two
-- one picks up a set of cardinality (card α - 2)
obtain ⟨s, _, hs⟩ :=
Set.exists_subset_card_eq (s := (Set.univ : Set α)) (n := Nat.card α - 2)
(by rw [Set.ncard_univ]; exact sub_le (Nat.card α) 2)
rw [← hs] at hmt
-- The index of (fixingSubgroup G s) is (card α)!/2
have := hmt.index_of_fixingSubgroup_mul rfl
rw [hs, Nat.sub_sub_self hα, factorial_two] at this
-- conclude
rw [← mul_le_mul_iff_of_pos_left (a := Nat.card G) card_pos,
Subgroup.card_mul_index, ← (fixingSubgroup G s).index_mul_card,
mul_assoc, mul_comm _ 2, ← mul_assoc]
rw [this, Nat.card_perm]
refine Nat.le_mul_of_pos_right (Nat.card α)! card_pos
/-- The alternating group on 3 letters or more acts transitively. -/
theorem isPretransitive_of_three_le_card (h : 3 ≤ Nat.card α) :
IsPretransitive (alternatingGroup α) α := by
rw [← is_one_pretransitive_iff]
letI := isMultiplyPretransitive α
apply isMultiplyPretransitive_of_le (n := Nat.card α - 2) _ (sub_le _ _)
rwa [← add_le_add_iff_right 2, Nat.sub_add_cancel (le_trans (by norm_num) h)]
open scoped Pointwise
/-- The action of the alternating group has trivial blocks.
This holds for any `α`, even when `Nat.card α ≤ 2` and the action
is not preprimitive, because it is not pretransitive. -/
theorem isTrivialBlock_of_isBlock {B : Set α} (hB : IsBlock (alternatingGroup α) B) :
IsTrivialBlock B := by
rcases le_or_gt (Nat.card α) 2 with h2 | h2
· exact isTrivialBlock_of_card_le_two h2 B
rcases le_or_gt (Nat.card α) 3 with h3 | h4
· replace h3 : Nat.card α = 3 := le_antisymm h3 h2
have : IsPretransitive (alternatingGroup α) α := isPretransitive_of_three_le_card α h3.ge
have : IsPreprimitive (alternatingGroup α) α := IsPreprimitive.of_prime_card (h3 ▸ prime_three)
exact this.isTrivialBlock_of_isBlock hB
-- IsTrivialBlock hB, for 4 ≤ Nat.card α
suffices IsPreprimitive (alternatingGroup α) α by
apply IsPreprimitive.isTrivialBlock_of_isBlock hB
apply isPreprimitive_of_is_two_pretransitive
letI := isMultiplyPretransitive α
apply isMultiplyPretransitive_of_le (n := Nat.card α - 2) _ (sub_le _ _)
rwa [← add_le_add_iff_right 2, Nat.sub_add_cancel (le_of_lt h2)]
/-- The alternating group on 3 letters or more acts primitively -/
theorem isPreprimitive_of_three_le_card (h : 3 ≤ Nat.card α) :
IsPreprimitive (alternatingGroup α) α :=
letI := isPretransitive_of_three_le_card α h
{ isTrivialBlock_of_isBlock := isTrivialBlock_of_isBlock α }
end AlternatingGroup |
.lake/packages/mathlib/Mathlib/GroupTheory/GroupAction/Transitive.lean | import Mathlib.GroupTheory.GroupAction.Defs
import Mathlib.GroupTheory.GroupAction.Hom
/-! # Complements to pretransitive actions
When `f : X →ₑ[φ] Y` is an equivariant map with respect to a map
of monoids `φ: M → N`,
- `MulAction.IsPretransitive.of_surjective_map` shows that
the action of `N` on `Y` is pretransitive
if that of `M` on `X` is pretransitive.
- `MulAction.isPretransitive_congr` shows that when
`φ` is surjective, the action of `N` on `Y` is pretransitive
iff that of `M` on `X` is pretransitive.
Given `MulAction G X` where `G` is a group,
- `MulAction.isPretransitive_iff_base G a` shows that `IsPretransitive G X`
iff every element is translated from `a`
- `MulAction.isPretransitive_iff_orbit_eq_univ G a` shows that `MulAction.IsPretransitive G X`
iff `MulAction.orbit G a` is full.
-/
variable {G X : Type*} [Group G] [MulAction G X]
namespace MulAction
/-- An action of a group is pretransitive iff any element can be moved from a fixed given one. -/
@[to_additive
/-- An additive action of an additive group is pretransitive
iff any element can be moved from a fixed given one. -/]
theorem isPretransitive_iff_base (a : X) :
IsPretransitive G X ↔ ∀ x : X, ∃ g : G, g • a = x where
mp hG x := exists_smul_eq _ a x
mpr hG := .mk fun x y ↦ by
obtain ⟨g, hx⟩ := hG x
obtain ⟨h, hy⟩ := hG y
exact ⟨h * g⁻¹, by rw [← hx, smul_smul, inv_mul_cancel_right, hy]⟩
/-- An action of a group is pretransitive iff the orbit of every given element is full -/
@[to_additive
/-- An action of a group is pretransitive iff the orbit of every given element is full -/]
theorem isPretransitive_iff_orbit_eq_univ (a : X) :
IsPretransitive G X ↔ orbit G a = .univ := by
rw [isPretransitive_iff_base a, Set.ext_iff]
apply forall_congr'
intro x
simp_rw [Set.mem_univ, iff_true, mem_orbit_iff]
variable {M N α β : Type*} [Monoid M] [Monoid N] [MulAction M α] [MulAction N β]
@[to_additive]
theorem IsPretransitive.of_surjective_map {φ : M → N} {f : α →ₑ[φ] β}
(hf : Function.Surjective f) (h : IsPretransitive M α) :
IsPretransitive N β := by
apply MulAction.IsPretransitive.mk
intro x y
obtain ⟨x', rfl⟩ := hf x
obtain ⟨y', rfl⟩ := hf y
obtain ⟨g, rfl⟩ := h.exists_smul_eq x' y'
exact ⟨φ g, by simp only [map_smulₛₗ]⟩
@[to_additive]
theorem isPretransitive_congr {φ : M → N} {f : α →ₑ[φ] β}
(hφ : Function.Surjective φ) (hf : Function.Bijective f) :
IsPretransitive M α ↔ IsPretransitive N β := by
constructor
· apply IsPretransitive.of_surjective_map hf.surjective
· intro hN
apply IsPretransitive.mk
intro x y
obtain ⟨k, hk⟩ := hN.exists_smul_eq (f x) (f y)
obtain ⟨g, rfl⟩ := hφ k
use g
apply hf.injective
simp only [hk, map_smulₛₗ]
end MulAction |
.lake/packages/mathlib/Mathlib/GroupTheory/GroupAction/Jordan.lean | import Mathlib.Algebra.Group.Pointwise.Set.Card
import Mathlib.Data.Set.Card
import Mathlib.GroupTheory.GroupAction.MultiplePrimitivity
/-! # Theorems of Jordan
A proof of theorems of Jordan regarding primitive permutation groups.
This mostly follows the book [Wielandt, *Finite permutation groups*][Wielandt-1964].
- `MulAction.IsPreprimitive.is_two_pretransitive` and
`MulAction.IsPreprimitive.is_two_preprimitive` are technical lemmas
that prove 2-pretransitivity / 2-preprimitivity for some group
primitive actions given the transitivity / primitivity of
`ofFixingSubgroup G s` (Wielandt, 13.1)
- `MulAction.IsPreprimitive.isMultiplyPreprimitive`:
A multiple preprimitivity criterion of Jordan (1871) for a preprimitive
action: the hypothesis is the preprimitivity of the `SubMulAction`
of `fixingSubgroup s` on `ofFixingSubgroup G s` (Wielandt, 13.2)
- `Equiv.Perm.eq_top_of_isPreprimitive_of_isSwap_mem` :
a primitive subgroup of a permutation group that contains a
swap is equal to the full permutation group (Wielandt, 13.3)
- `Equiv.Perm.alternatingGroup_le_of_isPreprimitive_of_isThreeCycle_mem` :
a primitive subgroup of a permutation group that contains a 3-cycle
contains the alternating group (Wielandt, 13.3)
## TODO
- Prove `Equiv.Perm.alternatingGroup_le_of_isPreprimitive_of_isCycle_mem`:
a primitive subgroup of a permutation group that contains
a cycle of *prime* order contains the alternating group (Wielandt, 13.9).
- Prove the stronger versions of the technical lemmas of Jordan (Wielandt, 13.1').
-/
open MulAction SubMulAction Subgroup
open scoped Pointwise
section Jordan
variable {G α : Type*} [Group G] [MulAction G α]
/-- In a 2-transitive action, the normal closure of stabilizers is the full group. -/
theorem normalClosure_of_stabilizer_eq_top (hsn' : 2 < ENat.card α)
(hG' : IsMultiplyPretransitive G α 2) {a : α} :
normalClosure ((stabilizer G a) : Set G) = ⊤ := by
have : IsPretransitive G α := by
rw [← is_one_pretransitive_iff]
exact isMultiplyPretransitive_of_le' (one_le_two) (le_of_lt hsn')
have : Nontrivial α := by
rw [← ENat.one_lt_card_iff_nontrivial]
exact lt_trans (by norm_num) hsn'
have hGa : IsCoatom (stabilizer G a) := by
rw [isCoatom_stabilizer_iff_preprimitive]
exact isPreprimitive_of_is_two_pretransitive hG'
apply hGa.right
-- Remains to prove: (stabilizer G a) < Subgroup.normalClosure (stabilizer G a)
constructor
· apply le_normalClosure
· intro hyp
have : Nontrivial (ofStabilizer G a) := by
rw [← ENat.one_lt_card_iff_nontrivial]
apply lt_of_add_lt_add_right
rwa [ENat_card_ofStabilizer_add_one_eq]
rw [nontrivial_iff] at this
obtain ⟨b, c, hbc⟩ := this
have : IsPretransitive (stabilizer G a) (ofStabilizer G a) := by
rw [← is_one_pretransitive_iff]
rwa [← ofStabilizer.isMultiplyPretransitive]
-- get g ∈ stabilizer G a, g • b = c,
obtain ⟨⟨g, hg⟩, hgbc⟩ := exists_smul_eq (stabilizer G a) b c
apply hbc
rw [← SetLike.coe_eq_coe] at hgbc ⊢
obtain ⟨h, hinvab⟩ := exists_smul_eq G (b : α) a
rw [eq_comm, ← inv_smul_eq_iff] at hinvab
rw [← hgbc, SetLike.val_smul, ← hinvab, inv_smul_eq_iff, eq_comm]
simp only [subgroup_smul_def, smul_smul, ← mul_assoc, ← mem_stabilizer_iff]
exact hyp (normalClosure_normal.conj_mem g (le_normalClosure hg) h)
-- Wielandt claims that this is proved by the same method as above.
proof_wanted IsPreprimitive.is_two_pretransitive'
(hG : IsPreprimitive G α)
{s : Set α} {n : ℕ} (hsn : Nat.card s = n + 1) (hsn' : n + 1 < Nat.card α)
(hs_trans : IsPretransitive (fixingSubgroup G s) (SubMulAction.ofFixingSubgroup G s)) :
IsMultiplyPretransitive (Subgroup.normalClosure (fixingSubgroup G s : Set G)) α 2
open MulAction.IsPreprimitive
open scoped Pointwise
/-- Simultaneously prove `MulAction.IsPreprimitive.is_two_pretransitive`
and `MulAction.IsPreprimitive.is_two_preprimitive`. -/
theorem MulAction.IsPreprimitive.is_two_motive_of_is_motive
(hG : IsPreprimitive G α) {s : Set α} {n : ℕ}
(hsn : s.ncard = n + 1) (hsn' : n + 2 < Nat.card α) :
(IsPretransitive (fixingSubgroup G s) (ofFixingSubgroup G s)
→ IsMultiplyPretransitive G α 2)
∧ (IsPreprimitive (fixingSubgroup G s) (ofFixingSubgroup G s)
→ IsMultiplyPreprimitive G α 2) := by
induction n using Nat.strong_induction_on generalizing α G with
| h n hrec =>
have : Finite α := Nat.finite_of_card_ne_zero <| ne_zero_of_lt hsn'
have hs_ne_univ : s ≠ Set.univ := by
intro hs
rw [hs, Set.ncard_univ] at hsn
simp only [hsn, add_lt_add_iff_left, Nat.not_ofNat_lt_one] at hsn'
have hs_nonempty : s.Nonempty := by
simp [← Set.ncard_pos s.toFinite, hsn]
-- The result is assumed by induction for sets of ncard ≤ n
rcases Nat.lt_or_ge (n + 1) 2 with hn | hn
· -- When n + 1 < 2 (imposes n = 0)
have hn : n = 0 := by
rwa [Nat.succ_lt_succ_iff, Nat.lt_one_iff] at hn
simp only [hn, zero_add, Set.ncard_eq_one] at hsn
obtain ⟨a, hsa⟩ := hsn
suffices IsPretransitive (fixingSubgroup G s) (ofFixingSubgroup G s) →
IsMultiplyPretransitive G α 2 by
refine ⟨this, fun hs_prim ↦ ?_⟩
rw [hsa] at hs_prim
rw [isMultiplyPreprimitive_succ_iff_ofStabilizer G α le_rfl (a := a),
is_one_preprimitive_iff]
exact IsPreprimitive.of_surjective
ofFixingSubgroup_of_singleton_bijective.surjective
rw [hsa]
rw [ofStabilizer.isMultiplyPretransitive (a := a)]
rw [is_one_pretransitive_iff]
exact IsPretransitive.of_surjective_map
ofFixingSubgroup_of_singleton_bijective.surjective
rcases Nat.lt_or_ge (2 * (n + 1)) (Nat.card α) with hn1 | hn2
· -- CASE where 2 * s.ncard < Nat.card α
-- get a, b ∈ s, a ≠ b
have : 1 < s.ncard := by rwa [hsn]
rw [Set.one_lt_ncard] at this
obtain ⟨a, ha, b, hb, hab⟩ := this
-- apply Rudio to get g ∈ G such that a ∈ g • s, b ∉ g • s
obtain ⟨g, hga, hgb⟩ :=
exists_mem_smul_and_notMem_smul (G := G) s.toFinite hs_nonempty hs_ne_univ hab
let t := s ∩ g • s
have ht : t.Finite := s.toFinite.inter_of_left (g • s)
have htm : t.ncard = t.ncard - 1 + 1 := by
apply (Nat.sub_eq_iff_eq_add ?_).mp rfl
rw [Nat.one_le_iff_ne_zero]
apply Set.ncard_ne_zero_of_mem (a := a) _ ht
exact ⟨ha, hga⟩
have hmn : t.ncard - 1 < n := by
rw [Nat.lt_iff_add_one_le, ← htm, Nat.le_iff_lt_add_one, ← hsn]
apply Set.ncard_lt_ncard _ s.toFinite
exact ⟨Set.inter_subset_left, fun h ↦ hgb (Set.inter_subset_right (h hb))⟩
have htm' : t.ncard - 1 + 2 < Nat.card α := lt_trans (Nat.add_lt_add_right hmn 2) hsn'
suffices IsPretransitive ↥(fixingSubgroup G s) ↥(ofFixingSubgroup G s) →
IsMultiplyPretransitive G α 2 by
refine ⟨this, fun hs_prim ↦ ?_⟩
have ht_prim : IsPreprimitive (fixingSubgroup G t) (ofFixingSubgroup G t) := by
apply IsPreprimitive.isPreprimitive_ofFixingSubgroup_inter hs_prim
apply Set.union_ne_univ_of_ncard_add_ncard_lt
rwa [Set.ncard_smul_set, hsn, ← two_mul]
apply (hrec (t.ncard - 1) hmn hG htm htm').2 ht_prim
intro hs_trans
have ht_trans : IsPretransitive (fixingSubgroup G t) (ofFixingSubgroup G t) :=
IsPretransitive.isPretransitive_ofFixingSubgroup_inter hs_trans (by
apply Set.union_ne_univ_of_ncard_add_ncard_lt
rwa [Set.ncard_smul_set, hsn, ← two_mul])
apply (hrec (t.ncard - 1) hmn hG htm ?_).1 ht_trans
apply lt_trans _ hsn'
exact Nat.add_lt_add_right hmn 2
· -- CASE : 2 * s.ncard ≥ Nat.card α
have : Set.Nontrivial sᶜ := by
rwa [← Set.one_lt_encard_iff_nontrivial, ← sᶜ.toFinite.cast_ncard_eq, Nat.one_lt_cast,
← Nat.add_lt_add_iff_left, Set.ncard_add_ncard_compl, add_comm, hsn, add_comm]
-- get a, b ∈ sᶜ, a ≠ b
obtain ⟨a, ha : a ∈ sᶜ, b, hb : b ∈ sᶜ, hab⟩ := this
-- apply Rudio to get g ∈ G such that a ∈ g • sᶜ, b ∉ g • sᶜ
obtain ⟨g, hga, hgb⟩ := exists_mem_smul_and_notMem_smul (G := G)
sᶜ.toFinite (Set.nonempty_of_mem ha)
(by simpa [Set.nonempty_iff_ne_empty] using hs_nonempty)
hab
let t := s ∩ g • s
have ha : a ∉ s ∪ g • s := by
simp only [Set.smul_set_compl, Set.mem_compl_iff] at hga ha
simp [ha, hga]
have htm : t.ncard = t.ncard - 1 + 1 := by
apply (Nat.sub_eq_iff_eq_add ?_).mp rfl
rw [Nat.one_le_iff_ne_zero, ← Nat.pos_iff_ne_zero, Set.ncard_pos]
apply Set.nonempty_inter_of_le_ncard_add_ncard
· rw [Set.ncard_smul_set, ← two_mul, hsn]; exact hn2
· exact fun h ↦ ha (by rw [h]; trivial)
have hmn : t.ncard - 1 < n := by
rw [Nat.lt_iff_add_one_le, ← htm, Nat.le_iff_lt_add_one, ← hsn]
apply Set.ncard_lt_ncard _ (Set.toFinite s)
refine ⟨Set.inter_subset_left, fun h ↦ hb ?_⟩
suffices s = g • s by
rw [this]
simpa only [Set.smul_set_compl, Set.mem_compl_iff, Set.not_notMem] using hgb
apply Set.eq_of_subset_of_ncard_le _ _ (g • s).toFinite
· exact subset_trans h Set.inter_subset_right
· rw [Set.ncard_smul_set]
have htm' : t.ncard - 1 + 2 < Nat.card α := lt_trans (Nat.add_lt_add_right hmn 2) hsn'
have hsgs_ne_top : s ∪ g • s ≠ ⊤ := fun h ↦ ha (h ▸ Set.mem_univ a)
suffices IsPretransitive ↥(fixingSubgroup G s) ↥(ofFixingSubgroup G s) →
IsMultiplyPretransitive G α 2 by
refine ⟨this, fun hs_prim ↦ ?_⟩
apply (hrec _ hmn hG htm htm').2
exact IsPreprimitive.isPreprimitive_ofFixingSubgroup_inter
hs_prim hsgs_ne_top
intro hs_trans
apply (hrec _ hmn hG htm htm').1
exact IsPretransitive.isPretransitive_ofFixingSubgroup_inter hs_trans hsgs_ne_top
/-- A criterion due to Jordan for being 2-pretransitive (Wielandt, 13.1) -/
theorem MulAction.IsPreprimitive.is_two_pretransitive
(hG : IsPreprimitive G α) {s : Set α} {n : ℕ}
(hsn : s.ncard = n + 1) (hsn' : n + 2 < Nat.card α)
(hs_trans : IsPretransitive (fixingSubgroup G s) (SubMulAction.ofFixingSubgroup G s)) :
IsMultiplyPretransitive G α 2 :=
(hG.is_two_motive_of_is_motive hsn hsn').1 hs_trans
/-- A criterion due to Jordan for being 2-preprimitive (Wielandt, 13.1) -/
theorem MulAction.IsPreprimitive.is_two_preprimitive
(hG : IsPreprimitive G α) {s : Set α} {n : ℕ}
(hsn : s.ncard = n + 1) (hsn' : n + 2 < Nat.card α)
(hs_prim : IsPreprimitive (fixingSubgroup G s) (SubMulAction.ofFixingSubgroup G s)) :
IsMultiplyPreprimitive G α 2 :=
(hG.is_two_motive_of_is_motive hsn hsn').2 hs_prim
-- Wielandt claims that this stronger version is proved in the same way
proof_wanted is_two_preprimitive_strong_jordan
(hG : IsPreprimitive G α)
{s : Set α} {n : ℕ} (hsn : s.ncard = n + 1) (hsn' : n + 2 < Nat.card α)
(hs_prim : IsPreprimitive (fixingSubgroup G s) (ofFixingSubgroup G s)) :
IsMultiplyPreprimitive (Subgroup.normalClosure (fixingSubgroup G s : Set G)) α 2
/-- Jordan's multiple primitivity criterion (Wielandt, 13.3) -/
theorem MulAction.IsPreprimitive.isMultiplyPreprimitive
(hG : IsPreprimitive G α) {s : Set α} {n : ℕ}
(hsn : s.ncard = n + 1) (hsn' : n + 2 < Nat.card α)
(hprim : IsPreprimitive (fixingSubgroup G s) (ofFixingSubgroup G s)) :
IsMultiplyPreprimitive G α (n + 2) := by
have hα : Finite α := Or.resolve_right (finite_or_infinite α) (fun _ ↦ by
simp [Nat.card_eq_zero_of_infinite] at hsn')
induction n generalizing α hα G with
| zero => -- case n = 0
have : IsPretransitive G α := hG.toIsPretransitive
simp only [zero_add, Set.ncard_eq_one] at hsn
obtain ⟨a, rfl⟩ := hsn
constructor
· rw [ofStabilizer.isMultiplyPretransitive (a := a), is_one_pretransitive_iff]
apply IsPretransitive.of_surjective_map
ofFixingSubgroup_of_singleton_bijective.surjective hprim.toIsPretransitive
· intro t h
rw [zero_add, Nat.cast_ofNat, ← one_add_one_eq_two,
(ENat.add_left_injective_of_ne_top ENat.one_ne_top).eq_iff] at h
obtain ⟨b, htb⟩ := Set.encard_eq_one.mp h
obtain ⟨g, hg⟩ := exists_smul_eq G a b
have hst : g • ({a} : Set α) = ({b} : Set α) := by
rw [Set.smul_set_singleton, hg]
rw [htb]
refine IsPreprimitive.of_surjective
(conjMap_ofFixingSubgroup_bijective (hst := hst)).surjective
-- Induction step
| succ n hrec =>
suffices ∃ (a : α) (t : Set (SubMulAction.ofStabilizer G a)),
a ∈ s ∧ s = insert a (Subtype.val '' t) by
obtain ⟨a, t, _, hst⟩ := this
have ha' : a ∉ Subtype.val '' t := by
intro h; rw [Set.mem_image] at h; obtain ⟨x, hx⟩ := h
apply x.prop; rw [hx.right]; exact Set.mem_singleton a
have ht_prim : IsPreprimitive (stabilizer G a) (SubMulAction.ofStabilizer G a) := by
rw [← is_one_preprimitive_iff]
rw [← isMultiplyPreprimitive_succ_iff_ofStabilizer]
· apply is_two_preprimitive hG hsn hsn' hprim
· norm_num
have : IsPreprimitive ↥(fixingSubgroup G (insert a (Subtype.val '' t)))
(ofFixingSubgroup G (insert a (Subtype.val '' t))) :=
IsPreprimitive.of_surjective
(ofFixingSubgroup_of_eq_bijective (hst := hst)).surjective
have hGs' : IsPreprimitive (fixingSubgroup (stabilizer G a) t)
(ofFixingSubgroup (stabilizer G a) t) :=
IsPreprimitive.of_surjective
ofFixingSubgroup_insert_map_bijective.surjective
rw [isMultiplyPreprimitive_succ_iff_ofStabilizer G (a := a) _ (Nat.le_add_left 1 (n + 1))]
refine hrec ht_prim ?_ ?_ hGs' Subtype.finite
· -- t.card = Nat.succ n
rw [← Set.ncard_image_of_injective t Subtype.val_injective]
apply Nat.add_right_cancel
rw [← Set.ncard_insert_of_notMem ha', ← hst, hsn]
· -- n + 2 < Nat.card (SubMulAction.ofStabilizer G α a)
rw [← Nat.add_lt_add_iff_right, nat_card_ofStabilizer_add_one_eq]
exact hsn'
-- ∃ a t, a ∈ s ∧ s = insert a (Subtype.val '' t)
suffices s.Nonempty by
obtain ⟨a, ha⟩ := this
use a, Subtype.val ⁻¹' s, ha
ext x
by_cases hx : x = a <;> simp [hx, mem_ofStabilizer_iff, ha]
rw [← Set.ncard_pos, hsn]; apply Nat.succ_pos
end Jordan
section Subgroups
namespace Equiv.Perm
open Equiv Set
variable {α : Type*}
variable {G : Subgroup (Perm α)}
theorem subgroup_eq_top_of_nontrivial [Finite α] (hα : Nat.card α ≤ 2) (hG : Nontrivial G) :
G = (⊤ : Subgroup (Perm α)) := by
apply Subgroup.eq_top_of_le_card
rw [Nat.card_perm]
apply (Nat.factorial_le hα).trans
rwa [Nat.factorial_two, Nat.succ_le, one_lt_card_iff_ne_bot, ← nontrivial_iff_ne_bot]
theorem isMultiplyPretransitive_of_nontrivial {K : Type*} [Group K] [MulAction K α]
(hα : Nat.card α = 2) (hK : fixedPoints K α ≠ .univ) (n : ℕ) :
IsMultiplyPretransitive K α n := by
have : Finite α := Or.resolve_right (finite_or_infinite α) (fun _ ↦ by
simp [Nat.card_eq_zero_of_infinite] at hα)
have : Fintype α := Fintype.ofFinite α
suffices h2 : IsMultiplyPretransitive K α 2 by
by_cases hn : n ≤ 2
· apply MulAction.isMultiplyPretransitive_of_le' hn
simp [← hα]
· suffices (IsEmpty (Fin n ↪ α)) by infer_instance
rwa [← not_nonempty_iff, Function.Embedding.nonempty_iff_card_le, Fintype.card_fin,
← Nat.card_eq_fintype_card, hα]
let φ := MulAction.toPermHom K α
let f : α →ₑ[φ] α :=
{ toFun := id
map_smul' := fun _ _ ↦ rfl }
have hf : Function.Bijective f := Function.bijective_id
suffices Function.Surjective φ by
unfold IsMultiplyPretransitive
rw [IsPretransitive.of_embedding_congr this hf (n := Fin 2), ← hα]
apply Perm.isMultiplyPretransitive
rw [← MonoidHom.range_eq_top]
apply Subgroup.eq_top_of_card_eq
apply le_antisymm (card_le_card_group φ.range)
simp only [Nat.card_perm, hα, Nat.factorial_two]
by_contra H
simp only [not_le, Nat.lt_succ, Finite.card_le_one_iff_subsingleton] at H
apply hK
apply Set.eq_univ_of_univ_subset
intro a _ g
suffices φ g = φ 1 by
conv_rhs => rw [← one_smul K a]
simp only [← toPerm_apply, ← toPermHom_apply K α g]
exact congrFun (congrArg DFunLike.coe this) a
simpa [← Subtype.coe_inj] using H.elim ⟨_, ⟨g, rfl⟩⟩ ⟨_, ⟨1, rfl⟩⟩
variable [Fintype α] [DecidableEq α]
theorem isPretransitive_of_isCycle_mem {g : Perm α}
(hgc : g.IsCycle) (hg : g ∈ G) :
IsPretransitive (fixingSubgroup G (g.support : Set α)ᶜ)
(SubMulAction.ofFixingSubgroup G (g.support : Set α)ᶜ) := by
obtain ⟨a, _, hgc⟩ := hgc
have hs : ∀ x : α, g • x ≠ x ↔
x ∈ SubMulAction.ofFixingSubgroup G ((↑g.support : Set α)ᶜ) := by
intro x
simp [SubMulAction.mem_ofFixingSubgroup_iff]
suffices ∀ x ∈ SubMulAction.ofFixingSubgroup G ((↑g.support : Set α)ᶜ),
∃ k : fixingSubgroup G ((↑g.support : Set α)ᶜ), x = k • a by
rw [isPretransitive_iff]
rintro ⟨x, hx⟩ ⟨y, hy⟩
obtain ⟨k, hk⟩ := this x hx
obtain ⟨k', hk'⟩ := this y hy
use k' * k⁻¹
rw [← SetLike.coe_eq_coe]
simp only [SetLike.mk_smul_mk]
rw [hk, hk', smul_smul, inv_mul_cancel_right]
intro x hx
have hg' : (⟨g, hg⟩ : ↥G) ∈ fixingSubgroup G ((↑g.support : Set α)ᶜ) := by
simp_rw [mem_fixingSubgroup_iff G]
intro y hy
simpa only [Set.mem_compl_iff, Finset.mem_coe, notMem_support] using hy
let g' : fixingSubgroup (↥G) ((↑g.support : Set α)ᶜ) := ⟨(⟨g, hg⟩ : ↥G), hg'⟩
obtain ⟨i, hi⟩ := hgc ((hs x).mpr hx)
exact ⟨g' ^ i, hi.symm⟩
/-- A primitive subgroup of `Equiv.Perm α` that contains a swap
is the full permutation group (Jordan). -/
theorem subgroup_eq_top_of_isPreprimitive_of_isSwap_mem
(hG : IsPreprimitive G α) (g : Perm α) (h2g : IsSwap g) (hg : g ∈ G) :
G = ⊤ := by
classical
rcases Nat.lt_or_ge (Nat.card α) 3 with hα3 | hα3
· -- trivial case : Nat.card α ≤ 2
rw [Nat.lt_succ_iff] at hα3
apply Subgroup.eq_top_of_card_eq
simp only [Nat.card_eq_fintype_card]
apply le_antisymm (Fintype.card_subtype_le _)
rw [← Nat.card_eq_fintype_card, Nat.card_perm]
refine le_trans (Nat.factorial_le hα3) ?_
rw [Nat.factorial_two]
have : Nonempty G := One.instNonempty
apply Nat.le_of_dvd Fintype.card_pos
rw [← h2g.orderOf, orderOf_submonoid ⟨g, hg⟩]
exact orderOf_dvd_card
-- important case : Nat.card α ≥ 3
obtain ⟨n, hn⟩ := Nat.exists_eq_add_of_le' hα3
have hsc : Set.ncard ((g.support)ᶜ : Set α) = n + 1 := by
apply Nat.add_left_cancel
rw [Set.ncard_add_ncard_compl, Set.ncard_coe_finset,
card_support_eq_two.mpr h2g, add_comm, hn]
apply eq_top_of_isMultiplyPretransitive
suffices IsMultiplyPreprimitive G α (Nat.card α - 1) by
apply IsMultiplyPreprimitive.isMultiplyPretransitive
rw [show Nat.card α - 1 = n + 2 by grind]
apply hG.isMultiplyPreprimitive hsc
· rw [hn]; apply Nat.lt_add_one
have := isPretransitive_of_isCycle_mem h2g.isCycle hg
apply IsPreprimitive.of_prime_card
convert Nat.prime_two
rw [Nat.card_eq_fintype_card, Fintype.card_subtype, ← card_support_eq_two.mpr h2g]
simp [SubMulAction.mem_ofFixingSubgroup_iff, support]
@[deprecated (since := "2025-11-04")]
alias eq_top_of_isPreprimitive_of_isSwap_mem := subgroup_eq_top_of_isPreprimitive_of_isSwap_mem
/-- A primitive subgroup of `Equiv.Perm α` that contains a 3-cycle
contains the alternating group (Jordan). -/
theorem alternatingGroup_le_of_isPreprimitive_of_isThreeCycle_mem
(hG : IsPreprimitive G α) {g : Perm α} (h3g : IsThreeCycle g) (hg : g ∈ G) :
alternatingGroup α ≤ G := by
classical
rcases Nat.lt_or_ge (Nat.card α) 4 with hα4 | hα4
· -- trivial case : Fintype.card α ≤ 3
rw [Nat.lt_succ_iff] at hα4
apply alternatingGroup_le_of_index_le_two
rw [← Nat.mul_le_mul_right_iff (k:= Nat.card G) (Nat.card_pos),
Subgroup.index_mul_card, Nat.card_perm]
apply le_trans (Nat.factorial_le hα4)
rw [show Nat.factorial 3 = 2 * 3 by simp [Nat.factorial]]
simp only [mul_le_mul_iff_right₀, Nat.succ_pos]
apply Nat.le_of_dvd Nat.card_pos
suffices 3 = orderOf (⟨g, hg⟩ : G) by
rw [this, Nat.card_eq_fintype_card]
exact orderOf_dvd_card
simp only [orderOf_mk, h3g.orderOf]
-- important case : Nat.card α ≥ 4
obtain ⟨n, hn⟩ := Nat.exists_eq_add_of_le' hα4
apply IsMultiplyPretransitive.alternatingGroup_le
suffices IsMultiplyPreprimitive G α (Nat.card α - 2) from
IsMultiplyPreprimitive.isMultiplyPretransitive ..
rw [show Nat.card α - 2 = n + 2 by grind]
apply hG.isMultiplyPreprimitive (s := (g.supportᶜ : Set α))
· apply Nat.add_left_cancel
rw [Set.ncard_add_ncard_compl, Set.ncard_coe_finset,
h3g.card_support, add_comm, hn]
· grind
have := isPretransitive_of_isCycle_mem h3g.isCycle hg
apply IsPreprimitive.of_prime_card
convert Nat.prime_three
rw [Nat.card_eq_fintype_card, Fintype.card_subtype, ← h3g.card_support]
apply congr_arg
ext x
simp [SubMulAction.mem_ofFixingSubgroup_iff]
/-- A primitive subgroup of `Equiv.Perm α` that contains a cycle of prime order
contains the alternating group. -/
proof_wanted alternatingGroup_le_of_isPreprimitive_of_isCycle_mem
(hG : IsPreprimitive G α)
{p : ℕ} (hp : p.Prime) (hp' : p + 3 ≤ Nat.card α)
{g : Perm α} (hgc : g.IsCycle) (hgp : g.support.card = p)
(hg : g ∈ G) : alternatingGroup α ≤ G
end Equiv.Perm
end Subgroups |
.lake/packages/mathlib/Mathlib/GroupTheory/GroupAction/Support.lean | import Mathlib.Algebra.Group.Action.Basic
import Mathlib.Algebra.Group.Pointwise.Set.Scalar
/-!
# Support of an element under an action
Given an action of a group `G` on a type `α`, we say that a set `s : Set α` supports an element
`a : α` if, for all `g` that fix `s` pointwise, `g` fixes `a`.
This is crucial in Fourier-Motzkin constructions.
-/
assert_not_exists MonoidWithZero
open Pointwise
variable {G H α β : Type*}
namespace MulAction
section SMul
variable (G) [SMul G α] [SMul G β]
/-- A set `s` supports `b` if `g • b = b` whenever `g • a = a` for all `a ∈ s`. -/
@[to_additive /-- A set `s` supports `b` if `g +ᵥ b = b` whenever `g +ᵥ a = a` for all `a ∈ s`. -/]
def Supports (s : Set α) (b : β) :=
∀ g : G, (∀ ⦃a⦄, a ∈ s → g • a = a) → g • b = b
variable {s t : Set α} {a : α} {b : β}
@[to_additive]
theorem supports_of_mem (ha : a ∈ s) : Supports G s a := fun _ h => h ha
variable {G}
@[to_additive]
theorem Supports.mono (h : s ⊆ t) (hs : Supports G s b) : Supports G t b := fun _ hg =>
(hs _) fun _ ha => hg <| h ha
end SMul
variable [Group H] [SMul G α] [SMul G β] [MulAction H α] [SMul H β] [SMulCommClass G H β]
[SMulCommClass G H α] {s : Set α} {b : β}
-- TODO: This should work without `SMulCommClass`
@[to_additive]
theorem Supports.smul (g : H) (h : Supports G s b) : Supports G (g • s) (g • b) := by
rintro g' hg'
rw [smul_comm, h]
rintro a ha
have := Set.forall_mem_image.1 hg' ha
rwa [smul_comm, smul_left_cancel_iff] at this
end MulAction |
.lake/packages/mathlib/Mathlib/GroupTheory/GroupAction/Ring.lean | import Mathlib.Algebra.GroupWithZero.Action.Defs
import Mathlib.Algebra.Ring.Defs
/-!
# Commutativity and associativity of action of integers on rings
This file proves that `ℕ` and `ℤ` act commutatively and associatively on (semi)rings.
## TODO
Those instances are in their own file only because they require much less imports than any existing
file they could go to. This is unfortunate and should be fixed by reorganising files.
-/
open scoped Int
variable {R : Type*}
instance NonUnitalNonAssocSemiring.toDistribSMul [NonUnitalNonAssocSemiring R] :
DistribSMul R R where smul_add := mul_add
/-- Note that `AddCommMonoid.nat_isScalarTower` requires stronger assumptions on `R`. -/
instance NonUnitalNonAssocSemiring.nat_isScalarTower [NonUnitalNonAssocSemiring R] :
IsScalarTower ℕ R R where
smul_assoc n x y := by
induction n with
| zero => simp
| succ n ih => simp_rw [succ_nsmul, ← ih, smul_eq_mul, add_mul]
/-- Note that `AddCommGroup.int_isScalarTower` requires stronger assumptions on `R`. -/
instance NonUnitalNonAssocRing.int_isScalarTower [NonUnitalNonAssocRing R] :
IsScalarTower ℤ R R where
smul_assoc n x y :=
match n with
| (n : ℕ) => by simp_rw [natCast_zsmul, smul_assoc]
| -[n+1] => by simp_rw [negSucc_zsmul, smul_eq_mul, neg_mul, smul_mul_assoc] |
.lake/packages/mathlib/Mathlib/GroupTheory/GroupAction/ConjAct.lean | import Mathlib.Algebra.Group.Subgroup.ZPowers.Basic
import Mathlib.Data.Fintype.Card
import Mathlib.GroupTheory.GroupAction.Defs
import Mathlib.GroupTheory.Subgroup.Centralizer
/-!
# Conjugation action of a group on itself
This file defines the conjugation action of a group on itself. See also `MulAut.conj` for
the definition of conjugation as a homomorphism into the automorphism group.
## Main definitions
A type alias `ConjAct G` is introduced for a group `G`. The group `ConjAct G` acts on `G`
by conjugation. The group `ConjAct G` also acts on any normal subgroup of `G` by conjugation.
As a generalization, this also allows:
* `ConjAct Mˣ` to act on `M`, when `M` is a `Monoid`
* `ConjAct G₀` to act on `G₀`, when `G₀` is a `GroupWithZero`
## Implementation Notes
The scalar action in defined in this file can also be written using `MulAut.conj g • h`. This
has the advantage of not using the type alias `ConjAct`, but the downside of this approach
is that some theorems about the group actions will not apply when since this
`MulAut.conj g • h` describes an action of `MulAut G` on `G`, and not an action of `G`.
-/
assert_not_exists MonoidWithZero
variable (α M G : Type*)
/-- A type alias for a group `G`. `ConjAct G` acts on `G` by conjugation -/
def ConjAct : Type _ :=
G
namespace ConjAct
open MulAction Subgroup
variable {M G}
instance [Group G] : Group (ConjAct G) := ‹Group G›
instance [DivInvMonoid G] : DivInvMonoid (ConjAct G) := ‹DivInvMonoid G›
instance [Fintype G] : Fintype (ConjAct G) := ‹Fintype G›
@[simp]
theorem card [Fintype G] : Fintype.card (ConjAct G) = Fintype.card G :=
rfl
section DivInvMonoid
variable [DivInvMonoid G]
instance : Inhabited (ConjAct G) :=
⟨1⟩
/-- Reinterpret `g : ConjAct G` as an element of `G`. -/
def ofConjAct : ConjAct G ≃* G where
toFun := id
invFun := id
map_mul' := fun _ _ => rfl
/-- Reinterpret `g : G` as an element of `ConjAct G`. -/
def toConjAct : G ≃* ConjAct G :=
ofConjAct.symm
/-- A recursor for `ConjAct`, for use as `induction x` when `x : ConjAct G`. -/
@[elab_as_elim, cases_eliminator, induction_eliminator]
protected def rec {C : ConjAct G → Sort*} (h : ∀ g, C (toConjAct g)) : ∀ g, C g :=
h
@[simp]
theorem «forall» (p : ConjAct G → Prop) : (∀ x : ConjAct G, p x) ↔ ∀ x : G, p (toConjAct x) :=
id Iff.rfl
@[simp]
theorem of_mul_symm_eq : (@ofConjAct G _).symm = toConjAct :=
rfl
@[simp]
theorem to_mul_symm_eq : (@toConjAct G _).symm = ofConjAct :=
rfl
@[simp]
theorem toConjAct_ofConjAct (x : ConjAct G) : toConjAct (ofConjAct x) = x :=
rfl
@[simp]
theorem ofConjAct_toConjAct (x : G) : ofConjAct (toConjAct x) = x :=
rfl
@[simp]
theorem ofConjAct_one : ofConjAct (1 : ConjAct G) = 1 :=
rfl
@[simp]
theorem toConjAct_one : toConjAct (1 : G) = 1 :=
rfl
@[simp]
theorem ofConjAct_inv (x : ConjAct G) : ofConjAct x⁻¹ = (ofConjAct x)⁻¹ :=
rfl
@[simp]
theorem toConjAct_inv (x : G) : toConjAct x⁻¹ = (toConjAct x)⁻¹ :=
rfl
@[simp]
theorem ofConjAct_mul (x y : ConjAct G) : ofConjAct (x * y) = ofConjAct x * ofConjAct y :=
rfl
@[simp]
theorem toConjAct_mul (x y : G) : toConjAct (x * y) = toConjAct x * toConjAct y :=
rfl
instance : SMul (ConjAct G) G where smul g h := ofConjAct g * h * (ofConjAct g)⁻¹
theorem smul_def (g : ConjAct G) (h : G) : g • h = ofConjAct g * h * (ofConjAct g)⁻¹ :=
rfl
theorem toConjAct_smul (g h : G) : toConjAct g • h = g * h * g⁻¹ :=
rfl
end DivInvMonoid
section Units
section Monoid
variable [Monoid M]
instance unitsScalar : SMul (ConjAct Mˣ) M where smul g h := ofConjAct g * h * ↑(ofConjAct g)⁻¹
theorem units_smul_def (g : ConjAct Mˣ) (h : M) : g • h = ofConjAct g * h * ↑(ofConjAct g)⁻¹ :=
rfl
instance unitsMulDistribMulAction : MulDistribMulAction (ConjAct Mˣ) M where
one_smul := by simp [units_smul_def]
mul_smul := by simp [units_smul_def, mul_assoc]
smul_mul := by simp [units_smul_def, mul_assoc]
smul_one := by simp [units_smul_def]
instance unitsSMulCommClass [SMul α M] [SMulCommClass α M M] [IsScalarTower α M M] :
SMulCommClass α (ConjAct Mˣ) M where
smul_comm a um m := by rw [units_smul_def, units_smul_def, mul_smul_comm, smul_mul_assoc]
instance unitsSMulCommClass' [SMul α M] [SMulCommClass M α M] [IsScalarTower α M M] :
SMulCommClass (ConjAct Mˣ) α M :=
haveI : SMulCommClass α M M := SMulCommClass.symm _ _ _
SMulCommClass.symm _ _ _
end Monoid
end Units
variable [Group G]
-- todo: this file is not in good order; I will refactor this after the PR
instance : MulDistribMulAction (ConjAct G) G where
smul_mul := by simp [smul_def]
smul_one := by simp [smul_def]
one_smul := by simp [smul_def]
mul_smul := by simp [smul_def, mul_assoc]
instance smulCommClass [SMul α G] [SMulCommClass α G G] [IsScalarTower α G G] :
SMulCommClass α (ConjAct G) G where
smul_comm a ug g := by rw [smul_def, smul_def, mul_smul_comm, smul_mul_assoc]
instance smulCommClass' [SMul α G] [SMulCommClass G α G] [IsScalarTower α G G] :
SMulCommClass (ConjAct G) α G :=
haveI := SMulCommClass.symm G α G
SMulCommClass.symm _ _ _
theorem smul_eq_mulAut_conj (g : ConjAct G) (h : G) : g • h = MulAut.conj (ofConjAct g) h :=
rfl
/-- The set of fixed points of the conjugation action of `G` on itself is the center of `G`. -/
theorem fixedPoints_eq_center : fixedPoints (ConjAct G) G = center G := by
ext x
simp [mem_center_iff, smul_def, mul_inv_eq_iff_eq_mul]
@[simp]
theorem mem_orbit_conjAct {g h : G} : g ∈ orbit (ConjAct G) h ↔ IsConj g h := by
rw [isConj_comm, isConj_iff, mem_orbit_iff]; rfl
theorem orbitRel_conjAct : ⇑(orbitRel (ConjAct G) G) = IsConj :=
funext₂ fun g h => by rw [orbitRel_apply, mem_orbit_conjAct]
theorem orbit_eq_carrier_conjClasses (g : G) :
orbit (ConjAct G) g = (ConjClasses.mk g).carrier := by
ext h
rw [ConjClasses.mem_carrier_iff_mk_eq, ConjClasses.mk_eq_mk_iff_isConj, mem_orbit_conjAct]
theorem stabilizer_eq_centralizer (g : G) :
stabilizer (ConjAct G) g = centralizer (zpowers (toConjAct g) : Set (ConjAct G)) :=
le_antisymm (le_centralizer_iff.mp (zpowers_le.mpr fun _ => mul_inv_eq_iff_eq_mul.mp)) fun _ h =>
mul_inv_eq_of_eq_mul (h g (mem_zpowers g)).symm
theorem _root_.Subgroup.centralizer_eq_comap_stabilizer (g : G) :
Subgroup.centralizer {g} = Subgroup.comap ConjAct.toConjAct.toMonoidHom
(MulAction.stabilizer (ConjAct G) g) := by
ext k
-- NOTE: `Subgroup.mem_centralizer_iff` should probably be stated
-- with the equality in the other direction
simp only [mem_centralizer_iff, Set.mem_singleton_iff, forall_eq]
rw [eq_comm]
exact Iff.symm mul_inv_eq_iff_eq_mul
/-- As normal subgroups are closed under conjugation, they inherit the conjugation action
of the underlying group. -/
instance Subgroup.conjAction {H : Subgroup G} [hH : H.Normal] : SMul (ConjAct G) H :=
⟨fun g h => ⟨g • (h : G), hH.conj_mem h.1 h.2 (ofConjAct g)⟩⟩
theorem Subgroup.val_conj_smul {H : Subgroup G} [H.Normal] (g : ConjAct G) (h : H) :
↑(g • h) = g • (h : G) :=
rfl
instance Subgroup.conjMulDistribMulAction {H : Subgroup G} [H.Normal] :
MulDistribMulAction (ConjAct G) H :=
Subtype.coe_injective.mulDistribMulAction H.subtype Subgroup.val_conj_smul
/-- Group conjugation on a normal subgroup. Analogous to `MulAut.conj`. -/
def _root_.MulAut.conjNormal {H : Subgroup G} [H.Normal] : G →* MulAut H :=
(MulDistribMulAction.toMulAut (ConjAct G) H).comp toConjAct.toMonoidHom
@[simp]
theorem _root_.MulAut.conjNormal_apply {H : Subgroup G} [H.Normal] (g : G) (h : H) :
↑(MulAut.conjNormal g h) = g * h * g⁻¹ :=
rfl
@[simp]
theorem _root_.MulAut.conjNormal_symm_apply {H : Subgroup G} [H.Normal] (g : G) (h : H) :
↑((MulAut.conjNormal g).symm h) = g⁻¹ * h * g := by
change _ * _⁻¹⁻¹ = _
rw [inv_inv]
rfl
theorem _root_.MulAut.conjNormal_inv_apply {H : Subgroup G} [H.Normal] (g : G) (h : H) :
↑((MulAut.conjNormal g)⁻¹ h) = g⁻¹ * h * g :=
MulAut.conjNormal_symm_apply g h
theorem _root_.MulAut.conjNormal_val {H : Subgroup G} [H.Normal] {h : H} :
MulAut.conjNormal ↑h = MulAut.conj h :=
MulEquiv.ext fun _ => rfl
instance normal_of_characteristic_of_normal {H : Subgroup G} [hH : H.Normal] {K : Subgroup H}
[h : K.Characteristic] : (K.map H.subtype).Normal :=
⟨fun a ha b => by
obtain ⟨a, ha, rfl⟩ := ha
exact K.apply_coe_mem_map H.subtype
⟨_, (SetLike.ext_iff.mp (h.fixed (MulAut.conjNormal b)) a).mpr ha⟩⟩
end ConjAct
section Units
variable [Monoid M]
/-- The stabilizer of `Mˣ` acting on itself by conjugation at `x : Mˣ` is exactly the
units of the centralizer of `x : M`. -/
@[simps! apply_coe_val symm_apply_val_coe]
def unitsCentralizerEquiv (x : Mˣ) :
(Submonoid.centralizer ({↑x} : Set M))ˣ ≃* MulAction.stabilizer (ConjAct Mˣ) x :=
MulEquiv.symm
{ toFun := MonoidHom.toHomUnits <|
{ toFun := fun u ↦ ⟨↑(ConjAct.ofConjAct u.1 : Mˣ), by
rintro x ⟨rfl⟩
have : (u : ConjAct Mˣ) • x = x := u.2
rwa [ConjAct.smul_def, mul_inv_eq_iff_eq_mul, Units.ext_iff, eq_comm] at this⟩,
map_one' := rfl,
map_mul' := fun _ _ ↦ rfl }
invFun := fun u ↦
⟨ConjAct.toConjAct (Units.map (Submonoid.centralizer ({↑x} : Set M)).subtype u), by
change _ • _ = _
simp only [ConjAct.smul_def, ConjAct.ofConjAct_toConjAct, mul_inv_eq_iff_eq_mul]
exact Units.ext <| (u.1.2 x <| Set.mem_singleton _).symm⟩
map_mul' := map_mul _ }
end Units |
.lake/packages/mathlib/Mathlib/GroupTheory/GroupAction/Pointwise.lean | import Mathlib.Algebra.Group.Pointwise.Set.Scalar
import Mathlib.Data.Set.Function
import Mathlib.GroupTheory.GroupAction.Hom
import Mathlib.Algebra.Group.Units.Hom
/-!
# Pointwise actions of equivariant maps
- `image_smul_setₛₗ` : under a `σ`-equivariant map,
one has `f '' (c • s) = (σ c) • f '' s`.
- `preimage_smul_setₛₗ'` is a general version of the equality
`f ⁻¹' (σ c • s) = c • f⁻¹' s`.
It requires that `c` acts surjectively and `σ c` acts injectively and
is provided with specific versions:
- `preimage_smul_setₛₗ_of_isUnit_isUnit` when `c` and `σ c` are units
- `IsUnit.preimage_smul_setₛₗ` when `σ` belongs to a `MonoidHomClass`and `c` is a unit
- `MonoidHom.preimage_smul_setₛₗ` when `σ` is a `MonoidHom` and `c` is a unit
- `Group.preimage_smul_setₛₗ` : when the types of `c` and `σ c` are groups.
- `image_smul_set`, `preimage_smul_set` and `Group.preimage_smul_set` are
the variants when `σ` is the identity.
-/
open Function Set Pointwise
section MulActionSemiHomClass
section SMul
variable {M N F : Type*} {α β : Type*} {σ : M → N} [SMul M α] [SMul N β] [FunLike F α β]
[MulActionSemiHomClass F σ α β] {f : F} {s : Set α} {t : Set β}
@[to_additive (attr := simp)]
theorem image_smul_setₛₗ (f : F) (c : M) (s : Set α) :
f '' (c • s) = σ c • f '' s :=
Semiconj.set_image (map_smulₛₗ f c) s
@[to_additive]
theorem Set.MapsTo.smul_setₛₗ (hst : MapsTo f s t) (c : M) : MapsTo f (c • s) (σ c • t) :=
Function.Semiconj.mapsTo_image_right (map_smulₛₗ _ _) hst
/-- Translation of preimage is contained in preimage of translation -/
@[to_additive]
theorem smul_preimage_set_subsetₛₗ (f : F) (c : M) (t : Set β) : c • f ⁻¹' t ⊆ f ⁻¹' (σ c • t) :=
((mapsTo_preimage f t).smul_setₛₗ c).subset_preimage
/-- General version of `preimage_smul_setₛₗ`.
This version assumes that the scalar multiplication by `c` is surjective
while the scalar multiplication by `σ c` is injective. -/
@[to_additive /-- General version of `preimage_vadd_setₛₗ`.
This version assumes that the vector addition of `c` is surjective
while the vector addition of `σ c` is injective. -/]
theorem preimage_smul_setₛₗ' {c : M}
(hc : Function.Surjective (fun (m : α) ↦ c • m))
(hc' : Function.Injective (fun (n : β) ↦ σ c • n)) :
f ⁻¹' (σ c • t) = c • f ⁻¹' t := by
refine Subset.antisymm ?_ (smul_preimage_set_subsetₛₗ f c t)
rw [subset_def, hc.forall]
rintro x ⟨y, hy, hxy⟩
rw [map_smulₛₗ, hc'.eq_iff] at hxy
subst y
exact smul_mem_smul_set hy
end SMul
section Monoid
variable {M N F : Type*} {α β : Type*} {σ : M → N} [Monoid M] [Monoid N]
[MulAction M α] [MulAction N β] [FunLike F α β] [MulActionSemiHomClass F σ α β]
{f : F} {s : Set α} {t : Set β} {c : M}
/-- `preimage_smul_setₛₗ` when both scalars act by unit -/
@[to_additive]
theorem preimage_smul_setₛₗ_of_isUnit_isUnit (f : F)
(hc : IsUnit c) (hc' : IsUnit (σ c)) (t : Set β) : f ⁻¹' (σ c • t) = c • f ⁻¹' t :=
preimage_smul_setₛₗ' hc.smul_bijective.surjective hc'.smul_bijective.injective
/-- `preimage_smul_setₛₗ` when `c` is a unit and `σ` is a monoid homomorphism. -/
@[to_additive]
theorem IsUnit.preimage_smul_setₛₗ {F G : Type*} [FunLike G M N] [MonoidHomClass G M N]
(σ : G) [FunLike F α β] [MulActionSemiHomClass F σ α β] (f : F) (hc : IsUnit c) (t : Set β) :
f ⁻¹' (σ c • t) = c • f ⁻¹' t :=
preimage_smul_setₛₗ_of_isUnit_isUnit _ hc (hc.map _) _
-- TODO: when you remove the next 2 aliases,
-- please move the group version below out of the `Group` namespace.
/-- `preimage_smul_setₛₗ` when `c` is a unit and `σ` is a monoid homomorphism. -/
@[to_additive]
protected theorem MonoidHom.preimage_smul_setₛₗ {F : Type*} (σ : M →* N) [FunLike F α β]
[MulActionSemiHomClass F σ α β] (f : F) (hc : IsUnit c) (t : Set β) :
f ⁻¹' (σ c • t) = c • f ⁻¹' t :=
hc.preimage_smul_setₛₗ σ f t
end Monoid
/-- `preimage_smul_setₛₗ` in the context of groups -/
@[to_additive]
theorem Group.preimage_smul_setₛₗ {G H α β : Type*} [Group G] [Group H] (σ : G → H)
[MulAction G α] [MulAction H β]
{F : Type*} [FunLike F α β] [MulActionSemiHomClass F σ α β] (f : F) (c : G) (t : Set β) :
f ⁻¹' (σ c • t) = c • f ⁻¹' t :=
preimage_smul_setₛₗ_of_isUnit_isUnit _ (Group.isUnit _) (Group.isUnit _) _
end MulActionSemiHomClass
section MulActionHomClass
section SMul
variable {M α β F : Type*} [SMul M α] [SMul M β] [FunLike F α β] [MulActionHomClass F M α β]
@[to_additive]
theorem image_smul_set (f : F) (c : M) (s : Set α) : f '' (c • s) = c • f '' s :=
image_smul_setₛₗ f c s
@[to_additive]
theorem smul_preimage_set_subset (f : F) (c : M) (t : Set β) : c • f ⁻¹' t ⊆ f ⁻¹' (c • t) :=
smul_preimage_set_subsetₛₗ f c t
@[to_additive]
theorem Set.MapsTo.smul_set {f : F} {s : Set α} {t : Set β} (hst : MapsTo f s t) (c : M) :
MapsTo f (c • s) (c • t) :=
hst.smul_setₛₗ c
end SMul
@[to_additive]
theorem IsUnit.preimage_smul_set {M α β F : Type*} [Monoid M] [MulAction M α] [MulAction M β]
[FunLike F α β] [MulActionHomClass F M α β] (f : F) {c : M} (hc : IsUnit c) (t : Set β) :
f ⁻¹' (c • t) = c • f ⁻¹' t :=
preimage_smul_setₛₗ_of_isUnit_isUnit f hc hc t
-- TODO: when you remove the next 2 aliases,
-- please move the `Group` version to the root namespace.
@[to_additive]
theorem Group.preimage_smul_set {G : Type*} [Group G] {α β : Type*} [MulAction G α] [MulAction G β]
{F : Type*} [FunLike F α β] [MulActionHomClass F G α β] (f : F) (c : G) (t : Set β) :
f ⁻¹' (c • t) = c • f ⁻¹' t :=
(Group.isUnit c).preimage_smul_set f t
end MulActionHomClass |
.lake/packages/mathlib/Mathlib/GroupTheory/GroupAction/Basic.lean | import Mathlib.Algebra.Group.Action.End
import Mathlib.Algebra.Group.Action.Pointwise.Set.Basic
import Mathlib.Algebra.Group.Action.Prod
import Mathlib.Algebra.Group.Subgroup.Map
import Mathlib.Algebra.Module.Defs
import Mathlib.Algebra.NoZeroSMulDivisors.Defs
import Mathlib.Data.Finite.Sigma
import Mathlib.Data.Set.Finite.Range
import Mathlib.Data.Setoid.Basic
import Mathlib.GroupTheory.GroupAction.Defs
/-!
# Basic properties of group actions
This file primarily concerns itself with orbits, stabilizers, and other objects defined in terms of
actions. Despite this file being called `basic`, low-level helper lemmas for algebraic manipulation
of `•` belong elsewhere.
## Main definitions
* `MulAction.orbit`
* `MulAction.fixedPoints`
* `MulAction.fixedBy`
* `MulAction.stabilizer`
-/
universe u v
open Pointwise
open Function
namespace MulAction
variable (M : Type u) [Monoid M] (α : Type v) [MulAction M α] {β : Type*} [MulAction M β]
section Orbit
variable {α M}
@[to_additive]
lemma fst_mem_orbit_of_mem_orbit {x y : α × β} (h : x ∈ MulAction.orbit M y) :
x.1 ∈ MulAction.orbit M y.1 := by
rcases h with ⟨g, rfl⟩
exact mem_orbit _ _
@[to_additive]
lemma snd_mem_orbit_of_mem_orbit {x y : α × β} (h : x ∈ MulAction.orbit M y) :
x.2 ∈ MulAction.orbit M y.2 := by
rcases h with ⟨g, rfl⟩
exact mem_orbit _ _
@[to_additive]
lemma _root_.Finite.finite_mulAction_orbit [Finite M] (a : α) : Set.Finite (orbit M a) :=
Set.finite_range _
variable (M)
@[to_additive]
theorem orbit_eq_univ [IsPretransitive M α] (a : α) : orbit M a = Set.univ :=
(surjective_smul M a).range_eq
end Orbit
section FixedPoints
variable {M α}
@[to_additive (attr := simp)]
theorem subsingleton_orbit_iff_mem_fixedPoints {a : α} :
(orbit M a).Subsingleton ↔ a ∈ fixedPoints M α := by
rw [mem_fixedPoints]
constructor
· exact fun h m ↦ h (mem_orbit a m) (mem_orbit_self a)
· rintro h _ ⟨m, rfl⟩ y ⟨p, rfl⟩
simp only [h]
@[to_additive mem_fixedPoints_iff_card_orbit_eq_one]
theorem mem_fixedPoints_iff_card_orbit_eq_one {a : α} [Fintype (orbit M a)] :
a ∈ fixedPoints M α ↔ Fintype.card (orbit M a) = 1 := by
simp only [← subsingleton_orbit_iff_mem_fixedPoints, le_antisymm_iff,
Fintype.card_le_one_iff_subsingleton, Nat.add_one_le_iff, Fintype.card_pos_iff,
Set.subsingleton_coe, iff_self_and, Set.nonempty_coe_sort, nonempty_orbit, implies_true]
@[to_additive instDecidablePredMemSetFixedByAddOfDecidableEq]
instance (m : M) [DecidableEq β] :
DecidablePred fun b : β => b ∈ MulAction.fixedBy β m := fun b ↦ by
simp only [MulAction.mem_fixedBy]
infer_instance
end FixedPoints
end MulAction
/-- `smul` by a `k : M` over a group is injective, if `k` is not a zero divisor.
The general theory of such `k` is elaborated by `IsSMulRegular`.
The typeclass that restricts all terms of `M` to have this property is `NoZeroSMulDivisors`. -/
theorem smul_cancel_of_non_zero_divisor {M G : Type*} [Monoid M] [AddGroup G]
[DistribMulAction M G] (k : M) (h : ∀ x : G, k • x = 0 → x = 0) {a b : G} (h' : k • a = k • b) :
a = b := by
rw [← sub_eq_zero]
refine h _ ?_
rw [smul_sub, h', sub_self]
namespace MulAction
variable {G α β : Type*} [Group G] [MulAction G α] [MulAction G β]
@[to_additive] theorem fixedPoints_of_subsingleton [Subsingleton α] :
fixedPoints G α = .univ := by
apply Set.eq_univ_of_forall
simp only [mem_fixedPoints]
intro x hx
apply Subsingleton.elim ..
/-- If a group acts nontrivially, then the type is nontrivial -/
@[to_additive /-- If a subgroup acts nontrivially, then the type is nontrivial. -/]
theorem nontrivial_of_fixedPoints_ne_univ (h : fixedPoints G α ≠ .univ) :
Nontrivial α :=
(subsingleton_or_nontrivial α).resolve_left fun _ ↦ h fixedPoints_of_subsingleton
section Orbit
-- TODO: This proof is redoing a special case of `MulAction.IsInvariantBlock.isBlock`. Can we move
-- this lemma earlier to golf?
@[to_additive (attr := simp)]
theorem smul_orbit (g : G) (a : α) : g • orbit G a = orbit G a :=
(smul_orbit_subset g a).antisymm <|
calc
orbit G a = g • g⁻¹ • orbit G a := (smul_inv_smul _ _).symm
_ ⊆ g • orbit G a := Set.image_mono (smul_orbit_subset _ _)
/-- The action of a group on an orbit is transitive. -/
@[to_additive /-- The action of an additive group on an orbit is transitive. -/]
instance (a : α) : IsPretransitive G (orbit G a) :=
⟨by
rintro ⟨_, g, rfl⟩ ⟨_, h, rfl⟩
use h * g⁻¹
ext1
simp [mul_smul]⟩
@[to_additive]
lemma orbitRel_subgroup_le (H : Subgroup G) : orbitRel H α ≤ orbitRel G α :=
Setoid.le_def.2 mem_orbit_of_mem_orbit_subgroup
@[to_additive]
lemma orbitRel_subgroupOf (H K : Subgroup G) :
orbitRel (H.subgroupOf K) α = orbitRel (H ⊓ K : Subgroup G) α := by
rw [← Subgroup.subgroupOf_map_subtype]
ext x
simp_rw [orbitRel_apply]
refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩
· rcases h with ⟨⟨gv, gp⟩, rfl⟩
simp only
refine mem_orbit _ (⟨gv, ?_⟩ : Subgroup.map K.subtype (H.subgroupOf K))
simpa using gp
· rcases h with ⟨⟨gv, gp⟩, rfl⟩
simp only
simp only [Subgroup.subgroupOf_map_subtype, Subgroup.mem_inf] at gp
refine mem_orbit _ (⟨⟨gv, ?_⟩, ?_⟩ : H.subgroupOf K)
· exact gp.2
· simp only [Subgroup.mem_subgroupOf]
exact gp.1
variable (G α)
/-- An action is pretransitive if and only if the quotient by `MulAction.orbitRel` is a
subsingleton. -/
@[to_additive /-- An additive action is pretransitive if and only if the quotient by
`AddAction.orbitRel` is a subsingleton. -/]
theorem pretransitive_iff_subsingleton_quotient :
IsPretransitive G α ↔ Subsingleton (orbitRel.Quotient G α) := by
refine ⟨fun _ ↦ ⟨fun a b ↦ ?_⟩, fun _ ↦ ⟨fun a b ↦ ?_⟩⟩
· refine Quot.inductionOn a (fun x ↦ ?_)
exact Quot.inductionOn b (fun y ↦ Quot.sound <| exists_smul_eq G y x)
· have h : Quotient.mk (orbitRel G α) b = ⟦a⟧ := Subsingleton.elim _ _
exact Quotient.eq''.mp h
/-- If `α` is non-empty, an action is pretransitive if and only if the quotient has exactly one
element. -/
@[to_additive /-- If `α` is non-empty, an additive action is pretransitive if and only if the
quotient has exactly one element. -/]
theorem pretransitive_iff_unique_quotient_of_nonempty [Nonempty α] :
IsPretransitive G α ↔ Nonempty (Unique <| orbitRel.Quotient G α) := by
rw [unique_iff_subsingleton_and_nonempty, pretransitive_iff_subsingleton_quotient, iff_self_and]
exact fun _ ↦ (nonempty_quotient_iff _).mpr inferInstance
variable {G α}
@[to_additive]
instance (x : orbitRel.Quotient G α) : IsPretransitive G x.orbit where
exists_smul_eq := by
induction x using Quotient.inductionOn'
rintro ⟨y, yh⟩ ⟨z, zh⟩
rw [orbitRel.Quotient.mem_orbit, Quotient.eq''] at yh zh
rcases yh with ⟨g, rfl⟩
rcases zh with ⟨h, rfl⟩
refine ⟨h * g⁻¹, ?_⟩
ext
simp [mul_smul]
variable (G) (α)
local notation "Ω" => orbitRel.Quotient G α
@[to_additive]
lemma _root_.Finite.of_finite_mulAction_orbitRel_quotient [Finite G] [Finite Ω] : Finite α := by
rw [(selfEquivSigmaOrbits' G _).finite_iff]
have : ∀ g : Ω, Finite g.orbit := by
intro g
induction g using Quotient.inductionOn'
simpa [Set.finite_coe_iff] using Finite.finite_mulAction_orbit _
exact Finite.instSigma
variable (β)
@[to_additive]
lemma orbitRel_le_fst :
orbitRel G (α × β) ≤ (orbitRel G α).comap Prod.fst :=
Setoid.le_def.2 fst_mem_orbit_of_mem_orbit
@[to_additive]
lemma orbitRel_le_snd :
orbitRel G (α × β) ≤ (orbitRel G β).comap Prod.snd :=
Setoid.le_def.2 snd_mem_orbit_of_mem_orbit
end Orbit
section Stabilizer
@[to_additive (attr := simp)]
lemma _root_.IsCancelSMul.stabilizer_eq_bot [IsCancelSMul G α] (a : α) :
stabilizer G a = ⊥ :=
Subgroup.eq_bot_iff_forall _ |>.mpr fun _ hg ↦ IsCancelSMul.eq_one_of_smul hg
@[to_additive]
lemma _root_.isCancelSMul_iff_stabilizer_eq_bot :
IsCancelSMul G α ↔ (∀ a : α, stabilizer G a = ⊥) := by
simp [isCancelSMul_iff_eq_one_of_smul_eq, Subgroup.eq_bot_iff_forall, forall_swap (α := G)]
/-- If the stabilizer of `a` is `S`, then the stabilizer of `g • a` is `gSg⁻¹`. -/
theorem stabilizer_smul_eq_stabilizer_map_conj (g : G) (a : α) :
stabilizer G (g • a) = (stabilizer G a).map (MulAut.conj g).toMonoidHom := by
ext h
rw [mem_stabilizer_iff, ← smul_left_cancel_iff g⁻¹, smul_smul, smul_smul, smul_smul,
inv_mul_cancel, one_smul, ← mem_stabilizer_iff, Subgroup.mem_map_equiv, MulAut.conj_symm_apply]
variable {g h k : G} {a b c : α}
/-- The natural group equivalence between the stabilizers of two elements in the same orbit. -/
def stabilizerEquivStabilizer (hg : b = g • a) : stabilizer G a ≃* stabilizer G b :=
((MulAut.conj g).subgroupMap (stabilizer G a)).trans
(MulEquiv.subgroupCongr (by
rw [hg, stabilizer_smul_eq_stabilizer_map_conj g a, ← MulEquiv.toMonoidHom_eq_coe]))
theorem stabilizerEquivStabilizer_apply (hg : b = g • a) (x : stabilizer G a) :
stabilizerEquivStabilizer hg x = MulAut.conj g x := by
simp [stabilizerEquivStabilizer]
theorem stabilizerEquivStabilizer_symm_apply (hg : b = g • a) (x : stabilizer G b) :
(stabilizerEquivStabilizer hg).symm x = MulAut.conj g⁻¹ x := by
simp [stabilizerEquivStabilizer]
theorem stabilizerEquivStabilizer_trans (hg : b = g • a) (hh : c = h • b) (hk : c = k • a)
(H : k = h * g) :
(stabilizerEquivStabilizer hg).trans (stabilizerEquivStabilizer hh) =
stabilizerEquivStabilizer hk := by
ext; simp [stabilizerEquivStabilizer_apply, H]
theorem stabilizerEquivStabilizer_one :
stabilizerEquivStabilizer (one_smul G a).symm = MulEquiv.refl (stabilizer G a) := by
ext; simp [stabilizerEquivStabilizer_apply]
theorem stabilizerEquivStabilizer_symm (hg : b = g • a) :
(stabilizerEquivStabilizer hg).symm =
stabilizerEquivStabilizer (eq_inv_smul_iff.mpr hg.symm) := by
ext x; simp [stabilizerEquivStabilizer]
theorem stabilizerEquivStabilizer_inv (hg : b = g⁻¹ • a) :
stabilizerEquivStabilizer hg =
(stabilizerEquivStabilizer (inv_smul_eq_iff.mp hg.symm)).symm := by
ext; simp [stabilizerEquivStabilizer]
/-- A bijection between the stabilizers of two elements in the same orbit. -/
noncomputable def stabilizerEquivStabilizerOfOrbitRel (h : orbitRel G α a b) :
stabilizer G a ≃* stabilizer G b :=
(stabilizerEquivStabilizer (Classical.choose_spec h).symm).symm
end Stabilizer
end MulAction
namespace AddAction
variable {G α : Type*} [AddGroup G] [AddAction G α]
variable {g h k : G} {a b c : α}
/-- If the stabilizer of `x` is `S`, then the stabilizer of `g +ᵥ x` is `g + S + (-g)`. -/
theorem stabilizer_vadd_eq_stabilizer_map_conj (g : G) (a : α) :
stabilizer G (g +ᵥ a) = (stabilizer G a).map (AddAut.conj g).toMul.toAddMonoidHom := by
ext h
rw [mem_stabilizer_iff, ← vadd_left_cancel_iff (-g), vadd_vadd, vadd_vadd, vadd_vadd,
neg_add_cancel, zero_vadd, ← mem_stabilizer_iff, AddSubgroup.mem_map_equiv,
AddAut.conj_symm_apply]
variable {g h k : G} {a b c : α}
/-- The natural group equivalence between the stabilizers of two elements in the same orbit. -/
def stabilizerEquivStabilizer (hg : b = g +ᵥ a) : stabilizer G a ≃+ stabilizer G b :=
AddEquiv.trans ((AddAut.conj g).toMul.addSubgroupMap _)
(AddEquiv.addSubgroupCongr (by
rw [hg, stabilizer_vadd_eq_stabilizer_map_conj g a, ← AddEquiv.toAddMonoidHom_eq_coe]))
theorem stabilizerEquivStabilizer_apply (hg : b = g +ᵥ a) (x : stabilizer G a) :
stabilizerEquivStabilizer hg x = (AddAut.conj g).toMul x := by
simp [stabilizerEquivStabilizer]
theorem stabilizerEquivStabilizer_symm_apply (hg : b = g +ᵥ b) (x : stabilizer G b) :
(stabilizerEquivStabilizer hg).symm x = (AddAut.conj (-g)).toMul x := by
simp [stabilizerEquivStabilizer]
theorem stabilizerEquivStabilizer_trans
(hg : b = g +ᵥ a) (hh : c = h +ᵥ b) (hk : c = k +ᵥ a) (H : k = h + g) :
(stabilizerEquivStabilizer hg).trans (stabilizerEquivStabilizer hh)
= stabilizerEquivStabilizer hk := by
ext; simp [stabilizerEquivStabilizer_apply, H]
theorem stabilizerEquivStabilizer_zero :
stabilizerEquivStabilizer (zero_vadd G a).symm = AddEquiv.refl (stabilizer G a) := by
ext; simp [stabilizerEquivStabilizer_apply]
theorem stabilizerEquivStabilizer_symm (hg : b = g +ᵥ a) :
(stabilizerEquivStabilizer hg).symm =
stabilizerEquivStabilizer (eq_neg_vadd_iff.mpr hg.symm) := by
ext; simp [stabilizerEquivStabilizer]
theorem stabilizerEquivStabilizer_neg (hg : b = -g +ᵥ a) :
stabilizerEquivStabilizer hg =
(stabilizerEquivStabilizer (neg_vadd_eq_iff.mp hg.symm)).symm := by
ext; simp [stabilizerEquivStabilizer]
/-- A bijection between the stabilizers of two elements in the same orbit. -/
noncomputable def stabilizerEquivStabilizerOfOrbitRel (h : orbitRel G α a b) :
stabilizer G a ≃+ stabilizer G b :=
(stabilizerEquivStabilizer (Classical.choose_spec h).symm).symm
end AddAction
attribute [to_additive existing] MulAction.stabilizerEquivStabilizer
attribute [to_additive existing] MulAction.stabilizerEquivStabilizer_trans
attribute [to_additive existing] MulAction.stabilizerEquivStabilizer_one
attribute [to_additive existing] MulAction.stabilizerEquivStabilizer_inv
attribute [to_additive existing] MulAction.stabilizerEquivStabilizerOfOrbitRel
theorem Equiv.swap_mem_stabilizer {α : Type*} [DecidableEq α] {S : Set α} {a b : α} :
Equiv.swap a b ∈ MulAction.stabilizer (Equiv.Perm α) S ↔ (a ∈ S ↔ b ∈ S) := by
rw [MulAction.mem_stabilizer_iff, Set.ext_iff, ← swap_inv]
simp_rw [Set.mem_inv_smul_set_iff, Perm.smul_def, swap_apply_def]
exact ⟨fun h ↦ by simpa [Iff.comm] using h a, by intros; split_ifs <;> simp [*]⟩
namespace MulAction
variable {G : Type*} [Group G] {α : Type*} [MulAction G α]
/-- To prove inclusion of a *subgroup* in a stabilizer, it is enough to prove inclusions. -/
@[to_additive
/-- To prove inclusion of a *subgroup* in a stabilizer, it is enough to prove inclusions. -/]
theorem le_stabilizer_iff_smul_le (s : Set α) (H : Subgroup G) :
H ≤ stabilizer G s ↔ ∀ g ∈ H, g • s ⊆ s := by
constructor
· intro hyp g hg
apply Eq.subset
rw [← mem_stabilizer_iff]
exact hyp hg
· intro hyp g hg
rw [mem_stabilizer_iff]
apply subset_antisymm (hyp g hg)
intro x hx
use g⁻¹ • x
constructor
· apply hyp g⁻¹ (inv_mem hg)
simp only [Set.smul_mem_smul_set_iff, hx]
· simp only [smul_inv_smul]
end MulAction
section
variable (R M : Type*) [Ring R] [AddCommGroup M] [Module R M] [NoZeroSMulDivisors R M]
variable {M} in
lemma Module.stabilizer_units_eq_bot_of_ne_zero {x : M} (hx : x ≠ 0) :
MulAction.stabilizer Rˣ x = ⊥ := by
rw [eq_bot_iff]
intro g (hg : g.val • x = x)
ext
rw [← sub_eq_zero, ← smul_eq_zero_iff_left hx, Units.val_one, sub_smul, hg, one_smul, sub_self]
end |
.lake/packages/mathlib/Mathlib/GroupTheory/GroupAction/IterateAct.lean | import Mathlib.Algebra.Group.Action.Defs
import Mathlib.Data.Countable.Defs
/-!
# Monoid action by iterates of a map
In this file we define `IterateMulAct f`, `f : α → α`, as a one field structure wrapper over `ℕ`
that acts on `α` by iterates of `f`, `⟨n⟩ • x = f^[n] x`.
It is useful to convert between definitions and theorems about maps and monoid actions.
-/
/-- A structure with a single field `val : ℕ`
that additively acts on `α` by `⟨n⟩ +ᵥ x = f^[n] x`. -/
structure IterateAddAct {α : Type*} (f : α → α) where
/-- The value of `n : IterateAddAct f`. -/
val : ℕ
/-- A structure with a single field `val : ℕ` that acts on `α` by `⟨n⟩ • x = f^[n] x`. -/
@[to_additive (attr := ext)]
structure IterateMulAct {α : Type*} (f : α → α) where
/-- The value of `n : IterateMulAct f`. -/
val : ℕ
namespace IterateMulAct
variable {α : Type*} {f : α → α}
@[to_additive]
instance instCountable : Countable (IterateMulAct f) :=
Function.Injective.countable fun _ _ ↦ IterateMulAct.ext
@[to_additive]
instance instCommMonoid : CommMonoid (IterateMulAct f) where
one := ⟨0⟩
mul m n := ⟨m.1 + n.1⟩
mul_assoc a b c := by ext; apply Nat.add_assoc
one_mul _ := by ext; apply Nat.zero_add
mul_one _ := rfl
mul_comm _ _ := by ext; apply Nat.add_comm
npow n a := ⟨n * a.val⟩
npow_zero _ := by ext; apply Nat.zero_mul
npow_succ n a := by ext; apply Nat.succ_mul
@[to_additive]
instance instMulAction : MulAction (IterateMulAct f) α where
smul n x := f^[n.val] x
one_smul _ := rfl
mul_smul _ _ := Function.iterate_add_apply f _ _
@[to_additive (attr := simp)]
theorem mk_smul (n : ℕ) (x : α) : mk (f := f) n • x = f^[n] x := rfl
end IterateMulAct |
.lake/packages/mathlib/Mathlib/GroupTheory/GroupAction/Quotient.lean | import Mathlib.Algebra.Group.Subgroup.Actions
import Mathlib.Algebra.Group.Subgroup.ZPowers.Lemmas
import Mathlib.Data.Fintype.BigOperators
import Mathlib.Dynamics.PeriodicPts.Defs
import Mathlib.GroupTheory.Commutator.Basic
import Mathlib.GroupTheory.Coset.Basic
import Mathlib.GroupTheory.GroupAction.Basic
import Mathlib.GroupTheory.GroupAction.ConjAct
import Mathlib.GroupTheory.GroupAction.Hom
/-!
# Properties of group actions involving quotient groups
This file proves properties of group actions which use the quotient group construction, notably
* the orbit-stabilizer theorem `MulAction.card_orbit_mul_card_stabilizer_eq_card_group`
* the class formula `MulAction.selfEquivSigmaOrbitsQuotientStabilizer'`
* Burnside's lemma `MulAction.sum_card_fixedBy_eq_card_orbits_mul_card_group`,
as well as their analogues for additive groups.
-/
assert_not_exists Cardinal
universe u v w
variable {α : Type u} {β : Type v} {γ : Type w}
open Function
namespace MulAction
variable [Group α]
section QuotientAction
open Subgroup MulOpposite QuotientGroup
variable (β) [Monoid β] [MulAction β α] (H : Subgroup α)
/-- A typeclass for when a `MulAction β α` descends to the quotient `α ⧸ H`. -/
class QuotientAction : Prop where
/-- The action fulfils a normality condition on products that lie in `H`.
This ensures that the action descends to an action on the quotient `α ⧸ H`. -/
inv_mul_mem : ∀ (b : β) {a a' : α}, a⁻¹ * a' ∈ H → (b • a)⁻¹ * b • a' ∈ H
/-- A typeclass for when an `AddAction β α` descends to the quotient `α ⧸ H`. -/
class _root_.AddAction.QuotientAction {α : Type u} (β : Type v) [AddGroup α] [AddMonoid β]
[AddAction β α] (H : AddSubgroup α) : Prop where
/-- The action fulfils a normality condition on summands that lie in `H`.
This ensures that the action descends to an action on the quotient `α ⧸ H`. -/
inv_mul_mem : ∀ (b : β) {a a' : α}, -a + a' ∈ H → -(b +ᵥ a) + (b +ᵥ a') ∈ H
attribute [to_additive] MulAction.QuotientAction
@[to_additive]
instance left_quotientAction : QuotientAction α H :=
⟨fun _ _ _ _ => by rwa [smul_eq_mul, smul_eq_mul, mul_inv_rev, mul_assoc, inv_mul_cancel_left]⟩
@[to_additive]
instance right_quotientAction : QuotientAction (normalizer H).op H :=
⟨fun b c _ _ => by
rwa [smul_def, smul_def, smul_eq_mul_unop, smul_eq_mul_unop, mul_inv_rev, ← mul_assoc,
mem_normalizer_iff'.mp b.prop, mul_assoc, mul_inv_cancel_left]⟩
@[to_additive]
instance right_quotientAction' [hH : H.Normal] : QuotientAction αᵐᵒᵖ H :=
⟨fun _ _ _ _ => by
rwa [smul_eq_mul_unop, smul_eq_mul_unop, mul_inv_rev, mul_assoc, hH.mem_comm_iff, mul_assoc,
mul_inv_cancel_right]⟩
@[to_additive]
instance quotient [QuotientAction β H] : MulAction β (α ⧸ H) where
smul b :=
Quotient.map' (b • ·) fun _ _ h =>
leftRel_apply.mpr <| QuotientAction.inv_mul_mem b <| leftRel_apply.mp h
one_smul q := Quotient.inductionOn' q fun a => congr_arg Quotient.mk'' (one_smul β a)
mul_smul b b' q := Quotient.inductionOn' q fun a => congr_arg Quotient.mk'' (mul_smul b b' a)
variable {β}
@[to_additive (attr := simp)]
theorem Quotient.smul_mk [QuotientAction β H] (b : β) (a : α) :
(b • QuotientGroup.mk a : α ⧸ H) = QuotientGroup.mk (b • a) :=
rfl
@[to_additive (attr := simp)]
theorem Quotient.smul_coe [QuotientAction β H] (b : β) (a : α) :
b • (a : α ⧸ H) = (↑(b • a) : α ⧸ H) :=
rfl
@[to_additive (attr := simp)]
theorem Quotient.mk_smul_out [QuotientAction β H] (b : β) (q : α ⧸ H) :
QuotientGroup.mk (b • q.out) = b • q := by rw [← Quotient.smul_mk, QuotientGroup.out_eq']
@[to_additive]
theorem Quotient.coe_smul_out [QuotientAction β H] (b : β) (q : α ⧸ H) : ↑(b • q.out) = b • q := by
simp
theorem _root_.QuotientGroup.out_conj_pow_minimalPeriod_mem (a : α) (q : α ⧸ H) :
q.out⁻¹ * a ^ Function.minimalPeriod (a • ·) q * q.out ∈ H := by
rw [mul_assoc, ← QuotientGroup.eq, QuotientGroup.out_eq', ← smul_eq_mul, Quotient.mk_smul_out,
eq_comm, pow_smul_eq_iff_minimalPeriod_dvd]
end QuotientAction
open QuotientGroup
/-- The canonical map to the left cosets. -/
def _root_.MulActionHom.toQuotient (H : Subgroup α) : α →[α] α ⧸ H where
toFun := (↑); map_smul' := Quotient.smul_coe H
@[simp]
theorem _root_.MulActionHom.toQuotient_apply (H : Subgroup α) (g : α) :
MulActionHom.toQuotient H g = g :=
rfl
@[to_additive]
instance mulLeftCosetsCompSubtypeVal (H I : Subgroup α) : MulAction I (α ⧸ H) :=
MulAction.compHom (α ⧸ H) (Subgroup.subtype I)
variable (α)
variable [MulAction α β] (x : β)
/-- The canonical map from the quotient of the stabilizer to the set. -/
@[to_additive /-- The canonical map from the quotient of the stabilizer to the set. -/]
def ofQuotientStabilizer (g : α ⧸ MulAction.stabilizer α x) : β :=
Quotient.liftOn' g (· • x) fun g1 g2 H =>
calc
g1 • x = g1 • (g1⁻¹ * g2) • x := congr_arg _ (leftRel_apply.mp H).symm
_ = g2 • x := by rw [smul_smul, mul_inv_cancel_left]
@[to_additive (attr := simp)]
theorem ofQuotientStabilizer_mk (g : α) : ofQuotientStabilizer α x (QuotientGroup.mk g) = g • x :=
rfl
@[to_additive]
theorem ofQuotientStabilizer_mem_orbit (g) : ofQuotientStabilizer α x g ∈ orbit α x :=
Quotient.inductionOn' g fun g => ⟨g, rfl⟩
@[to_additive]
theorem ofQuotientStabilizer_smul (g : α) (g' : α ⧸ MulAction.stabilizer α x) :
ofQuotientStabilizer α x (g • g') = g • ofQuotientStabilizer α x g' :=
Quotient.inductionOn' g' fun _ => mul_smul _ _ _
@[to_additive]
theorem injective_ofQuotientStabilizer : Function.Injective (ofQuotientStabilizer α x) :=
fun y₁ y₂ =>
Quotient.inductionOn₂' y₁ y₂ fun g₁ g₂ (H : g₁ • x = g₂ • x) =>
Quotient.sound' <| by
rw [leftRel_apply]
change (g₁⁻¹ * g₂) • x = x
rw [mul_smul, ← H, inv_smul_smul]
/-- **Orbit-stabilizer theorem**. -/
@[to_additive /-- Orbit-stabilizer theorem. -/]
noncomputable def orbitEquivQuotientStabilizer (b : β) : orbit α b ≃ α ⧸ stabilizer α b :=
Equiv.symm <|
Equiv.ofBijective (fun g => ⟨ofQuotientStabilizer α b g, ofQuotientStabilizer_mem_orbit α b g⟩)
⟨fun x y hxy => injective_ofQuotientStabilizer α b (by convert congr_arg Subtype.val hxy),
fun ⟨_, ⟨g, hgb⟩⟩ => ⟨g, Subtype.eq hgb⟩⟩
/-- Orbit-stabilizer theorem. -/
@[to_additive AddAction.orbitProdStabilizerEquivAddGroup /-- Orbit-stabilizer theorem. -/]
noncomputable def orbitProdStabilizerEquivGroup (b : β) : orbit α b × stabilizer α b ≃ α :=
(Equiv.prodCongr (orbitEquivQuotientStabilizer α _) (Equiv.refl _)).trans
Subgroup.groupEquivQuotientProdSubgroup.symm
/-- Orbit-stabilizer theorem. -/
@[to_additive AddAction.card_orbit_mul_card_stabilizer_eq_card_addGroup
/-- Orbit-stabilizer theorem. -/]
theorem card_orbit_mul_card_stabilizer_eq_card_group (b : β) [Fintype α] [Fintype <| orbit α b]
[Fintype <| stabilizer α b] :
Fintype.card (orbit α b) * Fintype.card (stabilizer α b) = Fintype.card α := by
rw [← Fintype.card_prod, Fintype.card_congr (orbitProdStabilizerEquivGroup α b)]
@[to_additive (attr := simp)]
theorem orbitEquivQuotientStabilizer_symm_apply (b : β) (a : α) :
((orbitEquivQuotientStabilizer α b).symm a : β) = a • b :=
rfl
@[to_additive (attr := simp)]
theorem stabilizer_quotient {G} [Group G] (H : Subgroup G) :
MulAction.stabilizer G ((1 : G) : G ⧸ H) = H := by
ext
simp [QuotientGroup.eq]
variable (β)
local notation "Ω" => Quotient <| orbitRel α β
/-- **Class formula** : given `G` a group acting on `X` and `φ` a function mapping each orbit of `X`
under this action (that is, each element of the quotient of `X` by the relation `orbitRel G X`) to
an element in this orbit, this gives a (noncomputable) bijection between `X` and the disjoint union
of `G/Stab(φ(ω))` over all orbits `ω`. In most cases you'll want `φ` to be `Quotient.out`, so we
provide `MulAction.selfEquivSigmaOrbitsQuotientStabilizer'` as a special case. -/
@[to_additive
/-- **Class formula** : given `G` an additive group acting on `X` and `φ` a function
mapping each orbit of `X` under this action (that is, each element of the quotient of `X` by
the relation `orbit_rel G X`) to an element in this orbit, this gives a (noncomputable)
bijection between `X` and the disjoint union of `G/Stab(φ(ω))` over all orbits `ω`. In most
cases you'll want `φ` to be `Quotient.out`, so we provide
`AddAction.selfEquivSigmaOrbitsQuotientStabilizer'` as a special case. -/]
noncomputable def selfEquivSigmaOrbitsQuotientStabilizer' {φ : Ω → β}
(hφ : LeftInverse Quotient.mk'' φ) : β ≃ Σ ω : Ω, α ⧸ stabilizer α (φ ω) :=
calc
β ≃ Σ ω : Ω, orbitRel.Quotient.orbit ω := selfEquivSigmaOrbits' α β
_ ≃ Σ ω : Ω, α ⧸ stabilizer α (φ ω) :=
Equiv.sigmaCongrRight fun ω =>
(Equiv.setCongr <| orbitRel.Quotient.orbit_eq_orbit_out _ hφ).trans <|
orbitEquivQuotientStabilizer α (φ ω)
/-- **Class formula**. This is a special case of
`MulAction.self_equiv_sigma_orbits_quotient_stabilizer'` with `φ = Quotient.out`. -/
@[to_additive
/-- **Class formula**. This is a special case of
`AddAction.self_equiv_sigma_orbits_quotient_stabilizer'` with `φ = Quotient.out`. -/]
noncomputable def selfEquivSigmaOrbitsQuotientStabilizer : β ≃ Σ ω : Ω, α ⧸ stabilizer α ω.out :=
selfEquivSigmaOrbitsQuotientStabilizer' α β Quotient.out_eq'
/-- **Burnside's lemma** : a (noncomputable) bijection between the disjoint union of all
`{x ∈ X | g • x = x}` for `g ∈ G` and the product `G × X/G`, where `G` is a group acting on `X` and
`X/G` denotes the quotient of `X` by the relation `orbitRel G X`. -/
@[to_additive AddAction.sigmaFixedByEquivOrbitsProdAddGroup
/-- **Burnside's lemma** : a (noncomputable) bijection between the disjoint union of all
`{x ∈ X | g • x = x}` for `g ∈ G` and the product `G × X/G`, where `G` is an additive group
acting on `X` and `X/G`denotes the quotient of `X` by the relation `orbitRel G X`. -/]
noncomputable def sigmaFixedByEquivOrbitsProdGroup : (Σ a : α, fixedBy β a) ≃ Ω × α :=
calc
(Σ a : α, fixedBy β a) ≃ { ab : α × β // ab.1 • ab.2 = ab.2 } :=
(Equiv.subtypeProdEquivSigmaSubtype _).symm
_ ≃ { ba : β × α // ba.2 • ba.1 = ba.1 } := (Equiv.prodComm α β).subtypeEquiv fun _ => Iff.rfl
_ ≃ Σ b : β, stabilizer α b :=
Equiv.subtypeProdEquivSigmaSubtype fun (b : β) a => a ∈ stabilizer α b
_ ≃ Σ ωb : Σ ω : Ω, orbit α ω.out, stabilizer α (ωb.2 : β) :=
(selfEquivSigmaOrbits α β).sigmaCongrLeft'
_ ≃ Σ ω : Ω, Σ b : orbit α ω.out, stabilizer α (b : β) :=
Equiv.sigmaAssoc fun (ω : Ω) (b : orbit α ω.out) => stabilizer α (b : β)
_ ≃ Σ ω : Ω, Σ _ : orbit α ω.out, stabilizer α ω.out :=
Equiv.sigmaCongrRight fun _ =>
Equiv.sigmaCongrRight fun ⟨_, hb⟩ => (stabilizerEquivStabilizerOfOrbitRel hb).toEquiv
_ ≃ Σ ω : Ω, orbit α ω.out × stabilizer α ω.out :=
Equiv.sigmaCongrRight fun _ => Equiv.sigmaEquivProd _ _
_ ≃ Σ _ : Ω, α := Equiv.sigmaCongrRight fun ω => orbitProdStabilizerEquivGroup α ω.out
_ ≃ Ω × α := Equiv.sigmaEquivProd Ω α
/-- **Burnside's lemma** : given a finite group `G` acting on a set `X`, the average number of
elements fixed by each `g ∈ G` is the number of orbits. -/
@[to_additive AddAction.sum_card_fixedBy_eq_card_orbits_mul_card_addGroup
/-- **Burnside's lemma** : given a finite additive group `G` acting on a set `X`,
the average number of elements fixed by each `g ∈ G` is the number of orbits. -/]
theorem sum_card_fixedBy_eq_card_orbits_mul_card_group [Fintype α] [∀ a : α, Fintype <| fixedBy β a]
[Fintype Ω] : (∑ a : α, Fintype.card (fixedBy β a)) = Fintype.card Ω * Fintype.card α := by
rw [← Fintype.card_prod, ← Fintype.card_sigma,
Fintype.card_congr (sigmaFixedByEquivOrbitsProdGroup α β)]
@[to_additive]
instance isPretransitive_quotient (G) [Group G] (H : Subgroup G) : IsPretransitive G (G ⧸ H) where
exists_smul_eq := by
{ rintro ⟨x⟩ ⟨y⟩
refine ⟨y * x⁻¹, QuotientGroup.eq.mpr ?_⟩
simp only [smul_eq_mul, H.one_mem, inv_mul_cancel, inv_mul_cancel_right]}
variable {α}
@[to_additive]
instance finite_quotient_of_pretransitive_of_finite_quotient [IsPretransitive α β] {H : Subgroup α}
[Finite (α ⧸ H)] : Finite <| orbitRel.Quotient H β := by
rcases isEmpty_or_nonempty β with he | ⟨⟨b⟩⟩
· exact Quotient.finite _
· have h' : Finite (Quotient (rightRel H)) :=
Finite.of_equiv _ (quotientRightRelEquivQuotientLeftRel _).symm
let f : Quotient (rightRel H) → orbitRel.Quotient H β :=
fun a ↦ Quotient.liftOn' a (fun g ↦ ⟦g • b⟧) fun g₁ g₂ r ↦ by
replace r := Setoid.symm' _ r
rw [rightRel_eq] at r
simp only [Quotient.eq, orbitRel_apply, mem_orbit_iff]
exact ⟨⟨g₁ * g₂⁻¹, r⟩, by simp [mul_smul]⟩
exact Finite.of_surjective f ((Quotient.surjective_liftOn' _).2
(Quotient.mk''_surjective.comp (MulAction.surjective_smul _ _)))
variable {β} in
/-- A bijection between the quotient of the action of a subgroup `H` on an orbit, and a
corresponding quotient expressed in terms of `Setoid.comap Subtype.val`. -/
@[to_additive /-- A bijection between the quotient of the action of an additive subgroup `H` on an
orbit, and a corresponding quotient expressed in terms of `Setoid.comap Subtype.val`. -/]
noncomputable def equivSubgroupOrbitsSetoidComap (H : Subgroup α) (ω : Ω) :
orbitRel.Quotient H (orbitRel.Quotient.orbit ω) ≃
Quotient ((orbitRel H β).comap (Subtype.val : Quotient.mk (orbitRel α β) ⁻¹' {ω} → β)) where
toFun := fun q ↦ q.liftOn' (fun x ↦ ⟦⟨↑x, by
simp only [Set.mem_preimage, Set.mem_singleton_iff]
have hx := x.property
rwa [orbitRel.Quotient.mem_orbit] at hx⟩⟧) fun a b h ↦ by
simp only [← Quotient.eq, orbitRel.Quotient.subgroup_quotient_eq_iff] at h
simp only [Quotient.eq] at h ⊢
exact h
invFun := fun q ↦ q.liftOn' (fun x ↦ ⟦⟨↑x, by
have hx := x.property
simp only [Set.mem_preimage, Set.mem_singleton_iff] at hx
rwa [orbitRel.Quotient.mem_orbit, @Quotient.mk''_eq_mk]⟩⟧) fun a b h ↦ by
rw [Setoid.comap_rel, ← Quotient.eq'', @Quotient.mk''_eq_mk] at h
simp only [orbitRel.Quotient.subgroup_quotient_eq_iff]
exact h
left_inv := by
simp only [LeftInverse]
intro q
induction q using Quotient.inductionOn'
rfl
right_inv := by
simp only [Function.RightInverse, LeftInverse]
intro q
induction q using Quotient.inductionOn'
rfl
/-- A bijection between the orbits under the action of a subgroup `H` on `β`, and the orbits
under the action of `H` on each orbit under the action of `G`. -/
@[to_additive /-- A bijection between the orbits under the action of an additive subgroup `H` on
`β`, and the orbits under the action of `H` on each orbit under the action of `G`. -/]
noncomputable def equivSubgroupOrbits (H : Subgroup α) :
orbitRel.Quotient H β ≃ Σ ω : Ω, orbitRel.Quotient H (orbitRel.Quotient.orbit ω) :=
(Setoid.sigmaQuotientEquivOfLe (orbitRel_subgroup_le H)).symm.trans
(Equiv.sigmaCongrRight fun ω ↦ (equivSubgroupOrbitsSetoidComap H ω).symm)
variable {β}
@[to_additive]
instance finite_quotient_of_finite_quotient_of_finite_quotient {H : Subgroup α}
[Finite (orbitRel.Quotient α β)] [Finite (α ⧸ H)] :
Finite <| orbitRel.Quotient H β := by
rw [(equivSubgroupOrbits β H).finite_iff]
infer_instance
/-- Given a group acting freely and transitively, an equivalence between the orbits under the
action of a subgroup and the quotient group. -/
@[to_additive /-- Given an additive group acting freely and transitively, an equivalence between the
orbits under the action of an additive subgroup and the quotient group. -/]
noncomputable def equivSubgroupOrbitsQuotientGroup [IsPretransitive α β]
[IsCancelSMul α β] (H : Subgroup α) :
orbitRel.Quotient H β ≃ α ⧸ H where
toFun := fun q ↦ q.liftOn' (fun y ↦ (exists_smul_eq α y x).choose) (by
intro y₁ y₂ h
rw [orbitRel_apply] at h
rw [Quotient.eq'', leftRel_eq]
dsimp only
rcases h with ⟨g, rfl⟩
dsimp only
suffices (exists_smul_eq α (g • y₂) x).choose = (exists_smul_eq α y₂ x).choose * g⁻¹ by
simp [this]
refine IsCancelSMul.right_cancel _ _ (g • y₂) ?_
rw [(exists_smul_eq α (g • y₂) x).choose_spec, Subgroup.smul_def, Subgroup.coe_inv,
smul_smul, inv_mul_cancel_right, (exists_smul_eq α y₂ x).choose_spec])
invFun := fun q ↦ q.liftOn' (fun g ↦ ⟦g⁻¹ • x⟧) (by
intro g₁ g₂ h
rw [leftRel_eq] at h
simp only
rw [← @Quotient.mk''_eq_mk, Quotient.eq'', orbitRel_apply]
exact ⟨⟨_, h⟩, by simp [mul_smul]⟩)
left_inv := fun y ↦ by
cases y using Quotient.inductionOn'
simp only [Quotient.liftOn'_mk'']
rw [← @Quotient.mk''_eq_mk, Quotient.eq'', orbitRel_apply]
convert mem_orbit_self _
rw [inv_smul_eq_iff, (exists_smul_eq α _ x).choose_spec]
right_inv := fun g ↦ by
cases g using Quotient.inductionOn' with | _ g
simp only [Quotient.liftOn'_mk'', QuotientGroup.mk]
rw [Quotient.eq'', leftRel_eq]
simp only
convert one_mem H
rw [inv_mul_eq_one, eq_comm, ← inv_mul_eq_one, ← Subgroup.mem_bot,
← IsCancelSMul.stabilizer_eq_bot (g⁻¹ • x), mem_stabilizer_iff, mul_smul,
(exists_smul_eq α (g⁻¹ • x) x).choose_spec]
/-- If `α` acts on `β` with trivial stabilizers, `β` is equivalent
to the product of the quotient of `β` by `α` and `α`.
See `MulAction.selfEquivOrbitsQuotientProd` with `φ = Quotient.out`. -/
@[to_additive selfEquivOrbitsQuotientProd' /-- If `α` acts freely on `β`, `β` is equivalent
to the product of the quotient of `β` by `α` and `α`.
See `AddAction.selfEquivOrbitsQuotientProd` with `φ = Quotient.out`. -/]
noncomputable def selfEquivOrbitsQuotientProd'
{φ : Quotient (MulAction.orbitRel α β) → β} (hφ : Function.LeftInverse Quotient.mk'' φ)
(h : ∀ b : β, MulAction.stabilizer α b = ⊥) :
β ≃ Quotient (MulAction.orbitRel α β) × α :=
(MulAction.selfEquivSigmaOrbitsQuotientStabilizer' α β hφ).trans <|
(Equiv.sigmaCongrRight <| fun _ ↦
(Subgroup.quotientEquivOfEq (h _)).trans (QuotientGroup.quotientEquivSelf α)).trans <|
Equiv.sigmaEquivProd _ _
/-- If `α` acts freely on `β`, `β` is equivalent to the product of the quotient of `β` by `α` and
`α`. -/
@[to_additive selfEquivOrbitsQuotientProd
/-- If `α` acts freely on `β`, `β` is equivalent to the product of the quotient of `β` by
`α` and `α`. -/]
noncomputable def selfEquivOrbitsQuotientProd (h : ∀ b : β, MulAction.stabilizer α b = ⊥) :
β ≃ Quotient (MulAction.orbitRel α β) × α :=
MulAction.selfEquivOrbitsQuotientProd' Quotient.out_eq' h
end MulAction
theorem ConjClasses.card_carrier {G : Type*} [Group G] [Fintype G] (g : G)
[Fintype (ConjClasses.mk g).carrier] [Fintype <| MulAction.stabilizer (ConjAct G) g] :
Fintype.card (ConjClasses.mk g).carrier =
Fintype.card G / Fintype.card (MulAction.stabilizer (ConjAct G) g) := by
classical
rw [Fintype.card_congr <| ConjAct.toConjAct (G := G) |>.toEquiv]
rw [← MulAction.card_orbit_mul_card_stabilizer_eq_card_group (ConjAct G) g, Nat.mul_div_cancel]
· simp_rw [ConjAct.orbit_eq_carrier_conjClasses]
· exact Fintype.card_pos_iff.mpr inferInstance
namespace Subgroup
variable {G : Type*} [Group G] (H : Subgroup G)
theorem normalCore_eq_ker : H.normalCore = (MulAction.toPermHom G (G ⧸ H)).ker := by
apply le_antisymm
· intro g hg
apply Equiv.Perm.ext
refine fun q ↦ QuotientGroup.induction_on q ?_
refine fun g' => (MulAction.Quotient.smul_mk H g g').trans (QuotientGroup.eq.mpr ?_)
rw [smul_eq_mul, mul_inv_rev, ← inv_inv g', inv_inv]
exact H.normalCore.inv_mem hg g'⁻¹
· refine (Subgroup.normal_le_normalCore.mpr fun g hg => ?_)
rw [← H.inv_mem_iff, ← mul_one g⁻¹, ← QuotientGroup.eq, ← mul_one g]
exact (MulAction.Quotient.smul_mk H g 1).symm.trans (Equiv.Perm.ext_iff.mp hg (1 : G))
open QuotientGroup
/-- Cosets of the centralizer of an element embed into the set of commutators. -/
noncomputable def quotientCentralizerEmbedding (g : G) :
G ⧸ centralizer (zpowers (g : G)) ↪ commutatorSet G :=
((MulAction.orbitEquivQuotientStabilizer (ConjAct G) g).trans
(quotientEquivOfEq (ConjAct.stabilizer_eq_centralizer g))).symm.toEmbedding.trans
⟨fun x =>
⟨x * g⁻¹,
let ⟨_, x, rfl⟩ := x
⟨x, g, rfl⟩⟩,
fun _ _ => Subtype.ext ∘ mul_right_cancel ∘ Subtype.ext_iff.mp⟩
theorem quotientCentralizerEmbedding_apply (g : G) (x : G) :
quotientCentralizerEmbedding g x = ⟨⁅x, g⁆, x, g, rfl⟩ :=
rfl
/-- If `G` is generated by `S`, then the quotient by the center embeds into `S`-indexed sequences
of commutators. -/
noncomputable def quotientCenterEmbedding {S : Set G} (hS : closure S = ⊤) :
G ⧸ center G ↪ S → commutatorSet G :=
(quotientEquivOfEq (center_eq_infi' S hS)).toEmbedding.trans
((quotientiInfEmbedding _).trans
(Function.Embedding.piCongrRight fun g => quotientCentralizerEmbedding (g : G)))
theorem quotientCenterEmbedding_apply {S : Set G} (hS : closure S = ⊤) (g : G) (s : S) :
quotientCenterEmbedding hS g s = ⟨⁅g, s⁆, g, s, rfl⟩ :=
rfl
end Subgroup |
.lake/packages/mathlib/Mathlib/GroupTheory/GroupAction/FixingSubgroup.lean | import Mathlib.Algebra.Group.Subgroup.Lattice
import Mathlib.GroupTheory.GroupAction.FixedPoints
/-!
# Fixing submonoid, fixing subgroup of an action
In the presence of an action of a monoid or a group,
this file defines the fixing submonoid or the fixing subgroup,
and relates it to the set of fixed points via a Galois connection.
## Main definitions
* `fixingSubmonoid M s` : in the presence of `MulAction M α` (with `Monoid M`)
it is the `Submonoid M` consisting of elements which fix `s : Set α` pointwise.
* `fixingSubmonoid_fixedPoints_gc M α` is the `GaloisConnection`
that relates `fixingSubmonoid` with `fixedPoints`.
* `fixingSubgroup M s` : in the presence of `MulAction M α` (with `Group M`)
it is the `Subgroup M` consisting of elements which fix `s : Set α` pointwise.
* `fixingSubgroup_fixedPoints_gc M α` is the `GaloisConnection`
that relates `fixingSubgroup` with `fixedPoints`.
TODO :
* Maybe other lemmas are useful
* Treat semigroups ?
-/
section Monoid
open MulAction
variable (M : Type*) {α : Type*} [Monoid M] [MulAction M α]
/-- The submonoid fixing a set under a `MulAction`. -/
@[to_additive /-- The additive submonoid fixing a set under an `AddAction`. -/]
def fixingSubmonoid (s : Set α) : Submonoid M where
carrier := { ϕ : M | ∀ x : s, ϕ • (x : α) = x }
one_mem' _ := one_smul _ _
mul_mem' {x y} hx hy z := by rw [mul_smul, hy z, hx z]
@[to_additive]
theorem mem_fixingSubmonoid_iff {s : Set α} {m : M} :
m ∈ fixingSubmonoid M s ↔ ∀ y ∈ s, m • y = y :=
⟨fun hg y hy => hg ⟨y, hy⟩, fun h ⟨y, hy⟩ => h y hy⟩
variable (α)
/-- The Galois connection between fixing submonoids and fixed points of a monoid action -/
@[to_additive]
theorem fixingSubmonoid_fixedPoints_gc :
GaloisConnection (OrderDual.toDual ∘ fixingSubmonoid M)
((fun P : Submonoid M => fixedPoints P α) ∘ OrderDual.ofDual) :=
fun _s _P => ⟨fun h s hs p => h p.2 ⟨s, hs⟩, fun h p hp s => h s.2 ⟨p, hp⟩⟩
@[to_additive]
theorem fixingSubmonoid_antitone : Antitone fun s : Set α => fixingSubmonoid M s :=
(fixingSubmonoid_fixedPoints_gc M α).monotone_l
@[to_additive fixedPoints_antitone_addSubmonoid]
theorem fixedPoints_antitone : Antitone fun P : Submonoid M => fixedPoints P α :=
(fixingSubmonoid_fixedPoints_gc M α).monotone_u.dual_left
/-- Fixing submonoid of union is intersection -/
@[to_additive]
theorem fixingSubmonoid_union {s t : Set α} :
fixingSubmonoid M (s ∪ t) = fixingSubmonoid M s ⊓ fixingSubmonoid M t :=
(fixingSubmonoid_fixedPoints_gc M α).l_sup
/-- Fixing submonoid of iUnion is intersection -/
@[to_additive]
theorem fixingSubmonoid_iUnion {ι : Sort*} {s : ι → Set α} :
fixingSubmonoid M (⋃ i, s i) = ⨅ i, fixingSubmonoid M (s i) :=
(fixingSubmonoid_fixedPoints_gc M α).l_iSup
/-- Fixed points of sup of submonoids is intersection -/
@[to_additive]
theorem fixedPoints_submonoid_sup {P Q : Submonoid M} :
fixedPoints (↥(P ⊔ Q)) α = fixedPoints P α ∩ fixedPoints Q α :=
(fixingSubmonoid_fixedPoints_gc M α).u_inf
/-- Fixed points of iSup of submonoids is intersection -/
@[to_additive]
theorem fixedPoints_submonoid_iSup {ι : Sort*} {P : ι → Submonoid M} :
fixedPoints (↥(iSup P)) α = ⋂ i, fixedPoints (P i) α :=
(fixingSubmonoid_fixedPoints_gc M α).u_iInf
end Monoid
section Group
open MulAction
variable (M : Type*) {α : Type*} [Group M] [MulAction M α]
/-- The subgroup fixing a set under a `MulAction`. -/
@[to_additive /-- The additive subgroup fixing a set under an `AddAction`. -/]
def fixingSubgroup (s : Set α) : Subgroup M :=
{ fixingSubmonoid M s with inv_mem' := fun hx z => by rw [inv_smul_eq_iff, hx z] }
@[to_additive]
theorem mem_fixingSubgroup_iff {s : Set α} {m : M} : m ∈ fixingSubgroup M s ↔ ∀ y ∈ s, m • y = y :=
⟨fun hg y hy => hg ⟨y, hy⟩, fun h ⟨y, hy⟩ => h y hy⟩
@[to_additive]
theorem mem_fixingSubgroup_iff_subset_fixedBy {s : Set α} {m : M} :
m ∈ fixingSubgroup M s ↔ s ⊆ fixedBy α m := by
simp_rw [mem_fixingSubgroup_iff, Set.subset_def, mem_fixedBy]
@[to_additive]
theorem mem_fixingSubgroup_compl_iff_movedBy_subset {s : Set α} {m : M} :
m ∈ fixingSubgroup M sᶜ ↔ (fixedBy α m)ᶜ ⊆ s := by
rw [mem_fixingSubgroup_iff_subset_fixedBy, Set.compl_subset_comm]
variable (α)
/-- The Galois connection between fixing subgroups and fixed points of a group action -/
@[to_additive]
theorem fixingSubgroup_fixedPoints_gc :
GaloisConnection (OrderDual.toDual ∘ fixingSubgroup M)
((fun P : Subgroup M => fixedPoints P α) ∘ OrderDual.ofDual) :=
fun _s _P => ⟨fun h s hs p => h p.2 ⟨s, hs⟩, fun h p hp s => h s.2 ⟨p, hp⟩⟩
@[to_additive (attr := simp)]
lemma fixingSubgroup_empty : fixingSubgroup M (∅ : Set α) = ⊤ :=
GaloisConnection.l_bot (fixingSubgroup_fixedPoints_gc M α)
@[to_additive]
theorem fixingSubgroup_antitone : Antitone (fixingSubgroup M : Set α → Subgroup M) :=
(fixingSubgroup_fixedPoints_gc M α).monotone_l
@[to_additive]
theorem fixedPoints_subgroup_antitone : Antitone fun P : Subgroup M => fixedPoints P α :=
(fixingSubgroup_fixedPoints_gc M α).monotone_u.dual_left
/-- Fixing subgroup of union is intersection -/
@[to_additive]
theorem fixingSubgroup_union {s t : Set α} :
fixingSubgroup M (s ∪ t) = fixingSubgroup M s ⊓ fixingSubgroup M t :=
(fixingSubgroup_fixedPoints_gc M α).l_sup
/-- Fixing subgroup of iUnion is intersection -/
@[to_additive]
theorem fixingSubgroup_iUnion {ι : Sort*} {s : ι → Set α} :
fixingSubgroup M (⋃ i, s i) = ⨅ i, fixingSubgroup M (s i) :=
(fixingSubgroup_fixedPoints_gc M α).l_iSup
/-- Fixed points of sup of subgroups is intersection -/
@[to_additive]
theorem fixedPoints_subgroup_sup {P Q : Subgroup M} :
fixedPoints (↥(P ⊔ Q)) α = fixedPoints P α ∩ fixedPoints Q α :=
(fixingSubgroup_fixedPoints_gc M α).u_inf
/-- Fixed points of iSup of subgroups is intersection -/
@[to_additive]
theorem fixedPoints_subgroup_iSup {ι : Sort*} {P : ι → Subgroup M} :
fixedPoints (↥(iSup P)) α = ⋂ i, fixedPoints (P i) α :=
(fixingSubgroup_fixedPoints_gc M α).u_iInf
/-- The orbit of the fixing subgroup of `sᶜ` (i.e. the moving subgroup of `s`) is a subset of `s` -/
@[to_additive]
theorem orbit_fixingSubgroup_compl_subset {s : Set α} {a : α} (a_in_s : a ∈ s) :
MulAction.orbit (fixingSubgroup M sᶜ) a ⊆ s := by
intro b b_in_orbit
let ⟨⟨g, g_fixing⟩, g_eq⟩ := MulAction.mem_orbit_iff.mp b_in_orbit
rw [Submonoid.mk_smul] at g_eq
rw [mem_fixingSubgroup_compl_iff_movedBy_subset] at g_fixing
rwa [← g_eq, smul_mem_of_set_mem_fixedBy (set_mem_fixedBy_of_movedBy_subset g_fixing)]
end Group |
.lake/packages/mathlib/Mathlib/GroupTheory/GroupAction/Defs.lean | import Mathlib.Algebra.Group.Action.Basic
import Mathlib.Algebra.Group.Pointwise.Set.Scalar
import Mathlib.Algebra.Group.Subgroup.Defs
import Mathlib.Algebra.Group.Submonoid.MulAction
import Mathlib.Data.Set.BooleanAlgebra
/-!
# Definition of `orbit`, `fixedPoints` and `stabilizer`
This file defines orbits, stabilizers, and other objects defined in terms of actions.
## Main definitions
* `MulAction.orbit`
* `MulAction.fixedPoints`
* `MulAction.fixedBy`
* `MulAction.stabilizer`
-/
assert_not_exists MonoidWithZero DistribMulAction
universe u v
open Pointwise
open Function
namespace MulAction
variable (M γ α : Type*) [SMul γ α] [Monoid M] [MulAction M α]
section Orbit
variable {α}
/-- The orbit of an element under an action. -/
@[to_additive /-- The orbit of an element under an action. -/]
def orbit (a : α) :=
Set.range fun m : γ => m • a
variable {γ}
@[to_additive]
theorem mem_orbit_iff {a₁ a₂ : α} : a₂ ∈ orbit γ a₁ ↔ ∃ x : γ, x • a₁ = a₂ :=
Iff.rfl
@[to_additive (attr := simp)]
theorem mem_orbit (a : α) (m : γ) : m • a ∈ orbit γ a :=
⟨m, rfl⟩
variable {M}
@[to_additive]
theorem mem_orbit_of_mem_orbit {a₁ a₂ : α} (m : M) (h : a₂ ∈ orbit M a₁) :
m • a₂ ∈ orbit M a₁ := by
obtain ⟨x, rfl⟩ := mem_orbit_iff.mp h
simp [smul_smul]
@[to_additive (attr := simp)]
theorem mem_orbit_self (a : α) : a ∈ orbit M a :=
⟨1, by simp⟩
@[to_additive]
theorem nonempty_orbit (a : α) : Set.Nonempty (orbit M a) :=
Set.range_nonempty _
@[deprecated (since := "2025-09-25")] alias orbit_nonempty := nonempty_orbit
@[to_additive]
theorem mapsTo_smul_orbit (m : M) (a : α) : Set.MapsTo (m • ·) (orbit M a) (orbit M a) :=
Set.range_subset_iff.2 fun m' => ⟨m * m', mul_smul _ _ _⟩
@[to_additive]
theorem smul_orbit_subset (m : M) (a : α) : m • orbit M a ⊆ orbit M a :=
(mapsTo_smul_orbit m a).image_subset
@[to_additive]
theorem orbit_smul_subset (m : M) (a : α) : orbit M (m • a) ⊆ orbit M a :=
Set.range_subset_iff.2 fun m' => mul_smul m' m a ▸ mem_orbit _ _
@[to_additive]
instance {a : α} : MulAction M (orbit M a) where
smul m := (mapsTo_smul_orbit m a).restrict _ _ _
one_smul m := Subtype.ext (one_smul M (m : α))
mul_smul m m' a' := Subtype.ext (mul_smul m m' (a' : α))
@[to_additive (attr := simp)]
theorem orbit.coe_smul {a : α} {m : M} {a' : orbit M a} : ↑(m • a') = m • (a' : α) :=
rfl
@[to_additive]
lemma orbit_submonoid_subset (S : Submonoid M) (a : α) : orbit S a ⊆ orbit M a := by
rintro b ⟨g, rfl⟩
exact mem_orbit _ _
@[to_additive]
lemma mem_orbit_of_mem_orbit_submonoid {S : Submonoid M} {a b : α} (h : a ∈ orbit S b) :
a ∈ orbit M b :=
orbit_submonoid_subset S _ h
end Orbit
section FixedPoints
/-- The set of elements fixed under the whole action. -/
@[to_additive /-- The set of elements fixed under the whole action. -/]
def fixedPoints : Set α :=
{ a : α | ∀ m : M, m • a = a }
variable {M} in
/-- `fixedBy m` is the set of elements fixed by `m`. -/
@[to_additive /-- `fixedBy m` is the set of elements fixed by `m`. -/]
def fixedBy (m : M) : Set α :=
{ x | m • x = x }
@[to_additive]
theorem fixed_eq_iInter_fixedBy : fixedPoints M α = ⋂ m : M, fixedBy α m :=
Set.ext fun _ =>
⟨fun hx => Set.mem_iInter.2 fun m => hx m, fun hx m => (Set.mem_iInter.1 hx m :)⟩
variable {M α}
@[to_additive (attr := simp)]
theorem mem_fixedPoints {a : α} : a ∈ fixedPoints M α ↔ ∀ m : M, m • a = a :=
Iff.rfl
@[to_additive (attr := simp)]
theorem mem_fixedBy {m : M} {a : α} : a ∈ fixedBy α m ↔ m • a = a :=
Iff.rfl
@[to_additive]
theorem mem_fixedPoints' {a : α} : a ∈ fixedPoints M α ↔ ∀ a', a' ∈ orbit M a → a' = a :=
⟨fun h _ h₁ =>
let ⟨m, hm⟩ := mem_orbit_iff.1 h₁
hm ▸ h m,
fun h _ => h _ (mem_orbit _ _)⟩
end FixedPoints
section Stabilizers
variable {α}
/-- The stabilizer of a point `a` as a submonoid of `M`. -/
@[to_additive /-- The stabilizer of a point `a` as an additive submonoid of `M`. -/]
def stabilizerSubmonoid (a : α) : Submonoid M where
carrier := { m | m • a = a }
one_mem' := one_smul _ a
mul_mem' {m m'} (ha : m • a = a) (hb : m' • a = a) :=
show (m * m') • a = a by rw [← smul_smul, hb, ha]
variable {M}
@[to_additive]
instance [DecidableEq α] (a : α) : DecidablePred (· ∈ stabilizerSubmonoid M a) :=
fun _ => inferInstanceAs <| Decidable (_ = _)
@[to_additive (attr := simp)]
theorem mem_stabilizerSubmonoid_iff {a : α} {m : M} : m ∈ stabilizerSubmonoid M a ↔ m • a = a :=
Iff.rfl
end Stabilizers
end MulAction
section FixedPoints
variable (M : Type u) (α : Type v) [Monoid M]
section Monoid
variable [Monoid α] [MulDistribMulAction M α]
/-- The submonoid of elements fixed under the whole action. -/
def FixedPoints.submonoid : Submonoid α where
carrier := MulAction.fixedPoints M α
one_mem' := smul_one
mul_mem' ha hb _ := by rw [smul_mul', ha, hb]
@[simp]
lemma FixedPoints.mem_submonoid (a : α) : a ∈ submonoid M α ↔ ∀ m : M, m • a = a :=
Iff.rfl
end Monoid
section Group
namespace FixedPoints
variable [Group α] [MulDistribMulAction M α]
/-- The subgroup of elements fixed under the whole action. -/
def subgroup : Subgroup α where
__ := submonoid M α
inv_mem' ha _ := by rw [smul_inv', ha]
/-- The notation for `FixedPoints.subgroup`, chosen to resemble `αᴹ`. -/
scoped notation α "^*" M:51 => FixedPoints.subgroup M α
@[simp]
lemma mem_subgroup (a : α) : a ∈ α^*M ↔ ∀ m : M, m • a = a :=
Iff.rfl
@[simp]
lemma subgroup_toSubmonoid : (α^*M).toSubmonoid = submonoid M α :=
rfl
end FixedPoints
end Group
end FixedPoints
namespace MulAction
variable {G α β : Type*} [Group G] [MulAction G α] [MulAction G β]
section Orbit
@[to_additive (attr := simp)]
theorem orbit_smul (g : G) (a : α) : orbit G (g • a) = orbit G a :=
(orbit_smul_subset g a).antisymm <|
calc
orbit G a = orbit G (g⁻¹ • g • a) := by rw [inv_smul_smul]
_ ⊆ orbit G (g • a) := orbit_smul_subset _ _
@[to_additive]
theorem orbit_eq_iff {a b : α} : orbit G a = orbit G b ↔ a ∈ orbit G b :=
⟨fun h => h ▸ mem_orbit_self _, fun ⟨_, hc⟩ => hc ▸ orbit_smul _ _⟩
@[to_additive]
theorem mem_orbit_smul (g : G) (a : α) : a ∈ orbit G (g • a) := by
simp only [orbit_smul, mem_orbit_self]
@[to_additive]
theorem smul_mem_orbit_smul (g h : G) (a : α) : g • a ∈ orbit G (h • a) := by
simp only [orbit_smul, mem_orbit]
@[to_additive]
instance instMulAction (H : Subgroup G) : MulAction H α :=
inferInstanceAs (MulAction H.toSubmonoid α)
@[to_additive]
lemma subgroup_smul_def {H : Subgroup G} (a : H) (b : α) : a • b = (a : G) • b := rfl
@[to_additive]
lemma orbit_subgroup_subset (H : Subgroup G) (a : α) : orbit H a ⊆ orbit G a :=
orbit_submonoid_subset H.toSubmonoid a
@[to_additive]
lemma mem_orbit_of_mem_orbit_subgroup {H : Subgroup G} {a b : α} (h : a ∈ orbit H b) :
a ∈ orbit G b :=
orbit_subgroup_subset H _ h
@[to_additive]
lemma mem_orbit_symm {a₁ a₂ : α} : a₁ ∈ orbit G a₂ ↔ a₂ ∈ orbit G a₁ := by
simp_rw [← orbit_eq_iff, eq_comm]
@[to_additive]
lemma mem_subgroup_orbit_iff {H : Subgroup G} {x : α} {a b : orbit G x} :
a ∈ MulAction.orbit H b ↔ (a : α) ∈ MulAction.orbit H (b : α) := by
refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩
· rcases h with ⟨g, rfl⟩
exact MulAction.mem_orbit _ g
· rcases h with ⟨g, h⟩
dsimp at h
rw [subgroup_smul_def, ← orbit.coe_smul, ← Subtype.ext_iff] at h
subst h
exact MulAction.mem_orbit _ g
variable (G α)
/-- The relation 'in the same orbit'. -/
@[to_additive /-- The relation 'in the same orbit'. -/]
def orbitRel : Setoid α where
r a b := a ∈ orbit G b
iseqv :=
⟨mem_orbit_self, fun {a b} => by simp [orbit_eq_iff.symm, eq_comm], fun {a b} => by
simp +contextual [orbit_eq_iff.symm]⟩
variable {G α}
@[to_additive]
theorem orbitRel_apply {a b : α} : orbitRel G α a b ↔ a ∈ orbit G b :=
Iff.rfl
/-- When you take a set `U` in `α`, push it down to the quotient, and pull back, you get the union
of the orbit of `U` under `G`. -/
@[to_additive
/-- When you take a set `U` in `α`, push it down to the quotient, and pull back, you get the union
of the orbit of `U` under `G`. -/]
theorem quotient_preimage_image_eq_union_mul (U : Set α) :
letI := orbitRel G α
Quotient.mk' ⁻¹' (Quotient.mk' '' U) = ⋃ g : G, (g • ·) '' U := by
letI := orbitRel G α
set f : α → Quotient (MulAction.orbitRel G α) := Quotient.mk'
ext a
constructor
· rintro ⟨b, hb, hab⟩
obtain ⟨g, rfl⟩ := Quotient.exact hab
rw [Set.mem_iUnion]
exact ⟨g⁻¹, g • a, hb, inv_smul_smul g a⟩
· intro hx
rw [Set.mem_iUnion] at hx
obtain ⟨g, u, hu₁, hu₂⟩ := hx
rw [Set.mem_preimage, Set.mem_image]
refine ⟨g⁻¹ • a, ?_, by simp [f, orbitRel, Quotient.eq']⟩
rw [← hu₂]
convert hu₁
simp only [inv_smul_smul]
@[to_additive]
theorem disjoint_image_image_iff {U V : Set α} :
letI := orbitRel G α
Disjoint (Quotient.mk' '' U) (Quotient.mk' '' V) ↔ ∀ x ∈ U, ∀ g : G, g • x ∉ V := by
letI := orbitRel G α
set f : α → Quotient (MulAction.orbitRel G α) := Quotient.mk'
refine
⟨fun h a a_in_U g g_in_V =>
h.le_bot ⟨⟨a, a_in_U, Quotient.sound ⟨g⁻¹, ?_⟩⟩, ⟨g • a, g_in_V, rfl⟩⟩, ?_⟩
· simp
· intro h
rw [Set.disjoint_left]
rintro _ ⟨b, hb₁, hb₂⟩ ⟨c, hc₁, hc₂⟩
obtain ⟨g, rfl⟩ := Quotient.exact (hc₂.trans hb₂.symm)
exact h b hb₁ g hc₁
@[to_additive]
theorem image_inter_image_iff (U V : Set α) :
letI := orbitRel G α
Quotient.mk' '' U ∩ Quotient.mk' '' V = ∅ ↔ ∀ x ∈ U, ∀ g : G, g • x ∉ V :=
Set.disjoint_iff_inter_eq_empty.symm.trans disjoint_image_image_iff
variable (G α)
/-- The quotient by `MulAction.orbitRel`, given a name to enable dot notation. -/
@[to_additive
/-- The quotient by `AddAction.orbitRel`, given a name to enable dot notation. -/]
abbrev orbitRel.Quotient : Type _ :=
_root_.Quotient <| orbitRel G α
variable {G α}
/-- The orbit corresponding to an element of the quotient by `MulAction.orbitRel` -/
@[to_additive /-- The orbit corresponding to an element of the quotient by `AddAction.orbitRel` -/]
nonrec def orbitRel.Quotient.orbit (x : orbitRel.Quotient G α) : Set α :=
Quotient.liftOn' x (orbit G) fun _ _ => MulAction.orbit_eq_iff.2
@[to_additive (attr := simp)]
theorem orbitRel.Quotient.orbit_mk (a : α) :
orbitRel.Quotient.orbit (Quotient.mk'' a : orbitRel.Quotient G α) = MulAction.orbit G a :=
rfl
@[to_additive]
theorem orbitRel.Quotient.mem_orbit {a : α} {x : orbitRel.Quotient G α} :
a ∈ x.orbit ↔ Quotient.mk'' a = x := by
induction x using Quotient.inductionOn'
rw [Quotient.eq'']
rfl
/-- Note that `hφ = Quotient.out_eq'` is a useful choice here. -/
@[to_additive /-- Note that `hφ = Quotient.out_eq'` is a useful choice here. -/]
theorem orbitRel.Quotient.orbit_eq_orbit_out (x : orbitRel.Quotient G α)
{φ : orbitRel.Quotient G α → α} (hφ : letI := orbitRel G α; RightInverse φ Quotient.mk') :
orbitRel.Quotient.orbit x = MulAction.orbit G (φ x) := by
conv_lhs => rw [← hφ x]
rfl
@[to_additive]
lemma orbitRel.Quotient.orbit_injective :
Injective (orbitRel.Quotient.orbit : orbitRel.Quotient G α → Set α) := by
intro x y h
simp_rw [orbitRel.Quotient.orbit_eq_orbit_out _ Quotient.out_eq', orbit_eq_iff,
← orbitRel_apply] at h
simpa [← Quotient.eq''] using h
@[to_additive (attr := simp)]
lemma orbitRel.Quotient.orbit_inj {x y : orbitRel.Quotient G α} : x.orbit = y.orbit ↔ x = y :=
orbitRel.Quotient.orbit_injective.eq_iff
@[to_additive]
lemma orbitRel.quotient_eq_of_quotient_subgroup_eq {H : Subgroup G} {a b : α}
(h : (⟦a⟧ : orbitRel.Quotient H α) = ⟦b⟧) : (⟦a⟧ : orbitRel.Quotient G α) = ⟦b⟧ := by
rw [@Quotient.eq] at h ⊢
exact mem_orbit_of_mem_orbit_subgroup h
@[to_additive]
lemma orbitRel.quotient_eq_of_quotient_subgroup_eq' {H : Subgroup G} {a b : α}
(h : (Quotient.mk'' a : orbitRel.Quotient H α) = Quotient.mk'' b) :
(Quotient.mk'' a : orbitRel.Quotient G α) = Quotient.mk'' b :=
orbitRel.quotient_eq_of_quotient_subgroup_eq h
@[to_additive]
nonrec lemma orbitRel.Quotient.nonempty_orbit (x : orbitRel.Quotient G α) :
Set.Nonempty x.orbit := by
rw [orbitRel.Quotient.orbit_eq_orbit_out x Quotient.out_eq']
exact nonempty_orbit _
@[deprecated (since := "2025-09-25")]
alias orbitRel.Quotient.orbit_nonempty := orbitRel.Quotient.nonempty_orbit
@[to_additive]
nonrec lemma orbitRel.Quotient.mapsTo_smul_orbit (g : G) (x : orbitRel.Quotient G α) :
Set.MapsTo (g • ·) x.orbit x.orbit := by
rw [orbitRel.Quotient.orbit_eq_orbit_out x Quotient.out_eq']
exact mapsTo_smul_orbit g x.out
@[to_additive]
instance (x : orbitRel.Quotient G α) : MulAction G x.orbit where
smul g := (orbitRel.Quotient.mapsTo_smul_orbit g x).restrict _ _ _
one_smul a := Subtype.ext (one_smul G (a : α))
mul_smul g g' a' := Subtype.ext (mul_smul g g' (a' : α))
@[to_additive (attr := simp)]
lemma orbitRel.Quotient.orbit.coe_smul {g : G} {x : orbitRel.Quotient G α} {a : x.orbit} :
↑(g • a) = g • (a : α) :=
rfl
@[to_additive (attr := norm_cast, simp)]
lemma orbitRel.Quotient.mem_subgroup_orbit_iff {H : Subgroup G} {x : orbitRel.Quotient G α}
{a b : x.orbit} : (a : α) ∈ MulAction.orbit H (b : α) ↔ a ∈ MulAction.orbit H b := by
refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩
· rcases h with ⟨g, h⟩
dsimp at h
rw [subgroup_smul_def, ← orbit.coe_smul, ← Subtype.ext_iff] at h
subst h
exact MulAction.mem_orbit _ g
· rcases h with ⟨g, rfl⟩
exact MulAction.mem_orbit _ g
@[to_additive]
lemma orbitRel.Quotient.subgroup_quotient_eq_iff {H : Subgroup G} {x : orbitRel.Quotient G α}
{a b : x.orbit} : (⟦a⟧ : orbitRel.Quotient H x.orbit) = ⟦b⟧ ↔
(⟦↑a⟧ : orbitRel.Quotient H α) = ⟦↑b⟧ := by
simp_rw [← @Quotient.mk''_eq_mk, Quotient.eq'']
exact orbitRel.Quotient.mem_subgroup_orbit_iff.symm
@[to_additive]
lemma orbitRel.Quotient.mem_subgroup_orbit_iff' {H : Subgroup G} {x : orbitRel.Quotient G α}
{a b : x.orbit} {c : α} (h : (⟦a⟧ : orbitRel.Quotient H x.orbit) = ⟦b⟧) :
(a : α) ∈ MulAction.orbit H c ↔ (b : α) ∈ MulAction.orbit H c := by
simp_rw [mem_orbit_symm (a₂ := c)]
convert Iff.rfl using 2
rw [orbit_eq_iff]
suffices hb : ↑b ∈ orbitRel.Quotient.orbit (⟦a⟧ : orbitRel.Quotient H x.orbit) by
rw [orbitRel.Quotient.orbit_eq_orbit_out (⟦a⟧ : orbitRel.Quotient H x.orbit) Quotient.out_eq']
at hb
rw [orbitRel.Quotient.mem_subgroup_orbit_iff]
convert hb using 1
rw [orbit_eq_iff, ← orbitRel_apply, ← Quotient.eq'', Quotient.out_eq', @Quotient.mk''_eq_mk]
rw [orbitRel.Quotient.mem_orbit, h, @Quotient.mk''_eq_mk]
variable (G) (α)
local notation "Ω" => orbitRel.Quotient G α
/-- Decomposition of a type `X` as a disjoint union of its orbits under a group action.
This version is expressed in terms of `MulAction.orbitRel.Quotient.orbit` instead of
`MulAction.orbit`, to avoid mentioning `Quotient.out`. -/
@[to_additive
/-- Decomposition of a type `X` as a disjoint union of its orbits under an additive group action.
This version is expressed in terms of `AddAction.orbitRel.Quotient.orbit` instead of
`AddAction.orbit`, to avoid mentioning `Quotient.out`. -/]
def selfEquivSigmaOrbits' : α ≃ Σ ω : Ω, ω.orbit :=
letI := orbitRel G α
calc
α ≃ Σ ω : Ω, { a // Quotient.mk' a = ω } := (Equiv.sigmaFiberEquiv Quotient.mk').symm
_ ≃ Σ ω : Ω, ω.orbit :=
Equiv.sigmaCongrRight fun _ =>
Equiv.subtypeEquivRight fun _ => orbitRel.Quotient.mem_orbit.symm
/-- Decomposition of a type `X` as a disjoint union of its orbits under a group action. -/
@[to_additive /-- Decomposition of a type `X` as a disjoint union of its orbits under an additive
group action. -/]
def selfEquivSigmaOrbits : α ≃ Σ ω : Ω, orbit G ω.out :=
(selfEquivSigmaOrbits' G α).trans <|
Equiv.sigmaCongrRight fun _ =>
Equiv.setCongr <| orbitRel.Quotient.orbit_eq_orbit_out _ Quotient.out_eq'
/-- Decomposition of a type `X` as a disjoint union of its orbits under a group action.
Phrased as a set union. See `MulAction.selfEquivSigmaOrbits` for the type isomorphism. -/
@[to_additive /-- Decomposition of a type `X` as a disjoint union of its orbits under an additive
group action. Phrased as a set union. See `AddAction.selfEquivSigmaOrbits` for the type
isomorphism. -/]
lemma univ_eq_iUnion_orbit :
Set.univ (α := α) = ⋃ x : Ω, x.orbit := by
ext x
simp only [Set.mem_univ, Set.mem_iUnion, true_iff]
exact ⟨Quotient.mk'' x, by simp⟩
end Orbit
section Stabilizer
variable (G) in
/-- The stabilizer of an element under an action, i.e. what sends the element to itself.
A subgroup. -/
@[to_additive /-- The stabilizer of an element under an action, i.e. what sends the element to
itself. An additive subgroup. -/]
def stabilizer (a : α) : Subgroup G :=
{ stabilizerSubmonoid G a with
inv_mem' := fun {m} (ha : m • a = a) => show m⁻¹ • a = a by rw [inv_smul_eq_iff, ha] }
@[to_additive]
instance [DecidableEq α] (a : α) : DecidablePred (· ∈ stabilizer G a) :=
fun _ => inferInstanceAs <| Decidable (_ = _)
@[to_additive (attr := simp)]
theorem mem_stabilizer_iff {a : α} {g : G} : g ∈ stabilizer G a ↔ g • a = a :=
Iff.rfl
@[to_additive]
lemma le_stabilizer_smul_left [SMul α β] [IsScalarTower G α β] (a : α) (b : β) :
stabilizer G a ≤ stabilizer G (a • b) := by
simp_rw [SetLike.le_def, mem_stabilizer_iff, ← smul_assoc]; rintro a h; rw [h]
-- This lemma does not need `MulAction G α`, only `SMul G α`.
-- We use `G'` instead of `G` to locally reduce the typeclass assumptions.
@[to_additive]
lemma le_stabilizer_smul_right {G'} [Group G'] [SMul α β] [MulAction G' β]
[SMulCommClass G' α β] (a : α) (b : β) :
stabilizer G' b ≤ stabilizer G' (a • b) := by
simp_rw [SetLike.le_def, mem_stabilizer_iff, smul_comm]; rintro a h; rw [h]
@[to_additive (attr := simp)]
lemma stabilizer_smul_eq_left [SMul α β] [IsScalarTower G α β] (a : α) (b : β)
(h : Injective (· • b : α → β)) : stabilizer G (a • b) = stabilizer G a := by
refine (le_stabilizer_smul_left _ _).antisymm' fun a ha ↦ ?_
simpa only [mem_stabilizer_iff, ← smul_assoc, h.eq_iff] using ha
@[to_additive (attr := simp)]
lemma stabilizer_smul_eq_right {α} [Group α] [MulAction α β] [SMulCommClass G α β] (a : α) (b : β) :
stabilizer G (a • b) = stabilizer G b :=
(le_stabilizer_smul_right _ _).antisymm' <| (le_stabilizer_smul_right a⁻¹ _).trans_eq <| by
rw [inv_smul_smul]
@[to_additive (attr := simp)]
lemma stabilizer_mul_eq_left [Group α] [IsScalarTower G α α] (a b : α) :
stabilizer G (a * b) = stabilizer G a := stabilizer_smul_eq_left a _ <| mul_left_injective _
@[to_additive (attr := simp)]
lemma stabilizer_mul_eq_right [Group α] [SMulCommClass G α α] (a b : α) :
stabilizer G (a * b) = stabilizer G b := stabilizer_smul_eq_right a _
end Stabilizer
end MulAction |
.lake/packages/mathlib/Mathlib/GroupTheory/GroupAction/Period.lean | import Mathlib.Dynamics.PeriodicPts.Lemmas
import Mathlib.GroupTheory.Exponent
import Mathlib.GroupTheory.GroupAction.Basic
/-!
# Period of a group action
This module defines some helpful lemmas around [`MulAction.period`] and [`AddAction.period`].
The period of a point `a` by a group element `g` is the smallest `m` such that `g ^ m • a = a`
(resp. `(m • g) +ᵥ a = a`) for a given `g : G` and `a : α`.
If such an `m` does not exist,
then by convention `MulAction.period` and `AddAction.period` return 0.
-/
namespace MulAction
universe u v
variable {α : Type v}
variable {G : Type u} [Group G] [MulAction G α]
variable {M : Type u} [Monoid M] [MulAction M α]
/-- If the action is periodic, then a lower bound for its period can be computed. -/
@[to_additive /-- If the action is periodic, then a lower bound for its period can be computed. -/]
theorem le_period {m : M} {a : α} {n : ℕ} (period_pos : 0 < period m a)
(moved : ∀ k, 0 < k → k < n → m ^ k • a ≠ a) : n ≤ period m a :=
le_of_not_gt fun period_lt_n =>
moved _ period_pos period_lt_n <| pow_period_smul m a
/-- If for some `n`, `m ^ n • a = a`, then `period m a ≤ n`. -/
@[to_additive /-- If for some `n`, `(n • m) +ᵥ a = a`, then `period m a ≤ n`. -/]
theorem period_le_of_fixed {m : M} {a : α} {n : ℕ} (n_pos : 0 < n) (fixed : m ^ n • a = a) :
period m a ≤ n :=
(isPeriodicPt_smul_iff.mpr fixed).minimalPeriod_le n_pos
/-- If for some `n`, `m ^ n • a = a`, then `0 < period m a`. -/
@[to_additive /-- If for some `n`, `(n • m) +ᵥ a = a`, then `0 < period m a`. -/]
theorem period_pos_of_fixed {m : M} {a : α} {n : ℕ} (n_pos : 0 < n) (fixed : m ^ n • a = a) :
0 < period m a :=
(isPeriodicPt_smul_iff.mpr fixed).minimalPeriod_pos n_pos
@[to_additive]
theorem period_eq_one_iff {m : M} {a : α} : period m a = 1 ↔ m • a = a :=
⟨fun eq_one => pow_one m ▸ eq_one ▸ pow_period_smul m a,
fun fixed => le_antisymm
(period_le_of_fixed one_pos (by simpa))
(period_pos_of_fixed one_pos (by simpa))⟩
/-- For any non-zero `n` less than the period of `m` on `a`, `a` is moved by `m ^ n`. -/
@[to_additive
/-- For any non-zero `n` less than the period of `m` on `a`, `a` is moved by `n • m`. -/]
theorem pow_smul_ne_of_lt_period {m : M} {a : α} {n : ℕ} (n_pos : 0 < n)
(n_lt_period : n < period m a) : m ^ n • a ≠ a := fun a_fixed =>
not_le_of_gt n_lt_period <| period_le_of_fixed n_pos a_fixed
section Identities
/-! ### `MulAction.period` for common group elements
-/
variable (M) in
@[to_additive (attr := simp)]
theorem period_one (a : α) : period (1 : M) a = 1 := period_eq_one_iff.mpr (one_smul M a)
@[to_additive (attr := simp)]
theorem period_inv (g : G) (a : α) : period g⁻¹ a = period g a := by
simp only [period_eq_minimalPeriod, Function.minimalPeriod_eq_minimalPeriod_iff,
isPeriodicPt_smul_iff]
intro n
rw [smul_eq_iff_eq_inv_smul, eq_comm, ← zpow_natCast, inv_zpow, inv_inv, zpow_natCast]
end Identities
section MonoidExponent
/-! ### `MulAction.period` and group exponents
The period of a given element `m : M` can be bounded by the `Monoid.exponent M` or `orderOf m`.
-/
@[to_additive]
theorem period_dvd_orderOf (m : M) (a : α) : period m a ∣ orderOf m := by
rw [← pow_smul_eq_iff_period_dvd, pow_orderOf_eq_one, one_smul]
@[to_additive]
theorem period_pos_of_orderOf_pos {m : M} (order_pos : 0 < orderOf m) (a : α) :
0 < period m a :=
Nat.pos_of_dvd_of_pos (period_dvd_orderOf m a) order_pos
@[to_additive]
theorem period_le_orderOf {m : M} (order_pos : 0 < orderOf m) (a : α) :
period m a ≤ orderOf m :=
Nat.le_of_dvd order_pos (period_dvd_orderOf m a)
@[to_additive]
theorem period_dvd_exponent (m : M) (a : α) : period m a ∣ Monoid.exponent M := by
rw [← pow_smul_eq_iff_period_dvd, Monoid.pow_exponent_eq_one, one_smul]
@[to_additive]
theorem period_pos_of_exponent_pos (exp_pos : 0 < Monoid.exponent M) (m : M) (a : α) :
0 < period m a :=
Nat.pos_of_dvd_of_pos (period_dvd_exponent m a) exp_pos
@[to_additive]
theorem period_le_exponent (exp_pos : 0 < Monoid.exponent M) (m : M) (a : α) :
period m a ≤ Monoid.exponent M :=
Nat.le_of_dvd exp_pos (period_dvd_exponent m a)
variable (α)
@[to_additive]
theorem period_bounded_of_exponent_pos (exp_pos : 0 < Monoid.exponent M) (m : M) :
BddAbove (Set.range (fun a : α => period m a)) := by
use Monoid.exponent M
simpa [upperBounds] using period_le_exponent exp_pos _
end MonoidExponent
end MulAction |
.lake/packages/mathlib/Mathlib/GroupTheory/GroupAction/Embedding.lean | import Mathlib.Algebra.Group.Action.Basic
import Mathlib.Algebra.Group.Action.Pi
import Mathlib.Algebra.Group.Opposite
/-!
# Group actions on embeddings
This file provides a `MulAction G (α ↪ β)` instance that agrees with the `MulAction G (α → β)`
instances defined by `Pi.mulAction`.
Note that unlike the `Pi` instance, this requires `G` to be a group.
-/
assert_not_exists MonoidWithZero
universe u v w
variable {G G' α β : Type*}
namespace Function.Embedding
@[to_additive]
instance smul [Group G] [MulAction G β] : SMul G (α ↪ β) :=
⟨fun g f => f.trans (MulAction.toPerm g).toEmbedding⟩
@[to_additive]
theorem smul_def [Group G] [MulAction G β] (g : G) (f : α ↪ β) :
g • f = f.trans (MulAction.toPerm g).toEmbedding :=
rfl
@[to_additive (attr := simp)]
theorem smul_apply [Group G] [MulAction G β] (g : G) (f : α ↪ β) (a : α) : (g • f) a = g • f a :=
rfl
@[to_additive]
theorem coe_smul [Group G] [MulAction G β] (g : G) (f : α ↪ β) : ⇑(g • f) = g • ⇑f :=
rfl
instance [Group G] [Group G'] [SMul G G'] [MulAction G β] [MulAction G' β]
[IsScalarTower G G' β] : IsScalarTower G G' (α ↪ β) :=
⟨fun x y z => Function.Embedding.ext fun i => smul_assoc x y (z i)⟩
@[to_additive]
instance [Group G] [Group G'] [MulAction G β] [MulAction G' β] [SMulCommClass G G' β] :
SMulCommClass G G' (α ↪ β) :=
⟨fun x y z => Function.Embedding.ext fun i => smul_comm x y (z i)⟩
instance [Group G] [MulAction G β] [MulAction Gᵐᵒᵖ β] [IsCentralScalar G β] :
IsCentralScalar G (α ↪ β) :=
⟨fun _ _ => Function.Embedding.ext fun _ => op_smul_eq_smul _ _⟩
@[to_additive]
instance [Group G] [MulAction G β] : MulAction G (α ↪ β) :=
DFunLike.coe_injective.mulAction _ coe_smul
end Function.Embedding |
.lake/packages/mathlib/Mathlib/GroupTheory/GroupAction/CardCommute.lean | import Mathlib.Algebra.Group.ConjFinite
import Mathlib.GroupTheory.Coset.Card
import Mathlib.GroupTheory.GroupAction.Quotient
/-!
# Properties of group actions involving quotient groups
This file proves cardinality properties of group actions which use the quotient group construction,
notably
* the class formula `MulAction.card_eq_sum_card_group_div_card_stabilizer'`
* `card_comm_eq_card_conjClasses_mul_card`
as well as their analogues for additive groups.
See `Mathlib/GroupTheory/GroupAction/Quotient.lean` for the construction of isomorphisms used to
prove these cardinality properties.
These lemmas are separate because they require the development of cardinals.
-/
variable {α β : Type*}
open Function
namespace MulAction
variable (α β)
variable [Group α] [MulAction α β]
local notation "Ω" => Quotient <| orbitRel α β
/-- **Class formula** for a finite group acting on a finite type. See
`MulAction.card_eq_sum_card_group_div_card_stabilizer` for a specialized version using
`Quotient.out`. -/
@[to_additive
/-- **Class formula** for a finite group acting on a finite type. See
`AddAction.card_eq_sum_card_addGroup_div_card_stabilizer` for a specialized version using
`Quotient.out`. -/]
theorem card_eq_sum_card_group_div_card_stabilizer' [Fintype α] [Fintype β] [Fintype Ω]
[∀ b : β, Fintype <| stabilizer α b] {φ : Ω → β} (hφ : LeftInverse Quotient.mk'' φ) :
Fintype.card β = ∑ ω : Ω, Fintype.card α / Fintype.card (stabilizer α (φ ω)) := by
classical
have : ∀ ω : Ω, Fintype.card α / Fintype.card (stabilizer α (φ ω)) =
Fintype.card (α ⧸ stabilizer α (φ ω)) := by
intro ω
rw [Fintype.card_congr (@Subgroup.groupEquivQuotientProdSubgroup α _ (stabilizer α <| φ ω)),
Fintype.card_prod, Nat.mul_div_cancel]
exact Fintype.card_pos_iff.mpr (by infer_instance)
simp_rw [this, ← Fintype.card_sigma,
Fintype.card_congr (selfEquivSigmaOrbitsQuotientStabilizer' α β hφ)]
/-- **Class formula** for a finite group acting on a finite type. -/
@[to_additive /-- **Class formula** for a finite group acting on a finite type. -/]
theorem card_eq_sum_card_group_div_card_stabilizer [Fintype α] [Fintype β] [Fintype Ω]
[∀ b : β, Fintype <| stabilizer α b] :
Fintype.card β = ∑ ω : Ω, Fintype.card α / Fintype.card (stabilizer α ω.out) :=
card_eq_sum_card_group_div_card_stabilizer' α β Quotient.out_eq'
end MulAction
instance instInfiniteProdSubtypeCommute [Mul α] [Infinite α] :
Infinite { p : α × α // Commute p.1 p.2 } :=
Infinite.of_injective (fun a => ⟨⟨a, a⟩, rfl⟩) (by intro; simp)
open Fintype
theorem card_comm_eq_card_conjClasses_mul_card (G : Type*) [Group G] :
Nat.card { p : G × G // Commute p.1 p.2 } = Nat.card (ConjClasses G) * Nat.card G := by
classical
rcases fintypeOrInfinite G; swap
· rw [mul_comm, Nat.card_eq_zero_of_infinite, Nat.card_eq_zero_of_infinite, zero_mul]
simp only [Nat.card_eq_fintype_card]
calc card { p : G × G // Commute p.1 p.2 }
_ = card ((a : G) × { b // Commute a b }) :=
card_congr (Equiv.subtypeProdEquivSigmaSubtype Commute)
_ = ∑ i, card { b // Commute i b } := card_sigma
_ = ∑ x, card (MulAction.fixedBy G x) :=
sum_equiv ConjAct.toConjAct.toEquiv (fun a ↦ card { b // Commute a b })
(fun g ↦ card (MulAction.fixedBy G g))
fun g ↦ card_congr' <| congr_arg _ <| funext fun h ↦ mul_inv_eq_iff_eq_mul.symm.eq
_ = card (Quotient (MulAction.orbitRel (ConjAct G) G)) * card (ConjAct G) :=
MulAction.sum_card_fixedBy_eq_card_orbits_mul_card_group _ _
_ = card (ConjClasses G) * card G := by
congr 1; apply card_congr'; congr; ext
exact (Setoid.comm' _).trans isConj_iff.symm |
.lake/packages/mathlib/Mathlib/GroupTheory/GroupAction/Blocks.lean | import Mathlib.Algebra.Pointwise.Stabilizer
import Mathlib.Data.Setoid.Partition
import Mathlib.GroupTheory.GroupAction.Pointwise
import Mathlib.GroupTheory.GroupAction.SubMulAction
import Mathlib.GroupTheory.Index
import Mathlib.Tactic.IntervalCases
/-! # Blocks
Given `SMul G X`, an action of a type `G` on a type `X`, we define
- the predicate `MulAction.IsBlock G B` states that `B : Set X` is a block,
which means that the sets `g • B`, for `g ∈ G`, are equal or disjoint.
Under `Group G` and `MulAction G X`, this is equivalent to the classical
definition `MulAction.IsBlock.def_one`
- a bunch of lemmas that give examples of “trivial” blocks : ⊥, ⊤, singletons,
and non-trivial blocks: orbit of the group, orbit of a normal subgroup…
The non-existence of nontrivial blocks is the definition of primitive actions.
## Results for actions on finite sets
- `MulAction.IsBlock.ncard_block_mul_ncard_orbit_eq` : The cardinality of a block
multiplied by the number of its translates is the cardinal of the ambient type
- `MulAction.IsBlock.eq_univ_of_card_lt` : a too large block is equal to `Set.univ`
- `MulAction.IsBlock.subsingleton_of_card_lt` : a too small block is a subsingleton
- `MulAction.IsBlock.of_subset` : the intersections of the translates of a finite subset
that contain a given point is a block
- `MulAction.BlockMem` : the type of blocks containing a given element
- `MulAction.BlockMem.instBoundedOrder` :
the type of blocks containing a given element is a bounded order.
## References
We follow [Wielandt-1964].
-/
open Set
open scoped Pointwise
namespace MulAction
section orbits
variable {G : Type*} [Group G] {X : Type*} [MulAction G X]
@[to_additive]
theorem orbit.eq_or_disjoint (a b : X) :
orbit G a = orbit G b ∨ Disjoint (orbit G a) (orbit G b) := by
apply (em (Disjoint (orbit G a) (orbit G b))).symm.imp _ id
simp +contextual
only [Set.not_disjoint_iff, ← orbit_eq_iff, forall_exists_index, eq_comm, implies_true]
@[to_additive]
theorem orbit.pairwiseDisjoint :
(Set.range fun x : X => orbit G x).PairwiseDisjoint id := by
rintro s ⟨x, rfl⟩ t ⟨y, rfl⟩ h
contrapose! h
exact (orbit.eq_or_disjoint x y).resolve_right h
/-- Orbits of an element form a partition -/
@[to_additive /-- Orbits of an element form a partition -/]
theorem IsPartition.of_orbits :
Setoid.IsPartition (Set.range fun a : X => orbit G a) := by
apply orbit.pairwiseDisjoint.isPartition_of_exists_of_ne_empty
· intro x
exact ⟨_, ⟨x, rfl⟩, mem_orbit_self x⟩
· rintro ⟨a, ha : orbit G a = ∅⟩
exact (MulAction.nonempty_orbit a).ne_empty ha
end orbits
section SMul
variable (G : Type*) {X : Type*} [SMul G X] {B : Set X} {a : X}
-- Change terminology to IsFullyInvariant?
/-- A set `B` is a `G`-fixed block if `g • B = B` for all `g : G`. -/
@[to_additive /-- A set `B` is a `G`-fixed block if `g +ᵥ B = B` for all `g : G`. -/]
def IsFixedBlock (B : Set X) := ∀ g : G, g • B = B
/-- A set `B` is a `G`-invariant block if `g • B ⊆ B` for all `g : G`.
Note: It is not necessarily a block when the action is not by a group. -/
@[to_additive
/-- A set `B` is a `G`-invariant block if `g +ᵥ B ⊆ B` for all `g : G`.
Note: It is not necessarily a block when the action is not by a group. -/]
def IsInvariantBlock (B : Set X) := ∀ g : G, g • B ⊆ B
section IsTrivialBlock
/-- A trivial block is a `Set X` which is either a subsingleton or `univ`.
Note: It is not necessarily a block when the action is not by a group. -/
@[to_additive
/-- A trivial block is a `Set X` which is either a subsingleton or `univ`.
Note: It is not necessarily a block when the action is not by a group. -/]
def IsTrivialBlock (B : Set X) := B.Subsingleton ∨ B = univ
variable {M α N β : Type*}
section monoid
variable [Monoid M] [MulAction M α] [Monoid N] [MulAction N β]
@[to_additive]
theorem IsTrivialBlock.image {φ : M → N} {f : α →ₑ[φ] β}
(hf : Function.Surjective f) {B : Set α} (hB : IsTrivialBlock B) :
IsTrivialBlock (f '' B) := by
obtain hB | hB := hB
· apply Or.intro_left; apply Set.Subsingleton.image hB
· apply Or.intro_right; rw [hB]
simp only [Set.image_univ, Set.range_eq_univ, hf]
@[to_additive]
theorem IsTrivialBlock.preimage {φ : M → N} {f : α →ₑ[φ] β}
(hf : Function.Injective f) {B : Set β} (hB : IsTrivialBlock B) :
IsTrivialBlock (f ⁻¹' B) := by
obtain hB | hB := hB
· apply Or.intro_left; exact Set.Subsingleton.preimage hB hf
· apply Or.intro_right; simp only [hB]; apply Set.preimage_univ
end monoid
variable [Group M] [MulAction M α] [Monoid N] [MulAction N β]
@[to_additive]
theorem IsTrivialBlock.smul {B : Set α} (hB : IsTrivialBlock B) (g : M) :
IsTrivialBlock (g • B) := by
cases hB with
| inl h =>
left
exact (Function.Injective.subsingleton_image_iff (MulAction.injective g)).mpr h
| inr h =>
right
rw [h, ← Set.image_smul, Set.image_univ_of_surjective (MulAction.surjective g)]
@[to_additive]
theorem IsTrivialBlock.smul_iff {B : Set α} (g : M) :
IsTrivialBlock (g • B) ↔ IsTrivialBlock B := by
constructor
· intro H
convert IsTrivialBlock.smul H g⁻¹
simp only [inv_smul_smul]
· intro H
exact IsTrivialBlock.smul H g
end IsTrivialBlock
/-- A set `B` is a `G`-block iff the sets of the form `g • B` are pairwise equal or disjoint. -/
@[to_additive
/-- A set `B` is a `G`-block iff the sets of the form `g +ᵥ B` are pairwise equal or disjoint. -/]
def IsBlock (B : Set X) := ∀ ⦃g₁ g₂ : G⦄, g₁ • B ≠ g₂ • B → Disjoint (g₁ • B) (g₂ • B)
variable {G} {s : Set G} {g g₁ g₂ : G}
@[to_additive]
lemma isBlock_iff_smul_eq_smul_of_nonempty :
IsBlock G B ↔ ∀ ⦃g₁ g₂ : G⦄, (g₁ • B ∩ g₂ • B).Nonempty → g₁ • B = g₂ • B := by
simp_rw [IsBlock, ← not_disjoint_iff_nonempty_inter, not_imp_comm]
@[to_additive]
lemma isBlock_iff_pairwiseDisjoint_range_smul :
IsBlock G B ↔ (range fun g : G ↦ g • B).PairwiseDisjoint id := pairwiseDisjoint_range_iff.symm
@[to_additive]
lemma isBlock_iff_smul_eq_smul_or_disjoint :
IsBlock G B ↔ ∀ g₁ g₂ : G, g₁ • B = g₂ • B ∨ Disjoint (g₁ • B) (g₂ • B) :=
forall₂_congr fun _ _ ↦ or_iff_not_imp_left.symm
@[to_additive]
lemma IsBlock.smul_eq_smul_of_subset (hB : IsBlock G B) (hg : g₁ • B ⊆ g₂ • B) :
g₁ • B = g₂ • B := by
by_contra! hg'
obtain rfl : B = ∅ := by simpa using (hB hg').eq_bot_of_le hg
simp at hg'
@[to_additive]
lemma IsBlock.not_smul_set_ssubset_smul_set (hB : IsBlock G B) : ¬ g₁ • B ⊂ g₂ • B :=
fun hab ↦ hab.ne <| hB.smul_eq_smul_of_subset hab.subset
@[to_additive]
lemma IsBlock.disjoint_smul_set_smul (hB : IsBlock G B) (hgs : ¬ g • B ⊆ s • B) :
Disjoint (g • B) (s • B) := by
rw [← iUnion_smul_set, disjoint_iUnion₂_right]
exact fun b hb ↦ hB fun h ↦ hgs <| h.trans_subset <| smul_set_subset_smul hb
@[to_additive]
lemma IsBlock.disjoint_smul_smul_set (hB : IsBlock G B) (hgs : ¬ g • B ⊆ s • B) :
Disjoint (s • B) (g • B) := (hB.disjoint_smul_set_smul hgs).symm
@[to_additive]
alias ⟨IsBlock.smul_eq_smul_of_nonempty, _⟩ := isBlock_iff_smul_eq_smul_of_nonempty
@[to_additive]
alias ⟨IsBlock.pairwiseDisjoint_range_smul, _⟩ := isBlock_iff_pairwiseDisjoint_range_smul
@[to_additive]
alias ⟨IsBlock.smul_eq_smul_or_disjoint, _⟩ := isBlock_iff_smul_eq_smul_or_disjoint
/-- A fixed block is a block. -/
@[to_additive /-- A fixed block is a block. -/]
lemma IsFixedBlock.isBlock (hfB : IsFixedBlock G B) : IsBlock G B := by simp [IsBlock, hfB _]
/-- The empty set is a block. -/
@[to_additive (attr := simp) /-- The empty set is a block. -/]
lemma IsBlock.empty : IsBlock G (∅ : Set X) := by simp [IsBlock]
/-- A singleton is a block. -/
@[to_additive /-- A singleton is a block. -/]
lemma IsBlock.singleton : IsBlock G ({a} : Set X) := by simp [IsBlock]
/-- Subsingletons are (trivial) blocks. -/
@[to_additive /-- Subsingletons are (trivial) blocks. -/]
lemma IsBlock.of_subsingleton (hB : B.Subsingleton) : IsBlock G B :=
hB.induction_on .empty fun _ ↦ .singleton
/-- A fixed block is an invariant block. -/
@[to_additive /-- A fixed block is an invariant block. -/]
lemma IsFixedBlock.isInvariantBlock (hB : IsFixedBlock G B) : IsInvariantBlock G B :=
fun _ ↦ (hB _).le
end SMul
section Monoid
variable {M X : Type*} [Monoid M] [MulAction M X] {B : Set X} {s : Set M}
@[to_additive]
lemma IsBlock.disjoint_smul_right (hB : IsBlock M B) (hs : ¬ B ⊆ s • B) : Disjoint B (s • B) := by
simpa using hB.disjoint_smul_set_smul (g := 1) (by simpa using hs)
@[to_additive]
lemma IsBlock.disjoint_smul_left (hB : IsBlock M B) (hs : ¬ B ⊆ s • B) : Disjoint (s • B) B :=
(hB.disjoint_smul_right hs).symm
end Monoid
section Group
variable {G : Type*} [Group G] {X : Type*} [MulAction G X] {B : Set X}
@[to_additive]
lemma isBlock_iff_disjoint_smul_of_ne :
IsBlock G B ↔ ∀ ⦃g : G⦄, g • B ≠ B → Disjoint (g • B) B := by
refine ⟨fun hB g ↦ by simpa using hB (g₂ := 1), fun hB g₁ g₂ h ↦ ?_⟩
simp only [disjoint_smul_set_right, ne_eq, ← inv_smul_eq_iff, smul_smul] at h ⊢
exact hB h
@[to_additive]
lemma isBlock_iff_smul_eq_of_nonempty :
IsBlock G B ↔ ∀ ⦃g : G⦄, (g • B ∩ B).Nonempty → g • B = B := by
simp_rw [isBlock_iff_disjoint_smul_of_ne, ← not_disjoint_iff_nonempty_inter, not_imp_comm]
@[to_additive]
lemma isBlock_iff_smul_eq_or_disjoint :
IsBlock G B ↔ ∀ g : G, g • B = B ∨ Disjoint (g • B) B :=
isBlock_iff_disjoint_smul_of_ne.trans <| forall_congr' fun _ ↦ or_iff_not_imp_left.symm
@[to_additive]
lemma isBlock_iff_smul_eq_of_mem :
IsBlock G B ↔ ∀ ⦃g : G⦄ ⦃a : X⦄, a ∈ B → g • a ∈ B → g • B = B := by
simp [isBlock_iff_smul_eq_of_nonempty, Set.Nonempty, mem_smul_set]
@[to_additive] alias ⟨IsBlock.disjoint_smul_of_ne, _⟩ := isBlock_iff_disjoint_smul_of_ne
@[to_additive] alias ⟨IsBlock.smul_eq_of_nonempty, _⟩ := isBlock_iff_smul_eq_of_nonempty
@[to_additive] alias ⟨IsBlock.smul_eq_or_disjoint, _⟩ := isBlock_iff_smul_eq_or_disjoint
@[to_additive] alias ⟨IsBlock.smul_eq_of_mem, _⟩ := isBlock_iff_smul_eq_of_mem
-- TODO: Generalise to `SubgroupClass`
/-- If `B` is a `G`-block, then it is also a `H`-block for any subgroup `H` of `G`. -/
@[to_additive
/-- If `B` is a `G`-block, then it is also a `H`-block for any subgroup `H` of `G`. -/]
lemma IsBlock.subgroup {H : Subgroup G} (hB : IsBlock G B) : IsBlock H B := fun _ _ h ↦ hB h
/-- A block of a group action is invariant iff it is fixed. -/
@[to_additive /-- A block of a group action is invariant iff it is fixed. -/]
lemma isInvariantBlock_iff_isFixedBlock : IsInvariantBlock G B ↔ IsFixedBlock G B :=
⟨fun hB g ↦ (hB g).antisymm <| subset_smul_set_iff.2 <| hB _, IsFixedBlock.isInvariantBlock⟩
/-- An invariant block of a group action is a fixed block. -/
@[to_additive /-- An invariant block of a group action is a fixed block. -/]
alias ⟨IsInvariantBlock.isFixedBlock, _⟩ := isInvariantBlock_iff_isFixedBlock
/-- An invariant block of a group action is a block. -/
@[to_additive /-- An invariant block of a group action is a block. -/]
lemma IsInvariantBlock.isBlock (hB : IsInvariantBlock G B) : IsBlock G B := hB.isFixedBlock.isBlock
/-- The full set is a fixed block. -/
@[to_additive /-- The full set is a fixed block. -/]
lemma IsFixedBlock.univ : IsFixedBlock G (univ : Set X) := fun _ ↦ by simp
/-- The full set is a block. -/
@[to_additive (attr := simp) /-- The full set is a block. -/]
lemma IsBlock.univ : IsBlock G (univ : Set X) := IsFixedBlock.univ.isBlock
/-- The intersection of two blocks is a block. -/
@[to_additive /-- The intersection of two blocks is a block. -/]
lemma IsBlock.inter {B₁ B₂ : Set X} (h₁ : IsBlock G B₁) (h₂ : IsBlock G B₂) :
IsBlock G (B₁ ∩ B₂) := by
simp only [isBlock_iff_smul_eq_smul_of_nonempty, smul_set_inter] at h₁ h₂ ⊢
rintro g₁ g₂ ⟨a, ha₁, ha₂⟩
rw [h₁ ⟨a, ha₁.1, ha₂.1⟩, h₂ ⟨a, ha₁.2, ha₂.2⟩]
/-- An intersection of blocks is a block. -/
@[to_additive /-- An intersection of blocks is a block. -/]
lemma IsBlock.iInter {ι : Sort*} {B : ι → Set X} (hB : ∀ i, IsBlock G (B i)) :
IsBlock G (⋂ i, B i) := by
simp only [isBlock_iff_smul_eq_smul_of_nonempty, smul_set_iInter] at hB ⊢
rintro g₁ g₂ ⟨a, ha₁, ha₂⟩
simp_rw [fun i ↦ hB i ⟨a, iInter_subset _ i ha₁, iInter_subset _ i ha₂⟩]
/-- A trivial block is a block. -/
@[to_additive /-- A trivial block is a block. -/]
lemma IsTrivialBlock.isBlock (hB : IsTrivialBlock B) : IsBlock G B := by
obtain hB | rfl := hB
· exact .of_subsingleton hB
· exact .univ
/-- An orbit is a fixed block. -/
@[to_additive /-- An orbit is a fixed block. -/]
protected lemma IsFixedBlock.orbit (a : X) : IsFixedBlock G (orbit G a) := (smul_orbit · a)
/-- An orbit is a block. -/
@[to_additive /-- An orbit is a block. -/]
protected lemma IsBlock.orbit (a : X) : IsBlock G (orbit G a) := (IsFixedBlock.orbit a).isBlock
@[to_additive]
lemma isBlock_top : IsBlock (⊤ : Subgroup G) B ↔ IsBlock G B :=
Subgroup.topEquiv.toEquiv.forall_congr fun _ ↦ Subgroup.topEquiv.toEquiv.forall_congr_left
@[to_additive]
lemma IsBlock.preimage {H Y : Type*} [Group H] [MulAction H Y]
{φ : H → G} (j : Y →ₑ[φ] X) (hB : IsBlock G B) :
IsBlock H (j ⁻¹' B) := by
rintro g₁ g₂ hg
rw [← Group.preimage_smul_setₛₗ, ← Group.preimage_smul_setₛₗ] at hg ⊢
exact (hB <| ne_of_apply_ne _ hg).preimage _
@[to_additive]
theorem IsBlock.image {H Y : Type*} [SMul H Y] {φ : G → H} (j : X →ₑ[φ] Y)
(hφ : Function.Surjective φ) (hj : Function.Injective j) (hB : IsBlock G B) :
IsBlock H (j '' B) := by
simp only [IsBlock, hφ.forall, ← image_smul_setₛₗ]
exact fun g₁ g₂ hg ↦ disjoint_image_of_injective hj <| hB <| ne_of_apply_ne _ hg
@[to_additive]
theorem IsBlock.subtype_val_preimage {C : SubMulAction G X} (hB : IsBlock G B) :
IsBlock G (Subtype.val ⁻¹' B : Set C) :=
hB.preimage C.inclusion
@[to_additive]
theorem isBlock_subtypeVal {C : SubMulAction G X} {B : Set C} :
IsBlock G (Subtype.val '' B : Set X) ↔ IsBlock G B := by
refine forall₂_congr fun g₁ g₂ ↦ ?_
rw [← SubMulAction.inclusion.coe_eq, ← image_smul_set, ← image_smul_set, ne_eq,
Set.image_eq_image C.inclusion_injective, disjoint_image_iff C.inclusion_injective]
theorem _root_.AddAction.IsBlock.of_addSubgroup_of_conjugate
{G : Type*} [AddGroup G] {X : Type*} [AddAction G X] {B : Set X}
{H : AddSubgroup G} (hB : AddAction.IsBlock H B) (g : G) :
AddAction.IsBlock (H.map (AddAut.conj g).toMul.toAddMonoidHom) (g +ᵥ B) := by
rw [AddAction.isBlock_iff_vadd_eq_or_disjoint]
intro h'
obtain ⟨h, hH, hh⟩ := AddSubgroup.mem_map.mp (SetLike.coe_mem h')
simp only [AddEquiv.coe_toAddMonoidHom, AddAut.conj_apply] at hh
suffices h' +ᵥ (g +ᵥ B) = g +ᵥ (h +ᵥ B) by
simp only [this]
apply (hB.vadd_eq_or_disjoint ⟨h, hH⟩).imp
· intro hB'; congr
· exact Set.disjoint_image_of_injective (AddAction.injective g)
suffices (h' : G) +ᵥ (g +ᵥ B) = g +ᵥ (h +ᵥ B) by
exact this
rw [← hh, vadd_vadd, vadd_vadd]
simp
theorem IsBlock.of_subgroup_of_conjugate {H : Subgroup G} (hB : IsBlock H B) (g : G) :
IsBlock (H.map (MulAut.conj g).toMonoidHom) (g • B) := by
rw [isBlock_iff_smul_eq_or_disjoint]
intro h'
obtain ⟨h, hH, hh⟩ := Subgroup.mem_map.mp (SetLike.coe_mem h')
simp only [MulEquiv.coe_toMonoidHom, MulAut.conj_apply] at hh
suffices h' • g • B = g • h • B by
simp only [this]
apply (hB.smul_eq_or_disjoint ⟨h, hH⟩).imp
· intro; congr
· exact Set.disjoint_image_of_injective (MulAction.injective g)
suffices (h' : G) • g • B = g • h • B by
rw [← this]; rfl
rw [← hh, smul_smul (g * h * g⁻¹) g B, smul_smul g h B, inv_mul_cancel_right]
/-- A translate of a block is a block -/
theorem _root_.AddAction.IsBlock.translate
{G : Type*} [AddGroup G] {X : Type*} [AddAction G X] (B : Set X)
(g : G) (hB : AddAction.IsBlock G B) :
AddAction.IsBlock G (g +ᵥ B) := by
rw [← AddAction.isBlock_top] at hB ⊢
rw [← AddSubgroup.map_comap_eq_self_of_surjective (G := G) ?_ ⊤]
· apply AddAction.IsBlock.of_addSubgroup_of_conjugate
rwa [AddSubgroup.comap_top]
· exact (AddAut.conj g).surjective
/-- A translate of a block is a block -/
@[to_additive existing]
theorem IsBlock.translate (g : G) (hB : IsBlock G B) :
IsBlock G (g • B) := by
rw [← isBlock_top] at hB ⊢
rw [← Subgroup.map_comap_eq_self_of_surjective
(G := G) (f := MulAut.conj g) (MulAut.conj g).surjective ⊤]
apply IsBlock.of_subgroup_of_conjugate
rwa [Subgroup.comap_top]
variable (G) in
/-- For `SMul G X`, a block system of `X` is a partition of `X` into blocks
for the action of `G` -/
@[to_additive /-- For `VAdd G X`, a block system of `X` is a partition of `X` into blocks
for the additive action of `G` -/]
def IsBlockSystem (ℬ : Set (Set X)) := Setoid.IsPartition ℬ ∧ ∀ ⦃B⦄, B ∈ ℬ → IsBlock G B
/-- Translates of a block form a block system -/
@[to_additive /-- Translates of a block form a block system -/]
theorem IsBlock.isBlockSystem [hGX : MulAction.IsPretransitive G X]
(hB : IsBlock G B) (hBe : B.Nonempty) :
IsBlockSystem G (Set.range fun g : G => g • B) := by
refine ⟨⟨?nonempty, ?cover⟩, ?mem_blocks⟩
case mem_blocks => rintro B' ⟨g, rfl⟩; exact hB.translate g
· simp only [Set.mem_range, not_exists]
intro g hg
apply hBe.ne_empty
simpa only [Set.smul_set_eq_empty] using hg
· intro a
obtain ⟨b : X, hb : b ∈ B⟩ := hBe
obtain ⟨g, rfl⟩ := exists_smul_eq G b a
use g • B
simp only [Set.smul_mem_smul_set_iff, hb, Set.mem_range,
exists_apply_eq_apply, and_imp, forall_exists_index,
forall_apply_eq_imp_iff, true_and]
exact fun g' ha ↦ hB.smul_eq_smul_of_nonempty ⟨g • b, ha, ⟨b, hb, rfl⟩⟩
section Normal
@[to_additive]
lemma smul_orbit_eq_orbit_smul (N : Subgroup G) [nN : N.Normal] (a : X) (g : G) :
g • orbit N a = orbit N (g • a) := by
simp only [orbit, Set.smul_set_range]
ext
simp only [Set.mem_range]
constructor
· rintro ⟨⟨k, hk⟩, rfl⟩
use ⟨g * k * g⁻¹, nN.conj_mem k hk g⟩
simp only [Subgroup.mk_smul]
rw [smul_smul, inv_mul_cancel_right, ← smul_smul]
· rintro ⟨⟨k, hk⟩, rfl⟩
use ⟨g⁻¹ * k * g, nN.conj_mem' k hk g⟩
simp only [Subgroup.mk_smul]
simp only [← smul_smul, smul_inv_smul]
/-- An orbit of a normal subgroup is a block -/
@[to_additive /-- An orbit of a normal subgroup is a block -/]
theorem IsBlock.orbit_of_normal {N : Subgroup G} [N.Normal] (a : X) :
IsBlock G (orbit N a) := by
rw [isBlock_iff_smul_eq_or_disjoint]
intro g
rw [smul_orbit_eq_orbit_smul]
apply orbit.eq_or_disjoint
/-- The orbits of a normal subgroup form a block system -/
@[to_additive /-- The orbits of a normal subgroup form a block system -/]
theorem IsBlockSystem.of_normal {N : Subgroup G} [N.Normal] :
IsBlockSystem G (Set.range fun a : X => orbit N a) := by
constructor
· apply IsPartition.of_orbits
· intro b; rintro ⟨a, rfl⟩
exact .orbit_of_normal a
section Group
variable {S H : Type*} [Group H] [SetLike S H] [SubgroupClass S H] {s : S} {a : G}
/-!
Annoyingly, it seems like the following two lemmas cannot be unified.
-/
section Left
variable [MulAction G H] [IsScalarTower G H H]
/-- See `MulAction.isBlock_subgroup'` for a version that works for the right action of a group on
itself. -/
@[to_additive /-- See `AddAction.isBlock_subgroup'` for a version that works for the right action
of a group on itself. -/]
lemma isBlock_subgroup : IsBlock G (s : Set H) := by
simp only [IsBlock, disjoint_left]
rintro a b hab _ ⟨c, hc, rfl⟩ ⟨d, hd, (hcd : b • d = a • c)⟩
refine hab ?_
rw [← smul_coe_set hc, ← smul_assoc, ← hcd, smul_assoc, smul_coe_set hc, smul_coe_set hd]
end Left
section Right
variable [MulAction G H] [IsScalarTower G Hᵐᵒᵖ H]
open MulOpposite
/-- See `MulAction.isBlock_subgroup` for a version that works for the left action of a group on
itself. -/
@[to_additive /-- See `AddAction.isBlock_subgroup` for a version that works for the left action
of a group on itself. -/]
lemma isBlock_subgroup' : IsBlock G (s : Set H) := by
simp only [IsBlock, disjoint_left]
rintro a b hab _ ⟨c, hc, rfl⟩ ⟨d, hd, (hcd : b • d = a • c)⟩
refine hab ?_
rw [← op_smul_coe_set hc, ← smul_assoc, ← op_smul, ← hcd, op_smul, smul_assoc, op_smul_coe_set hc,
op_smul_coe_set hd]
end Right
end Group
end Normal
section Stabilizer
/- For transitive actions, construction of the lattice equivalence
`block_stabilizerOrderIso` between
- blocks of `MulAction G X` containing a point `a ∈ X`,
and
- subgroups of G containing `stabilizer G a`.
(Wielandt, th. 7.5) -/
/-- The orbit of `a` under a subgroup containing the stabilizer of `a` is a block -/
@[to_additive /-- The orbit of `a` under a subgroup containing the stabilizer of `a` is a block -/]
theorem IsBlock.of_orbit {H : Subgroup G} {a : X} (hH : stabilizer G a ≤ H) :
IsBlock G (MulAction.orbit H a) := by
rw [isBlock_iff_smul_eq_of_nonempty]
rintro g ⟨-, ⟨-, ⟨h₁, rfl⟩, h⟩, h₂, rfl⟩
suffices g ∈ H by
rw [← Subgroup.coe_mk H g this, ← H.toSubmonoid.smul_def, smul_orbit (⟨g, this⟩ : H) a]
rw [← mul_mem_cancel_left h₂⁻¹.2, ← mul_mem_cancel_right h₁.2]
apply hH
simpa only [mem_stabilizer_iff, InvMemClass.coe_inv, mul_smul, inv_smul_eq_iff]
/-- If `B` is a block containing `a`, then the stabilizer of `B` contains the stabilizer of `a` -/
@[to_additive
/-- If `B` is a block containing `a`, then the stabilizer of `B` contains the stabilizer of `a` -/]
theorem IsBlock.stabilizer_le (hB : IsBlock G B) {a : X} (ha : a ∈ B) :
stabilizer G a ≤ stabilizer G B :=
fun g hg ↦ hB.smul_eq_of_nonempty ⟨a, by rwa [← hg, smul_mem_smul_set_iff], ha⟩
/-- A block containing `a` is the orbit of `a` under its stabilizer -/
@[to_additive /-- A block containing `a` is the orbit of `a` under its stabilizer -/]
theorem IsBlock.orbit_stabilizer_eq [IsPretransitive G X] (hB : IsBlock G B) {a : X} (ha : a ∈ B) :
MulAction.orbit (stabilizer G B) a = B := by
ext x
constructor
· rintro ⟨⟨k, k_mem⟩, rfl⟩
simp only [Subgroup.mk_smul]
rw [← k_mem, Set.smul_mem_smul_set_iff]
exact ha
· intro hx
obtain ⟨k, rfl⟩ := exists_smul_eq G a x
exact ⟨⟨k, hB.smul_eq_of_mem ha hx⟩, rfl⟩
/-- A subgroup containing the stabilizer of `a`
is the stabilizer of the orbit of `a` under that subgroup -/
@[to_additive
/-- A subgroup containing the stabilizer of `a`
is the stabilizer of the orbit of `a` under that subgroup -/]
theorem stabilizer_orbit_eq {a : X} {H : Subgroup G} (hH : stabilizer G a ≤ H) :
stabilizer G (orbit H a) = H := by
ext g
constructor
· intro hg
obtain ⟨-, ⟨b, rfl⟩, h⟩ := hg.symm ▸ mem_orbit_self a
simp_rw [H.toSubmonoid.smul_def, ← mul_smul, ← mem_stabilizer_iff] at h
exact (mul_mem_cancel_right b.2).mp (hH h)
· intro hg
rw [mem_stabilizer_iff, ← Subgroup.coe_mk H g hg, ← Submonoid.smul_def (S := H.toSubmonoid)]
apply smul_orbit (G := H)
variable (G)
/-- Order equivalence between blocks in `X` containing a point `a`
and subgroups of `G` containing the stabilizer of `a` (Wielandt, th. 7.5) -/
@[to_additive
/-- Order equivalence between blocks in `X` containing a point `a`
and subgroups of `G` containing the stabilizer of `a` (Wielandt, th. 7.5) -/]
def block_stabilizerOrderIso [htGX : IsPretransitive G X] (a : X) :
{ B : Set X // a ∈ B ∧ IsBlock G B } ≃o Set.Ici (stabilizer G a) where
toFun := fun ⟨B, ha, hB⟩ => ⟨stabilizer G B, hB.stabilizer_le ha⟩
invFun := fun ⟨H, hH⟩ =>
⟨MulAction.orbit H a, MulAction.mem_orbit_self a, IsBlock.of_orbit hH⟩
left_inv := fun ⟨_, ha, hB⟩ =>
(id (propext Subtype.mk_eq_mk)).mpr (hB.orbit_stabilizer_eq ha)
right_inv := fun ⟨_, hH⟩ =>
(id (propext Subtype.mk_eq_mk)).mpr (stabilizer_orbit_eq hH)
map_rel_iff' := by
rintro ⟨B, ha, hB⟩; rintro ⟨B', ha', hB'⟩
simp only [Equiv.coe_fn_mk, Subtype.mk_le_mk, Set.le_eq_subset]
constructor
· rintro hBB' b hb
obtain ⟨k, rfl⟩ := htGX.exists_smul_eq a b
suffices k ∈ stabilizer G B' by
exact this.symm ▸ (Set.smul_mem_smul_set ha')
exact hBB' (hB.smul_eq_of_mem ha hb)
· intro hBB' g hgB
apply hB'.smul_eq_of_mem ha'
exact hBB' <| hgB.symm ▸ (Set.smul_mem_smul_set ha)
/-- The type of blocks for a group action containing a given element -/
@[to_additive
/-- The type of blocks for an additive group action containing a given element -/]
abbrev BlockMem (a : X) : Type _ := {B : Set X // a ∈ B ∧ IsBlock G B}
namespace BlockMem
/-- The type of blocks for a group action containing a given element is a bounded order. -/
@[to_additive /-- The type of blocks for an additive group action containing a given element is a
bounded order. -/]
instance (a : X) : BoundedOrder (BlockMem G a) where
top := ⟨Set.univ, Set.mem_univ a, .univ⟩
le_top := by
rintro ⟨B, ha, hB⟩
simp only [Subtype.mk_le_mk, le_eq_subset, subset_univ]
bot := ⟨{a}, Set.mem_singleton a, IsBlock.singleton⟩
bot_le := by
rintro ⟨B, ha, hB⟩
simp only [Subtype.mk_le_mk, Set.le_eq_subset, Set.singleton_subset_iff]
exact ha
@[to_additive (attr := simp, norm_cast)]
theorem coe_top (a : X) :
((⊤ : BlockMem G a) : Set X) = Set.univ :=
rfl
@[to_additive (attr := simp, norm_cast)]
theorem coe_bot (a : X) :
((⊥ : BlockMem G a) : Set X) = {a} :=
rfl
@[to_additive]
instance [Nontrivial X] (a : X) : Nontrivial (BlockMem G a) := by
rw [nontrivial_iff]
use ⊥, ⊤
intro h
rw [← Subtype.coe_inj] at h
simp only [coe_top, coe_bot] at h
obtain ⟨b, hb⟩ := exists_ne a
apply hb
rw [← Set.mem_singleton_iff, h]
apply Set.mem_univ
end BlockMem
end Stabilizer
section Finite
namespace IsBlock
variable [IsPretransitive G X] {B : Set X}
@[to_additive]
theorem ncard_block_eq_relIndex (hB : IsBlock G B) {x : X} (hx : x ∈ B) :
B.ncard = (stabilizer G x).relIndex (stabilizer G B) := by
have key : (stabilizer G x).subgroupOf (stabilizer G B) = stabilizer (stabilizer G B) x := by
ext; rfl
rw [Subgroup.relIndex, key, index_stabilizer, hB.orbit_stabilizer_eq hx]
@[deprecated (since := "2025-08-12")] alias ncard_block_eq_relindex := ncard_block_eq_relIndex
/-- The cardinality of the ambient space is the product of the cardinality of a block
by the cardinality of the set of translates of that block -/
@[to_additive
/-- The cardinality of the ambient space is the product of the cardinality of a block
by the cardinality of the set of translates of that block -/]
theorem ncard_block_mul_ncard_orbit_eq (hB : IsBlock G B) (hB_ne : B.Nonempty) :
Set.ncard B * Set.ncard (orbit G B) = Nat.card X := by
obtain ⟨x, hx⟩ := hB_ne
rw [ncard_block_eq_relIndex hB hx, ← index_stabilizer,
Subgroup.relIndex_mul_index (hB.stabilizer_le hx), index_stabilizer_of_transitive]
/-- The cardinality of a block divides the cardinality of the ambient type -/
@[to_additive /-- The cardinality of a block divides the cardinality of the ambient type -/]
theorem ncard_dvd_card (hB : IsBlock G B) (hB_ne : B.Nonempty) :
Set.ncard B ∣ Nat.card X :=
Dvd.intro _ (hB.ncard_block_mul_ncard_orbit_eq hB_ne)
/-- A too large block is equal to `univ` -/
@[to_additive /-- A too large block is equal to `univ` -/]
theorem eq_univ_of_card_lt [hX : Finite X] (hB : IsBlock G B) (hB' : Nat.card X < Set.ncard B * 2) :
B = Set.univ := by
rcases Set.eq_empty_or_nonempty B with rfl | hB_ne
· simp only [Set.ncard_empty, zero_mul, not_lt_zero'] at hB'
have key := hB.ncard_block_mul_ncard_orbit_eq hB_ne
rw [← key, mul_lt_mul_iff_of_pos_left (by rwa [Set.ncard_pos])] at hB'
interval_cases (orbit G B).ncard
· rw [mul_zero, eq_comm, Nat.card_eq_zero, or_iff_left hX.not_infinite] at key
exact (IsEmpty.exists_iff.mp hB_ne).elim
· rw [mul_one, ← Set.ncard_univ] at key
rw [Set.eq_of_subset_of_ncard_le (Set.subset_univ B) key.ge]
/-- If a block has too many translates, then it is a (sub)singleton -/
@[to_additive /-- If a block has too many translates, then it is a (sub)singleton -/]
theorem subsingleton_of_card_lt [Finite X] (hB : IsBlock G B)
(hB' : Nat.card X < 2 * Set.ncard (orbit G B)) :
B.Subsingleton := by
suffices Set.ncard B < 2 by
rw [Nat.lt_succ_iff, Set.ncard_le_one_iff_eq] at this
cases this with
| inl h => rw [h]; exact Set.subsingleton_empty
| inr h =>
obtain ⟨a, ha⟩ := h; rw [ha]; exact Set.subsingleton_singleton
cases Set.eq_empty_or_nonempty B with
| inl h => rw [h, Set.ncard_empty]; simp
| inr h =>
rw [← hB.ncard_block_mul_ncard_orbit_eq h, lt_iff_not_ge] at hB'
rw [← not_le]
exact fun hb ↦ hB' (Nat.mul_le_mul_right _ hb)
/- The assumption `B.Finite` is necessary :
For G = ℤ acting on itself, a = 0 and B = ℕ, the translates `k • B` of the statement
are just `k + ℕ`, for `k ≤ 0`, and the corresponding intersection is `ℕ`, which is not a block.
(Remark by Thomas Browning) -/
/-- The intersection of the translates of a *finite* subset which contain a given point
is a block (Wielandt, th. 7.3). -/
@[to_additive
/-- The intersection of the translates of a *finite* subset which contain a given point
is a block (Wielandt, th. 7.3). -/]
theorem of_subset (a : X) (hfB : B.Finite) :
IsBlock G (⋂ (k : G) (_ : a ∈ k • B), k • B) := by
let B' := ⋂ (k : G) (_ : a ∈ k • B), k • B
rcases Set.eq_empty_or_nonempty B with hfB_e | hfB_ne
· simp [hfB_e]
have hB'₀ : ∀ (k : G) (_ : a ∈ k • B), B' ≤ k • B := by
intro k hk
exact Set.biInter_subset_of_mem hk
have hfB' : B'.Finite := by
obtain ⟨b, hb : b ∈ B⟩ := hfB_ne
obtain ⟨k, hk : k • b = a⟩ := exists_smul_eq G b a
apply Set.Finite.subset (Set.Finite.map _ hfB) (hB'₀ k ⟨b, hb, hk⟩)
have hag : ∀ g : G, a ∈ g • B' → B' ≤ g • B' := by
intro g hg x hx
-- a = g • b; b ∈ B'; a ∈ k • B → b ∈ k • B
simp only [B', Set.mem_iInter, Set.mem_smul_set_iff_inv_smul_mem,
smul_smul, ← mul_inv_rev] at hg hx ⊢
exact fun _ ↦ hx _ ∘ hg _
have hag' (g : G) (hg : a ∈ g • B') : B' = g • B' := by
rw [eq_comm, ← mem_stabilizer_iff, mem_stabilizer_set_iff_subset_smul_set hfB']
exact hag g hg
rw [isBlock_iff_smul_eq_of_nonempty]
rintro g ⟨b : X, hb' : b ∈ g • B', hb : b ∈ B'⟩
obtain ⟨k : G, hk : k • a = b⟩ := exists_smul_eq G a b
have hak : a ∈ k⁻¹ • B' := by
refine ⟨b, hb, ?_⟩
simp only [← hk, inv_smul_smul]
have hagk : a ∈ (k⁻¹ * g) • B' := by
rw [mul_smul, Set.mem_smul_set_iff_inv_smul_mem, inv_inv, hk]
exact hb'
have hkB' : B' = k⁻¹ • B' := hag' k⁻¹ hak
have hgkB' : B' = (k⁻¹ * g) • B' := hag' (k⁻¹ * g) hagk
rw [mul_smul] at hgkB'
rw [← smul_eq_iff_eq_inv_smul] at hkB' hgkB'
rw [← hgkB', hkB']
end IsBlock
end Finite
end Group
end MulAction |
.lake/packages/mathlib/Mathlib/GroupTheory/GroupAction/Iwasawa.lean | import Mathlib.Algebra.Group.Action.End
import Mathlib.GroupTheory.GroupAction.Primitive
import Mathlib.GroupTheory.Subgroup.Simple
/-! # Iwasawa criterion for simplicity
- `IwasawaStructure` : the structure underlying the Iwasawa criterion
For a group `G`, this consists of an action of `G` on a type `α` and,
for every `a : α`, of a subgroup `T a`, such that the following properties hold:
- for all `a`, `T a` is commutative
- for all `g : G` and `a : α`, `T (g • a) = MulAut.conj g • T a`
- the subgroups `T a` generate `G`
We then prove two versions of the Iwasawa criterion when
there is an Iwasawa structure.
- `IwasawaStructure.commutator_le` asserts that if the action of `G` on `α`
is quasiprimitive, then every normal subgroup that acts nontrivially
contains `commutator G`
- `IwasawaStructure.isSimpleGroup` : the Iwasawa criterion for simplicity
If the action of `G` on `α` is quasiprimitive and faithful,
and `G` is nontrivial and perfect, then `G` is simple.
## TODO
Additivize. The issue is that it requires to additivize `commutator`
(which, moreover, lives in the root namespace)
-/
namespace MulAction
open scoped BigOperators Pointwise
variable (M : Type*) [Group M] (α : Type*) [MulAction M α]
/-- The structure underlying the Iwasawa criterion -/
structure IwasawaStructure where
/-- The subgroups of the Iwasawa structure -/
T : α → Subgroup M
/-- The commutativity property of the subgroups -/
is_comm : ∀ x : α, IsMulCommutative (T x)
/-- The conjugacy property of the subgroups -/
is_conj : ∀ g : M, ∀ x : α, T (g • x) = MulAut.conj g • T x
/-- The subgroups generate the group -/
is_generator : iSup T = ⊤
variable {M α}
namespace IwasawaStructure
/-- The Iwasawa criterion : If a quasiprimitive action of a group G on X
has an Iwasawa structure, then any normal subgroup that acts nontrivially
contains the group of commutators. -/
theorem commutator_le (IwaS : IwasawaStructure M α) [IsQuasiPreprimitive M α]
(N : Subgroup M) [nN : N.Normal] (hNX : MulAction.fixedPoints N α ≠ .univ) :
commutator M ≤ N := by
have is_transN := IsQuasiPreprimitive.isPretransitive_of_normal hNX
have ntα : Nontrivial α := nontrivial_of_fixedPoints_ne_univ hNX
obtain a : α := Nontrivial.to_nonempty.some
apply nN.commutator_le_of_self_sup_commutative_eq_top ?_ (IwaS.is_comm a)
-- We have to prove that N ⊔ IwaS.T x = ⊤
rw [eq_top_iff, ← IwaS.is_generator, iSup_le_iff]
intro x
obtain ⟨g, rfl⟩ := MulAction.exists_smul_eq N a x
rw [Subgroup.smul_def, IwaS.is_conj g a]
rintro _ ⟨k, hk, rfl⟩
have hg' : ↑g ∈ N ⊔ IwaS.T a := Subgroup.mem_sup_left (Subtype.mem g)
have hk' : k ∈ N ⊔ IwaS.T a := Subgroup.mem_sup_right hk
exact (N ⊔ IwaS.T a).mul_mem ((N ⊔ IwaS.T a).mul_mem hg' hk') ((N ⊔ IwaS.T a).inv_mem hg')
/-- The Iwasawa criterion for simplicity -/
theorem isSimpleGroup [Nontrivial M] (is_perfect : commutator M = ⊤)
[IsQuasiPreprimitive M α] (IwaS : IwasawaStructure M α) (is_faithful : FaithfulSMul M α) :
IsSimpleGroup M := by
apply IsSimpleGroup.mk
intro N nN
cases or_iff_not_imp_left.mpr (IwaS.commutator_le N) with
| inl h =>
refine Or.inl (N.eq_bot_iff_forall.mpr fun n hn => ?_)
apply is_faithful.eq_of_smul_eq_smul
intro x
rw [one_smul]
exact Set.eq_univ_iff_forall.mp h x ⟨n, hn⟩
| inr h => exact Or.inr (top_le_iff.mp (le_trans (ge_of_eq is_perfect) h))
end MulAction.IwasawaStructure |
.lake/packages/mathlib/Mathlib/GroupTheory/GroupAction/FixedPoints.lean | import Mathlib.Algebra.Group.Action.Pointwise.Set.Basic
import Mathlib.Algebra.Group.Commute.Basic
import Mathlib.Dynamics.PeriodicPts.Defs
import Mathlib.GroupTheory.GroupAction.Defs
/-!
# Properties of `fixedPoints` and `fixedBy`
This module contains some useful properties of `MulAction.fixedPoints` and `MulAction.fixedBy`
that don't directly belong to `Mathlib/GroupTheory/GroupAction/Basic.lean`.
## Main theorems
* `MulAction.fixedBy_mul`: `fixedBy α (g * h) ⊆ fixedBy α g ∪ fixedBy α h`
* `MulAction.fixedBy_conj` and `MulAction.smul_fixedBy`: the pointwise group action of `h` on
`fixedBy α g` is equal to the `fixedBy` set of the conjugation of `h` with `g`
(`fixedBy α (h * g * h⁻¹)`).
* `MulAction.set_mem_fixedBy_of_movedBy_subset` shows that if a set `s` is a superset of
`(fixedBy α g)ᶜ`, then the group action of `g` cannot send elements of `s` outside of `s`.
This is expressed as `s ∈ fixedBy (Set α) g`, and `MulAction.set_mem_fixedBy_iff` allows one
to convert the relationship back to `g • x ∈ s ↔ x ∈ s`.
* `MulAction.not_commute_of_disjoint_smul_movedBy` allows one to prove that `g` and `h`
do not commute from the disjointness of the `(fixedBy α g)ᶜ` set and `h • (fixedBy α g)ᶜ`,
which is a property used in the proof of Rubin's theorem.
The theorems above are also available for `AddAction`.
## Pointwise group action and `fixedBy (Set α) g`
Since `fixedBy α g = { x | g • x = x }` by definition, properties about the pointwise action of
a set `s : Set α` can be expressed using `fixedBy (Set α) g`.
To properly use theorems using `fixedBy (Set α) g`, you should `open Pointwise` in your file.
`s ∈ fixedBy (Set α) g` means that `g • s = s`, which is equivalent to say that
`∀ x, g • x ∈ s ↔ x ∈ s` (the translation can be done using `MulAction.set_mem_fixedBy_iff`).
`s ∈ fixedBy (Set α) g` is a weaker statement than `s ⊆ fixedBy α g`: the latter requires that
all points in `s` are fixed by `g`, whereas the former only requires that `g • x ∈ s`.
-/
namespace MulAction
open Pointwise
variable {α : Type*}
variable {G : Type*} [Group G] [MulAction G α]
variable {M : Type*} [Monoid M] [MulAction M α]
section FixedPoints
variable (α) in
/-- In a multiplicative group action, the points fixed by `g` are also fixed by `g⁻¹` -/
@[to_additive (attr := simp)
/-- In an additive group action, the points fixed by `g` are also fixed by `g⁻¹` -/]
theorem fixedBy_inv (g : G) : fixedBy α g⁻¹ = fixedBy α g := by
ext
rw [mem_fixedBy, mem_fixedBy, inv_smul_eq_iff, eq_comm]
@[to_additive]
theorem smul_mem_fixedBy_iff_mem_fixedBy {a : α} {g : G} :
g • a ∈ fixedBy α g ↔ a ∈ fixedBy α g := by
rw [mem_fixedBy, smul_left_cancel_iff]
rfl
@[to_additive]
theorem smul_inv_mem_fixedBy_iff_mem_fixedBy {a : α} {g : G} :
g⁻¹ • a ∈ fixedBy α g ↔ a ∈ fixedBy α g := by
rw [← fixedBy_inv, smul_mem_fixedBy_iff_mem_fixedBy, fixedBy_inv]
@[to_additive minimalPeriod_eq_one_iff_fixedBy]
theorem minimalPeriod_eq_one_iff_fixedBy {a : α} {g : G} :
Function.minimalPeriod (fun x => g • x) a = 1 ↔ a ∈ fixedBy α g :=
Function.minimalPeriod_eq_one_iff_isFixedPt
@[to_additive]
theorem mem_fixedBy_zpow {g : G} {a : α} (h : a ∈ fixedBy α g) (j : ℤ) :
a ∈ fixedBy α (g ^ j) := by
rw [mem_fixedBy, zpow_smul_eq_iff_minimalPeriod_dvd, minimalPeriod_eq_one_iff_fixedBy.mpr h,
Int.natCast_one]
exact one_dvd j
@[to_additive]
theorem mem_fixedBy_zpowers_iff_mem_fixedBy {g : G} {a : α} :
(∀ j : ℤ, a ∈ fixedBy α (g ^ j)) ↔ a ∈ fixedBy α g :=
⟨fun h ↦ by simpa using h 1, fun h j ↦ mem_fixedBy_zpow h j⟩
variable (α) in
@[to_additive]
theorem fixedBy_subset_fixedBy_zpow (g : G) (j : ℤ) :
fixedBy α g ⊆ fixedBy α (g ^ j) :=
fun _ h ↦ mem_fixedBy_zpow h j
variable (M α) in
@[to_additive (attr := simp)]
theorem fixedBy_one_eq_univ : fixedBy α (1 : M) = Set.univ :=
Set.eq_univ_iff_forall.mpr <| one_smul M
variable (α) in
@[to_additive]
theorem fixedBy_mul (m₁ m₂ : M) : fixedBy α m₁ ∩ fixedBy α m₂ ⊆ fixedBy α (m₁ * m₂) := by
intro a ⟨h₁, h₂⟩
rw [mem_fixedBy, mul_smul, h₂, h₁]
variable (α) in
@[to_additive]
theorem smul_fixedBy (g h : G) :
h • fixedBy α g = fixedBy α (h * g * h⁻¹) := by
ext a
simp_rw [Set.mem_smul_set_iff_inv_smul_mem, mem_fixedBy, mul_smul, smul_eq_iff_eq_inv_smul h]
end FixedPoints
section Pointwise
/-!
### `fixedBy` sets of the pointwise group action
The theorems below need the `Pointwise` scoped to be opened (using `open Pointwise`)
to be used effectively.
-/
/--
If a set `s : Set α` is in `fixedBy (Set α) g`, then all points of `s` will stay in `s` after being
moved by `g`.
-/
@[to_additive /-- If a set `s : Set α` is in `fixedBy (Set α) g`, then all points of `s` will stay
in `s` after being moved by `g`. -/]
theorem set_mem_fixedBy_iff (s : Set α) (g : G) :
s ∈ fixedBy (Set α) g ↔ ∀ x, g • x ∈ s ↔ x ∈ s := by
simp_rw [mem_fixedBy, ← eq_inv_smul_iff, Set.ext_iff, Set.mem_inv_smul_set_iff, Iff.comm]
@[to_additive]
theorem smul_mem_of_set_mem_fixedBy {s : Set α} {g : G} (s_in_fixedBy : s ∈ fixedBy (Set α) g)
{x : α} : g • x ∈ s ↔ x ∈ s := (set_mem_fixedBy_iff s g).mp s_in_fixedBy x
/--
If `s ⊆ fixedBy α g`, then `g • s = s`, which means that `s ∈ fixedBy (Set α) g`.
Note that the reverse implication is in general not true, as `s ∈ fixedBy (Set α) g` is a
weaker statement (it allows for points `x ∈ s` for which `g • x ≠ x` and `g • x ∈ s`).
-/
@[to_additive /-- If `s ⊆ fixedBy α g`, then `g +ᵥ s = s`, which means that `s ∈ fixedBy (Set α) g`.
Note that the reverse implication is in general not true, as `s ∈ fixedBy (Set α) g` is a
weaker statement (it allows for points `x ∈ s` for which `g +ᵥ x ≠ x` and `g +ᵥ x ∈ s`). -/]
theorem set_mem_fixedBy_of_subset_fixedBy {s : Set α} {g : G} (s_ss_fixedBy : s ⊆ fixedBy α g) :
s ∈ fixedBy (Set α) g := by
rw [← fixedBy_inv]
ext x
rw [Set.mem_inv_smul_set_iff]
refine ⟨fun gxs => ?xs, fun xs => (s_ss_fixedBy xs).symm ▸ xs⟩
rw [← fixedBy_inv] at s_ss_fixedBy
rwa [← s_ss_fixedBy gxs, inv_smul_smul] at gxs
theorem smul_subset_of_set_mem_fixedBy {s t : Set α} {g : G} (t_ss_s : t ⊆ s)
(s_in_fixedBy : s ∈ fixedBy (Set α) g) : g • t ⊆ s :=
(Set.smul_set_subset_smul_set_iff.mpr t_ss_s).trans s_in_fixedBy.subset
/-!
If a set `s : Set α` is a superset of `(MulAction.fixedBy α g)ᶜ` (resp. `(AddAction.fixedBy α g)ᶜ`),
then no point or subset of `s` can be moved outside of `s` by the group action of `g`.
-/
/-- If `(fixedBy α g)ᶜ ⊆ s`, then `g` cannot move a point of `s` outside of `s`. -/
@[to_additive /-- If `(fixedBy α g)ᶜ ⊆ s`, then `g` cannot move a point of `s` outside of `s`. -/]
theorem set_mem_fixedBy_of_movedBy_subset {s : Set α} {g : G} (s_subset : (fixedBy α g)ᶜ ⊆ s) :
s ∈ fixedBy (Set α) g := by
rw [← fixedBy_inv]
ext a
rw [Set.mem_inv_smul_set_iff]
by_cases a ∈ fixedBy α g
case pos a_fixed =>
rw [a_fixed]
case neg a_moved =>
constructor <;> (intro; apply s_subset)
· exact a_moved
· rwa [Set.mem_compl_iff, smul_mem_fixedBy_iff_mem_fixedBy]
end Pointwise
section Commute
/-!
## Pointwise image of the `fixedBy` set by a commuting group element
If two group elements `g` and `h` commute, then `g` fixes `h • x` (resp. `h +ᵥ x`)
if and only if `g` fixes `x`.
This is equivalent to say that if `Commute g h`, then `fixedBy α g ∈ fixedBy (Set α) h` and
`(fixedBy α g)ᶜ ∈ fixedBy (Set α) h`.
-/
/--
If `g` and `h` commute, then `g` fixes `h • x` iff `g` fixes `x`.
This is equivalent to say that the set `fixedBy α g` is fixed by `h`.
-/
@[to_additive /-- If `g` and `h` commute, then `g` fixes `h +ᵥ x` iff `g` fixes `x`.
This is equivalent to say that the set `fixedBy α g` is fixed by `h`. -/]
theorem fixedBy_mem_fixedBy_of_commute {g h : G} (comm : Commute g h) :
(fixedBy α g) ∈ fixedBy (Set α) h := by
ext x
rw [Set.mem_smul_set_iff_inv_smul_mem, mem_fixedBy, ← mul_smul, comm.inv_right, mul_smul,
smul_left_cancel_iff, mem_fixedBy]
/--
If `g` and `h` commute, then `g` fixes `(h ^ j) • x` iff `g` fixes `x`.
-/
@[to_additive /-- If `g` and `h` commute, then `g` fixes `(j • h) +ᵥ x` iff `g` fixes `x`. -/]
theorem smul_zpow_fixedBy_eq_of_commute {g h : G} (comm : Commute g h) (j : ℤ) :
h ^ j • fixedBy α g = fixedBy α g :=
fixedBy_subset_fixedBy_zpow (Set α) h j (fixedBy_mem_fixedBy_of_commute comm)
/--
If `g` and `h` commute, then `g` moves `h • x` iff `g` moves `x`.
This is equivalent to say that the set `(fixedBy α g)ᶜ` is fixed by `h`.
-/
@[to_additive /-- If `g` and `h` commute, then `g` moves `h +ᵥ x` iff `g` moves `x`.
This is equivalent to say that the set `(fixedBy α g)ᶜ` is fixed by `h`. -/]
theorem movedBy_mem_fixedBy_of_commute {g h : G} (comm : Commute g h) :
(fixedBy α g)ᶜ ∈ fixedBy (Set α) h := by
rw [mem_fixedBy, Set.smul_set_compl, fixedBy_mem_fixedBy_of_commute comm]
/--
If `g` and `h` commute, then `g` moves `h ^ j • x` iff `g` moves `x`.
-/
@[to_additive /-- If `g` and `h` commute, then `g` moves `(j • h) +ᵥ x` iff `g` moves `x`. -/]
theorem smul_zpow_movedBy_eq_of_commute {g h : G} (comm : Commute g h) (j : ℤ) :
h ^ j • (fixedBy α g)ᶜ = (fixedBy α g)ᶜ :=
fixedBy_subset_fixedBy_zpow (Set α) h j (movedBy_mem_fixedBy_of_commute comm)
end Commute
section Faithful
variable [FaithfulSMul G α]
variable [FaithfulSMul M α]
/-- If the multiplicative action of `M` on `α` is faithful,
then `fixedBy α m = Set.univ` implies that `m = 1`. -/
@[to_additive /-- If the additive action of `M` on `α` is faithful,
then `fixedBy α m = Set.univ` implies that `m = 1`. -/]
theorem fixedBy_eq_univ_iff_eq_one {m : M} : fixedBy α m = Set.univ ↔ m = 1 := by
rw [← (smul_left_injective' (M := M) (α := α)).eq_iff, Set.eq_univ_iff_forall]
simp_rw [funext_iff, one_smul, mem_fixedBy]
/--
If the image of the `(fixedBy α g)ᶜ` set by the pointwise action of `h: G`
is disjoint from `(fixedBy α g)ᶜ`, then `g` and `h` cannot commute.
-/
@[to_additive /-- If the image of the `(fixedBy α g)ᶜ` set by the pointwise action of `h: G`
is disjoint from `(fixedBy α g)ᶜ`, then `g` and `h` cannot commute. -/]
theorem not_commute_of_disjoint_movedBy_preimage {g h : G} (ne_one : g ≠ 1)
(disjoint : Disjoint (fixedBy α g)ᶜ (h • (fixedBy α g)ᶜ)) : ¬Commute g h := by
contrapose! ne_one with comm
rwa [movedBy_mem_fixedBy_of_commute comm, disjoint_self, Set.bot_eq_empty, ← Set.compl_univ,
compl_inj_iff, fixedBy_eq_univ_iff_eq_one] at disjoint
end Faithful
end MulAction |
.lake/packages/mathlib/Mathlib/GroupTheory/GroupAction/Primitive.lean | import Mathlib.Algebra.BigOperators.Finprod
import Mathlib.Data.Nat.Prime.Basic
import Mathlib.Data.Setoid.Partition.Card
import Mathlib.GroupTheory.GroupAction.Blocks
import Mathlib.GroupTheory.GroupAction.Transitive
/-!
# Primitive actions
## Definitions
- `MulAction.IsPreprimitive G X`
A structure that says that the action of a type `G` on a type `X`
(defined by an instance `SMul G X`) is *preprimitive*,
namely, it is pretransitive and the only blocks are ⊤ and subsingletons.
(The pretransitivity assumption is essentially trivial,
because orbits are blocks, unless the action itself is trivial.)
The notion which is introduced in classical books on group theory
is restricted to group actions.
In fact, it may be irrelevant if the action is degenerate,
when “trivial blocks” might not be blocks.
Moreover, the classical notion is *primitive*,
which further assumes that `X` is not empty.
- `MulAction.IsQuasiPreprimitive G X`
A structure that says that the action of the group `G` on the type `X` is *quasipreprimitive*,
namely, normal subgroups of `G` which act nontrivially act pretransitively.
- We prove some straightforward theorems that relate preprimitivity
under equivariant maps, for images and preimages.
## Relation with stabilizers
- `MulAction.isSimpleOrderBlockMem_iff_isPreprimitive`
relates primitivity and the fact that the inclusion order on blocks containing is simple.
- `MulAction.isCoatom_stabilizer_iff_preprimitive`
An action is preprimitive iff the stabilizers of points are maximal subgroups.
- `MulAction.IsPreprimitive.isCoatom_stabilizer_of_isPreprimitive`
Stabilizers of points under a preprimitive action are maximal subgroups.
## Relation with normal subgroups
- `MulAction.IsPreprimitive.isQuasipreprimitive`
Preprimitive actions are quasipreprimitive.
## Particular results for actions on finite types
- `MulAction.IsPreprimitive.of_prime_card` :
A pretransitive action on a finite type of prime cardinal is preprimitive.
- `MulAction.IsPreprimitive.of_card_lt`
Given an equivariant map from a preprimitive action,
if the image is at least twice the codomain, then the codomain is preprimitive.
- `MulAction.IsPreprimitive.exists_mem_smul_and_notMem_smul` : **Theorem of Rudio**.
For a preprimitive action, a subset which is neither empty nor full has a translate
which contains a given point and avoids another one.
-/
open Pointwise
namespace MulAction
variable (G : Type*) (X : Type*)
-- Note : if the action is degenerate, singletons may not be blocks.
/-- An additive action is preprimitive if it is pretransitive and
the only blocks are the trivial ones -/
class _root_.AddAction.IsPreprimitive [VAdd G X] : Prop extends AddAction.IsPretransitive G X where
/-- An action is preprimitive if it is pretransitive and
the only blocks are the trivial ones -/
isTrivialBlock_of_isBlock : ∀ {B : Set X}, AddAction.IsBlock G B → AddAction.IsTrivialBlock B
/-- An action is preprimitive if it is pretransitive and
the only blocks are the trivial ones -/
@[to_additive]
class IsPreprimitive [SMul G X] : Prop extends IsPretransitive G X where
/-- An action is preprimitive if it is pretransitive and
the only blocks are the trivial ones -/
isTrivialBlock_of_isBlock : ∀ {B : Set X}, IsBlock G B → IsTrivialBlock B
open IsPreprimitive
/-- An additive action of an additive group is quasipreprimitive if any normal subgroup
that has no fixed point acts pretransitively -/
class _root_.AddAction.IsQuasiPreprimitive
[AddGroup G] [AddAction G X] : Prop extends AddAction.IsPretransitive G X where
isPretransitive_of_normal :
∀ {N : AddSubgroup G} [N.Normal], AddAction.fixedPoints N X ≠ .univ →
AddAction.IsPretransitive N X
/-- An action of a group is quasipreprimitive if any normal subgroup
that has no fixed point acts pretransitively -/
@[to_additive]
class IsQuasiPreprimitive [Group G] [MulAction G X] : Prop extends IsPretransitive G X where
isPretransitive_of_normal :
∀ {N : Subgroup G} [N.Normal], fixedPoints N X ≠ .univ → IsPretransitive N X
variable {G X}
@[to_additive]
theorem IsBlock.subsingleton_or_eq_univ
[SMul G X] [IsPreprimitive G X] {B : Set X} (hB : IsBlock G B) :
B.Subsingleton ∨ B = .univ :=
isTrivialBlock_of_isBlock hB
@[to_additive (attr := nontriviality)]
theorem IsPreprimitive.of_subsingleton [SMul G X] [Nonempty G] [Subsingleton X] :
IsPreprimitive G X where
exists_smul_eq (x y) := by
use Classical.arbitrary G
rw [eq_iff_true_of_subsingleton]
trivial
isTrivialBlock_of_isBlock B := by
left
exact Set.subsingleton_of_subsingleton
theorem isTrivialBlock_of_card_le_two
[Finite X] (hX : Nat.card X ≤ 2) (B : Set X) :
IsTrivialBlock B := by
rw [IsTrivialBlock, ← B.ncard_le_one_iff_subsingleton, B.eq_univ_iff_ncard]
have := B.ncard_le_card
grind
variable [Group G] [MulAction G X]
open scoped BigOperators Pointwise
/-- If the action is pretransitive, then the trivial blocks condition implies preprimitivity
(based condition) -/
@[to_additive
/-- If the action is pretransitive, then the trivial blocks condition implies preprimitivity
(based condition) -/]
theorem IsPreprimitive.of_isTrivialBlock_base [IsPretransitive G X] (a : X)
(H : ∀ {B : Set X} (_ : a ∈ B) (_ : IsBlock G B), IsTrivialBlock B) :
IsPreprimitive G X where
isTrivialBlock_of_isBlock {B} hB := by
obtain rfl | ⟨b, hb⟩ := B.eq_empty_or_nonempty
· simp [IsTrivialBlock]
· obtain ⟨g, hg⟩ := exists_smul_eq G b a
rw [← IsTrivialBlock.smul_iff g]
apply H _ (hB.translate g)
rw [← hg]
use b
/-- If the action is not trivial, then the trivial blocks condition implies preprimitivity
(pretransitivity is automatic) (based condition) -/
@[to_additive
/-- If the action is not trivial, then the trivial blocks condition implies preprimitivity
(pretransitivity is automatic) (based condition) -/]
theorem IsPreprimitive.of_isTrivialBlock_of_notMem_fixedPoints {a : X} (ha : a ∉ fixedPoints G X)
(H : ∀ ⦃B : Set X⦄, a ∈ B → IsBlock G B → IsTrivialBlock B) :
IsPreprimitive G X :=
have : IsPretransitive G X := by
rw [isPretransitive_iff_base a]
rcases H (mem_orbit_self a) (IsBlock.orbit a) with H | H
· exfalso; apply ha
rw [Set.subsingleton_iff_singleton (mem_orbit_self a)] at H
simp only [mem_fixedPoints]
intro g
rw [← Set.mem_singleton_iff]; rw [← H]
exact mem_orbit a g
· intro x; rw [← MulAction.mem_orbit_iff, H]; exact Set.mem_univ x
{ isTrivialBlock_of_isBlock {B} hB := by
obtain rfl | ⟨b, hb⟩ := B.eq_empty_or_nonempty
· simp [IsTrivialBlock]
· obtain ⟨g, hg⟩ := exists_smul_eq G b a
rw [← IsTrivialBlock.smul_iff g]
exact H ⟨b, hb, hg⟩ (hB.translate g) }
@[deprecated (since := "2025-05-23")]
alias _root_.AddAction.IsPreprimitive.of_isTrivialBlock_of_not_mem_fixedPoints :=
AddAction.IsPreprimitive.of_isTrivialBlock_of_notMem_fixedPoints
@[to_additive existing, deprecated (since := "2025-05-23")]
alias IsPreprimitive.of_isTrivialBlock_of_not_mem_fixedPoints :=
IsPreprimitive.of_isTrivialBlock_of_notMem_fixedPoints
/-- If the action is not trivial, then the trivial blocks condition implies preprimitivity
(pretransitivity is automatic) -/
@[to_additive
/-- If the action is not trivial, then the trivial blocks condition implies preprimitivity
(pretransitivity is automatic) -/]
theorem IsPreprimitive.mk' (Hnt : fixedPoints G X ≠ ⊤)
(H : ∀ {B : Set X} (_ : IsBlock G B), IsTrivialBlock B) :
IsPreprimitive G X := by
simp only [Set.top_eq_univ, Set.ne_univ_iff_exists_notMem] at Hnt
obtain ⟨_, ha⟩ := Hnt
exact .of_isTrivialBlock_of_notMem_fixedPoints ha fun {B} _ ↦ H
section EquivariantMap
variable {M : Type*} [Group M] {α : Type*} [MulAction M α]
variable {N β : Type*} [Group N] [MulAction N β]
variable {φ : M → N} {f : α →ₑ[φ] β}
@[to_additive]
theorem IsPreprimitive.of_surjective [IsPreprimitive M α] (hf : Function.Surjective f) :
IsPreprimitive N β where
toIsPretransitive := toIsPretransitive.of_surjective_map hf
isTrivialBlock_of_isBlock {B} hB := by
rw [← Set.image_preimage_eq B hf]
apply IsTrivialBlock.image hf
exact isTrivialBlock_of_isBlock (IsBlock.preimage f hB)
@[to_additive]
theorem isPreprimitive_congr (hφ : Function.Surjective φ) (hf : Function.Bijective f) :
IsPreprimitive M α ↔ IsPreprimitive N β := by
constructor
· intro _
apply IsPreprimitive.of_surjective hf.surjective
· intro _
haveI := (isPretransitive_congr hφ hf).mpr toIsPretransitive
exact {
isTrivialBlock_of_isBlock {B} hB := by
rw [← Set.preimage_image_eq B hf.injective]
exact IsTrivialBlock.preimage hf.injective
(isTrivialBlock_of_isBlock (hB.image f hφ hf.injective)) }
end EquivariantMap
section Stabilizer
variable (G : Type*) [Group G] {X : Type*} [MulAction G X]
open scoped BigOperators Pointwise
/-- A pretransitive action on a nontrivial type is preprimitive iff
the set of blocks containing a given element is a simple order -/
@[to_additive (attr := simp)
/-- A pretransitive action on a nontrivial type is preprimitive iff
the set of blocks containing a given element is a simple order -/]
theorem isSimpleOrder_blockMem_iff_isPreprimitive [IsPretransitive G X] [Nontrivial X] (a : X) :
IsSimpleOrder (BlockMem G a) ↔ IsPreprimitive G X := by
constructor
· intro h; let h_bot_or_top := h.eq_bot_or_eq_top
apply IsPreprimitive.of_isTrivialBlock_base a
intro B haB hB
rcases h_bot_or_top ⟨B, haB, hB⟩ with hB' | hB' <;>
simp only [← Subtype.coe_inj] at hB'
· left; rw [hB']; exact Set.subsingleton_singleton
· right; rw [hB']; rfl
· intro hGX'; apply IsSimpleOrder.mk
rintro ⟨B, haB, hB⟩
simp only [← Subtype.coe_inj]
cases hGX'.isTrivialBlock_of_isBlock hB with
| inl h =>
simp [BlockMem.coe_bot, h.eq_singleton_of_mem haB]
| inr h =>
simp [BlockMem.coe_top, h]
/-- A pretransitive action is preprimitive
iff the stabilizer of any point is a maximal subgroup (Wielandt, th. 7.5) -/
@[to_additive
/-- A pretransitive action is preprimitive
iff the stabilizer of any point is a maximal subgroup (Wielandt, th. 7.5) -/]
theorem isCoatom_stabilizer_iff_preprimitive [IsPretransitive G X] [Nontrivial X] (a : X) :
IsCoatom (stabilizer G a) ↔ IsPreprimitive G X := by
rw [← isSimpleOrder_blockMem_iff_isPreprimitive G a, ← Set.isSimpleOrder_Ici_iff_isCoatom]
simp only [isSimpleOrder_iff_isCoatom_bot]
rw [← OrderIso.isCoatom_iff (block_stabilizerOrderIso G a), OrderIso.map_bot]
/-- In a preprimitive action, stabilizers are maximal subgroups -/
@[to_additive /-- In a preprimitive action, stabilizers are maximal subgroups. -/]
theorem IsPreprimitive.isCoatom_stabilizer_of_isPreprimitive
[Nontrivial X] [IsPreprimitive G X] (a : X) :
IsCoatom (stabilizer G a) := by
rwa [isCoatom_stabilizer_iff_preprimitive]
end Stabilizer
section Normal
variable {M : Type*} [Group M] {α : Type*} [MulAction M α]
/-- In a preprimitive action, any normal subgroup that acts nontrivially is pretransitive
(Wielandt, th. 7.1). -/
@[to_additive /-- In a preprimitive additive action,
any normal subgroup that acts nontrivially is pretransitive (Wielandt, th. 7.1). -/]
-- See note [lower instance priority]
instance (priority := 100) IsPreprimitive.isQuasiPreprimitive [IsPreprimitive M α] :
IsQuasiPreprimitive M α where
isPretransitive_of_normal {N} _ hNX := by
rw [Set.ne_univ_iff_exists_notMem] at hNX
obtain ⟨a, ha⟩ := hNX
rw [isPretransitive_iff_orbit_eq_univ a]
apply Or.resolve_left (isTrivialBlock_of_isBlock (IsBlock.orbit_of_normal a))
intro h
apply ha
simp only [mem_fixedPoints]
intro n
rw [← Set.mem_singleton_iff]
suffices orbit N a = {a} by rw [← this]; use n
ext b
rw [Set.Subsingleton.eq_singleton_of_mem h (MulAction.mem_orbit_self a)]
end Normal
section Finite
namespace IsPreprimitive
variable {H Y : Type*} [Group H] [MulAction H Y]
/-- A pretransitive action on a set of prime order is preprimitive -/
@[to_additive /-- A pretransitive action on a set of prime order is preprimitive -/]
theorem of_prime_card [hGX : IsPretransitive G X] (hp : Nat.Prime (Nat.card X)) :
IsPreprimitive G X := by
refine ⟨fun {B} hB ↦ B.subsingleton_or_nontrivial.imp id fun hB' ↦ ?_⟩
have : Finite X := (Nat.card_ne_zero.mp hp.ne_zero).2
rw [Set.eq_univ_iff_ncard, eq_comm, ← hp.dvd_iff_eq ((Set.one_lt_ncard).mpr hB').ne']
exact hB.ncard_dvd_card hB'.nonempty
variable {φ : G → H} {f : X →ₑ[φ] Y}
/-- The codomain of an equivariant map of large image is preprimitive if the domain is. -/
@[to_additive
/-- The codomain of an equivariant map of large image is preprimitive if the domain is. -/]
theorem of_card_lt [Finite Y] [IsPretransitive H Y] [IsPreprimitive G X]
(hf' : Nat.card Y < 2 * (Set.range f).ncard) :
IsPreprimitive H Y := by
refine ⟨fun {B} hB ↦ ?_⟩
rcases B.eq_empty_or_nonempty with hB' | hB'; · simp [IsTrivialBlock, hB']
rw [IsTrivialBlock, or_iff_not_imp_right]
intro hB_ne_top
-- we need Set.Subsingleton B ↔ Set.ncard B ≤ 1
suffices Set.ncard B < 2 by simpa [Nat.lt_succ] using this
-- We reduce to proving that (Set.range f).ncard ≤ (orbit N B).ncard
apply lt_of_mul_lt_mul_right (lt_of_le_of_lt _ hf') (zero_le _)
simp only [← hB.ncard_block_mul_ncard_orbit_eq hB']
apply Nat.mul_le_mul_left
-- We reduce to proving that (Set.range f ∩ g • B).ncard ≤ 1 for every g
have hfin := Fintype.ofFinite (Set.range fun g : H ↦ g • B)
rw [(hB.isBlockSystem hB').left.ncard_eq_finsum, finsum_eq_sum_of_fintype]
apply le_trans (Finset.sum_le_card_nsmul _ _ 1 _)
· rw [nsmul_one, Finset.card_univ, ← Set.toFinset_card, ← Set.ncard_eq_toFinset_card',
orbit, Nat.cast_id]
· rintro ⟨x, ⟨g, rfl⟩⟩ -
suffices Set.Subsingleton (Set.range f ∩ g • B) by simpa
-- It suffices to prove that the preimage is subsingleton
rw [← Set.image_preimage_eq_range_inter]
apply Set.Subsingleton.image
-- Since the action of M on α is primitive, it suffices to prove that
-- the preimage is a block which is not ⊤
apply Or.resolve_right (isTrivialBlock_of_isBlock ((hB.translate g).preimage f))
intro h
simp only [Set.preimage_eq_univ_iff] at h
-- We will prove that B is large, which will contradict the assumption that it is not ⊤
apply hB_ne_top
apply hB.eq_univ_of_card_lt
-- It remains to show that Nat.card β < Set.ncard B * 2
apply lt_of_lt_of_le hf'
rw [mul_comm, mul_le_mul_iff_left₀ Nat.succ_pos']
apply le_trans (Set.ncard_le_ncard h) (Set.ncard_image_le B.toFinite)
/- The finiteness assumption is necessary :
For G = ℤ acting on itself, no translate of ℕ contains 0 but not 1.
(See comment before `IsBlock.of_subset`.) -/
/-- Theorem of Rudio (Wielandt, 1964, Th. 8.1)
For a preprimitive action, a subset which is neither empty nor full has a translate
which contains a given point and avoids another one. -/
@[to_additive /-- Theorem of Rudio (Wielandt, 1964, Th. 8.1)
For a preprimitive additive action, a subset which is neither empty nor full has a translate
which contains a given point and avoids another one. -/]
theorem exists_mem_smul_and_notMem_smul [IsPreprimitive G X]
{A : Set X} (hfA : A.Finite) (hA : A.Nonempty) (hA' : A ≠ .univ) {a b : X} (h : a ≠ b) :
∃ g : G, a ∈ g • A ∧ b ∉ g • A := by
let B := ⋂ (g : G) (_ : a ∈ g • A), g • A
suffices b ∉ B by
rw [Set.mem_iInter] at this
simpa only [Set.mem_iInter, not_forall, exists_prop] using this
suffices B = {a} by rw [this]; rw [Set.mem_singleton_iff]; exact Ne.symm h
-- B is a block hence is a trivial block
rcases isTrivialBlock_of_isBlock (G := G) (IsBlock.of_subset a hfA) with hyp | hyp
· -- B.subsingleton
apply Set.Subsingleton.eq_singleton_of_mem hyp
rw [Set.mem_iInter]; intro g; simp only [Set.mem_iInter, imp_self]
· -- B = Set.univ: contradiction
change B = Set.univ at hyp
exfalso; apply hA'
suffices ∃ g : G, a ∈ g • A by
obtain ⟨g, hg⟩ := this
have : B ⊆ g • A := Set.biInter_subset_of_mem hg
rw [hyp, Set.univ_subset_iff, ← eq_inv_smul_iff] at this
rw [this, Set.smul_set_univ]
-- ∃ (g : M), a ∈ g • A
obtain ⟨x, hx⟩ := hA
obtain ⟨g, hg⟩ := MulAction.exists_smul_eq G x a
use g, x
@[deprecated (since := "2025-05-23")]
alias _root_.AddAction.IsPreprimitive.exists_mem_vadd_and_not_mem_vadd :=
AddAction.IsPreprimitive.exists_mem_vadd_and_notMem_vadd
@[to_additive existing, deprecated (since := "2025-05-23")]
alias exists_mem_smul_and_not_mem_smul := exists_mem_smul_and_notMem_smul
end IsPreprimitive
end Finite
end MulAction |
.lake/packages/mathlib/Mathlib/GroupTheory/GroupAction/Hom.lean | import Mathlib.Algebra.Group.Hom.CompTypeclasses
import Mathlib.Algebra.Module.Defs
import Mathlib.Algebra.Notation.Prod
import Mathlib.Algebra.Regular.SMul
import Mathlib.Algebra.Ring.Action.Basic
/-!
# Equivariant homomorphisms
## Main definitions
* `MulActionHom φ X Y`, the type of equivariant functions from `X` to `Y`,
where `φ : M → N` is a map, `M` acting on the type `X` and `N` acting on the type of `Y`.
`AddActionHom φ X Y` is its additive version.
* `DistribMulActionHom φ A B`,
the type of equivariant additive monoid homomorphisms from `A` to `B`,
where `φ : M → N` is a morphism of monoids,
`M` acting on the additive monoid `A` and `N` acting on the additive monoid of `B`
* `SMulSemiringHom φ R S`, the type of equivariant ring homomorphisms
from `R` to `S`, where `φ : M → N` is a morphism of monoids,
`M` acting on the ring `R` and `N` acting on the ring `S`.
The above types have corresponding classes:
* `MulActionHomClass F φ X Y` states that `F` is a type of bundled `X → Y` homs
which are `φ`-equivariant;
`AddActionHomClass F φ X Y` is its additive version.
* `DistribMulActionHomClass F φ A B` states that `F` is a type of bundled `A → B` homs
preserving the additive monoid structure and `φ`-equivariant
* `SMulSemiringHomClass F φ R S` states that `F` is a type of bundled `R → S` homs
preserving the ring structure and `φ`-equivariant
## Notation
We introduce the following notation to code equivariant maps
(the subscript index `ₑ` is for *equivariant*) :
* `X →ₑ[φ] Y` is `MulActionHom φ X Y` and `AddActionHom φ X Y`
* `A →ₑ+[φ] B` is `DistribMulActionHom φ A B`.
* `R →ₑ+*[φ] S` is `MulSemiringActionHom φ R S`.
When `M = N` and `φ = MonoidHom.id M`, we provide the backward compatible notation :
* `X →[M] Y` is `MulActionHom (@id M) X Y` and `AddActionHom (@id M) X Y`
* `A →+[M] B` is `DistribMulActionHom (MonoidHom.id M) A B`
* `R →+*[M] S` is `MulSemiringActionHom (MonoidHom.id M) R S`
The notation for `MulActionHom` and `AddActionHom` is the same, because it is unlikely
that it could lead to confusion — unless one needs types `M` and `X` with simultaneous
instances of `Mul M`, `Add M`, `SMul M X` and `VAdd M X`…
-/
assert_not_exists Submonoid
section MulActionHom
variable {M' : Type*}
variable {M : Type*} {N : Type*} {P : Type*}
variable (φ : M → N) (ψ : N → P) (χ : M → P)
variable (X : Type*) [SMul M X] [SMul M' X]
variable (Y : Type*) [SMul N Y] [SMul M' Y]
variable (Z : Type*) [SMul P Z]
/-- Equivariant functions :
When `φ : M → N` is a function, and types `X` and `Y` are endowed with additive actions
of `M` and `N`, a function `f : X → Y` is `φ`-equivariant if `f (m +ᵥ x) = (φ m) +ᵥ (f x)`. -/
structure AddActionHom {M N : Type*} (φ : M → N) (X : Type*) [VAdd M X] (Y : Type*) [VAdd N Y] where
/-- The underlying function. -/
protected toFun : X → Y
/-- The proposition that the function commutes with the additive actions. -/
protected map_vadd' : ∀ (m : M) (x : X), toFun (m +ᵥ x) = (φ m) +ᵥ toFun x
/-- Equivariant functions :
When `φ : M → N` is a function, and types `X` and `Y` are endowed with actions of `M` and `N`,
a function `f : X → Y` is `φ`-equivariant if `f (m • x) = (φ m) • (f x)`. -/
@[to_additive]
structure MulActionHom where
/-- The underlying function. -/
protected toFun : X → Y
/-- The proposition that the function commutes with the actions. -/
protected map_smul' : ∀ (m : M) (x : X), toFun (m • x) = (φ m) • toFun x
/-- `φ`-equivariant functions `X → Y`,
where `φ : M → N`, where `M` and `N` act on `X` and `Y` respectively. -/
notation:25 (name := «MulActionHomLocal≺») X " →ₑ[" φ:25 "] " Y:0 => MulActionHom φ X Y
/-- `M`-equivariant functions `X → Y` with respect to the action of `M`.
This is the same as `X →ₑ[@id M] Y`. -/
notation:25 (name := «MulActionHomIdLocal≺») X " →[" M:25 "] " Y:0 => MulActionHom (@id M) X Y
/-- `φ`-equivariant functions `X → Y`,
where `φ : M → N`, where `M` and `N` act additively on `X` and `Y` respectively
We use the same notation as for multiplicative actions, as conflicts are unlikely. -/
notation:25 (name := «AddActionHomLocal≺») X " →ₑ[" φ:25 "] " Y:0 => AddActionHom φ X Y
/-- `M`-equivariant functions `X → Y` with respect to the additive action of `M`.
This is the same as `X →ₑ[@id M] Y`.
We use the same notation as for multiplicative actions, as conflicts are unlikely. -/
notation:25 (name := «AddActionHomIdLocal≺») X " →[" M:25 "] " Y:0 => AddActionHom (@id M) X Y
/-- `AddActionSemiHomClass F φ X Y` states that
`F` is a type of morphisms which are `φ`-equivariant.
You should extend this class when you extend `AddActionHom`. -/
class AddActionSemiHomClass (F : Type*)
{M N : outParam Type*} (φ : outParam (M → N))
(X Y : outParam Type*) [VAdd M X] [VAdd N Y] [FunLike F X Y] : Prop where
/-- The proposition that the function preserves the action. -/
map_vaddₛₗ : ∀ (f : F) (c : M) (x : X), f (c +ᵥ x) = (φ c) +ᵥ (f x)
/-- `MulActionSemiHomClass F φ X Y` states that
`F` is a type of morphisms which are `φ`-equivariant.
You should extend this class when you extend `MulActionHom`. -/
@[to_additive]
class MulActionSemiHomClass (F : Type*)
{M N : outParam Type*} (φ : outParam (M → N))
(X Y : outParam Type*) [SMul M X] [SMul N Y] [FunLike F X Y] : Prop where
/-- The proposition that the function preserves the action. -/
map_smulₛₗ : ∀ (f : F) (c : M) (x : X), f (c • x) = (φ c) • (f x)
export MulActionSemiHomClass (map_smulₛₗ)
export AddActionSemiHomClass (map_vaddₛₗ)
/-- `MulActionHomClass F M X Y` states that `F` is a type of
morphisms which are equivariant with respect to actions of `M`
This is an abbreviation of `MulActionSemiHomClass`. -/
@[to_additive /-- `MulActionHomClass F M X Y` states that `F` is a type of
morphisms which are equivariant with respect to actions of `M`
This is an abbreviation of `MulActionSemiHomClass`. -/]
abbrev MulActionHomClass (F : Type*) (M : outParam Type*)
(X Y : outParam Type*) [SMul M X] [SMul M Y] [FunLike F X Y] :=
MulActionSemiHomClass F (@id M) X Y
@[to_additive] instance : FunLike (MulActionHom φ X Y) X Y where
coe := MulActionHom.toFun
coe_injective' f g h := by cases f; cases g; congr
@[to_additive (attr := simp)]
theorem map_smul {F M X Y : Type*} [SMul M X] [SMul M Y]
[FunLike F X Y] [MulActionHomClass F M X Y]
(f : F) (c : M) (x : X) : f (c • x) = c • f x :=
map_smulₛₗ f c x
@[to_additive]
instance : MulActionSemiHomClass (X →ₑ[φ] Y) φ X Y where
map_smulₛₗ := MulActionHom.map_smul'
initialize_simps_projections MulActionHom (toFun → apply)
initialize_simps_projections AddActionHom (toFun → apply)
namespace MulActionHom
variable {φ X Y}
variable {F : Type*} [FunLike F X Y]
/-- Turn an element of a type `F` satisfying `MulActionSemiHomClass F φ X Y`
into an actual `MulActionHom`.
This is declared as the default coercion from `F` to `MulActionSemiHom φ X Y`. -/
@[to_additive (attr := coe)
/-- Turn an element of a type `F` satisfying `AddActionSemiHomClass F φ X Y`
into an actual `AddActionHom`.
This is declared as the default coercion from `F` to `AddActionSemiHom φ X Y`. -/]
def _root_.MulActionSemiHomClass.toMulActionHom [MulActionSemiHomClass F φ X Y] (f : F) :
X →ₑ[φ] Y where
toFun := DFunLike.coe f
map_smul' := map_smulₛₗ f
/-- Any type satisfying `MulActionSemiHomClass` can be cast into `MulActionHom` via
`MulActionHomSemiClass.toMulActionHom`. -/
@[to_additive]
instance [MulActionSemiHomClass F φ X Y] : CoeTC F (X →ₑ[φ] Y) :=
⟨MulActionSemiHomClass.toMulActionHom⟩
variable (M' X Y F) in
/-- If Y/X/M forms a scalar tower, any map X → Y preserving X-action also preserves M-action. -/
@[to_additive]
theorem _root_.IsScalarTower.smulHomClass [MulOneClass X] [SMul X Y] [IsScalarTower M' X Y]
[MulActionHomClass F X X Y] : MulActionHomClass F M' X Y where
map_smulₛₗ f m x := by
rw [← mul_one (m • x), ← smul_eq_mul, map_smul, smul_assoc, ← map_smul,
smul_eq_mul, mul_one, id_eq]
@[to_additive]
protected theorem map_smul (f : X →[M'] Y) (m : M') (x : X) : f (m • x) = m • f x :=
map_smul f m x
@[to_additive (attr := ext)]
theorem ext {f g : X →ₑ[φ] Y} :
(∀ x, f x = g x) → f = g :=
DFunLike.ext f g
@[to_additive]
protected theorem congr_fun {f g : X →ₑ[φ] Y} (h : f = g) (x : X) :
f x = g x :=
DFunLike.congr_fun h _
/-- Two equal maps on scalars give rise to an equivariant map for identity -/
@[to_additive /-- Two equal maps on scalars give rise to an equivariant map for identity -/]
def ofEq {φ' : M → N} (h : φ = φ') (f : X →ₑ[φ] Y) : X →ₑ[φ'] Y where
toFun := f.toFun
map_smul' m a := h ▸ f.map_smul' m a
@[to_additive (attr := simp)]
theorem ofEq_coe {φ' : M → N} (h : φ = φ') (f : X →ₑ[φ] Y) :
(f.ofEq h).toFun = f.toFun := rfl
@[to_additive (attr := simp)]
theorem ofEq_apply {φ' : M → N} (h : φ = φ') (f : X →ₑ[φ] Y) (a : X) :
(f.ofEq h) a = f a :=
rfl
lemma _root_.FaithfulSMul.of_injective
[FaithfulSMul M' X] [MulActionHomClass F M' X Y] (f : F)
(hf : Function.Injective f) :
FaithfulSMul M' Y where
eq_of_smul_eq_smul {_ _} h := eq_of_smul_eq_smul fun m ↦ hf <| by simp_rw [map_smul, h]
variable {ψ χ} (M N)
/-- The identity map as an equivariant map. -/
@[to_additive /-- The identity map as an equivariant map. -/]
protected def id : X →[M] X :=
⟨id, fun _ _ => rfl⟩
variable {M N Z}
@[to_additive (attr := simp)]
theorem id_apply (x : X) :
MulActionHom.id M x = x :=
rfl
end MulActionHom
namespace MulActionHom
open MulActionHom
variable {φ ψ χ X Y Z}
-- attribute [instance] CompTriple.id_comp CompTriple.comp_id
/-- Composition of two equivariant maps. -/
@[to_additive /-- Composition of two equivariant maps. -/]
def comp (g : Y →ₑ[ψ] Z) (f : X →ₑ[φ] Y) [κ : CompTriple φ ψ χ] :
X →ₑ[χ] Z :=
⟨g ∘ f, fun m x =>
calc
g (f (m • x)) = g (φ m • f x) := by rw [map_smulₛₗ]
_ = ψ (φ m) • g (f x) := by rw [map_smulₛₗ]
_ = (ψ ∘ φ) m • g (f x) := rfl
_ = χ m • g (f x) := by rw [κ.comp_eq] ⟩
@[to_additive (attr := simp)]
theorem comp_apply
(g : Y →ₑ[ψ] Z) (f : X →ₑ[φ] Y) [CompTriple φ ψ χ] (x : X) :
g.comp f x = g (f x) := rfl
@[to_additive (attr := simp)]
theorem id_comp (f : X →ₑ[φ] Y) :
(MulActionHom.id N).comp f = f :=
ext fun x => by rw [comp_apply, id_apply]
@[to_additive (attr := simp)]
theorem comp_id (f : X →ₑ[φ] Y) :
f.comp (MulActionHom.id M) = f :=
ext fun x => by rw [comp_apply, id_apply]
@[to_additive (attr := simp)]
theorem comp_assoc {Q T : Type*} [SMul Q T]
{η : P → Q} {θ : M → Q} {ζ : N → Q}
(h : Z →ₑ[η] T) (g : Y →ₑ[ψ] Z) (f : X →ₑ[φ] Y)
[CompTriple φ ψ χ] [CompTriple χ η θ]
[CompTriple ψ η ζ] [CompTriple φ ζ θ] :
h.comp (g.comp f) = (h.comp g).comp f :=
ext fun _ => rfl
variable {φ' : N → M}
variable {Y₁ : Type*} [SMul M Y₁]
/-- The inverse of a bijective equivariant map is equivariant. -/
@[to_additive (attr := simps) /-- The inverse of a bijective equivariant map is equivariant. -/]
def inverse (f : X →[M] Y₁) (g : Y₁ → X)
(h₁ : Function.LeftInverse g f) (h₂ : Function.RightInverse g f) : Y₁ →[M] X where
toFun := g
map_smul' m x :=
calc
g (m • x) = g (m • f (g x)) := by rw [h₂]
_ = g (f (m • g x)) := by simp only [map_smul]
_ = m • g x := by rw [h₁]
/-- The inverse of a bijective equivariant map is equivariant. -/
@[to_additive (attr := simps) /-- The inverse of a bijective equivariant map is equivariant. -/]
def inverse' (f : X →ₑ[φ] Y) (g : Y → X) (k : Function.RightInverse φ' φ)
(h₁ : Function.LeftInverse g f) (h₂ : Function.RightInverse g f) :
Y →ₑ[φ'] X where
toFun := g
map_smul' m x :=
calc
g (m • x) = g (m • f (g x)) := by rw [h₂]
_ = g ((φ (φ' m)) • f (g x)) := by rw [k]
_ = g (f (φ' m • g x)) := by rw [map_smulₛₗ]
_ = φ' m • g x := by rw [h₁]
@[to_additive]
lemma inverse_eq_inverse' (f : X →[M] Y₁) (g : Y₁ → X)
(h₁ : Function.LeftInverse g f) (h₂ : Function.RightInverse g f) :
inverse f g h₁ h₂ = inverse' f g (congrFun rfl) h₁ h₂ := by
rfl
@[to_additive]
theorem inverse'_inverse'
{f : X →ₑ[φ] Y} {g : Y → X}
{k₁ : Function.LeftInverse φ' φ} {k₂ : Function.RightInverse φ' φ}
{h₁ : Function.LeftInverse g f} {h₂ : Function.RightInverse g f} :
inverse' (inverse' f g k₂ h₁ h₂) f k₁ h₂ h₁ = f :=
ext fun _ => rfl
@[to_additive]
theorem comp_inverse' {f : X →ₑ[φ] Y} {g : Y → X}
{k₁ : Function.LeftInverse φ' φ} {k₂ : Function.RightInverse φ' φ}
{h₁ : Function.LeftInverse g f} {h₂ : Function.RightInverse g f} :
(inverse' f g k₂ h₁ h₂).comp f (κ := CompTriple.comp_inv k₁) = MulActionHom.id M := by
rw [MulActionHom.ext_iff]
intro x
simp only [comp_apply, id_apply]
exact h₁ x
@[to_additive]
theorem inverse'_comp {f : X →ₑ[φ] Y} {g : Y → X}
{k₂ : Function.RightInverse φ' φ}
{h₁ : Function.LeftInverse g f} {h₂ : Function.RightInverse g f} :
f.comp (inverse' f g k₂ h₁ h₂) (κ := CompTriple.comp_inv k₂) = MulActionHom.id N := by
rw [MulActionHom.ext_iff]
intro x
simp only [comp_apply, id_apply]
exact h₂ x
/-- If actions of `M` and `N` on `α` commute,
then for `c : M`, `(c • · : α → α)` is an `N`-action homomorphism. -/
@[to_additive (attr := simps) /-- If additive actions of `M` and `N` on `α` commute,
then for `c : M`, `(c • · : α → α)` is an `N`-additive action homomorphism. -/]
def _root_.SMulCommClass.toMulActionHom {M} (N α : Type*)
[SMul M α] [SMul N α] [SMulCommClass M N α] (c : M) :
α →[N] α where
toFun := (c • ·)
map_smul' := smul_comm _
end MulActionHom
end MulActionHom
/-- Evaluation at a point as a `MulActionHom`. -/
@[to_additive (attr := simps) /-- Evaluation at a point as an `AddActionHom`. -/]
def Pi.evalMulActionHom {ι M : Type*} {X : ι → Type*} [∀ i, SMul M (X i)] (i : ι) :
(∀ i, X i) →[M] X i where
toFun := Function.eval i
map_smul' _ _ := rfl
namespace MulActionHom
section FstSnd
variable {M α β : Type*} [SMul M α] [SMul M β]
variable (M α β) in
/-- `Prod.fst` as a bundled `MulActionHom`. -/
@[to_additive (attr := simps -fullyApplied) /-- `Prod.fst` as a bundled `AddActionHom`. -/]
def fst : α × β →[M] α where
toFun := Prod.fst
map_smul' _ _ := rfl
variable (M α β) in
/-- `Prod.snd` as a bundled `MulActionHom`. -/
@[to_additive (attr := simps -fullyApplied) /-- `Prod.snd` as a bundled `AddActionHom`. -/]
def snd : α × β →[M] β where
toFun := Prod.snd
map_smul' _ _ := rfl
end FstSnd
variable {M N α β γ δ : Type*} [SMul M α] [SMul M β] [SMul N γ] [SMul N δ] {σ : M → N}
/-- If `f` and `g` are equivariant maps, then so is `x ↦ (f x, g x)`. -/
@[to_additive (attr := simps -fullyApplied) prod
/-- If `f` and `g` are equivariant maps, then so is `x ↦ (f x, g x)`. -/]
def prod (f : α →ₑ[σ] γ) (g : α →ₑ[σ] δ) : α →ₑ[σ] γ × δ where
toFun x := (f x, g x)
map_smul' _ _ := Prod.ext (map_smulₛₗ f _ _) (map_smulₛₗ g _ _)
@[to_additive (attr := simp) fst_comp_prod]
lemma fst_comp_prod (f : α →ₑ[σ] γ) (g : α →ₑ[σ] δ) : (fst _ _ _).comp (prod f g) = f := rfl
@[to_additive (attr := simp) snd_comp_prod]
lemma snd_comp_prod (f : α →ₑ[σ] γ) (g : α →ₑ[σ] δ) : (snd _ _ _).comp (prod f g) = g := rfl
@[to_additive (attr := simp) prod_fst_snd]
lemma prod_fst_snd : prod (fst M α β) (snd M α β) = .id .. := rfl
/-- If `f` and `g` are equivariant maps, then so is `(x, y) ↦ (f x, g y)`. -/
@[to_additive (attr := simps -fullyApplied) prodMap
/-- If `f` and `g` are equivariant maps, then so is `(x, y) ↦ (f x, g y)`. -/]
def prodMap (f : α →ₑ[σ] γ) (g : β →ₑ[σ] δ) : α × β →ₑ[σ] γ × δ where
toFun := Prod.map f g
__ := (f.comp (fst ..)).prod (g.comp (snd ..))
end MulActionHom
namespace MulActionHom
section
variable {R M N X Y : Type*} {σ : M → N}
attribute [local simp] map_smulₛₗ smul_sub
@[to_additive]
instance [SMul M X] [SMul N Y] [SMul R Y] [SMulCommClass N R Y] :
SMul R (X →ₑ[σ] Y) where
smul h f := ⟨h • f, by simp [smul_comm _ h]⟩
@[to_additive (attr := simp, norm_cast)]
lemma coe_smul [SMul M X] [SMul N Y] [SMul R Y] [SMulCommClass N R Y] (f : X →ₑ[σ] Y) (r : R) :
⇑(r • f) = r • ⇑f := rfl
instance [SMul M X] [Zero Y] [SMulZeroClass N Y] :
Zero (X →ₑ[σ] Y) where
zero := ⟨0, by simp⟩
@[simp, norm_cast]
lemma coe_zero [SMul M X] [Zero Y] [SMulZeroClass N Y] : ⇑(0 : X →ₑ[σ] Y) = 0 := rfl
instance [SMul M X] [AddZeroClass Y] [DistribSMul N Y] :
AddZeroClass (X →ₑ[σ] Y) where
add f g := ⟨f + g, by simp [smul_add]⟩
zero_add _ := ext fun _ ↦ zero_add _
add_zero _ := ext fun _ ↦ add_zero _
@[simp, norm_cast]
lemma coe_add [SMul M X] [AddZeroClass Y] [DistribSMul N Y] (f g : X →ₑ[σ] Y) :
⇑(f + g) = ⇑f + ⇑g := rfl
instance [SMul M X] [AddMonoid Y] [DistribSMul N Y] :
AddMonoid (X →ₑ[σ] Y) where
add_assoc _ _ _ := ext fun _ ↦ add_assoc _ _ _
nsmul n f := n • f
nsmul_zero f := ext fun x ↦ AddMonoid.nsmul_zero (f x)
nsmul_succ n f := ext fun x ↦ AddMonoid.nsmul_succ n (f x)
instance [SMul M X] [AddCommMonoid Y] [DistribSMul N Y] :
AddCommMonoid (X →ₑ[σ] Y) where
add_comm _ _ := ext fun _ ↦ add_comm _ _
@[to_additive]
instance [SMul M X] [SMul N Y] [Monoid R] [MulAction R Y] [SMulCommClass N R Y] :
MulAction R (X →ₑ[σ] Y) where
one_smul _ := ext fun _ ↦ one_smul _ _
mul_smul _ _ _ := ext fun _ ↦ mul_smul _ _ _
instance [AddZeroClass Y] [SMul M X] [DistribSMul N Y] [DistribSMul R Y] [SMulCommClass N R Y] :
DistribSMul R (X →ₑ[σ] Y) where
smul_zero y := ext fun _ ↦ smul_zero y
smul_add y _ _ := ext fun _ ↦ smul_add y _ _
instance [AddMonoid Y] [Monoid R] [SMul M X] [DistribSMul N Y]
[DistribMulAction R Y] [SMulCommClass N R Y] :
DistribMulAction R (X →ₑ[σ] Y) where
__ := inferInstanceAs (MulAction _ _)
__ := inferInstanceAs (DistribSMul _ _)
instance [AddCommMonoid Y] [Semiring R] [SMul M X] [DistribSMul N Y]
[Module R Y] [SMulCommClass N R Y] :
Module R (X →ₑ[σ] Y) where
add_smul _ _ _ := ext fun _ ↦ add_smul _ _ _
zero_smul _ := ext fun _ ↦ zero_smul R _
instance [SMul M X] [AddGroup Y] [DistribSMul N Y] : AddGroup (X →ₑ[σ] Y) where
sub f g := ⟨f - g, by simp [smul_sub]⟩
neg f := ⟨-f, by simp⟩
neg_add_cancel f := ext fun _ ↦ neg_add_cancel _
sub_eq_add_neg _ _ := ext fun _ ↦ sub_eq_add_neg _ _
zsmul z f := z • f
zsmul_zero' f := ext fun x ↦ SubNegMonoid.zsmul_zero' _
zsmul_neg' _ _ := ext fun x ↦ SubNegMonoid.zsmul_neg' _ _
zsmul_succ' _ _ := ext fun x ↦ SubNegMonoid.zsmul_succ' _ _
@[simp, norm_cast]
lemma coe_neg [SMul M X] [AddGroup Y] [DistribSMul N Y] (f : X →ₑ[σ] Y) :
⇑(-f) = -⇑f := rfl
@[simp, norm_cast]
lemma coe_sub [SMul M X] [AddGroup Y] [DistribSMul N Y] (f g : X →ₑ[σ] Y) :
⇑(f - g) = ⇑f - ⇑g := rfl
instance [SMul M X] [AddCommGroup Y] [DistribSMul N Y] : AddCommGroup (X →ₑ[σ] Y) where
instance [SMul M X] [Monoid N] [Monoid Y] [MulDistribMulAction N Y] :
Monoid (X →ₑ[σ] Y) where
mul f g := ⟨f * g, by simp⟩
mul_assoc _ _ _ := ext fun x ↦ mul_assoc _ _ _
one := ⟨1, by simp⟩
one_mul _ := ext fun x ↦ one_mul _
mul_one _ := ext fun x ↦ mul_one _
@[simp, norm_cast]
lemma coe_mul [SMul M X] [Monoid N] [Monoid Y] [MulDistribMulAction N Y] (f g : X →ₑ[σ] Y) :
⇑(f * g) = ⇑f * ⇑g := rfl
@[simp, norm_cast]
lemma coe_one [SMul M X] [Monoid N] [Monoid Y] [MulDistribMulAction N Y] :
⇑(1 : X →ₑ[σ] Y) = 1 := rfl
instance [SMul M X] [Monoid N] [CommMonoid Y] [MulDistribMulAction N Y] :
CommMonoid (X →ₑ[σ] Y) where
mul_comm _ _ := ext fun _ ↦ mul_comm _ _
instance [SMul M X] [Monoid N] [Semiring Y] [MulSemiringAction N Y] :
Semiring (X →ₑ[σ] Y) where
__ := inferInstanceAs (Monoid _)
__ := inferInstanceAs (AddCommMonoid _)
zero_mul _ := ext fun x ↦ zero_mul _
mul_zero _ := ext fun x ↦ mul_zero _
left_distrib _ _ _ := ext fun x ↦ left_distrib _ _ _
right_distrib _ _ _ := ext fun x ↦ right_distrib _ _ _
instance [SMul M X] [Monoid N] [CommSemiring Y] [MulSemiringAction N Y] :
CommSemiring (X →ₑ[σ] Y) where
instance [SMul M X] [Monoid N] [Ring Y] [MulSemiringAction N Y] :
Ring (X →ₑ[σ] Y) where
instance [SMul M X] [Monoid N] [CommRing Y] [MulSemiringAction N Y] :
CommRing (X →ₑ[σ] Y) where
end
end MulActionHom
section DistribMulAction
variable {M : Type*} [Monoid M]
variable {N : Type*} [Monoid N]
variable {P : Type*} [Monoid P]
variable (φ : M →* N) (φ' : N →* M) (ψ : N →* P) (χ : M →* P)
variable (A : Type*) [AddMonoid A] [DistribMulAction M A]
variable (B : Type*) [AddMonoid B] [DistribMulAction N B]
variable (B₁ : Type*) [AddMonoid B₁] [DistribMulAction M B₁]
variable (C : Type*) [AddMonoid C] [DistribMulAction P C]
variable (A' : Type*) [AddGroup A'] [DistribMulAction M A']
variable (B' : Type*) [AddGroup B'] [DistribMulAction N B']
/-- Equivariant additive monoid homomorphisms. -/
structure DistribMulActionHom extends A →ₑ[φ] B, A →+ B
/-- Reinterpret an equivariant additive monoid homomorphism as an additive monoid homomorphism. -/
add_decl_doc DistribMulActionHom.toAddMonoidHom
/-- Reinterpret an equivariant additive monoid homomorphism as an equivariant function. -/
add_decl_doc DistribMulActionHom.toMulActionHom
@[inherit_doc]
notation:25 (name := «DistribMulActionHomLocal≺»)
A " →ₑ+[" φ:25 "] " B:0 => DistribMulActionHom φ A B
@[inherit_doc]
notation:25 (name := «DistribMulActionHomIdLocal≺»)
A " →+[" M:25 "] " B:0 => DistribMulActionHom (MonoidHom.id M) A B
-- QUESTION/TODO : Impose that `φ` is a morphism of monoids?
/-- `DistribMulActionSemiHomClass F φ A B` states that `F` is a type of morphisms
preserving the additive monoid structure and equivariant with respect to `φ`.
You should extend this class when you extend `DistribMulActionSemiHom`. -/
class DistribMulActionSemiHomClass (F : Type*)
{M N : outParam Type*} (φ : outParam (M → N))
(A B : outParam Type*)
[Monoid M] [Monoid N]
[AddMonoid A] [AddMonoid B] [DistribMulAction M A] [DistribMulAction N B]
[FunLike F A B] : Prop
extends MulActionSemiHomClass F φ A B, AddMonoidHomClass F A B
/-- `DistribMulActionHomClass F M A B` states that `F` is a type of morphisms preserving
the additive monoid structure and equivariant with respect to the action of `M`.
It is an abbreviation to `DistribMulActionHomClass F (MonoidHom.id M) A B`
You should extend this class when you extend `DistribMulActionHom`. -/
abbrev DistribMulActionHomClass (F : Type*) (M : outParam Type*)
(A B : outParam Type*) [Monoid M] [AddMonoid A] [AddMonoid B]
[DistribMulAction M A] [DistribMulAction M B] [FunLike F A B] :=
DistribMulActionSemiHomClass F (MonoidHom.id M) A B
namespace DistribMulActionHom
instance : FunLike (A →ₑ+[φ] B) A B where
coe m := m.toFun
coe_injective' f g h := by
rcases f with ⟨tF, _, _⟩; rcases g with ⟨tG, _, _⟩
cases tF; cases tG; congr
instance : DistribMulActionSemiHomClass (A →ₑ+[φ] B) φ A B where
map_smulₛₗ m := m.map_smul'
map_zero := DistribMulActionHom.map_zero'
map_add := DistribMulActionHom.map_add'
variable {φ φ' A B B₁}
variable {F : Type*} [FunLike F A B]
/-- Turn an element of a type `F` satisfying `MulActionHomClass F M X Y` into an actual
`MulActionHom`. This is declared as the default coercion from `F` to `MulActionHom M X Y`. -/
@[coe]
def _root_.DistribMulActionSemiHomClass.toDistribMulActionHom
[DistribMulActionSemiHomClass F φ A B]
(f : F) : A →ₑ+[φ] B :=
{ (f : A →+ B), (f : A →ₑ[φ] B) with }
/-- Any type satisfying `MulActionHomClass` can be cast into `MulActionHom`
via `MulActionHomClass.toMulActionHom`. -/
instance [DistribMulActionSemiHomClass F φ A B] : CoeTC F (A →ₑ+[φ] B) :=
⟨DistribMulActionSemiHomClass.toDistribMulActionHom⟩
/-- If `DistribMulAction` of `M` and `N` on `A` commute,
then for each `c : M`, `(c • ·)` is an `N`-action additive homomorphism. -/
@[simps]
def _root_.SMulCommClass.toDistribMulActionHom {M} (N A : Type*) [Monoid N] [AddMonoid A]
[DistribSMul M A] [DistribMulAction N A] [SMulCommClass M N A] (c : M) : A →+[N] A :=
{ SMulCommClass.toMulActionHom N A c,
DistribSMul.toAddMonoidHom _ c with
toFun := (c • ·) }
@[simp]
theorem toFun_eq_coe (f : A →ₑ+[φ] B) : f.toFun = f := rfl
@[norm_cast]
theorem coe_fn_coe (f : A →ₑ+[φ] B) : ⇑(f : A →+ B) = f :=
rfl
@[norm_cast]
theorem coe_fn_coe' (f : A →ₑ+[φ] B) : ⇑(f : A →ₑ[φ] B) = f :=
rfl
@[ext]
theorem ext {f g : A →ₑ+[φ] B} : (∀ x, f x = g x) → f = g :=
DFunLike.ext f g
protected theorem congr_fun {f g : A →ₑ+[φ] B} (h : f = g) (x : A) : f x = g x :=
DFunLike.congr_fun h _
theorem toMulActionHom_injective {f g : A →ₑ+[φ] B} (h : (f : A →ₑ[φ] B) = (g : A →ₑ[φ] B)) :
f = g := by
ext a
exact MulActionHom.congr_fun h a
theorem toAddMonoidHom_injective {f g : A →ₑ+[φ] B} (h : (f : A →+ B) = (g : A →+ B)) : f = g := by
ext a
exact DFunLike.congr_fun h a
protected theorem map_zero (f : A →ₑ+[φ] B) : f 0 = 0 :=
map_zero f
protected theorem map_add (f : A →ₑ+[φ] B) (x y : A) : f (x + y) = f x + f y :=
map_add f x y
protected theorem map_neg (f : A' →ₑ+[φ] B') (x : A') : f (-x) = -f x :=
map_neg f x
protected theorem map_sub (f : A' →ₑ+[φ] B') (x y : A') : f (x - y) = f x - f y :=
map_sub f x y
protected theorem map_smulₑ (f : A →ₑ+[φ] B) (m : M) (x : A) : f (m • x) = (φ m) • f x :=
map_smulₛₗ f m x
variable (M)
/-- The identity map as an equivariant additive monoid homomorphism. -/
protected def id : A →+[M] A :=
⟨MulActionHom.id _, rfl, fun _ _ => rfl⟩
@[simp]
theorem id_apply (x : A) : DistribMulActionHom.id M x = x := by
rfl
variable {M C ψ χ}
instance : Zero (A →ₑ+[φ] B) :=
⟨{ (0 : A →+ B) with map_smul' := fun m _ => by simp }⟩
instance : One (A →+[M] A) :=
⟨DistribMulActionHom.id M⟩
@[simp]
theorem coe_zero : ⇑(0 : A →ₑ+[φ] B) = 0 :=
rfl
@[simp]
theorem coe_one : ⇑(1 : A →+[M] A) = id :=
rfl
theorem zero_apply (a : A) : (0 : A →ₑ+[φ] B) a = 0 :=
rfl
theorem one_apply (a : A) : (1 : A →+[M] A) a = a :=
rfl
instance : Inhabited (A →ₑ+[φ] B) :=
⟨0⟩
/-- Composition of two equivariant additive monoid homomorphisms. -/
def comp (g : B →ₑ+[ψ] C) (f : A →ₑ+[φ] B) [κ : MonoidHom.CompTriple φ ψ χ] :
A →ₑ+[χ] C :=
{ MulActionHom.comp (g : B →ₑ[ψ] C) (f : A →ₑ[φ] B),
AddMonoidHom.comp (g : B →+ C) (f : A →+ B) with }
@[simp]
theorem comp_apply
(g : B →ₑ+[ψ] C) (f : A →ₑ+[φ] B) [MonoidHom.CompTriple φ ψ χ] (x : A) : g.comp f x = g (f x) :=
rfl
@[simp]
theorem id_comp (f : A →ₑ+[φ] B) : comp (DistribMulActionHom.id N) f = f :=
ext fun x => by rw [comp_apply, id_apply]
@[simp]
theorem comp_id (f : A →ₑ+[φ] B) : f.comp (DistribMulActionHom.id M) = f :=
ext fun x => by rw [comp_apply, id_apply]
@[simp]
theorem comp_assoc {Q D : Type*} [Monoid Q] [AddMonoid D] [DistribMulAction Q D]
{η : P →* Q} {θ : M →* Q} {ζ : N →* Q}
(h : C →ₑ+[η] D) (g : B →ₑ+[ψ] C) (f : A →ₑ+[φ] B)
[MonoidHom.CompTriple φ ψ χ] [MonoidHom.CompTriple χ η θ]
[MonoidHom.CompTriple ψ η ζ] [MonoidHom.CompTriple φ ζ θ] :
h.comp (g.comp f) = (h.comp g).comp f :=
ext fun _ => rfl
/-- The inverse of a bijective `DistribMulActionHom` is a `DistribMulActionHom`. -/
@[simps]
def inverse (f : A →+[M] B₁) (g : B₁ → A) (h₁ : Function.LeftInverse g f)
(h₂ : Function.RightInverse g f) : B₁ →+[M] A :=
{ (f : A →+ B₁).inverse g h₁ h₂, f.toMulActionHom.inverse g h₁ h₂ with toFun := g }
section Semiring
variable (R : Type*) [Semiring R] [MulSemiringAction M R]
variable (S : Type*) [Semiring S] [MulSemiringAction N S]
variable (T : Type*) [Semiring T] [MulSemiringAction P T]
variable {R S N'}
variable [AddMonoid N'] [DistribMulAction S N']
variable {σ : R →* S}
@[ext]
theorem ext_ring {f g : R →ₑ+[σ] N'} (h : f 1 = g 1) : f = g := by
ext x
rw [← mul_one x, ← smul_eq_mul, f.map_smulₑ, g.map_smulₑ, h]
end Semiring
end DistribMulActionHom
variable (R : Type*) [Semiring R] [MulSemiringAction M R]
variable (R' : Type*) [Ring R'] [MulSemiringAction M R']
variable (S : Type*) [Semiring S] [MulSemiringAction N S]
variable (S' : Type*) [Ring S'] [MulSemiringAction N S']
variable (T : Type*) [Semiring T] [MulSemiringAction P T]
/-- Equivariant ring homomorphisms. -/
structure MulSemiringActionHom extends R →ₑ+[φ] S, R →+* S
/-- Reinterpret an equivariant ring homomorphism as a ring homomorphism. -/
add_decl_doc MulSemiringActionHom.toRingHom
/-- Reinterpret an equivariant ring homomorphism as an equivariant additive monoid homomorphism. -/
add_decl_doc MulSemiringActionHom.toDistribMulActionHom
@[inherit_doc]
notation:25 (name := «MulSemiringActionHomLocal≺»)
R " →ₑ+*[" φ:25 "] " S:0 => MulSemiringActionHom φ R S
@[inherit_doc]
notation:25 (name := «MulSemiringActionHomIdLocal≺»)
R " →+*[" M:25 "] " S:0 => MulSemiringActionHom (MonoidHom.id M) R S
/-- `MulSemiringActionHomClass F φ R S` states that `F` is a type of morphisms preserving
the ring structure and equivariant with respect to `φ`.
You should extend this class when you extend `MulSemiringActionHom`. -/
class MulSemiringActionSemiHomClass (F : Type*)
{M N : outParam Type*} [Monoid M] [Monoid N]
(φ : outParam (M → N))
(R S : outParam Type*) [Semiring R] [Semiring S]
[DistribMulAction M R] [DistribMulAction N S] [FunLike F R S] : Prop
extends DistribMulActionSemiHomClass F φ R S, RingHomClass F R S
/-- `MulSemiringActionHomClass F M R S` states that `F` is a type of morphisms preserving
the ring structure and equivariant with respect to a `DistribMulAction`of `M` on `R` and `S` .
-/
abbrev MulSemiringActionHomClass
(F : Type*)
{M : outParam Type*} [Monoid M]
(R S : outParam Type*) [Semiring R] [Semiring S]
[DistribMulAction M R] [DistribMulAction M S] [FunLike F R S] :=
MulSemiringActionSemiHomClass F (MonoidHom.id M) R S
namespace MulSemiringActionHom
instance : FunLike (R →ₑ+*[φ] S) R S where
coe m := m.toFun
coe_injective' f g h := by
rcases f with ⟨⟨tF, _, _⟩, _, _⟩; rcases g with ⟨⟨tG, _, _⟩, _, _⟩
cases tF; cases tG; congr
instance : MulSemiringActionSemiHomClass (R →ₑ+*[φ] S) φ R S where
map_zero m := m.map_zero'
map_add m := m.map_add'
map_one := MulSemiringActionHom.map_one'
map_mul := MulSemiringActionHom.map_mul'
map_smulₛₗ m := m.map_smul'
variable {φ R S}
variable {F : Type*} [FunLike F R S]
/-- Turn an element of a type `F` satisfying `MulSemiringActionHomClass F M R S` into an actual
`MulSemiringActionHom`. This is declared as the default coercion from `F` to
`MulSemiringActionHom M X Y`. -/
@[coe]
def _root_.MulSemiringActionHomClass.toMulSemiringActionHom
[MulSemiringActionSemiHomClass F φ R S]
(f : F) : R →ₑ+*[φ] S :=
{ (f : R →+* S), (f : R →ₑ+[φ] S) with }
/-- Any type satisfying `MulSemiringActionHomClass` can be cast into `MulSemiringActionHom` via
`MulSemiringActionHomClass.toMulSemiringActionHom`. -/
instance [MulSemiringActionSemiHomClass F φ R S] :
CoeTC F (R →ₑ+*[φ] S) :=
⟨MulSemiringActionHomClass.toMulSemiringActionHom⟩
@[norm_cast]
theorem coe_fn_coe (f : R →ₑ+*[φ] S) : ⇑(f : R →+* S) = f :=
rfl
@[norm_cast]
theorem coe_fn_coe' (f : R →ₑ+*[φ] S) : ⇑(f : R →ₑ+[φ] S) = f :=
rfl
@[ext]
theorem ext {f g : R →ₑ+*[φ] S} : (∀ x, f x = g x) → f = g :=
DFunLike.ext f g
protected theorem map_zero (f : R →ₑ+*[φ] S) : f 0 = 0 :=
map_zero f
protected theorem map_add (f : R →ₑ+*[φ] S) (x y : R) : f (x + y) = f x + f y :=
map_add f x y
protected theorem map_neg (f : R' →ₑ+*[φ] S') (x : R') : f (-x) = -f x :=
map_neg f x
protected theorem map_sub (f : R' →ₑ+*[φ] S') (x y : R') : f (x - y) = f x - f y :=
map_sub f x y
protected theorem map_one (f : R →ₑ+*[φ] S) : f 1 = 1 :=
map_one f
protected theorem map_mul (f : R →ₑ+*[φ] S) (x y : R) : f (x * y) = f x * f y :=
map_mul f x y
protected theorem map_smulₛₗ (f : R →ₑ+*[φ] S) (m : M) (x : R) : f (m • x) = φ m • f x :=
map_smulₛₗ f m x
protected theorem map_smul [MulSemiringAction M S] (f : R →+*[M] S) (m : M) (x : R) :
f (m • x) = m • f x :=
map_smulₛₗ f m x
end MulSemiringActionHom
namespace MulSemiringActionHom
variable (M) {R}
/-- The identity map as an equivariant ring homomorphism. -/
protected def id : R →+*[M] R :=
⟨DistribMulActionHom.id _, rfl, (fun _ _ => rfl)⟩
@[simp]
theorem id_apply (x : R) : MulSemiringActionHom.id M x = x :=
rfl
end MulSemiringActionHom
namespace MulSemiringActionHom
open MulSemiringActionHom
variable {R S T}
variable {φ φ' ψ χ}
/-- Composition of two equivariant additive ring homomorphisms. -/
def comp (g : S →ₑ+*[ψ] T) (f : R →ₑ+*[φ] S) [κ : MonoidHom.CompTriple φ ψ χ] : R →ₑ+*[χ] T :=
{ DistribMulActionHom.comp (g : S →ₑ+[ψ] T) (f : R →ₑ+[φ] S),
RingHom.comp (g : S →+* T) (f : R →+* S) with }
@[simp]
theorem comp_apply (g : S →ₑ+*[ψ] T) (f : R →ₑ+*[φ] S) [MonoidHom.CompTriple φ ψ χ] (x : R) :
g.comp f x = g (f x) := rfl
@[simp]
theorem id_comp (f : R →ₑ+*[φ] S) : (MulSemiringActionHom.id N).comp f = f :=
ext fun x => by rw [comp_apply, id_apply]
@[simp]
theorem comp_id (f : R →ₑ+*[φ] S) : f.comp (MulSemiringActionHom.id M) = f :=
ext fun x => by rw [comp_apply, id_apply]
/-- The inverse of a bijective `MulSemiringActionHom` is a `MulSemiringActionHom`. -/
@[simps]
def inverse' (f : R →ₑ+*[φ] S) (g : S → R) (k : Function.RightInverse φ' φ)
(h₁ : Function.LeftInverse g f) (h₂ : Function.RightInverse g f) :
S →ₑ+*[φ'] R :=
{ (f : R →+ S).inverse g h₁ h₂,
(f : R →* S).inverse g h₁ h₂,
(f : R →ₑ[φ] S).inverse' g k h₁ h₂ with
toFun := g }
/-- The inverse of a bijective `MulSemiringActionHom` is a `MulSemiringActionHom`. -/
@[simps]
def inverse {S₁ : Type*} [Semiring S₁] [MulSemiringAction M S₁]
(f : R →+*[M] S₁) (g : S₁ → R)
(h₁ : Function.LeftInverse g f) (h₂ : Function.RightInverse g f) :
S₁ →+*[M] R :=
{ (f : R →+ S₁).inverse g h₁ h₂,
(f : R →* S₁).inverse g h₁ h₂,
f.toMulActionHom.inverse g h₁ h₂ with
toFun := g }
end MulSemiringActionHom
end DistribMulAction
lemma IsSMulRegular.of_injective {R M : Type*} [SMul R M]
{N F} [SMul R N] [FunLike F M N] [MulActionHomClass F R M N]
(f : F) {r : R} (h1 : Function.Injective f) (h2 : IsSMulRegular N r) :
IsSMulRegular M r := fun x y h3 => h1 <| h2 <|
(map_smulₛₗ f r x).symm.trans ((congrArg f h3).trans (map_smulₛₗ f r y)) |
.lake/packages/mathlib/Mathlib/GroupTheory/GroupAction/SubMulAction/OfStabilizer.lean | import Mathlib.GroupTheory.GroupAction.Basic
import Mathlib.GroupTheory.GroupAction.Embedding
import Mathlib.GroupTheory.GroupAction.SubMulAction
import Mathlib.SetTheory.Cardinal.Finite
import Mathlib.Data.Fin.Tuple.Embedding
/-! # The SubMulAction of the stabilizer of a point on the complement of that point
When a group `G` acts on a type `α`, the stabilizer of a point `a : α`
acts naturally on the complement of that point.
Such actions (as the similar one for the fixator of a set acting on the complement
of that set, defined in `Mathlib.GroupTheory.GroupAction.SubMulAction.OfFixingSubgroup`)
are useful to study the multiple transitivity of the group `G`,
since `n`-transitivity of `G` on `α` is equivalent to `n - 1`-transitivity
of `stabilizer G a` on the complement of `a`.
We define equivariant maps that relate various of these sub_mul_actions
and permit to manipulate them in a relatively smooth way.
* `SubMulAction.ofStabilizer a` : the action of `stabilizer G a` on `{a}ᶜ`
* `SubMulAction.Enat_card_ofStabilizer_eq_add_one`, `SubMulAction.nat_card_ofStabilizer_eq`
compute the cardinality of the `carrier` of that action.
Consider `a b : α` and `g : G` such that `hg : g • b = a`.
* `SubMulAction.conjMap hg` is the equivariant map
from `SubMulAction.ofStabilizer G a` to `SubMulAction.ofStabilizer G b`.
* `SubMulAction.ofStabilizer.isPretransitive_iff_conj hg` shows
that this actions are equivalently pretransitive or
* `SubMulAction.ofStabilizer.isMultiplyPretransitive_iff_conj hg` shows
that this actions are equivalently `n`-pretransitive for all `n : ℕ`.
* `SubMulAction.ofStabilizer.append` : given `x : Fin n ↪ ofStabilizer G a`,
append `a` to obtain `y : Fin n.succ ↪ α`
* `SubMulAction.ofStabilizer.isMultiplyPretransitive_iff` : is the action of `G` on `α`
is pretransitive, then it is `n.succ` pretransitive if and only if
the action of `stabilizer G a` on `ofStabilizer G a` is `n`-pretransitive.
-/
open scoped Pointwise
open MulAction Function.Embedding
namespace SubMulAction
variable (G : Type*) [Group G] {α : Type*} [MulAction G α]
/-- Action of the stabilizer of a point on the complement. -/
@[to_additive /-- Action of the stabilizer of a point on the complement. -/]
def ofStabilizer (a : α) : SubMulAction (stabilizer G a) α where
carrier := {a}ᶜ
smul_mem' g x := by
simp only [Set.mem_compl_iff, Set.mem_singleton_iff]
rw [not_imp_not, smul_eq_iff_eq_inv_smul]
intro hgx
apply symm
rw [hgx, ← smul_eq_iff_eq_inv_smul]
exact g.prop
@[to_additive]
theorem ofStabilizer_carrier (a : α) : (ofStabilizer G a).carrier = {a}ᶜ :=
rfl
@[to_additive]
theorem mem_ofStabilizer_iff (a : α) {x : α} : x ∈ ofStabilizer G a ↔ x ≠ a :=
Iff.rfl
@[to_additive]
theorem notMem_val_image {a : α} (t : Set (ofStabilizer G a)) :
a ∉ Subtype.val '' t := by
rintro ⟨b, hb⟩
exact b.prop (by simp [hb])
@[to_additive]
theorem neq_of_mem_ofStabilizer (a : α) {x : ofStabilizer G a} : ↑x ≠ a :=
x.prop
@[to_additive]
lemma ENat_card_ofStabilizer_add_one_eq (a : α) :
ENat.card (ofStabilizer G a) + 1 = ENat.card α := by
dsimp only [ENat.card]
rw [← Cardinal.mk_sum_compl {a}, map_add, add_comm, eq_comm]
congr
simp
@[deprecated (since := "2025-07-15")]
alias Enat_card_ofStabilizer_eq_add_one := ENat_card_ofStabilizer_add_one_eq
@[to_additive]
lemma nat_card_ofStabilizer_add_one_eq [Finite α] (a : α) :
Nat.card (ofStabilizer G a) + 1 = Nat.card α := by
dsimp only [Nat.card]
rw [← Cardinal.mk_sum_compl {a},
Cardinal.toNat_add Cardinal.mk_lt_aleph0 Cardinal.mk_lt_aleph0]
simp only [Cardinal.mk_fintype, Fintype.card_unique, Nat.cast_one, map_one, add_comm]
congr
@[deprecated (since := "2025-10-03")]
alias nat_card_ofStabilizer_eq_add_one := nat_card_ofStabilizer_add_one_eq
@[to_additive]
lemma nat_card_ofStabilizer_eq [Finite α] (a : α) :
Nat.card (ofStabilizer G a) = Nat.card α - 1 :=
Nat.eq_sub_of_add_eq (nat_card_ofStabilizer_add_one_eq G a)
variable {G}
/-- Conjugation induces an equivariant map between the SubAddAction of
the stabilizer of a point and that of its translate. -/
def _root_.SubAddAction.ofStabilizer.conjMap {G : Type*} [AddGroup G] {α : Type*} [AddAction G α]
{g : G} {a b : α} (hg : b = g +ᵥ a) :
AddActionHom (AddAction.stabilizerEquivStabilizer hg)
(SubAddAction.ofStabilizer G a) (SubAddAction.ofStabilizer G b) where
toFun x := ⟨g +ᵥ x.val, fun hy ↦ x.prop (by simpa [hg] using hy)⟩
map_vadd' := fun ⟨k, hk⟩ x ↦ by
simp [← SetLike.coe_eq_coe, AddAction.addSubgroup_vadd_def,
AddAction.stabilizerEquivStabilizer_apply, ← vadd_assoc]
/-- Conjugation induces an equivariant map between the SubMulAction of
the stabilizer of a point and that of its translate. -/
@[to_additive existing]
def ofStabilizer.conjMap {g : G} {a b : α} (hg : b = g • a) :
MulActionHom (stabilizerEquivStabilizer hg) (ofStabilizer G a) (ofStabilizer G b) where
toFun x := ⟨g • x.val, fun hy ↦ x.prop (by simpa [hg] using hy)⟩
map_smul' := fun ⟨k, hk⟩ ↦ by
simp [← SetLike.coe_eq_coe, subgroup_smul_def, stabilizerEquivStabilizer, ← smul_assoc]
variable {g h k : G} {a b c : α}
variable (hg : b = g • a) (hh : c = h • b) (hk : c = k • a)
@[to_additive]
theorem ofStabilizer.conjMap_apply (x : ofStabilizer G a) :
(conjMap hg x : α) = g • x := rfl
theorem _root_.AddAction.stabilizerEquivStabilizer_compTriple
{G : Type*} [AddGroup G] {α : Type*} [AddAction G α]
{g h k : G} {a b c : α} {hg : b = g +ᵥ a} {hh : c = h +ᵥ b} {hk : c = k +ᵥ a} (H : k = h + g) :
CompTriple (AddAction.stabilizerEquivStabilizer hg)
(AddAction.stabilizerEquivStabilizer hh) (AddAction.stabilizerEquivStabilizer hk) where
comp_eq := by
ext
simp [AddAction.stabilizerEquivStabilizer, H, AddAut.conj, ← add_assoc]
variable {hg hh hk} in
@[to_additive existing]
theorem _root_.MulAction.stabilizerEquivStabilizer_compTriple (H : k = h * g) :
CompTriple (stabilizerEquivStabilizer hg)
(stabilizerEquivStabilizer hh) (stabilizerEquivStabilizer hk) where
comp_eq := by
ext
simp [stabilizerEquivStabilizer, H, MulAut.conj, ← mul_assoc]
variable {hg hh hk} in
@[to_additive]
theorem ofStabilizer.conjMap_comp_apply (H : k = h * g) (x : ofStabilizer G a) :
conjMap hh (conjMap hg x) = conjMap hk x := by
simp [← Subtype.coe_inj, conjMap_apply, H, mul_smul]
@[to_additive]
theorem ofStabilizer.conjMap_comp_inv_apply (x : ofStabilizer G a) :
(conjMap (eq_inv_smul_iff.mpr hg.symm)) (conjMap hg x) = x := by
simp [← Subtype.coe_inj, conjMap_apply]
@[to_additive]
theorem ofStabilizer.inv_conjMap_comp_apply (x : ofStabilizer G b) :
conjMap hg (conjMap (eq_inv_smul_iff.mpr hg.symm) x) = x := by
simp [← Subtype.coe_inj, conjMap_apply]
@[to_additive]
theorem ofStabilizer.conjMap_comp (H : k = h * g) :
(conjMap hh).comp (conjMap hg) (κ := stabilizerEquivStabilizer_compTriple H) = conjMap hk := by
ext x
simpa using conjMap_comp_apply H x
@[to_additive]
theorem ofStabilizer.conjMap_bijective : Function.Bijective (conjMap hg) := by
constructor
· rintro ⟨x, hx⟩ ⟨y, hy⟩ hxy
simp only [Subtype.mk_eq_mk]
apply (MulAction.injective g)
rwa [← SetLike.coe_eq_coe, conjMap_apply] at hxy
· intro x
exact ⟨conjMap _ x, inv_conjMap_comp_apply _ x⟩
/-- Append `a` to `x : Fin n ↪ ofStabilizer G a` to get an element of `Fin n.succ ↪ α`. -/
@[to_additive
/-- Append `a` to `x : Fin n ↪ ofStabilizer G a` to get an element of `Fin n.succ ↪ α`. -/]
def ofStabilizer.snoc {n : ℕ} (x : Fin n ↪ ofStabilizer G a) :
Fin n.succ ↪ α :=
Fin.Embedding.snoc (x.trans (subtype _)) (a := a) (by
simp [Set.mem_range, trans_apply, not_exists]
exact fun i ↦ (x i).prop)
@[to_additive]
theorem ofStabilizer.snoc_castSucc {n : ℕ} (x : Fin n ↪ ofStabilizer G a) (i : Fin n) :
snoc x i.castSucc = x i := by
simp [snoc]
@[to_additive]
theorem ofStabilizer.snoc_last {n : ℕ} (x : Fin n ↪ ofStabilizer G a) :
snoc x (Fin.last n) = a := by
simp [snoc]
variable (G) in
@[to_additive]
lemma exists_smul_of_last_eq [IsPretransitive G α] {n : ℕ} (a : α) (x : Fin n.succ ↪ α) :
∃ (g : G) (y : Fin n ↪ ofStabilizer G a), g • x = ofStabilizer.snoc y := by
obtain ⟨g, hgx⟩ := exists_smul_eq G (x (Fin.last n)) a
have H : ∀ i, Fin.Embedding.init (g • x) i ∈ ofStabilizer G a := fun i ↦ by
simp only [mem_ofStabilizer_iff,
Nat.succ_eq_add_one, ← hgx, ← smul_apply, ne_eq]
suffices Fin.Embedding.init (g • x) i = (g • x) i.castSucc by
simp [this]
simp [Fin.Embedding.init, Fin.init_def]
use g, (Fin.Embedding.init (g • x)).codRestrict (ofStabilizer G a) H
ext i
rcases Fin.eq_castSucc_or_eq_last i with ⟨i, rfl⟩ | ⟨rfl⟩
· simpa [ofStabilizer.snoc] using
Subtype.eq_iff.mp <| Function.Embedding.codRestrict_apply _ _ H i
· simpa only [smul_apply, ofStabilizer.snoc, Fin.Embedding.snoc_last]
end SubMulAction
section Pointwise
open MulAction Set
variable (G : Type*) [Group G] (α : Type*) [MulAction G α]
/-- The stabilizer of a set acts on that set. -/
@[to_additive /-- The stabilizer of a set acts on that set. -/]
instance _root_.SMul.ofStabilizer (s : Set α) :
SMul (stabilizer G s) s where
smul g x := ⟨g • ↑x, by
convert Set.smul_mem_smul_set x.prop
exact (mem_stabilizer_iff.mp g.prop).symm⟩
@[simp]
theorem _root_.SMul.smul_stabilizer_def (s : Set α) (g : stabilizer G s) (x : s) :
((g • x : ↥s) : α) = (g : G) • (x : α) :=
rfl
/-- The stabilizer of a set acts on that set -/
@[to_additive /-- The stabilizer of a set acts on that set. -/]
instance (s : Set α) : MulAction (stabilizer G s) s where
one_smul x := by
simp only [← Subtype.coe_inj, SMul.smul_stabilizer_def, OneMemClass.coe_one, one_smul]
mul_smul g k x := by
simp only [← Subtype.coe_inj, SMul.smul_stabilizer_def, Subgroup.coe_mul,
MulAction.mul_smul]
theorem stabilizer_empty_eq_top :
stabilizer G (∅ : Set α) = ⊤ := by
aesop
theorem stabilizer_univ_eq_top :
stabilizer G (Set.univ : Set α) = ⊤ := by
aesop
/-- The stabilizer of the complement is the stabilizer of the set. -/
@[simp]
theorem stabilizer_compl {s : Set α} :
stabilizer G sᶜ = stabilizer G s := by
have (s : Set α) : stabilizer G s ≤ stabilizer G (sᶜ) := by
intro g h
simp [Set.smul_set_compl, mem_stabilizer_iff.1 h]
refine le_antisymm (le_of_le_of_eq (this _) ?_) (this _)
rw [compl_compl]
end Pointwise |
.lake/packages/mathlib/Mathlib/GroupTheory/GroupAction/SubMulAction/Pointwise.lean | import Mathlib.GroupTheory.GroupAction.SubMulAction
import Mathlib.Algebra.Group.Pointwise.Set.Basic
/-!
# Pointwise monoid structures on SubMulAction
This file provides `SubMulAction.Monoid` and weaker typeclasses, which show that `SubMulAction`s
inherit the same pointwise multiplications as sets.
To match `Submodule.idemSemiring`, we do not put these in the `Pointwise` locale.
-/
open Pointwise
variable {R M : Type*}
namespace SubMulAction
section One
variable [Monoid R] [MulAction R M] [One M]
instance : One (SubMulAction R M) where
one :=
{ carrier := Set.range fun r : R => r • (1 : M)
smul_mem' := fun r _ ⟨r', hr'⟩ => hr' ▸ ⟨r * r', mul_smul _ _ _⟩ }
theorem coe_one : ↑(1 : SubMulAction R M) = Set.range fun r : R => r • (1 : M) :=
rfl
@[simp]
theorem mem_one {x : M} : x ∈ (1 : SubMulAction R M) ↔ ∃ r : R, r • (1 : M) = x :=
Iff.rfl
theorem subset_coe_one : (1 : Set M) ⊆ (1 : SubMulAction R M) := fun _ hx =>
⟨1, (one_smul _ _).trans hx.symm⟩
end One
section Mul
variable [Monoid R] [MulAction R M] [Mul M] [IsScalarTower R M M]
instance : Mul (SubMulAction R M) where
mul p q :=
{ carrier := Set.image2 (· * ·) p q
smul_mem' := fun r _ ⟨m₁, hm₁, m₂, hm₂, h⟩ =>
h ▸ smul_mul_assoc r m₁ m₂ ▸ Set.mul_mem_mul (p.smul_mem _ hm₁) hm₂ }
@[norm_cast]
theorem coe_mul (p q : SubMulAction R M) : ↑(p * q) = (p * q : Set M) :=
rfl
theorem mem_mul {p q : SubMulAction R M} {x : M} : x ∈ p * q ↔ ∃ y ∈ p, ∃ z ∈ q, y * z = x :=
Set.mem_mul
end Mul
section MulOneClass
variable [Monoid R] [MulAction R M] [MulOneClass M] [IsScalarTower R M M] [SMulCommClass R M M]
instance : MulOneClass (SubMulAction R M) where
mul_one a := by
ext x
simp only [mem_mul, mem_one, mul_smul_comm, exists_exists_eq_and, mul_one]
constructor
· rintro ⟨y, hy, r, rfl⟩
exact smul_mem _ _ hy
· intro hx
exact ⟨x, hx, 1, one_smul _ _⟩
one_mul a := by
ext x
simp only [mem_mul, mem_one, smul_mul_assoc, exists_exists_eq_and, one_mul]
refine ⟨?_, fun hx => ⟨1, x, hx, one_smul _ _⟩⟩
rintro ⟨r, y, hy, rfl⟩
exact smul_mem _ _ hy
@[deprecated (since := "04-06-2025")] alias mulOneClass := instMulOneClass
end MulOneClass
section Semigroup
variable [Monoid R] [MulAction R M] [Semigroup M] [IsScalarTower R M M]
instance : Semigroup (SubMulAction R M) where
mul_assoc _ _ _ := SetLike.coe_injective (mul_assoc (_ : Set _) _ _)
@[deprecated (since := "04-06-2025")] alias semiGroup := instSemigroup
end Semigroup
section Monoid
variable [Monoid R] [MulAction R M] [Monoid M] [IsScalarTower R M M] [SMulCommClass R M M]
instance : Monoid (SubMulAction R M) := { }
theorem coe_pow (p : SubMulAction R M) : ∀ {n : ℕ} (_ : n ≠ 0), ↑(p ^ n) = (p : Set M) ^ n
| 0, hn => (hn rfl).elim
| 1, _ => by rw [pow_one, pow_one]
| n + 2, _ => by
rw [pow_succ _ (n + 1), pow_succ _ (n + 1), coe_mul, coe_pow _ n.succ_ne_zero]
theorem subset_coe_pow (p : SubMulAction R M) : ∀ {n : ℕ}, (p : Set M) ^ n ⊆ ↑(p ^ n)
| 0 => by
rw [pow_zero, pow_zero]
exact subset_coe_one
| n + 1 => by rw [← Nat.succ_eq_add_one, coe_pow _ n.succ_ne_zero]
end Monoid
end SubMulAction |
.lake/packages/mathlib/Mathlib/GroupTheory/GroupAction/SubMulAction/Closure.lean | import Mathlib.Data.Set.Finite.Basic
import Mathlib.Data.Set.Lattice
import Mathlib.GroupTheory.GroupAction.SubMulAction
/-!
# Closure and finiteness of `SubMulAction` and `SubAddAction`
-/
namespace SubMulAction
/-- The `SubMulAction` generated by a set `s`. -/
@[to_additive /-- The `SubAddAction` generated by a set `s`. -/]
def closure (R : Type*) {M : Type*} [SMul R M] (s : Set M) : SubMulAction R M :=
sInf { p | s ⊆ (p : Set M) }
variable {R M : Type*} [SMul R M] {s t : Set M} {x : M}
@[to_additive]
theorem mem_closure : x ∈ closure R s ↔ ∀ p : SubMulAction R M, s ⊆ p → x ∈ p :=
Set.mem_iInter₂
@[to_additive]
theorem subset_closure : s ⊆ closure R s := fun _ h => mem_closure.2 fun _ hp => hp h
@[to_additive]
theorem mem_closure_of_mem (hx : x ∈ s) : x ∈ closure R s := subset_closure hx
@[to_additive]
theorem closure_le {p} : closure R s ≤ p ↔ s ⊆ p :=
⟨subset_closure.trans, fun ss _ h => mem_closure.1 h _ ss⟩
@[to_additive (attr := gcongr)]
theorem closure_mono (h : s ⊆ t) : closure R s ≤ closure R t :=
closure_le.2 <| h.trans subset_closure
/-- A `SubMulAction` is finitely generated if it is the closure of a finite set. -/
@[to_additive /-- A `SubAddAction` is finitely generated if it is the closure of a finite set. -/]
def FG (p : SubMulAction R M) :=
∃ (s : Set M), s.Finite ∧ p = closure R s
@[to_additive]
theorem fg_iff {p : SubMulAction R M} : p.FG ↔ ∃ (s : Finset M), p = closure R s :=
Set.exists_finite_iff_finset
end SubMulAction |
.lake/packages/mathlib/Mathlib/GroupTheory/GroupAction/SubMulAction/OfFixingSubgroup.lean | import Mathlib.Algebra.Group.Pointwise.Set.Card
import Mathlib.GroupTheory.GroupAction.FixingSubgroup
import Mathlib.GroupTheory.GroupAction.SubMulAction.OfStabilizer
import Mathlib.GroupTheory.GroupAction.Transitive
import Mathlib.GroupTheory.GroupAction.Primitive
import Mathlib.Tactic.Group
/-!
# SubMulActions on complements of invariant subsets
- We define `SubMulAction` of an invariant subset in various contexts,
especially stabilizers and fixing subgroups : `SubMulAction_of_compl`,
`SubMulAction_of_stabilizer`, `SubMulAction_of_fixingSubgroup`.
- We define equivariant maps that relate various of these `SubMulAction`s
and permit to manipulate them in a relatively smooth way:
* `SubMulAction.ofFixingSubgroupEmpty_equivariantMap`:
the identity map, when the set is the empty set.
* `SubMulAction.fixingSubgroupInsertEquiv M a s` : the
multiplicative equivalence between `fixingSubgroup M (insert a s)`
and `fixingSubgroup (stabilizer M a) s`
* `SubMulAction.ofFixingSubgroup_insert_map` : the equivariant
map between `SubMulAction.ofFixingSubgroup M (insert a s)`
and `SubMulAction.ofFixingSubgroup (stabilizer M a) s`.
* `SubMulAction.fixingSubgroupEquivFixingSubgroup`:
the multiplicative equivalence between `SubMulAction.fixingSubgroup M s`
and `SubMulAction.fixingSubgroup M t` induced by `g : M`
such that `g • t = s`.
* `SubMulAction.conjMap_ofFixingSubgroup`:
the equivariant map between `SubMulAction.ofFixingSubgroup M t`
and `SubMulAction.ofFixingSubgroup M s`
induced by `g : M` such that `g • t = s`.
* `SubMulAction.ofFixingSubgroup_of_inclusion`:
the identity from `SubMulAction.ofFixingSubgroup M s`
to `SubMulAction.ofFixingSubgroup M t`, when `t ⊆ s`,
as an equivariant map.
* `SubMulAction.ofFixingSubgroup_of_singleton`:
the identity map from `SubMulAction.ofStabilizer M a`
to `SubMulAction.ofFixingSubgroup M {a}`.
* `SubMulAction.ofFixingSubgroup_of_eq`:
the identity from `SubMulAction.ofFixingSubgroup M s`
to `SubMulAction.ofFixingSubgroup M t`, when `s = t`,
as an equivariant map.
* `SubMulAction.ofFixingSubgroup.append`: appends
an enumeration of `ofFixingSubgroup M s` at the end
of an enumeration of `s`, as an equivariant map.
-/
open scoped Pointwise
open MulAction Function
namespace SubMulAction
variable (M : Type*) {α : Type*} [Group M] [MulAction M α] (s : Set α)
/-- The `SubMulAction` of `fixingSubgroup M s` on the complement of `s`. -/
@[to_additive /-- The `SubAddAction` of `fixingAddSubgroup M s` on the complement of `s`. -/]
def ofFixingSubgroup : SubMulAction (fixingSubgroup M s) α where
carrier := sᶜ
smul_mem' := fun ⟨c, hc⟩ x ↦ by
rw [← Subgroup.inv_mem_iff] at hc
simp only [Set.mem_compl_iff, not_imp_not]
intro hcx
rwa [← one_smul M x, ← inv_mul_cancel c, mul_smul, (mem_fixingSubgroup_iff M).mp hc (c • x) hcx]
@[to_additive (attr := simp)]
theorem ofFixingSubgroup_carrier :
(ofFixingSubgroup M s).carrier = sᶜ := rfl
variable {s}
@[to_additive]
theorem mem_ofFixingSubgroup_iff {x : α} :
x ∈ ofFixingSubgroup M s ↔ x ∉ s :=
Iff.rfl
variable {M}
@[to_additive]
theorem not_mem_of_mem_ofFixingSubgroup (x : ofFixingSubgroup M s) :
↑x ∉ s := x.prop
@[to_additive]
theorem disjoint_val_image {t : Set (ofFixingSubgroup M s)} :
Disjoint s (Subtype.val '' t) := by
rw [Set.disjoint_iff]
rintro a ⟨hbs, ⟨b, _, rfl⟩⟩; exact (b.prop hbs).elim
variable (M s) in
/-- The identity map of the `SubMulAction` of the `fixingSubgroup`
into the ambient set, as an equivariant map. -/
@[to_additive
/-- The identity map of the `SubAddAction` of the `fixingAddSubgroup`
into the ambient set, as an equivariant map. -/]
def ofFixingSubgroup_equivariantMap :
ofFixingSubgroup M s →ₑ[(fixingSubgroup M s).subtype] α where
toFun x := x
map_smul' _ _ := rfl
@[to_additive]
theorem ofFixingSubgroup_equivariantMap_injective :
Injective (ofFixingSubgroup_equivariantMap M s) := by
rintro ⟨x, hx⟩ ⟨y, hy⟩ hxy
simpa [Subtype.mk.injEq] using hxy
section Comparisons
section Empty
@[to_additive]
theorem ofFixingSubgroupEmpty_equivariantMap_bijective :
Bijective (ofFixingSubgroup_equivariantMap M (∅ : Set α)) := by
refine ⟨ofFixingSubgroup_equivariantMap_injective, fun x ↦ ?_⟩
exact ⟨⟨x, (mem_ofFixingSubgroup_iff M).mp (Set.notMem_empty x)⟩, rfl⟩
@[to_additive]
theorem of_fixingSubgroupEmpty_mapScalars_surjective :
Surjective (fixingSubgroup M (∅ : Set α)).subtype :=
fun g ↦ ⟨⟨g, by simp⟩, rfl⟩
end Empty
section FixingSubgroupInsert
@[to_additive]
theorem mem_fixingSubgroup_insert_iff {a : α} {s : Set α} {m : M} :
m ∈ fixingSubgroup M (insert a s) ↔ m • a = a ∧ m ∈ fixingSubgroup M s := by
simp [mem_fixingSubgroup_iff]
@[to_additive]
theorem fixingSubgroup_of_insert (a : α) (s : Set (ofStabilizer M a)) :
fixingSubgroup M (insert a ((fun x ↦ x.val) '' s)) =
(fixingSubgroup (↥(stabilizer M a)) s).map (stabilizer M a).subtype := by
ext m
simp [mem_fixingSubgroup_iff, mem_ofStabilizer_iff, subgroup_smul_def, and_comm]
@[to_additive]
theorem mem_ofFixingSubgroup_insert_iff {a : α} {s : Set (ofStabilizer M a)} {x : α} :
x ∈ ofFixingSubgroup M (insert a ((fun x ↦ x.val) '' s)) ↔
∃ (hx : x ∈ ofStabilizer M a),
(⟨x, hx⟩ : ofStabilizer M a) ∈ ofFixingSubgroup (stabilizer M a) s := by
simp_rw [mem_ofFixingSubgroup_iff, mem_ofStabilizer_iff]
aesop
/-- The natural group isomorphism between fixing subgroups. -/
@[to_additive /-- The natural additive group isomorphism between fixing additive subgroups. -/]
def fixingSubgroupInsertEquiv (a : α) (s : Set (ofStabilizer M a)) :
fixingSubgroup M (insert a (Subtype.val '' s)) ≃* fixingSubgroup (stabilizer M a) s where
toFun m := ⟨⟨(m : M), (mem_fixingSubgroup_iff M).mp m.prop a (Set.mem_insert _ _)⟩,
fun ⟨x, hx⟩ => by
simp only [← SetLike.coe_eq_coe]
refine (mem_fixingSubgroup_iff M).mp m.prop _ (Set.mem_insert_of_mem a ?_)
exact ⟨⟨x, (SubMulAction.mem_ofStabilizer_iff M a).mp x.prop⟩, hx, rfl⟩⟩
map_mul' _ _ := by simp [← Subtype.coe_inj]
invFun m := ⟨m, by simp [fixingSubgroup_of_insert]⟩
left_inv _ := by simp
right_inv _ := by simp
/-- The identity map of fixing subgroup of stabilizer
into the fixing subgroup of the extended set, as an equivariant map. -/
@[to_additive /-- The identity map of fixing additive subgroup of stabilizer
into the fixing additive subgroup of the extended set, as an equivariant map. -/]
def ofFixingSubgroup_insert_map (a : α) (s : Set (ofStabilizer M a)) :
ofFixingSubgroup M (insert a (Subtype.val '' s))
→ₑ[fixingSubgroupInsertEquiv a s]
ofFixingSubgroup (stabilizer M a) s where
toFun x := by
choose hx hx' using (mem_ofFixingSubgroup_insert_iff.mp x.prop)
exact ⟨_, hx'⟩
map_smul' _ _ := rfl
@[to_additive (attr := simp)]
theorem ofFixingSubgroup_insert_map_apply {a : α} {s : Set (ofStabilizer M a)}
{x : α} (hx : x ∈ ofFixingSubgroup M (insert a (Subtype.val '' s))) :
(ofFixingSubgroup_insert_map a s) ⟨x, hx⟩ = x :=
rfl
@[to_additive]
theorem ofFixingSubgroup_insert_map_bijective {a : α} {s : Set (ofStabilizer M a)} :
Bijective (ofFixingSubgroup_insert_map a s) := by
constructor
· rintro ⟨x, hx⟩ ⟨y, hy⟩ h
simpa only [← Subtype.coe_inj, ofFixingSubgroup_insert_map_apply] using h
· rintro ⟨⟨x, hx1⟩, hx2⟩
exact ⟨⟨x, mem_ofFixingSubgroup_insert_iff.mpr ⟨hx1, hx2⟩⟩, rfl⟩
end FixingSubgroupInsert
section FixingSubgroupConj
variable {s t : Set α} {g : M}
@[to_additive]
theorem _root_.Set.conj_mem_fixingSubgroup (hg : g • t = s) {k : M} (hk : k ∈ fixingSubgroup M t) :
MulAut.conj g k ∈ fixingSubgroup M s := by
simp only [mem_fixingSubgroup_iff] at hk ⊢
intro y hy
rw [MulAut.conj_apply, eq_comm, mul_smul, mul_smul, ← inv_smul_eq_iff, eq_comm]
apply hk
rw [← Set.mem_smul_set_iff_inv_smul_mem, hg]
exact hy
@[to_additive]
theorem fixingSubgroup_map_conj_eq (hg : g • t = s) :
(fixingSubgroup M t).map (MulAut.conj g).toMonoidHom = fixingSubgroup M s := by
ext k
simp only [MulEquiv.toMonoidHom_eq_coe, Subgroup.mem_map, MonoidHom.coe_coe]
constructor
· rintro ⟨n, hn, rfl⟩
exact Set.conj_mem_fixingSubgroup hg hn
· intro hk
use MulAut.conj g⁻¹ k
constructor
· apply Set.conj_mem_fixingSubgroup _ hk
rw [inv_smul_eq_iff, hg]
· simp [MulAut.conj]; group
variable (g s) in
/-- The `fixingSubgroup` of `g • s` is the conjugate of the `fixingSubgroup` of `s` by `g`. -/
@[to_additive /-- The `fixingAddSubgroup` of `g +ᵥ s` is the conjugate
of the `fixingAddSubgroup` of `s` by `g`. -/]
theorem fixingSubgroup_smul_eq_fixingSubgroup_map_conj :
fixingSubgroup M (g • s) = (fixingSubgroup M s).map (MulAut.conj g).toMonoidHom :=
(fixingSubgroup_map_conj_eq rfl).symm
/-- The equivalence of `fixingSubgroup M t` with `fixingSubgroup M s`
when `s` is a translate of `t`. -/
@[to_additive
/-- The equivalence of `fixingSubgroup M t` with `fixingSubgroup M s`
when `s` is a translate of `t`. -/]
def fixingSubgroupEquivFixingSubgroup (hg : g • t = s) :
fixingSubgroup M t ≃* fixingSubgroup M s :=
((MulAut.conj g).subgroupMap (fixingSubgroup M t)).trans
(MulEquiv.subgroupCongr (fixingSubgroup_map_conj_eq hg))
@[to_additive (attr := simp)]
theorem fixingSubgroupEquivFixingSubgroup_coe_apply (hg : g • t = s) (x : fixingSubgroup M t) :
(fixingSubgroupEquivFixingSubgroup hg x : M) = MulAut.conj g x := rfl
/-- Conjugation induces an equivariant map between the `SubMulAction` of
the fixing subgroup of a subset and that of a translate. -/
@[to_additive
/-- Conjugation induces an equivariant map between the `SubAddAction` of
the fixing subgroup of a subset and that of a translate. -/]
def conjMap_ofFixingSubgroup (hg : g • t = s) :
ofFixingSubgroup M t →ₑ[fixingSubgroupEquivFixingSubgroup hg] ofFixingSubgroup M s where
toFun := fun ⟨x, hx⟩ =>
⟨g • x, by
intro hgxt; apply hx
rw [← hg] at hgxt
exact Set.smul_mem_smul_set_iff.mp hgxt⟩
map_smul' := fun ⟨m, hm⟩ ⟨x, hx⟩ => by
simp only [← SetLike.coe_eq_coe, subgroup_smul_def,
SetLike.val_smul,
fixingSubgroupEquivFixingSubgroup_coe_apply,
MulAut.conj_apply, mul_smul, inv_smul_smul]
@[to_additive (attr := simp)]
theorem conjMap_ofFixingSubgroup_coe_apply {hg : g • t = s} (x : ofFixingSubgroup M t) :
conjMap_ofFixingSubgroup hg x = g • (x : α) := rfl
@[to_additive]
theorem conjMap_ofFixingSubgroup_bijective {s t : Set α} {g : M} {hst : g • s = t} :
Bijective (conjMap_ofFixingSubgroup hst) := by
constructor
· rintro x y hxy
simpa [← SetLike.coe_eq_coe] using hxy
· rintro ⟨x, hx⟩
rw [eq_comm, ← inv_smul_eq_iff] at hst
use (SubMulAction.conjMap_ofFixingSubgroup hst) ⟨x, hx⟩
simp [← SetLike.coe_eq_coe]
end FixingSubgroupConj
variable {s t : Set α}
@[to_additive]
lemma mem_fixingSubgroup_union_iff {g : M} :
g ∈ fixingSubgroup M (s ∪ t) ↔ g ∈ fixingSubgroup M s ∧ g ∈ fixingSubgroup M t := by
simp [fixingSubgroup_union, Subgroup.mem_inf]
/-- The group morphism from `fixingSubgroup` of a union to the iterated `fixingSubgroup`. -/
@[to_additive
/-- The additive group morphism from `fixingAddSubgroup` of a union
to the iterated `fixingAddSubgroup`. -/]
def fixingSubgroup_union_to_fixingSubgroup_of_fixingSubgroup :
fixingSubgroup M (s ∪ t) →*
fixingSubgroup (fixingSubgroup M s) (Subtype.val ⁻¹' t : Set (ofFixingSubgroup M s)) where
toFun m := ⟨⟨m, (mem_fixingSubgroup_union_iff.mp m.prop).1⟩, by
rintro ⟨⟨x, hx⟩, hx'⟩
simp only [Set.mem_preimage] at hx'
simp only [← SetLike.coe_eq_coe, SubMulAction.val_smul_of_tower]
exact (mem_fixingSubgroup_union_iff.mp m.prop).2 ⟨x, hx'⟩⟩
map_one' := by simp
map_mul' _ _ := by simp [← Subtype.coe_inj]
variable (M s t) in
/-- The identity between the iterated `SubMulAction`
of the `fixingSubgroup` and the `SubMulAction` of the `fixingSubgroup`
of the union, as an equivariant map. -/
@[to_additive /-- The identity between the iterated `SubAddAction`
of the `fixingAddSubgroup` and the `SubAddAction` of the `fixingAddSubgroup`
of the union, as an equivariant map. -/]
def map_ofFixingSubgroupUnion :
let ψ : fixingSubgroup M (s ∪ t) →
fixingSubgroup (fixingSubgroup M s) (Subtype.val ⁻¹' t : Set (ofFixingSubgroup M s)) :=
fun m ↦ ⟨⟨m, by
let hm := m.prop
simp only [fixingSubgroup_union, Subgroup.mem_inf] at hm
exact hm.left⟩, by
let hm := m.prop
simp only [fixingSubgroup_union, Subgroup.mem_inf] at hm
rintro ⟨⟨x, hx⟩, hx'⟩
simp only [Set.mem_preimage] at hx'
simp only [← SetLike.coe_eq_coe, SubMulAction.val_smul_of_tower]
exact hm.right ⟨x, hx'⟩⟩
ofFixingSubgroup M (s ∪ t) →ₑ[ψ]
ofFixingSubgroup (fixingSubgroup M s) (Subtype.val ⁻¹' t : Set (ofFixingSubgroup M s)) where
toFun x :=
⟨⟨x, fun hx => x.prop (Set.mem_union_left t hx)⟩,
fun hx => x.prop (by
apply Set.mem_union_right s
simpa only [Set.mem_preimage, Subtype.coe_mk] using hx)⟩
map_smul' := fun ⟨m, hm⟩ ⟨x, hx⟩ => by
rw [← SetLike.coe_eq_coe, ← SetLike.coe_eq_coe]
exact subgroup_smul_def ⟨m, hm⟩ x
@[to_additive]
theorem map_ofFixingSubgroupUnion_def (x : SubMulAction.ofFixingSubgroup M (s ∪ t)) :
((SubMulAction.map_ofFixingSubgroupUnion M s t) x : α) = x :=
rfl
@[to_additive]
theorem map_ofFixingSubgroupUnion_bijective :
Bijective (map_ofFixingSubgroupUnion M s t) := by
constructor
· intro a b h
simpa only [← SetLike.coe_eq_coe] using h
· rintro ⟨⟨a, ha⟩, ha'⟩
suffices a ∈ ofFixingSubgroup M (s ∪ t) by
exact ⟨⟨a, this⟩, rfl⟩
intro hy
rcases (Set.mem_union a s t).mp hy with h | h
· exact ha h
· apply ha'
simpa only [Set.mem_preimage]
variable (M) in
/-- The equivariant map on `SubMulAction.ofFixingSubgroup` given a set inclusion. -/
@[to_additive
/-- The equivariant map on `SubAddAction.ofFixingAddSubgroup` given a set inclusion. -/]
def ofFixingSubgroup_of_inclusion (hst : t ⊆ s) :
ofFixingSubgroup M s
→ₑ[Subgroup.inclusion (fixingSubgroup_antitone M α hst)]
ofFixingSubgroup M t where
toFun y := ⟨y.val, fun h => y.prop (hst h)⟩
map_smul' _ _ := rfl
@[to_additive]
lemma ofFixingSubgroup_of_inclusion_injective {hst : t ⊆ s} :
Injective (ofFixingSubgroup_of_inclusion M hst) := by
rintro ⟨x, hx⟩ ⟨y, hy⟩ hxy
rw [← SetLike.coe_eq_coe] at hxy ⊢
exact hxy
variable (M) in
/-- The equivariant map between `SubMulAction.ofStabilizer M a`
and `ofFixingSubgroup M {a}`. -/
@[to_additive /-- The equivariant map between `SubAddAction.ofStabilizer M a`
and `ofFixingAddSubgroup M {a}`. -/]
def ofFixingSubgroup_of_singleton (a : α) :
let φ : fixingSubgroup M ({a} : Set α) → stabilizer M a := fun ⟨m, hm⟩ =>
⟨m, ((mem_fixingSubgroup_iff M).mp hm) a (Set.mem_singleton a)⟩
ofFixingSubgroup M ({a} : Set α) →ₑ[φ] ofStabilizer M a where
toFun x := ⟨x, by simp⟩
map_smul' _ _ := rfl
@[to_additive]
theorem ofFixingSubgroup_of_singleton_bijective {a : α} :
Bijective (ofFixingSubgroup_of_singleton M a) :=
⟨fun _ _ ↦ id, fun x ↦ ⟨x, rfl⟩⟩
variable (M) in
/-- The identity between the `SubMulAction`s of `fixingSubgroup`s
of equal sets, as an equivariant map. -/
@[to_additive /-- The identity between the `SubAddAction`s of `fixingAddSubgroup`s
of equal sets, as an equivariant map. -/]
def ofFixingSubgroup_of_eq (hst : s = t) :
let φ : fixingSubgroup M s ≃* fixingSubgroup M t :=
MulEquiv.subgroupCongr (congrArg₂ _ rfl hst)
ofFixingSubgroup M s →ₑ[φ] ofFixingSubgroup M t where
toFun := fun ⟨x, hx⟩ => ⟨x, by rw [← hst]; exact hx⟩
map_smul' := fun ⟨m, hm⟩ ⟨x, hx⟩ => rfl
@[to_additive (attr := simp)]
theorem ofFixingSubgroup_of_eq_apply {hst : s = t}
(x : ofFixingSubgroup M s) :
((ofFixingSubgroup_of_eq M hst x) : α) = x := rfl
@[to_additive]
theorem ofFixingSubgroup_of_eq_bijective {hst : s = t} :
Bijective (ofFixingSubgroup_of_eq M hst) :=
⟨fun _ _ hxy ↦ by simpa [← SetLike.coe_eq_coe] using hxy,
fun ⟨x, hxt⟩ ↦ ⟨⟨x, by rwa [hst]⟩, by simp [← SetLike.coe_eq_coe]⟩⟩
end Comparisons
section Construction
open Function.Embedding Fin.Embedding
/-- Append `Fin m ↪ ofFixingSubgroup M s` at the end of an enumeration of `s`. -/
@[to_additive
/-- Append `Fin m ↪ ofFixingSubgroup M s` at the end of an enumeration of `s`. -/]
noncomputable def ofFixingSubgroup.append
{n : ℕ} [Finite s] (x : Fin n ↪ ofFixingSubgroup M s) :
Fin (s.ncard + n) ↪ α := by
have : Nonempty (Fin (s.ncard) ≃ s) :=
Finite.card_eq.mp (by simp [Nat.card_coe_set_eq])
let y := (Classical.choice this).toEmbedding
apply Fin.Embedding.append (x := y.trans (subtype _)) (y := x.trans (subtype _))
rw [Set.disjoint_iff_forall_ne]
rintro _ ⟨j, rfl⟩ _ ⟨i, rfl⟩ H
apply (x i).prop
simp only [trans_apply, Function.Embedding.subtype_apply] at H
simpa [H] using Subtype.coe_prop (y j)
@[to_additive]
theorem ofFixingSubgroup.append_left {n : ℕ} [Finite s]
(x : Fin n ↪ ofFixingSubgroup M s) (i : Fin s.ncard) :
let Hs : Nonempty (Fin (s.ncard) ≃ s) :=
Finite.card_eq.mp (by simp [Nat.card_coe_set_eq])
ofFixingSubgroup.append x (Fin.castAdd n i) = (Classical.choice Hs) i := by
simp [ofFixingSubgroup.append]
@[to_additive]
theorem ofFixingSubgroup.append_right {n : ℕ} [Finite s]
(x : Fin n ↪ ofFixingSubgroup M s) (i : Fin n) :
ofFixingSubgroup.append x (Fin.natAdd s.ncard i) = x i := by
simp [ofFixingSubgroup.append]
end Construction
section TwoCriteria
open MulAction
/-- A pretransitivity criterion. -/
theorem IsPretransitive.isPretransitive_ofFixingSubgroup_inter
(hs : IsPretransitive (fixingSubgroup M s) (ofFixingSubgroup M s))
{g : M} (ha : s ∪ g • s ≠ ⊤) :
IsPretransitive (fixingSubgroup M (s ∩ g • s)) (ofFixingSubgroup M (s ∩ g • s)) := by
rw [Ne, Set.top_eq_univ, ← Set.compl_empty_iff, ← Ne, ← Set.nonempty_iff_ne_empty] at ha
obtain ⟨a, ha⟩ := ha
rw [Set.compl_union] at ha
have ha' : a ∈ (s ∩ g • s)ᶜ := by
rw [Set.compl_inter]
exact Set.mem_union_left _ ha.1
rw [MulAction.isPretransitive_iff_base (⟨a, ha'⟩ : ofFixingSubgroup M (s ∩ g • s))]
rintro ⟨x, hx⟩
rw [mem_ofFixingSubgroup_iff, Set.mem_inter_iff, not_and_or] at hx
rcases hx with hx | hx
· obtain ⟨⟨k, hk⟩, hkax⟩ := hs.exists_smul_eq ⟨a, ha.1⟩ ⟨x, hx⟩
use ⟨k, fun ⟨y, hy⟩ ↦ hk ⟨y, hy.1⟩⟩
rwa [Subtype.ext_iff] at hkax ⊢
· have hg'x : g⁻¹ • x ∈ ofFixingSubgroup M s := mt Set.mem_smul_set_iff_inv_smul_mem.mpr hx
have hg'a : g⁻¹ • a ∈ ofFixingSubgroup M s := mt Set.mem_smul_set_iff_inv_smul_mem.mpr ha.2
obtain ⟨⟨k, hk⟩, hkax⟩ := hs.exists_smul_eq ⟨g⁻¹ • a, hg'a⟩ ⟨g⁻¹ • x, hg'x⟩
use ⟨g * k * g⁻¹, ?_⟩
· simp only [← SetLike.coe_eq_coe] at hkax ⊢
rwa [SetLike.val_smul, Subgroup.mk_smul, eq_inv_smul_iff, smul_smul, smul_smul] at hkax
· rw [mem_fixingSubgroup_iff] at hk ⊢
intro y hy
rw [mul_smul, mul_smul, smul_eq_iff_eq_inv_smul g]
exact hk _ (Set.mem_smul_set_iff_inv_smul_mem.mp hy.2)
/-- A primitivity criterion -/
theorem IsPreprimitive.isPreprimitive_ofFixingSubgroup_inter
[Finite α]
(hs : IsPreprimitive (fixingSubgroup M s) (ofFixingSubgroup M s))
{g : M} (ha : s ∪ g • s ≠ ⊤) :
IsPreprimitive (fixingSubgroup M (s ∩ g • s)) (ofFixingSubgroup M (s ∩ g • s)) := by
have := IsPretransitive.isPretransitive_ofFixingSubgroup_inter hs.toIsPretransitive ha
apply IsPreprimitive.of_card_lt (f := ofFixingSubgroup_of_inclusion M Set.inter_subset_left)
rw [show Nat.card (ofFixingSubgroup M (s ∩ g • s)) = (s ∩ g • s)ᶜ.ncard from
Nat.card_coe_set_eq _, Set.ncard_range_of_injective ofFixingSubgroup_of_inclusion_injective,
show Nat.card (ofFixingSubgroup M s) = sᶜ.ncard from Nat.card_coe_set_eq _, Set.compl_inter]
refine (Set.ncard_union_lt sᶜ.toFinite (g • s)ᶜ.toFinite ?_).trans_le ?_
· rwa [Set.disjoint_compl_right_iff_subset, Set.compl_subset_iff_union]
· rw [← Set.smul_set_compl, Set.ncard_smul_set, two_mul]
end TwoCriteria
end SubMulAction
section Pointwise
open MulAction Set
variable (G : Type*) [Group G] {α : Type*} [MulAction G α]
@[to_additive]
theorem MulAction.fixingSubgroup_le_stabilizer (s : Set α) :
fixingSubgroup G s ≤ stabilizer G s := by
intro k hk
rw [mem_stabilizer_iff]
conv_rhs => rw [← Set.image_id s]
apply Set.image_congr
simpa only [mem_fixingSubgroup_iff, id] using hk
end Pointwise |
.lake/packages/mathlib/Mathlib/GroupTheory/GroupAction/DomAct/ActionHom.lean | import Mathlib.GroupTheory.GroupAction.DomAct.Basic
import Mathlib.GroupTheory.GroupAction.Hom
/-!
# Action of `Mᵈᵐᵃ` on `α →[N] β` and `A →+[N] B`
In this file we define action of `DomMulAct M = Mᵈᵐᵃ` on `α →[N] β` and on `A →+[N] B`. At the
time of writing, these homomorphisms are not widely used in the library, so we put these instances
into a separate file, not with the definition of `DomMulAct`.
## TODO
Add left actions of, e.g., `M` on `α →[N] β` to `Mathlib/Algebra/Hom/GroupAction.lean` and
`SMulCommClass` instances saying that left and right actions commute.
-/
namespace DomMulAct
section MulActionSemiHom
section SMul
variable {M α N β : Type*}
variable [SMul M α] [SMul N α] [SMulCommClass M N α] [SMul N β]
instance : SMul Mᵈᵐᵃ (α →[N] β) where
smul c f := f.comp (SMulCommClass.toMulActionHom _ _ (mk.symm c))
instance {M' : Type*} [SMul M' α] [SMulCommClass M' N α] [SMulCommClass M M' α] :
SMulCommClass Mᵈᵐᵃ M'ᵈᵐᵃ (α →[N] β) :=
DFunLike.coe_injective.smulCommClass (fun _ _ ↦ rfl) (fun _ _ ↦ rfl)
theorem smul_mulActionHom_apply (c : Mᵈᵐᵃ) (f : α →[N] β) (a : α) :
(c • f) a = f (mk.symm c • a) :=
rfl
@[simp]
theorem mk_smul_mulActionHom_apply (c : M) (f : α →[N] β) (a : α) : (mk c • f) a = f (c • a) := rfl
end SMul
instance {M α N β : Type*} [Monoid M] [MulAction M α] [SMul N α] [SMulCommClass M N α] [SMul N β] :
MulAction Mᵈᵐᵃ (α →[N] β) :=
DFunLike.coe_injective.mulAction _ fun _ _ ↦ rfl
end MulActionSemiHom
section DistribMulActionHom
section SMul
variable {M N A B : Type*} [AddMonoid A] [DistribSMul M A] [Monoid N] [AddMonoid B]
[DistribMulAction N A] [SMulCommClass M N A] [DistribMulAction N B]
instance : SMul Mᵈᵐᵃ (A →+[N] B) where
smul c f := f.comp (SMulCommClass.toDistribMulActionHom _ _ (mk.symm c))
instance {M' : Type*} [DistribSMul M' A] [SMulCommClass M' N A] [SMulCommClass M M' A] :
SMulCommClass Mᵈᵐᵃ M'ᵈᵐᵃ (A →+[N] B) :=
DFunLike.coe_injective.smulCommClass (fun _ _ ↦ rfl) (fun _ _ ↦ rfl)
theorem smul_mulDistribActionHom_apply (c : Mᵈᵐᵃ) (f : A →+[N] B) (a : A) :
(c • f) a = f (mk.symm c • a) :=
rfl
@[simp]
theorem mk_smul_mulDistribActionHom_apply (c : M) (f : A →+[N] B) (a : A) :
(mk c • f) a = f (c • a) := rfl
end SMul
instance {M N A B : Type*} [Monoid M] [AddMonoid A] [DistribMulAction M A] [Monoid N] [AddMonoid B]
[DistribMulAction N A] [SMulCommClass M N A] [DistribMulAction N B] :
MulAction Mᵈᵐᵃ (A →+[N] B) :=
DFunLike.coe_injective.mulAction _ fun _ _ ↦ rfl
end DistribMulActionHom
end DomMulAct |
.lake/packages/mathlib/Mathlib/GroupTheory/GroupAction/DomAct/Basic.lean | import Mathlib.Algebra.Group.Action.Basic
import Mathlib.Algebra.Group.Opposite
import Mathlib.Algebra.Group.Pi.Lemmas
import Mathlib.Algebra.GroupWithZero.Action.Hom
import Mathlib.Algebra.Ring.Defs
/-!
# Type tags for right action on the domain of a function
By default, `M` acts on `α → β` if it acts on `β`, and the action is given by
`(c • f) a = c • (f a)`.
In some cases, it is useful to consider another action: if `M` acts on `α` on the left, then it acts
on `α → β` on the right so that `(c • f) a = f (c • a)`. E.g., this action is used to reformulate
the Mean Ergodic Theorem in terms of an operator on \(L^2\).
## Main definitions
- `DomMulAct M` (notation: `Mᵈᵐᵃ`): type synonym for `Mᵐᵒᵖ`; if `M` multiplicatively acts on `α`,
then `Mᵈᵐᵃ` acts on `α → β` for any type `β`;
- `DomAddAct M` (notation: `Mᵈᵃᵃ`): the additive version.
We also define actions of `Mᵈᵐᵃ` on:
- `α → β` provided that `M` acts on `α`;
- `A →* B` provided that `M` acts on `A` by a `MulDistribMulAction`;
- `A →+ B` provided that `M` acts on `A` by a `DistribMulAction`.
## Implementation details
### Motivation
Right action can be represented in `mathlib` as an action of the opposite group `Mᵐᵒᵖ`. However,
this "domain shift" action cannot be an instance because this would create a "diamond"
(a.k.a. ambiguous notation): if `M` is a monoid, then how does `Mᵐᵒᵖ` act on `M → M`? On the one
hand, `Mᵐᵒᵖ` acts on `M` by `c • a = a * c.unop`, thus we have an action
`(c • f) a = f a * c.unop`. On the other hand, `M` acts on itself by multiplication on the left, so
with this new instance we would have `(c • f) a = f (c.unop * a)`. Clearly, these are two different
actions, so both of them cannot be instances in the library.
To overcome this difficulty, we introduce a type synonym `DomMulAct M := Mᵐᵒᵖ` (notation:
`Mᵈᵐᵃ`). This new type carries the same algebraic structures as `Mᵐᵒᵖ` but acts on `α → β` by this
new action. So, e.g., `Mᵈᵐᵃ` acts on `(M → M) → M` by `DomMulAct.mk c • F f = F (fun a ↦ c • f a)`
while `(Mᵈᵐᵃ)ᵈᵐᵃ` (which is isomorphic to `M`) acts on `(M → M) → M` by
`DomMulAct.mk (DomMulAct.mk c) • F f = F (fun a ↦ f (c • a))`.
### Action on bundled homomorphisms
If the action of `M` on `A` preserves some structure, then `Mᵈᵐᵃ` acts on bundled homomorphisms from
`A` to any type `B` that preserve the same structure. Examples (some of them are not yet in the
library) include:
- a `MulDistribMulAction` generates an action on `A →* B`;
- a `DistribMulAction` generates an action on `A →+ B`;
- an action on `α` that commutes with action of some other monoid `N` generates an action on
`α →[N] β`;
- a `DistribMulAction` on an `R`-module that commutes with scalar multiplications by `c : R`
generates an action on `R`-linear maps from this module;
- a continuous action on `X` generates an action on `C(X, Y)`;
- a measurable action on `X` generates an action on `{ f : X → Y // Measurable f }`;
- a quasi-measure-preserving action on `X` generates an action on `X →ₘ[μ] Y`;
- a measure-preserving action generates an isometric action on `MeasureTheory.Lp _ _ _`.
### Left action vs right action
It is common in the literature to consider the left action given by `(c • f) a = f (c⁻¹ • a)`
instead of the action defined in this file. However, this left action is defined only if `c` belongs
to a group, not to a monoid, so we decided to go with the right action.
The left action can be written in terms of `DomMulAct` as `(DomMulAct.mk c)⁻¹ • f`. As for higher
level dynamics objects (orbits, invariant functions etc), they coincide for the left and for the
right action, so lemmas can be formulated in terms of `DomMulAct`.
## Keywords
group action, function, domain
-/
open Function
/-- If `M` multiplicatively acts on `α`, then `DomMulAct M` acts on `α → β` as well as some
bundled maps from `α`. This is a type synonym for `MulOpposite M`, so this corresponds to a right
action of `M`. -/
@[to_additive /-- If `M` additively acts on `α`, then `DomAddAct M` acts on `α → β` as
well as some bundled maps from `α`. This is a type synonym for `AddOpposite M`, so this corresponds
to a right action of `M`. -/]
def DomMulAct (M : Type*) := MulOpposite M
@[inherit_doc] postfix:max "ᵈᵐᵃ" => DomMulAct
@[inherit_doc] postfix:max "ᵈᵃᵃ" => DomAddAct
namespace DomMulAct
variable {M : Type*}
/-- Equivalence between `M` and `Mᵈᵐᵃ`. -/
@[to_additive /-- Equivalence between `M` and `Mᵈᵐᵃ`. -/]
def mk : M ≃ Mᵈᵐᵃ := MulOpposite.opEquiv
/-!
### Copy instances from `Mᵐᵒᵖ`
-/
set_option hygiene false in
run_cmd
for n in [`Mul, `One, `Inv, `Semigroup, `CommSemigroup, `LeftCancelSemigroup,
`RightCancelSemigroup, `MulOneClass, `Monoid, `CommMonoid, `LeftCancelMonoid,
`RightCancelMonoid, `CancelMonoid, `CancelCommMonoid, `InvolutiveInv, `DivInvMonoid,
`InvOneClass, `DivInvOneMonoid, `DivisionMonoid, `DivisionCommMonoid, `Group,
`CommGroup, `NonAssocSemiring, `NonUnitalSemiring, `Semiring,
`Ring, `CommRing].map Lean.mkIdent do
Lean.Elab.Command.elabCommand (← `(
@[to_additive] instance [$n Mᵐᵒᵖ] : $n Mᵈᵐᵃ := ‹_›
))
@[to_additive] instance [Mul Mᵐᵒᵖ] [IsLeftCancelMul Mᵐᵒᵖ] : IsLeftCancelMul Mᵈᵐᵃ := ‹_›
@[to_additive] instance [Mul Mᵐᵒᵖ] [IsRightCancelMul Mᵐᵒᵖ] : IsRightCancelMul Mᵈᵐᵃ := ‹_›
@[to_additive] instance [Mul Mᵐᵒᵖ] [IsCancelMul Mᵐᵒᵖ] : IsCancelMul Mᵈᵐᵃ := ‹_›
@[to_additive (attr := simp)]
lemma mk_one [One M] : mk (1 : M) = 1 := rfl
@[to_additive (attr := simp)]
lemma symm_mk_one [One M] : mk.symm (1 : Mᵈᵐᵃ) = 1 := rfl
@[to_additive (attr := simp)]
lemma mk_mul [Mul M] (a b : M) : mk (a * b) = mk b * mk a := rfl
@[to_additive (attr := simp)]
lemma symm_mk_mul [Mul M] (a b : Mᵈᵐᵃ) : mk.symm (a * b) = mk.symm b * mk.symm a := rfl
@[to_additive (attr := simp)]
lemma mk_inv [Inv M] (a : M) : mk (a⁻¹) = (mk a)⁻¹ := rfl
@[to_additive (attr := simp)]
lemma symm_mk_inv [Inv M] (a : Mᵈᵐᵃ) : mk.symm (a⁻¹) = (mk.symm a)⁻¹ := rfl
@[to_additive (attr := simp)]
lemma mk_pow [Monoid M] (a : M) (n : ℕ) : mk (a ^ n) = mk a ^ n := rfl
@[to_additive (attr := simp)]
lemma symm_mk_pow [Monoid M] (a : Mᵈᵐᵃ) (n : ℕ) : mk.symm (a ^ n) = mk.symm a ^ n := rfl
@[to_additive (attr := simp)]
lemma mk_zpow [DivInvMonoid M] (a : M) (n : ℤ) : mk (a ^ n) = mk a ^ n := rfl
@[to_additive (attr := simp)]
lemma symm_mk_zpow [DivInvMonoid M] (a : Mᵈᵐᵃ) (n : ℤ) : mk.symm (a ^ n) = mk.symm a ^ n := rfl
variable {β α N : Type*}
@[to_additive]
instance [SMul M α] : SMul Mᵈᵐᵃ (α → β) where
smul c f a := f (mk.symm c • a)
@[to_additive]
theorem smul_apply [SMul M α] (c : Mᵈᵐᵃ) (f : α → β) (a : α) : (c • f) a = f (mk.symm c • a) := rfl
@[to_additive]
instance [SMul M α] [SMul N β] : SMulCommClass Mᵈᵐᵃ N (α → β) where
smul_comm _ _ _ := rfl
@[to_additive]
instance [SMul M α] [SMul N β] : SMulCommClass N Mᵈᵐᵃ (α → β) where
smul_comm _ _ _ := rfl
@[to_additive]
instance [SMul M α] [SMul N α] [SMulCommClass M N α] : SMulCommClass Mᵈᵐᵃ Nᵈᵐᵃ (α → β) where
smul_comm _ _ f := funext fun _ ↦ congr_arg f (smul_comm _ _ _).symm
@[to_additive]
instance [SMul M α] [FaithfulSMul M α] [Nontrivial β] : FaithfulSMul Mᵈᵐᵃ (α → β) where
eq_of_smul_eq_smul {c₁ c₂} h := mk.symm.injective <| eq_of_smul_eq_smul fun a : α ↦ by
rcases exists_pair_ne β with ⟨x, y, hne⟩
contrapose! hne
haveI := Classical.decEq α
replace h := congr_fun (h (update (const α x) (mk.symm c₂ • a) y)) a
simpa [smul_apply, hne] using h
instance [SMul M α] [Zero β] : SMulZeroClass Mᵈᵐᵃ (α → β) where
smul_zero _ := rfl
instance {A : Type*} [SMul M α] [AddZeroClass A] : DistribSMul Mᵈᵐᵃ (α → A) where
smul_add _ _ _ := rfl
@[to_additive]
instance [Monoid M] [MulAction M α] : MulAction Mᵈᵐᵃ (α → β) where
one_smul f := funext fun _ ↦ congr_arg f (one_smul _ _)
mul_smul _ _ f := funext fun _ ↦ congr_arg f (mul_smul _ _ _)
instance {A : Type*} [Monoid M] [MulAction M α] [AddMonoid A] : DistribMulAction Mᵈᵐᵃ (α → A) where
smul_zero _ := rfl
smul_add _ _ _ := rfl
instance {A : Type*} [Monoid M] [MulAction M α] [Monoid A] : MulDistribMulAction Mᵈᵐᵃ (α → A) where
smul_mul _ _ _ := rfl
smul_one _ := rfl
section MonoidHom
variable {M M' A B : Type*} [Monoid M] [Monoid A] [MulDistribMulAction M A] [MulOneClass B]
instance : SMul Mᵈᵐᵃ (A →* B) where
smul c f := f.comp (MulDistribMulAction.toMonoidHom _ (mk.symm c))
instance [Monoid M'] [MulDistribMulAction M' A] [SMulCommClass M M' A] :
SMulCommClass Mᵈᵐᵃ M'ᵈᵐᵃ (A →* B) :=
DFunLike.coe_injective.smulCommClass (fun _ _ ↦ rfl) (fun _ _ ↦ rfl)
theorem smul_monoidHom_apply (c : Mᵈᵐᵃ) (f : A →* B) (a : A) : (c • f) a = f (mk.symm c • a) :=
rfl
@[simp]
theorem mk_smul_monoidHom_apply (c : M) (f : A →* B) (a : A) : (mk c • f) a = f (c • a) := rfl
instance : MulAction Mᵈᵐᵃ (A →* B) := DFunLike.coe_injective.mulAction (⇑) fun _ _ ↦ rfl
end MonoidHom
section AddMonoidHom
section DistribSMul
variable {A B M M' : Type*} [AddMonoid A] [DistribSMul M A] [AddZeroClass B]
instance : SMul Mᵈᵐᵃ (A →+ B) where
smul c f := f.comp (DistribSMul.toAddMonoidHom _ (mk.symm c))
instance [DistribSMul M' A] [SMulCommClass M M' A] : SMulCommClass Mᵈᵐᵃ M'ᵈᵐᵃ (A →+ B) :=
DFunLike.coe_injective.smulCommClass (fun _ _ ↦ rfl) (fun _ _ ↦ rfl)
instance [DistribSMul M' B] : SMulCommClass Mᵈᵐᵃ M' (A →+ B) :=
DFunLike.coe_injective.smulCommClass (fun _ _ ↦ rfl) (fun _ _ ↦ rfl)
theorem smul_addMonoidHom_apply (c : Mᵈᵐᵃ) (f : A →+ B) (a : A) : (c • f) a = f (mk.symm c • a) :=
rfl
@[simp]
theorem mk_smul_addMonoidHom_apply (c : M) (f : A →+ B) (a : A) : (mk c • f) a = f (c • a) := rfl
theorem coe_smul_addMonoidHom (c : Mᵈᵐᵃ) (f : A →+ B) : ⇑(c • f) = c • ⇑f :=
rfl
end DistribSMul
variable {A M B : Type*}
instance [Monoid M] [AddMonoid A] [DistribMulAction M A] [AddZeroClass B] :
MulAction Mᵈᵐᵃ (A →+ B) := DFunLike.coe_injective.mulAction (⇑) fun _ _ ↦ rfl
instance [Monoid M] [AddMonoid A] [DistribMulAction M A] [AddCommMonoid B] :
DistribMulAction Mᵈᵐᵃ (A →+ B) :=
DFunLike.coe_injective.distribMulAction (AddMonoidHom.coeFn A B) fun _ _ ↦ rfl
instance [Monoid M] [Monoid A] [MulDistribMulAction M A] [CommMonoid B] :
MulDistribMulAction Mᵈᵐᵃ (A →* B) :=
DFunLike.coe_injective.mulDistribMulAction (MonoidHom.coeFn A B) fun _ _ ↦ rfl
end AddMonoidHom
end DomMulAct |
.lake/packages/mathlib/Mathlib/GroupTheory/Coprod/Basic.lean | import Mathlib.Algebra.Group.PUnit
import Mathlib.Algebra.Group.Subgroup.Ker
import Mathlib.Algebra.Group.Submonoid.Membership
import Mathlib.GroupTheory.Congruence.Basic
/-!
# Coproduct (free product) of two monoids or groups
In this file we define `Monoid.Coprod M N` (notation: `M ∗ N`)
to be the coproduct (a.k.a. free product) of two monoids.
The same type is used for the coproduct of two monoids and for the coproduct of two groups.
The coproduct `M ∗ N` has the following universal property:
for any monoid `P` and homomorphisms `f : M →* P`, `g : N →* P`,
there exists a unique homomorphism `fg : M ∗ N →* P`
such that `fg ∘ Monoid.Coprod.inl = f` and `fg ∘ Monoid.Coprod.inr = g`,
where `Monoid.Coprod.inl : M →* M ∗ N`
and `Monoid.Coprod.inr : N →* M ∗ N` are canonical embeddings.
This homomorphism `fg` is given by `Monoid.Coprod.lift f g`.
We also define some homomorphisms and isomorphisms about `M ∗ N`,
and provide additive versions of all definitions and theorems.
## Main definitions
### Types
* `Monoid.Coprod M N` (a.k.a. `M ∗ N`):
the free product (a.k.a. coproduct) of two monoids `M` and `N`.
* `AddMonoid.Coprod M N` (no notation): the additive version of `Monoid.Coprod`.
In other sections, we only list multiplicative definitions.
### Instances
* `MulOneClass`, `Monoid`, and `Group` structures on the coproduct `M ∗ N`.
### Monoid homomorphisms
* `Monoid.Coprod.mk`: the projection `FreeMonoid (M ⊕ N) →* M ∗ N`.
* `Monoid.Coprod.inl`, `Monoid.Coprod.inr`: canonical embeddings `M →* M ∗ N` and `N →* M ∗ N`.
* `Monoid.Coprod.lift`: construct a monoid homomorphism `M ∗ N →* P`
from homomorphisms `M →* P` and `N →* P`; see also `Monoid.Coprod.liftEquiv`.
* `Monoid.Coprod.clift`: a constructor for homomorphisms `M ∗ N →* P`
that allows the user to control the computational behavior.
* `Monoid.Coprod.map`: combine two homomorphisms `f : M →* N` and `g : M' →* N'`
into `M ∗ M' →* N ∗ N'`.
* `Monoid.Coprod.swap`: the natural homomorphism `M ∗ N →* N ∗ M`.
* `Monoid.Coprod.fst`, `Monoid.Coprod.snd`, and `Monoid.Coprod.toProd`:
natural projections `M ∗ N →* M`, `M ∗ N →* N`, and `M ∗ N →* M × N`.
### Monoid isomorphisms
* `MulEquiv.coprodCongr`: a `MulEquiv` version of `Monoid.Coprod.map`.
* `MulEquiv.coprodComm`: a `MulEquiv` version of `Monoid.Coprod.swap`.
* `MulEquiv.coprodAssoc`: associativity of the coproduct.
* `MulEquiv.coprodPUnit`, `MulEquiv.punitCoprod`:
free product by `PUnit` on the left or on the right is isomorphic to the original monoid.
## Main results
The universal property of the coproduct
is given by the definition `Monoid.Coprod.lift` and the lemma `Monoid.Coprod.lift_unique`.
We also prove a slightly more general extensionality lemma `Monoid.Coprod.hom_ext`
for homomorphisms `M ∗ N →* P` and prove lots of basic lemmas like `Monoid.Coprod.fst_comp_inl`.
## Implementation details
The definition of the coproduct of an indexed family of monoids is formalized in `Monoid.CoprodI`.
While mathematically `M ∗ N` is a particular case
of the coproduct of an indexed family of monoids,
it is easier to build API from scratch instead of using something like
```
def Monoid.Coprod M N := Monoid.CoprodI ![M, N]
```
or
```
def Monoid.Coprod M N := Monoid.CoprodI (fun b : Bool => cond b M N)
```
There are several reasons to build an API from scratch.
- API about `Con` makes it easy to define the required type and prove the universal property,
so there is little overhead compared to transferring API from `Monoid.CoprodI`.
- If `M` and `N` live in different universes, then the definition has to add `ULift`s;
this makes it harder to transfer API and definitions.
- As of now, we have no way
to automatically build an instance of `(k : Fin 2) → Monoid (![M, N] k)`
from `[Monoid M]` and `[Monoid N]`,
not even speaking about more advanced typeclass assumptions that involve both `M` and `N`.
- Using a list of `M ⊕ N` instead of, e.g., a list of `Σ k : Fin 2, ![M, N] k`
as the underlying type makes it possible to write computationally effective code
(though this point is not tested yet).
## TODO
- Prove `Monoid.CoprodI (f : Fin 2 → Type*) ≃* f 0 ∗ f 1` and
`Monoid.CoprodI (f : Bool → Type*) ≃* f false ∗ f true`.
## Tags
group, monoid, coproduct, free product
-/
assert_not_exists MonoidWithZero
open FreeMonoid Function List Set
namespace Monoid
/-- The minimal congruence relation `c` on `FreeMonoid (M ⊕ N)`
such that `FreeMonoid.of ∘ Sum.inl` and `FreeMonoid.of ∘ Sum.inr` are monoid homomorphisms
to the quotient by `c`. -/
@[to_additive /-- The minimal additive congruence relation `c` on `FreeAddMonoid (M ⊕ N)`
such that `FreeAddMonoid.of ∘ Sum.inl` and `FreeAddMonoid.of ∘ Sum.inr`
are additive monoid homomorphisms to the quotient by `c`. -/]
def coprodCon (M N : Type*) [MulOneClass M] [MulOneClass N] : Con (FreeMonoid (M ⊕ N)) :=
sInf {c |
(∀ x y : M, c (of (Sum.inl (x * y))) (of (Sum.inl x) * of (Sum.inl y)))
∧ (∀ x y : N, c (of (Sum.inr (x * y))) (of (Sum.inr x) * of (Sum.inr y)))
∧ c (of <| Sum.inl 1) 1 ∧ c (of <| Sum.inr 1) 1}
/-- Coproduct of two monoids or groups. -/
@[to_additive /-- Coproduct of two additive monoids or groups. -/]
def Coprod (M N : Type*) [MulOneClass M] [MulOneClass N] := (coprodCon M N).Quotient
namespace Coprod
@[inherit_doc]
scoped infix:30 " ∗ " => Coprod
section MulOneClass
variable {M N M' N' P : Type*} [MulOneClass M] [MulOneClass N] [MulOneClass M'] [MulOneClass N']
[MulOneClass P]
@[to_additive] protected instance : MulOneClass (M ∗ N) := Con.mulOneClass _
/-- The natural projection `FreeMonoid (M ⊕ N) →* M ∗ N`. -/
@[to_additive /-- The natural projection `FreeAddMonoid (M ⊕ N) →+ AddMonoid.Coprod M N`. -/]
def mk : FreeMonoid (M ⊕ N) →* M ∗ N := Con.mk' _
@[to_additive (attr := simp)]
theorem con_ker_mk : Con.ker mk = coprodCon M N := Con.mk'_ker _
@[to_additive]
theorem mk_surjective : Surjective (@mk M N _ _) := Quot.mk_surjective
@[to_additive (attr := simp)]
theorem mrange_mk : MonoidHom.mrange (@mk M N _ _) = ⊤ := Con.mrange_mk'
@[to_additive]
theorem mk_eq_mk {w₁ w₂ : FreeMonoid (M ⊕ N)} : mk w₁ = mk w₂ ↔ coprodCon M N w₁ w₂ := Con.eq _
/-- The natural embedding `M →* M ∗ N`. -/
@[to_additive /-- The natural embedding `M →+ AddMonoid.Coprod M N`. -/]
def inl : M →* M ∗ N where
toFun := fun x => mk (of (.inl x))
map_one' := mk_eq_mk.2 fun _c hc => hc.2.2.1
map_mul' := fun x y => mk_eq_mk.2 fun _c hc => hc.1 x y
/-- The natural embedding `N →* M ∗ N`. -/
@[to_additive /-- The natural embedding `N →+ AddMonoid.Coprod M N`. -/]
def inr : N →* M ∗ N where
toFun := fun x => mk (of (.inr x))
map_one' := mk_eq_mk.2 fun _c hc => hc.2.2.2
map_mul' := fun x y => mk_eq_mk.2 fun _c hc => hc.2.1 x y
@[to_additive (attr := simp)]
theorem mk_of_inl (x : M) : (mk (of (.inl x)) : M ∗ N) = inl x := rfl
@[to_additive (attr := simp)]
theorem mk_of_inr (x : N) : (mk (of (.inr x)) : M ∗ N) = inr x := rfl
@[to_additive (attr := elab_as_elim)]
theorem induction_on' {C : M ∗ N → Prop} (m : M ∗ N)
(one : C 1)
(inl_mul : ∀ m x, C x → C (inl m * x))
(inr_mul : ∀ n x, C x → C (inr n * x)) : C m := by
rcases mk_surjective m with ⟨x, rfl⟩
induction x using FreeMonoid.inductionOn' with
| one => exact one
| mul_of x xs ih =>
cases x with
| inl m => simpa using inl_mul m _ ih
| inr n => simpa using inr_mul n _ ih
@[to_additive (attr := elab_as_elim)]
theorem induction_on {C : M ∗ N → Prop} (m : M ∗ N)
(inl : ∀ m, C (inl m)) (inr : ∀ n, C (inr n)) (mul : ∀ x y, C x → C y → C (x * y)) : C m :=
induction_on' m (by simpa using inl 1) (fun _ _ ↦ mul _ _ (inl _)) fun _ _ ↦ mul _ _ (inr _)
/-- Lift a monoid homomorphism `FreeMonoid (M ⊕ N) →* P` satisfying additional properties to
`M ∗ N →* P`. In many cases, `Coprod.lift` is more convenient.
Compared to `Coprod.lift`,
this definition allows a user to provide a custom computational behavior.
Also, it only needs `MulOneClass` assumptions while `Coprod.lift` needs a `Monoid` structure.
-/
@[to_additive /-- Lift an additive monoid homomorphism `FreeAddMonoid (M ⊕ N) →+ P` satisfying
additional properties to `AddMonoid.Coprod M N →+ P`.
Compared to `AddMonoid.Coprod.lift`,
this definition allows a user to provide a custom computational behavior.
Also, it only needs `AddZeroClass` assumptions
while `AddMonoid.Coprod.lift` needs an `AddMonoid` structure. -/]
def clift (f : FreeMonoid (M ⊕ N) →* P)
(hM₁ : f (of (.inl 1)) = 1) (hN₁ : f (of (.inr 1)) = 1)
(hM : ∀ x y, f (of (.inl (x * y))) = f (of (.inl x) * of (.inl y)))
(hN : ∀ x y, f (of (.inr (x * y))) = f (of (.inr x) * of (.inr y))) :
M ∗ N →* P :=
Con.lift _ f <| sInf_le ⟨hM, hN, hM₁.trans (map_one f).symm, hN₁.trans (map_one f).symm⟩
@[to_additive (attr := simp)]
theorem clift_apply_inl (f : FreeMonoid (M ⊕ N) →* P) (hM₁ hN₁ hM hN) (x : M) :
clift f hM₁ hN₁ hM hN (inl x) = f (of (.inl x)) :=
rfl
@[to_additive (attr := simp)]
theorem clift_apply_inr (f : FreeMonoid (M ⊕ N) →* P) (hM₁ hN₁ hM hN) (x : N) :
clift f hM₁ hN₁ hM hN (inr x) = f (of (.inr x)) :=
rfl
@[to_additive (attr := simp)]
theorem clift_apply_mk (f : FreeMonoid (M ⊕ N) →* P) (hM₁ hN₁ hM hN w) :
clift f hM₁ hN₁ hM hN (mk w) = f w :=
rfl
@[to_additive (attr := simp)]
theorem clift_comp_mk (f : FreeMonoid (M ⊕ N) →* P) (hM₁ hN₁ hM hN) :
(clift f hM₁ hN₁ hM hN).comp mk = f :=
DFunLike.ext' rfl
@[to_additive (attr := simp)]
theorem mclosure_range_inl_union_inr :
Submonoid.closure (range (inl : M →* M ∗ N) ∪ range (inr : N →* M ∗ N)) = ⊤ := by
rw [← mrange_mk, MonoidHom.mrange_eq_map, ← closure_range_of, MonoidHom.map_mclosure,
← range_comp, Sum.range_eq]; rfl
@[to_additive (attr := simp)] theorem mrange_inl_sup_mrange_inr :
MonoidHom.mrange (inl : M →* M ∗ N) ⊔ MonoidHom.mrange (inr : N →* M ∗ N) = ⊤ := by
rw [← mclosure_range_inl_union_inr, Submonoid.closure_union, ← MonoidHom.coe_mrange,
← MonoidHom.coe_mrange, Submonoid.closure_eq, Submonoid.closure_eq]
@[to_additive]
theorem codisjoint_mrange_inl_mrange_inr :
Codisjoint (MonoidHom.mrange (inl : M →* M ∗ N)) (MonoidHom.mrange inr) :=
codisjoint_iff.2 mrange_inl_sup_mrange_inr
@[to_additive] theorem mrange_eq (f : M ∗ N →* P) :
MonoidHom.mrange f = MonoidHom.mrange (f.comp inl) ⊔ MonoidHom.mrange (f.comp inr) := by
rw [MonoidHom.mrange_eq_map, ← mrange_inl_sup_mrange_inr, Submonoid.map_sup, MonoidHom.map_mrange,
MonoidHom.map_mrange]
/-- Extensionality lemma for monoid homomorphisms `M ∗ N →* P`.
If two homomorphisms agree on the ranges of `Monoid.Coprod.inl` and `Monoid.Coprod.inr`,
then they are equal. -/
@[to_additive (attr := ext 1100)
/-- Extensionality lemma for additive monoid homomorphisms `AddMonoid.Coprod M N →+ P`.
If two homomorphisms agree on the ranges of `AddMonoid.Coprod.inl` and `AddMonoid.Coprod.inr`,
then they are equal. -/]
theorem hom_ext {f g : M ∗ N →* P} (h₁ : f.comp inl = g.comp inl) (h₂ : f.comp inr = g.comp inr) :
f = g :=
MonoidHom.eq_of_eqOn_denseM mclosure_range_inl_union_inr <| eqOn_union.2
⟨eqOn_range.2 <| DFunLike.ext'_iff.1 h₁, eqOn_range.2 <| DFunLike.ext'_iff.1 h₂⟩
@[to_additive (attr := simp)]
theorem clift_mk :
clift (mk : FreeMonoid (M ⊕ N) →* M ∗ N) (map_one inl) (map_one inr) (map_mul inl)
(map_mul inr) = .id _ :=
hom_ext rfl rfl
/-- Map `M ∗ N` to `M' ∗ N'` by applying `Sum.map f g` to each element of the underlying list. -/
@[to_additive /-- Map `AddMonoid.Coprod M N` to `AddMonoid.Coprod M' N'`
by applying `Sum.map f g` to each element of the underlying list. -/]
def map (f : M →* M') (g : N →* N') : M ∗ N →* M' ∗ N' :=
clift (mk.comp <| FreeMonoid.map <| Sum.map f g)
(by simp only [MonoidHom.comp_apply, map_of, Sum.map_inl, map_one, mk_of_inl])
(by simp only [MonoidHom.comp_apply, map_of, Sum.map_inr, map_one, mk_of_inr])
(fun x y => by simp only [MonoidHom.comp_apply, map_of, Sum.map_inl, map_mul, mk_of_inl])
fun x y => by simp only [MonoidHom.comp_apply, map_of, Sum.map_inr, map_mul, mk_of_inr]
@[to_additive (attr := simp)]
theorem map_mk_ofList (f : M →* M') (g : N →* N') (l : List (M ⊕ N)) :
map f g (mk (ofList l)) = mk (ofList (l.map (Sum.map f g))) :=
rfl
@[to_additive (attr := simp)]
theorem map_apply_inl (f : M →* M') (g : N →* N') (x : M) : map f g (inl x) = inl (f x) := rfl
@[to_additive (attr := simp)]
theorem map_apply_inr (f : M →* M') (g : N →* N') (x : N) : map f g (inr x) = inr (g x) := rfl
@[to_additive (attr := simp)]
theorem map_comp_inl (f : M →* M') (g : N →* N') : (map f g).comp inl = inl.comp f := rfl
@[to_additive (attr := simp)]
theorem map_comp_inr (f : M →* M') (g : N →* N') : (map f g).comp inr = inr.comp g := rfl
@[to_additive (attr := simp)]
theorem map_id_id : map (.id M) (.id N) = .id (M ∗ N) := hom_ext rfl rfl
@[to_additive]
theorem map_comp_map {M'' N''} [MulOneClass M''] [MulOneClass N''] (f' : M' →* M'') (g' : N' →* N'')
(f : M →* M') (g : N →* N') : (map f' g').comp (map f g) = map (f'.comp f) (g'.comp g) :=
hom_ext rfl rfl
@[to_additive]
theorem map_map {M'' N''} [MulOneClass M''] [MulOneClass N''] (f' : M' →* M'') (g' : N' →* N'')
(f : M →* M') (g : N →* N') (x : M ∗ N) :
map f' g' (map f g x) = map (f'.comp f) (g'.comp g) x :=
DFunLike.congr_fun (map_comp_map f' g' f g) x
variable (M N)
/-- Map `M ∗ N` to `N ∗ M` by applying `Sum.swap` to each element of the underlying list.
See also `MulEquiv.coprodComm` for a `MulEquiv` version. -/
@[to_additive /-- Map `AddMonoid.Coprod M N` to `AddMonoid.Coprod N M`
by applying `Sum.swap` to each element of the underlying list.
See also `AddEquiv.coprodComm` for an `AddEquiv` version. -/]
def swap : M ∗ N →* N ∗ M :=
clift (mk.comp <| FreeMonoid.map Sum.swap)
(by simp only [MonoidHom.comp_apply, map_of, Sum.swap_inl, mk_of_inr, map_one])
(by simp only [MonoidHom.comp_apply, map_of, Sum.swap_inr, mk_of_inl, map_one])
(fun x y => by simp only [MonoidHom.comp_apply, map_of, Sum.swap_inl, mk_of_inr, map_mul])
(fun x y => by simp only [MonoidHom.comp_apply, map_of, Sum.swap_inr, mk_of_inl, map_mul])
@[to_additive (attr := simp)]
theorem swap_comp_swap : (swap M N).comp (swap N M) = .id _ := hom_ext rfl rfl
variable {M N}
@[to_additive (attr := simp)]
theorem swap_swap (x : M ∗ N) : swap N M (swap M N x) = x :=
DFunLike.congr_fun (swap_comp_swap _ _) x
@[to_additive]
theorem swap_comp_map (f : M →* M') (g : N →* N') :
(swap M' N').comp (map f g) = (map g f).comp (swap M N) :=
hom_ext rfl rfl
@[to_additive]
theorem swap_map (f : M →* M') (g : N →* N') (x : M ∗ N) :
swap M' N' (map f g x) = map g f (swap M N x) :=
DFunLike.congr_fun (swap_comp_map f g) x
@[to_additive (attr := simp)] theorem swap_comp_inl : (swap M N).comp inl = inr := rfl
@[to_additive (attr := simp)] theorem swap_inl (x : M) : swap M N (inl x) = inr x := rfl
@[to_additive (attr := simp)] theorem swap_comp_inr : (swap M N).comp inr = inl := rfl
@[to_additive (attr := simp)] theorem swap_inr (x : N) : swap M N (inr x) = inl x := rfl
@[to_additive]
theorem swap_injective : Injective (swap M N) := LeftInverse.injective swap_swap
@[to_additive (attr := simp)]
theorem swap_inj {x y : M ∗ N} : swap M N x = swap M N y ↔ x = y := swap_injective.eq_iff
@[to_additive (attr := simp)]
theorem swap_eq_one {x : M ∗ N} : swap M N x = 1 ↔ x = 1 := swap_injective.eq_iff' (map_one _)
@[to_additive]
theorem swap_surjective : Surjective (swap M N) := LeftInverse.surjective swap_swap
@[to_additive]
theorem swap_bijective : Bijective (swap M N) := ⟨swap_injective, swap_surjective⟩
@[to_additive (attr := simp)]
theorem mker_swap : MonoidHom.mker (swap M N) = ⊥ := Submonoid.ext fun _ ↦ swap_eq_one
@[to_additive (attr := simp)]
theorem mrange_swap : MonoidHom.mrange (swap M N) = ⊤ :=
MonoidHom.mrange_eq_top_of_surjective _ swap_surjective
end MulOneClass
section Lift
variable {M N P : Type*} [MulOneClass M] [MulOneClass N] [Monoid P]
/-- Lift a pair of monoid homomorphisms `f : M →* P`, `g : N →* P`
to a monoid homomorphism `M ∗ N →* P`.
See also `Coprod.clift` for a version that allows custom computational behavior
and works for a `MulOneClass` codomain.
-/
@[to_additive /-- Lift a pair of additive monoid homomorphisms `f : M →+ P`, `g : N →+ P`
to an additive monoid homomorphism `AddMonoid.Coprod M N →+ P`.
See also `AddMonoid.Coprod.clift` for a version that allows custom computational behavior
and works for an `AddZeroClass` codomain. -/]
def lift (f : M →* P) (g : N →* P) : (M ∗ N) →* P :=
clift (FreeMonoid.lift <| Sum.elim f g) (map_one f) (map_one g) (map_mul f) (map_mul g)
@[to_additive (attr := simp)]
theorem lift_apply_mk (f : M →* P) (g : N →* P) (x : FreeMonoid (M ⊕ N)) :
lift f g (mk x) = FreeMonoid.lift (Sum.elim f g) x :=
rfl
@[to_additive (attr := simp)]
theorem lift_apply_inl (f : M →* P) (g : N →* P) (x : M) : lift f g (inl x) = f x :=
rfl
@[to_additive]
theorem lift_unique {f : M →* P} {g : N →* P} {fg : M ∗ N →* P} (h₁ : fg.comp inl = f)
(h₂ : fg.comp inr = g) : fg = lift f g :=
hom_ext h₁ h₂
@[to_additive (attr := simp)]
theorem lift_comp_inl (f : M →* P) (g : N →* P) : (lift f g).comp inl = f := rfl
@[to_additive (attr := simp)]
theorem lift_apply_inr (f : M →* P) (g : N →* P) (x : N) : lift f g (inr x) = g x :=
rfl
@[to_additive (attr := simp)]
theorem lift_comp_inr (f : M →* P) (g : N →* P) : (lift f g).comp inr = g := rfl
@[to_additive (attr := simp)]
theorem lift_comp_swap (f : M →* P) (g : N →* P) : (lift f g).comp (swap N M) = lift g f :=
hom_ext rfl rfl
@[to_additive (attr := simp)]
theorem lift_swap (f : M →* P) (g : N →* P) (x : N ∗ M) : lift f g (swap N M x) = lift g f x :=
DFunLike.congr_fun (lift_comp_swap f g) x
@[to_additive]
theorem comp_lift {P' : Type*} [Monoid P'] (f : P →* P') (g₁ : M →* P) (g₂ : N →* P) :
f.comp (lift g₁ g₂) = lift (f.comp g₁) (f.comp g₂) :=
hom_ext (by rw [MonoidHom.comp_assoc, lift_comp_inl, lift_comp_inl]) <| by
rw [MonoidHom.comp_assoc, lift_comp_inr, lift_comp_inr]
/-- `Coprod.lift` as an equivalence. -/
@[to_additive /-- `AddMonoid.Coprod.lift` as an equivalence. -/]
def liftEquiv : (M →* P) × (N →* P) ≃ (M ∗ N →* P) where
toFun fg := lift fg.1 fg.2
invFun f := (f.comp inl, f.comp inr)
right_inv _ := Eq.symm <| lift_unique rfl rfl
@[to_additive (attr := simp)]
theorem mrange_lift (f : M →* P) (g : N →* P) :
MonoidHom.mrange (lift f g) = MonoidHom.mrange f ⊔ MonoidHom.mrange g := by
simp [mrange_eq]
end Lift
section ToProd
variable {M N : Type*} [Monoid M] [Monoid N]
@[to_additive] instance : Monoid (M ∗ N) :=
{ mul_assoc := (Con.monoid _).mul_assoc
one_mul := (Con.monoid _).one_mul
mul_one := (Con.monoid _).mul_one }
/-- The natural projection `M ∗ N →* M`. -/
@[to_additive /-- The natural projection `AddMonoid.Coprod M N →+ M`. -/]
def fst : M ∗ N →* M := lift (.id M) 1
/-- The natural projection `M ∗ N →* N`. -/
@[to_additive /-- The natural projection `AddMonoid.Coprod M N →+ N`. -/]
def snd : M ∗ N →* N := lift 1 (.id N)
/-- The natural projection `M ∗ N →* M × N`. -/
@[to_additive toProd /-- The natural projection `AddMonoid.Coprod M N →+ M × N`. -/]
def toProd : M ∗ N →* M × N := lift (.inl _ _) (.inr _ _)
@[to_additive (attr := simp)] theorem fst_comp_inl : (fst : M ∗ N →* M).comp inl = .id _ := rfl
@[to_additive (attr := simp)] theorem fst_apply_inl (x : M) : fst (inl x : M ∗ N) = x := rfl
@[to_additive (attr := simp)] theorem fst_comp_inr : (fst : M ∗ N →* M).comp inr = 1 := rfl
@[to_additive (attr := simp)] theorem fst_apply_inr (x : N) : fst (inr x : M ∗ N) = 1 := rfl
@[to_additive (attr := simp)] theorem snd_comp_inl : (snd : M ∗ N →* N).comp inl = 1 := rfl
@[to_additive (attr := simp)] theorem snd_apply_inl (x : M) : snd (inl x : M ∗ N) = 1 := rfl
@[to_additive (attr := simp)] theorem snd_comp_inr : (snd : M ∗ N →* N).comp inr = .id _ := rfl
@[to_additive (attr := simp)] theorem snd_apply_inr (x : N) : snd (inr x : M ∗ N) = x := rfl
@[to_additive (attr := simp) toProd_comp_inl]
theorem toProd_comp_inl : (toProd : M ∗ N →* M × N).comp inl = .inl _ _ := rfl
@[to_additive (attr := simp) toProd_comp_inr]
theorem toProd_comp_inr : (toProd : M ∗ N →* M × N).comp inr = .inr _ _ := rfl
@[to_additive (attr := simp) toProd_apply_inl]
theorem toProd_apply_inl (x : M) : toProd (inl x : M ∗ N) = (x, 1) := rfl
@[to_additive (attr := simp) toProd_apply_inr]
theorem toProd_apply_inr (x : N) : toProd (inr x : M ∗ N) = (1, x) := rfl
@[to_additive (attr := simp) fst_prod_snd]
theorem fst_prod_snd : (fst : M ∗ N →* M).prod snd = toProd := by ext1 <;> rfl
@[to_additive (attr := simp) prod_mk_fst_snd]
theorem prod_mk_fst_snd (x : M ∗ N) : (fst x, snd x) = toProd x := by
rw [← fst_prod_snd, MonoidHom.prod_apply]
@[to_additive (attr := simp) fst_comp_toProd]
theorem fst_comp_toProd : (MonoidHom.fst M N).comp toProd = fst := by
rw [← fst_prod_snd, MonoidHom.fst_comp_prod]
@[to_additive (attr := simp) fst_toProd]
theorem fst_toProd (x : M ∗ N) : (toProd x).1 = fst x := by
rw [← fst_comp_toProd]; rfl
@[to_additive (attr := simp) snd_comp_toProd]
theorem snd_comp_toProd : (MonoidHom.snd M N).comp toProd = snd := by
rw [← fst_prod_snd, MonoidHom.snd_comp_prod]
@[to_additive (attr := simp) snd_toProd]
theorem snd_toProd (x : M ∗ N) : (toProd x).2 = snd x := by
rw [← snd_comp_toProd]; rfl
@[to_additive (attr := simp)]
theorem fst_comp_swap : fst.comp (swap M N) = snd := lift_comp_swap _ _
@[to_additive (attr := simp)]
theorem fst_swap (x : M ∗ N) : fst (swap M N x) = snd x := lift_swap _ _ _
@[to_additive (attr := simp)]
theorem snd_comp_swap : snd.comp (swap M N) = fst := lift_comp_swap _ _
@[to_additive (attr := simp)]
theorem snd_swap (x : M ∗ N) : snd (swap M N x) = fst x := lift_swap _ _ _
@[to_additive (attr := simp)]
theorem lift_inr_inl : lift (inr : M →* N ∗ M) inl = swap M N := hom_ext rfl rfl
@[to_additive (attr := simp)]
theorem lift_inl_inr : lift (inl : M →* M ∗ N) inr = .id _ := hom_ext rfl rfl
@[to_additive]
theorem inl_injective : Injective (inl : M →* M ∗ N) := LeftInverse.injective fst_apply_inl
@[to_additive]
theorem inr_injective : Injective (inr : N →* M ∗ N) := LeftInverse.injective snd_apply_inr
@[to_additive]
theorem fst_surjective : Surjective (fst : M ∗ N →* M) := LeftInverse.surjective fst_apply_inl
@[to_additive]
theorem snd_surjective : Surjective (snd : M ∗ N →* N) := LeftInverse.surjective snd_apply_inr
@[to_additive toProd_surjective]
theorem toProd_surjective : Surjective (toProd : M ∗ N →* M × N) := fun x =>
⟨inl x.1 * inr x.2, by rw [map_mul, toProd_apply_inl, toProd_apply_inr, Prod.fst_mul_snd]⟩
end ToProd
section Group
variable {G H : Type*} [Group G] [Group H]
@[to_additive]
theorem mk_of_inv_mul : ∀ x : G ⊕ H, mk (of (x.map Inv.inv Inv.inv)) * mk (of x) = 1
| Sum.inl _ => map_mul_eq_one inl (inv_mul_cancel _)
| Sum.inr _ => map_mul_eq_one inr (inv_mul_cancel _)
@[to_additive]
theorem con_inv_mul_cancel (x : FreeMonoid (G ⊕ H)) :
coprodCon G H (ofList (x.toList.map (Sum.map Inv.inv Inv.inv)).reverse * x) 1 := by
rw [← mk_eq_mk, map_mul, map_one]
induction x using FreeMonoid.inductionOn' with
| one => simp
| mul_of x xs ihx =>
simp only [toList_of_mul, map_cons, reverse_cons, ofList_append, map_mul, ofList_singleton]
rwa [mul_assoc, ← mul_assoc (mk (of _)), mk_of_inv_mul, one_mul]
@[to_additive]
instance : Inv (G ∗ H) where
inv := Quotient.map' (fun w => ofList (w.toList.map (Sum.map Inv.inv Inv.inv)).reverse) fun _ _ ↦
(coprodCon G H).map_of_mul_left_rel_one _ con_inv_mul_cancel
@[to_additive]
theorem inv_def (w : FreeMonoid (G ⊕ H)) :
(mk w)⁻¹ = mk (ofList (w.toList.map (Sum.map Inv.inv Inv.inv)).reverse) :=
rfl
@[to_additive]
instance : Group (G ∗ H) where
inv_mul_cancel := mk_surjective.forall.2 fun x => mk_eq_mk.2 (con_inv_mul_cancel x)
@[to_additive (attr := simp)]
theorem closure_range_inl_union_inr :
Subgroup.closure (range (inl : G →* G ∗ H) ∪ range inr) = ⊤ :=
Subgroup.closure_eq_top_of_mclosure_eq_top mclosure_range_inl_union_inr
@[to_additive (attr := simp)] theorem range_inl_sup_range_inr :
MonoidHom.range (inl : G →* G ∗ H) ⊔ MonoidHom.range inr = ⊤ := by
rw [← closure_range_inl_union_inr, Subgroup.closure_union, ← MonoidHom.coe_range,
← MonoidHom.coe_range, Subgroup.closure_eq, Subgroup.closure_eq]
@[to_additive]
theorem codisjoint_range_inl_range_inr :
Codisjoint (MonoidHom.range (inl : G →* G ∗ H)) (MonoidHom.range inr) :=
codisjoint_iff.2 range_inl_sup_range_inr
@[to_additive (attr := simp)] theorem range_swap : MonoidHom.range (swap G H) = ⊤ :=
MonoidHom.range_eq_top.2 swap_surjective
variable {K : Type*} [Group K]
@[to_additive] theorem range_eq (f : G ∗ H →* K) :
MonoidHom.range f = MonoidHom.range (f.comp inl) ⊔ MonoidHom.range (f.comp inr) := by
rw [MonoidHom.range_eq_map, ← range_inl_sup_range_inr, Subgroup.map_sup, MonoidHom.map_range,
MonoidHom.map_range]
@[to_additive (attr := simp)] theorem range_lift (f : G →* K) (g : H →* K) :
MonoidHom.range (lift f g) = MonoidHom.range f ⊔ MonoidHom.range g := by
simp [range_eq]
end Group
end Monoid.Coprod
open Monoid Coprod
namespace MulEquiv
section MulOneClass
variable {M N M' N' : Type*} [MulOneClass M] [MulOneClass N] [MulOneClass M']
[MulOneClass N']
/-- Lift two monoid equivalences `e : M ≃* N` and `e' : M' ≃* N'` to a monoid equivalence
`(M ∗ M') ≃* (N ∗ N')`. -/
@[to_additive (attr := simps! -fullyApplied) /-- Lift two additive monoid
equivalences `e : M ≃+ N` and `e' : M' ≃+ N'` to an additive monoid equivalence
`(AddMonoid.Coprod M M') ≃+ (AddMonoid.Coprod N N')`. -/]
def coprodCongr (e : M ≃* N) (e' : M' ≃* N') : (M ∗ M') ≃* (N ∗ N') :=
(Coprod.map (e : M →* N) (e' : M' →* N')).toMulEquiv (Coprod.map e.symm e'.symm)
(by ext <;> simp) (by ext <;> simp)
variable (M N)
/-- A `MulEquiv` version of `Coprod.swap`. -/
@[to_additive (attr := simps! -fullyApplied)
/-- An `AddEquiv` version of `AddMonoid.Coprod.swap`. -/]
def coprodComm : M ∗ N ≃* N ∗ M :=
(Coprod.swap _ _).toMulEquiv (Coprod.swap _ _) (Coprod.swap_comp_swap _ _)
(Coprod.swap_comp_swap _ _)
end MulOneClass
variable (M N P : Type*) [Monoid M] [Monoid N] [Monoid P]
/-- A multiplicative equivalence between `(M ∗ N) ∗ P` and `M ∗ (N ∗ P)`. -/
@[to_additive /-- An additive equivalence between `AddMonoid.Coprod (AddMonoid.Coprod M N) P` and
`AddMonoid.Coprod M (AddMonoid.Coprod N P)`. -/]
def coprodAssoc : (M ∗ N) ∗ P ≃* M ∗ (N ∗ P) :=
MonoidHom.toMulEquiv
(Coprod.lift (Coprod.map (.id M) inl) (inr.comp inr))
(Coprod.lift (inl.comp inl) (Coprod.map inr (.id P)))
(by ext <;> rfl) (by ext <;> rfl)
variable {M N P}
@[to_additive (attr := simp)]
theorem coprodAssoc_apply_inl_inl (x : M) : coprodAssoc M N P (inl (inl x)) = inl x := rfl
@[to_additive (attr := simp)]
theorem coprodAssoc_apply_inl_inr (x : N) : coprodAssoc M N P (inl (inr x)) = inr (inl x) := rfl
@[to_additive (attr := simp)]
theorem coprodAssoc_apply_inr (x : P) : coprodAssoc M N P (inr x) = inr (inr x) := rfl
@[to_additive (attr := simp)]
theorem coprodAssoc_symm_apply_inl (x : M) : (coprodAssoc M N P).symm (inl x) = inl (inl x) :=
rfl
@[to_additive (attr := simp)]
theorem coprodAssoc_symm_apply_inr_inl (x : N) :
(coprodAssoc M N P).symm (inr (inl x)) = inl (inr x) :=
rfl
@[to_additive (attr := simp)]
theorem coprodAssoc_symm_apply_inr_inr (x : P) :
(coprodAssoc M N P).symm (inr (inr x)) = inr x :=
rfl
variable (M)
/-- Isomorphism between `M ∗ PUnit` and `M`. -/
@[to_additive (attr := simps! -fullyApplied)
/-- Isomorphism between `AddMonoid.Coprod M PUnit` and `M`. -/]
def coprodPUnit : M ∗ PUnit ≃* M :=
MonoidHom.toMulEquiv fst inl (hom_ext rfl <| Subsingleton.elim _ _) fst_comp_inl
/-- Isomorphism between `PUnit ∗ M` and `M`. -/
@[to_additive (attr := simps! -fullyApplied)
/-- Isomorphism between `AddMonoid.Coprod PUnit M` and `M`. -/]
def punitCoprod : PUnit ∗ M ≃* M :=
MonoidHom.toMulEquiv snd inr (hom_ext (Subsingleton.elim _ _) rfl) snd_comp_inr
end MulEquiv |
.lake/packages/mathlib/Mathlib/GroupTheory/Abelianization/Finite.lean | import Mathlib.GroupTheory.Abelianization.Defs
import Mathlib.GroupTheory.Coset.Card
/-!
# The abelianization of a finite group is finite
-/
variable {G : Type*} [Group G]
instance [Fintype G] [DecidablePred (· ∈ commutator G)] : Fintype (Abelianization G) :=
QuotientGroup.fintype (commutator G)
instance [Finite G] : Finite (Abelianization G) :=
Quotient.finite _ |
.lake/packages/mathlib/Mathlib/GroupTheory/Abelianization/Defs.lean | import Mathlib.GroupTheory.Commutator.Basic
/-!
# The abelianization of a group
This file defines the commutator and the abelianization of a group. It furthermore prepares for the
result that the abelianization is left adjoint to the forgetful functor from abelian groups to
groups, which can be found in `Mathlib/Algebra/Category/GrpCat/Adjunctions.lean`.
## Main definitions
* `Abelianization`: defines the abelianization of a group `G` as the quotient of a group by its
commutator subgroup.
* `Abelianization.map`: lifts a group homomorphism to a homomorphism between the abelianizations
* `MulEquiv.abelianizationCongr`: Equivalent groups have equivalent abelianizations
-/
assert_not_exists Cardinal Field
universe u v w
-- Let G be a group.
variable (G : Type u) [Group G]
open Subgroup (centralizer)
/-- The abelianization of G is the quotient of G by its commutator subgroup. -/
def Abelianization : Type u :=
G ⧸ commutator G
namespace Abelianization
attribute [local instance] QuotientGroup.leftRel
instance commGroup : CommGroup (Abelianization G) where
__ := QuotientGroup.Quotient.group _
mul_comm x y := Quotient.inductionOn₂ x y fun a b ↦ Quotient.sound' <|
QuotientGroup.leftRel_apply.mpr <| Subgroup.subset_closure
-- We avoid `group` here to minimize imports while low in the hierarchy;
-- typically it would be better to invoke the tactic.
⟨b⁻¹, Subgroup.mem_top _, a⁻¹, Subgroup.mem_top _, by simp [commutatorElement_def, mul_assoc]⟩
instance : Inhabited (Abelianization G) :=
⟨1⟩
variable {G}
/-- `of` is the canonical projection from G to its abelianization. -/
def of : G →* Abelianization G where
toFun := QuotientGroup.mk
map_one' := rfl
map_mul' _ _ := rfl
@[simp]
theorem mk_eq_of (a : G) : Quot.mk _ a = of a :=
rfl
variable (G) in
@[simp]
theorem ker_of : of.ker = commutator G :=
QuotientGroup.ker_mk' (commutator G)
section lift
-- So far we have built Gᵃᵇ and proved it's an abelian group.
-- Furthermore we defined the canonical projection `of : G → Gᵃᵇ`
-- Let `A` be an abelian group and let `f` be a group homomorphism from `G` to `A`.
variable {A : Type v} [CommGroup A] (f : G →* A)
theorem commutator_subset_ker : commutator G ≤ f.ker := by
rw [commutator_eq_closure, Subgroup.closure_le]
rintro x ⟨p, q, rfl⟩
simp [MonoidHom.mem_ker, mul_right_comm (f p) (f q), commutatorElement_def]
/-- If `f : G → A` is a group homomorphism to an abelian group, then `lift f` is the unique map
from the abelianization of a `G` to `A` that factors through `f`. -/
def lift : (G →* A) ≃ (Abelianization G →* A) where
toFun f := QuotientGroup.lift _ f fun _ h => MonoidHom.mem_ker.2 <| commutator_subset_ker _ h
invFun F := F.comp of
right_inv _ := MonoidHom.ext fun x => QuotientGroup.induction_on x fun _ => rfl
@[simp]
theorem lift_apply_of (x : G) : lift f (of x) = f x :=
rfl
@[deprecated (since := "2025-07-23")]
alias lift.of := lift_apply_of
theorem coe_lift_symm : (lift.symm : (Abelianization G →* A) → (G →* A)) = (·.comp of) := rfl
@[simp]
theorem lift_symm_apply (f : Abelianization G →* A) : lift.symm f = f.comp of := rfl
theorem lift_unique (φ : Abelianization G →* A)
-- hφ : φ agrees with f on the image of G in Gᵃᵇ
(hφ : ∀ x : G, φ (Abelianization.of x) = f x)
{x : Abelianization G} : φ x = lift f x :=
QuotientGroup.induction_on x hφ
@[deprecated (since := "2025-07-23")] alias lift.unique := lift_unique
@[simp]
theorem lift_of : lift of = MonoidHom.id (Abelianization G) :=
lift.apply_symm_apply <| MonoidHom.id _
end lift
variable {A : Type v} [Monoid A]
/-- See note [partially-applied ext lemmas]. -/
@[ext]
theorem hom_ext (φ ψ : Abelianization G →* A) (h : φ.comp of = ψ.comp of) : φ = ψ :=
MonoidHom.ext fun x => QuotientGroup.induction_on x <| DFunLike.congr_fun h
section Map
variable {H : Type v} [Group H] (f : G →* H)
/-- The map operation of the `Abelianization` functor -/
def map : Abelianization G →* Abelianization H :=
lift (of.comp f)
/-- Use `map` as the preferred simp normal form. -/
@[simp] theorem lift_of_comp :
Abelianization.lift (Abelianization.of.comp f) = Abelianization.map f := rfl
@[simp]
theorem map_of (x : G) : map f (of x) = of (f x) :=
rfl
@[simp]
theorem map_id : map (MonoidHom.id G) = MonoidHom.id (Abelianization G) :=
hom_ext _ _ rfl
@[simp]
theorem map_comp {I : Type w} [Group I] (g : H →* I) : (map g).comp (map f) = map (g.comp f) :=
hom_ext _ _ rfl
@[simp]
theorem map_map_apply {I : Type w} [Group I] {g : H →* I} {x : Abelianization G} :
map g (map f x) = map (g.comp f) x :=
DFunLike.congr_fun (map_comp _ _) x
end Map
end Abelianization
section AbelianizationCongr
variable {G} {H : Type v} [Group H]
/-- Equivalent groups have equivalent abelianizations -/
def MulEquiv.abelianizationCongr (e : G ≃* H) : Abelianization G ≃* Abelianization H where
toFun := Abelianization.map e.toMonoidHom
invFun := Abelianization.map e.symm.toMonoidHom
left_inv := by
rintro ⟨a⟩
simp
right_inv := by
rintro ⟨a⟩
simp
map_mul' := MonoidHom.map_mul _
@[simp]
theorem abelianizationCongr_of (e : G ≃* H) (x : G) :
e.abelianizationCongr (Abelianization.of x) = Abelianization.of (e x) :=
rfl
@[simp]
theorem abelianizationCongr_refl :
(MulEquiv.refl G).abelianizationCongr = MulEquiv.refl (Abelianization G) :=
MulEquiv.toMonoidHom_injective Abelianization.lift_of
@[simp]
theorem abelianizationCongr_symm (e : G ≃* H) :
e.abelianizationCongr.symm = e.symm.abelianizationCongr :=
rfl
@[simp]
theorem abelianizationCongr_trans {I : Type v} [Group I] (e : G ≃* H) (e₂ : H ≃* I) :
e.abelianizationCongr.trans e₂.abelianizationCongr = (e.trans e₂).abelianizationCongr :=
MulEquiv.toMonoidHom_injective (Abelianization.hom_ext _ _ rfl)
end AbelianizationCongr
/-- An Abelian group is equivalent to its own abelianization. -/
@[simps]
def Abelianization.equivOfComm {H : Type*} [CommGroup H] : H ≃* Abelianization H :=
{ Abelianization.of with
toFun := Abelianization.of
invFun := Abelianization.lift (MonoidHom.id H)
right_inv := by
rintro ⟨a⟩
rfl }
instance [Unique G] : Unique (Abelianization G) := Quotient.instUniqueQuotient _ |
.lake/packages/mathlib/Mathlib/GroupTheory/Submonoid/Inverses.lean | import Mathlib.Algebra.Group.Submonoid.Pointwise
/-!
# Submonoid of inverses
Given a submonoid `N` of a monoid `M`, we define the submonoid `N.leftInv` as the submonoid of
left inverses of `N`. When `M` is commutative, we may define `fromCommLeftInv : N.leftInv →* N`
since the inverses are unique. When `N ≤ IsUnit.Submonoid M`, this is precisely
the pointwise inverse of `N`, and we may define `leftInvEquiv : S.leftInv ≃* S`.
For the pointwise inverse of submonoids of groups, please refer to the file
`Mathlib/Algebra/Group/Submonoid/Pointwise.lean`.
`N.leftInv` is distinct from `N.units`, which is the subgroup of `Mˣ` containing all units that are
in `N`. See the implementation notes of `Mathlib/GroupTheory/Submonoid/Units.lean` for more details
on related constructions.
## TODO
Define the submonoid of right inverses and two-sided inverses.
See the comments of https://github.com/leanprover-community/mathlib4/pull/10679 for a possible
implementation.
-/
variable {M : Type*}
namespace Submonoid
@[to_additive]
noncomputable instance [Monoid M] : Group (IsUnit.submonoid M) :=
{ inferInstanceAs (Monoid (IsUnit.submonoid M)) with
inv := fun x ↦ ⟨x.prop.unit⁻¹.val, x.prop.unit⁻¹.isUnit⟩
inv_mul_cancel := fun x ↦
Subtype.ext ((Units.val_mul x.prop.unit⁻¹ _).trans x.prop.unit.inv_val) }
@[to_additive]
noncomputable instance [CommMonoid M] : CommGroup (IsUnit.submonoid M) :=
{ inferInstanceAs (Group (IsUnit.submonoid M)) with
mul_comm := fun a b ↦ by convert mul_comm a b }
@[to_additive]
theorem IsUnit.Submonoid.coe_inv [Monoid M] (x : IsUnit.submonoid M) :
↑x⁻¹ = (↑x.prop.unit⁻¹ : M) :=
rfl
section Monoid
variable [Monoid M] (S : Submonoid M)
/-- `S.leftInv` is the submonoid containing all the left inverses of `S`. -/
@[to_additive
/-- `S.leftNeg` is the additive submonoid containing all the left additive inverses of `S`. -/]
def leftInv : Submonoid M where
carrier := { x : M | ∃ y : S, x * y = 1 }
one_mem' := ⟨1, mul_one 1⟩
mul_mem' := fun {a} _b ⟨a', ha⟩ ⟨b', hb⟩ ↦
⟨b' * a', by simp only [coe_mul, ← mul_assoc, mul_assoc a, hb, mul_one, ha]⟩
@[to_additive]
theorem leftInv_leftInv_le : S.leftInv.leftInv ≤ S := by
rintro x ⟨⟨y, z, h₁⟩, h₂ : x * y = 1⟩
convert z.prop
rw [← mul_one x, ← h₁, ← mul_assoc, h₂, one_mul]
@[to_additive]
theorem unit_mem_leftInv (x : Mˣ) (hx : (x : M) ∈ S) : ((x⁻¹ :) : M) ∈ S.leftInv :=
⟨⟨x, hx⟩, x.inv_val⟩
@[to_additive]
theorem leftInv_leftInv_eq (hS : S ≤ IsUnit.submonoid M) : S.leftInv.leftInv = S := by
refine le_antisymm S.leftInv_leftInv_le ?_
intro x hx
have : x = ((hS hx).unit⁻¹⁻¹ : Mˣ) := by
rw [inv_inv (hS hx).unit]
rfl
rw [this]
exact S.leftInv.unit_mem_leftInv _ (S.unit_mem_leftInv _ hx)
/-- The function from `S.leftInv` to `S` sending an element to its right inverse in `S`.
This is a `MonoidHom` when `M` is commutative. -/
@[to_additive
/-- The function from `S.leftAdd` to `S` sending an element to its right additive
inverse in `S`. This is an `AddMonoidHom` when `M` is commutative. -/]
noncomputable def fromLeftInv : S.leftInv → S := fun x ↦ x.prop.choose
@[to_additive (attr := simp)]
theorem mul_fromLeftInv (x : S.leftInv) : (x : M) * S.fromLeftInv x = 1 :=
x.prop.choose_spec
@[to_additive (attr := simp)]
theorem fromLeftInv_one : S.fromLeftInv 1 = 1 :=
(one_mul _).symm.trans (Subtype.eq <| S.mul_fromLeftInv 1)
end Monoid
section CommMonoid
variable [CommMonoid M] (S : Submonoid M)
@[to_additive (attr := simp)]
theorem fromLeftInv_mul (x : S.leftInv) : (S.fromLeftInv x : M) * x = 1 := by
rw [mul_comm, mul_fromLeftInv]
@[to_additive]
theorem leftInv_le_isUnit : S.leftInv ≤ IsUnit.submonoid M := fun x ⟨y, hx⟩ ↦
⟨⟨x, y, hx, mul_comm x y ▸ hx⟩, rfl⟩
@[to_additive]
theorem fromLeftInv_eq_iff (a : S.leftInv) (b : M) :
(S.fromLeftInv a : M) = b ↔ (a : M) * b = 1 := by
rw [← IsUnit.mul_right_inj (leftInv_le_isUnit _ a.prop), S.mul_fromLeftInv, eq_comm]
/-- The `MonoidHom` from `S.leftInv` to `S` sending an element to its right inverse in `S`. -/
@[to_additive (attr := simps) /-- The `AddMonoidHom` from `S.leftNeg` to `S` sending an element to
its right additive inverse in `S`. -/]
noncomputable def fromCommLeftInv : S.leftInv →* S where
toFun := S.fromLeftInv
map_one' := S.fromLeftInv_one
map_mul' x y :=
Subtype.ext <| by
rw [fromLeftInv_eq_iff, mul_comm x, Submonoid.coe_mul, Submonoid.coe_mul, mul_assoc, ←
mul_assoc (x : M), mul_fromLeftInv, one_mul, mul_fromLeftInv]
variable (hS : S ≤ IsUnit.submonoid M)
/-- The submonoid of pointwise inverse of `S` is `MulEquiv` to `S`. -/
@[to_additive (attr := simps apply) /-- The additive submonoid of pointwise additive inverse of `S`
is `AddEquiv` to `S`. -/]
noncomputable def leftInvEquiv : S.leftInv ≃* S :=
{ S.fromCommLeftInv with
invFun := fun x ↦ ⟨↑(hS x.2).unit⁻¹, x, by simp⟩
left_inv := by
intro x
ext
simp [← Units.mul_eq_one_iff_inv_eq]
right_inv := by
rintro ⟨x, hx⟩
ext
simp [fromLeftInv_eq_iff] }
@[to_additive (attr := simp)]
theorem fromLeftInv_leftInvEquiv_symm (x : S) : S.fromLeftInv ((S.leftInvEquiv hS).symm x) = x :=
(S.leftInvEquiv hS).right_inv x
@[to_additive (attr := simp)]
theorem leftInvEquiv_symm_fromLeftInv (x : S.leftInv) :
(S.leftInvEquiv hS).symm (S.fromLeftInv x) = x :=
(S.leftInvEquiv hS).left_inv x
@[to_additive]
theorem leftInvEquiv_mul (x : S.leftInv) : (S.leftInvEquiv hS x : M) * x = 1 := by
simpa only [leftInvEquiv_apply, fromCommLeftInv] using fromLeftInv_mul S x
@[to_additive]
theorem mul_leftInvEquiv (x : S.leftInv) : (x : M) * S.leftInvEquiv hS x = 1 := by
simp only [leftInvEquiv_apply, fromCommLeftInv, mul_fromLeftInv]
@[to_additive (attr := simp)]
theorem leftInvEquiv_symm_mul (x : S) : ((S.leftInvEquiv hS).symm x : M) * x = 1 := by
convert S.mul_leftInvEquiv hS ((S.leftInvEquiv hS).symm x)
simp
@[to_additive (attr := simp)]
theorem mul_leftInvEquiv_symm (x : S) : (x : M) * (S.leftInvEquiv hS).symm x = 1 := by
convert S.leftInvEquiv_mul hS ((S.leftInvEquiv hS).symm x)
simp
end CommMonoid
section Group
variable [Group M] (S : Submonoid M)
open Pointwise
@[to_additive]
theorem leftInv_eq_inv : S.leftInv = S⁻¹ :=
Submonoid.ext fun _ ↦
⟨fun h ↦ Submonoid.mem_inv.mpr ((inv_eq_of_mul_eq_one_right h.choose_spec).symm ▸
h.choose.prop),
fun h ↦ ⟨⟨_, h⟩, mul_inv_cancel _⟩⟩
@[to_additive (attr := simp)]
theorem fromLeftInv_eq_inv (x : S.leftInv) : (S.fromLeftInv x : M) = (x : M)⁻¹ := by
rw [← mul_right_inj (x : M), mul_inv_cancel, mul_fromLeftInv]
end Group
section CommGroup
variable [CommGroup M] (S : Submonoid M) (hS : S ≤ IsUnit.submonoid M)
@[to_additive (attr := simp)]
theorem leftInvEquiv_symm_eq_inv (x : S) : ((S.leftInvEquiv hS).symm x : M) = (x : M)⁻¹ := by
rw [← mul_right_inj (x : M), mul_inv_cancel, mul_leftInvEquiv_symm]
end CommGroup
end Submonoid |
.lake/packages/mathlib/Mathlib/GroupTheory/Submonoid/Center.lean | import Mathlib.Algebra.Group.Submonoid.Operations
import Mathlib.GroupTheory.Subsemigroup.Center
/-!
# Centers of monoids
## Main definitions
* `Submonoid.center`: the center of a monoid
* `AddSubmonoid.center`: the center of an additive monoid
We provide `Subgroup.center`, `AddSubgroup.center`, `Subsemiring.center`, and `Subring.center` in
other files.
-/
-- Guard against import creep
assert_not_exists Finset
namespace Submonoid
section MulOneClass
variable (M : Type*) [MulOneClass M]
/-- The center of a multiplication with unit `M` is the set of elements that commute with everything
in `M` -/
@[to_additive
/-- The center of an addition with zero `M` is the set of elements that commute with everything in
`M` -/]
def center : Submonoid M where
carrier := Set.center M
one_mem' := Set.one_mem_center
mul_mem' := Set.mul_mem_center
@[to_additive]
theorem coe_center : ↑(center M) = Set.center M :=
rfl
@[to_additive (attr := simp) AddSubmonoid.center_toAddSubsemigroup]
theorem center_toSubsemigroup : (center M).toSubsemigroup = Subsemigroup.center M :=
rfl
variable {M}
/-- The center of a multiplication with unit is commutative and associative.
This is not an instance as it forms an non-defeq diamond with `Submonoid.toMonoid` in the `npow`
field. -/
@[to_additive /-- The center of an addition with zero is commutative and associative. -/]
abbrev center.commMonoid' : CommMonoid (center M) :=
{ (center M).toMulOneClass, Subsemigroup.center.commSemigroup with }
end MulOneClass
section Monoid
variable {M} [Monoid M]
/-- The center of a monoid is commutative. -/
@[to_additive]
instance center.commMonoid : CommMonoid (center M) :=
{ (center M).toMonoid, Subsemigroup.center.commSemigroup with }
-- no instance diamond, unlike the primed version
example : center.commMonoid.toMonoid = Submonoid.toMonoid (center M) := by
with_reducible_and_instances rfl
@[to_additive]
theorem mem_center_iff {z : M} : z ∈ center M ↔ ∀ g, g * z = z * g := by
rw [← Semigroup.mem_center_iff]
exact Iff.rfl
@[to_additive]
instance decidableMemCenter (a) [Decidable <| ∀ b : M, b * a = a * b] : Decidable (a ∈ center M) :=
decidable_of_iff' _ mem_center_iff
/-- The center of a monoid acts commutatively on that monoid. -/
instance center.smulCommClass_left : SMulCommClass (center M) M M where
smul_comm m x y := Commute.left_comm (m.prop.comm x) y
/-- The center of a monoid acts commutatively on that monoid. -/
instance center.smulCommClass_right : SMulCommClass M (center M) M :=
SMulCommClass.symm _ _ _
/-! Note that `smulCommClass (center M) (center M) M` is already implied by
`Submonoid.smulCommClass_right` -/
example : SMulCommClass (center M) (center M) M := by infer_instance
end Monoid
section
variable (M : Type*) [CommMonoid M]
@[simp]
theorem center_eq_top : center M = ⊤ :=
SetLike.coe_injective (Set.center_eq_univ M)
end
end Submonoid
variable (M)
/-- For a monoid, the units of the center inject into the center of the units. This is not an
equivalence in general; one case where this holds is for groups with zero, which is covered in
`centerUnitsEquivUnitsCenter`. -/
@[to_additive (attr := simps! apply_coe_val)
/-- For an additive monoid, the units of the center inject into the center of the units. -/]
def unitsCenterToCenterUnits [Monoid M] : (Submonoid.center M)ˣ →* Submonoid.center (Mˣ) :=
(Units.map (Submonoid.center M).subtype).codRestrict _ <|
fun u ↦ Submonoid.mem_center_iff.mpr <|
fun r ↦ Units.ext <| by
rw [Units.val_mul, Units.coe_map, Submonoid.coe_subtype, Units.val_mul, Units.coe_map,
Submonoid.coe_subtype, u.1.prop.comm r]
@[to_additive]
theorem unitsCenterToCenterUnits_injective [Monoid M] :
Function.Injective (unitsCenterToCenterUnits M) :=
fun _a _b h => Units.ext <| Subtype.ext <| congr_arg (Units.val ∘ Subtype.val) h
section congr
variable {M} {N : Type*}
@[to_additive] theorem _root_.MulEquivClass.apply_mem_center {F} [EquivLike F M N] [Mul M] [Mul N]
[MulEquivClass F M N] (e : F) {x : M} (hx : x ∈ Set.center M) : e x ∈ Set.center N := by
let e := MulEquivClass.toMulEquiv e
change e x ∈ Set.center N
constructor <;>
(intros; apply e.symm.injective; simp only
[map_mul, e.symm_apply_apply, (hx.comm _).eq, (isMulCentral_iff _).mp hx, ← hx.right_comm])
@[to_additive] theorem _root_.MulEquivClass.apply_mem_center_iff {F} [EquivLike F M N]
[Mul M] [Mul N] [MulEquivClass F M N] (e : F) {x : M} :
e x ∈ Set.center N ↔ x ∈ Set.center M :=
⟨(by simpa using MulEquivClass.apply_mem_center (MulEquivClass.toMulEquiv e).symm ·),
MulEquivClass.apply_mem_center e⟩
/-- The center of isomorphic magmas are isomorphic. -/
@[to_additive (attr := simps) /-- The center of isomorphic additive magmas are isomorphic. -/]
def Subsemigroup.centerCongr [Mul M] [Mul N] (e : M ≃* N) : center M ≃* center N where
toFun r := ⟨e r, MulEquivClass.apply_mem_center e r.2⟩
invFun s := ⟨e.symm s, MulEquivClass.apply_mem_center e.symm s.2⟩
left_inv _ := Subtype.ext (e.left_inv _)
right_inv _ := Subtype.ext (e.right_inv _)
map_mul' _ _ := Subtype.ext (map_mul ..)
/-- The center of isomorphic monoids are isomorphic. -/
@[to_additive (attr := simps!) /-- The center of isomorphic additive monoids are isomorphic. -/]
def Submonoid.centerCongr [MulOneClass M] [MulOneClass N] (e : M ≃* N) : center M ≃* center N :=
Subsemigroup.centerCongr e
@[to_additive] theorem MulOpposite.op_mem_center_iff [Mul M] {x : M} :
op x ∈ Set.center Mᵐᵒᵖ ↔ x ∈ Set.center M := by
simp_rw [Set.mem_center_iff, isMulCentral_iff, MulOpposite.forall, ← op_mul, op_inj]; aesop
@[to_additive] theorem MulOpposite.unop_mem_center_iff [Mul M] {x : Mᵐᵒᵖ} :
unop x ∈ Set.center M ↔ x ∈ Set.center Mᵐᵒᵖ :=
op_mem_center_iff.symm
/-- The center of a magma is isomorphic to the center of its opposite. -/
@[to_additive (attr := simps)
/-- The center of an additive magma is isomorphic to the center of its opposite. -/]
def Subsemigroup.centerToMulOpposite [Mul M] : center M ≃* center Mᵐᵒᵖ where
toFun r := ⟨_, MulOpposite.op_mem_center_iff.mpr r.2⟩
invFun r := ⟨_, MulOpposite.unop_mem_center_iff.mpr r.2⟩
map_mul' r _ := Subtype.ext (congr_arg MulOpposite.op <| r.2.1 _)
/-- The center of a monoid is isomorphic to the center of its opposite. -/
@[to_additive (attr := simps!)
/-- The center of an additive monoid is isomorphic to the center of its opposite. -/]
def Submonoid.centerToMulOpposite [MulOneClass M] : center M ≃* center Mᵐᵒᵖ :=
Subsemigroup.centerToMulOpposite
end congr |
.lake/packages/mathlib/Mathlib/GroupTheory/Submonoid/Centralizer.lean | import Mathlib.GroupTheory.Subsemigroup.Centralizer
import Mathlib.GroupTheory.Submonoid.Center
/-!
# Centralizers of magmas and monoids
## Main definitions
* `Submonoid.centralizer`: the centralizer of a subset of a monoid
* `AddSubmonoid.centralizer`: the centralizer of a subset of an additive monoid
We provide `Subgroup.centralizer`, `AddSubgroup.centralizer` in other files.
-/
-- Guard against import creep
assert_not_exists Finset
variable {M : Type*} {S T : Set M}
namespace Submonoid
section
variable [Monoid M] (S)
/-- The centralizer of a subset of a monoid `M`. -/
@[to_additive /-- The centralizer of a subset of an additive monoid. -/]
def centralizer : Submonoid M where
carrier := S.centralizer
one_mem' := S.one_mem_centralizer
mul_mem' := Set.mul_mem_centralizer
@[to_additive (attr := simp, norm_cast)]
theorem coe_centralizer : ↑(centralizer S) = S.centralizer :=
rfl
@[to_additive AddSubmonoid.centralizer_toAddSubsemigroup]
theorem centralizer_toSubsemigroup : (centralizer S).toSubsemigroup = Subsemigroup.centralizer S :=
rfl
variable {S}
@[to_additive]
theorem mem_centralizer_iff {z : M} : z ∈ centralizer S ↔ ∀ g ∈ S, g * z = z * g :=
Iff.rfl
@[to_additive]
theorem center_le_centralizer (s) : center M ≤ centralizer s :=
s.center_subset_centralizer
@[to_additive]
instance decidableMemCentralizer (a) [Decidable <| ∀ b ∈ S, b * a = a * b] :
Decidable (a ∈ centralizer S) :=
decidable_of_iff' _ mem_centralizer_iff
@[to_additive]
theorem centralizer_le (h : S ⊆ T) : centralizer T ≤ centralizer S :=
Set.centralizer_subset h
@[to_additive (attr := simp)]
theorem centralizer_eq_top_iff_subset {s : Set M} : centralizer s = ⊤ ↔ s ⊆ center M :=
SetLike.ext'_iff.trans Set.centralizer_eq_top_iff_subset
variable (M)
@[to_additive (attr := simp)]
theorem centralizer_univ : centralizer Set.univ = center M :=
SetLike.ext' (Set.centralizer_univ M)
@[to_additive]
lemma le_centralizer_centralizer {s : Submonoid M} : s ≤ centralizer (centralizer (s : Set M)) :=
Set.subset_centralizer_centralizer
@[to_additive (attr := simp)]
lemma centralizer_centralizer_centralizer {s : Set M} :
centralizer s.centralizer.centralizer = centralizer s := by
apply SetLike.coe_injective
simp only [coe_centralizer, Set.centralizer_centralizer_centralizer]
variable {M} in
@[to_additive]
lemma closure_le_centralizer_centralizer (s : Set M) :
closure s ≤ centralizer (centralizer s) :=
closure_le.mpr Set.subset_centralizer_centralizer
/-- If all the elements of a set `s` commute, then `closure s` is a commutative monoid. -/
@[to_additive
/-- If all the elements of a set `s` commute, then `closure s` forms an additive
commutative monoid. -/]
abbrev closureCommMonoidOfComm {s : Set M} (hcomm : ∀ a ∈ s, ∀ b ∈ s, a * b = b * a) :
CommMonoid (closure s) :=
{ (closure s).toMonoid with
mul_comm := fun ⟨_, h₁⟩ ⟨_, h₂⟩ ↦
have := closure_le_centralizer_centralizer s
Subtype.ext <| Set.centralizer_centralizer_comm_of_comm hcomm _ (this h₁) _ (this h₂) }
end
end Submonoid |
.lake/packages/mathlib/Mathlib/GroupTheory/FiniteAbelian/Duality.lean | import Mathlib.GroupTheory.FiniteAbelian.Basic
import Mathlib.RingTheory.RootsOfUnity.EnoughRootsOfUnity
/-!
# Duality for finite abelian groups
Let `G` be a finite abelian group and let `M` be a commutative monoid that has enough `n`th roots
of unity, where `n` is the exponent of `G`. The main results in this file are
* `CommGroup.exists_apply_ne_one_of_hasEnoughRootsOfUnity`: Homomorphisms `G →* Mˣ` separate
elements of `G`.
* `CommGroup.monoidHom_mulEquiv_self_of_hasEnoughRootsOfUnity`: `G` is isomorphic to `G →* Mˣ`.
-/
namespace CommGroup
open MonoidHom
private
lemma dvd_exponent {ι G : Type*} [Finite ι] [Monoid G] {n : ι → ℕ}
(e : G ≃* ((i : ι) → Multiplicative (ZMod (n i)))) (i : ι) :
n i ∣ Monoid.exponent G := by
classical -- to get `DecidableEq ι`
have : n i = orderOf (e.symm <| Pi.mulSingle i <| .ofAdd 1) := by
simpa only [MulEquiv.orderOf_eq, orderOf_piMulSingle, orderOf_ofAdd_eq_addOrderOf]
using (ZMod.addOrderOf_one (n i)).symm
exact this ▸ Monoid.order_dvd_exponent _
variable (G M : Type*) [CommGroup G] [Finite G] [CommMonoid M]
private
lemma exists_apply_ne_one_aux
(H : ∀ n : ℕ, n ∣ Monoid.exponent G → ∀ a : ZMod n, a ≠ 0 →
∃ φ : Multiplicative (ZMod n) →* M, φ (.ofAdd a) ≠ 1)
{a : G} (ha : a ≠ 1) :
∃ φ : G →* M, φ a ≠ 1 := by
obtain ⟨ι, _, n, _, h⟩ := CommGroup.equiv_prod_multiplicative_zmod_of_finite G
let e := h.some
obtain ⟨i, hi⟩ : ∃ i : ι, e a i ≠ 1 := by
contrapose! ha
exact (MulEquiv.map_eq_one_iff e).mp <| funext ha
obtain ⟨φi, hφi⟩ := H (n i) (dvd_exponent e i) ((e a i).toAdd) hi
use (φi.comp (Pi.evalMonoidHom (fun (i : ι) ↦ Multiplicative (ZMod (n i))) i)).comp e
simpa only [coe_comp, coe_coe, Function.comp_apply, Pi.evalMonoidHom_apply, ne_eq] using hφi
variable [HasEnoughRootsOfUnity M (Monoid.exponent G)]
/-- If `G` is a finite commutative group of exponent `n` and `M` is a commutative monoid
with enough `n`th roots of unity, then for each `a ≠ 1` in `G`, there exists a
group homomorphism `φ : G → Mˣ` such that `φ a ≠ 1`. -/
theorem exists_apply_ne_one_of_hasEnoughRootsOfUnity {a : G} (ha : a ≠ 1) :
∃ φ : G →* Mˣ, φ a ≠ 1 := by
refine exists_apply_ne_one_aux G Mˣ (fun n hn a ha₀ ↦ ?_) ha
have : NeZero n := ⟨fun H ↦ NeZero.ne _ <| Nat.eq_zero_of_zero_dvd (H ▸ hn)⟩
have := HasEnoughRootsOfUnity.of_dvd M hn
exact ZMod.exists_monoidHom_apply_ne_one (HasEnoughRootsOfUnity.exists_primitiveRoot M n) ha₀
/-- A finite commutative group `G` is (noncanonically) isomorphic to the group `G →* Mˣ`
when `M` is a commutative monoid with enough `n`th roots of unity, where `n` is the exponent
of `G`. -/
theorem monoidHom_mulEquiv_of_hasEnoughRootsOfUnity : Nonempty ((G →* Mˣ) ≃* G) := by
classical -- to get `DecidableEq ι`
obtain ⟨ι, _, n, ⟨h₁, h₂⟩⟩ := equiv_prod_multiplicative_zmod_of_finite G
let e := h₂.some
let e' := Pi.monoidHomMulEquiv (fun i ↦ Multiplicative (ZMod (n i))) Mˣ
have : ∀ i, NeZero (n i) := fun i ↦ NeZero.of_gt (h₁ i)
have inst i : HasEnoughRootsOfUnity M <| Nat.card <| Multiplicative <| ZMod (n i) := by
have hdvd : Nat.card (Multiplicative (ZMod (n i))) ∣ Monoid.exponent G := by
simpa only [Nat.card_eq_fintype_card, Fintype.card_multiplicative, ZMod.card]
using dvd_exponent e i
exact HasEnoughRootsOfUnity.of_dvd M hdvd
let E i := (IsCyclic.monoidHom_equiv_self (Multiplicative (ZMod (n i))) M).some
exact ⟨e.monoidHomCongrLeft.trans <| e'.trans <| .trans (.piCongrRight E) e.symm⟩
end CommGroup |
.lake/packages/mathlib/Mathlib/GroupTheory/FiniteAbelian/Basic.lean | import Mathlib.Algebra.Module.PID
import Mathlib.Algebra.Group.TypeTags.Finite
import Mathlib.Data.ZMod.QuotientRing
/-!
# Structure of finite(ly generated) abelian groups
* `AddCommGroup.equiv_free_prod_directSum_zmod` : Any finitely generated abelian group is the
product of a power of `ℤ` and a direct sum of some `ZMod (p i ^ e i)` for some prime powers
`p i ^ e i`.
* `AddCommGroup.equiv_directSum_zmod_of_finite` : Any finite abelian group is a direct sum of
some `ZMod (p i ^ e i)` for some prime powers `p i ^ e i`.
* `CommGroup.equiv_prod_multiplicative_zmod_of_finite` is a version for multiplicative groups.
-/
open scoped DirectSum
/-
TODO: Here's a more general approach to dropping trivial factors from a direct sum:
def DirectSum.congr {ι κ : Type*} {α : ι → Type*} {β : κ → Type*} [DecidableEq ι] [DecidableEq κ]
[∀ i, DecidableEq (α i)] [∀ j, DecidableEq (β j)] [∀ i, AddCommMonoid (α i)]
[∀ j, AddCommMonoid (β j)] (f : ∀ i, Nontrivial (α i) → κ) (g : ∀ j, Nontrivial (β j) → ι)
(F : ∀ i hi, α i →+ β (f i hi)) (G : ∀ j hj, β j →+ α (g j hj))
(hfg : ∀ i hi hj, g (f i hi) hj = i) (hgf : ∀ j hj hi, f (g j hj) hi = j)
(hFG : ∀ i hi hj a, hfg i hi hj ▸ G _ hj (F i hi a) = a)
(hGF : ∀ j hj hi b, hgf j hj hi ▸ F _ hi (G j hj b) = b) :
(⨁ i, α i) ≃+ ⨁ j, β j where
toFun x := x.sum fun i a ↦ if ha : a = 0 then 0 else DFinsupp.single (f i ⟨a, 0, ha⟩) (F _ _ a)
invFun y := y.sum fun j b ↦ if hb : b = 0 then 0 else DFinsupp.single (g j ⟨b, 0, hb⟩) (G _ _ b)
-- The two sorries here are probably doable with the existing machinery, but quite painful
left_inv x := DFinsupp.ext fun i ↦ sorry
right_inv y := DFinsupp.ext fun j ↦ sorry
map_add' x₁ x₂ := by
dsimp
refine DFinsupp.sum_add_index (by simp) fun i a₁ a₂ ↦ ?_
split_ifs
any_goals simp_all
rw [← DFinsupp.single_add, ← map_add, ‹a₁ + a₂ = 0›, map_zero, DFinsupp.single_zero]
private def directSumNeZeroMulEquiv (ι : Type) [DecidableEq ι] (p : ι → ℕ) (n : ι → ℕ) :
(⨁ i : {i // n i ≠ 0}, ZMod (p i ^ n i)) ≃+ ⨁ i, ZMod (p i ^ n i) :=
DirectSum.congr
(fun i _ ↦ i)
(fun j hj ↦ ⟨j, fun h ↦ by simp [h, pow_zero, zmod_nontrivial] at hj⟩)
(fun i _ ↦ AddMonoidHom.id _)
(fun j _ ↦ AddMonoidHom.id _)
(fun i hi hj ↦ rfl)
(fun j hj hi ↦ rfl)
(fun i hi hj a ↦ rfl)
(fun j hj hi a ↦ rfl)
-/
private def directSumNeZeroMulHom {ι : Type} [DecidableEq ι] (p : ι → ℕ) (n : ι → ℕ) :
(⨁ i : {i // n i ≠ 0}, ZMod (p i ^ n i)) →+ ⨁ i, ZMod (p i ^ n i) :=
DirectSum.toAddMonoid fun i ↦ DirectSum.of (fun i ↦ ZMod (p i ^ n i)) i
private def directSumNeZeroMulEquiv (ι : Type) [DecidableEq ι] (p : ι → ℕ) (n : ι → ℕ) :
(⨁ i : {i // n i ≠ 0}, ZMod (p i ^ n i)) ≃+ ⨁ i, ZMod (p i ^ n i) where
toFun := directSumNeZeroMulHom p n
invFun := DirectSum.toAddMonoid fun i ↦
if h : n i = 0 then 0 else DirectSum.of (fun j : {i // n i ≠ 0} ↦ ZMod (p j ^ n j)) ⟨i, h⟩
left_inv x := by
induction x using DirectSum.induction_on with
| zero => simp
| of i x =>
rw [directSumNeZeroMulHom, DirectSum.toAddMonoid_of, DirectSum.toAddMonoid_of,
dif_neg i.prop]
| add x y hx hy => rw [map_add, map_add, hx, hy]
right_inv x := by
induction x using DirectSum.induction_on with
| zero => rw [map_zero, map_zero]
| of i x =>
rw [DirectSum.toAddMonoid_of]
split_ifs with h
· simp [(ZMod.subsingleton_iff.2 <| by rw [h, pow_zero]).elim x 0]
· simp_rw [directSumNeZeroMulHom, DirectSum.toAddMonoid_of]
| add x y hx hy => rw [map_add, map_add, hx, hy]
map_add' := map_add (directSumNeZeroMulHom p n)
universe u
namespace Module
variable (M : Type u)
theorem finite_of_fg_torsion [AddCommGroup M] [Module ℤ M] [Module.Finite ℤ M]
(hM : Module.IsTorsion ℤ M) : _root_.Finite M := by
rcases Module.equiv_directSum_of_isTorsion hM with ⟨ι, _, p, h, e, ⟨l⟩⟩
haveI : ∀ i : ι, NeZero (p i ^ e i).natAbs := fun i =>
⟨Int.natAbs_ne_zero.mpr <| pow_ne_zero (e i) (h i).ne_zero⟩
haveI : ∀ i : ι, _root_.Finite <| ℤ ⧸ Submodule.span ℤ {p i ^ e i} := fun i =>
Finite.of_equiv _ (p i ^ e i).quotientSpanEquivZMod.symm.toEquiv
haveI : _root_.Finite (⨁ i, ℤ ⧸ (Submodule.span ℤ {p i ^ e i} : Submodule ℤ ℤ)) :=
Finite.of_equiv _ DFinsupp.equivFunOnFintype.symm
exact Finite.of_equiv _ l.symm.toEquiv
end Module
variable (G : Type u)
namespace AddCommGroup
variable [AddCommGroup G]
/-- **Structure theorem of finitely generated abelian groups** : Any finitely generated abelian
group is the product of a power of `ℤ` and a direct sum of some `ZMod (p i ^ e i)` for some
prime powers `p i ^ e i`. -/
theorem equiv_free_prod_directSum_zmod [hG : AddGroup.FG G] :
∃ (n : ℕ) (ι : Type) (_ : Fintype ι) (p : ι → ℕ) (_ : ∀ i, Nat.Prime <| p i) (e : ι → ℕ),
Nonempty <| G ≃+ (Fin n →₀ ℤ) × ⨁ i : ι, ZMod (p i ^ e i) := by
obtain ⟨n, ι, fι, p, hp, e, ⟨f⟩⟩ :=
@Module.equiv_free_prod_directSum _ _ _ _ _ _ _ (Module.Finite.iff_addGroup_fg.mpr hG)
refine ⟨n, ι, fι, fun i => (p i).natAbs, fun i => ?_, e, ⟨?_⟩⟩
· rw [← Int.prime_iff_natAbs_prime, ← irreducible_iff_prime]; exact hp i
exact
f.toAddEquiv.trans
((AddEquiv.refl _).prodCongr <|
DFinsupp.mapRange.addEquiv fun i =>
((Int.quotientSpanEquivZMod _).trans <|
ZMod.ringEquivCongr <| (p i).natAbs_pow _).toAddEquiv)
/-- **Structure theorem of finite abelian groups** : Any finite abelian group is a direct sum of
some `ZMod (p i ^ e i)` for some prime powers `p i ^ e i`. -/
theorem equiv_directSum_zmod_of_finite [Finite G] :
∃ (ι : Type) (_ : Fintype ι) (p : ι → ℕ) (_ : ∀ i, Nat.Prime <| p i) (e : ι → ℕ),
Nonempty <| G ≃+ ⨁ i : ι, ZMod (p i ^ e i) := by
cases nonempty_fintype G
obtain ⟨n, ι, fι, p, hp, e, ⟨f⟩⟩ := equiv_free_prod_directSum_zmod G
rcases n with - | n
· have : Unique (Fin Nat.zero →₀ ℤ) :=
{ uniq := by subsingleton }
exact ⟨ι, fι, p, hp, e, ⟨f.trans AddEquiv.uniqueProd⟩⟩
· haveI := @Fintype.prodLeft _ _ _ (Fintype.ofEquiv G f.toEquiv) _
exact
(Fintype.ofSurjective (fun f : Fin n.succ →₀ ℤ => f 0) fun a =>
⟨Finsupp.single 0 a, Finsupp.single_eq_same⟩).false.elim
/-- **Structure theorem of finite abelian groups** : Any finite abelian group is a direct sum of
some `ZMod (n i)` for some natural numbers `n i > 1`. -/
lemma equiv_directSum_zmod_of_finite' (G : Type*) [AddCommGroup G] [Finite G] :
∃ (ι : Type) (_ : Fintype ι) (n : ι → ℕ),
(∀ i, 1 < n i) ∧ Nonempty (G ≃+ ⨁ i, ZMod (n i)) := by
classical
obtain ⟨ι, hι, p, hp, n, ⟨e⟩⟩ := AddCommGroup.equiv_directSum_zmod_of_finite G
refine ⟨{i : ι // n i ≠ 0}, inferInstance, fun i ↦ p i ^ n i, ?_,
⟨e.trans (directSumNeZeroMulEquiv ι _ _).symm⟩⟩
rintro ⟨i, hi⟩
exact one_lt_pow₀ (hp _).one_lt hi
theorem finite_of_fg_torsion [hG' : AddGroup.FG G] (hG : AddMonoid.IsTorsion G) : Finite G :=
@Module.finite_of_fg_torsion _ _ _ (Module.Finite.iff_addGroup_fg.mpr hG') <|
AddMonoid.isTorsion_iff_isTorsion_int.mp hG
end AddCommGroup
namespace CommGroup
theorem finite_of_fg_torsion [CommGroup G] [Group.FG G] (hG : Monoid.IsTorsion G) : Finite G :=
@Finite.of_equiv _ _ (AddCommGroup.finite_of_fg_torsion (Additive G) hG) Multiplicative.ofAdd
/-- The **Structure Theorem For Finite Abelian Groups** in a multiplicative version:
A finite commutative group `G` is isomorphic to a finite product of finite cyclic groups. -/
theorem equiv_prod_multiplicative_zmod_of_finite (G : Type*) [CommGroup G] [Finite G] :
∃ (ι : Type) (_ : Fintype ι) (n : ι → ℕ),
(∀ (i : ι), 1 < n i) ∧ Nonempty (G ≃* ((i : ι) → Multiplicative (ZMod (n i)))) := by
obtain ⟨ι, inst, n, h₁, h₂⟩ := AddCommGroup.equiv_directSum_zmod_of_finite' (Additive G)
exact ⟨ι, inst, n, h₁, ⟨MulEquiv.toAdditive.symm <| h₂.some.trans <|
(DirectSum.addEquivProd _).trans (MulEquiv.piMultiplicative _).toAdditiveRight⟩⟩
end CommGroup |
.lake/packages/mathlib/Mathlib/GroupTheory/Congruence/Opposite.lean | import Mathlib.Algebra.Opposites
import Mathlib.GroupTheory.Congruence.Defs
/-!
# Congruences on the opposite of a group
This file defines the order isomorphism between the congruences on a group `G` and the congruences
on the opposite group `Gᵒᵖ`.
-/
variable {M : Type*} [Mul M]
namespace Con
/-- If `c` is a multiplicative congruence on `M`, then `(a, b) ↦ c b.unop a.unop` is a
multiplicative congruence on `Mᵐᵒᵖ`. -/
@[to_additive /-- If `c` is an additive congruence on `M`, then `(a, b) ↦ c b.unop a.unop` is an
additive congruence on `Mᵃᵒᵖ` -/]
def op (c : Con M) : Con Mᵐᵒᵖ where
r a b := c b.unop a.unop
iseqv :=
{ refl := fun a ↦ c.refl a.unop
symm := c.symm
trans := fun h1 h2 ↦ c.trans h2 h1 }
mul' h1 h2 := c.mul h2 h1
/-- If `c` is a multiplicative congruence on `Mᵐᵒᵖ`, then `(a, b) ↦ c bᵒᵖ aᵒᵖ` is a multiplicative
congruence on `M`. -/
@[to_additive /-- If `c` is an additive congruence on `Mᵃᵒᵖ`, then `(a, b) ↦ c bᵒᵖ aᵒᵖ` is an
additive congruence on `M`. -/]
def unop (c : Con Mᵐᵒᵖ) : Con M where
r a b := c (.op b) (.op a)
iseqv :=
{ refl := fun a ↦ c.refl (.op a)
symm := c.symm
trans := fun h1 h2 ↦ c.trans h2 h1 }
mul' h1 h2 := c.mul h2 h1
/--
The multiplicative congruences on `M` bijects to the multiplicative congruences on `Mᵐᵒᵖ`
-/
@[to_additive (attr := simps) /-- The additive congruences on `M` bijects to the additive
congruences on `Mᵃᵒᵖ` -/]
def orderIsoOp : Con M ≃o Con Mᵐᵒᵖ where
toFun := op
invFun := unop
map_rel_iff' {c d} := by rw [le_def, le_def]; constructor <;> intro h _ _ h' <;> exact h h'
end Con |
.lake/packages/mathlib/Mathlib/GroupTheory/Congruence/Basic.lean | import Mathlib.Algebra.Group.Submonoid.Operations
import Mathlib.Data.Setoid.Basic
import Mathlib.GroupTheory.Congruence.Hom
/-!
# Congruence relations
This file proves basic properties of the quotient of a type by a congruence relation.
The second half of the file concerns congruence relations on monoids, in which case the
quotient by the congruence relation is also a monoid. There are results about the universal
property of quotients of monoids, and the isomorphism theorems for monoids.
## Implementation notes
A congruence relation on a monoid `M` can be thought of as a submonoid of `M × M` for which
membership is an equivalence relation, but whilst this fact is established in the file, it is not
used, since this perspective adds more layers of definitional unfolding.
## Tags
congruence, congruence relation, quotient, quotient by congruence relation, monoid,
quotient monoid, isomorphism theorems
-/
variable (M : Type*) {N : Type*} {P : Type*}
open Function Setoid
variable {M}
namespace Con
section
variable [Mul M] [Mul N] [Mul P] (c : Con M)
variable {c}
/-- Given types with multiplications `M, N`, the product of two congruence relations `c` on `M` and
`d` on `N`: `(x₁, x₂), (y₁, y₂) ∈ M × N` are related by `c.prod d` iff `x₁` is related to `y₁`
by `c` and `x₂` is related to `y₂` by `d`. -/
@[to_additive prod /-- Given types with additions `M, N`, the product of two congruence relations
`c` on `M` and `d` on `N`: `(x₁, x₂), (y₁, y₂) ∈ M × N` are related by `c.prod d` iff `x₁`
is related to `y₁` by `c` and `x₂` is related to `y₂` by `d`. -/]
protected def prod (c : Con M) (d : Con N) : Con (M × N) :=
{ c.toSetoid.prod d.toSetoid with
mul' := fun h1 h2 => ⟨c.mul h1.1 h2.1, d.mul h1.2 h2.2⟩ }
/-- The product of an indexed collection of congruence relations. -/
@[to_additive /-- The product of an indexed collection of additive congruence relations. -/]
def pi {ι : Type*} {f : ι → Type*} [∀ i, Mul (f i)] (C : ∀ i, Con (f i)) : Con (∀ i, f i) :=
{ @piSetoid _ _ fun i => (C i).toSetoid with
mul' := fun h1 h2 i => (C i).mul (h1 i) (h2 i) }
/-- Makes an isomorphism of quotients by two congruence relations, given that the relations are
equal. -/
@[to_additive /-- Makes an additive isomorphism of quotients by two additive congruence relations,
given that the relations are equal. -/]
protected def congr {c d : Con M} (h : c = d) : c.Quotient ≃* d.Quotient :=
{ Quotient.congr (Equiv.refl M) <| by apply Con.ext_iff.mp h with
map_mul' := fun x y => by rcases x with ⟨⟩; rcases y with ⟨⟩; rfl }
@[to_additive (attr := simp)]
theorem congr_mk {c d : Con M} (h : c = d) (a : M) :
Con.congr h (a : c.Quotient) = (a : d.Quotient) := rfl
@[to_additive]
theorem le_comap_conGen {M N : Type*} [Mul M] [Mul N] (f : M → N)
(H : ∀ (x y : M), f (x * y) = f x * f y) (rel : N → N → Prop) :
conGen (fun x y ↦ rel (f x) (f y)) ≤ Con.comap f H (conGen rel) := by
intro x y h
simp only [Con.comap_rel]
exact .rec (fun x y h ↦ .of (f x) (f y) h) (fun x ↦ .refl (f x))
(fun _ h ↦ .symm h) (fun _ _ h1 h2 ↦ h1.trans h2) (fun {w x y z} _ _ h1 h2 ↦
(congrArg (fun a ↦ conGen rel a (f (x * z))) (H w y)).mpr
(((congrArg (fun a ↦ conGen rel (f w * f y) a) (H x z))).mpr
(.mul h1 h2))) h
@[to_additive]
theorem comap_conGen_equiv {M N : Type*} [Mul M] [Mul N] (f : MulEquiv M N) (rel : N → N → Prop) :
Con.comap f (map_mul f) (conGen rel) = conGen (fun x y ↦ rel (f x) (f y)) := by
apply le_antisymm _ (le_comap_conGen f (map_mul f) rel)
intro a b h
simp only [Con.comap_rel] at h
have H : ∀ n1 n2, (conGen rel) n1 n2 → ∀ a b, f a = n1 → f b = n2 →
(conGen fun x y ↦ rel (f x) (f y)) a b := by
intro n1 n2 h
induction h with
| of x y h =>
intro _ _ fa fb
apply ConGen.Rel.of
rwa [fa, fb]
| refl x =>
intro _ _ fc fd
rw [f.injective (fc.trans fd.symm)]
exact ConGen.Rel.refl _
| symm _ h => exact fun a b fs fb ↦ ConGen.Rel.symm (h b a fb fs)
| trans _ _ ih ih1 =>
exact fun a b fa fb ↦ Exists.casesOn (f.surjective _) fun c' hc' ↦
ConGen.Rel.trans (ih a c' fa hc') (ih1 c' b hc' fb)
| mul _ _ ih ih1 =>
rename_i w x y z _ _
intro a b fa fb
rw [← f.eq_symm_apply, map_mul] at fa fb
rw [fa, fb]
exact ConGen.Rel.mul (ih (f.symm w) (f.symm x) (by simp) (by simp))
(ih1 (f.symm y) (f.symm z) (by simp) (by simp))
exact H (f a) (f b) h a b (refl _) (refl _)
@[to_additive]
theorem comap_conGen_of_bijective {M N : Type*} [Mul M] [Mul N] (f : M → N)
(hf : Function.Bijective f) (H : ∀ (x y : M), f (x * y) = f x * f y) (rel : N → N → Prop) :
Con.comap f H (conGen rel) = conGen (fun x y ↦ rel (f x) (f y)) :=
comap_conGen_equiv (MulEquiv.ofBijective (MulHom.mk f H) hf) rel
end
section MulOneClass
variable [MulOneClass M] [MulOneClass N] [MulOneClass P] (c : Con M)
/-- The submonoid of `M × M` defined by a congruence relation on a monoid `M`. -/
@[to_additive (attr := coe) /-- The `AddSubmonoid` of `M × M` defined by an additive congruence
relation on an `AddMonoid` `M`. -/]
protected def submonoid : Submonoid (M × M) where
carrier := { x | c x.1 x.2 }
one_mem' := c.iseqv.1 1
mul_mem' := c.mul
variable {c}
/-- The congruence relation on a monoid `M` from a submonoid of `M × M` for which membership
is an equivalence relation. -/
@[to_additive /-- The additive congruence relation on an `AddMonoid` `M` from
an `AddSubmonoid` of `M × M` for which membership is an equivalence relation. -/]
def ofSubmonoid (N : Submonoid (M × M)) (H : Equivalence fun x y => (x, y) ∈ N) : Con M where
r x y := (x, y) ∈ N
iseqv := H
mul' := N.mul_mem
/-- Coercion from a congruence relation `c` on a monoid `M` to the submonoid of `M × M` whose
elements are `(x, y)` such that `x` is related to `y` by `c`. -/
@[to_additive /-- Coercion from a congruence relation `c` on an `AddMonoid` `M`
to the `AddSubmonoid` of `M × M` whose elements are `(x, y)` such that `x`
is related to `y` by `c`. -/]
instance toSubmonoid : Coe (Con M) (Submonoid (M × M)) :=
⟨fun c => c.submonoid⟩
@[to_additive]
theorem mem_coe {c : Con M} {x y} : (x, y) ∈ (↑c : Submonoid (M × M)) ↔ (x, y) ∈ c :=
Iff.rfl
@[to_additive]
theorem to_submonoid_inj (c d : Con M) (H : (c : Submonoid (M × M)) = d) : c = d :=
ext fun x y => show (x, y) ∈ c.submonoid ↔ (x, y) ∈ d from H ▸ Iff.rfl
@[to_additive]
theorem le_iff {c d : Con M} : c ≤ d ↔ (c : Submonoid (M × M)) ≤ d :=
⟨fun h _ H => h H, fun h x y hc => h <| show (x, y) ∈ c from hc⟩
variable (x y : M)
@[to_additive (attr := simp)]
-- Porting note (https://github.com/leanprover-community/mathlib4/issues/11036): removed dot notation
theorem mrange_mk' : MonoidHom.mrange c.mk' = ⊤ :=
MonoidHom.mrange_eq_top.2 mk'_surjective
variable {f : M →* P}
/-- Given a congruence relation `c` on a monoid and a homomorphism `f` constant on `c`'s
equivalence classes, `f` has the same image as the homomorphism that `f` induces on the
quotient. -/
@[to_additive /-- Given an additive congruence relation `c` on an `AddMonoid` and a homomorphism `f`
constant on `c`'s equivalence classes, `f` has the same image as the homomorphism that `f` induces
on the quotient. -/]
theorem lift_range (H : c ≤ ker f) : MonoidHom.mrange (c.lift f H) = MonoidHom.mrange f :=
Submonoid.ext fun x => ⟨by rintro ⟨⟨y⟩, hy⟩; exact ⟨y, hy⟩, fun ⟨y, hy⟩ => ⟨↑y, hy⟩⟩
/-- Given a monoid homomorphism `f`, the induced homomorphism on the quotient by `f`'s kernel has
the same image as `f`. -/
@[to_additive (attr := simp) /-- Given an `AddMonoid` homomorphism `f`, the induced homomorphism
on the quotient by `f`'s kernel has the same image as `f`. -/]
theorem kerLift_range_eq : MonoidHom.mrange (kerLift f) = MonoidHom.mrange f :=
lift_range fun _ _ => id
variable (c)
/-- The **first isomorphism theorem for monoids**. -/
@[to_additive /-- The first isomorphism theorem for `AddMonoid`s. -/]
noncomputable def quotientKerEquivRange (f : M →* P) : (ker f).Quotient ≃* MonoidHom.mrange f :=
{ Equiv.ofBijective
((@MulEquiv.toMonoidHom (MonoidHom.mrange (kerLift f)) _ _ _ <|
MulEquiv.submonoidCongr kerLift_range_eq).comp
(kerLift f).mrangeRestrict) <|
((Equiv.bijective (@MulEquiv.toEquiv (MonoidHom.mrange (kerLift f)) _ _ _ <|
MulEquiv.submonoidCongr kerLift_range_eq)).comp
⟨fun x y h =>
kerLift_injective f <| by rcases x with ⟨⟩; rcases y with ⟨⟩; injections,
fun ⟨w, z, hz⟩ => ⟨z, by rcases hz with ⟨⟩; rfl⟩⟩) with
map_mul' := MonoidHom.map_mul _ }
/-- The first isomorphism theorem for monoids in the case of a homomorphism with right inverse. -/
@[to_additive (attr := simps)
/-- The first isomorphism theorem for `AddMonoid`s in the case of a homomorphism
with right inverse. -/]
def quotientKerEquivOfRightInverse (f : M →* P) (g : P → M) (hf : Function.RightInverse g f) :
(ker f).Quotient ≃* P :=
{ kerLift f with
toFun := kerLift f
invFun := (↑) ∘ g
left_inv := fun x => kerLift_injective _ (by rw [Function.comp_apply, kerLift_mk, hf])
right_inv := fun x => by (conv_rhs => rw [← hf x]); rfl }
/-- The first isomorphism theorem for Monoids in the case of a surjective homomorphism.
For a `computable` version, see `Con.quotientKerEquivOfRightInverse`.
-/
@[to_additive /-- The first isomorphism theorem for `AddMonoid`s in the case of a surjective
homomorphism.
For a `computable` version, see `AddCon.quotientKerEquivOfRightInverse`. -/]
noncomputable def quotientKerEquivOfSurjective (f : M →* P) (hf : Surjective f) :
(ker f).Quotient ≃* P :=
quotientKerEquivOfRightInverse _ _ hf.hasRightInverse.choose_spec
/-- If e : M →* N is surjective then (c.comap e).Quotient ≃* c.Quotient with c : Con N -/
@[to_additive /-- If e : M →* N is surjective then (c.comap e).Quotient ≃* c.Quotient with c :
AddCon N -/]
noncomputable def comapQuotientEquivOfSurj (c : Con M) (f : N →* M) (hf : Function.Surjective f) :
(Con.comap f f.map_mul c).Quotient ≃* c.Quotient :=
(Con.congr Con.comap_eq).trans <| Con.quotientKerEquivOfSurjective (c.mk'.comp f) <|
Con.mk'_surjective.comp hf
@[to_additive (attr := simp)]
lemma comapQuotientEquivOfSurj_mk (c : Con M) {f : N →* M} (hf : Function.Surjective f) (x : N) :
comapQuotientEquivOfSurj c f hf x = f x := rfl
@[to_additive (attr := simp)]
lemma comapQuotientEquivOfSurj_symm_mk (c : Con M) {f : N →* M} (hf) (x : N) :
(comapQuotientEquivOfSurj c f hf).symm (f x) = x :=
(MulEquiv.symm_apply_eq (c.comapQuotientEquivOfSurj f hf)).mpr rfl
/-- This version infers the surjectivity of the function from a MulEquiv function -/
@[to_additive (attr := simp) /-- This version infers the surjectivity of the function from a
MulEquiv function -/]
lemma comapQuotientEquivOfSurj_symm_mk' (c : Con M) (f : N ≃* M) (x : N) :
((@MulEquiv.symm (Con.Quotient (comap ⇑f _ c)) _ _ _
(comapQuotientEquivOfSurj c (f : N →* M) f.surjective)) ⟦f x⟧) = ↑x :=
(MulEquiv.symm_apply_eq (@comapQuotientEquivOfSurj M N _ _ c f _)).mpr rfl
/-- The **second isomorphism theorem for monoids**. -/
@[to_additive /-- The second isomorphism theorem for `AddMonoid`s. -/]
noncomputable def comapQuotientEquiv (f : N →* M) :
(comap f f.map_mul c).Quotient ≃* MonoidHom.mrange (c.mk'.comp f) :=
(Con.congr comap_eq).trans <| quotientKerEquivRange <| c.mk'.comp f
/-- The **third isomorphism theorem for monoids**. -/
@[to_additive /-- The third isomorphism theorem for `AddMonoid`s. -/]
def quotientQuotientEquivQuotient (c d : Con M) (h : c ≤ d) :
(ker (c.map d h)).Quotient ≃* d.Quotient :=
{ Setoid.quotientQuotientEquivQuotient c.toSetoid d.toSetoid h with
map_mul' := fun x y =>
Con.induction_on₂ x y fun w z =>
Con.induction_on₂ w z fun a b =>
show _ = d.mk' a * d.mk' b by rw [← d.mk'.map_mul]; rfl }
end MulOneClass
section Monoids
@[to_additive]
theorem smul {α M : Type*} [MulOneClass M] [SMul α M] [IsScalarTower α M M] (c : Con M) (a : α)
{w x : M} (h : c w x) : c (a • w) (a • x) := by
simpa only [smul_one_mul] using c.mul (c.refl' (a • (1 : M) : M)) h
end Monoids
section Actions
@[to_additive]
instance instSMul {α M : Type*} [MulOneClass M] [SMul α M] [IsScalarTower α M M] (c : Con M) :
SMul α c.Quotient where
smul a := (Quotient.map' (a • ·)) fun _ _ => c.smul a
@[to_additive]
theorem coe_smul {α M : Type*} [MulOneClass M] [SMul α M] [IsScalarTower α M M] (c : Con M)
(a : α) (x : M) : (↑(a • x) : c.Quotient) = a • (x : c.Quotient) :=
rfl
instance instSMulCommClass {α β M : Type*} [MulOneClass M] [SMul α M] [SMul β M]
[IsScalarTower α M M] [IsScalarTower β M M] [SMulCommClass α β M] (c : Con M) :
SMulCommClass α β c.Quotient where
smul_comm a b := Quotient.ind' fun m => congr_arg Quotient.mk'' <| smul_comm a b m
instance instIsScalarTower {α β M : Type*} [MulOneClass M] [SMul α β] [SMul α M] [SMul β M]
[IsScalarTower α M M] [IsScalarTower β M M] [IsScalarTower α β M] (c : Con M) :
IsScalarTower α β c.Quotient where
smul_assoc a b := Quotient.ind' fun m => congr_arg Quotient.mk'' <| smul_assoc a b m
instance instIsCentralScalar {α M : Type*} [MulOneClass M] [SMul α M] [SMul αᵐᵒᵖ M]
[IsScalarTower α M M] [IsScalarTower αᵐᵒᵖ M M] [IsCentralScalar α M] (c : Con M) :
IsCentralScalar α c.Quotient where
op_smul_eq_smul a := Quotient.ind' fun m => congr_arg Quotient.mk'' <| op_smul_eq_smul a m
@[to_additive]
instance mulAction {α M : Type*} [Monoid α] [MulOneClass M] [MulAction α M] [IsScalarTower α M M]
(c : Con M) : MulAction α c.Quotient where
one_smul := Quotient.ind' fun _ => congr_arg Quotient.mk'' <| one_smul _ _
mul_smul _ _ := Quotient.ind' fun _ => congr_arg Quotient.mk'' <| mul_smul _ _ _
instance mulDistribMulAction {α M : Type*} [Monoid α] [Monoid M] [MulDistribMulAction α M]
[IsScalarTower α M M] (c : Con M) : MulDistribMulAction α c.Quotient :=
{ smul_one := fun _ => congr_arg Quotient.mk'' <| smul_one _
smul_mul := fun _ => Quotient.ind₂' fun _ _ => congr_arg Quotient.mk'' <| smul_mul' _ _ _ }
end Actions
end Con |
.lake/packages/mathlib/Mathlib/GroupTheory/Congruence/Defs.lean | import Mathlib.Algebra.Group.InjSurj
import Mathlib.Algebra.Group.Units.Defs
import Mathlib.Data.Setoid.Basic
import Mathlib.Tactic.FastInstance
/-!
# Congruence relations
This file defines congruence relations: equivalence relations that preserve a binary operation,
which in this case is multiplication or addition. The principal definition is a `structure`
extending a `Setoid` (an equivalence relation), and the inductive definition of the smallest
congruence relation containing a binary relation is also given (see `ConGen`).
The file also proves basic properties of the quotient of a type by a congruence relation, and the
complete lattice of congruence relations on a type. We then establish an order-preserving bijection
between the set of congruence relations containing a congruence relation `c` and the set of
congruence relations on the quotient by `c`.
The second half of the file concerns congruence relations on monoids, in which case the
quotient by the congruence relation is also a monoid.
## Implementation notes
The inductive definition of a congruence relation could be a nested inductive type, defined using
the equivalence closure of a binary relation `EqvGen`, but the recursor generated does not work.
A nested inductive definition could conceivably shorten proofs, because they would allow invocation
of the corresponding lemmas about `EqvGen`.
The lemmas `refl`, `symm` and `trans` are not tagged with `@[refl]`, `@[symm]`, and `@[trans]`
respectively as these tags do not work on a structure coerced to a binary relation.
There is a coercion from elements of a type to the element's equivalence class under a
congruence relation.
A congruence relation on a monoid `M` can be thought of as a submonoid of `M × M` for which
membership is an equivalence relation, but whilst this fact is established in the file, it is not
used, since this perspective adds more layers of definitional unfolding.
## Tags
congruence, congruence relation, quotient, quotient by congruence relation, monoid,
quotient monoid, isomorphism theorems
-/
variable (M : Type*) {N : Type*} {P : Type*}
open Function Setoid
/-- A congruence relation on a type with an addition is an equivalence relation which
preserves addition. -/
structure AddCon [Add M] extends Setoid M where
/-- Additive congruence relations are closed under addition -/
add' : ∀ {w x y z}, r w x → r y z → r (w + y) (x + z)
/-- A congruence relation on a type with a multiplication is an equivalence relation which
preserves multiplication. -/
@[to_additive AddCon]
structure Con [Mul M] extends Setoid M where
/-- Congruence relations are closed under multiplication -/
mul' : ∀ {w x y z}, r w x → r y z → r (w * y) (x * z)
/-- The equivalence relation underlying an additive congruence relation. -/
add_decl_doc AddCon.toSetoid
/-- The equivalence relation underlying a multiplicative congruence relation. -/
add_decl_doc Con.toSetoid
variable {M}
/-- The inductively defined smallest additive congruence relation containing a given binary
relation. -/
inductive AddConGen.Rel [Add M] (r : M → M → Prop) : M → M → Prop
| of : ∀ x y, r x y → AddConGen.Rel r x y
| refl : ∀ x, AddConGen.Rel r x x
| symm : ∀ {x y}, AddConGen.Rel r x y → AddConGen.Rel r y x
| trans : ∀ {x y z}, AddConGen.Rel r x y → AddConGen.Rel r y z → AddConGen.Rel r x z
| add : ∀ {w x y z}, AddConGen.Rel r w x → AddConGen.Rel r y z → AddConGen.Rel r (w + y) (x + z)
/-- The inductively defined smallest multiplicative congruence relation containing a given binary
relation. -/
@[to_additive AddConGen.Rel]
inductive ConGen.Rel [Mul M] (r : M → M → Prop) : M → M → Prop
| of : ∀ x y, r x y → ConGen.Rel r x y
| refl : ∀ x, ConGen.Rel r x x
| symm : ∀ {x y}, ConGen.Rel r x y → ConGen.Rel r y x
| trans : ∀ {x y z}, ConGen.Rel r x y → ConGen.Rel r y z → ConGen.Rel r x z
| mul : ∀ {w x y z}, ConGen.Rel r w x → ConGen.Rel r y z → ConGen.Rel r (w * y) (x * z)
/-- The inductively defined smallest multiplicative congruence relation containing a given binary
relation. -/
@[to_additive addConGen /-- The inductively defined smallest additive congruence relation containing
a given binary relation. -/]
def conGen [Mul M] (r : M → M → Prop) : Con M :=
⟨⟨ConGen.Rel r, ⟨ConGen.Rel.refl, ConGen.Rel.symm, ConGen.Rel.trans⟩⟩, ConGen.Rel.mul⟩
namespace Con
section
variable [Mul M] [Mul N] [Mul P] (c : Con M)
@[to_additive]
instance : Inhabited (Con M) :=
⟨conGen EmptyRelation⟩
/-- A coercion from a congruence relation to its underlying binary relation. -/
@[to_additive
/-- A coercion from an additive congruence relation to its underlying binary relation. -/]
instance : FunLike (Con M) M (M → Prop) where
coe c := c.r
coe_injective' x y h := by
rcases x with ⟨⟨x, _⟩, _⟩
rcases y with ⟨⟨y, _⟩, _⟩
have : x = y := h
subst x; rfl
@[to_additive (attr := simp)]
theorem rel_eq_coe (c : Con M) : c.r = c :=
rfl
/-- Congruence relations are reflexive. -/
@[to_additive /-- Additive congruence relations are reflexive. -/]
protected theorem refl (x) : c x x :=
c.toSetoid.refl' x
/-- Congruence relations are symmetric. -/
@[to_additive /-- Additive congruence relations are symmetric. -/]
protected theorem symm {x y} : c x y → c y x := c.toSetoid.symm'
/-- Congruence relations are transitive. -/
@[to_additive /-- Additive congruence relations are transitive. -/]
protected theorem trans {x y z} : c x y → c y z → c x z := c.toSetoid.trans'
/-- Multiplicative congruence relations preserve multiplication. -/
@[to_additive /-- Additive congruence relations preserve addition. -/]
protected theorem mul {w x y z} : c w x → c y z → c (w * y) (x * z) := c.mul'
@[to_additive (attr := simp)]
theorem rel_mk {s : Setoid M} {h a b} : Con.mk s h a b ↔ r a b :=
Iff.rfl
/-- Given a type `M` with a multiplication, a congruence relation `c` on `M`, and elements of `M`
`x, y`, `(x, y) ∈ M × M` iff `x` is related to `y` by `c`. -/
@[to_additive instMembershipProd
/-- Given a type `M` with an addition, `x, y ∈ M`, and an additive congruence relation
`c` on `M`, `(x, y) ∈ M × M` iff `x` is related to `y` by `c`. -/]
instance instMembershipProd : Membership (M × M) (Con M) :=
⟨fun c x => c x.1 x.2⟩
variable {c}
/-- The map sending a congruence relation to its underlying binary relation is injective. -/
@[to_additive /-- The map sending an additive congruence relation to its underlying binary relation
is injective. -/]
theorem ext' {c d : Con M} (H : ⇑c = ⇑d) : c = d := DFunLike.coe_injective H
/-- Extensionality rule for congruence relations. -/
@[to_additive (attr := ext) /-- Extensionality rule for additive congruence relations. -/]
theorem ext {c d : Con M} (H : ∀ x y, c x y ↔ d x y) : c = d :=
ext' <| by ext; apply H
/-- The map sending a congruence relation to its underlying equivalence relation is injective. -/
@[to_additive /-- The map sending an additive congruence relation to its underlying equivalence
relation is injective. -/]
theorem toSetoid_inj {c d : Con M} (H : c.toSetoid = d.toSetoid) : c = d :=
ext <| Setoid.ext_iff.1 H
/-- Two congruence relations are equal iff their underlying binary relations are equal. -/
@[to_additive /-- Two additive congruence relations are equal iff their underlying binary relations
are equal. -/]
theorem coe_inj {c d : Con M} : ⇑c = ⇑d ↔ c = d := DFunLike.coe_injective.eq_iff
variable (c)
-- Quotients
/-- Defining the quotient by a congruence relation of a type with a multiplication. -/
@[to_additive /-- Defining the quotient by an additive congruence relation of a type with
an addition. -/]
protected def Quotient :=
Quotient c.toSetoid
variable {c}
/-- The morphism into the quotient by a congruence relation -/
@[to_additive (attr := coe)
/-- The morphism into the quotient by an additive congruence relation -/]
def toQuotient : M → c.Quotient :=
Quotient.mk''
variable (c)
/-- Coercion from a type with a multiplication to its quotient by a congruence relation.
See Note [use has_coe_t]. -/
@[to_additive /-- Coercion from a type with an addition to its quotient by an additive congruence
relation -/]
instance (priority := 10) : CoeTC M c.Quotient :=
⟨toQuotient⟩
-- Lower the priority since it unifies with any quotient type.
/-- The quotient by a decidable congruence relation has decidable equality. -/
@[to_additive
/-- The quotient by a decidable additive congruence relation has decidable equality. -/]
instance (priority := 500) [∀ a b, Decidable (c a b)] : DecidableEq c.Quotient :=
inferInstanceAs (DecidableEq (Quotient c.toSetoid))
@[to_additive (attr := simp)]
theorem quot_mk_eq_coe {M : Type*} [Mul M] (c : Con M) (x : M) : Quot.mk c x = (x : c.Quotient) :=
rfl
-- Porting note (https://github.com/leanprover-community/mathlib4/issues/11215): TODO: restore `elab_as_elim`
/-- The function on the quotient by a congruence relation `c` induced by a function that is
constant on `c`'s equivalence classes. -/
@[to_additive /-- The function on the quotient by a congruence relation `c`
induced by a function that is constant on `c`'s equivalence classes. -/]
protected def liftOn {β} {c : Con M} (q : c.Quotient) (f : M → β) (h : ∀ a b, c a b → f a = f b) :
β :=
Quotient.liftOn' q f h
-- Porting note (https://github.com/leanprover-community/mathlib4/issues/11215): TODO: restore `elab_as_elim`
/-- The binary function on the quotient by a congruence relation `c` induced by a binary function
that is constant on `c`'s equivalence classes. -/
@[to_additive /-- The binary function on the quotient by a congruence relation `c`
induced by a binary function that is constant on `c`'s equivalence classes. -/]
protected def liftOn₂ {β} {c : Con M} (q r : c.Quotient) (f : M → M → β)
(h : ∀ a₁ a₂ b₁ b₂, c a₁ b₁ → c a₂ b₂ → f a₁ a₂ = f b₁ b₂) : β :=
Quotient.liftOn₂' q r f h
/-- A version of `Quotient.hrecOn₂'` for quotients by `Con`. -/
@[to_additive /-- A version of `Quotient.hrecOn₂'` for quotients by `AddCon`. -/]
protected def hrecOn₂ {cM : Con M} {cN : Con N} {φ : cM.Quotient → cN.Quotient → Sort*}
(a : cM.Quotient) (b : cN.Quotient) (f : ∀ (x : M) (y : N), φ x y)
(h : ∀ x y x' y', cM x x' → cN y y' → f x y ≍ f x' y') : φ a b :=
Quotient.hrecOn₂' a b f h
@[to_additive (attr := simp)]
theorem hrec_on₂_coe {cM : Con M} {cN : Con N} {φ : cM.Quotient → cN.Quotient → Sort*} (a : M)
(b : N) (f : ∀ (x : M) (y : N), φ x y)
(h : ∀ x y x' y', cM x x' → cN y y' → f x y ≍ f x' y') :
Con.hrecOn₂ (↑a) (↑b) f h = f a b :=
rfl
variable {c}
/-- The inductive principle used to prove propositions about the elements of a quotient by a
congruence relation. -/
@[to_additive (attr := elab_as_elim) /-- The inductive principle used to prove propositions about
the elements of a quotient by an additive congruence relation. -/]
protected theorem induction_on {C : c.Quotient → Prop} (q : c.Quotient) (H : ∀ x : M, C x) : C q :=
Quotient.inductionOn' q H
/-- A version of `Con.induction_on` for predicates which takes two arguments. -/
@[to_additive (attr := elab_as_elim)
/-- A version of `AddCon.induction_on` for predicates which takes two arguments. -/]
protected theorem induction_on₂ {d : Con N} {C : c.Quotient → d.Quotient → Prop} (p : c.Quotient)
(q : d.Quotient) (H : ∀ (x : M) (y : N), C x y) : C p q :=
Quotient.inductionOn₂' p q H
variable (c)
/-- Two elements are related by a congruence relation `c` iff they are represented by the same
element of the quotient by `c`. -/
@[to_additive (attr := simp) /-- Two elements are related by an additive congruence relation `c` iff
they are represented by the same element of the quotient by `c`. -/]
protected theorem eq {a b : M} : (a : c.Quotient) = (b : c.Quotient) ↔ c a b :=
Quotient.eq''
/-- The multiplication induced on the quotient by a congruence relation on a type with a
multiplication. -/
@[to_additive /-- The addition induced on the quotient by an additive congruence relation on a type
with an addition. -/]
instance hasMul : Mul c.Quotient :=
⟨Quotient.map₂ (· * ·) fun _ _ h1 _ _ h2 => c.mul h1 h2⟩
variable {c}
/-- The coercion to the quotient of a congruence relation commutes with multiplication (by
definition). -/
@[to_additive (attr := simp) /-- The coercion to the quotient of an additive congruence relation
commutes with addition (by definition). -/]
theorem coe_mul (x y : M) : (↑(x * y) : c.Quotient) = ↑x * ↑y :=
rfl
/-- Definition of the function on the quotient by a congruence relation `c` induced by a function
that is constant on `c`'s equivalence classes. -/
@[to_additive (attr := simp) /-- Definition of the function on the quotient by an additive
congruence relation `c` induced by a function that is constant on `c`'s equivalence classes. -/]
protected theorem liftOn_coe {β} (c : Con M) (f : M → β) (h : ∀ a b, c a b → f a = f b) (x : M) :
Con.liftOn (x : c.Quotient) f h = f x :=
rfl
-- The complete lattice of congruence relations on a type
/-- For congruence relations `c, d` on a type `M` with a multiplication, `c ≤ d` iff `∀ x y ∈ M`,
`x` is related to `y` by `d` if `x` is related to `y` by `c`. -/
@[to_additive /-- For additive congruence relations `c, d` on a type `M` with an addition, `c ≤ d`
iff `∀ x y ∈ M`, `x` is related to `y` by `d` if `x` is related to `y` by `c`. -/]
instance : LE (Con M) where
le c d := ∀ ⦃x y⦄, c x y → d x y
/-- Definition of `≤` for congruence relations. -/
@[to_additive /-- Definition of `≤` for additive congruence relations. -/]
theorem le_def {c d : Con M} : c ≤ d ↔ ∀ {x y}, c x y → d x y :=
Iff.rfl
/-- The infimum of a set of congruence relations on a given type with a multiplication. -/
@[to_additive /-- The infimum of a set of additive congruence relations on a given type with
an addition. -/]
instance : InfSet (Con M) where
sInf S :=
{ r := fun x y => ∀ c : Con M, c ∈ S → c x y
iseqv := ⟨fun x c _ => c.refl x, fun h c hc => c.symm <| h c hc,
fun h1 h2 c hc => c.trans (h1 c hc) <| h2 c hc⟩
mul' := fun h1 h2 c hc => c.mul (h1 c hc) <| h2 c hc }
/-- The infimum of a set of congruence relations is the same as the infimum of the set's image
under the map to the underlying equivalence relation. -/
@[to_additive /-- The infimum of a set of additive congruence relations is the same as the infimum
of the set's image under the map to the underlying equivalence relation. -/]
theorem sInf_toSetoid (S : Set (Con M)) : (sInf S).toSetoid = sInf (toSetoid '' S) :=
Setoid.ext fun x y =>
⟨fun h r ⟨c, hS, hr⟩ => by rw [← hr]; exact h c hS, fun h c hS => h c.toSetoid ⟨c, hS, rfl⟩⟩
/-- The infimum of a set of congruence relations is the same as the infimum of the set's image
under the map to the underlying binary relation. -/
@[to_additive (attr := simp, norm_cast)
/-- The infimum of a set of additive congruence relations is the same as the infimum
of the set's image under the map to the underlying binary relation. -/]
theorem coe_sInf (S : Set (Con M)) :
⇑(sInf S) = sInf ((⇑) '' S) := by
ext
simp only [sInf_image, iInf_apply, iInf_Prop_eq]
rfl
@[to_additive (attr := simp, norm_cast)]
theorem coe_iInf {ι : Sort*} (f : ι → Con M) : ⇑(iInf f) = ⨅ i, ⇑(f i) := by
rw [iInf, coe_sInf, ← Set.range_comp, sInf_range, Function.comp_def]
@[to_additive]
instance : PartialOrder (Con M) where
le_refl _ _ _ := id
le_trans _ _ _ h1 h2 _ _ h := h2 <| h1 h
le_antisymm _ _ hc hd := ext fun _ _ => ⟨fun h => hc h, fun h => hd h⟩
/-- The complete lattice of congruence relations on a given type with a multiplication. -/
@[to_additive /-- The complete lattice of additive congruence relations on a given type with
an addition. -/]
instance : CompleteLattice (Con M) where
__ := completeLatticeOfInf (Con M) fun s =>
⟨fun r hr x y h => (h : ∀ r ∈ s, (r : Con M) x y) r hr, fun r hr x y h r' hr' =>
hr hr'
h⟩
inf c d := ⟨c.toSetoid ⊓ d.toSetoid, fun h1 h2 => ⟨c.mul h1.1 h2.1, d.mul h1.2 h2.2⟩⟩
inf_le_left _ _ := fun _ _ h => h.1
inf_le_right _ _ := fun _ _ h => h.2
le_inf _ _ _ hb hc := fun _ _ h => ⟨hb h, hc h⟩
top := { Setoid.completeLattice.top with mul' := by tauto }
le_top _ := fun _ _ _ => trivial
bot := { Setoid.completeLattice.bot with mul' := fun h1 h2 => h1 ▸ h2 ▸ rfl }
bot_le c := fun x _ h => h ▸ c.refl x
/-- The infimum of two congruence relations equals the infimum of the underlying binary
operations. -/
@[to_additive (attr := simp, norm_cast)
/-- The infimum of two additive congruence relations equals the infimum of the underlying binary
operations. -/]
theorem coe_inf {c d : Con M} : ⇑(c ⊓ d) = ⇑c ⊓ ⇑d :=
rfl
/-- Definition of the infimum of two congruence relations. -/
@[to_additive /-- Definition of the infimum of two additive congruence relations. -/]
theorem inf_iff_and {c d : Con M} {x y} : (c ⊓ d) x y ↔ c x y ∧ d x y :=
Iff.rfl
/-- The inductively defined smallest congruence relation containing a binary relation `r` equals
the infimum of the set of congruence relations containing `r`. -/
@[to_additive addConGen_eq /-- The inductively defined smallest additive congruence relation
containing a binary relation `r` equals the infimum of the set of additive congruence relations
containing `r`. -/]
theorem conGen_eq (r : M → M → Prop) : conGen r = sInf { s : Con M | ∀ x y, r x y → s x y } :=
le_antisymm
(le_sInf (fun s hs x y (hxy : (conGen r) x y) =>
show s x y by
apply ConGen.Rel.recOn (motive := fun x y _ => s x y) hxy
· exact fun x y h => hs x y h
· exact s.refl'
· exact fun _ => s.symm'
· exact fun _ _ => s.trans'
· exact fun _ _ => s.mul))
(sInf_le ConGen.Rel.of)
/-- The smallest congruence relation containing a binary relation `r` is contained in any
congruence relation containing `r`. -/
@[to_additive addConGen_le /-- The smallest additive congruence relation containing a binary
relation `r` is contained in any additive congruence relation containing `r`. -/]
theorem conGen_le {r : M → M → Prop} {c : Con M} (h : ∀ x y, r x y → c x y) :
conGen r ≤ c := by rw [conGen_eq]; exact sInf_le h
/-- Given binary relations `r, s` with `r` contained in `s`, the smallest congruence relation
containing `s` contains the smallest congruence relation containing `r`. -/
@[to_additive addConGen_mono /-- Given binary relations `r, s` with `r` contained in `s`, the
smallest additive congruence relation containing `s` contains the smallest additive congruence
relation containing `r`. -/]
theorem conGen_mono {r s : M → M → Prop} (h : ∀ x y, r x y → s x y) : conGen r ≤ conGen s :=
conGen_le fun x y hr => ConGen.Rel.of _ _ <| h x y hr
/-- Congruence relations equal the smallest congruence relation in which they are contained. -/
@[to_additive (attr := simp) addConGen_of_addCon /-- Additive congruence relations equal the
smallest additive congruence relation in which they are contained. -/]
theorem conGen_of_con (c : Con M) : conGen c = c :=
le_antisymm (by rw [conGen_eq]; exact sInf_le fun _ _ => id) ConGen.Rel.of
/-- The map sending a binary relation to the smallest congruence relation in which it is
contained is idempotent. -/
@[to_additive addConGen_idem /-- The map sending a binary relation to the smallest additive
congruence relation in which it is contained is idempotent. -/]
theorem conGen_idem (r : M → M → Prop) : conGen (conGen r) = conGen r := by simp
/-- The supremum of congruence relations `c, d` equals the smallest congruence relation containing
the binary relation '`x` is related to `y` by `c` or `d`'. -/
@[to_additive sup_eq_addConGen /-- The supremum of additive congruence relations `c, d` equals the
smallest additive congruence relation containing the binary relation '`x` is related to `y`
by `c` or `d`'. -/]
theorem sup_eq_conGen (c d : Con M) : c ⊔ d = conGen fun x y => c x y ∨ d x y := by
rw [conGen_eq]
apply congr_arg sInf
simp only [le_def, or_imp, ← forall_and]
/-- The supremum of two congruence relations equals the smallest congruence relation containing
the supremum of the underlying binary operations. -/
@[to_additive /-- The supremum of two additive congruence relations equals the smallest additive
congruence relation containing the supremum of the underlying binary operations. -/]
theorem sup_def {c d : Con M} : c ⊔ d = conGen (⇑c ⊔ ⇑d) := by rw [sup_eq_conGen]; rfl
/-- The supremum of a set of congruence relations `S` equals the smallest congruence relation
containing the binary relation 'there exists `c ∈ S` such that `x` is related to `y` by `c`'. -/
@[to_additive sSup_eq_addConGen /-- The supremum of a set of additive congruence relations `S`
equals the smallest additive congruence relation containing the binary relation 'there exists
`c ∈ S` such that `x` is related to `y` by `c`'. -/]
theorem sSup_eq_conGen (S : Set (Con M)) :
sSup S = conGen fun x y => ∃ c : Con M, c ∈ S ∧ c x y := by
rw [conGen_eq]
apply congr_arg sInf
ext
exact ⟨fun h _ _ ⟨r, hr⟩ => h hr.1 hr.2, fun h r hS _ _ hr => h _ _ ⟨r, hS, hr⟩⟩
/-- The supremum of a set of congruence relations is the same as the smallest congruence relation
containing the supremum of the set's image under the map to the underlying binary relation. -/
@[to_additive /-- The supremum of a set of additive congruence relations is the same as the smallest
additive congruence relation containing the supremum of the set's image under the map to the
underlying binary relation. -/]
theorem sSup_def {S : Set (Con M)} :
sSup S = conGen (sSup ((⇑) '' S)) := by
rw [sSup_eq_conGen, sSup_image]
congr with (x y)
simp only [iSup_apply, iSup_Prop_eq, exists_prop]
variable (M)
/-- There is a Galois insertion of congruence relations on a type with a multiplication `M` into
binary relations on `M`. -/
@[to_additive /-- There is a Galois insertion of additive congruence relations on a type with
an addition `M` into binary relations on `M`. -/]
protected def gi : @GaloisInsertion (M → M → Prop) (Con M) _ _ conGen DFunLike.coe where
choice r _ := conGen r
gc _ c := ⟨fun H _ _ h => H <| ConGen.Rel.of _ _ h, @fun H => conGen_of_con c ▸ conGen_mono H⟩
le_l_u x := (conGen_of_con x).symm ▸ le_refl x
choice_eq _ _ := rfl
variable {M} (c)
/-- Given types with multiplications `M, N` and a congruence relation `c` on `N`, a
multiplication-preserving map `f : M → N` induces a congruence relation on `f`'s domain
defined by '`x ≈ y` iff `f(x)` is related to `f(y)` by `c`.' -/
@[to_additive /-- Given types with additions `M, N` and an additive congruence relation `c` on `N`,
an addition-preserving map `f : M → N` induces an additive congruence relation on `f`'s domain
defined by '`x ≈ y` iff `f(x)` is related to `f(y)` by `c`.' -/]
def comap (f : M → N) (H : ∀ x y, f (x * y) = f x * f y) (c : Con N) : Con M :=
{ c.toSetoid.comap f with
mul' := @fun w x y z h1 h2 => show c (f (w * y)) (f (x * z)) by rw [H, H]; exact c.mul h1 h2 }
@[to_additive (attr := simp)]
theorem comap_rel {f : M → N} (H : ∀ x y, f (x * y) = f x * f y) {c : Con N} {x y : M} :
comap f H c x y ↔ c (f x) (f y) :=
Iff.rfl
section
open Quotient
end
end
section MulOneClass
variable [MulOneClass M] (c : Con M)
/-- The quotient of a monoid by a congruence relation is a monoid. -/
@[to_additive /-- The quotient of an `AddMonoid` by an additive congruence relation is
an `AddMonoid`. -/]
instance mulOneClass : MulOneClass c.Quotient where
one := ((1 : M) : c.Quotient)
mul_one x := Quotient.inductionOn' x fun _ => congr_arg ((↑) : M → c.Quotient) <| mul_one _
one_mul x := Quotient.inductionOn' x fun _ => congr_arg ((↑) : M → c.Quotient) <| one_mul _
variable {c}
/-- The 1 of the quotient of a monoid by a congruence relation is the equivalence class of the
monoid's 1. -/
@[to_additive (attr := simp) /-- The 0 of the quotient of an `AddMonoid` by an additive congruence
relation is the equivalence class of the `AddMonoid`'s 0. -/]
theorem coe_one : ((1 : M) : c.Quotient) = 1 :=
rfl
/-- There exists an element of the quotient of a monoid by a congruence relation (namely 1). -/
@[to_additive /-- There exists an element of the quotient of an `AddMonoid` by a congruence relation
(namely 0). -/]
instance Quotient.inhabited : Inhabited c.Quotient :=
⟨((1 : M) : c.Quotient)⟩
end MulOneClass
section Monoids
/-- Multiplicative congruence relations preserve natural powers. -/
@[to_additive /-- Additive congruence relations preserve natural scaling. -/]
protected theorem pow {M : Type*} [Monoid M] (c : Con M) :
∀ (n : ℕ) {w x}, c w x → c (w ^ n) (x ^ n)
| 0, w, x, _ => by simpa using c.refl _
| Nat.succ n, w, x, h => by simpa [pow_succ] using c.mul (Con.pow c n h) h
@[to_additive]
instance one [Mul M] [One M] (c : Con M) : One c.Quotient where
-- Using Quotient.mk'' here instead of c.toQuotient
-- since c.toQuotient is not reducible.
-- This would lead to non-defeq diamonds since this instance ends up in
-- quotients modulo ideals.
one := Quotient.mk'' (1 : M)
-- one := ((1 : M) : c.Quotient)
instance _root_.AddCon.Quotient.nsmul {M : Type*} [AddMonoid M] (c : AddCon M) :
SMul ℕ c.Quotient where
smul n := (Quotient.map' (n • ·)) fun _ _ => c.nsmul n
@[to_additive existing AddCon.Quotient.nsmul]
instance {M : Type*} [Monoid M] (c : Con M) : Pow c.Quotient ℕ where
pow x n := Quotient.map' (fun x => x ^ n) (fun _ _ => c.pow n) x
/-- The quotient of a semigroup by a congruence relation is a semigroup. -/
@[to_additive /-- The quotient of an `AddSemigroup` by an additive congruence relation is
an `AddSemigroup`. -/]
instance semigroup {M : Type*} [Semigroup M] (c : Con M) : Semigroup c.Quotient := fast_instance%
Function.Surjective.semigroup _ Quotient.mk''_surjective fun _ _ => rfl
/-- The quotient of a commutative magma by a congruence relation is a commutative magma. -/
@[to_additive /-- The quotient of an `AddCommMagma` by an additive congruence relation is
an `AddCommMagma`. -/]
instance commMagma {M : Type*} [CommMagma M] (c : Con M) : CommMagma c.Quotient := fast_instance%
Function.Surjective.commMagma _ Quotient.mk''_surjective fun _ _ => rfl
/-- The quotient of a commutative semigroup by a congruence relation is a semigroup. -/
@[to_additive /-- The quotient of an `AddCommSemigroup` by an additive congruence relation is
an `AddCommSemigroup`. -/]
instance commSemigroup {M : Type*} [CommSemigroup M] (c : Con M) : CommSemigroup c.Quotient :=
Function.Surjective.commSemigroup _ Quotient.mk''_surjective fun _ _ => rfl
/-- The quotient of a monoid by a congruence relation is a monoid. -/
@[to_additive /-- The quotient of an `AddMonoid` by an additive congruence relation is
an `AddMonoid`. -/]
instance monoid {M : Type*} [Monoid M] (c : Con M) : Monoid c.Quotient := fast_instance%
Function.Surjective.monoid _ Quotient.mk''_surjective rfl (fun _ _ => rfl) fun _ _ => rfl
/-- The quotient of a `CommMonoid` by a congruence relation is a `CommMonoid`. -/
@[to_additive /-- The quotient of an `AddCommMonoid` by an additive congruence
relation is an `AddCommMonoid`. -/]
instance commMonoid {M : Type*} [CommMonoid M] (c : Con M) : CommMonoid c.Quotient := fast_instance%
fast_instance% Function.Surjective.commMonoid _ Quotient.mk''_surjective rfl
(fun _ _ => rfl) fun _ _ => rfl
/-- Sometimes, a group is defined as a quotient of a monoid by a congruence relation.
Usually, the inverse operation is defined as `Setoid.map f _` for some `f`.
This lemma allows to avoid code duplication in the definition of the inverse operation:
instead of proving both `∀ x y, c x y → c (f x) (f y)` (to define the operation)
and `∀ x, c (f x * x) 1` (to prove the group laws), one can only prove the latter. -/
@[to_additive /-- Sometimes, an additive group is defined as a quotient of a monoid
by an additive congruence relation.
Usually, the inverse operation is defined as `Setoid.map f _` for some `f`.
This lemma allows to avoid code duplication in the definition of the inverse operation:
instead of proving both `∀ x y, c x y → c (f x) (f y)` (to define the operation)
and `∀ x, c (f x + x) 0` (to prove the group laws), one can only prove the latter. -/]
theorem map_of_mul_left_rel_one [Monoid M] (c : Con M)
(f : M → M) (hf : ∀ x, c (f x * x) 1) {x y} (h : c x y) : c (f x) (f y) := by
simp only [← Con.eq, coe_one, coe_mul] at *
have hf' : ∀ x : M, (x : c.Quotient) * f x = 1 := fun x ↦
calc
(x : c.Quotient) * f x = f (f x) * f x * (x * f x) := by simp [hf]
_ = f (f x) * (f x * x) * f x := by simp_rw [mul_assoc]
_ = 1 := by simp [hf]
have : (⟨_, _, hf' x, hf x⟩ : c.Quotientˣ) = ⟨_, _, hf' y, hf y⟩ := Units.ext h
exact congr_arg Units.inv this
end Monoids
section Groups
variable [Group M] (c : Con M)
/-- Multiplicative congruence relations preserve inversion. -/
@[to_additive /-- Additive congruence relations preserve negation. -/]
protected theorem inv {x y} (h : c x y) : c x⁻¹ y⁻¹ :=
c.map_of_mul_left_rel_one Inv.inv (fun x => by simp only [inv_mul_cancel, c.refl 1]) h
/-- Multiplicative congruence relations preserve division. -/
@[to_additive /-- Additive congruence relations preserve subtraction. -/]
protected theorem div : ∀ {w x y z}, c w x → c y z → c (w / y) (x / z) := @fun w x y z h1 h2 => by
simpa only [div_eq_mul_inv] using c.mul h1 (c.inv h2)
/-- Multiplicative congruence relations preserve integer powers. -/
@[to_additive /-- Additive congruence relations preserve integer scaling. -/]
protected theorem zpow : ∀ (n : ℤ) {w x}, c w x → c (w ^ n) (x ^ n)
| Int.ofNat n, w, x, h => by simpa only [zpow_natCast, Int.ofNat_eq_coe] using c.pow n h
| Int.negSucc n, w, x, h => by simpa only [zpow_negSucc] using c.inv (c.pow _ h)
/-- The inversion induced on the quotient by a congruence relation on a type with an
inversion. -/
@[to_additive /-- The negation induced on the quotient by an additive congruence relation on a type
with a negation. -/]
instance hasInv : Inv c.Quotient :=
⟨(Quotient.map' Inv.inv) fun _ _ => c.inv⟩
/-- The division induced on the quotient by a congruence relation on a type with a
division. -/
@[to_additive /-- The subtraction induced on the quotient by an additive congruence relation on a
type with a subtraction. -/]
instance hasDiv : Div c.Quotient :=
⟨(Quotient.map₂ (· / ·)) fun _ _ h₁ _ _ h₂ => c.div h₁ h₂⟩
/-- The integer scaling induced on the quotient by a congruence relation on a type with a
subtraction. -/
instance _root_.AddCon.Quotient.zsmul {M : Type*} [AddGroup M] (c : AddCon M) :
SMul ℤ c.Quotient :=
⟨fun z => (Quotient.map' (z • ·)) fun _ _ => c.zsmul z⟩
/-- The integer power induced on the quotient by a congruence relation on a type with a
division. -/
@[to_additive existing AddCon.Quotient.zsmul]
instance zpowinst : Pow c.Quotient ℤ :=
⟨fun x z => Quotient.map' (fun x => x ^ z) (fun _ _ h => c.zpow z h) x⟩
/-- The quotient of a group by a congruence relation is a group. -/
@[to_additive /-- The quotient of an `AddGroup` by an additive congruence relation is
an `AddGroup`. -/]
instance group : Group c.Quotient := fast_instance%
Function.Surjective.group Quotient.mk'' Quotient.mk''_surjective
rfl (fun _ _ => rfl) (fun _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl) fun _ _ => rfl
/-- The quotient of a `CommGroup` by a congruence relation is a `CommGroup`. -/
@[to_additive /-- The quotient of an `AddCommGroup` by an additive congruence
relation is an `AddCommGroup`. -/]
instance commGroup {M : Type*} [CommGroup M] (c : Con M) : CommGroup c.Quotient := fast_instance%
Function.Surjective.commGroup _ Quotient.mk''_surjective rfl (fun _ _ => rfl) (fun _ => rfl)
(fun _ _ => rfl) (fun _ _ => rfl) (fun _ _ => rfl)
end Groups
section Units
variable {α : Type*} [Monoid M] {c : Con M}
/-- In order to define a function `(Con.Quotient c)ˣ → α` on the units of `Con.Quotient c`,
where `c : Con M` is a multiplicative congruence on a monoid, it suffices to define a function `f`
that takes elements `x y : M` with proofs of `c (x * y) 1` and `c (y * x) 1`, and returns an element
of `α` provided that `f x y _ _ = f x' y' _ _` whenever `c x x'` and `c y y'`. -/
@[to_additive]
def liftOnUnits (u : Units c.Quotient) (f : ∀ x y : M, c (x * y) 1 → c (y * x) 1 → α)
(Hf : ∀ x y hxy hyx x' y' hxy' hyx',
c x x' → c y y' → f x y hxy hyx = f x' y' hxy' hyx') : α := by
refine
Con.hrecOn₂ (cN := c) (φ := fun x y => x * y = 1 → y * x = 1 → α) (u : c.Quotient)
(↑u⁻¹ : c.Quotient)
(fun (x y : M) (hxy : (x * y : c.Quotient) = 1) (hyx : (y * x : c.Quotient) = 1) =>
f x y (c.eq.1 hxy) (c.eq.1 hyx))
(fun x y x' y' hx hy => ?_) u.3 u.4
refine Function.hfunext ?_ ?_
· rw [c.eq.2 hx, c.eq.2 hy]
· rintro Hxy Hxy' -
refine Function.hfunext ?_ ?_
· rw [c.eq.2 hx, c.eq.2 hy]
· rintro Hyx Hyx' -
exact heq_of_eq (Hf _ _ _ _ _ _ _ _ hx hy)
/-- In order to define a function `(Con.Quotient c)ˣ → α` on the units of `Con.Quotient c`,
where `c : Con M` is a multiplicative congruence on a monoid, it suffices to define a function `f`
that takes elements `x y : M` with proofs of `c (x * y) 1` and `c (y * x) 1`, and returns an element
of `α` provided that `f x y _ _ = f x' y' _ _` whenever `c x x'` and `c y y'`. -/
add_decl_doc AddCon.liftOnAddUnits
@[to_additive (attr := simp)]
theorem liftOnUnits_mk (f : ∀ x y : M, c (x * y) 1 → c (y * x) 1 → α)
(Hf : ∀ x y hxy hyx x' y' hxy' hyx', c x x' → c y y' → f x y hxy hyx = f x' y' hxy' hyx')
(x y : M) (hxy hyx) :
liftOnUnits ⟨(x : c.Quotient), y, hxy, hyx⟩ f Hf = f x y (c.eq.1 hxy) (c.eq.1 hyx) :=
rfl
@[to_additive (attr := elab_as_elim)]
theorem induction_on_units {p : Units c.Quotient → Prop} (u : Units c.Quotient)
(H : ∀ (x y : M) (hxy : c (x * y) 1) (hyx : c (y * x) 1), p ⟨x, y, c.eq.2 hxy, c.eq.2 hyx⟩) :
p u := by
rcases u with ⟨⟨x⟩, ⟨y⟩, h₁, h₂⟩
exact H x y (c.eq.1 h₁) (c.eq.1 h₂)
end Units
end Con |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.