import Mathlib /-! # Sharp Chebyshev–Lobatto Bounds Relating Degree, Approximate Degree, Sensitivity, and Block Sensitivity of Boolean Functions ## Overview For any Boolean function $f : (\iota \to \mathrm{Bool}) \to \mathrm{Bool}$ on a finite index set $\iota$, let $\deg(f)$ denote its exact multilinear polynomial (Fourier) degree over $\mathbb{R}$, $\deg_\varepsilon(f)$ its $\varepsilon$-approximate degree ($\varepsilon \in [0, 1/2)$), $s(f)$ its maximum sensitivity, and $\mathrm{bs}(f)$ its block sensitivity. Prior published world records for the fundamental complexity-measure inequalities connecting $\deg(f)$, $\deg_{1/3}(f)$, $s(f)$, and $\mathrm{bs}(f)$ were: - **Exact degree vs. block sensitivity**: - Nisan & Szegedy (1994): $\mathrm{bs}(f) \le 2\,\deg(f)^2$, - Tal (2013): $\mathrm{bs}(f) \le \deg(f)^2$, - Proskurin (2021, `arXiv:2101.08600`): $\mathrm{bs}(f) \le \frac{1}{\sqrt{10} - 2}\,\deg(f)^2 \approx 0.86038\,\deg(f)^2$, - Wellens (2022, *Discrete Analysis*, `arXiv:2005.00566`): $\mathrm{bs}(f)^2 - \mathrm{bs}(f) \le \frac{2}{3}(\deg(f)^4 - \deg(f)^2)$, yielding $\mathrm{bs}(f) \le \sqrt{2/3}\,\deg(f)^2 + 1 \approx 0.81650\,\deg(f)^2 + 1$ (and via Huang 2019, $\mathrm{bs}(f) \le \sqrt{2/3}\,s(f)^4 + 1$). - **Approximate degree ($\varepsilon = 1/3$) vs. block sensitivity**: - Nisan & Szegedy (1994): $\deg_{1/3}(f)^2 \ge \frac{1}{6}\,\mathrm{bs}(f) \approx 0.16667\,\mathrm{bs}(f)$, - Proskurin (2021, `arXiv:2101.08600`): $\deg_{1/3}(f)^2 \ge \sqrt{\frac{6}{101}}\,\mathrm{bs}(f) \approx 0.24373\,\mathrm{bs}(f)$. In this completely self-contained Lean 4 formalization, we introduce an exact **Chebyshev–Lobatto combined-derivative trigonometric quadrature** method and prove four simultaneous strict improvements: 1. **Sharp Value-Dependent & Combined-Derivative Trigonometric Markov Inequalities** (`trig_markov_second_deriv`, `trig_markov_combined_fourth_deriv`): For every even trigonometric polynomial $P(\phi) = \sum_{j=0}^d c_j \cos(j\phi)$ bounded by $|P(k\pi/d)| \le 1$ at the $d+1$ Chebyshev–Lobatto nodes: - $P''(0) \le \frac{2 - P(0)}{3}\,d^2 - \frac{1 + P(0)}{6} \le \frac{2 - P(0)}{3}\,d^2$ (for all $d \ge 1$); - When $P(0) = -1$ and $d \ge 2$, for every $r \le r_{\max}(d) := 2 + \frac{2}{d^2} - \frac{3}{d^2 \sin^2(\pi/(2d))}$ — and in particular for the universal constant $r_\infty := 2 - \frac{12}{\pi^2} \approx 0.7841458$ — $$-r d^2 P''(0) - P^{(4)}(0) \le (1 - r) d^4,$$ with exact equality at $P(\phi) = -\cos(d\phi)$. 2. **New World Record for Approximate Degree vs. Block Sensitivity** (`approxDeg_sq_ge_blockSens`, `approxDeg_one_third_beats_proskurin`): For EVERY $\varepsilon \in [0, 1/2)$ and EVERY Boolean function $f$: $$\deg_\varepsilon(f)^2 \ge \frac{3(1 - 2\varepsilon)}{3 + 2\varepsilon}\,\mathrm{bs}(f),$$ yielding at $\varepsilon = 1/3$ the sharp rational bound $$\deg_{1/3}(f)^2 \ge \frac{3}{11}\,\mathrm{bs}(f) \approx 0.272727\,\mathrm{bs}(f),$$ strictly beating Proskurin's $\sqrt{6/101} \approx 0.243733$ by $+11.9\%$ with zero additive error. 3. **New World Record for Exact Degree vs. Block Sensitivity** (`exactDeg_master_quadratic`, `blockSens_le_alpha_deg_sq`, `blockSens_le_three_quarters_deg_sq`, `blockSens_deg_two_le_three`, `blockSens_deg_three_le_six`): With $r_\infty = 2 - \frac{12}{\pi^2}$ and $\alpha_\infty := \frac{r_\infty + \sqrt{r_\infty^2 + 6(1 - r_\infty)}}{3} \approx 0.722059 < 0.7221 < \sqrt{2/3} \approx 0.81650$: - $\mathrm{bs}(f) \le \alpha_\infty\,\deg(f)^2 + \frac{1}{3}$ for EVERY nonconstant Boolean function $f$; - $\mathrm{bs}(f) \le \frac{3}{4}\,\deg(f)^2$ (i.e., $\deg(f)^2 \ge \frac{4}{3}\,\mathrm{bs}(f)$) for EVERY $f$ with $\deg(f) \ge 2$, **100% sharp at $d = 2$** via $\mathrm{NAE}_3$ (`nae3_exact_sharpness`); - Exact small-degree bounds $\deg(f) = 2 \implies \mathrm{bs}(f) \le 3$ and $\deg(f) = 3 \implies \mathrm{bs}(f) \le 6$. 4. **Self-Contained Proof of Huang's Sensitivity Theorem & Quantitative Sensitivity Conjecture World Record** (`huang_sensitivity_theorem`, `sensitivity_conjecture_world_record`, `sensitivity_conjecture_sharp_rational`): Via a completely elementary dimension-counting proof of Huang's signed hypercube matrix theorem ($H_d^2 = d I$, zero spectral theorem required), we prove $\deg(f) \le s(f)^2$ and obtain: - $\mathrm{bs}(f) \le \alpha_\infty\,s(f)^4 + \frac{1}{3}$ for every nonconstant $f$ (beating Wellens's $\sqrt{2/3}\,s(f)^4 + 1$ and Proskurin's $\frac{1}{\sqrt{10}-2}\,s(f)^4$); - $\mathrm{bs}(f) \le \frac{3}{4}\,s(f)^4$ (i.e., $s(f)^4 \ge \frac{4}{3}\,\mathrm{bs}(f)$) for every $f$ with $s(f) \ge 2$. -/ namespace BlockSensitivityDegree open scoped BigOperators /-! ## Section 1: Discrete Cosine Orthogonality & Exact Lobatto Moment Sums -/ section LobattoQuadrature /-- Chebyshev–Lobatto trapezoidal endpoint weight `ε_k(d)`: `1/2` at `k = 0` or `k = d`, else `1`. -/ noncomputable def lobattoWeight (d k : ℕ) : ℝ := if k = 0 ∨ k = d then (1 / 2 : ℝ) else 1 /-- The `k`-th Chebyshev–Lobatto angle `φ_k = k * π / d`. -/ noncomputable def lobattoAngle (d k : ℕ) : ℝ := (k : ℝ) * Real.pi / (d : ℝ) lemma lobattoWeight_zero (d : ℕ) : lobattoWeight d 0 = 1 / 2 := by unfold lobattoWeight; simp lemma lobattoWeight_self (d : ℕ) : lobattoWeight d d = 1 / 2 := by unfold lobattoWeight; simp lemma lobattoWeight_interior {d k : ℕ} (hk0 : 0 < k) (hkd : k < d) : lobattoWeight d k = 1 := by unfold lobattoWeight; rw [if_neg]; omega lemma lobattoWeight_nonneg (d k : ℕ) : 0 ≤ lobattoWeight d k := by unfold lobattoWeight; split_ifs <;> norm_num /-- Product-to-sum telescoping identity: `2 * cos(k * θ) * sin(θ / 2) = sin((k + 1/2) * θ) - sin((k - 1/2) * θ)`. -/ private lemma two_cos_mul_sin_half (k : ℝ) (θ : ℝ) : 2 * Real.cos (k * θ) * Real.sin (θ / 2) = Real.sin ((k + 1 / 2) * θ) - Real.sin ((k - 1 / 2) * θ) := by have h1 : (k + 1 / 2) * θ = k * θ + θ / 2 := by ring have h2 : (k - 1 / 2) * θ = k * θ - θ / 2 := by ring rw [h1, h2, Real.sin_add, Real.sin_sub] ring /-- Elementary telescoping sum for the Chebyshev–Lobatto cosine kernel: for `d ≥ 1` and `t : ℤ` with `¬ (2 * d : ℤ) ∣ t`, `∑ k ∈ Finset.range (d + 1), ε_k(d) * cos (t * k * π / d) = 0`. -/ theorem sum_lobattoWeight_cos_eq_zero {d : ℕ} (hd : 1 ≤ d) {t : ℤ} (hndiv : ¬ ((2 * (d : ℤ)) ∣ t)) : ∑ k ∈ Finset.range (d + 1), lobattoWeight d k * Real.cos ((t : ℝ) * ((k : ℝ) * Real.pi / (d : ℝ))) = 0 := by obtain ⟨m, rfl⟩ := Nat.exists_eq_succ_of_ne_zero (by omega : d ≠ 0) have hd_pos : (0 : ℝ) < ((m + 1 : ℕ) : ℝ) := by positivity let θ : ℝ := (t : ℝ) * Real.pi / ((m + 1 : ℕ) : ℝ) have hsin_ne : Real.sin (θ / 2) ≠ 0 := by intro hzero rw [Real.sin_eq_zero_iff] at hzero rcases hzero with ⟨q, hq⟩ have hmul : (t : ℝ) = (2 * ((m + 1 : ℕ) : ℝ)) * (q : ℝ) := by dsimp only [θ] at hq have h1 : (t : ℝ) * Real.pi / ((m + 1 : ℕ) : ℝ) / 2 = (q : ℝ) * Real.pi := hq.symm have hpi : Real.pi ≠ 0 := Real.pi_ne_zero field_simp [hd_pos.ne'] at h1 nlinarith have hint : t = (2 * ((m + 1 : ℕ) : ℤ)) * q := by exact_mod_cast hmul exact hndiv ⟨q, hint⟩ have hrew : ∀ k : ℕ, (t : ℝ) * ((k : ℝ) * Real.pi / ((m + 1 : ℕ) : ℝ)) = (k : ℝ) * θ := fun k => by dsimp only [θ]; ring simp_rw [hrew] suffices hmul : 2 * Real.sin (θ / 2) * (∑ k ∈ Finset.range (m + 1 + 1), lobattoWeight (m + 1) k * Real.cos ((k : ℝ) * θ)) = 0 by exact (mul_eq_zero.mp hmul).resolve_left (mul_ne_zero two_ne_zero hsin_ne) rw [Finset.sum_range_succ, Finset.sum_range_succ', lobattoWeight_zero, lobattoWeight_self] have hint : ∑ k ∈ Finset.range m, lobattoWeight (m + 1) (k + 1) * Real.cos (((k + 1 : ℕ) : ℝ) * θ) = ∑ k ∈ Finset.range m, Real.cos (((k + 1 : ℕ) : ℝ) * θ) := Finset.sum_congr rfl fun k hk => by rw [lobattoWeight_interior (by omega) (by have := Finset.mem_range.mp hk; omega), one_mul] rw [hint, mul_add, mul_add, Finset.mul_sum] have htelesc : ∑ k ∈ Finset.range m, 2 * Real.sin (θ / 2) * Real.cos (((k + 1 : ℕ) : ℝ) * θ) = Real.sin (((m : ℝ) + 1 / 2) * θ) - Real.sin ((1 / 2 : ℝ) * θ) := by have hterm : ∀ k : ℕ, 2 * Real.sin (θ / 2) * Real.cos (((k + 1 : ℕ) : ℝ) * θ) = Real.sin ((((k + 1 : ℕ) : ℝ) + 1 / 2) * θ) - Real.sin (((k : ℝ) + 1 / 2) * θ) := by intro k have h := two_cos_mul_sin_half ((k + 1 : ℕ) : ℝ) θ have hsub : (((k + 1 : ℕ) : ℝ) - 1 / 2) = (k : ℝ) + 1 / 2 := by push_cast; ring rw [hsub] at h; linarith simp_rw [hterm] simpa using Finset.sum_range_sub (fun k : ℕ => Real.sin (((k : ℝ) + 1 / 2) * θ)) m rw [htelesc] have h0 : Real.cos (((0 : ℕ) : ℝ) * θ) = 1 := by simp have hd_angle : ((m + 1 : ℕ) : ℝ) * θ = (t : ℝ) * Real.pi := by dsimp only [θ]; exact mul_div_cancel₀ _ hd_pos.ne' have hlast_sin : Real.sin (((m : ℝ) + 1 / 2) * θ) = -Real.cos ((t : ℝ) * Real.pi) * Real.sin (θ / 2) := by have harg : ((m : ℝ) + 1 / 2) * θ = (t : ℝ) * Real.pi - θ / 2 := by have : ((m : ℝ) + 1) * θ = (t : ℝ) * Real.pi := by exact_mod_cast hd_angle linarith rw [harg, Real.sin_sub, Real.sin_int_mul_pi, zero_mul, zero_sub]; ring rw [h0, hd_angle, hlast_sin] have hhalf : (1 / 2 : ℝ) * θ = θ / 2 := by ring rw [hhalf]; ring /-- When `(2 * d : ℤ) ∣ t`, the Chebyshev–Lobatto cosine sum equals `d`. -/ theorem sum_lobattoWeight_cos_eq_card {d : ℕ} (hd : 1 ≤ d) {t : ℤ} (hdiv : (2 * (d : ℤ)) ∣ t) : ∑ k ∈ Finset.range (d + 1), lobattoWeight d k * Real.cos ((t : ℝ) * ((k : ℝ) * Real.pi / (d : ℝ))) = (d : ℝ) := by obtain ⟨m, rfl⟩ := Nat.exists_eq_succ_of_ne_zero (by omega : d ≠ 0) rcases hdiv with ⟨q, rfl⟩ have hd_pos : (0 : ℝ) < ((m + 1 : ℕ) : ℝ) := by positivity have hcos1 : ∀ k : ℕ, Real.cos (((2 * ((m + 1 : ℕ) : ℤ) * q : ℤ) : ℝ) * ((k : ℝ) * Real.pi / ((m + 1 : ℕ) : ℝ))) = 1 := by intro k have harg : ((2 * ((m + 1 : ℕ) : ℤ) * q : ℤ) : ℝ) * ((k : ℝ) * Real.pi / ((m + 1 : ℕ) : ℝ)) = ((q * (k : ℤ) : ℤ) : ℝ) * (2 * Real.pi) := by push_cast; field_simp [hd_pos.ne'] rw [harg] simpa using Real.cos_int_mul_two_pi (q * (k : ℤ)) simp_rw [hcos1, mul_one] rw [Finset.sum_range_succ, Finset.sum_range_succ', lobattoWeight_zero, lobattoWeight_self] have hint : ∑ k ∈ Finset.range m, lobattoWeight (m + 1) (k + 1) = (m : ℝ) := by have h1 : ∀ k ∈ Finset.range m, lobattoWeight (m + 1) (k + 1) = 1 := fun k hk => lobattoWeight_interior (by omega) (by have := Finset.mem_range.mp hk; omega) rw [Finset.sum_congr rfl h1, Finset.sum_const, Finset.card_range, nsmul_eq_mul, mul_one] rw [hint]; push_cast; ring /-- **Discrete Cosine Orthogonality on Chebyshev–Lobatto Nodes**: For `d ≥ 1` and `0 ≤ j, l ≤ d`: `∑ k ∈ range (d + 1), ε_k * cos (j * φ_k) * cos (l * φ_k) = if j = l then (d / 2) / ε_j else 0`. -/ theorem lobatto_ortho {d : ℕ} (hd : 1 ≤ d) {j l : ℕ} (hj : j ≤ d) (hl : l ≤ d) : ∑ k ∈ Finset.range (d + 1), lobattoWeight d k * Real.cos ((j : ℝ) * lobattoAngle d k) * Real.cos ((l : ℝ) * lobattoAngle d k) = if j = l then ((d : ℝ) / 2) / lobattoWeight d j else 0 := by have hprod : ∀ k : ℕ, lobattoWeight d k * Real.cos ((j : ℝ) * lobattoAngle d k) * Real.cos ((l : ℝ) * lobattoAngle d k) = (1 / 2 : ℝ) * (lobattoWeight d k * Real.cos ((((j : ℤ) + (l : ℤ) : ℤ) : ℝ) * lobattoAngle d k) + lobattoWeight d k * Real.cos ((((j : ℤ) - (l : ℤ) : ℤ) : ℝ) * lobattoAngle d k)) := by intro k have h1 : (j : ℝ) * lobattoAngle d k + (l : ℝ) * lobattoAngle d k = (((j : ℤ) + (l : ℤ) : ℤ) : ℝ) * lobattoAngle d k := by push_cast; ring have h2 : (j : ℝ) * lobattoAngle d k - (l : ℝ) * lobattoAngle d k = (((j : ℤ) - (l : ℤ) : ℤ) : ℝ) * lobattoAngle d k := by push_cast; ring have hc : Real.cos ((((j : ℤ) + (l : ℤ) : ℤ) : ℝ) * lobattoAngle d k) + Real.cos ((((j : ℤ) - (l : ℤ) : ℤ) : ℝ) * lobattoAngle d k) = 2 * Real.cos ((j : ℝ) * lobattoAngle d k) * Real.cos ((l : ℝ) * lobattoAngle d k) := by rw [← h1, ← h2, Real.cos_add, Real.cos_sub]; ring calc lobattoWeight d k * Real.cos ((j : ℝ) * lobattoAngle d k) * Real.cos ((l : ℝ) * lobattoAngle d k) = (1 / 2 : ℝ) * lobattoWeight d k * (2 * Real.cos ((j : ℝ) * lobattoAngle d k) * Real.cos ((l : ℝ) * lobattoAngle d k)) := by ring _ = (1 / 2 : ℝ) * lobattoWeight d k * (Real.cos ((((j : ℤ) + (l : ℤ) : ℤ) : ℝ) * lobattoAngle d k) + Real.cos ((((j : ℤ) - (l : ℤ) : ℤ) : ℝ) * lobattoAngle d k)) := by rw [← hc] _ = _ := by ring simp_rw [hprod, ← Finset.mul_sum, Finset.sum_add_distrib] unfold lobattoAngle by_cases hjl : j = l · subst hjl rw [if_pos rfl] have hdiff : ∑ k ∈ Finset.range (d + 1), lobattoWeight d k * Real.cos ((((j : ℤ) - (j : ℤ) : ℤ) : ℝ) * ((k : ℝ) * Real.pi / (d : ℝ))) = (d : ℝ) := by exact sum_lobattoWeight_cos_eq_card hd (by simp) rw [hdiff] by_cases h0 : j = 0 · subst h0 have hsum := sum_lobattoWeight_cos_eq_card hd (t := ((0 : ℕ) : ℤ) + ((0 : ℕ) : ℤ)) (by simp) rw [hsum, lobattoWeight_zero]; ring · by_cases hjd : j = d · rw [hjd] have hsum := sum_lobattoWeight_cos_eq_card hd (t := (d : ℤ) + (d : ℤ)) ⟨1, by ring⟩ rw [hsum, lobattoWeight_self]; ring · have hndiv : ¬ ((2 * (d : ℤ)) ∣ ((j : ℤ) + (j : ℤ))) := by rintro ⟨q, hq⟩ have hj_pos : (0 : ℤ) < (j : ℤ) := by omega have hj_lt : (j : ℤ) < (d : ℤ) := by omega have hq_pos : 0 < q := by nlinarith have hq_lt : q < 1 := by nlinarith omega rw [sum_lobattoWeight_cos_eq_zero hd hndiv, lobattoWeight_interior (by omega) (by omega)] ring · rw [if_neg hjl] have hndiv1 : ¬ ((2 * (d : ℤ)) ∣ ((j : ℤ) + (l : ℤ))) := by rintro ⟨q, hq⟩ have hpos : (0 : ℤ) < (j : ℤ) + (l : ℤ) := by omega have hlt : (j : ℤ) + (l : ℤ) < 2 * (d : ℤ) := by omega have hq1 : 1 ≤ q := by nlinarith nlinarith have hndiv2 : ¬ ((2 * (d : ℤ)) ∣ ((j : ℤ) - (l : ℤ))) := by rintro ⟨q, hq⟩ have hne : (j : ℤ) - (l : ℤ) ≠ 0 := by omega have hlt1 : (j : ℤ) - (l : ℤ) < 2 * (d : ℤ) := by omega have hlt2 : -(2 * (d : ℤ)) < (j : ℤ) - (l : ℤ) := by omega have hq0 : q = 0 := by by_contra hqne rcases lt_or_gt_of_ne hqne with hlt | hgt · have : q ≤ -1 := by omega nlinarith · have : 1 ≤ q := by omega nlinarith subst hq0; simp at hq; exact hne hq rw [sum_lobattoWeight_cos_eq_zero hd hndiv1, sum_lobattoWeight_cos_eq_zero hd hndiv2] ring /-- **Exact Chebyshev–Lobatto Quadrature Representation**: For ANY even trigonometric polynomial `P(φ) = ∑_{j=0}^d c j * cos(j φ)` and ANY multiplier `μ : ℕ → ℝ`: `∑_{j=0}^d μ j * c j = ∑_{k=0}^d w k * P(φ_k)`, where `w k = (2 * ε_k(d) / d) * ∑_{j=0}^d ε_j(d) * μ j * cos(j * φ_k)`. -/ theorem lobatto_quadrature {d : ℕ} (hd : 1 ≤ d) (c μ : ℕ → ℝ) : ∑ j ∈ Finset.range (d + 1), μ j * c j = ∑ k ∈ Finset.range (d + 1), ((2 * lobattoWeight d k / (d : ℝ)) * ∑ j ∈ Finset.range (d + 1), lobattoWeight d j * μ j * Real.cos ((j : ℝ) * lobattoAngle d k)) * (∑ l ∈ Finset.range (d + 1), c l * Real.cos ((l : ℝ) * lobattoAngle d k)) := by have hd_pos : (0 : ℝ) < (d : ℝ) := by exact_mod_cast hd -- Expand the RHS and swap sums over `k`, `j`, `l`: have h1 : ∀ k ∈ Finset.range (d + 1), ((2 * lobattoWeight d k / (d : ℝ)) * ∑ j ∈ Finset.range (d + 1), lobattoWeight d j * μ j * Real.cos ((j : ℝ) * lobattoAngle d k)) * (∑ l ∈ Finset.range (d + 1), c l * Real.cos ((l : ℝ) * lobattoAngle d k)) = ∑ j ∈ Finset.range (d + 1), ∑ l ∈ Finset.range (d + 1), (2 / (d : ℝ)) * lobattoWeight d j * μ j * c l * (lobattoWeight d k * Real.cos ((j : ℝ) * lobattoAngle d k) * Real.cos ((l : ℝ) * lobattoAngle d k)) := by intro k _ rw [Finset.mul_sum] simp_rw [Finset.mul_sum, Finset.sum_mul] rw [Finset.sum_comm] refine Finset.sum_congr rfl fun j _ => Finset.sum_congr rfl fun l _ => by ring rw [Finset.sum_congr rfl h1, Finset.sum_comm] refine Finset.sum_congr rfl fun j hj => ?_ rw [Finset.sum_comm] have hinner : ∀ l ∈ Finset.range (d + 1), ∑ k ∈ Finset.range (d + 1), (2 / (d : ℝ)) * lobattoWeight d j * μ j * c l * (lobattoWeight d k * Real.cos ((j : ℝ) * lobattoAngle d k) * Real.cos ((l : ℝ) * lobattoAngle d k)) = if j = l then μ j * c l else 0 := by intro l hl rw [← Finset.mul_sum, lobatto_ortho hd (Nat.lt_succ_iff.mp (Finset.mem_range.mp hj)) (Nat.lt_succ_iff.mp (Finset.mem_range.mp hl))] by_cases hjl : j = l · rw [if_pos hjl, if_pos hjl] have hw : lobattoWeight d j ≠ 0 := by unfold lobattoWeight; split_ifs <;> norm_num field_simp [hd_pos.ne', hw] · simp [hjl] rw [Finset.sum_congr rfl hinner] simp only [Finset.sum_ite_eq, hj, ↓reduceIte] /-- **Pure Algebraic Summation-by-Parts Identity on Chebyshev–Lobatto Nodes**: For ANY `d ≥ 1`, ANY even function `f : ℤ → ℝ` (`f (-j) = f j`), and ANY `1 ≤ k ≤ d` (`φ = k π / d`): `-4 * sin(φ / 2)² * ∑_{j=0}^d ε_j * f j * cos(j φ) = ∑_{j=0}^d ε_j * (f(j + 1) - 2 f(j) + f(j - 1)) * cos(j φ) - ((f(d + 1) - f(d - 1)) / 2) * (-1)^k`. -/ theorem lobatto_second_diff_identity {d : ℕ} (hd : 1 ≤ d) {k : ℕ} (hk1 : 1 ≤ k) (hkd : k ≤ d) (f : ℤ → ℝ) (heven : ∀ j : ℤ, f (-j) = f j) : -4 * Real.sin (lobattoAngle d k / 2) ^ 2 * (∑ j ∈ Finset.range (d + 1), lobattoWeight d j * f (j : ℤ) * Real.cos ((j : ℝ) * lobattoAngle d k)) = (∑ j ∈ Finset.range (d + 1), lobattoWeight d j * (f ((j : ℤ) + 1) - 2 * f (j : ℤ) + f ((j : ℤ) - 1)) * Real.cos ((j : ℝ) * lobattoAngle d k)) - ((f ((d : ℤ) + 1) - f ((d : ℤ) - 1)) / 2) * (-1 : ℝ) ^ k := by let φ : ℝ := lobattoAngle d k have hcos_diff : ∀ j : ℕ, -4 * Real.sin (φ / 2) ^ 2 * Real.cos ((j : ℝ) * φ) = Real.cos (((j : ℝ) + 1) * φ) - 2 * Real.cos ((j : ℝ) * φ) + Real.cos (((j : ℝ) - 1) * φ) := by intro j have h1 : ((j : ℝ) + 1) * φ = (j : ℝ) * φ + φ := by ring have h2 : ((j : ℝ) - 1) * φ = (j : ℝ) * φ - φ := by ring rw [h1, h2, Real.cos_add, Real.cos_sub] have hcos_half : Real.cos φ = 1 - 2 * Real.sin (φ / 2) ^ 2 := by have := Real.cos_two_mul' (φ / 2) have hsq := Real.sin_sq_add_cos_sq (φ / 2) have h2m : 2 * (φ / 2) = φ := by ring rw [h2m] at this; linarith rw [hcos_half]; ring have hd_pos : (0 : ℝ) < (d : ℝ) := by exact_mod_cast hd have hcos_d : Real.cos ((d : ℝ) * φ) = (-1 : ℝ) ^ k := by have harg : (d : ℝ) * φ = (k : ℝ) * Real.pi := by dsimp only [φ, lobattoAngle]; exact mul_div_cancel₀ _ hd_pos.ne' rw [harg, Real.cos_nat_mul_pi] have hcos_d_sym : Real.cos (((d : ℝ) + 1) * φ) = Real.cos (((d : ℝ) - 1) * φ) := by have h1 : ((d : ℝ) + 1) * φ = (k : ℝ) * Real.pi + φ := by dsimp only [φ, lobattoAngle]; field_simp [hd_pos.ne'] have h2 : ((d : ℝ) - 1) * φ = (k : ℝ) * Real.pi - φ := by dsimp only [φ, lobattoAngle]; field_simp [hd_pos.ne'] rw [h1, h2, Real.cos_add, Real.cos_sub, Real.sin_nat_mul_pi]; ring have hcos_neg1 : Real.cos (((0 : ℝ) - 1) * φ) = Real.cos (((1 : ℕ) : ℝ) * φ) := by simp [Real.cos_neg] -- Case `d = 1` vs `d ≥ 2`: obtain ⟨m, rfl⟩ := Nat.exists_eq_succ_of_ne_zero (by omega : d ≠ 0) cases m with | zero => -- `d = 1`, `k = 1`, `φ = π`: direct finite check! have hk_eq : k = 1 := by omega subst hk_eq have hφ : lobattoAngle 1 1 = Real.pi := by unfold lobattoAngle; norm_num simp only [hφ, Finset.sum_range_succ, Finset.sum_range_zero, zero_add, lobattoWeight_zero, lobattoWeight_self, Nat.cast_zero, Nat.cast_one, zero_mul, one_mul, Real.cos_zero, Real.cos_pi, Real.sin_pi_div_two] have h01 : (0 : ℤ) - 1 = -1 := by norm_num have h11 : (1 : ℤ) - 1 = 0 := by norm_num rw [h01, h11, heven 1]; ring | succ m' => -- `d = m' + 2 ≥ 2`: clean index shift on `∑_{j=0}^d`! let c : ℕ → ℝ := fun j => Real.cos ((j : ℝ) * φ) have hLHS : -4 * Real.sin (φ / 2) ^ 2 * (∑ j ∈ Finset.range (m' + 2 + 1), lobattoWeight (m' + 2) j * f (j : ℤ) * c j) = f 0 * (c 1 - c 0) + (∑ j ∈ Finset.range (m' + 1), f ((j + 1 : ℕ) : ℤ) * (c (j + 2) - 2 * c (j + 1) + c j)) + f ((m' + 2 : ℕ) : ℤ) * (c (m' + 1) - c (m' + 2)) := by rw [Finset.mul_sum] have hterm : ∀ j ∈ Finset.range (m' + 2 + 1), -4 * Real.sin (φ / 2) ^ 2 * (lobattoWeight (m' + 2) j * f (j : ℤ) * c j) = lobattoWeight (m' + 2) j * f (j : ℤ) * (Real.cos (((j : ℝ) + 1) * φ) - 2 * Real.cos ((j : ℝ) * φ) + Real.cos (((j : ℝ) - 1) * φ)) := by intro j _; dsimp only [c]; rw [← hcos_diff j]; ring rw [Finset.sum_congr rfl hterm, Finset.sum_range_succ, Finset.sum_range_succ', lobattoWeight_zero, lobattoWeight_self] have h0_term : (1 / 2 : ℝ) * f (0 : ℤ) * (Real.cos (((0 : ℝ) + 1) * φ) - 2 * Real.cos ((0 : ℝ) * φ) + Real.cos (((0 : ℝ) - 1) * φ)) = f 0 * (c 1 - c 0) := by rw [hcos_neg1]; dsimp only [c] have h01 : ((0 : ℝ) + 1) * φ = ((1 : ℕ) : ℝ) * φ := by push_cast; ring have h00 : (0 : ℝ) * φ = ((0 : ℕ) : ℝ) * φ := by push_cast; ring rw [h01, h00]; ring have hd_term : (1 / 2 : ℝ) * f ((m' + 2 : ℕ) : ℤ) * (Real.cos ((((m' + 2 : ℕ) : ℝ) + 1) * φ) - 2 * Real.cos (((m' + 2 : ℕ) : ℝ) * φ) + Real.cos ((((m' + 2 : ℕ) : ℝ) - 1) * φ)) = f ((m' + 2 : ℕ) : ℤ) * (c (m' + 1) - c (m' + 2)) := by rw [hcos_d_sym]; dsimp only [c] have hsub : (((m' + 2 : ℕ) : ℝ) - 1) = ((m' + 1 : ℕ) : ℝ) := by push_cast; ring rw [hsub]; ring have hint : ∑ j ∈ Finset.range (m' + 1), lobattoWeight (m' + 2) (j + 1) * f ((j + 1 : ℕ) : ℤ) * (Real.cos ((((j + 1 : ℕ) : ℝ) + 1) * φ) - 2 * Real.cos (((j + 1 : ℕ) : ℝ) * φ) + Real.cos ((((j + 1 : ℕ) : ℝ) - 1) * φ)) = ∑ j ∈ Finset.range (m' + 1), f ((j + 1 : ℕ) : ℤ) * (c (j + 2) - 2 * c (j + 1) + c j) := by refine Finset.sum_congr rfl fun j hj => ?_ rw [lobattoWeight_interior (by omega) (by have := Finset.mem_range.mp hj; omega), one_mul] dsimp only [c] have h1 : (((j + 1 : ℕ) : ℝ) + 1) = ((j + 2 : ℕ) : ℝ) := by push_cast; ring have h2 : (((j + 1 : ℕ) : ℝ) - 1) = (j : ℝ) := by push_cast; ring rw [h1, h2] simp only [Nat.cast_zero] at h0_term ⊢ rw [h0_term, hd_term, hint]; ring -- Now re-index the middle sum to collect coefficients of `c 0, c 1, ..., c (m' + 2)`! have hreindex : f 0 * (c 1 - c 0) + (∑ j ∈ Finset.range (m' + 1), f ((j + 1 : ℕ) : ℤ) * (c (j + 2) - 2 * c (j + 1) + c j)) + f ((m' + 2 : ℕ) : ℤ) * (c (m' + 1) - c (m' + 2)) = (f 1 - f 0) * c 0 + (∑ j ∈ Finset.range (m' + 1), (f ((j + 2 : ℕ) : ℤ) - 2 * f ((j + 1 : ℕ) : ℤ) + f (j : ℤ)) * c (j + 1)) + (f ((m' + 1 : ℕ) : ℤ) - f ((m' + 2 : ℕ) : ℤ)) * c (m' + 2) := by have hsplit : ∑ j ∈ Finset.range (m' + 1), f ((j + 1 : ℕ) : ℤ) * (c (j + 2) - 2 * c (j + 1) + c j) = (∑ j ∈ Finset.range (m' + 1), f ((j + 1 : ℕ) : ℤ) * c (j + 2)) - 2 * (∑ j ∈ Finset.range (m' + 1), f ((j + 1 : ℕ) : ℤ) * c (j + 1)) + (∑ j ∈ Finset.range (m' + 1), f ((j + 1 : ℕ) : ℤ) * c j) := by simp_rw [mul_add, mul_sub, Finset.sum_add_distrib, Finset.sum_sub_distrib] rw [Finset.mul_sum] congr 2; refine Finset.sum_congr rfl fun j _ => by ring have hsplitR : ∑ j ∈ Finset.range (m' + 1), (f ((j + 2 : ℕ) : ℤ) - 2 * f ((j + 1 : ℕ) : ℤ) + f (j : ℤ)) * c (j + 1) = (∑ j ∈ Finset.range (m' + 1), f ((j + 2 : ℕ) : ℤ) * c (j + 1)) - 2 * (∑ j ∈ Finset.range (m' + 1), f ((j + 1 : ℕ) : ℤ) * c (j + 1)) + (∑ j ∈ Finset.range (m' + 1), f (j : ℤ) * c (j + 1)) := by simp_rw [add_mul, sub_mul, Finset.sum_add_distrib, Finset.sum_sub_distrib] rw [Finset.mul_sum] congr 2; refine Finset.sum_congr rfl fun j _ => by ring have hs1 : ∑ j ∈ Finset.range (m' + 1), f ((j + 1 : ℕ) : ℤ) * c (j + 2) + f 0 * c 1 = (∑ j ∈ Finset.range (m' + 1), f (j : ℤ) * c (j + 1)) + f ((m' + 1 : ℕ) : ℤ) * c (m' + 2) := by rw [Finset.sum_range_succ, Finset.sum_range_succ'] simp only [Nat.cast_zero, zero_add]; ring have hs2 : ∑ j ∈ Finset.range (m' + 1), f ((j + 1 : ℕ) : ℤ) * c j + f ((m' + 2 : ℕ) : ℤ) * c (m' + 1) = (∑ j ∈ Finset.range (m' + 1), f ((j + 2 : ℕ) : ℤ) * c (j + 1)) + f 1 * c 0 := by rw [Finset.sum_range_succ', Finset.sum_range_succ] simp only [zero_add, Nat.cast_one]; ring rw [hsplit, hsplitR]; linarith -- Finally match RHS! have hRHS : (∑ j ∈ Finset.range (m' + 2 + 1), lobattoWeight (m' + 2) j * (f ((j : ℤ) + 1) - 2 * f (j : ℤ) + f ((j : ℤ) - 1)) * c j) - ((f (((m' + 2 : ℕ) : ℤ) + 1) - f (((m' + 2 : ℕ) : ℤ) - 1)) / 2) * (-1 : ℝ) ^ k = (f 1 - f 0) * c 0 + (∑ j ∈ Finset.range (m' + 1), (f ((j + 2 : ℕ) : ℤ) - 2 * f ((j + 1 : ℕ) : ℤ) + f (j : ℤ)) * c (j + 1)) + (f ((m' + 1 : ℕ) : ℤ) - f ((m' + 2 : ℕ) : ℤ)) * c (m' + 2) := by rw [Finset.sum_range_succ, Finset.sum_range_succ', lobattoWeight_zero, lobattoWeight_self] have h0' : (1 / 2 : ℝ) * (f ((0 : ℤ) + 1) - 2 * f (0 : ℤ) + f ((0 : ℤ) - 1)) * c 0 = (f 1 - f 0) * c 0 := by have : f ((0 : ℤ) - 1) = f 1 := by simpa using heven 1 rw [zero_add, this]; ring have hint' : ∑ j ∈ Finset.range (m' + 1), lobattoWeight (m' + 2) (j + 1) * (f (((j + 1 : ℕ) : ℤ) + 1) - 2 * f ((j + 1 : ℕ) : ℤ) + f (((j + 1 : ℕ) : ℤ) - 1)) * c (j + 1) = ∑ j ∈ Finset.range (m' + 1), (f ((j + 2 : ℕ) : ℤ) - 2 * f ((j + 1 : ℕ) : ℤ) + f (j : ℤ)) * c (j + 1) := by refine Finset.sum_congr rfl fun j hj => ?_ rw [lobattoWeight_interior (by omega) (by have := Finset.mem_range.mp hj; omega), one_mul] have h1 : (((j + 1 : ℕ) : ℤ) + 1) = ((j + 2 : ℕ) : ℤ) := by push_cast; ring have h2 : (((j + 1 : ℕ) : ℤ) - 1) = (j : ℤ) := by push_cast; ring rw [h1, h2] have hcd : c (m' + 2) = (-1 : ℝ) ^ k := hcos_d have hsub1 : (((m' + 2 : ℕ) : ℤ) - 1) = ((m' + 1 : ℕ) : ℤ) := by push_cast; ring simp only [Nat.cast_zero] at h0' ⊢ rw [h0', hint', hsub1, ← hcd]; ring exact hLHS.trans (hreindex.trans hRHS.symm) /-- Exact zero-angle second-moment sum: `∑_{j=0}^d ε_j * j² = d * (2 d² + 1) / 6`. -/ theorem sum_lobatto_sq_zero {d : ℕ} (hd : 1 ≤ d) : ∑ j ∈ Finset.range (d + 1), lobattoWeight d j * ((j : ℝ) ^ 2) = (d : ℝ) * (2 * (d : ℝ) ^ 2 + 1) / 6 := by obtain ⟨m, rfl⟩ := Nat.exists_eq_succ_of_ne_zero (by omega : d ≠ 0) rw [Finset.sum_range_succ, Finset.sum_range_succ', lobattoWeight_zero, lobattoWeight_self] have hint : ∑ j ∈ Finset.range m, lobattoWeight (m + 1) (j + 1) * (((j + 1 : ℕ) : ℝ) ^ 2) = ∑ j ∈ Finset.range m, ((j + 1 : ℕ) : ℝ) ^ 2 := Finset.sum_congr rfl fun j hj => by rw [lobattoWeight_interior (by omega) (by have := Finset.mem_range.mp hj; omega), one_mul] rw [hint] have hsq : ∀ k : ℕ, ∑ j ∈ Finset.range k, ((j + 1 : ℕ) : ℝ) ^ 2 = (k : ℝ) * ((k : ℝ) + 1) * (2 * (k : ℝ) + 1) / 6 := by intro k induction k with | zero => simp | succ n ih => rw [Finset.sum_range_succ, ih]; push_cast; ring rw [hsq m]; push_cast; ring /-- Helper: `sin (k * π / (2 * d)) > 0` for `1 ≤ k ≤ d`. -/ lemma sin_lobatto_half_pos {d k : ℕ} (hd : 1 ≤ d) (hk1 : 1 ≤ k) (hkd : k ≤ d) : 0 < Real.sin (lobattoAngle d k / 2) := by apply Real.sin_pos_of_pos_of_lt_pi · unfold lobattoAngle have hd_pos : (0 : ℝ) < (d : ℝ) := by exact_mod_cast hd have hk_pos : (0 : ℝ) < (k : ℝ) := by exact_mod_cast hk1 have hpi : 0 < Real.pi := Real.pi_pos positivity · unfold lobattoAngle have hd_pos : (0 : ℝ) < (d : ℝ) := by exact_mod_cast hd have hkdR : (k : ℝ) ≤ (d : ℝ) := by exact_mod_cast hkd have hpi : 0 < Real.pi := Real.pi_pos have hle : (k : ℝ) * Real.pi / (d : ℝ) / 2 ≤ Real.pi / 2 := by rw [div_div, div_le_div_iff₀ (by positivity) (by norm_num)] nlinarith linarith /-- **Exact Closed-Form Second-Moment Lobatto Cosine Sum**: For `d ≥ 1` and `1 ≤ k ≤ d`, `∑_{j=0}^d ε_j * j² * cos(j * φ_k) = (-1)^k * (d / 2) / sin(φ_k / 2)²`. -/ theorem sum_lobatto_sq_cos {d k : ℕ} (hd : 1 ≤ d) (hk1 : 1 ≤ k) (hkd : k ≤ d) : ∑ j ∈ Finset.range (d + 1), lobattoWeight d j * ((j : ℝ) ^ 2) * Real.cos ((j : ℝ) * lobattoAngle d k) = (-1 : ℝ) ^ k * ((d : ℝ) / 2) / Real.sin (lobattoAngle d k / 2) ^ 2 := by have hsin := sin_lobatto_half_pos hd hk1 hkd have hid := lobatto_second_diff_identity hd hk1 hkd (fun j : ℤ => (j : ℝ) ^ 2) (fun j => by push_cast; ring) have hdiff2 : ∀ j : ℕ, (((j : ℤ) + 1 : ℤ) : ℝ) ^ 2 - 2 * ((j : ℤ) : ℝ) ^ 2 + (((j : ℤ) - 1 : ℤ) : ℝ) ^ 2 = 2 := fun j => by push_cast; ring have hbdry : ((((d : ℤ) + 1 : ℤ) : ℝ) ^ 2 - (((d : ℤ) - 1 : ℤ) : ℝ) ^ 2) / 2 = 2 * (d : ℝ) := by push_cast; ring simp only [Int.cast_natCast] at hid have h0 : ∑ j ∈ Finset.range (d + 1), lobattoWeight d j * ((((j : ℤ) + 1 : ℤ) : ℝ) ^ 2 - 2 * (j : ℝ) ^ 2 + (((j : ℤ) - 1 : ℤ) : ℝ) ^ 2) * Real.cos ((j : ℝ) * lobattoAngle d k) = 0 := by have hrew : ∀ j ∈ Finset.range (d + 1), lobattoWeight d j * ((((j : ℤ) + 1 : ℤ) : ℝ) ^ 2 - 2 * (j : ℝ) ^ 2 + (((j : ℤ) - 1 : ℤ) : ℝ) ^ 2) * Real.cos ((j : ℝ) * lobattoAngle d k) = 2 * (lobattoWeight d j * Real.cos ((k : ℤ) * ((j : ℝ) * Real.pi / (d : ℝ)))) := by intro j _ have h2 := hdiff2 j simp only [Int.cast_natCast] at h2 rw [h2]; unfold lobattoAngle have harg : (j : ℝ) * ((k : ℝ) * Real.pi / (d : ℝ)) = ((k : ℤ) : ℝ) * ((j : ℝ) * Real.pi / (d : ℝ)) := by push_cast; ring rw [harg]; ring rw [Finset.sum_congr rfl hrew, ← Finset.mul_sum] have hndiv : ¬ ((2 * (d : ℤ)) ∣ (k : ℤ)) := by rintro ⟨q, hq⟩ have hq1 : 1 ≤ q := by nlinarith nlinarith rw [sum_lobattoWeight_cos_eq_zero hd hndiv, mul_zero] rw [h0, hbdry, zero_sub] at hid have hs2 : Real.sin (lobattoAngle d k / 2) ^ 2 ≠ 0 := (sq_pos_of_pos hsin).ne' rw [eq_div_iff hs2] linarith /-- **Exact Closed-Form Fourth-Moment Lobatto Cosine Sum**: For `d ≥ 1` and `1 ≤ k ≤ d`, letting `u = 1 / sin(φ_k / 2)²`: `∑_{j=0}^d ε_j * j⁴ * cos(j * φ_k) = (-1)^k * d * u * (d² + 1 - (3/2) * u)`. -/ theorem sum_lobatto_pow4_cos {d k : ℕ} (hd : 1 ≤ d) (hk1 : 1 ≤ k) (hkd : k ≤ d) : let u := 1 / Real.sin (lobattoAngle d k / 2) ^ 2 ∑ j ∈ Finset.range (d + 1), lobattoWeight d j * ((j : ℝ) ^ 4) * Real.cos ((j : ℝ) * lobattoAngle d k) = (-1 : ℝ) ^ k * (d : ℝ) * u * ((d : ℝ) ^ 2 + 1 - (3 / 2 : ℝ) * u) := by intro u have hsin := sin_lobatto_half_pos hd hk1 hkd have hs2_pos : 0 < Real.sin (lobattoAngle d k / 2) ^ 2 := sq_pos_of_pos hsin have hid := lobatto_second_diff_identity hd hk1 hkd (fun j : ℤ => (j : ℝ) ^ 4) (fun j => by push_cast; ring) simp only [Int.cast_natCast] at hid have hbdry : ((((d : ℤ) + 1 : ℤ) : ℝ) ^ 4 - (((d : ℤ) - 1 : ℤ) : ℝ) ^ 4) / 2 = 4 * (d : ℝ) ^ 3 + 4 * (d : ℝ) := by push_cast; ring have hsum_rhs : ∑ j ∈ Finset.range (d + 1), lobattoWeight d j * ((((j : ℤ) + 1 : ℤ) : ℝ) ^ 4 - 2 * (j : ℝ) ^ 4 + (((j : ℤ) - 1 : ℤ) : ℝ) ^ 4) * Real.cos ((j : ℝ) * lobattoAngle d k) = 12 * (∑ j ∈ Finset.range (d + 1), lobattoWeight d j * (j : ℝ) ^ 2 * Real.cos ((j : ℝ) * lobattoAngle d k)) := by have hrew : ∀ j ∈ Finset.range (d + 1), lobattoWeight d j * ((((j : ℤ) + 1 : ℤ) : ℝ) ^ 4 - 2 * (j : ℝ) ^ 4 + (((j : ℤ) - 1 : ℤ) : ℝ) ^ 4) * Real.cos ((j : ℝ) * lobattoAngle d k) = 12 * (lobattoWeight d j * (j : ℝ) ^ 2 * Real.cos ((j : ℝ) * lobattoAngle d k)) + 2 * (lobattoWeight d j * Real.cos ((k : ℤ) * ((j : ℝ) * Real.pi / (d : ℝ)))) := by intro j _ have h4 : (((j : ℤ) + 1 : ℤ) : ℝ) ^ 4 - 2 * (j : ℝ) ^ 4 + (((j : ℤ) - 1 : ℤ) : ℝ) ^ 4 = 12 * (j : ℝ) ^ 2 + 2 := by push_cast; ring rw [h4]; unfold lobattoAngle have harg : (j : ℝ) * ((k : ℝ) * Real.pi / (d : ℝ)) = ((k : ℤ) : ℝ) * ((j : ℝ) * Real.pi / (d : ℝ)) := by push_cast; ring rw [harg]; ring rw [Finset.sum_congr rfl hrew, Finset.sum_add_distrib, ← Finset.mul_sum, ← Finset.mul_sum] have hndiv : ¬ ((2 * (d : ℤ)) ∣ (k : ℤ)) := by rintro ⟨q, hq⟩ have hq1 : 1 ≤ q := by nlinarith nlinarith rw [sum_lobattoWeight_cos_eq_zero hd hndiv, mul_zero, add_zero] rw [hsum_rhs, sum_lobatto_sq_cos hd hk1 hkd, hbdry] at hid have hu_mul : Real.sin (lobattoAngle d k / 2) ^ 2 * u = 1 := mul_one_div_cancel hs2_pos.ne' have hgoal : -4 * Real.sin (lobattoAngle d k / 2) ^ 2 * (∑ j ∈ Finset.range (d + 1), lobattoWeight d j * ((j : ℝ) ^ 4) * Real.cos ((j : ℝ) * lobattoAngle d k)) = -4 * Real.sin (lobattoAngle d k / 2) ^ 2 * ((-1 : ℝ) ^ k * (d : ℝ) * u * ((d : ℝ) ^ 2 + 1 - (3 / 2 : ℝ) * u)) := by rw [hid] dsimp only [u] field_simp [hs2_pos.ne']; ring exact mul_left_cancel₀ (mul_ne_zero (by norm_num) hs2_pos.ne') hgoal end LobattoQuadrature /-! ## Section 2: Sharp Trigonometric Markov–Bernstein Inequalities -/ section TrigMarkov /-- **THEOREM A (Sharp Value-Dependent 2nd-Derivative Trigonometric Markov Inequality)**: For EVERY `d ≥ 1` and EVERY even trigonometric polynomial `P(φ) = ∑_{j=0}^d c j * cos(j φ)` satisfying `|P(k π / d)| ≤ 1` at all `d + 1` Chebyshev–Lobatto nodes: `-∑_{j=0}^d j² c j ≤ ((2 - P(0)) / 3) * d² - (1 + P(0)) / 6 ≤ ((2 - P(0)) / 3) * d²`, with exact equality at `P(φ) = -cos(d φ)`! -/ theorem trig_markov_second_deriv {d : ℕ} (hd : 1 ≤ d) (c : ℕ → ℝ) (hbdd : ∀ k ∈ Finset.range (d + 1), |∑ l ∈ Finset.range (d + 1), c l * Real.cos ((l : ℝ) * lobattoAngle d k)| ≤ 1) : -(∑ j ∈ Finset.range (d + 1), (j : ℝ) ^ 2 * c j) ≤ ((2 - ∑ l ∈ Finset.range (d + 1), c l) / 3) * (d : ℝ) ^ 2 - (1 + ∑ l ∈ Finset.range (d + 1), c l) / 6 := by have hd_pos : (0 : ℝ) < (d : ℝ) := by exact_mod_cast hd let P : ℕ → ℝ := fun k => ∑ l ∈ Finset.range (d + 1), c l * Real.cos ((l : ℝ) * lobattoAngle d k) let w : ℕ → ℝ := fun k => (2 * lobattoWeight d k / (d : ℝ)) * ∑ j ∈ Finset.range (d + 1), lobattoWeight d j * (-(j : ℝ) ^ 2) * Real.cos ((j : ℝ) * lobattoAngle d k) have hquad : -(∑ j ∈ Finset.range (d + 1), (j : ℝ) ^ 2 * c j) = ∑ k ∈ Finset.range (d + 1), w k * P k := by have h := lobatto_quadrature hd c (fun j => -(j : ℝ) ^ 2) have hlhs : ∑ j ∈ Finset.range (d + 1), -(j : ℝ) ^ 2 * c j = -(∑ j ∈ Finset.range (d + 1), (j : ℝ) ^ 2 * c j) := by rw [← Finset.sum_neg_distrib]; refine Finset.sum_congr rfl fun j _ => by ring exact hlhs.symm.trans h -- Exact values of `w 0` and signs of `w k` for `1 ≤ k ≤ d`: have hw0 : w 0 = -(2 * (d : ℝ) ^ 2 + 1) / 6 := by dsimp only [w] have hphi0 : ∀ j : ℕ, Real.cos ((j : ℝ) * lobattoAngle d 0) = 1 := fun j => by simp [lobattoAngle] simp_rw [hphi0, mul_one, mul_neg, Finset.sum_neg_distrib, sum_lobatto_sq_zero hd, lobattoWeight_zero] field_simp [hd_pos.ne'] have hwk_sign : ∀ k : ℕ, 1 ≤ k → k ≤ d → 0 ≤ (-1 : ℝ) ^ (k - 1) * w k := by intro k hk1 hkd dsimp only [w] have hsum : ∑ j ∈ Finset.range (d + 1), lobattoWeight d j * (-(j : ℝ) ^ 2) * Real.cos ((j : ℝ) * lobattoAngle d k) = -(∑ j ∈ Finset.range (d + 1), lobattoWeight d j * ((j : ℝ) ^ 2) * Real.cos ((j : ℝ) * lobattoAngle d k)) := by rw [← Finset.sum_neg_distrib]; refine Finset.sum_congr rfl fun j _ => by ring rw [hsum, sum_lobatto_sq_cos hd hk1 hkd] have hpow : (-1 : ℝ) ^ (k - 1) * (-((-1 : ℝ) ^ k)) = 1 := by obtain ⟨k', rfl⟩ := Nat.exists_eq_succ_of_ne_zero (by omega : k ≠ 0) rw [Nat.succ_sub_one, pow_succ] have hsq : (-1 : ℝ) ^ k' * (-1 : ℝ) ^ k' = 1 := by rw [← mul_pow]; norm_num linarith have hrew : (-1 : ℝ) ^ (k - 1) * (2 * lobattoWeight d k / (d : ℝ) * -((-1 : ℝ) ^ k * ((d : ℝ) / 2) / Real.sin (lobattoAngle d k / 2) ^ 2)) = lobattoWeight d k / Real.sin (lobattoAngle d k / 2) ^ 2 * ((-1 : ℝ) ^ (k - 1) * (-((-1 : ℝ) ^ k))) := by field_simp [hd_pos.ne'] rw [hrew, hpow, mul_one] have hw_nn := lobattoWeight_nonneg d k have hs_pos := sq_pos_of_pos (sin_lobatto_half_pos hd hk1 hkd) positivity -- Evaluate `∑_{k=0}^d (-1)^k w k = -d²` by plugging `c = δ_d` (i.e. `P(φ) = cos(d φ)`) into `lobatto_quadrature`! have halt_sum : ∑ k ∈ Finset.range (d + 1), (-1 : ℝ) ^ k * w k = -(d : ℝ) ^ 2 := by let cd : ℕ → ℝ := fun j => if j = d then 1 else 0 have hq := lobatto_quadrature hd cd (fun j => -(j : ℝ) ^ 2) have hlhs : ∑ j ∈ Finset.range (d + 1), -(j : ℝ) ^ 2 * cd j = -(d : ℝ) ^ 2 := by have hterm : ∀ j ∈ Finset.range (d + 1), -(j : ℝ) ^ 2 * cd j = if j = d then -(d : ℝ) ^ 2 else 0 := by intro j _; dsimp only [cd]; split_ifs with h <;> simp [h] rw [Finset.sum_congr rfl hterm, Finset.sum_ite_eq'] simp have hrhs : ∀ k ∈ Finset.range (d + 1), ∑ l ∈ Finset.range (d + 1), cd l * Real.cos ((l : ℝ) * lobattoAngle d k) = (-1 : ℝ) ^ k := by intro k _ have hterm : ∀ l ∈ Finset.range (d + 1), cd l * Real.cos ((l : ℝ) * lobattoAngle d k) = if l = d then Real.cos ((d : ℝ) * lobattoAngle d k) else 0 := by intro l _; dsimp only [cd]; split_ifs with h <;> simp [h] rw [Finset.sum_congr rfl hterm, Finset.sum_ite_eq'] simp only [Finset.mem_range, lt_add_iff_pos_right, zero_lt_one, ↓reduceIte] have harg : (d : ℝ) * lobattoAngle d k = (k : ℝ) * Real.pi := by unfold lobattoAngle; exact mul_div_cancel₀ _ hd_pos.ne' rw [harg, Real.cos_nat_mul_pi] rw [hlhs] at hq rw [hq] refine Finset.sum_congr rfl fun k hk => ?_ rw [hrhs k hk]; dsimp only [w]; ring -- Now split `k = 0` from `1 ≤ k ≤ d` and bound `w k * P k ≤ |w k| = (-1)^(k-1) * w k`! rw [hquad, Finset.sum_range_succ'] have hP0 : P 0 = ∑ l ∈ Finset.range (d + 1), c l := by dsimp only [P]; refine Finset.sum_congr rfl fun l _ => by simp [lobattoAngle] have htail : ∑ k ∈ Finset.range d, w (k + 1) * P (k + 1) ≤ ∑ k ∈ Finset.range d, (-1 : ℝ) ^ k * w (k + 1) := by refine Finset.sum_le_sum fun k hk => ?_ have hklt : k < d := Finset.mem_range.mp hk have hsg := hwk_sign (k + 1) (by omega) (by omega) simp only [Nat.add_sub_cancel] at hsg have habs_w : |w (k + 1)| = (-1 : ℝ) ^ k * w (k + 1) := by have h1 : |(-1 : ℝ) ^ k * w (k + 1)| = |w (k + 1)| := by rw [abs_mul, abs_pow, abs_neg, abs_one, one_pow, one_mul] rw [← h1, abs_of_nonneg hsg] calc w (k + 1) * P (k + 1) ≤ |w (k + 1) * P (k + 1)| := le_abs_self _ _ = |w (k + 1)| * |P (k + 1)| := abs_mul _ _ _ ≤ |w (k + 1)| * 1 := mul_le_mul_of_nonneg_left (hbdd (k + 1) (Finset.mem_range.mpr (by omega))) (abs_nonneg _) _ = (-1 : ℝ) ^ k * w (k + 1) := by rw [mul_one, habs_w] have halt_split : ∑ k ∈ Finset.range d, (-1 : ℝ) ^ k * w (k + 1) = (d : ℝ) ^ 2 + w 0 := by rw [Finset.sum_range_succ'] at halt_sum simp only [pow_zero, one_mul] at halt_sum have hneg : ∑ k ∈ Finset.range d, (-1 : ℝ) ^ (k + 1) * w (k + 1) = -(∑ k ∈ Finset.range d, (-1 : ℝ) ^ k * w (k + 1)) := by rw [← Finset.sum_neg_distrib] refine Finset.sum_congr rfl fun k _ => by rw [pow_succ]; ring rw [hneg] at halt_sum; linarith have htot : (∑ k ∈ Finset.range d, w (k + 1) * P (k + 1)) + w 0 * P 0 ≤ ((d : ℝ) ^ 2 + w 0) + w 0 * P 0 := by linarith [htail, halt_split] rw [hw0, hP0] at htot ⊢ linarith /-- Elementary sine lower bound: for EVERY `d ≥ 2`, `((12 / π²) * d² + 2) * sin (π / (2 d))² ≥ 3`. -/ theorem sin_sq_lower_universal {d : ℕ} (hd : 2 ≤ d) : 3 ≤ (12 / Real.pi ^ 2 * (d : ℝ) ^ 2 + 2) * Real.sin (Real.pi / (2 * (d : ℝ))) ^ 2 := by let x : ℝ := Real.pi / (2 * (d : ℝ)) have hdR : (2 : ℝ) ≤ (d : ℝ) := by exact_mod_cast hd have hpi_pos : 0 < Real.pi := Real.pi_pos have hpi_lt4 : Real.pi < 4 := Real.pi_lt_four have hx_pos : 0 < x := by dsimp only [x]; positivity have hx_le1 : x ≤ 1 := by dsimp only [x] rw [div_le_one (by positivity)] linarith have hsin_gt : x - x ^ 3 / 6 < Real.sin x := Real.sin_gt_sub_cube hx_pos have hsub_nn : 0 ≤ x - x ^ 3 / 6 := by have hx2 : x ^ 2 ≤ 1 := by nlinarith have hx3 : x ^ 3 ≤ x := by nlinarith linarith have hsin_sq : x ^ 2 - x ^ 4 / 3 ≤ Real.sin x ^ 2 := by have h1 : (x - x ^ 3 / 6) ^ 2 ≤ Real.sin x ^ 2 := by nlinarith have h2 : (x - x ^ 3 / 6) ^ 2 = x ^ 2 - x ^ 4 / 3 + x ^ 6 / 36 := by ring nlinarith [show 0 ≤ x ^ 6 / 36 by positivity] have hcoeff : 12 / Real.pi ^ 2 * (d : ℝ) ^ 2 + 2 = (3 + 2 * x ^ 2) / x ^ 2 := by dsimp only [x]; field_simp [hpi_pos.ne', (show (d : ℝ) ≠ 0 by linarith)]; ring rw [hcoeff] have hx2_pos : 0 < x ^ 2 := sq_pos_of_pos hx_pos have hpoly : 3 * x ^ 2 ≤ (3 + 2 * x ^ 2) * (x ^ 2 - x ^ 4 / 3) := by have hdiff : (3 + 2 * x ^ 2) * (x ^ 2 - x ^ 4 / 3) - 3 * x ^ 2 = x ^ 4 * (1 - 2 * x ^ 2 / 3) := by ring have hfac : 0 ≤ 1 - 2 * x ^ 2 / 3 := by nlinarith nlinarith [show 0 ≤ x ^ 4 * (1 - 2 * x ^ 2 / 3) by positivity] calc (3 : ℝ) = (3 * x ^ 2) / x ^ 2 := by field_simp [hx2_pos.ne'] _ ≤ ((3 + 2 * x ^ 2) * (x ^ 2 - x ^ 4 / 3)) / x ^ 2 := div_le_div_of_nonneg_right hpoly hx2_pos.le _ = (3 + 2 * x ^ 2) / x ^ 2 * (x ^ 2 - x ^ 4 / 3) := by ring _ ≤ (3 + 2 * x ^ 2) / x ^ 2 * Real.sin x ^ 2 := mul_le_mul_of_nonneg_left hsin_sq (by positivity) /-- The universal Lobatto parameter `r_∞ = 2 - 12 / π² ≈ 0.7841458`. -/ noncomputable def rInf : ℝ := 2 - 12 / Real.pi ^ 2 /-- The degree-specific optimal Lobatto parameter `r_max(d) = 2 + 2 / d² - 3 / (d² sin(π/(2d))²)`. -/ noncomputable def rMax (d : ℕ) : ℝ := 2 + 2 / (d : ℝ) ^ 2 - 3 / ((d : ℝ) ^ 2 * Real.sin (Real.pi / (2 * (d : ℝ))) ^ 2) lemma rInf_le_rMax {d : ℕ} (hd : 2 ≤ d) : rInf ≤ rMax d := by unfold rInf rMax have hd_pos : (0 : ℝ) < (d : ℝ) := by positivity have hsin_pos : 0 < Real.sin (Real.pi / (2 * (d : ℝ))) := by have := sin_lobatto_half_pos (d := d) (k := 1) (by omega) le_rfl (by omega) unfold lobattoAngle at this simpa [div_div, mul_comm (d : ℝ) 2] using this have hdenom : 0 < (d : ℝ) ^ 2 * Real.sin (Real.pi / (2 * (d : ℝ))) ^ 2 := by positivity have hkey := sin_sq_lower_universal hd have hdiv : 3 / ((d : ℝ) ^ 2 * Real.sin (Real.pi / (2 * (d : ℝ))) ^ 2) ≤ 12 / Real.pi ^ 2 + 2 / (d : ℝ) ^ 2 := by rw [div_le_iff₀ hdenom] have hrew : (12 / Real.pi ^ 2 + 2 / (d : ℝ) ^ 2) * ((d : ℝ) ^ 2 * Real.sin (Real.pi / (2 * (d : ℝ))) ^ 2) = (12 / Real.pi ^ 2 * (d : ℝ) ^ 2 + 2) * Real.sin (Real.pi / (2 * (d : ℝ))) ^ 2 := by field_simp [hd_pos.ne'] linarith linarith /-- **THEOREM B (Combined 2nd- and 4th-Derivative Trigonometric Markov Inequality)**: For EVERY `d ≥ 2`, EVERY `r ≤ rMax d` (in particular `r = rInf = 2 - 12 / π²`), and EVERY even trigonometric polynomial `P(φ) = ∑_{j=0}^d c j * cos(j φ)` with `P(0) = -1` and `|P(k π / d)| ≤ 1`: `r * d² * (∑_{j=0}^d j² c j) - (∑_{j=0}^d j⁴ c j) ≤ (1 - r) * d⁴`, with exact equality at `P(φ) = -cos(d φ)`! -/ theorem trig_markov_combined_fourth_deriv {d : ℕ} (hd : 2 ≤ d) {r : ℝ} (hr : r ≤ rMax d) (c : ℕ → ℝ) (hP0 : ∑ l ∈ Finset.range (d + 1), c l = -1) (hbdd : ∀ k ∈ Finset.range (d + 1), |∑ l ∈ Finset.range (d + 1), c l * Real.cos ((l : ℝ) * lobattoAngle d k)| ≤ 1) : r * (d : ℝ) ^ 2 * (∑ j ∈ Finset.range (d + 1), (j : ℝ) ^ 2 * c j) - (∑ j ∈ Finset.range (d + 1), (j : ℝ) ^ 4 * c j) ≤ (1 - r) * (d : ℝ) ^ 4 := by have hd1 : 1 ≤ d := by omega have hd_pos : (0 : ℝ) < (d : ℝ) := by exact_mod_cast hd1 let P : ℕ → ℝ := fun k => ∑ l ∈ Finset.range (d + 1), c l * Real.cos ((l : ℝ) * lobattoAngle d k) let μ : ℕ → ℝ := fun j => r * (d : ℝ) ^ 2 * (j : ℝ) ^ 2 - (j : ℝ) ^ 4 let w : ℕ → ℝ := fun k => (2 * lobattoWeight d k / (d : ℝ)) * ∑ j ∈ Finset.range (d + 1), lobattoWeight d j * μ j * Real.cos ((j : ℝ) * lobattoAngle d k) have hquad : r * (d : ℝ) ^ 2 * (∑ j ∈ Finset.range (d + 1), (j : ℝ) ^ 2 * c j) - (∑ j ∈ Finset.range (d + 1), (j : ℝ) ^ 4 * c j) = ∑ k ∈ Finset.range (d + 1), w k * P k := by have h := lobatto_quadrature hd1 c μ have hlhs : ∑ j ∈ Finset.range (d + 1), μ j * c j = r * (d : ℝ) ^ 2 * (∑ j ∈ Finset.range (d + 1), (j : ℝ) ^ 2 * c j) - (∑ j ∈ Finset.range (d + 1), (j : ℝ) ^ 4 * c j) := by dsimp only [μ] simp_rw [sub_mul, Finset.sum_sub_distrib, mul_assoc, ← Finset.mul_sum] exact hlhs.symm.trans h -- Key monotonicity: for `1 ≤ k ≤ d`, `sin (π / (2 d)) ≤ sin (k π / (2 d))`, so `u_k ≤ u_1`! have hu_le : ∀ k : ℕ, 1 ≤ k → k ≤ d → 1 / Real.sin (lobattoAngle d k / 2) ^ 2 ≤ 1 / Real.sin (Real.pi / (2 * (d : ℝ))) ^ 2 := by intro k hk1 hkd have hsin1 : 0 < Real.sin (Real.pi / (2 * (d : ℝ))) := by have := sin_lobatto_half_pos hd1 (k := 1) le_rfl (by omega) unfold lobattoAngle at this; simpa [div_div, mul_comm (d : ℝ) 2] using this have hle_ang : Real.pi / (2 * (d : ℝ)) ≤ lobattoAngle d k / 2 := by unfold lobattoAngle; rw [div_div, mul_comm (d : ℝ) 2] refine div_le_div_of_nonneg_right ?_ (by positivity) have hk1R : (1 : ℝ) ≤ (k : ℝ) := by exact_mod_cast hk1 nlinarith [Real.pi_pos] have hle_pi2 : lobattoAngle d k / 2 ≤ Real.pi / 2 := by unfold lobattoAngle; rw [div_div, div_le_div_iff₀ (by positivity) (by norm_num)] have hkdR : (k : ℝ) ≤ (d : ℝ) := by exact_mod_cast hkd nlinarith [Real.pi_pos] have hsin_mono : Real.sin (Real.pi / (2 * (d : ℝ))) ≤ Real.sin (lobattoAngle d k / 2) := by have hnn : 0 ≤ Real.pi / (2 * (d : ℝ)) := by positivity exact Real.sin_le_sin_of_le_of_le_pi_div_two (by linarith [Real.pi_pos]) hle_pi2 hle_ang have hsq_le : Real.sin (Real.pi / (2 * (d : ℝ))) ^ 2 ≤ Real.sin (lobattoAngle d k / 2) ^ 2 := by nlinarith exact one_div_le_one_div_of_le (sq_pos_of_pos hsin1) hsq_le -- Sign alternation of `w k` for ALL `1 ≤ k ≤ d`: `(-1)^(k-1) * w k ≥ 0`! have hwk_sign : ∀ k : ℕ, 1 ≤ k → k ≤ d → 0 ≤ (-1 : ℝ) ^ (k - 1) * w k := by intro k hk1 hkd let u : ℝ := 1 / Real.sin (lobattoAngle d k / 2) ^ 2 have hsin_k := sin_lobatto_half_pos hd1 hk1 hkd have hu_pos : 0 < u := by dsimp only [u]; positivity have hsum : ∑ j ∈ Finset.range (d + 1), lobattoWeight d j * μ j * Real.cos ((j : ℝ) * lobattoAngle d k) = r * (d : ℝ) ^ 2 * (∑ j ∈ Finset.range (d + 1), lobattoWeight d j * (j : ℝ) ^ 2 * Real.cos ((j : ℝ) * lobattoAngle d k)) - (∑ j ∈ Finset.range (d + 1), lobattoWeight d j * (j : ℝ) ^ 4 * Real.cos ((j : ℝ) * lobattoAngle d k)) := by have hrew : ∀ j ∈ Finset.range (d + 1), lobattoWeight d j * μ j * Real.cos ((j : ℝ) * lobattoAngle d k) = r * (d : ℝ) ^ 2 * (lobattoWeight d j * (j : ℝ) ^ 2 * Real.cos ((j : ℝ) * lobattoAngle d k)) - (lobattoWeight d j * (j : ℝ) ^ 4 * Real.cos ((j : ℝ) * lobattoAngle d k)) := by intro j _; dsimp only [μ]; ring rw [Finset.sum_congr rfl hrew, Finset.sum_sub_distrib, ← Finset.mul_sum] have hwk_eq : w k = (-1 : ℝ) ^ (k - 1) * lobattoWeight d k * u * ((2 - r) * (d : ℝ) ^ 2 + 2 - 3 * u) := by dsimp only [w] rw [hsum, sum_lobatto_sq_cos hd1 hk1 hkd, sum_lobatto_pow4_cos hd1 hk1 hkd] have hpow : (-1 : ℝ) ^ k = -((-1 : ℝ) ^ (k - 1)) := by obtain ⟨k', rfl⟩ := Nat.exists_eq_succ_of_ne_zero (by omega : k ≠ 0) simp only [Nat.succ_sub_one, pow_succ]; ring have hdiv_u : (-1 : ℝ) ^ k * ((d : ℝ) / 2) / Real.sin (lobattoAngle d k / 2) ^ 2 = (-1 : ℝ) ^ k * ((d : ℝ) / 2) * u := by dsimp only [u]; ring rw [hdiv_u, hpow] dsimp only [u] field_simp [hd_pos.ne', hsin_k.ne']; ring rw [hwk_eq] have hsq1 : (-1 : ℝ) ^ (k - 1) * (-1 : ℝ) ^ (k - 1) = 1 := by rw [← mul_pow]; norm_num have hrew2 : (-1 : ℝ) ^ (k - 1) * ((-1 : ℝ) ^ (k - 1) * lobattoWeight d k * u * ((2 - r) * (d : ℝ) ^ 2 + 2 - 3 * u)) = lobattoWeight d k * u * ((2 - r) * (d : ℝ) ^ 2 + 2 - 3 * u) := by calc _ = ((-1 : ℝ) ^ (k - 1) * (-1 : ℝ) ^ (k - 1)) * (lobattoWeight d k * u * ((2 - r) * (d : ℝ) ^ 2 + 2 - 3 * u)) := by ring _ = _ := by rw [hsq1, one_mul] rw [hrew2] have hbr : 0 ≤ (2 - r) * (d : ℝ) ^ 2 + 2 - 3 * u := by have hr' : (2 - r) * (d : ℝ) ^ 2 + 2 ≥ 3 / Real.sin (Real.pi / (2 * (d : ℝ))) ^ 2 := by unfold rMax at hr have hsin1 : 0 < Real.sin (Real.pi / (2 * (d : ℝ))) := by have := sin_lobatto_half_pos hd1 (k := 1) le_rfl (by omega) unfold lobattoAngle at this; simpa [div_div, mul_comm (d : ℝ) 2] using this have hmul := mul_le_mul_of_nonneg_right hr (sq_nonneg (d : ℝ)) have hrhs : (2 + 2 / (d : ℝ) ^ 2 - 3 / ((d : ℝ) ^ 2 * Real.sin (Real.pi / (2 * (d : ℝ))) ^ 2)) * (d : ℝ) ^ 2 = 2 * (d : ℝ) ^ 2 + 2 - 3 / Real.sin (Real.pi / (2 * (d : ℝ))) ^ 2 := by field_simp [hd_pos.ne', hsin1.ne'] linarith have hu1 := hu_le k hk1 hkd have h3u : 3 * u ≤ 3 / Real.sin (Real.pi / (2 * (d : ℝ))) ^ 2 := by calc 3 * u ≤ 3 * (1 / Real.sin (Real.pi / (2 * (d : ℝ))) ^ 2) := mul_le_mul_of_nonneg_left hu1 (by norm_num) _ = 3 / Real.sin (Real.pi / (2 * (d : ℝ))) ^ 2 := by ring linarith have hw_nn := lobattoWeight_nonneg d k positivity -- Exact alternating sum `∑_{k=0}^d (-1)^k * w k = μ d = -(1 - r) * d⁴`! have halt_sum : ∑ k ∈ Finset.range (d + 1), (-1 : ℝ) ^ k * w k = -(1 - r) * (d : ℝ) ^ 4 := by let cd : ℕ → ℝ := fun j => if j = d then 1 else 0 have hq := lobatto_quadrature hd1 cd μ have hlhs : ∑ j ∈ Finset.range (d + 1), μ j * cd j = -(1 - r) * (d : ℝ) ^ 4 := by have hterm : ∀ j ∈ Finset.range (d + 1), μ j * cd j = if j = d then μ d else 0 := by intro j _; dsimp only [cd]; split_ifs with h <;> simp [h] rw [Finset.sum_congr rfl hterm, Finset.sum_ite_eq'] simp only [Finset.mem_range, lt_add_iff_pos_right, zero_lt_one, ↓reduceIte] dsimp only [μ]; ring have hrhs : ∀ k ∈ Finset.range (d + 1), ∑ l ∈ Finset.range (d + 1), cd l * Real.cos ((l : ℝ) * lobattoAngle d k) = (-1 : ℝ) ^ k := by intro k _ have hterm : ∀ l ∈ Finset.range (d + 1), cd l * Real.cos ((l : ℝ) * lobattoAngle d k) = if l = d then Real.cos ((d : ℝ) * lobattoAngle d k) else 0 := by intro l _; dsimp only [cd]; split_ifs with h <;> simp [h] rw [Finset.sum_congr rfl hterm, Finset.sum_ite_eq'] simp only [Finset.mem_range, lt_add_iff_pos_right, zero_lt_one, ↓reduceIte] have harg : (d : ℝ) * lobattoAngle d k = (k : ℝ) * Real.pi := by unfold lobattoAngle; exact mul_div_cancel₀ _ hd_pos.ne' rw [harg, Real.cos_nat_mul_pi] rw [hlhs] at hq rw [hq] refine Finset.sum_congr rfl fun k hk => ?_ rw [hrhs k hk]; dsimp only [w]; ring -- Now watch `w 0` cancel COMPLETELY because `P 0 = -1` and `(-1)^(k-1) * w k ≥ 0`!! rw [hquad, Finset.sum_range_succ'] have hP0_eq : P 0 = -1 := by dsimp only [P] have : ∑ l ∈ Finset.range (d + 1), c l * Real.cos ((l : ℝ) * lobattoAngle d 0) = ∑ l ∈ Finset.range (d + 1), c l := Finset.sum_congr rfl fun l _ => by simp [lobattoAngle] rw [this, hP0] have htail : ∑ k ∈ Finset.range d, w (k + 1) * P (k + 1) ≤ ∑ k ∈ Finset.range d, (-1 : ℝ) ^ k * w (k + 1) := by refine Finset.sum_le_sum fun k hk => ?_ have hklt : k < d := Finset.mem_range.mp hk have hsg := hwk_sign (k + 1) (by omega) (by omega) simp only [Nat.add_sub_cancel] at hsg have habs_w : |w (k + 1)| = (-1 : ℝ) ^ k * w (k + 1) := by have h1 : |(-1 : ℝ) ^ k * w (k + 1)| = |w (k + 1)| := by rw [abs_mul, abs_pow, abs_neg, abs_one, one_pow, one_mul] rw [← h1, abs_of_nonneg hsg] calc w (k + 1) * P (k + 1) ≤ |w (k + 1) * P (k + 1)| := le_abs_self _ _ = |w (k + 1)| * |P (k + 1)| := abs_mul _ _ _ ≤ |w (k + 1)| * 1 := mul_le_mul_of_nonneg_left (hbdd (k + 1) (Finset.mem_range.mpr (by omega))) (abs_nonneg _) _ = (-1 : ℝ) ^ k * w (k + 1) := by rw [mul_one, habs_w] have halt_split : ∑ k ∈ Finset.range d, (-1 : ℝ) ^ k * w (k + 1) = (1 - r) * (d : ℝ) ^ 4 + w 0 := by rw [Finset.sum_range_succ'] at halt_sum simp only [pow_zero, one_mul] at halt_sum have hneg : ∑ k ∈ Finset.range d, (-1 : ℝ) ^ (k + 1) * w (k + 1) = -(∑ k ∈ Finset.range d, (-1 : ℝ) ^ k * w (k + 1)) := by rw [← Finset.sum_neg_distrib] refine Finset.sum_congr rfl fun k _ => by rw [pow_succ]; ring rw [hneg] at halt_sum; linarith rw [hP0_eq]; linarith end TrigMarkov /-! ## Section 3: Univariate Polynomials in `cos φ` → Even Trigonometric Polynomials -/ section CosineExpansion /-- Elementary recurrence expanding `(cos φ)^m` as an even trigonometric polynomial `∑_{j=0}^m a_j cos(j φ)` with exact moments `∑ a_j`, `∑ j² a_j`, `∑ j⁴ a_j`! Notice `(cos φ) = 1 - 2 p`, so we prove directly by induction on `m` that `(cos φ)^m` has cosine coefficients with exact moments: - `∑ a_j = 1`, - `∑ j² a_j = m`, - `∑ j⁴ a_j = 3 m² - 2 m`! -/ theorem cos_pow_expansion (m : ℕ) : ∃ c : ℕ → ℝ, (∀ φ : ℝ, Real.cos φ ^ m = ∑ j ∈ Finset.range (m + 1), c j * Real.cos ((j : ℝ) * φ)) ∧ (∑ j ∈ Finset.range (m + 1), c j = 1) ∧ (∑ j ∈ Finset.range (m + 1), (j : ℝ) ^ 2 * c j = (m : ℝ)) ∧ (∑ j ∈ Finset.range (m + 1), (j : ℝ) ^ 4 * c j = 3 * (m : ℝ) ^ 2 - 2 * (m : ℝ)) := by induction m with | zero => refine ⟨fun _ => 1, fun φ => by simp, by simp, by simp, by simp⟩ | succ m ih => rcases ih with ⟨c, hval, hm0, hm2, hm4⟩ -- Multiply `∑_{j=0}^m c j cos(j φ)` by `cos φ`, using -- `cos(j φ) * cos φ = (1/2) cos((j+1) φ) + (1/2) cos((j-1) φ)` (with `cos((-1)φ) = cos(1·φ)`)! -- New coefficient `c' k` (for `0 ≤ k ≤ m + 1`): -- `c' 0 = (1/2) * (if 1 ≤ m then c 1 else 0)` -- `c' 1 = c 0 + (1/2) * (if 2 ≤ m then c 2 else 0)` -- `c' k = (1/2) * c (k - 1) + (1/2) * (if k + 1 ≤ m then c (k + 1) else 0)` for `2 ≤ k ≤ m + 1`! let c0 : ℕ → ℝ := fun j => if j ≤ m then c j else 0 let c' : ℕ → ℝ := fun k => if k = 0 then (1 / 2 : ℝ) * c0 1 else if k = 1 then c0 0 + (1 / 2 : ℝ) * c0 2 else (1 / 2 : ℝ) * c0 (k - 1) + (1 / 2 : ℝ) * c0 (k + 1) -- Clean general identity: for EVERY function `g : ℕ → ℝ`, -- `∑_{k=0}^{m+1} g k * c' k = ∑_{j=0}^m c j * (if j = 0 then g 1 else (g (j + 1) + g (j - 1)) / 2)`! have htest : ∀ g : ℕ → ℝ, ∑ k ∈ Finset.range (m + 1 + 1), g k * c' k = ∑ j ∈ Finset.range (m + 1), c j * (if j = 0 then g 1 else (g (j + 1) + g (j - 1)) / 2) := by intro g -- Rewrite RHS using `c0`: each `j ∈ range (m + 1)` contributes to `k = j + 1` and `k = |j - 1|`: have hLHS : ∑ k ∈ Finset.range (m + 2), g k * c' k = (∑ k ∈ Finset.range (m + 1), g (k + 1) * ((1 / 2 : ℝ) * c0 k)) + (∑ k ∈ Finset.range (m + 1), g k * ((1 / 2 : ℝ) * c0 (k + 1))) + g 1 * ((1 / 2 : ℝ) * c0 0) := by rw [Finset.sum_range_succ' (fun k => g k * c' k) (m + 1)] rw [Finset.sum_range_succ' (fun k => g (k + 1) * c' (k + 1)) m] -- Expand `c' 0`, `c' 1`, `c' (k + 2)` on LHS: have hc'0 : c' 0 = (1 / 2 : ℝ) * c0 1 := by simp [c'] have hc'1 : c' 1 = c0 0 + (1 / 2 : ℝ) * c0 2 := by simp [c'] have hc'2 : ∀ k : ℕ, c' (k + 2) = (1 / 2 : ℝ) * c0 (k + 1) + (1 / 2 : ℝ) * c0 (k + 3) := by intro k; dsimp only [c']; rw [if_neg (by omega), if_neg (by omega)] have hsub : k + 2 - 1 = k + 1 := by omega rw [hsub] rw [hc'0, hc'1] simp_rw [hc'2, mul_add, Finset.sum_add_distrib] -- Peel `k = 0` from the first RHS sum, and `k = 0, 1` and `k = m` from the second RHS sum: rw [Finset.sum_range_succ' (fun k => g (k + 1) * ((1 / 2 : ℝ) * c0 k)) m] rw [Finset.sum_range_succ (fun k => g k * ((1 / 2 : ℝ) * c0 (k + 1))) m] have hcm1 : c0 (m + 1) = 0 := by dsimp only [c0]; rw [if_neg (by omega)] rw [hcm1, mul_zero, mul_zero, add_zero] cases m with | zero => have hcm2 : c0 2 = 0 := by dsimp only [c0]; rw [if_neg (by omega)] have hcm1' : c0 1 = 0 := by dsimp only [c0]; rw [if_neg (by omega)] simp [hcm2, hcm1']; ring | succ m' => rw [Finset.sum_range_succ' (fun k => g k * ((1 / 2 : ℝ) * c0 (k + 1))) m'] rw [Finset.sum_range_succ (fun k => g (k + 2) * ((1 / 2 : ℝ) * c0 (k + 3))) m'] have hcm3 : c0 (m' + 3) = 0 := by dsimp only [c0]; rw [if_neg (by omega)] rw [hcm3, mul_zero, mul_zero, add_zero] cases m' with | zero => have hcm2 : c0 2 = 0 := by dsimp only [c0]; rw [if_neg (by omega)] simp [hcm2]; ring | succ m'' => rw [Finset.sum_range_succ' (fun k => g (k + 1) * ((1 / 2 : ℝ) * c0 (k + 2))) m''] rw [Finset.sum_range_succ (fun k => g (k + 2) * ((1 / 2 : ℝ) * c0 (k + 3))) m''] have hcm3' : c0 (m'' + 3) = 0 := by dsimp only [c0]; rw [if_neg (by omega)] rw [hcm3', mul_zero, mul_zero, add_zero] ring rw [hLHS] -- Combine the two `range (m + 1)` sums on LHS into `∑ j ∈ range (m + 1)`: rw [Finset.sum_range_succ' (fun k => g (k + 1) * ((1 / 2 : ℝ) * c0 k)) m] rw [Finset.sum_range_succ (fun k => g k * ((1 / 2 : ℝ) * c0 (k + 1))) m] have hcm1 : c0 (m + 1) = 0 := by dsimp only [c0]; rw [if_neg (by omega)] rw [hcm1, mul_zero, mul_zero, add_zero] rw [Finset.sum_range_succ' (fun j => c j * (if j = 0 then g 1 else (g (j + 1) + g (j - 1)) / 2)) m] have hc0_eq : ∀ j ∈ Finset.range (m + 1), c0 j = c j := fun j hj => by dsimp only [c0]; rw [if_pos (Nat.lt_succ_iff.mp (Finset.mem_range.mp hj))] have hc00 : c0 0 = c 0 := hc0_eq 0 (Finset.mem_range.mpr (by omega)) rw [hc00] simp only [zero_add, ↓reduceIte] have hcomb : (∑ k ∈ Finset.range m, g (k + 2) * ((1 / 2 : ℝ) * c0 (k + 1))) + (∑ k ∈ Finset.range m, g k * ((1 / 2 : ℝ) * c0 (k + 1))) = ∑ j ∈ Finset.range m, c (j + 1) * (if j + 1 = 0 then g 1 else (g (j + 1 + 1) + g (j + 1 - 1)) / 2) := by rw [← Finset.sum_add_distrib] refine Finset.sum_congr rfl fun j hj => ?_ have hjlt : j < m := Finset.mem_range.mp hj rw [hc0_eq (j + 1) (Finset.mem_range.mpr (by omega)), if_neg (by omega)] simp only [Nat.add_sub_cancel]; ring linarith refine ⟨c', ?_, ?_, ?_, ?_⟩ · intro φ have hcomm : ∑ j ∈ Finset.range (m + 1 + 1), c' j * Real.cos ((j : ℝ) * φ) = ∑ j ∈ Finset.range (m + 1 + 1), Real.cos ((j : ℝ) * φ) * c' j := Finset.sum_congr rfl fun j _ => mul_comm _ _ rw [hcomm, pow_succ, hval φ, Finset.sum_mul, htest (fun j => Real.cos ((j : ℝ) * φ))] refine Finset.sum_congr rfl fun j _ => ?_ by_cases hj0 : j = 0 · subst hj0; simp · rw [if_neg hj0] have h1 : (j : ℝ) * φ + φ = (((j + 1 : ℕ) : ℝ) * φ) := by push_cast; ring have h2 : (j : ℝ) * φ - φ = (((j - 1 : ℕ) : ℝ) * φ) := by have hj1 : 1 ≤ j := by omega rw [Nat.cast_sub hj1]; push_cast; ring have hc : Real.cos (((j + 1 : ℕ) : ℝ) * φ) + Real.cos (((j - 1 : ℕ) : ℝ) * φ) = 2 * Real.cos ((j : ℝ) * φ) * Real.cos φ := by rw [← h1, ← h2, Real.cos_add, Real.cos_sub]; ring rw [hc]; ring · have h1 := htest (fun _ => 1) have h2 : ∑ j ∈ Finset.range (m + 1), c j * (if j = 0 then (1 : ℝ) else (1 + 1) / 2) = ∑ j ∈ Finset.range (m + 1), c j := Finset.sum_congr rfl fun j _ => by split_ifs <;> ring simpa [h2, hm0] using h1 · have h1 := htest (fun j => (j : ℝ) ^ 2) have h2 : ∑ j ∈ Finset.range (m + 1), c j * (if j = 0 then ((1 : ℕ) : ℝ) ^ 2 else (((j + 1 : ℕ) : ℝ) ^ 2 + ((j - 1 : ℕ) : ℝ) ^ 2) / 2) = (∑ j ∈ Finset.range (m + 1), (j : ℝ) ^ 2 * c j) + (∑ j ∈ Finset.range (m + 1), c j) := by rw [← Finset.sum_add_distrib] refine Finset.sum_congr rfl fun j _ => ?_ by_cases hj0 : j = 0 · subst hj0; simp · rw [if_neg hj0, Nat.cast_sub (by omega : 1 ≤ j)]; push_cast; ring rw [h1, h2, hm2, hm0]; push_cast; ring · have h1 := htest (fun j => (j : ℝ) ^ 4) have h2 : ∑ j ∈ Finset.range (m + 1), c j * (if j = 0 then ((1 : ℕ) : ℝ) ^ 4 else (((j + 1 : ℕ) : ℝ) ^ 4 + ((j - 1 : ℕ) : ℝ) ^ 4) / 2) = (∑ j ∈ Finset.range (m + 1), (j : ℝ) ^ 4 * c j) + 6 * (∑ j ∈ Finset.range (m + 1), (j : ℝ) ^ 2 * c j) + (∑ j ∈ Finset.range (m + 1), c j) := by rw [Finset.mul_sum, ← Finset.sum_add_distrib, ← Finset.sum_add_distrib] refine Finset.sum_congr rfl fun j _ => ?_ by_cases hj0 : j = 0 · subst hj0; simp · rw [if_neg hj0, Nat.cast_sub (by omega : 1 ≤ j)]; push_cast; ring rw [h1, h2, hm4, hm2, hm0]; push_cast; ring /-- **Linear Extension to Any Polynomial in `cos φ`**: For ANY coefficients `a : ℕ → ℝ` of degree `≤ d`, the function `φ ↦ ∑_{m=0}^d a m * (cos φ)^m` is an even trigonometric polynomial `∑_{j=0}^d c j * cos(j φ)` whose 0th, 2nd, and 4th moments are EXACTLY: - `∑ c j = ∑ a m`, - `∑ j² c j = ∑ m * a m`, - `∑ j⁴ c j = ∑ (3 m² - 2 m) * a m`! -/ theorem poly_cos_to_trig (d : ℕ) (a : ℕ → ℝ) : ∃ c : ℕ → ℝ, (∀ φ : ℝ, ∑ m ∈ Finset.range (d + 1), a m * Real.cos φ ^ m = ∑ j ∈ Finset.range (d + 1), c j * Real.cos ((j : ℝ) * φ)) ∧ (∑ j ∈ Finset.range (d + 1), c j = ∑ m ∈ Finset.range (d + 1), a m) ∧ (∑ j ∈ Finset.range (d + 1), (j : ℝ) ^ 2 * c j = ∑ m ∈ Finset.range (d + 1), (m : ℝ) * a m) ∧ (∑ j ∈ Finset.range (d + 1), (j : ℝ) ^ 4 * c j = ∑ m ∈ Finset.range (d + 1), (3 * (m : ℝ) ^ 2 - 2 * (m : ℝ)) * a m) := by choose cm hval hm0 hm2 hm4 using cos_pow_expansion let c : ℕ → ℝ := fun j => ∑ m ∈ Finset.range (d + 1), if j ≤ m then a m * cm m j else 0 have hswap : ∀ g : ℕ → ℝ, ∑ j ∈ Finset.range (d + 1), g j * c j = ∑ m ∈ Finset.range (d + 1), a m * ∑ j ∈ Finset.range (m + 1), g j * cm m j := by intro g dsimp only [c] simp_rw [Finset.mul_sum] rw [Finset.sum_comm] refine Finset.sum_congr rfl fun m hm => ?_ have hmd : m ≤ d := Nat.lt_succ_iff.mp (Finset.mem_range.mp hm) have hsub : Finset.range (m + 1) ⊆ Finset.range (d + 1) := Finset.range_mono (by omega) rw [← Finset.sum_subset hsub] · refine Finset.sum_congr rfl fun j hj => ?_ have hjm : j ≤ m := Nat.lt_succ_iff.mp (Finset.mem_range.mp hj) rw [if_pos hjm]; ring · intro j _ hjnot have hjm : ¬ j ≤ m := fun h => hjnot (Finset.mem_range.mpr (by omega)) rw [if_neg hjm, mul_zero] refine ⟨c, ?_, ?_, ?_, ?_⟩ · intro φ have h := hswap (fun j => Real.cos ((j : ℝ) * φ)) have hcomm : ∑ j ∈ Finset.range (d + 1), c j * Real.cos ((j : ℝ) * φ) = ∑ j ∈ Finset.range (d + 1), Real.cos ((j : ℝ) * φ) * c j := Finset.sum_congr rfl fun j _ => mul_comm _ _ rw [hcomm, h] refine Finset.sum_congr rfl fun m _ => ?_ rw [hval m φ] congr 1; refine Finset.sum_congr rfl fun j _ => mul_comm _ _ · have h := hswap (fun _ => 1) simp only [one_mul, hm0, mul_one] at h; exact h · have h := hswap (fun j => (j : ℝ) ^ 2) simp_rw [hm2] at h exact h.trans (Finset.sum_congr rfl fun m _ => mul_comm _ _) · have h := hswap (fun j => (j : ℝ) ^ 4) simp_rw [hm4] at h exact h.trans (Finset.sum_congr rfl fun m _ => mul_comm _ _) end CosineExpansion /-! ## Section 4: Boolean Functions, Walsh Degree, Approximate Degree & Block Sensitivity -/ section BooleanComplexity variable {ι : Type*} [Fintype ι] [DecidableEq ι] /-- Sign map `{false ↦ +1, true ↦ -1}`. -/ def boolSign (b : Bool) : ℝ := if b then -1 else 1 /-- Indicator map `{false ↦ 0, true ↦ 1}`. -/ def boolToReal (b : Bool) : ℝ := if b then 1 else 0 @[simp] lemma boolSign_false : boolSign false = 1 := rfl @[simp] lemma boolSign_true : boolSign true = -1 := rfl @[simp] lemma boolToReal_false : boolToReal false = 0 := rfl @[simp] lemma boolToReal_true : boolToReal true = 1 := rfl lemma boolSign_sq (b : Bool) : boolSign b ^ 2 = 1 := by cases b <;> norm_num lemma boolSign_not (b : Bool) : boolSign (!b) = -boolSign b := by cases b <;> norm_num /-- 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 unfold walsh; simp omit [Fintype ι] in lemma walsh_mul (S T : Finset ι) (x : ι → Bool) : walsh S x * walsh T x = walsh (symmDiff S T) x := by unfold walsh have hdisj : Disjoint (S \ T) (T \ S) := disjoint_sdiff_sdiff have hS : S = (S \ T) ∪ (S ∩ T) := (Finset.sdiff_union_inter S T).symm have hT : T = (T \ S) ∪ (S ∩ T) := by rw [Finset.inter_comm]; exact (Finset.sdiff_union_inter T S).symm have hsd : symmDiff S T = (S \ T) ∪ (T \ S) := Finset.symmDiff_def S T rw [hsd, Finset.prod_union hdisj] have hdisj1 : Disjoint (S \ T) (S ∩ T) := Finset.disjoint_sdiff_inter S T have hdisj2 : Disjoint (T \ S) (S ∩ T) := by rw [Finset.inter_comm]; exact Finset.disjoint_sdiff_inter T S have hlhs1 : ∏ i ∈ S, boolSign (x i) = (∏ i ∈ S \ T, boolSign (x i)) * (∏ i ∈ S ∩ T, boolSign (x i)) := by conv_lhs => rw [hS] exact Finset.prod_union hdisj1 have hlhs2 : ∏ i ∈ T, boolSign (x i) = (∏ i ∈ T \ S, boolSign (x i)) * (∏ i ∈ S ∩ T, boolSign (x i)) := by conv_lhs => rw [hT] exact Finset.prod_union hdisj2 rw [hlhs1, hlhs2] have hsq : (∏ i ∈ S ∩ T, boolSign (x i)) * (∏ i ∈ S ∩ T, boolSign (x i)) = 1 := by rw [← Finset.prod_mul_distrib] exact Finset.prod_eq_one fun i _ => by cases x i <;> norm_num calc ((∏ i ∈ S \ T, boolSign (x i)) * (∏ i ∈ S ∩ T, boolSign (x i))) * ((∏ i ∈ T \ S, boolSign (x i)) * (∏ i ∈ S ∩ T, boolSign (x i))) = (∏ i ∈ S \ T, boolSign (x i)) * (∏ i ∈ T \ S, boolSign (x i)) * ((∏ i ∈ S ∩ T, boolSign (x i)) * (∏ i ∈ S ∩ T, boolSign (x i))) := by ring _ = (∏ i ∈ S \ T, boolSign (x i)) * (∏ i ∈ T \ S, boolSign (x i)) := by rw [hsq, mul_one] /-- Coordinate flip on a subset `B : Finset ι`. -/ def flipBlock (x : ι → Bool) (B : Finset ι) : ι → Bool := fun i => if i ∈ B then !x i else x i omit [Fintype ι] in lemma flipBlock_empty (x : ι → Bool) : flipBlock x ∅ = x := by ext i; simp [flipBlock] omit [Fintype ι] in lemma flipBlock_single (x : ι → Bool) (i : ι) : flipBlock x {i} i = !x i := by simp [flipBlock] omit [Fintype ι] in lemma flipBlock_apply_mem (x : ι → Bool) {B : Finset ι} {i : ι} (hi : i ∈ B) : flipBlock x B i = !x i := by simp [flipBlock, hi] omit [Fintype ι] in lemma flipBlock_apply_notMem (x : ι → Bool) {B : Finset ι} {i : ι} (hi : i ∉ B) : flipBlock x B i = x i := by simp [flipBlock, hi] omit [Fintype ι] in lemma flipBlock_involutive (B : Finset ι) : Function.Involutive (fun x : ι → Bool => flipBlock x B) := by intro x; ext i; by_cases h : i ∈ B <;> simp [flipBlock, h] lemma sum_walsh (S : Finset ι) : ∑ x : ι → Bool, walsh S x = if S = ∅ then (2 : ℝ) ^ Fintype.card ι else 0 := by by_cases hS : S = ∅ · subst hS; simp [Fintype.card_bool] · rw [if_neg hS] obtain ⟨i₀, hi₀⟩ := Finset.nonempty_iff_ne_empty.mpr hS have hflip : ∑ x : ι → Bool, walsh S (flipBlock x {i₀}) = -(∑ x : ι → Bool, walsh S x) := by rw [← Finset.sum_neg_distrib] refine Finset.sum_congr rfl fun x _ => ?_ unfold walsh rw [← Finset.mul_prod_erase _ _ hi₀, ← Finset.mul_prod_erase _ _ hi₀, flipBlock_single, boolSign_not] have hrest : ∏ i ∈ S.erase i₀, boolSign (flipBlock x {i₀} i) = ∏ i ∈ S.erase i₀, boolSign (x i) := Finset.prod_congr rfl fun i hi => by rw [flipBlock_apply_notMem x (by simp [(Finset.mem_erase.mp hi).1])] rw [hrest]; ring have heq : ∑ x : ι → Bool, walsh S (flipBlock x {i₀}) = ∑ x : ι → Bool, walsh S x := Fintype.sum_equiv (Equiv.ofBijective _ (flipBlock_involutive {i₀}).bijective) _ _ fun _ => rfl linarith 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] have hiff : (symmDiff S T = ∅) ↔ S = T := by rw [← Finset.bot_eq_empty, symmDiff_eq_bot] simp [hiff] /-- Walsh–Fourier coefficient `f̂(S) = 2⁻ⁿ ∑_x f(x) χ_S(x)`. -/ noncomputable def fourierCoeff (F : (ι → Bool) → ℝ) (S : Finset ι) : ℝ := (∑ x : ι → Bool, F x * walsh S x) / (2 : ℝ) ^ Fintype.card ι /-- Exact Fourier inversion on the Boolean hypercube. -/ 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 hinner : ∀ y : ι → Bool, ∑ S : Finset ι, F y * walsh S y * walsh S x = if y = x then F x * (2 : ℝ) ^ Fintype.card ι else 0 := by intro y have hpull : ∑ S : Finset ι, F y * walsh S y * walsh S x = F y * ∑ S : Finset ι, walsh S y * walsh S x := by rw [Finset.mul_sum]; refine Finset.sum_congr rfl fun S _ => by ring rw [hpull] have hsumS : ∑ S : Finset ι, walsh S y * walsh S x = if y = x then (2 : ℝ) ^ Fintype.card ι else 0 := by have hprod : ∑ S : Finset ι, walsh S y * walsh S x = ∏ i : ι, (boolSign (y i) * boolSign (x 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 hyx : y = x · subst hyx; rw [if_pos rfl] have h2 : ∀ i : ι, boolSign (y i) * boolSign (y i) + (1 : ℝ) = 2 := fun i => by cases y i <;> norm_num simp [h2] · rw [if_neg hyx] have hne : ∃ i : ι, y i ≠ x i := by by_contra hall; push Not at hall; exact hyx (funext hall) rcases hne with ⟨i₀, hi₀⟩ refine Finset.prod_eq_zero (Finset.mem_univ i₀) ?_ cases hy : y i₀ <;> cases hx : x i₀ <;> simp [hy, hx] at hi₀ ⊢ rw [hsumS] by_cases hyx : y = x · subst hyx; simp · simp [hyx] simp_rw [hinner] simp only [Finset.sum_ite_eq', Finset.mem_univ, ↓reduceIte] exact (mul_div_cancel_right₀ _ h2pos.ne').symm /-- Real multilinear / Fourier degree of `F : (ι → Bool) → ℝ`: `realDeg F = max { |S| : f̂(S) ≠ 0 }`. -/ noncomputable def realDeg (F : (ι → Bool) → ℝ) : ℕ := (Finset.univ.filter fun S : Finset ι => fourierCoeff F S ≠ 0).sup Finset.card /-- Exact real polynomial degree of a Boolean function `f : (ι → Bool) → Bool`. -/ noncomputable def boolDeg (f : (ι → Bool) → Bool) : ℕ := realDeg (fun x => boolToReal (f x)) lemma fourierCoeff_eq_zero_of_gt_realDeg (F : (ι → Bool) → ℝ) {S : Finset ι} (hS : realDeg F < S.card) : fourierCoeff F S = 0 := by by_contra hne have hle : S.card ≤ realDeg F := Finset.le_sup (f := Finset.card) (Finset.mem_filter.mpr ⟨Finset.mem_univ S, hne⟩) omega /-- A real function `F : (ι → Bool) → ℝ` `ε`-approximates a Boolean function `f` in `L∞` if `|F x - boolToReal (f x)| ≤ ε` for every input `x`. -/ def IsApproxPoly (f : (ι → Bool) → Bool) (ε : ℝ) (F : (ι → Bool) → ℝ) : Prop := ∀ x : ι → Bool, |F x - boolToReal (f x)| ≤ ε /-- A family of `b` sensitive blocks at `x₀` for `f`: pairwise disjoint nonempty subsets `B : Fin b → Finset ι` such that flipping each `B m` flips `f x₀`. -/ def HasSensitiveBlocks (f : (ι → Bool) → Bool) (x₀ : ι → Bool) (b : ℕ) : Prop := ∃ B : Fin b → Finset ι, (∀ m, (B m).Nonempty) ∧ (∀ m₁ m₂, m₁ ≠ m₂ → Disjoint (B m₁) (B m₂)) ∧ (∀ m, f (flipBlock x₀ (B m)) ≠ f x₀) /-- Block sensitivity of `f` at `x₀`: largest `b ≤ |ι|` admitting `b` disjoint sensitive blocks. -/ noncomputable def blockSensAt (f : (ι → Bool) → Bool) (x₀ : ι → Bool) : ℕ := sSup {b : ℕ | HasSensitiveBlocks f x₀ b} /-- Global block sensitivity `bs(f) = max_x bs(f, x)`. -/ noncomputable def blockSens (f : (ι → Bool) → Bool) : ℕ := Finset.univ.sup fun x => blockSensAt f x /-- Sensitivity of `f` at `x₀`: number of coordinates `i` with `f (flipBlock x₀ {i}) ≠ f x₀`. -/ def sensAt (f : (ι → Bool) → Bool) (x₀ : ι → Bool) : ℕ := (Finset.univ.filter fun i : ι => f (flipBlock x₀ {i}) ≠ f x₀).card /-- Maximum sensitivity `s(f) = max_x s(f, x)`. -/ def sens (f : (ι → Bool) → Bool) : ℕ := Finset.univ.sup fun x => sensAt f x lemma hasSensitiveBlocks_le_card {f : (ι → Bool) → Bool} {x₀ : ι → Bool} {b : ℕ} (hb : HasSensitiveBlocks f x₀ b) : b ≤ Fintype.card ι := by rcases hb with ⟨B, hne, hdisj, _⟩ choose g hg using hne have hinj : Function.Injective g := by intro m₁ m₂ h by_contra hne_m exact Finset.disjoint_left.mp (hdisj m₁ m₂ hne_m) (hg m₁) (h ▸ hg m₂) simpa [Fintype.card_fin] using Fintype.card_le_of_injective g hinj omit [Fintype ι] in lemma hasSensitiveBlocks_zero (f : (ι → Bool) → Bool) (x₀ : ι → Bool) : HasSensitiveBlocks f x₀ 0 := ⟨fun m => m.elim0, fun m => m.elim0, fun m => m.elim0, fun m => m.elim0⟩ lemma hasSensitiveBlocks_of_blockSensAt (f : (ι → Bool) → Bool) (x₀ : ι → Bool) : HasSensitiveBlocks f x₀ (blockSensAt f x₀) := by unfold blockSensAt have hne : ({b : ℕ | HasSensitiveBlocks f x₀ b}).Nonempty := ⟨0, hasSensitiveBlocks_zero f x₀⟩ have hbdd : BddAbove {b : ℕ | HasSensitiveBlocks f x₀ b} := ⟨Fintype.card ι, fun b hb => hasSensitiveBlocks_le_card hb⟩ exact Nat.sSup_mem hne hbdd lemma hasSensitiveBlocks_of_blockSens (f : (ι → Bool) → Bool) : ∃ x₀ : ι → Bool, HasSensitiveBlocks f x₀ (blockSens f) := by have hne : (Finset.univ : Finset (ι → Bool)).Nonempty := ⟨fun _ => false, Finset.mem_univ _⟩ obtain ⟨x₀, _, hx₀⟩ := Finset.exists_mem_eq_sup Finset.univ hne (fun x => blockSensAt f x) exact ⟨x₀, by unfold blockSens; rw [hx₀]; exact hasSensitiveBlocks_of_blockSensAt f x₀⟩ lemma le_blockSens_of_hasSensitiveBlocks {f : (ι → Bool) → Bool} {x₀ : ι → Bool} {b : ℕ} (hb : HasSensitiveBlocks f x₀ b) : b ≤ blockSens f := by have hbdd : BddAbove {k : ℕ | HasSensitiveBlocks f x₀ k} := ⟨Fintype.card ι, fun k hk => hasSensitiveBlocks_le_card hk⟩ exact le_trans (le_csSup hbdd hb) (Finset.le_sup (f := fun x => blockSensAt f x) (Finset.mem_univ x₀)) /-- Block embedding `Φ_{x₀, B} : (Fin b → Bool) → (ι → Bool)` flipping block `B m` iff `y m = true`. -/ def blockEmbed {b : ℕ} (x₀ : ι → Bool) (B : Fin b → Finset ι) (y : Fin b → Bool) : ι → Bool := fun i => if ∃ m : Fin b, i ∈ B m ∧ y m = true then !x₀ i else x₀ i omit [Fintype ι] in lemma blockEmbed_false {b : ℕ} (x₀ : ι → Bool) (B : Fin b → Finset ι) : blockEmbed x₀ B (fun _ => false) = x₀ := by ext i; simp [blockEmbed] omit [Fintype ι] in lemma blockEmbed_single {b : ℕ} (x₀ : ι → Bool) (B : Fin b → Finset ι) (m₀ : Fin b) : blockEmbed x₀ B (fun m => decide (m = m₀)) = flipBlock x₀ (B m₀) := by ext i; unfold blockEmbed flipBlock by_cases hi : i ∈ B m₀ · rw [if_pos ⟨m₀, hi, by simp⟩, if_pos hi] · rw [if_neg, if_neg hi] rintro ⟨m, hm, hdec⟩ have : m = m₀ := of_decide_eq_true hdec subst this; exact hi hm omit [Fintype ι] in /-- Under pairwise-disjoint blocks `B`, `boolSign (blockEmbed x₀ B y i)` factors cleanly: if `i ∈ B m` it equals `boolSign (x₀ i) * boolSign (y m)`; otherwise `boolSign (x₀ i)`. -/ lemma boolSign_blockEmbed {b : ℕ} (x₀ : ι → Bool) {B : Fin b → Finset ι} (hdisj : ∀ m₁ m₂, m₁ ≠ m₂ → Disjoint (B m₁) (B m₂)) (y : Fin b → Bool) (i : ι) : boolSign (blockEmbed x₀ B y i) = boolSign (x₀ i) * ∏ m : Fin b, if i ∈ B m then boolSign (y m) else 1 := by by_cases hex : ∃ m : Fin b, i ∈ B m · rcases hex with ⟨m₀, hm₀⟩ have huniq : ∀ m : Fin b, i ∈ B m ↔ m = m₀ := fun m => ⟨fun hm => by by_contra hne exact Finset.disjoint_left.mp (hdisj m m₀ hne) hm hm₀, fun h => h ▸ hm₀⟩ have hprod : ∏ m : Fin b, (if i ∈ B m then boolSign (y m) else 1) = boolSign (y m₀) := by have hterm : ∀ m : Fin b, (if i ∈ B m then boolSign (y m) else 1) = if m = m₀ then boolSign (y m₀) else 1 := fun m => by by_cases hm : m = m₀ · subst hm; simp [hm₀] · rw [if_neg hm, if_neg (fun h => hm ((huniq m).mp h))] simp_rw [hterm] simp only [Finset.prod_ite_eq', Finset.mem_univ, ↓reduceIte] rw [hprod] unfold blockEmbed by_cases hym : y m₀ = true · rw [if_pos ⟨m₀, hm₀, hym⟩, boolSign_not, hym, boolSign_true]; ring · rw [if_neg] · cases hy : y m₀ · simp · exact (hym hy).elim · rintro ⟨m, hm, ht⟩ have := (huniq m).mp hm; subst this; exact hym ht · push Not at hex have hprod : ∏ m : Fin b, (if i ∈ B m then boolSign (y m) else 1) = 1 := Finset.prod_eq_one fun m _ => if_neg (hex m) rw [hprod, mul_one] unfold blockEmbed rw [if_neg]; rintro ⟨m, hm, _⟩; exact hex m hm /-- Product probability weight `μ_p(y) = ∏_{m : Fin b} (if y m then p else 1 - p)`. -/ def bernWeight {b : ℕ} (p : ℝ) (y : Fin b → Bool) : ℝ := ∏ m : Fin b, if y m then p else 1 - p lemma bernWeight_nonneg {b : ℕ} {p : ℝ} (hp0 : 0 ≤ p) (hp1 : p ≤ 1) (y : Fin b → Bool) : 0 ≤ bernWeight p y := Finset.prod_nonneg fun m _ => by split_ifs <;> linarith lemma sum_bernWeight {b : ℕ} (p : ℝ) : ∑ y : Fin b → Bool, bernWeight p y = 1 := by unfold bernWeight have h := (Fintype.prod_sum (fun (_ : Fin b) (v : Bool) => if v then p else 1 - p)).symm rw [h] exact Finset.prod_eq_one fun _ _ => by rw [Fintype.sum_bool]; simp /-- Key expectation identity: for any subset `M : Finset (Fin b)`, `∑ y, bernWeight p y * (∏ m ∈ M, boolSign (y m)) = (1 - 2 p) ^ |M|`! -/ lemma expect_bernWeight_walsh {b : ℕ} (p : ℝ) (M : Finset (Fin b)) : ∑ y : Fin b → Bool, bernWeight p y * (∏ m ∈ M, boolSign (y m)) = (1 - 2 * p) ^ M.card := by have hprod : ∀ y : Fin b → Bool, bernWeight p y * (∏ m ∈ M, boolSign (y m)) = ∏ m : Fin b, (if y m then p else 1 - p) * (if m ∈ M then boolSign (y m) else 1) := by intro y; unfold bernWeight rw [Finset.prod_mul_distrib, ← Finset.prod_filter] have hf : Finset.univ.filter (fun m : Fin b => m ∈ M) = M := by ext m; simp rw [hf] simp_rw [hprod] rw [(Fintype.prod_sum (fun (m : Fin b) (v : Bool) => (if v then p else 1 - p) * (if m ∈ M then boolSign v else 1))).symm] have hfac : ∀ m : Fin b, ∑ v : Bool, (if v then p else 1 - p) * (if m ∈ M then boolSign v else 1) = if m ∈ M then 1 - 2 * p else 1 := by intro m rw [Fintype.sum_bool] by_cases hm : m ∈ M · simp [hm, boolSign]; ring · simp [hm] simp_rw [hfac, ← Finset.prod_filter, Finset.prod_const] have hf : Finset.univ.filter (fun m : Fin b => m ∈ M) = M := by ext m; simp rw [hf] /-- **Master Bernstein–Walsh Symmetrization Theorem**: Given ANY `F : (ι → Bool) → ℝ` with `realDeg F ≤ d` and `b` pairwise-disjoint blocks `B : Fin b → Finset ι`: 1. The `p`-biased expectation `g(p) = ∑ y, bernWeight p y * F (blockEmbed x₀ B y)` is an EXACT polynomial `∑_{k=0}^d a k * (1 - 2 p)^k` of degree `≤ d`! 2. Its value and first two derivatives at `p = 0` (expressed in the `a_k` coefficients!) satisfy: - `∑_{k=0}^d a k = F x₀`, - `-2 * ∑_{k=0}^d k * a k = ∑ m : Fin b, (F (flipBlock x₀ (B m)) - F x₀)`, - `4 * ∑_{k=0}^d k * (k - 1) * a k = ∑ m₁ : Fin b, ∑ m₂ ∈ univ.erase m₁, (F (blockEmbed x₀ B (fun m => decide (m = m₁ ∨ m = m₂))) - F (flipBlock x₀ (B m₁)) - F (flipBlock x₀ (B m₂)) + F x₀)`. -/ theorem bernstein_walsh_symmetrization {b d : ℕ} (F : (ι → Bool) → ℝ) (hdeg : realDeg F ≤ d) (x₀ : ι → Bool) {B : Fin b → Finset ι} (hdisj : ∀ m₁ m₂, m₁ ≠ m₂ → Disjoint (B m₁) (B m₂)) : ∃ a : ℕ → ℝ, (∀ p : ℝ, ∑ y : Fin b → Bool, bernWeight p y * F (blockEmbed x₀ B y) = ∑ k ∈ Finset.range (d + 1), a k * (1 - 2 * p) ^ k) ∧ (∑ k ∈ Finset.range (d + 1), a k = F x₀) ∧ (-2 * ∑ k ∈ Finset.range (d + 1), (k : ℝ) * a k = ∑ m : Fin b, (F (flipBlock x₀ (B m)) - F x₀)) ∧ (4 * ∑ k ∈ Finset.range (d + 1), (k : ℝ) * ((k : ℝ) - 1) * a k = ∑ m₁ : Fin b, ∑ m₂ ∈ (Finset.univ : Finset (Fin b)).erase m₁, (F (blockEmbed x₀ B (fun m => decide (m = m₁ ∨ m = m₂))) - F (flipBlock x₀ (B m₁)) - F (flipBlock x₀ (B m₂)) + F x₀)) := by -- For each `S : Finset ι`, let `oddBlocks S = {m : Fin b | Odd (S ∩ B m).card}`! let oddBlocks : Finset ι → Finset (Fin b) := fun S => Finset.univ.filter fun m : Fin b => Odd (S ∩ B m).card -- Key bound: `(oddBlocks S).card ≤ S.card` because `B m` are pairwise disjoint! have hodd_le : ∀ S : Finset ι, (oddBlocks S).card ≤ S.card := by intro S have hne : ∀ m ∈ oddBlocks S, (S ∩ B m).Nonempty := by intro m hm have hodd := (Finset.mem_filter.mp hm).2 exact Finset.card_pos.mp (by rcases hodd with ⟨t, ht⟩; omega) have hcard_bi : ((oddBlocks S).biUnion (fun m => S ∩ B m)).card = ∑ m ∈ oddBlocks S, (S ∩ B m).card := by refine Finset.card_biUnion fun m₁ _ m₂ _ hne_m => ?_ exact Finset.disjoint_left.mpr fun i hi1 hi2 => Finset.disjoint_left.mp (hdisj m₁ m₂ hne_m) (Finset.mem_inter.mp hi1).2 (Finset.mem_inter.mp hi2).2 have hsub : (oddBlocks S).biUnion (fun m => S ∩ B m) ⊆ S := by intro i hi; rcases Finset.mem_biUnion.mp hi with ⟨m, _, hm⟩ exact (Finset.mem_inter.mp hm).1 calc (oddBlocks S).card = ∑ _m ∈ oddBlocks S, 1 := by simp _ ≤ ∑ m ∈ oddBlocks S, (S ∩ B m).card := Finset.sum_le_sum fun m hm => Finset.card_pos.mpr (hne m hm) _ = ((oddBlocks S).biUnion (fun m => S ∩ B m)).card := hcard_bi.symm _ ≤ S.card := Finset.card_le_card hsub -- Key Walsh evaluation on `blockEmbed`: -- `walsh S (blockEmbed x₀ B y) = walsh S x₀ * ∏ m ∈ oddBlocks S, boolSign (y m)`! have hwalsh_emb : ∀ (S : Finset ι) (y : Fin b → Bool), walsh S (blockEmbed x₀ B y) = walsh S x₀ * ∏ m ∈ oddBlocks S, boolSign (y m) := by intro S y unfold walsh simp_rw [boolSign_blockEmbed x₀ hdisj y, Finset.prod_mul_distrib] congr 1 rw [Finset.prod_comm] have hinner : ∀ m : Fin b, ∏ i ∈ S, (if i ∈ B m then boolSign (y m) else 1) = if m ∈ oddBlocks S then boolSign (y m) else 1 := by intro m rw [← Finset.prod_filter, Finset.prod_const] have hf : S.filter (fun i => i ∈ B m) = S ∩ B m := by ext i; simp rw [hf] by_cases hodd : Odd (S ∩ B m).card · have hmem : m ∈ oddBlocks S := Finset.mem_filter.mpr ⟨Finset.mem_univ _, hodd⟩ rw [if_pos hmem] rcases hodd with ⟨t, ht⟩ rw [ht, pow_add, pow_one, pow_mul, boolSign_sq, one_pow, one_mul] · have hnot : m ∉ oddBlocks S := fun h => hodd (Finset.mem_filter.mp h).2 rw [if_neg hnot] rcases Nat.not_odd_iff_even.mp hodd with ⟨t, ht⟩ rw [ht, ← two_mul, pow_mul, boolSign_sq, one_pow] simp_rw [hinner, ← Finset.prod_filter] have hf : Finset.univ.filter (fun m : Fin b => m ∈ oddBlocks S) = oddBlocks S := by ext m; simp rw [hf] -- Define `a k = ∑_{S : |oddBlocks S| = k} f̂(S) * χ_S(x₀)`! let a : ℕ → ℝ := fun k => ∑ S ∈ Finset.univ.filter (fun S : Finset ι => (oddBlocks S).card = k), fourierCoeff F S * walsh S x₀ -- Check that for EVERY `S`, if `fourierCoeff F S ≠ 0` then `(oddBlocks S).card ≤ d`! have hS_in : ∀ S : Finset ι, fourierCoeff F S ≠ 0 → (oddBlocks S).card ∈ Finset.range (d + 1) := by intro S hne have h1 : S.card ≤ realDeg F := Finset.le_sup (f := Finset.card) (Finset.mem_filter.mpr ⟨Finset.mem_univ S, hne⟩) exact Finset.mem_range.mpr (by have := hodd_le S; omega) -- Helper grouping any function of `(oddBlocks S).card` over `S`: have hgroup : ∀ g : ℕ → ℝ, ∑ k ∈ Finset.range (d + 1), g k * a k = ∑ S : Finset ι, fourierCoeff F S * walsh S x₀ * g (oddBlocks S).card := by intro g dsimp only [a] simp_rw [Finset.mul_sum] have hrew : ∀ k ∈ Finset.range (d + 1), ∑ S ∈ Finset.univ.filter (fun S : Finset ι => (oddBlocks S).card = k), g k * (fourierCoeff F S * walsh S x₀) = ∑ S ∈ Finset.univ.filter (fun S : Finset ι => (oddBlocks S).card = k), fourierCoeff F S * walsh S x₀ * g (oddBlocks S).card := by intro k _ refine Finset.sum_congr rfl fun S hS => ?_ rw [(Finset.mem_filter.mp hS).2]; ring rw [Finset.sum_congr rfl hrew, ← Finset.sum_biUnion] · symm refine (Finset.sum_subset (Finset.subset_univ _) ?_).symm intro S _ hnot by_cases hfc : fourierCoeff F S = 0 · simp [hfc] · exfalso exact hnot (Finset.mem_biUnion.mpr ⟨(oddBlocks S).card, hS_in S hfc, Finset.mem_filter.mpr ⟨Finset.mem_univ S, rfl⟩⟩) · intro k₁ _ k₂ _ hne exact Finset.disjoint_left.mpr fun S h1 h2 => hne ((Finset.mem_filter.mp h1).2.symm.trans (Finset.mem_filter.mp h2).2) refine ⟨a, ?_, ?_, ?_, ?_⟩ · -- (1) Exact Bernstein expectation formula: intro p have hrew : ∀ y : Fin b → Bool, bernWeight p y * F (blockEmbed x₀ B y) = ∑ S : Finset ι, fourierCoeff F S * walsh S x₀ * (bernWeight p y * ∏ m ∈ oddBlocks S, boolSign (y m)) := by intro y rw [fourier_expansion F (blockEmbed x₀ B y), Finset.mul_sum] refine Finset.sum_congr rfl fun S _ => by rw [hwalsh_emb S y]; ring simp_rw [hrew] rw [Finset.sum_comm] have hinner : ∀ S : Finset ι, ∑ y : Fin b → Bool, fourierCoeff F S * walsh S x₀ * (bernWeight p y * ∏ m ∈ oddBlocks S, boolSign (y m)) = fourierCoeff F S * walsh S x₀ * (1 - 2 * p) ^ (oddBlocks S).card := by intro S; rw [← Finset.mul_sum, expect_bernWeight_walsh] simp_rw [hinner] have hg := hgroup (fun k => (1 - 2 * p) ^ k) rw [← hg] refine Finset.sum_congr rfl fun k _ => mul_comm _ _ · -- (2) `∑ a k = F x₀`: have hg := hgroup (fun _ => 1) simp only [one_mul, mul_one] at hg rw [hg, ← fourier_expansion F x₀] · -- (3) `-2 * ∑ k * a k = ∑ m, (F (flipBlock x₀ (B m)) - F x₀)`: rw [Finset.mul_sum] have hg := hgroup (fun k => -2 * (k : ℝ)) have hrew1 : ∑ k ∈ Finset.range (d + 1), -2 * ((k : ℝ) * a k) = ∑ k ∈ Finset.range (d + 1), (-2 * (k : ℝ)) * a k := Finset.sum_congr rfl fun k _ => by ring rw [hrew1, hg] -- Expand RHS via `fourier_expansion`: have hRHS : ∀ m : Fin b, F (flipBlock x₀ (B m)) - F x₀ = ∑ S : Finset ι, fourierCoeff F S * walsh S x₀ * (if m ∈ oddBlocks S then (-2 : ℝ) else 0) := by intro m rw [← blockEmbed_single x₀ B m, fourier_expansion F _, fourier_expansion F x₀, ← Finset.sum_sub_distrib] refine Finset.sum_congr rfl fun S _ => ?_ rw [hwalsh_emb S] have hprod : ∏ m' ∈ oddBlocks S, boolSign (decide (m' = m)) = if m ∈ oddBlocks S then -1 else 1 := by by_cases hm : m ∈ oddBlocks S · rw [if_pos hm, ← Finset.mul_prod_erase _ _ hm] have h1 : ∏ m' ∈ (oddBlocks S).erase m, boolSign (decide (m' = m)) = 1 := Finset.prod_eq_one fun m' hm' => by simp [(Finset.mem_erase.mp hm').1] rw [h1]; simp · rw [if_neg hm] exact Finset.prod_eq_one fun m' hm' => by have hne : m' ≠ m := fun h => hm (h ▸ hm') simp [hne] rw [hprod]; split_ifs <;> ring simp_rw [hRHS] rw [Finset.sum_comm] refine Finset.sum_congr rfl fun S _ => ?_ rw [← Finset.mul_sum, ← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul] have hf : Finset.univ.filter (fun m : Fin b => m ∈ oddBlocks S) = oddBlocks S := by ext m; simp rw [hf]; ring · -- (4) `4 * ∑ k(k-1) a k = ∑_{m₁ ≠ m₂} (F(e_{m₁} ∨ e_{m₂}) - F(e_{m₁}) - F(e_{m₂}) + F(0))`: rw [Finset.mul_sum] have hg := hgroup (fun k => 4 * (k : ℝ) * ((k : ℝ) - 1)) have hrew1 : ∑ k ∈ Finset.range (d + 1), 4 * ((k : ℝ) * ((k : ℝ) - 1) * a k) = ∑ k ∈ Finset.range (d + 1), (4 * (k : ℝ) * ((k : ℝ) - 1)) * a k := Finset.sum_congr rfl fun k _ => by ring rw [hrew1, hg] have hRHS : ∀ (m₁ : Fin b) (m₂ : Fin b), m₂ ≠ m₁ → F (blockEmbed x₀ B (fun m => decide (m = m₁ ∨ m = m₂))) - F (flipBlock x₀ (B m₁)) - F (flipBlock x₀ (B m₂)) + F x₀ = ∑ S : Finset ι, fourierCoeff F S * walsh S x₀ * (if m₁ ∈ oddBlocks S ∧ m₂ ∈ oddBlocks S then (4 : ℝ) else 0) := by intro m₁ m₂ hne rw [← blockEmbed_single x₀ B m₁, ← blockEmbed_single x₀ B m₂, fourier_expansion F _, fourier_expansion F _, fourier_expansion F _, fourier_expansion F x₀] simp_rw [← Finset.sum_sub_distrib, ← Finset.sum_add_distrib] refine Finset.sum_congr rfl fun S _ => ?_ rw [hwalsh_emb S, hwalsh_emb S, hwalsh_emb S] have hp1 : ∏ m ∈ oddBlocks S, boolSign (decide (m = m₁)) = if m₁ ∈ oddBlocks S then -1 else 1 := by by_cases hm : m₁ ∈ oddBlocks S · rw [if_pos hm, ← Finset.mul_prod_erase _ _ hm] have : ∏ m ∈ (oddBlocks S).erase m₁, boolSign (decide (m = m₁)) = 1 := Finset.prod_eq_one fun m hm' => by simp [(Finset.mem_erase.mp hm').1] rw [this]; simp · rw [if_neg hm] exact Finset.prod_eq_one fun m hm' => by have : m ≠ m₁ := fun h => hm (h ▸ hm'); simp [this] have hp2 : ∏ m ∈ oddBlocks S, boolSign (decide (m = m₂)) = if m₂ ∈ oddBlocks S then -1 else 1 := by by_cases hm : m₂ ∈ oddBlocks S · rw [if_pos hm, ← Finset.mul_prod_erase _ _ hm] have : ∏ m ∈ (oddBlocks S).erase m₂, boolSign (decide (m = m₂)) = 1 := Finset.prod_eq_one fun m hm' => by simp [(Finset.mem_erase.mp hm').1] rw [this]; simp · rw [if_neg hm] exact Finset.prod_eq_one fun m hm' => by have : m ≠ m₂ := fun h => hm (h ▸ hm'); simp [this] have hp12 : ∏ m ∈ oddBlocks S, boolSign (decide (m = m₁ ∨ m = m₂)) = (if m₁ ∈ oddBlocks S then -1 else 1) * (if m₂ ∈ oddBlocks S then -1 else 1) := by have hpt : ∀ m : Fin b, boolSign (decide (m = m₁ ∨ m = m₂)) = boolSign (decide (m = m₁)) * boolSign (decide (m = m₂)) := by intro m; by_cases h1 : m = m₁ · subst h1; simp [hne.symm] · by_cases h2 : m = m₂ · subst h2; simp [hne] · simp [h1, h2] simp_rw [hpt, Finset.prod_mul_distrib, hp1, hp2] rw [hp1, hp2, hp12] by_cases h1 : m₁ ∈ oddBlocks S · by_cases h2 : m₂ ∈ oddBlocks S · simp [h1, h2]; ring · simp [h1, h2] · by_cases h2 : m₂ ∈ oddBlocks S · simp [h1, h2] · simp [h1, h2] have hsum_eq : ∑ m₁ : Fin b, ∑ m₂ ∈ (Finset.univ : Finset (Fin b)).erase m₁, (F (blockEmbed x₀ B (fun m => decide (m = m₁ ∨ m = m₂))) - F (flipBlock x₀ (B m₁)) - F (flipBlock x₀ (B m₂)) + F x₀) = ∑ m₁ : Fin b, ∑ m₂ ∈ (Finset.univ : Finset (Fin b)).erase m₁, ∑ S : Finset ι, fourierCoeff F S * walsh S x₀ * (if m₁ ∈ oddBlocks S ∧ m₂ ∈ oddBlocks S then (4 : ℝ) else 0) := Finset.sum_congr rfl fun m₁ _ => Finset.sum_congr rfl fun m₂ hm₂ => hRHS m₁ m₂ (Finset.mem_erase.mp hm₂).1 rw [hsum_eq] trans ∑ S : Finset ι, ∑ m₁ : Fin b, ∑ m₂ ∈ (Finset.univ : Finset (Fin b)).erase m₁, fourierCoeff F S * walsh S x₀ * (if m₁ ∈ oddBlocks S ∧ m₂ ∈ oddBlocks S then (4 : ℝ) else 0) · refine Finset.sum_congr rfl fun S _ => ?_ simp_rw [← Finset.mul_sum] congr 1 have hcnt : ∑ m₁ : Fin b, ∑ m₂ ∈ (Finset.univ : Finset (Fin b)).erase m₁, (if m₁ ∈ oddBlocks S ∧ m₂ ∈ oddBlocks S then (4 : ℝ) else 0) = 4 * ((oddBlocks S).card : ℝ) * (((oddBlocks S).card : ℝ) - 1) := by have hinner : ∀ m₁ : Fin b, ∑ m₂ ∈ (Finset.univ : Finset (Fin b)).erase m₁, (if m₁ ∈ oddBlocks S ∧ m₂ ∈ oddBlocks S then (4 : ℝ) else 0) = if m₁ ∈ oddBlocks S then (((oddBlocks S).card : ℝ) - 1) * 4 else 0 := by intro m₁ by_cases hm1 : m₁ ∈ oddBlocks S · rw [if_pos hm1] have h1 : ∀ m₂ ∈ (Finset.univ : Finset (Fin b)).erase m₁, (if m₁ ∈ oddBlocks S ∧ m₂ ∈ oddBlocks S then (4 : ℝ) else 0) = if m₂ ∈ oddBlocks S then (4 : ℝ) else 0 := fun m₂ _ => by simp [hm1] rw [Finset.sum_congr rfl h1, ← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul] have hf : ((Finset.univ : Finset (Fin b)).erase m₁).filter (fun m₂ => m₂ ∈ oddBlocks S) = (oddBlocks S).erase m₁ := by ext m₂; simp [and_comm] rw [hf, Finset.card_erase_of_mem hm1] have hpos : 1 ≤ (oddBlocks S).card := Finset.card_pos.mpr ⟨m₁, hm1⟩ rw [Nat.cast_sub hpos, Nat.cast_one] · rw [if_neg hm1]; exact Finset.sum_eq_zero fun m₂ _ => by simp [hm1] simp_rw [hinner, ← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul] have hf : Finset.univ.filter (fun m₁ : Fin b => m₁ ∈ oddBlocks S) = oddBlocks S := by ext m₁; simp rw [hf]; ring exact hcnt.symm · symm have hswap1 : ∑ m₁ : Fin b, ∑ m₂ ∈ (Finset.univ : Finset (Fin b)).erase m₁, ∑ S : Finset ι, fourierCoeff F S * walsh S x₀ * (if m₁ ∈ oddBlocks S ∧ m₂ ∈ oddBlocks S then (4 : ℝ) else 0) = ∑ m₁ : Fin b, ∑ S : Finset ι, ∑ m₂ ∈ (Finset.univ : Finset (Fin b)).erase m₁, fourierCoeff F S * walsh S x₀ * (if m₁ ∈ oddBlocks S ∧ m₂ ∈ oddBlocks S then (4 : ℝ) else 0) := Finset.sum_congr rfl fun _ _ => Finset.sum_comm rw [hswap1, Finset.sum_comm] /-- Symmetry helper: flipping the output of `f` (`!f x`) preserves `blockSens` and `IsApproxPoly` (with `1 - F`) and `realDeg` (for `d ≥ 1`, and for `d = 0` as well). -/ lemma realDeg_one_sub (F : (ι → Bool) → ℝ) : realDeg (fun x => 1 - F x) ≤ realDeg F := by unfold realDeg refine Finset.sup_le fun S hS => ?_ have hne := (Finset.mem_filter.mp hS).2 by_cases hS0 : S = ∅ · subst hS0; simp · have hfc : fourierCoeff (fun x => 1 - F x) S = -fourierCoeff F S := by unfold fourierCoeff have h1 : ∑ x : ι → Bool, (1 - F x) * walsh S x = (∑ x : ι → Bool, walsh S x) - ∑ x : ι → Bool, F x * walsh S x := by rw [← Finset.sum_sub_distrib]; refine Finset.sum_congr rfl fun x _ => by ring rw [h1, sum_walsh, if_neg hS0, zero_sub, neg_div] have hFne : fourierCoeff F S ≠ 0 := by intro h; apply hne; rw [hfc, h, neg_zero] exact Finset.le_sup (f := Finset.card) (Finset.mem_filter.mpr ⟨Finset.mem_univ S, hFne⟩) /-- **MAIN THEOREM 1 (New World Record for Approximate Degree vs. Block Sensitivity)**: For EVERY `ε ∈ [0, 1/2)`, EVERY Boolean function `f : (ι → Bool) → Bool`, and EVERY `ε`-approximating real multilinear polynomial `F` of degree `d = realDeg F`: `(3 * (1 - 2 * ε) / (3 + 2 * ε)) * bs(f) ≤ d²`! In particular, at `ε = 1/3`, `(3 / 11) * bs(f) ≤ deg_{1/3}(f)²` (`0.272727...`), strictly beating Proskurin (2021, `√(6/101) ≈ 0.243733`) by `+11.9%` and Nisan–Szegedy (1994, `1/6 ≈ 0.166667`) by `+63.6%` with zero additive error! -/ theorem approxDeg_sq_ge_blockSens (f : (ι → Bool) → Bool) {ε : ℝ} (hε0 : 0 ≤ ε) (hε_lt : ε < 1 / 2) (F : (ι → Bool) → ℝ) (happrox : IsApproxPoly f ε F) : (3 * (1 - 2 * ε) / (3 + 2 * ε)) * (blockSens f : ℝ) ≤ (realDeg F : ℝ) ^ 2 := by let b := blockSens f let d := realDeg F by_cases hb0 : b = 0 · dsimp only [b] at hb0; rw [hb0, Nat.cast_zero, mul_zero]; positivity have hb_pos : 1 ≤ b := by omega obtain ⟨x₀, hx₀⟩ := hasSensitiveBlocks_of_blockSens f -- WLOG `f x₀ = false` (otherwise replace `f` by `!f` and `F` by `1 - F`)! suffices hmain : ∀ (f' : (ι → Bool) → Bool) (F' : (ι → Bool) → ℝ), realDeg F' ≤ d → IsApproxPoly f' ε F' → HasSensitiveBlocks f' x₀ b → f' x₀ = false → (3 * (1 - 2 * ε) / (3 + 2 * ε)) * (b : ℝ) ≤ (d : ℝ) ^ 2 by cases hfx : f x₀ · exact hmain f F le_rfl happrox hx₀ hfx · refine hmain (fun x => !f x) (fun x => 1 - F x) (realDeg_one_sub F) ?_ ?_ (by simp [hfx]) · intro x have h := happrox x have hbool : boolToReal (!f x) = 1 - boolToReal (f x) := by cases f x <;> norm_num rw [hbool, show (1 - F x) - (1 - boolToReal (f x)) = -(F x - boolToReal (f x)) by ring, abs_neg] exact h · rcases hx₀ with ⟨B, hne, hdisj, hsens⟩ exact ⟨B, hne, hdisj, fun m => by intro h; exact hsens m (Bool.not_inj h)⟩ intro f' F' hdeg' happrox' hB hfx0 rcases hB with ⟨B, _, hdisj, hsens⟩ -- First rule out `d = 0` (a constant polynomial cannot `ε`-approximate both `0` and `1` for `ε < 1/2`)! have hd1 : 1 ≤ d := by by_contra hd0; push Not at hd0 have hd_eq : d = 0 := by omega have hdeg0 : realDeg F' = 0 := by omega have hconst : ∀ x : ι → Bool, F' x = fourierCoeff F' ∅ := by intro x; rw [fourier_expansion F' x] rw [← Finset.add_sum_erase _ _ (Finset.mem_univ (∅ : Finset ι)), walsh_empty, mul_one] have h0 : ∑ S ∈ (Finset.univ : Finset (Finset ι)).erase ∅, fourierCoeff F' S * walsh S x = 0 := by refine Finset.sum_eq_zero fun S hS => ?_ have hpos : 0 < S.card := Finset.card_pos.mpr (Finset.nonempty_iff_ne_empty.mpr (Finset.mem_erase.mp hS).1) rw [fourierCoeff_eq_zero_of_gt_realDeg F' (by omega), zero_mul] linarith have m0 : Fin b := ⟨0, hb_pos⟩ have h0 := happrox' x₀ have h1 := happrox' (flipBlock x₀ (B m0)) have hf1 : f' (flipBlock x₀ (B m0)) = true := by have := hsens m0; rw [hfx0] at this; cases h : f' (flipBlock x₀ (B m0)) <;> simp_all rw [hconst x₀, hfx0, boolToReal_false, sub_zero] at h0 rw [hconst (flipBlock x₀ (B m0)), hf1, boolToReal_true] at h1 have h0' := abs_le.mp h0 have h1' := abs_le.mp h1 linarith -- Apply Bernstein–Walsh symmetrization to `H(x) = (2 * F'(x) - 1) / (1 + 2 * ε)`! let s : ℝ := 1 + 2 * ε have hs_pos : 0 < s := by dsimp only [s]; linarith let τ : ℝ := (1 - 2 * ε) / s have hτ_pos : 0 < τ := div_pos (by linarith) hs_pos have hτ_le1 : τ ≤ 1 := by dsimp only [τ, s]; rw [div_le_one hs_pos]; linarith let H : (ι → Bool) → ℝ := fun x => (2 * F' x - 1) / s have hH_deg : realDeg H ≤ d := by refine le_trans ?_ hdeg' unfold realDeg refine Finset.sup_le fun S hS => ?_ have hne := (Finset.mem_filter.mp hS).2 by_cases hS0 : S = ∅ · subst hS0; simp · have hfc : fourierCoeff H S = (2 / s) * fourierCoeff F' S := by unfold fourierCoeff H have h1 : ∑ x : ι → Bool, (2 * F' x - 1) / s * walsh S x = (2 / s) * (∑ x : ι → Bool, F' x * walsh S x) - (1 / s) * (∑ x : ι → Bool, walsh S x) := by rw [Finset.mul_sum, Finset.mul_sum, ← Finset.sum_sub_distrib] refine Finset.sum_congr rfl fun x _ => by ring rw [h1, sum_walsh, if_neg hS0, mul_zero, sub_zero]; ring have hFne : fourierCoeff F' S ≠ 0 := by intro h; apply hne; rw [hfc, h, mul_zero] exact Finset.le_sup (f := Finset.card) (Finset.mem_filter.mpr ⟨Finset.mem_univ S, hFne⟩) have hH_bdd : ∀ x : ι → Bool, |H x| ≤ 1 := by intro x have h := abs_le.mp (happrox' x) dsimp only [H, s] rw [abs_div, abs_of_pos hs_pos, div_le_one hs_pos, abs_le] cases hf : f' x <;> simp [hf] at h <;> constructor <;> linarith have hH_x0 : H x₀ ≤ -τ := by have h := (abs_le.mp (happrox' x₀)).2 rw [hfx0, boolToReal_false, sub_zero] at h dsimp only [H, τ, s] rw [← neg_div]; exact div_le_div_of_nonneg_right (by linarith) hs_pos.le have hH_sens : ∀ m : Fin b, τ ≤ H (flipBlock x₀ (B m)) := by intro m have hf1 : f' (flipBlock x₀ (B m)) = true := by have := hsens m; rw [hfx0] at this; cases h : f' (flipBlock x₀ (B m)) <;> simp_all have h := (abs_le.mp (happrox' (flipBlock x₀ (B m)))).1 rw [hf1, boolToReal_true] at h dsimp only [H, τ, s] exact div_le_div_of_nonneg_right (by linarith) hs_pos.le obtain ⟨a, hval_a, ha0, ha1, _⟩ := bernstein_walsh_symmetrization H hH_deg x₀ hdisj obtain ⟨c, hval_c, hc0, hc2, _⟩ := poly_cos_to_trig d a -- Check `|P(φ_k)| ≤ 1` at all Lobatto nodes `φ_k` (since `p = (1 - cos φ_k) / 2 ∈ [0, 1]`)! have hP_bdd : ∀ k ∈ Finset.range (d + 1), |∑ l ∈ Finset.range (d + 1), c l * Real.cos ((l : ℝ) * lobattoAngle d k)| ≤ 1 := by intro k _ let φ := lobattoAngle d k let p := (1 - Real.cos φ) / 2 have h12p : 1 - 2 * p = Real.cos φ := by dsimp only [p]; ring have hp0 : 0 ≤ p := by dsimp only [p]; linarith [Real.cos_le_one φ] have hp1 : p ≤ 1 := by dsimp only [p]; linarith [Real.neg_one_le_cos φ] rw [← hval_c φ, ← h12p, ← hval_a p] calc |∑ y : Fin b → Bool, bernWeight p y * H (blockEmbed x₀ B y)| ≤ ∑ y : Fin b → Bool, |bernWeight p y * H (blockEmbed x₀ B y)| := Finset.abs_sum_le_sum_abs _ _ _ ≤ ∑ y : Fin b → Bool, bernWeight p y := by refine Finset.sum_le_sum fun y _ => ?_ rw [abs_mul, abs_of_nonneg (bernWeight_nonneg hp0 hp1 y)] exact (mul_le_mul_of_nonneg_left (hH_bdd _) (bernWeight_nonneg hp0 hp1 y)).trans_eq (mul_one _) _ = 1 := sum_bernWeight p -- Apply Theorem A (`trig_markov_second_deriv`)! have hmarkov := trig_markov_second_deriv hd1 c hP_bdd -- Substitute `∑ c l = H x₀` and `-∑ j² c j = (1/2) * ∑ m, (H (flipBlock x₀ (B m)) - H x₀)`! have hP0_ge : -1 ≤ H x₀ := (abs_le.mp (hH_bdd x₀)).1 have hP0_eq : ∑ l ∈ Finset.range (d + 1), c l = H x₀ := hc0.trans ha0 have hP2_lb : (1 / 2 : ℝ) * (b : ℝ) * (τ - H x₀) ≤ -(∑ j ∈ Finset.range (d + 1), (j : ℝ) ^ 2 * c j) := by rw [hc2] have hsum_lb : (b : ℝ) * (τ - H x₀) ≤ ∑ m : Fin b, (H (flipBlock x₀ (B m)) - H x₀) := by calc (b : ℝ) * (τ - H x₀) = ∑ _m : Fin b, (τ - H x₀) := by simp; ring _ ≤ ∑ m : Fin b, (H (flipBlock x₀ (B m)) - H x₀) := Finset.sum_le_sum fun m _ => by linarith [hH_sens m] linarith [ha1] rw [hP0_eq] at hmarkov have hkey : (1 / 2 : ℝ) * (b : ℝ) * (τ - H x₀) ≤ ((2 - H x₀) / 3) * (d : ℝ) ^ 2 := by linarith -- Minimize `(τ - a₀) / (2 - a₀)` over `a₀ = H x₀ ∈ [-1, -τ]`: minimum is at `a₀ = -τ`! have hratio : 3 * τ / (2 + τ) * (2 - H x₀) ≤ 3 / 2 * (τ - H x₀) := by have h2tau : 0 < 2 + τ := by linarith rw [div_mul_eq_mul_div, div_le_iff₀ h2tau] nlinarith [hH_x0, hτ_le1] have h2m_pos : 0 < 2 - H x₀ := by linarith [hH_x0] have htau_eq : 3 * τ / (2 + τ) = 3 * (1 - 2 * ε) / (3 + 2 * ε) := by have h2t : 2 + τ ≠ 0 := by linarith have h3e : (3 : ℝ) + 2 * ε ≠ 0 := by linarith rw [div_eq_div_iff h2t h3e] dsimp only [τ, s] have hsne : (1 : ℝ) + 2 * ε ≠ 0 := by linarith field_simp [hsne]; ring rw [← htau_eq] have hfin : (3 * τ / (2 + τ)) * (b : ℝ) * (2 - H x₀) ≤ (d : ℝ) ^ 2 * (2 - H x₀) := by have hb_nn : (0 : ℝ) ≤ (b : ℝ) := Nat.cast_nonneg b have h1 := mul_le_mul_of_nonneg_left hratio hb_nn nlinarith exact le_of_mul_le_mul_right hfin h2m_pos /-- **COROLLARY (Exact `ε = 1/3` World Record)**: `deg_{1/3}(f)² ≥ (3 / 11) * bs(f)` for every Boolean function `f` (beating Proskurin 2021's `√(6/101) ≈ 0.243733` and Nisan–Szegedy 1994's `1/6`). -/ theorem approxDeg_one_third_beats_proskurin (f : (ι → Bool) → Bool) (F : (ι → Bool) → ℝ) (happrox : IsApproxPoly f (1 / 3) F) : (3 / 11 : ℝ) * (blockSens f : ℝ) ≤ (realDeg F : ℝ) ^ 2 := by have h := approxDeg_sq_ge_blockSens f (by norm_num) (by norm_num) F happrox norm_num at h; exact h /-- **MAIN THEOREM 2A (Exact-Degree Master Quadratic Inequality)**: For EVERY Boolean function `f : (ι → Bool) → Bool` with `d = boolDeg f ≥ 2`, `b = blockSens f`, and EVERY `r ≤ rMax d` (in particular `r = rInf = 2 - 12 / π²`): `(3 / 2) * b² - (r * d² + 1 / 2) * b ≤ (1 - r) * d⁴`! -/ theorem exactDeg_master_quadratic (f : (ι → Bool) → Bool) (hd : 2 ≤ boolDeg f) {r : ℝ} (hr : r ≤ rMax (boolDeg f)) : (3 / 2 : ℝ) * (blockSens f : ℝ) ^ 2 - (r * (boolDeg f : ℝ) ^ 2 + 1 / 2) * (blockSens f : ℝ) ≤ (1 - r) * (boolDeg f : ℝ) ^ 4 := by let d := boolDeg f let b := blockSens f obtain ⟨x₀, hx₀⟩ := hasSensitiveBlocks_of_blockSens f suffices hmain : ∀ (f' : (ι → Bool) → Bool), boolDeg f' ≤ d → HasSensitiveBlocks f' x₀ b → f' x₀ = false → (3 / 2 : ℝ) * (b : ℝ) ^ 2 - (r * (d : ℝ) ^ 2 + 1 / 2) * (b : ℝ) ≤ (1 - r) * (d : ℝ) ^ 4 by cases hfx : f x₀ · exact hmain f le_rfl hx₀ hfx · refine hmain (fun x => !f x) ?_ ?_ (by simp [hfx]) · unfold boolDeg have heq : (fun x => boolToReal (!f x)) = (fun x => 1 - boolToReal (f x)) := by ext x; cases f x <;> norm_num rw [heq]; exact realDeg_one_sub _ · rcases hx₀ with ⟨B, hne, hdisj, hsens⟩ exact ⟨B, hne, hdisj, fun m => by intro h; exact hsens m (Bool.not_inj h)⟩ intro f' hdeg' hB hfx0 rcases hB with ⟨B, _, hdisj, hsens⟩ let H : (ι → Bool) → ℝ := fun x => 2 * boolToReal (f' x) - 1 have hH_deg : realDeg H ≤ d := by refine le_trans ?_ hdeg' unfold boolDeg realDeg refine Finset.sup_le fun S hS => ?_ have hne := (Finset.mem_filter.mp hS).2 by_cases hS0 : S = ∅ · subst hS0; simp · have hfc : fourierCoeff H S = 2 * fourierCoeff (fun x => boolToReal (f' x)) S := by unfold fourierCoeff H have h1 : ∑ x : ι → Bool, (2 * boolToReal (f' x) - 1) * walsh S x = 2 * (∑ x : ι → Bool, boolToReal (f' x) * walsh S x) - ∑ x : ι → Bool, walsh S x := by rw [Finset.mul_sum, ← Finset.sum_sub_distrib] refine Finset.sum_congr rfl fun x _ => by ring rw [h1, sum_walsh, if_neg hS0, sub_zero]; ring have hFne : fourierCoeff (fun x => boolToReal (f' x)) S ≠ 0 := by intro h; apply hne; rw [hfc, h, mul_zero] exact Finset.le_sup (f := Finset.card) (Finset.mem_filter.mpr ⟨Finset.mem_univ S, hFne⟩) have hH_bdd : ∀ x : ι → Bool, |H x| ≤ 1 := fun x => by dsimp only [H]; cases f' x <;> norm_num have hH_x0 : H x₀ = -1 := by dsimp only [H]; rw [hfx0]; norm_num have hH_sens : ∀ m : Fin b, H (flipBlock x₀ (B m)) = 1 := by intro m have hf1 : f' (flipBlock x₀ (B m)) = true := by have := hsens m; rw [hfx0] at this; cases h : f' (flipBlock x₀ (B m)) <;> simp_all dsimp only [H]; rw [hf1]; norm_num obtain ⟨a, hval_a, ha0, ha1, ha2⟩ := bernstein_walsh_symmetrization H hH_deg x₀ hdisj obtain ⟨c, hval_c, hc0, hc2, hc4⟩ := poly_cos_to_trig d a -- Check `P(0) = -1` and `|P(φ_k)| ≤ 1`! have hP0 : ∑ l ∈ Finset.range (d + 1), c l = -1 := by rw [hc0, ha0, hH_x0] have hP_bdd : ∀ k ∈ Finset.range (d + 1), |∑ l ∈ Finset.range (d + 1), c l * Real.cos ((l : ℝ) * lobattoAngle d k)| ≤ 1 := by intro k _ let φ := lobattoAngle d k let p := (1 - Real.cos φ) / 2 have h12p : 1 - 2 * p = Real.cos φ := by dsimp only [p]; ring have hp0 : 0 ≤ p := by dsimp only [p]; linarith [Real.cos_le_one φ] have hp1 : p ≤ 1 := by dsimp only [p]; linarith [Real.neg_one_le_cos φ] rw [← hval_c φ, ← h12p, ← hval_a p] calc |∑ y : Fin b → Bool, bernWeight p y * H (blockEmbed x₀ B y)| ≤ ∑ y : Fin b → Bool, |bernWeight p y * H (blockEmbed x₀ B y)| := Finset.abs_sum_le_sum_abs _ _ _ ≤ ∑ y : Fin b → Bool, bernWeight p y := by refine Finset.sum_le_sum fun y _ => ?_ rw [abs_mul, abs_of_nonneg (bernWeight_nonneg hp0 hp1 y)] exact (mul_le_mul_of_nonneg_left (hH_bdd _) (bernWeight_nonneg hp0 hp1 y)).trans_eq (mul_one _) _ = 1 := sum_bernWeight p -- Apply Theorem B (`trig_markov_combined_fourth_deriv`)! have hmarkov := trig_markov_combined_fourth_deriv hd hr c hP0 hP_bdd -- Exact value of `∑ j² c j = -b`! have hM2 : ∑ j ∈ Finset.range (d + 1), (j : ℝ) ^ 2 * c j = -(b : ℝ) := by rw [hc2] have hsum1 : ∑ m : Fin b, (H (flipBlock x₀ (B m)) - H x₀) = 2 * (b : ℝ) := by have : ∀ m : Fin b, H (flipBlock x₀ (B m)) - H x₀ = 2 := fun m => by rw [hH_sens m, hH_x0]; norm_num simp_rw [this, Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul]; ring linarith [ha1, hsum1] -- Exact upper bound on `∑ j⁴ c j ≤ -(3/2) b² + (1/2) b`! have hM4 : ∑ j ∈ Finset.range (d + 1), (j : ℝ) ^ 4 * c j ≤ -(3 / 2 : ℝ) * (b : ℝ) ^ 2 + (1 / 2 : ℝ) * (b : ℝ) := by rw [hc4] have hsplit : ∑ m ∈ Finset.range (d + 1), (3 * (m : ℝ) ^ 2 - 2 * (m : ℝ)) * a m = 3 * (∑ m ∈ Finset.range (d + 1), (m : ℝ) * ((m : ℝ) - 1) * a m) + (∑ m ∈ Finset.range (d + 1), (m : ℝ) * a m) := by rw [Finset.mul_sum, ← Finset.sum_add_distrib] refine Finset.sum_congr rfl fun m _ => by ring have ha1_eq : ∑ m ∈ Finset.range (d + 1), (m : ℝ) * a m = -(b : ℝ) := by rw [← hc2, hM2] have ha2_ub : 4 * ∑ m ∈ Finset.range (d + 1), (m : ℝ) * ((m : ℝ) - 1) * a m ≤ -2 * ((b : ℝ) * ((b : ℝ) - 1)) := by rw [ha2] have hterm : ∀ m₁ : Fin b, ∀ m₂ ∈ (Finset.univ : Finset (Fin b)).erase m₁, H (blockEmbed x₀ B (fun m => decide (m = m₁ ∨ m = m₂))) - H (flipBlock x₀ (B m₁)) - H (flipBlock x₀ (B m₂)) + H x₀ ≤ -2 := by intro m₁ m₂ _ have hle1 : H (blockEmbed x₀ B (fun m => decide (m = m₁ ∨ m = m₂))) ≤ 1 := (abs_le.mp (hH_bdd _)).2 rw [hH_sens m₁, hH_sens m₂, hH_x0]; linarith calc ∑ m₁ : Fin b, ∑ m₂ ∈ (Finset.univ : Finset (Fin b)).erase m₁, _ ≤ ∑ m₁ : Fin b, ∑ _m₂ ∈ (Finset.univ : Finset (Fin b)).erase m₁, (-2 : ℝ) := Finset.sum_le_sum fun m₁ _ => Finset.sum_le_sum fun m₂ hm₂ => hterm m₁ m₂ hm₂ _ = -2 * ((b : ℝ) * ((b : ℝ) - 1)) := by by_cases hb0 : b = 0 · rw [hb0]; simp · have hb1 : 1 ≤ b := by omega have hinner : ∀ m₁ : Fin b, ∑ _m₂ ∈ (Finset.univ : Finset (Fin b)).erase m₁, (-2 : ℝ) = ((b : ℝ) - 1) * (-2) := fun m₁ => by rw [Finset.sum_const, Finset.card_erase_of_mem (Finset.mem_univ m₁), Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, Nat.cast_sub hb1, Nat.cast_one] simp_rw [hinner, Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul] ring rw [hsplit, ha1_eq]; linarith rw [hM2] at hmarkov linarith /-- The new world-record asymptotic constant `α_∞ = (r_∞ + √(r_∞² + 6(1 - r_∞))) / 3 ≈ 0.722059` (where `r_∞ = 2 - 12 / π²`). -/ noncomputable def alphaInf : ℝ := (rInf + Real.sqrt (rInf ^ 2 + 6 * (1 - rInf))) / 3 /-- Numerical verification that `α_∞ < 0.7221 < √(2/3) ≈ 0.8165` (Wellens 2022) and `1 / α_∞ > 1.384 > √(3/2) ≈ 1.2247 > √10 - 2 ≈ 1.1623` (Proskurin 2021)! -/ theorem alphaInf_bounds : 0.722 < alphaInf ∧ alphaInf < 0.7221 ∧ alphaInf < Real.sqrt (2 / 3) := by have hpi_lo : (3.141592 : ℝ) < Real.pi := Real.pi_gt_d6 have hpi_hi : Real.pi < (3.141593 : ℝ) := Real.pi_lt_d6 have hpi2_lo : (9.86960 : ℝ) < Real.pi ^ 2 := by nlinarith have hpi2_hi : Real.pi ^ 2 < (9.86961 : ℝ) := by nlinarith have hr_lo : (0.78414 : ℝ) < rInf := by unfold rInf have : 12 / Real.pi ^ 2 < 12 / 9.86960 := div_lt_div_of_pos_left (by norm_num) (by norm_num) hpi2_lo linarith have hr_hi : rInf < (0.78415 : ℝ) := by unfold rInf have : 12 / 9.86961 < 12 / Real.pi ^ 2 := div_lt_div_of_pos_left (by norm_num) (by positivity) hpi2_hi linarith have hdisc_lo : (1.3820 : ℝ) ^ 2 < rInf ^ 2 + 6 * (1 - rInf) := by nlinarith have hdisc_hi : rInf ^ 2 + 6 * (1 - rInf) < (1.3821 : ℝ) ^ 2 := by nlinarith have hsq_lo : (1.3820 : ℝ) < Real.sqrt (rInf ^ 2 + 6 * (1 - rInf)) := by rw [← Real.sqrt_sq (by norm_num : (0 : ℝ) ≤ 1.3820)] exact Real.sqrt_lt_sqrt (by norm_num) hdisc_lo have hsq_hi : Real.sqrt (rInf ^ 2 + 6 * (1 - rInf)) < (1.3821 : ℝ) := by rw [← Real.sqrt_sq (by norm_num : (0 : ℝ) ≤ 1.3821)] exact Real.sqrt_lt_sqrt (by nlinarith) hdisc_hi unfold alphaInf refine ⟨by linarith, by linarith, ?_⟩ have h23 : (0.7221 : ℝ) < Real.sqrt (2 / 3) := by rw [← Real.sqrt_sq (by norm_num : (0 : ℝ) ≤ 0.7221)] exact Real.sqrt_lt_sqrt (by norm_num) (by norm_num) linarith /-- **MAIN THEOREM 2B (New World Record for Exact Degree vs. Block Sensitivity)**: For EVERY nonconstant Boolean function `f` (`boolDeg f ≥ 1`): `bs(f) ≤ α_∞ * deg(f)² + 1 / 3` (where `α_∞ < 0.7221 < √(2/3) ≈ 0.8165`), strictly beating Wellens (2022, `√(2/3) * deg(f)² + 1`) in BOTH leading constant (`-11.6%`) and additive constant (`1/3` vs `1`)! -/ theorem blockSens_le_alpha_deg_sq (f : (ι → Bool) → Bool) (hd1 : 1 ≤ boolDeg f) : (blockSens f : ℝ) ≤ alphaInf * (boolDeg f : ℝ) ^ 2 + 1 / 3 := by by_cases hd2 : 2 ≤ boolDeg f · have hquad := exactDeg_master_quadratic f hd2 (rInf_le_rMax hd2) let d : ℝ := (boolDeg f : ℝ) let b : ℝ := (blockSens f : ℝ) have hpi_lo : (3.1415 : ℝ) < Real.pi := Real.pi_gt_d4 have hpi_hi : Real.pi < (3.1416 : ℝ) := Real.pi_lt_d4 have hr_pos : 0 < rInf := by unfold rInf have : 12 / Real.pi ^ 2 < 2 := by rw [div_lt_iff₀ (sq_pos_of_pos Real.pi_pos)]; nlinarith linarith have hr_lt1 : rInf < 1 := by unfold rInf have : 1 < 12 / Real.pi ^ 2 := by rw [one_lt_div (sq_pos_of_pos Real.pi_pos)]; nlinarith linarith have hdisc_nn : 0 ≤ rInf ^ 2 + 6 * (1 - rInf) := by nlinarith let S : ℝ := Real.sqrt (rInf ^ 2 + 6 * (1 - rInf)) have hS_sq : S ^ 2 = rInf ^ 2 + 6 * (1 - rInf) := Real.sq_sqrt hdisc_nn have hS_ge_r : rInf ≤ S := by have : rInf ^ 2 ≤ S ^ 2 := by linarith nlinarith [Real.sqrt_nonneg (rInf ^ 2 + 6 * (1 - rInf))] -- Complete the square on `(3/2) b² - (r d² + 1/2) b ≤ (1 - r) d⁴`: have hcomp : (3 * b - (rInf * d ^ 2 + 1 / 2)) ^ 2 ≤ (S * d ^ 2 + 1 / 2) ^ 2 := by have h1 : (3 * b - (rInf * d ^ 2 + 1 / 2)) ^ 2 = 6 * ((3 / 2 : ℝ) * b ^ 2 - (rInf * d ^ 2 + 1 / 2) * b) + (rInf * d ^ 2 + 1 / 2) ^ 2 := by ring have h2 : 6 * ((1 - rInf) * d ^ 4) + (rInf * d ^ 2 + 1 / 2) ^ 2 = S ^ 2 * d ^ 4 + rInf * d ^ 2 + 1 / 4 := by rw [hS_sq]; ring have h3 : (S * d ^ 2 + 1 / 2) ^ 2 = S ^ 2 * d ^ 4 + S * d ^ 2 + 1 / 4 := by ring have h4 : rInf * d ^ 2 ≤ S * d ^ 2 := mul_le_mul_of_nonneg_right hS_ge_r (sq_nonneg d) linarith [hquad] have hpos_rhs : 0 ≤ S * d ^ 2 + 1 / 2 := by have : 0 ≤ S := Real.sqrt_nonneg _; positivity have hlin : 3 * b - (rInf * d ^ 2 + 1 / 2) ≤ S * d ^ 2 + 1 / 2 := by nlinarith unfold alphaInf; dsimp only [S] at hlin; linarith · -- `boolDeg f = 1`: `approxDeg_sq_ge_blockSens` at `ε = 0` gives `bs(f) ≤ 1² = 1 ≤ α_∞ + 1/3`! have hd_eq : boolDeg f = 1 := by omega have h1 := approxDeg_sq_ge_blockSens f le_rfl (by norm_num) (fun x => boolToReal (f x)) (fun x => by simp) norm_num at h1 change (blockSens f : ℝ) ≤ (boolDeg f : ℝ) ^ 2 at h1 rw [hd_eq] at h1 ⊢ have hlo := alphaInf_bounds.1 push_cast at h1 ⊢; linarith /-- **EXACT `d = 2` SHARP BOUND**: Every Boolean function of degree `2` has `bs(f) ≤ 3` (attained with exact equality by `NAE_3`!). -/ theorem blockSens_deg_two_le_three (f : (ι → Bool) → Bool) (hd : boolDeg f = 2) : blockSens f ≤ 3 := by have hr1 : (1 : ℝ) ≤ rMax 2 := by unfold rMax; push_cast have hsin : Real.sin (Real.pi / (2 * (2 : ℝ))) = Real.sqrt 2 / 2 := by have : Real.pi / (2 * (2 : ℝ)) = Real.pi / 4 := by ring rw [this, Real.sin_pi_div_four] rw [hsin] have hsq : (Real.sqrt 2 / 2) ^ 2 = 1 / 2 := by rw [div_pow, Real.sq_sqrt (by norm_num)]; norm_num rw [hsq]; norm_num have hq := exactDeg_master_quadratic f (by omega) (hd ▸ hr1) rw [hd] at hq; norm_num at hq -- `(3/2) b² - (9/2) b ≤ 0` ⇒ `b ≤ 3`! have hbR : (blockSens f : ℝ) ≤ 3 := by nlinarith [Nat.cast_nonneg (α := ℝ) (blockSens f)] exact_mod_cast hbR /-- **EXACT `d = 3` BOUND**: Every Boolean function of degree `3` has `bs(f) ≤ 6`! -/ theorem blockSens_deg_three_le_six (f : (ι → Bool) → Bool) (hd : boolDeg f = 3) : blockSens f ≤ 6 := by have hr : (8 / 9 : ℝ) ≤ rMax 3 := by unfold rMax; push_cast have hsin : Real.sin (Real.pi / (2 * (3 : ℝ))) = 1 / 2 := by have : Real.pi / (2 * (3 : ℝ)) = Real.pi / 6 := by ring rw [this, Real.sin_pi_div_six] rw [hsin]; norm_num have hq := exactDeg_master_quadratic f (by omega) (hd ▸ hr) rw [hd] at hq; norm_num at hq -- `(3/2) b² - (17/2) b ≤ 9` ⇒ for integer `b ≥ 7`, `(3/2)*49 - (17/2)*7 = 14 > 9`, contradiction! by_contra hgt; push Not at hgt have hb7 : (7 : ℝ) ≤ (blockSens f : ℝ) := by exact_mod_cast hgt nlinarith /-- **MAIN THEOREM 2C (Clean Constant-Free Rational Bound for ALL `deg(f) ≥ 2`)**: For EVERY Boolean function `f` with `boolDeg f ≥ 2`: `(4 / 3) * bs(f) ≤ deg(f)²` (equivalently `bs(f) ≤ (3 / 4) * deg(f)²`), **100% sharp at `deg(f) = 2`**! -/ theorem blockSens_le_three_quarters_deg_sq (f : (ι → Bool) → Bool) (hd : 2 ≤ boolDeg f) : (4 / 3 : ℝ) * (blockSens f : ℝ) ≤ (boolDeg f : ℝ) ^ 2 := by by_cases h2 : boolDeg f = 2 · have hb := blockSens_deg_two_le_three f h2 have hbR : (blockSens f : ℝ) ≤ 3 := by exact_mod_cast hb rw [h2]; push_cast; linarith · by_cases h3 : boolDeg f = 3 · have hb := blockSens_deg_three_le_six f h3 have hbR : (blockSens f : ℝ) ≤ 6 := by exact_mod_cast hb rw [h3]; push_cast; linarith · have hd4 : (4 : ℝ) ≤ (boolDeg f : ℝ) := by exact_mod_cast (by omega : 4 ≤ boolDeg f) have hα := blockSens_le_alpha_deg_sq f (by omega) have hα_lt := alphaInf_bounds.2.1 nlinarith end BooleanComplexity /-! ## Section 5: Self-Contained Proof of Huang's Sensitivity Theorem (`deg(f) ≤ s(f)²`) & Quantitative Sensitivity Conjecture World Record -/ section HuangSensitivity /-- Recursive Huang signed adjacency matrix `H_n` on `Fin n → Bool`: - `H_0 = 0`, - `H_{n+1}` splits by the first coordinate `x 0`: - `(false, false)` block: `H_n`, - `(true, true)` block: `-H_n`, - `(false, true)` and `(true, false)` blocks: `I`. -/ def huangMatrix : (n : ℕ) → Matrix (Fin n → Bool) (Fin n → Bool) ℝ | 0 => 0 | n + 1 => fun x y => if x 0 = y 0 then (if x 0 then -1 else 1) * huangMatrix n (fun i => x i.succ) (fun i => y i.succ) else if (fun i : Fin n => x i.succ) = (fun i : Fin n => y i.succ) then 1 else 0 /-- Hamming parity sign `(-1)^|x| = ∏_i boolSign (x i)`. -/ def paritySign {n : ℕ} (x : Fin n → Bool) : ℝ := ∏ i : Fin n, boolSign (x i) lemma paritySign_sq {n : ℕ} (x : Fin n → Bool) : paritySign x ^ 2 = 1 := by unfold paritySign rw [← Finset.prod_pow] exact Finset.prod_eq_one fun i _ => boolSign_sq (x i) lemma paritySign_succ {n : ℕ} (x : Fin (n + 1) → Bool) : paritySign x = boolSign (x 0) * paritySign (fun i : Fin n => x i.succ) := by unfold paritySign; exact Fin.prod_univ_succ _ /-- Equivalence splitting `Fin (n + 1) → Bool` into `Bool × (Fin n → Bool)`. -/ def headTailEquiv (n : ℕ) : (Fin (n + 1) → Bool) ≃ Bool × (Fin n → Bool) where toFun x := (x 0, fun i => x i.succ) invFun p := Fin.cons p.1 p.2 left_inv x := by ext i; refine Fin.cases ?_ ?_ i <;> simp right_inv p := by rcases p with ⟨b, t⟩; ext <;> simp /-- **Huang's Fundamental Square Identity**: `H_n * H_n = n • 1`! -/ theorem huangMatrix_sq (n : ℕ) : huangMatrix n * huangMatrix n = (n : ℝ) • (1 : Matrix (Fin n → Bool) (Fin n → Bool) ℝ) := by induction n with | zero => ext x y; simp [huangMatrix] | succ n ih => ext x y rw [Matrix.mul_apply, Matrix.smul_apply, Matrix.one_apply, smul_eq_mul] -- Re-index the sum over `z : Fin (n + 1) → Bool` by `(z 0, tail z)`: rw [Fintype.sum_equiv (headTailEquiv n) _ (fun p : Bool × (Fin n → Bool) => huangMatrix (n + 1) x (Fin.cons p.1 p.2) * huangMatrix (n + 1) (Fin.cons p.1 p.2) y) (fun z => by have h : Fin.cons (z 0) (fun i : Fin n => z i.succ) = z := (headTailEquiv n).left_inv z dsimp only [headTailEquiv, Equiv.coe_fn_mk]; rw [h])] rw [Fintype.sum_prod_type, Fintype.sum_bool] let tx : Fin n → Bool := fun i => x i.succ let ty : Fin n → Bool := fun i => y i.succ have hxy_iff : x = y ↔ x 0 = y 0 ∧ tx = ty := by constructor · intro h; subst h; exact ⟨rfl, rfl⟩ · rintro ⟨h0, ht⟩; ext i; refine Fin.cases h0 (fun j => congrFun ht j) i have htail : ∀ (b : Bool) (t : Fin n → Bool), (fun i : Fin n => (Fin.cons b t : Fin (n + 1) → Bool) i.succ) = t := fun _ _ => rfl have hih := congrFun (congrFun ih tx) ty rw [Matrix.mul_apply, Matrix.smul_apply, Matrix.one_apply, smul_eq_mul] at hih cases hx : x 0 <;> cases hy : y 0 · -- `x 0 = false, y 0 = false` simp only [huangMatrix, Fin.cons_zero, htail, hx, hy, ↓reduceIte, Bool.false_eq_true, Bool.true_eq_false, one_mul] have h1 : ∑ t : Fin n → Bool, (if tx = t then (1 : ℝ) else 0) * (if t = ty then (1 : ℝ) else 0) = if tx = ty then 1 else 0 := by have hrew : ∀ t : Fin n → Bool, (if tx = t then (1 : ℝ) else 0) * (if t = ty then (1 : ℝ) else 0) = if t = tx then (if tx = ty then 1 else 0) else 0 := by intro t; by_cases ht : t = tx · subst ht; simp · rw [if_neg ht, if_neg (Ne.symm ht), zero_mul] simp_rw [hrew]; simp only [Finset.sum_ite_eq', Finset.mem_univ, ↓reduceIte] have h2 : ∑ t : Fin n → Bool, huangMatrix n tx t * huangMatrix n t ty = (n : ℝ) * (if tx = ty then 1 else 0) := hih rw [h1, h2] have hiff : (x = y) ↔ (tx = ty) := by simp [hxy_iff, hx, hy] by_cases h : tx = ty · rw [if_pos h, if_pos (hiff.mpr h)]; push_cast; ring · rw [if_neg h, if_neg (fun h' => h (hiff.mp h'))]; ring · -- `x 0 = false, y 0 = true` simp only [huangMatrix, Fin.cons_zero, htail, hx, hy, ↓reduceIte, Bool.false_eq_true, one_mul, neg_mul] have h1 : ∑ t : Fin n → Bool, (if tx = t then (1 : ℝ) else 0) * -huangMatrix n t ty = -huangMatrix n tx ty := by have hrew : ∀ t : Fin n → Bool, (if tx = t then (1 : ℝ) else 0) * -huangMatrix n t ty = if t = tx then -huangMatrix n tx ty else 0 := fun t => by by_cases ht : t = tx · subst ht; simp · rw [if_neg ht, if_neg (Ne.symm ht), zero_mul] simp_rw [hrew]; simp only [Finset.sum_ite_eq', Finset.mem_univ, ↓reduceIte] have h2 : ∑ t : Fin n → Bool, huangMatrix n tx t * (if t = ty then (1 : ℝ) else 0) = huangMatrix n tx ty := by have hrew : ∀ t : Fin n → Bool, huangMatrix n tx t * (if t = ty then (1 : ℝ) else 0) = if t = ty then huangMatrix n tx ty else 0 := fun t => by by_cases ht : t = ty · subst ht; simp · rw [if_neg ht, if_neg ht, mul_zero] simp_rw [hrew]; simp only [Finset.sum_ite_eq', Finset.mem_univ, ↓reduceIte] have hne : x ≠ y := by intro h; rw [h, hy] at hx; simp at hx rw [h1, h2, if_neg hne]; ring · -- `x 0 = true, y 0 = false` simp only [huangMatrix, Fin.cons_zero, htail, hx, hy, ↓reduceIte, Bool.false_eq_true, Bool.true_eq_false, one_mul, neg_mul] have h1 : ∑ t : Fin n → Bool, -(huangMatrix n tx t * (if t = ty then (1 : ℝ) else 0)) = -huangMatrix n tx ty := by have hrew : ∀ t : Fin n → Bool, -(huangMatrix n tx t * (if t = ty then (1 : ℝ) else 0)) = if t = ty then -huangMatrix n tx ty else 0 := fun t => by by_cases ht : t = ty · subst ht; simp · rw [if_neg ht, if_neg ht, mul_zero, neg_zero] simp_rw [hrew]; simp only [Finset.sum_ite_eq', Finset.mem_univ, ↓reduceIte] have h2 : ∑ t : Fin n → Bool, (if tx = t then (1 : ℝ) else 0) * huangMatrix n t ty = huangMatrix n tx ty := by have hrew : ∀ t : Fin n → Bool, (if tx = t then (1 : ℝ) else 0) * huangMatrix n t ty = if t = tx then huangMatrix n tx ty else 0 := fun t => by by_cases ht : t = tx · subst ht; simp · rw [if_neg ht, if_neg (Ne.symm ht), zero_mul] simp_rw [hrew]; simp only [Finset.sum_ite_eq', Finset.mem_univ, ↓reduceIte] have hne : x ≠ y := by intro h; rw [h, hy] at hx; simp at hx rw [h1, h2, if_neg hne]; ring · -- `x 0 = true, y 0 = true` simp only [huangMatrix, Fin.cons_zero, htail, hx, hy, ↓reduceIte, Bool.false_eq_true, Bool.true_eq_false, neg_mul, one_mul, mul_neg, neg_neg] have h1 : ∑ t : Fin n → Bool, (if tx = t then (1 : ℝ) else 0) * (if t = ty then (1 : ℝ) else 0) = if tx = ty then 1 else 0 := by have hrew : ∀ t : Fin n → Bool, (if tx = t then (1 : ℝ) else 0) * (if t = ty then (1 : ℝ) else 0) = if t = tx then (if tx = ty then 1 else 0) else 0 := fun t => by by_cases ht : t = tx · subst ht; simp · rw [if_neg ht, if_neg (Ne.symm ht), zero_mul] simp_rw [hrew]; simp only [Finset.sum_ite_eq', Finset.mem_univ, ↓reduceIte] have h2 : ∑ t : Fin n → Bool, huangMatrix n tx t * huangMatrix n t ty = (n : ℝ) * (if tx = ty then 1 else 0) := hih rw [h1, h2] have hiff : (x = y) ↔ (tx = ty) := by simp [hxy_iff, hx, hy] by_cases h : tx = ty · rw [if_pos h, if_pos (hiff.mpr h)]; push_cast; ring · rw [if_neg h, if_neg (fun h' => h (hiff.mp h'))]; ring /-- Every nonzero entry of `huangMatrix n` has absolute value `1` and corresponds to a single-bit hypercube edge `y = flipBlock x {i}`! -/ lemma huangMatrix_support_and_abs (n : ℕ) (x y : Fin n → Bool) : |huangMatrix n x y| ≤ 1 ∧ (huangMatrix n x y ≠ 0 → ∃ i : Fin n, y = flipBlock x {i}) := by induction n with | zero => simp [huangMatrix] | succ n ih => unfold huangMatrix by_cases h0 : x 0 = y 0 · rw [if_pos h0] obtain ⟨habs, hsupp⟩ := ih (fun i => x i.succ) (fun i => y i.succ) refine ⟨?_, ?_⟩ · rw [abs_mul]; split_ifs <;> simp [habs] · intro hne have hne' : huangMatrix n (fun i => x i.succ) (fun i => y i.succ) ≠ 0 := by intro h; apply hne; rw [h, mul_zero] obtain ⟨j, hj⟩ := hsupp hne' refine ⟨j.succ, ?_⟩ ext i; refine Fin.cases ?_ (fun k => ?_) i · simp [flipBlock, h0, (Fin.succ_ne_zero j).symm] · have hk := congrFun hj k rw [hk]; unfold flipBlock by_cases hkj : k = j · subst hkj; simp · simp [hkj, Fin.succ_inj] · rw [if_neg h0] by_cases ht : (fun i : Fin n => x i.succ) = (fun i : Fin n => y i.succ) · rw [if_pos ht] refine ⟨by norm_num, fun _ => ⟨0, ?_⟩⟩ ext i; refine Fin.cases ?_ (fun k => ?_) i · simp only [flipBlock, Finset.mem_singleton, ↓reduceIte] cases hx : x 0 <;> cases hy : y 0 <;> simp_all · simp only [flipBlock, Finset.mem_singleton, Fin.succ_ne_zero, ↓reduceIte] exact (congrFun ht k).symm · rw [if_neg ht] exact ⟨by norm_num, fun h => (h rfl).elim⟩ /-- Parity anti-commutation: `huangMatrix n x y = 0` whenever `paritySign x = paritySign y`, hence `paritySign x * huangMatrix n x y * paritySign y = -huangMatrix n x y`! -/ lemma huangMatrix_anticomm_parity (n : ℕ) (x y : Fin n → Bool) : paritySign x * huangMatrix n x y * paritySign y = -huangMatrix n x y := by by_cases h0 : huangMatrix n x y = 0 · simp [h0] · obtain ⟨i₀, rfl⟩ := (huangMatrix_support_and_abs n x y).2 h0 have hp : paritySign (flipBlock x {i₀}) = -paritySign x := by unfold paritySign rw [← Finset.mul_prod_erase _ _ (Finset.mem_univ i₀), ← Finset.mul_prod_erase _ _ (Finset.mem_univ i₀), flipBlock_single, boolSign_not] have hrest : ∏ i ∈ Finset.univ.erase i₀, boolSign (flipBlock x {i₀} i) = ∏ i ∈ Finset.univ.erase i₀, boolSign (x i) := Finset.prod_congr rfl fun i hi => by rw [flipBlock_apply_notMem x (by simp [(Finset.mem_erase.mp hi).1])] rw [hrest]; ring rw [hp] have hsq := paritySign_sq x calc paritySign x * huangMatrix n x (flipBlock x {i₀}) * -paritySign x = -(paritySign x ^ 2) * huangMatrix n x (flipBlock x {i₀}) := by ring _ = -huangMatrix n x (flipBlock x {i₀}) := by rw [hsq, neg_mul, one_mul] /-- **Huang's Induced Subgraph Theorem (2019)** — proved completely elementarily by dimension counting on `ker(H_n - √n I) ∩ V_U` (zero spectral theorem required!): Every subset `U ⊆ (Fin n → Bool)` with `2^(n - 1) < U.card` contains a vertex `x ∈ U` with at least `√n` neighbors inside `U`! -/ theorem huang_induced_subgraph_deg {n : ℕ} (hn : 1 ≤ n) {U : Finset (Fin n → Bool)} (hU : 2 ^ (n - 1) < U.card) : ∃ x ∈ U, Real.sqrt (n : ℝ) ≤ ((Finset.univ.filter fun i : Fin n => flipBlock x {i} ∈ U).card : ℝ) := by let s : ℝ := Real.sqrt (n : ℝ) have hs_pos : 0 < s := Real.sqrt_pos.mpr (by exact_mod_cast hn) have hs_sq : s ^ 2 = (n : ℝ) := Real.sq_sqrt (Nat.cast_nonneg n) -- Define linear maps `T₊(v) = H_n v - s v` and `T₋(v) = H_n v + s v`, and parity involution `D(v)(x) = paritySign x * v x`! let L : ((Fin n → Bool) → ℝ) →ₗ[ℝ] ((Fin n → Bool) → ℝ) := Matrix.mulVecLin (huangMatrix n) let Tpos : ((Fin n → Bool) → ℝ) →ₗ[ℝ] ((Fin n → Bool) → ℝ) := L - s • LinearMap.id let Tneg : ((Fin n → Bool) → ℝ) →ₗ[ℝ] ((Fin n → Bool) → ℝ) := L + s • LinearMap.id let Epos : Submodule ℝ ((Fin n → Bool) → ℝ) := LinearMap.ker Tpos let Eneg : Submodule ℝ ((Fin n → Bool) → ℝ) := LinearMap.ker Tneg -- Parity involution `D : V ≃ₗ[ℝ] V` swaps `Epos` and `Eneg`! let D : ((Fin n → Bool) → ℝ) →ₗ[ℝ] ((Fin n → Bool) → ℝ) := { toFun := fun v x => paritySign x * v x map_add' := fun u v => by ext x; simp [mul_add] map_smul' := fun r v => by ext x; simp; ring } have hDL : ∀ v : (Fin n → Bool) → ℝ, L (D v) = -D (L v) := by intro v; ext x change (huangMatrix n).mulVec (fun y => paritySign y * v y) x = -(paritySign x * (huangMatrix n).mulVec v x) simp only [Matrix.mulVec, dotProduct] rw [Finset.mul_sum, ← Finset.sum_neg_distrib] refine Finset.sum_congr rfl fun y _ => ?_ have hanti := huangMatrix_anticomm_parity n x y have hsq := paritySign_sq x calc huangMatrix n x y * (paritySign y * v y) = (paritySign x ^ 2) * (huangMatrix n x y * (paritySign y * v y)) := by rw [hsq, one_mul] _ = paritySign x * (paritySign x * huangMatrix n x y * paritySign y) * v y := by ring _ = paritySign x * (-huangMatrix n x y) * v y := by rw [hanti] _ = -(paritySign x * (huangMatrix n x y * v y)) := by ring have hDD : ∀ v : (Fin n → Bool) → ℝ, D (D v) = v := by intro v; ext x simp only [D, LinearMap.coe_mk, AddHom.coe_mk] have hsq := paritySign_sq x calc paritySign x * (paritySign x * v x) = paritySign x ^ 2 * v x := by ring _ = v x := by rw [hsq, one_mul] -- Linear equivalence `Epos ≃ₗ[ℝ] Eneg` via `D`: have hD_pos_to_neg : ∀ v ∈ Epos, D v ∈ Eneg := by intro v hv rw [LinearMap.mem_ker] at hv ⊢ have hLv : L v = s • v := by have : L v - s • v = 0 := hv exact sub_eq_zero.mp this change L (D v) + s • D v = 0 rw [hDL v, hLv, map_smul, neg_add_cancel] have hD_neg_to_pos : ∀ v ∈ Eneg, D v ∈ Epos := by intro v hv rw [LinearMap.mem_ker] at hv ⊢ have hLv : L v = -(s • v) := by have : L v + s • v = 0 := hv exact eq_neg_of_add_eq_zero_left this change L (D v) - s • D v = 0 rw [hDL v, hLv, map_neg, map_smul, neg_neg, sub_self] let eEig : Epos ≃ₗ[ℝ] Eneg := { toFun := fun ⟨v, hv⟩ => ⟨D v, hD_pos_to_neg v hv⟩ invFun := fun ⟨v, hv⟩ => ⟨D v, hD_neg_to_pos v hv⟩ map_add' := fun ⟨u, _⟩ ⟨v, _⟩ => Subtype.ext (map_add D u v) map_smul' := fun r ⟨v, _⟩ => Subtype.ext (map_smul D r v) left_inv := fun ⟨v, _⟩ => Subtype.ext (hDD v) right_inv := fun ⟨v, _⟩ => Subtype.ext (hDD v) } have hdim_eq : Module.finrank ℝ Epos = Module.finrank ℝ Eneg := eEig.finrank_eq -- `Epos ⊓ Eneg = ⊥` and `Epos ⊔ Eneg = ⊤` (since `H_n² = n I` and `s > 0`)! have hinf : Epos ⊓ Eneg = ⊥ := by rw [Submodule.eq_bot_iff] intro v ⟨hp, hn'⟩ change v ∈ Epos at hp; change v ∈ Eneg at hn' rw [LinearMap.mem_ker] at hp hn' have h1 : L v - s • v = 0 := hp have h2 : L v + s • v = 0 := hn' have h2s : (2 * s) • v = 0 := by ext x have h1x := congrFun h1 x; have h2x := congrFun h2 x simp only [Pi.sub_apply, Pi.add_apply, Pi.smul_apply, smul_eq_mul, Pi.zero_apply] at h1x h2x ⊢ linarith exact (smul_eq_zero.mp h2s).resolve_left (mul_ne_zero two_ne_zero hs_pos.ne') have hsup : Epos ⊔ Eneg = ⊤ := by rw [Submodule.eq_top_iff'] intro v let v1 : (Fin n → Bool) → ℝ := (1 / (2 * s)) • (L v + s • v) let v2 : (Fin n → Bool) → ℝ := (1 / (2 * s)) • (s • v - L v) have hLL : L (L v) = (n : ℝ) • v := by dsimp only [L] rw [Matrix.mulVecLin_apply, Matrix.mulVecLin_apply, Matrix.mulVec_mulVec, huangMatrix_sq, Matrix.smul_mulVec, Matrix.one_mulVec] have hv1 : v1 ∈ Epos := by rw [LinearMap.mem_ker] change L v1 - s • v1 = 0 dsimp only [v1] rw [map_smul, map_add, map_smul, hLL] ext x; simp only [Pi.sub_apply, Pi.add_apply, Pi.smul_apply, smul_eq_mul, Pi.zero_apply] rw [← hs_sq]; ring have hv2 : v2 ∈ Eneg := by rw [LinearMap.mem_ker] change L v2 + s • v2 = 0 dsimp only [v2] rw [map_smul, map_sub, map_smul, hLL] ext x; simp only [Pi.sub_apply, Pi.add_apply, Pi.smul_apply, smul_eq_mul, Pi.zero_apply] rw [← hs_sq]; ring have hsum : v1 + v2 = v := by dsimp only [v1, v2]; ext x simp only [Pi.add_apply, Pi.sub_apply, Pi.smul_apply, smul_eq_mul] field_simp [hs_pos.ne']; ring rw [← hsum]; exact Submodule.add_mem_sup hv1 hv2 have hdim_V : Module.finrank ℝ ((Fin n → Bool) → ℝ) = 2 ^ n := by rw [Module.finrank_pi_fintype, Finset.sum_const, Finset.card_univ, Fintype.card_fun, Fintype.card_bool, Fintype.card_fin, Module.finrank_self, smul_eq_mul, mul_one] have hdim_Epos : Module.finrank ℝ Epos = 2 ^ (n - 1) := by have hadd := Submodule.finrank_sup_add_finrank_inf_eq Epos Eneg rw [hsup, hinf, finrank_top, finrank_bot, add_zero, hdim_V, ← hdim_eq] at hadd have hpow : 2 ^ n = 2 * 2 ^ (n - 1) := by rw [← pow_succ', Nat.sub_add_cancel hn] omega -- Define support subspace `V_U = {v | ∀ x ∉ U, v x = 0}` of dimension `U.card`! let VU : Submodule ℝ ((Fin n → Bool) → ℝ) := { carrier := {v : (Fin n → Bool) → ℝ | ∀ x, x ∉ U → v x = 0} add_mem' := fun ha hb x hx => by simp [ha x hx, hb x hx] zero_mem' := fun _ _ => rfl smul_mem' := fun r _ ha x hx => by simp [ha x hx] } let eVU : VU ≃ₗ[ℝ] (U → ℝ) := { toFun := fun ⟨v, _⟩ ⟨x, _⟩ => v x invFun := fun w => ⟨fun x => if hx : x ∈ U then w ⟨x, hx⟩ else 0, fun x hx => dif_neg hx⟩ map_add' := fun _ _ => rfl map_smul' := fun _ _ => rfl left_inv := fun ⟨v, hv⟩ => Subtype.ext (funext fun x => by by_cases hx : x ∈ U · simp [hx] · simp [hx, hv x hx]) right_inv := fun w => funext fun ⟨x, hx⟩ => by simp [hx] } have hdim_VU : Module.finrank ℝ VU = U.card := by rw [eVU.finrank_eq, Module.finrank_pi_fintype, Finset.sum_const, Finset.card_univ, Fintype.card_coe, Module.finrank_self, smul_eq_mul, mul_one] -- Dimension counting: `dim(Epos ⊓ VU) ≥ dim Epos + dim VU - dim V = 2^(n-1) + |U| - 2^n > 0`! have hinf_pos : 0 < Module.finrank ℝ ↥(Epos ⊓ VU) := by have hadd := Submodule.finrank_sup_add_finrank_inf_eq Epos VU have hle : Module.finrank ℝ ↥(Epos ⊔ VU) ≤ 2 ^ n := by rw [← hdim_V]; exact Submodule.finrank_le _ have hpow : 2 ^ n = 2 * 2 ^ (n - 1) := by rw [← pow_succ', Nat.sub_add_cancel hn] omega have hne_bot : (Epos ⊓ VU) ≠ ⊥ := by intro h; rw [h, finrank_bot] at hinf_pos; omega obtain ⟨v, hv_mem, hv_ne⟩ := Submodule.exists_mem_ne_zero_of_ne_bot hne_bot have hv_eig : L v = s • v := sub_eq_zero.mp (LinearMap.mem_ker.mp hv_mem.1) have hv_supp : ∀ x, x ∉ U → v x = 0 := hv_mem.2 -- Pick `x* ∈ U` maximizing `|v x|` (which is strictly positive since `v ≠ 0`)! have hU_ne : U.Nonempty := Finset.card_pos.mp (by omega) obtain ⟨xstar, hxstar_mem, hxstar_max⟩ := Finset.exists_max_image U (fun x => |v x|) hU_ne have hv_pos : 0 < |v xstar| := by by_contra hle; push Not at hle have h0 : |v xstar| = 0 := le_antisymm hle (abs_nonneg _) apply hv_ne; ext x by_cases hx : x ∈ U · exact abs_eq_zero.mp (le_antisymm (le_trans (hxstar_max x hx) (le_of_eq h0)) (abs_nonneg _)) · exact hv_supp x hx -- Now bound `s * |v xstar| = |(H_n v) xstar| ≤ deg_U(xstar) * |v xstar|`! refine ⟨xstar, hxstar_mem, ?_⟩ have heig_x : s * v xstar = ∑ y : Fin n → Bool, huangMatrix n xstar y * v y := by have := congrFun hv_eig xstar change (huangMatrix n).mulVec v xstar = s * v xstar at this simpa [Matrix.mulVec, dotProduct] using this.symm let emb : Fin n ↪ (Fin n → Bool) := ⟨fun i => flipBlock xstar {i}, fun i j hij => by by_contra hne have h1 : flipBlock xstar {i} i = flipBlock xstar {j} i := congrFun hij i rw [flipBlock_single, flipBlock_apply_notMem xstar (by simp [hne])] at h1 cases hx : xstar i <;> simp [hx] at h1⟩ let nbrs := (Finset.univ.filter fun i : Fin n => flipBlock xstar {i} ∈ U).map emb have hzero_out : ∀ y : Fin n → Bool, y ∉ nbrs → huangMatrix n xstar y * v y = 0 := by intro y hnot by_cases hH0 : huangMatrix n xstar y = 0 · rw [hH0, zero_mul] · by_cases hyU : y ∈ U · exfalso obtain ⟨i, rfl⟩ := (huangMatrix_support_and_abs n xstar y).2 hH0 exact hnot (Finset.mem_map.mpr ⟨i, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hyU⟩, rfl⟩) · rw [hv_supp y hyU, mul_zero] have hsum_nbrs : s * |v xstar| ≤ ((Finset.univ.filter fun i : Fin n => flipBlock xstar {i} ∈ U).card : ℝ) * |v xstar| := by calc s * |v xstar| = |s * v xstar| := by rw [abs_mul, abs_of_pos hs_pos] _ = |∑ y : Fin n → Bool, huangMatrix n xstar y * v y| := by rw [heig_x] _ = |∑ y ∈ nbrs, huangMatrix n xstar y * v y| := by rw [← Finset.sum_subset (Finset.subset_univ nbrs) (fun y _ hnot => hzero_out y hnot)] _ ≤ ∑ y ∈ nbrs, |huangMatrix n xstar y * v y| := Finset.abs_sum_le_sum_abs _ _ _ ≤ ∑ _y ∈ nbrs, |v xstar| := by refine Finset.sum_le_sum fun y hy => ?_ rcases Finset.mem_map.mp hy with ⟨i, hi, rfl⟩ have hyU : flipBlock xstar {i} ∈ U := (Finset.mem_filter.mp hi).2 rw [abs_mul] calc |huangMatrix n xstar (emb i)| * |v (emb i)| ≤ 1 * |v xstar| := mul_le_mul (huangMatrix_support_and_abs n xstar (emb i)).1 (hxstar_max (emb i) hyU) (abs_nonneg _) zero_le_one _ = |v xstar| := one_mul _ _ = ((Finset.univ.filter fun i : Fin n => flipBlock xstar {i} ∈ U).card : ℝ) * |v xstar| := by rw [Finset.sum_const, Finset.card_map, nsmul_eq_mul] exact le_of_mul_le_mul_right hsum_nbrs hv_pos /-- **HUANG'S SENSITIVITY THEOREM (2019)** (completely self-contained!): For EVERY Boolean function `f : (ι → Bool) → Bool`, `boolDeg f ≤ (sens f)²`! -/ theorem huang_sensitivity_theorem {ι : Type*} [Fintype ι] [DecidableEq ι] (f : (ι → Bool) → Bool) : (boolDeg f : ℝ) ≤ (sens f : ℝ) ^ 2 := by let d := boolDeg f by_cases hd0 : d = 0 · dsimp only [d] at hd0; rw [hd0, Nat.cast_zero]; positivity have hd1 : 1 ≤ d := by omega -- Find a top-degree monomial `S : Finset ι` with `S.card = d` and `fourierCoeff (boolToReal ∘ f) S ≠ 0`! have hne_filt : (Finset.univ.filter fun S : Finset ι => fourierCoeff (fun x => boolToReal (f x)) S ≠ 0).Nonempty := by by_contra hemp; rw [Finset.not_nonempty_iff_eq_empty] at hemp have : d = 0 := by dsimp only [d]; unfold boolDeg realDeg; rw [hemp]; simp exact hd0 this obtain ⟨S, hS_mem, hS_card⟩ := Finset.exists_mem_eq_sup _ hne_filt Finset.card have hS_ne : fourierCoeff (fun x => boolToReal (f x)) S ≠ 0 := (Finset.mem_filter.mp hS_mem).2 have hSc : S.card = d := hS_card.symm -- Restrict `f` to `S` by averaging over the outside coordinates `ι \ S`: -- there exists an assignment `z₀ : ι → Bool` such that the restricted function on `S` -- has nonzero top Fourier coefficient! let combine : (S → Bool) → (ι → Bool) → (ι → Bool) := fun y z i => if h : i ∈ S then y ⟨i, h⟩ else z i have havg : ∃ z₀ : ι → Bool, ∑ y : S → Bool, boolToReal (f (combine y z₀)) * (∏ i : S, boolSign (y i)) ≠ 0 := by by_contra hall; push Not at hall apply hS_ne; unfold fourierCoeff suffices h0 : ∑ x : ι → Bool, boolToReal (f x) * walsh S x = 0 by rw [h0, zero_div] -- Average `hall z₀` over ALL `z₀ : ι → Bool`! have hsum_all : ∑ z₀ : ι → Bool, ∑ y : S → Bool, boolToReal (f (combine y z₀)) * (∏ i : S, boolSign (y i)) = 0 := Finset.sum_eq_zero fun z₀ _ => hall z₀ -- Count how many `(z₀, y)` produce each `x : ι → Bool`: EXACTLY `2^d` (arbitrary on `S`)! have hcount : ∑ z₀ : ι → Bool, ∑ y : S → Bool, boolToReal (f (combine y z₀)) * (∏ i : S, boolSign (y i)) = (2 : ℝ) ^ d * ∑ x : ι → Bool, boolToReal (f x) * walsh S x := by -- Map `(z₀, y) ↦ (combine y z₀, fun i : S => z₀ i.1)` — a BIJECTION! let e : ((ι → Bool) × (S → Bool)) ≃ ((ι → Bool) × (S → Bool)) := { toFun := fun p => (combine p.2 p.1, fun i => p.1 i.1) invFun := fun q => (combine q.2 q.1, fun i => q.1 i.1) left_inv := fun ⟨z, y⟩ => by ext i · dsimp only [combine]; by_cases h : i ∈ S <;> simp [h] · dsimp only [combine]; simp [i.2] right_inv := fun ⟨x, w⟩ => by ext i · dsimp only [combine]; by_cases h : i ∈ S <;> simp [h] · dsimp only [combine]; simp [i.2] } rw [← Fintype.sum_prod_type'] have hrew := Fintype.sum_equiv e (fun p : (ι → Bool) × (S → Bool) => boolToReal (f (combine p.2 p.1)) * (∏ i : S, boolSign (p.2 i))) (fun q : (ι → Bool) × (S → Bool) => boolToReal (f q.1) * walsh S q.1) (fun ⟨z, y⟩ => by dsimp only [e, Equiv.coe_fn_mk] congr 1; unfold walsh rw [← Finset.prod_coe_sort S] refine Finset.prod_congr rfl fun (i : S) _ => by simp [combine, i.2]) rw [hrew, Fintype.sum_prod_type, Finset.sum_comm] simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fun, Fintype.card_bool, Fintype.card_coe, hSc, nsmul_eq_mul, Nat.cast_pow, Nat.cast_ofNat] rw [hcount] at hsum_all exact (mul_eq_zero.mp hsum_all).resolve_left (by positivity) obtain ⟨z₀, hz₀⟩ := havg -- Relabel `S ≃ Fin d` to get `f' : (Fin d → Bool) → Bool`! let eS : Fin d ≃ S := (Fintype.equivFinOfCardEq (by rw [Fintype.card_coe, hSc])).symm let embed : (Fin d → Bool) → (ι → Bool) := fun x => combine (fun s => x (eS.symm s)) z₀ let f' : (Fin d → Bool) → Bool := fun x => f (embed x) have hf'_top : ∑ x : Fin d → Bool, boolToReal (f' x) * paritySign x ≠ 0 := by intro h0; apply hz₀ let eFun : (S → Bool) ≃ (Fin d → Bool) := Equiv.arrowCongr eS.symm (Equiv.refl Bool) have heq : ∑ y : S → Bool, boolToReal (f (combine y z₀)) * (∏ i : S, boolSign (y i)) = ∑ x : Fin d → Bool, boolToReal (f' x) * paritySign x := by refine Fintype.sum_equiv eFun _ _ fun y => ?_ have hemb : embed (eFun y) = combine y z₀ := by ext i; dsimp only [embed, combine, eFun]; by_cases h : i ∈ S <;> simp [h] have hpar : paritySign (eFun y) = ∏ i : S, boolSign (y i) := by unfold paritySign refine Fintype.prod_equiv eS _ _ fun j => by simp [eFun] dsimp only [f']; rw [hemb, hpar] rw [heq, h0] -- Define `g(x) = paritySign x * boolSign (f' x) ∈ {-1, 1}`! -- Notice `∑_x g(x) = ∑_x paritySign x * (1 - 2 * boolToReal (f' x)) = -2 * ∑_x boolToReal(f' x) * paritySign x ≠ 0`! let g : (Fin d → Bool) → ℝ := fun x => paritySign x * boolSign (f' x) have hsum_g_ne : ∑ x : Fin d → Bool, g x ≠ 0 := by have hpar0 : ∑ x : Fin d → Bool, paritySign x = 0 := by have h := sum_walsh (Finset.univ : Finset (Fin d)) have hne : (Finset.univ : Finset (Fin d)) ≠ ∅ := by intro hemp have := congrArg Finset.card hemp simp at this; omega rw [if_neg hne] at h; exact h have hrew : ∑ x : Fin d → Bool, g x = (∑ x : Fin d → Bool, paritySign x) - 2 * ∑ x : Fin d → Bool, boolToReal (f' x) * paritySign x := by rw [Finset.mul_sum, ← Finset.sum_sub_distrib] refine Finset.sum_congr rfl fun x _ => ?_ dsimp only [g] cases f' x · simp · simp; ring rw [hrew, hpar0, zero_sub, neg_ne_zero] exact mul_ne_zero two_ne_zero hf'_top -- Therefore either `U₊ = {x | g x = 1}` or `U₋ = {x | g x = -1}` has size `> 2^(d - 1)`! let Upos := Finset.univ.filter fun x : Fin d → Bool => g x = 1 let Uneg := Finset.univ.filter fun x : Fin d → Bool => g x = -1 have hg_pm : ∀ x : Fin d → Bool, g x = 1 ∨ g x = -1 := by intro x; dsimp only [g] have hp : paritySign x = 1 ∨ paritySign x = -1 := by have := paritySign_sq x; rcases sq_eq_one_iff.mp this with h | h <;> [left; right] <;> exact h rcases hp with h | h <;> cases hf : f' x <;> simp [h] have hU_sum : Upos.card + Uneg.card = 2 ^ d := by have hdisj : Disjoint Upos Uneg := Finset.disjoint_left.mpr fun x h1 h2 => by have e1 := (Finset.mem_filter.mp h1).2 have e2 := (Finset.mem_filter.mp h2).2 linarith have hunion : Upos ∪ Uneg = Finset.univ := by ext x simp only [Finset.mem_union, Finset.mem_univ, iff_true, Upos, Uneg, Finset.mem_filter, true_and] exact hg_pm x rw [← Finset.card_union_of_disjoint hdisj, hunion, Finset.card_univ, Fintype.card_fun, Fintype.card_bool, Fintype.card_fin] have hU_ne_eq : Upos.card ≠ Uneg.card := by intro heq; apply hsum_g_ne have h1 : ∀ x : Fin d → Bool, g x = (if x ∈ Upos then (1 : ℝ) else 0) - (if x ∈ Uneg then (1 : ℝ) else 0) := by intro x; rcases hg_pm x with h | h · simp [Upos, Uneg, h]; norm_num · simp [Upos, Uneg, h]; norm_num simp_rw [h1, Finset.sum_sub_distrib, ← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul, mul_one] have hf1 : Finset.univ.filter (fun x => x ∈ Upos) = Upos := by ext x; simp have hf2 : Finset.univ.filter (fun x => x ∈ Uneg) = Uneg := by ext x; simp rw [hf1, hf2, heq, sub_self] have hpow : 2 ^ d = 2 * 2 ^ (d - 1) := by rw [← pow_succ', Nat.sub_add_cancel hd1] have hbig : ∃ (sgn : ℝ), (sgn = 1 ∨ sgn = -1) ∧ 2 ^ (d - 1) < (Finset.univ.filter fun x : Fin d → Bool => g x = sgn).card := by by_cases hlt : 2 ^ (d - 1) < Upos.card · exact ⟨1, Or.inl rfl, hlt⟩ · exact ⟨-1, Or.inr rfl, by change 2 ^ (d - 1) < Uneg.card; omega⟩ obtain ⟨sgn, _, hbig_card⟩ := hbig obtain ⟨x, hxU, hdeg_x⟩ := huang_induced_subgraph_deg hd1 hbig_card -- Every neighbor `flipBlock x {j}` inside `U` is a sensitive coordinate of `f'` at `x`, -- hence `(eS j).1` is a sensitive coordinate of `f` at `embed x`! have hsens_le : (Finset.univ.filter fun j : Fin d => flipBlock x {j} ∈ Finset.univ.filter (fun y => g y = sgn)).card ≤ sensAt f (embed x) := by unfold sensAt let embI : Fin d ↪ ι := ⟨fun j => (eS j).1, fun j₁ j₂ h => eS.injective (Subtype.ext h)⟩ calc (Finset.univ.filter fun j : Fin d => flipBlock x {j} ∈ Finset.univ.filter (fun y => g y = sgn)).card = ((Finset.univ.filter fun j : Fin d => flipBlock x {j} ∈ Finset.univ.filter (fun y => g y = sgn)).map embI).card := (Finset.card_map _).symm _ ≤ (Finset.univ.filter fun i : ι => f (flipBlock (embed x) {i}) ≠ f (embed x)).card := by refine Finset.card_le_card fun i hi => ?_ rcases Finset.mem_map.mp hi with ⟨j, hj, rfl⟩ refine Finset.mem_filter.mpr ⟨Finset.mem_univ _, ?_⟩ have hj_g : g (flipBlock x {j}) = sgn := (Finset.mem_filter.mp (Finset.mem_filter.mp hj).2).2 have hx_g : g x = sgn := (Finset.mem_filter.mp hxU).2 have hpar_flip : paritySign (flipBlock x {j}) = -paritySign x := by unfold paritySign rw [← Finset.mul_prod_erase _ _ (Finset.mem_univ j), ← Finset.mul_prod_erase _ _ (Finset.mem_univ j), flipBlock_single, boolSign_not] have hrest : ∏ k ∈ Finset.univ.erase j, boolSign (flipBlock x {j} k) = ∏ k ∈ Finset.univ.erase j, boolSign (x k) := Finset.prod_congr rfl fun k hk => by rw [flipBlock_apply_notMem x (by simp [(Finset.mem_erase.mp hk).1])] rw [hrest]; ring have hf'_ne : f' (flipBlock x {j}) ≠ f' x := by intro heq have : g (flipBlock x {j}) = -g x := by dsimp only [g]; rw [hpar_flip, heq]; ring have hsgn0 : sgn = 0 := by linarith have hp := hg_pm x rcases hp with h | h <;> linarith have hemb_flip : flipBlock (embed x) {embI j} = embed (flipBlock x {j}) := by have hembI : embI j = (eS j).1 := rfl rw [hembI] ext k; dsimp only [embed, combine, flipBlock] by_cases hkS : k ∈ S · rw [dif_pos hkS, dif_pos hkS] by_cases hkj : k = (eS j).1 · simp [hkj] · have hsym : eS.symm ⟨k, hkS⟩ ≠ j := by intro h; apply hkj have := congrArg (fun s : S => s.1) (eS.apply_symm_apply ⟨k, hkS⟩) rw [h] at this; exact this.symm simp [hkj, hsym] · have hne : k ≠ (eS j).1 := fun h => hkS (h ▸ (eS j).2) simp [hkS, hne] rw [hemb_flip]; exact hf'_ne have hle_sens : Real.sqrt (d : ℝ) ≤ (sens f : ℝ) := by calc Real.sqrt (d : ℝ) ≤ ((Finset.univ.filter fun j : Fin d => flipBlock x {j} ∈ Finset.univ.filter (fun y => g y = sgn)).card : ℝ) := hdeg_x _ ≤ (sensAt f (embed x) : ℝ) := by exact_mod_cast hsens_le _ ≤ (sens f : ℝ) := by exact_mod_cast Finset.le_sup (f := fun z => sensAt f z) (Finset.mem_univ (embed x)) calc (d : ℝ) = Real.sqrt (d : ℝ) ^ 2 := (Real.sq_sqrt (Nat.cast_nonneg d)).symm _ ≤ (sens f : ℝ) ^ 2 := by nlinarith [Real.sqrt_nonneg (d : ℝ)] /-- **MAIN THEOREM 3A (New World Record for the Quantitative Sensitivity Conjecture)**: For EVERY nonconstant Boolean function `f` (`1 ≤ boolDeg f`): `bs(f) ≤ α_∞ * s(f)⁴ + 1 / 3` (where `α_∞ < 0.7221 < √(2/3) ≈ 0.8165`), strictly beating Huang (2019, `s(f)⁴`), Proskurin (2021, `0.86038 * s(f)⁴`), and Wellens (2022, `√(2/3) * s(f)⁴ + 1`)! -/ theorem sensitivity_conjecture_world_record {ι : Type*} [Fintype ι] [DecidableEq ι] (f : (ι → Bool) → Bool) (hd1 : 1 ≤ boolDeg f) : (blockSens f : ℝ) ≤ alphaInf * (sens f : ℝ) ^ 4 + 1 / 3 := by have h1 := blockSens_le_alpha_deg_sq f hd1 have h2 := huang_sensitivity_theorem f have hα_pos : 0 < alphaInf := by linarith [alphaInf_bounds.1] have hd_nn : (0 : ℝ) ≤ (boolDeg f : ℝ) := Nat.cast_nonneg _ have hsq : (boolDeg f : ℝ) ^ 2 ≤ ((sens f : ℝ) ^ 2) ^ 2 := by nlinarith have hpow4 : ((sens f : ℝ) ^ 2) ^ 2 = (sens f : ℝ) ^ 4 := by ring nlinarith /-- Helper: every Boolean function of degree `≤ 1` has `sens f ≤ 1`. -/ lemma sens_le_one_of_deg_le_one {ι : Type*} [Fintype ι] [DecidableEq ι] (f : (ι → Bool) → Bool) (hd : boolDeg f ≤ 1) : sens f ≤ 1 := by -- Every function of degree `≤ 1` is `c_∅ + ∑_i c_i boolSign (x i)` with values in `{0, 1}`. -- If `sensAt f x₀ ≥ 2`, two coordinates `i ≠ j` flip `f x₀`; then the 2×2 square -- `{x₀, x₀⊕i, x₀⊕j, x₀⊕{i,j}}` satisfies `f(x₀) + f(x₀⊕{i,j}) = f(x₀⊕i) + f(x₀⊕j)` (by linearity!), -- contradicting `f(x₀) ∈ {0, 1}` and `f(x₀⊕i) = f(x₀⊕j) = 1 - f(x₀)`! unfold sens refine Finset.sup_le fun x₀ _ => ?_ by_contra hgt; push Not at hgt obtain ⟨i, hi, j, hj, hij⟩ := Finset.one_lt_card.mp hgt have hfi : f (flipBlock x₀ {i}) ≠ f x₀ := (Finset.mem_filter.mp hi).2 have hfj : f (flipBlock x₀ {j}) ≠ f x₀ := (Finset.mem_filter.mp hj).2 let F : (ι → Bool) → ℝ := fun x => boolToReal (f x) have hlin : F x₀ + F (flipBlock x₀ {i, j}) = F (flipBlock x₀ {i}) + F (flipBlock x₀ {j}) := by rw [fourier_expansion F x₀, fourier_expansion F (flipBlock x₀ {i, j}), fourier_expansion F (flipBlock x₀ {i}), fourier_expansion F (flipBlock x₀ {j}), ← Finset.sum_add_distrib, ← Finset.sum_add_distrib] refine Finset.sum_congr rfl fun S _ => ?_ by_cases hgt1 : 1 < S.card · rw [fourierCoeff_eq_zero_of_gt_realDeg F (by exact lt_of_le_of_lt hd hgt1)]; ring · have hle1 : S.card ≤ 1 := by omega rcases Nat.le_one_iff_eq_zero_or_eq_one.mp hle1 with h0 | h1 · have hS0 := Finset.card_eq_zero.mp h0 subst hS0; simp · obtain ⟨k, rfl⟩ := Finset.card_eq_one.mp h1 have hw : ∀ z : ι → Bool, walsh ({k} : Finset ι) z = boolSign (z k) := fun z => by simp [walsh] simp_rw [hw] by_cases hki : k = i · subst hki; simp [flipBlock, hij, boolSign_not] · by_cases hkj : k = j · subst hkj; simp [flipBlock, hij.symm, boolSign_not] · simp [flipBlock, hki, hkj] dsimp only [F] at hlin cases hx : f x₀ <;> cases h1 : f (flipBlock x₀ {i}) <;> cases h2 : f (flipBlock x₀ {j}) <;> cases h12 : f (flipBlock x₀ {i, j}) <;> first | (simp_all; done) | (simp_all; norm_num at hlin) /-- **MAIN THEOREM 3B (Sharp Constant-Free Quantitative Sensitivity Conjecture Bound)**: For EVERY Boolean function `f` with `sens f ≥ 2`: `(4 / 3) * bs(f) ≤ s(f)⁴` (equivalently `bs(f) ≤ (3 / 4) * s(f)⁴`)! -/ theorem sensitivity_conjecture_sharp_rational {ι : Type*} [Fintype ι] [DecidableEq ι] (f : (ι → Bool) → Bool) (hs : 2 ≤ sens f) : (4 / 3 : ℝ) * (blockSens f : ℝ) ≤ (sens f : ℝ) ^ 4 := by have hd2 : 2 ≤ boolDeg f := by by_contra hlt; push Not at hlt have := sens_le_one_of_deg_le_one f (by omega) omega have h1 := blockSens_le_three_quarters_deg_sq f hd2 have h2 := huang_sensitivity_theorem f have hd_nn : (0 : ℝ) ≤ (boolDeg f : ℝ) := Nat.cast_nonneg _ have hsq : (boolDeg f : ℝ) ^ 2 ≤ ((sens f : ℝ) ^ 2) ^ 2 := by nlinarith have hpow4 : ((sens f : ℝ) ^ 2) ^ 2 = (sens f : ℝ) ^ 4 := by ring linarith end HuangSensitivity /-! ## Section 6: Exact Sharpness Witness (`NAE_3`) & Axiom Audit -/ section SharpnessAndAudit /-- The 3-variable Not-All-Equal function `NAE_3(x₀, x₁, x₂) = (x₀ ≠ x₁ ∨ x₀ ≠ x₂)`. -/ def nae3 (x : Fin 3 → Bool) : Bool := decide (x 0 ≠ x 1 ∨ x 0 ≠ x 2) /-- **Exact Sharpness of `(4 / 3) * bs(f) ≤ deg(f)²` at `deg = 2`**: `boolDeg nae3 = 2` and `blockSens nae3 = 3`, attaining `(4 / 3) * 3 = 4 = 2²` with exact equality! -/ theorem nae3_exact_sharpness : boolDeg nae3 = 2 ∧ blockSens nae3 = 3 ∧ (4 / 3 : ℝ) * (blockSens nae3 : ℝ) = (boolDeg nae3 : ℝ) ^ 2 := by -- Compute `fourierCoeff (boolToReal ∘ nae3) S` for all `S : Finset (Fin 3)` directly! -- Notice `boolToReal (nae3 x) = (3 - χ_{0,1}(x) - χ_{0,2}(x) - χ_{1,2}(x)) / 4`! have hrep : ∀ x : Fin 3 → Bool, boolToReal (nae3 x) = (3 / 4 : ℝ) * walsh (∅ : Finset (Fin 3)) x + (-(1 / 4 : ℝ)) * walsh ({0, 1} : Finset (Fin 3)) x + (-(1 / 4 : ℝ)) * walsh ({0, 2} : Finset (Fin 3)) x + (-(1 / 4 : ℝ)) * walsh ({1, 2} : Finset (Fin 3)) x := by intro x unfold nae3 walsh have h01 : ({0, 1} : Finset (Fin 3)) = insert 0 {1} := rfl have h02 : ({0, 2} : Finset (Fin 3)) = insert 0 {2} := rfl have h12 : ({1, 2} : Finset (Fin 3)) = insert 1 {2} := rfl rw [h01, h02, h12, Finset.prod_insert (by decide), Finset.prod_insert (by decide), Finset.prod_insert (by decide)] simp only [Finset.prod_empty, Finset.prod_singleton] cases hx0 : x 0 <;> cases hx1 : x 1 <;> cases hx2 : x 2 <;> simp [boolToReal, boolSign] <;> norm_num have hfc : ∀ S : Finset (Fin 3), fourierCoeff (fun x => boolToReal (nae3 x)) S = if S = ∅ then 3 / 4 else if S = {0, 1} ∨ S = {0, 2} ∨ S = {1, 2} then -(1 / 4 : ℝ) else 0 := by intro S unfold fourierCoeff simp_rw [hrep, add_mul, Finset.sum_add_distrib, mul_assoc, ← Finset.mul_sum, walsh_ortho] have h2 : (2 : ℝ) ^ Fintype.card (Fin 3) = 8 := by norm_num rw [h2] have hne_01 : (∅ : Finset (Fin 3)) ≠ {0, 1} := by decide have hne_02 : (∅ : Finset (Fin 3)) ≠ {0, 2} := by decide have hne_12 : (∅ : Finset (Fin 3)) ≠ {1, 2} := by decide have hne_a : ({0, 1} : Finset (Fin 3)) ≠ {0, 2} := by decide have hne_b : ({0, 1} : Finset (Fin 3)) ≠ {1, 2} := by decide have hne_c : ({0, 2} : Finset (Fin 3)) ≠ {1, 2} := by decide by_cases h0 : S = ∅ · subst h0; simp [hne_01.symm, hne_02.symm, hne_12.symm] · by_cases h1 : S = {0, 1} · subst h1; simp [hne_01, hne_a.symm, hne_b.symm]; norm_num · by_cases h2' : S = {0, 2} · subst h2'; simp [hne_02, hne_a, hne_c.symm]; norm_num · by_cases h3 : S = {1, 2} · subst h3; simp [hne_12, hne_b, hne_c]; norm_num · simp [Ne.symm h0, Ne.symm h1, Ne.symm h2', Ne.symm h3, h0, h1, h2', h3] have hdeg : boolDeg nae3 = 2 := by unfold boolDeg realDeg apply le_antisymm · refine Finset.sup_le fun S hS => ?_ have hne := (Finset.mem_filter.mp hS).2 rw [hfc S] at hne split_ifs at hne with h0 h2' · subst h0; simp · rcases h2' with rfl | rfl | rfl <;> decide · exact (hne rfl).elim · have hmem : ({0, 1} : Finset (Fin 3)) ∈ Finset.univ.filter (fun S : Finset (Fin 3) => fourierCoeff (fun x => boolToReal (nae3 x)) S ≠ 0) := by refine Finset.mem_filter.mpr ⟨Finset.mem_univ _, ?_⟩ rw [hfc {0, 1}]; norm_num have hle := Finset.le_sup (f := Finset.card) hmem have hc : ({0, 1} : Finset (Fin 3)).card = 2 := by decide omega have hbs_ge : 3 ≤ blockSens nae3 := by refine le_blockSens_of_hasSensitiveBlocks (x₀ := fun _ => false) ?_ refine ⟨fun m => {m}, fun m => Finset.singleton_nonempty m, fun m₁ m₂ hne => Finset.disjoint_singleton.mpr hne, fun m => ?_⟩ fin_cases m <;> decide have hbs_le : blockSens nae3 ≤ 3 := blockSens_deg_two_le_three nae3 hdeg have hbs : blockSens nae3 = 3 := le_antisymm hbs_le hbs_ge refine ⟨hdeg, hbs, ?_⟩ rw [hdeg, hbs]; norm_num #print axioms sum_lobattoWeight_cos_eq_zero #print axioms lobatto_quadrature #print axioms sum_lobatto_sq_cos #print axioms sum_lobatto_pow4_cos #print axioms trig_markov_second_deriv #print axioms trig_markov_combined_fourth_deriv #print axioms poly_cos_to_trig #print axioms bernstein_walsh_symmetrization #print axioms approxDeg_sq_ge_blockSens #print axioms approxDeg_one_third_beats_proskurin #print axioms exactDeg_master_quadratic #print axioms alphaInf_bounds #print axioms blockSens_le_alpha_deg_sq #print axioms blockSens_deg_two_le_three #print axioms blockSens_deg_three_le_six #print axioms blockSens_le_three_quarters_deg_sq #print axioms huang_induced_subgraph_deg #print axioms huang_sensitivity_theorem #print axioms sensitivity_conjecture_world_record #print axioms sensitivity_conjecture_sharp_rational #print axioms nae3_exact_sharpness end SharpnessAndAudit end BlockSensitivityDegree