/-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 Formalizations.MusicTheory.Fourierpublic import Mathlib.Analysis.Fourier.ZModpublic import Mathlib.Analysis.SpecialFunctions.Trigonometric.Basicpublic import Mathlib.NumberTheory.Zsqrtd.ToRealpublic import Mathlib.Tactic.Ringpublic import Mathlib.Tactic.Linarithpublic import Mathlib.Tactic.Positivitypublic import Mathlib.Tactic.IntervalCases /-!# The multiplication transform on the Fourier coefficients For a unit `u` of `β€/12`, multiplying a pitch-class set by `u` permutes its Fourier coefficients:`Ahat (u β’ A) t = Ahat A (u * t)`; with `u = 5` this exchanges the first and fifth coefficients.The power `βAhat A 1βΒ²` lies in `Β½ β€[β3]`: `2 βAhat A 1βΒ² = P + Q β3` with integers `P`, `Q`read from the interval vector, and the order of these values is decided in `β€β3`. ## Main results * `Ahat_mul`, `Ahat_mul_norm`, `Ahat_M5`, `Ahat_M5_norm`.* `powerSpec_one_eq`: the `β€[β3]` form of the first power coefficient.* `toR3_le_iff`, `powerSpec_one_re_le_iff`: the order of `β€β3` agrees with the real order. ## References * E. Amiot, *David Lewin and maximally even sets*, J. Math. Music 1 (2007).* I. Quinn, *General equal-tempered harmony*, Perspectives of New Music 44β45 (2006β2007).-/ @[expose] public section namespace MusicTheory open Finset ZMod AddChar Complexopen scoped ZMod Real namespace MTransform /-- The 0/1 indicator of a pc-set (= `Fourier.ind`). -/noncomputable def ind (A : Finset (ZMod 12)) : ZMod 12 β β := fun j => if j β A then 1 else 0 /-- The DFT of a pc-set (= `Fourier.Ahat`): `Γ A t = Ξ£_{a β A} exp(β2ΟiΒ·aΒ·t/12)`. -/noncomputable def Ahat (A : Finset (ZMod 12)) : ZMod 12 β β := π (ind A) /-- `Γ A t = Ξ£_{a β A} stdAddChar(β(aΒ·t))` (= `Fourier.Ahat_apply`). -/lemma Ahat_apply (A : Finset (ZMod 12)) (t : ZMod 12) : Ahat A t = β a β A, stdAddChar (-(a * t)) := by unfold Ahat ind rw [dft_apply] simp only [smul_eq_mul, mul_ite, mul_one, mul_zero, Finset.sum_ite_mem, Finset.univ_inter] /-- Left multiplication by a unit is injective on `ZMod 12` (no `NoZeroDivisors` needed: cancel by `uβ»ΒΉ`). The witness fed to `Finset.sum_image`. -/lemma unit_mul_injOn (u : (ZMod 12)Λ£) {s : Finset (ZMod 12)} : β x β s, β y β s, (u : ZMod 12) * x = (u : ZMod 12) * y β x = y := by intro x _ y _ h have h' := congrArg (fun z => (βuβ»ΒΉ : ZMod 12) * z) h simpa only [β mul_assoc, Units.inv_mul, one_mul] using h' /-- **STAGE A β the M-transform coefficient permutation.** For a unit `u β (β€/12)Λ£`, multiplying every pitch class by `u` permutes the Fourier index: `Γ(uΒ·A)(t) = Γ(A)(uΒ·t)`. Equivalently `a_k(M_u A) = a_{uΒ·k}(A)` β Amiot's footnote / Quinn's Multiplication Principle. -/theorem Ahat_mul (u : (ZMod 12)Λ£) (A : Finset (ZMod 12)) (t : ZMod 12) : Ahat (A.image (fun a => (u : ZMod 12) * a)) t = Ahat A ((u : ZMod 12) * t) := by rw [Ahat_apply, Ahat_apply, Finset.sum_image (unit_mul_injOn u)] refine Finset.sum_congr rfl fun a _ => ?_ congr 1 ring /-- **Magnitude corollary.** The M-transform preserves the spectrum up to the index permutation: `βΓ(uΒ·A)(t)β = βΓ(A)(uΒ·t)β`. -/theorem Ahat_mul_norm (u : (ZMod 12)Λ£) (A : Finset (ZMod 12)) (t : ZMod 12) : βAhat (A.image (fun a => (u : ZMod 12) * a)) tβ = βAhat A ((u : ZMod 12) * t)β := by rw [Ahat_mul] /-- `5` is a unit of `β€/12` (it is its own inverse: `5Β·5 = 25 β‘ 1`). The Mβ "circle-of-fifths" multiplication used in Amiot's corollary. -/def u5 : (ZMod 12)Λ£ := β¨5, 5, by decide, by decideβ© @[simp] lemma u5_coe : (u5 : ZMod 12) = 5 := rfl /-- **M-transform corollary, frequency `1 β¦ 5`.** With `u = 5`, the M-transform sends the `k = 1` coefficient to the `k = 5` coefficient: `Γ(Mβ A)(1) = Γ(A)(5)`. This is the index map that turns the Huddling Lemma (cluster maximizes `βa_1β`) into its M-corollary (the fifth-generated set, image of the cluster under Mβ , maximizes `βa_5β`). -/theorem Ahat_M5 (A : Finset (ZMod 12)) : Ahat (A.image (fun a => (5 : ZMod 12) * a)) 1 = Ahat A 5 := by have h := Ahat_mul u5 A 1 simpa only [u5_coe, mul_one] using h /-- **M-transform corollary (magnitudes), `βa_1β β¦ βa_5β`.** `βΓ(Mβ A)(1)β = βΓ(A)(5)β`. -/theorem Ahat_M5_norm (A : Finset (ZMod 12)) : βAhat (A.image (fun a => (5 : ZMod 12) * a)) 1β = βAhat A 5β := by rw [Ahat_M5] /-- The cluster `{0,1,2,3,4,5}` maps under Mβ to the fifth-generated chain `{0,5,10,3,8,1}` (= `{0,1,3,5,8,10}`), the diatonic-fifths skeleton β the concrete Huddlingβ¦Mβ witness. -/example : ({0, 1, 2, 3, 4, 5} : Finset (ZMod 12)).image (fun a => (5 : ZMod 12) * a) = {0, 1, 3, 5, 8, 10} := by decide /-! ### STAGE B β Amiot's Huddling Lemma: the β€[β3] reformulation and the decidable order. Amiot 2007 (Huddling Lemma) maximizes `βΓ A 1β`, equivalently `powerSpec A 1 = βΓ A 1βΒ² β β`.The 12th-root cosines `cos(Ο d/6)` introduce `β3` at the `d = Β±1, Β±5` interval classes, so thevalue is NOT rational: it lives in β€[β3] (scaled by Β½). We FORMALIZE that reformulation here.This is a Lean restatement of Amiot's analysis, NOT new mathematics. `powerSpec`, `autocorr`, `IVraw` live in `Fourier.lean`; `IV k := IVraw A k` is the interval vector. KEYSTONE (`powerSpec_one_eq`): 2 Β· powerSpec A 1 = P A + (Q A)Β·β3 , with the INTEGER coefficients P A = 2Β·|A| + IV 2 β IV 4 β 2Β·IV 6 (the β-part, Γ2) Q A = IV 1 β IV 5 (the β3-part)The β3 ordering BLOCKS naive `decide`; mapping `P + Qβ3 β¦ (β¨P,Qβ© : Zsqrtd 3)` exposes Mathlib's`LinearOrder (β€βd)` (decidable), and `toR3_le_iff` bridges that order to the real spectrum order(Mathlib has `Zsqrtd.toReal` as a ring hom and its injectivity, not its monotonicity, which isproved here from `SqLe`/`nonneg_cases`). -/ /-- Bridge: `stdAddChar` of an integer residue as `cos + sinΒ·i` (real cosines/sines). -/lemma charZ (n : β€) : stdAddChar ((n : β€) : ZMod 12) = (Real.cos (Ο * n / 6) : β) + (Real.sin (Ο * n / 6) : β) * Complex.I := by rw [stdAddChar_coe] have h : Complex.exp (2 * (Ο : β) * Complex.I * (n : β) / (12 : β)) = Complex.exp (((Ο * n / 6 : β) : β) * Complex.I) := by congr 1; push_cast; ring rw [h, Complex.exp_mul_I, Complex.ofReal_cos, Complex.ofReal_sin] -- derived fundamental real values (the two angles outside Mathlib's named special angles)private lemma rc4 : Real.cos (2 * Ο / 3) = -1 / 2 := by rw [show 2 * Ο / 3 = Ο - Ο / 3 by ring, Real.cos_pi_sub, Real.cos_pi_div_three]; ringprivate lemma rs4 : Real.sin (2 * Ο / 3) = Real.sqrt 3 / 2 := by rw [show 2 * Ο / 3 = Ο - Ο / 3 by ring, Real.sin_pi_sub, Real.sin_pi_div_three]private lemma rc5 : Real.cos (5 * Ο / 6) = -Real.sqrt 3 / 2 := by rw [show 5 * Ο / 6 = Ο - Ο / 6 by ring, Real.cos_pi_sub, Real.cos_pi_div_six]; ringprivate lemma rs5 : Real.sin (5 * Ο / 6) = 1 / 2 := by rw [show 5 * Ο / 6 = Ο - Ο / 6 by ring, Real.sin_pi_sub, Real.sin_pi_div_six] -- the twelve 12th-root character values stdAddChar (-(d : ZMod 12))private lemma ch0 : stdAddChar (-(0 : ZMod 12)) = 1 := by rw [show (-(0 : ZMod 12)) = (((0 : β€)) : ZMod 12) from by decide, charZ] rw [show (Ο * ((0 : β€) : β) / 6) = 0 from by push_cast; ring, Real.cos_zero, Real.sin_zero] push_cast; ringprivate lemma ch1 : stdAddChar (-(1 : ZMod 12)) = (Real.sqrt 3 : β) / 2 - (1 / 2) * Complex.I := by rw [show (-(1 : ZMod 12)) = (((-1 : β€)) : ZMod 12) from by decide, charZ] rw [show (Ο * ((-1 : β€) : β) / 6) = -(Ο / 6) from by push_cast; ring, Real.cos_neg, Real.sin_neg, Real.cos_pi_div_six, Real.sin_pi_div_six] push_cast; ringprivate lemma ch2 : stdAddChar (-(2 : ZMod 12)) = (1 / 2 : β) - (Real.sqrt 3 : β) / 2 * Complex.I := by rw [show (-(2 : ZMod 12)) = (((-2 : β€)) : ZMod 12) from by decide, charZ] rw [show (Ο * ((-2 : β€) : β) / 6) = -(Ο / 3) from by push_cast; ring, Real.cos_neg, Real.sin_neg, Real.cos_pi_div_three, Real.sin_pi_div_three] push_cast; ringprivate lemma ch3 : stdAddChar (-(3 : ZMod 12)) = -Complex.I := by rw [show (-(3 : ZMod 12)) = (((-3 : β€)) : ZMod 12) from by decide, charZ] rw [show (Ο * ((-3 : β€) : β) / 6) = -(Ο / 2) from by push_cast; ring, Real.cos_neg, Real.sin_neg, Real.cos_pi_div_two, Real.sin_pi_div_two] push_cast; ringprivate lemma ch4 : stdAddChar (-(4 : ZMod 12)) = (-1 / 2 : β) - (Real.sqrt 3 : β) / 2 * Complex.I := by rw [show (-(4 : ZMod 12)) = (((-4 : β€)) : ZMod 12) from by decide, charZ] rw [show (Ο * ((-4 : β€) : β) / 6) = -(2 * Ο / 3) from by push_cast; ring, Real.cos_neg, Real.sin_neg, rc4, rs4] push_cast; ringprivate lemma ch5 : stdAddChar (-(5 : ZMod 12)) = -(Real.sqrt 3 : β) / 2 - (1 / 2) * Complex.I := by rw [show (-(5 : ZMod 12)) = (((-5 : β€)) : ZMod 12) from by decide, charZ] rw [show (Ο * ((-5 : β€) : β) / 6) = -(5 * Ο / 6) from by push_cast; ring, Real.cos_neg, Real.sin_neg, rc5, rs5] push_cast; ringprivate lemma ch6 : stdAddChar (-(6 : ZMod 12)) = -1 := by rw [show (-(6 : ZMod 12)) = (((-6 : β€)) : ZMod 12) from by decide, charZ] rw [show (Ο * ((-6 : β€) : β) / 6) = -Ο from by push_cast; ring, Real.cos_neg, Real.sin_neg, Real.cos_pi, Real.sin_pi] push_cast; ringprivate lemma ch7 : stdAddChar (-(7 : ZMod 12)) = -(Real.sqrt 3 : β) / 2 + (1 / 2) * Complex.I := by rw [show (-(7 : ZMod 12)) = (((5 : β€)) : ZMod 12) from by decide, charZ] rw [show (Ο * ((5 : β€) : β) / 6) = 5 * Ο / 6 from by push_cast; ring, rc5, rs5] push_cast; ringprivate lemma ch8 : stdAddChar (-(8 : ZMod 12)) = (-1 / 2 : β) + (Real.sqrt 3 : β) / 2 * Complex.I := by rw [show (-(8 : ZMod 12)) = (((4 : β€)) : ZMod 12) from by decide, charZ] rw [show (Ο * ((4 : β€) : β) / 6) = 2 * Ο / 3 from by push_cast; ring, rc4, rs4] push_cast; ringprivate lemma ch9 : stdAddChar (-(9 : ZMod 12)) = Complex.I := by rw [show (-(9 : ZMod 12)) = (((3 : β€)) : ZMod 12) from by decide, charZ] rw [show (Ο * ((3 : β€) : β) / 6) = Ο / 2 from by push_cast; ring, Real.cos_pi_div_two, Real.sin_pi_div_two] push_cast; ringprivate lemma ch10 : stdAddChar (-(10 : ZMod 12)) = (1 / 2 : β) + (Real.sqrt 3 : β) / 2 * Complex.I := by rw [show (-(10 : ZMod 12)) = (((2 : β€)) : ZMod 12) from by decide, charZ] rw [show (Ο * ((2 : β€) : β) / 6) = Ο / 3 from by push_cast; ring, Real.cos_pi_div_three, Real.sin_pi_div_three] push_cast; ringprivate lemma ch11 : stdAddChar (-(11 : ZMod 12)) = (Real.sqrt 3 : β) / 2 + (1 / 2) * Complex.I := by rw [show (-(11 : ZMod 12)) = (((1 : β€)) : ZMod 12) from by decide, charZ] rw [show (Ο * ((1 : β€) : β) / 6) = Ο / 6 from by push_cast; ring, Real.cos_pi_div_six, Real.sin_pi_div_six] push_cast; ring /-- β-part (Γ2) of `2Β·powerSpec A 1`: `P A = 2Β·|A| + IV 2 β IV 4 β 2Β·IV 6`. -/def P (A : Finset (ZMod 12)) : β€ := 2 * (A.card : β€) + Fourier.IVraw A 2 - Fourier.IVraw A 4 - 2 * Fourier.IVraw A 6 /-- β3-part of `2Β·powerSpec A 1`: `Q A = IV 1 β IV 5`. -/def Q (A : Finset (ZMod 12)) : β€ := Fourier.IVraw A 1 - Fourier.IVraw A 5 /-- **STAGE B keystone β the β€[β3] reformulation of Amiot's Huddling target.** `2 Β· powerSpec A 1 = P A + (Q A)Β·β3` with `P A, Q A : β€` the interval-vector combinations. -/theorem powerSpec_one_eq (A : Finset (ZMod 12)) : 2 * Fourier.powerSpec A 1 = (P A : β) + (Q A : β) * Real.sqrt 3 := by -- conversions IVraw β autocorr have hIV : β k : β, 1 β€ k β k β€ 5 β (Fourier.IVraw A k : β) = 2 * (Fourier.autocorr A (k : ZMod 12) : β) := by intro k h1 h5 rw [Fourier.IVraw_eq_two_commonTones A k h1 h5, Fourier.commonTones_eq_autocorr] push_cast; ring have hIV6 : (Fourier.IVraw A 6 : β) = (Fourier.autocorr A (6 : ZMod 12) : β) := by rw [Fourier.IVraw_tritone, Fourier.commonTones_eq_autocorr] have hcard : (A.card : β) = (Fourier.autocorr A (0 : ZMod 12) : β) := by rw [Fourier.autocorr_zero] -- expand the power spectrum as a forward DFT of the autocorrelation rw [Fourier.powerSpec_eq_dft_autocorr, show (Finset.univ : Finset (ZMod 12)) = {0,1,2,3,4,5,6,7,8,9,10,11} from by decide] rw [Finset.sum_insert (by decide), Finset.sum_insert (by decide), Finset.sum_insert (by decide), Finset.sum_insert (by decide), Finset.sum_insert (by decide), Finset.sum_insert (by decide), Finset.sum_insert (by decide), Finset.sum_insert (by decide), Finset.sum_insert (by decide), Finset.sum_insert (by decide), Finset.sum_insert (by decide), Finset.sum_singleton] simp only [mul_one] rw [ch0, ch1, ch2, ch3, ch4, ch5, ch6, ch7, ch8, ch9, ch10, ch11] -- fold the upper-half autocorrelations onto the lower half (evenness, `autocorr_neg`) rw [show (7 : ZMod 12) = -(5 : ZMod 12) from by decide, Fourier.autocorr_neg, show (8 : ZMod 12) = -(4 : ZMod 12) from by decide, Fourier.autocorr_neg, show (9 : ZMod 12) = -(3 : ZMod 12) from by decide, Fourier.autocorr_neg, show (10 : ZMod 12) = -(2 : ZMod 12) from by decide, Fourier.autocorr_neg, show (11 : ZMod 12) = -(1 : ZMod 12) from by decide, Fourier.autocorr_neg] -- expand P, Q and convert to autocorrelation; then β-ring with β3 as an atom simp only [P, Q] push_cast rw [hcard, hIV6, hIV 1 (by norm_num) (by norm_num), hIV 2 (by norm_num) (by norm_num), hIV 4 (by norm_num) (by norm_num), hIV 5 (by norm_num) (by norm_num)] simp only [Nat.cast_ofNat, Nat.cast_one] ring /-! #### The decidable β€[β3] order (`Zsqrtd 3`) and the bridge to the real spectrum order. `Zsqrtd (3 : β)` is used (not `Zsqrtd (3 : β€)`) because Mathlib's `LinearOrder (β€βd)` is statedfor `d : β`. `Zsqrtd.toReal` is a ring hom but Mathlib does not prove it monotone, so we supply`toR3_le_iff` from the `SqLe`/`nonneg_cases` characterisation of the order. -/ /-- The β€[β3] coordinate vector of `2Β·powerSpec A 1` (= `P A + Q AΒ·β3`). -/def psZ (A : Finset (ZMod 12)) : Zsqrtd (3 : β) := β¨P A, Q Aβ© /-- `β€[β3] βͺ β`, the canonical ring hom sending `β3 β¦ Real.sqrt 3`. -/noncomputable abbrev toR3 : Zsqrtd (3 : β) β+* β := Zsqrtd.toReal (by norm_num : (0 : β€) β€ (3 : β)) /-- The image of `psZ A` in β is exactly `2Β·Re(powerSpec A 1)`: the spectrum value lives in β€[β3]. -/lemma toReal_psZ (A : Finset (ZMod 12)) : toR3 (psZ A) = 2 * (Fourier.powerSpec A 1).re := by have h := congrArg Complex.re (powerSpec_one_eq A) simp only [Complex.mul_re, Complex.add_re, Complex.ofReal_re, Complex.ofReal_im, Complex.intCast_re, Complex.intCast_im, Complex.re_ofNat, Complex.im_ofNat] at h simp only [psZ, toR3, Zsqrtd.toReal, Zsqrtd.lift_apply_apply] push_cast linarith [h] /-- `3` is not a perfect square in β€ (needed for `Zsqrtd.toReal` injectivity). -/lemma three_nonsquare : β n : β€, ((3 : β) : β€) β n * n := by intro n h push_cast at h have h1 : n β€ 1 := by nlinarith [sq_nonneg (n - 2), h] have h2 : -1 β€ n := by nlinarith [sq_nonneg (n + 2), h] interval_cases n <;> norm_num at h private lemma toReal_mk (p q : β€) : toR3 β¨p, qβ© = (p : β) + (q : β) * Real.sqrt 3 := by simp only [toR3, Zsqrtd.toReal, Zsqrtd.lift_apply_apply] push_cast ring private lemma sqrt3_ge_iff {u v : β} (hu : 0 β€ u) (hv : 0 β€ v) : v * Real.sqrt 3 β€ u β 3 * v ^ 2 β€ u ^ 2 := by have hs : Real.sqrt 3 ^ 2 = 3 := Real.sq_sqrt (by norm_num) have hsn : 0 β€ Real.sqrt 3 := Real.sqrt_nonneg 3 constructor Β· intro h; nlinarith [mul_nonneg hv hsn, h] Β· intro h; nlinarith [mul_nonneg hv hsn, h, sq_nonneg (u - v * Real.sqrt 3)] private lemma sqrt3_le_iff {u v : β} (hu : 0 β€ u) (hv : 0 β€ v) : u β€ v * Real.sqrt 3 β u ^ 2 β€ 3 * v ^ 2 := by have hs : Real.sqrt 3 ^ 2 = 3 := Real.sq_sqrt (by norm_num) have hsn : 0 β€ Real.sqrt 3 := Real.sqrt_nonneg 3 constructor Β· intro h; nlinarith [mul_nonneg hv hsn, h] Β· intro h; nlinarith [mul_nonneg hv hsn, h, sq_nonneg (v * Real.sqrt 3 - u)] private lemma toR3_nonneg {a : Zsqrtd (3 : β)} (ha : 0 β€ a) : 0 β€ toR3 a := by obtain β¨x, y, h | h | hβ© := Zsqrtd.nonneg_cases (Zsqrtd.nonneg_iff_zero_le.mpr ha) Β· subst h; rw [toReal_mk]; push_cast; positivity Β· subst h have hN : Zsqrtd.SqLe y 3 x 1 := Zsqrtd.nonnegg_pos_neg.1 (Zsqrtd.nonneg_iff_zero_le.mpr ha) rw [toReal_mk]; push_cast have hh : (3 : β) * (y : β) ^ 2 β€ (x : β) ^ 2 := by simp only [Zsqrtd.SqLe] at hN have h1 : (3 : β) * y * y β€ 1 * x * x := by exact_mod_cast hN nlinarith [h1] have := (sqrt3_ge_iff (by positivity) (by positivity)).2 hh linarith Β· subst h have hN : Zsqrtd.SqLe x 1 y 3 := Zsqrtd.nonnegg_neg_pos.1 (Zsqrtd.nonneg_iff_zero_le.mpr ha) rw [toReal_mk]; push_cast have hh : (x : β) ^ 2 β€ 3 * (y : β) ^ 2 := by simp only [Zsqrtd.SqLe] at hN have h1 : (1 : β) * x * x β€ 3 * y * y := by exact_mod_cast hN nlinarith [h1] have := (sqrt3_le_iff (by positivity) (by positivity)).2 hh linarith /-- `0 β€ a` in `β€[β3]` iff `0 β€ toR3 a` in β β monotonicity of `Zsqrtd.toReal` (not in Mathlib). -/lemma zero_le_iff_toR3 (a : Zsqrtd (3 : β)) : 0 β€ a β 0 β€ toR3 a := by constructor Β· exact toR3_nonneg Β· intro ht rcases Zsqrtd.nonneg_total a with h | h Β· exact Zsqrtd.nonneg_iff_zero_le.mp h Β· have h0 : 0 β€ toR3 (-a) := toR3_nonneg (Zsqrtd.nonneg_iff_zero_le.mp h) rw [map_neg] at h0 have hTa : toR3 a = 0 := le_antisymm (by linarith) ht have hinj : Function.Injective toR3 := Zsqrtd.toReal_injective (by norm_num) three_nonsquare have ha0 : a = 0 := hinj (by rw [hTa, map_zero]) rw [ha0] /-- **The β€[β3] order IS the real spectrum order.** `a β€ b` in `β€[β3]` iff `toR3 a β€ toR3 b`. -/lemma toR3_le_iff (a b : Zsqrtd (3 : β)) : a β€ b β toR3 a β€ toR3 b := by constructor Β· intro hab have h0 : (0 : β) β€ toR3 (b - a) := (zero_le_iff_toR3 (b - a)).mp (sub_nonneg.mpr hab) rw [map_sub] at h0; linarith Β· intro hab have h0 : (0 : β) β€ toR3 (b - a) := by rw [map_sub]; linarith exact sub_nonneg.mp ((zero_le_iff_toR3 (b - a)).mpr h0) /-- **STAGE B bridge β the Huddling comparison reduced to the decidable β€[β3] order.** `Re(powerSpec A 1) β€ Re(powerSpec B 1)` iff `psZ A β€ psZ B` in `Zsqrtd 3` (a `DecidableLE` order). So Amiot's "cluster maximizes `βaββ`" becomes a finite decidable comparison. -/theorem powerSpec_one_re_le_iff (A B : Finset (ZMod 12)) : (Fourier.powerSpec A 1).re β€ (Fourier.powerSpec B 1).re β psZ A β€ psZ B := by rw [toR3_le_iff, toReal_psZ, toReal_psZ] constructor <;> intro h <;> linarith /-- The β€[β3] order on spectrum values is decidable β kernel-checkable comparisons. -/example (A B : Finset (ZMod 12)) : Decidable (psZ A β€ psZ B) := inferInstance /-- **Concrete Huddling witness (kernel `decide`).** The contiguous cluster `{0,1,2,3,4,5}` dominates the whole-tone scale `{0,2,4,6,8,10}` in `βaββΒ²` β a single decidable β€[β3] comparison via `psZ`. (The general statement over all sets is `Huddling.arc_maximizes_power`, proved by a structural argument.) -/example : psZ {0, 2, 4, 6, 8, 10} β€ psZ {0, 1, 2, 3, 4, 5} := by decide end MTransform end MusicTheory