Skip to content

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

Python
20.8 KB
Raw Blame
module

import Mathlib.Data.Finset.Slice
import TauCeti.Algebra.Lie.GeneralLinear.Oscillator.Casimir
public import Lib.DiscreteSeries.Theta.FockDualPair

/-!
# The Casimir elements of an oscillator pair

An oscillator pair is given by a `FockDualPair` `T` with `n = card R` rows and `n' = card C`
columns; the first group acts on the rows. This file proves that, with the centres (the weights of
the twisting characters) removed, the Casimir elements of the two groups differ by the constant
`n n' (n - n') / 4`, and that for matching parameters the numbers `|u|² - |ρ|²` and `|u'|² - |ρ'|²`
differ by the same constant, where `u`, `u'` are the centred parameters, that is, the entries
shifted by the centres. By `HCParam.HasGap.casimirValue_sub_center` these numbers are the centred
Casimir values.

The notions that the statements use:
* a parameter `l : HCParam ε` is an integer vector that stands for `l = 2λ`; `l.HasGap h` says that
  its entries are distinct, of the parity of `n - 1`, and at least `2h` apart where the signs `ε`
  differ;
* for symmetric `r`, `twoRho l r` is the sum of the roots selected by `r` that are positive for `l`,
  so `twoRho l ⊤` is `2ρ`, and `l.casimirValue` is `|λ|² - |ρ|²`;
* `T.oscRows` is the oscillator action of `gl R` on polynomials, and `T.swap` is the same pair with
  rows and columns exchanged;
* `T.centeredParam l r` is `2u_r = l r - 2γ + n'` with `γ = T.rowShift` the scalar on the diagonal
  of the row action (`T.columnShift` is that of the column action `T.swap.oscRows`), and
  `IsMatch T l l'` says that `l` and `l'` have gap `500 (n + n')³`, that each row is matched with a
  column or has `|2u_r| < n - n'`, and that each column is matched with a row or has
  `|2u'_c| < n' - n`; the row `r` and the column `c` are matched if `u_r = -u'_c` and
  `T.globalSign * ε r * ε' c * 2u_r > |n - n'|`.

## Relation to the literature

Known result: the constant difference of the centred Casimir elements of the two groups of an
oscillator pair, a case of the correspondence of infinitesimal characters. Source: compare A. Paul,
First occurrence for the dual pairs (U(p,q), U(r,s)), Canad. J. Math. 51 (1999), Theorem 2.11.

See also `Lib.DiscreteSeries.Theta.LocalCorrespondence`.
-/

@[expose] public section

namespace New

open Finset Fock
open Fintype (card)

section SumsOfSquares

