🏛️ Atlas✒️Formalizations.MusicTheory.InversionDFT view on GitHub ↗32 theorems
/-Copyright (c) 2026 Carles Marín. All rights reserved.Released under Apache 2.0 license as described in the file LICENSE.Authors: Carles Marín-/module public import Mathlib.Analysis.Fourier.ZModpublic import Mathlib.LinearAlgebra.Span.Basicpublic import Mathlib.Tactic.Ring /-!# The dihedral action on the Fourier basis of `ℂ[ℤ/N]` With the characters `dftChar k j = stdAddChar (j * k)`, translation acts diagonally(`transl a (dftChar k) = stdAddChar (-(a * k)) • dftChar k`) and inversion swaps `k` and `-k`(`inv (dftChar k) = dftChar (-k)`). Hence each `block k = span {dftChar k, dftChar (-k)}` isinvariant under the dihedral group generated by translations and inversion, and it is irreduciblewhen `k ≠ -k`. Mathlib has the transform-level statement `ZMod.dft_comp_neg`; here the statementsare about the characters themselves. The decomposition into the abstract irreduciblerepresentations of the dihedral group is not formalized (Mathlib has no classification of them). ## Main results * `inv_dftChar`, `transl_dftChar`: the two operators on the characters.* `block_dihedral_invariant`, `block_irreducible`: the blocks are invariant, and irreducible for  `k ≠ -k`.* `selfPaired_eq`, `selfPaired_iff`, `selfPaired_odd`, `selfPaired_even`, `tritone_selfPaired`:  the self-paired frequencies (`{0, 6}` for `N = 12`; `{0, m}` for `N = 2m`). ## References * C. Marín, *The Tonnetz spectrum is the generating triad's Fourier balance profile*,  Zenodo (2026), doi:10.5281/zenodo.20862821.-/ @[expose] public section namespace MusicTheory open Complex Real namespace InversionDFT open ZMod AddChar variable {N : ℕ} [NeZero N] /-- The k-th DFT character as a vector on `ZMod N`: `dftChar k j = stdAddChar (j * k)`.    (The same characters as `CycleGraphSpectrum.dftChar`.) -/noncomputable def dftChar (k : ZMod N) : ZMod N → ℂ := fun j => stdAddChar (j * k) @[simp] lemma dftChar_apply (k j : ZMod N) : dftChar k j = stdAddChar (j * k) := rfl /-! ### T1 — the two operator actions on the DFT basis. -/ /-- Pitch-class INVERSION operator: `inv Φ x = Φ (-x)` (flip the chromatic circle). -/noncomputable def inv (Φ : ZMod N → ℂ) : ZMod N → ℂ := fun x => Φ (-x) /-- TRANSPOSITION operator by `a` semitones: `transl a Φ x = Φ (x - a)`. -/noncomputable def transl (a : ZMod N) (Φ : ZMod N → ℂ) : ZMod N → ℂ := fun x => Φ (x - a) /-- **Inversion swaps `k ↔ -k` (T1).** `inv (dftChar k) = dftChar (-k)`: inversion permutes the    DFT characters by negating the frequency. -/theorem inv_dftChar (k : ZMod N) : inv (dftChar k) = dftChar (-k) := by  funext x  simp only [inv, dftChar_apply, neg_mul, mul_neg] /-- **Translation is diagonal (T1).** `transl a (dftChar k) = stdAddChar (-(a*k)) • dftChar k`:    each DFT character is an eigenvector of every transposition, with eigenvalue the root of    unity `stdAddChar(-(a·k))`. -/theorem transl_dftChar (a k : ZMod N) :    transl a (dftChar k) = stdAddChar (-(a * k)) • dftChar k := by  funext x  simp only [transl, dftChar_apply, Pi.smul_apply, smul_eq_mul]  -- (x - a)*k = x*k + (-(a*k)); split the character  rw [sub_mul, sub_eq_add_neg, map_add_eq_mul]  ring /-! ### T2 — the D₁₂-invariant 2-dimensional block. -/ /-- The 2-dim block `block k = span{dftChar k, dftChar (-k)}` — a D₁₂-invariant subspace. -/noncomputable def block (k : ZMod N) : Submodule ℂ (ZMod N → ℂ) :=  Submodule.span ℂ {dftChar k, dftChar (-k)} /-- Both generators of `block k` lie in `block k` (trivially); recorded for the membership proofs. -/lemma dftChar_mem_block (k : ZMod N) : dftChar k ∈ block k :=  Submodule.subset_span (by simp) lemma dftChar_neg_mem_block (k : ZMod N) : dftChar (-k) ∈ block k :=  Submodule.subset_span (by simp) /-- **Inversion preserves the block (T2).** `inv` maps `block k` into `block k`: it swaps the two    spanning characters (`dftChar k ↦ dftChar (-k)` and `dftChar (-k) ↦ dftChar k`, using    `-(-k) = k`), so the whole span is preserved. -/theorem inv_mem_block (k : ZMod N) {Φ : ZMod N → ℂ} (hΦ : Φ ∈ block k) :    inv Φ ∈ block k := by  -- `inv` is ℂ-linear; induct over the span generators.  induction hΦ using Submodule.span_induction with  | mem x hx =>      rcases hx with h | h      · -- x = dftChar k  ↦  dftChar (-k)        subst h; rw [inv_dftChar]; exact dftChar_neg_mem_block k      · -- x = dftChar (-k)  ↦  dftChar k   (since -(-k) = k)        rw [Set.mem_singleton_iff] at h        subst h; rw [inv_dftChar, neg_neg]; exact dftChar_mem_block k  | zero =>      have : inv (0 : ZMod N → ℂ) = 0 := by funext z; simp [inv]      rw [this]; exact Submodule.zero_mem (block k)  | add x y _ _ hx hy =>      have : inv (x + y) = inv x + inv y := by funext z; simp [inv]      rw [this]; exact Submodule.add_mem _ hx hy  | smul c x _ hx =>      have : inv (c • x) = c • inv x := by funext z; simp [inv]      rw [this]; exact Submodule.smul_mem _ c hx /-- **Translation preserves the block (T2).** Every transposition `transl a` maps `block k` into    `block k`: each generator goes to a scalar times itself, hence stays in the span. -/theorem transl_mem_block (a k : ZMod N) {Φ : ZMod N → ℂ} (hΦ : Φ ∈ block k) :    transl a Φ ∈ block k := by  induction hΦ using Submodule.span_induction with  | mem x hx =>      rcases hx with h | h      · subst h; rw [transl_dftChar]        exact Submodule.smul_mem _ _ (dftChar_mem_block k)      · rw [Set.mem_singleton_iff] at h        subst h; rw [transl_dftChar]        exact Submodule.smul_mem _ _ (dftChar_neg_mem_block k)  | zero =>      have : transl a (0 : ZMod N → ℂ) = 0 := by funext z; simp [transl]      rw [this]; exact Submodule.zero_mem (block k)  | add x y _ _ hx hy =>      have : transl a (x + y) = transl a x + transl a y := by funext z; simp [transl]      rw [this]; exact Submodule.add_mem _ hx hy  | smul c x _ hx =>      have : transl a (c • x) = c • transl a x := by funext z; simp [transl]      rw [this]; exact Submodule.smul_mem _ c hx /-- **The block is D₁₂-invariant (T2 corollary).** `block k` is closed under inversion AND under    every transposition `transl a` — i.e. under the whole group ⟨T, I⟩ = D₁₂. This is the    block-diagonalization of the dihedral action in the DFT basis. -/theorem block_dihedral_invariant (k : ZMod N) {Φ : ZMod N → ℂ} (hΦ : Φ ∈ block k) :    inv Φ ∈ block k ∧ ∀ a : ZMod N, transl a Φ ∈ block k :=  ⟨inv_mem_block k hΦ, fun a => transl_mem_block a k hΦ⟩ /-! ### T3 — the pairing counts over ℤ/12. The self-paired classes `{k | k = -k}` are exactly `{0, 6}`: the two 1-dim blocks. The remainingten classes split into the five pairs {1,11},{2,10},{3,9},{4,8},{5,7}, each a 2-dim block. Thedimension bookkeeping `2·1 + 5·2 = 12 = dim ℂ[ℤ₁₂]` is recorded as an `example`. -/ /-- **The self-paired classes over ℤ/12 (T3).** `{k : ZMod 12 | k = -k} = {0, 6}`: exactly the two    frequencies fixed by inversion, giving the two 1-dimensional blocks. (`decide` over ZMod 12.) -/theorem selfPaired_eq : {k : ZMod 12 | k = -k} = {0, 6} := by  ext k  simp only [Set.mem_ofPred_eq, Set.mem_insert_iff, Set.mem_singleton_iff]  revert k  decide /-- Dimension bookkeeping: 2 one-dim blocks (k ∈ {0,6}) + 5 two-dim blocks (the ±k pairs)    account for all of `dim ℂ[ℤ₁₂] = 12`. -/example : 2 * 1 + 5 * 2 = 12 := by norm_num /-! ### The self-paired frequencies for every `N`. `selfPaired_eq` and the `2·1 + 5·2 = 12` bookkeeping above are the EVEN instance of a statement trueover every `ZMod N`. The self-paired frequencies `{k | k = -k}` — the negation fixed points = the1-dimensional dihedral blocks — and the rest pair into 2-dimensional blocks:  • N ODD  : self-paired `= {0}`        (1 one-dim block ; (N−1)/2 two-dim blocks),  • N EVEN : self-paired `= {0, N/2}`   (2 one-dim blocks; (N−2)/2 two-dim blocks — the extra                                          self-paired frequency is the TRITONE `N/2`).The count of 1-dim blocks is `gcd(2, N)`. The structural theorems above (`block_dihedral_invariant`,`block_irreducible`) hold for arbitrary `N`. The key lemma is Mathlib's `ZMod.neg_eq_self_iff`. -/ omit [NeZero N] in/-- **Self-paired ⟺ negation fixed point.** `k = -k ↔ k = 0 ∨ 2 * k.val = N`: a frequency is its    own inverse exactly at the DC term, or where `2·k = N` (the tritone, available only for even N). -/theorem selfPaired_iff (k : ZMod N) : k = -k ↔ (k = 0 ∨ 2 * k.val = N) := by  constructor  · intro h; exact (ZMod.neg_eq_self_iff k).mp h.symm  · intro h; exact ((ZMod.neg_eq_self_iff k).mpr h).symm omit [NeZero N] in/-- **Odd N — one 1-dim block.** `{k : ZMod N | k = -k} = {0}`: for odd N the equation    `2·k.val = N` is even = odd, impossible, so inversion fixes only the DC frequency. -/theorem selfPaired_odd (hodd : Odd N) : {k : ZMod N | k = -k} = {0} := by  obtain ⟨j, hj⟩ := hodd  ext k  simp only [Set.mem_ofPred_eq, Set.mem_singleton_iff, selfPaired_iff]  constructor  · rintro (h | h)    · exact h    · omega  · rintro rfl; exact Or.inl rfl /-- **Even N — two 1-dim blocks, DC and the TRITONE.** `{k : ZMod N | k = -k} = {0, (m : ZMod N)}`    where `N = 2m`: the only nonzero self-paired frequency is the tritone `m = N/2`. The n=12 case    `{0, 6}` (`selfPaired_eq`) is `m = 6`. -/theorem selfPaired_even (m : ℕ) (hm : N = 2 * m) :    {k : ZMod N | k = -k} = {0, (m : ZMod N)} := by  have hmlt : m < N := by have := NeZero.pos N; omega  have hval : ((m : ZMod N)).val = m := ZMod.val_cast_of_lt hmlt  ext k  simp only [Set.mem_ofPred_eq, Set.mem_insert_iff, Set.mem_singleton_iff, selfPaired_iff]  constructor  · rintro (h | h)    · exact Or.inl h    · refine Or.inr ?_      have hkv : k.val = m := by omega      calc k = ((k.val : ℕ) : ZMod N) := (ZMod.natCast_zmod_val k).symm        _ = ((m : ℕ) : ZMod N) := by rw [hkv]  · rintro (rfl | rfl)    · exact Or.inl rfl    · exact Or.inr (by rw [hval]; omega) /-- **The tritone is self-paired in every even universe ** `(m : ZMod N) =    -(m : ZMod N)` when `N = 2m`: the tritone `N/2` is fixed by inversion in every even `ℤ_N`. This is    the structural reason the tritone keeps recurring. -/theorem tritone_selfPaired (m : ℕ) (hm : N = 2 * m) : (m : ZMod N) = -(m : ZMod N) := by  rw [selfPaired_iff]  exact Or.inr (by rw [ZMod.val_cast_of_lt (by have := NeZero.pos N; omega : m < N)]; omega) omit [NeZero N] in/-- **One 1-dim block for odd N.** `gcd(2,N) = 1`: inversion has a single fixed frequency. -/theorem selfPaired_ncard_odd (hodd : Odd N) : ({k : ZMod N | k = -k}).ncard = 1 := by  rw [selfPaired_odd hodd, Set.ncard_singleton] /-- **Two 1-dim blocks for even N.** `gcd(2,N) = 2`: inversion fixes exactly the DC term    and the tritone. -/theorem selfPaired_ncard_even (m : ℕ) (hm : N = 2 * m) :    ({k : ZMod N | k = -k}).ncard = 2 := by  have hmlt : m < N := by have := NeZero.pos N; omega  have hm1 : 1 ≤ m := by have := NeZero.pos N; omega  have hne : (0 : ZMod N) ≠ (m : ZMod N) := by    intro h    have hv : ((m : ZMod N)).val = m := ZMod.val_cast_of_lt hmlt    have h0 : ((m : ZMod N)).val = 0 := by rw [← h]; simp    omega  rw [selfPaired_even m hm, Set.ncard_pair hne] /-- Dimension bookkeeping for all N: `(#1-dim)·1 + (#2-dim)·2 = N` — odd `1 + 2·(N−1)/2 = N`,    even `2 + 2·(N−2)/2 = N`. (n=12 is the even case `2 + 2·5 = 12`.) -/example (j : ℕ) : 1 + 2 * j = 2 * j + 1 := by omegaexample (m : ℕ) (hm : 1 ≤ m) : 2 * 1 + 2 * (m - 1) = 2 * m := by omega /-! ### The conjugate pair `{k, −k}` The orbit `conjPair k = {k, −k}` of `k` under negation indexes the dihedral blocks: `block k` is thespan of `dftChar '' conjPair k` (`block_eq_span_conjPair`), of dimension `(conjPair k).ncard ∈ {1, 2}`;it is a singleton exactly at the self-paired frequencies (`conjPair_ncard_*`), which for even `N` are`0` and the tritone `N/2` (`tritone_selfPaired`). -/ /-- The conjugate pair / negation orbit `conjPair k = {k, −k}`, the index of the dihedral blocks. -/def conjPair (k : ZMod N) : Set (ZMod N) := {k, -k} omit [NeZero N] in@[simp] theorem mem_conjPair {k j : ZMod N} : j ∈ conjPair k ↔ j = k ∨ j = -k := Iff.rfl omit [NeZero N] in/-- **The pair is well defined on the negation quotient.** `conjPair (-k) = conjPair k`: the    two ends of a conjugate pair name the same object — `conjPair` factors through `k ~ -k`. -/theorem conjPair_neg (k : ZMod N) : conjPair (-k) = conjPair k := by  unfold conjPair; rw [neg_neg, Set.pair_comm] /-- **The block is the span of the conjugate pair.** `block k = span ℂ    (dftChar '' conjPair k)`: the dihedral block is literally the span of the two characters indexed by    the conjugate pair. So `conjPair k` IS the block index. -/theorem block_eq_span_conjPair (k : ZMod N) :    block k = Submodule.span ℂ (dftChar '' conjPair k) := by  unfold block conjPair; rw [Set.image_pair] omit [NeZero N] in/-- **Self-paired ⟹ the block is 1-dimensional.** When `k = -k` the conjugate pair collapses to    a singleton, `(conjPair k).ncard = 1`: the two fixed frequencies `{0, N/2}` are the 1-dim blocks. -/theorem conjPair_ncard_of_selfPaired {k : ZMod N} (h : k = -k) : (conjPair k).ncard = 1 := by  unfold conjPair; rw [← h, Set.pair_eq_singleton, Set.ncard_singleton] omit [NeZero N] in/-- **Not self-paired ⟹ the block is 2-dimensional.** When `k ≠ -k` the conjugate pair has two    elements, `(conjPair k).ncard = 2`: the genuine 2-dim irreducible blocks. -/theorem conjPair_ncard_of_not {k : ZMod N} (h : k ≠ -k) : (conjPair k).ncard = 2 :=  Set.ncard_pair h /-- **The tritone pair is a singleton in every even universe.** `conjPair (N/2)` collapses    to `{N/2}` for `N = 2m`: the tritone is its own conjugate, so its block is 1-dimensional. -/theorem conjPair_tritone_ncard (m : ℕ) (hm : N = 2 * m) : (conjPair (m : ZMod N)).ncard = 1 :=  conjPair_ncard_of_selfPaired (tritone_selfPaired m hm) /-! ### Irreducibility of the 2-dim blocks (eigenvalue separation). For `k ≠ -k` the block `block k` is an IRREDUCIBLE ⟨T, I⟩ = D₁₂ representation: it has no propernonzero subspace invariant under both `inv` and all `transl a`. The mechanism is eigenvalueseparation — at `a = 1` the two `transl 1` eigenvalues `stdAddChar(-k)` and `stdAddChar k` areDISTINCT iff `k ≠ -k`, so the only `transl`-invariant lines are the two coordinate axes, which `inv`swaps. Standard 2-dim-dihedral-irrep representation theory; here for this concreteDFT block. -/ /-! #### T-next-1 — eigenvalue apartness. -/ /-- **Eigenvalue apartness (T-next-1).** For `k ≠ -k` the two `transl 1` eigenvalues are distinct:    `stdAddChar k ≠ stdAddChar (-k)`. Immediate from injectivity of the standard additive character    (`ZMod.injective_stdAddChar`). -/theorem dftChar_apart {k : ZMod N} (hk : k ≠ -k) : stdAddChar k ≠ stdAddChar (-k) :=  fun h => hk (injective_stdAddChar h) /-- **The non-self-paired ℤ/12 frequencies (T-next-1, ZMod face).** Over ℤ/12, `k ∉ {0,6}` is    exactly the apartness hypothesis `k ≠ -k` (contrapositive of `selfPaired_eq`). -/theorem not_selfPaired {k : ZMod 12} (hk : k ∉ ({0, 6} : Set (ZMod 12))) : k ≠ -k := by  intro h  exact hk (by rw [← selfPaired_eq]; exact h) /-! #### T-next-2 — pair independence + operator linearity. -/ omit [NeZero N] in/-- `transl a` is additive. -/theorem transl_add (a : ZMod N) (Φ Ψ : ZMod N → ℂ) :    transl a (Φ + Ψ) = transl a Φ + transl a Ψ := by funext z; simp [transl] omit [NeZero N] in/-- `transl a` is ℂ-homogeneous. -/theorem transl_smul (a : ZMod N) (c : ℂ) (Φ : ZMod N → ℂ) :    transl a (c • Φ) = c • transl a Φ := by funext z; simp [transl] omit [NeZero N] in/-- `inv` is additive. -/theorem inv_add (Φ Ψ : ZMod N → ℂ) : inv (Φ + Ψ) = inv Φ + inv Ψ := by  funext z; simp [inv] omit [NeZero N] in/-- `inv` is ℂ-homogeneous. -/theorem inv_smul (c : ℂ) (Φ : ZMod N → ℂ) : inv (c • Φ) = c • inv Φ := by  funext z; simp [inv] /-- `dftChar k 0 = 1`. -/@[simp] lemma dftChar_zero (k : ZMod N) : dftChar k 0 = 1 := by  simp [dftChar, AddChar.map_zero_eq_one] /-- `dftChar k 1 = stdAddChar k`. -/@[simp] lemma dftChar_one (k : ZMod N) : dftChar k 1 = stdAddChar k := by  simp [dftChar] /-- **Pair independence (T-next-2).** For `k ≠ -k` the two DFT characters `dftChar k`, `dftChar (-k)`    are ℂ-linearly independent: a vanishing combination `c • dftChar k + d • dftChar (-k) = 0` forces    `c = d = 0`. Proof: evaluate at `x = 0` (gives `c + d = 0`) and at `x = 1` (gives    `c·stdAddChar k + d·stdAddChar(-k) = 0`); the 2×2 system has determinant    `stdAddChar(-k) − stdAddChar k ≠ 0` by `dftChar_apart`. -/theorem dftChar_pair_indep {k : ZMod N} (hk : k ≠ -k) (c d : ℂ)    (h : c • dftChar k + d • dftChar (-k) = 0) : c = 0 ∧ d = 0 := by  have h0 := congrFun h 0  have h1 := congrFun h 1  simp only [Pi.add_apply, Pi.smul_apply, smul_eq_mul, dftChar_zero, dftChar_one,    Pi.zero_apply, mul_one] at h0 h1  -- h0 : c + d = 0,  h1 : c * stdAddChar k + d * stdAddChar (-k) = 0  have hd : d = -c := by linear_combination h0  subst hd  -- h1 : c * stdAddChar k + (-c) * stdAddChar (-k) = 0  have hc : c * (stdAddChar k - stdAddChar (-k)) = 0 := by linear_combination h1  have hne : stdAddChar k - stdAddChar (-k) ≠ 0 := sub_ne_zero.mpr (dftChar_apart hk)  have : c = 0 := by    rcases mul_eq_zero.mp hc with hc0 | hc0    · exact hc0    · exact absurd hc0 hne  exact ⟨this, by rw [this, neg_zero]⟩ /-! #### T-next-3 — concrete irreducibility (eigenvalue separation). -/ /-- Helper: the eigenvalue-separation vector. For `w₀ = c • dftChar k + d • dftChar (-k)`,    `transl 1 w₀ - stdAddChar k • w₀ = (c * (stdAddChar (-k) - stdAddChar k)) • dftChar k`.    The `dftChar (-k)` component cancels because `transl 1` acts on it by `stdAddChar k` — the same    scalar we subtract. This is the algebra that isolates the `k`-eigenvector. -/lemma eigen_sep (k : ZMod N) (c d : ℂ) :    transl 1 (c • dftChar k + d • dftChar (-k)) - stdAddChar k • (c • dftChar k + d • dftChar (-k))      = (c * (stdAddChar (-k) - stdAddChar k)) • dftChar k := by  rw [transl_add, transl_smul, transl_smul, transl_dftChar, transl_dftChar]  funext x  simp only [Pi.sub_apply, Pi.add_apply, Pi.smul_apply, smul_eq_mul, dftChar_apply,    one_mul, neg_neg]  ring /-- **Concrete irreducibility of the 2-dim block (T-next-3, THE PRIZE).** For `k ≠ -k`, any subspace    `W ≤ block k` invariant under inversion `inv` and all transpositions `transl a` is either `⊥` or    all of `block k`. So `block k` is an IRREDUCIBLE ⟨T, I⟩ = D₁₂ representation. The proof is    eigenvalue separation: a nonzero `w₀ ∈ W`, written `c • dftChar k + d • dftChar (-k)`, yields via    `eigen_sep` the vector `u = c·(stdAddChar(-k) − stdAddChar k) • dftChar k ∈ W`; when `c ≠ 0` the    scalar is nonzero (apartness) so `dftChar k ∈ W`, when `c = 0` then `dftChar (-k) ∈ W` directly;    `inv` supplies the partner, hence `block k ≤ W`, and `le_antisymm` finishes. -/theorem block_irreducible {k : ZMod N} (hk : k ≠ -k) (W : Submodule ℂ (ZMod N → ℂ))    (hWle : W ≤ block k) (hinv : ∀ w ∈ W, inv w ∈ W)    (htransl : ∀ (a : ZMod N) (w : ZMod N → ℂ), w ∈ W → transl a w ∈ W) :    W = ⊥ ∨ W = block k := by  by_cases hW : W = ⊥  · exact Or.inl hW  · refine Or.inr ?_    -- A nonzero witness in W, decomposed in the block basis.    obtain ⟨w₀, hw₀W, hw₀ne⟩ := Submodule.exists_mem_ne_zero_of_ne_bot hW    obtain ⟨c, d, hcd⟩ := Submodule.mem_span_pair.mp (hWle hw₀W)    -- Key claim: dftChar k ∈ W. Then inv gives dftChar (-k) ∈ W, hence block k ≤ W.    have hchar_k : dftChar k ∈ W := by      by_cases hc : c = 0      · -- c = 0 ⇒ w₀ = d • dftChar (-k), with d ≠ 0; so dftChar (-k) ∈ W, then inv ⇒ dftChar k ∈ W.        subst hc        rw [zero_smul, zero_add] at hcd        have hd : d ≠ 0 := by          rintro rfl; rw [zero_smul] at hcd; exact hw₀ne hcd.symm        have hcharneg : dftChar (-k) ∈ W := by          have : dftChar (-k) = d⁻¹ • w₀ := by rw [← hcd, smul_smul, inv_mul_cancel₀ hd, one_smul]          rw [this]; exact W.smul_mem _ hw₀W        have := hinv _ hcharneg        rwa [inv_dftChar, neg_neg] at this      · -- c ≠ 0: extract via eigen_sep.        have hu_mem : transl 1 w₀ - stdAddChar k • w₀ ∈ W :=          W.sub_mem (htransl 1 w₀ hw₀W) (W.smul_mem _ hw₀W)        rw [← hcd, eigen_sep] at hu_mem        set γ : ℂ := c * (stdAddChar (-k) - stdAddChar k) with hγ        have hγne : γ ≠ 0 := by          rw [hγ]          exact mul_ne_zero hc (sub_ne_zero.mpr (fun h => (dftChar_apart hk) h.symm))        have : dftChar k = γ⁻¹ • (γ • dftChar k) := by          rw [smul_smul, inv_mul_cancel₀ hγne, one_smul]        rw [this]; exact W.smul_mem _ hu_mem    have hchar_negk : dftChar (-k) ∈ W := by      have := hinv _ hchar_k; rwa [inv_dftChar] at this    -- block k ≤ W, then antisymmetry.    refine le_antisymm hWle ?_    rw [block, Submodule.span_le]    intro x hx    rcases hx with h | h    · rw [h]; exact hchar_k    · rw [Set.mem_singleton_iff] at h; rw [h]; exact hchar_negk /-! ### Not formalized The packaging of `block k` as a simple module over `MonoidAlgebra ℂ (DihedralGroup 6)`, itsisomorphism with an abstract irreducible representation, and the isotypic decomposition`ℂ[ℤ₁₂] = ⊕ block` need a classification of the irreducible representations of the dihedral group,which Mathlib does not have. -/ /-! ### Other equal temperaments — the block census for arbitrary N-TET, for free.     Every theorem above is generic over `{N : ℕ} [NeZero N]`, so the dihedral block decomposition holds    in ANY equal temperament, instantiated with no extra proof. For the famous microtonal systems 19-, 31-,    53-TET (all odd) the ONLY self-paired frequency is the DC term — there is NO tritone, and `gcd(2,N)=1`    gives a single 1-dimensional block, the remaining `(N-1)/2` frequencies pairing into 2-dimensional    irreducible blocks (`block_irreducible`, generic in N). For an even temperament such as 24-TET (quarter    tones) the tritone reappears at `N/2 = 12`, giving two 1-dim blocks. The proof assistant supplies each    instance by feeding `N` to the same generic theorem — no per-system work. -/ example : ({k : ZMod 19 | k = -k}).ncard = 1 := selfPaired_ncard_odd (by decide)   -- 19-TET: no tritoneexample : ({k : ZMod 31 | k = -k}).ncard = 1 := selfPaired_ncard_odd (by decide)   -- 31-TET: no tritoneexample : ({k : ZMod 53 | k = -k}).ncard = 1 := selfPaired_ncard_odd (by decide)   -- 53-TET: no tritoneexample : ({k : ZMod 24 | k = -k}).ncard = 2 := selfPaired_ncard_even 12 (by decide) -- 24-TET: DC + tritoneexample : (12 : ZMod 24) = -(12 : ZMod 24) := tritone_selfPaired 12 (by decide)      -- the 24-TET tritone end InversionDFT end MusicTheory