Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

BG §5: narrow ppp-groups, Lemmas 5.1 and 5.2

Definition
OddOrder_BG_Ch1_Preliminary_S05_NarrowSCN

by burkh4rt · Nov 12, 2026 · Mathlib 0df444a (Lean v4.33.1)

feit-thompsonfinite-groupsgroup-theoryishida-odd-order

Bender–Glauberman, Local Analysis for the Odd Order Theorem, Chapter I §5: Lemma 5.1 (nonemptiness of SCN3\mathrm{SCN}_3SCN3​ and the embedding of a normal E2\mathcal{E}^2E2) and Lemma 5.2 (the central structure of T=CR(W)T=C_R(W)T=CR​(W)), with the helper layer for Ω1(Z(R))\Omega_1(Z(R))Ω1​(Z(R)).

The main definition is omega1Center, Ω1(Z(R))\Omega_1(Z(R))Ω1​(Z(R)), the subgroup generated by the order-ppp elements of the center.

The bundle also proves 37 supporting lemmas used by later statements.

Definition code
/-
Copyright (c) 2026 Yawara Ishida. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Yawara Ishida
-/
-- From github.com/yawara/odd-order @ 20a6fccbb63c (Apache-2.0; LICENSE at that commit):
--   OddOrder/BG/Ch1_Preliminary/S05_NarrowSCN.lean
-- Generated for Prove2Me by deleting declarations; the remaining commands are verbatim except:
-- `private` dropped where another file uses the declaration, and a solution's main theorem
-- renamed `_root_.solution` (platform convention).
import Definitions.Def_OddOrder_BG_Ch1_Preliminary_S01_Solvable
import Definitions.Def_OddOrder_BG_Ch1_Preliminary_S04_PGroupsSmallRank
import Definitions.Def_OddOrder_BG_Ch1_Preliminary_S04d_GorThm415
import Definitions.Def_OddOrder_BG_Ch1_Preliminary_S04f_Blackburn
import Definitions.Def_OddOrder_BG_Ch1_Preliminary_S04g_Thm418
import Definitions.Def_OddOrder_BG_Ch1_Preliminary_PLength
import Definitions.Def_OddOrder_GroupTheory_NarrowPGroup
import Definitions.Def_OddOrder_GroupTheory_SCN
import Definitions.Def_OddOrder_GroupTheory_OmegaSubgroup
import Definitions.Def_OddOrder_GroupTheory_OpResidual
import Definitions.Def_OddOrder_Isaacs_Ch04_Commutators_Main_CommutatorBasics
import Definitions.Def_OddOrder_Isaacs_Ch04_Commutators_Main_ThreeSubgroupsCoprime
import Definitions.Def_OddOrder_Isaacs_Ch04_Commutators_Main_BaerTrick
import Definitions.Def_OddOrder_Isaacs_Ch04_Commutators_Main_ChainNilpotent
import Definitions.Def_OddOrder_Isaacs_Ch04_Commutators_ForwardFromCh03
import Definitions.Def_OddOrder_Isaacs_Ch04_Commutators_Main_ThreeSubgroups
import Definitions.Def_OddOrder_Isaacs_Ch05_Transfer_Main

namespace OddOrder.BG.Ch1.S05

open OddOrder.GroupTheory

open OddOrder.Isaacs

open scoped IsMulCommutative commutatorElement

variable {R : Type*} [Group R]

/-- `Ω₁(Z(R))`: 中心 `Z(R)` の位数 `p` 元が生成する部分群。中心は可換なので
`omega1OfAbelian` で `Subgroup R` として実現できる (BG §5 で `|Ω₁(Z(R))| = p` を述べるため)。 -/
def omega1Center (R : Type*) [Group R] (p : ℕ) : Subgroup R :=
  omega1OfAbelian R (Subgroup.center R) p
    (fun _ hx _ _ => (Subgroup.mem_center_iff.mp hx _).symm)

theorem omega1Center_le_center {p : ℕ} : omega1Center R p ≤ Subgroup.center R :=
  fun _ hg => hg.1

theorem mem_omega1Center {p : ℕ} {g : R} :
    g ∈ omega1Center R p ↔ g ∈ Subgroup.center R ∧ g ^ p = 1 := Iff.rfl

/-- `Ω₁(Z(R))` is elementary abelian: it is central and every element has
`p`-th power `1` by definition. -/
theorem omega1Center_isElementaryAbelian {p : ℕ} :
    (omega1Center R p).IsElementaryAbelian p := by
  refine ⟨fun x y => ?_, fun x => ?_⟩
  · apply Subtype.ext
    exact (Subgroup.mem_center_iff.mp (omega1Center_le_center x.2) (y : R)).symm
  · apply Subtype.ext
    have : (x : R) ^ p = 1 := (mem_omega1Center.mp x.2).2
    simpa using this

/-- **BG Lemma 5.2 support**: the central subgroup `Ω₁(Z(R))` is contained in any
maximal elementary abelian subgroup `E`. This packages the textbook step `EZ = E`
from `E ∈ E*(R)`. -/
theorem omega1Center_le_of_maximalElementaryAbelian {p : ℕ} {E : Subgroup R}
    (hEstar : IsMaximalElementaryAbelian p E) :
    omega1Center R p ≤ E := by
  have hE_le_cent : E ≤ Subgroup.centralizer (omega1Center R p : Set R) := by
    intro x _
    rw [Subgroup.mem_centralizer_iff]
    intro z hz
    exact (Subgroup.mem_center_iff.mp (omega1Center_le_center hz) x).symm
  exact hEstar.le_of_le_centralizer omega1Center_isElementaryAbelian hE_le_cent

/-- **BG Lemma 5.2 support**: `Ω₁(Z(R)) ≤ Ω₁(Z₂(R))`. -/
theorem omega1Center_le_omega1UpperCentralTwo {p : ℕ} :
    omega1Center R p ≤ omega1UpperCentralTwo R p := by
  intro z hz
  rw [omega1UpperCentralTwo, Subgroup.mem_map]
  have hz_pow : z ^ p = 1 := (mem_omega1Center.mp hz).2
  have hzZ2 : z ∈ Subgroup.upperCentralSeries R 2 := by
    exact (Subgroup.upperCentralSeries_mono R (by norm_num : (1 : ℕ) ≤ 2))
      (by
        rw [Subgroup.upperCentralSeries_one]
        exact (mem_omega1Center.mp hz).1)
  refine ⟨⟨z, hzZ2⟩, ?_, rfl⟩
  refine Omega.mem_of_pow_eq_one ?_
  rw [pow_one]
  exact Subtype.ext (by simpa using hz_pow)

/-- **BG Lemma 5.2 support**: once Lemma 4.5(c) supplies noncyclicity of
`Ω₁(Z₂(R))`, the inclusion `Ω₁(Z(R)) ≤ Ω₁(Z₂(R))` is strict whenever
`|Ω₁(Z(R))| = p`. -/
theorem omega1Center_lt_omega1UpperCentralTwo_of_not_isCyclic
    [Finite R] {p : ℕ} [Fact p.Prime]
    (hZcard : Nat.card ↥(omega1Center R p) = p)
    (hWnc : ¬ IsCyclic ↥(omega1UpperCentralTwo R p)) :
    omega1Center R p < omega1UpperCentralTwo R p := by
  refine lt_of_le_of_ne omega1Center_le_omega1UpperCentralTwo ?_
  intro hZW
  have hZcyc : IsCyclic ↥(omega1Center R p) := isCyclic_of_prime_card hZcard
  have hWcyc : IsCyclic ↥(omega1UpperCentralTwo R p) := by
    have : IsCyclic ↥(omega1Center R p) := hZcyc
    exact isCyclic_of_surjective (MulEquiv.subgroupCongr hZW).toMonoidHom
      (MulEquiv.subgroupCongr hZW).surjective
  exact hWnc hWcyc

/-- **BG Lemma 5.2 support**: `[Ω₁(Z₂(R)), R] ≤ Ω₁(Z(R))`.
For `w ∈ Ω₁(Z₂(R))`, the inclusion `w ∈ Z₂(R)` puts `⁅w, r⁆` in the centre.
The odd-prime exponent statement for `Ω₁(Z₂(R))`, together with the central
commutator power identity, gives `(⁅w, r⁆)^p = 1`. -/
theorem commutator_omega1UpperCentralTwo_le_omega1Center {p : ℕ} (hp : Odd p) :
    ⁅omega1UpperCentralTwo R p, (⊤ : Subgroup R)⁆ ≤ omega1Center R p := by
  rw [Subgroup.commutator_le]
  intro w hw r _
  have hwZ2 : w ∈ Subgroup.upperCentralSeries R 2 := omega1UpperCentralTwo_le R p hw
  have hcomm_center : ⁅w, r⁆ ∈ Subgroup.center R := by
    have hmem : w * r * w⁻¹ * r⁻¹ ∈ Subgroup.upperCentralSeries R 1 :=
      Subgroup.mem_upperCentralSeries_succ_iff.mp hwZ2 r
    rwa [Subgroup.upperCentralSeries_one, ← commutatorElement_def] at hmem
  refine (mem_omega1Center).mpr ⟨hcomm_center, ?_⟩
  have hwpow : w ^ p = 1 := pow_eq_one_of_mem_omega1UpperCentralTwo hp hw
  have hpow := S04.commutatorElement_pow_left_of_central hcomm_center p
  rw [← hpow, hwpow, commutatorElement_one_left]

/-- **BG Lemma 5.1(a)**: 奇素数 `p`, 有限 `p`-群 `R`, `r(R) ≥ 3` ⇒ `SCN₃(R) ≠ ∅`。

`SCN₃(R) = ∅ ⇒ r(R) ≤ 2` (= Lem 4.7 hard dir, `pRank_le_two_of_scn3_empty`) の対偶。
本リポでは §4d に hard dir が在るので、本補題は純論理で **証明済 (sorry なし)**。 -/
theorem scn3_nonempty_of_three_le_pRank [Finite R] {p : ℕ} [Fact p.Prime]
    (hp : Odd p) (hpg : IsPGroup p R) (h3 : 3 ≤ pRank R p) :
    ∃ A : Subgroup R, IsSCN₃ p A := by
  by_contra hcon
  rw [not_exists] at hcon
  exact absurd (S04.pRank_le_two_of_scn3_empty hp hpg hcon) (by omega)

/-- **BG Lemma 5.1(b), first construction step**: from an `SCN₃` subgroup `A`,
BG Lemma 1.22 produces a normal elementary abelian subgroup of order `p³`.