/-- A set of `d` distinct integers of the parity of `d - 1` and of modulus below `d` is
`{1 - d, 3 - d, …, d - 1}`, so the sum of their squares is `d (d² - 1) / 3`. -/
theorem three_mul_sum_sq_of_injOn {α : Type*} (s : Finset α) (f : α → ℤ) (h_inj : Set.InjOn f s)
    (h_parity : ∀ i ∈ s, Even (f i + #s - 1)) (h_bound : ∀ i ∈ s, |f i| < #s) :
    3 * ∑ i ∈ s, f i ^ 2 = #s * (#s ^ 2 - 1) := by
  let g (k : Fin #s) : ℤ := (#s - 1) - 2 * k
  have hg_inj : Function.Injective g := fun j k hjk ↦ Fin.ext (by lia)
  have h_subset : s.image f ⊆ univ.image g := by
    intro z hz
    obtain ⟨i, hi, rfl⟩ := mem_image.1 hz
    obtain ⟨k, hk⟩ := h_parity i hi
    have hi_bound := abs_lt.1 (h_bound i hi)
    exact mem_image.2 ⟨⟨(#s - 1 - k).toNat, by lia⟩, mem_univ _, by grind⟩
  have h_image : s.image f = univ.image g := eq_of_subset_of_card_le h_subset <| by
    simp [card_image_of_injective _ hg_inj, card_image_of_injOn h_inj]
  have h_sq (k : Fin #s) : (g k : ℚ) ^ 2 = 4 * (((#s : ℚ) - 1) / 2 - k) ^ 2 := by
    push_cast [g]; ring
  calc 3 * ∑ i ∈ s, f i ^ 2 = 3 * ∑ z ∈ s.image f, z ^ 2 := by rw [sum_image h_inj]
    _ = 3 * ∑ k : Fin #s, g k ^ 2 := by rw [h_image, sum_image hg_inj.injOn]
    _ = #s * (#s ^ 2 - 1) := by qify; simp only [h_sq, ← mul_sum, TauCeti.sum_rho_sq]; ring

variable {n : Type} [Fintype n]

/-- For a vector `l` with distinct entries, `twoRho l ⊤ = 2ρ` is the sum of the roots positive for
`l`. The squares of its entries sum to `N (N² - 1) / 3` with `N = card n`, that is,
`|ρ|² = N (N² - 1) / 12`. -/
theorem three_mul_sum_twoRho_sq {l : n → ℤ} (hl : l.Injective) :
    3 * ∑ i : n, twoRho l ⊤ i ^ 2 = card n * (card n ^ 2 - 1) := by
  classical
  have h_count (i : n) : (#{j | l j < l i} + #{j | l i < l j} + 1 : ℤ) = card n :=
    mod_cast card_lt_add_card_gt_add_one hl i
  have h_value (i : n) : twoRho l ⊤ i = #{j | l j < l i} - #{j | l i < l j} := by
    simp [twoRho]
  have h_inj : Function.Injective (twoRho l ⊤) := by
    intro a b hab
    obtain h | h | h := lt_trichotomy (l a) (l b)
    exacts [absurd hab (twoRho_lt_twoRho h).ne, hl h, absurd hab (twoRho_lt_twoRho h).ne']
  have h_parity (i : n) : Even (twoRho l ⊤ i + card n - 1) :=
    ⟨#{j | l j < l i}, by linear_combination h_value i - h_count i⟩
  have h_bound (i : n) : |twoRho l ⊤ i| < card n := by grind
  exact three_mul_sum_sq_of_injOn univ _ h_inj.injOn (fun i _ ↦ h_parity i) fun i _ ↦ h_bound i

/-- For a symmetric relation `r`, the entries of `twoRho l r` sum to zero. -/
theorem sum_twoRho_eq_zero (l : n → ℤ) (r : n → n → Prop) [DecidableRel r]
    (hr : ∀ i j : n, r i j → r j i) : ∑ i : n, twoRho l r i = 0 := by
  -- Both counts run over the pairs with `r`, ordered by `l`.
  simp only [twoRho, sum_sub_distrib, card_filter, Nat.cast_sum, sub_eq_zero]
  rw [sum_comm]
  refine sum_congr rfl fun i _ ↦ sum_congr rfl fun j _ ↦ ?_
  simp only [Iff.intro (hr j i) (hr i j)]

/-- For a parameter `l = 2λ` with a gap (distinct entries of the parity of `n - 1`, those of
different signs `ε` far apart), the lowest K-type and `λ` have the same sum of entries. -/
theorem HCParam.HasGap.two_mul_sum_lowestKType {ε : n → ℤˣ} {l : HCParam ε} {h : ℕ}
    (hg : l.HasGap h) : 2 * ∑ i : n, l.lowestKType i = ∑ i : n, l i := by
  have h_noncompact : ∑ i, twoRho l (fun i j ↦ ε i ≠ ε j) i = 0 :=
    sum_twoRho_eq_zero l _ fun i j ↦ Ne.symm
  have h_compact : ∑ i, twoRho l (fun i j ↦ ε i = ε j) i = 0 :=
    sum_twoRho_eq_zero l _ fun i j ↦ Eq.symm
  simp [mul_sum, two_mul_lowestKType hg, sum_sub_distrib, sum_add_distrib, h_noncompact, h_compact]

/-- Let `l = 2λ` be a parameter with a gap (distinct entries of the parity of `n - 1`, those of
different signs far apart), with Casimir value `κ = |λ|² - |ρ|²` and lowest K-type `μ`. For any
scalar `w`, the value with the centre `w` removed, `κ - 2w ∑ μ_a + n w²`, is
`∑ (λ_a - w)² - n (n² - 1) / 12`, where `n` is the number of entries. -/
theorem HCParam.HasGap.casimirValue_sub_center {ε : n → ℤˣ} {l : HCParam ε} {h : ℕ}
    (hg : l.HasGap h) (w : ℂ) :
    l.casimirValue - 2 * w * ∑ a : n, (l.lowestKType a : ℂ) + card n * w ^ 2 =
      ∑ a : n, (l a / 2 - w) ^ 2 - (card n * (card n ^ 2 - 1) / 12 : ℂ) := by
  have h_rho : 3 * ∑ a, (twoRho l ⊤ a : ℂ) ^ 2 = card n * (card n ^ 2 - 1) :=
    mod_cast three_mul_sum_twoRho_sq hg.injective
  have h_sum : 2 * ∑ a, (l.lowestKType a : ℂ) = ∑ a, (l a : ℂ) :=
    mod_cast hg.two_mul_sum_lowestKType
  have h_value : (l.casimirValue : ℂ) =
      (∑ a, (l a : ℂ) ^ 2 - ∑ a, (twoRho l ⊤ a : ℂ) ^ 2) / 4 := by
    simp [casimirValue, ← sum_div, sum_sub_distrib]
  have h_term (a : n) : (l a / 2 - w : ℂ) ^ 2 = (l a : ℂ) ^ 2 / 4 - w * l a + w ^ 2 := by ring
  have h_square : ∑ a, (l a / 2 - w : ℂ) ^ 2 =
      (∑ a, (l a : ℂ) ^ 2) / 4 - w * ∑ a, (l a : ℂ) + card n * w ^ 2 := by
    simp [h_term, sum_add_distrib, ← sum_div, ← mul_sum]
  rw [h_value, h_square]
  linear_combination -w * h_sum - h_rho / 12

end SumsOfSquares

section Casimir

variable {R C ι : Type} [Fintype R] [DecidableEq R] [Fintype C] {ε : R → ℤˣ} {ε' : C → ℤˣ}

omit [Fintype R] [DecidableEq R] in
/-- The centred parameters `l r - 2γ + card C` of a vector `l` with distinct entries are
distinct. -/
theorem FockDualPair.centeredParam_injective (T : FockDualPair ε ε' ι) {l : HCParam ε}
    (hl : Function.Injective l) : Function.Injective (T.centeredParam l) :=
  fun a b hab ↦ hl (by simpa [FockDualPair.centeredParam] using hab)

/-- Let `l`, `l'` be matching parameters of the pair `T`: they have a large gap, and each row and
column is matched, with opposite centred parameters, or has a small one. Let `n' ≤ n` for
`n = card R` and `n' = card C`. The squares of the centred parameters `l r - 2 T.rowShift + n'` of
the rows and `l' c - 2 T.columnShift + n` of the columns (the rows of `T.swap`) differ in sum by
`d₀ (d₀² - 1) / 3` with `d₀ = n - n'`, the share of the unmatched rows. -/
theorem IsMatch.three_mul_sum_sq_sub_of_le {T : FockDualPair ε ε' ι} {l : HCParam ε}
    {l' : HCParam ε'} (hm : IsMatch T l l') (h_le : card C ≤ card R) :
    3 * (∑ r : R, T.centeredParam l r ^ 2 - ∑ c : C, T.swap.centeredParam l' c ^ 2) =
      (card R - card C) * ((card R - card C) ^ 2 - 1) := by
  -- Every index of the smaller group is matched, with one row `m c`.
  have h_matched (c : C) : ∃ r : R, T.centeredParam l r = -T.swap.centeredParam l' c := by
    obtain ⟨r, h_eq, -⟩ | h_lt := hm.right c
    · exact ⟨r, h_eq⟩
    · grind [abs_nonneg]
  choose m h_opposite using h_matched
  have h_row_inj : Function.Injective (T.centeredParam l) :=
    T.centeredParam_injective hm.hasGap_row.injective
  have hm_inj : Function.Injective m := by
    refine fun c c' hc ↦
        T.swap.centeredParam_injective hm.hasGap_column.injective (neg_injective ?_)
    rw [← h_opposite c, ← h_opposite c', hc]
  -- So the larger group has `n - n'` unmatched entries.
  set free : Finset R := (univ.image m)ᶜ with h_free
  have h_card : (#free : ℤ) = card R - card C := by
    simp [h_free, card_compl, card_image_of_injective _ hm_inj, h_le]
  have h_split : ∑ r, T.centeredParam l r ^ 2 =
      ∑ c, T.swap.centeredParam l' c ^ 2 + ∑ r ∈ free, T.centeredParam l r ^ 2 := by
    rw [← sum_add_sum_compl (univ.image m), sum_image hm_inj.injOn]
    simp only [h_opposite, neg_sq, h_free]
  -- They are distinct, of the parity of `n - n' - 1` and of modulus below `n - n'`.
  have h_small (r : R) (hr : r ∈ free) : |T.centeredParam l r| < #free := by
    rw [h_card]
    refine (hm.left r).resolve_left ?_
    rintro ⟨c, hr_eq, -⟩
    have h_eq : m c = r := h_row_inj ((h_opposite c).trans hr_eq.symm)
    exact mem_compl.1 hr (mem_image.2 ⟨c, mem_univ c, h_eq⟩)
  have h_parity (r : R) (_ : r ∈ free) : Even (T.centeredParam l r + #free - 1) := by
    obtain ⟨k, hk⟩ : Even (l r + card R - 1) := hm.hasGap_row.parity r
    refine ⟨k - T.rowShift, ?_⟩
    rw [h_card, FockDualPair.centeredParam]
    lia
  rw [h_split, add_sub_cancel_left, ← h_card]
  exact three_mul_sum_sq_of_injOn free _ h_row_inj.injOn h_parity h_small

/-- For matching parameters `l`, `l'` of the pair `T`, the squares of the centred parameters
`l r - 2γ + n'` of the rows and `l' c - 2γ' + n` of the columns differ in sum by `d₀ (d₀² - 1) / 3`,
where `n = card R`, `n' = card C`, and `d₀ = n - n'` may have either sign. -/
theorem IsMatch.three_mul_sum_sq_sub [DecidableEq C] {T : FockDualPair ε ε' ι} {l : HCParam ε}
    {l' : HCParam ε'} (hm : IsMatch T l l') :
    3 * (∑ r : R, T.centeredParam l r ^ 2 - ∑ c : C, T.swap.centeredParam l' c ^ 2) =
      (card R - card C) * ((card R - card C) ^ 2 - 1) := by
  obtain h_le | h_le := le_total (card C) (card R)
  · exact hm.three_mul_sum_sq_sub_of_le h_le
  · have h_swap : 3 * (∑ c, T.swap.centeredParam l' c ^ 2 - ∑ r, T.centeredParam l r ^ 2) =
        (card C - card R : ℤ) * ((card C - card R : ℤ) ^ 2 - 1) := by
      simpa only [T.swap_swap] using hm.swap.three_mul_sum_sq_sub_of_le h_le
    linear_combination -h_swap

variable [DecidableEq C]

/-- The Casimir element with the centre `w` removed: it is formed with `E_ab - w δ_ab` in place of
`E_ab`. -/
noncomputable def GlModule.centeredCasimir {M : Type*} [AddCommGroup M] [Module ℂ M]
    (ρ : GlModule R M) (w : ℂ) : Module.End ℂ M :=
  ∑ a : R, ∑ b : R, (ρ.E a b - if a = b then w • 1 else 0) * (ρ.E b a - if b = a then w • 1 else 0)

/-- On a vector of weight `ν`, the Casimir element with the centre `w` removed is
`Ω - 2w ∑ ν_a + n w²`, where `n = card R`. Here `Ω = ρ.casimirK 1` is the full Casimir element
`∑ E_ab E_ba`: all signs are `1`, so every pair of indices counts. -/
theorem GlModule.centeredCasimir_apply {M : Type*} [AddCommGroup M] [Module ℂ M]
    (ρ : GlModule R M) (w : ℂ) {ν : R → ℤ} {v : M} (hv : ∀ a : R, ρ.E a a v = (ν a : ℂ) • v) :
    ρ.centeredCasimir w v =
      ρ.casimirK 1 v - (2 * w * ∑ a : R, (ν a : ℂ)) • v + (card R * w ^ 2) • v := by
  have h_expand : ρ.centeredCasimir w =
      ρ.casimirK 1 + (2 * -w) • ∑ a, ρ.E a a + (card R * (-w) ^ 2) • 1 := by
    have h_casimir : ρ.casimirK 1 = ∑ a, ∑ b, ρ.E a b * ρ.E b a := by
      simp [GlModule.casimir]
    rw [h_casimir, ← TauCeti.sum_add_scalar_mul_add_scalar]
    simp only [centeredCasimir, sub_eq_add_neg, neg_ite, neg_zero, neg_smul]
  simp [h_expand, hv, ← sum_smul]
  module

namespace FockDualPair

variable (T : FockDualPair ε ε' ι)

/-- The centre `w` of the action on the rows: the scalar `T.rowShift` on the diagonal is `w + n'/2`.
It is the weight of the character of the determinant by which the action is twisted. -/
noncomputable def center : ℂ := T.rowShift - card C / 2

open MvPolynomial Matrix

/-- Absorb the global sign into the row signs in Tau Ceti's parity convention. -/
private abbrev rowParity (r : R) : Bool := decide (T.globalSign * ε r = 1)

/-- Read a column sign in Tau Ceti's parity convention. -/
private abbrev columnParity (signs : C → ℤˣ) (c : C) : Bool := decide (signs c = 1)

/-- Rename the polynomial variables from pairs of indices to the indices of the oscillator. -/
private noncomputable abbrev renameEnd :
    Module.End ℂ (MvPolynomial (R × C) ℂ) ≃ₐ[ℂ] Module.End ℂ (MvPolynomial ι ℂ) :=
  (renameEquiv ℂ T.varEquiv).toLinearEquiv.conjAlgEquiv ℂ

omit [Fintype R] [DecidableEq R] [Fintype C] [DecidableEq C] in
/-- The variable renaming transports Tau Ceti's raising and lowering operators to the oscillator
operators with signs given by `T.indexSign`. -/
private theorem rename_oscillator_operators (x : R × C) :
    T.renameEnd (TauCeti.oscRaise ℂ (TauCeti.IsEvenPair T.rowParity (columnParity ε')) x) =
      raiseOp T.indexSign (T.varEquiv x) ∧
    T.renameEnd (TauCeti.oscLower ℂ (TauCeti.IsEvenPair T.rowParity (columnParity ε')) x) =
      lowerOp T.indexSign (T.varEquiv x) := by
  have h_even (x : R × C) :
      T.indexSign (T.varEquiv x) = 1 ↔ TauCeti.IsEvenPair T.rowParity (columnParity ε') x := by
    rcases Int.units_eq_one_or (T.globalSign * ε x.1) with h | h <;>
      rcases Int.units_eq_one_or (ε' x.2) with h' | h' <;>
      simp [TauCeti.isEvenPair_iff, rowParity, columnParity, indexSign, varSign, pairSign, h, h']
  constructor <;> apply LinearMap.ext <;> intro P
  · change rename T.varEquiv
      (TauCeti.oscRaise ℂ (TauCeti.IsEvenPair T.rowParity (columnParity ε')) x
        ((renameEquiv ℂ T.varEquiv).symm P)) = _
    rw [TauCeti.rename_oscRaise (q := fun i ↦ T.indexSign i = 1) T.varEquiv.injective h_even,
      ← renameEquiv_apply, AlgEquiv.apply_symm_apply]
    by_cases hx : T.varSign x = 1 <;> simp [raiseOp, hx]
  · change rename T.varEquiv
      (TauCeti.oscLower ℂ (TauCeti.IsEvenPair T.rowParity (columnParity ε')) x
        ((renameEquiv ℂ T.varEquiv).symm P)) = _
    rw [TauCeti.rename_oscLower (q := fun i ↦ T.indexSign i = 1) T.varEquiv.injective h_even,
      ← renameEquiv_apply, AlgEquiv.apply_symm_apply]
    by_cases hx : T.varSign x = 1 <;> simp [lowerOp, hx]

/-- An integer scalar acts on the polynomial module by a multiple of the identity. -/
private theorem intCast_end_eq_smul_one (k : ℤ) :
    (k : Module.End ℂ (MvPolynomial ι ℂ)) = (k : ℂ) • 1 :=
  ((Int.cast_smul_eq_zsmul ℂ k (1 : Module.End ℂ (MvPolynomial ι ℂ))).trans (zsmul_one k)).symm

/-- On a matrix unit, the centred row action is the renamed Tau Ceti action multiplied by
the row sign factor. -/
private theorem centered_row_action_eq (a b : R) :
    T.oscRows.E a b - (if a = b then T.center • 1 else 0) =
    (if ε a = ε b then 1 else T.globalSign : ℂ) •
      T.renameEnd (TauCeti.fockRowHom ℂ T.rowParity (columnParity ε') (single a b 1)) := by
  rw [TauCeti.fockRowHom_single, oscRows_E, oscRowsUnit]
  simp only [map_add, map_sum, map_mul, map_smul, apply_ite T.renameEnd, map_one, map_zero,
    T.rename_oscillator_operators, glOp]
  obtain rfl | hab := eq_or_ne a b
  · simp only [ite_true, one_smul, center, intCast_end_eq_smul_one]
    module
  · simp [hab]

/-- On a matrix unit, the centred column action is the renamed negative transpose of the Tau Ceti
action multiplied by the column sign factor. -/
private theorem centered_column_action_eq (a b : C) :
    T.swap.oscRows.E a b - (if a = b then T.swap.center • 1 else 0) =
      -(if ε' a = ε' b then 1 else T.globalSign : ℂ) •
        T.renameEnd (TauCeti.fockColHom ℂ T.rowParity (columnParity ε') (single b a 1)) := by
  have h_comm (r : R) (a b : C) :
      lowerOp T.indexSign (T.varEquiv (r, a)) * raiseOp T.indexSign (T.varEquiv (r, b)) =
        raiseOp T.indexSign (T.varEquiv (r, b)) * lowerOp T.indexSign (T.varEquiv (r, a)) +
          if a = b then 1 else 0 := by
    simpa [apply_ite T.renameEnd, T.rename_oscillator_operators] using congrArg T.renameEnd
      (TauCeti.oscLower_mul_oscRaise (K := ℂ)
        (p := TauCeti.IsEvenPair T.rowParity (columnParity ε')) (r, a) (r, b))
  -- Commuting the two operators accounts for the scalar on the diagonal.
  rw [TauCeti.fockColHom_single, swap_oscRows_E]
  simp only [map_add, map_sum, map_mul, map_smul, apply_ite T.renameEnd, map_one, map_zero,
    T.rename_oscillator_operators, h_comm, sum_add_distrib, sum_const, card_univ]
  obtain rfl | hab := eq_or_ne a b
  · simp only [ite_true, one_smul, center, intCast_end_eq_smul_one, ← Nat.cast_smul_eq_nsmul ℂ]
    module
  · simp only [hab, hab.symm, ite_false, add_zero, sub_zero, nsmul_zero, smul_neg]
    exact (neg_smul _ _).symm

/-- For signs `δ` and a sign `s` (read in `ℂ`), the factor that is `1` if `δ a = δ b` and `s`
otherwise, times the same factor for `(b, a)`, is `1`. So these factors drop out of a Casimir
element. -/
theorem sign_mul_sign {n : Type*} (δ : n → ℤˣ) (s : ℤˣ) (a b : n) :
    (if δ a = δ b then 1 else s : ℂ) * (if δ b = δ a then 1 else s : ℂ) = 1 :=
  (ite_units_eq_mul_ite_units_eq s _ _ _).trans (ite_eq_left rfl)

/-- The centred Casimir element of the column action `T.swap.oscRows` is that of the row action
`T.oscRows` plus the constant `n n' d₀ / 4`, where `n = card R`, `n' = card C` and `d₀ = n - n'`. -/
theorem centeredCasimir_swap_oscRows_eq_add : T.swap.oscRows.centeredCasimir T.swap.center =
    T.oscRows.centeredCasimir T.center + (card R * card C * (card R - card C) / 4 : ℂ) • 1 := by
  -- Transport Tau Ceti's identity through the renaming. Opposite matrix units give reciprocal
  -- signs, and exchanging the column indices preserves the Casimir sum.
  have h_casimir := congrArg T.renameEnd
    (TauCeti.lift_fockColHom_glCasimir (K := ℂ) (ε := T.rowParity) (ε' := (columnParity ε')))
  simp only [TauCeti.lift_glCasimir, map_add, map_sum, map_mul, map_smul, map_one] at h_casimir
  simp only [GlModule.centeredCasimir, T.centered_row_action_eq, T.centered_column_action_eq,
    smul_mul_smul_comm, neg_mul_neg, sign_mul_sign ε T.globalSign,
    sign_mul_sign ε' T.globalSign, one_smul]
  rw [sum_comm, h_casimir]

omit [DecidableEq R] [DecidableEq C] in
/-- The squares of the centred parameters `T.centeredParam l r = l r - 2γ + n'` (with
`γ = T.rowShift`, `n' = card C`) sum to four times the sum of the squares of `λ_r - T.center`, for
`l = 2λ`. -/
theorem sum_centeredParam_sq (l : HCParam ε) :
    ∑ r : R, (T.centeredParam l r : ℂ) ^ 2 = 4 * ∑ r : R, (l r / 2 - T.center) ^ 2 := by
  rw [mul_sum]
  refine sum_congr rfl fun r _ ↦ ?_
  push_cast [center]
  ring

end FockDualPair

/-- For matching parameters `l = 2λ`, `l' = 2λ'` of the pair `T` (both of large gap, with centred
parameters that are opposite or small), `|u|² - |ρ|² + n n' d₀ / 4 = |u'|² - |ρ'|²`. Here
`u = λ - T.center` and `u' = λ' - T.swap.center`, with the centres `T.rowShift - n'/2` and
`T.columnShift - n/2` of the row and column actions; `|u|²` is the sum of squares, `n = card R`,
`n' = card C`, `d₀ = n - n'`, and `n (n² - 1) / 12`, `n' (n'² - 1) / 12` are `|ρ|²`, `|ρ'|²`. -/
theorem IsMatch.centered_casimirValue_eq {T : FockDualPair ε ε' ι} {l : HCParam ε}
    {l' : HCParam ε'} (hm : IsMatch T l l') :
    (∑ r : R, (l r / 2 - T.center) ^ 2 - card R * (card R ^ 2 - 1) / 12 +
        card R * card C * (card R - card C) / 4 : ℂ) =
      (∑ c : C, (l' c / 2 - T.swap.center) ^ 2 - card C * (card C ^ 2 - 1) / 12 : ℂ) := by
  have h_unmatched :
      3 * (∑ r, (T.centeredParam l r : ℂ) ^ 2 - ∑ c, (T.swap.centeredParam l' c : ℂ) ^ 2) =
        (card R - card C) * ((card R - card C) ^ 2 - 1) :=
    mod_cast hm.three_mul_sum_sq_sub
  -- What remains is `n³ - n'³ - d₀³ = 3 n n' d₀`.
  rw [T.sum_centeredParam_sq, T.swap.sum_centeredParam_sq] at h_unmatched
  linear_combination h_unmatched / 12

end Casimir

end New