Skip to content

Lean formalization of the Riemann Hypothesis (Alpöge, 2026-11-20) being cleaned up by members of the Lean community.

Python
39.7 KB
Raw Blame
module

public import TauCeti.RepresentationTheory.AsAlgebraHom
import TauCeti.RepresentationTheory.Simple.Basic
import TauCeti.RepresentationTheory.CharacterTable.Values
public import Aesop.BuiltinRules
public import Mathlib.RepresentationTheory.Character
import Mathlib.Algebra.Module.StablyFree.Basic
import Mathlib.Algebra.Order.PUnit
import Mathlib.Analysis.CStarAlgebra.Classes
import Mathlib.LinearAlgebra.Matrix.FiniteDimensional
import Mathlib.RingTheory.Coalgebra.CoassocSimps
import Mathlib.RingTheory.Coalgebra.IsFrobenius
import Mathlib.RingTheory.Etale.Weakly
import Mathlib.RingTheory.Finiteness.ModuleFinitePresentation
import Mathlib.RingTheory.HopfAlgebra.Basic
import Mathlib.RingTheory.SimpleRing.Principal
import Mathlib.RingTheory.TotallySplit
import TauCeti.RepresentationTheory.CharacterTable.CentralCharacter
import TauCeti.RepresentationTheory.CharacterTable.Completeness
import TauCeti.RepresentationTheory.Unitary
public import Lib.Speed

/-!
# Characters of finite groups: averages, virtual characters and central projections

This file sets up the character theory of a finite group `G` that is used for the characters of
`GL n` over a finite field. From Wedderburn's theorem it derives criteria for irreducibility.

## Main definitions and results

* `New.IsIrreducibleChar`: the characters of simple finite-dimensional complex representations.
* `New.virtualChars S G`: the `S`-span of the characters, a subalgebra of `G → ℂ`; for `S = ℤ` these
  are the virtual characters, for `S = ℕ` the characters (`New.isChar_of_mem_virtualChars`).
* `New.IsCentralProj`: central idempotents e of the group algebra ℂ[H] of any group H. Their
  coefficients are class functions; 1 − e, the image of e under a ring endomorphism of ℂ and tensor
  products are again central idempotents.
* `New.IsClassFunction.isIrreducibleChar_of_classInner_eq_intCast`,
  `New.IsClassFunction.mem_virtualChars`, `New.IsClassFunction.exists_eq_mul_groupAlgElem_mul`:
  criteria for a class function `f` to be an irreducible character, for `f` to be a combination of
  characters with coefficients in a given semiring, and for an element of `ℂ[G]` to be recovered
  from its product with `New.groupAlgElem f`.
* `New.IsCentralProj.isChar_card_mul_coeff`: for a central idempotent `e` of `ℂ[G]`, the function
  `g ↦ |G| · e(g)` is a character. Its pairing with any character is the rank of an idempotent, so a
  natural number. It is the character of a representation of dimension at most `|G|`
  (`New.IsCentralProj.exists_character_eq_and_finrank_le_card`), so the coefficients of `e` have
  norm at most `1` (`New.IsCentralProj.norm_coeff_le_one`).
* `New.IsCentralProj.self_adjoint`, `New.IsCentralProj.sum_norm_sq_conv_le`: a central idempotent of
  `ℂ[G]` acts self-adjointly for every `G`-invariant form that is sesquilinear for `σ⁻¹ ∘ conj ∘ σ`,
  complex conjugation transported along an automorphism `σ` of `ℂ`. So it acts as an orthogonal
  projection in every unitary representation. Hence convolution with it does not increase `ℓ²`
  norms.
-/

@[expose] public section

noncomputable section

/-!
## Averages, inner products, characters and group algebra elements

The basic definitions: `New.finMean`, `New.classInner`, `New.groupAlgElem` (a function `f` as the
element `∑ g, f g • g` of the group algebra), `New.IsChar`, `New.IsClassFunction` and
`New.IsIrreducibleChar`.
-/

namespace New

variable {G : Type*} [Group G] [Finite G] (f h : G → ℂ)

/-- The average of a complex function f on a finite type G: the sum of its values divided by the
cardinality of G. -/
def finMean : ℂ := finsum f / Nat.card G

/-- The inner product ⟨f, h⟩ of complex functions on a finite set: the average over g of conj
f(g) · h(g). -/
def classInner : ℂ := finMean fun g ↦ starRingEnd ℂ (f g) * h g

/-- For a complex function f on a finite group G, the element Σ f(g)·g of the group algebra
ℂ[G]. -/
@[simps]
def groupAlgElem : MonoidAlgebra ℂ G := ⟨Finsupp.equivFunOnFinite.symm f⟩

/-- The function f : G → ℂ is the character of a finite-dimensional complex representation
of G. -/
def IsChar : Prop := ∃ V : FDRep ℂ G, V.character = f

/-- The function f : G → ℂ is a class function: f(xgx⁻¹) = f(g) for all g, x in G. -/
@[simp]
abbrev IsClassFunction : Prop := ∀ g x : G, f (x * g * x⁻¹) = f g

/-- The function `f` is an irreducible character: the character of a simple finite-dimensional
complex representation of `G`. `New.IsClassFunction.isIrreducibleChar_of_classInner_eq_intCast`
gives a criterion. -/
def IsIrreducibleChar : Prop := ∃ V : FDRep ℂ G, CategoryTheory.Simple V ∧ V.character = f

end New

namespace New

/-!
## Averages of complex functions on finite sets

`New.finMean f` is the mean of a complex function on a finite type.
-/

section Average

open ComplexConjugate Finset Fintype

attribute [local instance low] Fintype.ofFinite

variable {α β : Type*} {ι : Type*} [Finite α] [Finite β] {f : α → ℂ} {g : β → ℂ}

omit [Finite α] in
lemma finMean_eq [Fintype α] : finMean f = (∑ x : α, f x) / Fintype.card α := by
  rw [finMean, finsum_eq_sum_of_fintype, Nat.card_eq_fintype_card]

@[simp]
lemma finMean_const_mul (c : ℂ) : finMean (fun x : α ↦ c * f x) = c * finMean f := by
  simp [finMean_eq, mul_div, mul_sum]

lemma finMean_sum (s : Finset ι) (f : ι → α → ℂ) :
    finMean (fun x : α ↦ ∑ i ∈ s, f i x) = ∑ i ∈ s, finMean (f i) := by
  simp [finMean_eq, s.sum_comm, sum_div]

@[simp]
lemma finMean_const [Nonempty α] (c : ℂ) : finMean (fun _ : α ↦ c) = c := by
  simp [finMean_eq]

