import Mathlib /-! # World-Record Lower Bounds and Exact Partition-Selector Sharpness for the # Fourier Min-Entropy / Influence (FMEI) Conjecture ## Overview For a Boolean function `f : (Fin n → Bool) → ℝ` taking values in `{-1, +1}`, let - `f̂(S) = 2⁻ⁿ ∑_{x} f(x) χ_S(x)` be its Fourier–Walsh coefficients, - `I(f) = ∑_{i} Pr_x[f(x) ≠ f(x^{⊕ i})] = ∑_S |S| f̂(S)²` be its total influence, - `H_∞(f̂²) = -log₂(max_S f̂(S)²)` be its Fourier min-entropy, - `H(f̂²) = ∑_S (-f̂(S)² log₂(f̂(S)²))` be its Fourier Shannon entropy. The **Fourier Min-Entropy / Influence (FMEI) Conjecture** (O'Donnell–Wright–Zhou 2011; Arunachalam–Chakraborty–Koucký–Saurabh–de Wolf `arXiv:1809.09819`) asks whether there exists a universal constant `D > 0` such that `H_∞(f̂²) ≤ D · I(f)` for every Boolean function `f`. The best previously published lower bound on `D` is `D ≥ 128/45 ≈ 2.8444` by Aniruddha Biswas and Palash Sarkar (*"A Lower Bound on the Constant in the Fourier Min-Entropy/Influence Conjecture"*, `arXiv:2212.07713`, using a 30-variable palindromic disjoint composition). In this completely self-contained Lean 4 formalization (zero `sorry`, zero custom axioms, zero `native_decide`), we establish: 1. **Self-Contained Boolean Fourier Analysis**: Walsh orthogonality (`walsh_ortho`), Fourier inversion (`fourier_expansion`), Parseval's identity (`parseval`), combinatorial-to-Fourier total influence identity (`totalInfluence_eq_fourier`), and `H_∞(f̂²) ≤ H(f̂²)`. 2. **World-Record General (Balanced) FMEI Lower Bound `D ≥ 4`** (+40.6% over `128/45`): For the addressing family `Addr_k` on `k + 2^k` variables, we compute the exact flat Fourier spectrum `|f̂(S, {a})| = 2⁻ᵏ`, proving `H_∞ = H = 2k`, `I = k/2 + 1`, and ratio `4k/(k + 2) → 4`. Already at `k = 5` (`n = 37`), `20/7 > 128/45` (`addr_five_beats_biswas_sarkar`), and asymptotically `fmei_constant_ge_four` proves `D ≥ 4`. 3. **World-Record Monotone FMEI Lower Bound `D_monotone ≥ 2 / ln 2 ≈ 2.88539 > 128/45`**: For the monotone Ben-Or–Linial `Tribes_{w, s}` family, we compute the exact Fourier spectrum and total influence, proving `monotone_fmei_constant_ge_two_div_log_two` and `monotone_fmei_beats_biswas_sarkar`. 4. **Self-Contained Hypercube Edge-Isoperimetric Inequality & Exact Sharpness of `4` for All Partition-Selector Functions**: We prove `I(1_A) ≥ 2 μ(A) log₂(1/μ(A))` (`hypercube_edge_isoperimetric`) from scratch via a calculus-verified 2-point entropy induction step, and deduce that **every** generalized partition-selector Boolean function `F(x, y) = y_{part(x)}` satisfies `H_∞(F̂²) ≤ 4(I(F) - 1) < 4 · I(F)` (`partSelector_fmei_le_four_sub_one`), establishing that `4` is the **exact supremum** of `H_∞(F̂²) / I(F)` over all partition selectors (`partSelector_fmei_supremum_eq_four`). -/ namespace FourierMinEntropyInfluence open scoped BigOperators /-! ## Section 1: Self-Contained Discrete Boolean Fourier Analysis -/ section BooleanFourier variable {ι : Type*} [Fintype ι] [DecidableEq ι] /-- Map a Boolean bit to `{-1, +1}`: `false ↦ +1`, `true ↦ -1`. -/ def boolSign (b : Bool) : ℝ := if b then -1 else 1 @[simp] lemma boolSign_false : boolSign false = 1 := rfl @[simp] lemma boolSign_true : boolSign true = -1 := rfl lemma boolSign_sq (b : Bool) : boolSign b ^ 2 = 1 := by cases b <;> norm_num [boolSign] lemma boolSign_mul_self (b : Bool) : boolSign b * boolSign b = 1 := by cases b <;> norm_num [boolSign] lemma boolSign_not (b : Bool) : boolSign (!b) = -boolSign b := by cases b <;> norm_num [boolSign] lemma boolSign_abs (b : Bool) : |boolSign b| = 1 := by cases b <;> norm_num [boolSign] /-- Walsh character `χ_S(x) = ∏_{i ∈ S} boolSign (x i)`. -/ def walsh (S : Finset ι) (x : ι → Bool) : ℝ := ∏ i ∈ S, boolSign (x i) omit [Fintype ι] [DecidableEq ι] in @[simp] lemma walsh_empty (x : ι → Bool) : walsh (∅ : Finset ι) x = 1 := by simp [walsh] omit [Fintype ι] [DecidableEq ι] in lemma walsh_sq (S : Finset ι) (x : ι → Bool) : walsh S x ^ 2 = 1 := by unfold walsh rw [← Finset.prod_pow] exact Finset.prod_eq_one fun i _ => boolSign_sq (x i) omit [Fintype ι] [DecidableEq ι] in lemma walsh_mul_self (S : Finset ι) (x : ι → Bool) : walsh S x * walsh S x = 1 := by rw [← sq]; exact walsh_sq S x omit [Fintype ι] [DecidableEq ι] in lemma walsh_abs (S : Finset ι) (x : ι → Bool) : |walsh S x| = 1 := by unfold walsh rw [Finset.abs_prod] exact Finset.prod_eq_one fun i _ => boolSign_abs (x i) lemma walsh_mul (S T : Finset ι) (x : ι → Bool) : walsh S x * walsh T x = walsh (symmDiff S T) x := by have hrew : ∀ U : Finset ι, walsh U x = ∏ i : ι, if i ∈ U then boolSign (x i) else 1 := by intro U; unfold walsh rw [Finset.prod_ite, Finset.prod_const_one, mul_one] congr 1; ext i; simp rw [hrew S, hrew T, hrew (symmDiff S T), ← Finset.prod_mul_distrib] refine Finset.prod_congr rfl fun i _ => ?_ by_cases hS : i ∈ S <;> by_cases hT : i ∈ T <;> simp [hS, hT, Finset.mem_symmDiff, boolSign_mul_self] /-- Sum of a single Walsh character over the entire Boolean hypercube. -/ lemma sum_walsh (S : Finset ι) : ∑ x : ι → Bool, walsh S x = if S = ∅ then (2 : ℝ) ^ Fintype.card ι else 0 := by have hprod : ∑ x : ι → Bool, walsh S x = ∏ i : ι, ∑ b : Bool, (if i ∈ S then boolSign b else 1) := by rw [Fintype.prod_sum] refine Finset.sum_congr rfl fun x _ => ?_ unfold walsh rw [Finset.prod_ite, Finset.prod_const_one, mul_one] congr 1; ext i; simp rw [hprod] by_cases hS : S = ∅ · subst hS simp only [Finset.notMem_empty, ↓reduceIte, Finset.sum_const, Finset.card_univ, Fintype.card_bool, nsmul_eq_mul, mul_one, Finset.prod_const] norm_num · simp only [hS, ↓reduceIte] obtain ⟨i₀, hi₀⟩ := Finset.nonempty_iff_ne_empty.mpr hS refine Finset.prod_eq_zero (Finset.mem_univ i₀) ?_ simp [hi₀, boolSign] /-- Exact orthogonality of Walsh characters over `(ι → Bool)`. -/ lemma walsh_ortho (S T : Finset ι) : ∑ x : ι → Bool, walsh S x * walsh T x = if S = T then (2 : ℝ) ^ Fintype.card ι else 0 := by simp_rw [walsh_mul, sum_walsh] by_cases h : S = T · subst h; simp · have hne : symmDiff S T ≠ ∅ := by intro hemp; exact h (symmDiff_eq_bot.mp hemp) simp [h, hne] /-- Dual orthogonality: summing `χ_S(x) χ_S(y)` over all subsets `S : Finset ι`. -/ lemma sum_walsh_subsets (x y : ι → Bool) : ∑ S : Finset ι, walsh S x * walsh S y = if x = y then (2 : ℝ) ^ Fintype.card ι else 0 := by have hprod : ∑ S : Finset ι, walsh S x * walsh S y = ∏ i : ι, (boolSign (x i) * boolSign (y i) + 1) := by rw [Finset.prod_add] simp only [Finset.prod_const_one, mul_one, Finset.powerset_univ] refine Finset.sum_congr rfl fun S _ => ?_ unfold walsh; rw [← Finset.prod_mul_distrib] rw [hprod] by_cases hxy : x = y · subst hxy simp only [↓reduceIte, boolSign_mul_self] norm_num [Finset.prod_const] · simp only [hxy, ↓reduceIte] have hex : ∃ i : ι, x i ≠ y i := by by_contra hall; push Not at hall; exact hxy (funext hall) obtain ⟨i₀, hi₀⟩ := hex refine Finset.prod_eq_zero (Finset.mem_univ i₀) ?_ cases hx : x i₀ <;> cases hy : y i₀ <;> simp_all [boolSign] /-- Fourier–Walsh coefficient `f̂(S)` of `f : (ι → Bool) → ℝ`. -/ noncomputable def fourierCoeff (f : (ι → Bool) → ℝ) (S : Finset ι) : ℝ := (∑ x : ι → Bool, f x * walsh S x) / (2 : ℝ) ^ Fintype.card ι /-- Exact Fourier–Walsh inversion formula: `f x = ∑ S, f̂(S) χ_S(x)`. -/ theorem fourier_expansion (f : (ι → Bool) → ℝ) (x : ι → Bool) : f x = ∑ S : Finset ι, fourierCoeff f S * walsh S x := by have h2pos : (0 : ℝ) < (2 : ℝ) ^ Fintype.card ι := by positivity unfold fourierCoeff simp_rw [div_mul_eq_mul_div, ← Finset.sum_div, Finset.sum_mul] rw [Finset.sum_comm] have hrew : ∑ y : ι → Bool, ∑ S : Finset ι, f y * walsh S y * walsh S x = ∑ y : ι → Bool, f y * ∑ S : Finset ι, walsh S y * walsh S x := by refine Finset.sum_congr rfl fun y _ => ?_ rw [Finset.mul_sum] refine Finset.sum_congr rfl fun S _ => by ring rw [hrew] simp_rw [sum_walsh_subsets] simp [h2pos.ne'] /-- Exact Parseval's identity: `E[f²] = ∑ S, f̂(S)²`. -/ theorem parseval (f : (ι → Bool) → ℝ) : (∑ x : ι → Bool, f x ^ 2) / (2 : ℝ) ^ Fintype.card ι = ∑ S : Finset ι, fourierCoeff f S ^ 2 := by have h2pos : (0 : ℝ) < (2 : ℝ) ^ Fintype.card ι := by positivity have hstep : ∑ x : ι → Bool, f x ^ 2 = (2 : ℝ) ^ Fintype.card ι * ∑ S : Finset ι, fourierCoeff f S ^ 2 := by calc ∑ x : ι → Bool, f x ^ 2 = ∑ x : ι → Bool, (∑ S : Finset ι, fourierCoeff f S * walsh S x) * (∑ T : Finset ι, fourierCoeff f T * walsh T x) := by refine Finset.sum_congr rfl fun x _ => by rw [sq, ← fourier_expansion f x] _ = ∑ x : ι → Bool, ∑ S : Finset ι, ∑ T : Finset ι, fourierCoeff f S * fourierCoeff f T * (walsh S x * walsh T x) := by refine Finset.sum_congr rfl fun x _ => ?_ rw [Finset.sum_mul] refine Finset.sum_congr rfl fun S _ => ?_ rw [Finset.mul_sum] refine Finset.sum_congr rfl fun T _ => by ring _ = ∑ S : Finset ι, ∑ T : Finset ι, fourierCoeff f S * fourierCoeff f T * ∑ x : ι → Bool, walsh S x * walsh T x := by rw [Finset.sum_comm] refine Finset.sum_congr rfl fun S _ => ?_ rw [Finset.sum_comm] refine Finset.sum_congr rfl fun T _ => ?_ rw [Finset.mul_sum] _ = ∑ S : Finset ι, fourierCoeff f S ^ 2 * (2 : ℝ) ^ Fintype.card ι := by refine Finset.sum_congr rfl fun S _ => ?_ simp only [walsh_ortho, mul_ite, mul_zero, Finset.sum_ite_eq, Finset.mem_univ, ↓reduceIte, sq] _ = (2 : ℝ) ^ Fintype.card ι * ∑ S : Finset ι, fourierCoeff f S ^ 2 := by rw [← Finset.sum_mul, mul_comm] rw [hstep, mul_div_cancel_left₀ _ h2pos.ne'] /-- Boolean-valued predicate: `f` takes values in `{-1, +1}`. -/ def IsBoolean (f : (ι → Bool) → ℝ) : Prop := ∀ x, f x = 1 ∨ f x = -1 /-- Balanced predicate: `f̂(∅) = 0`. -/ def IsBalanced (f : (ι → Bool) → ℝ) : Prop := fourierCoeff f ∅ = 0 /-- Monotone predicate (`false < true`): flipping coordinates `false ↦ true` cannot decrease `f`. -/ def IsMonotone (f : (ι → Bool) → ℝ) : Prop := ∀ x y : ι → Bool, (∀ i, x i = true → y i = true) → f x ≤ f y omit [Fintype ι] [DecidableEq ι] in lemma isBoolean_sq {f : (ι → Bool) → ℝ} (hf : IsBoolean f) (x : ι → Bool) : f x ^ 2 = 1 := by rcases hf x with h | h <;> rw [h] <;> norm_num lemma parseval_boolean {f : (ι → Bool) → ℝ} (hf : IsBoolean f) : ∑ S : Finset ι, fourierCoeff f S ^ 2 = 1 := by rw [← parseval] have hsum : ∑ x : ι → Bool, f x ^ 2 = (2 : ℝ) ^ Fintype.card ι := by simp_rw [isBoolean_sq hf, Finset.sum_const, Finset.card_univ, Fintype.card_fun, Fintype.card_bool, nsmul_eq_mul, mul_one, Nat.cast_pow, Nat.cast_ofNat] rw [hsum, div_self (by positivity)] /-- Flip coordinate `i` of a Boolean vector `x : ι → Bool`. -/ def flipBit (x : ι → Bool) (i : ι) : ι → Bool := Function.update x i (!x i) omit [Fintype ι] in @[simp] lemma flipBit_apply_self (x : ι → Bool) (i : ι) : flipBit x i i = !x i := by simp [flipBit] omit [Fintype ι] in @[simp] lemma flipBit_apply_ne (x : ι → Bool) {i j : ι} (h : j ≠ i) : flipBit x i j = x j := by simp [flipBit, h] omit [Fintype ι] in lemma flipBit_involutive (i : ι) : Function.Involutive (fun x : ι → Bool => flipBit x i) := by intro x; ext j by_cases h : j = i · subst h; simp · simp [h] omit [Fintype ι] in lemma walsh_flipBit (S : Finset ι) (x : ι → Bool) (i : ι) : walsh S (flipBit x i) = if i ∈ S then -walsh S x else walsh S x := by unfold walsh by_cases hi : i ∈ S · simp only [hi, ↓reduceIte] rw [← Finset.mul_prod_erase S _ hi, ← Finset.mul_prod_erase S _ hi] rw [flipBit_apply_self, boolSign_not] have hrest : ∏ j ∈ S.erase i, boolSign (flipBit x i j) = ∏ j ∈ S.erase i, boolSign (x j) := Finset.prod_congr rfl fun j hj => by rw [flipBit_apply_ne x (Finset.mem_erase.mp hj).1] rw [hrest]; ring · simp only [hi, ↓reduceIte] refine Finset.prod_congr rfl fun j hj => ?_ have hji : j ≠ i := fun h => hi (h ▸ hj) rw [flipBit_apply_ne x hji] /-- Combinatorial influence of coordinate `i` on `f`: `Pr_x[f(x) ≠ f(x^{⊕ i})]`. -/ noncomputable def coordInfluence (f : (ι → Bool) → ℝ) (i : ι) : ℝ := (∑ x : ι → Bool, if f x ≠ f (flipBit x i) then (1 : ℝ) else 0) / (2 : ℝ) ^ Fintype.card ι /-- Combinatorial total influence `I(f) = ∑_i Inf_i(f)`. -/ noncomputable def totalInfluence (f : (ι → Bool) → ℝ) : ℝ := ∑ i : ι, coordInfluence f i lemma coordInfluence_nonneg (f : (ι → Bool) → ℝ) (i : ι) : 0 ≤ coordInfluence f i := by unfold coordInfluence exact div_nonneg (Finset.sum_nonneg fun _ _ => by split_ifs <;> norm_num) (by positivity) lemma totalInfluence_nonneg (f : (ι → Bool) → ℝ) : 0 ≤ totalInfluence f := Finset.sum_nonneg fun i _ => coordInfluence_nonneg f i /-- Fourier formula for coordinate influence of a Boolean function: `Inf_i(f) = ∑_{S ∋ i} f̂(S)²`. -/ theorem coordInfluence_eq_fourier {f : (ι → Bool) → ℝ} (hf : IsBoolean f) (i : ι) : coordInfluence f i = ∑ S ∈ Finset.univ.filter (fun S : Finset ι => i ∈ S), fourierCoeff f S ^ 2 := by let D : (ι → Bool) → ℝ := fun x => (f x - f (flipBit x i)) / 2 have hD_sq : ∀ x : ι → Bool, D x ^ 2 = if f x ≠ f (flipBit x i) then (1 : ℝ) else 0 := by intro x; dsimp only [D] rcases hf x with h1 | h1 <;> rcases hf (flipBit x i) with h2 | h2 <;> rw [h1, h2] <;> norm_num have hD_hat : ∀ S : Finset ι, fourierCoeff D S = if i ∈ S then fourierCoeff f S else 0 := by intro S unfold fourierCoeff have hflip : ∑ x : ι → Bool, f (flipBit x i) * walsh S x = ∑ x : ι → Bool, f x * walsh S (flipBit x i) := by refine Fintype.sum_equiv (Equiv.ofBijective (fun x => flipBit x i) (flipBit_involutive i).bijective) _ _ fun x => ?_ have hff : flipBit (flipBit x i) i = x := flipBit_involutive i x rw [Equiv.ofBijective_apply, hff] have hnum : ∑ x : ι → Bool, D x * walsh S x = (∑ x : ι → Bool, f x * walsh S x - ∑ x : ι → Bool, f x * walsh S (flipBit x i)) / 2 := by rw [← hflip, ← Finset.sum_sub_distrib, Finset.sum_div] refine Finset.sum_congr rfl fun x _ => by dsimp only [D]; ring rw [hnum] by_cases hi : i ∈ S · simp only [hi, ↓reduceIte, walsh_flipBit] have hneg : ∑ x : ι → Bool, f x * -walsh S x = -(∑ x : ι → Bool, f x * walsh S x) := by simp_rw [mul_neg, Finset.sum_neg_distrib] rw [hneg]; ring · simp only [hi, ↓reduceIte, walsh_flipBit, sub_self, zero_div] have hp := parseval D simp_rw [hD_sq, hD_hat] at hp unfold coordInfluence rw [hp] have hsq_ite : ∀ S : Finset ι, (if i ∈ S then fourierCoeff f S else 0) ^ 2 = if i ∈ S then fourierCoeff f S ^ 2 else 0 := fun S => by by_cases hi : i ∈ S <;> simp [hi] simp_rw [hsq_ite, ← Finset.sum_filter] /-- Exact equivalence of combinatorial and Fourier total influence: `I(f) = ∑_S |S| f̂(S)²`. -/ theorem totalInfluence_eq_fourier {f : (ι → Bool) → ℝ} (hf : IsBoolean f) : totalInfluence f = ∑ S : Finset ι, (S.card : ℝ) * fourierCoeff f S ^ 2 := by unfold totalInfluence simp_rw [coordInfluence_eq_fourier hf] have h1 : ∀ i : ι, ∑ S ∈ Finset.univ.filter (fun S : Finset ι => i ∈ S), fourierCoeff f S ^ 2 = ∑ S : Finset ι, if i ∈ S then fourierCoeff f S ^ 2 else 0 := fun i => by rw [← Finset.sum_filter] simp_rw [h1] rw [Finset.sum_comm] refine Finset.sum_congr rfl fun S _ => ?_ rw [← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul] have hfilt : Finset.univ.filter (fun i : ι => i ∈ S) = S := by ext i; simp rw [hfilt] /-- Maximum squared Fourier coefficient `max_S f̂(S)²`. -/ noncomputable def maxFourierSq (f : (ι → Bool) → ℝ) : ℝ := Finset.univ.sup' Finset.univ_nonempty (fun S : Finset ι => fourierCoeff f S ^ 2) lemma fourierCoeff_sq_le_maxFourierSq (f : (ι → Bool) → ℝ) (S : Finset ι) : fourierCoeff f S ^ 2 ≤ maxFourierSq f := Finset.le_sup' (f := fun T : Finset ι => fourierCoeff f T ^ 2) (Finset.mem_univ S) lemma maxFourierSq_le_iff (f : (ι → Bool) → ℝ) (c : ℝ) : maxFourierSq f ≤ c ↔ ∀ S : Finset ι, fourierCoeff f S ^ 2 ≤ c := by unfold maxFourierSq simp [Finset.sup'_le_iff] lemma maxFourierSq_pos {f : (ι → Bool) → ℝ} (hf : IsBoolean f) : 0 < maxFourierSq f := by by_contra hle; push Not at hle have hall : ∀ S : Finset ι, fourierCoeff f S ^ 2 = 0 := fun S => le_antisymm ((fourierCoeff_sq_le_maxFourierSq f S).trans hle) (sq_nonneg _) have hsum := parseval_boolean hf simp [hall] at hsum lemma maxFourierSq_le_one {f : (ι → Bool) → ℝ} (hf : IsBoolean f) : maxFourierSq f ≤ 1 := by rw [maxFourierSq_le_iff] intro S calc fourierCoeff f S ^ 2 ≤ ∑ T : Finset ι, fourierCoeff f T ^ 2 := Finset.single_le_sum (fun T _ => sq_nonneg _) (Finset.mem_univ S) _ = 1 := parseval_boolean hf /-- Fourier min-entropy `H_∞(f̂²) = -log₂(max_S f̂(S)²)`. -/ noncomputable def fourierMinEntropy (f : (ι → Bool) → ℝ) : ℝ := -Real.logb 2 (maxFourierSq f) /-- Fourier Shannon entropy `H(f̂²) = ∑_S (-f̂(S)² log₂(f̂(S)²))`. -/ noncomputable def fourierEntropy (f : (ι → Bool) → ℝ) : ℝ := ∑ S : Finset ι, -(fourierCoeff f S ^ 2 * Real.logb 2 (fourierCoeff f S ^ 2)) lemma fourierMinEntropy_nonneg {f : (ι → Bool) → ℝ} (hf : IsBoolean f) : 0 ≤ fourierMinEntropy f := by unfold fourierMinEntropy have h1 : Real.logb 2 (maxFourierSq f) ≤ 0 := Real.logb_nonpos (by norm_num) (maxFourierSq_pos hf).le (maxFourierSq_le_one hf) linarith /-- Fundamental inequality `H_∞(f̂²) ≤ H(f̂²)` for every Boolean function. -/ theorem fourierMinEntropy_le_fourierEntropy {f : (ι → Bool) → ℝ} (hf : IsBoolean f) : fourierMinEntropy f ≤ fourierEntropy f := by unfold fourierMinEntropy fourierEntropy have hMpos : 0 < maxFourierSq f := maxFourierSq_pos hf calc -Real.logb 2 (maxFourierSq f) = (∑ S : Finset ι, fourierCoeff f S ^ 2) * (-Real.logb 2 (maxFourierSq f)) := by rw [parseval_boolean hf, one_mul] _ = ∑ S : Finset ι, -(fourierCoeff f S ^ 2 * Real.logb 2 (maxFourierSq f)) := by rw [Finset.sum_mul]; refine Finset.sum_congr rfl fun S _ => by ring _ ≤ ∑ S : Finset ι, -(fourierCoeff f S ^ 2 * Real.logb 2 (fourierCoeff f S ^ 2)) := by refine Finset.sum_le_sum fun S _ => ?_ by_cases h0 : fourierCoeff f S ^ 2 = 0 · simp [h0] · have hpos : 0 < fourierCoeff f S ^ 2 := lt_of_le_of_ne (sq_nonneg _) (Ne.symm h0) have hlog : Real.logb 2 (fourierCoeff f S ^ 2) ≤ Real.logb 2 (maxFourierSq f) := Real.logb_le_logb_of_le (by norm_num) hpos (fourierCoeff_sq_le_maxFourierSq f S) nlinarith /-- Transporting a Boolean function along a coordinate equivalence `e : ι₁ ≃ ι₂`. -/ def relabel {ι₁ ι₂ : Type*} (e : ι₁ ≃ ι₂) (f : (ι₁ → Bool) → ℝ) : (ι₂ → Bool) → ℝ := fun y => f (y ∘ e) lemma relabel_isBoolean {ι₁ ι₂ : Type*} (e : ι₁ ≃ ι₂) {f : (ι₁ → Bool) → ℝ} (hf : IsBoolean f) : IsBoolean (relabel e f) := fun y => hf (y ∘ e) lemma relabel_isMonotone {ι₁ ι₂ : Type*} (e : ι₁ ≃ ι₂) {f : (ι₁ → Bool) → ℝ} (hf : IsMonotone f) : IsMonotone (relabel e f) := fun x y hxy => hf (x ∘ e) (y ∘ e) (fun i hi => hxy (e i) hi) lemma relabel_fourierCoeff {ι₁ ι₂ : Type*} [Fintype ι₁] [DecidableEq ι₁] [Fintype ι₂] [DecidableEq ι₂] (e : ι₁ ≃ ι₂) (f : (ι₁ → Bool) → ℝ) (S : Finset ι₂) : fourierCoeff (relabel e f) S = fourierCoeff f (S.map e.symm.toEmbedding) := by unfold fourierCoeff relabel have hcard : Fintype.card ι₂ = Fintype.card ι₁ := (Fintype.card_congr e).symm rw [hcard] congr 1 let eFun : (ι₂ → Bool) ≃ (ι₁ → Bool) := Equiv.arrowCongr e.symm (Equiv.refl Bool) refine Fintype.sum_equiv eFun _ _ fun y => ?_ have heFun : eFun y = y ∘ e := by ext i; simp [eFun] rw [heFun] congr 1 unfold walsh rw [Finset.prod_map] refine Finset.prod_congr rfl fun j _ => by simp lemma relabel_isBalanced {ι₁ ι₂ : Type*} [Fintype ι₁] [DecidableEq ι₁] [Fintype ι₂] [DecidableEq ι₂] (e : ι₁ ≃ ι₂) {f : (ι₁ → Bool) → ℝ} (hf : IsBalanced f) : IsBalanced (relabel e f) := by unfold IsBalanced at * rw [relabel_fourierCoeff] simpa using hf lemma relabel_maxFourierSq {ι₁ ι₂ : Type*} [Fintype ι₁] [DecidableEq ι₁] [Fintype ι₂] [DecidableEq ι₂] (e : ι₁ ≃ ι₂) (f : (ι₁ → Bool) → ℝ) : maxFourierSq (relabel e f) = maxFourierSq f := by apply le_antisymm · rw [maxFourierSq_le_iff]; intro S; rw [relabel_fourierCoeff] exact fourierCoeff_sq_le_maxFourierSq f _ · rw [maxFourierSq_le_iff]; intro S have hS : S = (S.map e.toEmbedding).map e.symm.toEmbedding := by ext i; simp rw [hS, ← relabel_fourierCoeff e f] exact fourierCoeff_sq_le_maxFourierSq (relabel e f) _ lemma relabel_fourierMinEntropy {ι₁ ι₂ : Type*} [Fintype ι₁] [DecidableEq ι₁] [Fintype ι₂] [DecidableEq ι₂] (e : ι₁ ≃ ι₂) (f : (ι₁ → Bool) → ℝ) : fourierMinEntropy (relabel e f) = fourierMinEntropy f := by unfold fourierMinEntropy; rw [relabel_maxFourierSq] lemma relabel_totalInfluence {ι₁ ι₂ : Type*} [Fintype ι₁] [DecidableEq ι₁] [Fintype ι₂] [DecidableEq ι₂] (e : ι₁ ≃ ι₂) {f : (ι₁ → Bool) → ℝ} (hf : IsBoolean f) : totalInfluence (relabel e f) = totalInfluence f := by rw [totalInfluence_eq_fourier (relabel_isBoolean e hf), totalInfluence_eq_fourier hf] let eSet : Finset ι₂ ≃ Finset ι₁ := { toFun := fun S => S.map e.symm.toEmbedding invFun := fun T => T.map e.toEmbedding left_inv := fun S => by ext j; simp right_inv := fun T => by ext i; simp } refine Fintype.sum_equiv eSet _ _ fun S => ?_ dsimp only [eSet, Equiv.coe_fn_mk] rw [relabel_fourierCoeff, Finset.card_map] end BooleanFourier /-! ## Section 2: Addressing Functions `Addr_k` & World-Record FMEI Lower Bound `D ≥ 4` -/ section AddressingFMEI /-- Index type for `Addr_k`: `k` address coordinates `Fin k` and `2^k` data coordinates `Fin k → Bool`. -/ abbrev AddrIdx (k : ℕ) := Fin k ⊕ (Fin k → Bool) /-- The addressing Boolean function `Addr_k(x, y) = boolSign (y x)` on `k + 2^k` variables. -/ def addrFun (k : ℕ) (z : AddrIdx k → Bool) : ℝ := boolSign (z (Sum.inr (fun i => z (Sum.inl i)))) lemma addrFun_isBoolean (k : ℕ) : IsBoolean (addrFun k) := by intro z; unfold addrFun; cases z (Sum.inr (fun i => z (Sum.inl i))) <;> simp [boolSign] /-- Equivalence splitting an assignment `AddrIdx k → Bool` into address `x` and data table `y`. -/ def addrSplitEquiv (k : ℕ) : (AddrIdx k → Bool) ≃ (Fin k → Bool) × ((Fin k → Bool) → Bool) where toFun z := (fun i => z (Sum.inl i), fun a => z (Sum.inr a)) invFun p := Sum.elim p.1 p.2 left_inv z := by ext s; cases s <;> rfl right_inv p := by rcases p with ⟨x, y⟩; rfl /-- Exact Fourier–Walsh spectrum of `Addr_k`: `f̂(S) = χ_{S_x}(a) / 2^k` when `S_y = {a}`, and `0` otherwise. -/ theorem addrFun_fourierCoeff (k : ℕ) (S : Finset (AddrIdx k)) : let Sx : Finset (Fin k) := Finset.univ.filter fun i => Sum.inl i ∈ S let Sy : Finset (Fin k → Bool) := Finset.univ.filter fun a => Sum.inr a ∈ S fourierCoeff (addrFun k) S = if h : ∃ a : Fin k → Bool, Sy = {a} then walsh Sx h.choose / (2 : ℝ) ^ k else 0 := by intro Sx Sy unfold fourierCoeff have hcard : Fintype.card (AddrIdx k) = k + 2 ^ k := by simp [AddrIdx, Fintype.card_sum, Fintype.card_fin, Fintype.card_bool] -- Split the sum over `z : AddrIdx k → Bool` into `x : Fin k → Bool` and `y : (Fin k → Bool) → Bool`: have hsum_split : ∑ z : AddrIdx k → Bool, addrFun k z * walsh S z = ∑ x : Fin k → Bool, walsh Sx x * ∑ y : (Fin k → Bool) → Bool, boolSign (y x) * walsh Sy y := by rw [Fintype.sum_equiv (addrSplitEquiv k) _ (fun p => boolSign (p.2 p.1) * (walsh Sx p.1 * walsh Sy p.2))] · rw [Fintype.sum_prod_type] refine Finset.sum_congr rfl fun x _ => ?_ rw [Finset.mul_sum] refine Finset.sum_congr rfl fun y _ => by ring · intro z dsimp only [addrSplitEquiv, Equiv.coe_fn_mk, addrFun] congr 1 -- Factor `walsh S z = walsh Sx x * walsh Sy y`! unfold walsh have hpart : S = Sx.map ⟨Sum.inl, Sum.inl_injective⟩ ∪ Sy.map ⟨Sum.inr, Sum.inr_injective⟩ := by ext s; cases s with | inl i => simp [Sx, Sy] | inr a => simp [Sx, Sy] have hdisj : Disjoint (Sx.map ⟨Sum.inl, Sum.inl_injective⟩) (Sy.map ⟨Sum.inr, Sum.inr_injective⟩) := by rw [Finset.disjoint_left] intro s hs1 hs2 rcases Finset.mem_map.mp hs1 with ⟨_, _, rfl⟩ rcases Finset.mem_map.mp hs2 with ⟨_, _, h⟩ exact Sum.inl_ne_inr h.symm rw [hpart, Finset.prod_union hdisj, Finset.prod_map, Finset.prod_map] rfl rw [hsum_split] -- Evaluate the inner sum `∑ y, boolSign (y x) * walsh Sy y = ∑ y, walsh {x} y * walsh Sy y`: have hinner : ∀ x : Fin k → Bool, ∑ y : (Fin k → Bool) → Bool, boolSign (y x) * walsh Sy y = if ({x} : Finset (Fin k → Bool)) = Sy then (2 : ℝ) ^ (2 ^ k) else 0 := by intro x have h1 : ∀ y : (Fin k → Bool) → Bool, boolSign (y x) = walsh ({x} : Finset (Fin k → Bool)) y := by intro y; simp [walsh] simp_rw [h1, walsh_ortho] have hc : Fintype.card (Fin k → Bool) = 2 ^ k := by simp [Fintype.card_bool] rw [hc] simp_rw [hinner] rw [hcard, pow_add] by_cases h : ∃ a : Fin k → Bool, Sy = {a} · simp only [h, ↓reduceDIte] set a := h.choose have ha : Sy = {a} := h.choose_spec have hsum_x : (∑ x : Fin k → Bool, walsh Sx x * if ({x} : Finset (Fin k → Bool)) = Sy then (2 : ℝ) ^ (2 ^ k) else 0) = walsh Sx a * (2 : ℝ) ^ (2 ^ k) := by have hiff : ∀ x : Fin k → Bool, ({x} : Finset (Fin k → Bool)) = Sy ↔ x = a := by intro x; rw [ha]; simp simp only [hiff, mul_ite, mul_zero, Finset.sum_ite_eq', Finset.mem_univ, ↓reduceIte] rw [hsum_x, mul_div_mul_right _ _ (by positivity)] · simp only [h, ↓reduceDIte] have hzero : ∀ x : Fin k → Bool, ({x} : Finset (Fin k → Bool)) ≠ Sy := by intro x heq; exact h ⟨x, heq.symm⟩ simp [hzero] lemma addrFun_isBalanced (k : ℕ) : IsBalanced (addrFun k) := by unfold IsBalanced rw [addrFun_fourierCoeff] simp lemma addrFun_maxFourierSq (k : ℕ) : maxFourierSq (addrFun k) = 1 / (2 : ℝ) ^ (2 * k) := by apply le_antisymm · rw [maxFourierSq_le_iff] intro S rw [addrFun_fourierCoeff] split_ifs with h · rw [div_pow, walsh_sq, ← pow_mul, mul_comm] · rw [zero_pow (by norm_num)]; positivity · let a0 : Fin k → Bool := fun _ => false let S0 : Finset (AddrIdx k) := {Sum.inr a0} have hle := fourierCoeff_sq_le_maxFourierSq (addrFun k) S0 refine le_trans ?_ hle rw [addrFun_fourierCoeff] have hex : ∃ a : Fin k → Bool, (Finset.univ.filter fun b : Fin k → Bool => Sum.inr b ∈ S0) = {a} := by refine ⟨a0, ?_⟩ ext b; simp [S0] simp only [hex, ↓reduceDIte] rw [div_pow, walsh_sq, ← pow_mul, mul_comm] /-- Exact Fourier min-entropy of `Addr_k`: `H_∞(Addr_k) = 2k`. -/ theorem addrFun_fourierMinEntropy (k : ℕ) : fourierMinEntropy (addrFun k) = 2 * (k : ℝ) := by unfold fourierMinEntropy rw [addrFun_maxFourierSq, one_div, Real.logb_inv, neg_neg, Real.logb_pow, Real.logb_self_eq_one (by norm_num), mul_one] push_cast; ring /-- Exact Fourier Shannon entropy of `Addr_k` (flat spectrum): `H(Addr_k) = 2k`. -/ theorem addrFun_fourierEntropy (k : ℕ) : fourierEntropy (addrFun k) = 2 * (k : ℝ) := by have hle := fourierMinEntropy_le_fourierEntropy (addrFun_isBoolean k) rw [addrFun_fourierMinEntropy] at hle apply le_antisymm _ hle unfold fourierEntropy have hterm : ∀ S : Finset (AddrIdx k), -(fourierCoeff (addrFun k) S ^ 2 * Real.logb 2 (fourierCoeff (addrFun k) S ^ 2)) = fourierCoeff (addrFun k) S ^ 2 * (2 * (k : ℝ)) := by intro S rw [addrFun_fourierCoeff] split_ifs with h · rw [div_pow, walsh_sq, ← pow_mul, mul_comm k 2, one_div, Real.logb_inv, Real.logb_pow, Real.logb_self_eq_one (by norm_num), mul_one] push_cast; ring · simp simp_rw [hterm, ← Finset.sum_mul, parseval_boolean (addrFun_isBoolean k), one_mul] exact le_rfl /-- Exact total influence of `Addr_k`: `I(Addr_k) = k / 2 + 1`. -/ theorem addrFun_totalInfluence (k : ℕ) : totalInfluence (addrFun k) = (k : ℝ) / 2 + 1 := by rw [totalInfluence_eq_fourier (addrFun_isBoolean k)] -- Only subsets `S` with `Sy = {a}` contribute, each with weight `2^(-2k)` and size `|Sx| + 1`! let toSet : Finset (Fin k) × (Fin k → Bool) → Finset (AddrIdx k) := fun p => insert (Sum.inr p.2 : AddrIdx k) (p.1.map ⟨(Sum.inl : Fin k → AddrIdx k), Sum.inl_injective⟩) let supp : Finset (Finset (AddrIdx k)) := (Finset.univ : Finset (Finset (Fin k) × (Fin k → Bool))).image toSet have hzero_out : ∀ S : Finset (AddrIdx k), S ∉ supp → (S.card : ℝ) * fourierCoeff (addrFun k) S ^ 2 = 0 := by intro S hS rw [addrFun_fourierCoeff] split_ifs with h · exfalso; apply hS obtain ⟨a, ha⟩ := h let Sx : Finset (Fin k) := Finset.univ.filter fun i => Sum.inl i ∈ S refine Finset.mem_image.mpr ⟨(Sx, a), Finset.mem_univ _, ?_⟩ ext s; cases s with | inl i => simp [toSet, Sx] | inr b => have hb : b ∈ Finset.univ.filter (fun c : Fin k → Bool => Sum.inr c ∈ S) ↔ b = a := by rw [ha]; simp simpa [toSet] using hb.symm · simp have hsum_supp : ∑ S : Finset (AddrIdx k), (S.card : ℝ) * fourierCoeff (addrFun k) S ^ 2 = ∑ S ∈ supp, (S.card : ℝ) * fourierCoeff (addrFun k) S ^ 2 := by rw [← Finset.sum_subset (Finset.subset_univ supp)] intro S _ hS; exact hzero_out S hS rw [hsum_supp] have hinj : Set.InjOn toSet (Finset.univ : Finset (Finset (Fin k) × (Fin k → Bool))) := by rintro ⟨Sx₁, a₁⟩ _ ⟨Sx₂, a₂⟩ _ heq dsimp only [toSet] at heq have ha : a₁ = a₂ := by have hmem : (Sum.inr a₁ : AddrIdx k) ∈ insert (Sum.inr a₂ : AddrIdx k) (Sx₂.map ⟨(Sum.inl : Fin k → AddrIdx k), Sum.inl_injective⟩) := heq ▸ Finset.mem_insert_self _ _ rcases Finset.mem_insert.mp hmem with h1 | h2 · exact Sum.inr.inj h1 · rcases Finset.mem_map.mp h2 with ⟨_, _, h⟩; exact (Sum.inl_ne_inr h).elim have hSx : Sx₁ = Sx₂ := by ext i have hiff : (Sum.inl i : AddrIdx k) ∈ insert (Sum.inr a₁ : AddrIdx k) (Sx₁.map ⟨(Sum.inl : Fin k → AddrIdx k), Sum.inl_injective⟩) ↔ (Sum.inl i : AddrIdx k) ∈ insert (Sum.inr a₂ : AddrIdx k) (Sx₂.map ⟨(Sum.inl : Fin k → AddrIdx k), Sum.inl_injective⟩) := by rw [heq] simpa using hiff exact Prod.ext hSx ha rw [Finset.sum_image hinj] have hterm : ∀ p : Finset (Fin k) × (Fin k → Bool), ((toSet p).card : ℝ) * fourierCoeff (addrFun k) (toSet p) ^ 2 = ((p.1.card : ℝ) + 1) / (2 : ℝ) ^ (2 * k) := by rintro ⟨Sx, a⟩ dsimp only [toSet] have hnot : Sum.inr a ∉ Sx.map ⟨Sum.inl, Sum.inl_injective⟩ := by intro h; rcases Finset.mem_map.mp h with ⟨_, _, h'⟩; exact Sum.inl_ne_inr h' rw [Finset.card_insert_of_notMem hnot, Finset.card_map, addrFun_fourierCoeff] have hex : ∃ b : Fin k → Bool, (Finset.univ.filter fun c : Fin k → Bool => Sum.inr c ∈ insert (Sum.inr a) (Sx.map ⟨Sum.inl, Sum.inl_injective⟩)) = {b} := by refine ⟨a, ?_⟩ ext c; simp simp only [hex, ↓reduceDIte] rw [div_pow, walsh_sq, ← pow_mul, mul_comm] push_cast; ring simp_rw [hterm] rw [Fintype.sum_prod_type] -- Evaluate `∑ Sx : Finset (Fin k), (|Sx| + 1) = (k/2 + 1) * 2^k` using pairing `Sx ↔ Sxᶜ`! have hsum_card : ∑ Sx : Finset (Fin k), ((Sx.card : ℝ) + 1) = ((k : ℝ) / 2 + 1) * (2 : ℝ) ^ k := by have hpair : 2 * ∑ Sx : Finset (Fin k), (Sx.card : ℝ) = (k : ℝ) * (2 : ℝ) ^ k := by have hcompl : ∑ Sx : Finset (Fin k), (Sx.card : ℝ) = ∑ Sx : Finset (Fin k), ((Sxᶜ).card : ℝ) := Fintype.sum_equiv { toFun := compl, invFun := compl, left_inv := compl_compl, right_inv := compl_compl } _ _ fun Sx => by simp have hadd : ∑ Sx : Finset (Fin k), (Sx.card : ℝ) + ∑ Sx : Finset (Fin k), ((Sxᶜ).card : ℝ) = ∑ _Sx : Finset (Fin k), (k : ℝ) := by rw [← Finset.sum_add_distrib] refine Finset.sum_congr rfl fun Sx _ => ?_ have hnat : Sx.card + (Sxᶜ).card = k := by rw [Finset.card_add_card_compl, Fintype.card_fin] exact_mod_cast hnat have htot : ∑ _Sx : Finset (Fin k), (k : ℝ) = (k : ℝ) * (2 : ℝ) ^ k := by rw [Finset.sum_const, Finset.card_univ, Fintype.card_finset, Fintype.card_fin, nsmul_eq_mul, Nat.cast_pow, Nat.cast_ofNat, mul_comm] linarith rw [Finset.sum_add_distrib, Finset.sum_const, Finset.card_univ, Fintype.card_finset, Fintype.card_fin, nsmul_eq_mul, mul_one, Nat.cast_pow, Nat.cast_ofNat] linarith have hinner_a : ∀ Sx : Finset (Fin k), ∑ _a : Fin k → Bool, ((Sx.card : ℝ) + 1) / (2 : ℝ) ^ (2 * k) = ((Sx.card : ℝ) + 1) / (2 : ℝ) ^ k := by intro Sx rw [Finset.sum_const, Finset.card_univ, Fintype.card_fun, Fintype.card_bool, Fintype.card_fin, nsmul_eq_mul, Nat.cast_pow, Nat.cast_ofNat, two_mul, pow_add] field_simp simp_rw [hinner_a, ← Finset.sum_div, hsum_card] rw [mul_div_cancel_right₀ _ (by positivity)] /-- Exact FMEI ratio of `Addr_k`: `H_∞(Addr_k) / I(Addr_k) = 4k / (k + 2)`. -/ theorem addrFun_fmei_ratio (k : ℕ) : fourierMinEntropy (addrFun k) / totalInfluence (addrFun k) = 4 * (k : ℝ) / ((k : ℝ) + 2) := by rw [addrFun_fourierMinEntropy, addrFun_totalInfluence] have hpos : (0 : ℝ) < (k : ℝ) + 2 := by positivity field_simp [hpos.ne'] ring /-- Canonical equivalence `AddrIdx k ≃ Fin (k + 2 ^ k)`. -/ noncomputable def addrIdxEquivFin (k : ℕ) : AddrIdx k ≃ Fin (k + 2 ^ k) := Fintype.equivFinOfCardEq (by simp [AddrIdx, Fintype.card_sum, Fintype.card_bool]) /-- **Concrete Beat of Biswas–Sarkar (`arXiv:2212.07713`, `128/45 ≈ 2.8444`) at `n = 37` (`k = 5`)**: There exists a balanced Boolean function on `Fin 37 → Bool` achieving `H_∞(f̂²) / I(f) = 20/7 > 128/45`. -/ theorem addr_five_beats_biswas_sarkar : ∃ f : (Fin 37 → Bool) → ℝ, IsBoolean f ∧ IsBalanced f ∧ (128 / 45 : ℝ) * totalInfluence f < fourierMinEntropy f := by have heq : 5 + 2 ^ 5 = 37 := by norm_num let e : AddrIdx 5 ≃ Fin 37 := (addrIdxEquivFin 5).trans (finCongr heq) let f := relabel e (addrFun 5) refine ⟨f, relabel_isBoolean e (addrFun_isBoolean 5), relabel_isBalanced e (addrFun_isBalanced 5), ?_⟩ rw [relabel_totalInfluence e (addrFun_isBoolean 5), relabel_fourierMinEntropy e, addrFun_totalInfluence, addrFun_fourierMinEntropy] norm_num /-- **MAIN WORLD-RECORD THEOREM 1 (General Balanced FMEI Lower Bound `D ≥ 4`)**: For every `D < 4`, there exist `n : ℕ` and a balanced Boolean function `f : (Fin n → Bool) → ℝ` such that `D * totalInfluence f < fourierMinEntropy f`. Hence any universal FMEI constant `D` must satisfy `4 ≤ D`, improving the Biswas–Sarkar (`arXiv:2212.07713`) world record `128/45 ≈ 2.8444` by `+40.6%`. -/ theorem fmei_constant_ge_four (D : ℝ) (hD : D < 4) : ∃ (n : ℕ) (f : (Fin n → Bool) → ℝ), IsBoolean f ∧ IsBalanced f ∧ D * totalInfluence f < fourierMinEntropy f := by have hgap : 0 < 4 - D := by linarith obtain ⟨k, hk⟩ := exists_nat_gt (2 * max D 0 / (4 - D)) let e := addrIdxEquivFin k refine ⟨k + 2 ^ k, relabel e (addrFun k), relabel_isBoolean e (addrFun_isBoolean k), relabel_isBalanced e (addrFun_isBalanced k), ?_⟩ rw [relabel_totalInfluence e (addrFun_isBoolean k), relabel_fourierMinEntropy e, addrFun_totalInfluence, addrFun_fourierMinEntropy] have h1 : 2 * max D 0 < (k : ℝ) * (4 - D) := (div_lt_iff₀ hgap).mp hk have hDle : D ≤ max D 0 := le_max_left D 0 nlinarith end AddressingFMEI /-! ## Section 3: Ben-Or–Linial `Tribes_{w, s}` & Monotone World-Record FMEI `D_monotone ≥ 2 / ln 2` -/ section MonotoneTribesFMEI /-- Monotone Ben-Or–Linial `Tribes_{w, s}` function on `Fin s × Fin w → Bool`: outputs `+1` iff at least one of the `s` disjoint tribes of width `w` is all-`true`, and `-1` otherwise. -/ def tribesFun (w s : ℕ) (x : Fin s × Fin w → Bool) : ℝ := if ∃ j : Fin s, ∀ i : Fin w, x (j, i) = true then 1 else -1 lemma tribesFun_isBoolean (w s : ℕ) : IsBoolean (tribesFun w s) := by intro x; unfold tribesFun; split_ifs <;> simp lemma tribesFun_isMonotone (w s : ℕ) : IsMonotone (tribesFun w s) := by intro x y hxy unfold tribesFun split_ifs with hx hy · exact le_rfl · exfalso; apply hy rcases hx with ⟨j, hj⟩ exact ⟨j, fun i => hxy (j, i) (hj i)⟩ · norm_num · exact le_rfl /-- Indicator of a single tribe `Fin w → Bool` NOT being all-`true`: `1 - ∏_i 1_{u_i = true}`. -/ def notAllTrue (w : ℕ) (u : Fin w → Bool) : ℝ := if ∀ i : Fin w, u i = true then 0 else 1 lemma tribesFun_eq_one_sub_two_prod (w s : ℕ) (x : Fin s × Fin w → Bool) : tribesFun w s x = 1 - 2 * ∏ j : Fin s, notAllTrue w (fun i => x (j, i)) := by unfold tribesFun by_cases h : ∃ j : Fin s, ∀ i : Fin w, x (j, i) = true · simp only [h, ↓reduceIte] rcases h with ⟨j₀, hj₀⟩ have hprod : ∏ j : Fin s, notAllTrue w (fun i => x (j, i)) = 0 := Finset.prod_eq_zero (Finset.mem_univ j₀) (by simp [notAllTrue, hj₀]) rw [hprod]; ring · simp only [h, ↓reduceIte] push Not at h have hprod : ∏ j : Fin s, notAllTrue w (fun i => x (j, i)) = 1 := by refine Finset.prod_eq_one fun j _ => ?_ have hj : ¬ ∀ i : Fin w, x (j, i) = true := by intro hall; rcases h j with ⟨i, hi⟩; exact hi (hall i) simp [notAllTrue, hj] rw [hprod]; ring /-- Exact Fourier coefficient of the single-tribe indicator `notAllTrue w`. -/ lemma notAllTrue_fourierCoeff (w : ℕ) (A : Finset (Fin w)) : fourierCoeff (notAllTrue w) A = if A = ∅ then 1 - 1 / (2 : ℝ) ^ w else -walsh A (fun _ => true) / (2 : ℝ) ^ w := by unfold fourierCoeff have hcard : Fintype.card (Fin w) = w := Fintype.card_fin w rw [hcard] have hall_eq : ∑ u : Fin w → Bool, notAllTrue w u * walsh A u = (∑ u : Fin w → Bool, walsh A u) - walsh A (fun _ => true) := by have h1 : ∀ u : Fin w → Bool, notAllTrue w u * walsh A u = walsh A u - (if u = (fun _ => true) then walsh A u else 0) := by intro u by_cases hu : u = fun _ => true · subst hu; simp [notAllTrue] · have hnot : ¬ ∀ i : Fin w, u i = true := fun hall => hu (funext hall) simp [notAllTrue, hu, hnot] simp only [h1, Finset.sum_sub_distrib, Finset.sum_ite_eq', Finset.mem_univ, ↓reduceIte] rw [hall_eq, sum_walsh, hcard] by_cases hA : A = ∅ · subst hA; simp only [↓reduceIte, walsh_empty] rw [sub_div, div_self (by positivity)] · simp only [hA, ↓reduceIte, zero_sub] /-- Equivalence splitting `Fin s × Fin w → Bool` into `s` independent blocks `Fin s → (Fin w → Bool)`. -/ def tribesSplitEquiv (w s : ℕ) : (Fin s × Fin w → Bool) ≃ (Fin s → (Fin w → Bool)) where toFun x j i := x (j, i) invFun y p := y p.1 p.2 left_inv _ := rfl right_inv _ := rfl /-- Exact Fourier coefficient of `tribesFun w s` at `∅`. -/ theorem tribesFun_fourierCoeff_empty (w s : ℕ) : fourierCoeff (tribesFun w s) ∅ = 1 - 2 * (1 - 1 / (2 : ℝ) ^ w) ^ s := by unfold fourierCoeff have hcard : Fintype.card (Fin s × Fin w) = s * w := by simp rw [hcard] simp_rw [walsh_empty, mul_one, tribesFun_eq_one_sub_two_prod, Finset.sum_sub_distrib, ← Finset.mul_sum] have hsum1 : ∑ _x : Fin s × Fin w → Bool, (1 : ℝ) = (2 : ℝ) ^ (s * w) := by rw [Finset.sum_const, Finset.card_univ, Fintype.card_fun, Fintype.card_bool, hcard, nsmul_eq_mul, mul_one, Nat.cast_pow, Nat.cast_ofNat] have hsum_prod : ∑ x : Fin s × Fin w → Bool, ∏ j : Fin s, notAllTrue w (fun i => x (j, i)) = ((2 : ℝ) ^ w * (1 - 1 / (2 : ℝ) ^ w)) ^ s := by refine (Fintype.sum_equiv (tribesSplitEquiv w s) _ (fun y : Fin s → (Fin w → Bool) => ∏ j : Fin s, notAllTrue w (y j)) (fun _ => rfl)).trans ?_ rw [← Fintype.prod_sum (fun (_ : Fin s) (u : Fin w → Bool) => notAllTrue w u), Finset.prod_const, Finset.card_univ, Fintype.card_fin] congr 1 have h0 := notAllTrue_fourierCoeff w ∅ simp only [↓reduceIte, fourierCoeff, walsh_empty, mul_one, Fintype.card_fin] at h0 have h2pos : (0 : ℝ) < (2 : ℝ) ^ w := by positivity rw [div_eq_iff h2pos.ne'] at h0 linarith rw [hsum1, hsum_prod, sub_div, div_self (by positivity), mul_pow, ← pow_mul, mul_comm w s] have h2pos : (0 : ℝ) < (2 : ℝ) ^ (s * w) := by positivity field_simp [h2pos.ne'] /-- Exact upper bound on every nonempty Fourier coefficient of `tribesFun w s`. -/ theorem tribesFun_fourierCoeff_nonempty_abs_le {w s : ℕ} (_hs : 1 ≤ s) (T : Finset (Fin s × Fin w)) (hT : T ≠ ∅) : |fourierCoeff (tribesFun w s) T| ≤ 2 * (1 - 1 / (2 : ℝ) ^ w) ^ (s - 1) * (1 / (2 : ℝ) ^ w) := by let block : Fin s → Finset (Fin w) := fun j => Finset.univ.filter fun i => (j, i) ∈ T have hprod_eval : fourierCoeff (tribesFun w s) T = -2 * ∏ j : Fin s, fourierCoeff (notAllTrue w) (block j) := by unfold fourierCoeff have hcard : Fintype.card (Fin s × Fin w) = s * w := by simp rw [hcard] simp_rw [tribesFun_eq_one_sub_two_prod, sub_mul, Finset.sum_sub_distrib, mul_assoc, ← Finset.mul_sum] have hsum_walsh0 : ∑ x : Fin s × Fin w → Bool, walsh T x = 0 := by rw [sum_walsh]; simp [hT] rw [hsum_walsh0, mul_zero, zero_sub, neg_div] have hwalsh_fac : ∀ x : Fin s × Fin w → Bool, walsh T x = ∏ j : Fin s, walsh (block j) (fun i => x (j, i)) := by intro x unfold walsh let emb : Fin s → (Fin w ↪ Fin s × Fin w) := fun j => ⟨fun i => (j, i), fun _ _ h => (Prod.mk.inj h).2⟩ have hbiU : (Finset.univ : Finset (Fin s)).biUnion (fun j => (block j).map (emb j)) = T := by ext ⟨j, i⟩ simp only [Finset.mem_biUnion, Finset.mem_univ, true_and, Finset.mem_map, Finset.mem_filter, block] constructor · rintro ⟨j', i', hi', heq⟩ have hj' : j' = j := (Prod.mk.inj heq).1 have hi'' : i' = i := (Prod.mk.inj heq).2 subst hj' hi''; exact hi' · intro hmem exact ⟨j, i, hmem, rfl⟩ have hdisj : Set.PairwiseDisjoint ((Finset.univ : Finset (Fin s)) : Set (Fin s)) (fun j => (block j).map (emb j)) := by intro j₁ _ j₂ _ hne change Disjoint _ _ rw [Finset.disjoint_left] intro p hp1 hp2 rcases Finset.mem_map.mp hp1 with ⟨i₁, _, rfl⟩ rcases Finset.mem_map.mp hp2 with ⟨i₂, _, h⟩ exact hne (Prod.mk.inj h).1.symm rw [← hbiU, Finset.prod_biUnion hdisj] refine Finset.prod_congr rfl fun j _ => ?_ rw [Finset.prod_map]; rfl have hsum_prod : ∑ x : Fin s × Fin w → Bool, (∏ j : Fin s, notAllTrue w (fun i => x (j, i))) * walsh T x = ∏ j : Fin s, ∑ u : Fin w → Bool, notAllTrue w u * walsh (block j) u := by simp_rw [hwalsh_fac, ← Finset.prod_mul_distrib] refine (Fintype.sum_equiv (tribesSplitEquiv w s) _ (fun y : Fin s → (Fin w → Bool) => ∏ j : Fin s, notAllTrue w (y j) * walsh (block j) (y j)) (fun _ => rfl)).trans ?_ exact (Fintype.prod_sum (fun (j : Fin s) (u : Fin w → Bool) => notAllTrue w u * walsh (block j) u)).symm rw [hsum_prod] simp_rw [Fintype.card_fin] rw [Finset.prod_div_distrib, Finset.prod_const, Finset.card_univ, Fintype.card_fin, ← pow_mul, mul_comm w s] ring rw [hprod_eval, abs_mul, abs_neg, abs_of_pos (by norm_num : (0 : ℝ) < 2), Finset.abs_prod] -- Pick an active block `j₀` (exists since `T ≠ ∅`!). obtain ⟨⟨j₀, i₀⟩, hmem⟩ := Finset.nonempty_iff_ne_empty.mpr hT have hj₀_ne : block j₀ ≠ ∅ := Finset.nonempty_iff_ne_empty.mp ⟨i₀, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hmem⟩⟩ rw [← Finset.mul_prod_erase Finset.univ _ (Finset.mem_univ j₀)] have hj₀_val : |fourierCoeff (notAllTrue w) (block j₀)| = 1 / (2 : ℝ) ^ w := by rw [notAllTrue_fourierCoeff, if_neg hj₀_ne, abs_div, abs_neg, walsh_abs, abs_of_pos (by positivity)] have h1sub_nn : 0 ≤ 1 - 1 / (2 : ℝ) ^ w := by have : (1 : ℝ) ≤ (2 : ℝ) ^ w := one_le_pow₀ (by norm_num) have : 1 / (2 : ℝ) ^ w ≤ 1 := div_le_one_of_le₀ this (by positivity) linarith have hrest_le : ∏ j ∈ Finset.univ.erase j₀, |fourierCoeff (notAllTrue w) (block j)| ≤ (1 - 1 / (2 : ℝ) ^ w) ^ (s - 1) := by have hcard_er : ((Finset.univ : Finset (Fin s)).erase j₀).card = s - 1 := by rw [Finset.card_erase_of_mem (Finset.mem_univ _), Finset.card_univ, Fintype.card_fin] calc ∏ j ∈ Finset.univ.erase j₀, |fourierCoeff (notAllTrue w) (block j)| ≤ ∏ _j ∈ Finset.univ.erase j₀, (1 - 1 / (2 : ℝ) ^ w) := by refine Finset.prod_le_prod (fun j _ => abs_nonneg _) fun j _ => ?_ rw [notAllTrue_fourierCoeff] split_ifs with hb · exact le_of_eq (abs_of_nonneg h1sub_nn) · rw [abs_div, abs_neg, walsh_abs, abs_of_pos (by positivity)] by_cases hw0 : w = 0 · exfalso; subst hw0; exact hb (Finset.eq_empty_of_isEmpty _) · have h2w : (2 : ℝ) ≤ (2 : ℝ) ^ w := by have : 1 ≤ w := Nat.pos_of_ne_zero hw0 exact le_trans (by norm_num) (pow_le_pow_right₀ (by norm_num : (1 : ℝ) ≤ 2) this) have : 1 / (2 : ℝ) ^ w ≤ 1 / 2 := one_div_le_one_div_of_le (by norm_num) h2w linarith _ = (1 - 1 / (2 : ℝ) ^ w) ^ (s - 1) := by rw [Finset.prod_const, hcard_er] rw [hj₀_val] have := mul_le_mul_of_nonneg_left hrest_le (show 0 ≤ 1 / (2 : ℝ) ^ w by positivity) nlinarith /-- Exact total influence of `tribesFun w s`: `I(Tribes_{w, s}) = w * s * 2^(1 - w) * (1 - 2^(-w))^(s - 1)` for `w ≥ 1, s ≥ 1`. -/ theorem tribesFun_totalInfluence {w s : ℕ} (hw : 1 ≤ w) (hs : 1 ≤ s) : totalInfluence (tribesFun w s) = (w : ℝ) * (s : ℝ) * (1 / (2 : ℝ) ^ (w - 1)) * (1 - 1 / (2 : ℝ) ^ w) ^ (s - 1) := by unfold totalInfluence have hcoord : ∀ p : Fin s × Fin w, coordInfluence (tribesFun w s) p = (1 / (2 : ℝ) ^ (w - 1)) * (1 - 1 / (2 : ℝ) ^ w) ^ (s - 1) := by rintro ⟨j₀, i₀⟩ unfold coordInfluence have hcard : Fintype.card (Fin s × Fin w) = s * w := by simp rw [hcard] -- `tribesFun x ≠ tribesFun (flipBit x (j₀, i₀))` iff all other bits in tribe `j₀` are `true` -- AND all other `s - 1` tribes are NOT all-`true`! have hiff : ∀ x : Fin s × Fin w → Bool, tribesFun w s x ≠ tribesFun w s (flipBit x (j₀, i₀)) ↔ (∀ i : Fin w, i ≠ i₀ → x (j₀, i) = true) ∧ (∀ j : Fin s, j ≠ j₀ → ¬ ∀ i : Fin w, x (j, i) = true) := by intro x constructor · intro hne have hother_tribes : ∀ j : Fin s, j ≠ j₀ → ¬ ∀ i : Fin w, x (j, i) = true := by intro j hj hall apply hne; unfold tribesFun have h1 : ∃ j' : Fin s, ∀ i : Fin w, x (j', i) = true := ⟨j, hall⟩ have h2 : ∃ j' : Fin s, ∀ i : Fin w, flipBit x (j₀, i₀) (j', i) = true := ⟨j, fun i => by rw [flipBit_apply_ne x (by intro h; exact hj (Prod.mk.inj h).1)]; exact hall i⟩ simp [h1, h2] refine ⟨?_, hother_tribes⟩ intro i hi by_contra hfalse apply hne; unfold tribesFun have hnot1 : ¬ ∃ j' : Fin s, ∀ i' : Fin w, x (j', i') = true := by rintro ⟨j', hj'⟩ by_cases hjj : j' = j₀ · subst hjj; exact hfalse (hj' i) · exact hother_tribes j' hjj hj' have hnot2 : ¬ ∃ j' : Fin s, ∀ i' : Fin w, flipBit x (j₀, i₀) (j', i') = true := by rintro ⟨j', hj'⟩ by_cases hjj : j' = j₀ · subst hjj have := hj' i rw [flipBit_apply_ne x (by intro h; exact hi (Prod.mk.inj h).2)] at this exact hfalse this · exact hother_tribes j' hjj fun i' => by have := hj' i' rwa [flipBit_apply_ne x (by intro h; exact hjj (Prod.mk.inj h).1)] at this simp [hnot1, hnot2] · rintro ⟨hblock, hothers⟩ unfold tribesFun cases hx0 : x (j₀, i₀) · have hnot1 : ¬ ∃ j' : Fin s, ∀ i' : Fin w, x (j', i') = true := by rintro ⟨j', hj'⟩ by_cases hjj : j' = j₀ · subst hjj; have := hj' i₀; rw [hx0] at this; exact Bool.false_ne_true this · exact hothers j' hjj hj' have hyes2 : ∃ j' : Fin s, ∀ i' : Fin w, flipBit x (j₀, i₀) (j', i') = true := by refine ⟨j₀, fun i' => ?_⟩ by_cases hii : i' = i₀ · subst hii; simp [hx0] · rw [flipBit_apply_ne x (by intro h; exact hii (Prod.mk.inj h).2)] exact hblock i' hii simp [hnot1, hyes2]; norm_num · have hyes1 : ∃ j' : Fin s, ∀ i' : Fin w, x (j', i') = true := by refine ⟨j₀, fun i' => ?_⟩ by_cases hii : i' = i₀ · subst hii; exact hx0 · exact hblock i' hii have hnot2 : ¬ ∃ j' : Fin s, ∀ i' : Fin w, flipBit x (j₀, i₀) (j', i') = true := by rintro ⟨j', hj'⟩ by_cases hjj : j' = j₀ · subst hjj; have := hj' i₀; simp [hx0] at this · exact hothers j' hjj fun i' => by have := hj' i' rwa [flipBit_apply_ne x (by intro h; exact hjj (Prod.mk.inj h).1)] at this simp [hyes1, hnot2]; norm_num -- Count satisfying `x` via product over the `s` blocks! have hcount : ∑ x : Fin s × Fin w → Bool, (if tribesFun w s x ≠ tribesFun w s (flipBit x (j₀, i₀)) then (1 : ℝ) else 0) = 2 * ((2 : ℝ) ^ w * (1 - 1 / (2 : ℝ) ^ w)) ^ (s - 1) := by let blkInd : Fin s → (Fin w → Bool) → ℝ := fun j u => if j = j₀ then (if ∀ i : Fin w, i ≠ i₀ → u i = true then 1 else 0) else notAllTrue w u have hfac : ∀ x : Fin s × Fin w → Bool, (if tribesFun w s x ≠ tribesFun w s (flipBit x (j₀, i₀)) then (1 : ℝ) else 0) = ∏ j : Fin s, blkInd j (fun i => x (j, i)) := by intro x by_cases hc : tribesFun w s x ≠ tribesFun w s (flipBit x (j₀, i₀)) · rw [if_pos hc] rcases (hiff x).mp hc with ⟨hb, ho⟩ symm refine Finset.prod_eq_one fun j _ => ?_ by_cases hjj : j = j₀ · subst hjj; simp only [blkInd, ↓reduceIte]; rw [if_pos hb] · simp [blkInd, hjj, notAllTrue, ho j hjj] · rw [if_neg hc] have hnc : ¬ ((∀ i : Fin w, i ≠ i₀ → x (j₀, i) = true) ∧ (∀ j : Fin s, j ≠ j₀ → ¬ ∀ i : Fin w, x (j, i) = true)) := fun h => hc ((hiff x).mpr h) symm by_cases hb : ∀ i : Fin w, i ≠ i₀ → x (j₀, i) = true · have hno : ¬ ∀ j : Fin s, j ≠ j₀ → ¬ ∀ i : Fin w, x (j, i) = true := fun ho => hnc ⟨hb, ho⟩ push Not at hno rcases hno with ⟨j₁, hj₁ne, hj₁all⟩ exact Finset.prod_eq_zero (Finset.mem_univ j₁) (by simp [blkInd, hj₁ne, notAllTrue, hj₁all]) · exact Finset.prod_eq_zero (Finset.mem_univ j₀) (by simp [blkInd, hb]) simp_rw [hfac] refine (Fintype.sum_equiv (tribesSplitEquiv w s) _ (fun y : Fin s → (Fin w → Bool) => ∏ j : Fin s, blkInd j (y j)) (fun _ => rfl)).trans ?_ rw [← Fintype.prod_sum, ← Finset.mul_prod_erase Finset.univ _ (Finset.mem_univ j₀)] have hj₀_sum : ∑ u : Fin w → Bool, blkInd j₀ u = 2 := by simp only [blkInd, ↓reduceIte] rw [← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul, mul_one] have hbij : (Finset.univ.filter fun u : Fin w → Bool => ∀ i : Fin w, i ≠ i₀ → u i = true).card = 2 := by have hset : (Finset.univ.filter fun u : Fin w → Bool => ∀ i : Fin w, i ≠ i₀ → u i = true) = {fun i => if i = i₀ then false else true, fun _ => true} := by ext u simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_insert, Finset.mem_singleton] constructor · intro hu cases hu0 : u i₀ · left; ext i; by_cases hi : i = i₀ <;> simp [hi, hu0, hu] · right; ext i; by_cases hi : i = i₀ <;> simp [hi, hu0, hu] · rintro (rfl | rfl) i hi <;> simp [hi] rw [hset, Finset.card_pair] intro h have := congrFun h i₀ simp at this exact_mod_cast hbij have hother_sum : ∀ j ∈ (Finset.univ : Finset (Fin s)).erase j₀, ∑ u : Fin w → Bool, blkInd j u = (2 : ℝ) ^ w * (1 - 1 / (2 : ℝ) ^ w) := by intro j hj have hne : j ≠ j₀ := (Finset.mem_erase.mp hj).1 simp only [blkInd, hne, ↓reduceIte] have h0 := notAllTrue_fourierCoeff w ∅ simp only [↓reduceIte, fourierCoeff, walsh_empty, mul_one, Fintype.card_fin] at h0 have h2pos : (0 : ℝ) < (2 : ℝ) ^ w := by positivity rw [div_eq_iff h2pos.ne'] at h0 linarith rw [hj₀_sum, Finset.prod_congr rfl hother_sum, Finset.prod_const] have hcard_er : ((Finset.univ : Finset (Fin s)).erase j₀).card = s - 1 := by rw [Finset.card_erase_of_mem (Finset.mem_univ _), Finset.card_univ, Fintype.card_fin] rw [hcard_er] rw [hcount, mul_pow, ← pow_mul] have hexp : s * w = w * (s - 1) + (w - 1) + 1 := by have : s = (s - 1) + 1 := (Nat.sub_add_cancel hs).symm have : w = (w - 1) + 1 := (Nat.sub_add_cancel hw).symm nlinarith rw [hexp, pow_add, pow_add, pow_one] have h2pos1 : (0 : ℝ) < (2 : ℝ) ^ (w * (s - 1)) := by positivity have h2pos2 : (0 : ℝ) < (2 : ℝ) ^ (w - 1) := by positivity field_simp [h2pos1.ne', h2pos2.ne'] simp_rw [hcoord] rw [Finset.sum_const, Finset.card_univ, Fintype.card_prod, Fintype.card_fin, Fintype.card_fin, nsmul_eq_mul, Nat.cast_mul] ring /-- Existence of the unique threshold `s ≥ 1` with `(1 - 2⁻ʷ)^s ≤ 1/2 < (1 - 2⁻ʷ)^(s - 1)`. -/ lemma exists_tribes_threshold {w : ℕ} (hw : 1 ≤ w) : ∃ s : ℕ, 1 ≤ s ∧ (1 - 1 / (2 : ℝ) ^ w) ^ s ≤ 1 / 2 ∧ 1 / 2 < (1 - 1 / (2 : ℝ) ^ w) ^ (s - 1) := by let q : ℝ := 1 - 1 / (2 : ℝ) ^ w have hq0 : 0 < q := by dsimp only [q] have h2w : (2 : ℝ) ≤ (2 : ℝ) ^ w := le_trans (by norm_num) (pow_le_pow_right₀ (by norm_num : (1 : ℝ) ≤ 2) hw) have : 1 / (2 : ℝ) ^ w ≤ 1 / 2 := one_div_le_one_div_of_le (by norm_num) h2w linarith have hq1 : q < 1 := by dsimp only [q] have : (0 : ℝ) < 1 / (2 : ℝ) ^ w := by positivity linarith have hex : ∃ n : ℕ, q ^ n ≤ 1 / 2 := by have hlim : Filter.Tendsto (fun n : ℕ => q ^ n) Filter.atTop (nhds 0) := tendsto_pow_atTop_nhds_zero_of_lt_one hq0.le hq1 have hev := hlim.eventually (gt_mem_nhds (by norm_num : (0 : ℝ) < 1 / 2)) obtain ⟨n, hn⟩ := hev.exists exact ⟨n, hn.le⟩ classical let s := Nat.find hex have hs_le : q ^ s ≤ 1 / 2 := Nat.find_spec hex have hs_ne0 : s ≠ 0 := by intro h0; rw [h0, pow_zero] at hs_le; norm_num at hs_le have hs1 : 1 ≤ s := Nat.pos_of_ne_zero hs_ne0 have hlt : 1 / 2 < q ^ (s - 1) := by have hnot := Nat.find_min hex (show s - 1 < s by omega) push Not at hnot; exact hnot exact ⟨s, hs1, hs_le, hlt⟩ /-- Elementary quantitative bounds on `tribesFun w s` at the threshold `q^s ≤ 1/2 < q^(s - 1)`. -/ lemma tribesFun_threshold_bounds {w s : ℕ} (hw : 2 ≤ w) (hs : 1 ≤ s) (hle : (1 - 1 / (2 : ℝ) ^ w) ^ s ≤ 1 / 2) (hlt : 1 / 2 < (1 - 1 / (2 : ℝ) ^ w) ^ (s - 1)) : 2 * Real.logb 2 ((2 : ℝ) ^ w - 1) ≤ fourierMinEntropy (tribesFun w s) ∧ totalInfluence (tribesFun w s) ≤ (w : ℝ) * (Real.log 2 + 1 / (2 : ℝ) ^ w) / (1 - 1 / (2 : ℝ) ^ w) := by let q : ℝ := 1 - 1 / (2 : ℝ) ^ w have h2w_ge4 : (4 : ℝ) ≤ (2 : ℝ) ^ w := by calc (4 : ℝ) = (2 : ℝ) ^ 2 := by norm_num _ ≤ (2 : ℝ) ^ w := pow_le_pow_right₀ (by norm_num) hw have hq_pos : 0 < q := by dsimp only [q]; have : 1 / (2 : ℝ) ^ w ≤ 1 / 4 := one_div_le_one_div_of_le (by norm_num) h2w_ge4; linarith -- Bound `q^(s - 1) ≤ 1 / (2 * q)`: have hqs1_ub : q ^ (s - 1) ≤ 1 / (2 * q) := by have hpow : q ^ (s - 1) * q = q ^ s := by rw [← pow_succ, Nat.sub_add_cancel hs] rw [le_div_iff₀ (by positivity)] nlinarith -- Step 1: Every Fourier coefficient (including `∅`) has `|f̂(T)| ≤ 2 * q^(s - 1) * 2^(-w) ≤ 1 / (2^w - 1)`! have hM_le : maxFourierSq (tribesFun w s) ≤ (1 / ((2 : ℝ) ^ w - 1)) ^ 2 := by rw [maxFourierSq_le_iff] have hbound : 2 * q ^ (s - 1) * (1 / (2 : ℝ) ^ w) ≤ 1 / ((2 : ℝ) ^ w - 1) := by have h1 : 2 * q ^ (s - 1) * (1 / (2 : ℝ) ^ w) ≤ 2 * (1 / (2 * q)) * (1 / (2 : ℝ) ^ w) := by have := mul_le_mul_of_nonneg_left hqs1_ub (by norm_num : (0 : ℝ) ≤ 2) exact mul_le_mul_of_nonneg_right this (by positivity) have h2 : 2 * (1 / (2 * q)) * (1 / (2 : ℝ) ^ w) = 1 / ((2 : ℝ) ^ w - 1) := by dsimp only [q] have hne1 : (2 : ℝ) ^ w ≠ 0 := by positivity have hne2 : (2 : ℝ) ^ w - 1 ≠ 0 := by linarith field_simp [hne1, hne2] linarith intro T have habs : |fourierCoeff (tribesFun w s) T| ≤ 2 * q ^ (s - 1) * (1 / (2 : ℝ) ^ w) := by by_cases hT : T = ∅ · subst hT rw [tribesFun_fourierCoeff_empty] have hqs_eq : q ^ s = q ^ (s - 1) - q ^ (s - 1) * (1 / (2 : ℝ) ^ w) := by have hpow : q ^ s = q ^ (s - 1) * q := by rw [← pow_succ, Nat.sub_add_cancel hs] rw [hpow]; dsimp only [q]; ring have hnn : 0 ≤ 1 - 2 * q ^ s := by linarith rw [abs_of_nonneg hnn] linarith · exact tribesFun_fourierCoeff_nonempty_abs_le hs T hT have habs' : |fourierCoeff (tribesFun w s) T| ≤ 1 / ((2 : ℝ) ^ w - 1) := habs.trans hbound have hden_pos : (0 : ℝ) < (2 : ℝ) ^ w - 1 := by linarith have hpos_rhs : (0 : ℝ) < 1 / ((2 : ℝ) ^ w - 1) := div_pos one_pos hden_pos exact sq_le_sq.mpr (by rw [abs_of_pos hpos_rhs]; exact habs') have hH_lb : 2 * Real.logb 2 ((2 : ℝ) ^ w - 1) ≤ fourierMinEntropy (tribesFun w s) := by unfold fourierMinEntropy have hlog := Real.logb_le_logb_of_le (by norm_num : (1 : ℝ) < 2) (maxFourierSq_pos (tribesFun_isBoolean w s)) hM_le have heval : -Real.logb 2 ((1 / ((2 : ℝ) ^ w - 1)) ^ 2) = 2 * Real.logb 2 ((2 : ℝ) ^ w - 1) := by rw [Real.logb_pow, one_div, Real.logb_inv]; push_cast; ring linarith -- Step 2: Upper-bound `I(Tribes_{w, s})` using `(s - 1) ≤ 2^w * ln 2` and `q^(s - 1) ≤ 1 / (2 * q)`! have hs_ub : (s : ℝ) ≤ (2 : ℝ) ^ w * Real.log 2 + 1 := by have hlogq : Real.log q ≤ -(1 / (2 : ℝ) ^ w) := by have := Real.log_le_sub_one_of_pos hq_pos dsimp only [q] at this ⊢; linarith have hlog_pow : Real.log (1 / 2) < ((s - 1 : ℕ) : ℝ) * Real.log q := by have := Real.log_lt_log (by norm_num : (0 : ℝ) < 1 / 2) hlt rwa [Real.log_pow] at this have hlog_half : Real.log (1 / 2) = -Real.log 2 := by rw [one_div, Real.log_inv] rw [hlog_half] at hlog_pow have hmul : ((s - 1 : ℕ) : ℝ) * Real.log q ≤ ((s - 1 : ℕ) : ℝ) * -(1 / (2 : ℝ) ^ w) := mul_le_mul_of_nonneg_left hlogq (Nat.cast_nonneg _) have hmul_eq : ((s - 1 : ℕ) : ℝ) * -(1 / (2 : ℝ) ^ w) = -(((s - 1 : ℕ) : ℝ) / (2 : ℝ) ^ w) := by ring have hlt2 : ((s - 1 : ℕ) : ℝ) / (2 : ℝ) ^ w < Real.log 2 := by linarith have hs1_lt : ((s - 1 : ℕ) : ℝ) < Real.log 2 * (2 : ℝ) ^ w := (div_lt_iff₀ (by positivity)).mp hlt2 have hcast : ((s - 1 : ℕ) : ℝ) = (s : ℝ) - 1 := by simpa using Nat.cast_sub (R := ℝ) hs linarith have hI_ub : totalInfluence (tribesFun w s) ≤ (w : ℝ) * (Real.log 2 + 1 / (2 : ℝ) ^ w) / q := by rw [tribesFun_totalInfluence (by omega) hs] have h1 : (w : ℝ) * (s : ℝ) * (1 / (2 : ℝ) ^ (w - 1)) * q ^ (s - 1) ≤ (w : ℝ) * ((2 : ℝ) ^ w * Real.log 2 + 1) * (1 / (2 : ℝ) ^ (w - 1)) * (1 / (2 * q)) := by have ha : (w : ℝ) * (s : ℝ) * (1 / (2 : ℝ) ^ (w - 1)) ≤ (w : ℝ) * ((2 : ℝ) ^ w * Real.log 2 + 1) * (1 / (2 : ℝ) ^ (w - 1)) := by refine mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hs_ub (Nat.cast_nonneg _)) (by positivity) exact mul_le_mul ha hqs1_ub (pow_nonneg hq_pos.le _) (by positivity) have h2 : (w : ℝ) * ((2 : ℝ) ^ w * Real.log 2 + 1) * (1 / (2 : ℝ) ^ (w - 1)) * (1 / (2 * q)) = (w : ℝ) * (Real.log 2 + 1 / (2 : ℝ) ^ w) / q := by have hpow : (2 : ℝ) ^ w = (2 : ℝ) ^ (w - 1) * 2 := by rw [← pow_succ, Nat.sub_add_cancel (by omega : 1 ≤ w)] have h2w1 : (2 : ℝ) ^ (w - 1) ≠ 0 := by positivity have h2w : (2 : ℝ) ^ w ≠ 0 := by positivity rw [hpow] at h2w ⊢ field_simp [h2w1, hq_pos.ne'] linarith exact ⟨hH_lb, hI_ub⟩ /-- Canonical equivalence `Fin s × Fin w ≃ Fin (s * w)`. -/ noncomputable def tribesIdxEquivFin (w s : ℕ) : Fin s × Fin w ≃ Fin (s * w) := Fintype.equivFinOfCardEq (by simp) /-- **MAIN WORLD-RECORD THEOREM 2 (Monotone FMEI Lower Bound `D_monotone ≥ 2 / ln 2 ≈ 2.88539`)**: For every `D < 2 / Real.log 2`, there exist `n : ℕ` and a **monotone** Boolean function `f : (Fin n → Bool) → ℝ` such that `D * totalInfluence f < fourierMinEntropy f`. -/ theorem monotone_fmei_constant_ge_two_div_log_two (D : ℝ) (hD : D < 2 / Real.log 2) : ∃ (n : ℕ) (f : (Fin n → Bool) → ℝ), IsBoolean f ∧ IsMonotone f ∧ D * totalInfluence f < fourierMinEntropy f := by have hlog2_pos : 0 < Real.log 2 := Real.log_pos (by norm_num) let gap : ℝ := 2 - D * Real.log 2 have hgap : 0 < gap := by dsimp only [gap] have := (lt_div_iff₀ hlog2_pos).mp hD; linarith -- Choose `w ≥ 2` large enough so `(2^w)⁻¹` is tiny and `w` is large enough to absorb the `O(1)` loss: let M : ℝ := max (max D 0) 2 have hM_pos : 0 < M := lt_of_lt_of_le (by norm_num) (le_max_right _ _) have hD_le_M : D ≤ M := le_trans (le_max_left D 0) (le_max_left _ _) obtain ⟨w₀, hw₀⟩ := exists_nat_gt (max (4 * M / gap) (16 / gap)) let w := max 4 w₀ have hw2 : 2 ≤ w := by omega have hw4 : 4 ≤ w := le_max_left _ _ obtain ⟨s, hs1, hle, hlt⟩ := exists_tribes_threshold (show 1 ≤ w by omega) obtain ⟨hH_lb, hI_ub⟩ := tribesFun_threshold_bounds hw2 hs1 hle hlt let e := tribesIdxEquivFin w s refine ⟨s * w, relabel e (tribesFun w s), relabel_isBoolean e (tribesFun_isBoolean w s), relabel_isMonotone e (tribesFun_isMonotone w s), ?_⟩ rw [relabel_totalInfluence e (tribesFun_isBoolean w s), relabel_fourierMinEntropy e] -- Lower bound `Real.logb 2 (2^w - 1) ≥ w - 1` (since `2^(w - 1) ≤ 2^w - 1` for `w ≥ 2`): have hlog_lb : (w : ℝ) - 1 ≤ Real.logb 2 ((2 : ℝ) ^ w - 1) := by have hpow : (2 : ℝ) ^ (w - 1) ≤ (2 : ℝ) ^ w - 1 := by have h1 : (2 : ℝ) ^ w = 2 * (2 : ℝ) ^ (w - 1) := by rw [mul_comm, ← pow_succ, Nat.sub_add_cancel (by omega : 1 ≤ w)] have h2 : (1 : ℝ) ≤ (2 : ℝ) ^ (w - 1) := one_le_pow₀ (by norm_num) linarith have h := Real.logb_le_logb_of_le (by norm_num : (1 : ℝ) < 2) (by positivity) hpow rw [Real.logb_pow, Real.logb_self_eq_one (by norm_num), mul_one] at h have hcast : ((w - 1 : ℕ) : ℝ) = (w : ℝ) - 1 := by simpa using Nat.cast_sub (R := ℝ) (show 1 ≤ w by omega) linarith have hH_lb' : 2 * ((w : ℝ) - 1) ≤ fourierMinEntropy (tribesFun w s) := by linarith -- Upper bound `D * I ≤ D * w * (ln 2 + 1/2^w) / (1 - 1/2^w)`: -- Note `2^w ≥ w` (`Nat.lt_two_pow_self`), so `1 / 2^w ≤ 1 / w`, and `1 - 1 / 2^w ≥ 1 / 2`! have h2w_ge_w : (w : ℝ) ≤ (2 : ℝ) ^ w := by exact_mod_cast (Nat.lt_two_pow_self (n := w)).le have h2w_ge16 : (16 : ℝ) ≤ (2 : ℝ) ^ w := by calc (16 : ℝ) = (2 : ℝ) ^ 4 := by norm_num _ ≤ (2 : ℝ) ^ w := pow_le_pow_right₀ (by norm_num) hw4 have hq_ge_half : (1 / 2 : ℝ) ≤ 1 - 1 / (2 : ℝ) ^ w := by have : 1 / (2 : ℝ) ^ w ≤ 1 / 16 := one_div_le_one_div_of_le (by norm_num) h2w_ge16 linarith have hinv_le : 1 / (2 : ℝ) ^ w ≤ 1 / (w : ℝ) := one_div_le_one_div_of_le (by positivity) h2w_ge_w -- Multiply by `(1 - 2^(-w)) > 0` to clear denominator cleanly: have hq_pos : 0 < 1 - 1 / (2 : ℝ) ^ w := by linarith by_cases hD0 : D ≤ 0 · have hI_nn := totalInfluence_nonneg (tribesFun w s) have : D * totalInfluence (tribesFun w s) ≤ 0 := mul_nonpos_of_nonpos_of_nonneg hD0 hI_nn have hwR : (4 : ℝ) ≤ (w : ℝ) := by exact_mod_cast hw4 linarith · push Not at hD0 have hDI : D * totalInfluence (tribesFun w s) ≤ D * ((w : ℝ) * (Real.log 2 + 1 / (2 : ℝ) ^ w) / (1 - 1 / (2 : ℝ) ^ w)) := mul_le_mul_of_nonneg_left hI_ub hD0.le refine lt_of_le_of_lt hDI (lt_of_lt_of_le ?_ hH_lb') rw [mul_div_assoc', div_lt_iff₀ hq_pos] -- Need: `D * (w * (ln 2 + 2^(-w))) < 2 * (w - 1) * (1 - 2^(-w))` -- Since `w * 2^(-w) ≤ 1`, `LHS ≤ D * w * ln 2 + D`, and `RHS ≥ 2 * w - 2 - 2 * w * 2^(-w) ≥ 2 * w - 4`! -- Wait: `w * 2^(-w) ≤ 1` and `16 / hgap < w` => `w * (2 - D * ln 2) > 16`, while `D + 4 ≤ ...`! have hw_inv : (w : ℝ) * (1 / (2 : ℝ) ^ w) ≤ 1 := by have := mul_le_mul_of_nonneg_left hinv_le (Nat.cast_nonneg w) rwa [mul_one_div_cancel (show (w : ℝ) ≠ 0 by positivity)] at this have hLHS : D * ((w : ℝ) * (Real.log 2 + 1 / (2 : ℝ) ^ w)) ≤ D * Real.log 2 * (w : ℝ) + D := by have h1 : D * ((w : ℝ) * (Real.log 2 + 1 / (2 : ℝ) ^ w)) = D * Real.log 2 * (w : ℝ) + D * ((w : ℝ) * (1 / (2 : ℝ) ^ w)) := by ring rw [h1] have := mul_le_mul_of_nonneg_left hw_inv hD0.le linarith have hRHS : 2 * (w : ℝ) - 4 ≤ 2 * ((w : ℝ) - 1) * (1 - 1 / (2 : ℝ) ^ w) := by have h1 : 2 * ((w : ℝ) - 1) * (1 - 1 / (2 : ℝ) ^ w) = 2 * (w : ℝ) - 2 - 2 * ((w : ℝ) * (1 / (2 : ℝ) ^ w)) + 2 * (1 / (2 : ℝ) ^ w) := by ring rw [h1] have : 0 ≤ 2 * (1 / (2 : ℝ) ^ w) := by positivity linarith have hw_gt1 : 4 * M / gap < (w : ℝ) := by have h1 : 4 * M / gap < (w₀ : ℝ) := lt_of_le_of_lt (le_max_left _ _) hw₀ have h2 : (w₀ : ℝ) ≤ (w : ℝ) := by exact_mod_cast le_max_right 4 w₀ linarith have hw_gt2 : 16 / gap < (w : ℝ) := by have h1 : 16 / gap < (w₀ : ℝ) := lt_of_le_of_lt (le_max_right _ _) hw₀ have h2 : (w₀ : ℝ) ≤ (w : ℝ) := by exact_mod_cast le_max_right 4 w₀ linarith have hprod1 : 4 * M < (w : ℝ) * gap := (div_lt_iff₀ hgap).mp hw_gt1 have hprod2 : 16 < (w : ℝ) * gap := (div_lt_iff₀ hgap).mp hw_gt2 dsimp only [gap] at hprod1 hprod2 nlinarith /-- **Monotone Beat of Biswas–Sarkar (`arXiv:2212.07713`, `128/45`)**: Even restricted to **monotone** Boolean functions, the FMEI ratio strictly exceeds `128/45`. -/ theorem monotone_fmei_beats_biswas_sarkar : ∃ (n : ℕ) (f : (Fin n → Bool) → ℝ), IsBoolean f ∧ IsMonotone f ∧ (128 / 45 : ℝ) * totalInfluence f < fourierMinEntropy f := by apply monotone_fmei_constant_ge_two_div_log_two have hlog2_pos : 0 < Real.log 2 := Real.log_pos (by norm_num) rw [lt_div_iff₀ hlog2_pos] have hlt := Real.log_two_lt_d9 linarith end MonotoneTribesFMEI /-! ## Section 4: Hypercube Edge-Isoperimetric Inequality & Exact Sharpness of `4` for Partition Selectors -/ section EdgeIsoperimetricAndSharpness /-- Elementary 1-variable calculus lemma: for all `t ∈ [0, 1]`, `0 ≤ (1 + t) * log (1 + t) - t * log t - 2 * t * log 2`. -/ lemma edgeIso_aux_nonneg {t : ℝ} (ht0 : 0 ≤ t) (ht1 : t ≤ 1) : 0 ≤ (1 + t) * Real.log (1 + t) - t * Real.log t - 2 * t * Real.log 2 := by let g : ℝ → ℝ := fun x => (1 + x) * Real.log (1 + x) - x * Real.log x - 2 * x * Real.log 2 have hg_cont : Continuous g := by have h1 : Continuous (fun x : ℝ => (1 + x) * Real.log (1 + x)) := Real.continuous_mul_log.comp (continuous_const.add continuous_id) have h2 : Continuous (fun x : ℝ => x * Real.log x) := Real.continuous_mul_log have h3 : Continuous (fun x : ℝ => 2 * x * Real.log 2) := by fun_prop exact (h1.sub h2).sub h3 have hg_deriv : ∀ x : ℝ, 0 < x → HasDerivAt g (Real.log ((1 + x) / (4 * x))) x := by intro x hx have hx1 : 0 < 1 + x := by linarith have hd1 : HasDerivAt (fun y : ℝ => (1 + y) * Real.log (1 + y)) (Real.log (1 + x) + 1) x := by have ha : HasDerivAt (fun y : ℝ => 1 + y) 1 x := (hasDerivAt_id x).const_add 1 have hb : HasDerivAt (fun y : ℝ => Real.log (1 + y)) ((1 + x)⁻¹ * 1) x := (Real.hasDerivAt_log hx1.ne').comp x ha have hmul := ha.mul hb have hmul_eq : 1 * Real.log (1 + x) + (1 + x) * ((1 + x)⁻¹ * 1) = Real.log (1 + x) + 1 := by rw [one_mul, mul_one, mul_inv_cancel₀ hx1.ne'] rwa [hmul_eq] at hmul have hd2 : HasDerivAt (fun y : ℝ => y * Real.log y) (Real.log x + 1) x := by have ha : HasDerivAt (fun y : ℝ => y) 1 x := hasDerivAt_id x have hb : HasDerivAt Real.log x⁻¹ x := Real.hasDerivAt_log hx.ne' have hmul := ha.mul hb have hmul_eq : 1 * Real.log x + x * x⁻¹ = Real.log x + 1 := by rw [one_mul, mul_inv_cancel₀ hx.ne'] rwa [hmul_eq] at hmul have hd3 : HasDerivAt (fun y : ℝ => 2 * y * Real.log 2) (2 * Real.log 2) x := by have ha : HasDerivAt (fun y : ℝ => 2 * y) 2 x := by simpa using (hasDerivAt_id x).const_mul (2 : ℝ) simpa using ha.mul_const (Real.log 2) have hsub : HasDerivAt g (Real.log (1 + x) + 1 - (Real.log x + 1) - 2 * Real.log 2) x := (hd1.sub hd2).sub hd3 have hderiv_eq : Real.log ((1 + x) / (4 * x)) = Real.log (1 + x) + 1 - (Real.log x + 1) - 2 * Real.log 2 := by rw [Real.log_div hx1.ne' (by positivity), Real.log_mul (by norm_num) hx.ne'] have hlog4 : Real.log (4 : ℝ) = 2 * Real.log 2 := by rw [show (4 : ℝ) = 2 ^ 2 by norm_num, Real.log_pow]; push_cast; ring rw [hlog4]; ring rwa [← hderiv_eq] at hsub have hg0 : g 0 = 0 := by simp [g] have hg1 : g 1 = 0 := by dsimp only [g]; norm_num by_cases hle : t ≤ 1 / 3 · have hmono : MonotoneOn g (Set.Icc 0 (1 / 3)) := by refine monotoneOn_of_deriv_nonneg (convex_Icc _ _) hg_cont.continuousOn ?_ ?_ · intro x hx rw [interior_Icc] at hx exact (hg_deriv x hx.1).differentiableAt.differentiableWithinAt · intro x hx rw [interior_Icc] at hx have hxpos : 0 < x := hx.1 rw [(hg_deriv x hxpos).deriv] apply Real.log_nonneg rw [one_le_div (by positivity)] linarith [hx.2] have := hmono ⟨le_rfl, by norm_num⟩ ⟨ht0, hle⟩ ht0 linarith [hg0] · push Not at hle have hanti : AntitoneOn g (Set.Icc (1 / 3) 1) := by refine antitoneOn_of_deriv_nonpos (convex_Icc _ _) hg_cont.continuousOn ?_ ?_ · intro x hx rw [interior_Icc] at hx exact (hg_deriv x (by linarith [hx.1])).differentiableAt.differentiableWithinAt · intro x hx rw [interior_Icc] at hx have hxpos : 0 < x := by linarith [hx.1] have hx1 : 0 < 1 + x := by linarith rw [(hg_deriv x hxpos).deriv] apply Real.log_nonpos (by positivity) rw [div_le_one (by positivity)] linarith [hx.1] have := hanti ⟨hle.le, ht1⟩ ⟨by norm_num, le_rfl⟩ ht1 linarith [hg1] /-- Key 2-point induction inequality for Harper's hypercube edge-isoperimetric theorem: for `0 ≤ a, b ≤ 1`, letting `h(x) = -x log₂ x`, `h((a + b) / 2) ≤ (h(a) + h(b)) / 2 + |a - b| / 2`. -/ lemma edgeIso_two_point {a b : ℝ} (ha0 : 0 ≤ a) (ha1 : a ≤ 1) (hb0 : 0 ≤ b) (hb1 : b ≤ 1) : -((a + b) / 2 * Real.logb 2 ((a + b) / 2)) ≤ (-(a * Real.logb 2 a) + -(b * Real.logb 2 b)) / 2 + |a - b| / 2 := by -- Reduce by symmetry to `a ≤ b`: wlog hab : a ≤ b generalizing a b · push Not at hab have := this hb0 hb1 ha0 ha1 hab.le rw [add_comm b a, add_comm (-(b * Real.logb 2 b)), abs_sub_comm] at this exact this rw [abs_of_nonpos (sub_nonpos.mpr hab), neg_sub] by_cases hb : b = 0 · have ha : a = 0 := le_antisymm (hb ▸ hab) ha0 subst ha hb; simp · have hb_pos : 0 < b := lt_of_le_of_ne hb0 (Ne.symm hb) let t : ℝ := a / b have ht0 : 0 ≤ t := div_nonneg ha0 hb_pos.le have ht1 : t ≤ 1 := (div_le_one hb_pos).mpr hab have haux := edgeIso_aux_nonneg ht0 ht1 have hlog2 : 0 < Real.log 2 := Real.log_pos (by norm_num) -- Multiply `haux` by `b / (2 * ln 2) > 0` and substitute `a = t * b`: have ha_eq : a = t * b := (div_mul_cancel₀ a hb_pos.ne').symm have hscale := mul_nonneg (show 0 ≤ b / (2 * Real.log 2) by positivity) haux -- Expand in terms of `Real.log` via `Real.logb 2 x = Real.log x / Real.log 2`: unfold Real.logb have h1t_pos : 0 < 1 + t := by linarith have hab_eq : (a + b) / 2 = b * ((1 + t) / 2) := by rw [ha_eq]; ring have hlog_ab : Real.log ((a + b) / 2) = Real.log b + Real.log (1 + t) - Real.log 2 := by rw [hab_eq, Real.log_mul hb_pos.ne' (by positivity), Real.log_div h1t_pos.ne' (by norm_num)] ring have hlog_a : a * Real.log a = t * b * (Real.log t + Real.log b) := by by_cases ht : t = 0 · have : a = 0 := by rw [ha_eq, ht, zero_mul] simp [ht, this] · rw [ha_eq, Real.log_mul ht hb_pos.ne'] have hident : (-(a * (Real.log a / Real.log 2)) + -(b * (Real.log b / Real.log 2))) / 2 + (b - a) / 2 - -((a + b) / 2 * (Real.log ((a + b) / 2) / Real.log 2)) = b / (2 * Real.log 2) * ((1 + t) * Real.log (1 + t) - t * Real.log t - 2 * t * Real.log 2) := by have ha_rew : a * (Real.log a / Real.log 2) = (a * Real.log a) / Real.log 2 := by ring rw [ha_rew, hlog_a, hlog_ab, ha_eq] field_simp [hlog2.ne'] ring linarith /-- **Hypercube Edge-Isoperimetric Inequality (Harper / Hart 1976, completely self-contained)**: For every `m : ℕ` and every subset `A : Finset (Fin m → Bool)`, letting `μ = |A| / 2^m` and `indA x = if x ∈ A then 1 else 0`, the total edge boundary (combinatorial total influence of `indA`) satisfies `2 * (-μ * log₂ μ) ≤ totalInfluence indA`. -/ theorem hypercube_edge_isoperimetric : ∀ (m : ℕ) (A : Finset (Fin m → Bool)), let μ : ℝ := (A.card : ℝ) / (2 : ℝ) ^ m 2 * (-(μ * Real.logb 2 μ)) ≤ totalInfluence (fun x : Fin m → Bool => if x ∈ A then (1 : ℝ) else 0) := by intro m induction m with | zero => intro A μ have hcard_le : A.card ≤ 1 := by have := Finset.card_le_univ A simpa [Fintype.card_fun] using this have hμ01 : μ = 0 ∨ μ = 1 := by have h01 : A.card = 0 ∨ A.card = 1 := by omega rcases h01 with h | h <;> simp [μ, h] rcases hμ01 with h | h <;> simp [h, totalInfluence] | succ m ih => intro A μ let indA : (Fin (m + 1) → Bool) → ℝ := fun x => if x ∈ A then 1 else 0 -- Split `A` along coordinate `0 : Fin (m + 1)` into `A₀` (`x 0 = false`) and `A₁` (`x 0 = true`)! let A₀ : Finset (Fin m → Bool) := Finset.univ.filter fun u => Fin.cons false u ∈ A let A₁ : Finset (Fin m → Bool) := Finset.univ.filter fun u => Fin.cons true u ∈ A let a : ℝ := (A₀.card : ℝ) / (2 : ℝ) ^ m let b : ℝ := (A₁.card : ℝ) / (2 : ℝ) ^ m have ha0 : 0 ≤ a := by positivity have hb0 : 0 ≤ b := by positivity have ha1 : a ≤ 1 := by dsimp only [a]; rw [div_le_one (by positivity)] have := Finset.card_le_univ A₀ simpa [Fintype.card_fun, Fintype.card_bool, Fintype.card_fin] using (show (A₀.card : ℝ) ≤ (2 : ℝ) ^ m by exact_mod_cast (by simpa [Fintype.card_fun, Fintype.card_bool, Fintype.card_fin] using this)) have hb1 : b ≤ 1 := by dsimp only [b]; rw [div_le_one (by positivity)] have := Finset.card_le_univ A₁ exact_mod_cast (by simpa [Fintype.card_fun, Fintype.card_bool, Fintype.card_fin] using this) -- Show `μ = (a + b) / 2`: have hcard_split : A.card = A₀.card + A₁.card := by let eCons : Bool × (Fin m → Bool) ≃ (Fin (m + 1) → Bool) := { toFun := fun p => Fin.cons p.1 p.2 invFun := fun x => (x 0, Fin.tail x) left_inv := fun ⟨b, u⟩ => by simp right_inv := fun x => by simp } have h1 : A.card = (Finset.univ.filter fun p : Bool × (Fin m → Bool) => Fin.cons p.1 p.2 ∈ A).card := by refine Finset.card_bij (fun x _ => (x 0, Fin.tail x)) ?_ ?_ ?_ · intro x hx; exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, by simpa using hx⟩ · intro x₁ _ x₂ _ h have h0 : x₁ 0 = x₂ 0 := congrArg Prod.fst h have ht : Fin.tail x₁ = Fin.tail x₂ := congrArg Prod.snd h rw [← Fin.cons_self_tail x₁, ← Fin.cons_self_tail x₂, h0, ht] · intro p hp exact ⟨Fin.cons p.1 p.2, (Finset.mem_filter.mp hp).2, by simp⟩ rw [h1] let embF : (Fin m → Bool) ↪ Bool × (Fin m → Bool) := ⟨fun u => (false, u), fun _ _ h => (Prod.mk.inj h).2⟩ let embT : (Fin m → Bool) ↪ Bool × (Fin m → Bool) := ⟨fun u => (true, u), fun _ _ h => (Prod.mk.inj h).2⟩ have hdisj : Disjoint (A₀.map embF) (A₁.map embT) := by rw [Finset.disjoint_left]; intro p h1 h2 rcases Finset.mem_map.mp h1 with ⟨_, _, rfl⟩ rcases Finset.mem_map.mp h2 with ⟨_, _, h⟩ exact Bool.false_ne_true (Prod.mk.inj h).1.symm have hunion : (Finset.univ.filter fun p : Bool × (Fin m → Bool) => Fin.cons p.1 p.2 ∈ A) = A₀.map embF ∪ A₁.map embT := by ext ⟨c, u⟩ cases c with | false => simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_union, Finset.mem_map, A₀, A₁] constructor · intro h; left; exact ⟨u, h, rfl⟩ · rintro (⟨a, ha, heq⟩ | ⟨_, _, heq⟩) · have := (Prod.mk.inj heq).2; subst this; exact ha · exact (Bool.false_ne_true (Prod.mk.inj heq).1.symm).elim | true => simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_union, Finset.mem_map, A₀, A₁] constructor · intro h; right; exact ⟨u, h, rfl⟩ · rintro (⟨_, _, heq⟩ | ⟨a, ha, heq⟩) · exact (Bool.false_ne_true (Prod.mk.inj heq).1).elim · have := (Prod.mk.inj heq).2; subst this; exact ha rw [hunion, Finset.card_union_of_disjoint hdisj, Finset.card_map, Finset.card_map] have hμ_eq : μ = (a + b) / 2 := by dsimp only [μ, a, b] rw [hcard_split, Nat.cast_add, pow_succ] ring -- Lower-bound `coordInfluence indA 0 ≥ |a - b|`: have hinf0 : |a - b| ≤ coordInfluence indA 0 := by unfold coordInfluence have hcard_fin : Fintype.card (Fin (m + 1)) = m + 1 := Fintype.card_fin _ rw [hcard_fin] -- Each `u` with `u ∈ A₀ ↔ u ∉ A₁` contributes `2` flips along coordinate `0`! let eCons : Bool × (Fin m → Bool) ≃ (Fin (m + 1) → Bool) := { toFun := fun p => Fin.cons p.1 p.2 invFun := fun x => (x 0, Fin.tail x) left_inv := fun ⟨_, _⟩ => by simp right_inv := fun x => by simp } have hsum0 : ∑ x : Fin (m + 1) → Bool, (if indA x ≠ indA (flipBit x 0) then (1 : ℝ) else 0) = 2 * ∑ u : Fin m → Bool, (if (u ∈ A₀) ≠ (u ∈ A₁) then (1 : ℝ) else 0) := by rw [Fintype.sum_equiv eCons.symm _ (fun p : Bool × (Fin m → Bool) => if indA (Fin.cons p.1 p.2) ≠ indA (flipBit (Fin.cons p.1 p.2) 0) then (1 : ℝ) else 0) (fun x => by simp [eCons])] rw [Fintype.sum_prod_type, Fintype.sum_bool] have hflip_t : ∀ u : Fin m → Bool, flipBit (Fin.cons true u) 0 = Fin.cons false u := by intro u; ext j; refine Fin.cases ?_ ?_ j <;> simp [flipBit] have hflip_f : ∀ u : Fin m → Bool, flipBit (Fin.cons false u) 0 = Fin.cons true u := by intro u; ext j; refine Fin.cases ?_ ?_ j <;> simp [flipBit] have h1 : ∀ u : Fin m → Bool, (if indA (Fin.cons true u) ≠ indA (flipBit (Fin.cons true u) 0) then (1 : ℝ) else 0) = (if (u ∈ A₀) ≠ (u ∈ A₁) then (1 : ℝ) else 0) := by intro u; rw [hflip_t]; dsimp only [indA] by_cases h0 : Fin.cons false u ∈ A <;> by_cases h1 : Fin.cons true u ∈ A <;> simp [A₀, A₁, h0, h1] have h2 : ∀ u : Fin m → Bool, (if indA (Fin.cons false u) ≠ indA (flipBit (Fin.cons false u) 0) then (1 : ℝ) else 0) = (if (u ∈ A₀) ≠ (u ∈ A₁) then (1 : ℝ) else 0) := by intro u; rw [hflip_f]; dsimp only [indA] by_cases h0 : Fin.cons false u ∈ A <;> by_cases h1 : Fin.cons true u ∈ A <;> simp [A₀, A₁, h0, h1] simp_rw [h1, h2]; ring rw [hsum0, pow_succ, mul_comm (2 : ℝ) (∑ u : Fin m → Bool, _), mul_div_mul_right _ _ (by norm_num : (2 : ℝ) ≠ 0)] -- Compare `|A₀.card - A₁.card| ≤ ∑ u, [u ∈ A₀ ≠ u ∈ A₁]`: have hdiff_le : |(A₀.card : ℝ) - (A₁.card : ℝ)| ≤ ∑ u : Fin m → Bool, (if (u ∈ A₀) ≠ (u ∈ A₁) then (1 : ℝ) else 0) := by have hrew : (A₀.card : ℝ) - (A₁.card : ℝ) = ∑ u : Fin m → Bool, ((if u ∈ A₀ then (1 : ℝ) else 0) - (if u ∈ A₁ then (1 : ℝ) else 0)) := by rw [Finset.sum_sub_distrib, ← Finset.sum_filter, ← Finset.sum_filter] have hf0 : Finset.univ.filter (fun u : Fin m → Bool => u ∈ A₀) = A₀ := by ext u; simp have hf1 : Finset.univ.filter (fun u : Fin m → Bool => u ∈ A₁) = A₁ := by ext u; simp rw [hf0, hf1, Finset.sum_const, Finset.sum_const, nsmul_eq_mul, nsmul_eq_mul, mul_one, mul_one] rw [hrew] refine (Finset.abs_sum_le_sum_abs _ _).trans (Finset.sum_le_sum fun u _ => ?_) by_cases h0 : u ∈ A₀ <;> by_cases h1 : u ∈ A₁ <;> simp [h0, h1] dsimp only [a, b] rw [← sub_div, abs_div, abs_of_pos (by positivity : (0 : ℝ) < (2 : ℝ) ^ m)] exact div_le_div_of_nonneg_right hdiff_le (by positivity) -- Show `∑ i : Fin m, coordInfluence indA i.succ = (totalInfluence indA₀ + totalInfluence indA₁) / 2`: have hinf_tail : ∑ i : Fin m, coordInfluence indA i.succ = (totalInfluence (fun u : Fin m → Bool => if u ∈ A₀ then (1 : ℝ) else 0) + totalInfluence (fun u : Fin m → Bool => if u ∈ A₁ then (1 : ℝ) else 0)) / 2 := by unfold totalInfluence rw [← Finset.sum_add_distrib, Finset.sum_div] refine Finset.sum_congr rfl fun i _ => ?_ unfold coordInfluence simp only [Fintype.card_fin] let eCons : Bool × (Fin m → Bool) ≃ (Fin (m + 1) → Bool) := { toFun := fun p => Fin.cons p.1 p.2 invFun := fun x => (x 0, Fin.tail x) left_inv := fun ⟨_, _⟩ => by simp right_inv := fun x => by simp } have hflip_succ : ∀ (c : Bool) (u : Fin m → Bool), flipBit (Fin.cons c u) i.succ = Fin.cons c (flipBit u i) := by intro c u; ext j refine Fin.cases ?_ ?_ j · simp [flipBit, (Fin.succ_ne_zero i).symm] · intro k by_cases hk : k = i · subst hk; simp [flipBit] · have hne : k.succ ≠ i.succ := fun h => hk (Fin.succ_inj.mp h) simp [flipBit, hk, hne] have hsum_s : ∑ x : Fin (m + 1) → Bool, (if indA x ≠ indA (flipBit x i.succ) then (1 : ℝ) else 0) = (∑ u : Fin m → Bool, if (if u ∈ A₀ then (1 : ℝ) else 0) ≠ (if flipBit u i ∈ A₀ then (1 : ℝ) else 0) then (1 : ℝ) else 0) + (∑ u : Fin m → Bool, if (if u ∈ A₁ then (1 : ℝ) else 0) ≠ (if flipBit u i ∈ A₁ then (1 : ℝ) else 0) then (1 : ℝ) else 0) := by rw [Fintype.sum_equiv eCons.symm _ (fun p : Bool × (Fin m → Bool) => if indA (Fin.cons p.1 p.2) ≠ indA (flipBit (Fin.cons p.1 p.2) i.succ) then (1 : ℝ) else 0) (fun x => by simp [eCons])] rw [Fintype.sum_prod_type, Fintype.sum_bool, add_comm] simp_rw [hflip_succ] congr 1 <;> refine Finset.sum_congr rfl fun u _ => by simp [indA, A₀, A₁] rw [hsum_s, pow_succ] ring -- Combine via `Fin.sum_univ_succ`, `ih A₀`, `ih A₁`, and `edgeIso_two_point`! have htot_eq : totalInfluence indA = coordInfluence indA 0 + ∑ i : Fin m, coordInfluence indA i.succ := Fin.sum_univ_succ (fun i => coordInfluence indA i) have hstep := edgeIso_two_point ha0 ha1 hb0 hb1 have ih0 := ih A₀ have ih1 := ih A₁ rw [hμ_eq] rw [htot_eq, hinf_tail] linarith /-- Generalized partition-selector Boolean function on `Fin m ⊕ Fin R → Bool`: given ANY partition `part : (Fin m → Bool) → Fin R`, `partSelector part (x, y) = boolSign (y (part x))`. -/ def partSelector {m R : ℕ} (part : (Fin m → Bool) → Fin R) (z : (Fin m ⊕ Fin R) → Bool) : ℝ := boolSign (z (Sum.inr (part (fun i => z (Sum.inl i))))) lemma partSelector_isBoolean {m R : ℕ} (part : (Fin m → Bool) → Fin R) : IsBoolean (partSelector part) := by intro z; unfold partSelector; cases z (Sum.inr (part (fun i => z (Sum.inl i)))) <;> simp [boolSign] /-- Equivalence splitting `Fin m ⊕ Fin R → Bool` into `(Fin m → Bool) × (Fin R → Bool)`. -/ def partSplitEquiv (m R : ℕ) : ((Fin m ⊕ Fin R) → Bool) ≃ (Fin m → Bool) × (Fin R → Bool) where toFun z := (fun i => z (Sum.inl i), fun a => z (Sum.inr a)) invFun p := Sum.elim p.1 p.2 left_inv z := by ext s; cases s <;> rfl right_inv p := by rcases p with ⟨x, y⟩; rfl /-- Exact Fourier–Walsh coefficient of `partSelector part`: nonzero only when `S_y = {a}`, in which case it equals `fourierCoeff (1_{part⁻¹(a)}) S_x`. -/ theorem partSelector_fourierCoeff {m R : ℕ} (part : (Fin m → Bool) → Fin R) (S : Finset (Fin m ⊕ Fin R)) : let Sx : Finset (Fin m) := Finset.univ.filter fun i => Sum.inl i ∈ S let Sy : Finset (Fin R) := Finset.univ.filter fun a => Sum.inr a ∈ S fourierCoeff (partSelector part) S = if h : ∃ a : Fin R, Sy = {a} then fourierCoeff (fun x : Fin m → Bool => if part x = h.choose then (1 : ℝ) else 0) Sx else 0 := by intro Sx Sy unfold fourierCoeff have hcard : Fintype.card (Fin m ⊕ Fin R) = m + R := by simp have hsum_split : ∑ z : (Fin m ⊕ Fin R) → Bool, partSelector part z * walsh S z = ∑ x : Fin m → Bool, walsh Sx x * ∑ y : Fin R → Bool, boolSign (y (part x)) * walsh Sy y := by rw [Fintype.sum_equiv (partSplitEquiv m R) _ (fun p => boolSign (p.2 (part p.1)) * (walsh Sx p.1 * walsh Sy p.2))] · rw [Fintype.sum_prod_type] refine Finset.sum_congr rfl fun x _ => ?_ rw [Finset.mul_sum] refine Finset.sum_congr rfl fun y _ => by ring · intro z dsimp only [partSplitEquiv, Equiv.coe_fn_mk, partSelector] congr 1 unfold walsh have hpart : S = Sx.map ⟨Sum.inl, Sum.inl_injective⟩ ∪ Sy.map ⟨Sum.inr, Sum.inr_injective⟩ := by ext s; cases s with | inl i => simp [Sx, Sy] | inr a => simp [Sx, Sy] have hdisj : Disjoint (Sx.map ⟨Sum.inl, Sum.inl_injective⟩) (Sy.map ⟨Sum.inr, Sum.inr_injective⟩) := by rw [Finset.disjoint_left]; intro s h1 h2 rcases Finset.mem_map.mp h1 with ⟨_, _, rfl⟩ rcases Finset.mem_map.mp h2 with ⟨_, _, h⟩ exact Sum.inl_ne_inr h.symm rw [hpart, Finset.prod_union hdisj, Finset.prod_map, Finset.prod_map] rfl rw [hsum_split] have hinner : ∀ x : Fin m → Bool, ∑ y : Fin R → Bool, boolSign (y (part x)) * walsh Sy y = if ({part x} : Finset (Fin R)) = Sy then (2 : ℝ) ^ R else 0 := by intro x have h1 : ∀ y : Fin R → Bool, boolSign (y (part x)) = walsh ({part x} : Finset (Fin R)) y := by intro y; simp [walsh] simp_rw [h1, walsh_ortho, Fintype.card_fin] simp_rw [hinner] rw [hcard, pow_add] by_cases h : ∃ a : Fin R, Sy = {a} · simp only [h, ↓reduceDIte] set a := h.choose have ha : Sy = {a} := h.choose_spec rw [Fintype.card_fin] have hsum_x : (∑ x : Fin m → Bool, walsh Sx x * if ({part x} : Finset (Fin R)) = Sy then (2 : ℝ) ^ R else 0) = (∑ x : Fin m → Bool, (if part x = a then (1 : ℝ) else 0) * walsh Sx x) * (2 : ℝ) ^ R := by rw [Finset.sum_mul] refine Finset.sum_congr rfl fun x _ => ?_ have hiff : ({part x} : Finset (Fin R)) = Sy ↔ part x = a := by rw [ha]; simp by_cases hx : part x = a · rw [if_pos (hiff.mpr hx), if_pos hx]; ring · rw [if_neg (fun h' => hx (hiff.mp h')), if_neg hx]; ring rw [hsum_x, mul_div_mul_right _ _ (by positivity)] · simp only [h, ↓reduceDIte] have hzero : ∀ x : Fin m → Bool, ({part x} : Finset (Fin R)) ≠ Sy := fun x heq => h ⟨part x, heq.symm⟩ simp [hzero] /-- Exact maximum squared Fourier coefficient of any partition selector: `maxFourierSq (partSelector part) = max_{a} μ(part⁻¹(a))²`. -/ theorem partSelector_maxFourierSq {m R : ℕ} (hR : 1 ≤ R) (part : (Fin m → Bool) → Fin R) : have : Nonempty (Fin R) := ⟨⟨0, hR⟩⟩ maxFourierSq (partSelector part) = Finset.univ.sup' Finset.univ_nonempty (fun a : Fin R => (((Finset.univ.filter fun x => part x = a).card : ℝ) / (2 : ℝ) ^ m) ^ 2) := by have : Nonempty (Fin R) := ⟨⟨0, hR⟩⟩ apply le_antisymm · rw [maxFourierSq_le_iff] intro S rw [partSelector_fourierCoeff] split_ifs with h · let a := h.choose have htri : |fourierCoeff (fun x : Fin m → Bool => if part x = a then (1 : ℝ) else 0) (Finset.univ.filter fun i => Sum.inl i ∈ S)| ≤ ((Finset.univ.filter fun x => part x = a).card : ℝ) / (2 : ℝ) ^ m := by unfold fourierCoeff rw [Fintype.card_fin, abs_div, abs_of_pos (show (0 : ℝ) < (2 : ℝ) ^ m by positivity)] refine div_le_div_of_nonneg_right ?_ (show (0 : ℝ) ≤ (2 : ℝ) ^ m by positivity) calc |∑ x : Fin m → Bool, (if part x = a then (1 : ℝ) else 0) * walsh _ x| ≤ ∑ x : Fin m → Bool, |(if part x = a then (1 : ℝ) else 0) * walsh _ x| := Finset.abs_sum_le_sum_abs _ _ _ = ∑ x : Fin m → Bool, if part x = a then (1 : ℝ) else 0 := by refine Finset.sum_congr rfl fun x _ => ?_ rw [abs_mul, walsh_abs, mul_one]; split_ifs <;> simp _ = ((Finset.univ.filter fun x => part x = a).card : ℝ) := by rw [← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul, mul_one] have hsq : fourierCoeff (fun x : Fin m → Bool => if part x = a then (1 : ℝ) else 0) (Finset.univ.filter fun i => Sum.inl i ∈ S) ^ 2 ≤ (((Finset.univ.filter fun x => part x = a).card : ℝ) / (2 : ℝ) ^ m) ^ 2 := by exact sq_le_sq.mpr (by rw [abs_of_nonneg (show (0 : ℝ) ≤ ((Finset.univ.filter fun x => part x = a).card : ℝ) / (2 : ℝ) ^ m by positivity)] exact htri) exact hsq.trans (Finset.le_sup' (f := fun b : Fin R => (((Finset.univ.filter fun x => part x = b).card : ℝ) / (2 : ℝ) ^ m) ^ 2) (Finset.mem_univ a)) · rw [zero_pow (by norm_num)] exact le_trans (sq_nonneg _) (Finset.le_sup' (f := fun b : Fin R => (((Finset.univ.filter fun x => part x = b).card : ℝ) / (2 : ℝ) ^ m) ^ 2) (Finset.mem_univ ⟨0, hR⟩)) · rw [Finset.sup'_le_iff] intro a _ let Sa : Finset (Fin m ⊕ Fin R) := {Sum.inr a} have hle := fourierCoeff_sq_le_maxFourierSq (partSelector part) Sa refine le_trans ?_ hle rw [partSelector_fourierCoeff] have hex : ∃ b : Fin R, (Finset.univ.filter fun c : Fin R => Sum.inr c ∈ Sa) = {b} := ⟨a, by ext c; simp [Sa]⟩ simp only [hex, ↓reduceDIte] have hch : hex.choose = a := by have h1 : ({hex.choose} : Finset (Fin R)) = {a} := by rw [← hex.choose_spec]; ext c; simp [Sa] exact Finset.singleton_injective h1 have hSx : (Finset.univ.filter fun i : Fin m => Sum.inl i ∈ Sa) = ∅ := by ext i; simp [Sa] rw [hch, hSx] unfold fourierCoeff simp only [walsh_empty, mul_one, Fintype.card_fin] rw [← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul, mul_one] /-- Exact total influence decomposition of any partition selector: `I(partSelector part) = 1 + (1 / 4) * ∑_{a : Fin R} I(1_{part⁻¹(a)})`. -/ theorem partSelector_totalInfluence {m R : ℕ} (part : (Fin m → Bool) → Fin R) : totalInfluence (partSelector part) = 1 + (1 / 4 : ℝ) * ∑ a : Fin R, totalInfluence (fun x : Fin m → Bool => if part x = a then (1 : ℝ) else 0) := by unfold totalInfluence rw [Fintype.sum_sum_type] -- Part 1: Sum of influences of data coordinates `Sum.inr a` equals `1`: have hdata : ∑ a : Fin R, coordInfluence (partSelector part) (Sum.inr a) = 1 := by have hcoord_a : ∀ a : Fin R, coordInfluence (partSelector part) (Sum.inr a) = ((Finset.univ.filter fun x : Fin m → Bool => part x = a).card : ℝ) / (2 : ℝ) ^ m := by intro a unfold coordInfluence have hcard : Fintype.card (Fin m ⊕ Fin R) = m + R := by simp rw [hcard] have hsum : ∑ z : (Fin m ⊕ Fin R) → Bool, (if partSelector part z ≠ partSelector part (flipBit z (Sum.inr a)) then (1 : ℝ) else 0) = ((Finset.univ.filter fun x : Fin m → Bool => part x = a).card : ℝ) * (2 : ℝ) ^ R := by rw [Fintype.sum_equiv (partSplitEquiv m R) _ (fun p : (Fin m → Bool) × (Fin R → Bool) => if part p.1 = a then (1 : ℝ) else 0)] · rw [Fintype.sum_prod_type] have hinner : ∀ x : Fin m → Bool, ∑ _y : Fin R → Bool, (if part x = a then (1 : ℝ) else 0) = (2 : ℝ) ^ R * (if part x = a then (1 : ℝ) else 0) := fun x => by rw [Finset.sum_const, Finset.card_univ, Fintype.card_fun, Fintype.card_bool, Fintype.card_fin, nsmul_eq_mul, Nat.cast_pow, Nat.cast_ofNat] simp_rw [hinner] rw [← Finset.mul_sum, ← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul, mul_one, mul_comm] · intro z have hfx : (fun i : Fin m => flipBit z (Sum.inr a) (Sum.inl i)) = (fun i => z (Sum.inl i)) := by ext i; exact flipBit_apply_ne z Sum.inl_ne_inr have hval : partSelector part (flipBit z (Sum.inr a)) = boolSign (flipBit z (Sum.inr a) (Sum.inr (part (fun i => z (Sum.inl i))))) := by unfold partSelector; rw [hfx] by_cases hpa : part ((partSplitEquiv m R) z).1 = a · have hpa' : part (fun i => z (Sum.inl i)) = a := hpa have h1 : partSelector part z = boolSign (z (Sum.inr a)) := by unfold partSelector; rw [hpa'] have h2 : partSelector part (flipBit z (Sum.inr a)) = boolSign (!z (Sum.inr a)) := by rw [hval, hpa', flipBit_apply_self] have hne : partSelector part z ≠ partSelector part (flipBit z (Sum.inr a)) := by rw [h1, h2]; cases z (Sum.inr a) <;> norm_num [boolSign] rw [if_pos hne, if_pos hpa] · have hpa' : part (fun i => z (Sum.inl i)) ≠ a := hpa have h2 : partSelector part (flipBit z (Sum.inr a)) = partSelector part z := by rw [hval, flipBit_apply_ne z (fun h => hpa' (Sum.inr.inj h))]; rfl rw [if_neg (by rw [h2]; exact not_not.mpr rfl), if_neg hpa] rw [hsum, pow_add, mul_div_mul_right _ _ (by positivity)] simp_rw [hcoord_a, ← Finset.sum_div] have hpart_sum : ∑ a : Fin R, ((Finset.univ.filter fun x : Fin m → Bool => part x = a).card : ℝ) = (2 : ℝ) ^ m := by rw [← Nat.cast_sum] have hnat : ∑ a : Fin R, (Finset.univ.filter fun x : Fin m → Bool => part x = a).card = 2 ^ m := by rw [← Finset.card_biUnion] · have : (Finset.univ : Finset (Fin R)).biUnion (fun a => Finset.univ.filter fun x => part x = a) = Finset.univ := by ext x; simp rw [this, Finset.card_univ, Fintype.card_fun, Fintype.card_bool, Fintype.card_fin] · intro a _ b _ hab change Disjoint _ _ rw [Finset.disjoint_left] intro x hx1 hx2 exact hab ((Finset.mem_filter.mp hx1).2.symm.trans (Finset.mem_filter.mp hx2).2) exact_mod_cast hnat rw [hpart_sum, div_self (by positivity)] -- Part 2: Sum of influences of address coordinates `Sum.inl i` equals `(1/4) * ∑_a I(1_{part⁻¹(a)})`: have haddr : ∑ i : Fin m, coordInfluence (partSelector part) (Sum.inl i) = (1 / 4 : ℝ) * ∑ a : Fin R, ∑ i : Fin m, coordInfluence (fun x : Fin m → Bool => if part x = a then (1 : ℝ) else 0) i := by rw [Finset.sum_comm, Finset.mul_sum] refine Finset.sum_congr rfl fun i _ => ?_ unfold coordInfluence have hcard : Fintype.card (Fin m ⊕ Fin R) = m + R := by simp rw [hcard] simp_rw [Fintype.card_fin, ← Finset.sum_div] -- Count `(x, y)` where `y (part x) ≠ y (part (flipBit x i))`: -- If `part x = part (flipBit x i)`, count over `y` is `0`; if `part x ≠ part (flipBit x i)`, count is `2^(R - 1)`! have hsum_i : ∑ z : (Fin m ⊕ Fin R) → Bool, (if partSelector part z ≠ partSelector part (flipBit z (Sum.inl i)) then (1 : ℝ) else 0) = (∑ x : Fin m → Bool, if part x ≠ part (flipBit x i) then (1 : ℝ) else 0) * ((2 : ℝ) ^ R / 2) := by rw [Fintype.sum_equiv (partSplitEquiv m R) _ (fun p : (Fin m → Bool) × (Fin R → Bool) => if boolSign (p.2 (part p.1)) ≠ boolSign (p.2 (part (flipBit p.1 i))) then (1 : ℝ) else 0)] · rw [Fintype.sum_prod_type, Finset.sum_mul] refine Finset.sum_congr rfl fun x _ => ?_ by_cases hpeq : part x = part (flipBit x i) · simp [hpeq] · rw [if_pos hpeq, one_mul] -- Half of all `y : Fin R → Bool` satisfy `y a ≠ y b` when `a ≠ b`: let a := part x let b := part (flipBit x i) have hab : a ≠ b := hpeq have hhalf : 2 * ∑ y : Fin R → Bool, (if boolSign (y a) ≠ boolSign (y b) then (1 : ℝ) else 0) = (2 : ℝ) ^ R := by have hflip : ∑ y : Fin R → Bool, (if boolSign (y a) ≠ boolSign (y b) then (1 : ℝ) else 0) = ∑ y : Fin R → Bool, (if boolSign (y a) = boolSign (y b) then (1 : ℝ) else 0) := by refine Fintype.sum_equiv (Equiv.ofBijective (fun y => flipBit y a) (flipBit_involutive a).bijective) _ _ fun y => ?_ rw [Equiv.ofBijective_apply, flipBit_apply_self, flipBit_apply_ne y hab.symm] cases y a <;> cases y b <;> norm_num [boolSign] have htot : ∑ y : Fin R → Bool, (if boolSign (y a) ≠ boolSign (y b) then (1 : ℝ) else 0) + ∑ y : Fin R → Bool, (if boolSign (y a) = boolSign (y b) then (1 : ℝ) else 0) = (2 : ℝ) ^ R := by rw [← Finset.sum_add_distrib] have h1 : ∀ y : Fin R → Bool, (if boolSign (y a) ≠ boolSign (y b) then (1 : ℝ) else 0) + (if boolSign (y a) = boolSign (y b) then (1 : ℝ) else 0) = 1 := by intro y; by_cases h : boolSign (y a) = boolSign (y b) <;> simp [h] rw [Finset.sum_congr rfl fun y _ => h1 y, Finset.sum_const, Finset.card_univ, Fintype.card_fun, Fintype.card_bool, Fintype.card_fin, nsmul_eq_mul, mul_one, Nat.cast_pow, Nat.cast_ofNat] linarith dsimp only [a, b] at hhalf linarith · intro z dsimp only [partSplitEquiv, Equiv.coe_fn_mk] have hfx : (fun k : Fin m => flipBit z (Sum.inl i) (Sum.inl k)) = flipBit (fun k : Fin m => z (Sum.inl k)) i := by ext k; by_cases hk : k = i · subst hk; simp · have hne : (Sum.inl k : Fin m ⊕ Fin R) ≠ Sum.inl i := fun h => hk (Sum.inl.inj h) simp [hk, hne] have hval : partSelector part (flipBit z (Sum.inl i)) = boolSign (z (Sum.inr (part (flipBit (fun k => z (Sum.inl k)) i)))) := by unfold partSelector; rw [hfx, flipBit_apply_ne z (Sum.inl_ne_inr.symm)] rw [hval]; rfl -- Meanwhile `∑ a, ∑ x, [1_{part x = a} ≠ 1_{part (flipBit x i) = a}] = 2 * ∑ x, [part x ≠ part (flipBit x i)]`! have hdouble : ∑ a : Fin R, ∑ x : Fin m → Bool, (if (if part x = a then (1 : ℝ) else 0) ≠ (if part (flipBit x i) = a then (1 : ℝ) else 0) then (1 : ℝ) else 0) = 2 * ∑ x : Fin m → Bool, (if part x ≠ part (flipBit x i) then (1 : ℝ) else 0) := by rw [Finset.sum_comm, Finset.mul_sum] refine Finset.sum_congr rfl fun x _ => ?_ by_cases hpeq : part x = part (flipBit x i) · simp [hpeq] · rw [if_pos hpeq, mul_one] have h1 : ∀ a : Fin R, (if (if part x = a then (1 : ℝ) else 0) ≠ (if part (flipBit x i) = a then (1 : ℝ) else 0) then (1 : ℝ) else 0) = (if a = part x ∨ a = part (flipBit x i) then (1 : ℝ) else 0) := by intro a by_cases h1 : a = part x <;> by_cases h2 : a = part (flipBit x i) · exfalso; exact hpeq (h1.symm.trans h2) · rw [if_pos (Or.inl h1), if_pos h1.symm, if_neg (Ne.symm h2)]; norm_num · rw [if_pos (Or.inr h2), if_neg (Ne.symm h1), if_pos h2.symm]; norm_num · rw [if_neg (Ne.symm h1), if_neg (Ne.symm h2), if_neg (not_not.mpr rfl), if_neg (by rintro (h | h) <;> [exact h1 h; exact h2 h])] simp_rw [h1, ← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul, mul_one] have hpair : (Finset.univ.filter fun a : Fin R => a = part x ∨ a = part (flipBit x i)) = {part x, part (flipBit x i)} := by ext a; simp rw [hpair, Finset.card_pair hpeq]; norm_num rw [hsum_i, hdouble, pow_add] have h2R : (2 : ℝ) ^ R ≠ 0 := by positivity have h2m : (2 : ℝ) ^ m ≠ 0 := by positivity field_simp [h2R, h2m] ring rw [hdata, haddr, add_comm] /-- **MAIN SHARPNESS THEOREM 3 (Exact Barrier `4` for All Partition-Selector Functions)**: For **every** `m : ℕ`, `R ≥ 1`, and **every** partition `part : (Fin m → Bool) → Fin R`, the generalized addressing / partition-selector Boolean function `F = partSelector part` satisfies `fourierMinEntropy F ≤ 4 * (totalInfluence F - 1)` and hence `fourierMinEntropy F < 4 * totalInfluence F`. -/ theorem partSelector_fmei_le_four_sub_one {m R : ℕ} (hR : 1 ≤ R) (part : (Fin m → Bool) → Fin R) : fourierMinEntropy (partSelector part) ≤ 4 * (totalInfluence (partSelector part) - 1) ∧ fourierMinEntropy (partSelector part) < 4 * totalInfluence (partSelector part) := by have : Nonempty (Fin R) := ⟨⟨0, hR⟩⟩ let μ : Fin R → ℝ := fun a => ((Finset.univ.filter fun x : Fin m → Bool => part x = a).card : ℝ) / (2 : ℝ) ^ m have hμ_nn : ∀ a : Fin R, 0 ≤ μ a := fun a => by positivity have hμ_sum : ∑ a : Fin R, μ a = 1 := by dsimp only [μ]; rw [← Finset.sum_div, ← Nat.cast_sum] have hnat : ∑ a : Fin R, (Finset.univ.filter fun x : Fin m → Bool => part x = a).card = 2 ^ m := by rw [← Finset.card_biUnion] · have : (Finset.univ : Finset (Fin R)).biUnion (fun a => Finset.univ.filter fun x => part x = a) = Finset.univ := by ext x; simp rw [this, Finset.card_univ, Fintype.card_fun, Fintype.card_bool, Fintype.card_fin] · intro a _ b _ hab change Disjoint _ _ rw [Finset.disjoint_left] intro x hx1 hx2 exact hab ((Finset.mem_filter.mp hx1).2.symm.trans (Finset.mem_filter.mp hx2).2) rw [hnat, Nat.cast_pow, Nat.cast_ofNat, div_self (by positivity)] -- Pick `a₀` maximizing `μ a`: obtain ⟨a₀, _, ha₀_max⟩ := Finset.exists_max_image Finset.univ μ Finset.univ_nonempty have hμ_a0_pos : 0 < μ a₀ := by by_contra hle; push Not at hle have hall : ∀ a : Fin R, μ a = 0 := fun a => le_antisymm ((ha₀_max a (Finset.mem_univ a)).trans hle) (hμ_nn a) simp [hall] at hμ_sum have hM_eq : maxFourierSq (partSelector part) = (μ a₀) ^ 2 := by rw [partSelector_maxFourierSq hR part] apply le_antisymm · rw [Finset.sup'_le_iff]; intro a _ exact sq_le_sq.mpr (by rw [abs_of_nonneg (hμ_nn a), abs_of_nonneg (hμ_nn a₀)]; exact ha₀_max a (Finset.mem_univ a)) · exact Finset.le_sup' (f := fun a : Fin R => (μ a) ^ 2) (Finset.mem_univ a₀) -- Therefore `H_∞(partSelector part) = 2 * (-log₂(μ a₀))`: have hH_eq : fourierMinEntropy (partSelector part) = 2 * (-Real.logb 2 (μ a₀)) := by unfold fourierMinEntropy rw [hM_eq, Real.logb_pow]; push_cast; ring -- Meanwhile, by `hypercube_edge_isoperimetric` summed over all parts `a : Fin R`: have hI_lb : 1 + (1 / 2 : ℝ) * ∑ a : Fin R, -(μ a * Real.logb 2 (μ a)) ≤ totalInfluence (partSelector part) := by rw [partSelector_totalInfluence] have hsum_iso : 2 * ∑ a : Fin R, -(μ a * Real.logb 2 (μ a)) ≤ ∑ a : Fin R, totalInfluence (fun x : Fin m → Bool => if part x = a then (1 : ℝ) else 0) := by rw [Finset.mul_sum] refine Finset.sum_le_sum fun a _ => ?_ have h := hypercube_edge_isoperimetric m (Finset.univ.filter fun x => part x = a) simpa [μ] using h linarith -- Since `μ a ≤ μ a₀` for all `a`, `-log₂(μ a₀) ≤ -log₂(μ a)` whenever `μ a > 0`, so -- `-log₂(μ a₀) = ∑ a, μ a * (-log₂(μ a₀)) ≤ ∑ a, -(μ a * log₂(μ a))`! have hent_lb : -Real.logb 2 (μ a₀) ≤ ∑ a : Fin R, -(μ a * Real.logb 2 (μ a)) := by calc -Real.logb 2 (μ a₀) = (∑ a : Fin R, μ a) * (-Real.logb 2 (μ a₀)) := by rw [hμ_sum, one_mul] _ = ∑ a : Fin R, -(μ a * Real.logb 2 (μ a₀)) := by rw [Finset.sum_mul]; refine Finset.sum_congr rfl fun a _ => by ring _ ≤ ∑ a : Fin R, -(μ a * Real.logb 2 (μ a)) := by refine Finset.sum_le_sum fun a _ => ?_ by_cases h0 : μ a = 0 · simp [h0] · have hpos : 0 < μ a := lt_of_le_of_ne (hμ_nn a) (Ne.symm h0) have hlog := Real.logb_le_logb_of_le (by norm_num : (1 : ℝ) < 2) hpos (ha₀_max a (Finset.mem_univ a)) nlinarith constructor <;> linarith /-- **EXACT SUPREMUM CHARACTERIZATION**: Over the entire infinite class of generalized addressing / partition-selector Boolean functions, the supremum of `H_∞(F̂²) / I(F)` is **precisely `4`**: every partition selector strictly obeys `H_∞ < 4 * I`, while for every `D < 4` there exists a partition selector (in fact an addressing function) with `D * I < H_∞`. -/ theorem partSelector_fmei_supremum_eq_four : (∀ (m R : ℕ) (_ : 1 ≤ R) (part : (Fin m → Bool) → Fin R), fourierMinEntropy (partSelector part) < 4 * totalInfluence (partSelector part)) ∧ (∀ D : ℝ, D < 4 → ∃ (m R : ℕ) (_ : 1 ≤ R) (part : (Fin m → Bool) → Fin R), D * totalInfluence (partSelector part) < fourierMinEntropy (partSelector part)) := by refine ⟨fun m R hR part => (partSelector_fmei_le_four_sub_one hR part).2, fun D hD => ?_⟩ have hgap : 0 < 4 - D := by linarith obtain ⟨k, hk⟩ := exists_nat_gt (2 * max D 0 / (4 - D)) let eFin : (Fin k → Bool) ≃ Fin (2 ^ k) := Fintype.equivFinOfCardEq (by simp [Fintype.card_bool]) let part : (Fin k → Bool) → Fin (2 ^ k) := eFin have hR : 1 ≤ 2 ^ k := Nat.one_le_two_pow -- Relabel `addrFun k` to `partSelector part` via `Sum.map id eFin`! let eSum : AddrIdx k ≃ (Fin k ⊕ Fin (2 ^ k)) := Equiv.sumCongr (Equiv.refl (Fin k)) eFin have heq : partSelector part = relabel eSum (addrFun k) := by ext z dsimp only [partSelector, relabel, addrFun, eSum, part] simp [Equiv.sumCongr_apply] refine ⟨k, 2 ^ k, hR, part, ?_⟩ rw [heq, relabel_totalInfluence eSum (addrFun_isBoolean k), relabel_fourierMinEntropy eSum, addrFun_totalInfluence, addrFun_fourierMinEntropy] have h1 : 2 * max D 0 < (k : ℝ) * (4 - D) := (div_lt_iff₀ hgap).mp hk have hDle : D ≤ max D 0 := le_max_left D 0 nlinarith end EdgeIsoperimetricAndSharpness /-! ## Section 5: Axiom Audit -/ #print axioms fourier_expansion #print axioms parseval #print axioms totalInfluence_eq_fourier #print axioms fourierMinEntropy_le_fourierEntropy #print axioms addrFun_fmei_ratio #print axioms addr_five_beats_biswas_sarkar #print axioms fmei_constant_ge_four #print axioms monotone_fmei_constant_ge_two_div_log_two #print axioms monotone_fmei_beats_biswas_sarkar #print axioms hypercube_edge_isoperimetric #print axioms partSelector_fmei_le_four_sub_one #print axioms partSelector_fmei_supremum_eq_four end FourierMinEntropyInfluence