/-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.Data.Matrix.Mulpublic import Mathlib.Basic.Complex.Basicpublic import Mathlib.Data.ZMod.Basicpublic import Mathlib.Data.Fintype.BigOperatorspublic import Mathlib.Algebra.BigOperators.Group.Finset.Basicpublic import Mathlib.Algebra.BigOperators.Group.Finset.Lemmaspublic import Mathlib.Analysis.Fourier.ZModpublic import Mathlib.LinearAlgebra.LinearIndependent.Defspublic import Mathlib.LinearAlgebra.LinearIndependent.Basicpublic import Mathlib.LinearAlgebra.Basis.Basicpublic import Mathlib.LinearAlgebra.FiniteDimensional.Lemmaspublic import Mathlib.LinearAlgebra.Dimension.Constructionspublic import Mathlib.FieldTheory.IsAlgClosed.Basicpublic import Mathlib.Analysis.SpecialFunctions.Complex.Circlepublic import Mathlib.Tactic.Ring /-!# Completeness of the Tonnetz spectrum `β^(ZMod 12 Γ Bool)` is `β^(ZMod 12) β βΒ²`. For each frequency `k` the Tonnetz adjacency matrixpreserves `dftChar k β βΒ²` and acts there as a `2 Γ 2` block with eigenvalues `Β±Ξ» k`,`Ξ» k ^ 2 = pp k * pm k`. The 24 eigenvectors so obtained are linearly independent (a tensorproduct of the character basis with an independent pair for each character), hence a basis.So `A` is diagonalizable with exactly these eigenvalues, without the classification of theirreducible representations of the dihedral group. ## Main results * `tensor_linearIndependent`: characters tensored with independent pairs are independent.* `eigFam_is_eigenvector`, `eigFam_linearIndependent`, `eigenBasis`.* `tonnetz_spectrum_complete`, `tonnetz_spectrum_complete_unconditional`: a basis of eigenvectors with eigenvalues `Β±Ξ» k`. ## References * L. Babai, *Spectra of Cayley graphs*, J. Combin. Theory Ser. B 27 (1979).* 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 scoped Matrix BigOperatorsopen Complex namespace TonnetzCompleteness /-! ### The triad type, neo-Riemannian ops, and the adjacency operator (re-stated, as inTonnetzSpectrum.lean). -/ abbrev Triad := ZMod 12 Γ Bool def Pf : Triad β Triad | (x, b) => (x, !b)def Lf : Triad β Triad | (x, true) => (x + 4, false) | (x, false) => (x - 4, true)def Rf : Triad β Triad | (x, true) => (x - 3, false) | (x, false) => (x + 3, true) def adj (t t' : Triad) : β := if t' = Pf t β¨ t' = Lf t β¨ t' = Rf t then 1 else 0def A : Matrix Triad Triad β := Matrix.of adj@[simp] lemma A_apply (t t' : Triad) : A t t' = adj t t' := rfl theorem neighbours_distinct : β t : Triad, Pf t β Lf t β§ Pf t β Rf t β§ Lf t β Rf t := by decide def nbhd (t : Triad) : Finset Triad := {Pf t, Lf t, Rf t} lemma adj_eq_indicator (t t' : Triad) : adj t t' = if t' β nbhd t then 1 else 0 := by unfold adj nbhd; congr 1; simp only [Finset.mem_insert, Finset.mem_singleton] /-- The generic row sum: `Ξ£_{t'} adj t t' Β· f t' = f (P t) + f (L t) + f (R t)`. -/lemma row_sum (f : Triad β β) (t : Triad) : β t' : Triad, adj t t' * f t' = f (Pf t) + f (Lf t) + f (Rf t) := by rw [Finset.sum_congr rfl (fun t' _ => by rw [adj_eq_indicator t t', boole_mul])] rw [Finset.sum_ite_mem, Finset.univ_inter] obtain β¨hPL, hPR, hLRβ© := neighbours_distinct t unfold nbhd rw [Finset.sum_insert (by simp only [Finset.mem_insert, Finset.mem_singleton]; push Not; exact β¨hPL, hPRβ©), Finset.sum_insert (by simp only [Finset.mem_singleton]; exact hLR), Finset.sum_singleton, add_assoc] /-! ### The DFT character on the root, and its shift law. -/ open ZMod AddChar /-- The k-th DFT character on the root: `dftChar k x = stdAddChar (x * k)`. -/noncomputable def dftChar (k : ZMod 12) : ZMod 12 β β := fun x => stdAddChar (x * k) @[simp] lemma dftChar_apply (k x : ZMod 12) : dftChar k x = stdAddChar (x * k) := rfl /-- Character shift law: `dftChar k (x + c) = dftChar k x Β· stdAddChar (c * k)`. -/lemma dftChar_shift (k x c : ZMod 12) : dftChar k (x + c) = dftChar k x * stdAddChar (c * k) := by simp only [dftChar_apply, add_mul, map_add_eq_mul] /-! ### The generic eigenvector `eig k q (x,b) = dftChar k x Β· q b`. For the quality 2-vector `q : Bool β β`, the vector `eig k q` is an `A`-eigenvector with eigenvalue`lam` provided the two structural relations hold: `q false Β· (1 + stdAddChar (4Β·k) + stdAddChar ((-3)Β·k)) = lam Β· q true` (major side), `q true Β· (1 + stdAddChar ((-4)Β·k) + stdAddChar (3Β·k)) = lam Β· q false` (minor side). -/ /-- The eigenvector skeleton: DFT character on the root times a quality 2-vector. -/noncomputable def eig (k : ZMod 12) (q : Bool β β) : Triad β β := fun t => dftChar k t.1 * q t.2 @[simp] lemma eig_maj (k : ZMod 12) (q : Bool β β) (x : ZMod 12) : eig k q (x, true) = dftChar k x * q true := rfl@[simp] lemma eig_min (k : ZMod 12) (q : Bool β β) (x : ZMod 12) : eig k q (x, false) = dftChar k x * q false := rfl /-- **Generic eigenvector lemma (dftChar form).** Given the two structural relations, `eig k q` is an `A`-eigenvector with eigenvalue `lam`. -/theorem A_mulVec_eig (k : ZMod 12) (q : Bool β β) (lam : β) (hmaj : q false * (1 + stdAddChar (4 * k) + stdAddChar ((-3) * k)) = lam * q true) (hmin : q true * (1 + stdAddChar ((-4) * k) + stdAddChar (3 * k)) = lam * q false) : A *α΅₯ (eig k q) = lam β’ (eig k q) := by funext t obtain β¨x, bβ© := t simp only [Matrix.mulVec, dotProduct, A_apply, Pi.smul_apply, smul_eq_mul] rw [row_sum (eig k q) (x, b)] cases b Β· -- minor (x,false): neighbours (x,true), (xβ4,true), (x+3,true) β all majors show eig k q (x, true) + eig k q (x - 4, true) + eig k q (x + 3, true) = _ rw [eig_maj, eig_maj, eig_maj, eig_min, show (x - 4) = x + (-4) from by ring, show (x + 3) = x + 3 from rfl, dftChar_shift k x (-4), dftChar_shift k x 3] have e : dftChar k x * q true + dftChar k x * stdAddChar ((-4) * k) * q true + dftChar k x * stdAddChar (3 * k) * q true = dftChar k x * (q true * (1 + stdAddChar ((-4) * k) + stdAddChar (3 * k))) := by ring rw [e, hmin]; ring Β· -- major (x,true): neighbours (x,false), (x+4,false), (xβ3,false) β all minors show eig k q (x, false) + eig k q (x + 4, false) + eig k q (x - 3, false) = _ rw [eig_min, eig_min, eig_min, eig_maj, show (x - 3) = x + (-3) from by ring, dftChar_shift k x 4, dftChar_shift k x (-3)] have e : dftChar k x * q false + dftChar k x * stdAddChar (4 * k) * q false + dftChar k x * stdAddChar ((-3) * k) * q false = dftChar k x * (q false * (1 + stdAddChar (4 * k) + stdAddChar ((-3) * k))) := by ring rw [e, hmaj]; ring /-! ### DFT-character linear independence (as in `CycleGraphSpectrum`). -/ /-- The k-th DFT character is `N` times the inverse-DFT of the standard delta `Pi.single k 1`. -/lemma dftChar_eq_smul_invDFT (k : ZMod 12) : dftChar k = (12 : β) β’ (ZMod.dft (N := 12)).symm (Pi.single k (1 : β)) := by funext x rw [Pi.smul_apply, ZMod.invDFT_apply] rw [Finset.sum_eq_single k (fun j _ hj => by rw [Pi.single_eq_of_ne hj, smul_zero]) (fun h => absurd (Finset.mem_univ k) h), Pi.single_eq_same, dftChar_apply, mul_comm x k] simp only [smul_eq_mul, mul_one] rw [show ((12 : β) : β) = (12 : β) by norm_num, β mul_assoc, mul_inv_cancelβ (by norm_num : (12 : β) β 0), one_mul] /-- Sealed helper (as in CycleGraphSpectrum): the standard basis pushed through an injective map. -/theorem linearIndependent_single_one_map (M' : Type*) [AddCommGroup M'] [Module β M'] (f : (ZMod 12 β β) ββ[β] M') (hf : Function.Injective f) : LinearIndependent β (fun k : ZMod 12 => f (Pi.single k (1 : β))) := (Pi.linearIndependent_single_one (ZMod 12) β).map' f (LinearMap.ker_eq_bot.2 hf) /-- **The DFT characters are linearly independent.** -/theorem dftChar_linearIndependent : LinearIndependent β (fun k : ZMod 12 => dftChar k) := by have hmap : LinearIndependent β (fun k : ZMod 12 => (ZMod.dft (N := 12) (E := β)).symm (Pi.single k (1 : β))) := linearIndependent_single_one_map (ZMod 12 β β) (ZMod.dft (N := 12) (E := β)).symm.toLinearMap (ZMod.dft (N := 12) (E := β)).symm.injective have hN : (12 : β) β 0 := by norm_num have hscale := hmap.units_smul (fun _ : ZMod 12 => (Units.mk0 (12 : β) hN)) have hfam : (fun _ : ZMod 12 => (Units.mk0 (12 : β) hN)) β’ (fun k : ZMod 12 => (ZMod.dft (N := 12) (E := β)).symm (Pi.single k (1 : β))) = fun k : ZMod 12 => dftChar k := by funext k rw [Pi.smul_apply', dftChar_eq_smul_invDFT, Units.smul_mk0] rwa [hfam] at hscale /-! ### Abstract "(character basis) β (independent quality pair)" independence. -/ /-- **Abstract product-independence.** If `(f i)_i` is a linearly independent family in `ΞΉ β β` and for each `i`, `(q i b)_{b}` is a linearly independent family in `ΞΊ β β`, then the tensor family `(x, b') β¦ f i x * q i b b'` indexed by `(i, b)` is linearly independent in `(ΞΉ Γ ΞΊ) β β`. -/theorem tensor_linearIndependent {ΞΉ ΞΊ : Type*} [Fintype ΞΉ] [Fintype ΞΊ] (f : ΞΉ β (ΞΉ β β)) (hf : LinearIndependent β f) (q : ΞΉ β ΞΊ β (ΞΊ β β)) (hq : β i, LinearIndependent β (q i)) : LinearIndependent β (fun ib : ΞΉ Γ ΞΊ => fun xb : ΞΉ Γ ΞΊ => f ib.1 xb.1 * q ib.1 ib.2 xb.2) := by rw [Fintype.linearIndependent_iff] intro c hc iβ obtain β¨i, bββ© := iβ rw [Fintype.linearIndependent_iff] at hf have key : β b' : ΞΊ, β i : ΞΉ, β b : ΞΊ, c (i, b) * q i b b' = 0 := by intro b' refine hf (fun i => β b : ΞΊ, c (i, b) * q i b b') ?_ funext x have hcx := congrFun hc (x, b') simp only [Pi.zero_apply, Finset.sum_apply, Pi.smul_apply, smul_eq_mul] at hcx rw [Fintype.sum_prod_type] at hcx simp only [Pi.zero_apply, Finset.sum_apply, Pi.smul_apply, smul_eq_mul] rw [β hcx] apply Finset.sum_congr rfl intro i _ rw [Finset.sum_mul] apply Finset.sum_congr rfl intro b _ ring have hqi := hq i rw [Fintype.linearIndependent_iff] at hqi exact hqi (fun b => c (i, b)) (by funext b' simp only [Pi.zero_apply, Finset.sum_apply, Pi.smul_apply, smul_eq_mul] exact key b' i) bβ /-! ### The unconditional 24-vector BASIS of `β^Triad`. The 24 vectors `eig j (Pi.single b 1)` β DFT character on the root tensored with a STANDARD qualitybasis vector β are linearly independent (character basis β standard basis, both manifestlyindependent), hence (card = 24 = dim) a BASIS of `Triad β β`. This is the structural backbone ofcompleteness: `A` preserves each frequency's 2-dim quality block (the eigenvector lemma `A_mulVec_eig`says so), so in this basis `A` is block-diagonal with twelve explicit 2Γ2 blocks. -/ /-- The standard product family: `stdFam (j,b) (x,b') = dftChar j x Β· (Pi.single b 1) b'`, i.e. `dftChar j` on the root, the `b`-th standard quality vector on the quality bit. -/noncomputable def stdFam : (ZMod 12 Γ Bool) β (Triad β β) := fun jb => fun xb => dftChar jb.1 xb.1 * (Pi.single (M := fun _ : Bool => β) jb.2 (1 : β)) xb.2 /-- **The 24 standard product vectors are linearly independent.** -/theorem stdFam_linearIndependent : LinearIndependent β stdFam := by have h := tensor_linearIndependent dftChar dftChar_linearIndependent (fun _ : ZMod 12 => fun b : Bool => (Pi.single (M := fun _ : Bool => β) b (1 : β))) (fun _ => Pi.linearIndependent_single_one Bool β) exact h /-- `Triad β β` has dimension 24 = `card (ZMod 12 Γ Bool)`. -/lemma finrank_triad_fun : Module.finrank β (Triad β β) = Fintype.card (ZMod 12 Γ Bool) := Module.finrank_fintype_fun_eq_card β /-- **THE COMPLETENESS BASIS.** The 24 vectors `stdFam (j,b)` form a basis of `Triad β β`. (Linear independence + card = dim.) In this basis `A` is block-diagonal across the 12 frequencies; combined with `A_mulVec_eig` this exhibits the full spectrum as the twelve 2Γ2 quality blocks. -/noncomputable def tonnetzBasis : Module.Basis (ZMod 12 Γ Bool) β (Triad β β) := basisOfLinearIndependentOfCardEqFinrank stdFam_linearIndependent finrank_triad_fun.symm @[simp] lemma tonnetzBasis_apply (jb : ZMod 12 Γ Bool) : tonnetzBasis jb = stdFam jb := by simp only [tonnetzBasis, coe_basisOfLinearIndependentOfCardEqFinrank] /-! ### The completeness ENGINE: a basis of `A`-eigenvectors β spectrum complete. The general, reusable statement. The per-frequency major/minor structure constants are `pp k = 1 + stdAddChar (4Β·k) + stdAddChar ((-3)Β·k)`, `pm k = 1 + stdAddChar ((-4)Β·k) + stdAddChar (3Β·k)`,and the two quality eigenvectors for frequency `k` are `qβΊ = (pp k, lam)`, `qβ» = (pp k, -lam)` with`lamΒ² = pp k Β· pm k`. These are `A`-eigenvectors with eigenvalues `Β± lam` (lemma `A_mulVec_eig`),and across the 12 frequencies they form a basis IFF, per frequency, the pair `qβΊ, qβ»` is independentβ equivalently `pp k β 0` (then `lam β 0` too, since `lamΒ² = βpp kβΒ² β 0`). -/ /-- Major-side structure constant `pp k = 1 + Ο^{4k} + Ο^{-3k}`. -/noncomputable def pp (k : ZMod 12) : β := 1 + stdAddChar (4 * k) + stdAddChar ((-3) * k)/-- Minor-side structure constant `pm k = 1 + Ο^{-4k} + Ο^{3k}`. -/noncomputable def pm (k : ZMod 12) : β := 1 + stdAddChar ((-4) * k) + stdAddChar (3 * k) /-- The `+` quality eigenvector for frequency `k`: `(pp k, lam)`. -/noncomputable def qPlus (k : ZMod 12) (lam : β) : Bool β β := fun b => if b then pp k else lam/-- The `β` quality eigenvector for frequency `k`: `(pp k, βlam)`. -/noncomputable def qMinus (k : ZMod 12) (lam : β) : Bool β β := fun b => if b then pp k else -lam @[simp] lemma qPlus_true (k : ZMod 12) (lam : β) : qPlus k lam true = pp k := rfl@[simp] lemma qPlus_false (k : ZMod 12) (lam : β) : qPlus k lam false = lam := rfl@[simp] lemma qMinus_true (k : ZMod 12) (lam : β) : qMinus k lam true = pp k := rfl@[simp] lemma qMinus_false (k : ZMod 12) (lam : β) : qMinus k lam false = -lam := rfl /-- `eig k (qPlus k lam)` is an `A`-eigenvector with eigenvalue `lam`, when `lamΒ² = pp k Β· pm k`. -/theorem A_mulVec_eig_plus (k : ZMod 12) (lam : β) (hlam : lam ^ 2 = pp k * pm k) : A *α΅₯ (eig k (qPlus k lam)) = lam β’ (eig k (qPlus k lam)) := by apply A_mulVec_eig k (qPlus k lam) lam Β· -- q false Β· pp = lam Β· q true : lam Β· pp = lam Β· pp rw [qPlus_false, qPlus_true, show (1 : β) + stdAddChar (4 * k) + stdAddChar ((-3) * k) = pp k from rfl] Β· -- q true Β· pm = lam Β· q false : pp Β· pm = lam Β· lam rw [qPlus_true, qPlus_false, show (1 : β) + stdAddChar ((-4) * k) + stdAddChar (3 * k) = pm k from rfl, mul_comm lam lam, β pow_two, hlam] /-- `eig k (qMinus k lam)` is an `A`-eigenvector with eigenvalue `βlam`, when `lamΒ² = pp k Β· pm k`. -/theorem A_mulVec_eig_minus (k : ZMod 12) (lam : β) (hlam : lam ^ 2 = pp k * pm k) : A *α΅₯ (eig k (qMinus k lam)) = (-lam) β’ (eig k (qMinus k lam)) := by apply A_mulVec_eig k (qMinus k lam) (-lam) Β· rw [qMinus_false, qMinus_true, show (1 : β) + stdAddChar (4 * k) + stdAddChar ((-3) * k) = pp k from rfl] Β· rw [qMinus_true, qMinus_false, show (1 : β) + stdAddChar ((-4) * k) + stdAddChar (3 * k) = pm k from rfl, show (-lam) * -lam = lam ^ 2 by ring, hlam] /-- For each frequency, the two quality eigenvectors are linearly independent βΊ `pp k β 0 β§ lam β 0`. Here we prove the `β` direction (the one we need): nonvanishing β independence. -/theorem qPair_linearIndependent (k : ZMod 12) (lam : β) (hpp : pp k β 0) (hlam : lam β 0) : LinearIndependent β (fun s : Bool => bif s then qPlus k lam else qMinus k lam) := by rw [Fintype.linearIndependent_iff] intro c hc -- c true β’ qPlus + c false β’ qMinus = 0 as a function of b' : Bool have htrue := congrFun hc true have hfalse := congrFun hc false simp only [Fintype.sum_bool, Pi.add_apply, Pi.zero_apply, Pi.smul_apply, smul_eq_mul, Bool.cond_true, Bool.cond_false, qPlus_true, qPlus_false, qMinus_true, qMinus_false] at htrue hfalse -- htrue : c true * pp k + c false * pp k = 0 β (c true + c false) * pp k = 0 -- hfalse: c true * lam + c false * (-lam) = 0 β (c true - c false) * lam = 0 have hsum : c true + c false = 0 := by have h0 : (c true + c false) * pp k = 0 := by linear_combination htrue exact (mul_eq_zero.mp h0).resolve_right hpp have hdiff : c true - c false = 0 := by have h0 : (c true - c false) * lam = 0 := by linear_combination hfalse exact (mul_eq_zero.mp h0).resolve_right hlam intro s cases s Β· -- s = false : c false = 0 linear_combination (hsum - hdiff) / 2 Β· -- s = true : c true = 0 linear_combination (hsum + hdiff) / 2 /-! ### The capstone: a BASIS of `A`-eigenvectors β the spectrum is complete. Assemble the 24 vectors. `lam : ZMod 12 β β` picks, per frequency, a complex square root of`pp k Β· pm k` (it exists β β is algebraically closed). The eigenvector family is `eigFam (k, s) = eig k (qPlus k (lam k))` for `s = true` (eigenvalue `lam k`), `eigFam (k, s) = eig k (qMinus k (lam k))` for `s = false` (eigenvalue `βlam k`).Given the per-frequency nonvanishing `pp k β 0 β§ lam k β 0`, the 24 are linearly independent(`tensor_linearIndependent` β `qPair_linearIndependent`), hence a BASIS β a diagonalization of `A`. -/ /-- The 24-vector eigen-family (parametrized by a choice of square roots `lam`). -/noncomputable def eigFam (lam : ZMod 12 β β) : (ZMod 12 Γ Bool) β (Triad β β) := fun ks => eig ks.1 (bif ks.2 then qPlus ks.1 (lam ks.1) else qMinus ks.1 (lam ks.1)) /-- Each member of `eigFam` is an `A`-eigenvector (eigenvalue `Β± lam k`), given `lam kΒ² = pp kΒ·pm k`. -/theorem eigFam_is_eigenvector (lam : ZMod 12 β β) (hlam : β k, lam k ^ 2 = pp k * pm k) (k : ZMod 12) (s : Bool) : A *α΅₯ (eigFam lam (k, s)) = (bif s then lam k else -lam k) β’ (eigFam lam (k, s)) := by cases s Β· exact A_mulVec_eig_minus k (lam k) (hlam k) Β· exact A_mulVec_eig_plus k (lam k) (hlam k) /-- **The eigen-family is linearly independent** (given per-frequency nonvanishing). The crux: the "(DFT character basis) β (per-frequency independent quality pair)" lemma. -/theorem eigFam_linearIndependent (lam : ZMod 12 β β) (hpp : β k, pp k β 0) (hlamne : β k, lam k β 0) : LinearIndependent β (eigFam lam) := by have h := tensor_linearIndependent dftChar dftChar_linearIndependent (fun k : ZMod 12 => fun s : Bool => bif s then qPlus k (lam k) else qMinus k (lam k)) (fun k => qPair_linearIndependent k (lam k) (hpp k) (hlamne k)) -- the tensor family IS eigFam, up to the `eig`/`bif` unfolding exact h /-- **THE COMPLETENESS BASIS OF EIGENVECTORS (engine).** Given square roots `lam k` of `pp kΒ·pm k` with `pp k β 0` and `lam k β 0` for every frequency, the 24 vectors `eigFam lam` form a BASIS of `Triad β β` consisting of `A`-eigenvectors. This is a full diagonalization of the Tonnetz adjacency operator: the certified eigenvalues `Β± lam k` (k = 0..11) are ALL of the spectrum, with their multiplicities β completeness, without the dihedral-irrep classification. -/noncomputable def eigenBasis (lam : ZMod 12 β β) (hpp : β k, pp k β 0) (hlamne : β k, lam k β 0) : Module.Basis (ZMod 12 Γ Bool) β (Triad β β) := basisOfLinearIndependentOfCardEqFinrank (eigFam_linearIndependent lam hpp hlamne) finrank_triad_fun.symm @[simp] lemma eigenBasis_apply (lam : ZMod 12 β β) (hpp : β k, pp k β 0) (hlamne : β k, lam k β 0) (ks : ZMod 12 Γ Bool) : eigenBasis lam hpp hlamne ks = eigFam lam ks := by simp only [eigenBasis, coe_basisOfLinearIndependentOfCardEqFinrank] /-! ### Reducing the residual hypothesis to the single fact `pp k β 0`. `pm k = conj (pp k)` (the minor-side constant is the complex conjugate of the major-side one, since`stdAddChar` is unimodular), hence `pp k Β· pm k = βpp kβΒ²`. So the square root `lam k` exists (β isalgebraically closed) and is nonzero exactly when `pp k β 0`; the whole eigen-basis is then a basis of`A`-eigenvectors. The completeness of the Tonnetz spectrum thus rests on the SINGLE concrete algebraicinput `β k, pp k β 0`. -/ /-- `conj (stdAddChar a) = stdAddChar (-a)` β `stdAddChar` is unimodular (factors through `Circle`). -/lemma conj_stdAddChar (a : ZMod 12) : (starRingEnd β) (stdAddChar a) = stdAddChar (-a) := by rw [AddChar.map_neg_eq_inv] rw [show (stdAddChar a : β) = ((ZMod.toCircle a : Circle) : β) from rfl, β Circle.coe_inv_eq_conj, β Circle.coe_inv] /-- `pm k = conj (pp k)`: the minor-side structure constant is the conjugate of the major-side one. -/lemma pm_eq_conj_pp (k : ZMod 12) : pm k = (starRingEnd β) (pp k) := by unfold pp pm rw [map_add, map_add, map_one, conj_stdAddChar, conj_stdAddChar] congr 2 <;> ring_nf /-- `pp k Β· pm k = βpp kβΒ²` (a nonneg real); in particular it is `0` iff `pp k = 0`. -/lemma pp_mul_pm (k : ZMod 12) : pp k * pm k = (Complex.normSq (pp k) : β) := by rw [pm_eq_conj_pp, Complex.normSq_eq_conj_mul_self]; ring /-- `pp k Β· pm k β 0` precisely when `pp k β 0`. -/lemma pp_mul_pm_ne_zero (k : ZMod 12) (hpp : pp k β 0) : pp k * pm k β 0 := by rw [pp_mul_pm] simp only [ne_eq, Complex.ofReal_eq_zero, Complex.normSq_eq_zero] exact hpp /-- **THE COMPLETENESS THEOREM (packaged).** Assuming only the concrete algebraic nonvanishing `β k, pp k β 0`, the Tonnetz adjacency operator `A` has a BASIS of eigenvectors β i.e. it is diagonalizable and the certified eigenvalues `Β± β(pp k Β· pm k)` (k = 0..11) are its COMPLETE spectrum with multiplicities. The square roots are produced from β being algebraically closed; no dihedral-irrep classification. -/theorem tonnetz_spectrum_complete (hpp : β k, pp k β 0) : β (lam : ZMod 12 β β), (β k, lam k ^ 2 = pp k * pm k) β§ (β B : Module.Basis (ZMod 12 Γ Bool) β (Triad β β), β ks : ZMod 12 Γ Bool, A *α΅₯ (B ks) = (bif ks.2 then lam ks.1 else -lam ks.1) β’ (B ks)) := by -- choose a square root of pp k Β· pm k for each k (β algebraically closed) have hroot : β k, β z : β, z ^ 2 = pp k * pm k := fun k => IsAlgClosed.exists_pow_nat_eq (pp k * pm k) (by norm_num) choose lam hlam using hroot have hlamne : β k, lam k β 0 := by intro k hz apply pp_mul_pm_ne_zero k (hpp k) rw [β hlam k, hz]; ring refine β¨lam, hlam, eigenBasis lam hpp hlamne, ?_β© intro ks rw [eigenBasis_apply] obtain β¨k, sβ© := ks exact eigFam_is_eigenvector lam hlam k s /-! ### Discharging the residual `β k, pp k β 0`: explicit root-of-unity arithmetic. `pp k = 1 + Ο^{4k} + Ο^{-3k}` only ever involves `Ο^m` for `m β {0,3,4,6,8,9}`. We evaluate these six`stdAddChar` values to their closed forms (`exp(2Οi m/12)`), giving `pp k = (rational) + (rational)Β·I`whose REAL part is one of `{3, 1, 2, 3/2, 1/2, -1/2}` for every `k` β never zero. Hence `pp k β 0` forall 12 frequencies, by a `decide` exponent reduction + `Complex.re` extraction. Elementary algebraicarithmetic on twelfth roots of unity. -/ open Real inprivate lemma sac_int (j : β€) : (stdAddChar ((j : ZMod 12)) : β) = Complex.exp (2 * Real.pi * I * j / 12) := by rw [stdAddChar_coe]; norm_num /-- `stdAddChar 0 = 1`. -/private lemma sac0 : (stdAddChar (0 : ZMod 12) : β) = 1 := by rw [show (0 : ZMod 12) = ((0:β€):ZMod 12) by rfl, sac_int]; norm_num/-- `stdAddChar 3 = I`. -/private lemma sac3 : (stdAddChar (3 : ZMod 12) : β) = I := by rw [show (3 : ZMod 12) = ((3:β€):ZMod 12) by push_cast; rfl, sac_int] push_cast rw [show (2 * (Real.pi:β) * I * 3 / 12) = (Real.pi/2) * I by ring, Complex.exp_mul_I, show ((Real.pi:β)/2) = (((Real.pi/2 : β)) : β) by push_cast; ring, β Complex.ofReal_cos, β Complex.ofReal_sin, Real.cos_pi_div_two, Real.sin_pi_div_two] simp/-- `stdAddChar 6 = -1`. -/private lemma sac6 : (stdAddChar (6 : ZMod 12) : β) = -1 := by rw [show (6 : ZMod 12) = ((6:β€):ZMod 12) by push_cast; rfl, sac_int] push_cast rw [show (2 * (Real.pi:β) * I * 6 / 12) = Real.pi * I by ring, Complex.exp_pi_mul_I]/-- `stdAddChar 9 = -I`. -/private lemma sac9 : (stdAddChar (9 : ZMod 12) : β) = -I := by rw [show (9 : ZMod 12) = ((9:β€):ZMod 12) by push_cast; rfl, sac_int] push_cast rw [show (2 * (Real.pi:β) * I * 9 / 12) = (3*Real.pi/2) * I by ring, Complex.exp_mul_I, show ((3*(Real.pi:β)/2)) = (((3*Real.pi/2 : β)) : β) by push_cast; ring, β Complex.ofReal_cos, β Complex.ofReal_sin, show (3*Real.pi/2) = Real.pi + Real.pi/2 by ring, Real.cos_add, Real.sin_add, Real.cos_pi, Real.sin_pi, Real.cos_pi_div_two, Real.sin_pi_div_two] push_cast; ring/-- `stdAddChar 4 = (-1 + β3Β·I)/2`. -/private lemma sac4 : (stdAddChar (4 : ZMod 12) : β) = (-1 + (Real.sqrt 3 : β) * I)/2 := by rw [show (4 : ZMod 12) = ((4:β€):ZMod 12) by push_cast; rfl, sac_int] push_cast rw [show (2 * (Real.pi:β) * I * 4 / 12) = (2*Real.pi/3) * I by ring, Complex.exp_mul_I, show ((2*(Real.pi:β)/3)) = (((2*Real.pi/3 : β)) : β) by push_cast; ring, β Complex.ofReal_cos, β Complex.ofReal_sin, show (2*Real.pi/3) = Real.pi - Real.pi/3 by ring, Real.cos_pi_sub, Real.sin_pi_sub, Real.cos_pi_div_three, Real.sin_pi_div_three] push_cast; ring/-- `stdAddChar 8 = (-1 - β3Β·I)/2`. -/private lemma sac8 : (stdAddChar (8 : ZMod 12) : β) = (-1 - (Real.sqrt 3 : β) * I)/2 := by rw [show (8 : ZMod 12) = ((8:β€):ZMod 12) by push_cast; rfl, sac_int] push_cast rw [show (2 * (Real.pi:β) * I * 8 / 12) = (4*Real.pi/3) * I by ring, Complex.exp_mul_I, show ((4*(Real.pi:β)/3)) = (((4*Real.pi/3 : β)) : β) by push_cast; ring, β Complex.ofReal_cos, β Complex.ofReal_sin, show (4*Real.pi/3) = Real.pi + Real.pi/3 by ring, Real.cos_add, Real.sin_add, Real.cos_pi, Real.sin_pi, Real.cos_pi_div_three, Real.sin_pi_div_three] push_cast; ring /-- `pp` written via the reduced exponents (`rfl` unfolding). -/private lemma pp_eq (k : ZMod 12) : pp k = 1 + stdAddChar (4 * k) + stdAddChar ((-3) * k) := rfl /-- Helper: a nonzero real part forces a nonzero complex number. -/private lemma finRe : β (z : β), z.re β 0 β z β 0 := fun z hz h => hz (by rw [h]; rfl) private lemma pp0_ne : pp (0 : ZMod 12) β 0 := by rw [pp_eq, show (4:ZMod 12)*0 = 0 by decide, show ((-3):ZMod 12)*0 = 0 by decide, sac0] norm_numprivate lemma pp1_ne : pp (1 : ZMod 12) β 0 := by rw [pp_eq, show (4:ZMod 12)*1 = 4 by decide, show ((-3):ZMod 12)*1 = 9 by decide, sac4, sac9] apply finRe simp only [Complex.add_re, Complex.one_re, Complex.div_ofNat_re, Complex.neg_re, Complex.mul_re, Complex.ofReal_re, Complex.ofReal_im, Complex.I_re, Complex.I_im] norm_numprivate lemma pp2_ne : pp (2 : ZMod 12) β 0 := by rw [pp_eq, show (4:ZMod 12)*2 = 8 by decide, show ((-3):ZMod 12)*2 = 6 by decide, sac8, sac6] apply finRe simp only [Complex.add_re, Complex.one_re, Complex.div_ofNat_re, Complex.neg_re] norm_numprivate lemma pp3_ne : pp (3 : ZMod 12) β 0 := by rw [pp_eq, show (4:ZMod 12)*3 = 0 by decide, show ((-3):ZMod 12)*3 = 3 by decide, sac0, sac3] apply finRe simp only [Complex.add_re, Complex.one_re, Complex.I_re] norm_numprivate lemma pp4_ne : pp (4 : ZMod 12) β 0 := by rw [pp_eq, show (4:ZMod 12)*4 = 4 by decide, show ((-3):ZMod 12)*4 = 0 by decide, sac4, sac0] apply finRe simp only [Complex.add_re, Complex.one_re, Complex.div_ofNat_re, Complex.neg_re, Complex.mul_re, Complex.ofReal_re, Complex.ofReal_im, Complex.I_re, Complex.I_im] norm_numprivate lemma pp5_ne : pp (5 : ZMod 12) β 0 := by rw [pp_eq, show (4:ZMod 12)*5 = 8 by decide, show ((-3):ZMod 12)*5 = 9 by decide, sac8, sac9] apply finRe simp only [Complex.add_re, Complex.one_re, Complex.div_ofNat_re, Complex.neg_re, Complex.I_re] norm_numprivate lemma pp6_ne : pp (6 : ZMod 12) β 0 := by rw [pp_eq, show (4:ZMod 12)*6 = 0 by decide, show ((-3):ZMod 12)*6 = 6 by decide, sac0, sac6] apply finRe simp only [Complex.add_re, Complex.one_re, Complex.neg_re] norm_numprivate lemma pp7_ne : pp (7 : ZMod 12) β 0 := by rw [pp_eq, show (4:ZMod 12)*7 = 4 by decide, show ((-3):ZMod 12)*7 = 3 by decide, sac4, sac3] apply finRe simp only [Complex.add_re, Complex.one_re, Complex.div_ofNat_re, Complex.neg_re, Complex.mul_re, Complex.ofReal_re, Complex.ofReal_im, Complex.I_re, Complex.I_im] norm_numprivate lemma pp8_ne : pp (8 : ZMod 12) β 0 := by rw [pp_eq, show (4:ZMod 12)*8 = 8 by decide, show ((-3):ZMod 12)*8 = 0 by decide, sac8, sac0] apply finRe simp only [Complex.add_re, Complex.one_re, Complex.div_ofNat_re] norm_numprivate lemma pp9_ne : pp (9 : ZMod 12) β 0 := by rw [pp_eq, show (4:ZMod 12)*9 = 0 by decide, show ((-3):ZMod 12)*9 = 9 by decide, sac0, sac9] apply finRe simp only [Complex.add_re, Complex.one_re, Complex.neg_re, Complex.I_re] norm_numprivate lemma pp10_ne : pp (10 : ZMod 12) β 0 := by rw [pp_eq, show (4:ZMod 12)*10 = 4 by decide, show ((-3):ZMod 12)*10 = 6 by decide, sac4, sac6] apply finRe simp only [Complex.add_re, Complex.one_re, Complex.div_ofNat_re, Complex.neg_re, Complex.mul_re, Complex.ofReal_re, Complex.ofReal_im, Complex.I_re, Complex.I_im] norm_numprivate lemma pp11_ne : pp (11 : ZMod 12) β 0 := by rw [pp_eq, show (4:ZMod 12)*11 = 8 by decide, show ((-3):ZMod 12)*11 = 3 by decide, sac8, sac3] apply finRe simp only [Complex.add_re, Complex.one_re, Complex.div_ofNat_re, Complex.I_re] norm_num /-- **THE RESIDUAL NONVANISHING β DISCHARGED.** `pp k β 0` for every frequency `k`. The 12 cases use the six explicit twelfth-root values; each `pp k` has nonzero real part. -/theorem pp_ne_zero : β k : ZMod 12, pp k β 0 := by intro k fin_cases k <;> first | exact pp0_ne | exact pp1_ne | exact pp2_ne | exact pp3_ne | exact pp4_ne | exact pp5_ne | exact pp6_ne | exact pp7_ne | exact pp8_ne | exact pp9_ne | exact pp10_ne | exact pp11_ne /-! ### The unconditional completeness theorem. -/ /-- **THE TONNETZ SPECTRUM IS COMPLETE (unconditional).** The adjacency operator `A` of the PLR/Tonnetz Cayley graph has a BASIS of 24 explicit eigenvectors β it is diagonalizable, and the eigenvalues `Β± β(pp k Β· pm k)` (k = 0..11), which are exactly `Β± {3, β5, 2cos(Ο/12), β3, 1, 2cos(5Ο/12)}` with their multiplicities, are its COMPLETE spectrum, without the dihedral-irrep classification. -/theorem tonnetz_spectrum_complete_unconditional : β (lam : ZMod 12 β β), (β k, lam k ^ 2 = pp k * pm k) β§ (β B : Module.Basis (ZMod 12 Γ Bool) β (Triad β β), β ks : ZMod 12 Γ Bool, A *α΅₯ (B ks) = (bif ks.2 then lam ks.1 else -lam ks.1) β’ (B ks)) := tonnetz_spectrum_complete pp_ne_zero end TonnetzCompleteness end MusicTheory