lemma finMean_conj : finMean (fun x : α ↦ conj (f x)) = conj (finMean f) := by
  simp [finMean_eq]

lemma finMean_equiv (e : β ≃ α) (hfg : ∀ x : β, f (e x) = g x) : finMean f = finMean g := by
  simp [finMean_eq, ← hfg, card_congr e, Equiv.sum_comp]

/-- Fubini: the average over a product is the iterated average. -/
lemma finMean_prod (f : α × β → ℂ) :
    finMean f = finMean fun x : α ↦ finMean fun y : β ↦ f (x, y) := by
  simp only [finMean_eq, sum_prod_type, card_prod, Nat.cast_mul, ← sum_div, div_div, mul_comm]

/-- Let `p : α →+ β` be a surjective homomorphism of finite additive groups. Then the mean of
`f ∘ p` over `α` equals the mean of `f` over `β`. -/
lemma finMean_comp_surjective [AddGroup α] [AddGroup β] (p : α →+ β) (hp : Function.Surjective p)
    (f : β → ℂ) : finMean (fun x : α ↦ f (p x)) = finMean f := by
  -- `α` is in bijection with `β × ker p`, and `p` becomes the first projection
  let e : α ≃ β × p.ker :=
    (Equiv.sigmaFiberEquiv p).symm.trans (.sigmaEquivProdOfEquiv (p.fiberEquivKerOfSurjective hp))
  calc
    _ = finMean fun x : β × p.ker ↦ f x.1 := (finMean_equiv e fun _ ↦ rfl).symm
    _ = finMean f := by simp_rw [finMean_prod, finMean_const]

end Average

/-!
## Characters and the algebra of virtual characters

* `New.IsChar.apply_inv`, `New.IsChar.isIntegral`, `New.IsChar.norm_apply_le` and `New.IsChar.star`:
  basic arithmetic properties of character values, obtained from Mathlib
  (`FDRep.isIntegral_character`) and Tau Ceti (`FDRep.conj_char`, `FDRep.norm_char_le_finrank`).
-/

section VirtualCharacters

open ComplexConjugate Submodule LinearMap Finset

attribute [local instance low] Fintype.ofFinite

variable {S : Type*} [CommSemiring S] [Algebra S ℂ]
  {G : Type*} [Group G] {χ ψ f : G → ℂ}

/-! ### The algebra spanned by the characters -/

/-- The product of two characters is a character, that of the tensor product. -/
lemma IsChar.mul (hχ : IsChar χ) (hψ : IsChar ψ) : IsChar (χ * ψ) := by
  obtain ⟨V, rfl⟩ := hχ
  obtain ⟨W, rfl⟩ := hψ
  exact ⟨CategoryTheory.MonoidalCategory.tensorObj V W, FDRep.char_tensor V W⟩

lemma isChar_monoidHom (l : G →* ℂ) : IsChar l :=
  -- the one-dimensional representation in which `g` acts as multiplication by `l g`
  ⟨.of (.comp MonoidHom.smulOneHom l), funext fun g ↦ Algebra.trace_self_apply (l g)⟩

variable (S G) in
/-- For a group G and a commutative semiring S with ℂ an S-algebra, the S-subalgebra of functions
G → ℂ spanned over S by the characters of G. -/
def virtualChars : Subalgebra S (G → ℂ) :=
  (span S {f : G → ℂ | IsChar f}).toSubalgebra
    -- the constant `1` is the trivial character
    (subset_span (isChar_monoidHom 1))
    -- a product of characters is a character, and multiplication is bilinear
    (BilinMap.apply_apply_mem_of_mem_span (span S {f : G → ℂ | IsChar f}) {f : G → ℂ | IsChar f}
      {f : G → ℂ | IsChar f} (LinearMap.mul S (G → ℂ)) fun _ hχ _ hψ ↦ subset_span (hχ.mul hψ))

/-- The zero function is a character, that of the zero representation. -/
lemma isChar_zero : IsChar (0 : G → ℂ) :=
  ⟨.of (Representation.trivial ℂ G PUnit), funext fun _ ↦ (trace ℂ PUnit).map_zero⟩

/-- The sum of two characters is a character, that of the direct sum. -/
lemma IsChar.add (hχ : IsChar χ) (hψ : IsChar ψ) : IsChar (χ + ψ) := by
  obtain ⟨V, rfl⟩ := hχ
  obtain ⟨W, rfl⟩ := hψ
  exact ⟨.of (.prod V.ρ W.ρ), funext fun g ↦ trace_prodMap' (V.ρ g) (W.ρ g)⟩

lemma isChar_of_mem_virtualChars (hf : f ∈ virtualChars ℕ G) : IsChar f := by
  -- The characters form an additive submonoid, which is therefore its own `ℕ`-span.
  let M : AddSubmonoid (G → ℂ) := ⟨⟨{χ : G → ℂ | IsChar χ}, IsChar.add⟩, isChar_zero⟩
  have h_span : f ∈ (span ℕ (M : Set (G → ℂ))).toAddSubmonoid := hf
  rwa [span_nat_eq] at h_span

/-! ### Properties of a character -/

lemma IsChar.comp (hχ : IsChar χ) {H : Type*} [Group H] (p : H →* G) : IsChar (χ ∘ p) := by
  obtain ⟨V, rfl⟩ := hχ
  exact ⟨.of (V.ρ.comp p), rfl⟩

lemma IsChar.mem_virtualChars (hχ : IsChar χ) : χ ∈ virtualChars S G := subset_span hχ

lemma IsChar.isClassFunction (hχ : IsChar χ) : IsClassFunction χ := by
  obtain ⟨V, rfl⟩ := hχ
  exact V.char_conj

lemma IsIrreducibleChar.isChar (hχ : IsIrreducibleChar χ) : IsChar χ :=
  hχ.imp fun _ h ↦ h.2

/-- The value of an irreducible character at the identity has positive real part. -/
lemma IsIrreducibleChar.re_apply_one_pos (hχ : IsIrreducibleChar χ) : 0 < (χ 1).re := by
  obtain ⟨V, hV, rfl⟩ := hχ
  have : Nontrivial V := (FDRep.isIrreducible_of_simple V).nontrivial
  simpa [FDRep.char_one] using (Module.finrank_pos (R := ℂ) (M := V))

variable [Finite G]

lemma IsChar.apply_inv (hχ : IsChar χ) (g : G) : χ g⁻¹ = conj (χ g) := by
  obtain ⟨V, rfl⟩ := hχ
  exact (V.conj_char g).symm