This packages the textbook line “by (a) and Lemma 1.22, there exists a normal elementary
abelian subgroup `B` of order `p³` in `R`”: use `3 ≤ pRank A p` to see that `p³` divides
`|Ω₁(A)|`, then apply Lemma 1.22 inside the normal subgroup `Ω₁(A)`. -/
theorem exists_normal_isElementaryAbelian_card_prime_cube_of_scn3
    [Finite R] {p : ℕ} [Fact p.Prime] (hpg : IsPGroup p R)
    {A : Subgroup R} (hA : IsSCN₃ p A) :
    ∃ B : Subgroup R, B.Normal ∧ B.IsElementaryAbelian p ∧ Nat.card B = p ^ 3 := by
  have hA_scn : IsSCN A := hA.isSCN
  have hA_comm : ∀ x ∈ A, ∀ y ∈ A, x * y = y * x := by
    let : IsMulCommutative A := hA_scn.isMulCommutative
    intro x hx y hy
    exact congrArg Subtype.val (mul_comm (⟨x, hx⟩ : A) ⟨y, hy⟩)
  set H : Subgroup R := omega1OfAbelian R A p hA_comm with hHdef
  have hH_le_A : H ≤ A := by
    simpa [hHdef] using
      (omega1OfAbelian_le (G := R) (H := A) (p := p) (hH := hA_comm))
  have hH_normal : H.Normal := by
    refine { conj_mem := fun h hh g => ?_ }
    have hh' : h ∈ A ∧ h ^ p = 1 := by simpa [hHdef] using hh
    rw [hHdef]
    refine (mem_omega1OfAbelian).mpr ⟨hA_scn.isNormal.conj_mem h hh'.1 g, ?_⟩
    calc (g * h * g⁻¹) ^ p = g * h ^ p * g⁻¹ := conj_pow
      _ = 1 := by rw [hh'.2, mul_one, mul_inv_cancel]
  have hH_elem : H.IsElementaryAbelian p := by
    rw [hHdef]
    exact
      ⟨fun x y => Subtype.ext (hA_comm x.val x.2.1 y.val y.2.1),
       fun x => Subtype.ext (by simpa using pow_eq_one_of_mem_omega1OfAbelian x.2)⟩
  have hH_dvd : p ^ 3 ∣ Nat.card H := by
    simpa [hHdef] using
      (pow_dvd_card_omega1OfAbelian_of_pos_le_pRank (G := R) (H := A)
        (p := p) (hH := hA_comm) (n := 3) (by norm_num) hA.le_pRank)
  have : H.Normal := hH_normal
  obtain ⟨B, hB_normal, hB_le_H, hB_card⟩ :=
    OddOrder.BG.Ch1.S01.normal_subgroup_card_pow_le_of_pGroup
      (G := R) (p := p) hpg (N := H) (r := 3) hH_dvd
  have hB_elem : B.IsElementaryAbelian p := by
    have hB_sub_elem : (B.subgroupOf H).IsElementaryAbelian p :=
      hH_elem.to_subgroup (B.subgroupOf H)
    exact IsElementaryAbelian.of_mulEquiv (Subgroup.subgroupOfEquivOfLe hB_le_H) hB_sub_elem
  exact ⟨B, hB_normal, hB_elem, hB_card⟩

/-- **BG Lemma 5.1(b), `B* = E C_B(E)` support**: if `E` and `B` are normal
elementary abelian `p`-subgroups, then the Lean encoding
`E ⊔ (B ⊓ C_R(E))` of the textbook product `E C_B(E)` is again normal and elementary
abelian. -/
theorem bStar_normal_isElementaryAbelian_of_normal_isElementaryAbelian
    {p : ℕ} {E B : Subgroup R} [E.Normal] [B.Normal]
    (hE : E.IsElementaryAbelian p) (hB : B.IsElementaryAbelian p) :
    (E ⊔ (B ⊓ Subgroup.centralizer (E : Set R))).Normal ∧
      (E ⊔ (B ⊓ Subgroup.centralizer (E : Set R))).IsElementaryAbelian p := by
  constructor
  · have : (Subgroup.centralizer (E : Set R)).Normal := Subgroup.normal_centralizer
    infer_instance
  · let K : Subgroup R := B ⊓ Subgroup.centralizer (E : Set R)
    have hK_le_B : K ≤ B := by
      dsimp [K]
      exact inf_le_left
    have hK_elem : K.IsElementaryAbelian p := by
      have hK_sub_elem : (K.subgroupOf B).IsElementaryAbelian p :=
        hB.to_subgroup (K.subgroupOf B)
      exact OddOrder.GroupTheory.IsElementaryAbelian.of_mulEquiv
        (Subgroup.subgroupOfEquivOfLe hK_le_B) hK_sub_elem
    have hE_le_cent_K : E ≤ Subgroup.centralizer (K : Set R) := by
      dsimp [K]
      exact Subgroup.le_centralizer_iff.mpr inf_le_right
    exact Subgroup.IsElementaryAbelian.sup_of_le_centralizer hE hK_elem hE_le_cent_K

/-- **BG Lemma 5.1(b), large `B*` branch**: if the subgroup
`B* = E ⊔ (B ⊓ C_R(E))` constructed from normal elementary abelian `E` and `B` has
cardinality at least `p^3`, then `E` is contained in some `SCN₃` subgroup. -/
theorem exists_scn3_ge_of_bStar_card_ge_prime_cube
    [Finite R] {p : ℕ} [Fact p.Prime] (hpg : IsPGroup p R)
    {E B : Subgroup R} [E.Normal] [B.Normal]
    (hE : E.IsElementaryAbelian p) (hB : B.IsElementaryAbelian p)
    (hcard : p ^ 3 ≤ Nat.card ↥(E ⊔ (B ⊓ Subgroup.centralizer (E : Set R)))) :
    ∃ A : Subgroup R, IsSCN₃ p A ∧ E ≤ A := by
  let Bstar : Subgroup R := E ⊔ (B ⊓ Subgroup.centralizer (E : Set R))
  have hBstar := bStar_normal_isElementaryAbelian_of_normal_isElementaryAbelian
    (E := E) (B := B) hE hB
  have hBstar_norm : Bstar.Normal := by
    simpa [Bstar] using hBstar.1
  have hBstar_elem : Bstar.IsElementaryAbelian p := by
    simpa [Bstar] using hBstar.2
  have hBstar_comm : IsMulCommutative Bstar :=
    IsMulCommutative.of_comm hBstar_elem.comm
  have hcard' : p ^ 3 ≤ Nat.card Bstar := by
    simpa [Bstar] using hcard
  have hlog : 3 ≤ Nat.log p (Nat.card Bstar) :=
    Nat.le_log_of_pow_le (Fact.out : p.Prime).one_lt hcard'
  have hBrank : 3 ≤ pRank Bstar p :=
    hlog.trans hBstar_elem.log_card_le_pRank
  obtain ⟨A, hA, hBstar_le_A⟩ :=
    exists_scn3_ge_of_normal_abelian_pRank_ge_three hpg hBstar_norm hBstar_comm hBrank
  refine ⟨A, hA, ?_⟩
  have hE_le_Bstar : E ≤ Bstar := by
    dsimp [Bstar]
    exact le_sup_left
  exact hE_le_Bstar.trans hBstar_le_A

/-- **BG Lemma 5.1(b), centralizer-count support**: if `E` has order `p^2` and
`B` has order `p^3`, both elementary abelian, then the centralizer of `E` inside `B`
has order at least `p^2`. This is the Lean form of the textbook estimate
`|B / C_B(E)| ≤ p`, obtained from the conjugation action of `B` on `E`. -/
theorem card_inf_centralizer_ge_prime_sq_of_card_prime_cube
    [Finite R] {p : ℕ} [Fact p.Prime]
    {E B : Subgroup R} [E.Normal]
    (hE : E.IsElementaryAbelian p) (hEcard : Nat.card E = p ^ 2)
    (hB : B.IsElementaryAbelian p) (hBcard : Nat.card B = p ^ 3) :
    p ^ 2 ≤ Nat.card ↥(B ⊓ Subgroup.centralizer (E : Set R)) := by
  let φ : B →* MulAut E := (MulAut.conjNormal (H := E)).comp B.subtype
  have hrange_pg : IsPGroup p φ.range :=
    hB.isPGroup.of_surjective φ.rangeRestrict φ.rangeRestrict_surjective
  have hEcard_le : Nat.card E ≤ p ^ 2 := by
    rw [hEcard]
  have hrange_le : Nat.card φ.range ≤ p :=
    card_pSubgroup_mulAut_le_prime_of_card_le_prime_sq hE hEcard_le hrange_pg
  have hLagrange : Nat.card B = Nat.card φ.range * Nat.card φ.ker := by
    rw [Subgroup.card_eq_card_quotient_mul_card_subgroup φ.ker,
      Nat.card_congr (QuotientGroup.quotientKerEquivRange φ).toEquiv]
  have hker_map_eq : φ.ker.map B.subtype = B ⊓ Subgroup.centralizer (E : Set R) := by
    ext x
    constructor
    · intro hx
      rw [Subgroup.mem_map] at hx
      obtain ⟨b, hbker, rfl⟩ := hx
      refine ⟨b.2, ?_⟩
      change B.subtype b ∈ Subgroup.centralizer (E : Set R)
      rw [Subgroup.mem_centralizer_iff]
      intro e he
      have hfix : (MulAut.conjNormal (H := E) (B.subtype b)) ⟨e, he⟩ = ⟨e, he⟩ := by
        have hφb : φ b = 1 := MonoidHom.mem_ker.mp hbker
        simpa [φ] using congrArg (fun σ : MulAut E => σ ⟨e, he⟩) hφb
      have hfix_val := congrArg Subtype.val hfix
      rw [MulAut.conjNormal_apply] at hfix_val
      exact (mul_inv_eq_iff_eq_mul.mp hfix_val).symm
    · intro hx
      obtain ⟨hxB, hxC⟩ := hx
      rw [Subgroup.mem_map]
      refine ⟨⟨x, hxB⟩, ?_, rfl⟩
      rw [MonoidHom.mem_ker]
      ext e
      change x * (e : R) * x⁻¹ = (e : R)
      have hcomm : (e : R) * x = x * (e : R) :=
        Subgroup.mem_centralizer_iff.mp hxC (e : R) e.2
      rw [← hcomm]
      group
  have hker_card : Nat.card ↥(B ⊓ Subgroup.centralizer (E : Set R)) = Nat.card φ.ker := by
    rw [← hker_map_eq, Subgroup.card_map_of_injective B.subtype_injective]
  have hB_le : Nat.card B ≤ p * Nat.card φ.ker := by
    rw [hLagrange]
    exact Nat.mul_le_mul_right _ hrange_le
  have hp3_le : p ^ 3 ≤ p * Nat.card φ.ker := by
    rw [← hBcard]
    exact hB_le
  have hp3_eq : p ^ 3 = p * p ^ 2 := by ring
  have hp2_le_ker : p ^ 2 ≤ Nat.card φ.ker := by
    have hmul : p * p ^ 2 ≤ p * Nat.card φ.ker := by
      rwa [← hp3_eq]
    exact Nat.le_of_mul_le_mul_left hmul (Fact.out : p.Prime).pos
  rwa [hker_card]

/-- **BG Lemma 5.1(b), small-branch contradiction packaged as a lower bound**:
if `E` has order `p^2` and `B` has order `p^3`, both elementary abelian, then
the Lean encoding `E ⊔ (B ⊓ C_R(E))` of `E C_B(E)` has order at least `p^3`.
This is the formal version of BG's argument that the alternative `|E C_B(E)| < p^3`
would force `C_B(E)=E` and then, since `B` is abelian, `B=C_B(E)`, contradicting
`|B|=p^3` and `|E|=p^2`. -/
theorem bStar_card_ge_prime_cube_of_card_prime_cube
    [Finite R] {p : ℕ} [Fact p.Prime]
    {E B : Subgroup R} [E.Normal]
    (hE : E.IsElementaryAbelian p) (hEcard : Nat.card E = p ^ 2)
    (hB : B.IsElementaryAbelian p) (hBcard : Nat.card B = p ^ 3) :
    p ^ 3 ≤ Nat.card ↥(E ⊔ (B ⊓ Subgroup.centralizer (E : Set R))) := by
  let K : Subgroup R := B ⊓ Subgroup.centralizer (E : Set R)
  let Bstar : Subgroup R := E ⊔ K
  by_contra hnot
  have hsmall : Nat.card Bstar < p ^ 3 := Nat.lt_of_not_ge hnot
  have hK_le_B : K ≤ B := by
    intro x hx
    dsimp [K] at hx
    exact hx.1
  have hK_elem : K.IsElementaryAbelian p := by
    have hK_sub_elem : (K.subgroupOf B).IsElementaryAbelian p :=
      hB.to_subgroup (K.subgroupOf B)
    exact OddOrder.GroupTheory.IsElementaryAbelian.of_mulEquiv
      (Subgroup.subgroupOfEquivOfLe hK_le_B) hK_sub_elem
  have hE_le_cent_K : E ≤ Subgroup.centralizer (K : Set R) := by
    dsimp [K]
    exact Subgroup.le_centralizer_iff.mpr inf_le_right
  have hBstar_elem : Bstar.IsElementaryAbelian p := by
    simpa [Bstar] using
      Subgroup.IsElementaryAbelian.sup_of_le_centralizer hE hK_elem hE_le_cent_K
  let : IsMulCommutative Bstar := IsMulCommutative.of_comm hBstar_elem.comm
  let := hBstar_elem.zmodModule
  let m : ℕ := Module.finrank (ZMod p) (Additive Bstar)
  have hBstar_card_pow : Nat.card Bstar = p ^ m := by
    dsimp [m]
    simpa using hBstar_elem.card_eq_pow_finrank
  have hE_le_Bstar : E ≤ Bstar := by
    dsimp [Bstar]
    exact le_sup_left
  have hK_le_Bstar : K ≤ Bstar := by
    dsimp [Bstar]
    exact le_sup_right
  have hE_card_le_Bstar : Nat.card E ≤ Nat.card Bstar :=
    Nat.card_le_card_of_injective
      (fun x : E => (⟨x.1, hE_le_Bstar x.2⟩ : Bstar))
      (fun x y hxy => Subtype.ext (congrArg (fun z : Bstar => (z : R)) hxy))
  have hp1 : 1 < p := (Fact.out : p.Prime).one_lt
  have hm_lt : m < 3 := by
    have hp_lt : p ^ m < p ^ 3 := by
      simpa [hBstar_card_pow] using hsmall
    exact (Nat.pow_lt_pow_iff_right hp1).mp hp_lt
  have hm_ge : 2 ≤ m := by
    have hp_le : p ^ 2 ≤ p ^ m := by
      simpa [hEcard, hBstar_card_pow] using hE_card_le_Bstar
    exact (Nat.pow_le_pow_iff_right hp1).mp hp_le
  have hm_eq : m = 2 := by omega
  have hBstar_card_eq : Nat.card Bstar = p ^ 2 := by
    rw [hBstar_card_pow, hm_eq]
  have hBstar_card_le_E : Nat.card Bstar ≤ Nat.card E := by
    simp [hBstar_card_eq, hEcard]
  have hE_eq_Bstar : E = Bstar :=
    Subgroup.eq_of_le_of_card_ge hE_le_Bstar hBstar_card_le_E
  have hK_card : p ^ 2 ≤ Nat.card K := by
    simpa [K] using
      card_inf_centralizer_ge_prime_sq_of_card_prime_cube
        (E := E) (B := B) hE hEcard hB hBcard
  have hBstar_card_le_K : Nat.card Bstar ≤ Nat.card K :=
    hBstar_card_eq.le.trans hK_card
  have hK_eq_Bstar : K = Bstar :=
    Subgroup.eq_of_le_of_card_ge hK_le_Bstar hBstar_card_le_K
  have hE_eq_K : E = K := hE_eq_Bstar.trans hK_eq_Bstar.symm
  have hE_le_B : E ≤ B := by
    intro x hx
    have hxK : x ∈ K := by
      simpa [hE_eq_K] using hx
    dsimp [K] at hxK
    exact hxK.1
  have hB_le_cent : B ≤ Subgroup.centralizer (E : Set R) := by
    intro x hx
    rw [Subgroup.mem_centralizer_iff]
    intro e he
    have heB : e ∈ B := hE_le_B he
    have hcomm : x * e = e * x :=
      congrArg (fun z : B => (z : R)) (hB.comm ⟨x, hx⟩ ⟨e, heB⟩)
    exact hcomm.symm
  have hB_le_K : B ≤ K := by
    intro x hx
    dsimp [K]
    exact ⟨hx, hB_le_cent hx⟩
  have hB_eq_K : B = K := le_antisymm hB_le_K hK_le_B
  have hB_eq_E : B = E := hB_eq_K.trans hE_eq_K.symm
  have hp32_ne : p ^ 3 ≠ p ^ 2 := by
    exact ne_of_gt ((Nat.pow_lt_pow_iff_right hp1).mpr (by norm_num : (2 : ℕ) < 3))
  have hp32_eq : p ^ 3 = p ^ 2 := by
    rw [← hBcard, hB_eq_E, hEcard]
  exact hp32_ne hp32_eq

/-- **BG Lemma 5.1(b)**: 奇素数 `p`, 有限 `p`-群 `R`, `r(R) ≥ 3`。`E ∈ ℰ²(R)` (elem-ab,
位数 `p²`) かつ `E ⊴ R` ⇒ `E` は `SCN₃(R)` のある元に含まれる。

mmd L1800-1806: (a) + Lem 1.22 で normal elem-ab `B` (位数 `p³`) を取り、`B* = E·C_B(E)` の
位数で場合分け (`≥ p³` なら Prop 4.4、`< p³` は `B` abelian で矛盾)。 -/
theorem mem_scn3_of_normal_isElementaryAbelian_card_prime_sq [Finite R] {p : ℕ} [Fact p.Prime]
    (hp : Odd p) (hpg : IsPGroup p R) (h3 : 3 ≤ pRank R p)
    (E : Subgroup R) (hE : E.IsElementaryAbelian p) (hEcard : Nat.card ↥E = p ^ 2)
    [E.Normal] :
    ∃ A : Subgroup R, IsSCN₃ p A ∧ E ≤ A := by
  obtain ⟨A, hA⟩ := scn3_nonempty_of_three_le_pRank hp hpg h3
  obtain ⟨B, hB_normal, hB, hBcard⟩ :=
    exists_normal_isElementaryAbelian_card_prime_cube_of_scn3 hpg hA
  have : B.Normal := hB_normal
  have hBstar_card : p ^ 3 ≤ Nat.card ↥(E ⊔ (B ⊓ Subgroup.centralizer (E : Set R))) :=
    bStar_card_ge_prime_cube_of_card_prime_cube hE hEcard hB hBcard
  exact exists_scn3_ge_of_bStar_card_ge_prime_cube hpg hE hB hBstar_card

/-- **BG Lemma 5.2 support / Lemma 4.5(c) in the `r(R) ≥ 3` context**:
`W = Ω₁(Z₂(R))` is noncyclic.

We route around Lemma 4.5(a) by using the stronger local hypothesis
`r(R) ≥ 3` (4.5(a) itself is available unconditionally as
`S04.exists_normal_isElementaryAbelian_card_prime_sq_of_not_isCyclic`; this route is kept
because it delivers order `p³` directly): Lemma 5.1's SCN₃ construction gives a normal
elementary abelian subgroup
of order `p³`; BG Lemma 1.22 extracts a normal elementary abelian subgroup `S` of
order `p²`. Since `R` is nilpotent, `[S,R]` is a proper subgroup of `S`; hence it has
order `1` or `p`, and in the latter case it is central. Thus `S ≤ Z₂(R)`, and since
`S` has exponent `p`, `S ≤ W`. A cyclic `W` would make its subgroup `S` cyclic,
contradicting `|S| = p²` and elementary abelianness. -/
theorem omega1UpperCentralTwo_not_isCyclic_of_three_le_pRank
    [Finite R] {p : ℕ} [Fact p.Prime] (hp : Odd p) (hpg : IsPGroup p R)
    (h3 : 3 ≤ pRank R p) :
    ¬ IsCyclic ↥(omega1UpperCentralTwo R p) := by
  obtain ⟨A, hA⟩ := scn3_nonempty_of_three_le_pRank hp hpg h3
  obtain ⟨B, hB_normal, hB_elem, hBcard⟩ :=
    exists_normal_isElementaryAbelian_card_prime_cube_of_scn3 hpg hA
  have : B.Normal := hB_normal
  have hB_dvd : p ^ 2 ∣ Nat.card B := by
    rw [hBcard]
    exact pow_dvd_pow p (by norm_num : 2 ≤ 3)
  obtain ⟨S, hS_normal, hS_le_B, hScard⟩ :=
    OddOrder.BG.Ch1.S01.normal_subgroup_card_pow_le_of_pGroup
      (G := R) (p := p) hpg (N := B) (r := 2) hB_dvd
  have : S.Normal := hS_normal
  have hS_elem : S.IsElementaryAbelian p := by
    have hS_sub_elem : (S.subgroupOf B).IsElementaryAbelian p :=
      hB_elem.to_subgroup (S.subgroupOf B)
    exact IsElementaryAbelian.of_mulEquiv (Subgroup.subgroupOfEquivOfLe hS_le_B) hS_sub_elem
  have hS_ne_bot : S ≠ ⊥ := by
    intro hSbot
    have hcard_one : Nat.card S = 1 := by rw [hSbot, Subgroup.card_bot]
    have hp_sq_gt_one : 1 < p ^ 2 :=
      one_lt_pow₀ (Fact.out : p.Prime).one_lt two_ne_zero
    exact (ne_of_gt hp_sq_gt_one) (by rw [← hScard, hcard_one])
  have : Group.IsNilpotent R := IsPGroup.isNilpotent hpg
  let H : Subgroup R := ⁅S, (⊤ : Subgroup R)⁆
  have hHlt : H < S := by
    dsimp [H]
    exact OddOrder.Isaacs.Ch04.commutator_lt_self_of_isNilpotent_ambient
      (E := S) (F := (⊤ : Subgroup R)) hS_ne_bot
  have hH_le_S : H ≤ S := hHlt.le
  have hH_normal : H.Normal := by
    dsimp [H]
    infer_instance
  have hH_le_center : H ≤ Subgroup.center R := by
    by_cases hHbot : H = ⊥
    · rw [hHbot]
      exact bot_le
    · have hH_dvd : Nat.card H ∣ p ^ 2 := by
        rw [← hScard]
        exact Subgroup.card_dvd_of_le hH_le_S
      obtain ⟨j, hj_le, hj_eq⟩ :=
        (Nat.dvd_prime_pow (p := p) (Fact.out (p := p.Prime))).mp hH_dvd
      have hj_ne_zero : j ≠ 0 := by
        intro hj0
        have hHcard_one : Nat.card H = 1 := by simpa [hj0] using hj_eq
        exact hHbot ((Subgroup.card_eq_one (H := H)).mp hHcard_one)
      have hj_ne_two : j ≠ 2 := by
        intro hj2
        have hHcard_eq_S : Nat.card H = Nat.card S := by
          rw [hj_eq, hj2, hScard]
        have hHS : H = S :=
          Subgroup.eq_of_le_of_card_ge hH_le_S (le_of_eq hHcard_eq_S.symm)
        exact hHlt.ne hHS
      have hj_eq_one : j = 1 := by omega
      have hHcard : Nat.card H = p := by simpa [hj_eq_one] using hj_eq
      exact S04.le_center_of_card_eq_prime_of_normal hpg hHcard
  have hS_le_Z2 : S ≤ Subgroup.upperCentralSeries R 2 := by
    intro s hs
    rw [Subgroup.mem_upperCentralSeries_succ_iff]
    intro r
    have hcomm_center : ⁅s, r⁆ ∈ Subgroup.center R := by
      exact hH_le_center (by
        dsimp [H]
        exact Subgroup.commutator_mem_commutator hs trivial)
    simpa [Subgroup.upperCentralSeries_one, commutatorElement_def] using hcomm_center
  let W : Subgroup R := omega1UpperCentralTwo R p
  have hS_le_W : S ≤ W := by
    intro s hs
    dsimp [W]
    rw [omega1UpperCentralTwo, Subgroup.mem_map]
    have hs_pow_sub := hS_elem.pow_eq_one (⟨s, hs⟩ : S)
    have hs_pow : s ^ p = 1 := by
      simpa using congrArg Subtype.val hs_pow_sub
    refine ⟨⟨s, hS_le_Z2 hs⟩, ?_, rfl⟩
    refine Omega.mem_of_pow_eq_one ?_
    rw [pow_one]
    exact Subtype.ext (by simpa using hs_pow)
  have hS_not_cyclic : ¬ IsCyclic ↥S :=
    hS_elem.not_isCyclic_of_card_prime_sq (Fact.out : p.Prime) hScard
  intro hWcyc
  have hSsub_cyc : IsCyclic ↥(S.subgroupOf W) := by
    have : IsCyclic ↥W := by simpa [W] using hWcyc
    exact Subgroup.isCyclic _
  have hS_cyc : IsCyclic ↥S := by
    have : IsCyclic ↥(S.subgroupOf W) := hSsub_cyc
    exact isCyclic_of_surjective (Subgroup.subgroupOfEquivOfLe hS_le_W).toMonoidHom
      (Subgroup.subgroupOfEquivOfLe hS_le_W).surjective
  exact hS_not_cyclic hS_cyc

/-- **BG Lemma 5.2 support**: if `E ∈ E*(R)` has order `p²`, then
`C_R(E)` has `p`-rank at most `2`.

Indeed, any elementary abelian `p`-subgroup of `C_R(E)` centralizes `E`; adjoining it
to `E` is still elementary abelian, so maximality of `E` forces the subgroup back
inside `E`. -/
theorem pRank_centralizer_le_two_of_maximalElementaryAbelian_card_prime_sq
    [Finite R] {p : ℕ} [Fact p.Prime] {E : Subgroup R}
    (hEcard : Nat.card ↥E = p ^ 2) (hEstar : IsMaximalElementaryAbelian p E) :
    pRank ↥(Subgroup.centralizer (E : Set R)) p ≤ 2 := by
  rw [pRank_le_iff]
  intro A hA
  let C : Subgroup R := Subgroup.centralizer (E : Set R)
  let F : Subgroup R := A.map C.subtype
  have hF : F.IsElementaryAbelian p := by
    dsimp [F, C]
    exact Subgroup.IsElementaryAbelian.map C.subtype_injective hA
  have hE_le_cent_F : E ≤ Subgroup.centralizer (F : Set R) := by
    intro e he
    rw [Subgroup.mem_centralizer_iff]
    intro x hxF
    change x ∈ A.map C.subtype at hxF
    rw [Subgroup.mem_map] at hxF
    obtain ⟨a, _, rfl⟩ := hxF
    exact (Subgroup.mem_centralizer_iff.mp a.2 e he).symm
  have hF_le_E : F ≤ E :=
    hEstar.le_of_le_centralizer (F := F) hF hE_le_cent_F
  calc
    Nat.log p (Nat.card A) = Nat.log p (Nat.card F) := by
      dsimp [F, C]
      rw [Subgroup.card_map_of_injective C.subtype_injective]
    _ ≤ Nat.log p (Nat.card E) :=
      Nat.log_mono_right (Subgroup.card_le_of_le hF_le_E)
    _ = 2 := by
      rw [hEcard, Nat.log_pow (Fact.out : p.Prime).one_lt]

/-- **BG Lemma 5.2 support**: in the same situation, `Ω₁(Z(R))` is a proper
subgroup of `E`, and hence has order `p`.

This is the textbook step after `Z ≤ E`: if `Z = E`, then `E` is central, so
`C_R(E) = R`, contradicting `r(R) ≥ 3` and the rank bound for `C_R(E)`. The
order calculation uses the central subgroup of order `p` in a nontrivial finite
`p`-group and the divisibility `|Z| ∣ |E| = p²`. -/
theorem omega1Center_lt_and_card_eq_prime_of_maximalElementaryAbelian_card_prime_sq
    [Finite R] {p : ℕ} [Fact p.Prime] (hpg : IsPGroup p R)
    (h3 : 3 ≤ pRank R p) {E : Subgroup R} (hEcard : Nat.card ↥E = p ^ 2)
    (hEstar : IsMaximalElementaryAbelian p E) :
    omega1Center R p < E ∧ Nat.card ↥(omega1Center R p) = p := by
  have hZleE : omega1Center R p ≤ E :=
    omega1Center_le_of_maximalElementaryAbelian hEstar
  have hZ_ne_E : omega1Center R p ≠ E := by
    intro hZE
    have hE_le_center : E ≤ Subgroup.center R := by
      intro x hx
      rw [← hZE] at hx
      exact omega1Center_le_center hx
    have hCtop : Subgroup.centralizer (E : Set R) = ⊤ := by
      rw [eq_top_iff]
      intro x _
      rw [Subgroup.mem_centralizer_iff]
      intro e he
      exact (Subgroup.mem_center_iff.mp (hE_le_center he) x).symm
    let C : Subgroup R := Subgroup.centralizer (E : Set R)
    let toC : R →* C :=
      { toFun := fun r => ⟨r, by
          dsimp [C]
          rw [hCtop]
          exact Subgroup.mem_top r⟩
        map_one' := Subtype.ext rfl
        map_mul' := fun _ _ => Subtype.ext rfl }
    have hR_le_C : pRank R p ≤ pRank C p :=
      pRank_le_of_injective (G := C) (H := R) (f := toC)
        (fun _ _ hxy => congrArg Subtype.val hxy)
    have h3C : 3 ≤ pRank ↥(Subgroup.centralizer (E : Set R)) p := by
      simpa [C] using h3.trans hR_le_C
    have hC_le_two :
        pRank ↥(Subgroup.centralizer (E : Set R)) p ≤ 2 :=
      pRank_centralizer_le_two_of_maximalElementaryAbelian_card_prime_sq hEcard hEstar
    have : (3 : ℕ) ≤ 2 := h3C.trans hC_le_two
    omega
  have hZltE : omega1Center R p < E := lt_of_le_of_ne hZleE hZ_ne_E
  have hE_card_gt_one : 1 < Nat.card E := by
    rw [hEcard]
    exact one_lt_pow₀ (Fact.out : p.Prime).one_lt two_ne_zero
  have : Nontrivial E := Finite.one_lt_card_iff_nontrivial.mp hE_card_gt_one
  obtain ⟨e, he_ne⟩ := exists_ne (1 : E)
  have : Nontrivial R := ⟨⟨(e : R), 1, fun heq => he_ne (Subtype.ext heq)⟩⟩
  obtain ⟨K, hK_le_center, hKcard⟩ := hpg.exists_subgroup_le_center_card_prime
  have hK_le_Z : K ≤ omega1Center R p := by
    intro x hx
    refine ⟨hK_le_center hx, ?_⟩
    have hxpow := pow_card_eq_one' (G := K) (x := (⟨x, hx⟩ : K))
    have hxpow_coe := congrArg Subtype.val hxpow
    simpa [hKcard] using hxpow_coe
  have hp_le_Z : p ≤ Nat.card (omega1Center R p) := by
    simpa [hKcard] using (Subgroup.card_le_of_le hK_le_Z)
  have hZdvd : Nat.card (omega1Center R p) ∣ p ^ 2 := by
    rw [← hEcard]
    exact Subgroup.card_dvd_of_le hZleE
  obtain ⟨j, hj_le, hj_eq⟩ :=
    (Nat.dvd_prime_pow (p := p) (Fact.out (p := p.Prime))).mp hZdvd
  have hj_ne_zero : j ≠ 0 := by
    intro hj0
    have hp_le_one : p ≤ 1 := by
      simpa [hj0, hj_eq] using hp_le_Z
    exact (not_lt_of_ge hp_le_one) (Fact.out : p.Prime).one_lt
  have hj_ne_two : j ≠ 2 := by
    intro hj2
    have hZcard_eq_E : Nat.card (omega1Center R p) = Nat.card E := by
      rw [hj_eq, hj2, hEcard]
    have hZE : omega1Center R p = E :=
      Subgroup.eq_of_le_of_card_ge hZleE (le_of_eq hZcard_eq_E.symm)
    exact hZ_ne_E hZE
  have hj_eq_one : j = 1 := by omega
  refine ⟨hZltE, ?_⟩
  simpa [hj_eq_one] using hj_eq

/-- **BG Lemma 5.2 front-half support**: the portion of the proof up through
`Z < W` and `[W, R] ≤ Z`, together with the centralizer rank bound.

This is the reusable sorry-free package for the initial paragraphs of Lemma 5.2:
from `E ∈ E*(R)` and `|E| = p²`, `C_R(E)` has `p`-rank at most `2`; then
`Z = Ω₁(Z(R))` is a proper subgroup of `E` of order `p`; Lemma 4.5(c) in the
`r(R) ≥ 3` context makes `W = Ω₁(Z₂(R))` noncyclic, hence `Z < W`, and the
upper-central-series argument gives `[W, R] ≤ Z`. -/
theorem lemma52_frontHalf_support
    [Finite R] {p : ℕ} [Fact p.Prime] (hp : Odd p) (hpg : IsPGroup p R)
    (h3 : 3 ≤ pRank R p) {E : Subgroup R} (hEcard : Nat.card ↥E = p ^ 2)
    (hEstar : IsMaximalElementaryAbelian p E) :
    pRank ↥(Subgroup.centralizer (E : Set R)) p ≤ 2 ∧
      omega1Center R p < E ∧
      Nat.card ↥(omega1Center R p) = p ∧
      ¬ IsCyclic ↥(omega1UpperCentralTwo R p) ∧
      omega1Center R p < omega1UpperCentralTwo R p ∧
      ⁅omega1UpperCentralTwo R p, (⊤ : Subgroup R)⁆ ≤ omega1Center R p := by
  have hC : pRank ↥(Subgroup.centralizer (E : Set R)) p ≤ 2 :=
    pRank_centralizer_le_two_of_maximalElementaryAbelian_card_prime_sq hEcard hEstar
  have hZ :=
    omega1Center_lt_and_card_eq_prime_of_maximalElementaryAbelian_card_prime_sq
      hpg h3 hEcard hEstar
  have hWnc := omega1UpperCentralTwo_not_isCyclic_of_three_le_pRank hp hpg h3
  have hZW : omega1Center R p < omega1UpperCentralTwo R p :=
    omega1Center_lt_omega1UpperCentralTwo_of_not_isCyclic hZ.2 hWnc
  exact ⟨hC, hZ.1, hZ.2, hWnc, hZW, commutator_omega1UpperCentralTwo_le_omega1Center hp⟩

/-- **BG Lemma 5.2 support**: `W = Ω₁(Z₂(R))` normalizes `E`.

This is the textbook step following `(5.1)` and `(5.2)`: from
`[W, R] ≤ Z = Ω₁(Z(R)) < E`, in particular `[E, W] ≤ E`, so `W ≤ N_R(E)`. -/
theorem omega1UpperCentralTwo_le_normalizer_of_maximalElementaryAbelian_card_prime_sq
    [Finite R] {p : ℕ} [Fact p.Prime] (hp : Odd p) (hpg : IsPGroup p R)
    (h3 : 3 ≤ pRank R p) {E : Subgroup R} (hEcard : Nat.card ↥E = p ^ 2)
    (hEstar : IsMaximalElementaryAbelian p E) :
    omega1UpperCentralTwo R p ≤ Subgroup.normalizer (E : Set R) := by
  rcases lemma52_frontHalf_support hp hpg h3 hEcard hEstar with
    ⟨_, hZltE, _, _, _, hWR_le_Z⟩
  have hWE_le_Z : ⁅omega1UpperCentralTwo R p, E⁆ ≤ omega1Center R p := by
    exact (Subgroup.commutator_mono le_rfl (show E ≤ (⊤ : Subgroup R) from le_top)).trans
      hWR_le_Z
  have hEW_le_E : ⁅E, omega1UpperCentralTwo R p⁆ ≤ E := by
    rw [Subgroup.commutator_comm]
    exact hWE_le_Z.trans hZltE.le
  exact OddOrder.Isaacs.Ch04.le_normalizer_of_commutator_le hEW_le_E

private theorem zpowers_isElementaryAbelian_of_pow_eq_one {p : ℕ} {x : R} (hxp : x ^ p = 1) :
    (Subgroup.zpowers x).IsElementaryAbelian p := by
  let : IsMulCommutative (Subgroup.zpowers x) := Subgroup.zpowers_isMulCommutative x
  refine ⟨?_, ?_⟩
  · intro a b
    exact Subtype.ext (congrArg Subtype.val (mul_comm a b))
  · intro a
    apply Subtype.ext
    change (a : R) ^ p = 1
    obtain ⟨i, hi⟩ := Subgroup.mem_zpowers_iff.mp a.2
    rw [← hi, ← zpow_natCast (x ^ i) p, ← zpow_mul, mul_comm, zpow_mul, zpow_natCast,
      hxp, one_zpow]

/-- **BG Lemma 5.2 support**: an order-`p` element centralizing a maximal elementary
abelian subgroup already lies in it. This is the elementwise form used for
`C_W(E) ≤ E`; it avoids assuming `W` is elementary abelian. -/
theorem mem_of_mem_centralizer_pow_eq_one_of_maximalElementaryAbelian {p : ℕ}
    {E : Subgroup R} (hEstar : IsMaximalElementaryAbelian p E) {x : R}
    (hxC : x ∈ Subgroup.centralizer (E : Set R)) (hxp : x ^ p = 1) :
    x ∈ E := by
  let X : Subgroup R := Subgroup.zpowers x
  have hX : X.IsElementaryAbelian p := by
    dsimp [X]
    exact zpowers_isElementaryAbelian_of_pow_eq_one hxp
  have hE_le_cent_X : E ≤ Subgroup.centralizer (X : Set R) := by
    intro e he
    rw [Subgroup.mem_centralizer_iff]
    intro y hy
    change y ∈ Subgroup.zpowers x at hy
    obtain ⟨i, rfl⟩ := Subgroup.mem_zpowers_iff.mp hy
    have hex : e * x = x * e := Subgroup.mem_centralizer_iff.mp hxC e he
    exact ((show Commute e x from hex).zpow_right i).eq.symm
  exact hEstar.le_of_le_centralizer (F := X) hX hE_le_cent_X (Subgroup.mem_zpowers x)

/-- **BG Lemma 5.2 support**: `Z = Ω₁(Z(R))` lies in `C_W(E)`, where
`W = Ω₁(Z₂(R))`. -/
theorem omega1Center_le_omega1UpperCentralTwo_inf_centralizer {p : ℕ} {E : Subgroup R} :
    omega1Center R p ≤ omega1UpperCentralTwo R p ⊓ Subgroup.centralizer (E : Set R) := by
  intro z hz
  refine ⟨omega1Center_le_omega1UpperCentralTwo hz, ?_⟩
  change z ∈ Subgroup.centralizer (E : Set R)
  rw [Subgroup.mem_centralizer_iff]
  intro e _
  exact Subgroup.mem_center_iff.mp (omega1Center_le_center hz) e

/-- **BG Lemma 5.2 support**: `C_W(E) ≤ E`, where `W = Ω₁(Z₂(R))`.
Every element of `W` has `p`-th power `1`, and any element in `C_W(E)` centralizes
`E`; maximality of `E` then absorbs the cyclic elementary abelian subgroup it
generates. -/
theorem omega1UpperCentralTwo_inf_centralizer_le_of_maximalElementaryAbelian
    {p : ℕ} (hp : Odd p) {E : Subgroup R} (hEstar : IsMaximalElementaryAbelian p E) :
    omega1UpperCentralTwo R p ⊓ Subgroup.centralizer (E : Set R) ≤ E := by
  intro x hx
  exact mem_of_mem_centralizer_pow_eq_one_of_maximalElementaryAbelian hEstar hx.2
    (pow_eq_one_of_mem_omega1UpperCentralTwo hp hx.1)

/-- **BG Lemma 5.2 support**: if `C_W(E) = E`, then `E` is normal in `R`.
Indeed, the equality puts `E` inside `W`; hence `[E,R] ≤ [W,R] ≤ Z < E`, and the
commutator-normalizer criterion gives normality. -/
theorem normal_of_omega1UpperCentralTwo_inf_centralizer_eq
    [Finite R] {p : ℕ} [Fact p.Prime] (hp : Odd p) (hpg : IsPGroup p R)
    (h3 : 3 ≤ pRank R p) {E : Subgroup R} (hEcard : Nat.card ↥E = p ^ 2)
    (hEstar : IsMaximalElementaryAbelian p E)
    (hCW_eq : omega1UpperCentralTwo R p ⊓ Subgroup.centralizer (E : Set R) = E) :
    E.Normal := by
  rcases lemma52_frontHalf_support hp hpg h3 hEcard hEstar with
    ⟨_, hZltE, _, _, _, hWR_le_Z⟩
  have hE_le_W : E ≤ omega1UpperCentralTwo R p := by
    rw [← hCW_eq]
    exact inf_le_left
  have hER_le_Z : ⁅E, (⊤ : Subgroup R)⁆ ≤ omega1Center R p := by
    exact (Subgroup.commutator_mono hE_le_W le_rfl).trans hWR_le_Z
  have hER_le_E : ⁅E, (⊤ : Subgroup R)⁆ ≤ E := hER_le_Z.trans hZltE.le
  have htop_le_norm : (⊤ : Subgroup R) ≤ Subgroup.normalizer (E : Set R) :=
    OddOrder.Isaacs.Ch04.le_normalizer_of_commutator_le hER_le_E
  exact Subgroup.normalizer_eq_top_iff.mp (eq_top_iff.mpr htop_le_norm)

/-- **BG Lemma 5.2 support**: the branch `C_W(E) = E` is impossible.

If `C_W(E) = E`, the preceding support lemma makes `E` normal in `R`. Lemma 5.1(b)
then embeds `E` in an `SCN₃` subgroup `A`. The elementary abelian subgroup
`Ω₁(A)` contains `E`, so maximality collapses it back to `E`; but the `SCN₃`
rank condition forces `p³ ∣ |Ω₁(A)|`, contradicting `|E| = p²`. -/
theorem omega1UpperCentralTwo_inf_centralizer_ne_of_maximalElementaryAbelian_card_prime_sq
    [Finite R] {p : ℕ} [Fact p.Prime] (hp : Odd p) (hpg : IsPGroup p R)
    (h3 : 3 ≤ pRank R p) {E : Subgroup R} (hEcard : Nat.card ↥E = p ^ 2)
    (hEstar : IsMaximalElementaryAbelian p E) :
    omega1UpperCentralTwo R p ⊓ Subgroup.centralizer (E : Set R) ≠ E := by
  intro hCW_eq
  have hE_normal : E.Normal :=
    normal_of_omega1UpperCentralTwo_inf_centralizer_eq hp hpg h3 hEcard hEstar hCW_eq
  let : E.Normal := hE_normal
  obtain ⟨A, hA, hEA⟩ :=
    mem_scn3_of_normal_isElementaryAbelian_card_prime_sq hp hpg h3 E
      hEstar.isElementaryAbelian hEcard
  have hA_scn : IsSCN A := hA.isSCN
  have hA_comm : ∀ x ∈ A, ∀ y ∈ A, x * y = y * x := by
    let : IsMulCommutative A := hA_scn.isMulCommutative
    intro x hx y hy
    exact congrArg Subtype.val (mul_comm (⟨x, hx⟩ : A) ⟨y, hy⟩)
  let F : Subgroup R := omega1OfAbelian R A p hA_comm
  have hF_elem : F.IsElementaryAbelian p := by
    dsimp [F]
    exact
      ⟨fun x y => Subtype.ext (hA_comm x.val x.2.1 y.val y.2.1),
       fun x => Subtype.ext (by simpa using pow_eq_one_of_mem_omega1OfAbelian x.2)⟩
  have hE_le_F : E ≤ F := by
    intro e he
    dsimp [F]
    refine (mem_omega1OfAbelian).mpr ⟨hEA he, ?_⟩
    have hep := hEstar.isElementaryAbelian.pow_eq_one (⟨e, he⟩ : E)
    simpa using congrArg Subtype.val hep
  have hF_eq_E : F = E := hEstar.eq_of_le hF_elem hE_le_F
  have hF_dvd : p ^ 3 ∣ Nat.card F := by
    simpa [F] using
      (pow_dvd_card_omega1OfAbelian_of_pos_le_pRank (G := R) (H := A)
        (p := p) (hH := hA_comm) (n := 3) (by norm_num) hA.le_pRank)
  have hF_ge : p ^ 3 ≤ Nat.card F := Nat.le_of_dvd (Nat.card_pos : 0 < Nat.card F) hF_dvd
  have hle : p ^ 3 ≤ p ^ 2 := by
    rw [hF_eq_E, hEcard] at hF_ge
    exact hF_ge
  have hp1 : 1 < p := (Fact.out : p.Prime).one_lt
  have hp_sq_lt_cube : p ^ 2 < p ^ 3 :=
    (Nat.pow_lt_pow_iff_right hp1).mpr (by norm_num : (2 : ℕ) < 3)
  exact (not_le_of_gt hp_sq_lt_cube) hle

/-- **BG Lemma 5.2 support**: `C_W(E)` is exactly `Ω₁(Z(R))`.

The squeeze `Z ≤ C_W(E) ≤ E`, the preceding exclusion of `C_W(E)=E`, and
`|Z| = p`, `|E| = p²` leave only the order-`p` possibility. -/
theorem omega1UpperCentralTwo_inf_centralizer_eq_omega1Center
    [Finite R] {p : ℕ} [Fact p.Prime] (hp : Odd p) (hpg : IsPGroup p R)
    (h3 : 3 ≤ pRank R p) {E : Subgroup R} (hEcard : Nat.card ↥E = p ^ 2)
    (hEstar : IsMaximalElementaryAbelian p E) :
    omega1UpperCentralTwo R p ⊓ Subgroup.centralizer (E : Set R) = omega1Center R p := by
  let K : Subgroup R := omega1UpperCentralTwo R p ⊓ Subgroup.centralizer (E : Set R)
  have hZleK : omega1Center R p ≤ K := omega1Center_le_omega1UpperCentralTwo_inf_centralizer
  have hKleE : K ≤ E := by
    dsimp [K]
    exact omega1UpperCentralTwo_inf_centralizer_le_of_maximalElementaryAbelian hp hEstar
  have hK_ne_E : K ≠ E := by
    dsimp [K]
    exact omega1UpperCentralTwo_inf_centralizer_ne_of_maximalElementaryAbelian_card_prime_sq
      hp hpg h3 hEcard hEstar
  have hZcard : Nat.card ↥(omega1Center R p) = p :=
    (omega1Center_lt_and_card_eq_prime_of_maximalElementaryAbelian_card_prime_sq
      hpg h3 hEcard hEstar).2
  have hp_le_K : p ≤ Nat.card K := by
    simpa [hZcard] using Subgroup.card_le_of_le hZleK
  have hKdvd : Nat.card K ∣ p ^ 2 := by
    rw [← hEcard]
    exact Subgroup.card_dvd_of_le hKleE
  obtain ⟨j, hj_le, hj_eq⟩ :=
    (Nat.dvd_prime_pow (p := p) (Fact.out (p := p.Prime))).mp hKdvd
  have hj_ne_zero : j ≠ 0 := by
    intro hj0
    have hp_le_one : p ≤ 1 := by
      simpa [hj0, hj_eq] using hp_le_K
    exact (not_lt_of_ge hp_le_one) (Fact.out : p.Prime).one_lt
  have hj_ne_two : j ≠ 2 := by
    intro hj2
    have hKcard_eq_E : Nat.card K = Nat.card E := by
      rw [hj_eq, hj2, hEcard]
    have hKE : K = E :=
      Subgroup.eq_of_le_of_card_ge hKleE (le_of_eq hKcard_eq_E.symm)
    exact hK_ne_E hKE
  have hj_eq_one : j = 1 := by omega
  have hKcard : Nat.card K = p := by
    simpa [hj_eq_one] using hj_eq
  have hZ_eq_K : omega1Center R p = K :=
    Subgroup.eq_of_le_of_card_ge hZleK (by rw [hKcard, hZcard])
  simpa [K] using hZ_eq_K.symm

/-- **BG Lemma 5.2 support**: the conjugation action of
`W = Ω₁(Z₂(R))` on `E` gives `|W| ≤ p²`.

Since `W ≤ N_R(E)`, restrict the normalizer action `N_R(E) → Aut(E)` to `W`.
Its kernel is `C_W(E) = Ω₁(Z(R))`, already proved above, hence has order `p`; the
image is a `p`-subgroup of `Aut(E)` and has order at most `p` because `|E| = p²`. -/
theorem omega1UpperCentralTwo_card_le_prime_sq_of_maximalElementaryAbelian_card_prime_sq
    [Finite R] {p : ℕ} [Fact p.Prime] (hp : Odd p) (hpg : IsPGroup p R)
    (h3 : 3 ≤ pRank R p) {E : Subgroup R} (hEcard : Nat.card ↥E = p ^ 2)
    (hEstar : IsMaximalElementaryAbelian p E) :
    Nat.card ↥(omega1UpperCentralTwo R p) ≤ p ^ 2 := by
  let W : Subgroup R := omega1UpperCentralTwo R p
  let Z : Subgroup R := omega1Center R p
  let N : Subgroup R := Subgroup.normalizer (E : Set R)
  let C : Subgroup R := Subgroup.centralizer (E : Set R)
  have hWleN : W ≤ N := by
    dsimp [W, N]
    exact omega1UpperCentralTwo_le_normalizer_of_maximalElementaryAbelian_card_prime_sq
      hp hpg h3 hEcard hEstar
  let WN : Subgroup N := W.subgroupOf N
  let φ : WN →* MulAut E := E.normalizerMonoidHom.comp WN.subtype
  have hZcard : Nat.card ↥Z = p := by
    dsimp [Z]
    exact (omega1Center_lt_and_card_eq_prime_of_maximalElementaryAbelian_card_prime_sq
      hpg h3 hEcard hEstar).2
  have hCW_eq_Z : W ⊓ C = Z := by
    dsimp [W, C, Z]
    exact omega1UpperCentralTwo_inf_centralizer_eq_omega1Center hp hpg h3 hEcard hEstar
  let incl : WN →* R := N.subtype.comp WN.subtype
  have hincl : Function.Injective incl := by
    intro a b hab
    apply Subtype.ext
    apply Subtype.ext
    exact hab
  have hker_map : φ.ker.map incl = Z := by
    ext x
    constructor
    · intro hx
      rw [Subgroup.mem_map] at hx
      obtain ⟨w, hwker, rfl⟩ := hx
      rw [← hCW_eq_Z]
      have hwW : (w : R) ∈ W := w.2
      have hwC : (w : R) ∈ C := by
        have hwNker : WN.subtype w ∈ E.normalizerMonoidHom.ker := by
          rw [MonoidHom.mem_ker]
          have hφw : φ w = 1 := MonoidHom.mem_ker.mp hwker
          simpa [φ] using hφw
        have hwC_N : WN.subtype w ∈ C.subgroupOf N := by
          simpa [Subgroup.normalizerMonoidHom_ker, C] using hwNker
        exact hwC_N
      exact ⟨hwW, hwC⟩
    · intro hxZ
      have hxK : x ∈ W ⊓ C := by
        rw [hCW_eq_Z]
        exact hxZ
      rw [Subgroup.mem_map]
      have hxN : x ∈ N := hWleN hxK.1
      let n : N := ⟨x, hxN⟩
      have hnWN : n ∈ WN := by
        change (n : R) ∈ W
        exact hxK.1
      let w : WN := ⟨n, hnWN⟩
      refine ⟨w, ?_, rfl⟩
      rw [MonoidHom.mem_ker]
      have hwNker : WN.subtype w ∈ E.normalizerMonoidHom.ker := by
        rw [Subgroup.normalizerMonoidHom_ker]
        change (x : R) ∈ C
        exact hxK.2
      simpa [φ] using MonoidHom.mem_ker.mp hwNker
  have hker_card : Nat.card φ.ker = p := by
    have hmap_card : Nat.card (φ.ker.map incl) = Nat.card φ.ker := by
      rw [Subgroup.card_map_of_injective hincl]
    rw [← hmap_card, hker_map, hZcard]
  have hWN_pg : IsPGroup p WN := by
    exact (hpg.to_subgroup W).of_equiv (Subgroup.subgroupOfEquivOfLe hWleN).symm
  have hrange_pg : IsPGroup p φ.range :=
    hWN_pg.of_surjective φ.rangeRestrict φ.rangeRestrict_surjective
  have hEcard_le : Nat.card E ≤ p ^ 2 := by
    rw [hEcard]
  have hrange_le : Nat.card φ.range ≤ p :=
    card_pSubgroup_mulAut_le_prime_of_card_le_prime_sq hEstar.isElementaryAbelian hEcard_le
      hrange_pg
  have hLagrange : Nat.card WN = Nat.card φ.range * Nat.card φ.ker := by
    rw [Subgroup.card_eq_card_quotient_mul_card_subgroup φ.ker,
      Nat.card_congr (QuotientGroup.quotientKerEquivRange φ).toEquiv]
  have hWN_le : Nat.card WN ≤ p ^ 2 := by
    rw [hLagrange, hker_card, pow_two]
    exact Nat.mul_le_mul_right p hrange_le
  have hW_card : Nat.card W = Nat.card WN :=
    (Nat.card_congr (Subgroup.subgroupOfEquivOfLe hWleN).toEquiv).symm
  simpa [W] using hW_card.trans_le hWN_le

/-- **BG Lemma 5.2 support**: `W = Ω₁(Z₂(R))` has order `p²`. -/
theorem omega1UpperCentralTwo_card_eq_prime_sq_of_maximalElementaryAbelian_card_prime_sq
    [Finite R] {p : ℕ} [Fact p.Prime] (hp : Odd p) (hpg : IsPGroup p R)
    (h3 : 3 ≤ pRank R p) {E : Subgroup R} (hEcard : Nat.card ↥E = p ^ 2)
    (hEstar : IsMaximalElementaryAbelian p E) :
    Nat.card ↥(omega1UpperCentralTwo R p) = p ^ 2 := by
  let W : Subgroup R := omega1UpperCentralTwo R p
  let Z : Subgroup R := omega1Center R p
  change Nat.card W = p ^ 2
  have hWle : Nat.card W ≤ p ^ 2 := by
    simpa [W] using
      omega1UpperCentralTwo_card_le_prime_sq_of_maximalElementaryAbelian_card_prime_sq
        hp hpg h3 hEcard hEstar
  rcases lemma52_frontHalf_support hp hpg h3 hEcard hEstar with
    ⟨_, _, hZcard, _, hZltW, _⟩
  have hZcard' : Nat.card Z = p := by
    simpa [Z] using hZcard
  have hZltW' : Z < W := by
    simpa [Z, W] using hZltW
  have hZ_card_lt_W : Nat.card Z < Nat.card W :=
    Set.Finite.card_lt_card (Set.toFinite _) (hZltW' : (Z : Set R) ⊂ (W : Set R))
  have hp_lt_W : p < Nat.card W := by
    simpa [hZcard'] using hZ_card_lt_W
  have hW_pg : IsPGroup p W := hpg.to_subgroup W
  obtain ⟨j, hj⟩ := IsPGroup.iff_card.mp hW_pg
  have hp1 : 1 < p := (Fact.out : p.Prime).one_lt
  have hj_le_two : j ≤ 2 := by
    have hpow_le : p ^ j ≤ p ^ 2 := by
      rw [← hj]
      exact hWle
    exact (Nat.pow_le_pow_iff_right hp1).mp hpow_le
  have hj_ne_zero : j ≠ 0 := by
    intro hj0
    have hp_lt_one : p < 1 := by
      rw [hj, hj0, pow_zero] at hp_lt_W
      exact hp_lt_W
    exact (not_lt_of_ge hp1.le) hp_lt_one
  have hj_ne_one : j ≠ 1 := by
    intro hj1
    have hp_lt_self : p < p := by
      rw [hj, hj1, pow_one] at hp_lt_W
      exact hp_lt_W
    exact (lt_irrefl p) hp_lt_self
  have hj_eq_two : j = 2 := by omega
  rw [hj, hj_eq_two]

/-- **BG Lemma 5.2 support**: `W = Ω₁(Z₂(R))` is elementary abelian. -/
theorem omega1UpperCentralTwo_isElementaryAbelian_of_maximalElementaryAbelian_card_prime_sq
    [Finite R] {p : ℕ} [Fact p.Prime] (hp : Odd p) (hpg : IsPGroup p R)
    (h3 : 3 ≤ pRank R p) {E : Subgroup R} (hEcard : Nat.card ↥E = p ^ 2)
    (hEstar : IsMaximalElementaryAbelian p E) :
    (omega1UpperCentralTwo R p).IsElementaryAbelian p := by
  let W : Subgroup R := omega1UpperCentralTwo R p
  change W.IsElementaryAbelian p
  have hWcard : Nat.card W = p ^ 2 := by
    simpa [W] using
      omega1UpperCentralTwo_card_eq_prime_sq_of_maximalElementaryAbelian_card_prime_sq
        hp hpg h3 hEcard hEstar
  refine ⟨?_, ?_⟩
  · intro x y
    exact (IsPGroup.isMulCommutative_of_card_eq_prime_sq (p := p) (G := W) hWcard).is_comm.comm x y
  · intro x
    apply Subtype.ext
    exact pow_eq_one_of_mem_omega1UpperCentralTwo hp x.2

/-- **BG Lemma 5.2 support**: `E` does not centralize `W = Ω₁(Z₂(R))`. -/
theorem not_le_centralizer_omega1UpperCentralTwo_of_maximalElementaryAbelian_card_prime_sq
    [Finite R] {p : ℕ} [Fact p.Prime] (hp : Odd p) (hpg : IsPGroup p R)
    (h3 : 3 ≤ pRank R p) {E : Subgroup R} (hEcard : Nat.card ↥E = p ^ 2)
    (hEstar : IsMaximalElementaryAbelian p E) :
    ¬ E ≤ Subgroup.centralizer (omega1UpperCentralTwo R p : Set R) := by
  intro hE_le_T
  let W : Subgroup R := omega1UpperCentralTwo R p
  let Z : Subgroup R := omega1Center R p
  let C : Subgroup R := Subgroup.centralizer (E : Set R)
  have hCW_eq_Z : W ⊓ C = Z := by
    dsimp [W, C, Z]
    exact omega1UpperCentralTwo_inf_centralizer_eq_omega1Center hp hpg h3 hEcard hEstar
  rcases lemma52_frontHalf_support hp hpg h3 hEcard hEstar with
    ⟨_, _, _, _, hZltW, _⟩
  have hZltW' : Z < W := by
    simpa [Z, W] using hZltW
  have hW_le_C : W ≤ C := by
    intro w hw
    dsimp [C]
    rw [Subgroup.mem_centralizer_iff]
    intro e he
    have heT : e ∈ Subgroup.centralizer (W : Set R) := by
      simpa [W] using hE_le_T he
    exact (Subgroup.mem_centralizer_iff.mp heT w hw).symm
  have hW_le_Z : W ≤ Z := by
    intro w hw
    rw [← hCW_eq_Z]
    exact ⟨hw, hW_le_C hw⟩
  exact hZltW'.ne (le_antisymm hZltW'.le hW_le_Z)

private theorem conjNormal_ker_eq_centralizer_for_subgroup
    {G : Type*} [Group G] {V : Subgroup G} [V.Normal] :
    (MulAut.conjNormal (H := V)).ker = Subgroup.centralizer (V : Set G) := by
  ext g
  rw [MonoidHom.mem_ker, Subgroup.mem_centralizer_iff]
  constructor
  · intro hg v hv
    have hfix : (MulAut.conjNormal g (⟨v, hv⟩ : V) : G) = ((⟨v, hv⟩ : V) : G) := by
      rw [hg]
      rfl
    rw [MulAut.conjNormal_apply] at hfix
    have hcomm : g * v = v * g := by
      have : g * v * g⁻¹ * g = v * g := by rw [hfix]
      simpa [mul_assoc] using this
    exact hcomm.symm
  · intro hg
    apply MulEquiv.ext
    intro v
    apply Subtype.ext
    simp only [MulAut.one_apply]
    rw [MulAut.conjNormal_apply]
    have hcomm : (v : G) * g = g * (v : G) := hg (v : G) v.property
    rw [← hcomm]
    group

/-- **BG Lemma 5.2 support**: `T = C_R(W)` has index `p`. -/
theorem centralizer_omega1UpperCentralTwo_index_eq_prime_of_maximalElementaryAbelian_card_prime_sq
    [Finite R] {p : ℕ} [Fact p.Prime] (hp : Odd p) (hpg : IsPGroup p R)
    (h3 : 3 ≤ pRank R p) {E : Subgroup R} (hEcard : Nat.card ↥E = p ^ 2)
    (hEstar : IsMaximalElementaryAbelian p E) :
    (Subgroup.centralizer (omega1UpperCentralTwo R p : Set R)).index = p := by
  let W : Subgroup R := omega1UpperCentralTwo R p
  let T : Subgroup R := Subgroup.centralizer (W : Set R)
  have hW_normal : W.Normal := by
    dsimp [W]
    infer_instance
  have hT_normal : T.Normal := by
    dsimp [T, W]
    infer_instance
  have hWcard : Nat.card W = p ^ 2 := by
    simpa [W] using
      omega1UpperCentralTwo_card_eq_prime_sq_of_maximalElementaryAbelian_card_prime_sq
        hp hpg h3 hEcard hEstar
  have hWelem : W.IsElementaryAbelian p := by
    simpa [W] using
      omega1UpperCentralTwo_isElementaryAbelian_of_maximalElementaryAbelian_card_prime_sq
        hp hpg h3 hEcard hEstar
  let φ : R →* MulAut W := MulAut.conjNormal (H := W)
  have hker : φ.ker = T := by
    simpa [φ, T] using conjNormal_ker_eq_centralizer_for_subgroup (G := R) (V := W)
  have hquot_range : Nat.card (R ⧸ T) = Nat.card φ.range := by
    rw [← hker]
    exact Nat.card_congr (QuotientGroup.quotientKerEquivRange φ).toEquiv
  have hrange_pg : IsPGroup p φ.range :=
    hpg.of_surjective φ.rangeRestrict φ.rangeRestrict_surjective
  have hWcard_le : Nat.card W ≤ p ^ 2 := by
    rw [hWcard]
  have hrange_le : Nat.card φ.range ≤ p :=
    card_pSubgroup_mulAut_le_prime_of_card_le_prime_sq hWelem hWcard_le hrange_pg
  have hquot_le : Nat.card (R ⧸ T) ≤ p := by
    rw [hquot_range]
    exact hrange_le
  have hT_ne_top : T ≠ ⊤ := by
    intro hTtop
    have hE_le_T : E ≤ Subgroup.centralizer (omega1UpperCentralTwo R p : Set R) := by
      intro e he
      change e ∈ T
      rw [hTtop]
      exact trivial
    exact not_le_centralizer_omega1UpperCentralTwo_of_maximalElementaryAbelian_card_prime_sq
      hp hpg h3 hEcard hEstar hE_le_T
  have hquot_nontriv : Nontrivial (R ⧸ T) :=
    Subgroup.nontrivial_quotient_of_ne_top hT_ne_top
  have hquot_gt_one : 1 < Nat.card (R ⧸ T) :=
    Finite.one_lt_card_iff_nontrivial.mpr hquot_nontriv
  have hquot_pg : IsPGroup p (R ⧸ T) := hpg.to_quotient T
  obtain ⟨j, hj⟩ := IsPGroup.iff_card.mp hquot_pg
  have hp1 : 1 < p := (Fact.out : p.Prime).one_lt
  have hj_le_one : j ≤ 1 := by
    have hpow_le : p ^ j ≤ p ^ 1 := by
      rw [← hj, pow_one]
      exact hquot_le
    exact (Nat.pow_le_pow_iff_right hp1).mp hpow_le
  have hj_ne_zero : j ≠ 0 := by
    intro hj0
    have hone_lt_one : 1 < 1 := by
      rw [hj, hj0, pow_zero] at hquot_gt_one
      exact hquot_gt_one
    exact (lt_irrefl 1) hone_lt_one
  have hj_eq_one : j = 1 := by omega
  have hquot_card : Nat.card (R ⧸ T) = p := by
    rw [hj, hj_eq_one, pow_one]
  rw [Subgroup.index_eq_card]
  exact hquot_card

/-- **BG Lemma 5.2**: 奇素数 `p`, 有限 `p`-群 `R`, `r(R) ≥ 3`, `E ∈ ℰ²(R) ∩ ℰ*(R)` (位数 `p²`
の maximal elem-ab)。`T = C_R(Ω₁(Z₂(R)))` とおくと:

* (a) `E ⊄ T`,
* (b) `|Ω₁(Z(R))| = p` かつ `Ω₁(Z₂(R)) ∈ ℰ²(R)` (= `W` が位数 `p²` の elem-ab),
* (c) `T` は `R` の指数 `p` の characteristic 部分群 (char は `NarrowPGroup` で既証, 指数 `p`)。

mmd L1814-1836: `Z=Ω₁(Z(R))⊆E` + `W=Ω₁(Z₂(R))` exp `p` (Lem 4.5c) + `W/C_W(E) ↪ Aut E` の
位数評価 (≤ `p`)。Thm 5.3 の中核。 -/
theorem lemma52 [Finite R] {p : ℕ} [Fact p.Prime] (hp : Odd p) (hpg : IsPGroup p R)
    (h3 : 3 ≤ pRank R p) (E : Subgroup R) (hEcard : Nat.card ↥E = p ^ 2)
    (hEstar : IsMaximalElementaryAbelian p E) :
    ¬ E ≤ Subgroup.centralizer (omega1UpperCentralTwo R p : Set R) ∧
    (Nat.card ↥(omega1Center R p) = p ∧
      (omega1UpperCentralTwo R p).IsElementaryAbelian p ∧
      Nat.card ↥(omega1UpperCentralTwo R p) = p ^ 2) ∧
    (Subgroup.centralizer (omega1UpperCentralTwo R p : Set R)).index = p := by
  exact
    ⟨not_le_centralizer_omega1UpperCentralTwo_of_maximalElementaryAbelian_card_prime_sq
        hp hpg h3 hEcard hEstar,
      ⟨(omega1Center_lt_and_card_eq_prime_of_maximalElementaryAbelian_card_prime_sq
          hpg h3 hEcard hEstar).2,
        omega1UpperCentralTwo_isElementaryAbelian_of_maximalElementaryAbelian_card_prime_sq
          hp hpg h3 hEcard hEstar,
        omega1UpperCentralTwo_card_eq_prime_sq_of_maximalElementaryAbelian_card_prime_sq
          hp hpg h3 hEcard hEstar⟩,
      centralizer_omega1UpperCentralTwo_index_eq_prime_of_maximalElementaryAbelian_card_prime_sq
        hp hpg h3 hEcard hEstar⟩

/-- **BG §5 narrow witness extraction**: when `r(R) ≥ 3`, the first disjunct in the
definition of `IsNarrow` is impossible, so a narrow group supplies BG's order-`p`
witness `R₀` and cyclic complement `R₁` inside `C_R(R₀)`.

This is the definition-level forward support for Corollary 5.4; it does not assert the
hard rank/decomposition conclusions of Theorem 5.3. -/
theorem exists_narrow_witness_of_three_le_pRank {p : ℕ}
    (h3 : 3 ≤ pRank R p) (hnarrow : IsNarrow p R) :
    ∃ R₀ R₁ : Subgroup R, Nat.card R₀ = p ∧ IsCyclic R₁ ∧
      R₀ ⊓ R₁ = ⊥ ∧ Subgroup.centralizer (R₀ : Set R) = R₀ ⊔ R₁ := by
  rcases hnarrow with hrank | hwitness
  · omega
  · exact hwitness

theorem pRank_centralizer_le_two_of_narrow_witness
    [Finite R] {p : ℕ} [Fact p.Prime] (hp : Odd p) (hpg : IsPGroup p R)
    {S K : Subgroup R} (hScard : Nat.card S = p) (hKcyc : IsCyclic K)
    (hSKinf : S ⊓ K = ⊥) (hCeq : Subgroup.centralizer (S : Set R) = S ⊔ K) :
    pRank ↥(Subgroup.centralizer (S : Set R)) p ≤ 2 := by
  classical
  let C : Subgroup R := Subgroup.centralizer (S : Set R)
  have hScomm : ∀ a ∈ S, ∀ b ∈ S, a * b = b * a := by
    have hScyc : IsCyclic S := isCyclic_of_prime_card hScard
    have : IsCyclic S := hScyc
    let : CommGroup S := IsCyclic.commGroup
    intro a ha b hb
    exact congrArg Subtype.val (mul_comm (⟨a, ha⟩ : S) (⟨b, hb⟩ : S))
  have hSleC : S ≤ C := by
    intro s hs
    dsimp [C]
    rw [Subgroup.mem_centralizer_iff]
    intro t ht
    exact (hScomm s hs t ht).symm
  have hKleC : K ≤ C := by
    dsimp [C]
    rw [hCeq]
    exact le_sup_right
  let Ssub : Subgroup C := S.subgroupOf C
  let Ksub : Subgroup C := K.subgroupOf C
  have hSsub_card : Nat.card Ssub = p := by
    exact (Nat.card_congr (Subgroup.subgroupOfEquivOfLe hSleC).toEquiv).trans hScard
  have hKsub_cyc : IsCyclic Ksub := by
    have : IsCyclic K := hKcyc
    exact isCyclic_of_injective (Subgroup.subgroupOfEquivOfLe hKleC).toMonoidHom
      (Subgroup.subgroupOfEquivOfLe hKleC).injective
  have hSsub_inf : Ssub ⊓ Ksub = ⊥ := by
    refine le_antisymm ?_ bot_le
    intro x hx
    rw [Subgroup.mem_bot]
    apply Subtype.ext
    change (x : R) = 1
    have hxR : (x : R) ∈ S ⊓ K := by
      exact ⟨hx.1, hx.2⟩
    rwa [hSKinf, Subgroup.mem_bot] at hxR
  have hSsub_le_center : Ssub ≤ Subgroup.center C := by
    intro s hs
    rw [Subgroup.mem_center_iff]
    intro c
    apply Subtype.ext
    exact (Subgroup.mem_centralizer_iff.mp c.2 (s : R) hs).symm
  have hSsub_normal : Ssub.Normal := by
    refine { conj_mem := fun x hx g => ?_ }
    have hx_center : x ∈ Subgroup.center C := hSsub_le_center hx
    have hconj : g * x * g⁻¹ = x := by
      have hcomm := Subgroup.mem_center_iff.mp hx_center g
      calc g * x * g⁻¹ = x * g * g⁻¹ := by rw [hcomm]
        _ = x := by group
    rwa [hconj]
  have hSup_top : Ssub ⊔ Ksub = ⊤ := by
    calc
      Ssub ⊔ Ksub = (S ⊔ K).subgroupOf C :=
        (Subgroup.subgroupOf_sup hSleC hKleC).symm
      _ = ⊤ := by
        rw [← hCeq]
        exact Subgroup.subgroupOf_self C
  have hCcard : Nat.card C = p * Nat.card Ksub := by
    have hcard := Subgroup.card_HK_mul_card_inf_eq_card_mul_card Ssub Ksub
    rw [← Subgroup.normal_mul Ssub Ksub, hSsub_inf, Subgroup.card_bot, hSsub_card,
      mul_one, hSup_top] at hcard
    simpa [Subgroup.coe_top] using hcard
  have hKsub_index : Ksub.index = p := by
    have hmul : Ksub.index * Nat.card Ksub = Nat.card C := Ksub.index_mul_card
    have hmul' : Ksub.index * Nat.card Ksub = p * Nat.card Ksub := by
      simpa [hCcard] using hmul
    exact Nat.mul_right_cancel (Nat.card_pos (α := Ksub)) hmul'
  obtain ⟨x, hx⟩ := (Subgroup.isCyclic_iff_exists_zpowers_eq_top Ksub).mp hKsub_cyc
  have hidx : (Subgroup.zpowers x).index = p := by
    rw [hx]
    exact hKsub_index
  have hOmega_le : Nat.card (Omega C p 1) ≤ p ^ 2 :=
    OddOrder.BG.Ch1.S04.card_omega1_le_prime_sq_of_cyclic_index_prime
      (hpg.to_subgroup C) hp hidx
  rw [pRank_le_iff]
  intro A hA
  have hA_le_omega : A ≤ Omega C p 1 := by
    rw [Omega]
    intro a ha
    exact Subgroup.subset_closure (by
      rw [Set.mem_ofPred_eq, pow_one]
      exact congrArg Subtype.val (hA.pow_eq_one ⟨a, ha⟩))
  have hAcard_le : Nat.card A ≤ Nat.card (Omega C p 1) := Subgroup.card_le_of_le hA_le_omega
  have hlog_le : Nat.log p (Nat.card A) ≤ Nat.log p (p ^ 2) :=
    Nat.log_mono_right (hAcard_le.trans hOmega_le)
  simpa [Nat.log_pow (Fact.out : p.Prime).one_lt] using hlog_le

/-- **BG Theorem 5.3(d) support**: if an order-p subgroup has centralizer
p-rank at most two, then it meets Omega_1 of the center trivially under the
standing rank-at-least-three hypothesis. -/
theorem inf_omega1Center_eq_bot_of_card_prime_centralizer_pRank_le_two
    [Finite R] {p : ℕ} [Fact p.Prime] (h3 : 3 ≤ pRank R p)
    {S : Subgroup R} (hScard : Nat.card S = p)
    (hSrank : pRank ↥(Subgroup.centralizer (S : Set R)) p ≤ 2) :
    S ⊓ omega1Center R p = ⊥ := by
  classical
  let Z : Subgroup R := omega1Center R p
  let C : Subgroup R := Subgroup.centralizer (S : Set R)
  have hS_not_le_Z : ¬ S ≤ Z := by
    intro hSleZ
    have hCtop : C = ⊤ := by
      rw [eq_top_iff]
      intro x _
      dsimp [C]
      rw [Subgroup.mem_centralizer_iff]
      intro s hs
      exact (Subgroup.mem_center_iff.mp (omega1Center_le_center (hSleZ hs)) x).symm
    let toC : R →* C :=
      { toFun := fun r => ⟨r, by rw [hCtop]; exact trivial⟩
        map_one' := rfl
        map_mul' := fun _ _ => rfl }
    have htoC_inj : Function.Injective toC := by
      intro x y hxy
      exact congrArg Subtype.val hxy
    have hRrank_le_C : pRank R p ≤ pRank C p :=
      pRank_le_of_injective (G := C) (H := R) (f := toC) htoC_inj
    exact absurd (hRrank_le_C.trans hSrank) (by omega)
  let H : Subgroup S := (S ⊓ Z).subgroupOf S
  have : Fact (Nat.card S).Prime := ⟨by rw [hScard]; exact (Fact.out : p.Prime)⟩
  rcases Subgroup.eq_bot_or_eq_top_of_prime_card H with hHbot | hHtop
  · refine le_antisymm ?_ bot_le
    intro x hx
    have hxH : (⟨x, hx.1⟩ : S) ∈ H := by
      dsimp [H]
      rw [Subgroup.mem_subgroupOf]
      exact hx
    rw [hHbot, Subgroup.mem_bot] at hxH
    exact Subtype.ext_iff.mp hxH
  · exfalso
    apply hS_not_le_Z
    intro s hs
    have hsH : (⟨s, hs⟩ : S) ∈ H := by
      rw [hHtop]
      exact trivial
    exact (Subgroup.mem_subgroupOf.mp hsH).2

/-- **BG Corollary 5.4 forward support**: under rank at least three, a definitional
narrow witness has centralizer p-rank at most two. This is the direct Lean version
of the first sentence of BG Corollary 5.4, using the cyclic-complement form of narrowness. -/
theorem exists_card_prime_centralizer_pRank_le_two_of_narrow
    [Finite R] {p : ℕ} [Fact p.Prime] (hp : Odd p) (hpg : IsPGroup p R)
    (h3 : 3 ≤ pRank R p) (hnarrow : IsNarrow p R) :
    ∃ S : Subgroup R, Nat.card S = p ∧
      pRank ↥(Subgroup.centralizer (S : Set R)) p ≤ 2 := by
  obtain ⟨S, K, hScard, hKcyc, hSKinf, hCeq⟩ :=
    exists_narrow_witness_of_three_le_pRank h3 hnarrow
  exact ⟨S, hScard,
    pRank_centralizer_le_two_of_narrow_witness hp hpg hScard hKcyc hSKinf hCeq⟩

end OddOrder.BG.Ch1.S05
Source
Yawara Ishida, Lean 4 formalization of the Feit–Thompson (odd order) theorem, github.com/yawara/odd-order @ 20a6fccbb63c (Apache-2.0), https://github.com/yawara/odd-order/blob/20a6fccbb63c0b138acda9f7fafd798c42f9441b/OddOrder/BG/Ch1_Preliminary/S05_NarrowSCN.lean

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me