import Mathlib /-! # Exact Multibit $\chi^2$- and High-Noise Courtade–Kumar Theorems, Subcube Rigidity, # and Perfect-Hamming Breakdown ## Overview Let $X \sim \mathrm{Unif}(\{\text{false}, \text{true}\}^n)$ and let $Y$ be the output of $n$ independent binary symmetric channels $\mathrm{BSC}(p)$ ($p \in [0, 1]$, correlation $\varepsilon = 1 - 2p \in [-1, 1]$) on input $X$. For any $M$-ary quantizer $Q : (\mathrm{Fin}\,n \to \mathrm{Bool}) \to \mathrm{Fin}\,M$ (with cells $A_m = Q^{-1}(m)$ and masses $\mu_m = |A_m| / 2^n$, **without any balance assumption**), define: - the **Pearson $\chi^2$-mutual information** $$I_{\chi^2}(Q; p) = \sum_{m : \mu_m > 0} \frac{1}{\mu_m}\,\mathbb{E}_y\!\left[(P(Q(X) = m \mid Y = y) - \mu_m)^2\right] = \sum_{m : \mu_m > 0} \frac{1}{\mu_m}\sum_{S \neq \emptyset} \varepsilon^{2|S|}\,\widehat{\mathbf{1}_{A_m}}(S)^2,$$ - the **Shannon mutual information** $I(Q; p)$ in bits, and - the **high-noise mutual-information curvature** $$\Lambda(Q) = \sum_{m : \mu_m > 0} \frac{W_1(\mathbf{1}_{A_m})}{\mu_m}, \qquad W_1(f) = \sum_{i : \mathrm{Fin}\,n} \widehat{f}(\{i\})^2.$$ Following the September 2026 proofs of the single-bit Courtade–Kumar conjecture ($k = 1$, $I(f(X); Y) \le 1 - h_2(p)$), Mahdavifar and Beirami (`arXiv:2609.26444`) proposed the **Multibit Courtade–Kumar Conjecture**: coordinate projections retain $k(1 - h_2(p))$ bits and are conjectured optimal for small $k$ (while coding quantizers beat coordinate projections for large $k$). In this completely self-contained Lean 4 formalization (zero `sorry`, zero custom axioms, zero `native_decide`), we establish: 1. **Sharp Antipodal Odd-Weight Inequality & Complete Subcube Rigidity**: For every $n \in \mathbb{N}$ and every subset $A \subseteq (\mathrm{Fin}\,n \to \mathrm{Bool})$, $$W_1(\mathbf{1}_A) \le W_{\mathrm{odd}}(\mathbf{1}_A) = \frac{\mu(A) - \mu(A \cap \neg A)}{2} \le \min\!\left(\frac{\mu(A)}{2},\; \frac{1 - \mu(A)}{2},\; \frac{1}{4}\right)$$ (`level1Weight_le_half_mass`), and for nonempty $A$, equality $W_1(\mathbf{1}_A) = \mu(A) / 2$ holds **if and only if** $A$ is a codimension-1 or codimension-2 subcube (`level1Weight_eq_half_mass_iff`). 2. **Exact Universal $\chi^2$-Courtade–Kumar Theorem ($M \in \{2, 3, 4\}$ Sharp with Full Rigidity)**: For EVERY $n \in \mathbb{N}$, EVERY $M \ge 1$, EVERY $Q : (\mathrm{Fin}\,n \to \mathrm{Bool}) \to \mathrm{Fin}\,M$, and EVERY $p \in [0, 1]$ ($\varepsilon = 1 - 2p$): $$I_{\chi^2}(Q; p) \le \frac{M}{2}\varepsilon^2 + \left(\frac{M}{2} - 1\right)\varepsilon^4$$ (`chi2MutualInfo_le_universal`). In particular: - **1-bit ($M = 2$)**: $I_{\chi^2}(Q; p) \le \varepsilon^2$, sharp iff dictator (`chi2_courtade_kumar_one_bit`). - **Ternary ($M = 3$)**: $I_{\chi^2}(Q; p) \le \frac{3}{2}\varepsilon^2 + \frac{1}{2}\varepsilon^4$, sharp iff $Q$ is an **unbalanced** $(1/2, 1/4, 1/4)$ ternary subcube partition (`chi2_courtade_kumar_ternary`). - **2-bit ($M = 4$)**: $I_{\chi^2}(Q; p) \le 2\varepsilon^2 + \varepsilon^4 = (1 + \varepsilon^2)^2 - 1 = I_{\chi^2}(\text{2-bit coord proj}; p)$, with equality for $p \in (0, 1) \setminus \{1/2\}$ **if and only if** every cell of $Q$ is a codimension-2 subcube (2-coordinate projection OR 2-bit adaptive decision tree) (`chi2_courtade_kumar_two_bit`, `chi2_two_bit_eq_iff`). 3. **Exact High-Noise Shannon 2-Bit & Ternary Courtade–Kumar Theorem**: Via an explicit quantitative Taylor bound `|I(Q; (1-ε)/2) - (ε² / (2 ln 2)) Λ(Q)| ≤ C_Q |ε|³` (`shannonMutualInfo_high_noise_approx`), we prove: - Every 2-bit quantizer $Q$ satisfies $\Lambda(Q) \le 2$; every codimension-2 subcube partition (including the 3-variable adaptive decision tree) satisfies $I(Q; p) = 2(1 - h_2(p))$ identically for all $p \in [0, 1]$, while every other 2-bit quantizer strictly satisfies $I(Q; p) < 2(1 - h_2(p))$ near $p = 1/2$ (`shannon_two_bit_high_noise_optimal`). - Every ternary quantizer $Q$ satisfies $\Lambda(Q) \le 3/2$; the unbalanced $(1/2, 1/4, 1/4)$ ternary subcube partition achieves $I(Q; p) = \frac{3}{2}(1 - h_2(p))$ identically, and strictly beats every non-subcube (in particular every balanced) ternary quantizer near $p = 1/2$ (`shannon_ternary_high_noise_optimal`). 4. **Simultaneous Breakdown of Both $\chi^2$- and Shannon Multibit Benchmarks for All $k \ge 11$**: Using the infinite family of perfect binary Hamming codes $\mathrm{Ham}_r$ ($r \ge 4$, length $n = 2^r - 1$, $k = 2^r - 1 - r$), we prove the exact closed-form curvature $$\Lambda(\mathrm{Ham}_r) = (2^r - 1)\left(1 - \frac{2}{2^r}\right)^2 = k + (r - 4) + \frac{8}{2^r} - \frac{4}{4^r} > k$$ (`hammingQuantizer_curvature`), and by direct sum with coordinate dictators prove that for **every $k \ge 11$**, there exist a balanced $k$-bit quantizer on $k + 4$ bits and $p \in (0, 1/2)$ simultaneously exceeding both $k(1 - h_2(p))$ and $(1 + (1 - 2p)^2)^k - 1$ (`multibit_courtade_kumar_fails_all_ge_eleven`). -/ namespace MultibitCourtadeKumar open scoped BigOperators /-! ## Section 1: Boolean Fourier Analysis, BSC Noise Operator, and Mutual Information -/ section FourierAndBSC variable {ι : Type*} [Fintype ι] [DecidableEq ι] /-- Map a Boolean bit to `{-1, +1}`: `false ↦ +1`, `true ↦ -1`. -/ def boolSign (b : Bool) : ℝ := if b then -1 else 1 @[simp] lemma boolSign_false : boolSign false = 1 := rfl @[simp] lemma boolSign_true : boolSign true = -1 := rfl lemma boolSign_sq (b : Bool) : boolSign b ^ 2 = 1 := by cases b <;> norm_num [boolSign] lemma boolSign_mul_self (b : Bool) : boolSign b * boolSign b = 1 := by cases b <;> norm_num [boolSign] lemma boolSign_not (b : Bool) : boolSign (!b) = -boolSign b := by cases b <;> norm_num [boolSign] lemma boolSign_abs (b : Bool) : |boolSign b| = 1 := by cases b <;> norm_num [boolSign] /-- Walsh character `χ_S(x) = ∏_{i ∈ S} boolSign (x i)`. -/ def walsh (S : Finset ι) (x : ι → Bool) : ℝ := ∏ i ∈ S, boolSign (x i) omit [Fintype ι] [DecidableEq ι] in @[simp] lemma walsh_empty (x : ι → Bool) : walsh (∅ : Finset ι) x = 1 := by simp [walsh] omit [Fintype ι] [DecidableEq ι] in @[simp] lemma walsh_singleton (i : ι) (x : ι → Bool) : walsh ({i} : Finset ι) x = boolSign (x i) := by simp [walsh] omit [Fintype ι] [DecidableEq ι] in lemma walsh_sq (S : Finset ι) (x : ι → Bool) : walsh S x ^ 2 = 1 := by unfold walsh; rw [← Finset.prod_pow]; exact Finset.prod_eq_one fun i _ => boolSign_sq (x i) omit [Fintype ι] [DecidableEq ι] in lemma walsh_mul_self (S : Finset ι) (x : ι → Bool) : walsh S x * walsh S x = 1 := by rw [← sq]; exact walsh_sq S x omit [Fintype ι] [DecidableEq ι] in lemma walsh_abs (S : Finset ι) (x : ι → Bool) : |walsh S x| = 1 := by unfold walsh; rw [Finset.abs_prod]; exact Finset.prod_eq_one fun i _ => boolSign_abs (x i) lemma walsh_mul (S T : Finset ι) (x : ι → Bool) : walsh S x * walsh T x = walsh (symmDiff S T) x := by have hrew : ∀ U : Finset ι, walsh U x = ∏ i : ι, if i ∈ U then boolSign (x i) else 1 := by intro U; unfold walsh rw [Finset.prod_ite, Finset.prod_const_one, mul_one] congr 1; ext i; simp rw [hrew S, hrew T, hrew (symmDiff S T), ← Finset.prod_mul_distrib] refine Finset.prod_congr rfl fun i _ => ?_ by_cases hS : i ∈ S <;> by_cases hT : i ∈ T <;> simp [hS, hT, Finset.mem_symmDiff, boolSign_mul_self] /-- Sum of a single Walsh character over `(ι → Bool)`. -/ lemma sum_walsh (S : Finset ι) : ∑ x : ι → Bool, walsh S x = if S = ∅ then (2 : ℝ) ^ Fintype.card ι else 0 := by have hprod : ∑ x : ι → Bool, walsh S x = ∏ i : ι, ∑ b : Bool, (if i ∈ S then boolSign b else 1) := by rw [Fintype.prod_sum] refine Finset.sum_congr rfl fun x _ => ?_ unfold walsh; rw [Finset.prod_ite, Finset.prod_const_one, mul_one] congr 1; ext i; simp rw [hprod] by_cases hS : S = ∅ · subst hS simp only [Finset.notMem_empty, ↓reduceIte, Finset.sum_const, Finset.card_univ, Fintype.card_bool, nsmul_eq_mul, mul_one, Finset.prod_const] norm_num · simp only [hS, ↓reduceIte] obtain ⟨i₀, hi₀⟩ := Finset.nonempty_iff_ne_empty.mpr hS refine Finset.prod_eq_zero (Finset.mem_univ i₀) ?_ simp [hi₀, boolSign] /-- Orthogonality of Walsh characters. -/ lemma walsh_ortho (S T : Finset ι) : ∑ x : ι → Bool, walsh S x * walsh T x = if S = T then (2 : ℝ) ^ Fintype.card ι else 0 := by simp_rw [walsh_mul, sum_walsh] by_cases h : S = T · subst h; simp · have hne : symmDiff S T ≠ ∅ := fun hemp => h (symmDiff_eq_bot.mp hemp) simp [h, hne] /-- Dual orthogonality over subsets `S : Finset ι`. -/ lemma sum_walsh_subsets (x y : ι → Bool) : ∑ S : Finset ι, walsh S x * walsh S y = if x = y then (2 : ℝ) ^ Fintype.card ι else 0 := by have hprod : ∑ S : Finset ι, walsh S x * walsh S y = ∏ i : ι, (boolSign (x i) * boolSign (y i) + 1) := by rw [Finset.prod_add] simp only [Finset.prod_const_one, mul_one, Finset.powerset_univ] refine Finset.sum_congr rfl fun S _ => ?_ unfold walsh; rw [← Finset.prod_mul_distrib] rw [hprod] by_cases hxy : x = y · subst hxy simp only [↓reduceIte, boolSign_mul_self] norm_num [Finset.prod_const] · simp only [hxy, ↓reduceIte] have hex : ∃ i : ι, x i ≠ y i := by by_contra hall; push Not at hall; exact hxy (funext hall) obtain ⟨i₀, hi₀⟩ := hex refine Finset.prod_eq_zero (Finset.mem_univ i₀) ?_ cases hx : x i₀ <;> cases hy : y i₀ <;> simp_all [boolSign] /-- Fourier–Walsh coefficient `f̂(S)` of `f : (ι → Bool) → ℝ`. -/ noncomputable def fourierCoeff (f : (ι → Bool) → ℝ) (S : Finset ι) : ℝ := (∑ x : ι → Bool, f x * walsh S x) / (2 : ℝ) ^ Fintype.card ι /-- Exact Fourier–Walsh inversion formula: `f x = ∑ S, f̂(S) χ_S(x)`. -/ theorem fourier_expansion (f : (ι → Bool) → ℝ) (x : ι → Bool) : f x = ∑ S : Finset ι, fourierCoeff f S * walsh S x := by have h2pos : (0 : ℝ) < (2 : ℝ) ^ Fintype.card ι := by positivity unfold fourierCoeff simp_rw [div_mul_eq_mul_div, ← Finset.sum_div, Finset.sum_mul] rw [Finset.sum_comm] have hrew : ∑ y : ι → Bool, ∑ S : Finset ι, f y * walsh S y * walsh S x = ∑ y : ι → Bool, f y * ∑ S : Finset ι, walsh S y * walsh S x := by refine Finset.sum_congr rfl fun y _ => ?_ rw [Finset.mul_sum] refine Finset.sum_congr rfl fun S _ => by ring rw [hrew] simp_rw [sum_walsh_subsets] simp [h2pos.ne'] /-- Exact Parseval's identity: `E[f²] = ∑ S, f̂(S)²`. -/ theorem parseval (f : (ι → Bool) → ℝ) : (∑ x : ι → Bool, f x ^ 2) / (2 : ℝ) ^ Fintype.card ι = ∑ S : Finset ι, fourierCoeff f S ^ 2 := by have h2pos : (0 : ℝ) < (2 : ℝ) ^ Fintype.card ι := by positivity have hstep : ∑ x : ι → Bool, f x ^ 2 = (2 : ℝ) ^ Fintype.card ι * ∑ S : Finset ι, fourierCoeff f S ^ 2 := by calc ∑ x : ι → Bool, f x ^ 2 = ∑ x : ι → Bool, (∑ S : Finset ι, fourierCoeff f S * walsh S x) * (∑ T : Finset ι, fourierCoeff f T * walsh T x) := by refine Finset.sum_congr rfl fun x _ => by rw [sq, ← fourier_expansion f x] _ = ∑ x : ι → Bool, ∑ S : Finset ι, ∑ T : Finset ι, fourierCoeff f S * fourierCoeff f T * (walsh S x * walsh T x) := by refine Finset.sum_congr rfl fun x _ => ?_ rw [Finset.sum_mul] refine Finset.sum_congr rfl fun S _ => ?_ rw [Finset.mul_sum] refine Finset.sum_congr rfl fun T _ => by ring _ = ∑ S : Finset ι, ∑ T : Finset ι, fourierCoeff f S * fourierCoeff f T * ∑ x : ι → Bool, walsh S x * walsh T x := by rw [Finset.sum_comm] refine Finset.sum_congr rfl fun S _ => ?_ rw [Finset.sum_comm] refine Finset.sum_congr rfl fun T _ => ?_ rw [Finset.mul_sum] _ = ∑ S : Finset ι, fourierCoeff f S ^ 2 * (2 : ℝ) ^ Fintype.card ι := by refine Finset.sum_congr rfl fun S _ => ?_ simp only [walsh_ortho, mul_ite, mul_zero, Finset.sum_ite_eq, Finset.mem_univ, ↓reduceIte, sq] _ = (2 : ℝ) ^ Fintype.card ι * ∑ S : Finset ι, fourierCoeff f S ^ 2 := by rw [← Finset.sum_mul, mul_comm] rw [hstep, mul_div_cancel_left₀ _ h2pos.ne'] /-- Flip coordinate `i` of a Boolean vector `x : ι → Bool`. -/ def flipBit (x : ι → Bool) (i : ι) : ι → Bool := Function.update x i (!x i) omit [Fintype ι] in @[simp] lemma flipBit_apply_self (x : ι → Bool) (i : ι) : flipBit x i i = !x i := by simp [flipBit] omit [Fintype ι] in @[simp] lemma flipBit_apply_ne (x : ι → Bool) {i j : ι} (h : j ≠ i) : flipBit x i j = x j := by simp [flipBit, h] omit [Fintype ι] in lemma flipBit_involutive (i : ι) : Function.Involutive (fun x : ι → Bool => flipBit x i) := by intro x; ext j; by_cases h : j = i <;> simp [h] /-- Binary symmetric channel transition probability `P(Y = y | X = x)` with crossover `p`. -/ def bsc (p : ℝ) (x y : ι → Bool) : ℝ := ∏ i : ι, if x i = y i then 1 - p else p omit [DecidableEq ι] in lemma bsc_nonneg {p : ℝ} (hp0 : 0 ≤ p) (hp1 : p ≤ 1) (x y : ι → Bool) : 0 ≤ bsc p x y := Finset.prod_nonneg fun i _ => by split_ifs <;> linarith /-- Spectral expansion of the BSC transition kernel in the Walsh basis: `bsc p x y = 2⁻ⁿ ∑_S (1 - 2p)^|S| χ_S(x) χ_S(y)`. -/ lemma bsc_eq_walsh_sum (p : ℝ) (x y : ι → Bool) : bsc p x y = (∑ S : Finset ι, (1 - 2 * p) ^ S.card * (walsh S x * walsh S y)) / (2 : ℝ) ^ Fintype.card ι := by unfold bsc have hfac : ∀ i : ι, (if x i = y i then 1 - p else p) = ((1 - 2 * p) * (boolSign (x i) * boolSign (y i)) + 1) / 2 := by intro i; cases hx : x i <;> cases hy : y i <;> simp [boolSign] <;> ring simp_rw [hfac, Finset.prod_div_distrib, Finset.prod_const, Finset.card_univ] congr 1 rw [Finset.prod_add] simp only [Finset.prod_const_one, mul_one, Finset.powerset_univ] refine Finset.sum_congr rfl fun S _ => ?_ rw [Finset.prod_mul_distrib, Finset.prod_const] unfold walsh rw [Finset.prod_mul_distrib] lemma sum_bsc_left (p : ℝ) (y : ι → Bool) : ∑ x : ι → Bool, bsc p x y = 1 := by simp_rw [bsc_eq_walsh_sum, ← Finset.sum_div] rw [Finset.sum_comm] have hinner : ∀ S : Finset ι, ∑ x : ι → Bool, (1 - 2 * p) ^ S.card * (walsh S x * walsh S y) = if S = ∅ then (2 : ℝ) ^ Fintype.card ι else 0 := by intro S have hrew : ∑ x : ι → Bool, (1 - 2 * p) ^ S.card * (walsh S x * walsh S y) = (1 - 2 * p) ^ S.card * walsh S y * ∑ x : ι → Bool, walsh S x := by rw [Finset.mul_sum]; refine Finset.sum_congr rfl fun x _ => by ring rw [hrew, sum_walsh] by_cases hS : S = ∅ · subst hS; simp · simp [hS] simp_rw [hinner] simp /-- Bonami–Beckner / BSC noise operator `(T_p f)(y) = ∑ x, bsc p x y * f x`. -/ def noiseOp (p : ℝ) (f : (ι → Bool) → ℝ) (y : ι → Bool) : ℝ := ∑ x : ι → Bool, bsc p x y * f x /-- Exact spectral diagonalization of `noiseOp p`: `(T_p f)(y) = ∑_S (1 - 2p)^|S| f̂(S) χ_S(y)`. -/ theorem noiseOp_eq_fourier (p : ℝ) (f : (ι → Bool) → ℝ) (y : ι → Bool) : noiseOp p f y = ∑ S : Finset ι, (1 - 2 * p) ^ S.card * fourierCoeff f S * walsh S y := by unfold noiseOp fourierCoeff have hlhs : ∑ x : ι → Bool, bsc p x y * f x = (∑ x : ι → Bool, ∑ S : Finset ι, (1 - 2 * p) ^ S.card * (walsh S x * walsh S y) * f x) / (2 : ℝ) ^ Fintype.card ι := by simp_rw [bsc_eq_walsh_sum, div_mul_eq_mul_div, ← Finset.sum_div, Finset.sum_mul] rw [hlhs, Finset.sum_comm, Finset.sum_div] refine Finset.sum_congr rfl fun S _ => ?_ have hrew : ∑ x : ι → Bool, (1 - 2 * p) ^ S.card * (walsh S x * walsh S y) * f x = (1 - 2 * p) ^ S.card * (∑ x : ι → Bool, f x * walsh S x) * walsh S y := by rw [Finset.mul_sum, Finset.sum_mul] refine Finset.sum_congr rfl fun x _ => by ring rw [hrew]; ring /-- Fourier coefficients of `noiseOp p f`: `widehat{T_p f}(S) = (1 - 2p)^|S| f̂(S)`. -/ theorem fourierCoeff_noiseOp (p : ℝ) (f : (ι → Bool) → ℝ) (S : Finset ι) : fourierCoeff (noiseOp p f) S = (1 - 2 * p) ^ S.card * fourierCoeff f S := by have h2pos : (0 : ℝ) < (2 : ℝ) ^ Fintype.card ι := by positivity unfold fourierCoeff simp_rw [noiseOp_eq_fourier, Finset.sum_mul] rw [Finset.sum_comm] have hterm : ∀ T : Finset ι, ∑ y : ι → Bool, (1 - 2 * p) ^ T.card * fourierCoeff f T * walsh T y * walsh S y = if T = S then (1 - 2 * p) ^ S.card * fourierCoeff f S * (2 : ℝ) ^ Fintype.card ι else 0 := by intro T have hpull : ∑ y : ι → Bool, (1 - 2 * p) ^ T.card * fourierCoeff f T * walsh T y * walsh S y = (1 - 2 * p) ^ T.card * fourierCoeff f T * ∑ y : ι → Bool, walsh T y * walsh S y := by rw [Finset.mul_sum]; refine Finset.sum_congr rfl fun y _ => by ring rw [hpull, walsh_ortho] by_cases hTS : T = S · subst hTS; simp · simp [hTS] simp_rw [hterm] simp only [Finset.sum_ite_eq', Finset.mem_univ, ↓reduceIte] rw [mul_div_cancel_right₀ _ h2pos.ne'] rfl lemma noiseOp_nonneg {p : ℝ} (hp0 : 0 ≤ p) (hp1 : p ≤ 1) {f : (ι → Bool) → ℝ} (hf : ∀ x, 0 ≤ f x) (y : ι → Bool) : 0 ≤ noiseOp p f y := Finset.sum_nonneg fun x _ => mul_nonneg (bsc_nonneg hp0 hp1 x y) (hf x) lemma noiseOp_le_one {p : ℝ} (hp0 : 0 ≤ p) (hp1 : p ≤ 1) {f : (ι → Bool) → ℝ} (hf : ∀ x, f x ≤ 1) (y : ι → Bool) : noiseOp p f y ≤ 1 := by unfold noiseOp calc ∑ x : ι → Bool, bsc p x y * f x ≤ ∑ x : ι → Bool, bsc p x y * 1 := Finset.sum_le_sum fun x _ => mul_le_mul_of_nonneg_left (hf x) (bsc_nonneg hp0 hp1 x y) _ = 1 := by simp_rw [mul_one]; exact sum_bsc_left p y lemma noiseOp_pos_of_pos {p : ℝ} (hp0 : 0 < p) (hp1 : p < 1) {f : (ι → Bool) → ℝ} (hf_nn : ∀ x, 0 ≤ f x) {x₀ : ι → Bool} (hx₀ : 0 < f x₀) (y : ι → Bool) : 0 < noiseOp p f y := by unfold noiseOp have hbsc : 0 < bsc p x₀ y := Finset.prod_pos fun i _ => by split_ifs <;> linarith have hsingle : bsc p x₀ y * f x₀ ≤ ∑ x : ι → Bool, bsc p x y * f x := Finset.single_le_sum (fun x _ => mul_nonneg (bsc_nonneg hp0.le hp1.le x y) (hf_nn x)) (Finset.mem_univ x₀) exact lt_of_lt_of_le (mul_pos hbsc hx₀) hsingle /-- Indicator function of a subset `A : Finset (ι → Bool)`. -/ def indFun (A : Finset (ι → Bool)) (x : ι → Bool) : ℝ := if x ∈ A then 1 else 0 /-- Normalized density `μ(A) = |A| / 2^|ι|`. -/ noncomputable def setMass (A : Finset (ι → Bool)) : ℝ := (A.card : ℝ) / (2 : ℝ) ^ Fintype.card ι omit [DecidableEq ι] in lemma setMass_nonneg (A : Finset (ι → Bool)) : 0 ≤ setMass A := by unfold setMass; positivity lemma setMass_le_one (A : Finset (ι → Bool)) : setMass A ≤ 1 := by unfold setMass rw [div_le_one (by positivity)] have h : A.card ≤ 2 ^ Fintype.card ι := (Finset.card_le_univ A).trans_eq (by rw [Fintype.card_fun, Fintype.card_bool]) exact_mod_cast h lemma fourierCoeff_indFun_empty (A : Finset (ι → Bool)) : fourierCoeff (indFun A) ∅ = setMass A := by unfold fourierCoeff indFun setMass simp only [walsh_empty, mul_one, ← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul] have hf : Finset.univ.filter (fun x : ι → Bool => x ∈ A) = A := by ext x; simp rw [hf] lemma parseval_indFun (A : Finset (ι → Bool)) : ∑ S : Finset ι, fourierCoeff (indFun A) S ^ 2 = setMass A := by rw [← parseval] unfold indFun setMass have hsq : ∀ x : ι → Bool, (if x ∈ A then (1 : ℝ) else 0) ^ 2 = if x ∈ A then 1 else 0 := by intro x; split_ifs <;> norm_num simp_rw [hsq, ← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul, mul_one] have hf : Finset.univ.filter (fun x : ι → Bool => x ∈ A) = A := by ext x; simp rw [hf] /-- Level-1 Fourier weight `W_1(f) = ∑_{i : ι} f̂({i})²`. -/ noncomputable def level1Weight (f : (ι → Bool) → ℝ) : ℝ := ∑ i : ι, fourierCoeff f {i} ^ 2 /-- Odd-degree Fourier weight `W_odd(f) = ∑_{|S| odd} f̂(S)²`. -/ noncomputable def oddWeight (f : (ι → Bool) → ℝ) : ℝ := ∑ S ∈ Finset.univ.filter (fun S : Finset ι => Odd S.card), fourierCoeff f S ^ 2 lemma level1Weight_nonneg (f : (ι → Bool) → ℝ) : 0 ≤ level1Weight f := Finset.sum_nonneg fun _ _ => sq_nonneg _ lemma level1Weight_le_oddWeight (f : (ι → Bool) → ℝ) : level1Weight f ≤ oddWeight f := by unfold level1Weight oddWeight let emb : ι ↪ Finset ι := ⟨fun i => {i}, Finset.singleton_injective⟩ have hsub : (Finset.univ : Finset ι).map emb ⊆ Finset.univ.filter (fun S : Finset ι => Odd S.card) := by intro S hS rcases Finset.mem_map.mp hS with ⟨i, _, rfl⟩ exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, by simp [emb]⟩ have hmap : ∑ i : ι, fourierCoeff f {i} ^ 2 = ∑ S ∈ (Finset.univ : Finset ι).map emb, fourierCoeff f S ^ 2 := by rw [Finset.sum_map]; rfl rw [hmap] exact Finset.sum_le_sum_of_subset_of_nonneg hsub fun _ _ _ => sq_nonneg _ /-- Preimage cell `Q⁻¹(m)` of a quantizer `Q : (ι → Bool) → α`. -/ def quantCell {α : Type*} [DecidableEq α] (Q : (ι → Bool) → α) (m : α) : Finset (ι → Bool) := Finset.univ.filter fun x => Q x = m /-- Cell mass `μ_m = |Q⁻¹(m)| / 2^|ι|`. -/ noncomputable def cellMass {α : Type*} [DecidableEq α] (Q : (ι → Bool) → α) (m : α) : ℝ := setMass (quantCell Q m) lemma sum_cellMass {α : Type*} [Fintype α] [DecidableEq α] (Q : (ι → Bool) → α) : ∑ m : α, cellMass Q m = 1 := by unfold cellMass setMass quantCell rw [← Finset.sum_div, ← Nat.cast_sum] have hnat : ∑ m : α, (Finset.univ.filter fun x : ι → Bool => Q x = m).card = 2 ^ Fintype.card ι := by rw [← Finset.card_biUnion] · have hu : (Finset.univ : Finset α).biUnion (fun m => Finset.univ.filter fun x : ι → Bool => Q x = m) = Finset.univ := by ext x; simp rw [hu, Finset.card_univ, Fintype.card_fun, Fintype.card_bool] · intro a _ b _ hab change Disjoint _ _ rw [Finset.disjoint_left] intro x hx1 hx2 exact hab ((Finset.mem_filter.mp hx1).2.symm.trans (Finset.mem_filter.mp hx2).2) rw [hnat, Nat.cast_pow, Nat.cast_ofNat, div_self (by positivity)] /-- High-noise mutual-information curvature `Λ(Q) = ∑_{m : μ_m > 0} W_1(1_{A_m}) / μ_m`. -/ noncomputable def curvature {α : Type*} [Fintype α] [DecidableEq α] (Q : (ι → Bool) → α) : ℝ := ∑ m : α, if cellMass Q m = 0 then 0 else level1Weight (indFun (quantCell Q m)) / cellMass Q m /-- Pearson `χ²`-mutual information `I_{χ²}(Q(X); Y)` under `BSC(p)`. -/ noncomputable def chi2MutualInfo {α : Type*} [Fintype α] [DecidableEq α] (Q : (ι → Bool) → α) (p : ℝ) : ℝ := ∑ m : α, if cellMass Q m = 0 then 0 else ((∑ y : ι → Bool, (noiseOp p (indFun (quantCell Q m)) y - cellMass Q m) ^ 2) / (2 : ℝ) ^ Fintype.card ι) / cellMass Q m /-- Exact Fourier–Walsh formula for `I_{χ²}(Q(X); Y)`: `I_{χ²}(Q; p) = ∑_{m : μ_m > 0} (1 / μ_m) ∑_{S ≠ ∅} (1 - 2p)^(2|S|) f̂_m(S)²`. -/ theorem chi2MutualInfo_eq_fourier {α : Type*} [Fintype α] [DecidableEq α] (Q : (ι → Bool) → α) (p : ℝ) : chi2MutualInfo Q p = ∑ m : α, if cellMass Q m = 0 then 0 else (∑ S ∈ (Finset.univ : Finset (Finset ι)).erase ∅, (1 - 2 * p) ^ (2 * S.card) * fourierCoeff (indFun (quantCell Q m)) S ^ 2) / cellMass Q m := by unfold chi2MutualInfo refine Finset.sum_congr rfl fun m _ => ?_ split_ifs with hm · rfl · congr 1 let g : (ι → Bool) → ℝ := fun y => noiseOp p (indFun (quantCell Q m)) y - cellMass Q m have hparse := parseval g have hfc : ∀ S : Finset ι, fourierCoeff g S = if S = ∅ then 0 else (1 - 2 * p) ^ S.card * fourierCoeff (indFun (quantCell Q m)) S := by intro S have hsub : fourierCoeff g S = fourierCoeff (noiseOp p (indFun (quantCell Q m))) S - fourierCoeff (fun _ => cellMass Q m) S := by unfold fourierCoeff g rw [← sub_div, ← Finset.sum_sub_distrib] congr 1; refine Finset.sum_congr rfl fun y _ => by ring have hconst : fourierCoeff (fun _ : ι → Bool => cellMass Q m) S = if S = ∅ then cellMass Q m else 0 := by unfold fourierCoeff rw [← Finset.mul_sum, sum_walsh] by_cases hS : S = ∅ · subst hS; simp [mul_div_cancel_right₀ _ (show (2 : ℝ) ^ Fintype.card ι ≠ 0 by positivity)] · simp [hS] rw [hsub, fourierCoeff_noiseOp, hconst] by_cases hS : S = ∅ · subst hS; simp [cellMass, fourierCoeff_indFun_empty] · simp [hS] rw [show (∑ y : ι → Bool, (noiseOp p (indFun (quantCell Q m)) y - cellMass Q m) ^ 2) / (2 : ℝ) ^ Fintype.card ι = ∑ S : Finset ι, fourierCoeff g S ^ 2 from hparse] rw [← Finset.add_sum_erase _ _ (Finset.mem_univ (∅ : Finset ι)), hfc ∅] simp only [↓reduceIte, zero_pow (by norm_num : 2 ≠ 0), zero_add] refine Finset.sum_congr rfl fun S hS => ?_ have hne : S ≠ ∅ := (Finset.mem_erase.mp hS).1 rw [hfc S, if_neg hne, mul_pow, ← pow_mul, mul_comm S.card 2] /-- Binary Shannon entropy in bits `h₂(p) = (-p ln p - (1 - p) ln(1 - p)) / ln 2`. -/ noncomputable def binEntropyBits (p : ℝ) : ℝ := Real.binEntropy p / Real.log 2 /-- Shannon mutual information `I(Q(X); Y)` in bits under uniform `X` and `BSC(p)`: `I(Q(X); Y) = (1 / ln 2) * ∑_{m : μ_m > 0} E_y[ P(Q=m | Y=y) ln(P(Q=m | Y=y) / μ_m) ]`. -/ noncomputable def shannonMutualInfo {α : Type*} [Fintype α] [DecidableEq α] (Q : (ι → Bool) → α) (p : ℝ) : ℝ := (∑ m : α, if cellMass Q m = 0 then 0 else (∑ y : ι → Bool, noiseOp p (indFun (quantCell Q m)) y * Real.log (noiseOp p (indFun (quantCell Q m)) y / cellMass Q m)) / (2 : ℝ) ^ Fintype.card ι) / Real.log 2 /-- Equivalence with the standard entropy difference `H(Q(X)) - H(Q(X) | Y)` in bits (matching `CourtadeKumar.mutualInfo`). -/ theorem shannonMutualInfo_eq_entropy_sub_condEntropy {α : Type*} [Fintype α] [DecidableEq α] (Q : (ι → Bool) → α) {p : ℝ} (_hp0 : 0 ≤ p) (_hp1 : p ≤ 1) : shannonMutualInfo Q p = ((∑ m : α, Real.negMulLog (cellMass Q m)) - (∑ y : ι → Bool, ∑ m : α, Real.negMulLog (noiseOp p (indFun (quantCell Q m)) y)) / (2 : ℝ) ^ Fintype.card ι) / Real.log 2 := by unfold shannonMutualInfo congr 1 have h2pos : (0 : ℝ) < (2 : ℝ) ^ Fintype.card ι := by positivity rw [Finset.sum_comm, Finset.sum_div, ← Finset.sum_sub_distrib] refine Finset.sum_congr rfl fun m _ => ?_ by_cases hm : cellMass Q m = 0 · rw [if_pos hm, hm, Real.negMulLog_zero, zero_sub] have hempty : quantCell Q m = ∅ := by unfold cellMass setMass at hm have hcard0 : (quantCell Q m).card = 0 := by have h1 : ((quantCell Q m).card : ℝ) = 0 := (div_eq_zero_iff.mp hm).resolve_right h2pos.ne' exact_mod_cast h1 exact Finset.card_eq_zero.mp hcard0 have hzero : ∀ y : ι → Bool, noiseOp p (indFun (quantCell Q m)) y = 0 := by intro y; unfold noiseOp indFun; simp [hempty] simp [hzero] · rw [if_neg hm] have hmass_pos : 0 < cellMass Q m := lt_of_le_of_ne (setMass_nonneg _) (Ne.symm hm) -- `∑_y T_p(1_{A_m})(y) = 2^n * μ_m`: have hsum_T : ∑ y : ι → Bool, noiseOp p (indFun (quantCell Q m)) y = (2 : ℝ) ^ Fintype.card ι * cellMass Q m := by have h0 := fourierCoeff_noiseOp p (indFun (quantCell Q m)) ∅ simp only [Finset.card_empty, pow_zero, one_mul, fourierCoeff_indFun_empty] at h0 unfold fourierCoeff at h0 simp only [walsh_empty, mul_one] at h0 rw [div_eq_iff h2pos.ne'] at h0 unfold cellMass; linarith have hterm : ∀ y : ι → Bool, noiseOp p (indFun (quantCell Q m)) y * Real.log (noiseOp p (indFun (quantCell Q m)) y / cellMass Q m) = -Real.negMulLog (noiseOp p (indFun (quantCell Q m)) y) - noiseOp p (indFun (quantCell Q m)) y * Real.log (cellMass Q m) := by intro y by_cases hy : noiseOp p (indFun (quantCell Q m)) y = 0 · simp [hy] · rw [Real.log_div hy hm, Real.negMulLog]; ring simp_rw [hterm, Finset.sum_sub_distrib, ← Finset.sum_mul, hsum_T] rw [Finset.sum_neg_distrib, sub_div, mul_assoc, mul_div_cancel_left₀ _ h2pos.ne'] rw [Real.negMulLog]; ring /-- Coordinate-relabeling transport of a quantizer along `e : ι₁ ≃ ι₂`. -/ def relabelQuant {ι₁ ι₂ α : Type*} (e : ι₁ ≃ ι₂) (Q : (ι₁ → Bool) → α) : (ι₂ → Bool) → α := fun y => Q (y ∘ e) lemma relabelQuant_cellMass {ι₁ ι₂ α : Type*} [Fintype ι₁] [DecidableEq ι₁] [Fintype ι₂] [DecidableEq ι₂] [DecidableEq α] (e : ι₁ ≃ ι₂) (Q : (ι₁ → Bool) → α) (m : α) : cellMass (relabelQuant e Q) m = cellMass Q m := by unfold cellMass setMass quantCell relabelQuant have hcard : Fintype.card ι₂ = Fintype.card ι₁ := (Fintype.card_congr e).symm rw [hcard]; congr 1 let eFun : (ι₂ → Bool) ≃ (ι₁ → Bool) := Equiv.arrowCongr e.symm (Equiv.refl Bool) have hnat : (Finset.univ.filter fun y : ι₂ → Bool => Q (y ∘ e) = m).card = (Finset.univ.filter fun x : ι₁ → Bool => Q x = m).card := by refine Finset.card_bij (fun y _ => eFun y) ?_ ?_ ?_ · intro y hy have he : eFun y = y ∘ e := by ext i; simp [eFun] rw [he]; exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, (Finset.mem_filter.mp hy).2⟩ · intro y₁ _ y₂ _ h; exact eFun.injective h · intro x hx refine ⟨eFun.symm x, Finset.mem_filter.mpr ⟨Finset.mem_univ _, ?_⟩, eFun.apply_symm_apply x⟩ have he : eFun (eFun.symm x) = (eFun.symm x) ∘ e := by ext i; simp [eFun] rw [← he, eFun.apply_symm_apply] exact (Finset.mem_filter.mp hx).2 exact_mod_cast hnat lemma relabelQuant_fourierCoeff {ι₁ ι₂ α : Type*} [Fintype ι₁] [DecidableEq ι₁] [Fintype ι₂] [DecidableEq ι₂] [DecidableEq α] (e : ι₁ ≃ ι₂) (Q : (ι₁ → Bool) → α) (m : α) (S : Finset ι₂) : fourierCoeff (indFun (quantCell (relabelQuant e Q) m)) S = fourierCoeff (indFun (quantCell Q m)) (S.map e.symm.toEmbedding) := by unfold fourierCoeff indFun quantCell relabelQuant have hcard : Fintype.card ι₂ = Fintype.card ι₁ := (Fintype.card_congr e).symm rw [hcard]; congr 1 let eFun : (ι₂ → Bool) ≃ (ι₁ → Bool) := Equiv.arrowCongr e.symm (Equiv.refl Bool) refine Fintype.sum_equiv eFun _ _ fun y => ?_ have he : eFun y = y ∘ e := by ext i; simp [eFun] rw [he] have hmem : y ∈ Finset.univ.filter (fun z : ι₂ → Bool => Q (z ∘ e) = m) ↔ (y ∘ e) ∈ Finset.univ.filter (fun x : ι₁ → Bool => Q x = m) := by simp have hite : (if y ∈ Finset.univ.filter (fun z : ι₂ → Bool => Q (z ∘ e) = m) then (1 : ℝ) else 0) = (if (y ∘ e) ∈ Finset.univ.filter (fun x : ι₁ → Bool => Q x = m) then (1 : ℝ) else 0) := by by_cases h : Q (y ∘ e) = m <;> simp [h] rw [hite]; congr 1 unfold walsh; rw [Finset.prod_map] refine Finset.prod_congr rfl fun j _ => by simp lemma relabelQuant_curvature {ι₁ ι₂ α : Type*} [Fintype ι₁] [DecidableEq ι₁] [Fintype ι₂] [DecidableEq ι₂] [Fintype α] [DecidableEq α] (e : ι₁ ≃ ι₂) (Q : (ι₁ → Bool) → α) : curvature (relabelQuant e Q) = curvature Q := by unfold curvature refine Finset.sum_congr rfl fun m _ => ?_ rw [relabelQuant_cellMass] split_ifs with hm · rfl · congr 1 unfold level1Weight refine Fintype.sum_equiv e.symm _ _ fun j => ?_ rw [relabelQuant_fourierCoeff] have hs : ({j} : Finset ι₂).map e.symm.toEmbedding = {e.symm j} := by ext i; simp rw [hs] lemma relabelQuant_chi2MutualInfo {ι₁ ι₂ α : Type*} [Fintype ι₁] [DecidableEq ι₁] [Fintype ι₂] [DecidableEq ι₂] [Fintype α] [DecidableEq α] (e : ι₁ ≃ ι₂) (Q : (ι₁ → Bool) → α) (p : ℝ) : chi2MutualInfo (relabelQuant e Q) p = chi2MutualInfo Q p := by rw [chi2MutualInfo_eq_fourier, chi2MutualInfo_eq_fourier] refine Finset.sum_congr rfl fun m _ => ?_ rw [relabelQuant_cellMass] split_ifs with hm · rfl · congr 1 let eSet : Finset ι₂ ≃ Finset ι₁ := { toFun := fun S => S.map e.symm.toEmbedding invFun := fun T => T.map e.toEmbedding left_inv := fun S => by ext j; simp right_inv := fun T => by ext i; simp } refine Finset.sum_bij (fun S _ => eSet S) ?_ ?_ ?_ ?_ · intro S hS refine Finset.mem_erase.mpr ⟨?_, Finset.mem_univ _⟩ intro hemp have h0 : S = ∅ := by have := congrArg eSet.symm hemp simpa [eSet] using this exact (Finset.mem_erase.mp hS).1 h0 · intro S₁ _ S₂ _ h; exact eSet.injective h · intro T hT refine ⟨eSet.symm T, Finset.mem_erase.mpr ⟨?_, Finset.mem_univ _⟩, eSet.apply_symm_apply T⟩ intro hemp have h0 : T = ∅ := by have := congrArg eSet hemp simpa [eSet] using this exact (Finset.mem_erase.mp hT).1 h0 · intro S _ dsimp only [eSet, Equiv.coe_fn_mk] rw [relabelQuant_fourierCoeff, Finset.card_map] lemma relabelQuant_shannonMutualInfo {ι₁ ι₂ α : Type*} [Fintype ι₁] [DecidableEq ι₁] [Fintype ι₂] [DecidableEq ι₂] [Fintype α] [DecidableEq α] (e : ι₁ ≃ ι₂) (Q : (ι₁ → Bool) → α) (p : ℝ) : shannonMutualInfo (relabelQuant e Q) p = shannonMutualInfo Q p := by unfold shannonMutualInfo congr 1 refine Finset.sum_congr rfl fun m _ => ?_ rw [relabelQuant_cellMass] split_ifs with hm · rfl · have hcard : Fintype.card ι₂ = Fintype.card ι₁ := (Fintype.card_congr e).symm rw [hcard]; congr 1 let eFun : (ι₂ → Bool) ≃ (ι₁ → Bool) := Equiv.arrowCongr e.symm (Equiv.refl Bool) refine Fintype.sum_equiv eFun _ _ fun y => ?_ have hnoise : noiseOp p (indFun (quantCell (relabelQuant e Q) m)) y = noiseOp p (indFun (quantCell Q m)) (eFun y) := by unfold noiseOp refine Fintype.sum_equiv eFun _ _ fun x => ?_ have he_x : eFun x = x ∘ e := by ext i; simp [eFun] have he_y : eFun y = y ∘ e := by ext i; simp [eFun] have hbsc : bsc p x y = bsc p (eFun x) (eFun y) := by unfold bsc refine Fintype.prod_equiv e.symm _ _ fun j => ?_ simp [he_x, he_y] have hind : indFun (quantCell (relabelQuant e Q) m) x = indFun (quantCell Q m) (eFun x) := by unfold indFun quantCell relabelQuant rw [he_x]; by_cases h : Q (x ∘ e) = m <;> simp [h] rw [hbsc, hind] rw [hnoise] /-- Relabeling the output alphabet along `e : α ≃ β` preserves all information quantities. -/ lemma comp_equiv_cellMass {α β : Type*} [DecidableEq α] [DecidableEq β] (Q : (ι → Bool) → α) (e : α ≃ β) (b : β) : cellMass (e ∘ Q) b = cellMass Q (e.symm b) := by have hcell : quantCell (e ∘ Q) b = quantCell Q (e.symm b) := by unfold quantCell; ext x; simp [Equiv.apply_eq_iff_eq_symm_apply] unfold cellMass; rw [hcell] lemma comp_equiv_curvature {α β : Type*} [Fintype α] [DecidableEq α] [Fintype β] [DecidableEq β] (Q : (ι → Bool) → α) (e : α ≃ β) : curvature (e ∘ Q) = curvature Q := by unfold curvature refine Fintype.sum_equiv e.symm _ _ fun b => ?_ rw [comp_equiv_cellMass] have hcell : quantCell (e ∘ Q) b = quantCell Q (e.symm b) := by unfold quantCell; ext x; simp [Equiv.apply_eq_iff_eq_symm_apply] rw [hcell] lemma comp_equiv_chi2MutualInfo {α β : Type*} [Fintype α] [DecidableEq α] [Fintype β] [DecidableEq β] (Q : (ι → Bool) → α) (e : α ≃ β) (p : ℝ) : chi2MutualInfo (e ∘ Q) p = chi2MutualInfo Q p := by unfold chi2MutualInfo refine Fintype.sum_equiv e.symm _ _ fun b => ?_ rw [comp_equiv_cellMass] have hcell : quantCell (e ∘ Q) b = quantCell Q (e.symm b) := by unfold quantCell; ext x; simp [Equiv.apply_eq_iff_eq_symm_apply] rw [hcell] lemma comp_equiv_shannonMutualInfo {α β : Type*} [Fintype α] [DecidableEq α] [Fintype β] [DecidableEq β] (Q : (ι → Bool) → α) (e : α ≃ β) (p : ℝ) : shannonMutualInfo (e ∘ Q) p = shannonMutualInfo Q p := by unfold shannonMutualInfo congr 1 refine Fintype.sum_equiv e.symm _ _ fun b => ?_ rw [comp_equiv_cellMass] have hcell : quantCell (e ∘ Q) b = quantCell Q (e.symm b) := by unfold quantCell; ext x; simp [Equiv.apply_eq_iff_eq_symm_apply] rw [hcell] end FourierAndBSC /-! ## Section 2: Sharp Antipodal Odd-Weight Inequality & Complete Subcube Rigidity -/ section AntipodalRigidity variable {ι : Type*} [Fintype ι] [DecidableEq ι] /-- Antipodal involution on the Boolean hypercube: `negVec x i = !x i`. -/ def negVec (x : ι → Bool) : ι → Bool := fun i => !x i omit [Fintype ι] [DecidableEq ι] in lemma negVec_involutive : Function.Involutive (negVec (ι := ι)) := by intro x; ext i; simp [negVec] omit [Fintype ι] [DecidableEq ι] in lemma walsh_negVec (S : Finset ι) (x : ι → Bool) : walsh S (negVec x) = (-1 : ℝ) ^ S.card * walsh S x := by unfold walsh negVec simp_rw [boolSign_not] have hneg : ∀ i : ι, -boolSign (x i) = (-1 : ℝ) * boolSign (x i) := fun i => by ring simp_rw [hneg, Finset.prod_mul_distrib, Finset.prod_const] /-- Exact Fourier coefficient of the odd part `(f x - f (negVec x)) / 2`. -/ lemma fourierCoeff_oddPart (f : (ι → Bool) → ℝ) (S : Finset ι) : fourierCoeff (fun x => (f x - f (negVec x)) / 2) S = if Odd S.card then fourierCoeff f S else 0 := by unfold fourierCoeff have hneg_sum : ∑ x : ι → Bool, f (negVec x) * walsh S x = (-1 : ℝ) ^ S.card * ∑ x : ι → Bool, f x * walsh S x := by have h1 : ∑ x : ι → Bool, f (negVec x) * walsh S x = ∑ x : ι → Bool, f x * walsh S (negVec x) := by refine Fintype.sum_equiv (Equiv.ofBijective negVec negVec_involutive.bijective) _ _ fun x => ?_ have hnn : negVec (negVec x) = x := negVec_involutive x rw [Equiv.ofBijective_apply, hnn] rw [h1, Finset.mul_sum] refine Finset.sum_congr rfl fun x _ => by rw [walsh_negVec]; ring have hnum : ∑ x : ι → Bool, (f x - f (negVec x)) / 2 * walsh S x = ((1 - (-1 : ℝ) ^ S.card) / 2) * ∑ x : ι → Bool, f x * walsh S x := by have h1 : ∑ x : ι → Bool, (f x - f (negVec x)) / 2 * walsh S x = (∑ x : ι → Bool, f x * walsh S x - ∑ x : ι → Bool, f (negVec x) * walsh S x) / 2 := by rw [← Finset.sum_sub_distrib, Finset.sum_div] refine Finset.sum_congr rfl fun x _ => by ring rw [h1, hneg_sum]; ring rw [hnum] by_cases hodd : Odd S.card · rw [if_pos hodd, hodd.neg_one_pow]; ring · rw [if_neg hodd] have heven : Even S.card := Nat.not_odd_iff_even.mp hodd rw [heven.neg_one_pow]; ring /-- **Exact Antipodal Odd-Weight Identity**: `W_odd(1_A) = (1 / 4) * E_x[(1_A(x) - 1_A(negVec x))²] = (μ(A) - μ(A ∩ negVec A)) / 2`. -/ theorem oddWeight_indFun_eq (A : Finset (ι → Bool)) : oddWeight (indFun A) = (∑ x : ι → Bool, (indFun A x - indFun A (negVec x)) ^ 2) / (4 * (2 : ℝ) ^ Fintype.card ι) := by let g : (ι → Bool) → ℝ := fun x => (indFun A x - indFun A (negVec x)) / 2 have hp := parseval g have hfc : ∀ S : Finset ι, fourierCoeff g S ^ 2 = if Odd S.card then fourierCoeff (indFun A) S ^ 2 else 0 := by intro S; rw [fourierCoeff_oddPart]; split_ifs <;> simp simp_rw [hfc] at hp unfold oddWeight rw [Finset.sum_filter, ← hp] have hsq : ∑ x : ι → Bool, g x ^ 2 = (∑ x : ι → Bool, (indFun A x - indFun A (negVec x)) ^ 2) / 4 := by rw [Finset.sum_div]; refine Finset.sum_congr rfl fun x _ => by dsimp only [g]; ring rw [hsq, div_div, mul_comm 4] /-- Exact antipodal-overlap formula for `W_odd(1_A)`. -/ theorem oddWeight_indFun_overlap (A : Finset (ι → Bool)) : oddWeight (indFun A) = (setMass A - setMass (A.filter fun x => negVec x ∈ A)) / 2 := by rw [oddWeight_indFun_eq] have hnum : ∑ x : ι → Bool, (indFun A x - indFun A (negVec x)) ^ 2 = 2 * (A.card : ℝ) - 2 * ((A.filter fun x => negVec x ∈ A).card : ℝ) := by have hpt : ∀ x : ι → Bool, (indFun A x - indFun A (negVec x)) ^ 2 = indFun A x + indFun A (negVec x) - 2 * (if x ∈ A ∧ negVec x ∈ A then (1 : ℝ) else 0) := by intro x; unfold indFun by_cases h1 : x ∈ A <;> by_cases h2 : negVec x ∈ A <;> simp [h1, h2] norm_num simp_rw [hpt, Finset.sum_sub_distrib, Finset.sum_add_distrib, ← Finset.mul_sum] have hs1 : ∑ x : ι → Bool, indFun A x = (A.card : ℝ) := by unfold indFun; rw [← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul, mul_one] have : Finset.univ.filter (fun x => x ∈ A) = A := by ext x; simp rw [this] have hs2 : ∑ x : ι → Bool, indFun A (negVec x) = (A.card : ℝ) := by have heq : ∑ x : ι → Bool, indFun A (negVec x) = ∑ x : ι → Bool, indFun A x := Fintype.sum_equiv (Equiv.ofBijective negVec negVec_involutive.bijective) _ _ fun _ => rfl rw [heq, hs1] have hs3 : ∑ x : ι → Bool, (if x ∈ A ∧ negVec x ∈ A then (1 : ℝ) else 0) = ((A.filter fun x => negVec x ∈ A).card : ℝ) := by rw [← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul, mul_one] have : Finset.univ.filter (fun x : ι → Bool => x ∈ A ∧ negVec x ∈ A) = A.filter fun x => negVec x ∈ A := by ext x; simp rw [this] rw [hs1, hs2, hs3]; ring rw [hnum]; unfold setMass; ring /-- **MAIN THEOREM 1A (Universal Sharp Odd-Weight and Level-1 Ratio Bound)**: For EVERY `A : Finset (ι → Bool)`, `W_1(1_A) ≤ W_odd(1_A) ≤ min (μ(A) / 2) (min ((1 - μ(A)) / 2) (1 / 4))`. -/ theorem oddWeight_le_bounds (A : Finset (ι → Bool)) : oddWeight (indFun A) ≤ setMass A / 2 ∧ oddWeight (indFun A) ≤ (1 - setMass A) / 2 ∧ oddWeight (indFun A) ≤ 1 / 4 := by have h1 : oddWeight (indFun A) ≤ setMass A / 2 := by rw [oddWeight_indFun_overlap] have := setMass_nonneg (A.filter fun x => negVec x ∈ A) linarith have h3 : oddWeight (indFun A) ≤ 1 / 4 := by rw [oddWeight_indFun_eq] have hsum : ∑ x : ι → Bool, (indFun A x - indFun A (negVec x)) ^ 2 ≤ (2 : ℝ) ^ Fintype.card ι := by calc ∑ x : ι → Bool, (indFun A x - indFun A (negVec x)) ^ 2 ≤ ∑ _x : ι → Bool, (1 : ℝ) := by refine Finset.sum_le_sum fun x _ => ?_ unfold indFun; by_cases h1 : x ∈ A <;> by_cases h2 : negVec x ∈ A <;> simp [h1, h2] _ = (2 : ℝ) ^ Fintype.card ι := by rw [Finset.sum_const, Finset.card_univ, Fintype.card_fun, Fintype.card_bool, nsmul_eq_mul, mul_one, Nat.cast_pow, Nat.cast_ofNat] have h2pos : (0 : ℝ) < (2 : ℝ) ^ Fintype.card ι := by positivity rw [div_le_iff₀ (by positivity)] linarith have h2 : oddWeight (indFun A) ≤ (1 - setMass A) / 2 := by have hcompl_eq : oddWeight (indFun Aᶜ) = oddWeight (indFun A) := by rw [oddWeight_indFun_eq, oddWeight_indFun_eq] congr 1 refine Finset.sum_congr rfl fun x _ => ?_ unfold indFun by_cases hx : x ∈ A <;> by_cases hnx : negVec x ∈ A <;> simp [hx, hnx] have hmass_compl : setMass Aᶜ = 1 - setMass A := by unfold setMass have hcard : A.card + Aᶜ.card = 2 ^ Fintype.card ι := by rw [Finset.card_add_card_compl, Fintype.card_fun, Fintype.card_bool] have hcast : (A.card : ℝ) + (Aᶜ.card : ℝ) = (2 : ℝ) ^ Fintype.card ι := by exact_mod_cast hcard have h2pos : (0 : ℝ) < (2 : ℝ) ^ Fintype.card ι := by positivity field_simp [h2pos.ne']; linarith have hc1 : oddWeight (indFun Aᶜ) ≤ setMass Aᶜ / 2 := by rw [oddWeight_indFun_overlap] have := setMass_nonneg (Aᶜ.filter fun x => negVec x ∈ Aᶜ) linarith rw [hcompl_eq, hmass_compl] at hc1 exact hc1 exact ⟨h1, h2, h3⟩ theorem level1Weight_le_half_mass (A : Finset (ι → Bool)) : level1Weight (indFun A) ≤ setMass A / 2 := (level1Weight_le_oddWeight _).trans (oddWeight_le_bounds A).1 /-- A subset `A` is a codimension-1 subcube iff `A = {x | x i = b}` for some `i, b`. -/ def IsCodim1Subcube (A : Finset (ι → Bool)) : Prop := ∃ (i : ι) (b : Bool), A = Finset.univ.filter fun x => x i = b /-- A subset `A` is a codimension-2 subcube iff `A = {x | x i = b₁ ∧ x j = b₂}` for `i ≠ j`. -/ def IsCodim2Subcube (A : Finset (ι → Bool)) : Prop := ∃ (i j : ι) (b₁ b₂ : Bool), i ≠ j ∧ A = Finset.univ.filter fun x => x i = b₁ ∧ x j = b₂ /-- Exact mass and Fourier spectrum of a codimension-1 subcube. -/ lemma codim1Subcube_fourierCoeff (i : ι) (b : Bool) (S : Finset ι) : fourierCoeff (indFun (Finset.univ.filter fun x : ι → Bool => x i = b)) S = if S = ∅ then 1 / 2 else if S = {i} then boolSign b / 2 else 0 := by have hrepr : ∀ x : ι → Bool, indFun (Finset.univ.filter fun y : ι → Bool => y i = b) x = (1 + boolSign b * boolSign (x i)) / 2 := by intro x; unfold indFun; simp only [Finset.mem_filter, Finset.mem_univ, true_and] cases hb : b <;> cases hx : x i <;> norm_num [boolSign] unfold fourierCoeff have h2pos : (0 : ℝ) < (2 : ℝ) ^ Fintype.card ι := by positivity simp_rw [hrepr] have hsplit : ∑ x : ι → Bool, (1 + boolSign b * boolSign (x i)) / 2 * walsh S x = (∑ x : ι → Bool, walsh S x + boolSign b * ∑ x : ι → Bool, walsh {i} x * walsh S x) / 2 := by rw [Finset.mul_sum, ← Finset.sum_add_distrib, Finset.sum_div] refine Finset.sum_congr rfl fun x _ => by simp only [walsh_singleton]; ring rw [hsplit, sum_walsh, walsh_ortho] by_cases hS0 : S = ∅ · subst hS0 have hne : ({i} : Finset ι) ≠ ∅ := Finset.singleton_ne_empty i simp only [↓reduceIte, hne, mul_zero, add_zero] field_simp [h2pos.ne'] · by_cases hSi : S = {i} · subst hSi simp only [hS0, ↓reduceIte, zero_add] field_simp [h2pos.ne'] · have hne' : ({i} : Finset ι) ≠ S := Ne.symm hSi simp [hS0, hSi, hne'] /-- Exact mass and Fourier spectrum of a codimension-2 subcube. -/ lemma codim2Subcube_fourierCoeff {i j : ι} (hij : i ≠ j) (b₁ b₂ : Bool) (S : Finset ι) : fourierCoeff (indFun (Finset.univ.filter fun x : ι → Bool => x i = b₁ ∧ x j = b₂)) S = if S = ∅ then 1 / 4 else if S = {i} then boolSign b₁ / 4 else if S = {j} then boolSign b₂ / 4 else if S = {i, j} then (boolSign b₁ * boolSign b₂) / 4 else 0 := by have hrepr : ∀ x : ι → Bool, indFun (Finset.univ.filter fun y : ι → Bool => y i = b₁ ∧ y j = b₂) x = (1 + boolSign b₁ * boolSign (x i) + boolSign b₂ * boolSign (x j) + (boolSign b₁ * boolSign b₂) * walsh {i, j} x) / 4 := by intro x; unfold indFun; simp only [Finset.mem_filter, Finset.mem_univ, true_and] have hw : walsh ({i, j} : Finset ι) x = boolSign (x i) * boolSign (x j) := by unfold walsh; rw [Finset.prod_pair hij] rw [hw] cases hb1 : b₁ <;> cases hb2 : b₂ <;> cases hxi : x i <;> cases hxj : x j <;> norm_num [boolSign] unfold fourierCoeff have h2pos : (0 : ℝ) < (2 : ℝ) ^ Fintype.card ι := by positivity simp_rw [hrepr] have hsplit : ∑ x : ι → Bool, (1 + boolSign b₁ * boolSign (x i) + boolSign b₂ * boolSign (x j) + (boolSign b₁ * boolSign b₂) * walsh {i, j} x) / 4 * walsh S x = (∑ x : ι → Bool, walsh S x + boolSign b₁ * ∑ x : ι → Bool, walsh {i} x * walsh S x + boolSign b₂ * ∑ x : ι → Bool, walsh {j} x * walsh S x + (boolSign b₁ * boolSign b₂) * ∑ x : ι → Bool, walsh {i, j} x * walsh S x) / 4 := by simp_rw [Finset.mul_sum, ← Finset.sum_add_distrib, Finset.sum_div] refine Finset.sum_congr rfl fun x _ => by simp only [walsh_singleton]; ring rw [hsplit, sum_walsh, walsh_ortho, walsh_ortho, walsh_ortho] have hne_i0 : ({i} : Finset ι) ≠ ∅ := Finset.singleton_ne_empty i have hne_j0 : ({j} : Finset ι) ≠ ∅ := Finset.singleton_ne_empty j have hne_ij0 : ({i, j} : Finset ι) ≠ ∅ := by simp have hne_ij : ({i} : Finset ι) ≠ {j} := fun h => hij (Finset.singleton_injective h) have hne_i_ij : ({i} : Finset ι) ≠ {i, j} := by intro h; have : j ∈ ({i} : Finset ι) := h ▸ by simp exact hij.symm (Finset.mem_singleton.mp this) have hne_j_ij : ({j} : Finset ι) ≠ {i, j} := by intro h; have : i ∈ ({j} : Finset ι) := h ▸ by simp exact hij (Finset.mem_singleton.mp this) by_cases h0 : S = ∅ · subst h0; simp only [↓reduceIte, hne_i0, hne_j0, hne_ij0, mul_zero, add_zero] field_simp [h2pos.ne'] · by_cases hi : S = {i} · subst hi simp only [h0, ↓reduceIte, hne_ij.symm, hne_i_ij.symm, mul_zero, zero_add, add_zero] field_simp [h2pos.ne'] · by_cases hj : S = {j} · subst hj simp only [h0, hi, ↓reduceIte, hne_ij, hne_j_ij.symm, mul_zero, zero_add, add_zero] field_simp [h2pos.ne'] · by_cases hijS : S = {i, j} · subst hijS simp only [h0, hi, hj, ↓reduceIte, hne_i_ij, hne_j_ij, mul_zero, zero_add] field_simp [h2pos.ne'] · simp [h0, hi, hj, hijS, Ne.symm hi, Ne.symm hj, Ne.symm hijS] lemma codim1Subcube_mass (i : ι) (b : Bool) : setMass (Finset.univ.filter fun x : ι → Bool => x i = b) = 1 / 2 := by rw [← fourierCoeff_indFun_empty, codim1Subcube_fourierCoeff]; simp lemma codim2Subcube_mass {i j : ι} (hij : i ≠ j) (b₁ b₂ : Bool) : setMass (Finset.univ.filter fun x : ι → Bool => x i = b₁ ∧ x j = b₂) = 1 / 4 := by rw [← fourierCoeff_indFun_empty, codim2Subcube_fourierCoeff hij]; simp /-- Auxiliary classification of linear functions `L(x) = ∑ i, c i * boolSign (x i)` on `(ι → Bool)` taking values only in `{-1/2, 0, 1/2}` with `max_x L(x) = 1/2`. -/ private lemma linear_three_values_classification (c : ι → ℝ) (hvals : ∀ x : ι → Bool, (∑ i : ι, c i * boolSign (x i)) ∈ ({(-1 / 2 : ℝ), 0, 1 / 2} : Set ℝ)) (hsum_abs : ∑ i : ι, |c i| = 1 / 2) : (∃ i : ι, |c i| = 1 / 2 ∧ ∀ k ≠ i, c k = 0) ∨ (∃ i j : ι, i ≠ j ∧ |c i| = 1 / 4 ∧ |c j| = 1 / 4 ∧ ∀ k, k ≠ i → k ≠ j → c k = 0) := by -- Construct `xstar` attaining `L(xstar) = ∑ |c i| = 1 / 2`! let xstar : ι → Bool := fun i => decide (c i < 0) have hterm_star : ∀ i : ι, c i * boolSign (xstar i) = |c i| := by intro i; dsimp only [xstar] by_cases hneg : c i < 0 · simp [hneg, boolSign, abs_of_neg hneg] · push Not at hneg; simp [not_lt.mpr hneg, boolSign, abs_of_nonneg hneg] -- Flipping any single coordinate `i` from `xstar` gives `1/2 - 2*|c i| ∈ {-1/2, 0, 1/2}`! have hflip_val : ∀ i : ι, (1 / 2 : ℝ) - 2 * |c i| ∈ ({(-1 / 2 : ℝ), 0, 1 / 2} : Set ℝ) := by intro i have hL : ∑ k : ι, c k * boolSign (flipBit xstar i k) = 1 / 2 - 2 * |c i| := by rw [← hsum_abs, ← Finset.add_sum_erase _ _ (Finset.mem_univ i), ← Finset.add_sum_erase _ _ (Finset.mem_univ i)] have hrest : ∑ k ∈ Finset.univ.erase i, c k * boolSign (flipBit xstar i k) = ∑ k ∈ Finset.univ.erase i, |c k| := Finset.sum_congr rfl fun k hk => by rw [flipBit_apply_ne xstar (Finset.mem_erase.mp hk).1, hterm_star k] rw [hrest, flipBit_apply_self, boolSign_not, mul_neg, hterm_star i]; ring rw [← hL]; exact hvals (flipBit xstar i) -- Therefore EVERY `|c i|` lies in `{0, 1/4, 1/2}`!! have hci_quant : ∀ i : ι, |c i| = 0 ∨ |c i| = 1 / 4 ∨ |c i| = 1 / 2 := by intro i have hmem := hflip_val i simp only [Set.mem_insert_iff, Set.mem_singleton_iff] at hmem rcases hmem with h | h | h · right; right; linarith · right; left; linarith · left; linarith -- Case split on whether some `i` has `|c i| = 1/2`! by_cases hex_half : ∃ i : ι, |c i| = 1 / 2 · left obtain ⟨i, hi⟩ := hex_half refine ⟨i, hi, fun k hki => ?_⟩ have hsum_er : ∑ j ∈ Finset.univ.erase i, |c j| = 0 := by have h := Finset.add_sum_erase Finset.univ (fun j => |c j|) (Finset.mem_univ i) linarith have hzero : |c k| = 0 := (Finset.sum_eq_zero_iff_of_nonneg fun j _ => abs_nonneg (c j)).mp hsum_er k (Finset.mem_erase.mpr ⟨hki, Finset.mem_univ k⟩) exact abs_eq_zero.mp hzero · right push Not at hex_half have hci_q : ∀ i : ι, |c i| = 0 ∨ |c i| = 1 / 4 := fun i => match hci_quant i with | Or.inl h => Or.inl h | Or.inr (Or.inl h) => Or.inr h | Or.inr (Or.inr h) => (hex_half i h).elim -- Count how many `i` have `|c i| = 1/4`: sum = 1/2 forces EXACTLY 2 such indices! let supp : Finset ι := Finset.univ.filter fun i => |c i| = 1 / 4 have hsum_supp : ∑ i : ι, |c i| = (supp.card : ℝ) * (1 / 4) := by have h1 : ∀ i : ι, |c i| = if i ∈ supp then (1 / 4 : ℝ) else 0 := by intro i; rcases hci_q i with h | h · rw [h, if_neg]; simp [supp, h] · rw [h, if_pos]; simp [supp, h] simp_rw [h1, ← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul] have hf : Finset.univ.filter (fun i : ι => i ∈ supp) = supp := by ext i; simp rw [hf] have hcard2 : supp.card = 2 := by have : (supp.card : ℝ) = 2 := by linarith exact_mod_cast this obtain ⟨i, j, hij, hpair⟩ := Finset.card_eq_two.mp hcard2 have hi_mem : i ∈ supp := by rw [hpair]; simp have hj_mem : j ∈ supp := by rw [hpair]; simp refine ⟨i, j, hij, (Finset.mem_filter.mp hi_mem).2, (Finset.mem_filter.mp hj_mem).2, fun k hki hkj => ?_⟩ · have hnot : k ∉ supp := by rw [hpair]; simp [hki, hkj] have hne : |c k| ≠ 1 / 4 := fun h => hnot (Finset.mem_filter.mpr ⟨Finset.mem_univ _, h⟩) exact abs_eq_zero.mp ((hci_q k).resolve_right hne) /-- **MAIN THEOREM 1B (Complete Subcube Rigidity of `W_1(1_A) = μ(A) / 2`)**: For EVERY `n` (finite index type `ι`) and EVERY nonempty subset `A : Finset (ι → Bool)`, `W_1(1_A) = μ(A) / 2` holds **if and only if** `A` is a codimension-1 or codimension-2 subcube. -/ theorem level1Weight_eq_half_mass_iff {A : Finset (ι → Bool)} (hA : A.Nonempty) : level1Weight (indFun A) = setMass A / 2 ↔ IsCodim1Subcube A ∨ IsCodim2Subcube A := by constructor · intro heq have h1 := level1Weight_le_oddWeight (indFun A) have h2 := (oddWeight_le_bounds A).1 have hodd_eq_half : oddWeight (indFun A) = setMass A / 2 := le_antisymm h2 (heq ▸ h1) have h1_eq_odd : level1Weight (indFun A) = oddWeight (indFun A) := heq.trans hodd_eq_half.symm -- Step 1: `A` is antipodal-free (`A ∩ negVec A = ∅`)! have hdisj : ∀ x ∈ A, negVec x ∉ A := by have hov := oddWeight_indFun_overlap A have hm0 : setMass (A.filter fun x => negVec x ∈ A) = 0 := by linarith unfold setMass at hm0 have hc0 : (A.filter fun x => negVec x ∈ A).card = 0 := by have h : ((A.filter fun x => negVec x ∈ A).card : ℝ) = 0 := (div_eq_zero_iff.mp hm0).resolve_right (by positivity) exact_mod_cast h have hemp := Finset.card_eq_zero.mp hc0 intro x hx hnx have : x ∈ A.filter (fun y => negVec y ∈ A) := Finset.mem_filter.mpr ⟨hx, hnx⟩ rw [hemp] at this; exact Finset.notMem_empty x this -- Step 2: Every odd Fourier coefficient of degree ≥ 3 vanishes! have hzero_odd : ∀ S : Finset ι, Odd S.card → (∀ i : ι, S ≠ {i}) → fourierCoeff (indFun A) S = 0 := by intro S hodd hne1 let emb : ι ↪ Finset ι := ⟨fun i => {i}, Finset.singleton_injective⟩ let oddSets := Finset.univ.filter (fun T : Finset ι => Odd T.card) let singSets := (Finset.univ : Finset ι).map emb have hsub : singSets ⊆ oddSets := by intro T hT; rcases Finset.mem_map.mp hT with ⟨i, _, rfl⟩ exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, by simp [emb]⟩ have hsdiff : ∑ T ∈ oddSets \ singSets, fourierCoeff (indFun A) T ^ 2 = 0 := by have hsum_s : ∑ T ∈ singSets, fourierCoeff (indFun A) T ^ 2 = level1Weight (indFun A) := by unfold level1Weight; rw [Finset.sum_map]; rfl have hpart := Finset.sum_sdiff hsub (f := fun T => fourierCoeff (indFun A) T ^ 2) unfold oddWeight at h1_eq_odd linarith have hSmem : S ∈ oddSets \ singSets := by refine Finset.mem_sdiff.mpr ⟨Finset.mem_filter.mpr ⟨Finset.mem_univ _, hodd⟩, ?_⟩ intro hmem; rcases Finset.mem_map.mp hmem with ⟨i, _, hi⟩ exact hne1 i hi.symm have hsq0 : fourierCoeff (indFun A) S ^ 2 = 0 := (Finset.sum_eq_zero_iff_of_nonneg fun _ _ => sq_nonneg _).mp hsdiff S hSmem exact sq_eq_zero_iff.mp hsq0 -- Step 3: Therefore the odd part `(1_A(x) - 1_A(negVec x))/2` equals the linear function -- `L(x) = ∑ i, f̂({i}) * boolSign (x i)`! let c : ι → ℝ := fun i => fourierCoeff (indFun A) {i} have hL_eq : ∀ x : ι → Bool, (indFun A x - indFun A (negVec x)) / 2 = ∑ i : ι, c i * boolSign (x i) := by intro x rw [fourier_expansion (fun y => (indFun A y - indFun A (negVec y)) / 2) x] simp_rw [fourierCoeff_oddPart] let emb : ι ↪ Finset ι := ⟨fun i => {i}, Finset.singleton_injective⟩ have hzero_out : ∀ S : Finset ι, S ∉ (Finset.univ : Finset ι).map emb → (if Odd S.card then fourierCoeff (indFun A) S else 0) * walsh S x = 0 := by intro S hS split_ifs with hodd · have hne1 : ∀ i : ι, S ≠ {i} := fun i hi => hS (Finset.mem_map.mpr ⟨i, Finset.mem_univ _, hi.symm⟩) rw [hzero_odd S hodd hne1, zero_mul] · ring rw [← Finset.sum_subset (Finset.subset_univ ((Finset.univ : Finset ι).map emb)) (fun S _ hS => hzero_out S hS), Finset.sum_map] refine Finset.sum_congr rfl fun i _ => ?_ simp [emb, c, walsh_singleton] -- Step 4: `L(x) ∈ {-1/2, 0, 1/2}` for all `x`, and `∑ |c i| = 1/2` (since `A` is nonempty & antipodal-free)! have hvals : ∀ x : ι → Bool, (∑ i : ι, c i * boolSign (x i)) ∈ ({(-1 / 2 : ℝ), 0, 1 / 2} : Set ℝ) := by intro x; rw [← hL_eq x]; unfold indFun by_cases h1 : x ∈ A <;> by_cases h2 : negVec x ∈ A <;> simp [h1, h2] have hsum_abs : ∑ i : ι, |c i| = 1 / 2 := by let xstar : ι → Bool := fun i => decide (c i < 0) have hterm_star : ∀ i : ι, c i * boolSign (xstar i) = |c i| := by intro i; dsimp only [xstar] by_cases hneg : c i < 0 · simp [hneg, boolSign, abs_of_neg hneg] · push Not at hneg; simp [not_lt.mpr hneg, boolSign, abs_of_nonneg hneg] have hle_half : ∑ i : ι, |c i| ≤ 1 / 2 := by have hmem := hvals xstar simp_rw [hterm_star] at hmem simp only [Set.mem_insert_iff, Set.mem_singleton_iff] at hmem rcases hmem with h | h | h <;> linarith obtain ⟨x₀, hx₀⟩ := hA have hge_half : (1 / 2 : ℝ) ≤ ∑ i : ι, |c i| := by have hval0 := hL_eq x₀ have hnx₀ := hdisj x₀ hx₀ unfold indFun at hval0 simp only [hx₀, hnx₀, ↓reduceIte, sub_zero] at hval0 calc (1 / 2 : ℝ) = ∑ i : ι, c i * boolSign (x₀ i) := hval0 _ ≤ ∑ i : ι, |c i * boolSign (x₀ i)| := Finset.sum_le_sum fun i _ => le_abs_self _ _ = ∑ i : ι, |c i| := Finset.sum_congr rfl fun i _ => by rw [abs_mul, boolSign_abs, mul_one] exact le_antisymm hle_half hge_half -- Step 5: Apply `linear_three_values_classification` and recover `A` from `x ∈ A ↔ L(x) = 1/2`! have hmem_iff : ∀ x : ι → Bool, x ∈ A ↔ ∑ i : ι, c i * boolSign (x i) = 1 / 2 := by intro x; rw [← hL_eq x]; unfold indFun constructor · intro hx; have hnx := hdisj x hx; simp [hx, hnx] · intro h; by_contra hnx by_cases h2 : negVec x ∈ A · simp [hnx, h2] at h; norm_num at h · simp [hnx, h2] at h rcases linear_three_values_classification c hvals hsum_abs with ⟨i, hi, hrest⟩ | ⟨i, j, hij, hi, hj, hrest⟩ · left let b : Bool := decide (c i < 0) have hcb : c i = boolSign b * (1 / 2) := by dsimp only [b]; by_cases hneg : c i < 0 · simp [hneg, boolSign]; linarith [abs_of_neg hneg] · push Not at hneg; simp [not_lt.mpr hneg, boolSign]; linarith [abs_of_nonneg hneg] refine ⟨i, b, ?_⟩ ext x; simp only [hmem_iff x, Finset.mem_filter, Finset.mem_univ, true_and] rw [← Finset.add_sum_erase _ _ (Finset.mem_univ i)] have hsum0 : ∑ k ∈ Finset.univ.erase i, c k * boolSign (x k) = 0 := Finset.sum_eq_zero fun k hk => by rw [hrest k (Finset.mem_erase.mp hk).1, zero_mul] rw [hsum0, add_zero, hcb] cases hb : b <;> cases hx : x i <;> simp [boolSign] <;> norm_num · right let b₁ : Bool := decide (c i < 0) let b₂ : Bool := decide (c j < 0) have hci : c i = boolSign b₁ * (1 / 4) := by dsimp only [b₁]; by_cases hneg : c i < 0 · simp [hneg, boolSign]; linarith [abs_of_neg hneg] · push Not at hneg; simp [not_lt.mpr hneg, boolSign]; linarith [abs_of_nonneg hneg] have hcj : c j = boolSign b₂ * (1 / 4) := by dsimp only [b₂]; by_cases hneg : c j < 0 · simp [hneg, boolSign]; linarith [abs_of_neg hneg] · push Not at hneg; simp [not_lt.mpr hneg, boolSign]; linarith [abs_of_nonneg hneg] refine ⟨i, j, b₁, b₂, hij, ?_⟩ ext x; simp only [hmem_iff x, Finset.mem_filter, Finset.mem_univ, true_and] have hsum_ij : ∑ k : ι, c k * boolSign (x k) = c i * boolSign (x i) + c j * boolSign (x j) := by rw [← Finset.add_sum_erase _ _ (Finset.mem_univ i), ← Finset.add_sum_erase _ _ (Finset.mem_erase.mpr ⟨hij.symm, Finset.mem_univ j⟩)] have h0 : ∑ k ∈ (Finset.univ.erase i).erase j, c k * boolSign (x k) = 0 := Finset.sum_eq_zero fun k hk => by have hkj := (Finset.mem_erase.mp hk).1 have hki := (Finset.mem_erase.mp (Finset.mem_erase.mp hk).2).1 rw [hrest k hki hkj, zero_mul] rw [h0, add_zero] rw [hsum_ij, hci, hcj] cases hb1 : b₁ <;> cases hb2 : b₂ <;> cases hxi : x i <;> cases hxj : x j <;> simp [boolSign] <;> norm_num · rintro (⟨i, b, rfl⟩ | ⟨i, j, b₁, b₂, hij, rfl⟩) · rw [codim1Subcube_mass] unfold level1Weight rw [← Finset.add_sum_erase _ _ (Finset.mem_univ i)] have h0 : ∑ k ∈ Finset.univ.erase i, fourierCoeff (indFun (Finset.univ.filter fun x : ι → Bool => x i = b)) {k} ^ 2 = 0 := by refine Finset.sum_eq_zero fun k hk => ?_ have hki : k ≠ i := (Finset.mem_erase.mp hk).1 rw [codim1Subcube_fourierCoeff] have hne0 : ({k} : Finset ι) ≠ ∅ := Finset.singleton_ne_empty k have hnei : ({k} : Finset ι) ≠ {i} := fun h => hki (Finset.singleton_injective h) simp [hne0, hnei] rw [h0, add_zero, codim1Subcube_fourierCoeff] have hne0 : ({i} : Finset ι) ≠ ∅ := Finset.singleton_ne_empty i simp only [hne0, ↓reduceIte, div_pow, boolSign_sq]; norm_num · rw [codim2Subcube_mass hij] unfold level1Weight rw [← Finset.add_sum_erase _ _ (Finset.mem_univ i), ← Finset.add_sum_erase _ _ (Finset.mem_erase.mpr ⟨hij.symm, Finset.mem_univ j⟩)] have h0 : ∑ k ∈ (Finset.univ.erase i).erase j, fourierCoeff (indFun (Finset.univ.filter fun x : ι → Bool => x i = b₁ ∧ x j = b₂)) {k} ^ 2 = 0 := by refine Finset.sum_eq_zero fun k hk => ?_ have hkj := (Finset.mem_erase.mp hk).1 have hki := (Finset.mem_erase.mp (Finset.mem_erase.mp hk).2).1 rw [codim2Subcube_fourierCoeff hij] have hne0 : ({k} : Finset ι) ≠ ∅ := Finset.singleton_ne_empty k have hnei : ({k} : Finset ι) ≠ {i} := fun h => hki (Finset.singleton_injective h) have hnej : ({k} : Finset ι) ≠ {j} := fun h => hkj (Finset.singleton_injective h) have hneij : ({k} : Finset ι) ≠ {i, j} := by intro h; have : i ∈ ({k} : Finset ι) := h ▸ by simp exact hki (Finset.mem_singleton.mp this).symm simp [hne0, hnei, hnej, hneij] rw [h0, add_zero, codim2Subcube_fourierCoeff hij, codim2Subcube_fourierCoeff hij] have hne_i0 : ({i} : Finset ι) ≠ ∅ := Finset.singleton_ne_empty i have hne_j0 : ({j} : Finset ι) ≠ ∅ := Finset.singleton_ne_empty j have hne_ji : ({j} : Finset ι) ≠ {i} := fun h => hij.symm (Finset.singleton_injective h) simp only [hne_i0, hne_j0, hne_ji, ↓reduceIte, div_pow, boolSign_sq]; norm_num end AntipodalRigidity /-! ## Section 3: Exact Universal $\chi^2$-Courtade–Kumar Theorem ($M \in \{2, 3, 4\}$ Sharp with Rigidity) -/ section Chi2CourtadeKumar variable {ι : Type*} [Fintype ι] [DecidableEq ι] /-- Single-cell `χ²` contribution bound: for every subset `A : Finset (ι → Bool)` and `ε ∈ [-1, 1]`, `∑_{S ≠ ∅} ε^(2|S|) f̂(S)² ≤ ε⁴ μ(1 - μ) + (ε² - ε⁴) W_odd(1_A)`. -/ lemma single_cell_chi2_le (A : Finset (ι → Bool)) {ε : ℝ} (hε : ε ^ 2 ≤ 1) : ∑ S ∈ (Finset.univ : Finset (Finset ι)).erase ∅, ε ^ (2 * S.card) * fourierCoeff (indFun A) S ^ 2 ≤ ε ^ 4 * (setMass A * (1 - setMass A)) + (ε ^ 2 - ε ^ 4) * oddWeight (indFun A) := by have hε2_nn : 0 ≤ ε ^ 2 := sq_nonneg ε -- Split `univ.erase ∅` into `Odd S.card` and `Even S.card` (with `S ≠ ∅`, so `2 ≤ S.card`): have hterm : ∀ S ∈ (Finset.univ : Finset (Finset ι)).erase ∅, ε ^ (2 * S.card) * fourierCoeff (indFun A) S ^ 2 ≤ (if Odd S.card then ε ^ 2 else ε ^ 4) * fourierCoeff (indFun A) S ^ 2 := by intro S hS have hne : S ≠ ∅ := (Finset.mem_erase.mp hS).1 have hpos : 1 ≤ S.card := Finset.card_pos.mpr (Finset.nonempty_iff_ne_empty.mpr hne) refine mul_le_mul_of_nonneg_right ?_ (sq_nonneg _) rw [pow_mul] by_cases hodd : Odd S.card · rw [if_pos hodd] exact pow_le_of_le_one hε2_nn hε (by omega) · rw [if_neg hodd] have heven : Even S.card := Nat.not_odd_iff_even.mp hodd have hge2 : 2 ≤ S.card := by rcases heven with ⟨k, hk⟩; omega calc (ε ^ 2) ^ S.card ≤ (ε ^ 2) ^ 2 := pow_le_pow_of_le_one hε2_nn hε hge2 _ = ε ^ 4 := by ring calc ∑ S ∈ (Finset.univ : Finset (Finset ι)).erase ∅, ε ^ (2 * S.card) * fourierCoeff (indFun A) S ^ 2 ≤ ∑ S ∈ (Finset.univ : Finset (Finset ι)).erase ∅, (if Odd S.card then ε ^ 2 else ε ^ 4) * fourierCoeff (indFun A) S ^ 2 := Finset.sum_le_sum hterm _ = ε ^ 4 * ∑ S ∈ (Finset.univ : Finset (Finset ι)).erase ∅, fourierCoeff (indFun A) S ^ 2 + (ε ^ 2 - ε ^ 4) * oddWeight (indFun A) := by have hrew : ∀ S ∈ (Finset.univ : Finset (Finset ι)).erase ∅, (if Odd S.card then ε ^ 2 else ε ^ 4) * fourierCoeff (indFun A) S ^ 2 = ε ^ 4 * fourierCoeff (indFun A) S ^ 2 + (ε ^ 2 - ε ^ 4) * (if Odd S.card then fourierCoeff (indFun A) S ^ 2 else 0) := by intro S _ by_cases h : Odd S.card · simp [h]; ring · simp [h] rw [Finset.sum_congr rfl hrew, Finset.sum_add_distrib, ← Finset.mul_sum, ← Finset.mul_sum] congr 2 unfold oddWeight rw [Finset.sum_filter, ← Finset.add_sum_erase _ _ (Finset.mem_univ (∅ : Finset ι))] simp _ = ε ^ 4 * (setMass A * (1 - setMass A)) + (ε ^ 2 - ε ^ 4) * oddWeight (indFun A) := by have hvar : ∑ S ∈ (Finset.univ : Finset (Finset ι)).erase ∅, fourierCoeff (indFun A) S ^ 2 = setMass A * (1 - setMass A) := by have hp := parseval_indFun A rw [← Finset.add_sum_erase _ _ (Finset.mem_univ (∅ : Finset ι)), fourierCoeff_indFun_empty] at hp linarith rw [hvar] /-- **MAIN THEOREM 2 (Universal Sharp $\chi^2$-Courtade–Kumar Bound for All $M$-ary Quantizers)**: For EVERY `n`, EVERY `M : ℕ`, EVERY quantizer `Q : (ι → Bool) → Fin M` (without ANY balance assumption!), and EVERY `p ∈ [0, 1]` (`ε = 1 - 2p`): `I_{χ²}(Q; p) ≤ (M / 2) * ε² + (M / 2 - 1) * ε⁴`. -/ theorem chi2MutualInfo_le_universal {M : ℕ} (Q : (ι → Bool) → Fin M) {p : ℝ} (hp0 : 0 ≤ p) (hp1 : p ≤ 1) : let ε : ℝ := 1 - 2 * p chi2MutualInfo Q p ≤ (M : ℝ) / 2 * ε ^ 2 + ((M : ℝ) / 2 - 1) * ε ^ 4 := by intro ε have hε : ε ^ 2 ≤ 1 := by have h1 : -1 ≤ ε := by dsimp only [ε]; linarith have h2 : ε ≤ 1 := by dsimp only [ε]; linarith nlinarith have hε_diff : 0 ≤ ε ^ 2 - ε ^ 4 := by nlinarith [sq_nonneg ε] rw [chi2MutualInfo_eq_fourier] have hcell : ∀ m : Fin M, (if cellMass Q m = 0 then 0 else (∑ S ∈ (Finset.univ : Finset (Finset ι)).erase ∅, ε ^ (2 * S.card) * fourierCoeff (indFun (quantCell Q m)) S ^ 2) / cellMass Q m) ≤ (1 / 2 : ℝ) * ε ^ 2 + (1 / 2 - cellMass Q m) * ε ^ 4 := by intro m by_cases hm : cellMass Q m = 0 · rw [if_pos hm, hm]; nlinarith [sq_nonneg ε] · rw [if_neg hm] have hm_pos : 0 < cellMass Q m := lt_of_le_of_ne (setMass_nonneg _) (Ne.symm hm) rw [div_le_iff₀ hm_pos] have hsc := single_cell_chi2_le (quantCell Q m) hε have hodd := (oddWeight_le_bounds (quantCell Q m)).1 have hmul : (ε ^ 2 - ε ^ 4) * oddWeight (indFun (quantCell Q m)) ≤ (ε ^ 2 - ε ^ 4) * (cellMass Q m / 2) := mul_le_mul_of_nonneg_left hodd hε_diff unfold cellMass at * linarith calc ∑ m : Fin M, (if cellMass Q m = 0 then 0 else (∑ S ∈ (Finset.univ : Finset (Finset ι)).erase ∅, ε ^ (2 * S.card) * fourierCoeff (indFun (quantCell Q m)) S ^ 2) / cellMass Q m) ≤ ∑ m : Fin M, ((1 / 2 : ℝ) * ε ^ 2 + (1 / 2 - cellMass Q m) * ε ^ 4) := Finset.sum_le_sum fun m _ => hcell m _ = (M : ℝ) / 2 * ε ^ 2 + ((M : ℝ) / 2 - 1) * ε ^ 4 := by simp_rw [Finset.sum_add_distrib, sub_mul, Finset.sum_sub_distrib, ← Finset.sum_mul, sum_cellMass, Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] ring /-- **MAIN COROLLARY 2A (Exact 1-Bit $\chi^2$-Courtade–Kumar)**: For every `Q : (ι → Bool) → Fin 2` and every `p ∈ [0, 1]`, `I_{χ²}(Q; p) ≤ (1 - 2p)²`. -/ theorem chi2_courtade_kumar_one_bit (Q : (ι → Bool) → Fin 2) {p : ℝ} (hp0 : 0 ≤ p) (hp1 : p ≤ 1) : chi2MutualInfo Q p ≤ (1 - 2 * p) ^ 2 := by have h := chi2MutualInfo_le_universal Q hp0 hp1 norm_num at h linarith /-- **MAIN COROLLARY 2B (Exact Ternary $\chi^2$-Courtade–Kumar)**: For every ternary quantizer `Q : (ι → Bool) → Fin 3` and every `p ∈ [0, 1]`, `I_{χ²}(Q; p) ≤ (3/2)(1 - 2p)² + (1/2)(1 - 2p)⁴`. -/ theorem chi2_courtade_kumar_ternary (Q : (ι → Bool) → Fin 3) {p : ℝ} (hp0 : 0 ≤ p) (hp1 : p ≤ 1) : chi2MutualInfo Q p ≤ (3 / 2 : ℝ) * (1 - 2 * p) ^ 2 + (1 / 2 : ℝ) * (1 - 2 * p) ^ 4 := by have h := chi2MutualInfo_le_universal Q hp0 hp1 norm_num at h linarith /-- **MAIN COROLLARY 2C (Exact 2-Bit $\chi^2$-Courtade–Kumar — ALL `p ∈ [0, 1]`, NO balance assumption)**: For every 2-bit quantizer `Q : (ι → Bool) → Fin 4` and every `p ∈ [0, 1]`, `I_{χ²}(Q; p) ≤ (1 + (1 - 2p)²)² - 1 = 2(1 - 2p)² + (1 - 2p)⁴`. -/ theorem chi2_courtade_kumar_two_bit (Q : (ι → Bool) → Fin 4) {p : ℝ} (hp0 : 0 ≤ p) (hp1 : p ≤ 1) : chi2MutualInfo Q p ≤ (1 + (1 - 2 * p) ^ 2) ^ 2 - 1 := by have h := chi2MutualInfo_le_universal Q hp0 hp1 norm_num at h linarith /-- Universal high-noise curvature bound: `Λ(Q) ≤ M / 2` for every `M`-ary quantizer `Q`. -/ theorem curvature_le_half_card {M : ℕ} (Q : (ι → Bool) → Fin M) : curvature Q ≤ (M : ℝ) / 2 := by unfold curvature calc ∑ m : Fin M, (if cellMass Q m = 0 then 0 else level1Weight (indFun (quantCell Q m)) / cellMass Q m) ≤ ∑ _m : Fin M, (1 / 2 : ℝ) := by refine Finset.sum_le_sum fun m _ => ?_ split_ifs with hm · norm_num · have hm_pos : 0 < cellMass Q m := lt_of_le_of_ne (setMass_nonneg _) (Ne.symm hm) rw [div_le_iff₀ hm_pos] have h := level1Weight_le_half_mass (quantCell Q m) unfold cellMass; linarith _ = (M : ℝ) / 2 := by rw [Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul]; ring /-- **EXACT RIGIDITY OF 2-BIT CURVATURE (`Λ(Q) = 2`)**: For EVERY `Q : (ι → Bool) → Fin 4`, `Λ(Q) = 2` holds **if and only if** every one of the 4 cells `Q⁻¹(m)` is a codimension-2 subcube! -/ theorem curvature_two_bit_eq_two_iff (Q : (ι → Bool) → Fin 4) : curvature Q = 2 ↔ ∀ m : Fin 4, IsCodim2Subcube (quantCell Q m) := by constructor · intro hcurv -- Every single term in `curvature Q = ∑_{m : Fin 4} term m` is `≤ 1/2`, and their sum is `2`, -- so EVERY term equals `1/2`! have hle : ∀ m : Fin 4, (if cellMass Q m = 0 then 0 else level1Weight (indFun (quantCell Q m)) / cellMass Q m) ≤ (1 / 2 : ℝ) := fun m => by split_ifs with hm · norm_num · have hm_pos : 0 < cellMass Q m := lt_of_le_of_ne (setMass_nonneg _) (Ne.symm hm) rw [div_le_iff₀ hm_pos] have := level1Weight_le_half_mass (quantCell Q m); unfold cellMass; linarith have hall_eq : ∀ m : Fin 4, (if cellMass Q m = 0 then 0 else level1Weight (indFun (quantCell Q m)) / cellMass Q m) = (1 / 2 : ℝ) := by have hsum_eq : ∑ m : Fin 4, ((1 / 2 : ℝ) - if cellMass Q m = 0 then 0 else level1Weight (indFun (quantCell Q m)) / cellMass Q m) = 0 := by rw [Finset.sum_sub_distrib, Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] unfold curvature at hcurv; norm_num at *; linarith intro m have h0 := (Finset.sum_eq_zero_iff_of_nonneg fun k _ => sub_nonneg.mpr (hle k)).mp hsum_eq m (Finset.mem_univ m) linarith -- Therefore EVERY cell is nonempty and satisfies `W_1(1_{A_m}) = μ_m / 2`, so it is codim-1 or codim-2! have hsub12 : ∀ m : Fin 4, IsCodim1Subcube (quantCell Q m) ∨ IsCodim2Subcube (quantCell Q m) := by intro m have hm_eq := hall_eq m have hm_ne0 : cellMass Q m ≠ 0 := by intro h0; rw [if_pos h0] at hm_eq; norm_num at hm_eq rw [if_neg hm_ne0] at hm_eq have hne : (quantCell Q m).Nonempty := by by_contra hemp; rw [Finset.not_nonempty_iff_eq_empty] at hemp apply hm_ne0; unfold cellMass setMass; simp [hemp] have hw1 : level1Weight (indFun (quantCell Q m)) = setMass (quantCell Q m) / 2 := by have hm_pos : 0 < cellMass Q m := lt_of_le_of_ne (setMass_nonneg _) (Ne.symm hm_ne0) unfold cellMass at hm_eq hm_pos; rw [div_eq_iff hm_pos.ne'] at hm_eq; linarith exact (level1Weight_eq_half_mass_iff hne).mp hw1 -- Since all 4 cells have mass in `{1/2, 1/4}` and their 4 masses sum to `1`, ALL FOUR must have mass `1/4`! have hmass_ge : ∀ m : Fin 4, (1 / 4 : ℝ) ≤ cellMass Q m := fun m => by rcases hsub12 m with ⟨i, b, heq⟩ | ⟨i, j, b₁, b₂, hij, heq⟩ · unfold cellMass; rw [heq, codim1Subcube_mass]; norm_num · unfold cellMass; rw [heq, codim2Subcube_mass hij] intro m rcases hsub12 m with ⟨i, b, heq⟩ | h2 · exfalso have hm_half : cellMass Q m = 1 / 2 := by unfold cellMass; rw [heq, codim1Subcube_mass] have htot := sum_cellMass Q rw [← Finset.add_sum_erase _ _ (Finset.mem_univ m)] at htot have her : (3 / 4 : ℝ) ≤ ∑ k ∈ (Finset.univ : Finset (Fin 4)).erase m, cellMass Q k := by calc (3 / 4 : ℝ) = ∑ _k ∈ (Finset.univ : Finset (Fin 4)).erase m, (1 / 4 : ℝ) := by rw [Finset.sum_const, Finset.card_erase_of_mem (Finset.mem_univ m), Finset.card_univ, Fintype.card_fin, nsmul_eq_mul]; norm_num _ ≤ ∑ k ∈ (Finset.univ : Finset (Fin 4)).erase m, cellMass Q k := Finset.sum_le_sum fun k _ => hmass_ge k linarith · exact h2 · intro hall unfold curvature have hterm : ∀ m : Fin 4, (if cellMass Q m = 0 then 0 else level1Weight (indFun (quantCell Q m)) / cellMass Q m) = (1 / 2 : ℝ) := by intro m rcases hall m with ⟨i, j, b₁, b₂, hij, heq⟩ have hm : cellMass Q m = 1 / 4 := by unfold cellMass; rw [heq, codim2Subcube_mass hij] have hne : (quantCell Q m).Nonempty := by by_contra hemp; rw [Finset.not_nonempty_iff_eq_empty] at hemp unfold cellMass setMass at hm; simp [hemp] at hm have hw1 : level1Weight (indFun (quantCell Q m)) = setMass (quantCell Q m) / 2 := (level1Weight_eq_half_mass_iff hne).mpr (Or.inr ⟨i, j, b₁, b₂, hij, heq⟩) rw [if_neg (by rw [hm]; norm_num : cellMass Q m ≠ 0)] unfold cellMass at *; rw [hw1, hm]; norm_num simp_rw [hterm, Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul]; norm_num /-- **EXACT RIGIDITY OF TERNARY CURVATURE (`Λ(Q) = 3 / 2`)**: For EVERY `Q : (ι → Bool) → Fin 3`, `Λ(Q) = 3/2` holds **if and only if** `Q` is an **unbalanced** ternary subcube partition: one cell is a codimension-1 subcube (`μ = 1/2`) and the other two cells are codimension-2 subcubes (`μ = 1/4, 1/4`). -/ theorem curvature_ternary_eq_three_halves_iff (Q : (ι → Bool) → Fin 3) : curvature Q = 3 / 2 ↔ ∃ m₀ : Fin 3, IsCodim1Subcube (quantCell Q m₀) ∧ ∀ m : Fin 3, m ≠ m₀ → IsCodim2Subcube (quantCell Q m) := by constructor · intro hcurv have hle : ∀ m : Fin 3, (if cellMass Q m = 0 then 0 else level1Weight (indFun (quantCell Q m)) / cellMass Q m) ≤ (1 / 2 : ℝ) := fun m => by split_ifs with hm · norm_num · have hm_pos : 0 < cellMass Q m := lt_of_le_of_ne (setMass_nonneg _) (Ne.symm hm) rw [div_le_iff₀ hm_pos] have := level1Weight_le_half_mass (quantCell Q m); unfold cellMass; linarith have hall_eq : ∀ m : Fin 3, (if cellMass Q m = 0 then 0 else level1Weight (indFun (quantCell Q m)) / cellMass Q m) = (1 / 2 : ℝ) := by have hsum_eq : ∑ m : Fin 3, ((1 / 2 : ℝ) - if cellMass Q m = 0 then 0 else level1Weight (indFun (quantCell Q m)) / cellMass Q m) = 0 := by rw [Finset.sum_sub_distrib, Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] unfold curvature at hcurv; norm_num at *; linarith intro m have h0 := (Finset.sum_eq_zero_iff_of_nonneg fun k _ => sub_nonneg.mpr (hle k)).mp hsum_eq m (Finset.mem_univ m) linarith have hsub12 : ∀ m : Fin 3, IsCodim1Subcube (quantCell Q m) ∨ IsCodim2Subcube (quantCell Q m) := by intro m have hm_eq := hall_eq m have hm_ne0 : cellMass Q m ≠ 0 := by intro h0; rw [if_pos h0] at hm_eq; norm_num at hm_eq rw [if_neg hm_ne0] at hm_eq have hne : (quantCell Q m).Nonempty := by by_contra hemp; rw [Finset.not_nonempty_iff_eq_empty] at hemp apply hm_ne0; unfold cellMass setMass; simp [hemp] have hw1 : level1Weight (indFun (quantCell Q m)) = setMass (quantCell Q m) / 2 := by have hm_pos : 0 < cellMass Q m := lt_of_le_of_ne (setMass_nonneg _) (Ne.symm hm_ne0) unfold cellMass at hm_eq hm_pos; rw [div_eq_iff hm_pos.ne'] at hm_eq; linarith exact (level1Weight_eq_half_mass_iff hne).mp hw1 -- Masses of the 3 cells are each `1/2` or `1/4` and sum to `1`, so EXACTLY ONE is `1/2` and TWO are `1/4`! have hmass_val : ∀ m : Fin 3, (IsCodim1Subcube (quantCell Q m) → cellMass Q m = 1 / 2) ∧ (IsCodim2Subcube (quantCell Q m) → cellMass Q m = 1 / 4) := fun m => ⟨fun ⟨i, b, h⟩ => by unfold cellMass; rw [h, codim1Subcube_mass], fun ⟨i, j, b₁, b₂, hij, h⟩ => by unfold cellMass; rw [h, codim2Subcube_mass hij]⟩ have htot := sum_cellMass Q rw [Fin.sum_univ_three] at htot rcases hsub12 0 with h0 | h0 <;> rcases hsub12 1 with h1 | h1 <;> rcases hsub12 2 with h2 | h2 · linarith [(hmass_val 0).1 h0, (hmass_val 1).1 h1, (hmass_val 2).1 h2] · linarith [(hmass_val 0).1 h0, (hmass_val 1).1 h1, (hmass_val 2).2 h2] · linarith [(hmass_val 0).1 h0, (hmass_val 1).2 h1, (hmass_val 2).1 h2] · exact ⟨0, h0, fun m hm => by fin_cases m <;> [exact (hm rfl).elim; exact h1; exact h2]⟩ · linarith [(hmass_val 0).2 h0, (hmass_val 1).1 h1, (hmass_val 2).1 h2] · exact ⟨1, h1, fun m hm => by fin_cases m <;> [exact h0; exact (hm rfl).elim; exact h2]⟩ · exact ⟨2, h2, fun m hm => by fin_cases m <;> [exact h0; exact h1; exact (hm rfl).elim]⟩ · linarith [(hmass_val 0).2 h0, (hmass_val 1).2 h1, (hmass_val 2).2 h2] · rintro ⟨m₀, h1, h2⟩ unfold curvature have hterm : ∀ m : Fin 3, (if cellMass Q m = 0 then 0 else level1Weight (indFun (quantCell Q m)) / cellMass Q m) = (1 / 2 : ℝ) := by intro m have h12 : IsCodim1Subcube (quantCell Q m) ∨ IsCodim2Subcube (quantCell Q m) := by by_cases hm : m = m₀ · subst hm; exact Or.inl h1 · exact Or.inr (h2 m hm) have hm_pos : 0 < cellMass Q m := by rcases h12 with ⟨i, b, heq⟩ | ⟨i, j, b₁, b₂, hij, heq⟩ · unfold cellMass; rw [heq, codim1Subcube_mass]; norm_num · unfold cellMass; rw [heq, codim2Subcube_mass hij]; norm_num have hne : (quantCell Q m).Nonempty := by by_contra hemp; rw [Finset.not_nonempty_iff_eq_empty] at hemp unfold cellMass setMass at hm_pos; simp [hemp] at hm_pos have hw1 : level1Weight (indFun (quantCell Q m)) = setMass (quantCell Q m) / 2 := (level1Weight_eq_half_mass_iff hne).mpr h12 rw [if_neg hm_pos.ne']; unfold cellMass at *; rw [hw1]; field_simp [hm_pos.ne'] simp_rw [hterm, Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul]; norm_num /-- **EXACT EQUALITY RIGIDITY FOR 2-BIT $\chi^2$-COURTADE–KUMAR (`I_{χ²}(Q; p) = (1 + ε²)² - 1`)**: For every `p ∈ (0, 1) \ {1/2}`, a 2-bit quantizer `Q : (ι → Bool) → Fin 4` attains `I_{χ²}(Q; p) = (1 + (1 - 2p)²)² - 1` **if and only if** every cell `Q⁻¹(m)` is a codimension-2 subcube! -/ theorem chi2_two_bit_eq_iff (Q : (ι → Bool) → Fin 4) {p : ℝ} (hp0 : 0 < p) (hp1 : p < 1) (hp_half : p ≠ 1 / 2) : chi2MutualInfo Q p = (1 + (1 - 2 * p) ^ 2) ^ 2 - 1 ↔ ∀ m : Fin 4, IsCodim2Subcube (quantCell Q m) := by let ε : ℝ := 1 - 2 * p have hε0 : ε ≠ 0 := by dsimp only [ε]; intro h; apply hp_half; linarith have hε2_pos : 0 < ε ^ 2 := sq_pos_of_ne_zero hε0 have hε2_lt1 : ε ^ 2 < 1 := by have h1 : -1 < ε := by dsimp only [ε]; linarith have h2 : ε < 1 := by dsimp only [ε]; linarith nlinarith have hε_diff : 0 < ε ^ 2 - ε ^ 4 := by nlinarith constructor · intro heq rw [← curvature_two_bit_eq_two_iff] apply le_antisymm (by have := curvature_le_half_card Q; norm_num at this; linarith) -- Show `I_{χ²}(Q; p) ≤ 2 ε² + ε⁴ - (ε² - ε⁴) * (2 - Λ(Q))`? Even more directly: -- For every cell `A` of mass `μ > 0`, every odd `|S| ≥ 3` has `ε^(2|S|) ≤ ε⁶ < ε²`! -- Even better: `∑_{S ≠ ∅} ε^(2|S|) f̂(S)² ≤ ε⁴ μ(1-μ) + (ε² - ε⁴) W_1(A) + (ε⁶ - ε⁴) (W_odd(A) - W_1(A))` -- `≤ ε⁴ μ(1-μ) + (ε² - ε⁴) W_1(A)` since `ε⁶ - ε⁴ ≤ 0` and `W_odd(A) ≥ W_1(A)`!! have hcell_w1 : ∀ m : Fin 4, (if cellMass Q m = 0 then 0 else (∑ S ∈ (Finset.univ : Finset (Finset ι)).erase ∅, ε ^ (2 * S.card) * fourierCoeff (indFun (quantCell Q m)) S ^ 2) / cellMass Q m) ≤ ε ^ 4 * (1 - cellMass Q m) + (ε ^ 2 - ε ^ 4) * (if cellMass Q m = 0 then 0 else level1Weight (indFun (quantCell Q m)) / cellMass Q m) := by intro m by_cases hm : cellMass Q m = 0 · rw [if_pos hm, if_pos hm, hm]; nlinarith · rw [if_neg hm, if_neg hm] have hm_pos : 0 < cellMass Q m := lt_of_le_of_ne (setMass_nonneg _) (Ne.symm hm) rw [div_le_iff₀ hm_pos] have hterm : ∀ S ∈ (Finset.univ : Finset (Finset ι)).erase ∅, ε ^ (2 * S.card) * fourierCoeff (indFun (quantCell Q m)) S ^ 2 ≤ (if S.card = 1 then ε ^ 2 else ε ^ 4) * fourierCoeff (indFun (quantCell Q m)) S ^ 2 := by intro S hS have hne : S ≠ ∅ := (Finset.mem_erase.mp hS).1 have hpos : 1 ≤ S.card := Finset.card_pos.mpr (Finset.nonempty_iff_ne_empty.mpr hne) refine mul_le_mul_of_nonneg_right ?_ (sq_nonneg _) by_cases h1 : S.card = 1 · rw [if_pos h1, h1, mul_one] · rw [if_neg h1, pow_mul] have hge2 : 2 ≤ S.card := by omega calc (ε ^ 2) ^ S.card ≤ (ε ^ 2) ^ 2 := pow_le_pow_of_le_one hε2_pos.le hε2_lt1.le hge2 _ = ε ^ 4 := by ring have hsum_s1 : ∑ S ∈ (Finset.univ : Finset (Finset ι)).erase ∅, (if S.card = 1 then fourierCoeff (indFun (quantCell Q m)) S ^ 2 else 0) = level1Weight (indFun (quantCell Q m)) := by let emb : ι ↪ Finset ι := ⟨fun i => {i}, Finset.singleton_injective⟩ have hfilt : ((Finset.univ : Finset (Finset ι)).erase ∅).filter (fun S => S.card = 1) = (Finset.univ : Finset ι).map emb := by ext S; simp only [Finset.mem_filter, Finset.mem_erase, Finset.mem_univ, and_true, Finset.mem_map, true_and] constructor · rintro ⟨_, h1⟩; obtain ⟨i, rfl⟩ := Finset.card_eq_one.mp h1; exact ⟨i, rfl⟩ · rintro ⟨i, rfl⟩; exact ⟨Finset.singleton_ne_empty i, Finset.card_singleton i⟩ rw [← Finset.sum_filter, hfilt, Finset.sum_map]; rfl have hvar : ∑ S ∈ (Finset.univ : Finset (Finset ι)).erase ∅, fourierCoeff (indFun (quantCell Q m)) S ^ 2 = cellMass Q m * (1 - cellMass Q m) := by have hp := parseval_indFun (quantCell Q m) rw [← Finset.add_sum_erase _ _ (Finset.mem_univ (∅ : Finset ι)), fourierCoeff_indFun_empty] at hp unfold cellMass; linarith calc ∑ S ∈ (Finset.univ : Finset (Finset ι)).erase ∅, ε ^ (2 * S.card) * fourierCoeff (indFun (quantCell Q m)) S ^ 2 ≤ ∑ S ∈ (Finset.univ : Finset (Finset ι)).erase ∅, (if S.card = 1 then ε ^ 2 else ε ^ 4) * fourierCoeff (indFun (quantCell Q m)) S ^ 2 := Finset.sum_le_sum hterm _ = ε ^ 4 * (cellMass Q m * (1 - cellMass Q m)) + (ε ^ 2 - ε ^ 4) * level1Weight (indFun (quantCell Q m)) := by have hrew : ∀ S ∈ (Finset.univ : Finset (Finset ι)).erase ∅, (if S.card = 1 then ε ^ 2 else ε ^ 4) * fourierCoeff (indFun (quantCell Q m)) S ^ 2 = ε ^ 4 * fourierCoeff (indFun (quantCell Q m)) S ^ 2 + (ε ^ 2 - ε ^ 4) * (if S.card = 1 then fourierCoeff (indFun (quantCell Q m)) S ^ 2 else 0) := by intro S _ by_cases h : S.card = 1 · simp [h]; ring · simp [h] rw [Finset.sum_congr rfl hrew, Finset.sum_add_distrib, ← Finset.mul_sum, ← Finset.mul_sum, hvar, hsum_s1] _ = (ε ^ 4 * (1 - cellMass Q m) + (ε ^ 2 - ε ^ 4) * (level1Weight (indFun (quantCell Q m)) / cellMass Q m)) * cellMass Q m := by field_simp [hm_pos.ne'] have hchi_le : chi2MutualInfo Q p ≤ 3 * ε ^ 4 + (ε ^ 2 - ε ^ 4) * curvature Q := by rw [chi2MutualInfo_eq_fourier] calc ∑ m : Fin 4, _ ≤ ∑ m : Fin 4, (ε ^ 4 * (1 - cellMass Q m) + (ε ^ 2 - ε ^ 4) * (if cellMass Q m = 0 then 0 else level1Weight (indFun (quantCell Q m)) / cellMass Q m)) := Finset.sum_le_sum fun m _ => hcell_w1 m _ = 3 * ε ^ 4 + (ε ^ 2 - ε ^ 4) * curvature Q := by rw [Finset.sum_add_distrib, ← Finset.mul_sum, ← Finset.mul_sum, Finset.sum_sub_distrib, Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, sum_cellMass] unfold curvature; norm_num; ring have heq' : chi2MutualInfo Q p = 2 * ε ^ 2 + ε ^ 4 := by dsimp only [ε]; rw [heq]; ring nlinarith · intro hall rw [chi2MutualInfo_eq_fourier] have hterm : ∀ m : Fin 4, (if cellMass Q m = 0 then 0 else (∑ S ∈ (Finset.univ : Finset (Finset ι)).erase ∅, ε ^ (2 * S.card) * fourierCoeff (indFun (quantCell Q m)) S ^ 2) / cellMass Q m) = (1 / 2 : ℝ) * ε ^ 2 + (1 / 4 : ℝ) * ε ^ 4 := by intro m rcases hall m with ⟨i, j, b₁, b₂, hij, heq⟩ have hm : cellMass Q m = 1 / 4 := by unfold cellMass; rw [heq, codim2Subcube_mass hij] rw [if_neg (by rw [hm]; norm_num : cellMass Q m ≠ 0), hm, heq] let T : Finset (Finset ι) := {{i}, {j}, {i, j}} have hTsub : T ⊆ (Finset.univ : Finset (Finset ι)).erase ∅ := by intro S hS; simp only [T, Finset.mem_insert, Finset.mem_singleton] at hS refine Finset.mem_erase.mpr ⟨?_, Finset.mem_univ _⟩ rcases hS with rfl | rfl | rfl <;> simp have hzero_out : ∀ S ∈ (Finset.univ : Finset (Finset ι)).erase ∅, S ∉ T → ε ^ (2 * S.card) * fourierCoeff (indFun (Finset.univ.filter fun x : ι → Bool => x i = b₁ ∧ x j = b₂)) S ^ 2 = 0 := by intro S hS hnot have hne0 := (Finset.mem_erase.mp hS).1 simp only [T, Finset.mem_insert, Finset.mem_singleton, not_or] at hnot rw [codim2Subcube_fourierCoeff hij] simp [hne0, hnot.1, hnot.2.1, hnot.2.2] rw [← Finset.sum_subset hTsub hzero_out] have hne_ij : ({i} : Finset ι) ≠ {j} := fun h => hij (Finset.singleton_injective h) have hne_i_ij : ({i} : Finset ι) ≠ {i, j} := by intro h; have : j ∈ ({i} : Finset ι) := h ▸ by simp exact hij.symm (Finset.mem_singleton.mp this) have hne_j_ij : ({j} : Finset ι) ≠ {i, j} := by intro h; have : i ∈ ({j} : Finset ι) := h ▸ by simp exact hij (Finset.mem_singleton.mp this) dsimp only [T] rw [Finset.sum_insert (by simp [hne_ij, hne_i_ij]), Finset.sum_insert (by simp [hne_j_ij]), Finset.sum_singleton] rw [codim2Subcube_fourierCoeff hij, codim2Subcube_fourierCoeff hij, codim2Subcube_fourierCoeff hij] have hc_i : ({i} : Finset ι).card = 1 := Finset.card_singleton i have hc_j : ({j} : Finset ι).card = 1 := Finset.card_singleton j have hc_ij : ({i, j} : Finset ι).card = 2 := Finset.card_pair hij have hne_i0 : ({i} : Finset ι) ≠ ∅ := Finset.singleton_ne_empty i have hne_j0 : ({j} : Finset ι) ≠ ∅ := Finset.singleton_ne_empty j have hne_ij0 : ({i, j} : Finset ι) ≠ ∅ := by simp simp only [hc_i, hc_j, hc_ij, hne_i0, hne_j0, hne_ij0, hne_ij.symm, hne_i_ij.symm, hne_j_ij.symm, ↓reduceIte, div_pow, mul_pow, boolSign_sq] ring simp_rw [show 1 - 2 * p = ε from rfl, hterm, Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] dsimp only [ε]; ring end Chi2CourtadeKumar /-! ## Section 4: High-Noise Multibit Shannon Courtade–Kumar Theorem (`M = 2, 3, 4`) & Subcube Identities -/ section HighNoiseShannon variable {ι : Type*} [Fintype ι] [DecidableEq ι] /-- Elementary 1-variable calculus bound: for all `u ∈ [-1/2, 1/2]`, `|(1 + u) * log (1 + u) - u - u² / 2| ≤ |u|³ / 2`. -/ lemma log_taylor_rem_abs_le {u : ℝ} (hu : |u| ≤ 1 / 2) : |(1 + u) * Real.log (1 + u) - u - u ^ 2 / 2| ≤ |u| ^ 3 / 2 := by have h1 : -(1 / 2 : ℝ) ≤ u := (abs_le.mp hu).1 have h2 : u ≤ 1 / 2 := (abs_le.mp hu).2 let r : ℝ → ℝ := fun x => (1 + x) * Real.log (1 + x) - x - x ^ 2 / 2 have hr_deriv : ∀ x : ℝ, -1 < x → HasDerivAt r (Real.log (1 + x) - x) x := by intro x hx have hx1 : 0 < 1 + x := by linarith have ha : HasDerivAt (fun y : ℝ => 1 + y) 1 x := (hasDerivAt_id x).const_add 1 have hb : HasDerivAt (fun y : ℝ => Real.log (1 + y)) ((1 + x)⁻¹ * 1) x := (Real.hasDerivAt_log hx1.ne').comp x ha have hd1 : HasDerivAt (fun y : ℝ => (1 + y) * Real.log (1 + y)) (Real.log (1 + x) + 1) x := by have hmul := ha.mul hb have heq : 1 * Real.log (1 + x) + (1 + x) * ((1 + x)⁻¹ * 1) = Real.log (1 + x) + 1 := by rw [one_mul, mul_one, mul_inv_cancel₀ hx1.ne'] rwa [heq] at hmul have hd2 : HasDerivAt (fun y : ℝ => y) 1 x := hasDerivAt_id x have hd3 : HasDerivAt (fun y : ℝ => y ^ 2 / 2) x x := by have hp := (hasDerivAt_pow 2 x).div_const 2 have heq : (2 : ℝ) * x ^ (2 - 1) * 1 / 2 = x := by ring simpa [heq] using hp have hsub := (hd1.sub hd2).sub hd3 have heq : Real.log (1 + x) + 1 - 1 - x = Real.log (1 + x) - x := by ring rwa [heq] at hsub have hr_cont : ContinuousOn r (Set.Icc (-(1 / 2)) (1 / 2)) := by intro x hx exact (hr_deriv x (by linarith [hx.1])).continuousAt.continuousWithinAt have hr0 : r 0 = 0 := by simp [r] -- Bound `Real.log (1 + x) - x`: -- Always `log (1 + x) - x ≤ 0` (by `Real.log_le_sub_one_of_pos`). -- Also for `x ≥ 0`: `log (1 + x) - x ≥ -x² / 2` (since `(log (1 + x) - x + x²/2)' = x² / (1 + x) ≥ 0`). -- And for `x ∈ [-1/2, 0]`: `log (1 + x) - x ≥ -x²` (since `(log (1 + x) - x + x²)' = x(1 + 2x)/(1 + x) ≤ 0` on `[-1/2, 0]`). have hlog_le : ∀ x : ℝ, -1 < x → Real.log (1 + x) - x ≤ 0 := fun x hx => by have := Real.log_le_sub_one_of_pos (show 0 < 1 + x by linarith); linarith have hlog_ge_pos : ∀ x : ℝ, 0 ≤ x → -(x ^ 2 / 2) ≤ Real.log (1 + x) - x := by intro x hx let g : ℝ → ℝ := fun y => Real.log (1 + y) - y + y ^ 2 / 2 have hg_deriv : ∀ y : ℝ, -1 < y → HasDerivAt g (y ^ 2 / (1 + y)) y := by intro y hy have hy1 : 0 < 1 + y := by linarith have hd1 : HasDerivAt (fun z : ℝ => Real.log (1 + z)) ((1 + y)⁻¹ * 1) y := (Real.hasDerivAt_log hy1.ne').comp y ((hasDerivAt_id y).const_add 1) have hd2 : HasDerivAt (fun z : ℝ => z) 1 y := hasDerivAt_id y have hd3 : HasDerivAt (fun z : ℝ => z ^ 2 / 2) y y := by simpa [show (2 : ℝ) * y ^ (2 - 1) * 1 / 2 = y by ring] using (hasDerivAt_pow 2 y).div_const 2 have htot := (hd1.sub hd2).add hd3 have heq : (1 + y)⁻¹ * 1 - 1 + y = y ^ 2 / (1 + y) := by field_simp [hy1.ne']; ring rwa [heq] at htot have hmono : MonotoneOn g (Set.Icc 0 x) := by refine monotoneOn_of_deriv_nonneg (convex_Icc _ _) (fun y hy => (hg_deriv y (by linarith [hy.1])).continuousAt.continuousWithinAt) (fun y hy => by rw [interior_Icc] at hy; exact (hg_deriv y (by linarith [hy.1])).differentiableAt.differentiableWithinAt) (fun y hy => by rw [interior_Icc] at hy have hy1 : 0 < 1 + y := by linarith [hy.1] rw [(hg_deriv y (by linarith [hy.1])).deriv]; positivity) have := hmono ⟨le_rfl, hx⟩ ⟨hx, le_rfl⟩ hx have hg0 : g 0 = 0 := by simp [g] rw [hg0] at this; dsimp only [g] at this; linarith have hlog_ge_neg : ∀ x : ℝ, -(1 / 2 : ℝ) ≤ x → x ≤ 0 → -(x ^ 2) ≤ Real.log (1 + x) - x := by intro x hx1 hx2 let g : ℝ → ℝ := fun y => Real.log (1 + y) - y + y ^ 2 have hg_deriv : ∀ y : ℝ, -1 < y → HasDerivAt g (y * (1 + 2 * y) / (1 + y)) y := by intro y hy have hy1 : 0 < 1 + y := by linarith have hd1 : HasDerivAt (fun z : ℝ => Real.log (1 + z)) ((1 + y)⁻¹ * 1) y := (Real.hasDerivAt_log hy1.ne').comp y ((hasDerivAt_id y).const_add 1) have hd2 : HasDerivAt (fun z : ℝ => z) 1 y := hasDerivAt_id y have hd3 : HasDerivAt (fun z : ℝ => z ^ 2) (2 * y) y := by simpa [show (2 : ℝ) * y ^ (2 - 1) * 1 = 2 * y by ring] using hasDerivAt_pow 2 y have htot := (hd1.sub hd2).add hd3 have heq : (1 + y)⁻¹ * 1 - 1 + 2 * y = y * (1 + 2 * y) / (1 + y) := by field_simp [hy1.ne']; ring rwa [heq] at htot have hanti : AntitoneOn g (Set.Icc x 0) := by refine antitoneOn_of_deriv_nonpos (convex_Icc _ _) (fun y hy => (hg_deriv y (by linarith [hy.1])).continuousAt.continuousWithinAt) (fun y hy => by rw [interior_Icc] at hy; exact (hg_deriv y (by linarith [hy.1])).differentiableAt.differentiableWithinAt) (fun y hy => by rw [interior_Icc] at hy have hy1 : 0 < 1 + y := by linarith [hy.1] rw [(hg_deriv y (by linarith [hy.1])).deriv] exact div_nonpos_of_nonpos_of_nonneg (by nlinarith [hy.1, hy.2]) hy1.le) have := hanti ⟨le_rfl, hx2⟩ ⟨hx2, le_rfl⟩ hx2 have hg0 : g 0 = 0 := by simp [g] rw [hg0] at this; dsimp only [g] at this; linarith by_cases hu0 : 0 ≤ u · rw [abs_of_nonneg hu0] -- On `[0, u]`: `-x^2/2 ≤ r'(x) ≤ 0`, so `-u^3/6 ≤ r(u) ≤ 0`! have hr_le0 : r u ≤ 0 := by have hanti : AntitoneOn r (Set.Icc 0 u) := antitoneOn_of_deriv_nonpos (convex_Icc _ _) (hr_cont.mono (Set.Icc_subset_Icc (by linarith) h2)) (fun x hx => by rw [interior_Icc] at hx; exact (hr_deriv x (by linarith [hx.1])).differentiableAt.differentiableWithinAt) (fun x hx => by rw [interior_Icc] at hx; rw [(hr_deriv x (by linarith [hx.1])).deriv]; exact hlog_le x (by linarith [hx.1])) have := hanti ⟨le_rfl, hu0⟩ ⟨hu0, le_rfl⟩ hu0 linarith [hr0] have hr_ge : -(u ^ 3 / 2) ≤ r u := by let q : ℝ → ℝ := fun x => r x + x ^ 3 / 2 have hq_deriv : ∀ x : ℝ, -1 < x → HasDerivAt q (Real.log (1 + x) - x + 3 * x ^ 2 / 2) x := by intro x hx have hd3 : HasDerivAt (fun y : ℝ => y ^ 3 / 2) (3 * x ^ 2 / 2) x := by simpa [show (3 : ℝ) * x ^ (3 - 1) * 1 / 2 = 3 * x ^ 2 / 2 by ring] using (hasDerivAt_pow 3 x).div_const 2 exact (hr_deriv x hx).add hd3 have hmono : MonotoneOn q (Set.Icc 0 u) := monotoneOn_of_deriv_nonneg (convex_Icc _ _) (fun x hx => (hq_deriv x (by linarith [hx.1])).continuousAt.continuousWithinAt) (fun x hx => by rw [interior_Icc] at hx; exact (hq_deriv x (by linarith [hx.1])).differentiableAt.differentiableWithinAt) (fun x hx => by rw [interior_Icc] at hx rw [(hq_deriv x (by linarith [hx.1])).deriv] have := hlog_ge_pos x hx.1.le nlinarith [sq_nonneg x]) have := hmono ⟨le_rfl, hu0⟩ ⟨hu0, le_rfl⟩ hu0 have hq0 : q 0 = 0 := by simp [q, hr0] rw [hq0] at this; dsimp only [q] at this; linarith rw [abs_of_nonpos hr_le0]; linarith · push Not at hu0 rw [abs_of_neg hu0] -- On `[u, 0]`: `-x^2 ≤ r'(x) ≤ 0`, so `0 ≤ r(u) ≤ (-u)^3 / 3 ≤ (-u)^3 / 2`! have hr_ge0 : 0 ≤ r u := by have hanti : AntitoneOn r (Set.Icc u 0) := antitoneOn_of_deriv_nonpos (convex_Icc _ _) (hr_cont.mono (Set.Icc_subset_Icc h1 (by norm_num))) (fun x hx => by rw [interior_Icc] at hx; exact (hr_deriv x (by linarith [hx.1])).differentiableAt.differentiableWithinAt) (fun x hx => by rw [interior_Icc] at hx; rw [(hr_deriv x (by linarith [hx.1])).deriv]; exact hlog_le x (by linarith [hx.1])) have := hanti ⟨le_rfl, hu0.le⟩ ⟨hu0.le, le_rfl⟩ hu0.le linarith [hr0] have hr_le : r u ≤ (-u) ^ 3 / 2 := by let q : ℝ → ℝ := fun x => r x + x ^ 3 / 2 have hq_deriv : ∀ x : ℝ, -1 < x → HasDerivAt q (Real.log (1 + x) - x + 3 * x ^ 2 / 2) x := by intro x hx have hd3 : HasDerivAt (fun y : ℝ => y ^ 3 / 2) (3 * x ^ 2 / 2) x := by simpa [show (3 : ℝ) * x ^ (3 - 1) * 1 / 2 = 3 * x ^ 2 / 2 by ring] using (hasDerivAt_pow 3 x).div_const 2 exact (hr_deriv x hx).add hd3 have hmono : MonotoneOn q (Set.Icc u 0) := monotoneOn_of_deriv_nonneg (convex_Icc _ _) (fun x hx => (hq_deriv x (by linarith [hx.1])).continuousAt.continuousWithinAt) (fun x hx => by rw [interior_Icc] at hx; exact (hq_deriv x (by linarith [hx.1])).differentiableAt.differentiableWithinAt) (fun x hx => by rw [interior_Icc] at hx rw [(hq_deriv x (by linarith [hx.1])).deriv] have := hlog_ge_neg x (by linarith [hx.1]) hx.2.le nlinarith [sq_nonneg x]) have := hmono ⟨le_rfl, hu0.le⟩ ⟨hu0.le, le_rfl⟩ hu0.le have hq0 : q 0 = 0 := by simp [q, hr0] rw [hq0] at this; dsimp only [q] at this have hcube : (-u) ^ 3 / 2 = -(u ^ 3 / 2) := by ring linarith rw [abs_of_nonneg hr_ge0]; exact hr_le /-- **Quantitative High-Noise Taylor Expansion of Shannon Mutual Information**: For EVERY finite quantizer `Q : (ι → Bool) → α`, there exist `δ > 0` and `C ≥ 0` such that for all `ε ∈ (-δ, δ)`, letting `p = (1 - ε) / 2`, `|I(Q; p) - (ε² / (2 * ln 2)) * Λ(Q)| ≤ C * |ε|³`. -/ theorem shannonMutualInfo_high_noise_approx {α : Type*} [Fintype α] [DecidableEq α] (Q : (ι → Bool) → α) : ∃ (δ C : ℝ), 0 < δ ∧ δ ≤ 1 ∧ 0 ≤ C ∧ ∀ ε : ℝ, |ε| < δ → |shannonMutualInfo Q ((1 - ε) / 2) - ε ^ 2 / (2 * Real.log 2) * curvature Q| ≤ C * |ε| ^ 3 := by -- For every cell `m` with `μ_m > 0`, `μ_m ≥ 1 / 2^|ι|`. -- And `|T_p(1_{A_m})(y) - μ_m| ≤ ∑_{S ≠ ∅} |ε|^|S| |f̂_m(S)| ≤ 2^|ι| * |ε|` when `|ε| ≤ 1`! let n := Fintype.card ι let B : ℝ := (2 : ℝ) ^ n have hB_pos : 0 < B := by positivity -- Choose `δ = min (1 / 2) (1 / (2 * B ^ 2))` so that `|u_{m,y}| = |T_p - μ_m| / μ_m ≤ B^2 * |ε| ≤ 1/2`! let δ : ℝ := min (1 / 2 : ℝ) (1 / (2 * B ^ 2)) have hδ_pos : 0 < δ := lt_min (by norm_num) (by positivity) have hδ_le1 : δ ≤ 1 := le_trans (min_le_left _ _) (by norm_num) have hδ_le_B : δ ≤ 1 / (2 * B ^ 2) := min_le_right _ _ -- Explicit error constant `C`: let C : ℝ := ((Fintype.card α : ℝ) * (B ^ 5 + 3 * B ^ 3)) / Real.log 2 have hlog2_pos : 0 < Real.log 2 := Real.log_pos (by norm_num) refine ⟨δ, C, hδ_pos, hδ_le1, by positivity, fun ε hε => ?_⟩ have hε_le1 : |ε| ≤ 1 := le_trans hε.le hδ_le1 have h1sub : 1 - 2 * ((1 - ε) / 2) = ε := by ring -- Bound each cell's error `|cell_term m - (ε² / 2) * (W_1(A_m) / μ_m)| ≤ (B^5 + 3 * B^3) * |ε|^3`! have hcell_err : ∀ m : α, |(if cellMass Q m = 0 then 0 else (∑ y : ι → Bool, noiseOp ((1 - ε) / 2) (indFun (quantCell Q m)) y * Real.log (noiseOp ((1 - ε) / 2) (indFun (quantCell Q m)) y / cellMass Q m)) / (2 : ℝ) ^ n) - (ε ^ 2 / 2) * (if cellMass Q m = 0 then 0 else level1Weight (indFun (quantCell Q m)) / cellMass Q m)| ≤ (B ^ 5 + 3 * B ^ 3) * |ε| ^ 3 := by intro m by_cases hm : cellMass Q m = 0 · simp only [hm, ↓reduceIte, mul_zero, sub_self, abs_zero]; positivity · rw [if_neg hm, if_neg hm] have hm_pos : 0 < cellMass Q m := lt_of_le_of_ne (setMass_nonneg _) (Ne.symm hm) have hm_ge : 1 / B ≤ cellMass Q m := by unfold cellMass setMass have hne : (quantCell Q m).Nonempty := by by_contra hemp; rw [Finset.not_nonempty_iff_eq_empty] at hemp apply hm; unfold cellMass setMass; simp [hemp] have hc1 : (1 : ℝ) ≤ ((quantCell Q m).card : ℝ) := by exact_mod_cast Finset.card_pos.mpr hne exact div_le_div_of_nonneg_right hc1 hB_pos.le let A := quantCell Q m let μ := cellMass Q m have hμ_pos : 0 < μ := hm_pos -- Fourier coefficient bound: `|f̂_A(S)| ≤ 1` for all `S`! have hfc_le1 : ∀ S : Finset ι, |fourierCoeff (indFun A) S| ≤ 1 := by intro S; unfold fourierCoeff rw [abs_div, abs_of_pos hB_pos, div_le_one hB_pos] calc |∑ x : ι → Bool, indFun A x * walsh S x| ≤ ∑ x : ι → Bool, |indFun A x * walsh S x| := Finset.abs_sum_le_sum_abs _ _ _ ≤ ∑ _x : ι → Bool, (1 : ℝ) := by refine Finset.sum_le_sum fun x _ => ?_ rw [abs_mul, walsh_abs, mul_one]; unfold indFun; split_ifs <;> norm_num _ = B := by rw [Finset.sum_const, Finset.card_univ, Fintype.card_fun, Fintype.card_bool, nsmul_eq_mul, mul_one, Nat.cast_pow, Nat.cast_ofNat] -- Define `u y = (T_p(1_A)(y) - μ) / μ = (∑_{S ≠ ∅} ε^|S| f̂(S) χ_S(y)) / μ`! let u : (ι → Bool) → ℝ := fun y => (noiseOp ((1 - ε) / 2) (indFun A) y - μ) / μ have hu_eq : ∀ y : ι → Bool, noiseOp ((1 - ε) / 2) (indFun A) y = μ * (1 + u y) := by intro y; dsimp only [u]; rw [mul_add, mul_one, mul_div_cancel₀ _ hμ_pos.ne']; ring have hu_fourier : ∀ y : ι → Bool, μ * u y = ∑ S ∈ (Finset.univ : Finset (Finset ι)).erase ∅, ε ^ S.card * fourierCoeff (indFun A) S * walsh S y := by intro y have h1 : μ * u y = noiseOp ((1 - ε) / 2) (indFun A) y - μ := by dsimp only [u]; exact mul_div_cancel₀ _ hμ_pos.ne' rw [h1, noiseOp_eq_fourier, h1sub, ← Finset.add_sum_erase _ _ (Finset.mem_univ (∅ : Finset ι))] simp only [Finset.card_empty, pow_zero, one_mul, walsh_empty, mul_one, fourierCoeff_indFun_empty] dsimp only [μ, A, cellMass]; ring -- Bound `|u y| ≤ B^2 * |ε| ≤ 1/2`! have hu_abs : ∀ y : ι → Bool, |u y| ≤ B ^ 2 * |ε| := by intro y have hnum : |μ * u y| ≤ B * |ε| := by rw [hu_fourier y] calc |∑ S ∈ (Finset.univ : Finset (Finset ι)).erase ∅, ε ^ S.card * fourierCoeff (indFun A) S * walsh S y| ≤ ∑ S ∈ (Finset.univ : Finset (Finset ι)).erase ∅, |ε ^ S.card * fourierCoeff (indFun A) S * walsh S y| := Finset.abs_sum_le_sum_abs _ _ _ ≤ ∑ _S ∈ (Finset.univ : Finset (Finset ι)).erase ∅, |ε| := by refine Finset.sum_le_sum fun S hS => ?_ have hne := (Finset.mem_erase.mp hS).1 have hpos : 1 ≤ S.card := Finset.card_pos.mpr (Finset.nonempty_iff_ne_empty.mpr hne) rw [abs_mul, abs_mul, walsh_abs, mul_one, abs_pow] have hp : |ε| ^ S.card ≤ |ε| := pow_le_of_le_one (abs_nonneg ε) hε_le1 (by omega) have hf := hfc_le1 S calc |ε| ^ S.card * |fourierCoeff (indFun A) S| ≤ |ε| * 1 := mul_le_mul hp hf (abs_nonneg _) (abs_nonneg _) _ = |ε| := mul_one _ _ ≤ B * |ε| := by rw [Finset.sum_const, nsmul_eq_mul] refine mul_le_mul_of_nonneg_right ?_ (abs_nonneg ε) have hle_u : (((Finset.univ : Finset (Finset ι)).erase ∅).card : ℝ) ≤ B := by have h1 : ((Finset.univ : Finset (Finset ι)).erase ∅).card ≤ (Finset.univ : Finset (Finset ι)).card := Finset.card_le_card (Finset.erase_subset _ _) have h2 : (Finset.univ : Finset (Finset ι)).card = 2 ^ n := by rw [Finset.card_univ, Fintype.card_finset] dsimp only [B]; exact_mod_cast h1.trans_eq h2 exact hle_u rw [abs_mul, abs_of_pos hμ_pos] at hnum have h1 : |u y| ≤ (B * |ε|) / μ := (le_div_iff₀' hμ_pos).mpr hnum calc |u y| ≤ (B * |ε|) / μ := h1 _ ≤ (B * |ε|) / (1 / B) := div_le_div_of_nonneg_left (by positivity) (by positivity) hm_ge _ = B ^ 2 * |ε| := by field_simp [hB_pos.ne'] have hu_half : ∀ y : ι → Bool, |u y| ≤ 1 / 2 := fun y => by calc |u y| ≤ B ^ 2 * |ε| := hu_abs y _ ≤ B ^ 2 * (1 / (2 * B ^ 2)) := mul_le_mul_of_nonneg_left (hε.le.trans hδ_le_B) (by positivity) _ = 1 / 2 := by field_simp [hB_pos.ne'] -- Note `∑_y u y = 0`! have hsum_u0 : ∑ y : ι → Bool, u y = 0 := by have h1 : μ * ∑ y : ι → Bool, u y = 0 := by rw [Finset.mul_sum]; simp_rw [hu_fourier] rw [Finset.sum_comm] refine Finset.sum_eq_zero fun S hS => ?_ have hpull : ∑ y : ι → Bool, ε ^ S.card * fourierCoeff (indFun A) S * walsh S y = ε ^ S.card * fourierCoeff (indFun A) S * ∑ y : ι → Bool, walsh S y := by rw [Finset.mul_sum] rw [hpull, sum_walsh, if_neg (Finset.mem_erase.mp hS).1, mul_zero] exact (mul_eq_zero.mp h1).resolve_left hμ_pos.ne' -- And `(∑_y (μ * u y)²) / (2^n * μ) = (1/μ) ∑_{S ≠ ∅} ε^(2|S|) f̂(S)²`! have hsum_u2 : (μ / 2) * ((∑ y : ι → Bool, u y ^ 2) / B) = (1 / 2 : ℝ) * (∑ S ∈ (Finset.univ : Finset (Finset ι)).erase ∅, ε ^ (2 * S.card) * fourierCoeff (indFun A) S ^ 2) / μ := by have hparse_u : (∑ y : ι → Bool, (μ * u y) ^ 2) / B = ∑ S ∈ (Finset.univ : Finset (Finset ι)).erase ∅, ε ^ (2 * S.card) * fourierCoeff (indFun A) S ^ 2 := by have hp := parseval (fun y => noiseOp ((1 - ε) / 2) (indFun A) y - μ) have hrew : ∀ y : ι → Bool, (μ * u y) ^ 2 = (noiseOp ((1 - ε) / 2) (indFun A) y - μ) ^ 2 := by intro y; rw [hu_eq y]; ring simp_rw [hrew]; rw [hp] have hfc_u : ∀ S : Finset ι, fourierCoeff (fun y => noiseOp ((1 - ε) / 2) (indFun A) y - μ) S = if S = ∅ then 0 else ε ^ S.card * fourierCoeff (indFun A) S := by intro S have hsub : fourierCoeff (fun y => noiseOp ((1 - ε) / 2) (indFun A) y - μ) S = fourierCoeff (noiseOp ((1 - ε) / 2) (indFun A)) S - fourierCoeff (fun _ => μ) S := by unfold fourierCoeff; rw [← sub_div, ← Finset.sum_sub_distrib] congr 1; refine Finset.sum_congr rfl fun y _ => by ring have hc : fourierCoeff (fun _ : ι → Bool => μ) S = if S = ∅ then μ else 0 := by unfold fourierCoeff; rw [← Finset.mul_sum, sum_walsh] by_cases hS : S = ∅ · subst hS; simp · simp [hS] rw [hsub, fourierCoeff_noiseOp, h1sub, hc] by_cases hS : S = ∅ · subst hS; simp [μ, A, cellMass, fourierCoeff_indFun_empty] · simp [hS] rw [← Finset.add_sum_erase _ _ (Finset.mem_univ (∅ : Finset ι)), hfc_u ∅] simp only [↓reduceIte, zero_pow (by norm_num : 2 ≠ 0), zero_add] refine Finset.sum_congr rfl fun S hS => ?_ rw [hfc_u S, if_neg (Finset.mem_erase.mp hS).1, mul_pow, ← pow_mul, mul_comm S.card 2] have hpull : ∑ y : ι → Bool, (μ * u y) ^ 2 = μ ^ 2 * ∑ y : ι → Bool, u y ^ 2 := by rw [Finset.mul_sum]; refine Finset.sum_congr rfl fun y _ => by ring rw [hpull] at hparse_u rw [← hparse_u]; field_simp [hμ_pos.ne', hB_pos.ne'] -- Split total cell error into: -- (a) Taylor remainder `|cell_term - (μ/2) E_y[u²]| ≤ B^5 * |ε|^3` -- (b) Higher-degree Fourier modes `|(1/2μ) ∑_{|S| ≥ 2} ε^(2|S|) f̂(S)²| ≤ 3 * B^3 * |ε|^3`! have herr_a : |(∑ y : ι → Bool, noiseOp ((1 - ε) / 2) (indFun A) y * Real.log (noiseOp ((1 - ε) / 2) (indFun A) y / μ)) / B - (μ / 2) * ((∑ y : ι → Bool, u y ^ 2) / B)| ≤ B ^ 5 * |ε| ^ 3 := by have hdiff : (∑ y : ι → Bool, noiseOp ((1 - ε) / 2) (indFun A) y * Real.log (noiseOp ((1 - ε) / 2) (indFun A) y / μ)) / B - (μ / 2) * ((∑ y : ι → Bool, u y ^ 2) / B) = μ * (∑ y : ι → Bool, ((1 + u y) * Real.log (1 + u y) - u y - u y ^ 2 / 2)) / B := by have h1 : ∀ y : ι → Bool, noiseOp ((1 - ε) / 2) (indFun A) y * Real.log (noiseOp ((1 - ε) / 2) (indFun A) y / μ) = μ * ((1 + u y) * Real.log (1 + u y)) := by intro y; rw [hu_eq y, mul_div_cancel_left₀ _ hμ_pos.ne']; ring simp_rw [h1, ← Finset.mul_sum, Finset.sum_sub_distrib, hsum_u0, sub_zero, ← Finset.sum_div] ring rw [hdiff, abs_div, abs_of_pos hB_pos, abs_mul, abs_of_pos hμ_pos] have htight : ∀ y : ι → Bool, μ * (|u y| ^ 3 / 2) ≤ B ^ 5 * |ε| ^ 3 := by intro y have hmu_u : μ * |u y| ≤ B * |ε| := by have hnum : |μ * u y| ≤ B * |ε| := by rw [hu_fourier y] calc |∑ S ∈ (Finset.univ : Finset (Finset ι)).erase ∅, ε ^ S.card * fourierCoeff (indFun A) S * walsh S y| ≤ ∑ S ∈ (Finset.univ : Finset (Finset ι)).erase ∅, |ε ^ S.card * fourierCoeff (indFun A) S * walsh S y| := Finset.abs_sum_le_sum_abs _ _ _ ≤ ∑ _S ∈ (Finset.univ : Finset (Finset ι)).erase ∅, |ε| := by refine Finset.sum_le_sum fun S hS => ?_ have hpos : 1 ≤ S.card := Finset.card_pos.mpr (Finset.nonempty_iff_ne_empty.mpr (Finset.mem_erase.mp hS).1) rw [abs_mul, abs_mul, walsh_abs, mul_one, abs_pow] exact (mul_le_mul (pow_le_of_le_one (abs_nonneg ε) hε_le1 (by omega)) (hfc_le1 S) (abs_nonneg _) (abs_nonneg _)).trans_eq (mul_one _) _ ≤ B * |ε| := by rw [Finset.sum_const, nsmul_eq_mul] refine mul_le_mul_of_nonneg_right ?_ (abs_nonneg ε) have h1 : ((Finset.univ : Finset (Finset ι)).erase ∅).card ≤ 2 ^ n := by calc ((Finset.univ : Finset (Finset ι)).erase ∅).card ≤ (Finset.univ : Finset (Finset ι)).card := Finset.card_le_card (Finset.erase_subset _ _) _ = 2 ^ n := by rw [Finset.card_univ, Fintype.card_finset] dsimp only [B]; exact_mod_cast h1 rwa [abs_mul, abs_of_pos hμ_pos] at hnum have hcube : (μ * |u y|) ^ 3 ≤ (B * |ε|) ^ 3 := pow_le_pow_left₀ (by positivity) hmu_u 3 have hinv : 1 / μ ^ 2 ≤ B ^ 2 := by rw [div_le_iff₀ (sq_pos_of_pos hμ_pos)] have : (1 : ℝ) ≤ (B * μ) ^ 2 := by have h1 : 1 ≤ B * μ := by have := mul_le_mul_of_nonneg_left hm_ge hB_pos.le rwa [mul_one_div_cancel hB_pos.ne'] at this nlinarith nlinarith have heq : μ * (|u y| ^ 3 / 2) = (1 / 2) * ((μ * |u y|) ^ 3 * (1 / μ ^ 2)) := by field_simp [hμ_pos.ne'] rw [heq] have hprod : (μ * |u y|) ^ 3 * (1 / μ ^ 2) ≤ (B * |ε|) ^ 3 * B ^ 2 := mul_le_mul hcube hinv (by positivity) (by positivity) have hB5 : (B * |ε|) ^ 3 * B ^ 2 = B ^ 5 * |ε| ^ 3 := by ring nlinarith [show 0 ≤ B ^ 5 * |ε| ^ 3 by positivity] calc μ * |∑ y : ι → Bool, ((1 + u y) * Real.log (1 + u y) - u y - u y ^ 2 / 2)| / B ≤ (∑ y : ι → Bool, μ * (|u y| ^ 3 / 2)) / B := by refine div_le_div_of_nonneg_right ?_ hB_pos.le rw [← Finset.mul_sum] refine mul_le_mul_of_nonneg_left ?_ hμ_pos.le exact (Finset.abs_sum_le_sum_abs _ _).trans (Finset.sum_le_sum fun y _ => log_taylor_rem_abs_le (hu_half y)) _ ≤ (∑ _y : ι → Bool, B ^ 5 * |ε| ^ 3) / B := div_le_div_of_nonneg_right (Finset.sum_le_sum fun y _ => htight y) hB_pos.le _ = B ^ 5 * |ε| ^ 3 := by rw [Finset.sum_const, Finset.card_univ, Fintype.card_fun, Fintype.card_bool, nsmul_eq_mul, Nat.cast_pow, Nat.cast_ofNat, mul_div_cancel_left₀ _ hB_pos.ne'] have herr_b : |(μ / 2) * ((∑ y : ι → Bool, u y ^ 2) / B) - (ε ^ 2 / 2) * (level1Weight (indFun A) / μ)| ≤ 3 * B ^ 3 * |ε| ^ 3 := by rw [hsum_u2] let emb : ι ↪ Finset ι := ⟨fun i => {i}, Finset.singleton_injective⟩ let singSets := (Finset.univ : Finset ι).map emb have hsub : singSets ⊆ (Finset.univ : Finset (Finset ι)).erase ∅ := by intro S hS; rcases Finset.mem_map.mp hS with ⟨i, _, rfl⟩ exact Finset.mem_erase.mpr ⟨Finset.singleton_ne_empty i, Finset.mem_univ _⟩ have hsplit := (Finset.sum_sdiff hsub (f := fun S : Finset ι => ε ^ (2 * S.card) * fourierCoeff (indFun A) S ^ 2)).symm have hsing : ∑ S ∈ singSets, ε ^ (2 * S.card) * fourierCoeff (indFun A) S ^ 2 = ε ^ 2 * level1Weight (indFun A) := by unfold level1Weight; rw [Finset.sum_map, Finset.mul_sum] refine Finset.sum_congr rfl fun i _ => by simp [emb] rw [hsplit, hsing] have hdiff_eq : (1 / 2 : ℝ) * ((∑ S ∈ ((Finset.univ : Finset (Finset ι)).erase ∅) \ singSets, ε ^ (2 * S.card) * fourierCoeff (indFun A) S ^ 2) + ε ^ 2 * level1Weight (indFun A)) / μ - ε ^ 2 / 2 * (level1Weight (indFun A) / μ) = (∑ S ∈ ((Finset.univ : Finset (Finset ι)).erase ∅) \ singSets, ε ^ (2 * S.card) * fourierCoeff (indFun A) S ^ 2) / (2 * μ) := by field_simp [hμ_pos.ne']; ring rw [hdiff_eq, abs_div, abs_of_pos (by positivity : 0 < 2 * μ)] have hnum_le : |∑ S ∈ ((Finset.univ : Finset (Finset ι)).erase ∅) \ singSets, ε ^ (2 * S.card) * fourierCoeff (indFun A) S ^ 2| ≤ B * |ε| ^ 4 := by calc |∑ S ∈ ((Finset.univ : Finset (Finset ι)).erase ∅) \ singSets, ε ^ (2 * S.card) * fourierCoeff (indFun A) S ^ 2| ≤ ∑ S ∈ ((Finset.univ : Finset (Finset ι)).erase ∅) \ singSets, |ε ^ (2 * S.card) * fourierCoeff (indFun A) S ^ 2| := Finset.abs_sum_le_sum_abs _ _ _ ≤ ∑ _S ∈ ((Finset.univ : Finset (Finset ι)).erase ∅) \ singSets, |ε| ^ 4 := by refine Finset.sum_le_sum fun S hS => ?_ have hne0 := (Finset.mem_erase.mp (Finset.mem_sdiff.mp hS).1).1 have hnot1 := (Finset.mem_sdiff.mp hS).2 have hge2 : 2 ≤ S.card := by have hpos : 1 ≤ S.card := Finset.card_pos.mpr (Finset.nonempty_iff_ne_empty.mpr hne0) by_contra hlt; push Not at hlt have h1 : S.card = 1 := by omega obtain ⟨i, rfl⟩ := Finset.card_eq_one.mp h1 exact hnot1 (Finset.mem_map.mpr ⟨i, Finset.mem_univ _, rfl⟩) rw [abs_mul, abs_pow, abs_pow] have hp : |ε| ^ (2 * S.card) ≤ |ε| ^ 4 := pow_le_pow_of_le_one (abs_nonneg ε) hε_le1 (by omega) have hfc2 : |fourierCoeff (indFun A) S| ^ 2 ≤ 1 := by have := hfc_le1 S; nlinarith [abs_nonneg (fourierCoeff (indFun A) S)] exact (mul_le_mul hp hfc2 (by positivity) (by positivity)).trans_eq (mul_one _) _ ≤ B * |ε| ^ 4 := by rw [Finset.sum_const, nsmul_eq_mul] refine mul_le_mul_of_nonneg_right ?_ (by positivity) have hle : (((Finset.univ : Finset (Finset ι)).erase ∅) \ singSets).card ≤ 2 ^ n := by calc _ ≤ (Finset.univ : Finset (Finset ι)).card := Finset.card_le_card (Finset.subset_univ _) _ = 2 ^ n := by rw [Finset.card_univ, Fintype.card_finset] dsimp only [B]; exact_mod_cast hle have h4_le_3 : |ε| ^ 4 ≤ |ε| ^ 3 := by have : |ε| ^ 4 = |ε| ^ 3 * |ε| := by ring rw [this]; exact (mul_le_mul_of_nonneg_left hε_le1 (by positivity)).trans_eq (mul_one _) have hB_ge1 : (1 : ℝ) ≤ B := one_le_pow₀ (by norm_num) calc |∑ S ∈ ((Finset.univ : Finset (Finset ι)).erase ∅) \ singSets, ε ^ (2 * S.card) * fourierCoeff (indFun A) S ^ 2| / (2 * μ) ≤ (B * |ε| ^ 4) / (2 * (1 / B)) := div_le_div₀ (by positivity) hnum_le (by positivity) (by linarith) _ = B ^ 2 / 2 * |ε| ^ 4 := by field_simp [hB_pos.ne'] _ ≤ 3 * B ^ 3 * |ε| ^ 3 := by have h1 : B ^ 2 / 2 ≤ 3 * B ^ 3 := by nlinarith exact mul_le_mul h1 h4_le_3 (by positivity) (by positivity) have htri := abs_add_le ((∑ y : ι → Bool, noiseOp ((1 - ε) / 2) (indFun A) y * Real.log (noiseOp ((1 - ε) / 2) (indFun A) y / μ)) / B - (μ / 2) * ((∑ y : ι → Bool, u y ^ 2) / B)) ((μ / 2) * ((∑ y : ι → Bool, u y ^ 2) / B) - (ε ^ 2 / 2) * (level1Weight (indFun A) / μ)) have hcomb : (∑ y : ι → Bool, noiseOp ((1 - ε) / 2) (indFun A) y * Real.log (noiseOp ((1 - ε) / 2) (indFun A) y / μ)) / B - (ε ^ 2 / 2) * (level1Weight (indFun A) / μ) = ((∑ y : ι → Bool, noiseOp ((1 - ε) / 2) (indFun A) y * Real.log (noiseOp ((1 - ε) / 2) (indFun A) y / μ)) / B - (μ / 2) * ((∑ y : ι → Bool, u y ^ 2) / B)) + ((μ / 2) * ((∑ y : ι → Bool, u y ^ 2) / B) - (ε ^ 2 / 2) * (level1Weight (indFun A) / μ)) := by ring rw [hcomb]; linarith -- Sum the per-cell bounds over all `m : α` and divide by `Real.log 2`! unfold shannonMutualInfo curvature have hrew : (∑ m : α, if cellMass Q m = 0 then 0 else (∑ y : ι → Bool, noiseOp ((1 - ε) / 2) (indFun (quantCell Q m)) y * Real.log (noiseOp ((1 - ε) / 2) (indFun (quantCell Q m)) y / cellMass Q m)) / B) / Real.log 2 - ε ^ 2 / (2 * Real.log 2) * ∑ m : α, (if cellMass Q m = 0 then 0 else level1Weight (indFun (quantCell Q m)) / cellMass Q m) = (∑ m : α, ((if cellMass Q m = 0 then 0 else (∑ y : ι → Bool, noiseOp ((1 - ε) / 2) (indFun (quantCell Q m)) y * Real.log (noiseOp ((1 - ε) / 2) (indFun (quantCell Q m)) y / cellMass Q m)) / B) - (ε ^ 2 / 2) * (if cellMass Q m = 0 then 0 else level1Weight (indFun (quantCell Q m)) / cellMass Q m))) / Real.log 2 := by rw [Finset.sum_sub_distrib, ← Finset.mul_sum]; field_simp [hlog2_pos.ne'] rw [hrew, abs_div, abs_of_pos hlog2_pos] dsimp only [C] rw [div_mul_eq_mul_div] refine div_le_div_of_nonneg_right ?_ hlog2_pos.le calc |∑ m : α, _| ≤ ∑ m : α, |_| := Finset.abs_sum_le_sum_abs _ _ _ ≤ ∑ _m : α, (B ^ 5 + 3 * B ^ 3) * |ε| ^ 3 := Finset.sum_le_sum fun m _ => hcell_err m _ = (Fintype.card α : ℝ) * (B ^ 5 + 3 * B ^ 3) * |ε| ^ 3 := by rw [Finset.sum_const, Finset.card_univ, nsmul_eq_mul]; ring /-- Exact Shannon mutual information of a single-cell codimension-1 subcube: `E_y[T_p(1_A)(y) log(T_p(1_A)(y) / (1/2))] = (1/2) * (1 - h₂(p)) * ln 2`. -/ lemma codim1Subcube_shannon_cell (i : ι) (b : Bool) {p : ℝ} (_hp0 : 0 ≤ p) (_hp1 : p ≤ 1) : (∑ y : ι → Bool, noiseOp p (indFun (Finset.univ.filter fun x : ι → Bool => x i = b)) y * Real.log (noiseOp p (indFun (Finset.univ.filter fun x : ι → Bool => x i = b)) y / setMass (Finset.univ.filter fun x : ι → Bool => x i = b))) / (2 : ℝ) ^ Fintype.card ι = (1 / 2 : ℝ) * (1 - binEntropyBits p) * Real.log 2 := by have hlog2 : Real.log 2 ≠ 0 := (Real.log_pos (by norm_num)).ne' rw [codim1Subcube_mass] have hT : ∀ y : ι → Bool, noiseOp p (indFun (Finset.univ.filter fun x : ι → Bool => x i = b)) y = if y i = b then 1 - p else p := by intro y rw [noiseOp_eq_fourier] let T : Finset (Finset ι) := {∅, {i}} have hzero : ∀ S : Finset ι, S ∉ T → (1 - 2 * p) ^ S.card * fourierCoeff (indFun (Finset.univ.filter fun x : ι → Bool => x i = b)) S * walsh S y = 0 := by intro S hS; simp only [T, Finset.mem_insert, Finset.mem_singleton, not_or] at hS rw [codim1Subcube_fourierCoeff, if_neg hS.1, if_neg hS.2]; ring rw [← Finset.sum_subset (Finset.subset_univ T) (fun S _ hS => hzero S hS)] dsimp only [T] rw [Finset.sum_insert (by simp), Finset.sum_singleton, codim1Subcube_fourierCoeff, codim1Subcube_fourierCoeff] have hne : ({i} : Finset ι) ≠ ∅ := Finset.singleton_ne_empty i simp only [Finset.card_empty, pow_zero, one_mul, ↓reduceIte, walsh_empty, mul_one, Finset.card_singleton, pow_one, hne, walsh_singleton] cases hb : b <;> cases hy : y i <;> simp [boolSign] <;> ring simp_rw [hT] -- Count `y` with `y i = b` (exact half = `2^n / 2`) and `y i ≠ b` (exact half = `2^n / 2`)! have hhalf_eq : (Finset.univ.filter fun y : ι → Bool => y i = b).card = 2 ^ Fintype.card ι / 2 ∧ ((Finset.univ.filter fun y : ι → Bool => y i = b).card : ℝ) = (2 : ℝ) ^ Fintype.card ι / 2 := by have hmass := codim1Subcube_mass i b unfold setMass at hmass have hR : ((Finset.univ.filter fun y : ι → Bool => y i = b).card : ℝ) = (2 : ℝ) ^ Fintype.card ι / 2 := by have h2pos : (0 : ℝ) < (2 : ℝ) ^ Fintype.card ι := by positivity rw [div_eq_iff h2pos.ne'] at hmass; linarith refine ⟨?_, hR⟩ have h2 : 2 * (Finset.univ.filter fun y : ι → Bool => y i = b).card = 2 ^ Fintype.card ι := by have : (2 : ℝ) * ((Finset.univ.filter fun y : ι → Bool => y i = b).card : ℝ) = (2 : ℝ) ^ Fintype.card ι := by linarith exact_mod_cast this omega have hsum_split : ∑ y : ι → Bool, (if y i = b then 1 - p else p) * Real.log ((if y i = b then 1 - p else p) / (1 / 2)) = ((2 : ℝ) ^ Fintype.card ι / 2) * ((1 - p) * Real.log ((1 - p) / (1 / 2)) + p * Real.log (p / (1 / 2))) := by have hite : ∀ y : ι → Bool, (if y i = b then 1 - p else p) * Real.log ((if y i = b then 1 - p else p) / (1 / 2)) = (if y i = b then (1 - p) * Real.log ((1 - p) / (1 / 2)) else 0) + (if y i ≠ b then p * Real.log (p / (1 / 2)) else 0) := by intro y; by_cases h : y i = b <;> simp [h] simp_rw [hite, Finset.sum_add_distrib, ← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul] have hcard_ne : ((Finset.univ.filter fun y : ι → Bool => y i ≠ b).card : ℝ) = (2 : ℝ) ^ Fintype.card ι / 2 := by have hadd := Finset.card_filter_add_card_filter_not (s := (Finset.univ : Finset (ι → Bool))) (p := fun y : ι → Bool => y i = b) have hu : (Finset.univ : Finset (ι → Bool)).card = 2 ^ Fintype.card ι := by rw [Finset.card_univ, Fintype.card_fun, Fintype.card_bool] rw [hu] at hadd have hcast : ((Finset.univ.filter fun y : ι → Bool => y i = b).card : ℝ) + ((Finset.univ.filter fun y : ι → Bool => ¬ y i = b).card : ℝ) = (2 : ℝ) ^ Fintype.card ι := by exact_mod_cast hadd have hne_eq : Finset.univ.filter (fun y : ι → Bool => y i ≠ b) = Finset.univ.filter (fun y : ι → Bool => ¬ y i = b) := rfl rw [hne_eq]; linarith [hhalf_eq.2] rw [hhalf_eq.2, hcard_ne]; ring have h2pos : (0 : ℝ) < (2 : ℝ) ^ Fintype.card ι := by positivity rw [hsum_split] have hcancel : (2 : ℝ) ^ Fintype.card ι / 2 * ((1 - p) * Real.log ((1 - p) / (1 / 2)) + p * Real.log (p / (1 / 2))) / (2 : ℝ) ^ Fintype.card ι = (1 / 2 : ℝ) * ((1 - p) * Real.log ((1 - p) / (1 / 2)) + p * Real.log (p / (1 / 2))) := by field_simp [h2pos.ne'] rw [hcancel] have hterm1 : (1 - p) * Real.log ((1 - p) / (1 / 2)) = (1 - p) * Real.log (1 - p) + (1 - p) * Real.log 2 := by by_cases h : 1 - p = 0 · simp [h] · rw [div_div_eq_mul_div, div_one, Real.log_mul h (by norm_num)]; ring have hterm2 : p * Real.log (p / (1 / 2)) = p * Real.log p + p * Real.log 2 := by by_cases h : p = 0 · simp [h] · rw [div_div_eq_mul_div, div_one, Real.log_mul h (by norm_num)]; ring rw [hterm1, hterm2] unfold binEntropyBits rw [Real.binEntropy_eq_negMulLog_add_negMulLog_one_sub, Real.negMulLog, Real.negMulLog] field_simp [hlog2]; ring /-- Exact Shannon mutual information of a single-cell codimension-2 subcube: `E_y[T_p(1_A)(y) log(T_p(1_A)(y) / (1/4))] = (1/2) * (1 - h₂(p)) * ln 2`. -/ lemma codim2Subcube_shannon_cell {i j : ι} (hij : i ≠ j) (b₁ b₂ : Bool) {p : ℝ} (hp0 : 0 ≤ p) (hp1 : p ≤ 1) : (∑ y : ι → Bool, noiseOp p (indFun (Finset.univ.filter fun x : ι → Bool => x i = b₁ ∧ x j = b₂)) y * Real.log (noiseOp p (indFun (Finset.univ.filter fun x : ι → Bool => x i = b₁ ∧ x j = b₂)) y / setMass (Finset.univ.filter fun x : ι → Bool => x i = b₁ ∧ x j = b₂))) / (2 : ℝ) ^ Fintype.card ι = (1 / 2 : ℝ) * (1 - binEntropyBits p) * Real.log 2 := by have hlog2 : Real.log 2 ≠ 0 := (Real.log_pos (by norm_num)).ne' rw [codim2Subcube_mass hij] have hT : ∀ y : ι → Bool, noiseOp p (indFun (Finset.univ.filter fun x : ι → Bool => x i = b₁ ∧ x j = b₂)) y = (if y i = b₁ then 1 - p else p) * (if y j = b₂ then 1 - p else p) := by intro y rw [noiseOp_eq_fourier] let T : Finset (Finset ι) := {∅, {i}, {j}, {i, j}} have hzero : ∀ S : Finset ι, S ∉ T → (1 - 2 * p) ^ S.card * fourierCoeff (indFun (Finset.univ.filter fun x : ι → Bool => x i = b₁ ∧ x j = b₂)) S * walsh S y = 0 := by intro S hS; simp only [T, Finset.mem_insert, Finset.mem_singleton, not_or] at hS rw [codim2Subcube_fourierCoeff hij, if_neg hS.1, if_neg hS.2.1, if_neg hS.2.2.1, if_neg hS.2.2.2]; ring rw [← Finset.sum_subset (Finset.subset_univ T) (fun S _ hS => hzero S hS)] have hne_i0 : ({i} : Finset ι) ≠ ∅ := Finset.singleton_ne_empty i have hne_j0 : ({j} : Finset ι) ≠ ∅ := Finset.singleton_ne_empty j have hne_ij0 : ({i, j} : Finset ι) ≠ ∅ := by simp have hne_ij : ({i} : Finset ι) ≠ {j} := fun h => hij (Finset.singleton_injective h) have hne_i_ij : ({i} : Finset ι) ≠ {i, j} := by intro h; have : j ∈ ({i} : Finset ι) := h ▸ by simp exact hij.symm (Finset.mem_singleton.mp this) have hne_j_ij : ({j} : Finset ι) ≠ {i, j} := by intro h; have : i ∈ ({j} : Finset ι) := h ▸ by simp exact hij (Finset.mem_singleton.mp this) dsimp only [T] rw [Finset.sum_insert (by simp [hne_i0.symm, hne_j0.symm, hne_ij0.symm]), Finset.sum_insert (by simp [hne_ij, hne_i_ij]), Finset.sum_insert (by simp [hne_j_ij]), Finset.sum_singleton] rw [codim2Subcube_fourierCoeff hij, codim2Subcube_fourierCoeff hij, codim2Subcube_fourierCoeff hij, codim2Subcube_fourierCoeff hij] have hw_ij : walsh ({i, j} : Finset ι) y = boolSign (y i) * boolSign (y j) := by unfold walsh; rw [Finset.prod_pair hij] have hc_ij : ({i, j} : Finset ι).card = 2 := Finset.card_pair hij simp only [Finset.card_empty, pow_zero, one_mul, ↓reduceIte, walsh_empty, mul_one, Finset.card_singleton, pow_one, hc_ij, hne_i0, hne_j0, hne_ij0, hne_ij.symm, hne_i_ij.symm, hne_j_ij.symm, walsh_singleton, hw_ij] cases hb1 : b₁ <;> cases hb2 : b₂ <;> cases hy1 : y i <;> cases hy2 : y j <;> simp [boolSign] <;> ring simp_rw [hT] -- Count each of the 4 `(y i = b₁, y j = b₂)` quadrants: each has exact cardinality `2^n / 4`! have hquad : ∀ (c₁ c₂ : Bool), ((Finset.univ.filter fun y : ι → Bool => y i = c₁ ∧ y j = c₂).card : ℝ) = (2 : ℝ) ^ Fintype.card ι / 4 := by intro c₁ c₂ have hm := codim2Subcube_mass hij c₁ c₂ unfold setMass at hm have h2pos : (0 : ℝ) < (2 : ℝ) ^ Fintype.card ι := by positivity rw [div_eq_iff h2pos.ne'] at hm; linarith -- Expand the sum over the 4 Boolean outcomes `(y i = b₁, y j = b₂)`: let q1 := 1 - p have hlog_prod : ∀ a b : ℝ, 0 ≤ a → 0 ≤ b → (a * b) * Real.log ((a * b) / (1 / 4)) = b * (a * Real.log (2 * a)) + a * (b * Real.log (2 * b)) := by intro a b ha hb by_cases ha0 : a = 0 · simp [ha0] · by_cases hb0 : b = 0 · simp [hb0] · have h1 : (a * b) / (1 / 4) = (2 * a) * (2 * b) := by ring rw [h1, Real.log_mul (by positivity) (by positivity)]; ring have hpt : ∀ y : ι → Bool, ((if y i = b₁ then q1 else p) * (if y j = b₂ then q1 else p)) * Real.log (((if y i = b₁ then q1 else p) * (if y j = b₂ then q1 else p)) / (1 / 4)) = (if y i = b₁ ∧ y j = b₂ then q1 * q1 * Real.log (q1 * q1 / (1 / 4)) else 0) + (if y i = b₁ ∧ y j = !b₂ then q1 * p * Real.log (q1 * p / (1 / 4)) else 0) + (if y i = !b₁ ∧ y j = b₂ then p * q1 * Real.log (p * q1 / (1 / 4)) else 0) + (if y i = !b₁ ∧ y j = !b₂ then p * p * Real.log (p * p / (1 / 4)) else 0) := by intro y; cases hb1 : b₁ <;> cases hb2 : b₂ <;> cases hy1 : y i <;> cases hy2 : y j <;> simp have hsum_q : ∑ y : ι → Bool, ((if y i = b₁ then 1 - p else p) * (if y j = b₂ then 1 - p else p)) * Real.log (((if y i = b₁ then 1 - p else p) * (if y j = b₂ then 1 - p else p)) / (1 / 4)) = ∑ y : ι → Bool, ((if y i = b₁ then q1 else p) * (if y j = b₂ then q1 else p)) * Real.log (((if y i = b₁ then q1 else p) * (if y j = b₂ then q1 else p)) / (1 / 4)) := rfl rw [hsum_q] simp_rw [hpt] simp only [Finset.sum_add_distrib, ← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul, hquad] have h2pos : (0 : ℝ) < (2 : ℝ) ^ Fintype.card ι := by positivity have hnum : (2 : ℝ) ^ Fintype.card ι / 4 * (q1 * q1 * Real.log (q1 * q1 / (1 / 4))) + (2 : ℝ) ^ Fintype.card ι / 4 * (q1 * p * Real.log (q1 * p / (1 / 4))) + (2 : ℝ) ^ Fintype.card ι / 4 * (p * q1 * Real.log (p * q1 / (1 / 4))) + (2 : ℝ) ^ Fintype.card ι / 4 * (p * p * Real.log (p * p / (1 / 4))) = (2 : ℝ) ^ Fintype.card ι * ((1 / 2 : ℝ) * (q1 * Real.log (2 * q1) + p * Real.log (2 * p))) := by have hq1_nn : 0 ≤ q1 := by dsimp only [q1]; linarith rw [hlog_prod q1 q1 hq1_nn hq1_nn, hlog_prod q1 p hq1_nn hp0, hlog_prod p q1 hp0 hq1_nn, hlog_prod p p hp0 hp0] have hqp : q1 + p = 1 := by dsimp only [q1]; ring linear_combination ((2 : ℝ) ^ Fintype.card ι / 2 * (q1 * Real.log (2 * q1) + p * Real.log (2 * p))) * hqp rw [hnum, mul_div_cancel_left₀ _ h2pos.ne'] have h1 : q1 * Real.log (2 * q1) = q1 * Real.log q1 + q1 * Real.log 2 := by by_cases h : q1 = 0 · simp [h] · rw [Real.log_mul (by norm_num) h]; ring have h2 : p * Real.log (2 * p) = p * Real.log p + p * Real.log 2 := by by_cases h : p = 0 · simp [h] · rw [Real.log_mul (by norm_num) h]; ring rw [h1, h2] unfold binEntropyBits rw [Real.binEntropy_eq_negMulLog_add_negMulLog_one_sub, Real.negMulLog, Real.negMulLog] dsimp only [q1]; field_simp [hlog2]; ring /-- Every 2-bit codimension-2 subcube partition (including both 2-coordinate projections AND adaptive 2-bit decision trees!) achieves `I(Q; p) = 2 * (1 - h₂(p))` identically for all `p ∈ [0, 1]`. -/ theorem shannon_two_bit_subcubePartition (Q : (ι → Bool) → Fin 4) (hall : ∀ m : Fin 4, IsCodim2Subcube (quantCell Q m)) {p : ℝ} (hp0 : 0 ≤ p) (hp1 : p ≤ 1) : shannonMutualInfo Q p = 2 * (1 - binEntropyBits p) := by have hlog2 : Real.log 2 ≠ 0 := (Real.log_pos (by norm_num)).ne' unfold shannonMutualInfo have hterm : ∀ m : Fin 4, (if cellMass Q m = 0 then 0 else (∑ y : ι → Bool, noiseOp p (indFun (quantCell Q m)) y * Real.log (noiseOp p (indFun (quantCell Q m)) y / cellMass Q m)) / (2 : ℝ) ^ Fintype.card ι) = (1 / 2 : ℝ) * (1 - binEntropyBits p) * Real.log 2 := by intro m rcases hall m with ⟨i, j, b₁, b₂, hij, heq⟩ have hm : cellMass Q m = 1 / 4 := by unfold cellMass; rw [heq, codim2Subcube_mass hij] rw [if_neg (by rw [hm]; norm_num : cellMass Q m ≠ 0)] unfold cellMass; rw [heq] exact codim2Subcube_shannon_cell hij b₁ b₂ hp0 hp1 simp_rw [hterm, Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] field_simp [hlog2]; ring /-- Every unbalanced `(1/2, 1/4, 1/4)` ternary subcube partition achieves `I(Q; p) = (3/2) * (1 - h₂(p))` identically for all `p ∈ [0, 1]`. -/ theorem shannon_ternary_subcubePartition (Q : (ι → Bool) → Fin 3) {m₀ : Fin 3} (h1 : IsCodim1Subcube (quantCell Q m₀)) (h2 : ∀ m : Fin 3, m ≠ m₀ → IsCodim2Subcube (quantCell Q m)) {p : ℝ} (hp0 : 0 ≤ p) (hp1 : p ≤ 1) : shannonMutualInfo Q p = (3 / 2 : ℝ) * (1 - binEntropyBits p) := by have hlog2 : Real.log 2 ≠ 0 := (Real.log_pos (by norm_num)).ne' unfold shannonMutualInfo have hterm : ∀ m : Fin 3, (if cellMass Q m = 0 then 0 else (∑ y : ι → Bool, noiseOp p (indFun (quantCell Q m)) y * Real.log (noiseOp p (indFun (quantCell Q m)) y / cellMass Q m)) / (2 : ℝ) ^ Fintype.card ι) = (1 / 2 : ℝ) * (1 - binEntropyBits p) * Real.log 2 := by intro m by_cases hm : m = m₀ · subst hm rcases h1 with ⟨i, b, heq⟩ have hmass : cellMass Q m = 1 / 2 := by unfold cellMass; rw [heq, codim1Subcube_mass] rw [if_neg (by rw [hmass]; norm_num : cellMass Q m ≠ 0)] unfold cellMass; rw [heq]; exact codim1Subcube_shannon_cell i b hp0 hp1 · rcases h2 m hm with ⟨i, j, b₁, b₂, hij, heq⟩ have hmass : cellMass Q m = 1 / 4 := by unfold cellMass; rw [heq, codim2Subcube_mass hij] rw [if_neg (by rw [hmass]; norm_num : cellMass Q m ≠ 0)] unfold cellMass; rw [heq]; exact codim2Subcube_shannon_cell hij b₁ b₂ hp0 hp1 simp_rw [hterm, Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] field_simp [hlog2]; ring /-- High-noise expansion of `1 - h₂((1 - ε)/2)` deduced directly from the 1-bit dictator! -/ lemma one_sub_binEntropyBits_high_noise_approx : ∃ (δ C : ℝ), 0 < δ ∧ δ ≤ 1 ∧ 0 ≤ C ∧ ∀ ε : ℝ, |ε| < δ → |(1 - binEntropyBits ((1 - ε) / 2)) - ε ^ 2 / (2 * Real.log 2)| ≤ C * |ε| ^ 3 := by let dict : (Fin 1 → Bool) → Fin 2 := fun x => if x 0 then 1 else 0 obtain ⟨δ, C, hδ, hδ1, hC, happrox⟩ := shannonMutualInfo_high_noise_approx dict refine ⟨δ, C, hδ, hδ1, hC, fun ε hε => ?_⟩ have hcurv : curvature dict = 1 := by unfold curvature have h0 : quantCell dict 0 = Finset.univ.filter fun x : Fin 1 → Bool => x 0 = false := by unfold quantCell dict; ext x; cases hx : x 0 <;> simp [hx] have h1 : quantCell dict 1 = Finset.univ.filter fun x : Fin 1 → Bool => x 0 = true := by unfold quantCell dict; ext x; cases hx : x 0 <;> simp [hx] rw [Fin.sum_univ_two] have hm0 : cellMass dict 0 = 1 / 2 := by unfold cellMass; rw [h0, codim1Subcube_mass] have hm1 : cellMass dict 1 = 1 / 2 := by unfold cellMass; rw [h1, codim1Subcube_mass] have hne0 : (quantCell dict 0).Nonempty := ⟨fun _ => false, by simp [quantCell, dict]⟩ have hne1 : (quantCell dict 1).Nonempty := ⟨fun _ => true, by simp [quantCell, dict]⟩ have hw0 := (level1Weight_eq_half_mass_iff hne0).mpr (Or.inl ⟨0, false, h0⟩) have hw1 := (level1Weight_eq_half_mass_iff hne1).mpr (Or.inl ⟨0, true, h1⟩) rw [if_neg (by rw [hm0]; norm_num), if_neg (by rw [hm1]; norm_num)] unfold cellMass at *; rw [hw0, hw1, hm0, hm1]; norm_num have hsh : shannonMutualInfo dict ((1 - ε) / 2) = 1 - binEntropyBits ((1 - ε) / 2) := by have hp0 : 0 ≤ (1 - ε) / 2 := by linarith [(abs_le.mp (hε.le.trans hδ1)).2] have hp1 : (1 - ε) / 2 ≤ 1 := by linarith [(abs_le.mp (hε.le.trans hδ1)).1] have hlog2 : Real.log 2 ≠ 0 := (Real.log_pos (by norm_num)).ne' have h0 : quantCell dict 0 = Finset.univ.filter fun x : Fin 1 → Bool => x 0 = false := by unfold quantCell dict; ext x; cases hx : x 0 <;> simp [hx] have h1 : quantCell dict 1 = Finset.univ.filter fun x : Fin 1 → Bool => x 0 = true := by unfold quantCell dict; ext x; cases hx : x 0 <;> simp [hx] have hm0 : cellMass dict 0 = 1 / 2 := by unfold cellMass; rw [h0, codim1Subcube_mass] have hm1 : cellMass dict 1 = 1 / 2 := by unfold cellMass; rw [h1, codim1Subcube_mass] unfold shannonMutualInfo; rw [Fin.sum_univ_two, if_neg (by rw [hm0]; norm_num), if_neg (by rw [hm1]; norm_num)] unfold cellMass; rw [h0, h1, codim1Subcube_shannon_cell 0 false hp0 hp1, codim1Subcube_shannon_cell 0 true hp0 hp1] field_simp [hlog2]; ring have := happrox ε hε rw [hcurv, mul_one, hsh] at this exact this /-- **MAIN THEOREM 3A (High-Noise 2-Bit Shannon Courtade–Kumar Theorem with Strict Rigidity)**: For EVERY `n` (finite index type `ι`) and EVERY 2-bit quantizer `Q : (ι → Bool) → Fin 4` (no balance assumption!): 1. If every cell `Q⁻¹(m)` is a codimension-2 subcube, then `I(Q; p) = 2 * (1 - h₂(p))` for all `p ∈ [0, 1]`. 2. Otherwise, `Λ(Q) < 2` and there exists `δ > 0` such that for all `p` with `0 < |p - 1/2| < δ`, `I(Q; p) < 2 * (1 - h₂(p))` strictly! -/ theorem shannon_two_bit_high_noise_optimal (Q : (ι → Bool) → Fin 4) : ((∀ m : Fin 4, IsCodim2Subcube (quantCell Q m)) → ∀ p : ℝ, 0 ≤ p → p ≤ 1 → shannonMutualInfo Q p = 2 * (1 - binEntropyBits p)) ∧ ((¬ ∀ m : Fin 4, IsCodim2Subcube (quantCell Q m)) → curvature Q < 2 ∧ ∃ δ : ℝ, 0 < δ ∧ ∀ p : ℝ, 0 < |p - 1 / 2| → |p - 1 / 2| < δ → shannonMutualInfo Q p < 2 * (1 - binEntropyBits p)) := by refine ⟨fun hall p hp0 hp1 => shannon_two_bit_subcubePartition Q hall hp0 hp1, fun hnot => ?_⟩ have hle : curvature Q ≤ 2 := by have := curvature_le_half_card Q; norm_num at this; linarith have hlt : curvature Q < 2 := lt_of_le_of_ne hle fun heq => hnot ((curvature_two_bit_eq_two_iff Q).mp heq) refine ⟨hlt, ?_⟩ obtain ⟨δ₁, C₁, hδ₁, _, hC₁, ha₁⟩ := shannonMutualInfo_high_noise_approx Q obtain ⟨δ₂, C₂, hδ₂, _, hC₂, ha₂⟩ := one_sub_binEntropyBits_high_noise_approx have hlog2 : 0 < Real.log 2 := Real.log_pos (by norm_num) let gap : ℝ := (2 - curvature Q) / (2 * Real.log 2) have hgap : 0 < gap := div_pos (by linarith) (by positivity) let δ : ℝ := min (min δ₁ δ₂) (gap / (C₁ + 2 * C₂ + 1)) / 2 have hδ_pos : 0 < δ := by dsimp only [δ] apply div_pos _ (by norm_num) exact lt_min (lt_min hδ₁ hδ₂) (div_pos hgap (by positivity)) refine ⟨δ, hδ_pos, fun p hp_pos hp_lt => ?_⟩ let ε : ℝ := 1 - 2 * p have hε_abs : |ε| = 2 * |p - 1 / 2| := by have : ε = -2 * (p - 1 / 2) := by dsimp only [ε]; ring rw [this, abs_mul, abs_neg, abs_of_pos (by norm_num : (0 : ℝ) < 2)] have hε_pos : 0 < |ε| := by rw [hε_abs]; linarith have hε_lt1 : |ε| < δ₁ := by rw [hε_abs] have h1 : 2 * δ ≤ min δ₁ δ₂ := by dsimp only [δ]; linarith [min_le_left (min δ₁ δ₂) (gap / (C₁ + 2 * C₂ + 1))] linarith [min_le_left δ₁ δ₂] have hε_lt2 : |ε| < δ₂ := by rw [hε_abs] have h1 : 2 * δ ≤ min δ₁ δ₂ := by dsimp only [δ]; linarith [min_le_left (min δ₁ δ₂) (gap / (C₁ + 2 * C₂ + 1))] linarith [min_le_right δ₁ δ₂] have hε_lt_gap : |ε| < gap / (C₁ + 2 * C₂ + 1) := by rw [hε_abs] have h1 : 2 * δ ≤ gap / (C₁ + 2 * C₂ + 1) := by dsimp only [δ]; linarith [min_le_right (min δ₁ δ₂) (gap / (C₁ + 2 * C₂ + 1))] linarith have hp_eq : (1 - ε) / 2 = p := by dsimp only [ε]; ring have h1 := ha₁ ε hε_lt1 have h2 := ha₂ ε hε_lt2 rw [hp_eq] at h1 h2 have h1u := (abs_le.mp h1).2 have h2l := (abs_le.mp h2).1 have herr : (C₁ + 2 * C₂) * |ε| ^ 3 < gap * ε ^ 2 := by have hmul := (lt_div_iff₀ (show 0 < C₁ + 2 * C₂ + 1 by positivity)).mp hε_lt_gap have hsq : 0 < ε ^ 2 := sq_pos_of_ne_zero (abs_pos.mp hε_pos) have hcube : |ε| ^ 3 = ε ^ 2 * |ε| := by rw [← sq_abs ε]; ring rw [hcube] nlinarith [mul_lt_mul_of_pos_left hmul hsq] have hgap_eq : gap * ε ^ 2 = 2 * (ε ^ 2 / (2 * Real.log 2)) - ε ^ 2 / (2 * Real.log 2) * curvature Q := by dsimp only [gap]; ring linarith /-- **MAIN THEOREM 3B (High-Noise Ternary `M = 3` Exact Optimality of Unbalanced `(1/2, 1/4, 1/4)` Partition)**: For EVERY ternary quantizer `Q : (ι → Bool) → Fin 3`: 1. If `Q` is an unbalanced `(1/2, 1/4, 1/4)` ternary subcube partition, then `I(Q; p) = (3/2) * (1 - h₂(p))` for all `p ∈ [0, 1]`. 2. Otherwise (in particular for EVERY balanced ternary quantizer!), `Λ(Q) < 3/2` and there exists `δ > 0` such that `I(Q; p) < (3/2) * (1 - h₂(p))` for all `0 < |p - 1/2| < δ`! -/ theorem shannon_ternary_high_noise_optimal (Q : (ι → Bool) → Fin 3) : ((∃ m₀ : Fin 3, IsCodim1Subcube (quantCell Q m₀) ∧ ∀ m : Fin 3, m ≠ m₀ → IsCodim2Subcube (quantCell Q m)) → ∀ p : ℝ, 0 ≤ p → p ≤ 1 → shannonMutualInfo Q p = (3 / 2 : ℝ) * (1 - binEntropyBits p)) ∧ ((¬ ∃ m₀ : Fin 3, IsCodim1Subcube (quantCell Q m₀) ∧ ∀ m : Fin 3, m ≠ m₀ → IsCodim2Subcube (quantCell Q m)) → curvature Q < 3 / 2 ∧ ∃ δ : ℝ, 0 < δ ∧ ∀ p : ℝ, 0 < |p - 1 / 2| → |p - 1 / 2| < δ → shannonMutualInfo Q p < (3 / 2 : ℝ) * (1 - binEntropyBits p)) := by refine ⟨fun ⟨m₀, h1, h2⟩ p hp0 hp1 => shannon_ternary_subcubePartition Q h1 h2 hp0 hp1, fun hnot => ?_⟩ have hle : curvature Q ≤ 3 / 2 := by have := curvature_le_half_card Q; norm_num at this; linarith have hlt : curvature Q < 3 / 2 := lt_of_le_of_ne hle fun heq => hnot ((curvature_ternary_eq_three_halves_iff Q).mp heq) refine ⟨hlt, ?_⟩ obtain ⟨δ₁, C₁, hδ₁, _, hC₁, ha₁⟩ := shannonMutualInfo_high_noise_approx Q obtain ⟨δ₂, C₂, hδ₂, _, hC₂, ha₂⟩ := one_sub_binEntropyBits_high_noise_approx have hlog2 : 0 < Real.log 2 := Real.log_pos (by norm_num) let gap : ℝ := (3 / 2 - curvature Q) / (2 * Real.log 2) have hgap : 0 < gap := div_pos (by linarith) (by positivity) let δ : ℝ := min (min δ₁ δ₂) (gap / (C₁ + 2 * C₂ + 1)) / 2 have hδ_pos : 0 < δ := by dsimp only [δ] apply div_pos _ (by norm_num) exact lt_min (lt_min hδ₁ hδ₂) (div_pos hgap (by positivity)) refine ⟨δ, hδ_pos, fun p hp_pos hp_lt => ?_⟩ let ε : ℝ := 1 - 2 * p have hε_abs : |ε| = 2 * |p - 1 / 2| := by have : ε = -2 * (p - 1 / 2) := by dsimp only [ε]; ring rw [this, abs_mul, abs_neg, abs_of_pos (by norm_num : (0 : ℝ) < 2)] have hε_pos : 0 < |ε| := by rw [hε_abs]; linarith have hε_lt1 : |ε| < δ₁ := by rw [hε_abs] have h1 : 2 * δ ≤ min δ₁ δ₂ := by dsimp only [δ]; linarith [min_le_left (min δ₁ δ₂) (gap / (C₁ + 2 * C₂ + 1))] linarith [min_le_left δ₁ δ₂] have hε_lt2 : |ε| < δ₂ := by rw [hε_abs] have h1 : 2 * δ ≤ min δ₁ δ₂ := by dsimp only [δ]; linarith [min_le_left (min δ₁ δ₂) (gap / (C₁ + 2 * C₂ + 1))] linarith [min_le_right δ₁ δ₂] have hε_lt_gap : |ε| < gap / (C₁ + 2 * C₂ + 1) := by rw [hε_abs] have h1 : 2 * δ ≤ gap / (C₁ + 2 * C₂ + 1) := by dsimp only [δ]; linarith [min_le_right (min δ₁ δ₂) (gap / (C₁ + 2 * C₂ + 1))] linarith have hp_eq : (1 - ε) / 2 = p := by dsimp only [ε]; ring have h1 := ha₁ ε hε_lt1 have h2 := ha₂ ε hε_lt2 rw [hp_eq] at h1 h2 have h1u := (abs_le.mp h1).2 have h2l := (abs_le.mp h2).1 have herr : (C₁ + 3 / 2 * C₂) * |ε| ^ 3 < gap * ε ^ 2 := by have hmul := (lt_div_iff₀ (show 0 < C₁ + 2 * C₂ + 1 by positivity)).mp hε_lt_gap have hsq : 0 < ε ^ 2 := sq_pos_of_ne_zero (abs_pos.mp hε_pos) have hcube : |ε| ^ 3 = ε ^ 2 * |ε| := by rw [← sq_abs ε]; ring have hc2_nn : 0 ≤ C₂ * (ε ^ 2 * |ε|) := by positivity rw [hcube] nlinarith [mul_lt_mul_of_pos_left hmul hsq] have hgap_eq : gap * ε ^ 2 = (3 / 2) * (ε ^ 2 / (2 * Real.log 2)) - ε ^ 2 / (2 * Real.log 2) * curvature Q := by dsimp only [gap]; ring linarith /-- **Adaptive 2-Bit Decision Tree Example (`n = 3`)**: `Q_adapt(x₀, x₁, x₂) = (x₀, if x₀ then x₂ else x₁)` is NOT a 2-coordinate projection, yet achieves the exact benchmark `2 * (1 - h₂(p))` and `(1 + (1 - 2p)²)² - 1` for ALL `p ∈ [0, 1]`! -/ def adaptiveTree2Bit (x : Fin 3 → Bool) : Fin 4 := if x 0 then (if x 2 then 3 else 2) else (if x 1 then 1 else 0) theorem adaptiveTree2Bit_exact (p : ℝ) (hp0 : 0 ≤ p) (hp1 : p ≤ 1) : shannonMutualInfo adaptiveTree2Bit p = 2 * (1 - binEntropyBits p) ∧ chi2MutualInfo adaptiveTree2Bit p = (1 + (1 - 2 * p) ^ 2) ^ 2 - 1 := by have hall : ∀ m : Fin 4, IsCodim2Subcube (quantCell adaptiveTree2Bit m) := by intro m; fin_cases m · refine ⟨0, 1, false, false, by decide, ?_⟩ ext x; unfold quantCell adaptiveTree2Bit; simp only [Finset.mem_filter, Finset.mem_univ, true_and] cases x 0 <;> cases x 1 <;> cases x 2 <;> decide · refine ⟨0, 1, false, true, by decide, ?_⟩ ext x; unfold quantCell adaptiveTree2Bit; simp only [Finset.mem_filter, Finset.mem_univ, true_and] cases x 0 <;> cases x 1 <;> cases x 2 <;> decide · refine ⟨0, 2, true, false, by decide, ?_⟩ ext x; unfold quantCell adaptiveTree2Bit; simp only [Finset.mem_filter, Finset.mem_univ, true_and] cases x 0 <;> cases x 1 <;> cases x 2 <;> decide · refine ⟨0, 2, true, true, by decide, ?_⟩ ext x; unfold quantCell adaptiveTree2Bit; simp only [Finset.mem_filter, Finset.mem_univ, true_and] cases x 0 <;> cases x 1 <;> cases x 2 <;> decide refine ⟨shannon_two_bit_subcubePartition adaptiveTree2Bit hall hp0 hp1, ?_⟩ by_cases h0 : p = 0 · subst h0 rw [chi2MutualInfo_eq_fourier] have hterm : ∀ m : Fin 4, (if cellMass adaptiveTree2Bit m = 0 then 0 else (∑ S ∈ (Finset.univ : Finset (Finset (Fin 3))).erase ∅, (1 - 2 * (0 : ℝ)) ^ (2 * S.card) * fourierCoeff (indFun (quantCell adaptiveTree2Bit m)) S ^ 2) / cellMass adaptiveTree2Bit m) = 3 / 4 := by intro m rcases hall m with ⟨i, j, b₁, b₂, hij, heq⟩ have hm : cellMass adaptiveTree2Bit m = 1 / 4 := by unfold cellMass; rw [heq, codim2Subcube_mass hij] rw [if_neg (by rw [hm]; norm_num)] have hvar : ∑ S ∈ (Finset.univ : Finset (Finset (Fin 3))).erase ∅, fourierCoeff (indFun (quantCell adaptiveTree2Bit m)) S ^ 2 = cellMass adaptiveTree2Bit m * (1 - cellMass adaptiveTree2Bit m) := by have hp := parseval_indFun (quantCell adaptiveTree2Bit m) rw [← Finset.add_sum_erase _ _ (Finset.mem_univ (∅ : Finset (Fin 3))), fourierCoeff_indFun_empty] at hp unfold cellMass; linarith simp only [mul_zero, sub_zero, one_pow, one_mul, hvar, hm]; norm_num simp_rw [hterm, Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul]; norm_num · by_cases h1 : p = 1 · subst h1 rw [chi2MutualInfo_eq_fourier] have hterm : ∀ m : Fin 4, (if cellMass adaptiveTree2Bit m = 0 then 0 else (∑ S ∈ (Finset.univ : Finset (Finset (Fin 3))).erase ∅, (1 - 2 * (1 : ℝ)) ^ (2 * S.card) * fourierCoeff (indFun (quantCell adaptiveTree2Bit m)) S ^ 2) / cellMass adaptiveTree2Bit m) = 3 / 4 := by intro m rcases hall m with ⟨i, j, b₁, b₂, hij, heq⟩ have hm : cellMass adaptiveTree2Bit m = 1 / 4 := by unfold cellMass; rw [heq, codim2Subcube_mass hij] rw [if_neg (by rw [hm]; norm_num)] have hvar : ∑ S ∈ (Finset.univ : Finset (Finset (Fin 3))).erase ∅, fourierCoeff (indFun (quantCell adaptiveTree2Bit m)) S ^ 2 = cellMass adaptiveTree2Bit m * (1 - cellMass adaptiveTree2Bit m) := by have hp := parseval_indFun (quantCell adaptiveTree2Bit m) rw [← Finset.add_sum_erase _ _ (Finset.mem_univ (∅ : Finset (Fin 3))), fourierCoeff_indFun_empty] at hp unfold cellMass; linarith have hev : ∀ S : Finset (Fin 3), (1 - 2 * (1 : ℝ)) ^ (2 * S.card) = 1 := fun S => by rw [show (1 - 2 * (1 : ℝ)) = -1 by norm_num, pow_mul]; norm_num simp_rw [hev, one_mul]; rw [hvar, hm]; norm_num simp_rw [hterm, Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul]; norm_num · by_cases hh : p = 1 / 2 · subst hh; rw [chi2MutualInfo_eq_fourier] have hzero : ∀ S ∈ (Finset.univ : Finset (Finset (Fin 3))).erase ∅, (1 - 2 * (1 / 2 : ℝ)) ^ (2 * S.card) = 0 := fun S hS => by have hpos : 0 < 2 * S.card := by have := Finset.card_pos.mpr (Finset.nonempty_iff_ne_empty.mpr (Finset.mem_erase.mp hS).1) omega rw [show (1 - 2 * (1 / 2 : ℝ)) = 0 by norm_num, zero_pow hpos.ne'] have hsum0 : ∀ m : Fin 4, ∑ S ∈ (Finset.univ : Finset (Finset (Fin 3))).erase ∅, (1 - 2 * (1 / 2 : ℝ)) ^ (2 * S.card) * fourierCoeff (indFun (quantCell adaptiveTree2Bit m)) S ^ 2 = 0 := fun m => Finset.sum_eq_zero fun S hS => by rw [hzero S hS, zero_mul] simp_rw [hsum0, zero_div, ite_self, Finset.sum_const_zero]; norm_num · exact (chi2_two_bit_eq_iff adaptiveTree2Bit (lt_of_le_of_ne hp0 (Ne.symm h0)) (lt_of_le_of_ne hp1 h1) hh).mpr hall /-- **Curvature-Exceeds-`k` Criterion for Simultaneous Breakdown of Both Multibit Benchmarks**: Whenever a quantizer `Q : (ι → Bool) → α` has `k < Λ(Q)`, there exists `p ∈ (0, 1/2)` such that SIMULTANEOUSLY `I(Q; p) > k * (1 - h₂(p))` AND `I_{χ²}(Q; p) > (1 + (1 - 2p)²)ᵏ - 1`! -/ theorem exists_p_beats_both_of_curvature_gt {α : Type*} [Fintype α] [DecidableEq α] (Q : (ι → Bool) → α) {k : ℕ} (hgt : (k : ℝ) < curvature Q) : ∃ p : ℝ, 0 < p ∧ p < 1 / 2 ∧ (k : ℝ) * (1 - binEntropyBits p) < shannonMutualInfo Q p ∧ (1 + (1 - 2 * p) ^ 2) ^ k - 1 < chi2MutualInfo Q p := by obtain ⟨δ₁, C₁, hδ₁, _, hC₁, ha₁⟩ := shannonMutualInfo_high_noise_approx Q obtain ⟨δ₂, C₂, hδ₂, _, hC₂, ha₂⟩ := one_sub_binEntropyBits_high_noise_approx have hlog2 : 0 < Real.log 2 := Real.log_pos (by norm_num) let gapS : ℝ := (curvature Q - k) / (2 * Real.log 2) have hgapS : 0 < gapS := div_pos (by linarith) (by positivity) -- For `χ²`: `I_{χ²}(Q; (1-ε)/2) ≥ ε² * Λ(Q)` (since all terms are ≥ 0 and level-1 alone gives `ε² Λ(Q)`!) -- Meanwhile `(1 + ε²)^k - 1 = k * ε² + ∑_{j=2}^k C(k, j) ε^(2j) ≤ k * ε² + 2^k * ε⁴` for `ε² ≤ 1`! have hchi_lb : ∀ ε : ℝ, ε ^ 2 * curvature Q ≤ chi2MutualInfo Q ((1 - ε) / 2) := by intro ε rw [chi2MutualInfo_eq_fourier] unfold curvature; rw [Finset.mul_sum] refine Finset.sum_le_sum fun m _ => ?_ split_ifs with hm · simp · have hm_pos : 0 < cellMass Q m := lt_of_le_of_ne (setMass_nonneg _) (Ne.symm hm) rw [mul_div_assoc'] refine div_le_div_of_nonneg_right ?_ hm_pos.le let emb : ι ↪ Finset ι := ⟨fun i => {i}, Finset.singleton_injective⟩ have hsub : (Finset.univ : Finset ι).map emb ⊆ (Finset.univ : Finset (Finset ι)).erase ∅ := by intro S hS; rcases Finset.mem_map.mp hS with ⟨i, _, rfl⟩ exact Finset.mem_erase.mpr ⟨Finset.singleton_ne_empty i, Finset.mem_univ _⟩ have hsing : ε ^ 2 * level1Weight (indFun (quantCell Q m)) = ∑ S ∈ (Finset.univ : Finset ι).map emb, (1 - 2 * ((1 - ε) / 2)) ^ (2 * S.card) * fourierCoeff (indFun (quantCell Q m)) S ^ 2 := by unfold level1Weight; rw [Finset.sum_map, Finset.mul_sum] refine Finset.sum_congr rfl fun i _ => by simp only [emb, Function.Embedding.coeFn_mk, Finset.card_singleton, mul_one]; ring rw [hsing] exact Finset.sum_le_sum_of_subset_of_nonneg hsub fun S _ _ => by rw [show 1 - 2 * ((1 - ε) / 2) = ε by ring, pow_mul]; positivity have hpow_ub : ∀ t : ℝ, 0 ≤ t → t ≤ 1 → (1 + t) ^ k - 1 ≤ (k : ℝ) * t + (2 : ℝ) ^ k * t ^ 2 := by intro t ht0 ht1 rw [add_comm 1 t, add_pow] have hsplit : ∑ j ∈ Finset.range (k + 1), t ^ j * 1 ^ (k - j) * (k.choose j : ℝ) - 1 = (k : ℝ) * t + ∑ j ∈ (Finset.range (k + 1)).filter (fun j => 2 ≤ j), t ^ j * (k.choose j : ℝ) := by cases k with | zero => have hf0 : ({0} : Finset ℕ).filter (fun j => 2 ≤ j) = ∅ := by ext j; simp only [Finset.mem_filter, Finset.mem_singleton, Finset.notMem_empty, iff_false, not_and]; omega simp [hf0] | succ k' => rw [Finset.sum_range_succ', Finset.sum_range_succ'] simp only [pow_zero, mul_one, Nat.choose_zero_right, Nat.cast_one, one_pow, zero_add, pow_one, Nat.choose_one_right, Nat.cast_add] have hfilt : (Finset.range (k' + 1 + 1)).filter (fun j => 2 ≤ j) = (Finset.range k').image (· + 2) := by ext j; simp only [Finset.mem_filter, Finset.mem_range, Finset.mem_image] constructor · rintro ⟨hj, h2⟩; exact ⟨j - 2, by omega, by omega⟩ · rintro ⟨m, hm, rfl⟩; omega rw [hfilt, Finset.sum_image (fun _ _ _ _ h => by omega)] have hsum_eq : ∑ x ∈ Finset.range k', t ^ (x + 1 + 1) * ((k' + 1).choose (x + 1 + 1) : ℝ) = ∑ x ∈ Finset.range k', t ^ (x + 2) * ((k' + 1).choose (x + 2) : ℝ) := Finset.sum_congr rfl fun x _ => by rfl rw [hsum_eq]; ring rw [hsplit] have hrem : ∑ j ∈ (Finset.range (k + 1)).filter (fun j => 2 ≤ j), t ^ j * (k.choose j : ℝ) ≤ (2 : ℝ) ^ k * t ^ 2 := by calc ∑ j ∈ (Finset.range (k + 1)).filter (fun j => 2 ≤ j), t ^ j * (k.choose j : ℝ) ≤ ∑ j ∈ (Finset.range (k + 1)).filter (fun j => 2 ≤ j), t ^ 2 * (k.choose j : ℝ) := by refine Finset.sum_le_sum fun j hj => ?_ have hj2 : 2 ≤ j := (Finset.mem_filter.mp hj).2 exact mul_le_mul_of_nonneg_right (pow_le_pow_of_le_one ht0 ht1 hj2) (Nat.cast_nonneg _) _ ≤ ∑ j ∈ Finset.range (k + 1), t ^ 2 * (k.choose j : ℝ) := Finset.sum_le_sum_of_subset_of_nonneg (Finset.filter_subset _ _) fun _ _ _ => by positivity _ = (2 : ℝ) ^ k * t ^ 2 := by rw [← Finset.mul_sum, ← Nat.cast_sum, Nat.sum_range_choose, Nat.cast_pow, Nat.cast_ofNat, mul_comm] linarith -- Choose `ε > 0` small enough for BOTH inequalities simultaneously! let δ : ℝ := min (min (min δ₁ δ₂) (1 / 2)) (min (gapS / (C₁ + (k : ℝ) * C₂ + 1)) ((curvature Q - k) / ((2 : ℝ) ^ k + 1))) have hδ_pos : 0 < δ := by dsimp only [δ] exact lt_min (lt_min (lt_min hδ₁ hδ₂) (by norm_num)) (lt_min (div_pos hgapS (by positivity)) (div_pos (by linarith) (by positivity))) let ε : ℝ := δ / 2 have hε_pos : 0 < ε := by dsimp only [ε]; linarith have hε_lt_δ : ε < δ := by dsimp only [ε]; linarith have hε_lt_half : ε < 1 / 2 := lt_of_lt_of_le hε_lt_δ ((min_le_left _ _).trans (min_le_right _ _)) have hε_lt1 : |ε| < δ₁ := by rw [abs_of_pos hε_pos] exact lt_of_lt_of_le hε_lt_δ (((min_le_left _ _).trans (min_le_left _ _)).trans (min_le_left _ _)) have hε_lt2 : |ε| < δ₂ := by rw [abs_of_pos hε_pos] exact lt_of_lt_of_le hε_lt_δ (((min_le_left _ _).trans (min_le_left _ _)).trans (min_le_right _ _)) have hε_lt_S : ε < gapS / (C₁ + (k : ℝ) * C₂ + 1) := lt_of_lt_of_le hε_lt_δ ((min_le_right _ _).trans (min_le_left _ _)) have hε_lt_C : ε < (curvature Q - k) / ((2 : ℝ) ^ k + 1) := lt_of_lt_of_le hε_lt_δ ((min_le_right _ _).trans (min_le_right _ _)) let p : ℝ := (1 - ε) / 2 refine ⟨p, by dsimp only [p]; linarith, by dsimp only [p]; linarith, ?_, ?_⟩ · -- Shannon beat: have h1 := (abs_le.mp (ha₁ ε hε_lt1)).1 have h2 := (abs_le.mp (ha₂ ε hε_lt2)).2 rw [abs_of_pos hε_pos] at h1 h2 have hmul := (lt_div_iff₀ (show 0 < C₁ + (k : ℝ) * C₂ + 1 by positivity)).mp hε_lt_S have hsq : 0 < ε ^ 2 := sq_pos_of_pos hε_pos have herr : (C₁ + (k : ℝ) * C₂) * ε ^ 3 < gapS * ε ^ 2 := by have : ε ^ 3 = ε ^ 2 * ε := by ring rw [this]; nlinarith [mul_lt_mul_of_pos_left hmul hsq] have hgap_eq : gapS * ε ^ 2 = ε ^ 2 / (2 * Real.log 2) * curvature Q - (k : ℝ) * (ε ^ 2 / (2 * Real.log 2)) := by dsimp only [gapS]; ring have h2k := mul_le_mul_of_nonneg_left h2 (Nat.cast_nonneg k) dsimp only [p]; linarith · -- `χ²` beat: have h1sub : 1 - 2 * p = ε := by dsimp only [p]; ring rw [h1sub] have hlb := hchi_lb ε have hub := hpow_ub (ε ^ 2) (sq_nonneg ε) (by nlinarith) have hmul := (lt_div_iff₀ (show 0 < (2 : ℝ) ^ k + 1 by positivity)).mp hε_lt_C have hε2_lt : ε ^ 2 < ε := by nlinarith have hsq : 0 < ε ^ 2 := sq_pos_of_pos hε_pos have hstrict : (2 : ℝ) ^ k * (ε ^ 2) ^ 2 < (curvature Q - k) * ε ^ 2 := by have h1 : (2 : ℝ) ^ k * ε ^ 2 < curvature Q - k := by nlinarith nlinarith dsimp only [p]; linarith end HighNoiseShannon /-! ## Section 5: Perfect Hamming Codes `Ham_r` (`r ≥ 4`) & Breakdown for All `k ≥ 11` -/ section PerfectHammingBreakdown /-- Nonzero binary vectors of length `r` (columns of the parity-check matrix of `Ham_r`). -/ abbrev NonzeroVec (r : ℕ) := {v : Fin r → ZMod 2 // v ≠ 0} lemma card_nonzeroVec (r : ℕ) : Fintype.card (NonzeroVec r) = 2 ^ r - 1 := by have hcard0 : Fintype.card {v : Fin r → ZMod 2 // v = 0} = 1 := Fintype.card_eq_one_iff.mpr ⟨⟨0, rfl⟩, fun ⟨v, hv⟩ => Subtype.ext hv⟩ have h1 : Fintype.card (NonzeroVec r) = Fintype.card (Fin r → ZMod 2) - 1 := by rw [Fintype.card_subtype_compl, hcard0] rw [h1, Fintype.card_fun, ZMod.card, Fintype.card_fin] /-- Parity-check syndrome of `x : NonzeroVec r → Bool` in `Fin r → ZMod 2`. -/ def hamSyndrome (r : ℕ) (x : NonzeroVec r → Bool) : Fin r → ZMod 2 := ∑ i : NonzeroVec r, if x i then i.1 else 0 lemma hamSyndrome_flipBit (r : ℕ) (x : NonzeroVec r → Bool) (i₀ : NonzeroVec r) : hamSyndrome r (flipBit x i₀) = hamSyndrome r x + i₀.1 := by unfold hamSyndrome rw [← Finset.add_sum_erase _ _ (Finset.mem_univ i₀), ← Finset.add_sum_erase _ _ (Finset.mem_univ i₀)] have hrest : ∑ i ∈ (Finset.univ : Finset (NonzeroVec r)).erase i₀, (if flipBit x i₀ i then i.1 else 0) = ∑ i ∈ (Finset.univ : Finset (NonzeroVec r)).erase i₀, (if x i then i.1 else 0) := Finset.sum_congr rfl fun i hi => by rw [flipBit_apply_ne x (Finset.mem_erase.mp hi).1] rw [hrest, flipBit_apply_self] ext j cases hx : x i₀ <;> simp only [Bool.not_false, Bool.not_true, Bool.false_eq_true, ↓reduceIte, Pi.add_apply, Pi.zero_apply, zero_add] · ring · have h2 : i₀.1 j + i₀.1 j = 0 := CharTwo.add_self_eq_zero (i₀.1 j) calc (∑ i ∈ (Finset.univ : Finset (NonzeroVec r)).erase i₀, if x i then i.1 else 0) j = (i₀.1 j + i₀.1 j) + (∑ i ∈ (Finset.univ : Finset (NonzeroVec r)).erase i₀, if x i then i.1 else 0) j := by rw [h2, zero_add] _ = i₀.1 j + (∑ i ∈ (Finset.univ : Finset (NonzeroVec r)).erase i₀, if x i then i.1 else 0) j + i₀.1 j := by ring /-- Subtype of Hamming codewords `{c : NonzeroVec r → Bool // hamSyndrome r c = 0}`. -/ abbrev HamCodeword (r : ℕ) := {c : NonzeroVec r → Bool // hamSyndrome r c = 0} /-- Voronoi nearest-codeword decoder of the perfect binary Hamming code `Ham_r`: if `hamSyndrome x = 0`, return `x`; otherwise flip the unique coordinate matching `hamSyndrome x`! -/ def hamDecode (r : ℕ) (x : NonzeroVec r → Bool) : HamCodeword r := if h : hamSyndrome r x = 0 then ⟨x, h⟩ else ⟨flipBit x ⟨hamSyndrome r x, h⟩, by rw [hamSyndrome_flipBit] ext j; simp only [Pi.add_apply, Pi.zero_apply] exact CharTwo.add_self_eq_zero (hamSyndrome r x j)⟩ /-- Exact radius-1 Hamming ball characterization of every Voronoi cell of `hamDecode r`: `hamDecode r x = c ↔ x = c.1 ∨ ∃ i, x = flipBit c.1 i`. -/ lemma hamDecode_eq_iff (r : ℕ) (x : NonzeroVec r → Bool) (c : HamCodeword r) : hamDecode r x = c ↔ x = c.1 ∨ ∃ i : NonzeroVec r, x = flipBit c.1 i := by constructor · intro heq unfold hamDecode at heq split_ifs at heq with hs · left; exact congrArg Subtype.val heq · right refine ⟨⟨hamSyndrome r x, hs⟩, ?_⟩ have hval : flipBit x ⟨hamSyndrome r x, hs⟩ = c.1 := congrArg Subtype.val heq have hff : flipBit (flipBit x ⟨hamSyndrome r x, hs⟩) ⟨hamSyndrome r x, hs⟩ = x := flipBit_involutive _ x rw [← hval, hff] · rintro (rfl | ⟨i, rfl⟩) · unfold hamDecode; rw [dif_pos c.2] · have hs : hamSyndrome r (flipBit c.1 i) = i.1 := by rw [hamSyndrome_flipBit, c.2, zero_add] unfold hamDecode rw [dif_neg (by rw [hs]; exact i.2)] apply Subtype.ext dsimp only have hsub : (⟨hamSyndrome r (flipBit c.1 i), by rw [hs]; exact i.2⟩ : NonzeroVec r) = i := Subtype.ext hs rw [hsub] exact flipBit_involutive i c.1 /-- Every Voronoi cell of `hamDecode r` has exact cardinality `2^r`. -/ lemma hamDecode_cell_card (r : ℕ) (c : HamCodeword r) : (quantCell (hamDecode r) c).card = 2 ^ r := by let emb : NonzeroVec r ↪ (NonzeroVec r → Bool) := ⟨fun i => flipBit c.1 i, fun i j hij => by by_contra hne have h1 : flipBit c.1 i i = flipBit c.1 j i := congrFun hij i rw [flipBit_apply_self, flipBit_apply_ne c.1 hne] at h1 cases hc : c.1 i <;> simp [hc] at h1⟩ have hcell : quantCell (hamDecode r) c = insert c.1 ((Finset.univ : Finset (NonzeroVec r)).map emb) := by ext x simp only [quantCell, Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_insert, Finset.mem_map, hamDecode_eq_iff] constructor · rintro (rfl | ⟨i, rfl⟩) · left; rfl · right; exact ⟨i, rfl⟩ · rintro (rfl | ⟨i, rfl⟩) · left; rfl · right; exact ⟨i, rfl⟩ have hnotmem : c.1 ∉ (Finset.univ : Finset (NonzeroVec r)).map emb := by intro hmem; rcases Finset.mem_map.mp hmem with ⟨i, _, hi⟩ have h1 : flipBit c.1 i i = c.1 i := congrFun hi i rw [flipBit_apply_self] at h1 cases hc : c.1 i <;> simp [hc] at h1 rw [hcell, Finset.card_insert_of_notMem hnotmem, Finset.card_map, Finset.card_univ, card_nonzeroVec] have hpos : 1 ≤ 2 ^ r := Nat.one_le_two_pow omega /-- Exact count of codewords in `Ham_r` (proved purely by ball-packing, no rank-nullity needed!): `|HamCodeword r| = 2 ^ (2^r - 1 - r)` for `r ≥ 1`. -/ lemma card_hamCodeword {r : ℕ} (hr : 1 ≤ r) : Fintype.card (HamCodeword r) = 2 ^ (2 ^ r - 1 - r) := by have htot : ∑ c : HamCodeword r, (quantCell (hamDecode r) c).card = 2 ^ (2 ^ r - 1) := by rw [← Finset.card_biUnion] · have hu : (Finset.univ : Finset (HamCodeword r)).biUnion (fun c => quantCell (hamDecode r) c) = Finset.univ := by ext x; simp [quantCell] rw [hu, Finset.card_univ, Fintype.card_fun, Fintype.card_bool, card_nonzeroVec] · intro a _ b _ hab change Disjoint _ _ rw [Finset.disjoint_left] intro x hx1 hx2 exact hab ((Finset.mem_filter.mp hx1).2.symm.trans (Finset.mem_filter.mp hx2).2) simp_rw [hamDecode_cell_card, Finset.sum_const, Finset.card_univ, smul_eq_mul] at htot have hge : r ≤ 2 ^ r - 1 := by have := Nat.lt_two_pow_self (n := r); omega have hpow : 2 ^ (2 ^ r - 1) = 2 ^ (2 ^ r - 1 - r) * 2 ^ r := by rw [← pow_add, Nat.sub_add_cancel hge] rw [hpow] at htot exact Nat.eq_of_mul_eq_mul_right (by positivity : 0 < 2 ^ r) htot /-- **Exact Closed-Form Curvature of the Perfect Binary Hamming Code `Ham_r`**: For EVERY `r ≥ 1`, `Λ(hamDecode r) = (2^r - 1) * (1 - 2 / 2^r)²`. -/ theorem hammingQuantizer_curvature {r : ℕ} (hr : 1 ≤ r) : curvature (hamDecode r) = ((2 : ℝ) ^ r - 1) * (1 - 2 / (2 : ℝ) ^ r) ^ 2 := by have hcardN : Fintype.card (NonzeroVec r) = 2 ^ r - 1 := card_nonzeroVec r have hcardC : Fintype.card (HamCodeword r) = 2 ^ (2 ^ r - 1 - r) := card_hamCodeword hr have hge : r ≤ 2 ^ r - 1 := by have := Nat.lt_two_pow_self (n := r); omega have h2r_pos : (0 : ℝ) < (2 : ℝ) ^ r := by positivity have h2n_pos : (0 : ℝ) < (2 : ℝ) ^ (2 ^ r - 1) := by positivity -- Exact mass of every cell `c`: `2^r / 2^(2^r - 1)`. have hmass : ∀ c : HamCodeword r, cellMass (hamDecode r) c = (2 : ℝ) ^ r / (2 : ℝ) ^ (2 ^ r - 1) := by intro c; unfold cellMass setMass; rw [hamDecode_cell_card, hcardN]; norm_cast -- Exact single-coordinate Fourier coefficient `f̂_c({i}) = ((2^r - 2) * boolSign (c.1 i)) / 2^(2^r - 1)`! have hfc1 : ∀ (c : HamCodeword r) (i : NonzeroVec r), fourierCoeff (indFun (quantCell (hamDecode r) c)) {i} = ((2 : ℝ) ^ r - 2) * boolSign (c.1 i) / (2 : ℝ) ^ (2 ^ r - 1) := by intro c i unfold fourierCoeff indFun rw [hcardN] congr 1 simp_rw [walsh_singleton, ite_mul, one_mul, zero_mul, ← Finset.sum_filter] have hf : Finset.univ.filter (fun x : NonzeroVec r → Bool => x ∈ quantCell (hamDecode r) c) = quantCell (hamDecode r) c := by ext x; simp rw [hf] let emb : NonzeroVec r ↪ (NonzeroVec r → Bool) := ⟨fun j => flipBit c.1 j, fun j₁ j₂ hij => by by_contra hne have h1 : flipBit c.1 j₁ j₁ = flipBit c.1 j₂ j₁ := congrFun hij j₁ rw [flipBit_apply_self, flipBit_apply_ne c.1 hne] at h1 cases hc : c.1 j₁ <;> simp [hc] at h1⟩ have hcell : quantCell (hamDecode r) c = insert c.1 ((Finset.univ : Finset (NonzeroVec r)).map emb) := by ext x simp only [quantCell, Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_insert, Finset.mem_map, hamDecode_eq_iff] constructor · rintro (rfl | ⟨j, rfl⟩) · left; rfl · right; exact ⟨j, rfl⟩ · rintro (rfl | ⟨j, rfl⟩) · left; rfl · right; exact ⟨j, rfl⟩ have hnotmem : c.1 ∉ (Finset.univ : Finset (NonzeroVec r)).map emb := by intro hmem; rcases Finset.mem_map.mp hmem with ⟨j, _, hj⟩ have h1 : flipBit c.1 j j = c.1 j := congrFun hj j rw [flipBit_apply_self] at h1 cases hc : c.1 j <;> simp [hc] at h1 rw [hcell, Finset.sum_insert hnotmem, Finset.sum_map] rw [← Finset.add_sum_erase _ _ (Finset.mem_univ i)] have hrest : ∑ j ∈ (Finset.univ : Finset (NonzeroVec r)).erase i, boolSign (emb j i) = (((2 ^ r - 1) - 1 : ℕ) : ℝ) * boolSign (c.1 i) := by have hpt : ∀ j ∈ (Finset.univ : Finset (NonzeroVec r)).erase i, boolSign (emb j i) = boolSign (c.1 i) := fun j hj => by change boolSign (flipBit c.1 j i) = boolSign (c.1 i) rw [flipBit_apply_ne c.1 (Finset.mem_erase.mp hj).1.symm] rw [Finset.sum_congr rfl hpt, Finset.sum_const, Finset.card_erase_of_mem (Finset.mem_univ i), Finset.card_univ, hcardN, nsmul_eq_mul] have hself : boolSign (emb i i) = -boolSign (c.1 i) := by change boolSign (flipBit c.1 i i) = -boolSign (c.1 i) rw [flipBit_apply_self, boolSign_not] rw [hrest, hself] have h2r_ge2 : 2 ≤ 2 ^ r := by calc 2 = 2 ^ 1 := by norm_num _ ≤ 2 ^ r := Nat.pow_le_pow_right (by norm_num) hr have hcast : (((2 ^ r - 1 - 1 : ℕ) : ℝ)) = (2 : ℝ) ^ r - 2 := by have h1 : 2 ^ r - 1 - 1 + 2 = 2 ^ r := by omega have h2 : (((2 ^ r - 1 - 1 : ℕ) : ℝ)) + 2 = (2 : ℝ) ^ r := by exact_mod_cast h1 linarith rw [hcast]; ring -- Sum over all `2^(2^r - 1 - r)` codewords: unfold curvature have hterm : ∀ c : HamCodeword r, (if cellMass (hamDecode r) c = 0 then 0 else level1Weight (indFun (quantCell (hamDecode r) c)) / cellMass (hamDecode r) c) = ((2 : ℝ) ^ r - 1) * ((2 : ℝ) ^ r - 2) ^ 2 / ((2 : ℝ) ^ r * (2 : ℝ) ^ (2 ^ r - 1)) := by intro c rw [hmass c, if_neg (by positivity)] unfold level1Weight have hsq : ∀ i : NonzeroVec r, fourierCoeff (indFun (quantCell (hamDecode r) c)) {i} ^ 2 = ((2 : ℝ) ^ r - 2) ^ 2 / ((2 : ℝ) ^ (2 ^ r - 1)) ^ 2 := by intro i; rw [hfc1 c i, div_pow, mul_pow, boolSign_sq, mul_one] simp_rw [hsq, Finset.sum_const, Finset.card_univ, hcardN, nsmul_eq_mul] have hcastN : ((2 ^ r - 1 : ℕ) : ℝ) = (2 : ℝ) ^ r - 1 := by rw [Nat.cast_sub (Nat.one_le_two_pow : 1 ≤ 2 ^ r)]; norm_num rw [hcastN]; field_simp [h2r_pos.ne', h2n_pos.ne'] simp_rw [hterm, Finset.sum_const, Finset.card_univ, hcardC, nsmul_eq_mul] have hpow : (2 : ℝ) ^ (2 ^ r - 1) = (2 : ℝ) ^ (2 ^ r - 1 - r) * (2 : ℝ) ^ r := by rw [← pow_add, Nat.sub_add_cancel hge] have h2k_pos : (0 : ℝ) < (2 : ℝ) ^ (2 ^ r - 1 - r) := by positivity rw [Nat.cast_pow, Nat.cast_ofNat, hpow] field_simp [h2r_pos.ne', h2k_pos.ne'] /-- For every `r ≥ 4`, `Ham_r` (`k = 2^r - 1 - r`) strictly exceeds the coordinate-projection curvature benchmark: `k < Λ(Ham_r)`. -/ theorem hammingQuantizer_curvature_gt {r : ℕ} (hr : 4 ≤ r) : ((2 ^ r - 1 - r : ℕ) : ℝ) < curvature (hamDecode r) := by rw [hammingQuantizer_curvature (by omega)] have hge : r ≤ 2 ^ r - 1 := by have := Nat.lt_two_pow_self (n := r); omega have hcast : ((2 ^ r - 1 - r : ℕ) : ℝ) = (2 : ℝ) ^ r - 1 - (r : ℝ) := by have h1 : 2 ^ r - 1 - r + (r + 1) = 2 ^ r := by omega have h2 : ((2 ^ r - 1 - r : ℕ) : ℝ) + ((r : ℝ) + 1) = (2 : ℝ) ^ r := by exact_mod_cast h1 linarith rw [hcast] have h2r_ge16 : (16 : ℝ) ≤ (2 : ℝ) ^ r := by calc (16 : ℝ) = (2 : ℝ) ^ 4 := by norm_num _ ≤ (2 : ℝ) ^ r := pow_le_pow_right₀ (by norm_num) hr have hrR : (4 : ℝ) ≤ (r : ℝ) := by exact_mod_cast hr have h2r_pos : (0 : ℝ) < (2 : ℝ) ^ r := by positivity have hident : ((2 : ℝ) ^ r - 1) * (1 - 2 / (2 : ℝ) ^ r) ^ 2 - ((2 : ℝ) ^ r - 1 - (r : ℝ)) = ((r : ℝ) - 4) + (8 * (2 : ℝ) ^ r - 4) / ((2 : ℝ) ^ r) ^ 2 := by field_simp [h2r_pos.ne']; ring have hpos2 : (0 : ℝ) < (8 * (2 : ℝ) ^ r - 4) / ((2 : ℝ) ^ r) ^ 2 := div_pos (by linarith) (sq_pos_of_pos h2r_pos) linarith /-- Direct-sum product of two quantizers `Q₁ : (ι₁ → Bool) → α₁` and `Q₂ : (ι₂ → Bool) → α₂`. -/ def prodQuant {ι₁ ι₂ α₁ α₂ : Type*} (Q₁ : (ι₁ → Bool) → α₁) (Q₂ : (ι₂ → Bool) → α₂) : ((ι₁ ⊕ ι₂) → Bool) → α₁ × α₂ := fun z => (Q₁ (fun i => z (Sum.inl i)), Q₂ (fun j => z (Sum.inr j))) /-- Equivalence splitting `(ι₁ ⊕ ι₂) → Bool` into `(ι₁ → Bool) × (ι₂ → Bool)`. -/ def sumSplitEquiv (ι₁ ι₂ : Type*) : ((ι₁ ⊕ ι₂) → Bool) ≃ (ι₁ → Bool) × (ι₂ → Bool) where toFun z := (fun i => z (Sum.inl i), fun j => z (Sum.inr j)) invFun p := Sum.elim p.1 p.2 left_inv z := by ext s; cases s <;> rfl right_inv p := by rcases p with ⟨x, y⟩; rfl /-- Exact additivity of high-noise curvature under direct sum: `Λ(Q₁ ⊗ Q₂) = Λ(Q₁) + Λ(Q₂)`. -/ theorem curvature_prodQuant {ι₁ ι₂ α₁ α₂ : Type*} [Fintype ι₁] [DecidableEq ι₁] [Fintype ι₂] [DecidableEq ι₂] [Fintype α₁] [DecidableEq α₁] [Fintype α₂] [DecidableEq α₂] (Q₁ : (ι₁ → Bool) → α₁) (Q₂ : (ι₂ → Bool) → α₂) : curvature (prodQuant Q₁ Q₂) = curvature Q₁ + curvature Q₂ := by have hmass : ∀ (m₁ : α₁) (m₂ : α₂), cellMass (prodQuant Q₁ Q₂) (m₁, m₂) = cellMass Q₁ m₁ * cellMass Q₂ m₂ := by intro m₁ m₂ unfold cellMass setMass quantCell prodQuant rw [Fintype.card_sum, pow_add, ← mul_div_mul_comm] congr 1 have hnat : (Finset.univ.filter fun z : (ι₁ ⊕ ι₂) → Bool => (Q₁ (fun i => z (Sum.inl i)), Q₂ (fun j => z (Sum.inr j))) = (m₁, m₂)).card = (Finset.univ.filter fun x : ι₁ → Bool => Q₁ x = m₁).card * (Finset.univ.filter fun y : ι₂ → Bool => Q₂ y = m₂).card := by rw [← Finset.card_product] refine Finset.card_bij (fun z _ => sumSplitEquiv ι₁ ι₂ z) ?_ ?_ ?_ · intro z hz have h := Prod.mk.inj (Finset.mem_filter.mp hz).2 exact Finset.mem_product.mpr ⟨Finset.mem_filter.mpr ⟨Finset.mem_univ _, h.1⟩, Finset.mem_filter.mpr ⟨Finset.mem_univ _, h.2⟩⟩ · intro z₁ _ z₂ _ h; exact (sumSplitEquiv ι₁ ι₂).injective h · intro p hp rcases Finset.mem_product.mp hp with ⟨hp1, hp2⟩ refine ⟨(sumSplitEquiv ι₁ ι₂).symm p, Finset.mem_filter.mpr ⟨Finset.mem_univ _, ?_⟩, (sumSplitEquiv ι₁ ι₂).apply_symm_apply p⟩ exact Prod.ext (Finset.mem_filter.mp hp1).2 (Finset.mem_filter.mp hp2).2 exact_mod_cast hnat have hfc_inl : ∀ (m₁ : α₁) (m₂ : α₂) (i : ι₁), fourierCoeff (indFun (quantCell (prodQuant Q₁ Q₂) (m₁, m₂))) {Sum.inl i} = fourierCoeff (indFun (quantCell Q₁ m₁)) {i} * cellMass Q₂ m₂ := by intro m₁ m₂ i unfold fourierCoeff cellMass setMass indFun quantCell prodQuant rw [Fintype.card_sum, pow_add, ← mul_div_mul_comm] congr 1 refine (Fintype.sum_equiv (sumSplitEquiv ι₁ ι₂) _ (fun p : (ι₁ → Bool) × (ι₂ → Bool) => (if Q₁ p.1 = m₁ then (1 : ℝ) else 0) * boolSign (p.1 i) * (if Q₂ p.2 = m₂ then (1 : ℝ) else 0)) (fun z => by dsimp only [sumSplitEquiv, Equiv.coe_fn_mk] simp only [Finset.mem_filter, Finset.mem_univ, true_and, Prod.mk.injEq, walsh_singleton] by_cases h1 : Q₁ (fun k => z (Sum.inl k)) = m₁ <;> by_cases h2 : Q₂ (fun k => z (Sum.inr k)) = m₂ <;> simp [h1, h2])).trans ?_ rw [Fintype.sum_prod_type] have hinner : ∀ x : ι₁ → Bool, ∑ y : ι₂ → Bool, (if Q₁ x = m₁ then (1 : ℝ) else 0) * boolSign (x i) * (if Q₂ y = m₂ then (1 : ℝ) else 0) = ((if Q₁ x = m₁ then (1 : ℝ) else 0) * boolSign (x i)) * ((Finset.univ.filter fun y : ι₂ → Bool => Q₂ y = m₂).card : ℝ) := fun x => by rw [← Finset.mul_sum, ← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul, mul_one] simp_rw [hinner, ← Finset.sum_mul] congr 1 refine Finset.sum_congr rfl fun x _ => by simp [walsh_singleton] have hfc_inr : ∀ (m₁ : α₁) (m₂ : α₂) (j : ι₂), fourierCoeff (indFun (quantCell (prodQuant Q₁ Q₂) (m₁, m₂))) {Sum.inr j} = cellMass Q₁ m₁ * fourierCoeff (indFun (quantCell Q₂ m₂)) {j} := by intro m₁ m₂ j unfold fourierCoeff cellMass setMass indFun quantCell prodQuant rw [Fintype.card_sum, pow_add, ← mul_div_mul_comm] congr 1 refine (Fintype.sum_equiv (sumSplitEquiv ι₁ ι₂) _ (fun p : (ι₁ → Bool) × (ι₂ → Bool) => (if Q₁ p.1 = m₁ then (1 : ℝ) else 0) * ((if Q₂ p.2 = m₂ then (1 : ℝ) else 0) * boolSign (p.2 j))) (fun z => by dsimp only [sumSplitEquiv, Equiv.coe_fn_mk] simp only [Finset.mem_filter, Finset.mem_univ, true_and, Prod.mk.injEq, walsh_singleton] by_cases h1 : Q₁ (fun k => z (Sum.inl k)) = m₁ <;> by_cases h2 : Q₂ (fun k => z (Sum.inr k)) = m₂ <;> simp [h1, h2])).trans ?_ rw [Fintype.sum_prod_type] have hinner : ∀ x : ι₁ → Bool, ∑ y : ι₂ → Bool, (if Q₁ x = m₁ then (1 : ℝ) else 0) * ((if Q₂ y = m₂ then (1 : ℝ) else 0) * boolSign (y j)) = (if Q₁ x = m₁ then (1 : ℝ) else 0) * ∑ y : ι₂ → Bool, (if Q₂ y = m₂ then (1 : ℝ) else 0) * boolSign (y j) := fun x => by rw [← Finset.mul_sum] simp_rw [hinner, ← Finset.sum_mul, ← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul, mul_one] congr 1 refine Finset.sum_congr rfl fun y _ => by simp [walsh_singleton] have hw1 : ∀ (m₁ : α₁) (m₂ : α₂), level1Weight (indFun (quantCell (prodQuant Q₁ Q₂) (m₁, m₂))) = level1Weight (indFun (quantCell Q₁ m₁)) * cellMass Q₂ m₂ ^ 2 + cellMass Q₁ m₁ ^ 2 * level1Weight (indFun (quantCell Q₂ m₂)) := by intro m₁ m₂ unfold level1Weight rw [Fintype.sum_sum_type] simp_rw [hfc_inl, hfc_inr, mul_pow, ← Finset.sum_mul, ← Finset.mul_sum] unfold curvature rw [Fintype.sum_prod_type] have hterm : ∀ (m₁ : α₁) (m₂ : α₂), (if cellMass (prodQuant Q₁ Q₂) (m₁, m₂) = 0 then 0 else level1Weight (indFun (quantCell (prodQuant Q₁ Q₂) (m₁, m₂))) / cellMass (prodQuant Q₁ Q₂) (m₁, m₂)) = (if cellMass Q₁ m₁ = 0 then 0 else level1Weight (indFun (quantCell Q₁ m₁)) / cellMass Q₁ m₁) * cellMass Q₂ m₂ + cellMass Q₁ m₁ * (if cellMass Q₂ m₂ = 0 then 0 else level1Weight (indFun (quantCell Q₂ m₂)) / cellMass Q₂ m₂) := by intro m₁ m₂ rw [hmass, hw1] by_cases h1 : cellMass Q₁ m₁ = 0 · simp [h1] · by_cases h2 : cellMass Q₂ m₂ = 0 · simp [h2] · rw [if_neg (mul_ne_zero h1 h2), if_neg h1, if_neg h2] field_simp [h1, h2] simp_rw [hterm, Finset.sum_add_distrib, ← Finset.mul_sum, ← Finset.sum_mul, sum_cellMass, mul_one, one_mul] /-- Identity coordinate-projection quantizer `id : (Fin t → Bool) → (Fin t → Bool)` has curvature `t`. -/ lemma curvature_id_cube (t : ℕ) : curvature (id : (Fin t → Bool) → (Fin t → Bool)) = (t : ℝ) := by unfold curvature have hcell : ∀ y : Fin t → Bool, quantCell (id : (Fin t → Bool) → (Fin t → Bool)) y = {y} := by intro y; ext x; simp [quantCell] have hmass : ∀ y : Fin t → Bool, cellMass (id : (Fin t → Bool) → (Fin t → Bool)) y = 1 / (2 : ℝ) ^ t := by intro y; unfold cellMass setMass; rw [hcell, Finset.card_singleton, Fintype.card_fin]; norm_num have hfc : ∀ (y : Fin t → Bool) (i : Fin t), fourierCoeff (indFun {y}) {i} = boolSign (y i) / (2 : ℝ) ^ t := by intro y i; unfold fourierCoeff indFun simp only [Finset.mem_singleton, ite_mul, one_mul, zero_mul, Finset.sum_ite_eq', Finset.mem_univ, ↓reduceIte, walsh_singleton, Fintype.card_fin] have hterm : ∀ y : Fin t → Bool, (if cellMass (id : (Fin t → Bool) → (Fin t → Bool)) y = 0 then 0 else level1Weight (indFun (quantCell (id : (Fin t → Bool) → (Fin t → Bool)) y)) / cellMass (id : (Fin t → Bool) → (Fin t → Bool)) y) = (t : ℝ) / (2 : ℝ) ^ t := by intro y; rw [hmass y, if_neg (by positivity), hcell] unfold level1Weight simp_rw [hfc, div_pow, boolSign_sq, Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] have h2t : (0 : ℝ) < (2 : ℝ) ^ t := by positivity field_simp [h2t.ne'] simp_rw [hterm, Finset.sum_const, Finset.card_univ, Fintype.card_fun, Fintype.card_bool, Fintype.card_fin, nsmul_eq_mul, Nat.cast_pow, Nat.cast_ofNat] rw [mul_div_cancel₀ _ (by positivity)] /-- **MAIN THEOREM 4A (Infinite Perfect-Hamming Simultaneous Breakdown, `r ≥ 4`)**: For EVERY `r ≥ 4`, letting `n = 2^r - 1` and `k = 2^r - 1 - r`, there exist a balanced `k`-bit quantizer `Q : (Fin n → Bool) → Fin (2^k)` (relabeled `Ham_r`) and a crossover probability `p ∈ (0, 1/2)` that SIMULTANEOUSLY beat BOTH the Shannon coordinate-projection benchmark `k * (1 - h₂(p))` AND the `χ²` coordinate-projection benchmark `(1 + (1 - 2p)²)ᵏ - 1`! -/ theorem perfect_hamming_beats_both_benchmarks {r : ℕ} (hr : 4 ≤ r) : let n := 2 ^ r - 1 let k := 2 ^ r - 1 - r ∃ (Q : (Fin n → Bool) → Fin (2 ^ k)) (p : ℝ), (∀ m : Fin (2 ^ k), cellMass Q m = 1 / (2 : ℝ) ^ k) ∧ 0 < p ∧ p < 1 / 2 ∧ (k : ℝ) * (1 - binEntropyBits p) < shannonMutualInfo Q p ∧ (1 + (1 - 2 * p) ^ 2) ^ k - 1 < chi2MutualInfo Q p := by intro n k let eIn : NonzeroVec r ≃ Fin n := Fintype.equivFinOfCardEq (card_nonzeroVec r) let eOut : HamCodeword r ≃ Fin (2 ^ k) := Fintype.equivFinOfCardEq (card_hamCodeword (by omega)) let Q : (Fin n → Bool) → Fin (2 ^ k) := eOut ∘ relabelQuant eIn (hamDecode r) have hcurv : curvature Q = curvature (hamDecode r) := by dsimp only [Q]; rw [comp_equiv_curvature, relabelQuant_curvature] have hgt : (k : ℝ) < curvature Q := hcurv ▸ hammingQuantizer_curvature_gt hr obtain ⟨p, hp0, hp1, hS, hC⟩ := exists_p_beats_both_of_curvature_gt Q hgt refine ⟨Q, p, ?_, hp0, hp1, hS, hC⟩ intro m dsimp only [Q] rw [comp_equiv_cellMass, relabelQuant_cellMass] unfold cellMass setMass rw [hamDecode_cell_card, card_nonzeroVec] have hge : r ≤ 2 ^ r - 1 := by have := Nat.lt_two_pow_self (n := r); omega have hpow : (2 : ℝ) ^ (2 ^ r - 1) = (2 : ℝ) ^ k * (2 : ℝ) ^ r := by dsimp only [k]; rw [← pow_add, Nat.sub_add_cancel hge] rw [Nat.cast_pow, Nat.cast_ofNat, hpow] field_simp [show (2 : ℝ) ^ r ≠ 0 by positivity, show (2 : ℝ) ^ k ≠ 0 by positivity] /-- Product cell-mass formula for direct-sum quantizers. -/ lemma cellMass_prodQuant {ι₁ ι₂ α₁ α₂ : Type*} [Fintype ι₁] [DecidableEq ι₁] [Fintype ι₂] [DecidableEq ι₂] [DecidableEq α₁] [DecidableEq α₂] (Q₁ : (ι₁ → Bool) → α₁) (Q₂ : (ι₂ → Bool) → α₂) (m₁ : α₁) (m₂ : α₂) : cellMass (prodQuant Q₁ Q₂) (m₁, m₂) = cellMass Q₁ m₁ * cellMass Q₂ m₂ := by unfold cellMass setMass quantCell prodQuant rw [Fintype.card_sum, pow_add, ← mul_div_mul_comm] congr 1 have hnat : (Finset.univ.filter fun z : (ι₁ ⊕ ι₂) → Bool => (Q₁ (fun i => z (Sum.inl i)), Q₂ (fun j => z (Sum.inr j))) = (m₁, m₂)).card = (Finset.univ.filter fun x : ι₁ → Bool => Q₁ x = m₁).card * (Finset.univ.filter fun y : ι₂ → Bool => Q₂ y = m₂).card := by rw [← Finset.card_product] refine Finset.card_bij (fun z _ => sumSplitEquiv ι₁ ι₂ z) ?_ ?_ ?_ · intro z hz have h := Prod.mk.inj (Finset.mem_filter.mp hz).2 exact Finset.mem_product.mpr ⟨Finset.mem_filter.mpr ⟨Finset.mem_univ _, h.1⟩, Finset.mem_filter.mpr ⟨Finset.mem_univ _, h.2⟩⟩ · intro z₁ _ z₂ _ h; exact (sumSplitEquiv ι₁ ι₂).injective h · intro p hp rcases Finset.mem_product.mp hp with ⟨hp1, hp2⟩ refine ⟨(sumSplitEquiv ι₁ ι₂).symm p, Finset.mem_filter.mpr ⟨Finset.mem_univ _, ?_⟩, (sumSplitEquiv ι₁ ι₂).apply_symm_apply p⟩ exact Prod.ext (Finset.mem_filter.mp hp1).2 (Finset.mem_filter.mp hp2).2 exact_mod_cast hnat private instance instDecidableEqHamProd (r t : ℕ) : DecidableEq (HamCodeword r × (Fin t → Bool)) := @instDecidableEqProd (HamCodeword r) (Fin t → Bool) inferInstance inferInstance /-- Direct-sum `Ham_r ⊗ id_t` beats both benchmarks simultaneously for all `r ≥ 4`, `t : ℕ`. -/ lemma hamming_prod_id_beats {r t n k : ℕ} (hr : 4 ≤ r) (hn : (2 ^ r - 1) + t = n) (hk : (2 ^ r - 1 - r) + t = k) : ∃ (Q : (Fin n → Bool) → Fin (2 ^ k)) (p : ℝ), (∀ m : Fin (2 ^ k), cellMass Q m = 1 / (2 : ℝ) ^ k) ∧ 0 < p ∧ p < 1 / 2 ∧ (k : ℝ) * (1 - binEntropyBits p) < shannonMutualInfo Q p ∧ (1 + (1 - 2 * p) ^ 2) ^ k - 1 < chi2MutualInfo Q p := by let Q0 := prodQuant (hamDecode r) (id : (Fin t → Bool) → (Fin t → Bool)) have hcardIn : Fintype.card (NonzeroVec r ⊕ Fin t) = n := by rw [Fintype.card_sum, card_nonzeroVec, Fintype.card_fin, hn] have hcardOut : Fintype.card (HamCodeword r × (Fin t → Bool)) = 2 ^ k := by rw [Fintype.card_prod, card_hamCodeword (by omega), Fintype.card_fun, Fintype.card_bool, Fintype.card_fin, ← pow_add, hk] let eIn : (NonzeroVec r ⊕ Fin t) ≃ Fin n := Fintype.equivFinOfCardEq hcardIn let eOut : (HamCodeword r × (Fin t → Bool)) ≃ Fin (2 ^ k) := Fintype.equivFinOfCardEq hcardOut let Q : (Fin n → Bool) → Fin (2 ^ k) := eOut ∘ relabelQuant eIn Q0 have hcurv : curvature Q = curvature (hamDecode r) + (t : ℝ) := by dsimp only [Q, Q0] rw [comp_equiv_curvature, relabelQuant_curvature, curvature_prodQuant, curvature_id_cube] have hgt : (k : ℝ) < curvature Q := by rw [hcurv] have hk_cast : (k : ℝ) = ((2 ^ r - 1 - r : ℕ) : ℝ) + (t : ℝ) := by rw [← hk]; push_cast; rfl rw [hk_cast] linarith [hammingQuantizer_curvature_gt hr] obtain ⟨p, hp0, hp1, hS, hC⟩ := exists_p_beats_both_of_curvature_gt Q hgt refine ⟨Q, p, ?_, hp0, hp1, hS, hC⟩ intro m dsimp only [Q] rw [comp_equiv_cellMass, relabelQuant_cellMass] rcases eOut.symm m with ⟨c, y⟩ dsimp only [Q0] rw [cellMass_prodQuant] have hm1 : cellMass (hamDecode r) c = 1 / (2 : ℝ) ^ (2 ^ r - 1 - r) := by unfold cellMass setMass rw [hamDecode_cell_card, card_nonzeroVec] have hge : r ≤ 2 ^ r - 1 := by have := Nat.lt_two_pow_self (n := r); omega have hpow : (2 : ℝ) ^ (2 ^ r - 1) = (2 : ℝ) ^ (2 ^ r - 1 - r) * (2 : ℝ) ^ r := by rw [← pow_add, Nat.sub_add_cancel hge] rw [Nat.cast_pow, Nat.cast_ofNat, hpow] field_simp [show (2 : ℝ) ^ r ≠ 0 by positivity, show (2 : ℝ) ^ (2 ^ r - 1 - r) ≠ 0 by positivity] have hm2 : cellMass (id : (Fin t → Bool) → (Fin t → Bool)) y = 1 / (2 : ℝ) ^ t := by unfold cellMass setMass quantCell have h1 : (Finset.univ.filter fun u : Fin t → Bool => id u = y) = {y} := by ext u; simp rw [h1, Finset.card_singleton, Fintype.card_fin]; norm_num rw [hm1, hm2, div_mul_div_comm, one_mul, ← pow_add, hk] /-- **MAIN THEOREM 4B (Simultaneous Breakdown for ALL `k ≥ 11`)**: For EVERY integer `k ≥ 11`, there exist a balanced `k`-bit quantizer `Q : (Fin (k + 4) → Bool) → Fin (2 ^ k)` (built as the direct sum `Ham_4 ⊗ id_{k - 11}`) and a crossover probability `p ∈ (0, 1/2)` that SIMULTANEOUSLY beat BOTH `k * (1 - h₂(p))` AND `(1 + (1 - 2p)²)ᵏ - 1`! -/ theorem multibit_courtade_kumar_fails_all_ge_eleven {k : ℕ} (hk : 11 ≤ k) : ∃ (Q : (Fin (k + 4) → Bool) → Fin (2 ^ k)) (p : ℝ), (∀ m : Fin (2 ^ k), cellMass Q m = 1 / (2 : ℝ) ^ k) ∧ 0 < p ∧ p < 1 / 2 ∧ (k : ℝ) * (1 - binEntropyBits p) < shannonMutualInfo Q p ∧ (1 + (1 - 2 * p) ^ 2) ^ k - 1 < chi2MutualInfo Q p := hamming_prod_id_beats (r := 4) (t := k - 11) (by norm_num) (by omega) (by omega) end PerfectHammingBreakdown /-! ## Section 6: Axiom Audit -/ #print axioms fourierCoeff_noiseOp #print axioms chi2MutualInfo_eq_fourier #print axioms shannonMutualInfo_eq_entropy_sub_condEntropy #print axioms oddWeight_le_bounds #print axioms level1Weight_eq_half_mass_iff #print axioms chi2MutualInfo_le_universal #print axioms chi2_courtade_kumar_two_bit #print axioms chi2_two_bit_eq_iff #print axioms shannonMutualInfo_high_noise_approx #print axioms shannon_two_bit_high_noise_optimal #print axioms shannon_ternary_high_noise_optimal #print axioms adaptiveTree2Bit_exact #print axioms hammingQuantizer_curvature #print axioms perfect_hamming_beats_both_benchmarks #print axioms multibit_courtade_kumar_fails_all_ge_eleven end MultibitCourtadeKumar