/-- The values of a character of a finite group are algebraic integers. -/
lemma IsChar.isIntegral (hχ : IsChar χ) (g : G) : IsIntegral ℤ (χ g) := by
  obtain ⟨V, rfl⟩ := hχ
  exact V.isIntegral_character g

/-- The norm of a character of a finite group is largest at the identity. -/
lemma IsChar.norm_apply_le (hχ : IsChar χ) (g : G) : ‖χ g‖ ≤ ‖χ 1‖ := by
  obtain ⟨V, rfl⟩ := hχ
  simpa [FDRep.char_one] using V.norm_char_le_finrank g

/-- The complex conjugate of a character is a character, that of the dual representation. -/
lemma IsChar.star (hχ : IsChar χ) : IsChar fun g : G ↦ conj (χ g) := by
  simp only [← hχ.apply_inv]
  obtain ⟨V, rfl⟩ := hχ
  exact ⟨.of (.dual V.ρ), funext fun g ↦ by simp⟩

/-- The inner product `classInner χ f` (the average of `conj (χ g) * f g`) of a character `χ` with
an `S`-linear combination `f` of characters lies in the image of `S` in `ℂ`. -/
lemma IsChar.exists_classInner_eq (hχ : IsChar χ) (hf : f ∈ virtualChars S G) :
    ∃ m : S, classInner χ f = algebraMap S ℂ m := by
  -- Write `f = ∑ j, a j • ψ j` with characters `ψ j`. Each pairing is the dimension of the
  -- space of equivariant maps from the representation for `χ` to the one for `ψ j`.
  obtain ⟨n, a, ψ, rfl⟩ := mem_span_set'.1 hf
  choose m hm using fun j : Fin n ↦
    show ∃ m : ℕ, classInner χ (ψ j) = m from by
      obtain ⟨V, rfl⟩ := hχ
      obtain ⟨W, hW⟩ := (ψ j).property
      rw [← hW]
      exact ⟨_, by simpa [classInner, finMean_eq, div_eq_inv_mul, V.conj_char, mul_comm] using
        V.scalar_product_char_eq_finrank_equivariant W⟩
  use ∑ j : Fin n, a j * m j
  calc classInner χ (∑ j : Fin n, a j • (ψ j : G → ℂ))
      = ∑ j : Fin n, algebraMap S ℂ (a j) * classInner χ (ψ j) := by
        simp [classInner, mul_sum, finMean_sum, Algebra.smul_def, mul_left_comm]
    _ = algebraMap S ℂ (∑ j : Fin n, a j * m j) := by simp [hm]

omit [Finite G] in
/-- The pull-back along a homomorphism from a finite group of an `S`-linear combination of
characters is an `S`-linear combination of characters. -/
lemma comp_mem_virtualChars (hf : f ∈ virtualChars S G) {H : Type*} [Group H]
    (p : H →* G) : f ∘ p ∈ virtualChars S H :=
  -- precomposition with `p` is linear and maps characters to characters
  mapsTo_span (f := funLeft S ℂ p) (s := {χ | IsChar χ}) (fun _ hχ ↦ IsChar.comp hχ p) hf

omit [Finite G] in
lemma isClassFunction_of_mem_virtualChars (hf : f ∈ virtualChars S G) : IsClassFunction f := by
  induction hf using span_induction with
  | mem χ hχ => exact IsChar.isClassFunction hχ
  | zero => simp
  | add χ ψ _ _ hχ hψ => exact fun g x ↦ by simp [hχ g x, hψ g x]
  | smul a χ _ hχ => exact fun g x ↦ by simp [hχ g x]

end VirtualCharacters

/-!
## Central projections of group algebras and their tensor products

* `New.piTensorElem`: the tensor product ⊗ x_i in ℂ[∏ G_i] of elements x_i of ℂ[G_i], for a finite
  index type ι. If every x_i is a central idempotent, so is ⊗ x_i
  (`New.IsCentralProj.piTensorElem`).
* `New.piTensorElem_apply_eq_zero`, `New.piTensorElem_mul_eq_zero`: a tensor product kills a vector,
  or another tensor product, as soon as one factor does.
-/

section CentralProjections

open MonoidAlgebra Finset Finsupp Representation Function

attribute [local instance low] Fintype.ofFinite

variable {ι : Type _} [Fintype ι] [DecidableEq ι]
  {G : ι → Type _} [∀ i : ι, Group (G i)] [∀ i : ι, Finite (G i)] {H : Type*} [Group H]
  {x : ∀ i : ι, ℂ[G i]} {V : Type*} [AddCommGroup V] [Module ℂ V]
  (σ : Representation ℂ H V) {e : ℂ[H]} {ρ : Representation ℂ (∀ i : ι, G i) V}

/-- A class function takes the same value on the products `a * b` and `b * a`. -/
lemma IsClassFunction.apply_mul_comm {f : H → ℂ} (hf : IsClassFunction f) (a b : H) :
    f (a * b) = f (b * a) := by
  simpa [mul_assoc] using hf (b * a) a

lemma IsClassFunction.commute (he : IsClassFunction e.coeff) (x : ℂ[H]) : Commute x e := by
  ext g
  simp only [coeff_mul_apply_left x e, coeff_mul_apply_right e x, he.apply_mul_comm g, mul_comm]

/-- `e` is a central idempotent of the complex group algebra `ℂ[H]` of a group `H`: it is
idempotent and its coefficients form a class function. -/
def IsCentralProj (e : ℂ[H]) : Prop := IsIdempotentElem e ∧ IsClassFunction e.coeff

lemma IsCentralProj.isIdempotentElem (h : IsCentralProj e) : IsIdempotentElem e := h.left

lemma IsCentralProj.isClassFunction (h : IsCentralProj e) : IsClassFunction e.coeff := h.right

open scoped Classical in
/-- The multiplicative map sending a family `x i ∈ ℂ[G i]` to its tensor product in the group
algebra of the product of the `G i`: the coefficient at `s` is the product over `i` of the
coefficients of `x i` at `s i`. -/
@[simps!]
noncomputable def piTensorElem : (∀ i : ι, ℂ[G i]) →* ℂ[∀ i : ι, G i] where
  toFun x := groupAlgElem fun s : ∀ i : ι, G i ↦ ∏ i : ι, (x i).coeff (s i)
  map_one' := by aesop (add simp [one_def, single_apply, prod_boole])
  map_mul' := by
    -- the convolution at `s` factors over `ι`, as a product of sums is a sum over families
    aesop (add simp [coeff_mul_apply_left, sum_fintype, prod_univ_sum, prod_mul_distrib])

/-- The tensor `1 ⊗ ⋯ ⊗ x ⊗ ⋯ ⊗ 1`, with `x` in place `i`, acts in a representation `ρ` of the
product of the groups `G j` as `x` does in the restriction of `ρ` to the factor `G i`. -/
lemma asAlgebraHom_piTensorElem_mulSingle (i : ι) (x : ℂ[G i]) :
    ρ.asAlgebraHom (piTensorElem (Pi.mulSingle i x)) =
      asAlgebraHom (ρ.comp (MonoidHom.mulSingle G i)) x := by
  classical
  -- Both sides are sums over a group; compare them along the inclusion of `G i` in the product.
  -- Every factor other than the one at `i` is a coefficient of `1`, so it is `1` or `0`.
  have h_coeff (s : ∀ j : ι, G j) : (piTensorElem (Pi.mulSingle i x)).coeff s =
      x.coeff (s i) * if ∀ j : ι, j ≠ i → s j = 1 then 1 else 0 := by
    simp +contextual [prod_congr rfl, Fintype.prod_eq_mul_prod_compl i, Pi.mulSingle, one_def,
      single_apply, prod_boole, eq_comm]
  rw [asAlgebraHom_eq_sum, asAlgebraHom_eq_sum,
    Fintype.sum_of_injective _ (Pi.mulSingle_injective i)]
  · -- an element outside the image is nontrivial at some index other than `i`
    intro s hs
    have h_ne : ¬ ∀ j : ι, j ≠ i → s j = 1 := fun h_one ↦
      hs ⟨s i, update_eq_iff.2 ⟨rfl, fun j hj ↦ (h_one j hj).symm⟩⟩
    simp [h_coeff, h_ne]
  · simp +contextual [h_coeff]

/-- If the factor `x i` kills the vector `v` in the restriction of `ρ` to `G i`, then the tensor
product of the `x j` kills `v` in `ρ`. -/
lemma piTensorElem_apply_eq_zero {v : V} (i : ι)
    (hv : asAlgebraHom (ρ.comp (MonoidHom.mulSingle G i)) (x i) v = 0) :
    ρ.asAlgebraHom (piTensorElem x) v = 0 := by
  -- split off the i-th component of x, which acts first and kills v
  have h_split : x = update x i 1 * Pi.mulSingle i (x i) := by
    rw [Pi.mulSingle, ← update_mul, one_mul, mul_one, update_eq_self]
  rw [h_split]
  simp [asAlgebraHom_piTensorElem_mulSingle, hv]

/-- Two tensor products multiply to zero as soon as their factors in one place `i` do. -/
lemma piTensorElem_mul_eq_zero {y : (i : ι) → ℂ[G i]} (i : ι) (h_mul : x i * y i = 0) :
    piTensorElem x * piTensorElem y = 0 := by
  ext s
  simpa [← map_mul] using
    prod_eq_zero (f := fun j ↦ (x j * y j).coeff (s j)) (mem_univ i) (by simp [h_mul])

namespace IsCentralProj

open scoped Classical in
lemma one_sub (h : IsCentralProj e) : IsCentralProj (1 - e) :=
  ⟨h.isIdempotentElem.one_sub, fun g x ↦ by
    simp [h.isClassFunction g x, eq_comm, one_def, single_apply]⟩

/-- Applying a ring endomorphism `σ` of `ℂ` to the coefficients of a central idempotent `e` of
`ℂ[H]` (`H` any group) gives a central idempotent. -/
lemma map (h : IsCentralProj e) (σ : ℂ →+* ℂ) : IsCentralProj (mapRingHom H σ e) :=
  ⟨h.isIdempotentElem.map (mapRingHom H σ), fun g x ↦ by simp [h.isClassFunction g x]⟩

lemma piTensorElem (h : ∀ i : ι, IsCentralProj (x i)) : IsCentralProj (New.piTensorElem x) := by
  have h_idem : IsIdempotentElem x := funext fun i ↦ (h i).isIdempotentElem
  exact ⟨h_idem.map New.piTensorElem, fun g s ↦ by simp [(h _).isClassFunction _ _]⟩

end IsCentralProj

end CentralProjections

/-!
## Irreducibility criteria and expansion of class functions

* `New.classInner_eq_sum_of_eq_sum`: Parseval's identity for the expansion of a class function.
* `New.IsChar.asAlgebraHom_groupAlgElem_eq_zero_iff`: `∑ g, conj (χ g) • g` acts as zero in `ρ` iff
  `χ` is orthogonal to the character of `ρ`. `New.IsChar.asAlgebraHom_groupAlgElem_eq_zero` is a
  sufficient condition for `∑ g, χ (i g * s) • g` to act as zero, `i` a group homomorphism.
-/

section IrreducibleCharacters

open MonoidAlgebra Finset LinearMap ComplexConjugate Matrix Algebra Representation

attribute [local instance low] Fintype.ofFinite

variable {G H V : Type*} [Group G] [Finite G] [Group H] {χ f : G → ℂ}
  [AddCommGroup V] [Module ℂ V] {ρ : Representation ℂ G V}
  (Z : Type*) [CommSemiring Z] [Algebra Z ℂ]

omit [Group G] in
/-- Parseval's identity: if `φ = ∑ i, ⟨χ i, φ⟩ • χ i` for the inner product `New.classInner`, then
`⟨φ, f⟩ = ∑ i, conj ⟨χ i, φ⟩ * ⟨χ i, f⟩`. -/
lemma classInner_eq_sum_of_eq_sum {ι : Type*} [Fintype ι] {χ : ι → G → ℂ} {φ : G → ℂ}
    (hφ : φ = ∑ i : ι, classInner (χ i) φ • χ i) (f : G → ℂ) :
    classInner φ f = ∑ i : ι, conj (classInner (χ i) φ) * classInner (χ i) f := by
  conv_lhs => rw [hφ, classInner]
  simp [sum_mul, finMean_sum, mul_assoc, finMean_const_mul, ← classInner.eq_1]

/-- Suppose `f = ∑ j, ⟨χ j, f⟩ • χ j` has norm `⟨f, f⟩ = 1` and `0 ≤ re (f 1)`. If the coefficient
`⟨χ i, f⟩` is a nonzero integer and `0 < re (χ i 1)`, then `f = χ i`. -/
lemma eq_of_eq_sum_of_classInner_eq_intCast {ι : Type*} [Fintype ι] {χ : ι → G → ℂ} {i : ι}
    {m : ℤ} (hf : f = ∑ j : ι, classInner (χ j) f • χ j) (h_norm : classInner f f = 1)
    (hf_one : 0 ≤ (f 1).re) (hχ_one : 0 < (χ i 1).re) (hm : classInner (χ i) f = m)
    (hm_ne : m ≠ 0) : f = χ i := by
  -- The squared norms of the coefficients add up to `1`, so all others vanish and `m = ±1`.
  have hm_sq : (1 : ℝ) ≤ ‖classInner (χ i) f‖ ^ 2 := by
    simpa [hm] using mod_cast Int.one_le_abs hm_ne
  have h_sum : ∑ j : ι, ‖classInner (χ j) f‖ ^ 2 = 1 := by
    apply Complex.ofReal_injective
    simpa [classInner_eq_sum_of_eq_sum hf f, Complex.conj_mul'] using h_norm
  have h_other (j : ι) (hj : j ≠ i) : classInner (χ j) f = 0 := by
    by_contra h_ne
    have h_lt : ‖classInner (χ i) f‖ ^ 2 < ∑ k : ι, ‖classInner (χ k) f‖ ^ 2 :=
      single_lt_sum (f := fun k ↦ ‖classInner (χ k) f‖ ^ 2) hj (mem_univ i) (mem_univ j)
        (by positivity) (by simp)
    linarith
  have hf_eq : f = (m : ℂ) • χ i := by
    simpa +contextual [sum_eq_single i, h_other, hm] using hf
  obtain rfl | hm_neg : m = 1 ∨ (m : ℝ) = -1 := by
    simpa +contextual [sum_eq_single i, h_other, hm] using h_sum
  · simpa using hf_eq
  · have h_re : (f 1).re = -(χ i 1).re := by simp [hf_eq, hm_neg]
    linarith

/-- An irreducible character has norm `1` (Mathlib's `FDRep.char_orthonormal`). -/
lemma IsIrreducibleChar.classInner_self (hχ : IsIrreducibleChar χ) : classInner χ χ = 1 := by
  obtain ⟨V, hV, rfl⟩ := hχ
  have h := FDRep.char_orthonormal V V
  simp only [Nonempty.intro (CategoryTheory.Iso.refl V), ite_true] at h
  rw [← h, classInner, finMean_eq, Nat.card_eq_fintype_card, div_eq_inv_mul]
  exact congrArg _ (Finset.sum_congr rfl fun g _ ↦ by rw [← V.conj_char, mul_comm])

/-- A class function `φ` acts by a scalar in an irreducible representation; on characters this
reads `χ 1 * mean (conj χ · φ (· * y)) = ⟨χ, φ⟩ * χ y`. -/
lemma IsIrreducibleChar.mul_classInner_translate (hχ : IsIrreducibleChar χ) {φ : G → ℂ}
    (hφ : IsClassFunction φ) (y : G) :
    χ 1 * finMean (fun t ↦ conj (χ t) * φ (t * y)) = classInner χ φ * χ y := by
  classical
  obtain ⟨V, hV, rfl⟩ := hχ
  have := FDRep.isIrreducible_of_simple V
  have hφ_inv : IsClassFunction (fun t : G ↦ φ t⁻¹) := fun g x ↦ by
    simpa [mul_assoc] using hφ g⁻¹ x
  let z : Subalgebra.center ℂ ℂ[G] :=
    ⟨groupAlgElem fun t ↦ φ t⁻¹, Subalgebra.mem_center_iff.2 hφ_inv.commute⟩
  have h_translate (y : G) : ∑ x : G, conj (V.character x) * φ (x * y) =
      TauCeti.Representation.centralCharacter V.ρ z * V.character y := by
    calc ∑ x : G, conj (V.character x) * φ (x * y)
        = LinearMap.trace ℂ _ (asAlgebraHom V.ρ (z.val * single y 1)) := by
          rw [asAlgebraHom_eq_sum, map_sum]
          refine Fintype.sum_equiv (Equiv.inv G) _ _ fun x ↦ ?_
          have h_swap : φ (y * x) = φ (x * y) := hφ.apply_mul_comm y x
          rw [V.conj_char]
          simp [z, h_swap, FDRep.character, mul_comm]
      _ = TauCeti.Representation.centralCharacter V.ρ z * V.character y := by
          rw [map_mul, TauCeti.Representation.asAlgebraHom_center]
          simp [FDRep.character, Module.End.mul_eq_comp]
  have h_one := h_translate 1
  simp only [mul_one] at h_one
  rw [classInner, finMean_eq, finMean_eq, h_translate y, h_one]
  ring

/-- A finite family `χ i` of irreducible characters of a finite group `G` in which every class
function expands. The brackets `⟨ , ⟩` denote the inner product `New.classInner`. -/
structure IsExpansionFamily {ι : Type*} [Fintype ι] (χ : ι → G → ℂ) : Prop where
  /-- Each `χ i` is an irreducible character. -/
  isIrreducibleChar (i : ι) : IsIrreducibleChar (χ i)
  /-- A class function `φ` is the sum of the `⟨χ i, φ⟩ • χ i`. -/
  eq_sum {φ : G → ℂ} (hφ : IsClassFunction φ) : φ = ∑ i : ι, classInner (χ i) φ • χ i

variable (G) in
/-- A finite group has a finite family of characters in which every class function expands. -/
lemma exists_isExpansionFamily : ∃ (n : ℕ) (χ : Fin n → G → ℂ), IsExpansionFamily χ := by
  classical
  obtain ⟨d, ρ, hirr, hind, -⟩ := TauCeti.exists_irreducible_family_conjClasses ℂ G
  have := hirr
  let e : ConjClasses G ≃ Fin (Fintype.card (ConjClasses G)) := Fintype.equivFin (ConjClasses G)
  let χ : Fin (Fintype.card (ConjClasses G)) → G → ℂ := fun i ↦ (ρ (e.symm i)).character
  refine ⟨Fintype.card (ConjClasses G), χ,
    fun i ↦ ⟨.of (ρ (e.symm i)), (FDRep.simple_iff_isIrreducible _).2 (hirr _), rfl⟩,
    fun {φ} hφ ↦ funext fun g ↦ ?_⟩
  let Φ : TauCeti.ClassFunction ℂ G := ⟨φ, TauCeti.ClassFunction.mem_iff.2 hφ⟩
  have h_pair (i : Fin (Fintype.card (ConjClasses G))) :
      TauCeti.ClassFunction.characterPairing
          (TauCeti.ClassFunction.ofCharacter (ρ (e.symm i))) Φ =
        classInner (χ i) φ := by
    rw [TauCeti.ClassFunction.characterPairing_apply, classInner, finMean,
      finsum_eq_sum_of_fintype, div_eq_inv_mul]
    congr 1
    refine Fintype.sum_equiv (Equiv.inv G) _ _ fun x ↦ ?_
    simp [Φ, χ]
  have hexp := TauCeti.ClassFunction.apply_eq_sum_characterPairing_mul_character ρ hind rfl Φ g
  have hsum : ∑ i, classInner (χ i) φ * χ i g =
      ∑ C, TauCeti.ClassFunction.characterPairing (TauCeti.ClassFunction.ofCharacter (ρ C)) Φ *
        (ρ C).character g :=
    Fintype.sum_equiv e.symm _ _ fun i ↦ by simp [h_pair i, χ]
  simpa [Φ, Finset.sum_apply] using hexp.trans hsum.symm

/-- Let `f` and `I` be class functions on a finite group `G` with `⟨I, f⟩ ≠ 0`, `⟨f, f⟩ = 1` and
`0 ≤ re (f 1)`, where `⟨ , ⟩` is the inner product `New.classInner`. Suppose `⟨χ, f⟩` is an integer
for every character `χ` with `⟨χ, I⟩ ≠ 0` and `χ 1 * ⟨χ, I (· * y)⟩ = ⟨χ, I⟩ * χ y` for all `y`.
Then `f` is an irreducible character. -/
lemma IsClassFunction.isIrreducibleChar_of_classInner_eq_intCast {I : G → ℂ}
    (hf : IsClassFunction f) (hI : IsClassFunction I) (h_inner_ne : classInner I f ≠ 0)
    (h_norm : classInner f f = 1) (h_re : 0 ≤ (f 1).re)
    (h_int : ∀ χ : G → ℂ, IsChar χ → classInner χ I ≠ 0 →
      (∀ y : G, χ 1 * classInner χ (fun x : G ↦ I (x * y)) = classInner χ I * χ y) →
      ∃ m : ℤ, classInner χ f = m) :
    IsIrreducibleChar f := by
  -- Expand in irreducible characters `χ i`. Some `χ i` is orthogonal to neither `I` nor `f`; its
  -- coefficient in `f` is a nonzero integer `m`, which forces `f = χ i`.
  obtain ⟨n, χ, hχ⟩ := exists_isExpansionFamily G
  rw [classInner_eq_sum_of_eq_sum (hχ.eq_sum hI)] at h_inner_ne
  obtain ⟨i, -, hi⟩ := exists_ne_zero_of_sum_ne_zero h_inner_ne
  obtain ⟨hI_ne, hf_ne⟩ : classInner (χ i) I ≠ 0 ∧ classInner (χ i) f ≠ 0 := by simpa using hi
  have hχ_irr := hχ.isIrreducibleChar i
  obtain ⟨m, hm⟩ := h_int (χ i) hχ_irr.isChar hI_ne (hχ_irr.mul_classInner_translate hI)
  obtain rfl : f = χ i := eq_of_eq_sum_of_classInner_eq_intCast (hχ.eq_sum hf) h_norm h_re
    hχ_irr.re_apply_one_pos hm (by simpa [hm] using hf_ne)
  exact hχ_irr

variable {Z} in
/-- Let `f` be a class function on a finite group `G`. If the inner product of every character with
`f` comes from the semiring `Z`, then `f` is a `Z`-combination of characters. -/
lemma IsClassFunction.mem_virtualChars (hf : IsClassFunction f)
    (h_coeff : ∀ χ : G → ℂ, IsChar χ → ∃ m : Z, classInner χ f = algebraMap Z ℂ m) :
    f ∈ virtualChars Z G := by
  -- Every coefficient of the expansion of `f` in characters comes from `Z`.
  obtain ⟨n, χ, hχ⟩ := exists_isExpansionFamily G
  rw [hχ.eq_sum hf]
  refine sum_mem fun i _ ↦ ?_
  have hχ_char := (hχ.isIrreducibleChar i).isChar
  obtain ⟨m, hm⟩ := h_coeff (χ i) hχ_char
  simpa [hm] using Subalgebra.smul_mem _ hχ_char.mem_virtualChars m

/-- Let `f` be a class function on a finite group `G`. Suppose `a ∈ ℂ[G]` acts as zero in every
finite-dimensional representation in which `New.groupAlgElem f = ∑ g, f g • g` acts as zero. Then
`a = u * New.groupAlgElem f * a` for some `u ∈ ℂ[G]`. -/
lemma IsClassFunction.exists_eq_mul_groupAlgElem_mul (hf : IsClassFunction f) (a : ℂ[G])
    (ha : ∀ V : FDRep ℂ G, asAlgebraHom V.ρ (groupAlgElem f) = 0 → asAlgebraHom V.ρ a = 0) :
    ∃ u : ℂ[G], a = u * groupAlgElem f * a := by
  -- Wedderburn: `e` identifies `ℂ[G]` with a product of matrix algebras, and the `i`-th block of
  -- `groupAlgElem f` is a scalar `c i`. Take for `u` the blockwise scalar `(c i)⁻¹`.
  obtain ⟨n, d, hd, ⟨e⟩⟩ := IsSemisimpleRing.exists_algEquiv_pi_matrix_of_isAlgClosed ℂ ℂ[G]
  have := hd
  have (i : Fin n) := TauCeti.isIrreducible_blockRepresentation e i
  let z : Subalgebra.center ℂ ℂ[G] := ⟨groupAlgElem f, Subalgebra.mem_center_iff.2 hf.commute⟩
  let c : Fin n → ℂ := fun i ↦
    TauCeti.Representation.centralCharacter (TauCeti.blockRepresentation e i) z
  have hc (i : Fin n) : e (groupAlgElem f) i = algebraMap ℂ _ (c i) := by
    have h := TauCeti.Representation.asAlgebraHom_center (TauCeti.blockRepresentation e i) z
    simpa [z, c, TauCeti.asAlgebraHom_blockRepresentation, TauCeti.blockAlgHom_apply,
      algebraMap_eq_smul_one] using congrArg Matrix.toLinAlgEquiv'.symm h
  refine ⟨e.symm (c⁻¹ • 1), e.injective (funext fun i ↦ ?_)⟩
  by_cases hi : c i = 0
  · -- `groupAlgElem f` acts as zero on the `i`-th block, so `a` does too
    have ha_zero : e a i = 0 := by
      have h := ha (.of (TauCeti.blockRepresentation e i)) (by
        simp [TauCeti.asAlgebraHom_blockRepresentation, TauCeti.blockAlgHom_apply, hc, hi])
      simpa [TauCeti.asAlgebraHom_blockRepresentation, TauCeti.blockAlgHom_apply] using
        congrArg Matrix.toLinAlgEquiv'.symm h
    simp [ha_zero]
  · simp [hc, hi, algebraMap_eq_smul_one]

/-- The trace of the group algebra element with coefficients `conj (χ g)`, divided by the order
of the group, is the inner product of `χ` with the character of the representation. -/
lemma trace_asAlgebraHom_groupAlgElem_conj (χ : G → ℂ) :
    trace ℂ V (ρ.asAlgebraHom (groupAlgElem (conj ∘ χ))) / Nat.card G =
      classInner χ ρ.character := by
  simp [asAlgebraHom_eq_sum, classInner, finMean, finsum_eq_sum_of_fintype, character]

variable [Module.Finite ℂ V]

/-- Let `i : G →* H` be a group homomorphism with `G` finite, `χ` a character of `H` and `s ∈ H`.
If the product of `χ ∘ i` with the character of a finite-dimensional representation `ρ` of `G` has
average zero, then `∑ g, χ (i g * s) • g` acts as zero in `ρ`. -/
lemma IsChar.asAlgebraHom_groupAlgElem_eq_zero {χ : H → ℂ} (hχ : IsChar χ) (i : G →* H) (s : H)
    (h_mean : finMean (χ ∘ i * ρ.character) = 0) :
    ρ.asAlgebraHom (groupAlgElem fun x : G ↦ χ (i x * s)) = 0 := by
  -- Let `τ` have character `χ`. The averaging projection of `(τ ∘ i) ⊗ ρ` has trace `0` by
  -- `h_mean`, so it vanishes.
  obtain ⟨τ, rfl⟩ := hχ
  have h_trace : trace ℂ (TensorProduct ℂ τ V) (tprod (τ.ρ.comp i) ρ).averageMap = 0 := by
    simpa [GroupAlgebra.average, trace_tensorProduct', FDRep.character, character, finMean,
      finsum_eq_sum_of_fintype, -asAlgebraHom_sum_single_one] using h_mean
  have h_avg : (tprod (τ.ρ.comp i) ρ).averageMap = 0 :=
    (isProj_averageMap _).isIdempotentElem.eq_zero_of_trace_eq_zero h_trace
  -- Read this in `End τ ⊗ End V`, then apply `T : A ⊗ B ↦ trace (A * τ s) • B`.
  have h_tensor : ∑ u : G, τ.ρ (i u) ⊗ₜ[ℂ] ρ u = 0 := by
    apply (homTensorHomEquiv ℂ τ V τ V).injective
    simpa [GroupAlgebra.average, -asAlgebraHom_sum_single_one] using h_avg
  let T : TensorProduct ℂ (τ →ₗ[ℂ] τ) (V →ₗ[ℂ] V) →ₗ[ℂ] V →ₗ[ℂ] V :=
    TensorProduct.lift (lsmul ℂ (V →ₗ[ℂ] V) ∘ₗ trace ℂ τ ∘ₗ mulRight ℂ (τ.ρ s))
  calc ρ.asAlgebraHom (groupAlgElem fun x : G ↦ τ.character (i x * s))
      = T (∑ u : G, τ.ρ (i u) ⊗ₜ[ℂ] ρ u) := by simp [T, FDRep.character, asAlgebraHom_eq_sum]
    _ = 0 := by rw [h_tensor, map_zero]

/-- For a character `χ` and finite-dimensional `ρ`, the element `∑ g, conj (χ g) • g` acts as zero
in `ρ` iff `χ` is orthogonal to the character of `ρ` for the inner product `New.classInner`. -/
lemma IsChar.asAlgebraHom_groupAlgElem_eq_zero_iff (h : IsChar χ) :
    ρ.asAlgebraHom (groupAlgElem (conj ∘ χ)) = 0 ↔ classInner χ ρ.character = 0 := by
  refine ⟨fun h_zero ↦ ?_, fun h_zero ↦ ?_⟩
  · rw [← trace_asAlgebraHom_groupAlgElem_conj χ, h_zero, map_zero, zero_div]
  · -- `IsChar.asAlgebraHom_groupAlgElem_eq_zero` for the character `conj χ`, with `i` the identity
    -- and `s = 1`
    simpa [asAlgebraHom_eq_sum] using h.star.asAlgebraHom_groupAlgElem_eq_zero (i := .id G) (s := 1)
      h_zero

end IrreducibleCharacters

end New

/-! ## Integrality of central projections -/

section ProjectionCharacter

open MonoidAlgebra LinearMap Representation Finset

attribute [local instance low] Fintype.ofFinite

variable {G : Type*} [Group G] [Finite G] {e : ℂ[G]}

/-- If `e` is a central idempotent of the complex group algebra of a finite group `G`, then
`g ↦ |G| · e(g)`, with `e(g)` the coefficient of `g`, is the character of a finite-dimensional
representation of `G`. -/
lemma New.IsCentralProj.isChar_card_mul_coeff (h : IsCentralProj e) :
    IsChar fun g : G ↦ Nat.card G * e.coeff g := by
  -- The pairing of |G|·e with a character χ is the trace of e on a representation with character
  -- conj χ. As e acts there by an idempotent, this trace is a natural number, the rank.
  -- A class function whose pairing with every character is in `ℕ` is an `ℕ`-combination of
  -- characters, hence a character.
  refine isChar_of_mem_virtualChars <|
    IsClassFunction.mem_virtualChars (by simp [h.isClassFunction _ _]) fun χ hχ ↦ ?_
  obtain ⟨ρ, hρ⟩ := hχ.star
  refine ⟨_, by simpa [classInner, finMean, finsum_eq_sum_of_fintype, ← congrFun hρ,
    asAlgebraHom_eq_sum, FDRep.character, sum_div, mul_rotate', eq_natCast] using
    (h.isIdempotentElem.map (asAlgebraHom ρ.ρ)).isProj_range.trace⟩

/-- If `e` is a central idempotent of the complex group algebra of a finite group `G`, then
`g ↦ |G| · e(g)`, with `e(g)` the coefficient of `g`, is the character of a representation of `G` of
dimension at most `|G|`. -/
lemma New.IsCentralProj.exists_character_eq_and_finrank_le_card (h : IsCentralProj e) :
    ∃ V : FDRep ℂ G,
      V.character = (fun g : G ↦ Nat.card G * e.coeff g) ∧
      Module.finrank ℂ V ≤ Nat.card G := by
  -- As `1 - e` is again a central idempotent, it gives a second representation. The two
  -- dimensions, the values of the characters at the identity, add up to `|G|`.
  obtain ⟨V, hV⟩ : IsChar fun g : G ↦ Nat.card G * e.coeff g := h.isChar_card_mul_coeff
  obtain ⟨W, hW⟩ : IsChar fun g : G ↦ Nat.card G * (1 - e).coeff g :=
    h.one_sub.isChar_card_mul_coeff
  have h_sum : (Module.finrank ℂ V + Module.finrank ℂ W : ℂ) = Nat.card G :=
    calc
      _ = V.character 1 + W.character 1 := by rw [FDRep.char_one, FDRep.char_one]
      _ = Nat.card G * (e.coeff 1 + (1 - e).coeff 1) := by rw [hV, hW, mul_add]
      _ = Nat.card G := by simp
  exact ⟨V, hV, Nat.le.intro (mod_cast h_sum)⟩

/-- The coefficients of a central idempotent of `ℂ[G]` have norm at most `1`. -/
lemma New.IsCentralProj.norm_coeff_le_one (h : IsCentralProj e) (g : G) : ‖e.coeff g‖ ≤ 1 := by
  obtain ⟨V, hV, h_dim⟩ := h.exists_character_eq_and_finrank_le_card
  refine le_of_mul_le_mul_left (a := (Nat.card G : ℝ)) ?_ (Nat.cast_pos.2 Nat.card_pos)
  calc (Nat.card G : ℝ) * ‖e.coeff g‖ = ‖V.character g‖ := by simp [hV]
    _ ≤ ‖V.character 1‖ := IsChar.norm_apply_le ⟨V, rfl⟩ g
    _ ≤ Nat.card G * 1 := by simpa [FDRep.char_one] using h_dim

end ProjectionCharacter

/-! ## Central projections as orthogonal projections -/

section CentralConvolution

open LinearMap LinearIsometryEquiv
open scoped InnerProductSpace

namespace New.IsCentralProj

variable {G : Type*} [Group G] [Fintype G] {e : MonoidAlgebra ℂ G}

/-- Let `ρ` be a representation of a finite group `G` on a complex vector space `V` and `σ` a field
automorphism of `ℂ`. Let `B` be a `G`-invariant form on `V`, linear in the second argument and
semilinear for `σ⁻¹ ∘ conj ∘ σ` in the first. Then a central idempotent `e` of `ℂ[G]` is
self-adjoint for `B`: `B (e x) y = B x (e y)`. -/
lemma self_adjoint {V : Type*} [AddCommGroup V] [Module ℂ V] (ρ : Representation ℂ G V)
    (he : IsCentralProj e) (σ : ℂ ≃+* ℂ)
    (B : V →ₛₗ[(↑σ⁻¹ : ℂ →+* ℂ).comp ((starRingEnd ℂ).comp (σ : ℂ →+* ℂ))] V →ₗ[ℂ] ℂ)
    (hB : ∀ (s : G) (x y : V), B (ρ s x) (ρ s y) = B x y) (x y : V) :
    B (ρ.asAlgebraHom e x) y = B x (ρ.asAlgebraHom e y) := by
  -- The coefficients of `σ e` are a character divided by `|G|`, so inversion conjugates them.
  -- Expand both sides over `G` and match the term of `s` with the term of `s⁻¹`.
  have h_coeff (s : G) : σ (e.coeff s⁻¹) = starRingEnd ℂ (σ (e.coeff s)) := by
    simpa using (he.map σ).isChar_card_mul_coeff.apply_inv s
  have h_adj (s : G) : B (ρ s x) y = B x (ρ s⁻¹ y) := by simp [← hB s x]
  have h_term (s : G) : B ((e.coeff s • ρ s) x) y = B x ((e.coeff s⁻¹ • ρ s⁻¹) y) := by
    simp [h_adj, ← h_coeff]
  simp only [Representation.asAlgebraHom_eq_sum, LinearMap.sum_apply, map_sum]
  exact Fintype.sum_equiv (.inv G) _ _ h_term

/-- In a unitary representation, a central idempotent of the complex group algebra acts as an
orthogonal projection. -/
lemma isSymmetricProjection {H : Type*} [Group H] [Fintype H]
    {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℂ V]
    {ρ : Representation ℂ H V} (hρ : ∀ (s : H) (x y : V), ⟪ρ s x, ρ s y⟫_ℂ = ⟪x, y⟫_ℂ)
    {z : MonoidAlgebra ℂ H} (hz : IsCentralProj z) :
    (ρ.asAlgebraHom z).IsSymmetricProjection :=
  ρ.isSymmetricProjection_asAlgebraHom hρ (fun s ↦ by
    simpa using hz.isChar_card_mul_coeff.apply_inv s) hz.isIdempotentElem

/-- Convolution with a central idempotent e of ℂ[G], along a homomorphism φ : G → H of finite
groups, is a contraction of ℓ²(H, V): ∑_s ‖∑_t e(t) f(φ(t)⁻¹ s)‖² ≤ ∑_s ‖f(s)‖². -/
lemma sum_norm_sq_conv_le {V : Type*} [NormedAddCommGroup V] [InnerProductSpace ℂ V]
    (he : IsCentralProj e) {H : Type*} [Group H] [Fintype H] (φ : G →* H) (f : H → V) :
    ∑ s : H, ‖∑ t : G, e.coeff t • f ((φ t)⁻¹ * s)‖ ^ 2 ≤ ∑ s : H, ‖f s‖ ^ 2 := by
  -- `G` acts on `ℓ²(H, V)` by left translation through `φ`, unitarily; so `e` acts as an orthogonal
  -- projection, which does not increase the norm.
  let L (t : G) : PiLp 2 (fun _ : H ↦ V) ≃ₗᵢ[ℂ] PiLp 2 fun _ : H ↦ V :=
    piLpCongrLeft 2 ℂ V (.mulLeft (φ t))
  let ρ : Representation ℂ G (PiLp 2 fun _ : H ↦ V) :=
    { toFun t := (L t).toLinearEquiv.toLinearMap
      map_one' := by
        ext f s
        change f ((φ 1)⁻¹ * s) = f s
        simp
      map_mul' t u := by
        ext f s
        change f ((φ (t * u))⁻¹ * s) = f ((φ u)⁻¹ * ((φ t)⁻¹ * s))
        simp [mul_assoc] }
  obtain ⟨K, _, hK : ρ.asAlgebraHom e = K.starProjection⟩ :=
    isSymmetricProjection_iff_eq_coe_starProjection.1
      (he.isSymmetricProjection (ρ := ρ) fun t ↦ (L t).inner_map_map)
  have h_norm : ‖ρ.asAlgebraHom e (.toLp 2 f)‖ ≤ ‖WithLp.toLp 2 f‖ := by
    simpa [hK] using K.norm_starProjection_apply_le _
  -- write both norms in coordinates and square
  simpa (disch := positivity) [ρ, L, PiLp.norm_eq_of_L2, Representation.asAlgebraHom_eq_sum]
    using h_norm

end New.IsCentralProj

end CentralConvolution

end