import Mathlib /-! # Sharp Asymmetric Decision-Tree, Certificate-Complexity, Bootstrap-Sensitivity, # and Parity-Tree Trade-Offs for Boolean Functions This file is a completely self-contained, standard-foundations Lean 4 formalization of four interlocking pillars in Boolean function complexity: 1. **Pillar 1 — Asymmetric `𝔽₂`-Degree (ANF) Midrijanis & Certificate Decision-Tree Bounds**: - Exact `𝔽₂` Algebraic Normal Form (ANF) expansion (`anf_eval`), `deg₂(f) ≤ deg(f) ≤ D(f)`. - Simultaneous drop of `bs₀`, `bs₁`, `C₀`, `C₁` on every branch of any max-degree ANF monomial (`anf_top_monomial_simultaneous_drop`). - Sharp asymmetric `𝔽₂`-Midrijanis bound (`detDepth_le_deg2_mul_min_bs`): `D(f) ≤ deg₂(f) · min(bs₀(f), bs₁(f)) ≤ deg(f) · min(bs₀(f), bs₁(f)) ≤ deg(f) · bs(f)`. - Sharp asymmetric certificate–block-sensitivity bounds (`detDepth_le_cert1_mul_bs0`, `detDepth_le_cert0_mul_bs1`, `detDepth_le_cert0_mul_cert1`): `D(f) ≤ min(C₁(f) · bs₀(f), C₀(f) · bs₁(f)) ≤ C₀(f) · C₁(f)`. 2. **Pillar 2 — Essential-Bit Double Counting, Strict Nisan Improvement, and Bootstrap-Percolation Sensitivity Rigidity**: - Nisan's asymmetric certificate bound `C₀(f) ≤ s₁(f) · bs₀(f)` (`nisan_cert_le_sens_mul_bs`). - Exact essential-bit sensitivity-deficit law (`essential_bit_sensitivity_deficit`): `|U| + |M_{≥2}| ≤ s₁(f) · bs₀(f)` at every maximum disjoint minimal-block family. - Universal strict improvement over Nisan (1991) (`cert0_strict_lt_nisan`): for all `s₁(f) ≥ 2` and `bs₀(f) ≥ 2`, `C₀(f) ≤ s₁(f) · bs₀(f) - 1`, yielding `D(f) ≤ (s₀(f) · bs₁(f) - 1) · bs₀(f)` (`detDepth_strict_lt_nisan_cubic`). - Exact `s₁(f) ≤ 1` `2`-bootstrap-percolation subcube rigidity (`s1_le_one_exact_equality`): pointwise `s(f, x) = bs(f, x) = C(f, x)` for all `x ∈ f⁻¹(0)`. - Sharp `s₁(f) ≤ 2` `3`-bootstrap-percolation private-neighbor theorem (`s1_le_two_private_neighbor_bound`), `C₀(f) ≤ 2 · bs₀(f) - 2` (`s1_le_two_cert0_le_two_bs0_sub_two`), and exact `(2, 2)` collapse `s₁(f) ≤ 2 ∧ bs₀(f) ≤ 2 → C₀(f) ≤ 2` (`s1_le_two_bs0_le_two_cert0_le_two`, a `2×` improvement over Nisan's `4`). 3. **Pillar 3 — Sharp Parity Decision Tree Hierarchy, Granularity, Spectral-Norm Gap, and Exact Signed-Collision Reduction**: - Lower bounds `deg₂(f) ≤ D_⊕(f)`, `C_⊕(f) ≤ D_⊕(f)`, and Chistopolskaya–Podolskii granularity bound `D_⊕(f) ≥ gran(f) + 1` for every nonconstant `f`. - Sharp non-asymptotic exponential bounds `L₁(f̂) ≤ 2^(D_⊕(f) - 1)` and `‖f̂‖₀ ≤ 4^(D_⊕(f) - 1)` for every nonconstant `f` (improving naive `2^D_⊕` and `4^D_⊕` by factors of `2` and `4`, tight for every `d ≥ 1`). - Zhang–Shi affine-certificate bound `D_⊕(f) ≤ C₀^⊕(f) · C₁^⊕(f)`. - Exact Signed-Collision Spectral-Norm Drop (`signed_collision_L1_drop`): for every non-affine Boolean `f`, querying `γ = α* ⊕ β` drops `L₁(f̂)` by at least `2 M₂` on both branches simultaneously and raises `‖f̂‖_∞` to at least `M₁ + M₂` on one branch. - Spectral-Norm Gap & Rigidity (`spectralNorm_gap_ge_two`, `spectralNorm_eq_two_rigidity`) and Forbidden Low-Sparsity Gap (`fourierSparsity_forbidden_gap`: `‖f̂‖₀ ∉ {2, 3, 5, 6, 7}`). 4. **Pillar 4 — Exact Infinite-Family Sharpness & Separations**: - `AND_a ∘ OR_b` (all-`(a, b)` simultaneous sharpness of `D ≤ C₀C₁`, `D ≤ C₁bs₀`, `D_⊕ ≤ C₀^⊕C₁^⊕`). - `IP_{2m}` (all-`m` simultaneous sharpness of `D_⊕ ≥ gran + 1`, `L₁ ≤ 2^(D_⊕-1)`, `‖f̂‖₀ ≤ 4^(D_⊕-1)`, and linear vs quadratic separation over Midrijanis). - `PARITY_n` (all-`n` sharpness of `D ≤ deg₂ · min(bs₀, bs₁)` and unbounded `D / D_⊕ = n` gap). - `AND_n` (all-`n` exact sharpness of the Signed-Collision `L₁` drop). - `Rubinstein(k, m)` (quadratic separation `bs(f) = C(f) = (1/2) s(f)²` at `k = 2m`). - `MAJ_3` (simultaneous sharpness of `(2, 2)` Nisan collapse and `L₁ = 2` rigidity). -/ open scoped BigOperators open Finset namespace SensitivityDecisionTrees section Foundations variable {ι : Type*} [DecidableEq ι] /-- Flip a single coordinate `i` of a Boolean input `x`. -/ def flipBit (x : ι → Bool) (i : ι) : ι → Bool := fun j => if j = i then !x j else x j /-- Flip all coordinates in a block `B : Finset ι` of a Boolean input `x`. -/ def flipSet (x : ι → Bool) (B : Finset ι) : ι → Bool := fun j => if j ∈ B then !x j else x j @[simp] lemma flipSet_empty (x : ι → Bool) : flipSet x ∅ = x := by ext j; simp [flipSet] @[simp] lemma flipSet_singleton (x : ι → Bool) (i : ι) : flipSet x {i} = flipBit x i := by ext j; simp [flipSet, flipBit] lemma flipBit_self (x : ι → Bool) (i : ι) : flipBit (flipBit x i) i = x := by ext j; by_cases h : j = i <;> simp [flipBit, h] lemma flipSet_flipSet (x : ι → Bool) (A B : Finset ι) : flipSet (flipSet x A) B = flipSet x (symmDiff A B) := by ext j by_cases ha : j ∈ A <;> by_cases hb : j ∈ B <;> simp [flipSet, Finset.mem_symmDiff, ha, hb] lemma flipSet_disjoint_union (x : ι → Bool) {A B : Finset ι} (h : Disjoint A B) : flipSet (flipSet x A) B = flipSet x (A ∪ B) := by ext j by_cases ha : j ∈ A · have hb : j ∉ B := Finset.disjoint_left.mp h ha simp [flipSet, ha, hb] · by_cases hb : j ∈ B <;> simp [flipSet, ha, hb] lemma flipSet_insert_of_notMem (x : ι → Bool) {B : Finset ι} {i : ι} (hi : i ∉ B) : flipBit (flipSet x B) i = flipSet x (insert i B) := by rw [← flipSet_singleton, flipSet_disjoint_union] · rw [Finset.union_comm, Finset.singleton_union] · exact Finset.disjoint_singleton_right.mpr hi lemma flipBit_comm (x : ι → Bool) (i j : ι) : flipBit (flipBit x i) j = flipBit (flipBit x j) i := by ext k by_cases h1 : k = i <;> by_cases h2 : k = j · subst h1; subst h2; simp [flipBit] · subst h1; simp [flipBit, h2] · subst h2; simp [flipBit, h1] · simp [flipBit, h1, h2] /-- Restriction of `f` fixing all coordinates in `M` to `ρ`. The result lives on the same index type `ι` and ignores coordinates in `M`. -/ def restrict (f : (ι → Bool) → Bool) (M : Finset ι) (ρ : ι → Bool) : (ι → Bool) → Bool := fun x => f (fun i => if i ∈ M then ρ i else x i) /-- Single-coordinate restriction of `f` setting coordinate `i` to `b`. -/ def restrictBit (f : (ι → Bool) → Bool) (i : ι) (b : Bool) : (ι → Bool) → Bool := fun x => f (fun j => if j = i then b else x j) lemma restrict_eq_of_agree (f : (ι → Bool) → Bool) (M : Finset ι) (ρ x : ι → Bool) (h : ∀ i ∈ M, x i = ρ i) : restrict f M ρ x = f x := by simp only [restrict] congr 1; ext i by_cases hi : i ∈ M · simp [hi, h i hi] · simp [hi] lemma restrict_ignores (f : (ι → Bool) → Bool) (M : Finset ι) (ρ x y : ι → Bool) (h : ∀ i, i ∉ M → y i = x i) : restrict f M ρ y = restrict f M ρ x := by simp only [restrict] congr 1; ext i by_cases hi : i ∈ M · simp [hi] · simp [hi, h i hi] lemma restrict_flipSet_sdiff (f : (ι → Bool) → Bool) (M : Finset ι) (ρ x : ι → Bool) (B : Finset ι) : restrict f M ρ (flipSet x B) = f (flipSet (fun i => if i ∈ M then ρ i else x i) (B \ M)) := by simp only [restrict] congr 1; ext i by_cases hi : i ∈ M · simp [flipSet, hi] · by_cases hb : i ∈ B <;> simp [flipSet, hi, hb] variable [Fintype ι] /-! ### Sensitivity, Block Sensitivity, and Certificate Complexity -/ /-- Set of sensitive coordinates of `f` at `x`. -/ def sensSet (f : (ι → Bool) → Bool) (x : ι → Bool) : Finset ι := Finset.univ.filter (fun i => f (flipBit x i) ≠ f x) /-- Pointwise sensitivity `s(f, x)`. -/ def sensAt (f : (ι → Bool) → Bool) (x : ι → Bool) : ℕ := (sensSet f x).card /-- One-sided sensitivity `s_b(f) = max_{f(x) = b} s(f, x)`. -/ def sensSide (f : (ι → Bool) → Bool) (b : Bool) : ℕ := (Finset.univ.filter (fun x => f x = b)).sup (sensAt f) /-- Maximum sensitivity `s(f) = max(s₀(f), s₁(f))`. -/ def sens (f : (ι → Bool) → Bool) : ℕ := max (sensSide f false) (sensSide f true) lemma sensAt_le_sensSide (f : (ι → Bool) → Bool) (x : ι → Bool) : sensAt f x ≤ sensSide f (f x) := Finset.le_sup (f := sensAt f) (by simp) lemma sensSide_le_sens (f : (ι → Bool) → Bool) (b : Bool) : sensSide f b ≤ sens f := by cases b <;> simp [sens] /-- `B` is a sensitive block of `f` at `x`. -/ def IsSensBlock (f : (ι → Bool) → Bool) (x : ι → Bool) (B : Finset ι) : Prop := f (flipSet x B) ≠ f x omit [Fintype ι] in lemma IsSensBlock.nonempty {f : (ι → Bool) → Bool} {x : ι → Bool} {B : Finset ι} (h : IsSensBlock f x B) : B.Nonempty := by by_contra hemp rw [Finset.not_nonempty_iff_eq_empty] at hemp subst hemp exact h (by simp) /-- `B` is an inclusion-minimal sensitive block of `f` at `x`. -/ def IsMinSensBlock (f : (ι → Bool) → Bool) (x : ι → Bool) (B : Finset ι) : Prop := IsSensBlock f x B ∧ ∀ B' ⊂ B, f (flipSet x B') = f x omit [Fintype ι] in lemma exists_minSensBlock_subset {f : (ι → Bool) → Bool} {x : ι → Bool} {B : Finset ι} (hB : IsSensBlock f x B) : ∃ B' ⊆ B, IsMinSensBlock f x B' := by classical have hex : ∃ n, ∃ B' ⊆ B, IsSensBlock f x B' ∧ B'.card = n := ⟨B.card, B, Subset.rfl, hB, rfl⟩ obtain ⟨B', hsub, hsens, hcard⟩ := Nat.find_spec hex refine ⟨B', hsub, hsens, ?_⟩ intro C hC by_contra hne have hlt : C.card < Nat.find hex := hcard ▸ Finset.card_lt_card hC exact Nat.find_min hex hlt ⟨C, hC.subset.trans hsub, hne, rfl⟩ /-- Every coordinate of a minimal sensitive block `B` at `x` is sensitive at `x^{⊕ B}`. -/ lemma mem_sensSet_of_minSensBlock {f : (ι → Bool) → Bool} {x : ι → Bool} {B : Finset ι} (hB : IsMinSensBlock f x B) {i : ι} (hi : i ∈ B) : i ∈ sensSet f (flipSet x B) := by rw [sensSet, Finset.mem_filter] refine ⟨Finset.mem_univ i, ?_⟩ have hflip : flipBit (flipSet x B) i = flipSet x (B.erase i) := by ext j by_cases hji : j = i · subst hji; simp [flipBit, flipSet, hi] · by_cases hjb : j ∈ B <;> simp [flipBit, flipSet, hji, hjb] rw [hflip, hB.2 (B.erase i) (Finset.erase_ssubset hi)] exact hB.1.symm /-- Size of any minimal sensitive block at `x` is bounded by `s(f, x^{⊕ B}) ≤ s_{¬f(x)}(f)`. -/ lemma card_le_sensAt_flip_of_minSensBlock {f : (ι → Bool) → Bool} {x : ι → Bool} {B : Finset ι} (hB : IsMinSensBlock f x B) : B.card ≤ sensAt f (flipSet x B) := by apply Finset.card_le_card intro i hi exact mem_sensSet_of_minSensBlock hB hi lemma card_le_sensSide_not_of_minSensBlock {f : (ι → Bool) → Bool} {x : ι → Bool} {B : Finset ι} (hB : IsMinSensBlock f x B) : B.card ≤ sensSide f (!f x) := by have hval : f (flipSet x B) = !f x := by have hne : f (flipSet x B) ≠ f x := hB.1 cases h1 : f (flipSet x B) <;> cases h2 : f x <;> simp_all calc B.card ≤ sensAt f (flipSet x B) := card_le_sensAt_flip_of_minSensBlock hB _ ≤ sensSide f (f (flipSet x B)) := sensAt_le_sensSide f _ _ = sensSide f (!f x) := by rw [hval] /-- A finite family of pairwise disjoint sensitive blocks of `f` at `x`. -/ def IsDisjointSensBlocks (f : (ι → Bool) → Bool) (x : ι → Bool) (ℬ : Finset (Finset ι)) : Prop := (∀ B ∈ ℬ, IsSensBlock f x B) ∧ (ℬ : Set (Finset ι)).PairwiseDisjoint id /-- Pointwise block sensitivity `bs(f, x)`. -/ noncomputable def blockSensAt (f : (ι → Bool) → Bool) (x : ι → Bool) : ℕ := by classical exact (Finset.univ.filter (fun ℬ : Finset (Finset ι) => IsDisjointSensBlocks f x ℬ)).sup Finset.card /-- One-sided block sensitivity `bs_b(f) = max_{f(x) = b} bs(f, x)`. -/ noncomputable def blockSensSide (f : (ι → Bool) → Bool) (b : Bool) : ℕ := (Finset.univ.filter (fun x => f x = b)).sup (blockSensAt f) /-- Maximum block sensitivity `bs(f) = max(bs₀(f), bs₁(f))`. -/ noncomputable def blockSens (f : (ι → Bool) → Bool) : ℕ := max (blockSensSide f false) (blockSensSide f true) lemma card_le_blockSensAt {f : (ι → Bool) → Bool} {x : ι → Bool} {ℬ : Finset (Finset ι)} (hℬ : IsDisjointSensBlocks f x ℬ) : ℬ.card ≤ blockSensAt f x := by classical unfold blockSensAt exact Finset.le_sup (f := Finset.card) (by simp [hℬ]) lemma blockSensAt_le_of_forall {f : (ι → Bool) → Bool} {x : ι → Bool} {k : ℕ} (hk : ∀ ℬ : Finset (Finset ι), IsDisjointSensBlocks f x ℬ → ℬ.card ≤ k) : blockSensAt f x ≤ k := by classical unfold blockSensAt exact Finset.sup_le fun ℬ hℬ => hk ℬ (Finset.mem_filter.mp hℬ).2 lemma exists_disjointSensBlocks_eq_blockSensAt (f : (ι → Bool) → Bool) (x : ι → Bool) : ∃ ℬ : Finset (Finset ι), IsDisjointSensBlocks f x ℬ ∧ ℬ.card = blockSensAt f x := by classical have hne : (Finset.univ.filter (fun ℬ : Finset (Finset ι) => IsDisjointSensBlocks f x ℬ)).Nonempty := by refine ⟨∅, Finset.mem_filter.mpr ⟨Finset.mem_univ _, ?_⟩⟩ exact ⟨by simp, by simp⟩ obtain ⟨ℬ, hℬmem, hℬmax⟩ := Finset.exists_mem_eq_sup _ hne Finset.card exact ⟨ℬ, (Finset.mem_filter.mp hℬmem).2, hℬmax.symm⟩ lemma blockSensAt_le_blockSensSide (f : (ι → Bool) → Bool) (x : ι → Bool) : blockSensAt f x ≤ blockSensSide f (f x) := Finset.le_sup (f := blockSensAt f) (by simp) lemma blockSensSide_le_blockSens (f : (ι → Bool) → Bool) (b : Bool) : blockSensSide f b ≤ blockSens f := by cases b <;> simp [blockSens] /-- Every sensitivity coordinate is a singleton sensitive block, hence `s(f, x) ≤ bs(f, x)`. -/ lemma sensAt_le_blockSensAt (f : (ι → Bool) → Bool) (x : ι → Bool) : sensAt f x ≤ blockSensAt f x := by let ℬ : Finset (Finset ι) := (sensSet f x).image (fun i => ({i} : Finset ι)) have hcard : ℬ.card = sensAt f x := by rw [Finset.card_image_of_injective _ Finset.singleton_injective]; rfl rw [← hcard] apply card_le_blockSensAt refine ⟨?_, ?_⟩ · intro B hB rcases Finset.mem_image.mp hB with ⟨i, hi, rfl⟩ rw [IsSensBlock, flipSet_singleton] exact (Finset.mem_filter.mp hi).2 · intro B₁ hB₁ B₂ hB₂ hne rcases Finset.mem_image.mp hB₁ with ⟨i₁, _, rfl⟩ rcases Finset.mem_image.mp hB₂ with ⟨i₂, _, rfl⟩ have hi : i₁ ≠ i₂ := fun h => hne (by rw [h]) exact Finset.disjoint_singleton.mpr hi lemma sensSide_le_blockSensSide (f : (ι → Bool) → Bool) (b : Bool) : sensSide f b ≤ blockSensSide f b := Finset.sup_le fun x hx => (sensAt_le_blockSensAt f x).trans (Finset.le_sup (f := blockSensAt f) hx) /-- `S` is a certificate for `f` at `x`. -/ def IsCert (f : (ι → Bool) → Bool) (x : ι → Bool) (S : Finset ι) : Prop := ∀ y : ι → Bool, (∀ i ∈ S, y i = x i) → f y = f x omit [DecidableEq ι] in lemma exists_cert (f : (ι → Bool) → Bool) (x : ι → Bool) : ∃ k : ℕ, ∃ S : Finset ι, IsCert f x S ∧ S.card = k := ⟨Fintype.card ι, Finset.univ, fun y hy => by have : y = x := funext fun i => hy i (Finset.mem_univ i) rw [this], Finset.card_univ⟩ /-- Pointwise certificate complexity `C(f, x)`. -/ noncomputable def certAt (f : (ι → Bool) → Bool) (x : ι → Bool) : ℕ := by classical exact Nat.find (exists_cert f x) /-- One-sided certificate complexity `C_b(f) = max_{f(x) = b} C(f, x)`. -/ noncomputable def certSide (f : (ι → Bool) → Bool) (b : Bool) : ℕ := (Finset.univ.filter (fun x => f x = b)).sup (certAt f) /-- Maximum certificate complexity `C(f) = max(C₀(f), C₁(f))`. -/ noncomputable def cert (f : (ι → Bool) → Bool) : ℕ := max (certSide f false) (certSide f true) omit [DecidableEq ι] in lemma certAt_le_of_isCert {f : (ι → Bool) → Bool} {x : ι → Bool} {S : Finset ι} (hS : IsCert f x S) : certAt f x ≤ S.card := by classical exact Nat.find_min' (exists_cert f x) ⟨S, hS, rfl⟩ omit [DecidableEq ι] in lemma exists_isCert_eq_certAt (f : (ι → Bool) → Bool) (x : ι → Bool) : ∃ S : Finset ι, IsCert f x S ∧ S.card = certAt f x := by classical exact Nat.find_spec (exists_cert f x) lemma certAt_le_certSide (f : (ι → Bool) → Bool) (x : ι → Bool) : certAt f x ≤ certSide f (f x) := Finset.le_sup (f := certAt f) (by simp) lemma certSide_le_cert (f : (ι → Bool) → Bool) (b : Bool) : certSide f b ≤ cert f := by cases b <;> simp [cert] omit [Fintype ι] in /-- A certificate at `x` must intersect every sensitive block at `x`. -/ lemma isCert_inter_sensBlock_nonempty {f : (ι → Bool) → Bool} {x : ι → Bool} {S B : Finset ι} (hS : IsCert f x S) (hB : IsSensBlock f x B) : (S ∩ B).Nonempty := by by_contra hemp rw [Finset.not_nonempty_iff_eq_empty] at hemp have hagree : ∀ i ∈ S, flipSet x B i = x i := by intro i hi have hni : i ∉ B := fun hbi => by have : i ∈ S ∩ B := Finset.mem_inter.mpr ⟨hi, hbi⟩ rw [hemp] at this; exact Finset.notMem_empty i this simp [flipSet, hni] exact hB (hS (flipSet x B) hagree) /-- Characterization: `S` is a certificate at `x` iff `S` hits every sensitive block at `x`. -/ lemma isCert_iff_hits_sensBlocks {f : (ι → Bool) → Bool} {x : ι → Bool} {S : Finset ι} : IsCert f x S ↔ ∀ B : Finset ι, IsSensBlock f x B → (S ∩ B).Nonempty := by constructor · intro hS B hB; exact isCert_inter_sensBlock_nonempty hS hB · intro hhit y hy by_contra hne let B : Finset ι := Finset.univ.filter (fun i => y i ≠ x i) have hfy : flipSet x B = y := by ext i by_cases h : y i = x i · simp [flipSet, B, h] · have hmem : i ∈ B := Finset.mem_filter.mpr ⟨Finset.mem_univ i, h⟩ simp only [flipSet, hmem, ↓reduceIte] cases h1 : y i <;> cases h2 : x i <;> simp_all have hB : IsSensBlock f x B := by rwa [IsSensBlock, hfy] obtain ⟨i, hi⟩ := hhit B hB rw [Finset.mem_inter] at hi exact (Finset.mem_filter.mp hi.2).2 (hy i hi.1) /-- `bs(f, x) ≤ C(f, x)` because any certificate hits every block of any disjoint family. -/ lemma blockSensAt_le_certAt (f : (ι → Bool) → Bool) (x : ι → Bool) : blockSensAt f x ≤ certAt f x := by obtain ⟨S, hS, hScard⟩ := exists_isCert_eq_certAt f x rw [← hScard] apply blockSensAt_le_of_forall intro ℬ hℬ classical have hpick : ∀ B ∈ ℬ, ∃ i ∈ S, i ∈ B := fun B hB => by obtain ⟨i, hi⟩ := isCert_inter_sensBlock_nonempty hS (hℬ.1 B hB) exact ⟨i, (Finset.mem_inter.mp hi).1, (Finset.mem_inter.mp hi).2⟩ choose g hgS hgB using hpick have hinj : ∀ B₁ (h₁ : B₁ ∈ ℬ) B₂ (h₂ : B₂ ∈ ℬ), g B₁ h₁ = g B₂ h₂ → B₁ = B₂ := by intro B₁ h₁ B₂ h₂ heq by_contra hne have hdisj := hℬ.2 h₁ h₂ hne exact Finset.disjoint_left.mp hdisj (hgB B₁ h₁) (heq ▸ hgB B₂ h₂) calc ℬ.card = ℬ.attach.card := (Finset.card_attach).symm _ = (ℬ.attach.image (fun p => g p.1 p.2)).card := by symm apply Finset.card_image_of_injective intro ⟨B₁, h₁⟩ ⟨B₂, h₂⟩ heq exact Subtype.ext (hinj B₁ h₁ B₂ h₂ heq) _ ≤ S.card := by apply Finset.card_le_card intro i hi rcases Finset.mem_image.mp hi with ⟨⟨B, hB⟩, _, rfl⟩ exact hgS B hB lemma blockSensSide_le_certSide (f : (ι → Bool) → Bool) (b : Bool) : blockSensSide f b ≤ certSide f b := Finset.sup_le fun x hx => (blockSensAt_le_certAt f x).trans (Finset.le_sup (f := certAt f) hx) /-- If `f` is nonconstant, both `0`- and `1`-inputs exist and `bs₀(f) ≥ 1, bs₁(f) ≥ 1`. -/ lemma blockSensSide_pos_of_nonconst {f : (ι → Bool) → Bool} (hnc : ∃ x y, f x ≠ f y) (b : Bool) : 1 ≤ blockSensSide f b := by obtain ⟨x, y, hxy⟩ := hnc have hex : ∃ u v, f u = b ∧ f v ≠ b := by by_cases hx : f x = b · exact ⟨x, y, hx, hx ▸ hxy.symm⟩ · have hy : f y = b := by cases h1 : f x <;> cases h2 : f y <;> cases b <;> simp_all exact ⟨y, x, hy, hx⟩ obtain ⟨u, v, hu, hv⟩ := hex let B : Finset ι := Finset.univ.filter (fun i => v i ≠ u i) have hfu : flipSet u B = v := by ext i by_cases h : v i = u i · simp [flipSet, B, h] · have hmem : i ∈ B := Finset.mem_filter.mpr ⟨Finset.mem_univ i, h⟩ simp only [flipSet, hmem, ↓reduceIte] cases h1 : v i <;> cases h2 : u i <;> simp_all have hB : IsSensBlock f u B := by rw [IsSensBlock, hfu, hu]; exact hv have h1 : 1 ≤ blockSensAt f u := by have : ({B} : Finset (Finset ι)).card ≤ blockSensAt f u := card_le_blockSensAt ⟨by simp [hB], by simp⟩ simpa using this exact h1.trans (hu ▸ blockSensAt_le_blockSensSide f u) lemma const_of_blockSensSide_eq_zero {f : (ι → Bool) → Bool} {b : Bool} (h : blockSensSide f b = 0) : ∀ x y, f x = f y := by by_contra hnc push Not at hnc have hpos := blockSensSide_pos_of_nonconst hnc b omega omit [Fintype ι] in /-- Two certificates of opposite values must intersect on a coordinate where they disagree. -/ lemma opposite_certs_disagree {f : (ι → Bool) → Bool} {x y : ι → Bool} {S T : Finset ι} (hS : IsCert f x S) (hT : IsCert f y T) (hxy : f x ≠ f y) : ∃ i ∈ S ∩ T, x i ≠ y i := by by_contra hall push Not at hall let z : ι → Bool := fun i => if i ∈ S then x i else y i have hzS : ∀ i ∈ S, z i = x i := fun i hi => by simp [z, hi] have hzT : ∀ i ∈ T, z i = y i := fun i hi => by by_cases hs : i ∈ S · simp [z, hs, hall i (Finset.mem_inter.mpr ⟨hs, hi⟩)] · simp [z, hs] exact hxy ((hS z hzS).symm.trans (hT z hzT)) /-! ### Deterministic Decision Trees -/ /-- Explicit deterministic decision trees querying single Boolean coordinates. -/ inductive DecTree (ι : Type*) where | leaf (b : Bool) : DecTree ι | branch (i : ι) (tFalse tTrue : DecTree ι) : DecTree ι /-- Evaluation of a deterministic decision tree on an input `x`. -/ def DecTree.eval : DecTree ι → (ι → Bool) → Bool | .leaf b, _ => b | .branch i tF tT, x => if x i then tT.eval x else tF.eval x /-- Depth (worst-case query count) of a deterministic decision tree. -/ def DecTree.depth : DecTree ι → ℕ | .leaf _ => 0 | .branch _ tF tT => 1 + max tF.depth tT.depth /-- Build a decision tree querying all coordinates in a list `L`, then running `cont` on the accumulated partial assignment. -/ def DecTree.queryList : List ι → ((ι → Bool) → DecTree ι) → (ι → Bool) → DecTree ι | [], cont, ρ => cont ρ | i :: L, cont, ρ => .branch i (DecTree.queryList L cont (fun j => if j = i then false else ρ j)) (DecTree.queryList L cont (fun j => if j = i then true else ρ j)) omit [Fintype ι] in lemma DecTree.queryList_depth (L : List ι) (cont : (ι → Bool) → DecTree ι) (ρ : ι → Bool) (d : ℕ) (hcont : ∀ σ, (cont σ).depth ≤ d) : (DecTree.queryList L cont ρ).depth ≤ L.length + d := by induction L generalizing ρ with | nil => simpa [DecTree.queryList] using hcont ρ | cons i L ih => simp only [DecTree.queryList, DecTree.depth, List.length_cons] have h1 := ih (fun j => if j = i then false else ρ j) have h2 := ih (fun j => if j = i then true else ρ j) omega omit [Fintype ι] in lemma DecTree.queryList_eval (L : List ι) (cont : (ι → Bool) → DecTree ι) (ρ x : ι → Bool) : (DecTree.queryList L cont ρ).eval x = (cont (fun j => if j ∈ L then x j else ρ j)).eval x := by induction L generalizing ρ with | nil => simp [DecTree.queryList] | cons i L ih => simp only [DecTree.queryList, DecTree.eval] cases hxi : x i · simp only [Bool.false_eq_true, ↓reduceIte] rw [ih] have hfun : (fun j => if j ∈ L then x j else if j = i then false else ρ j) = (fun j => if j ∈ i :: L then x j else ρ j) := by ext j by_cases hL : j ∈ L · simp [hL] · by_cases hji : j = i · subst hji; simp [hL, hxi] · simp [hL, hji] rw [hfun] · simp only [↓reduceIte] rw [ih] have hfun : (fun j => if j ∈ L then x j else if j = i then true else ρ j) = (fun j => if j ∈ i :: L then x j else ρ j) := by ext j by_cases hL : j ∈ L · simp [hL] · by_cases hji : j = i · subst hji; simp [hL, hxi] · simp [hL, hji] rw [hfun] /-- Every Boolean function on a finite type `ι` is computed by a decision tree of depth `≤ |ι|`. -/ lemma exists_decTree (f : (ι → Bool) → Bool) : ∃ d : ℕ, ∃ t : DecTree ι, (∀ x, t.eval x = f x) ∧ t.depth = d := by let L := (Finset.univ : Finset ι).toList let t := DecTree.queryList L (fun σ => DecTree.leaf (f σ)) (fun _ => false) refine ⟨t.depth, t, ?_, rfl⟩ intro x rw [DecTree.queryList_eval] simp only [DecTree.eval] congr 1; ext j simp [L] /-- Deterministic decision-tree depth `D(f)`. -/ noncomputable def detDepth (f : (ι → Bool) → Bool) : ℕ := by classical exact Nat.find (exists_decTree f) lemma detDepth_le_of_tree {f : (ι → Bool) → Bool} {t : DecTree ι} (heval : ∀ x, t.eval x = f x) : detDepth f ≤ t.depth := by classical exact Nat.find_min' (exists_decTree f) ⟨t, heval, rfl⟩ lemma exists_decTree_eq_detDepth (f : (ι → Bool) → Bool) : ∃ t : DecTree ι, (∀ x, t.eval x = f x) ∧ t.depth = detDepth f := by classical exact Nat.find_spec (exists_decTree f) lemma detDepth_eq_zero_of_const {f : (ι → Bool) → Bool} {c : Bool} (hc : ∀ x, f x = c) : detDepth f = 0 := by have h := detDepth_le_of_tree (t := DecTree.leaf c) (fun x => (hc x).symm) simpa [DecTree.depth] using h /-- Composing a batch query of `M : Finset ι` with optimal trees for each `restrict f M ρ`. -/ lemma detDepth_le_card_add_sup_restrict (f : (ι → Bool) → Bool) (M : Finset ι) (d : ℕ) (hd : ∀ ρ : ι → Bool, detDepth (restrict f M ρ) ≤ d) : detDepth f ≤ M.card + d := by classical choose tree htree_eval htree_depth using fun ρ => exists_decTree_eq_detDepth (restrict f M ρ) let L := M.toList let T := DecTree.queryList L tree (fun _ => false) have hT_eval : ∀ x, T.eval x = f x := by intro x rw [DecTree.queryList_eval, htree_eval] apply restrict_eq_of_agree intro i hi have hiL : i ∈ L := Finset.mem_toList.mpr hi simp [hiL] have hT_depth : T.depth ≤ M.card + d := by have hlen : L.length = M.card := Finset.length_toList M rw [← hlen] exact DecTree.queryList_depth L tree (fun _ => false) d (fun σ => (htree_depth σ).le.trans (hd σ)) exact (detDepth_le_of_tree hT_eval).trans hT_depth /-- The coordinates queried along the path of `t` on input `x` form a certificate of size at most `t.depth`. -/ def DecTree.queriedSet : DecTree ι → (ι → Bool) → Finset ι | .leaf _, _ => ∅ | .branch i tF tT, x => insert i (if x i then tT.queriedSet x else tF.queriedSet x) omit [Fintype ι] in lemma DecTree.queriedSet_card_le (t : DecTree ι) (x : ι → Bool) : (t.queriedSet x).card ≤ t.depth := by induction t with | leaf b => simp [DecTree.queriedSet, DecTree.depth] | branch i tF tT ihF ihT => simp only [DecTree.queriedSet, DecTree.depth] cases h : x i · simp only [Bool.false_eq_true, ↓reduceIte] calc (insert i (tF.queriedSet x)).card ≤ (tF.queriedSet x).card + 1 := Finset.card_insert_le _ _ _ ≤ tF.depth + 1 := Nat.add_le_add_right ihF 1 _ ≤ 1 + max tF.depth tT.depth := by omega · simp only [↓reduceIte] calc (insert i (tT.queriedSet x)).card ≤ (tT.queriedSet x).card + 1 := Finset.card_insert_le _ _ _ ≤ tT.depth + 1 := Nat.add_le_add_right ihT 1 _ ≤ 1 + max tF.depth tT.depth := by omega omit [Fintype ι] in lemma DecTree.eval_eq_of_agree_queriedSet (t : DecTree ι) (x y : ι → Bool) (h : ∀ i ∈ t.queriedSet x, y i = x i) : t.eval y = t.eval x := by induction t with | leaf b => rfl | branch i tF tT ihF ihT => have hi : y i = x i := h i (Finset.mem_insert_self i _) simp only [DecTree.eval, hi] cases hx : x i · simp only [Bool.false_eq_true, ↓reduceIte] apply ihF intro j hj exact h j (Finset.mem_insert_of_mem (by simpa [hx] using hj)) · simp only [↓reduceIte] apply ihT intro j hj exact h j (Finset.mem_insert_of_mem (by simpa [hx] using hj)) /-- Universal lower bound `C(f, x) ≤ D(f)`, hence `C_b(f) ≤ D(f)` and `C(f) ≤ D(f)`. -/ theorem certAt_le_detDepth (f : (ι → Bool) → Bool) (x : ι → Bool) : certAt f x ≤ detDepth f := by obtain ⟨t, ht_eval, ht_depth⟩ := exists_decTree_eq_detDepth f have hcert : IsCert f x (t.queriedSet x) := fun y hy => by rw [← ht_eval y, ← ht_eval x] exact t.eval_eq_of_agree_queriedSet x y hy exact (certAt_le_of_isCert hcert).trans (ht_depth ▸ t.queriedSet_card_le x) theorem certSide_le_detDepth (f : (ι → Bool) → Bool) (b : Bool) : certSide f b ≤ detDepth f := Finset.sup_le fun x _ => certAt_le_detDepth f x theorem cert_le_detDepth (f : (ι → Bool) → Bool) : cert f ≤ detDepth f := max_le (certSide_le_detDepth f false) (certSide_le_detDepth f true) theorem hierarchy_chain (f : (ι → Bool) → Bool) (b : Bool) : sensSide f b ≤ blockSensSide f b ∧ blockSensSide f b ≤ certSide f b ∧ certSide f b ≤ detDepth f := ⟨sensSide_le_blockSensSide f b, blockSensSide_le_certSide f b, certSide_le_detDepth f b⟩ end Foundations /-! ## Pillar 1: Asymmetric `𝔽₂`-Degree (ANF) Midrijanis & Certificate Decision-Tree Bounds -/ section Pillar1 variable {ι : Type*} [Fintype ι] [DecidableEq ι] /-- Indicator vector `1_T : ι → Bool` of a subset `T : Finset ι`. -/ def indicatorVec (T : Finset ι) : ι → Bool := fun i => decide (i ∈ T) /-- Support of a Boolean input `x : ι → Bool`. -/ def inputSupp (x : ι → Bool) : Finset ι := Finset.univ.filter (fun i => x i = true) @[simp] lemma indicatorVec_inputSupp (x : ι → Bool) : indicatorVec (inputSupp x) = x := by ext i; simp [indicatorVec, inputSupp] @[simp] lemma inputSupp_indicatorVec (T : Finset ι) : inputSupp (indicatorVec T) = T := by ext i; simp [indicatorVec, inputSupp] /-- Boolean value embedded in `ZMod 2`. -/ def boolToZ2 (b : Bool) : ZMod 2 := if b then 1 else 0 /-- Algebraic Normal Form (`𝔽₂`-Möbius) coefficient of monomial `S : Finset ι`. -/ def anfCoeff (f : (ι → Bool) → Bool) (S : Finset ι) : ZMod 2 := ∑ T ∈ S.powerset, boolToZ2 (f (indicatorVec T)) /-- Exact `𝔽₂`-degree `deg₂(f)` (maximum degree of a nonzero ANF monomial). -/ def deg2 (f : (ι → Bool) → Bool) : ℕ := (Finset.univ.filter (fun S : Finset ι => anfCoeff f S ≠ 0)).sup Finset.card /-- Helper: in `ZMod 2`, the sum of `1` over all `S` with `T ⊆ S ⊆ X` is `1` iff `T = X`. -/ lemma sum_Icc_zmod2 (T X : Finset ι) (hTX : T ⊆ X) : (∑ _S ∈ X.powerset.filter (fun S => T ⊆ S), (1 : ZMod 2)) = if T = X then 1 else 0 := by have hbij : (X.powerset.filter (fun S => T ⊆ S)).card = (X \ T).powerset.card := by apply Finset.card_bij (fun S _ => S \ T) · intro S hS rw [Finset.mem_powerset] rw [Finset.mem_filter, Finset.mem_powerset] at hS exact Finset.sdiff_subset_sdiff hS.1 Subset.rfl · intro S₁ hS₁ S₂ hS₂ heq rw [Finset.mem_filter] at hS₁ hS₂ rw [← Finset.sdiff_union_of_subset hS₁.2, ← Finset.sdiff_union_of_subset hS₂.2, heq] · intro R hR rw [Finset.mem_powerset] at hR refine ⟨R ∪ T, ?_, ?_⟩ · rw [Finset.mem_filter, Finset.mem_powerset] exact ⟨Finset.union_subset (hR.trans Finset.sdiff_subset) hTX, Finset.subset_union_right⟩ · ext i simp only [Finset.mem_sdiff, Finset.mem_union] by_cases hi : i ∈ T · have hni : i ∉ R := fun hr => (Finset.mem_sdiff.mp (hR hr)).2 hi simp [hi, hni] · simp [hi] rw [Finset.sum_const, nsmul_eq_mul, mul_one, hbij, Finset.card_powerset] by_cases heq : T = X · subst heq; simp · have hne : (X \ T).Nonempty := Finset.sdiff_nonempty.mpr (fun h => heq (Finset.Subset.antisymm hTX h)) have hpos : 0 < (X \ T).card := Finset.card_pos.mpr hne have h2 : (2 : ZMod 2) = 0 := rfl rw [if_neg heq] have : ((2 ^ (X \ T).card : ℕ) : ZMod 2) = (2 : ZMod 2) ^ (X \ T).card := by push_cast; rfl rw [this, h2, zero_pow (Nat.ne_of_gt hpos)] /-- Exact ANF (`𝔽₂`-polynomial) evaluation identity: `f(x) = ∑_{S ⊆ supp(x)} anfCoeff f S`. -/ theorem anf_eval (f : (ι → Bool) → Bool) (x : ι → Bool) : boolToZ2 (f x) = ∑ S ∈ (inputSupp x).powerset, anfCoeff f S := by let X := inputSupp x have hx : x = indicatorVec X := (indicatorVec_inputSupp x).symm conv_lhs => rw [hx] simp only [anfCoeff] rw [Finset.sum_sigma'] have hswap : (∑ p ∈ X.powerset.sigma Finset.powerset, boolToZ2 (f (indicatorVec p.2))) = ∑ T ∈ X.powerset, ∑ S ∈ X.powerset.filter (fun S => T ⊆ S), boolToZ2 (f (indicatorVec T)) := by rw [Finset.sum_sigma'] apply Finset.sum_bij (fun p _ => ⟨p.2, p.1⟩) · intro ⟨S, T⟩ hp simp only [Finset.mem_sigma, Finset.mem_powerset, Finset.mem_filter] at hp ⊢ exact ⟨hp.2.trans hp.1, hp.1, hp.2⟩ · intro ⟨S₁, T₁⟩ _ ⟨S₂, T₂⟩ _ heq cases heq; rfl · intro ⟨T, S⟩ hp simp only [Finset.mem_sigma, Finset.mem_powerset, Finset.mem_filter] at hp ⊢ exact ⟨⟨S, T⟩, ⟨hp.2.1, hp.2.2⟩, rfl⟩ · intro _ _; rfl rw [hswap] have hinner : ∀ T ∈ X.powerset, (∑ S ∈ X.powerset.filter (fun S => T ⊆ S), boolToZ2 (f (indicatorVec T))) = if T = X then boolToZ2 (f (indicatorVec T)) else 0 := by intro T hT have hTX : T ⊆ X := Finset.mem_powerset.mp hT have h1 := sum_Icc_zmod2 T X hTX calc ∑ S ∈ X.powerset.filter (fun S => T ⊆ S), boolToZ2 (f (indicatorVec T)) = (∑ S ∈ X.powerset.filter (fun S => T ⊆ S), (1 : ZMod 2)) * boolToZ2 (f (indicatorVec T)) := by rw [Finset.sum_mul]; simp _ = (if T = X then 1 else 0) * boolToZ2 (f (indicatorVec T)) := by rw [h1] _ = if T = X then boolToZ2 (f (indicatorVec T)) else 0 := by split_ifs <;> simp rw [Finset.sum_congr rfl hinner, Finset.sum_ite_eq'] simp /-- Uniqueness of ANF coefficients: any `𝔽₂`-multilinear expansion agrees coefficientwise with `anfCoeff`. -/ lemma anfCoeff_unique (f : (ι → Bool) → Bool) (c : Finset ι → ZMod 2) (heval : ∀ x : ι → Bool, boolToZ2 (f x) = ∑ S ∈ (inputSupp x).powerset, c S) : ∀ S : Finset ι, anfCoeff f S = c S := by intro S simp only [anfCoeff] have h1 : ∀ T ∈ S.powerset, boolToZ2 (f (indicatorVec T)) = ∑ U ∈ T.powerset, c U := by intro T _ rw [heval (indicatorVec T), inputSupp_indicatorVec] rw [Finset.sum_congr rfl h1, Finset.sum_sigma'] have hswap : (∑ p ∈ S.powerset.sigma Finset.powerset, c p.2) = ∑ U ∈ S.powerset, ∑ T ∈ S.powerset.filter (fun T => U ⊆ T), c U := by rw [Finset.sum_sigma'] apply Finset.sum_bij (fun p _ => ⟨p.2, p.1⟩) · intro ⟨T, U⟩ hp simp only [Finset.mem_sigma, Finset.mem_powerset, Finset.mem_filter] at hp ⊢ exact ⟨hp.2.trans hp.1, hp.1, hp.2⟩ · intro ⟨T₁, U₁⟩ _ ⟨T₂, U₂⟩ _ heq; cases heq; rfl · intro ⟨U, T⟩ hp simp only [Finset.mem_sigma, Finset.mem_powerset, Finset.mem_filter] at hp ⊢ exact ⟨⟨T, U⟩, ⟨hp.2.1, hp.2.2⟩, rfl⟩ · intro _ _; rfl rw [hswap] have hinner : ∀ U ∈ S.powerset, (∑ T ∈ S.powerset.filter (fun T => U ⊆ T), c U) = if U = S then c U else 0 := by intro U hU have hUS : U ⊆ S := Finset.mem_powerset.mp hU calc ∑ T ∈ S.powerset.filter (fun T => U ⊆ T), c U = (∑ T ∈ S.powerset.filter (fun T => U ⊆ T), (1 : ZMod 2)) * c U := by rw [Finset.sum_mul]; simp _ = (if U = S then 1 else 0) * c U := by rw [sum_Icc_zmod2 U S hUS] _ = if U = S then c U else 0 := by split_ifs <;> simp rw [Finset.sum_congr rfl hinner, Finset.sum_ite_eq'] simp /-- Restricting variables in `M` to `ρ` produces an ANF whose coefficients are sums over subsets of `M` that evaluate to `1` under `ρ`; in particular `deg₂(f|_ρ) ≤ deg₂(f)`. -/ lemma anfCoeff_restrict (f : (ι → Bool) → Bool) (M : Finset ι) (ρ : ι → Bool) (S : Finset ι) : anfCoeff (restrict f M ρ) S = if Disjoint S M then ∑ R ∈ (M.filter (fun i => ρ i = true)).powerset, anfCoeff f (S ∪ R) else 0 := by let M1 := M.filter (fun i => ρ i = true) let c : Finset ι → ZMod 2 := fun S => if Disjoint S M then ∑ R ∈ M1.powerset, anfCoeff f (S ∪ R) else 0 suffices h : ∀ x : ι → Bool, boolToZ2 (restrict f M ρ x) = ∑ S ∈ (inputSupp x).powerset, c S by exact anfCoeff_unique (restrict f M ρ) c h S intro x rw [restrict, anf_eval] have hsupp : inputSupp (fun i => if i ∈ M then ρ i else x i) = (inputSupp x \ M) ∪ M1 := by ext i simp only [inputSupp, M1, Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_union, Finset.mem_sdiff] by_cases hi : i ∈ M <;> simp [hi] rw [hsupp] have hdisj : Disjoint (inputSupp x \ M) M1 := Finset.disjoint_left.mpr fun i hi1 hi2 => (Finset.mem_sdiff.mp hi1).2 (Finset.mem_filter.mp hi2).1 have hlhs : (∑ U ∈ ((inputSupp x \ M) ∪ M1).powerset, anfCoeff f U) = ∑ S ∈ (inputSupp x \ M).powerset, ∑ R ∈ M1.powerset, anfCoeff f (S ∪ R) := by rw [Finset.sum_sigma'] symm apply Finset.sum_bij (fun p _ => p.1 ∪ p.2) · intro ⟨S, R⟩ hp simp only [Finset.mem_sigma, Finset.mem_powerset] at hp ⊢ exact Finset.union_subset_union hp.1 hp.2 · intro ⟨S₁, R₁⟩ hp₁ ⟨S₂, R₂⟩ hp₂ heq simp only [Finset.mem_sigma, Finset.mem_powerset] at hp₁ hp₂ have hS : S₁ = S₂ := by ext i have := Finset.ext_iff.mp heq i constructor · intro hi have hni : i ∉ M1 := Finset.disjoint_left.mp hdisj (hp₁.1 hi) have hni2 : i ∉ R₂ := fun h => hni (hp₂.2 h) simpa [hni2] using this.mp (Finset.mem_union_left R₁ hi) · intro hi have hni : i ∉ M1 := Finset.disjoint_left.mp hdisj (hp₂.1 hi) have hni1 : i ∉ R₁ := fun h => hni (hp₁.2 h) simpa [hni1] using this.mpr (Finset.mem_union_left R₂ hi) have hR : R₁ = R₂ := by ext i have := Finset.ext_iff.mp heq i constructor · intro hi have hni : i ∉ inputSupp x \ M := Finset.disjoint_right.mp hdisj (hp₁.2 hi) have hni2 : i ∉ S₂ := fun h => hni (hp₂.1 h) simpa [hni2] using this.mp (Finset.mem_union_right S₁ hi) · intro hi have hni : i ∉ inputSupp x \ M := Finset.disjoint_right.mp hdisj (hp₂.2 hi) have hni1 : i ∉ S₁ := fun h => hni (hp₁.1 h) simpa [hni1] using this.mpr (Finset.mem_union_right S₂ hi) subst hS; subst hR; rfl · intro U hU rw [Finset.mem_powerset] at hU refine ⟨⟨U ∩ (inputSupp x \ M), U ∩ M1⟩, ?_, ?_⟩ · simp only [Finset.mem_sigma, Finset.mem_powerset] exact ⟨Finset.inter_subset_right, Finset.inter_subset_right⟩ · ext i simp only [Finset.mem_union, Finset.mem_inter] constructor · rintro (⟨hi, _⟩ | ⟨hi, _⟩) <;> exact hi · intro hi rcases Finset.mem_union.mp (hU hi) with h1 | h2 · exact Or.inl ⟨hi, h1⟩ · exact Or.inr ⟨hi, h2⟩ · intro _ _; rfl rw [hlhs] symm calc ∑ S ∈ (inputSupp x).powerset, c S = ∑ S ∈ (inputSupp x).powerset.filter (fun S => Disjoint S M), ∑ R ∈ M1.powerset, anfCoeff f (S ∪ R) := by rw [Finset.sum_filter] _ = ∑ S ∈ (inputSupp x \ M).powerset, ∑ R ∈ M1.powerset, anfCoeff f (S ∪ R) := by congr 1 ext S simp only [Finset.mem_filter, Finset.mem_powerset, Finset.subset_sdiff] lemma deg2_restrict_le (f : (ι → Bool) → Bool) (M : Finset ι) (ρ : ι → Bool) : deg2 (restrict f M ρ) ≤ deg2 f := by unfold deg2 apply Finset.sup_le intro S hS have hne : anfCoeff (restrict f M ρ) S ≠ 0 := (Finset.mem_filter.mp hS).2 rw [anfCoeff_restrict] at hne split_ifs at hne with hdisj · have hex : ∃ R ∈ (M.filter (fun i => ρ i = true)).powerset, anfCoeff f (S ∪ R) ≠ 0 := by by_contra hall push Not at hall exact hne (Finset.sum_eq_zero hall) obtain ⟨R, _, hR⟩ := hex calc S.card ≤ (S ∪ R).card := Finset.card_le_card Finset.subset_union_left _ ≤ (Finset.univ.filter (fun T => anfCoeff f T ≠ 0)).sup Finset.card := Finset.le_sup (f := Finset.card) (by simp [hR]) · exact absurd rfl hne lemma deg2_eq_zero_iff_const (f : (ι → Bool) → Bool) : deg2 f = 0 ↔ ∀ x y, f x = f y := by constructor · intro hdeg x y have hzero : ∀ S : Finset ι, S.Nonempty → anfCoeff f S = 0 := by intro S hSne by_contra hne have hle : S.card ≤ deg2 f := Finset.le_sup (f := Finset.card) (by simp [hne]) have hpos : 0 < S.card := Finset.card_pos.mpr hSne omega have hev : ∀ z : ι → Bool, boolToZ2 (f z) = anfCoeff f ∅ := by intro z rw [anf_eval] rw [Finset.sum_eq_single ∅] · intro S _ hne exact hzero S (Finset.nonempty_iff_ne_empty.mpr hne) · intro h; exact absurd (Finset.empty_mem_powerset _) h have hxy : boolToZ2 (f x) = boolToZ2 (f y) := (hev x).trans (hev y).symm cases h1 : f x <;> cases h2 : f y <;> simp_all [boolToZ2] · intro hconst apply Nat.le_zero.mp unfold deg2 apply Finset.sup_le intro S hS have hne : anfCoeff f S ≠ 0 := (Finset.mem_filter.mp hS).2 by_cases hemp : S = ∅ · simp [hemp] · exfalso have h1 : ∀ z, boolToZ2 (f z) = ∑ U ∈ (inputSupp z).powerset, (if U = ∅ then boolToZ2 (f (fun _ => false)) else 0) := by intro z rw [Finset.sum_ite_eq'] simp [hconst z (fun _ => false)] have h2 := anfCoeff_unique f (fun U => if U = ∅ then boolToZ2 (f (fun _ => false)) else 0) h1 S simp [hemp] at h2 exact hne h2 /-- Key hitting property: if `M` is a maximum-degree ANF monomial (`|M| = deg₂(f) ≥ 1`), then `f` cannot be constant on any subcube where all coordinates in `M` are free; equivalently, for every `x`, there is a sensitive block `S ⊆ M` at `x`. -/ lemma anf_top_monomial_has_sensBlock {f : (ι → Bool) → Bool} {M : Finset ι} (hM_nz : anfCoeff f M ≠ 0) (hM_deg : M.card = deg2 f) (hM_ne : M.Nonempty) (x : ι → Bool) : ∃ S ⊆ M, IsSensBlock f x S := by by_contra hno push Not at hno -- `g := restrict f Mᶜ x` fixes all coordinates outside `M` to `x`, so `g` is constant! let g := restrict f Mᶜ x have hg_const : ∀ z, g z = f x := by intro z let S := M.filter (fun i => z i ≠ x i) have hSM : S ⊆ M := Finset.filter_subset _ _ have hfl : (fun i => if i ∈ Mᶜ then x i else z i) = flipSet x S := by ext i by_cases hi : i ∈ M · by_cases hzx : z i = x i · simp [flipSet, S, hi, hzx] · have hmemS : i ∈ S := Finset.mem_filter.mpr ⟨hi, hzx⟩ simp only [Finset.mem_compl, hi, not_true_eq_false, ↓reduceIte, flipSet, hmemS] cases h1 : z i <;> cases h2 : x i <;> simp_all · have hnS : i ∉ S := fun h => hi (hSM h) simp [flipSet, hi, hnS] simp only [g, restrict, hfl] have := hno S hSM unfold IsSensBlock at this push Not at this exact this -- On the other hand, `anfCoeff g M = anfCoeff f M ≠ 0` because `M` is max-degree! have hcoeff_g : anfCoeff g M = anfCoeff f M := by rw [anfCoeff_restrict] have hdisj : Disjoint M Mᶜ := disjoint_compl_right rw [if_pos hdisj] rw [Finset.sum_eq_single ∅] · simp · intro R hR hRne by_contra hnz have hle : (M ∪ R).card ≤ deg2 f := Finset.le_sup (f := Finset.card) (by simp [hnz]) have hdisjMR : Disjoint M R := by have hRsub : R ⊆ Mᶜ := (Finset.mem_powerset.mp hR).trans (Finset.filter_subset _ _) exact Finset.disjoint_of_subset_right hRsub hdisj have hcard : (M ∪ R).card = M.card + R.card := Finset.card_union_of_disjoint hdisjMR have hRpos : 0 < R.card := Finset.card_pos.mpr (Finset.nonempty_iff_ne_empty.mpr hRne) omega · intro hemp; exact absurd (Finset.empty_mem_powerset _) hemp have hdeg_g : deg2 g = 0 := (deg2_eq_zero_iff_const g).mpr (fun u v => (hg_const u).trans (hg_const v).symm) have hle : M.card ≤ deg2 g := Finset.le_sup (f := Finset.card) (by simp [hcoeff_g, hM_nz]) have hpos : 0 < M.card := Finset.card_pos.mpr hM_ne omega /-- **Theorem 1A (Simultaneous ANF Top-Monomial Drop)**: For any max-degree ANF monomial `M` (`|M| = deg₂(f) ≥ 1`) and any assignment `ρ` to `M`, restricting `f` on `M` simultaneously drops `bs₀`, `bs₁`, `C₀`, and `C₁` by at least `1` while preserving `deg₂(f|_ρ) ≤ deg₂(f)`. -/ theorem anf_top_monomial_simultaneous_drop {f : (ι → Bool) → Bool} {M : Finset ι} (hM_nz : anfCoeff f M ≠ 0) (hM_deg : M.card = deg2 f) (hM_ne : M.Nonempty) (ρ : ι → Bool) (b : Bool) : blockSensSide (restrict f M ρ) b + 1 ≤ blockSensSide f b ∧ certSide (restrict f M ρ) b + 1 ≤ certSide f b ∧ deg2 (restrict f M ρ) ≤ deg2 f := by refine ⟨?_, ?_, deg2_restrict_le f M ρ⟩ · -- Drop of `bs_b`: have h1 : ∀ x : ι → Bool, restrict f M ρ x = b → blockSensAt (restrict f M ρ) x + 1 ≤ blockSensSide f b := by intro x hx let x' : ι → Bool := fun i => if i ∈ M then ρ i else x i have hfx' : f x' = b := hx obtain ⟨ℬ, hℬ, hℬcard⟩ := exists_disjointSensBlocks_eq_blockSensAt (restrict f M ρ) x rw [← hℬcard] -- Replace each block `B ∈ ℬ` by `B \ M`, which stays sensitive for `f` at `x'` and disjoint from `M` let ℬ' := ℬ.image (fun B => B \ M) have hmem_sens : ∀ B ∈ ℬ, IsSensBlock f x' (B \ M) := by intro B hB have h := hℬ.1 B hB rw [IsSensBlock, restrict_flipSet_sdiff] at h exact h have hcard_eq : ℬ'.card = ℬ.card := by apply Finset.card_image_of_injOn intro B₁ hB₁ B₂ hB₂ heq by_contra hne have hdisj := hℬ.2 hB₁ hB₂ hne have hne1 : (B₁ \ M).Nonempty := (hmem_sens B₁ hB₁).nonempty obtain ⟨i, hi⟩ := hne1 have heq' : B₁ \ M = B₂ \ M := heq have hi2 : i ∈ B₂ \ M := heq' ▸ hi exact Finset.disjoint_left.mp hdisj (Finset.mem_sdiff.mp hi).1 (Finset.mem_sdiff.mp hi2).1 -- Add one sensitive block `S ⊆ M` at `x'`! obtain ⟨S, hSM, hS⟩ := anf_top_monomial_has_sensBlock hM_nz hM_deg hM_ne x' have hS_not_mem : S ∉ ℬ' := by intro hmem rcases Finset.mem_image.mp hmem with ⟨B, _, hBM⟩ obtain ⟨i, hiS⟩ := hS.nonempty have hiBM : i ∈ B \ M := hBM ▸ hiS exact (Finset.mem_sdiff.mp hiBM).2 (hSM hiS) have hfam : IsDisjointSensBlocks f x' (insert S ℬ') := by refine ⟨?_, ?_⟩ · intro B hB rcases Finset.mem_insert.mp hB with rfl | hB' · exact hS · rcases Finset.mem_image.mp hB' with ⟨C, hC, rfl⟩ exact hmem_sens C hC · intro B₁ hB₁ B₂ hB₂ hne rcases Finset.mem_insert.mp hB₁ with rfl | hB₁' <;> rcases Finset.mem_insert.mp hB₂ with rfl | hB₂' · exact absurd rfl hne · rcases Finset.mem_image.mp hB₂' with ⟨C, _, rfl⟩ exact Finset.disjoint_left.mpr fun i hiS hiCM => (Finset.mem_sdiff.mp hiCM).2 (hSM hiS) · rcases Finset.mem_image.mp hB₁' with ⟨C, _, rfl⟩ exact Finset.disjoint_right.mpr fun i hiS hiCM => (Finset.mem_sdiff.mp hiCM).2 (hSM hiS) · rcases Finset.mem_image.mp hB₁' with ⟨C₁, hC₁, rfl⟩ rcases Finset.mem_image.mp hB₂' with ⟨C₂, hC₂, rfl⟩ have hCne : C₁ ≠ C₂ := fun h => hne (by rw [h]) exact (hℬ.2 hC₁ hC₂ hCne).mono Finset.sdiff_subset Finset.sdiff_subset have hle := card_le_blockSensAt hfam rw [Finset.card_insert_of_notMem hS_not_mem, hcard_eq] at hle exact hle.trans (hfx' ▸ blockSensAt_le_blockSensSide f x') by_cases hne : (Finset.univ.filter (fun x => restrict f M ρ x = b)).Nonempty · obtain ⟨x, hx, hsup⟩ := Finset.exists_mem_eq_sup _ hne (blockSensAt (restrict f M ρ)) rw [blockSensSide, hsup] exact h1 x (Finset.mem_filter.mp hx).2 · have hemp : Finset.univ.filter (fun x => restrict f M ρ x = b) = ∅ := Finset.not_nonempty_iff_eq_empty.mp hne rw [blockSensSide, hemp, Finset.sup_empty, bot_eq_zero, zero_add] have hnc : ∃ x y, f x ≠ f y := by by_contra hc push Not at hc have h0 := (deg2_eq_zero_iff_const f).mpr hc have hpos := Finset.card_pos.mpr hM_ne omega exact blockSensSide_pos_of_nonconst hnc b · -- Drop of `C_b`: have h1 : ∀ x : ι → Bool, restrict f M ρ x = b → certAt (restrict f M ρ) x + 1 ≤ certSide f b := by intro x hx let x' : ι → Bool := fun i => if i ∈ M then ρ i else x i have hfx' : f x' = b := hx obtain ⟨K, hK, hKcard⟩ := exists_isCert_eq_certAt f x' -- `K` must intersect `M` because `M` contains a sensitive block at `x'`! obtain ⟨S, hSM, hS⟩ := anf_top_monomial_has_sensBlock hM_nz hM_deg hM_ne x' obtain ⟨i₀, hi₀⟩ := isCert_inter_sensBlock_nonempty hK hS have hi₀K : i₀ ∈ K := (Finset.mem_inter.mp hi₀).1 have hi₀M : i₀ ∈ M := hSM (Finset.mem_inter.mp hi₀).2 -- `K \ M` is a certificate for `restrict f M ρ` at `x` of size ≤ |K| - 1! have hKM_cert : IsCert (restrict f M ρ) x (K \ M) := by intro y hy simp only [restrict] apply hK intro i hiK by_cases hiM : i ∈ M · simp [x', hiM] · simp [x', hiM, hy i (Finset.mem_sdiff.mpr ⟨hiK, hiM⟩)] have hsub : K \ M ⊆ K.erase i₀ := fun i hi => by rw [Finset.mem_sdiff] at hi exact Finset.mem_erase.mpr ⟨fun h => hi.2 (h ▸ hi₀M), hi.1⟩ have hcard_lt : (K \ M).card + 1 ≤ K.card := by have h1 := Finset.card_le_card hsub have h2 := Finset.card_erase_add_one hi₀K omega calc certAt (restrict f M ρ) x + 1 ≤ (K \ M).card + 1 := Nat.add_le_add_right (certAt_le_of_isCert hKM_cert) 1 _ ≤ K.card := hcard_lt _ = certAt f x' := hKcard _ ≤ certSide f b := hfx' ▸ certAt_le_certSide f x' by_cases hne : (Finset.univ.filter (fun x => restrict f M ρ x = b)).Nonempty · obtain ⟨x, hx, hsup⟩ := Finset.exists_mem_eq_sup _ hne (certAt (restrict f M ρ)) rw [certSide, hsup] exact h1 x (Finset.mem_filter.mp hx).2 · have hemp : Finset.univ.filter (fun x => restrict f M ρ x = b) = ∅ := Finset.not_nonempty_iff_eq_empty.mp hne rw [certSide, hemp, Finset.sup_empty, bot_eq_zero, zero_add] have hnc : ∃ x y, f x ≠ f y := by by_contra hc; push Not at hc have h0 := (deg2_eq_zero_iff_const f).mpr hc have hpos := Finset.card_pos.mpr hM_ne; omega exact (blockSensSide_pos_of_nonconst hnc b).trans (blockSensSide_le_certSide f b) /-- **Theorem 1B (Sharp Asymmetric `𝔽₂`-Midrijanis Bound)**: For every Boolean function `f : (ι → Bool) → Bool` and every side `b ∈ {false, true}`, `D(f) ≤ deg₂(f) · bs_b(f)`, hence `D(f) ≤ deg₂(f) · min(bs₀(f), bs₁(f))`. -/ theorem detDepth_le_deg2_mul_blockSensSide (f : (ι → Bool) → Bool) (b : Bool) : detDepth f ≤ deg2 f * blockSensSide f b := by suffices h : ∀ k, ∀ g : (ι → Bool) → Bool, blockSensSide g b ≤ k → detDepth g ≤ deg2 g * k by exact h (blockSensSide f b) f le_rfl intro k induction k with | zero => intro g hg have hg0 : blockSensSide g b = 0 := Nat.le_zero.mp hg have hconst := const_of_blockSensSide_eq_zero hg0 rw [detDepth_eq_zero_of_const (c := g (fun _ => false)) (fun x => hconst x _)] exact Nat.zero_le _ | succ k ih => intro g hg by_cases hdeg0 : deg2 g = 0 · have hconst := (deg2_eq_zero_iff_const g).mp hdeg0 rw [detDepth_eq_zero_of_const (c := g (fun _ => false)) (fun x => hconst x _)] exact Nat.zero_le _ · have hne : (Finset.univ.filter (fun S : Finset ι => anfCoeff g S ≠ 0)).Nonempty := by by_contra hemp rw [Finset.not_nonempty_iff_eq_empty] at hemp exact hdeg0 (by simp [deg2, hemp]) obtain ⟨M, hMmem, hMdeg⟩ := Finset.exists_mem_eq_sup _ hne Finset.card have hM_nz : anfCoeff g M ≠ 0 := (Finset.mem_filter.mp hMmem).2 have hM_card : M.card = deg2 g := hMdeg.symm have hM_ne : M.Nonempty := Finset.card_pos.mp (by omega) have hstep : detDepth g ≤ M.card + deg2 g * k := by apply detDepth_le_card_add_sup_restrict g M (deg2 g * k) intro ρ obtain ⟨hbs, _, hd2⟩ := anf_top_monomial_simultaneous_drop hM_nz hM_card hM_ne ρ b have hbk : blockSensSide (restrict g M ρ) b ≤ k := by omega exact (ih (restrict g M ρ) hbk).trans (Nat.mul_le_mul_right k hd2) calc detDepth g ≤ M.card + deg2 g * k := hstep _ = deg2 g + deg2 g * k := by rw [hM_card] _ = deg2 g * (k + 1) := by ring theorem detDepth_le_deg2_mul_min_bs (f : (ι → Bool) → Bool) : detDepth f ≤ deg2 f * min (blockSensSide f false) (blockSensSide f true) := by rcases le_total (blockSensSide f false) (blockSensSide f true) with h | h · rw [min_eq_left h]; exact detDepth_le_deg2_mul_blockSensSide f false · rw [min_eq_right h]; exact detDepth_le_deg2_mul_blockSensSide f true /-- Querying a `(!b)`-certificate `S` of `f` leaves `C_{!b}` non-increasing and strictly drops `bs_b` on every branch where the restricted function is nonconstant (or makes it constant `(!b)`). -/ lemma certSide_restrict_le (f : (ι → Bool) → Bool) (M : Finset ι) (ρ : ι → Bool) (b : Bool) : certSide (restrict f M ρ) b ≤ certSide f b := by unfold certSide apply Finset.sup_le intro x hx have hfx : restrict f M ρ x = b := (Finset.mem_filter.mp hx).2 let x' : ι → Bool := fun i => if i ∈ M then ρ i else x i have hfx' : f x' = b := hfx obtain ⟨K, hK, hKcard⟩ := exists_isCert_eq_certAt f x' have hK_res : IsCert (restrict f M ρ) x (K \ M) := by intro y hy simp only [restrict] apply hK intro i hiK by_cases hiM : i ∈ M · simp [x', hiM] · simp [x', hiM, hy i (Finset.mem_sdiff.mpr ⟨hiK, hiM⟩)] calc certAt (restrict f M ρ) x ≤ (K \ M).card := certAt_le_of_isCert hK_res _ ≤ K.card := Finset.card_le_card Finset.sdiff_subset _ = certAt f x' := hKcard _ ≤ certSide f b := hfx' ▸ certAt_le_certSide f x' /-- **Theorem 1C (Sharp Asymmetric Beals–Buhrman–Cleve–Mosca–de Wolf & Blum–Impagliazzo–Tardos Bounds)**: For every Boolean function `f` and side `b ∈ {false, true}`, `D(f) ≤ C_{!b}(f) · bs_b(f) ≤ C₀(f) · C₁(f)`. -/ theorem detDepth_le_certSide_not_mul_blockSensSide (f : (ι → Bool) → Bool) (b : Bool) : detDepth f ≤ certSide f (!b) * blockSensSide f b := by suffices h : ∀ k, ∀ g : (ι → Bool) → Bool, blockSensSide g b ≤ k → detDepth g ≤ certSide g (!b) * k by exact h (blockSensSide f b) f le_rfl intro k induction k with | zero => intro g hg have hg0 : blockSensSide g b = 0 := Nat.le_zero.mp hg have hconst := const_of_blockSensSide_eq_zero hg0 rw [detDepth_eq_zero_of_const (c := g (fun _ => false)) (fun x => hconst x _)] exact Nat.zero_le _ | succ k ih => intro g hg by_cases hconst : ∀ x, g x = b · rw [detDepth_eq_zero_of_const hconst]; exact Nat.zero_le _ · push Not at hconst obtain ⟨x₁, hx₁⟩ := hconst have hgx₁ : g x₁ = !b := by cases h : g x₁ <;> cases b <;> simp_all obtain ⟨S, hS, hScard⟩ := exists_isCert_eq_certAt g x₁ have hS_le : S.card ≤ certSide g (!b) := hScard.symm ▸ hgx₁ ▸ certAt_le_certSide g x₁ have hstep : detDepth g ≤ S.card + certSide g (!b) * k := by apply detDepth_le_card_add_sup_restrict g S (certSide g (!b) * k) intro ρ by_cases hagree : ∀ i ∈ S, ρ i = x₁ i · have hrc : ∀ y, restrict g S ρ y = !b := fun y => by rw [restrict, ← hgx₁] exact hS _ (fun i hi => by simp [hi, hagree i hi]) rw [detDepth_eq_zero_of_const hrc]; exact Nat.zero_le _ · -- `ρ` disagrees with `x₁` on `S`: every `b`-input of `restrict g S ρ` can flip a subset of `S` -- to match `x₁` on `S`, giving a sensitive block inside `S`! have hbs_drop : blockSensSide (restrict g S ρ) b ≤ k := by unfold blockSensSide apply Finset.sup_le intro x hx have hrx : restrict g S ρ x = b := (Finset.mem_filter.mp hx).2 let x' : ι → Bool := fun i => if i ∈ S then ρ i else x i have hgx' : g x' = b := hrx obtain ⟨ℬ, hℬ, hℬcard⟩ := exists_disjointSensBlocks_eq_blockSensAt (restrict g S ρ) x let ℬ' := ℬ.image (fun B => B \ S) have hmem_sens : ∀ B ∈ ℬ, IsSensBlock g x' (B \ S) := by intro B hB have h := hℬ.1 B hB rw [IsSensBlock, restrict_flipSet_sdiff] at h exact h have hcard_eq : ℬ'.card = ℬ.card := by apply Finset.card_image_of_injOn intro B₁ hB₁ B₂ hB₂ heq by_contra hne obtain ⟨i, hi⟩ := (hmem_sens B₁ hB₁).nonempty have heq' : B₁ \ S = B₂ \ S := heq have hi2 : i ∈ B₂ \ S := heq' ▸ hi exact Finset.disjoint_left.mp (hℬ.2 hB₁ hB₂ hne) (Finset.mem_sdiff.mp hi).1 (Finset.mem_sdiff.mp hi2).1 let D : Finset ι := S.filter (fun i => ρ i ≠ x₁ i) have hDsub : D ⊆ S := Finset.filter_subset _ _ have hD_sens : IsSensBlock g x' D := by have hmatch : ∀ i ∈ S, flipSet x' D i = x₁ i := by intro i hiS by_cases hne : ρ i = x₁ i · have hnD : i ∉ D := fun h => (Finset.mem_filter.mp h).2 hne simp [flipSet, x', hiS, hnD, hne] · have hmemD : i ∈ D := Finset.mem_filter.mpr ⟨hiS, hne⟩ simp only [flipSet, hmemD, ↓reduceIte, x', hiS] cases h1 : ρ i <;> cases h2 : x₁ i <;> simp_all rw [IsSensBlock, hS _ hmatch, hgx₁, hgx'] cases b <;> decide have hD_not_mem : D ∉ ℬ' := by intro hmem rcases Finset.mem_image.mp hmem with ⟨B, _, hBS⟩ obtain ⟨i, hiD⟩ := hD_sens.nonempty have hiBS : i ∈ B \ S := hBS ▸ hiD exact (Finset.mem_sdiff.mp hiBS).2 (hDsub hiD) have hfam : IsDisjointSensBlocks g x' (insert D ℬ') := by refine ⟨?_, ?_⟩ · intro B hB rcases Finset.mem_insert.mp hB with rfl | hB' · exact hD_sens · rcases Finset.mem_image.mp hB' with ⟨C, hC, rfl⟩ exact hmem_sens C hC · intro B₁ hB₁ B₂ hB₂ hne rcases Finset.mem_insert.mp hB₁ with rfl | hB₁' <;> rcases Finset.mem_insert.mp hB₂ with rfl | hB₂' · exact absurd rfl hne · rcases Finset.mem_image.mp hB₂' with ⟨C, _, rfl⟩ exact Finset.disjoint_left.mpr fun i hiD hiCS => (Finset.mem_sdiff.mp hiCS).2 (hDsub hiD) · rcases Finset.mem_image.mp hB₁' with ⟨C, _, rfl⟩ exact Finset.disjoint_right.mpr fun i hiD hiCS => (Finset.mem_sdiff.mp hiCS).2 (hDsub hiD) · rcases Finset.mem_image.mp hB₁' with ⟨C₁, hC₁, rfl⟩ rcases Finset.mem_image.mp hB₂' with ⟨C₂, hC₂, rfl⟩ have hCne : C₁ ≠ C₂ := fun h => hne (by rw [h]) exact (hℬ.2 hC₁ hC₂ hCne).mono Finset.sdiff_subset Finset.sdiff_subset have hle := card_le_blockSensAt hfam rw [Finset.card_insert_of_notMem hD_not_mem, hcard_eq, hℬcard] at hle have hle2 : blockSensAt g x' ≤ k + 1 := (hgx' ▸ blockSensAt_le_blockSensSide g x').trans hg omega exact (ih (restrict g S ρ) hbs_drop).trans (Nat.mul_le_mul_right k (certSide_restrict_le g S ρ (!b))) calc detDepth g ≤ S.card + certSide g (!b) * k := hstep _ ≤ certSide g (!b) + certSide g (!b) * k := Nat.add_le_add_right hS_le _ _ = certSide g (!b) * (k + 1) := by ring theorem detDepth_le_cert1_mul_bs0 (f : (ι → Bool) → Bool) : detDepth f ≤ certSide f true * blockSensSide f false := detDepth_le_certSide_not_mul_blockSensSide f false theorem detDepth_le_cert0_mul_bs1 (f : (ι → Bool) → Bool) : detDepth f ≤ certSide f false * blockSensSide f true := detDepth_le_certSide_not_mul_blockSensSide f true theorem detDepth_le_cert0_mul_cert1 (f : (ι → Bool) → Bool) : detDepth f ≤ certSide f false * certSide f true := (detDepth_le_cert0_mul_bs1 f).trans (Nat.mul_le_mul_left _ (blockSensSide_le_certSide f true)) end Pillar1 /-! ## Pillar 2: Essential-Bit Double Counting, Strict Nisan Improvement, ## and Hypercube Bootstrap-Percolation Sensitivity Rigidity -/ section Pillar2 variable {ι : Type*} [Fintype ι] [DecidableEq ι] /-- Existence of a maximal pairwise-disjoint family of **minimal** sensitive blocks at `x`, whose union `U = ℬ.biUnion id` is a certificate at `x`. -/ lemma exists_maximal_minSensBlocks (f : (ι → Bool) → Bool) (x : ι → Bool) : ∃ ℬ : Finset (Finset ι), (∀ B ∈ ℬ, IsMinSensBlock f x B) ∧ (ℬ : Set (Finset ι)).PairwiseDisjoint id ∧ IsCert f x (ℬ.biUnion id) := by classical have hex : ∃ k : ℕ, ∃ ℬ : Finset (Finset ι), (∀ B ∈ ℬ, IsMinSensBlock f x B) ∧ (ℬ : Set (Finset ι)).PairwiseDisjoint id ∧ ℬ.card = k := ⟨0, ∅, by simp, by simp, rfl⟩ let ℱ := Finset.univ.filter (fun ℬ : Finset (Finset ι) => (∀ B ∈ ℬ, IsMinSensBlock f x B) ∧ (ℬ : Set (Finset ι)).PairwiseDisjoint id) have hne : ℱ.Nonempty := ⟨∅, Finset.mem_filter.mpr ⟨Finset.mem_univ _, by simp, by simp⟩⟩ obtain ⟨ℬ, hℬmem, hℬmax⟩ := Finset.exists_mem_eq_sup ℱ hne Finset.card obtain ⟨hmin, hdisj⟩ := (Finset.mem_filter.mp hℬmem).2 refine ⟨ℬ, hmin, hdisj, ?_⟩ rw [isCert_iff_hits_sensBlocks] intro E hE by_contra hno rw [Finset.not_nonempty_iff_eq_empty] at hno obtain ⟨E', hE'sub, hE'min⟩ := exists_minSensBlock_subset hE have hdisjE' : ∀ B ∈ ℬ, Disjoint E' B := by intro B hB rw [Finset.disjoint_left] intro i hiE' hiB have h1 : i ∈ ℬ.biUnion id ∩ E := Finset.mem_inter.mpr ⟨Finset.mem_biUnion.mpr ⟨B, hB, hiB⟩, hE'sub hiE'⟩ rw [hno] at h1 exact Finset.notMem_empty i h1 have hnotmem : E' ∉ ℬ := fun hmem => by obtain ⟨i, hi⟩ := hE'min.1.nonempty exact Finset.disjoint_left.mp (hdisjE' E' hmem) hi hi have hmem' : insert E' ℬ ∈ ℱ := by rw [Finset.mem_filter] refine ⟨Finset.mem_univ _, ?_, ?_⟩ · intro B hB rcases Finset.mem_insert.mp hB with rfl | hB' · exact hE'min · exact hmin B hB' · intro B₁ hB₁ B₂ hB₂ hne12 rcases Finset.mem_insert.mp hB₁ with rfl | hB₁' <;> rcases Finset.mem_insert.mp hB₂ with rfl | hB₂' · exact absurd rfl hne12 · exact hdisjE' B₂ hB₂' · exact (hdisjE' B₁ hB₁').symm · exact hdisj hB₁' hB₂' hne12 have hle : (insert E' ℬ).card ≤ ℬ.card := by rw [← hℬmax] exact Finset.le_sup (f := Finset.card) hmem' rw [Finset.card_insert_of_notMem hnotmem] at hle omega /-- **Theorem 2A (Nisan 1991 — Asymmetric Form)**: `C_b(f) ≤ s_{!b}(f) · bs_b(f)` for every Boolean function `f` and side `b`. -/ theorem nisan_cert_le_sens_mul_bs (f : (ι → Bool) → Bool) (b : Bool) : certSide f b ≤ sensSide f (!b) * blockSensSide f b := by unfold certSide apply Finset.sup_le intro x hx have hfx : f x = b := (Finset.mem_filter.mp hx).2 obtain ⟨ℬ, hmin, hdisj, hcert⟩ := exists_maximal_minSensBlocks f x have hcardU : (ℬ.biUnion id).card = ∑ B ∈ ℬ, B.card := Finset.card_biUnion hdisj have hsum : ∑ B ∈ ℬ, B.card ≤ ∑ _B ∈ ℬ, sensSide f (!b) := by apply Finset.sum_le_sum intro B hB simpa [hfx] using card_le_sensSide_not_of_minSensBlock (hmin B hB) have hℬle : ℬ.card ≤ blockSensSide f b := by have h1 : ℬ.card ≤ blockSensAt f x := card_le_blockSensAt ⟨fun B hB => (hmin B hB).1, hdisj⟩ exact h1.trans (hfx ▸ blockSensAt_le_blockSensSide f x) calc certAt f x ≤ (ℬ.biUnion id).card := certAt_le_of_isCert hcert _ = ∑ B ∈ ℬ, B.card := hcardU _ ≤ ℬ.card * sensSide f (!b) := by simpa using hsum _ = sensSide f (!b) * ℬ.card := Nat.mul_comm _ _ _ ≤ sensSide f (!b) * blockSensSide f b := Nat.mul_le_mul_left _ hℬle /-- The set of non-singleton essential bits of `U = ℬ.biUnion id` at `x`. -/ noncomputable def essentialNonSingletonBits (f : (ι → Bool) → Bool) (x : ι → Bool) (ℬ : Finset (Finset ι)) : Finset ι := by classical let U := ℬ.biUnion id exact U.filter (fun i => (∃ B ∈ ℬ, i ∈ B ∧ 2 ≤ B.card) ∧ ¬ IsCert f x (U.erase i)) /-- **Theorem 2B (NEW — Essential-Bit Sensitivity-Deficit Double-Counting Law)**: Let `ℬ` be a pairwise-disjoint family of minimal sensitive blocks of `f` at `x` (`f x = b`) with `|ℬ| = bs_b(f)` and union `U = ℬ.biUnion id`. Then every `i ∈ essentialNonSingletonBits f x ℬ` is sensitive at `x^{⊕ B}` for at least one block `B ∈ ℬ` not containing `i`, yielding the exact double-counting deficit inequality: `|U| + |M_{≥2}| ≤ s_{!b}(f) · bs_b(f)`. -/ theorem essential_bit_sensitivity_deficit {f : (ι → Bool) → Bool} {x : ι → Bool} {b : Bool} (hfx : f x = b) {ℬ : Finset (Finset ι)} (hmin : ∀ B ∈ ℬ, IsMinSensBlock f x B) (hdisj : (ℬ : Set (Finset ι)).PairwiseDisjoint id) (hmax : ℬ.card = blockSensSide f b) : (ℬ.biUnion id).card + (essentialNonSingletonBits f x ℬ).card ≤ sensSide f (!b) * blockSensSide f b := by classical set U := ℬ.biUnion id set Mge2 := essentialNonSingletonBits f x ℬ -- Key claim: every `i ∈ Mge2` is sensitive at `x^{⊕ B}` for some `B ∈ ℬ` with `i ∉ B`! have hhit : ∀ i ∈ Mge2, ∃ B ∈ ℬ, i ∉ B ∧ i ∈ sensSet f (flipSet x B) := by intro i hi have hi' : i ∈ U ∧ (∃ B ∈ ℬ, i ∈ B ∧ 2 ≤ B.card) ∧ ¬ IsCert f x (U.erase i) := by simpa [Mge2, essentialNonSingletonBits, U] using hi have hiU : i ∈ U := hi'.1 obtain ⟨⟨Bm, hBm, hiBm, hBm2⟩, hnotcert⟩ := hi'.2 -- Since `U.erase i` is not a certificate, there exists a sensitive block `E` with `E ∩ U ⊆ {i}` rw [isCert_iff_hits_sensBlocks] at hnotcert push Not at hnotcert obtain ⟨E, hE_sens, hE_disj⟩ := hnotcert -- `z := flipBit x i` still has `f z = b` because `Bm` is minimal and `|Bm| ≥ 2`! let z := flipBit x i have hfz : f z = b := by have hss : ({i} : Finset ι) ⊂ Bm := by rw [Finset.ssubset_iff_subset_ne] refine ⟨Finset.singleton_subset_iff.mpr hiBm, ?_⟩ intro heq rw [← heq] at hBm2 simp at hBm2 have := (hmin Bm hBm).2 {i} hss simpa [z, flipSet_singleton, hfx] using this -- Notice `i ∈ E`? Wait: if `i ∉ E`, then `E` is disjoint from `U`, so `insert E ℬ` has card `bs_b + 1`! have hiE : i ∈ E := by by_contra hniE have hdisjE : ∀ B ∈ ℬ, Disjoint E B := fun B hB => Finset.disjoint_left.mpr fun j hjE hjB => by have hjU : j ∈ U.erase i := Finset.mem_erase.mpr ⟨fun h => hniE (h ▸ hjE), Finset.mem_biUnion.mpr ⟨B, hB, hjB⟩⟩ have : j ∈ U.erase i ∩ E := Finset.mem_inter.mpr ⟨hjU, hjE⟩ rw [hE_disj] at this; exact Finset.notMem_empty j this have hnotmem : E ∉ ℬ := fun h => by obtain ⟨j, hj⟩ := hE_sens.nonempty exact Finset.disjoint_left.mp (hdisjE E h) hj hj have hfam : IsDisjointSensBlocks f x (insert E ℬ) := by refine ⟨fun B hB => ?_, fun B₁ h₁ B₂ h₂ hne => ?_⟩ · rcases Finset.mem_insert.mp hB with rfl | hB' · exact hE_sens · exact (hmin B hB').1 · rcases Finset.mem_insert.mp h₁ with rfl | h₁' <;> rcases Finset.mem_insert.mp h₂ with rfl | h₂' · exact absurd rfl hne · exact hdisjE B₂ h₂' · exact (hdisjE B₁ h₁').symm · exact hdisj h₁' h₂' hne have hle := (card_le_blockSensAt hfam).trans (hfx ▸ blockSensAt_le_blockSensSide f x) rw [Finset.card_insert_of_notMem hnotmem, hmax] at hle omega -- Moreover, `E.erase i` is disjoint from `U`! have hE_erase_disj : Disjoint (E.erase i) U := by rw [Finset.disjoint_left] intro j hjE hjU have hjne : j ≠ i := (Finset.mem_erase.mp hjE).1 have : j ∈ U.erase i ∩ E := Finset.mem_inter.mpr ⟨Finset.mem_erase.mpr ⟨hjne, hjU⟩, (Finset.mem_erase.mp hjE).2⟩ rw [hE_disj] at this; exact Finset.notMem_empty j this -- Now suppose for contradiction that for EVERY `B ∈ ℬ.erase Bm`, `i ∉ sensSet f (flipSet x B)`! by_contra hnone push Not at hnone -- Then at `z = flipBit x i`, `Bm.erase i`, `E.erase i`, and every `B ∈ ℬ.erase Bm` are ALL -- pairwise disjoint sensitive blocks — giving `|ℬ| + 1 = bs_b + 1` disjoint blocks at `z`! have hB_sens_z : ∀ B ∈ ℬ.erase Bm, IsSensBlock f z B := by intro B hB have hBmem : B ∈ ℬ := Finset.mem_of_mem_erase hB have hBne : B ≠ Bm := Finset.ne_of_mem_erase hB have hniB : i ∉ B := Finset.disjoint_left.mp (hdisj hBm hBmem hBne.symm) hiBm have hns := hnone B hBmem hniB rw [sensSet, Finset.mem_filter] at hns have heq_f : f (flipBit (flipSet x B) i) = f (flipSet x B) := by by_contra hne exact hns ⟨Finset.mem_univ i, hne⟩ have hcomm : flipSet z B = flipBit (flipSet x B) i := by ext j by_cases hji : j = i · subst hji; simp [flipSet, flipBit, z, hniB] · by_cases hjB : j ∈ B <;> simp [flipSet, flipBit, z, hji, hjB] rw [IsSensBlock, hcomm, heq_f, hfz, ← hfx] exact (hmin B hBmem).1 have hBm_sens_z : IsSensBlock f z (Bm.erase i) := by have hfl : flipSet z (Bm.erase i) = flipSet x Bm := by ext j by_cases hji : j = i · subst hji; simp [flipSet, flipBit, z, hiBm] · by_cases hjB : j ∈ Bm <;> simp [flipSet, flipBit, z, hji, hjB] rw [IsSensBlock, hfl, hfz, ← hfx] exact (hmin Bm hBm).1 have hE_sens_z : IsSensBlock f z (E.erase i) := by have hfl : flipSet z (E.erase i) = flipSet x E := by ext j by_cases hji : j = i · subst hji; simp [flipSet, flipBit, z, hiE] · by_cases hjE : j ∈ E <;> simp [flipSet, flipBit, z, hji, hjE] rw [IsSensBlock, hfl, hfz, ← hfx] exact hE_sens have hBm_disj_E : Disjoint (Bm.erase i) (E.erase i) := by refine hE_erase_disj.symm.mono ?_ Subset.rfl intro j hj exact Finset.mem_biUnion.mpr ⟨Bm, hBm, Finset.mem_of_mem_erase hj⟩ have hBm_disj_rest : ∀ B ∈ ℬ.erase Bm, Disjoint (Bm.erase i) B := fun B hB => (hdisj hBm (Finset.mem_of_mem_erase hB) (Finset.ne_of_mem_erase hB).symm).mono (Finset.erase_subset _ _) Subset.rfl have hE_disj_rest : ∀ B ∈ ℬ.erase Bm, Disjoint (E.erase i) B := fun B hB => hE_erase_disj.mono Subset.rfl (fun j hj => Finset.mem_biUnion.mpr ⟨B, Finset.mem_of_mem_erase hB, hj⟩) let 𝒞 : Finset (Finset ι) := insert (Bm.erase i) (insert (E.erase i) (ℬ.erase Bm)) have hBm_ne_E : Bm.erase i ≠ E.erase i := fun heq => by obtain ⟨j, hj⟩ := hBm_sens_z.nonempty exact Finset.disjoint_left.mp hBm_disj_E hj (heq ▸ hj) have hBm_nmem : Bm.erase i ∉ ℬ.erase Bm := fun h => by obtain ⟨j, hj⟩ := hBm_sens_z.nonempty exact Finset.disjoint_left.mp (hBm_disj_rest _ h) hj hj have hE_nmem : E.erase i ∉ ℬ.erase Bm := fun h => by obtain ⟨j, hj⟩ := hE_sens_z.nonempty exact Finset.disjoint_left.mp (hE_disj_rest _ h) hj hj have h𝒞_fam : IsDisjointSensBlocks f z 𝒞 := by refine ⟨?_, ?_⟩ · intro B hB rcases Finset.mem_insert.mp hB with rfl | hB1 · exact hBm_sens_z · rcases Finset.mem_insert.mp hB1 with rfl | hB2 · exact hE_sens_z · exact hB_sens_z B hB2 · intro B₁ h₁ B₂ h₂ hne rcases Finset.mem_insert.mp h₁ with rfl | h₁' <;> rcases Finset.mem_insert.mp h₂ with rfl | h₂' · exact absurd rfl hne · rcases Finset.mem_insert.mp h₂' with rfl | h₂'' · exact hBm_disj_E · exact hBm_disj_rest B₂ h₂'' · rcases Finset.mem_insert.mp h₁' with rfl | h₁'' · exact hBm_disj_E.symm · exact (hBm_disj_rest B₁ h₁'').symm · rcases Finset.mem_insert.mp h₁' with rfl | h₁'' <;> rcases Finset.mem_insert.mp h₂' with rfl | h₂'' · exact absurd rfl hne · exact hE_disj_rest B₂ h₂'' · exact (hE_disj_rest B₁ h₁'').symm · exact hdisj (Finset.mem_of_mem_erase h₁'') (Finset.mem_of_mem_erase h₂'') hne have h𝒞_card : 𝒞.card = ℬ.card + 1 := by simp only [𝒞] rw [Finset.card_insert_of_notMem (by simp [hBm_ne_E, hBm_nmem]), Finset.card_insert_of_notMem hE_nmem, Finset.card_erase_of_mem hBm] have hpos : 1 ≤ ℬ.card := Finset.card_pos.mpr ⟨Bm, hBm⟩ omega have hle := (card_le_blockSensAt h𝒞_fam).trans (hfz ▸ blockSensAt_le_blockSensSide f z) rw [h𝒞_card, hmax] at hle omega -- Now double-count pairs `(i, B)` with `i ∈ Mge2`, `B ∈ ℬ`, `i ∉ B`, `i ∈ sensSet f (flipSet x B)`! -- Every `i ∈ Mge2` has at least one such `B ∈ ℬ`, so `|Mge2| ≤ ∑_{B ∈ ℬ} |(sensSet f (flipSet x B)) \ B|`! have hMle : Mge2.card ≤ ∑ B ∈ ℬ, ((sensSet f (flipSet x B)) \ B).card := by have hsub : Mge2 ⊆ ℬ.biUnion (fun B => (sensSet f (flipSet x B)) \ B) := by intro i hi obtain ⟨B, hB, hniB, hisens⟩ := hhit i hi exact Finset.mem_biUnion.mpr ⟨B, hB, Finset.mem_sdiff.mpr ⟨hisens, hniB⟩⟩ exact (Finset.card_le_card hsub).trans Finset.card_biUnion_le -- And for each `B ∈ ℬ`, `B ⊆ sensSet f (flipSet x B)`, so `|B| + |sensSet \ B| = |sensSet| ≤ s_{!b}(f)`! have hperB : ∀ B ∈ ℬ, B.card + ((sensSet f (flipSet x B)) \ B).card ≤ sensSide f (!b) := by intro B hB have hsub : B ⊆ sensSet f (flipSet x B) := fun i hi => mem_sensSet_of_minSensBlock (hmin B hB) hi have hval : f (flipSet x B) = !b := by have hne : f (flipSet x B) ≠ f x := (hmin B hB).1 rw [hfx] at hne cases h1 : f (flipSet x B) <;> cases b <;> simp_all rw [Nat.add_comm, Finset.card_sdiff_add_card_eq_card hsub] calc (sensSet f (flipSet x B)).card = sensAt f (flipSet x B) := rfl _ ≤ sensSide f (f (flipSet x B)) := sensAt_le_sensSide f _ _ = sensSide f (!b) := by rw [hval] have hUcard : U.card = ∑ B ∈ ℬ, B.card := Finset.card_biUnion hdisj calc U.card + Mge2.card ≤ (∑ B ∈ ℬ, B.card) + ∑ B ∈ ℬ, ((sensSet f (flipSet x B)) \ B).card := by rw [hUcard]; exact Nat.add_le_add_left hMle _ _ = ∑ B ∈ ℬ, (B.card + ((sensSet f (flipSet x B)) \ B).card) := (Finset.sum_add_distrib).symm _ ≤ ∑ _B ∈ ℬ, sensSide f (!b) := Finset.sum_le_sum hperB _ = ℬ.card * sensSide f (!b) := by simp _ = sensSide f (!b) * blockSensSide f b := by rw [hmax, Nat.mul_comm] /-- **Theorem 2C (NEW — Universal Strict Improvement over Nisan 1991)**: For every Boolean function `f : (ι → Bool) → Bool` and side `b` with `s_{!b}(f) ≥ 2` and `bs_b(f) ≥ 2`, `C_b(f) ≤ s_{!b}(f) · bs_b(f) - 1`. -/ theorem certSide_strict_lt_nisan {f : (ι → Bool) → Bool} {b : Bool} (hs : 2 ≤ sensSide f (!b)) (hbs : 2 ≤ blockSensSide f b) : certSide f b ≤ sensSide f (!b) * blockSensSide f b - 1 := by classical unfold certSide apply Finset.sup_le intro x hx have hfx : f x = b := (Finset.mem_filter.mp hx).2 obtain ⟨ℬ, hmin, hdisj, hcert⟩ := exists_maximal_minSensBlocks f x let U := ℬ.biUnion id have hUcard : U.card = ∑ B ∈ ℬ, B.card := Finset.card_biUnion hdisj have hℬle : ℬ.card ≤ blockSensSide f b := (card_le_blockSensAt ⟨fun B hB => (hmin B hB).1, hdisj⟩).trans (hfx ▸ blockSensAt_le_blockSensSide f x) have hB_le_s : ∀ B ∈ ℬ, B.card ≤ sensSide f (!b) := fun B hB => hfx ▸ card_le_sensSide_not_of_minSensBlock (hmin B hB) by_cases hlt : ℬ.card < blockSensSide f b · -- Case 1: `|ℬ| ≤ bs_b - 1`, so `|U| ≤ s_{!b} · (bs_b - 1) ≤ s_{!b} · bs_b - 2`! have hsum : ∑ B ∈ ℬ, B.card ≤ ℬ.card * sensSide f (!b) := by simpa using Finset.sum_le_sum hB_le_s have h1 : U.card ≤ sensSide f (!b) * (blockSensSide f b - 1) := by rw [hUcard, Nat.mul_comm] exact hsum.trans (Nat.mul_le_mul_right _ (by omega)) have h2 : sensSide f (!b) * (blockSensSide f b - 1) ≤ sensSide f (!b) * blockSensSide f b - 1 := by have hmul : sensSide f (!b) * (blockSensSide f b - 1) + sensSide f (!b) = sensSide f (!b) * blockSensSide f b := by have : blockSensSide f b - 1 + 1 = blockSensSide f b := by omega calc sensSide f (!b) * (blockSensSide f b - 1) + sensSide f (!b) = sensSide f (!b) * (blockSensSide f b - 1 + 1) := by ring _ = sensSide f (!b) * blockSensSide f b := by rw [this] omega exact (certAt_le_of_isCert hcert).trans (h1.trans h2) · -- Case 2: `|ℬ| = bs_b`! have hmax : ℬ.card = blockSensSide f b := by omega by_cases hUsmall : U.card ≤ sensSide f (!b) * blockSensSide f b - 1 · exact (certAt_le_of_isCert hcert).trans hUsmall · -- Otherwise `|U| = s_{!b} · bs_b`, so EVERY block `B ∈ ℬ` has `|B| = s_{!b} ≥ 2`, -- and by Theorem 2B, `|M_{≥2}| = 0` — hence dropping ANY bit `i ∈ U` leaves a certificate! have hdef : U.card + (essentialNonSingletonBits f x ℬ).card ≤ sensSide f (!b) * blockSensSide f b := essential_bit_sensitivity_deficit hfx hmin hdisj hmax have hUge : sensSide f (!b) * blockSensSide f b ≤ U.card := by omega have hM0 : (essentialNonSingletonBits f x ℬ).card = 0 := by omega have hmul_eq : ℬ.card * sensSide f (!b) = sensSide f (!b) * blockSensSide f b := by rw [hmax, Nat.mul_comm] have hsum_eq : ∑ B ∈ ℬ, B.card = ℬ.card * sensSide f (!b) := by have hle : ∑ B ∈ ℬ, B.card ≤ ℬ.card * sensSide f (!b) := by simpa using Finset.sum_le_sum hB_le_s omega have hall_s : ∀ B ∈ ℬ, B.card = sensSide f (!b) := by intro B hB by_contra hne have hltB : B.card < sensSide f (!b) := lt_of_le_of_ne (hB_le_s B hB) hne have hlt_sum : ∑ C ∈ ℬ, C.card < ∑ _C ∈ ℬ, sensSide f (!b) := Finset.sum_lt_sum hB_le_s ⟨B, hB, hltB⟩ simp at hlt_sum omega obtain ⟨B₀, hB₀⟩ : ℬ.Nonempty := Finset.card_pos.mp (by omega) have hB₀_card : B₀.card = sensSide f (!b) := hall_s B₀ hB₀ obtain ⟨i₀, hi₀B₀⟩ : B₀.Nonempty := Finset.card_pos.mp (by omega) have hi₀U : i₀ ∈ U := Finset.mem_biUnion.mpr ⟨B₀, hB₀, hi₀B₀⟩ have hcert_erase : IsCert f x (U.erase i₀) := by by_contra hnc have hi₀M : i₀ ∈ essentialNonSingletonBits f x ℬ := by simp only [essentialNonSingletonBits, Finset.mem_filter] exact ⟨hi₀U, ⟨B₀, hB₀, hi₀B₀, by omega⟩, hnc⟩ have hpos : 0 < (essentialNonSingletonBits f x ℬ).card := Finset.card_pos.mpr ⟨i₀, hi₀M⟩ omega have hUeq : U.card = sensSide f (!b) * blockSensSide f b := by omega calc certAt f x ≤ (U.erase i₀).card := certAt_le_of_isCert hcert_erase _ = U.card - 1 := Finset.card_erase_of_mem hi₀U _ = sensSide f (!b) * blockSensSide f b - 1 := by rw [hUeq] /-- Corollary: Strict improvement over Nisan's cubic bound `D(f) ≤ s(f) · bs(f)²`. -/ theorem detDepth_strict_lt_nisan_cubic {f : (ι → Bool) → Bool} (hs0 : 2 ≤ sensSide f false) (hbs1 : 2 ≤ blockSensSide f true) : detDepth f ≤ (sensSide f false * blockSensSide f true - 1) * blockSensSide f false := (detDepth_le_cert1_mul_bs0 f).trans (Nat.mul_le_mul_right _ (by simpa using certSide_strict_lt_nisan (f := f) (b := true) hs0 hbs1)) /-! ### `2`-Bootstrap-Percolation Subcube Rigidity (`s₁(f) ≤ 1`) -/ /-- **Theorem 2D (Exact `s_{!b}(f) ≤ 1` Subcube Rigidity)**: When `s_{!b}(f) ≤ 1`, every minimal sensitive block at any `b`-input `x` has size `1`, forcing **pointwise exact equality** `s(f, x) = bs(f, x) = C(f, x)` for all `x ∈ f⁻¹(b)`, and therefore `s_b(f) = bs_b(f) = C_b(f)`. -/ theorem sensSide_not_le_one_pointwise_eq {f : (ι → Bool) → Bool} {b : Bool} (hs : sensSide f (!b) ≤ 1) {x : ι → Bool} (hfx : f x = b) : sensAt f x = blockSensAt f x ∧ blockSensAt f x = certAt f x := by have hcert : IsCert f x (sensSet f x) := by rw [isCert_iff_hits_sensBlocks] intro B hB obtain ⟨B', hB'sub, hB'min⟩ := exists_minSensBlock_subset hB have hcard : B'.card ≤ 1 := (hfx ▸ card_le_sensSide_not_of_minSensBlock hB'min).trans hs have hne : B'.Nonempty := hB'min.1.nonempty have hcard1 : B'.card = 1 := le_antisymm hcard (Finset.card_pos.mpr hne) obtain ⟨i, hi⟩ := Finset.card_eq_one.mp hcard1 subst hi refine ⟨i, Finset.mem_inter.mpr ⟨?_, hB'sub (Finset.mem_singleton_self i)⟩⟩ rw [sensSet, Finset.mem_filter] refine ⟨Finset.mem_univ i, ?_⟩ simpa [IsSensBlock, flipSet_singleton] using hB'min.1 have hle1 := sensAt_le_blockSensAt f x have hle2 := blockSensAt_le_certAt f x have hle3 : certAt f x ≤ sensAt f x := certAt_le_of_isCert hcert exact ⟨by omega, by omega⟩ theorem s1_le_one_exact_equality {f : (ι → Bool) → Bool} (hs1 : sensSide f true ≤ 1) : sensSide f false = blockSensSide f false ∧ blockSensSide f false = certSide f false := by have h1 : sensSide f false = blockSensSide f false := by unfold sensSide blockSensSide apply Finset.sup_congr rfl intro x hx exact (sensSide_not_le_one_pointwise_eq hs1 (Finset.mem_filter.mp hx).2).1 have h2 : blockSensSide f false = certSide f false := by unfold blockSensSide certSide apply Finset.sup_congr rfl intro x hx exact (sensSide_not_le_one_pointwise_eq hs1 (Finset.mem_filter.mp hx).2).2 exact ⟨h1, h2⟩ /-! ### `3`-Bootstrap-Percolation Rigidity (`s₁(f) ≤ 2`) -/ /-- When `s_{!b}(f) ≤ 2`, the `b`-level set `f⁻¹(b)` is `3`-bootstrap-percolation-closed in `Q_n`: any vertex with at least `3` neighbors in `f⁻¹(b)` must itself lie in `f⁻¹(b)`. -/ lemma bootstrap_three_closed {f : (ι → Bool) → Bool} {b : Bool} (hs : sensSide f (!b) ≤ 2) {y : ι → Bool} {S : Finset ι} (hS3 : 3 ≤ S.card) (hnb : ∀ i ∈ S, f (flipBit y i) = b) : f y = b := by by_contra hne have hfy : f y = !b := by cases h1 : f y <;> cases b <;> simp_all have hsub : S ⊆ sensSet f y := by intro i hi rw [sensSet, Finset.mem_filter] refine ⟨Finset.mem_univ i, ?_⟩ rw [hnb i hi, hfy] cases b <;> decide have hle : S.card ≤ sensSide f (!b) := (Finset.card_le_card hsub).trans (hfy ▸ sensAt_le_sensSide f y) omega /-- Size-2 minimal sensitive-block adjacency at a `b`-input `x`. -/ def sizeTwoBlockAdj (f : (ι → Bool) → Bool) (x : ι → Bool) (u v : ι) : Prop := u ≠ v ∧ IsMinSensBlock f x {u, v} /-- An independent set in the size-2 minimal sensitive-block graph at `x` (avoiding singletons). -/ def IsIndepInBlockGraph (f : (ι → Bool) → Bool) (x : ι → Bool) (I : Finset ι) : Prop := (∀ u ∈ I, u ∉ sensSet f x) ∧ ∀ u ∈ I, ∀ v ∈ I, ¬ sizeTwoBlockAdj f x u v /-- **Subcube Lemma under `3`-Bootstrap-Percolation (`s_{!b}(f) ≤ 2`)**: Every independent set `I` in the size-2 minimal sensitive-block graph at `x` spans an entire `b`-monochromatic subcube `{x^{⊕ J} : J ⊆ I} ⊆ f⁻¹(b)`. -/ lemma s_not_le_two_indep_subcube {f : (ι → Bool) → Bool} {b : Bool} (hs : sensSide f (!b) ≤ 2) {x : ι → Bool} (hfx : f x = b) {I : Finset ι} (hI : IsIndepInBlockGraph f x I) : ∀ J ⊆ I, f (flipSet x J) = b := by intro J hJI by_contra hne have hsens : IsSensBlock f x J := by rw [IsSensBlock, hfx]; exact hne obtain ⟨B, hBJ, hBmin⟩ := exists_minSensBlock_subset hsens have hcard : B.card ≤ 2 := (hfx ▸ card_le_sensSide_not_of_minSensBlock hBmin).trans hs have hpos : 1 ≤ B.card := Finset.card_pos.mpr hBmin.1.nonempty interval_cases hBcard : B.card · obtain ⟨u, rfl⟩ := Finset.card_eq_one.mp hBcard have huI : u ∈ I := hJI (hBJ (Finset.mem_singleton_self u)) have husens : u ∈ sensSet f x := by rw [sensSet, Finset.mem_filter] exact ⟨Finset.mem_univ u, by simpa [IsSensBlock, flipSet_singleton] using hBmin.1⟩ exact hI.1 u huI husens · obtain ⟨u, v, huv, rfl⟩ := Finset.card_eq_two.mp hBcard have huI : u ∈ I := hJI (hBJ (by simp)) have hvI : v ∈ I := hJI (hBJ (by simp)) exact hI.2 u huI v hvI ⟨huv, hBmin⟩ /-- Helper persistence lemma: if `s_{!b}(f) ≤ 2`, `f(x^{⊕ (J ∪ {u, v})}) = !b` persists as we add vertices of `I` whenever `{u, v}` is a minimal sensitive block at `x` and `J ∪ {u}`, `J ∪ {v}` stay inside `f⁻¹(b)`. -/ lemma s_not_le_two_pair_persists {f : (ι → Bool) → Bool} {b : Bool} (hs : sensSide f (!b) ≤ 2) {x : ι → Bool} (hfx : f x = b) {u v : ι} (huv : u ≠ v) (hpair : f (flipSet x {u, v}) ≠ b) {K : Finset ι} (huK : u ∉ K) (hvK : v ∉ K) (hKu : ∀ J ⊆ K, f (flipSet x (insert u J)) = b) (hKv : ∀ J ⊆ K, f (flipSet x (insert v J)) = b) : ∀ J ⊆ K, f (flipSet x (insert u (insert v J))) ≠ b := by intro J induction J using Finset.induction_on with | empty => intro _ simpa using hpair | insert w J hwJ ih => intro hsub have hJK : J ⊆ K := (Finset.subset_insert w J).trans hsub have hwK : w ∈ K := hsub (Finset.mem_insert_self w J) have hwu : w ≠ u := fun h => huK (h ▸ hwK) have hwv : w ≠ v := fun h => hvK (h ▸ hwK) let y := flipSet x (insert u (insert v J)) have hfy_ne : f y ≠ b := ih hJK have hfy : f y = !b := by cases h1 : f y <;> cases b <;> simp_all -- Both `u` and `v` are sensitive at `y`! have hu_sens : u ∈ sensSet f y := by rw [sensSet, Finset.mem_filter] refine ⟨Finset.mem_univ u, ?_⟩ have hfl : flipBit y u = flipSet x (insert v J) := by ext j by_cases hju : j = u · subst hju have hjJ : j ∉ J := fun h => huK (hJK h) simp [y, flipBit, flipSet, huv, hjJ] · by_cases hjv : j = v · subst hjv; simp [y, flipBit, flipSet, Ne.symm huv] · by_cases hjJ : j ∈ J <;> simp [y, flipBit, flipSet, hju, hjv, hjJ] rw [hfl, hKv J hJK, hfy] cases b <;> decide have hv_sens : v ∈ sensSet f y := by rw [sensSet, Finset.mem_filter] refine ⟨Finset.mem_univ v, ?_⟩ have hfl : flipBit y v = flipSet x (insert u J) := by ext j by_cases hjv : j = v · subst hjv have hjJ : j ∉ J := fun h => hvK (hJK h) simp [y, flipBit, flipSet, huv.symm, hjJ] · by_cases hju : j = u · subst hju; simp [y, flipBit, flipSet, huv] · by_cases hjJ : j ∈ J <;> simp [y, flipBit, flipSet, hju, hjv, hjJ] rw [hfl, hKu J hJK, hfy] cases b <;> decide -- Since `s_{!b}(f) ≤ 2`, `w` cannot be sensitive at `y`! have hw_not_sens : w ∉ sensSet f y := by intro hw_sens have hsub3 : ({u, v, w} : Finset ι) ⊆ sensSet f y := by intro j hj simp only [Finset.mem_insert, Finset.mem_singleton] at hj rcases hj with rfl | rfl | rfl <;> assumption have hcard3 : ({u, v, w} : Finset ι).card = 3 := by rw [Finset.card_insert_of_notMem (by simp [huv, hwu.symm]), Finset.card_insert_of_notMem (by simp [hwv.symm]), Finset.card_singleton] have hle : 3 ≤ sensSide f (!b) := hcard3 ▸ (Finset.card_le_card hsub3).trans (hfy ▸ sensAt_le_sensSide f y) omega rw [sensSet, Finset.mem_filter] at hw_not_sens have hfw : f (flipBit y w) = f y := by by_contra hne; exact hw_not_sens ⟨Finset.mem_univ w, hne⟩ have hflw : flipBit y w = flipSet x (insert u (insert v (insert w J))) := by ext j by_cases hjw : j = w · subst hjw; simp [y, flipBit, flipSet, hwu, hwv, hwJ] · by_cases hju : j = u · subst hju; simp [y, flipBit, flipSet, hjw] · by_cases hjv : j = v · subst hjv; simp [y, flipBit, flipSet, hjw, hju] · by_cases hjJ : j ∈ J <;> simp [y, flipBit, flipSet, hjw, hju, hjv, hjJ] rw [← hflw, hfw] exact hfy_ne /-- **Theorem 2E (NEW — `3`-Bootstrap-Percolation Private-Neighbor Matching Bound)**: When `s_{!b}(f) ≤ 2`, let `x ∈ f⁻¹(b)` and let `I` be any independent set in the size-2 minimal sensitive-block graph `G_x`. Let `U₁(I)` be the set of non-singleton vertices `w ∉ I` having a **unique** neighbor in `I` in `G_x`, and let `ℳ` be any matching of edges `{u, v}` of `G_x` completely disjoint from `I` and having no adjacency to `I` in `G_x`. Then at `z = x^{⊕ I}`: `f(z) = b` and `|U₁(I)| + |ℳ| ≤ bs(f, z) ≤ bs_b(f)`. -/ theorem s1_le_two_private_neighbor_bound {f : (ι → Bool) → Bool} {b : Bool} (hs : sensSide f (!b) ≤ 2) {x : ι → Bool} (hfx : f x = b) {I : Finset ι} (hI : IsIndepInBlockGraph f x I) {U1 : Finset ι} (hU1_disj : Disjoint U1 I) (hU1_nsens : ∀ w ∈ U1, w ∉ sensSet f x) (hU1_uniq : ∀ w ∈ U1, ∃ v ∈ I, sizeTwoBlockAdj f x w v ∧ ∀ v' ∈ I, sizeTwoBlockAdj f x w v' → v' = v) {ℳ : Finset (Finset ι)} (hℳ_disj : (ℳ : Set (Finset ι)).PairwiseDisjoint id) (hℳ_edges : ∀ e ∈ ℳ, ∃ u v, e = {u, v} ∧ sizeTwoBlockAdj f x u v ∧ u ∉ I ∧ v ∉ I ∧ u ∉ U1 ∧ v ∉ U1 ∧ (∀ t ∈ I, ¬ sizeTwoBlockAdj f x u t) ∧ (∀ t ∈ I, ¬ sizeTwoBlockAdj f x v t)) : f (flipSet x I) = b ∧ U1.card + ℳ.card ≤ blockSensSide f b := by let z := flipSet x I have hfz : f z = b := s_not_le_two_indep_subcube hs hfx hI I Subset.rfl refine ⟨hfz, ?_⟩ -- 1. Every `w ∈ U1` is sensitive at `z`! have hU1_sens : ∀ w ∈ U1, IsSensBlock f z {w} := by intro w hw obtain ⟨v, hvI, ⟨hwv, hmin⟩, huniq⟩ := hU1_uniq w hw have hwI : w ∉ I := Finset.disjoint_left.mp hU1_disj hw let K := I.erase v have hKu : ∀ J ⊆ K, f (flipSet x (insert w J)) = b := by intro J hJK apply s_not_le_two_indep_subcube hs hfx (I := insert w K) · refine ⟨?_, ?_⟩ · intro a ha rcases Finset.mem_insert.mp ha with hwa | haK · exact hwa ▸ hU1_nsens w hw · exact hI.1 a (Finset.mem_of_mem_erase haK) · intro a ha c hc hadj rcases Finset.mem_insert.mp ha with hwa | haK <;> rcases Finset.mem_insert.mp hc with hwc | hcK · rw [hwa, hwc] at hadj; exact hadj.1 rfl · rw [hwa] at hadj have heq := huniq c (Finset.mem_of_mem_erase hcK) hadj exact (Finset.ne_of_mem_erase hcK) heq · rw [hwc] at hadj have hadj' : sizeTwoBlockAdj f x w a := ⟨hadj.1.symm, by simpa [Finset.pair_comm] using hadj.2⟩ have heq := huniq a (Finset.mem_of_mem_erase haK) hadj' exact (Finset.ne_of_mem_erase haK) heq · exact hI.2 a (Finset.mem_of_mem_erase haK) c (Finset.mem_of_mem_erase hcK) hadj · exact Finset.insert_subset_insert w hJK have hKv : ∀ J ⊆ K, f (flipSet x (insert v J)) = b := by intro J hJK exact s_not_le_two_indep_subcube hs hfx hI (insert v J) (Finset.insert_subset hvI (hJK.trans (Finset.erase_subset v I))) have hpers := s_not_le_two_pair_persists hs hfx hwv (hfx ▸ hmin.1) (fun h => hwI (Finset.mem_of_mem_erase h)) (Finset.notMem_erase v I) hKu hKv K Subset.rfl have hfl : flipSet z {w} = flipSet x (insert w (insert v K)) := by have hIv : insert v K = I := Finset.insert_erase hvI rw [hIv, flipSet_singleton, flipSet_insert_of_notMem x hwI] rw [IsSensBlock, hfl, hfz] exact hpers -- 2. Every `e ∈ ℳ` is still a sensitive block at `z`! have hℳ_sens : ∀ e ∈ ℳ, IsSensBlock f z e := by intro e he obtain ⟨u, v, rfl, ⟨huv, hmin⟩, huI, hvI, _, _, huN, hvN⟩ := hℳ_edges e he have hKu : ∀ J ⊆ I, f (flipSet x (insert u J)) = b := by intro J hJI have hu_nsens : u ∉ sensSet f x := by intro hsu rw [sensSet, Finset.mem_filter] at hsu have hss : ({u} : Finset ι) ⊂ {u, v} := by rw [Finset.ssubset_iff_subset_ne] exact ⟨by simp, fun h => huv.symm (by simpa using Finset.ext_iff.mp h v)⟩ have := hmin.2 {u} hss rw [flipSet_singleton] at this exact hsu.2 this apply s_not_le_two_indep_subcube hs hfx (I := insert u I) · refine ⟨fun a ha => ?_, fun a ha c hc hadj => ?_⟩ · rcases Finset.mem_insert.mp ha with rfl | haI · exact hu_nsens · exact hI.1 a haI · rcases Finset.mem_insert.mp ha with rfl | haI <;> rcases Finset.mem_insert.mp hc with rfl | hcI · exact hadj.1 rfl · exact huN c hcI hadj · exact huN a haI ⟨hadj.1.symm, by simpa [Finset.pair_comm] using hadj.2⟩ · exact hI.2 a haI c hcI hadj · exact Finset.insert_subset_insert u hJI have hKv : ∀ J ⊆ I, f (flipSet x (insert v J)) = b := by intro J hJI have hv_nsens : v ∉ sensSet f x := by intro hsv rw [sensSet, Finset.mem_filter] at hsv have hss : ({v} : Finset ι) ⊂ {u, v} := by rw [Finset.ssubset_iff_subset_ne] exact ⟨by simp, fun h => huv (by simpa using Finset.ext_iff.mp h u)⟩ have := hmin.2 {v} hss rw [flipSet_singleton] at this exact hsv.2 this apply s_not_le_two_indep_subcube hs hfx (I := insert v I) · refine ⟨fun a ha => ?_, fun a ha c hc hadj => ?_⟩ · rcases Finset.mem_insert.mp ha with rfl | haI · exact hv_nsens · exact hI.1 a haI · rcases Finset.mem_insert.mp ha with rfl | haI <;> rcases Finset.mem_insert.mp hc with rfl | hcI · exact hadj.1 rfl · exact hvN c hcI hadj · exact hvN a haI ⟨hadj.1.symm, by simpa [Finset.pair_comm] using hadj.2⟩ · exact hI.2 a haI c hcI hadj · exact Finset.insert_subset_insert v hJI have hpers := s_not_le_two_pair_persists hs hfx huv (hfx ▸ hmin.1) huI hvI hKu hKv I Subset.rfl have hfl : flipSet z {u, v} = flipSet x (insert u (insert v I)) := by rw [flipSet_disjoint_union] · congr 1; ext j; simp only [Finset.mem_union, Finset.mem_insert, Finset.mem_singleton]; tauto · rw [Finset.disjoint_right] intro j hj simp only [Finset.mem_insert, Finset.mem_singleton] at hj rcases hj with rfl | rfl <;> assumption rw [IsSensBlock, hfl, hfz] exact hpers -- 3. Combine `{ {w} | w ∈ U1 } ∪ ℳ` into a disjoint family at `z`! let ℬ1 : Finset (Finset ι) := U1.image (fun w => ({w} : Finset ι)) have hdisj_fams : Disjoint ℬ1 ℳ := by rw [Finset.disjoint_left] intro B hB1 hB2 rcases Finset.mem_image.mp hB1 with ⟨w, _, rfl⟩ obtain ⟨u, v, heq, ⟨huv, _⟩, _⟩ := hℳ_edges {w} hB2 have h1 := Finset.card_singleton w rw [heq, Finset.card_pair huv] at h1 omega have hfam : IsDisjointSensBlocks f z (ℬ1 ∪ ℳ) := by refine ⟨?_, ?_⟩ · intro B hB rcases Finset.mem_union.mp hB with h1 | h2 · rcases Finset.mem_image.mp h1 with ⟨w, hw, rfl⟩; exact hU1_sens w hw · exact hℳ_sens B h2 · intro B₁ h₁ B₂ h₂ hne rcases Finset.mem_union.mp h₁ with h₁' | h₁' <;> rcases Finset.mem_union.mp h₂ with h₂' | h₂' · rcases Finset.mem_image.mp h₁' with ⟨w₁, _, rfl⟩ rcases Finset.mem_image.mp h₂' with ⟨w₂, _, rfl⟩ exact Finset.disjoint_singleton.mpr (fun h => hne (by rw [h])) · rcases Finset.mem_image.mp h₁' with ⟨w, hw, rfl⟩ obtain ⟨u, v, rfl, _, _, _, huU, hvU, _, _⟩ := hℳ_edges B₂ h₂' exact Finset.disjoint_singleton_left.mpr fun h => by rcases Finset.mem_insert.mp h with rfl | h' · exact huU hw · exact hvU (Finset.mem_singleton.mp h' ▸ hw) · rcases Finset.mem_image.mp h₂' with ⟨w, hw, rfl⟩ obtain ⟨u, v, rfl, _, _, _, huU, hvU, _, _⟩ := hℳ_edges B₁ h₁' exact Finset.disjoint_singleton_right.mpr fun h => by rcases Finset.mem_insert.mp h with rfl | h' · exact huU hw · exact hvU (Finset.mem_singleton.mp h' ▸ hw) · exact hℳ_disj h₁' h₂' hne have hcard1 : ℬ1.card = U1.card := Finset.card_image_of_injective _ Finset.singleton_injective have hle := (card_le_blockSensAt hfam).trans (hfz ▸ blockSensAt_le_blockSensSide f z) rw [Finset.card_union_of_disjoint hdisj_fams, hcard1] at hle exact hle /-- **Theorem 2F (Sharp `s₁(f) ≤ 2` Certificate Bounds & Exact `(2, 2)` Collapse)**: 1. For all `s₁(f) ≤ 2` and `bs₀(f) ≥ 2`: `C₀(f) ≤ 2 · bs₀(f) - 2` (strictly beating Nisan by `2`). 2. Exact `(2, 2)` collapse: `s₁(f) ≤ 2 ∧ bs₀(f) ≤ 2 → C₀(f) ≤ 2` (a `2×` improvement over Nisan's `4`). -/ theorem s1_le_two_cert0_le_two_bs0_sub_two {f : (ι → Bool) → Bool} (hs1 : sensSide f true ≤ 2) (hbs0 : 2 ≤ blockSensSide f false) : certSide f false ≤ 2 * blockSensSide f false - 2 := by classical unfold certSide apply Finset.sup_le intro x hx have hfx : f x = false := (Finset.mem_filter.mp hx).2 obtain ⟨ℬ, hmin, hdisj, hcert⟩ := exists_maximal_minSensBlocks f x let U := ℬ.biUnion id have hUcard : U.card = ∑ B ∈ ℬ, B.card := Finset.card_biUnion hdisj have hℬle : ℬ.card ≤ blockSensSide f false := (card_le_blockSensAt ⟨fun B hB => (hmin B hB).1, hdisj⟩).trans (hfx ▸ blockSensAt_le_blockSensSide f x) have hB_le2 : ∀ B ∈ ℬ, B.card ≤ 2 := fun B hB => (hfx ▸ card_le_sensSide_not_of_minSensBlock (hmin B hB)).trans hs1 by_cases hlt : ℬ.card < blockSensSide f false · have hsum : ∑ B ∈ ℬ, B.card ≤ ℬ.card * 2 := by simpa using Finset.sum_le_sum hB_le2 calc certAt f x ≤ U.card := certAt_le_of_isCert hcert _ ≤ ℬ.card * 2 := hUcard ▸ hsum _ ≤ 2 * blockSensSide f false - 2 := by omega · have hmax : ℬ.card = blockSensSide f false := by omega by_cases hUle : U.card ≤ 2 * blockSensSide f false - 2 · exact (certAt_le_of_isCert hcert).trans hUle · -- Remaining cases: `U.card = 2 * b - 1` or `U.card = 2 * b`! have hdef := essential_bit_sensitivity_deficit hfx hmin hdisj hmax let Mge2 := essentialNonSingletonBits f x ℬ have hMle : U.card + Mge2.card ≤ 2 * blockSensSide f false := hdef.trans (Nat.mul_le_mul_right _ hs1) by_cases hUeq1 : U.card = 2 * blockSensSide f false - 1 · -- Exactly one block has size `1`, all other `b - 1 ≥ 1` blocks have size `2`, and `|Mge2| ≤ 1`, -- whereas there are `2(b - 1) ≥ 2` bits in size-2 blocks! So some bit in a size-2 block is non-essential! have hex2 : ∃ B ∈ ℬ, B.card = 2 := by by_contra hall push Not at hall have h1 : ∀ B ∈ ℬ, B.card ≤ 1 := fun B hB => by have := hB_le2 B hB; have := hall B hB; omega have hsum : ∑ B ∈ ℬ, B.card ≤ ℬ.card * 1 := by simpa using Finset.sum_le_sum h1 omega obtain ⟨B₂, hB₂, hB₂card⟩ := hex2 have hsub : B₂ ⊆ U := fun i hi => Finset.mem_biUnion.mpr ⟨B₂, hB₂, hi⟩ have hex_drop : ∃ i ∈ B₂, i ∉ Mge2 := by by_contra hall push Not at hall have hle := Finset.card_le_card (s := B₂) (t := Mge2) hall omega obtain ⟨i₀, hi₀B₂, hi₀nM⟩ := hex_drop have hcert' : IsCert f x (U.erase i₀) := by by_contra hnc apply hi₀nM simp only [Mge2, essentialNonSingletonBits, Finset.mem_filter] exact ⟨hsub hi₀B₂, ⟨B₂, hB₂, hi₀B₂, by omega⟩, hnc⟩ calc certAt f x ≤ (U.erase i₀).card := certAt_le_of_isCert hcert' _ = U.card - 1 := Finset.card_erase_of_mem (hsub hi₀B₂) _ = 2 * blockSensSide f false - 2 := by omega · -- `U.card = 2 * b`: every block in `ℬ` has size `2`, and `Mge2 = ∅`! have hUeq : U.card = 2 * blockSensSide f false := by have hsum : ∑ B ∈ ℬ, B.card ≤ ℬ.card * 2 := by simpa using Finset.sum_le_sum hB_le2 omega have hall2 : ∀ B ∈ ℬ, B.card = 2 := by intro B hB by_contra hne have hltB : B.card < 2 := lt_of_le_of_ne (hB_le2 B hB) hne have hlt_sum : ∑ C ∈ ℬ, C.card < ∑ _C ∈ ℬ, 2 := Finset.sum_lt_sum hB_le2 ⟨B, hB, hltB⟩ simp at hlt_sum; omega -- Pick two distinct blocks `B₁, B₂ ∈ ℬ` (since `b ≥ 2`), and pick `u ∈ B₁`, `v₁ ≠ v₂ ∈ B₂`. -- We claim either `U \ {u, v₁}` or `U \ {u, v₂}` is a certificate! have hℬ2 : 2 ≤ ℬ.card := by omega obtain ⟨B₁, hB₁, B₂, hB₂, hB12⟩ := Finset.one_lt_card.mp (by omega : 1 < ℬ.card) obtain ⟨u, u', huu', hB₁eq⟩ := Finset.card_eq_two.mp (hall2 B₁ hB₁) obtain ⟨v₁, v₂, hv12, hB₂eq⟩ := Finset.card_eq_two.mp (hall2 B₂ hB₂) have huB₁ : u ∈ B₁ := hB₁eq ▸ by simp have hu'B₁ : u' ∈ B₁ := hB₁eq ▸ by simp have hv₁B₂ : v₁ ∈ B₂ := hB₂eq ▸ by simp have hv₂B₂ : v₂ ∈ B₂ := hB₂eq ▸ by simp have huU : u ∈ U := Finset.mem_biUnion.mpr ⟨B₁, hB₁, huB₁⟩ have hv₁U : v₁ ∈ U := Finset.mem_biUnion.mpr ⟨B₂, hB₂, hv₁B₂⟩ have hv₂U : v₂ ∈ U := Finset.mem_biUnion.mpr ⟨B₂, hB₂, hv₂B₂⟩ have huv₁ : u ≠ v₁ := fun h => Finset.disjoint_left.mp (hdisj hB₁ hB₂ hB12) huB₁ (h ▸ hv₁B₂) have huv₂ : u ≠ v₂ := fun h => Finset.disjoint_left.mp (hdisj hB₁ hB₂ hB12) huB₁ (h ▸ hv₂B₂) -- If neither `U \ {u, v₁}` nor `U \ {u, v₂}` is a certificate, then `{u, v₁}` and `{u, v₂}` -- must BOTH be sensitive blocks at `x`, giving `b + 1` disjoint sensitive blocks at `x^{⊕ u}`! by_cases hc1 : IsCert f x ((U.erase u).erase v₁) · calc certAt f x ≤ ((U.erase u).erase v₁).card := certAt_le_of_isCert hc1 _ = (U.erase u).card - 1 := Finset.card_erase_of_mem (Finset.mem_erase.mpr ⟨huv₁.symm, hv₁U⟩) _ = U.card - 2 := by rw [Finset.card_erase_of_mem huU]; omega _ = 2 * blockSensSide f false - 2 := by omega · by_cases hc2 : IsCert f x ((U.erase u).erase v₂) · calc certAt f x ≤ ((U.erase u).erase v₂).card := certAt_le_of_isCert hc2 _ = (U.erase u).card - 1 := Finset.card_erase_of_mem (Finset.mem_erase.mpr ⟨huv₂.symm, hv₂U⟩) _ = U.card - 2 := by rw [Finset.card_erase_of_mem huU]; omega _ = 2 * blockSensSide f false - 2 := by omega · exfalso -- Helper: since `Mge2 = ∅`, any minimal sensitive block disjoint from `(U.erase u).erase v` -- MUST equal `{u, v}` (size ≤ 2 and must hit both `u` and `v`)! have hM0 : Mge2.card = 0 := by omega have hcert_erase : ∀ w ∈ U, IsCert f x (U.erase w) := by intro w hw by_contra hnc rcases Finset.mem_biUnion.mp hw with ⟨Bw, hBw, hwBw⟩ have hwM : w ∈ Mge2 := by simp only [Mge2, essentialNonSingletonBits, Finset.mem_filter] exact ⟨hw, ⟨Bw, hBw, hwBw, by rw [hall2 Bw hBw]⟩, hnc⟩ have hpos : 0 < Mge2.card := Finset.card_pos.mpr ⟨w, hwM⟩ omega have hpair_sens : ∀ v ∈ U, u ≠ v → ¬ IsCert f x ((U.erase u).erase v) → IsSensBlock f x {u, v} := by intro v hvU huv hnc rw [isCert_iff_hits_sensBlocks] at hnc push Not at hnc obtain ⟨E, hE, hEdisj⟩ := hnc obtain ⟨E', hE'sub, hE'min⟩ := exists_minSensBlock_subset hE have hE'card : E'.card ≤ 2 := (hfx ▸ card_le_sensSide_not_of_minSensBlock hE'min).trans hs1 have huE' : u ∈ E' := by obtain ⟨j, hj⟩ := isCert_inter_sensBlock_nonempty (hcert_erase v hvU) hE'min.1 rw [Finset.mem_inter, Finset.mem_erase] at hj by_contra hnu have hju : j ≠ u := fun h => hnu (h ▸ hj.2) have hmem : j ∈ (U.erase u).erase v ∩ E := Finset.mem_inter.mpr ⟨Finset.mem_erase.mpr ⟨hj.1.1, Finset.mem_erase.mpr ⟨hju, hj.1.2⟩⟩, hE'sub hj.2⟩ rw [hEdisj] at hmem; exact Finset.notMem_empty j hmem have hvE' : v ∈ E' := by obtain ⟨j, hj⟩ := isCert_inter_sensBlock_nonempty (hcert_erase u huU) hE'min.1 rw [Finset.mem_inter, Finset.mem_erase] at hj by_contra hnv have hjv : j ≠ v := fun h => hnv (h ▸ hj.2) have hmem : j ∈ (U.erase u).erase v ∩ E := Finset.mem_inter.mpr ⟨Finset.mem_erase.mpr ⟨hjv, Finset.mem_erase.mpr ⟨hj.1.1, hj.1.2⟩⟩, hE'sub hj.2⟩ rw [hEdisj] at hmem; exact Finset.notMem_empty j hmem have hsub2 : ({u, v} : Finset ι) ⊆ E' := by intro j hj; simp only [Finset.mem_insert, Finset.mem_singleton] at hj rcases hj with rfl | rfl <;> assumption have heq2 : ({u, v} : Finset ι) = E' := Finset.eq_of_subset_of_card_le hsub2 (by rw [Finset.card_pair huv]; exact hE'card) rw [heq2]; exact hE'min.1 have hsens_uv1 : IsSensBlock f x {u, v₁} := hpair_sens v₁ hv₁U huv₁ hc1 have hsens_uv2 : IsSensBlock f x {u, v₂} := hpair_sens v₂ hv₂U huv₂ hc2 -- At `z := flipBit x u`, `f z = false`, and `{u'}, {v₁}, {v₂}` plus all `B ∈ ℬ \ {B₁, B₂}` -- are `3 + (b - 2) = b + 1` pairwise disjoint sensitive blocks! let z := flipBit x u have hfz : f z = false := by have hss : ({u} : Finset ι) ⊂ B₁ := by rw [hB₁eq, Finset.ssubset_iff_subset_ne] exact ⟨by simp, fun h => huu'.symm (by simpa using Finset.ext_iff.mp h u')⟩ simpa [z, flipSet_singleton, hfx] using (hmin B₁ hB₁).2 {u} hss have h_u'_z : IsSensBlock f z {u'} := by have hfl : flipSet z {u'} = flipSet x B₁ := by rw [hB₁eq, flipSet_singleton] ext j by_cases hj1 : j = u · subst hj1; simp [z, flipBit, flipSet, huu'] · by_cases hj2 : j = u' · subst hj2; simp [z, flipBit, flipSet, Ne.symm huu'] · simp [z, flipBit, flipSet, hj1, hj2] rw [IsSensBlock, hfl, hfz, ← hfx]; exact (hmin B₁ hB₁).1 have h_v1_z : IsSensBlock f z {v₁} := by have hfl : flipSet z {v₁} = flipSet x {u, v₁} := by rw [flipSet_singleton] ext j by_cases hj1 : j = u · subst hj1; simp [z, flipBit, flipSet, huv₁] · by_cases hj2 : j = v₁ · subst hj2; simp [z, flipBit, flipSet, Ne.symm huv₁] · simp [z, flipBit, flipSet, hj1, hj2] rw [IsSensBlock, hfl, hfz, ← hfx]; exact hsens_uv1 have h_v2_z : IsSensBlock f z {v₂} := by have hfl : flipSet z {v₂} = flipSet x {u, v₂} := by rw [flipSet_singleton] ext j by_cases hj1 : j = u · subst hj1; simp [z, flipBit, flipSet, huv₂] · by_cases hj2 : j = v₂ · subst hj2; simp [z, flipBit, flipSet, Ne.symm huv₂] · simp [z, flipBit, flipSet, hj1, hj2] rw [IsSensBlock, hfl, hfz, ← hfx]; exact hsens_uv2 -- Every `B ∈ (ℬ.erase B₁).erase B₂` has `|B| = 2 = s₁(f)`, so `u` is NOT sensitive at `x^{⊕ B}`! let ℬrest := (ℬ.erase B₁).erase B₂ have hrest_z : ∀ B ∈ ℬrest, IsSensBlock f z B := by intro B hB have hBmem : B ∈ ℬ := Finset.mem_of_mem_erase (Finset.mem_of_mem_erase hB) have hBne1 : B ≠ B₁ := Finset.ne_of_mem_erase (Finset.mem_of_mem_erase hB) have hnuB : u ∉ B := Finset.disjoint_left.mp (hdisj hB₁ hBmem hBne1.symm) huB₁ have hsubB : B ⊆ sensSet f (flipSet x B) := fun i hi => mem_sensSet_of_minSensBlock (hmin B hBmem) hi have hvalB : f (flipSet x B) = true := by have hne : f (flipSet x B) ≠ f x := (hmin B hBmem).1 rw [hfx] at hne; cases h1 : f (flipSet x B) <;> simp_all have hsensB_le2 : (sensSet f (flipSet x B)).card ≤ 2 := (hvalB ▸ sensAt_le_sensSide f (flipSet x B)).trans hs1 have hsensB_eq : B = sensSet f (flipSet x B) := Finset.eq_of_subset_of_card_le hsubB (by rw [hall2 B hBmem]; exact hsensB_le2) have hunot : u ∉ sensSet f (flipSet x B) := hsensB_eq ▸ hnuB rw [sensSet, Finset.mem_filter] at hunot have hfeq : f (flipBit (flipSet x B) u) = f (flipSet x B) := by by_contra hne; exact hunot ⟨Finset.mem_univ u, hne⟩ have hcomm : flipSet z B = flipBit (flipSet x B) u := by ext j by_cases hju : j = u · subst hju; simp [z, flipSet, flipBit, hnuB] · by_cases hjB : j ∈ B <;> simp [z, flipSet, flipBit, hju, hjB] rw [IsSensBlock, hcomm, hfeq, hfz, ← hfx]; exact (hmin B hBmem).1 have hu'v1 : u' ≠ v₁ := fun h => Finset.disjoint_left.mp (hdisj hB₁ hB₂ hB12) hu'B₁ (h ▸ hv₁B₂) have hu'v2 : u' ≠ v₂ := fun h => Finset.disjoint_left.mp (hdisj hB₁ hB₂ hB12) hu'B₁ (h ▸ hv₂B₂) have hdisj_u' : ∀ B ∈ ℬrest, Disjoint ({u'} : Finset ι) B := fun B hB => Finset.disjoint_singleton_left.mpr (Finset.disjoint_left.mp (hdisj hB₁ (Finset.mem_of_mem_erase (Finset.mem_of_mem_erase hB)) (Finset.ne_of_mem_erase (Finset.mem_of_mem_erase hB)).symm) hu'B₁) have hdisj_v1 : ∀ B ∈ ℬrest, Disjoint ({v₁} : Finset ι) B := fun B hB => Finset.disjoint_singleton_left.mpr (Finset.disjoint_left.mp (hdisj hB₂ (Finset.mem_of_mem_erase (Finset.mem_of_mem_erase hB)) (Finset.ne_of_mem_erase hB).symm) hv₁B₂) have hdisj_v2 : ∀ B ∈ ℬrest, Disjoint ({v₂} : Finset ι) B := fun B hB => Finset.disjoint_singleton_left.mpr (Finset.disjoint_left.mp (hdisj hB₂ (Finset.mem_of_mem_erase (Finset.mem_of_mem_erase hB)) (Finset.ne_of_mem_erase hB).symm) hv₂B₂) let 𝒞 : Finset (Finset ι) := insert {u'} (insert {v₁} (insert {v₂} ℬrest)) have h𝒞_fam : IsDisjointSensBlocks f z 𝒞 := by refine ⟨?_, ?_⟩ · intro B hB rcases Finset.mem_insert.mp hB with rfl | h1 · exact h_u'_z · rcases Finset.mem_insert.mp h1 with rfl | h2 · exact h_v1_z · rcases Finset.mem_insert.mp h2 with rfl | h3 · exact h_v2_z · exact hrest_z B h3 · intro A hA C hC hne rcases Finset.mem_insert.mp hA with rfl | hA1 <;> rcases Finset.mem_insert.mp hC with rfl | hC1 · exact absurd rfl hne · rcases Finset.mem_insert.mp hC1 with rfl | hC2 · exact Finset.disjoint_singleton.mpr hu'v1 · rcases Finset.mem_insert.mp hC2 with rfl | hC3 · exact Finset.disjoint_singleton.mpr hu'v2 · exact hdisj_u' C hC3 · rcases Finset.mem_insert.mp hA1 with rfl | hA2 · exact Finset.disjoint_singleton.mpr hu'v1.symm · rcases Finset.mem_insert.mp hA2 with rfl | hA3 · exact Finset.disjoint_singleton.mpr hu'v2.symm · exact (hdisj_u' A hA3).symm · rcases Finset.mem_insert.mp hA1 with rfl | hA2 <;> rcases Finset.mem_insert.mp hC1 with rfl | hC2 · exact absurd rfl hne · rcases Finset.mem_insert.mp hC2 with rfl | hC3 · exact Finset.disjoint_singleton.mpr hv12 · exact hdisj_v1 C hC3 · rcases Finset.mem_insert.mp hA2 with rfl | hA3 · exact Finset.disjoint_singleton.mpr hv12.symm · exact (hdisj_v1 A hA3).symm · rcases Finset.mem_insert.mp hA2 with rfl | hA3 <;> rcases Finset.mem_insert.mp hC2 with rfl | hC3 · exact absurd rfl hne · exact hdisj_v2 C hC3 · exact (hdisj_v2 A hA3).symm · exact hdisj (Finset.mem_of_mem_erase (Finset.mem_of_mem_erase hA3)) (Finset.mem_of_mem_erase (Finset.mem_of_mem_erase hC3)) hne have hnm_u' : ({u'} : Finset ι) ∉ ℬrest := fun h => by have := hall2 _ (Finset.mem_of_mem_erase (Finset.mem_of_mem_erase h)); simp at this have hnm_v1 : ({v₁} : Finset ι) ∉ ℬrest := fun h => by have := hall2 _ (Finset.mem_of_mem_erase (Finset.mem_of_mem_erase h)); simp at this have hnm_v2 : ({v₂} : Finset ι) ∉ ℬrest := fun h => by have := hall2 _ (Finset.mem_of_mem_erase (Finset.mem_of_mem_erase h)); simp at this have h𝒞_card : 𝒞.card = ℬ.card + 1 := by simp only [𝒞] rw [Finset.card_insert_of_notMem (by simp [hu'v1, hu'v2, hnm_u']), Finset.card_insert_of_notMem (by simp [hv12, hnm_v1]), Finset.card_insert_of_notMem hnm_v2] have hrest_card : ℬrest.card = ℬ.card - 2 := by simp only [ℬrest] rw [Finset.card_erase_of_mem (Finset.mem_erase.mpr ⟨hB12.symm, hB₂⟩), Finset.card_erase_of_mem hB₁] omega omega have hle := (card_le_blockSensAt h𝒞_fam).trans (hfz ▸ blockSensAt_le_blockSensSide f z) rw [h𝒞_card, hmax] at hle omega /-- **Exact `(2, 2)` Nisan Collapse**: `s₁(f) ≤ 2 ∧ bs₀(f) ≤ 2 → C₀(f) ≤ 2` (exact `2×` gain over Nisan's `s₁ · bs₀ = 4`). -/ theorem s1_le_two_bs0_le_two_cert0_le_two {f : (ι → Bool) → Bool} (hs1 : sensSide f true ≤ 2) (hbs0 : blockSensSide f false ≤ 2) : certSide f false ≤ 2 := by by_cases h2 : 2 ≤ blockSensSide f false · have := s1_le_two_cert0_le_two_bs0_sub_two hs1 h2; omega · -- `bs₀(f) ≤ 1`: then `C₀(f) ≤ s₁(f) · bs₀(f) ≤ 2 · 1 = 2` directly from Nisan! have hnisan := nisan_cert_le_sens_mul_bs f false have : sensSide f true * blockSensSide f false ≤ 2 * 1 := Nat.mul_le_mul hs1 (by omega) simpa using hnisan.trans this end Pillar2 /-! ## Pillar 3: Sharp Parity Decision Tree Hierarchy, Granularity, ## Spectral-Norm Gap & Rigidity, Signed-Collision Reduction, and Forbidden Sparsity Gap -/ section Pillar3 variable {ι : Type*} [DecidableEq ι] lemma zmod2_cases (a : ZMod 2) : a = 0 ∨ a = 1 := by fin_cases a · left; rfl · right; rfl @[simp] lemma zmod2_one_add_one : (1 : ZMod 2) + 1 = 0 := rfl lemma zmod2_add_self (a : ZMod 2) : a + a = 0 := by fin_cases a <;> decide @[simp] lemma symmDiff_empty_finset (A : Finset ι) : symmDiff A ∅ = A := by ext i; simp [Finset.mem_symmDiff] @[simp] lemma empty_symmDiff_finset (A : Finset ι) : symmDiff ∅ A = A := by ext i; simp [Finset.mem_symmDiff] @[simp] lemma symmDiff_eq_empty_finset (A B : Finset ι) : symmDiff A B = ∅ ↔ A = B := by rw [← Finset.bot_eq_empty, symmDiff_eq_bot] @[simp] lemma symmDiff_cancel_left (A B : Finset ι) : symmDiff A (symmDiff A B) = B := by ext i; simp only [Finset.mem_symmDiff]; tauto @[simp] lemma symmDiff_cancel_right (A B : Finset ι) : symmDiff (symmDiff A B) B = A := by ext i; simp only [Finset.mem_symmDiff]; tauto /-- Sign encoding `false ↦ +1`, `true ↦ -1`. -/ def boolSign (b : Bool) : ℝ := if b then -1 else 1 @[simp] lemma boolSign_sq (b : Bool) : boolSign b * boolSign b = 1 := by cases b <;> norm_num [boolSign] @[simp] lemma abs_boolSign (b : Bool) : |boolSign b| = 1 := by cases b <;> norm_num [boolSign] /-- Walsh–Fourier character `χ_S(x) = ∏_{i ∈ S} (-1)^{x_i}`. -/ def walshChar (S : Finset ι) (x : ι → Bool) : ℝ := ∏ i ∈ S, boolSign (x i) /-- Linear parity functional `⟨α, x⟩ ∈ ZMod 2`. -/ def parityVal (α : Finset ι) (x : ι → Bool) : ZMod 2 := ∑ i ∈ α, boolToZ2 (x i) omit [DecidableEq ι] in @[simp] lemma parityVal_empty (x : ι → Bool) : parityVal (∅ : Finset ι) x = 0 := by simp [parityVal] omit [DecidableEq ι] in @[simp] lemma parityVal_singleton (i : ι) (x : ι → Bool) : parityVal ({i} : Finset ι) x = boolToZ2 (x i) := by simp [parityVal] lemma parityVal_symmDiff (α β : Finset ι) (x : ι → Bool) : parityVal (symmDiff α β) x = parityVal α x + parityVal β x := by unfold parityVal have h1 : ∑ i ∈ α, boolToZ2 (x i) = (∑ i ∈ α \ β, boolToZ2 (x i)) + ∑ i ∈ α ∩ β, boolToZ2 (x i) := by rw [← Finset.sum_union (Finset.disjoint_sdiff_inter α β), Finset.sdiff_union_inter] have h2 : ∑ i ∈ β, boolToZ2 (x i) = (∑ i ∈ β \ α, boolToZ2 (x i)) + ∑ i ∈ α ∩ β, boolToZ2 (x i) := by have hd : Disjoint (β \ α) (α ∩ β) := by rw [Finset.inter_comm]; exact Finset.disjoint_sdiff_inter β α rw [← Finset.sum_union hd, Finset.inter_comm, Finset.sdiff_union_inter] have hsd : symmDiff α β = (α \ β) ∪ (β \ α) := Finset.symmDiff_def α β rw [hsd, Finset.sum_union disjoint_sdiff_sdiff, h1, h2] have hsum2 : (∑ i ∈ α ∩ β, boolToZ2 (x i)) + (∑ i ∈ α ∩ β, boolToZ2 (x i)) = 0 := zmod2_add_self _ calc (∑ i ∈ α \ β, boolToZ2 (x i)) + ∑ i ∈ β \ α, boolToZ2 (x i) = ((∑ i ∈ α \ β, boolToZ2 (x i)) + ∑ i ∈ β \ α, boolToZ2 (x i)) + 0 := (add_zero _).symm _ = ((∑ i ∈ α \ β, boolToZ2 (x i)) + ∑ i ∈ β \ α, boolToZ2 (x i)) + ((∑ i ∈ α ∩ β, boolToZ2 (x i)) + ∑ i ∈ α ∩ β, boolToZ2 (x i)) := by rw [hsum2] _ = ((∑ i ∈ α \ β, boolToZ2 (x i)) + ∑ i ∈ α ∩ β, boolToZ2 (x i)) + ((∑ i ∈ β \ α, boolToZ2 (x i)) + ∑ i ∈ α ∩ β, boolToZ2 (x i)) := by ring lemma walshChar_eq_parityVal (S : Finset ι) (x : ι → Bool) : walshChar S x = if parityVal S x = 0 then 1 else -1 := by induction S using Finset.induction_on with | empty => simp [walshChar, parityVal] | insert i S hi ih => have hprod : walshChar (insert i S) x = boolSign (x i) * walshChar S x := by simp [walshChar, Finset.prod_insert hi] have hp : parityVal (insert i S) x = boolToZ2 (x i) + parityVal S x := by simp [parityVal, Finset.sum_insert hi] rw [hprod, ih, hp] cases hx : x i <;> rcases zmod2_cases (parityVal S x) with hS | hS <;> simp [boolSign, boolToZ2, hS] lemma walshChar_mul (S T : Finset ι) (x : ι → Bool) : walshChar S x * walshChar T x = walshChar (symmDiff S T) x := by rw [walshChar_eq_parityVal, walshChar_eq_parityVal, walshChar_eq_parityVal, parityVal_symmDiff] rcases zmod2_cases (parityVal S x) with h1 | h1 <;> rcases zmod2_cases (parityVal T x) with h2 | h2 <;> simp [h1, h2] @[simp] lemma walshChar_sq (S : Finset ι) (x : ι → Bool) : walshChar S x * walshChar S x = 1 := by rw [walshChar_mul, symmDiff_self, walshChar_eq_parityVal] simp omit [DecidableEq ι] in @[simp] lemma walshChar_empty (x : ι → Bool) : walshChar (∅ : Finset ι) x = 1 := by simp [walshChar] lemma abs_walshChar (S : Finset ι) (x : ι → Bool) : |walshChar S x| = 1 := by rw [walshChar_eq_parityVal]; split_ifs <;> norm_num variable [Fintype ι] lemma sum_walshChar (S : Finset ι) : ∑ x : ι → Bool, walshChar S x = if S = ∅ then (2 : ℝ) ^ Fintype.card ι else 0 := by by_cases hS : S = ∅ · subst hS simp only [walshChar_empty, ↓reduceIte, Finset.sum_const, Finset.card_univ, Fintype.card_fun, Fintype.card_bool, nsmul_eq_mul, mul_one, Nat.cast_pow, Nat.cast_ofNat] · rw [if_neg hS] obtain ⟨i₀, hi₀⟩ := Finset.nonempty_iff_ne_empty.mpr hS have hneg : ∀ x : ι → Bool, walshChar S (flipBit x i₀) = -walshChar S x := by intro x rw [walshChar_eq_parityVal, walshChar_eq_parityVal] have hdiff : parityVal S (flipBit x i₀) = parityVal S x + 1 := by unfold parityVal rw [← Finset.add_sum_erase _ _ hi₀, ← Finset.add_sum_erase _ _ hi₀] have hrest : ∑ j ∈ S.erase i₀, boolToZ2 (flipBit x i₀ j) = ∑ j ∈ S.erase i₀, boolToZ2 (x j) := by apply Finset.sum_congr rfl intro j hj simp [flipBit, Finset.ne_of_mem_erase hj] rw [hrest] have hflip : boolToZ2 (flipBit x i₀ i₀) = boolToZ2 (x i₀) + 1 := by cases h : x i₀ <;> simp [flipBit, boolToZ2, h] rw [hflip]; ring rw [hdiff] rcases zmod2_cases (parityVal S x) with hp | hp <;> simp [hp] have hsum_eq : ∑ x : ι → Bool, walshChar S x = ∑ x : ι → Bool, walshChar S (flipBit x i₀) := Fintype.sum_equiv (Equiv.mk (fun x => flipBit x i₀) (fun x => flipBit x i₀) (fun x => flipBit_self x i₀) (fun x => flipBit_self x i₀)) _ _ (fun x => by simp [flipBit_self]) have hsum_neg : ∑ x : ι → Bool, walshChar S (flipBit x i₀) = -∑ x : ι → Bool, walshChar S x := by simp_rw [hneg, Finset.sum_neg_distrib] linarith /-- Walsh–Fourier coefficient `f̂(S)` of a Boolean function `f : (ι → Bool) → Bool`. -/ noncomputable def fourierCoeff (f : (ι → Bool) → Bool) (S : Finset ι) : ℝ := (2 : ℝ)⁻¹ ^ Fintype.card ι * ∑ x : ι → Bool, boolSign (f x) * walshChar S x /-- Real Fourier (multilinear polynomial) degree `deg(f)`. -/ noncomputable def realDeg (f : (ι → Bool) → Bool) : ℕ := by classical exact (Finset.univ.filter (fun S : Finset ι => fourierCoeff f S ≠ 0)).sup Finset.card /-- Fourier sparsity `‖f̂‖₀ = |supp(f̂)|`. -/ noncomputable def fourierSparsity (f : (ι → Bool) → Bool) : ℕ := by classical exact (Finset.univ.filter (fun S : Finset ι => fourierCoeff f S ≠ 0)).card /-- Fourier spectral norm `L₁(f̂) = ∑_S |f̂(S)|`. -/ noncomputable def spectralNorm (f : (ι → Bool) → Bool) : ℝ := ∑ S : Finset ι, |fourierCoeff f S| lemma exists_granularity (f : (ι → Bool) → Bool) : ∃ g : ℕ, ∀ S : Finset ι, ∃ z : ℤ, (2 : ℝ) ^ g * fourierCoeff f S = (z : ℝ) := by refine ⟨Fintype.card ι, fun S => ?_⟩ refine ⟨∑ x : ι → Bool, (if f x then (-1 : ℤ) else 1) * (if parityVal S x = 0 then (1 : ℤ) else -1), ?_⟩ unfold fourierCoeff have hinv : (2 : ℝ) ^ Fintype.card ι * (2 : ℝ)⁻¹ ^ Fintype.card ι = 1 := by rw [← mul_pow]; norm_num rw [← mul_assoc, hinv, one_mul] push_cast apply Finset.sum_congr rfl intro x _ rw [walshChar_eq_parityVal] cases f x <;> rcases zmod2_cases (parityVal S x) with hp | hp <;> simp [boolSign, hp] /-- Fourier granularity `gran(f) = min {g ∈ ℕ | ∀ S, 2^g f̂(S) ∈ ℤ}`. -/ noncomputable def granularity (f : (ι → Bool) → Bool) : ℕ := by classical exact Nat.find (exists_granularity f) lemma granularity_le_of_int {f : (ι → Bool) → Bool} {g : ℕ} (hg : ∀ S : Finset ι, ∃ z : ℤ, (2 : ℝ) ^ g * fourierCoeff f S = (z : ℝ)) : granularity f ≤ g := by classical exact Nat.find_min' (exists_granularity f) hg lemma granularity_spec (f : (ι → Bool) → Bool) : ∀ S : Finset ι, ∃ z : ℤ, (2 : ℝ) ^ granularity f * fourierCoeff f S = (z : ℝ) := by classical exact Nat.find_spec (exists_granularity f) lemma sum_walshChar_subsets (x y : ι → Bool) : ∑ S : Finset ι, walshChar S x * walshChar S y = if x = y then (2 : ℝ) ^ Fintype.card ι else 0 := by have hprod : ∀ S : Finset ι, walshChar S x * walshChar S y = ∏ i ∈ S, (boolSign (x i) * boolSign (y i)) := fun S => by simp [walshChar, Finset.prod_mul_distrib] simp_rw [hprod] have hfact : ∑ S : Finset ι, ∏ i ∈ S, (boolSign (x i) * boolSign (y i)) = ∏ i : ι, (1 + boolSign (x i) * boolSign (y i)) := by rw [Fintype.prod_add] simp only [Finset.prod_const_one, one_mul] exact Fintype.sum_equiv (Equiv.mk compl compl compl_compl compl_compl) _ _ (fun S => by simp) rw [hfact] by_cases hxy : x = y · subst hxy simp [boolSign_sq] norm_num · rw [if_neg hxy] have hex : ∃ i : ι, x i ≠ y i := by by_contra hall; push Not at hall; exact hxy (funext hall) obtain ⟨i₀, hi₀⟩ := hex apply Finset.prod_eq_zero (Finset.mem_univ i₀) cases hx : x i₀ <;> cases hy : y i₀ <;> simp_all [boolSign] /-- Exact Walsh–Fourier inversion: `boolSign (f x) = ∑_S f̂(S) χ_S(x)`. -/ theorem fourier_expansion (f : (ι → Bool) → Bool) (x : ι → Bool) : boolSign (f x) = ∑ S : Finset ι, fourierCoeff f S * walshChar S x := by simp only [fourierCoeff, Finset.mul_sum, Finset.sum_mul] rw [Finset.sum_comm] have hinner : ∀ y : ι → Bool, ∑ S : Finset ι, (2 : ℝ)⁻¹ ^ Fintype.card ι * (boolSign (f y) * walshChar S y) * walshChar S x = (2 : ℝ)⁻¹ ^ Fintype.card ι * boolSign (f y) * ∑ S : Finset ι, walshChar S y * walshChar S x := by intro y rw [Finset.mul_sum] apply Finset.sum_congr rfl intro S _; ring simp_rw [hinner, sum_walshChar_subsets] simp only [mul_ite, mul_zero, Finset.sum_ite_eq', Finset.mem_univ, ↓reduceIte] have hinv : (2 : ℝ)⁻¹ ^ Fintype.card ι * (2 : ℝ) ^ Fintype.card ι = 1 := by rw [← mul_pow]; norm_num calc boolSign (f x) = boolSign (f x) * 1 := (mul_one _).symm _ = boolSign (f x) * ((2 : ℝ)⁻¹ ^ Fintype.card ι * (2 : ℝ) ^ Fintype.card ι) := by rw [hinv] _ = (2 : ℝ)⁻¹ ^ Fintype.card ι * boolSign (f x) * (2 : ℝ) ^ Fintype.card ι := by ring /-- Exact Fourier autocorrelation identity: for every Boolean `f` and every `γ : Finset ι`, `∑_S f̂(S) f̂(S ∆ γ) = 1` if `γ = ∅` (Parseval) and `0` if `γ ≠ ∅` (Boolean orthogonality). -/ theorem fourier_autocorr (f : (ι → Bool) → Bool) (γ : Finset ι) : ∑ S : Finset ι, fourierCoeff f S * fourierCoeff f (symmDiff S γ) = if γ = ∅ then 1 else 0 := by have h1 : (2 : ℝ)⁻¹ ^ Fintype.card ι * ∑ x : ι → Bool, boolSign (f x) * boolSign (f x) * walshChar γ x = if γ = ∅ then 1 else 0 := by simp_rw [boolSign_sq, one_mul, sum_walshChar] split_ifs · rw [← mul_pow]; norm_num · ring rw [← h1] have h2 : ∀ x : ι → Bool, boolSign (f x) * boolSign (f x) * walshChar γ x = ∑ S : Finset ι, ∑ T : Finset ι, fourierCoeff f S * fourierCoeff f T * walshChar (symmDiff (symmDiff S T) γ) x := by intro x conv_lhs => rw [fourier_expansion f x] rw [Finset.sum_mul, Finset.sum_mul] apply Finset.sum_congr rfl intro S _ rw [Finset.mul_sum, Finset.sum_mul] apply Finset.sum_congr rfl intro T _ rw [← walshChar_mul, ← walshChar_mul] ring simp_rw [h2] rw [Finset.sum_comm, Finset.mul_sum] symm apply Finset.sum_congr rfl intro S _ rw [Finset.sum_comm, Finset.mul_sum] have hT : ∀ T : Finset ι, (2 : ℝ)⁻¹ ^ Fintype.card ι * ∑ x : ι → Bool, fourierCoeff f S * fourierCoeff f T * walshChar (symmDiff (symmDiff S T) γ) x = if T = symmDiff S γ then fourierCoeff f S * fourierCoeff f T else 0 := by intro T rw [← Finset.mul_sum, sum_walshChar] have hiff : symmDiff (symmDiff S T) γ = ∅ ↔ T = symmDiff S γ := by rw [symmDiff_eq_empty_finset] constructor · intro h calc T = symmDiff S (symmDiff S T) := (symmDiff_cancel_left S T).symm _ = symmDiff S γ := by rw [h] · intro h; subst h; exact symmDiff_cancel_left S γ by_cases ha : symmDiff (symmDiff S T) γ = ∅ <;> by_cases hb : T = symmDiff S γ · rw [if_pos ha, if_pos hb] have hinv : (2 : ℝ)⁻¹ ^ Fintype.card ι * (2 : ℝ) ^ Fintype.card ι = 1 := by rw [← mul_pow]; norm_num calc (2 : ℝ)⁻¹ ^ Fintype.card ι * (fourierCoeff f S * fourierCoeff f T * (2 : ℝ) ^ Fintype.card ι) = fourierCoeff f S * fourierCoeff f T * ((2 : ℝ)⁻¹ ^ Fintype.card ι * (2 : ℝ) ^ Fintype.card ι) := by ring _ = fourierCoeff f S * fourierCoeff f T := by rw [hinv, mul_one] · exact absurd (hiff.mp ha) hb · exact absurd (hiff.mpr hb) ha · rw [if_neg ha, if_neg hb]; ring simp_rw [hT] simp theorem parseval (f : (ι → Bool) → Bool) : ∑ S : Finset ι, (fourierCoeff f S) ^ 2 = 1 := by have h := fourier_autocorr f ∅ simp only [symmDiff_empty_finset, ↓reduceIte] at h simpa [sq] using h theorem boolean_fourier_autocorr_zero (f : (ι → Bool) → Bool) {γ : Finset ι} (hγ : γ ≠ ∅) : ∑ S : Finset ι, fourierCoeff f S * fourierCoeff f (symmDiff S γ) = 0 := by have h := fourier_autocorr f γ rwa [if_neg hγ] at h /-- Link between `deg₂(f)` and `realDeg(f)`: every ANF monomial coefficient is the mod-2 reduction of the exact integer multilinear coefficient, yielding `deg₂(f) ≤ realDeg(f)`. -/ lemma deg2_le_realDeg (f : (ι → Bool) → Bool) : deg2 f ≤ realDeg f := by classical unfold deg2 apply Finset.sup_le intro S hS have hnz : anfCoeff f S ≠ 0 := (Finset.mem_filter.mp hS).2 -- Show there exists `U ⊇ S` with `fourierCoeff f U ≠ 0`! by_contra hlt push Not at hlt have hzero_super : ∀ U : Finset ι, S ⊆ U → fourierCoeff f U = 0 := by intro U hSU by_contra hUnz have hUle : U.card ≤ realDeg f := Finset.le_sup (f := Finset.card) (by simp [hUnz]) have hSle : S.card ≤ U.card := Finset.card_le_card hSU omega -- Compute `∑ T ∈ S.powerset, (-1)^(|S|-|T|) * boolSign (f (indicatorVec T))`! -- On one hand, since `boolSign (f x) = 1 - 2 * 1_{f(x)}` and `S` is nonempty (as `realDeg f ≥ 0`, `S.card > realDeg f ≥ 0`), -- it equals `-2 * ∑ T ⊆ S, (-1)^(|S|-|T|) * 1_{f(1_T)}`. -- On the other hand, expanding via `fourier_expansion` gives `0` because every `U` with `S ⊆ U` has `f̂(U) = 0`, -- and every `U` with `¬ S ⊆ U` has `∑_{T ⊆ S} (-1)^(|S|-|T|) χ_U(1_T) = 0`! have hSpos : 0 < S.card := by omega have hSne : S.Nonempty := Finset.card_pos.mp hSpos have hsum_sign : ∑ T ∈ S.powerset, (-1 : ℝ) ^ (S.card - T.card) * boolSign (f (indicatorVec T)) = 0 := by simp_rw [fourier_expansion, Finset.mul_sum] rw [Finset.sum_comm] apply Finset.sum_eq_zero intro U _ by_cases hSU : S ⊆ U · simp [hzero_super U hSU] · have hex : ∃ i₀ ∈ S, i₀ ∉ U := by by_contra hall; push Not at hall; exact hSU hall obtain ⟨i₀, hi₀S, hi₀U⟩ := hex have hpull : ∑ T ∈ S.powerset, (-1 : ℝ) ^ (S.card - T.card) * (fourierCoeff f U * walshChar U (indicatorVec T)) = fourierCoeff f U * ∑ T ∈ S.powerset, (-1 : ℝ) ^ (S.card - T.card) * walshChar U (indicatorVec T) := by rw [Finset.mul_sum]; apply Finset.sum_congr rfl; intro T _; ring rw [hpull] suffices hz : ∑ T ∈ S.powerset, (-1 : ℝ) ^ (S.card - T.card) * walshChar U (indicatorVec T) = 0 by rw [hz, mul_zero] -- Pair `T ⊆ S` with `symmDiff T {i₀} ⊆ S`: `walshChar U` is unchanged since `i₀ ∉ U`, while `(-1)^(|S|-|T|)` negates! have hneg : ∀ T ∈ S.powerset, (-1 : ℝ) ^ (S.card - (symmDiff T {i₀}).card) * walshChar U (indicatorVec (symmDiff T {i₀})) = -((-1 : ℝ) ^ (S.card - T.card) * walshChar U (indicatorVec T)) := by intro T hT have hTS : T ⊆ S := Finset.mem_powerset.mp hT have hwal : walshChar U (indicatorVec (symmDiff T {i₀})) = walshChar U (indicatorVec T) := by unfold walshChar apply Finset.prod_congr rfl intro j hjU have hne : j ≠ i₀ := fun h => hi₀U (h ▸ hjU) simp [indicatorVec, Finset.mem_symmDiff, hne] rw [hwal] by_cases hi₀T : i₀ ∈ T · have hsd : symmDiff T {i₀} = T.erase i₀ := by ext j; simp only [Finset.mem_symmDiff, Finset.mem_singleton, Finset.mem_erase] by_cases h : j = i₀ <;> simp [h, hi₀T] have hcard : (symmDiff T {i₀}).card = T.card - 1 := by rw [hsd, Finset.card_erase_of_mem hi₀T] have hTpos : 1 ≤ T.card := Finset.card_pos.mpr ⟨i₀, hi₀T⟩ have hTle : T.card ≤ S.card := Finset.card_le_card hTS have hexp : S.card - (symmDiff T {i₀}).card = (S.card - T.card) + 1 := by omega rw [hexp, pow_succ]; ring · have hsd : symmDiff T {i₀} = insert i₀ T := by ext j; simp only [Finset.mem_symmDiff, Finset.mem_singleton, Finset.mem_insert] by_cases h : j = i₀ <;> simp [h, hi₀T] have hcard : (symmDiff T {i₀}).card = T.card + 1 := by rw [hsd, Finset.card_insert_of_notMem hi₀T] have hTlt : T.card + 1 ≤ S.card := by rw [← Finset.card_insert_of_notMem hi₀T] exact Finset.card_le_card (Finset.insert_subset hi₀S hTS) have hexp : S.card - T.card = (S.card - (symmDiff T {i₀}).card) + 1 := by omega rw [hexp, pow_succ]; ring have hbij : ∑ T ∈ S.powerset, (-1 : ℝ) ^ (S.card - T.card) * walshChar U (indicatorVec T) = ∑ T ∈ S.powerset, (-1 : ℝ) ^ (S.card - (symmDiff T {i₀}).card) * walshChar U (indicatorVec (symmDiff T {i₀})) := by apply Finset.sum_bij (fun T _ => symmDiff T {i₀}) · intro T hT rw [Finset.mem_powerset] at hT ⊢ intro j hj rcases Finset.mem_symmDiff.mp hj with ⟨h1, _⟩ | ⟨h2, _⟩ · exact hT h1 · exact (Finset.mem_singleton.mp h2) ▸ hi₀S · intro T₁ _ T₂ _ heq calc T₁ = symmDiff (symmDiff T₁ {i₀}) {i₀} := (symmDiff_cancel_right T₁ {i₀}).symm _ = symmDiff (symmDiff T₂ {i₀}) {i₀} := by rw [heq] _ = T₂ := symmDiff_cancel_right T₂ {i₀} · intro T hT refine ⟨symmDiff T {i₀}, ?_, symmDiff_cancel_right T {i₀}⟩ rw [Finset.mem_powerset] at hT ⊢ intro j hj rcases Finset.mem_symmDiff.mp hj with ⟨h1, _⟩ | ⟨h2, _⟩ · exact hT h1 · exact (Finset.mem_singleton.mp h2) ▸ hi₀S · intro T _; rw [symmDiff_cancel_right] have hsum_neg : ∑ T ∈ S.powerset, (-1 : ℝ) ^ (S.card - (symmDiff T {i₀}).card) * walshChar U (indicatorVec (symmDiff T {i₀})) = -∑ T ∈ S.powerset, (-1 : ℝ) ^ (S.card - T.card) * walshChar U (indicatorVec T) := by rw [← Finset.sum_neg_distrib] exact Finset.sum_congr rfl hneg linarith -- Also `∑ T ⊆ S, (-1)^(|S|-|T|) = 0` since `S` is nonempty! have hsum_one : ∑ T ∈ S.powerset, (-1 : ℝ) ^ (S.card - T.card) = 0 := by obtain ⟨i₀, hi₀S⟩ := hSne have hbij : ∑ T ∈ S.powerset, (-1 : ℝ) ^ (S.card - T.card) = ∑ T ∈ S.powerset, (-1 : ℝ) ^ (S.card - (symmDiff T {i₀}).card) := by apply Finset.sum_bij (fun T _ => symmDiff T {i₀}) · intro T hT; rw [Finset.mem_powerset] at hT ⊢ intro j hj; rcases Finset.mem_symmDiff.mp hj with ⟨h1, _⟩ | ⟨h2, _⟩ · exact hT h1 · exact (Finset.mem_singleton.mp h2) ▸ hi₀S · intro T₁ _ T₂ _ heq calc T₁ = symmDiff (symmDiff T₁ {i₀}) {i₀} := (symmDiff_cancel_right T₁ {i₀}).symm _ = symmDiff (symmDiff T₂ {i₀}) {i₀} := by rw [heq] _ = T₂ := symmDiff_cancel_right T₂ {i₀} · intro T hT; refine ⟨symmDiff T {i₀}, ?_, symmDiff_cancel_right T {i₀}⟩ rw [Finset.mem_powerset] at hT ⊢ intro j hj; rcases Finset.mem_symmDiff.mp hj with ⟨h1, _⟩ | ⟨h2, _⟩ · exact hT h1 · exact (Finset.mem_singleton.mp h2) ▸ hi₀S · intro T _; rw [symmDiff_cancel_right] have hneg : ∀ T ∈ S.powerset, (-1 : ℝ) ^ (S.card - (symmDiff T {i₀}).card) = -((-1 : ℝ) ^ (S.card - T.card)) := by intro T hT have hTS : T ⊆ S := Finset.mem_powerset.mp hT by_cases hi₀T : i₀ ∈ T · have hsd : symmDiff T {i₀} = T.erase i₀ := by ext j; simp only [Finset.mem_symmDiff, Finset.mem_singleton, Finset.mem_erase] by_cases h : j = i₀ <;> simp [h, hi₀T] have hcard : (symmDiff T {i₀}).card = T.card - 1 := by rw [hsd, Finset.card_erase_of_mem hi₀T] have hTpos : 1 ≤ T.card := Finset.card_pos.mpr ⟨i₀, hi₀T⟩ have hTle : T.card ≤ S.card := Finset.card_le_card hTS have hexp : S.card - (symmDiff T {i₀}).card = (S.card - T.card) + 1 := by omega rw [hexp, pow_succ]; ring · have hsd : symmDiff T {i₀} = insert i₀ T := by ext j; simp only [Finset.mem_symmDiff, Finset.mem_singleton, Finset.mem_insert] by_cases h : j = i₀ <;> simp [h, hi₀T] have hcard : (symmDiff T {i₀}).card = T.card + 1 := by rw [hsd, Finset.card_insert_of_notMem hi₀T] have hTlt : T.card + 1 ≤ S.card := by rw [← Finset.card_insert_of_notMem hi₀T] exact Finset.card_le_card (Finset.insert_subset hi₀S hTS) have hexp : S.card - T.card = (S.card - (symmDiff T {i₀}).card) + 1 := by omega rw [hexp, pow_succ]; ring have hsum_neg : ∑ T ∈ S.powerset, (-1 : ℝ) ^ (S.card - (symmDiff T {i₀}).card) = -∑ T ∈ S.powerset, (-1 : ℝ) ^ (S.card - T.card) := by rw [← Finset.sum_neg_distrib]; exact Finset.sum_congr rfl hneg linarith -- Hence the integer Möbius coefficient `z := ∑ T ⊆ S, (-1)^(|S|-|T|) * 1_{f(1_T)}` is `0`, -- contradicting `anfCoeff f S = (z : ZMod 2) ≠ 0`! let z : ℤ := ∑ T ∈ S.powerset, (-1 : ℤ) ^ (S.card - T.card) * (if f (indicatorVec T) then 1 else 0) have hz_real : (z : ℝ) = 0 := by have hrel : ∀ b : Bool, boolSign b = 1 - 2 * (if b then (1 : ℝ) else 0) := by intro b; cases b <;> norm_num [boolSign] have hcalc : ∑ T ∈ S.powerset, (-1 : ℝ) ^ (S.card - T.card) * boolSign (f (indicatorVec T)) = (∑ T ∈ S.powerset, (-1 : ℝ) ^ (S.card - T.card)) - 2 * (z : ℝ) := by simp only [z]; push_cast rw [Finset.mul_sum, ← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro T _ rw [hrel]; ring linarith have hz0 : z = 0 := Int.cast_eq_zero.mp hz_real have hmod : (z : ZMod 2) = anfCoeff f S := by simp only [z, anfCoeff] push_cast apply Finset.sum_congr rfl intro T _ have hm1 : (-1 : ZMod 2) = 1 := rfl rw [hm1, one_pow, one_mul] cases f (indicatorVec T) <;> rfl rw [hz0] at hmod exact hnz (by simpa using hmod.symm) /-- Corollary: `D(f) ≤ deg(f) · min(bs₀(f), bs₁(f))` (asymmetric refinement of Midrijanis 2004). -/ theorem detDepth_le_realDeg_mul_min_bs (f : (ι → Bool) → Bool) : detDepth f ≤ realDeg f * min (blockSensSide f false) (blockSensSide f true) := (detDepth_le_deg2_mul_min_bs f).trans (Nat.mul_le_mul_right _ (deg2_le_realDeg f)) /-! ### Parity Decision Trees, Affine Certificates, and Hyperplane Restrictions -/ /-- Explicit parity decision trees querying arbitrary `𝔽₂`-linear forms `⟨α, x⟩`. -/ inductive ParityDecTree (ι : Type*) where | leaf (b : Bool) : ParityDecTree ι | branch (α : Finset ι) (tZero tOne : ParityDecTree ι) : ParityDecTree ι /-- Evaluation of a parity decision tree on `x : ι → Bool`. -/ def ParityDecTree.eval : ParityDecTree ι → (ι → Bool) → Bool | .leaf b, _ => b | .branch α t0 t1, x => if parityVal α x = 0 then t0.eval x else t1.eval x /-- Depth of a parity decision tree. -/ def ParityDecTree.depth : ParityDecTree ι → ℕ | .leaf _ => 0 | .branch _ t0 t1 => 1 + max t0.depth t1.depth /-- Embedding every standard decision tree into a parity decision tree of identical depth. -/ def DecTree.toParityDecTree : DecTree ι → ParityDecTree ι | .leaf b => .leaf b | .branch i tF tT => .branch {i} tF.toParityDecTree tT.toParityDecTree omit [DecidableEq ι] [Fintype ι] in lemma DecTree.toParityDecTree_eval (t : DecTree ι) (x : ι → Bool) : t.toParityDecTree.eval x = t.eval x := by induction t with | leaf b => rfl | branch i tF tT ihF ihT => simp only [DecTree.toParityDecTree, ParityDecTree.eval, DecTree.eval, parityVal_singleton] cases h : x i <;> simp [boolToZ2, ihF, ihT] omit [DecidableEq ι] [Fintype ι] in lemma DecTree.toParityDecTree_depth (t : DecTree ι) : t.toParityDecTree.depth = t.depth := by induction t with | leaf b => rfl | branch i tF tT ihF ihT => simp [DecTree.toParityDecTree, ParityDecTree.depth, DecTree.depth, ihF, ihT] lemma exists_parityDecTree (f : (ι → Bool) → Bool) : ∃ d : ℕ, ∃ t : ParityDecTree ι, (∀ x, t.eval x = f x) ∧ t.depth = d := by obtain ⟨t, ht_eval, _⟩ := exists_decTree_eq_detDepth f exact ⟨t.toParityDecTree.depth, t.toParityDecTree, fun x => (t.toParityDecTree_eval x).trans (ht_eval x), rfl⟩ /-- Deterministic parity decision tree complexity `D_⊕(f)`. -/ noncomputable def parityDepth (f : (ι → Bool) → Bool) : ℕ := by classical exact Nat.find (exists_parityDecTree f) lemma parityDepth_le_of_tree {f : (ι → Bool) → Bool} {t : ParityDecTree ι} (heval : ∀ x, t.eval x = f x) : parityDepth f ≤ t.depth := by classical exact Nat.find_min' (exists_parityDecTree f) ⟨t, heval, rfl⟩ lemma exists_parityDecTree_eq_parityDepth (f : (ι → Bool) → Bool) : ∃ t : ParityDecTree ι, (∀ x, t.eval x = f x) ∧ t.depth = parityDepth f := by classical exact Nat.find_spec (exists_parityDecTree f) theorem parityDepth_le_detDepth (f : (ι → Bool) → Bool) : parityDepth f ≤ detDepth f := by obtain ⟨t, ht_eval, ht_depth⟩ := exists_decTree_eq_detDepth f calc parityDepth f ≤ t.toParityDecTree.depth := parityDepth_le_of_tree (fun x => (t.toParityDecTree_eval x).trans (ht_eval x)) _ = t.depth := t.toParityDecTree_depth _ = detDepth f := ht_depth /-- Parity (affine-subspace) certificate: `A : Finset (Finset ι)` certifies `f` at `x` if every `y` agreeing with `x` on all parities `α ∈ A` has `f y = f x`. -/ def IsParityCert (f : (ι → Bool) → Bool) (x : ι → Bool) (A : Finset (Finset ι)) : Prop := ∀ y : ι → Bool, (∀ α ∈ A, parityVal α y = parityVal α x) → f y = f x lemma exists_parityCert (f : (ι → Bool) → Bool) (x : ι → Bool) : ∃ k : ℕ, ∃ A : Finset (Finset ι), IsParityCert f x A ∧ A.card = k := by obtain ⟨S, hS, hScard⟩ := exists_isCert_eq_certAt f x refine ⟨S.card, S.image (fun i => ({i} : Finset ι)), ?_, Finset.card_image_of_injective _ Finset.singleton_injective⟩ intro y hy apply hS intro i hi have h1 := hy {i} (Finset.mem_image_of_mem _ hi) simp only [parityVal_singleton] at h1 cases h2 : y i <;> cases h3 : x i <;> simp_all [boolToZ2] /-- Pointwise parity certificate complexity `C_⊕(f, x)`. -/ noncomputable def parityCertAt (f : (ι → Bool) → Bool) (x : ι → Bool) : ℕ := by classical exact Nat.find (exists_parityCert f x) /-- One-sided parity certificate complexity `C_b^⊕(f)`. -/ noncomputable def parityCertSide (f : (ι → Bool) → Bool) (b : Bool) : ℕ := (Finset.univ.filter (fun x => f x = b)).sup (parityCertAt f) /-- Maximum parity certificate complexity `C_⊕(f)`. -/ noncomputable def parityCert (f : (ι → Bool) → Bool) : ℕ := max (parityCertSide f false) (parityCertSide f true) lemma parityCertAt_le_of_isParityCert {f : (ι → Bool) → Bool} {x : ι → Bool} {A : Finset (Finset ι)} (hA : IsParityCert f x A) : parityCertAt f x ≤ A.card := by classical exact Nat.find_min' (exists_parityCert f x) ⟨A, hA, rfl⟩ lemma exists_isParityCert_eq_parityCertAt (f : (ι → Bool) → Bool) (x : ι → Bool) : ∃ A : Finset (Finset ι), IsParityCert f x A ∧ A.card = parityCertAt f x := by classical exact Nat.find_spec (exists_parityCert f x) lemma parityCertAt_le_certAt (f : (ι → Bool) → Bool) (x : ι → Bool) : parityCertAt f x ≤ certAt f x := by obtain ⟨S, hS, hScard⟩ := exists_isCert_eq_certAt f x rw [← hScard, ← Finset.card_image_of_injective S Finset.singleton_injective] apply parityCertAt_le_of_isParityCert intro y hy apply hS intro i hi have h1 := hy {i} (Finset.mem_image_of_mem _ hi) simp only [parityVal_singleton] at h1 cases h2 : y i <;> cases h3 : x i <;> simp_all [boolToZ2] theorem parityCertSide_le_certSide (f : (ι → Bool) → Bool) (b : Bool) : parityCertSide f b ≤ certSide f b := Finset.sup_le fun x hx => (parityCertAt_le_certAt f x).trans (Finset.le_sup (f := certAt f) hx) /-- The set of parities queried along a parity decision tree path on `x`. -/ def ParityDecTree.queriedParities : ParityDecTree ι → (ι → Bool) → Finset (Finset ι) | .leaf _, _ => ∅ | .branch α t0 t1, x => insert α (if parityVal α x = 0 then t0.queriedParities x else t1.queriedParities x) omit [Fintype ι] in lemma ParityDecTree.queriedParities_card_le (t : ParityDecTree ι) (x : ι → Bool) : (t.queriedParities x).card ≤ t.depth := by induction t with | leaf b => simp [ParityDecTree.queriedParities, ParityDecTree.depth] | branch α t0 t1 ih0 ih1 => simp only [ParityDecTree.queriedParities, ParityDecTree.depth] split_ifs · calc (insert α (t0.queriedParities x)).card ≤ (t0.queriedParities x).card + 1 := Finset.card_insert_le _ _ _ ≤ t0.depth + 1 := Nat.add_le_add_right ih0 1 _ ≤ 1 + max t0.depth t1.depth := by omega · calc (insert α (t1.queriedParities x)).card ≤ (t1.queriedParities x).card + 1 := Finset.card_insert_le _ _ _ ≤ t1.depth + 1 := Nat.add_le_add_right ih1 1 _ ≤ 1 + max t0.depth t1.depth := by omega omit [Fintype ι] in lemma ParityDecTree.eval_eq_of_agree_queriedParities (t : ParityDecTree ι) (x y : ι → Bool) (h : ∀ α ∈ t.queriedParities x, parityVal α y = parityVal α x) : t.eval y = t.eval x := by induction t with | leaf b => rfl | branch α t0 t1 ih0 ih1 => have hα : parityVal α y = parityVal α x := h α (Finset.mem_insert_self α _) simp only [ParityDecTree.eval, hα] split_ifs with h0 · apply ih0; intro β hβ exact h β (Finset.mem_insert_of_mem (by simpa [h0] using hβ)) · apply ih1; intro β hβ exact h β (Finset.mem_insert_of_mem (by simpa [h0] using hβ)) theorem parityCertAt_le_parityDepth (f : (ι → Bool) → Bool) (x : ι → Bool) : parityCertAt f x ≤ parityDepth f := by obtain ⟨t, ht_eval, ht_depth⟩ := exists_parityDecTree_eq_parityDepth f have hpc : IsParityCert f x (t.queriedParities x) := fun y hy => by rw [← ht_eval y, ← ht_eval x] exact t.eval_eq_of_agree_queriedParities x y hy exact (parityCertAt_le_of_isParityCert hpc).trans (ht_depth ▸ t.queriedParities_card_le x) theorem parityCertSide_le_parityDepth (f : (ι → Bool) → Bool) (b : Bool) : parityCertSide f b ≤ parityDepth f := Finset.sup_le fun x _ => parityCertAt_le_parityDepth f x theorem parityCert_le_parityDepth (f : (ι → Bool) → Bool) : parityCert f ≤ parityDepth f := max_le (parityCertSide_le_parityDepth f false) (parityCertSide_le_parityDepth f true) /-! ### Exact Parity-Tree Structural Bounds (Theorems 3A & 3B) -/ /-- Helper: multiplying an `𝔽₂` function of ANF degree `≤ d` by a linear form `⟨α, x⟩ + c` yields ANF degree `≤ d + 1`. -/ lemma deg2_branch_le (α : Finset ι) (f0 f1 : (ι → Bool) → Bool) : deg2 (fun x => if parityVal α x = 0 then f0 x else f1 x) ≤ 1 + max (deg2 f0) (deg2 f1) := by let g : (ι → Bool) → Bool := fun x => if parityVal α x = 0 then f0 x else f1 x -- Write `boolToZ2 (g x) = boolToZ2 (f0 x) + parityVal α x * (boolToZ2 (f0 x) + boolToZ2 (f1 x))`! have hform : ∀ x : ι → Bool, boolToZ2 (g x) = boolToZ2 (f0 x) + parityVal α x * (boolToZ2 (f0 x) + boolToZ2 (f1 x)) := by intro x simp only [g] rcases zmod2_cases (parityVal α x) with hp | hp · simp [hp] · simp only [hp, one_ne_zero, ↓reduceIte, one_mul] have h2 : boolToZ2 (f0 x) + boolToZ2 (f0 x) = 0 := zmod2_add_self _ calc boolToZ2 (f1 x) = 0 + boolToZ2 (f1 x) := (zero_add _).symm _ = (boolToZ2 (f0 x) + boolToZ2 (f0 x)) + boolToZ2 (f1 x) := by rw [h2] _ = boolToZ2 (f0 x) + (boolToZ2 (f0 x) + boolToZ2 (f1 x)) := by ring let h : Finset ι → ZMod 2 := fun T => anfCoeff f0 T + anfCoeff f1 T let c : Finset ι → ZMod 2 := fun S => anfCoeff f0 S + ∑ i ∈ S ∩ α, (h S + h (S.erase i)) have hc_eval : ∀ x : ι → Bool, boolToZ2 (g x) = ∑ S ∈ (inputSupp x).powerset, c S := by intro x rw [hform, anf_eval f0 x, anf_eval f1 x] have hsum_h : (∑ S ∈ (inputSupp x).powerset, anfCoeff f0 S) + ∑ S ∈ (inputSupp x).powerset, anfCoeff f1 S = ∑ T ∈ (inputSupp x).powerset, h T := (Finset.sum_add_distrib).symm rw [hsum_h] have hpar : parityVal α x = ∑ i ∈ inputSupp x ∩ α, (1 : ZMod 2) := by unfold parityVal have hfilt : inputSupp x ∩ α = α.filter (fun i => x i = true) := by ext i; simp [inputSupp, Finset.mem_inter, and_comm] rw [hfilt, Finset.sum_filter] apply Finset.sum_congr rfl intro i _ cases hx : x i <;> simp [boolToZ2] rw [hpar, Finset.sum_mul] simp_rw [one_mul] have hprod : ∑ i ∈ inputSupp x ∩ α, ∑ T ∈ (inputSupp x).powerset, h T = ∑ S ∈ (inputSupp x).powerset, ∑ i ∈ S ∩ α, (h S + h (S.erase i)) := by have hrhs : ∑ S ∈ (inputSupp x).powerset, ∑ i ∈ S ∩ α, (h S + h (S.erase i)) = ∑ i ∈ inputSupp x ∩ α, ∑ S ∈ (inputSupp x).powerset.filter (fun S => i ∈ S), (h S + h (S.erase i)) := by rw [Finset.sum_sigma', Finset.sum_sigma'] apply Finset.sum_bij (fun p _ => ⟨p.2, p.1⟩) · intro ⟨S, i⟩ hp simp only [Finset.mem_sigma, Finset.mem_powerset, Finset.mem_inter, Finset.mem_filter] at hp ⊢ exact ⟨⟨hp.1 hp.2.1, hp.2.2⟩, hp.1, hp.2.1⟩ · intro ⟨S₁, i₁⟩ _ ⟨S₂, i₂⟩ _ heq; cases heq; rfl · intro ⟨i, S⟩ hp simp only [Finset.mem_sigma, Finset.mem_powerset, Finset.mem_inter, Finset.mem_filter] at hp ⊢ exact ⟨⟨S, i⟩, ⟨hp.2.1, hp.2.2, hp.1.2⟩, rfl⟩ · intro _ _; rfl rw [hrhs] apply Finset.sum_congr rfl intro i hi have hiX : i ∈ inputSupp x := (Finset.mem_inter.mp hi).1 have hpart : ∑ T ∈ (inputSupp x).powerset, h T = (∑ T ∈ (inputSupp x).powerset.filter (fun T => i ∈ T), h T) + (∑ T ∈ (inputSupp x).powerset.filter (fun T => i ∉ T), h T) := (Finset.sum_filter_add_sum_filter_not _ _ _).symm rw [hpart] conv_rhs => rw [Finset.sum_add_distrib] congr 1 apply Finset.sum_bij (fun T _ => insert i T) · intro T hT simp only [Finset.mem_filter, Finset.mem_powerset] at hT ⊢ exact ⟨Finset.insert_subset hiX hT.1, Finset.mem_insert_self i T⟩ · intro T₁ hT₁ T₂ hT₂ heq simp only [Finset.mem_filter] at hT₁ hT₂ have := congrArg (fun S => S.erase i) heq simpa [Finset.erase_insert hT₁.2, Finset.erase_insert hT₂.2] using this · intro S hS simp only [Finset.mem_filter, Finset.mem_powerset] at hS refine ⟨S.erase i, ?_, Finset.insert_erase hS.2⟩ simp only [Finset.mem_filter, Finset.mem_powerset] exact ⟨(Finset.erase_subset i S).trans hS.1, Finset.notMem_erase i S⟩ · intro T hT simp only [Finset.mem_filter] at hT rw [Finset.erase_insert hT.2] rw [hprod, ← Finset.sum_add_distrib] -- Now bound `deg2 g`: for any `S` with `anfCoeff g S ≠ 0`, `c S ≠ 0`! unfold deg2 apply Finset.sup_le intro S hS have hne : c S ≠ 0 := by rw [← anfCoeff_unique g c hc_eval S] exact (Finset.mem_filter.mp hS).2 by_cases h0 : anfCoeff f0 S ≠ 0 · have hle : S.card ≤ deg2 f0 := Finset.le_sup (f := Finset.card) (by simp [h0]) exact hle.trans ((le_max_left _ _).trans (Nat.le_add_left _ 1)) · push Not at h0 have hsum_ne : ∑ i ∈ S ∩ α, (h S + h (S.erase i)) ≠ 0 := by simpa [c, h0] using hne have hex : ∃ i ∈ S ∩ α, h S + h (S.erase i) ≠ 0 := by by_contra hall; push Not at hall; exact hsum_ne (Finset.sum_eq_zero hall) obtain ⟨i, hi, hi_ne⟩ := hex have hiS : i ∈ S := (Finset.mem_inter.mp hi).1 have hcases : anfCoeff f0 S ≠ 0 ∨ anfCoeff f1 S ≠ 0 ∨ anfCoeff f0 (S.erase i) ≠ 0 ∨ anfCoeff f1 (S.erase i) ≠ 0 := by by_contra hall; push Not at hall rcases hall with ⟨a1, a2, a3, a4⟩ exact hi_ne (by simp [h, a1, a2, a3, a4]) rcases hcases with h1 | h1 | h1 | h1 · have hle : S.card ≤ deg2 f0 := Finset.le_sup (f := Finset.card) (by simp [h1]) exact hle.trans ((le_max_left _ _).trans (Nat.le_add_left _ 1)) · have hle : S.card ≤ deg2 f1 := Finset.le_sup (f := Finset.card) (by simp [h1]) exact hle.trans ((le_max_right _ _).trans (Nat.le_add_left _ 1)) · have hle : (S.erase i).card ≤ deg2 f0 := Finset.le_sup (f := Finset.card) (by simp [h1]) have hcard := Finset.card_erase_add_one hiS calc S.card = (S.erase i).card + 1 := hcard.symm _ = 1 + (S.erase i).card := Nat.add_comm _ _ _ ≤ 1 + max (deg2 f0) (deg2 f1) := Nat.add_le_add_left (hle.trans (le_max_left _ _)) 1 · have hle : (S.erase i).card ≤ deg2 f1 := Finset.le_sup (f := Finset.card) (by simp [h1]) have hcard := Finset.card_erase_add_one hiS calc S.card = (S.erase i).card + 1 := hcard.symm _ = 1 + (S.erase i).card := Nat.add_comm _ _ _ ≤ 1 + max (deg2 f0) (deg2 f1) := Nat.add_le_add_left (hle.trans (le_max_right _ _)) 1 /-- **Theorem 3A (Part 1 — `𝔽₂`-Degree Lower Bound for Parity Decision Trees)**: `deg₂(f) ≤ D_⊕(f)` for every Boolean function `f`. -/ theorem deg2_le_parityDepth (f : (ι → Bool) → Bool) : deg2 f ≤ parityDepth f := by obtain ⟨t, ht_eval, ht_depth⟩ := exists_parityDecTree_eq_parityDepth f have hfun : f = t.eval := funext fun x => (ht_eval x).symm rw [← ht_depth, hfun] clear ht_eval ht_depth hfun f induction t with | leaf b => have h0 : deg2 (fun _ : ι → Bool => b) = 0 := (deg2_eq_zero_iff_const _).mpr (fun _ _ => rfl) simp [ParityDecTree.eval, ParityDecTree.depth, h0] | branch α t0 t1 ih0 ih1 => calc deg2 (ParityDecTree.branch α t0 t1).eval ≤ 1 + max (deg2 t0.eval) (deg2 t1.eval) := deg2_branch_le α t0.eval t1.eval _ ≤ 1 + max t0.depth t1.depth := Nat.add_le_add_left (max_le_max ih0 ih1) 1 /-- Exact Fourier coefficient decomposition of a parity-tree branch `if ⟨α, x⟩ = 0 then f₀ else f₁`. -/ lemma fourierCoeff_branch (α : Finset ι) (f0 f1 : (ι → Bool) → Bool) (S : Finset ι) : fourierCoeff (fun x => if parityVal α x = 0 then f0 x else f1 x) S = (fourierCoeff f0 S + fourierCoeff f1 S) / 2 + (fourierCoeff f0 (symmDiff S α) - fourierCoeff f1 (symmDiff S α)) / 2 := by have hsign : ∀ x : ι → Bool, boolSign (if parityVal α x = 0 then f0 x else f1 x) = (1 + walshChar α x) / 2 * boolSign (f0 x) + (1 - walshChar α x) / 2 * boolSign (f1 x) := by intro x rw [walshChar_eq_parityVal] split_ifs <;> ring unfold fourierCoeff simp_rw [hsign] have hsplit : ∀ x : ι → Bool, ((1 + walshChar α x) / 2 * boolSign (f0 x) + (1 - walshChar α x) / 2 * boolSign (f1 x)) * walshChar S x = (boolSign (f0 x) * walshChar S x + boolSign (f1 x) * walshChar S x) / 2 + (boolSign (f0 x) * walshChar (symmDiff S α) x - boolSign (f1 x) * walshChar (symmDiff S α) x) / 2 := by intro x rw [← walshChar_mul] ring simp_rw [hsplit, Finset.sum_add_distrib, ← Finset.sum_div, Finset.sum_add_distrib, Finset.sum_sub_distrib] ring /-- Helper: every parity decision tree of depth `d` has Fourier coefficients in `2^{-d} ℤ`, and for `d ≥ 1` even in `2^{-(d - 1)} ℤ` (Chistopolskaya–Podolskii 2018)! -/ lemma parityTree_fourier_dyadic (t : ParityDecTree ι) : (t.depth = 0 → ∀ S : Finset ι, ∃ z : ℤ, fourierCoeff t.eval S = (z : ℝ)) ∧ (1 ≤ t.depth → ∀ S : Finset ι, ∃ z : ℤ, (2 : ℝ) ^ (t.depth - 1) * fourierCoeff t.eval S = (z : ℝ)) := by induction t with | leaf b => refine ⟨fun _ S => ?_, fun h => by simp [ParityDecTree.depth] at h⟩ simp only [ParityDecTree.eval] unfold fourierCoeff simp_rw [← Finset.mul_sum, sum_walshChar] by_cases hS : S = ∅ · subst hS have hinv : (2 : ℝ)⁻¹ ^ Fintype.card ι * (2 : ℝ) ^ Fintype.card ι = 1 := by rw [← mul_pow]; norm_num refine ⟨if b then -1 else 1, ?_⟩ simp only [↓reduceIte] calc (2 : ℝ)⁻¹ ^ Fintype.card ι * (boolSign b * (2 : ℝ) ^ Fintype.card ι) = boolSign b * ((2 : ℝ)⁻¹ ^ Fintype.card ι * (2 : ℝ) ^ Fintype.card ι) := by ring _ = boolSign b := by rw [hinv, mul_one] _ = ↑(if b then (-1 : ℤ) else 1) := by cases b <;> norm_num [boolSign] · refine ⟨0, ?_⟩ simp [hS] | branch α t0 t1 ih0 ih1 => refine ⟨fun h => by simp [ParityDecTree.depth] at h, fun _ S => ?_⟩ simp only [ParityDecTree.depth, Nat.add_sub_cancel_left] let d := max t0.depth t1.depth -- Case `d = 0`: both `t0` and `t1` are leaves, so `t.eval` is either constant or `±χ_α`, -- which has **integer** Fourier coefficients (`2^0 · f̂(S) ∈ ℤ`)!! by_cases hd0 : d = 0 · have h0 : t0.depth = 0 := by omega have h1 : t1.depth = 0 := by omega have hleaf : ∀ t' : ParityDecTree ι, t'.depth = 0 → ∃ c : Bool, ∀ x, t'.eval x = c := by intro t' ht' cases t' with | leaf c => exact ⟨c, fun _ => rfl⟩ | branch _ _ _ => simp [ParityDecTree.depth] at ht' obtain ⟨c0, hc0⟩ := hleaf t0 h0 obtain ⟨c1, hc1⟩ := hleaf t1 h1 have hf0 : ∀ U, fourierCoeff t0.eval U = if U = ∅ then boolSign c0 else 0 := by intro U; unfold fourierCoeff simp_rw [hc0, ← Finset.mul_sum, sum_walshChar] split_ifs · have hinv : (2 : ℝ)⁻¹ ^ Fintype.card ι * (2 : ℝ) ^ Fintype.card ι = 1 := by rw [← mul_pow]; norm_num calc (2 : ℝ)⁻¹ ^ Fintype.card ι * (boolSign c0 * (2 : ℝ) ^ Fintype.card ι) = boolSign c0 * ((2 : ℝ)⁻¹ ^ Fintype.card ι * (2 : ℝ) ^ Fintype.card ι) := by ring _ = boolSign c0 := by rw [hinv, mul_one] · ring have hf1 : ∀ U, fourierCoeff t1.eval U = if U = ∅ then boolSign c1 else 0 := by intro U; unfold fourierCoeff simp_rw [hc1, ← Finset.mul_sum, sum_walshChar] split_ifs · have hinv : (2 : ℝ)⁻¹ ^ Fintype.card ι * (2 : ℝ) ^ Fintype.card ι = 1 := by rw [← mul_pow]; norm_num calc (2 : ℝ)⁻¹ ^ Fintype.card ι * (boolSign c1 * (2 : ℝ) ^ Fintype.card ι) = boolSign c1 * ((2 : ℝ)⁻¹ ^ Fintype.card ι * (2 : ℝ) ^ Fintype.card ι) := by ring _ = boolSign c1 := by rw [hinv, mul_one] · ring have hbr := fourierCoeff_branch α t0.eval t1.eval S rw [hf0 S, hf1 S, hf0 (symmDiff S α), hf1 (symmDiff S α)] at hbr change ∃ z : ℤ, (2 : ℝ) ^ d * fourierCoeff (fun x => if parityVal α x = 0 then t0.eval x else t1.eval x) S = z rw [hd0, pow_zero, one_mul, hbr] by_cases hS0 : S = ∅ <;> by_cases hSα : symmDiff S α = ∅ · rw [if_pos hS0, if_pos hS0, if_pos hSα, if_pos hSα] cases c0 <;> cases c1 <;> [exact ⟨1, by norm_num [boolSign]⟩; exact ⟨1, by norm_num [boolSign]⟩; exact ⟨-1, by norm_num [boolSign]⟩; exact ⟨-1, by norm_num [boolSign]⟩] · rw [if_pos hS0, if_pos hS0, if_neg hSα, if_neg hSα] cases c0 <;> cases c1 <;> [exact ⟨1, by norm_num [boolSign]⟩; exact ⟨0, by norm_num [boolSign]⟩; exact ⟨0, by norm_num [boolSign]⟩; exact ⟨-1, by norm_num [boolSign]⟩] · rw [if_neg hS0, if_neg hS0, if_pos hSα, if_pos hSα] cases c0 <;> cases c1 <;> [exact ⟨0, by norm_num [boolSign]⟩; exact ⟨1, by norm_num [boolSign]⟩; exact ⟨-1, by norm_num [boolSign]⟩; exact ⟨0, by norm_num [boolSign]⟩] · rw [if_neg hS0, if_neg hS0, if_neg hSα, if_neg hSα] exact ⟨0, by norm_num⟩ · -- Case `d ≥ 1`: every coefficient of `t0` and `t1` is in `2^{-(d-1)} ℤ`, so dividing by `2` -- puts every coefficient of `branch α t0 t1` in `2^{-d} ℤ`! have hd1 : 1 ≤ d := by omega have hscale : ∀ t' : ParityDecTree ι, t'.depth ≤ d → (t'.depth = 0 → ∀ U, ∃ z : ℤ, fourierCoeff t'.eval U = z) → (1 ≤ t'.depth → ∀ U, ∃ z : ℤ, (2 : ℝ) ^ (t'.depth - 1) * fourierCoeff t'.eval U = z) → ∀ U, ∃ z : ℤ, (2 : ℝ) ^ (d - 1) * fourierCoeff t'.eval U = z := by intro t' htd h0 h1 U by_cases ht0 : t'.depth = 0 · obtain ⟨z, hz⟩ := h0 ht0 U refine ⟨(2 : ℤ) ^ (d - 1) * z, ?_⟩ push_cast; rw [hz] · obtain ⟨z, hz⟩ := h1 (by omega) U have hsub : d - 1 = (d - t'.depth) + (t'.depth - 1) := by omega refine ⟨(2 : ℤ) ^ (d - t'.depth) * z, ?_⟩ push_cast; rw [hsub, pow_add, mul_assoc, hz] obtain ⟨z0, hz0⟩ := hscale t0 (le_max_left _ _) ih0.1 ih0.2 S obtain ⟨z1, hz1⟩ := hscale t1 (le_max_right _ _) ih1.1 ih1.2 S obtain ⟨w0, hw0⟩ := hscale t0 (le_max_left _ _) ih0.1 ih0.2 (symmDiff S α) obtain ⟨w1, hw1⟩ := hscale t1 (le_max_right _ _) ih1.1 ih1.2 (symmDiff S α) refine ⟨z0 + z1 + (w0 - w1), ?_⟩ change (2 : ℝ) ^ d * fourierCoeff (fun x => if parityVal α x = 0 then t0.eval x else t1.eval x) S = _ rw [fourierCoeff_branch] have hpow : (2 : ℝ) ^ d = 2 * (2 : ℝ) ^ (d - 1) := by conv_lhs => rw [show d = (d - 1) + 1 by omega, pow_succ, mul_comm] rw [hpow] push_cast linarith /-- **Theorem 3A (Part 2 — Chistopolskaya–Podolskii 2018 Granularity Bound)**: For every nonconstant Boolean function `f`, `gran(f) + 1 ≤ D_⊕(f)`. -/ theorem granularity_add_one_le_parityDepth {f : (ι → Bool) → Bool} (hnc : ∃ x y, f x ≠ f y) : granularity f + 1 ≤ parityDepth f := by obtain ⟨t, ht_eval, ht_depth⟩ := exists_parityDecTree_eq_parityDepth f have hfun : f = t.eval := funext fun x => (ht_eval x).symm have hd_pos : 1 ≤ t.depth := by by_contra h0 have hd0 : t.depth = 0 := by omega cases t with | leaf b => obtain ⟨x, y, hxy⟩ := hnc exact hxy ((ht_eval x).symm.trans (ht_eval y)) | branch _ _ _ => simp [ParityDecTree.depth] at hd0 have hg : granularity f ≤ t.depth - 1 := by apply granularity_le_of_int intro S rw [hfun] exact (parityTree_fourier_dyadic t).2 hd_pos S omega /-- **Theorem 3B (Sharp Non-Asymptotic Exponential Spectral-Norm & Sparsity Bounds)**: For every nonconstant Boolean function `f`: 1. `L₁(f̂) ≤ 2 ^ (D_⊕(f) - 1)` (tight for all `d ≥ 1`, beating naive `2 ^ D_⊕(f)` by `2×`). 2. `‖f̂‖₀ ≤ 4 ^ (D_⊕(f) - 1)` (tight for all `d ≥ 1`, beating naive `4 ^ D_⊕(f)` by `4×`). -/ lemma parityTree_L1_and_sparsity_bounds (t : ParityDecTree ι) : spectralNorm t.eval ≤ (2 : ℝ) ^ (t.depth - 1) ∧ fourierSparsity t.eval ≤ 4 ^ (t.depth - 1) := by classical induction t with | leaf b => have hf : ∀ S, fourierCoeff (fun _ : ι → Bool => b) S = if S = ∅ then boolSign b else 0 := by intro S; unfold fourierCoeff simp_rw [← Finset.mul_sum, sum_walshChar] split_ifs · have hinv : (2 : ℝ)⁻¹ ^ Fintype.card ι * (2 : ℝ) ^ Fintype.card ι = 1 := by rw [← mul_pow]; norm_num calc (2 : ℝ)⁻¹ ^ Fintype.card ι * (boolSign b * (2 : ℝ) ^ Fintype.card ι) = boolSign b * ((2 : ℝ)⁻¹ ^ Fintype.card ι * (2 : ℝ) ^ Fintype.card ι) := by ring _ = boolSign b := by rw [hinv, mul_one] · ring constructor · simp only [ParityDecTree.eval, ParityDecTree.depth, Nat.zero_sub, pow_zero, spectralNorm] simp_rw [hf] have : ∑ S : Finset ι, |if S = ∅ then boolSign b else 0| = |boolSign b| := by rw [Finset.sum_eq_single ∅ (fun S _ hne => by simp [hne]) (fun h => absurd (Finset.mem_univ _) h)] simp rw [this, abs_boolSign] · simp only [ParityDecTree.eval, ParityDecTree.depth, Nat.zero_sub, pow_zero, fourierSparsity] have hsub : Finset.univ.filter (fun S : Finset ι => fourierCoeff (fun _ => b) S ≠ 0) ⊆ {∅} := by intro S hS have hne := (Finset.mem_filter.mp hS).2 rw [hf] at hne by_contra hnot have hne0 : S ≠ ∅ := by simpa using hnot simp [hne0] at hne exact (Finset.card_le_card hsub).trans (by simp) | branch α t0 t1 ih0 ih1 => simp only [ParityDecTree.depth, Nat.add_sub_cancel_left] set d := max t0.depth t1.depth by_cases hd0 : d = 0 · have h0 : t0.depth = 0 := by omega have h1 : t1.depth = 0 := by omega have hleaf : ∀ t' : ParityDecTree ι, t'.depth = 0 → ∃ c : Bool, ∀ x, t'.eval x = c := by intro t' ht'; cases t' with | leaf c => exact ⟨c, fun _ => rfl⟩ | branch _ _ _ => simp [ParityDecTree.depth] at ht' obtain ⟨c0, hc0⟩ := hleaf t0 h0 obtain ⟨c1, hc1⟩ := hleaf t1 h1 have hf : ∀ S, fourierCoeff (ParityDecTree.branch α t0 t1).eval S = (if S = ∅ then (boolSign c0 + boolSign c1) / 2 else 0) + (if S = α then (boolSign c0 - boolSign c1) / 2 else 0) := by intro S change fourierCoeff (fun x => if parityVal α x = 0 then t0.eval x else t1.eval x) S = _ rw [fourierCoeff_branch] have hf0 : ∀ U, fourierCoeff t0.eval U = if U = ∅ then boolSign c0 else 0 := by intro U; unfold fourierCoeff simp_rw [hc0, ← Finset.mul_sum, sum_walshChar] split_ifs · have hinv : (2 : ℝ)⁻¹ ^ Fintype.card ι * (2 : ℝ) ^ Fintype.card ι = 1 := by rw [← mul_pow]; norm_num calc (2 : ℝ)⁻¹ ^ Fintype.card ι * (boolSign c0 * (2 : ℝ) ^ Fintype.card ι) = boolSign c0 * ((2 : ℝ)⁻¹ ^ Fintype.card ι * (2 : ℝ) ^ Fintype.card ι) := by ring _ = boolSign c0 := by rw [hinv, mul_one] · ring have hf1 : ∀ U, fourierCoeff t1.eval U = if U = ∅ then boolSign c1 else 0 := by intro U; unfold fourierCoeff simp_rw [hc1, ← Finset.mul_sum, sum_walshChar] split_ifs · have hinv : (2 : ℝ)⁻¹ ^ Fintype.card ι * (2 : ℝ) ^ Fintype.card ι = 1 := by rw [← mul_pow]; norm_num calc (2 : ℝ)⁻¹ ^ Fintype.card ι * (boolSign c1 * (2 : ℝ) ^ Fintype.card ι) = boolSign c1 * ((2 : ℝ)⁻¹ ^ Fintype.card ι * (2 : ℝ) ^ Fintype.card ι) := by ring _ = boolSign c1 := by rw [hinv, mul_one] · ring rw [hf0, hf1, hf0, hf1] simp only [symmDiff_eq_empty_finset] by_cases hS0 : S = ∅ <;> by_cases hSα : S = α · rw [if_pos hS0, if_pos hS0, if_pos hSα, if_pos hSα, if_pos hS0, if_pos hSα] · rw [if_pos hS0, if_pos hS0, if_neg hSα, if_neg hSα, if_pos hS0, if_neg hSα]; ring · rw [if_neg hS0, if_neg hS0, if_pos hSα, if_pos hSα, if_neg hS0, if_pos hSα]; ring · rw [if_neg hS0, if_neg hS0, if_neg hSα, if_neg hSα, if_neg hS0, if_neg hSα]; ring rw [hd0, pow_zero, pow_zero] cases c0 <;> cases c1 · have hf' : ∀ S, fourierCoeff (ParityDecTree.branch α t0 t1).eval S = if S = ∅ then 1 else 0 := by intro S; rw [hf]; norm_num [boolSign] constructor · unfold spectralNorm; simp_rw [hf'] rw [Finset.sum_eq_single ∅] <;> simp · unfold fourierSparsity have hsub : Finset.univ.filter (fun S => fourierCoeff (ParityDecTree.branch α t0 t1).eval S ≠ 0) ⊆ {∅} := by intro S hS; have := (Finset.mem_filter.mp hS).2; rw [hf'] at this by_contra h; simp [show S ≠ ∅ by simpa using h] at this exact (Finset.card_le_card hsub).trans (by simp) · have hf' : ∀ S, fourierCoeff (ParityDecTree.branch α t0 t1).eval S = if S = α then 1 else 0 := by intro S; rw [hf]; norm_num [boolSign] constructor · unfold spectralNorm; simp_rw [hf'] rw [Finset.sum_eq_single α] <;> simp · unfold fourierSparsity have hsub : Finset.univ.filter (fun S => fourierCoeff (ParityDecTree.branch α t0 t1).eval S ≠ 0) ⊆ {α} := by intro S hS; have := (Finset.mem_filter.mp hS).2; rw [hf'] at this by_contra h; simp [show S ≠ α by simpa using h] at this exact (Finset.card_le_card hsub).trans (by simp) · have hf' : ∀ S, fourierCoeff (ParityDecTree.branch α t0 t1).eval S = if S = α then -1 else 0 := by intro S; rw [hf]; norm_num [boolSign] constructor · unfold spectralNorm; simp_rw [hf'] rw [Finset.sum_eq_single α] <;> simp · unfold fourierSparsity have hsub : Finset.univ.filter (fun S => fourierCoeff (ParityDecTree.branch α t0 t1).eval S ≠ 0) ⊆ {α} := by intro S hS; have := (Finset.mem_filter.mp hS).2; rw [hf'] at this by_contra h; simp [show S ≠ α by simpa using h] at this exact (Finset.card_le_card hsub).trans (by simp) · have hf' : ∀ S, fourierCoeff (ParityDecTree.branch α t0 t1).eval S = if S = ∅ then -1 else 0 := by intro S; rw [hf]; norm_num [boolSign] constructor · unfold spectralNorm; simp_rw [hf'] rw [Finset.sum_eq_single ∅] <;> simp · unfold fourierSparsity have hsub : Finset.univ.filter (fun S => fourierCoeff (ParityDecTree.branch α t0 t1).eval S ≠ 0) ⊆ {∅} := by intro S hS; have := (Finset.mem_filter.mp hS).2; rw [hf'] at this by_contra h; simp [show S ≠ ∅ by simpa using h] at this exact (Finset.card_le_card hsub).trans (by simp) · have hd1 : 1 ≤ d := by omega have hL0 : spectralNorm t0.eval ≤ (2 : ℝ) ^ (d - 1) := ih0.1.trans (pow_le_pow_right₀ (by norm_num) (by omega)) have hL1 : spectralNorm t1.eval ≤ (2 : ℝ) ^ (d - 1) := ih1.1.trans (pow_le_pow_right₀ (by norm_num) (by omega)) have hK0 : fourierSparsity t0.eval ≤ 4 ^ (d - 1) := ih0.2.trans (Nat.pow_le_pow_right (by norm_num) (by omega)) have hK1 : fourierSparsity t1.eval ≤ 4 ^ (d - 1) := ih1.2.trans (Nat.pow_le_pow_right (by norm_num) (by omega)) have hsym_sum : ∀ g : (ι → Bool) → Bool, ∑ S : Finset ι, |fourierCoeff g (symmDiff S α)| = spectralNorm g := by intro g; unfold spectralNorm exact Fintype.sum_equiv (Equiv.mk (fun S => symmDiff S α) (fun S => symmDiff S α) (fun S => symmDiff_cancel_right S α) (fun S => symmDiff_cancel_right S α)) _ _ (fun _ => rfl) constructor · have htri : ∀ S : Finset ι, |fourierCoeff (ParityDecTree.branch α t0 t1).eval S| ≤ (|fourierCoeff t0.eval S| + |fourierCoeff t1.eval S|) / 2 + (|fourierCoeff t0.eval (symmDiff S α)| + |fourierCoeff t1.eval (symmDiff S α)|) / 2 := by intro S change |fourierCoeff (fun x => if parityVal α x = 0 then t0.eval x else t1.eval x) S| ≤ _ rw [fourierCoeff_branch] calc |(fourierCoeff t0.eval S + fourierCoeff t1.eval S) / 2 + (fourierCoeff t0.eval (symmDiff S α) - fourierCoeff t1.eval (symmDiff S α)) / 2| ≤ |(fourierCoeff t0.eval S + fourierCoeff t1.eval S) / 2| + |(fourierCoeff t0.eval (symmDiff S α) - fourierCoeff t1.eval (symmDiff S α)) / 2| := abs_add_le _ _ _ ≤ (|fourierCoeff t0.eval S| + |fourierCoeff t1.eval S|) / 2 + (|fourierCoeff t0.eval (symmDiff S α)| + |fourierCoeff t1.eval (symmDiff S α)|) / 2 := by rw [abs_div, abs_div, abs_of_pos (by norm_num : (0 : ℝ) < 2)] have ha := abs_add_le (fourierCoeff t0.eval S) (fourierCoeff t1.eval S) have hb := abs_sub (fourierCoeff t0.eval (symmDiff S α)) (fourierCoeff t1.eval (symmDiff S α)) linarith have hsum_le : spectralNorm (ParityDecTree.branch α t0 t1).eval ≤ spectralNorm t0.eval + spectralNorm t1.eval := by calc spectralNorm (ParityDecTree.branch α t0 t1).eval ≤ ∑ S : Finset ι, ((|fourierCoeff t0.eval S| + |fourierCoeff t1.eval S|) / 2 + (|fourierCoeff t0.eval (symmDiff S α)| + |fourierCoeff t1.eval (symmDiff S α)|) / 2) := Finset.sum_le_sum fun S _ => htri S _ = (spectralNorm t0.eval + spectralNorm t1.eval) / 2 + (spectralNorm t0.eval + spectralNorm t1.eval) / 2 := by simp only [Finset.sum_add_distrib, ← Finset.sum_div, hsym_sum]; rfl _ = spectralNorm t0.eval + spectralNorm t1.eval := by ring have hpow : (2 : ℝ) ^ d = (2 : ℝ) ^ (d - 1) + (2 : ℝ) ^ (d - 1) := by conv_lhs => rw [show d = (d - 1) + 1 by omega, pow_succ] ring linarith · let S0 := Finset.univ.filter (fun S : Finset ι => fourierCoeff t0.eval S ≠ 0) let S1 := Finset.univ.filter (fun S : Finset ι => fourierCoeff t1.eval S ≠ 0) let S0' := S0.image (fun S => symmDiff S α) let S1' := S1.image (fun S => symmDiff S α) have hsub : Finset.univ.filter (fun S : Finset ι => fourierCoeff (ParityDecTree.branch α t0 t1).eval S ≠ 0) ⊆ (S0 ∪ S1) ∪ (S0' ∪ S1') := by intro S hS have hne := (Finset.mem_filter.mp hS).2 change fourierCoeff (fun x => if parityVal α x = 0 then t0.eval x else t1.eval x) S ≠ 0 at hne rw [fourierCoeff_branch] at hne by_contra hnot simp only [Finset.mem_union, not_or] at hnot have h1 : fourierCoeff t0.eval S = 0 := by by_contra hc; exact hnot.1.1 (Finset.mem_filter.mpr ⟨Finset.mem_univ _, hc⟩) have h2 : fourierCoeff t1.eval S = 0 := by by_contra hc; exact hnot.1.2 (Finset.mem_filter.mpr ⟨Finset.mem_univ _, hc⟩) have h3 : fourierCoeff t0.eval (symmDiff S α) = 0 := by by_contra hc apply hnot.2.1 exact Finset.mem_image.mpr ⟨symmDiff S α, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hc⟩, symmDiff_cancel_right S α⟩ have h4 : fourierCoeff t1.eval (symmDiff S α) = 0 := by by_contra hc apply hnot.2.2 exact Finset.mem_image.mpr ⟨symmDiff S α, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hc⟩, symmDiff_cancel_right S α⟩ rw [h1, h2, h3, h4] at hne norm_num at hne have hcard : fourierSparsity (ParityDecTree.branch α t0 t1).eval ≤ 2 * (fourierSparsity t0.eval + fourierSparsity t1.eval) := by have hc0' : S0'.card ≤ S0.card := Finset.card_image_le have hc1' : S1'.card ≤ S1.card := Finset.card_image_le calc fourierSparsity (ParityDecTree.branch α t0 t1).eval ≤ ((S0 ∪ S1) ∪ (S0' ∪ S1')).card := Finset.card_le_card hsub _ ≤ (S0 ∪ S1).card + (S0' ∪ S1').card := Finset.card_union_le _ _ _ ≤ (S0.card + S1.card) + (S0'.card + S1'.card) := Nat.add_le_add (Finset.card_union_le _ _) (Finset.card_union_le _ _) _ ≤ 2 * (S0.card + S1.card) := by omega have hpow4 : 4 ^ d = 2 * (4 ^ (d - 1) + 4 ^ (d - 1)) := by conv_lhs => rw [show d = (d - 1) + 1 by omega, pow_succ] ring omega theorem spectralNorm_le_two_pow_parityDepth_sub_one (f : (ι → Bool) → Bool) : spectralNorm f ≤ (2 : ℝ) ^ (parityDepth f - 1) := by obtain ⟨t, ht_eval, ht_depth⟩ := exists_parityDecTree_eq_parityDepth f have hfun : f = t.eval := funext fun x => (ht_eval x).symm rw [← ht_depth, hfun] exact (parityTree_L1_and_sparsity_bounds t).1 theorem fourierSparsity_le_four_pow_parityDepth_sub_one (f : (ι → Bool) → Bool) : fourierSparsity f ≤ 4 ^ (parityDepth f - 1) := by obtain ⟨t, ht_eval, ht_depth⟩ := exists_parityDecTree_eq_parityDepth f have hfun : f = t.eval := funext fun x => (ht_eval x).symm rw [← ht_depth, hfun] exact (parityTree_L1_and_sparsity_bounds t).2 /-! ### Hyperplane Parity Restriction & Exact Signed-Collision Spectral-Norm Drop (Theorem 3D) -/ /-- Exact hyperplane restriction `f|_{⟨γ, x⟩ = b}` (for `p ∈ γ`) living on the SAME index type `ι` by substituting `x_p := ⟨γ \ {p}, x⟩ + b`. -/ def parityRestrict (f : (ι → Bool) → Bool) (γ : Finset ι) (p : ι) (b : ZMod 2) : (ι → Bool) → Bool := fun x => f (fun i => if i = p then decide (parityVal (γ.erase p) x + b = 1) else x i) omit [Fintype ι] in lemma parityRestrict_eq_of_hyperplane (f : (ι → Bool) → Bool) {γ : Finset ι} {p : ι} (hp : p ∈ γ) (b : ZMod 2) {x : ι → Bool} (hx : parityVal γ x = b) : parityRestrict f γ p b x = f x := by simp only [parityRestrict] congr 1; ext i by_cases hi : i = p · subst hi simp only [↓reduceIte] have hsplit : parityVal γ x = boolToZ2 (x i) + parityVal (γ.erase i) x := by unfold parityVal; rw [← Finset.add_sum_erase _ _ hp] have hsolve : parityVal (γ.erase i) x + b = boolToZ2 (x i) := by have h2 : parityVal (γ.erase i) x + parityVal (γ.erase i) x = 0 := zmod2_add_self _ rw [← hx, hsplit] calc parityVal (γ.erase i) x + (boolToZ2 (x i) + parityVal (γ.erase i) x) = boolToZ2 (x i) + (parityVal (γ.erase i) x + parityVal (γ.erase i) x) := by ring _ = boolToZ2 (x i) := by rw [h2, add_zero] rw [hsolve] cases x i <;> decide · simp [hi] /-- Exact Fourier transform of the hyperplane restriction `parityRestrict f γ p b`: 1. `p ∈ S → f̂_{γ,b}(S) = 0`, 2. `p ∉ S → f̂_{γ,b}(S) = f̂(S) + (-1)^b · f̂(S ∆ γ)`. -/ theorem fourierCoeff_parityRestrict (f : (ι → Bool) → Bool) {γ : Finset ι} {p : ι} (hp : p ∈ γ) (b : ZMod 2) (S : Finset ι) : fourierCoeff (parityRestrict f γ p b) S = if p ∈ S then 0 else fourierCoeff f S + (if b = 0 then (1 : ℝ) else -1) * fourierCoeff f (symmDiff S γ) := by let g := parityRestrict f γ p b have hg_ign : ∀ x : ι → Bool, g (flipBit x p) = g x := by intro x simp only [g, parityRestrict] congr 1; ext i by_cases hi : i = p · subst hi simp only [↓reduceIte] have heq : parityVal (γ.erase i) (flipBit x i) = parityVal (γ.erase i) x := by unfold parityVal apply Finset.sum_congr rfl intro j hj simp [flipBit, Finset.ne_of_mem_erase hj] rw [heq] · simp [flipBit, hi] by_cases hpS : p ∈ S · rw [if_pos hpS] unfold fourierCoeff suffices hz : ∑ x : ι → Bool, boolSign (g x) * walshChar S x = 0 by rw [hz, mul_zero] have hneg : ∀ x : ι → Bool, boolSign (g (flipBit x p)) * walshChar S (flipBit x p) = -(boolSign (g x) * walshChar S x) := by intro x rw [hg_ign x, walshChar_eq_parityVal, walshChar_eq_parityVal] have hdiff : parityVal S (flipBit x p) = parityVal S x + 1 := by unfold parityVal rw [← Finset.add_sum_erase _ _ hpS, ← Finset.add_sum_erase _ _ hpS] have hrest : ∑ j ∈ S.erase p, boolToZ2 (flipBit x p j) = ∑ j ∈ S.erase p, boolToZ2 (x j) := Finset.sum_congr rfl fun j hj => by simp [flipBit, Finset.ne_of_mem_erase hj] rw [hrest] have hfl : boolToZ2 (flipBit x p p) = boolToZ2 (x p) + 1 := by cases h : x p <;> simp [flipBit, boolToZ2, h] rw [hfl]; ring rw [hdiff] rcases zmod2_cases (parityVal S x) with hv | hv <;> simp [hv] have heq : ∑ x : ι → Bool, boolSign (g x) * walshChar S x = ∑ x : ι → Bool, boolSign (g (flipBit x p)) * walshChar S (flipBit x p) := Fintype.sum_equiv (Equiv.mk (fun x => flipBit x p) (fun x => flipBit x p) (fun x => flipBit_self x p) (fun x => flipBit_self x p)) _ _ (fun x => by simp [flipBit_self]) have hsum_neg : ∑ x : ι → Bool, boolSign (g (flipBit x p)) * walshChar S (flipBit x p) = -∑ x : ι → Bool, boolSign (g x) * walshChar S x := by rw [← Finset.sum_neg_distrib]; exact Finset.sum_congr rfl fun x _ => hneg x linarith · rw [if_neg hpS] have hwal_ign : ∀ x : ι → Bool, walshChar S (flipBit x p) = walshChar S x := by intro x; unfold walshChar apply Finset.prod_congr rfl intro j hj have hne : j ≠ p := fun h => hpS (h ▸ hj) simp [flipBit, hne] have hpar_flip : ∀ x : ι → Bool, parityVal γ (flipBit x p) = parityVal γ x + 1 := by intro x; unfold parityVal rw [← Finset.add_sum_erase _ _ hp, ← Finset.add_sum_erase _ _ hp] have hrest : ∑ j ∈ γ.erase p, boolToZ2 (flipBit x p j) = ∑ j ∈ γ.erase p, boolToZ2 (x j) := Finset.sum_congr rfl fun j hj => by simp [flipBit, Finset.ne_of_mem_erase hj] rw [hrest] have hfl : boolToZ2 (flipBit x p p) = boolToZ2 (x p) + 1 := by cases h : x p <;> simp [flipBit, boolToZ2, h] rw [hfl]; ring have hsplit_sum : ∑ x : ι → Bool, boolSign (g x) * walshChar S x = 2 * ∑ x ∈ Finset.univ.filter (fun x : ι → Bool => parityVal γ x = b), boolSign (f x) * walshChar S x := by have hpart := (Finset.sum_filter_add_sum_filter_not (Finset.univ : Finset (ι → Bool)) (fun x => parityVal γ x = b) (fun x => boolSign (g x) * walshChar S x)).symm rw [hpart] have h1 : ∑ x ∈ Finset.univ.filter (fun x : ι → Bool => parityVal γ x = b), boolSign (g x) * walshChar S x = ∑ x ∈ Finset.univ.filter (fun x : ι → Bool => parityVal γ x = b), boolSign (f x) * walshChar S x := by apply Finset.sum_congr rfl intro x hx simp only [g] rw [parityRestrict_eq_of_hyperplane f hp b (Finset.mem_filter.mp hx).2] have h2 : ∑ x ∈ Finset.univ.filter (fun x : ι → Bool => ¬ parityVal γ x = b), boolSign (g x) * walshChar S x = ∑ x ∈ Finset.univ.filter (fun x : ι → Bool => parityVal γ x = b), boolSign (f x) * walshChar S x := by apply Finset.sum_bij (fun x _ => flipBit x p) · intro x hx rw [Finset.mem_filter] at hx ⊢ refine ⟨Finset.mem_univ _, ?_⟩ rw [hpar_flip] rcases zmod2_cases b with rfl | rfl <;> rcases zmod2_cases (parityVal γ x) with hpx | hpx <;> simp_all · intro x₁ _ x₂ _ heq have := congrArg (fun z => flipBit z p) heq simpa [flipBit_self] using this · intro y hy rw [Finset.mem_filter] at hy refine ⟨flipBit y p, ?_, flipBit_self y p⟩ rw [Finset.mem_filter] refine ⟨Finset.mem_univ _, ?_⟩ rw [hpar_flip, hy.2] rcases zmod2_cases b with rfl | rfl <;> decide · intro x hx have hflb : parityVal γ (flipBit x p) = b := by rw [hpar_flip] have hne := (Finset.mem_filter.mp hx).2 rcases zmod2_cases b with rfl | rfl <;> rcases zmod2_cases (parityVal γ x) with hpx | hpx <;> simp_all rw [← hg_ign x, ← hwal_ign x] simp only [g] rw [parityRestrict_eq_of_hyperplane f hp b hflb] rw [h1, h2]; ring have hind : ∀ x : ι → Bool, (if parityVal γ x = b then (2 : ℝ) else 0) = 1 + (if b = 0 then (1 : ℝ) else -1) * walshChar γ x := by intro x rw [walshChar_eq_parityVal] rcases zmod2_cases b with rfl | rfl <;> rcases zmod2_cases (parityVal γ x) with hpx | hpx <;> simp [hpx] <;> norm_num unfold fourierCoeff change (2 : ℝ)⁻¹ ^ Fintype.card ι * ∑ x : ι → Bool, boolSign (g x) * walshChar S x = _ rw [hsplit_sum] have hfilt : 2 * ∑ x ∈ Finset.univ.filter (fun x : ι → Bool => parityVal γ x = b), boolSign (f x) * walshChar S x = ∑ x : ι → Bool, (if parityVal γ x = b then (2 : ℝ) else 0) * (boolSign (f x) * walshChar S x) := by rw [Finset.mul_sum, Finset.sum_filter] apply Finset.sum_congr rfl intro x _; split_ifs <;> ring rw [hfilt] simp_rw [hind] have hexpand : ∑ x : ι → Bool, (1 + (if b = 0 then (1 : ℝ) else -1) * walshChar γ x) * (boolSign (f x) * walshChar S x) = (∑ x : ι → Bool, boolSign (f x) * walshChar S x) + (if b = 0 then (1 : ℝ) else -1) * ∑ x : ι → Bool, boolSign (f x) * walshChar (symmDiff S γ) x := by rw [Finset.mul_sum, ← Finset.sum_add_distrib] apply Finset.sum_congr rfl intro x _ rw [← walshChar_mul] ring rw [hexpand]; ring /-- Exact spectral norm of `parityRestrict f γ p b`: sum of `|f̂(S) ± f̂(S ∆ γ)|` over `p ∉ S`. -/ lemma spectralNorm_parityRestrict (f : (ι → Bool) → Bool) {γ : Finset ι} {p : ι} (hp : p ∈ γ) (b : ZMod 2) : spectralNorm (parityRestrict f γ p b) = ∑ S ∈ Finset.univ.filter (fun S : Finset ι => p ∉ S), |fourierCoeff f S + (if b = 0 then (1 : ℝ) else -1) * fourierCoeff f (symmDiff S γ)| := by unfold spectralNorm simp_rw [fourierCoeff_parityRestrict f hp b] rw [Finset.sum_filter] apply Finset.sum_congr rfl intro S _ by_cases hpS : p ∈ S <;> simp [hpS] /-- Splitting `spectralNorm f` into `p ∉ S` pairs `{S, S ∆ γ}` (since `p ∈ γ` toggles membership of `p`). -/ lemma spectralNorm_eq_sum_pairs (f : (ι → Bool) → Bool) {γ : Finset ι} {p : ι} (hp : p ∈ γ) : spectralNorm f = ∑ S ∈ Finset.univ.filter (fun S : Finset ι => p ∉ S), (|fourierCoeff f S| + |fourierCoeff f (symmDiff S γ)|) := by unfold spectralNorm rw [Finset.sum_add_distrib] have hpart := (Finset.sum_filter_add_sum_filter_not (Finset.univ : Finset (Finset ι)) (fun S => p ∉ S) (fun S => |fourierCoeff f S|)).symm rw [hpart] congr 1 apply Finset.sum_bij (fun S _ => symmDiff S γ) · intro S hS rw [Finset.mem_filter] at hS ⊢ refine ⟨Finset.mem_univ _, ?_⟩ have hpS : p ∈ S := by simpa using hS.2 intro hmem rcases Finset.mem_symmDiff.mp hmem with ⟨_, hng⟩ | ⟨_, hns⟩ · exact hng hp · exact hns hpS · intro S₁ _ S₂ _ heq calc S₁ = symmDiff (symmDiff S₁ γ) γ := (symmDiff_cancel_right S₁ γ).symm _ = symmDiff (symmDiff S₂ γ) γ := by rw [heq] _ = S₂ := symmDiff_cancel_right S₂ γ · intro T hT rw [Finset.mem_filter] at hT refine ⟨symmDiff T γ, ?_, symmDiff_cancel_right T γ⟩ rw [Finset.mem_filter] exact ⟨Finset.mem_univ _, by simp [Finset.mem_symmDiff, hp, hT.2]⟩ · intro S _; rw [symmDiff_cancel_right] /-- Exact signed autocorrelation over `p ∉ S` pairs equals `0` for `γ ≠ ∅`. -/ lemma sum_pairs_autocorr_zero (f : (ι → Bool) → Bool) {γ : Finset ι} {p : ι} (hp : p ∈ γ) : ∑ S ∈ Finset.univ.filter (fun S : Finset ι => p ∉ S), fourierCoeff f S * fourierCoeff f (symmDiff S γ) = 0 := by have hγne : γ ≠ ∅ := Finset.nonempty_iff_ne_empty.mp ⟨p, hp⟩ have hall := boolean_fourier_autocorr_zero f hγne have hpart := (Finset.sum_filter_add_sum_filter_not (Finset.univ : Finset (Finset ι)) (fun S => p ∉ S) (fun S => fourierCoeff f S * fourierCoeff f (symmDiff S γ))).symm rw [hpart] at hall have heq : ∑ S ∈ Finset.univ.filter (fun S : Finset ι => ¬ p ∉ S), fourierCoeff f S * fourierCoeff f (symmDiff S γ) = ∑ S ∈ Finset.univ.filter (fun S : Finset ι => p ∉ S), fourierCoeff f S * fourierCoeff f (symmDiff S γ) := by apply Finset.sum_bij (fun S _ => symmDiff S γ) · intro S hS rw [Finset.mem_filter] at hS ⊢ have hpS : p ∈ S := by simpa using hS.2 refine ⟨Finset.mem_univ _, fun hmem => ?_⟩ rcases Finset.mem_symmDiff.mp hmem with ⟨_, hng⟩ | ⟨_, hns⟩ · exact hng hp · exact hns hpS · intro S₁ _ S₂ _ heq calc S₁ = symmDiff (symmDiff S₁ γ) γ := (symmDiff_cancel_right S₁ γ).symm _ = symmDiff (symmDiff S₂ γ) γ := by rw [heq] _ = S₂ := symmDiff_cancel_right S₂ γ · intro T hT rw [Finset.mem_filter] at hT refine ⟨symmDiff T γ, ?_, symmDiff_cancel_right T γ⟩ rw [Finset.mem_filter] exact ⟨Finset.mem_univ _, by simp [Finset.mem_symmDiff, hp, hT.2]⟩ · intro S _ rw [symmDiff_cancel_right, mul_comm] linarith /-- Elementary signed-pair cancellation lemma: `(|a| + |b|) - |a + b| = 2 * min(|a|, |b|)` if `a * b < 0`, and `0` if `a * b ≥ 0`; in particular, for every `a, b : ℝ` and `M > 0` with `|a| ≤ M` and `|b| ≤ M`: - If `a * b ≤ 0`, then `|a| + |b| - |a + b| ≥ (2 / M) * (-a * b)` (and `= 2 * min(|a|, |b|)`). - Always `|a| + |b| - |a + b| ≥ 0`. -/ lemma pair_cancel_ge_prod (a b M : ℝ) (hM : 0 < M) (ha : |a| ≤ M) (hb : |b| ≤ M) : 2 * (-(a * b)) ≤ M * (|a| + |b| - |a + b|) := by by_cases hab : 0 ≤ a * b · have htri : 0 ≤ |a| + |b| - |a + b| := sub_nonneg.mpr (abs_add_le a b) have h1 : 0 ≤ M * (|a| + |b| - |a + b|) := mul_nonneg hM.le htri linarith · push Not at hab -- `a` and `b` have opposite signs, so `|a| + |b| - |a + b| = 2 * min(|a|, |b|)` -- and `-a * b = |a| * |b| = max(|a|, |b|) * min(|a|, |b|) ≤ M * min(|a|, |b|)`! have hprod : -(a * b) = |a| * |b| := by rw [← abs_mul, abs_of_neg hab] have hdiff : |a| + |b| - |a + b| = 2 * min |a| |b| := by rcases le_or_gt a 0 with ha0 | ha0 · have hb0 : 0 < b := by nlinarith rw [abs_of_nonpos ha0, abs_of_pos hb0] rcases le_total (-a) b with hle | hle · rw [abs_of_nonneg (by linarith), min_eq_left hle]; ring · rw [abs_of_nonpos (by linarith), min_eq_right hle]; ring · have hb0 : b < 0 := by nlinarith rw [abs_of_pos ha0, abs_of_neg hb0] rcases le_total a (-b) with hle | hle · rw [abs_of_nonpos (by linarith), min_eq_left hle]; ring · rw [abs_of_nonneg (by linarith), min_eq_right hle]; ring rw [hprod, hdiff] rcases le_total |a| |b| with hle | hle · rw [min_eq_left hle] have h1 : |a| * |b| ≤ |a| * M := mul_le_mul_of_nonneg_left hb (abs_nonneg a) linarith · rw [min_eq_right hle] have h1 : |a| * |b| ≤ M * |b| := mul_le_mul_of_nonneg_right ha (abs_nonneg b) linarith /-- **Theorem 3D (NEW — Exact Signed-Collision Spectral-Norm Reduction)**: Let `f : (ι → Bool) → Bool` have two distinct Fourier characters `α₁ ≠ α₂` with `|f̂(α₁)| = M₁ = max_S |f̂(S)| > 0` and `|f̂(α₂)| = M₂`. Set `γ = symmDiff α₁ α₂` (nonempty) and pick any pivot `p ∈ γ`. Then on **BOTH** hyperplane restrictions `b ∈ {0, 1}` simultaneously: `L₁(f̂_{γ, b}) ≤ L₁(f̂) - 2 · M₂`, and on one branch `b ∈ {0, 1}`, the maximum Fourier magnitude increases to at least `M₁ + M₂`. *(100% sharp for all `n ≥ 2` on `AND_n`!)* -/ theorem signed_collision_L1_drop (f : (ι → Bool) → Bool) {α₁ α₂ : Finset ι} (hne : α₁ ≠ α₂) (hmax : ∀ S : Finset ι, |fourierCoeff f S| ≤ |fourierCoeff f α₁|) (hpos : 0 < |fourierCoeff f α₁|) {p : ι} (hp : p ∈ symmDiff α₁ α₂) : let γ := symmDiff α₁ α₂ (∀ b : ZMod 2, spectralNorm (parityRestrict f γ p b) ≤ spectralNorm f - 2 * |fourierCoeff f α₂|) ∧ (∃ b : ZMod 2, ∃ S : Finset ι, |fourierCoeff f α₁| + |fourierCoeff f α₂| ≤ |fourierCoeff (parityRestrict f γ p b) S|) := by intro γ let M₁ := |fourierCoeff f α₁| let M₂ := |fourierCoeff f α₂| have hM1_pos : 0 < M₁ := hpos let H := Finset.univ.filter (fun S : Finset ι => p ∉ S) -- Identify the representative `S₀ ∈ H` of the pair `{α₁, α₂}`! have hrep : ∃ S₀ ∈ H, (S₀ = α₁ ∧ symmDiff S₀ γ = α₂) ∨ (S₀ = α₂ ∧ symmDiff S₀ γ = α₁) := by by_cases hp1 : p ∈ α₁ · have hp2 : p ∉ α₂ := by intro hp2 rcases Finset.mem_symmDiff.mp hp with ⟨_, h⟩ | ⟨_, h⟩ · exact h hp2 · exact h hp1 refine ⟨α₂, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hp2⟩, Or.inr ⟨rfl, ?_⟩⟩ simp only [γ]; rw [symmDiff_comm α₁ α₂, symmDiff_cancel_left] · refine ⟨α₁, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hp1⟩, Or.inl ⟨rfl, ?_⟩⟩ simp only [γ]; rw [symmDiff_cancel_left] obtain ⟨S₀, hS₀H, hS₀pair⟩ := hrep have hprodS₀ : |fourierCoeff f S₀ * fourierCoeff f (symmDiff S₀ γ)| = M₁ * M₂ := by rcases hS₀pair with ⟨rfl, h2⟩ | ⟨rfl, h2⟩ · rw [h2, abs_mul] · rw [h2, abs_mul, mul_comm] have hminS₀ : |fourierCoeff f S₀| + |fourierCoeff f (symmDiff S₀ γ)| - abs (|fourierCoeff f S₀| - |fourierCoeff f (symmDiff S₀ γ)|) = 2 * M₂ := by have hle : M₂ ≤ M₁ := hmax α₂ rcases hS₀pair with ⟨rfl, h2⟩ | ⟨rfl, h2⟩ · rw [h2, abs_of_nonneg (sub_nonneg.mpr hle)]; ring · rw [h2, abs_of_nonpos (sub_nonpos.mpr hle)]; ring constructor · -- Part 1: Simultaneous drop by `2 * M₂` on BOTH branches `b ∈ {0, 1}`! intro b let sgn : ℝ := if b = 0 then 1 else -1 have hsgn_abs : |sgn| = 1 := by rcases zmod2_cases b with rfl | rfl <;> simp [sgn] have hdrop : spectralNorm f - spectralNorm (parityRestrict f γ p b) = ∑ S ∈ H, (|fourierCoeff f S| + |fourierCoeff f (symmDiff S γ)| - |fourierCoeff f S + sgn * fourierCoeff f (symmDiff S γ)|) := by rw [spectralNorm_eq_sum_pairs f hp, spectralNorm_parityRestrict f hp b, ← Finset.sum_sub_distrib] have hnonneg : ∀ S ∈ H, 0 ≤ |fourierCoeff f S| + |fourierCoeff f (symmDiff S γ)| - |fourierCoeff f S + sgn * fourierCoeff f (symmDiff S γ)| := by intro S _ have h1 := abs_add_le (fourierCoeff f S) (sgn * fourierCoeff f (symmDiff S γ)) rw [abs_mul, hsgn_abs, one_mul] at h1 linarith -- Split into two cases according to the sign of `sgn * f̂(S₀) * f̂(S₀ ∆ γ)`! by_cases hsame : sgn * (fourierCoeff f S₀ * fourierCoeff f (symmDiff S₀ γ)) ≤ 0 · -- Opposite-sign pair on this branch: the single term `S = S₀` ALREADY drops by `2 * M₂`! have hterm : 2 * M₂ ≤ |fourierCoeff f S₀| + |fourierCoeff f (symmDiff S₀ γ)| - |fourierCoeff f S₀ + sgn * fourierCoeff f (symmDiff S₀ γ)| := by have h1 : |fourierCoeff f S₀ + sgn * fourierCoeff f (symmDiff S₀ γ)| = abs (|fourierCoeff f S₀| - |fourierCoeff f (symmDiff S₀ γ)|) := by let ha := fourierCoeff f S₀ let hb := sgn * fourierCoeff f (symmDiff S₀ γ) have hab : ha * hb ≤ 0 := by have : ha * hb = sgn * (fourierCoeff f S₀ * fourierCoeff f (symmDiff S₀ γ)) := by ring linarith have habs_b : |hb| = |fourierCoeff f (symmDiff S₀ γ)| := by simp only [hb, abs_mul, hsgn_abs, one_mul] change |ha + hb| = abs (|ha| - |fourierCoeff f (symmDiff S₀ γ)|) rw [← habs_b] rcases lt_trichotomy ha 0 with ha_neg | ha_eq | ha_pos · have hb0 : 0 ≤ hb := by nlinarith rw [abs_of_neg ha_neg, abs_of_nonneg hb0] rcases le_total (-ha) hb with hle | hle · rw [abs_of_nonneg (by linarith), abs_of_nonpos (by linarith)]; ring · rw [abs_of_nonpos (by linarith), abs_of_nonneg (by linarith)]; ring · rw [ha_eq]; simp · have hb0 : hb ≤ 0 := by nlinarith rw [abs_of_pos ha_pos, abs_of_nonpos hb0] rcases le_total ha (-hb) with hle | hle · rw [abs_of_nonpos (by linarith), abs_of_nonpos (by linarith)]; ring · rw [abs_of_nonneg (by linarith), abs_of_nonneg (by linarith)]; ring rw [h1, hminS₀] have hsum_ge := Finset.single_le_sum hnonneg hS₀H linarith · -- Same-sign pair on this branch: by Boolean orthogonality `∑_{S ∈ H} f̂(S) f̂(S ∆ γ) = 0`, -- the opposite-sign pairs `H⁻ := {S ∈ H | sgn * f̂(S) * f̂(S ∆ γ) < 0}` must have -- `∑_{S ∈ H⁻} (-sgn * f̂(S) * f̂(S ∆ γ)) ≥ sgn * f̂(S₀) * f̂(S₀ ∆ γ) = M₁ * M₂`! push Not at hsame have hposS₀ : sgn * (fourierCoeff f S₀ * fourierCoeff f (symmDiff S₀ γ)) = M₁ * M₂ := by have h1 : |sgn * (fourierCoeff f S₀ * fourierCoeff f (symmDiff S₀ γ))| = M₁ * M₂ := by rw [abs_mul, hsgn_abs, one_mul, hprodS₀] rw [← h1, abs_of_pos hsame] let Hneg := H.filter (fun S => sgn * (fourierCoeff f S * fourierCoeff f (symmDiff S γ)) < 0) let Hpos := H.filter (fun S => ¬ (sgn * (fourierCoeff f S * fourierCoeff f (symmDiff S γ)) < 0)) have hsum0 : ∑ S ∈ H, sgn * (fourierCoeff f S * fourierCoeff f (symmDiff S γ)) = 0 := by rw [← Finset.mul_sum, sum_pairs_autocorr_zero f hp, mul_zero] have hsplit0 := (Finset.sum_filter_add_sum_filter_not H (fun S => sgn * (fourierCoeff f S * fourierCoeff f (symmDiff S γ)) < 0) (fun S => sgn * (fourierCoeff f S * fourierCoeff f (symmDiff S γ)))).symm rw [hsplit0] at hsum0 have hS₀_pos : S₀ ∈ Hpos := Finset.mem_filter.mpr ⟨hS₀H, by linarith⟩ have hpos_ge : M₁ * M₂ ≤ ∑ S ∈ Hpos, sgn * (fourierCoeff f S * fourierCoeff f (symmDiff S γ)) := by rw [← hposS₀] exact Finset.single_le_sum (f := fun S => sgn * (fourierCoeff f S * fourierCoeff f (symmDiff S γ))) (fun S hS => le_of_not_gt (Finset.mem_filter.mp hS).2) hS₀_pos have hneg_ge : M₁ * M₂ ≤ ∑ S ∈ Hneg, -(sgn * (fourierCoeff f S * fourierCoeff f (symmDiff S γ))) := by rw [Finset.sum_neg_distrib]; linarith -- Apply `pair_cancel_ge_prod` to every `S ∈ Hneg`! have hM_mul : 2 * (M₁ * M₂) ≤ M₁ * (spectralNorm f - spectralNorm (parityRestrict f γ p b)) := by rw [hdrop, Finset.mul_sum] calc 2 * (M₁ * M₂) ≤ 2 * ∑ S ∈ Hneg, -(sgn * (fourierCoeff f S * fourierCoeff f (symmDiff S γ))) := by linarith _ = ∑ S ∈ Hneg, 2 * (-(fourierCoeff f S * (sgn * fourierCoeff f (symmDiff S γ)))) := by rw [Finset.mul_sum]; apply Finset.sum_congr rfl; intro S _; ring _ ≤ ∑ S ∈ Hneg, M₁ * (|fourierCoeff f S| + |fourierCoeff f (symmDiff S γ)| - |fourierCoeff f S + sgn * fourierCoeff f (symmDiff S γ)|) := by apply Finset.sum_le_sum intro S _ have h1 := pair_cancel_ge_prod (fourierCoeff f S) (sgn * fourierCoeff f (symmDiff S γ)) M₁ hM1_pos (hmax S) (by rw [abs_mul, hsgn_abs, one_mul]; exact hmax (symmDiff S γ)) rw [abs_mul, hsgn_abs, one_mul] at h1 exact h1 _ ≤ ∑ S ∈ H, M₁ * (|fourierCoeff f S| + |fourierCoeff f (symmDiff S γ)| - |fourierCoeff f S + sgn * fourierCoeff f (symmDiff S γ)|) := Finset.sum_le_sum_of_subset_of_nonneg (Finset.filter_subset _ _) (fun S hS _ => mul_nonneg hM1_pos.le (hnonneg S hS)) nlinarith · -- Part 2: On the merging branch, `|f̂_{γ,b}(S₀)| = M₁ + M₂`! have hpS₀ : p ∉ S₀ := (Finset.mem_filter.mp hS₀H).2 by_cases hsame : 0 ≤ fourierCoeff f S₀ * fourierCoeff f (symmDiff S₀ γ) · refine ⟨0, S₀, ?_⟩ rw [fourierCoeff_parityRestrict f hp 0 S₀, if_neg hpS₀] simp only [↓reduceIte, one_mul] have hadd : |fourierCoeff f S₀ + fourierCoeff f (symmDiff S₀ γ)| = |fourierCoeff f S₀| + |fourierCoeff f (symmDiff S₀ γ)| := by rcases le_or_gt 0 (fourierCoeff f S₀) with h1 | h1 · rcases eq_or_lt_of_le h1 with h10 | h1p · rw [← h10]; simp · have h2 : 0 ≤ fourierCoeff f (symmDiff S₀ γ) := by nlinarith rw [abs_of_nonneg h1, abs_of_nonneg h2, abs_of_nonneg (by linarith)] · have h2 : fourierCoeff f (symmDiff S₀ γ) ≤ 0 := by nlinarith rw [abs_of_neg h1, abs_of_nonpos h2, abs_of_nonpos (by linarith)]; ring rw [hadd] rcases hS₀pair with ⟨rfl, h2⟩ | ⟨rfl, h2⟩ · rw [h2] · rw [h2, add_comm] · push Not at hsame refine ⟨1, S₀, ?_⟩ rw [fourierCoeff_parityRestrict f hp 1 S₀, if_neg hpS₀] simp only [one_ne_zero, ↓reduceIte, neg_one_mul] have hadd : |fourierCoeff f S₀ + -fourierCoeff f (symmDiff S₀ γ)| = |fourierCoeff f S₀| + |fourierCoeff f (symmDiff S₀ γ)| := by rcases le_or_gt 0 (fourierCoeff f S₀) with h1 | h1 · have h2 : fourierCoeff f (symmDiff S₀ γ) ≤ 0 := by nlinarith rw [abs_of_nonneg h1, abs_of_nonpos h2, abs_of_nonneg (by linarith)] · have h2 : 0 ≤ fourierCoeff f (symmDiff S₀ γ) := by nlinarith rw [abs_of_neg h1, abs_of_nonneg h2, abs_of_nonpos (by linarith)]; ring rw [hadd] rcases hS₀pair with ⟨rfl, h2⟩ | ⟨rfl, h2⟩ · rw [h2] · rw [h2, add_comm] /-! ### Spectral-Norm Gap (`L₁ ≥ 2`), Exact `L₁ = 2` Rigidity, and Forbidden Low-Sparsity Gap (Theorem 3E) -/ /-- Helper: `L₁(f̂) ≥ 1` for every Boolean function `f`, with `L₁(f̂) = 1 ↔ ‖f̂‖₀ = 1 ↔ D_⊕(f) ≤ 1`. -/ lemma spectralNorm_ge_one (f : (ι → Bool) → Bool) : 1 ≤ spectralNorm f := by have h0 := fourier_expansion f (fun _ => false) have habs : (1 : ℝ) = |boolSign (f (fun _ => false))| := (abs_boolSign _).symm rw [habs, h0] calc |∑ S : Finset ι, fourierCoeff f S * walshChar S (fun _ => false)| ≤ ∑ S : Finset ι, |fourierCoeff f S * walshChar S (fun _ => false)| := Finset.abs_sum_le_sum_abs _ _ _ = spectralNorm f := by unfold spectralNorm apply Finset.sum_congr rfl intro S _; rw [abs_mul, abs_walshChar, mul_one] /-- Helper: every Boolean function has `|f̂(S)| ≤ 1`. -/ lemma abs_fourierCoeff_le_one (f : (ι → Bool) → Bool) (S : Finset ι) : |fourierCoeff f S| ≤ 1 := by have hsq : (fourierCoeff f S) ^ 2 ≤ 1 := by 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 f nlinarith [sq_abs (fourierCoeff f S)] /-- A Boolean function has `‖f̂‖₀ = 1` iff `∃ α c, ∀ x, boolSign (f x) = c * χ_α(x)` (affine). -/ lemma fourierSparsity_eq_one_iff (f : (ι → Bool) → Bool) : fourierSparsity f = 1 ↔ ∃ α : Finset ι, |fourierCoeff f α| = 1 := by classical constructor · intro h1 obtain ⟨α, hα⟩ := Finset.card_eq_one.mp h1 have hzero : ∀ S, S ≠ α → fourierCoeff f S = 0 := by intro S hne by_contra hnz have hmem : S ∈ ({α} : Finset (Finset ι)) := hα ▸ Finset.mem_filter.mpr ⟨Finset.mem_univ _, hnz⟩ exact hne (Finset.mem_singleton.mp hmem) have hp := parseval f rw [Finset.sum_eq_single α (fun S _ hne => by rw [hzero S hne]; ring) (fun h => absurd (Finset.mem_univ _) h)] at hp refine ⟨α, ?_⟩ nlinarith [sq_abs (fourierCoeff f α), abs_nonneg (fourierCoeff f α)] · rintro ⟨α, hα⟩ have hzero : ∀ S, S ≠ α → fourierCoeff f S = 0 := by intro S hne have hp := parseval f have h2 : (fourierCoeff f α) ^ 2 + (fourierCoeff f S) ^ 2 ≤ 1 := by rw [← hp] have hsub : ({α, S} : Finset (Finset ι)) ⊆ Finset.univ := Finset.subset_univ _ have hsum := Finset.sum_le_sum_of_subset_of_nonneg hsub (fun T _ _ => sq_nonneg (fourierCoeff f T)) rw [Finset.sum_pair hne.symm] at hsum exact hsum have hαsq : (fourierCoeff f α) ^ 2 = 1 := by rw [← sq_abs, hα]; norm_num nlinarith [sq_nonneg (fourierCoeff f S)] have heq : Finset.univ.filter (fun S : Finset ι => fourierCoeff f S ≠ 0) = {α} := by ext S simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_singleton] constructor · intro hnz; by_contra hne; exact hnz (hzero S hne) · rintro rfl; intro h0; rw [h0] at hα; norm_num at hα simp [fourierSparsity, heq] lemma parityDepth_le_one_of_sparsity_eq_one {f : (ι → Bool) → Bool} (h1 : fourierSparsity f = 1) : parityDepth f ≤ 1 := by obtain ⟨α, hα⟩ := (fourierSparsity_eq_one_iff f).mp h1 have hzero : ∀ S, S ≠ α → fourierCoeff f S = 0 := by intro S hne have hp := parseval f have h2 : (fourierCoeff f α) ^ 2 + (fourierCoeff f S) ^ 2 ≤ 1 := by rw [← hp] have hsum := Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ {α, S}) (fun T _ _ => sq_nonneg (fourierCoeff f T)) rwa [Finset.sum_pair hne.symm] at hsum have hαsq : (fourierCoeff f α) ^ 2 = 1 := by rw [← sq_abs, hα]; norm_num nlinarith [sq_nonneg (fourierCoeff f S)] have hexp : ∀ x, boolSign (f x) = fourierCoeff f α * walshChar α x := fun x => by rw [fourier_expansion f x] exact Finset.sum_eq_single α (fun S _ hne => by rw [hzero S hne, zero_mul]) (fun h => absurd (Finset.mem_univ _) h) rcases eq_or_eq_neg_of_abs_eq hα with hpos | hneg · let t : ParityDecTree ι := .branch α (.leaf false) (.leaf true) have hev : ∀ x, t.eval x = f x := by intro x have hx := hexp x rw [hpos, one_mul, walshChar_eq_parityVal] at hx simp only [t, ParityDecTree.eval] split_ifs with h0 · simp only [h0, ↓reduceIte] at hx cases hf : f x · rfl · rw [hf] at hx; norm_num [boolSign] at hx · simp only [h0, ↓reduceIte] at hx cases hf : f x · rw [hf] at hx; norm_num [boolSign] at hx · rfl exact (parityDepth_le_of_tree hev).trans (by simp [t, ParityDecTree.depth]) · let t : ParityDecTree ι := .branch α (.leaf true) (.leaf false) have hev : ∀ x, t.eval x = f x := by intro x have hx := hexp x rw [hneg, walshChar_eq_parityVal] at hx simp only [t, ParityDecTree.eval] split_ifs with h0 · simp only [h0, ↓reduceIte] at hx cases hf : f x · rw [hf] at hx; norm_num [boolSign] at hx · rfl · simp only [h0, ↓reduceIte] at hx cases hf : f x · rfl · rw [hf] at hx; norm_num [boolSign] at hx exact (parityDepth_le_of_tree hev).trans (by simp [t, ParityDecTree.depth]) lemma spectralNorm_eq_one_iff (f : (ι → Bool) → Bool) : spectralNorm f = 1 ↔ fourierSparsity f = 1 := by constructor · intro hL1 obtain ⟨α, _, hαmax⟩ := Finset.exists_max_image (Finset.univ : Finset (Finset ι)) (fun S => |fourierCoeff f S|) ⟨∅, Finset.mem_univ _⟩ have h1 : 1 ≤ |fourierCoeff f α| * spectralNorm f := by rw [← parseval f, spectralNorm, Finset.mul_sum] apply Finset.sum_le_sum intro S _ calc (fourierCoeff f S) ^ 2 = |fourierCoeff f S| * |fourierCoeff f S| := by rw [← sq_abs, sq] _ ≤ |fourierCoeff f α| * |fourierCoeff f S| := mul_le_mul_of_nonneg_right (hαmax S (Finset.mem_univ _)) (abs_nonneg _) rw [hL1, mul_one] at h1 have hle := abs_fourierCoeff_le_one f α exact (fourierSparsity_eq_one_iff f).mpr ⟨α, le_antisymm hle h1⟩ · intro hsp obtain ⟨α, hα⟩ := (fourierSparsity_eq_one_iff f).mp hsp have hzero : ∀ S, S ≠ α → fourierCoeff f S = 0 := by intro S hne have hp := parseval f have h2 : (fourierCoeff f α) ^ 2 + (fourierCoeff f S) ^ 2 ≤ 1 := by rw [← hp] have hsum := Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ {α, S}) (fun T _ _ => sq_nonneg (fourierCoeff f T)) rwa [Finset.sum_pair hne.symm] at hsum have hαsq : (fourierCoeff f α) ^ 2 = 1 := by rw [← sq_abs, hα]; norm_num nlinarith [sq_nonneg (fourierCoeff f S)] unfold spectralNorm rw [Finset.sum_eq_single α (fun S _ hne => by rw [hzero S hne, abs_zero]) (fun h => absurd (Finset.mem_univ _) h)] exact hα /-- **Theorem 3E (Part 1 — Spectral-Norm Gap)**: Every non-affine Boolean function (`1 < spectralNorm f`, equivalently `fourierSparsity f ≠ 1`) satisfies `2 ≤ spectralNorm f` (with strict inequality whenever `max_S |f̂(S)| > 1/2`). -/ theorem spectralNorm_gap_ge_two {f : (ι → Bool) → Bool} (hna : fourierSparsity f ≠ 1) : 2 ≤ spectralNorm f := by obtain ⟨α, _, hαmax⟩ := Finset.exists_max_image (Finset.univ : Finset (Finset ι)) (fun S => |fourierCoeff f S|) ⟨∅, Finset.mem_univ _⟩ let M₁ := |fourierCoeff f α| have hM1_lt : M₁ < 1 := by have hle := abs_fourierCoeff_le_one f α by_contra hge have heq : M₁ = 1 := le_antisymm hle (by linarith) exact hna ((fourierSparsity_eq_one_iff f).mpr ⟨α, heq⟩) by_cases hhalf : M₁ ≤ (1 : ℝ) / 2 · -- Case 1 (`M₁ ≤ 1/2`): Parseval gives `1 ≤ M₁ * L₁(f̂) ≤ (1/2) * L₁(f̂)`! have h1 : 1 ≤ M₁ * spectralNorm f := by rw [← parseval f, spectralNorm, Finset.mul_sum] apply Finset.sum_le_sum intro S _ calc (fourierCoeff f S) ^ 2 = |fourierCoeff f S| * |fourierCoeff f S| := by rw [← sq_abs, sq] _ ≤ M₁ * |fourierCoeff f S| := mul_le_mul_of_nonneg_right (hαmax S (Finset.mem_univ _)) (abs_nonneg _) have hL1_pos : 0 ≤ spectralNorm f := Finset.sum_nonneg fun _ _ => abs_nonneg _ nlinarith · -- Case 2 (`M₁ > 1/2`): shifting `f` by `sgn(f̂(α)) · χ_α` gives `g(x) = sgn(f̂(α)) · χ_α(x) · f(x)` -- with `g(x₀) = -1` for some `x₀` (since `M₁ < 1`), so `-1 = g(x₀) = M₁ + ∑_{S ≠ α} ...`, -- yielding `1 + M₁ ≤ ∑_{S ≠ α} |f̂(S)| = L₁(f̂) - M₁`, hence `L₁(f̂) ≥ 1 + 2 M₁ > 2`!! push Not at hhalf let s : ℝ := if 0 ≤ fourierCoeff f α then 1 else -1 have hs_abs : |s| = 1 := by dsimp only [s]; split_ifs <;> norm_num have hs_mul : s * fourierCoeff f α = M₁ := by dsimp only [s, M₁]; split_ifs with h0 · rw [one_mul, abs_of_nonneg h0] · push Not at h0; rw [abs_of_neg h0]; ring -- There exists `x₀` where `s * boolSign (f x₀) * walshChar α x₀ = -1`! -- (Otherwise it equals `+1` everywhere, forcing `M₁ = s * f̂(α) = 1`, contradicting `M₁ < 1`!) have hex : ∃ x₀ : ι → Bool, s * boolSign (f x₀) * walshChar α x₀ = -1 := by by_contra hall push Not at hall have hall1 : ∀ x : ι → Bool, s * boolSign (f x) * walshChar α x = 1 := by intro x have habs : |s * boolSign (f x) * walshChar α x| = 1 := by rw [abs_mul, abs_mul, hs_abs, abs_boolSign, abs_walshChar]; norm_num rcases eq_or_eq_neg_of_abs_eq habs with h1 | hm1 · exact h1 · exact absurd hm1 (hall x) have hM1_eq : M₁ = 1 := by rw [← hs_mul, fourierCoeff] have h1 : s * ((2 : ℝ)⁻¹ ^ Fintype.card ι * ∑ x : ι → Bool, boolSign (f x) * walshChar α x) = (2 : ℝ)⁻¹ ^ Fintype.card ι * ∑ x : ι → Bool, s * boolSign (f x) * walshChar α x := by rw [← mul_assoc, mul_comm s, mul_assoc, Finset.mul_sum] congr 1; apply Finset.sum_congr rfl; intro x _; ring rw [h1] simp_rw [hall1] simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fun, Fintype.card_bool, nsmul_eq_mul, mul_one, Nat.cast_pow, Nat.cast_ofNat] rw [← mul_pow]; norm_num linarith obtain ⟨x₀, hx₀⟩ := hex -- Expand `s * boolSign (f x₀) * walshChar α x₀ = M₁ + ∑_{S ≠ α} s * f̂(S) * χ_{S ∆ α}(x₀)`! have hexp : -1 = M₁ + ∑ S ∈ Finset.univ.erase α, s * fourierCoeff f S * walshChar (symmDiff S α) x₀ := by rw [← hx₀, fourier_expansion f x₀, Finset.mul_sum, Finset.sum_mul] rw [← Finset.add_sum_erase _ _ (Finset.mem_univ α)] congr 1 · calc s * (fourierCoeff f α * walshChar α x₀) * walshChar α x₀ = (s * fourierCoeff f α) * (walshChar α x₀ * walshChar α x₀) := by ring _ = M₁ := by rw [hs_mul, walshChar_sq, mul_one] · apply Finset.sum_congr rfl intro S _ rw [← walshChar_mul]; ring have hbound : 1 + M₁ ≤ ∑ S ∈ Finset.univ.erase α, |fourierCoeff f S| := by have h1 : -(1 + M₁) = ∑ S ∈ Finset.univ.erase α, s * fourierCoeff f S * walshChar (symmDiff S α) x₀ := by linarith calc 1 + M₁ = |-(1 + M₁)| := by rw [abs_neg, abs_of_pos (by linarith)] _ = |∑ S ∈ Finset.univ.erase α, s * fourierCoeff f S * walshChar (symmDiff S α) x₀| := by rw [h1] _ ≤ ∑ S ∈ Finset.univ.erase α, |s * fourierCoeff f S * walshChar (symmDiff S α) x₀| := Finset.abs_sum_le_sum_abs _ _ _ = ∑ S ∈ Finset.univ.erase α, |fourierCoeff f S| := by apply Finset.sum_congr rfl intro S _; rw [abs_mul, abs_mul, hs_abs, abs_walshChar]; ring have hL1 : spectralNorm f = M₁ + ∑ S ∈ Finset.univ.erase α, |fourierCoeff f S| := by unfold spectralNorm exact (Finset.add_sum_erase _ _ (Finset.mem_univ α)).symm linarith /-- **Theorem 3E (Part 2 — Exact `L₁ = 2` Rigidity & Parity Depth Collapse)**: For every Boolean function `f`, `spectralNorm f = 2 ↔ fourierSparsity f = 4`, and whenever `spectralNorm f = 2`, every nonzero Fourier coefficient has magnitude `1/2` and `D_⊕(f) = 2`. -/ theorem spectralNorm_eq_two_rigidity (f : (ι → Bool) → Bool) : (spectralNorm f = 2 ↔ fourierSparsity f = 4) ∧ (spectralNorm f = 2 → parityDepth f = 2) := by classical have hL1_to_4 : spectralNorm f = 2 → fourierSparsity f = 4 ∧ ∀ S : Finset ι, fourierCoeff f S ≠ 0 → |fourierCoeff f S| = 1 / 2 := by intro hL1 have hna : fourierSparsity f ≠ 1 := by intro h1; have := (spectralNorm_eq_one_iff f).mpr h1; linarith obtain ⟨α, _, hαmax⟩ := Finset.exists_max_image (Finset.univ : Finset (Finset ι)) (fun S => |fourierCoeff f S|) ⟨∅, Finset.mem_univ _⟩ let M₁ := |fourierCoeff f α| have hM1_lt : M₁ < 1 := by by_contra hge exact hna ((fourierSparsity_eq_one_iff f).mpr ⟨α, le_antisymm (abs_fourierCoeff_le_one f α) (by linarith)⟩) -- If `M₁ > 1/2`, Case 2 of `spectralNorm_gap_ge_two` gave STRICT `L₁(f̂) ≥ 1 + 2 M₁ > 2`! have hM1_le : M₁ ≤ (1 : ℝ) / 2 := by by_contra hgt push Not at hgt let s : ℝ := if 0 ≤ fourierCoeff f α then 1 else -1 have hs_abs : |s| = 1 := by dsimp only [s]; split_ifs <;> norm_num have hs_mul : s * fourierCoeff f α = M₁ := by dsimp only [s, M₁]; split_ifs with h0 · rw [one_mul, abs_of_nonneg h0] · push Not at h0; rw [abs_of_neg h0]; ring have hex : ∃ x₀ : ι → Bool, s * boolSign (f x₀) * walshChar α x₀ = -1 := by by_contra hall; push Not at hall have hall1 : ∀ x : ι → Bool, s * boolSign (f x) * walshChar α x = 1 := by intro x have habs : |s * boolSign (f x) * walshChar α x| = 1 := by rw [abs_mul, abs_mul, hs_abs, abs_boolSign, abs_walshChar]; norm_num rcases eq_or_eq_neg_of_abs_eq habs with h1 | hm1 · exact h1 · exact absurd hm1 (hall x) have hM1_eq : M₁ = 1 := by rw [← hs_mul, fourierCoeff] have h1 : s * ((2 : ℝ)⁻¹ ^ Fintype.card ι * ∑ x : ι → Bool, boolSign (f x) * walshChar α x) = (2 : ℝ)⁻¹ ^ Fintype.card ι * ∑ x : ι → Bool, s * boolSign (f x) * walshChar α x := by rw [← mul_assoc, mul_comm s, mul_assoc, Finset.mul_sum] congr 1; apply Finset.sum_congr rfl; intro x _; ring rw [h1]; simp_rw [hall1] simp only [Finset.sum_const, Finset.card_univ, Fintype.card_fun, Fintype.card_bool, nsmul_eq_mul, mul_one, Nat.cast_pow, Nat.cast_ofNat] rw [← mul_pow]; norm_num linarith obtain ⟨x₀, hx₀⟩ := hex have hexp : -1 = M₁ + ∑ S ∈ Finset.univ.erase α, s * fourierCoeff f S * walshChar (symmDiff S α) x₀ := by rw [← hx₀, fourier_expansion f x₀, Finset.mul_sum, Finset.sum_mul] rw [← Finset.add_sum_erase _ _ (Finset.mem_univ α)] congr 1 · calc s * (fourierCoeff f α * walshChar α x₀) * walshChar α x₀ = (s * fourierCoeff f α) * (walshChar α x₀ * walshChar α x₀) := by ring _ = M₁ := by rw [hs_mul, walshChar_sq, mul_one] · apply Finset.sum_congr rfl; intro S _; rw [← walshChar_mul]; ring have hbound : 1 + M₁ ≤ ∑ S ∈ Finset.univ.erase α, |fourierCoeff f S| := by have h1 : -(1 + M₁) = ∑ S ∈ Finset.univ.erase α, s * fourierCoeff f S * walshChar (symmDiff S α) x₀ := by linarith calc 1 + M₁ = |-(1 + M₁)| := by rw [abs_neg, abs_of_pos (by linarith)] _ = |∑ S ∈ Finset.univ.erase α, s * fourierCoeff f S * walshChar (symmDiff S α) x₀| := by rw [h1] _ ≤ ∑ S ∈ Finset.univ.erase α, |s * fourierCoeff f S * walshChar (symmDiff S α) x₀| := Finset.abs_sum_le_sum_abs _ _ _ = ∑ S ∈ Finset.univ.erase α, |fourierCoeff f S| := by apply Finset.sum_congr rfl; intro S _; rw [abs_mul, abs_mul, hs_abs, abs_walshChar]; ring have hL1' : spectralNorm f = M₁ + ∑ S ∈ Finset.univ.erase α, |fourierCoeff f S| := by unfold spectralNorm; exact (Finset.add_sum_erase _ _ (Finset.mem_univ α)).symm linarith -- Now `∑ |f̂(S)| · (1/2 - |f̂(S)|) = (1/2) * 2 - 1 = 0`, and every term is `≥ 0`! have hdiff0 : ∑ S : Finset ι, |fourierCoeff f S| * ((1 : ℝ) / 2 - |fourierCoeff f S|) = 0 := by have h1 : ∑ S : Finset ι, |fourierCoeff f S| * ((1 : ℝ) / 2 - |fourierCoeff f S|) = (1 : ℝ) / 2 * spectralNorm f - ∑ S : Finset ι, (fourierCoeff f S) ^ 2 := by rw [spectralNorm, Finset.mul_sum, ← Finset.sum_sub_distrib] apply Finset.sum_congr rfl intro S _; rw [← sq_abs]; ring rw [h1, hL1, parseval]; norm_num have hall_half : ∀ S : Finset ι, fourierCoeff f S ≠ 0 → |fourierCoeff f S| = (1 : ℝ) / 2 := by intro S hSnz have hterm0 := (Finset.sum_eq_zero_iff_of_nonneg (fun T _ => by have hle := (hαmax T (Finset.mem_univ _)).trans hM1_le exact mul_nonneg (abs_nonneg _) (by linarith))).mp hdiff0 S (Finset.mem_univ S) have habs_pos : |fourierCoeff f S| ≠ 0 := abs_ne_zero.mpr hSnz rcases mul_eq_zero.mp hterm0 with h0 | h0 · exact absurd h0 habs_pos · linarith have hcard4 : fourierSparsity f = 4 := by let supp := Finset.univ.filter (fun S : Finset ι => fourierCoeff f S ≠ 0) have hsum : spectralNorm f = (supp.card : ℝ) * ((1 : ℝ) / 2) := by unfold spectralNorm rw [← Finset.sum_filter_add_sum_filter_not Finset.univ (fun S => fourierCoeff f S ≠ 0)] have hz : ∑ S ∈ Finset.univ.filter (fun S => ¬ fourierCoeff f S ≠ 0), |fourierCoeff f S| = 0 := Finset.sum_eq_zero fun S hS => by have := (Finset.mem_filter.mp hS).2; push Not at this; simp [this] rw [hz, add_zero] have hcongr : ∑ S ∈ supp, |fourierCoeff f S| = ∑ _S ∈ supp, ((1 : ℝ) / 2) := Finset.sum_congr rfl fun S hS => hall_half S (Finset.mem_filter.mp hS).2 rw [hcongr, Finset.sum_const, nsmul_eq_mul] rw [hL1] at hsum have hcast : (supp.card : ℝ) = (4 : ℝ) := by linarith exact_mod_cast hcast exact ⟨hcard4, hall_half⟩ -- Reverse direction: `‖f̂‖₀ = 4 → L₁(f̂) = 2` (by Cauchy–Schwarz: `L₁(f̂) ≤ √4 · √1 = 2`, -- and `2 ≤ L₁(f̂)` by `spectralNorm_gap_ge_two`!) have h4_to_L1 : fourierSparsity f = 4 → spectralNorm f = 2 := by intro h4 have hge : 2 ≤ spectralNorm f := spectralNorm_gap_ge_two (by omega) let supp := Finset.univ.filter (fun S : Finset ι => fourierCoeff f S ≠ 0) have hcs : (∑ S ∈ supp, |fourierCoeff f S|) ^ 2 ≤ (supp.card : ℝ) * ∑ S ∈ supp, (fourierCoeff f S) ^ 2 := by have h1 := Finset.sum_mul_sq_le_sq_mul_sq supp (fun _ => (1 : ℝ)) (fun S => |fourierCoeff f S|) simp only [one_mul, one_pow, Finset.sum_const, nsmul_eq_mul, mul_one, sq_abs] at h1 exact h1 have hsum_L1 : ∑ S ∈ supp, |fourierCoeff f S| = spectralNorm f := by unfold spectralNorm rw [← Finset.sum_filter_add_sum_filter_not Finset.univ (fun S => fourierCoeff f S ≠ 0)] have hz : ∑ S ∈ Finset.univ.filter (fun S => ¬ fourierCoeff f S ≠ 0), |fourierCoeff f S| = 0 := Finset.sum_eq_zero fun S hS => by have := (Finset.mem_filter.mp hS).2; push Not at this; simp [this] rw [hz, add_zero] have hsum_sq : ∑ S ∈ supp, (fourierCoeff f S) ^ 2 = 1 := by rw [← parseval f] rw [← Finset.sum_filter_add_sum_filter_not Finset.univ (fun S => fourierCoeff f S ≠ 0)] have hz : ∑ S ∈ Finset.univ.filter (fun S => ¬ fourierCoeff f S ≠ 0), (fourierCoeff f S) ^ 2 = 0 := Finset.sum_eq_zero fun S hS => by have := (Finset.mem_filter.mp hS).2; push Not at this; simp [this] rw [hz, add_zero] rw [hsum_L1, hsum_sq, mul_one] at hcs have hcard : (supp.card : ℝ) = 4 := by exact_mod_cast h4 rw [hcard] at hcs nlinarith refine ⟨⟨fun h => (hL1_to_4 h).1, h4_to_L1⟩, fun hL1 => ?_⟩ -- Finally, `spectralNorm f = 2 → parityDepth f = 2`: -- Lower bound `2 ≤ parityDepth f`: if `parityDepth f ≤ 1`, then `L₁(f̂) ≤ 2^0 = 1 < 2`! -- Upper bound `parityDepth f ≤ 2`: apply `signed_collision_L1_drop` with `M₁ = M₂ = 1/2`! -- Both branches drop to `L₁ ≤ 2 - 2*(1/2) = 1`, hence `parityDepth ≤ 1` on both branches! have hge2 : 2 ≤ parityDepth f := by by_contra hlt have h1 := spectralNorm_le_two_pow_parityDepth_sub_one f have hsub : parityDepth f - 1 = 0 := by omega rw [hsub, pow_zero] at h1 linarith obtain ⟨hcard4, hall_half⟩ := hL1_to_4 hL1 let supp := Finset.univ.filter (fun S : Finset ι => fourierCoeff f S ≠ 0) obtain ⟨α₁, hα₁, α₂, hα₂, hne⟩ := Finset.one_lt_card.mp (by rw [show supp.card = 4 from hcard4]; omega) have hα₁_nz : fourierCoeff f α₁ ≠ 0 := (Finset.mem_filter.mp hα₁).2 have hα₂_nz : fourierCoeff f α₂ ≠ 0 := (Finset.mem_filter.mp hα₂).2 have hM1 : |fourierCoeff f α₁| = 1 / 2 := hall_half α₁ hα₁_nz have hM2 : |fourierCoeff f α₂| = 1 / 2 := hall_half α₂ hα₂_nz have hmax : ∀ S, |fourierCoeff f S| ≤ |fourierCoeff f α₁| := fun S => by by_cases hS : fourierCoeff f S = 0 · rw [hS, abs_zero, hM1]; norm_num · rw [hall_half S hS, hM1] have hγ_ne : (symmDiff α₁ α₂).Nonempty := by rw [Finset.nonempty_iff_ne_empty] intro hemp exact hne ((symmDiff_eq_bot.mp ∘ fun h => bot_eq_empty.symm ▸ h) hemp) obtain ⟨p, hp⟩ := hγ_ne let γ := symmDiff α₁ α₂ have hdrop := (signed_collision_L1_drop f hne hmax (by linarith) hp).1 have hbr : ∀ b : ZMod 2, parityDepth (parityRestrict f γ p b) ≤ 1 := by intro b have hLb : spectralNorm (parityRestrict f γ p b) ≤ 1 := by have := hdrop b; linarith have hLb_eq : spectralNorm (parityRestrict f γ p b) = 1 := le_antisymm hLb (spectralNorm_ge_one _) exact parityDepth_le_one_of_sparsity_eq_one ((spectralNorm_eq_one_iff _).mp hLb_eq) obtain ⟨t0, ht0_eval, ht0_depth⟩ := exists_parityDecTree_eq_parityDepth (parityRestrict f γ p 0) obtain ⟨t1, ht1_eval, ht1_depth⟩ := exists_parityDecTree_eq_parityDepth (parityRestrict f γ p 1) let T : ParityDecTree ι := .branch γ t0 t1 have hT_eval : ∀ x, T.eval x = f x := by intro x simp only [T, ParityDecTree.eval] split_ifs with h0 · rw [ht0_eval, parityRestrict_eq_of_hyperplane f hp 0 h0] · have h1 : parityVal γ x = 1 := by rcases zmod2_cases (parityVal γ x) with hv | hv <;> simp_all rw [ht1_eval, parityRestrict_eq_of_hyperplane f hp 1 h1] have hle2 : parityDepth f ≤ 2 := by calc parityDepth f ≤ T.depth := parityDepth_le_of_tree hT_eval _ = 1 + max t0.depth t1.depth := rfl _ ≤ 2 := by have := hbr 0; have := hbr 1; omega omega omit [Fintype ι] in private lemma sd_ne_a {x y z : Finset ι} (hzy : z ≠ y) : symmDiff z (symmDiff x y) ≠ x := by intro h; apply hzy calc z = symmDiff (symmDiff z (symmDiff x y)) (symmDiff x y) := (symmDiff_cancel_right _ _).symm _ = symmDiff x (symmDiff x y) := by rw [h] _ = y := symmDiff_cancel_left x y omit [Fintype ι] in private lemma sd_ne_b {x y z : Finset ι} (hzx : z ≠ x) : symmDiff z (symmDiff x y) ≠ y := by intro h; rw [symmDiff_comm x y] at h; exact sd_ne_a hzx h omit [Fintype ι] in private lemma sd_ne_c {x y z : Finset ι} (hxy : x ≠ y) : symmDiff z (symmDiff x y) ≠ z := by intro h; apply hxy; rw [← symmDiff_eq_empty_finset] calc symmDiff x y = symmDiff z (symmDiff z (symmDiff x y)) := (symmDiff_cancel_left z _).symm _ = symmDiff z z := by rw [h] _ = ∅ := by rw [symmDiff_self, Finset.bot_eq_empty] omit [Fintype ι] in private lemma sd_rearrange (u x y : Finset ι) : x = symmDiff u (symmDiff (symmDiff u (symmDiff x y)) y) := by rw [symmDiff_assoc u, symmDiff_cancel_right, symmDiff_cancel_left] omit [Fintype ι] in private lemma sd_rearrange2 (u x y : Finset ι) : y = symmDiff u (symmDiff (symmDiff u (symmDiff x y)) x) := by rw [symmDiff_comm x y]; exact sd_rearrange u y x omit [Fintype ι] in private lemma sd_cross (u x y : Finset ι) : symmDiff x (symmDiff u (symmDiff x y)) = symmDiff y u := by rw [symmDiff_comm u (symmDiff x y), ← symmDiff_assoc, symmDiff_cancel_left] omit [Fintype ι] in private lemma affinePlane_closed (a b c : Finset ι) : let P : Finset (Finset ι) := {a, b, c, symmDiff c (symmDiff a b)} ∀ x ∈ P, ∀ y ∈ P, ∀ z ∈ P, symmDiff x (symmDiff y z) ∈ P := by intro P x hx y hy z hz let u := symmDiff a b let v := symmDiff a c let elem : Bool → Bool → Finset ι := fun r s => symmDiff a (symmDiff (if r then u else ∅) (if s then v else ∅)) have hduv : symmDiff c (symmDiff a b) = symmDiff a (symmDiff u v) := by calc symmDiff c (symmDiff a b) = symmDiff (symmDiff a b) c := symmDiff_comm c _ _ = symmDiff (symmDiff a b) (symmDiff a (symmDiff a c)) := by rw [symmDiff_cancel_left] _ = symmDiff (symmDiff a (symmDiff a b)) (symmDiff a c) := by rw [← symmDiff_assoc, symmDiff_comm (symmDiff a b) a, symmDiff_assoc] _ = symmDiff a (symmDiff u v) := by rw [symmDiff_assoc] have hmem_elem : ∀ w ∈ P, ∃ r s : Bool, w = elem r s := by intro w hw simp only [P, Finset.mem_insert, Finset.mem_singleton] at hw rcases hw with rfl | rfl | rfl | rfl · exact ⟨false, false, by simp [elem]⟩ · exact ⟨true, false, by simp [elem, u]⟩ · exact ⟨false, true, by simp [elem, v]⟩ · exact ⟨true, true, by simp only [elem, ↓reduceIte]; exact hduv⟩ have helem_mem : ∀ r s : Bool, elem r s ∈ P := by intro r s cases r <;> cases s <;> simp only [P, elem, ↓reduceIte, Bool.false_eq_true, Finset.mem_insert, Finset.mem_singleton] · left; simp · right; right; left; simp [v] · right; left; simp [u] · right; right; right; exact hduv.symm have hsd_if : ∀ (r₁ r₂ : Bool) (w : Finset ι), symmDiff (if r₁ then w else ∅) (if r₂ then w else ∅) = if xor r₁ r₂ then w else ∅ := by intro r₁ r₂ w; cases r₁ <;> cases r₂ <;> simp have hsd_ab : ∀ x₁ x₂ y₁ y₂ : Finset ι, symmDiff (symmDiff x₁ y₁) (symmDiff x₂ y₂) = symmDiff (symmDiff x₁ x₂) (symmDiff y₁ y₂) := by intro x₁ x₂ y₁ y₂ rw [symmDiff_assoc, ← symmDiff_assoc y₁ x₂ y₂, symmDiff_comm y₁ x₂, symmDiff_assoc x₂ y₁ y₂, ← symmDiff_assoc] have hsd_cancel_mid : ∀ p w₁ w₂ : Finset ι, symmDiff (symmDiff p w₁) (symmDiff p w₂) = symmDiff w₁ w₂ := by intro p w₁ w₂ rw [hsd_ab, symmDiff_self, Finset.bot_eq_empty, empty_symmDiff_finset] obtain ⟨r₁, s₁, rfl⟩ := hmem_elem x hx obtain ⟨r₂, s₂, rfl⟩ := hmem_elem y hy obtain ⟨r₃, s₃, rfl⟩ := hmem_elem z hz have h23 : symmDiff (elem r₂ s₂) (elem r₃ s₃) = symmDiff (if xor r₂ r₃ then u else ∅) (if xor s₂ s₃ then v else ∅) := by simp only [elem] rw [hsd_cancel_mid a, hsd_ab, hsd_if r₂ r₃ u, hsd_if s₂ s₃ v] have hcomb : symmDiff (elem r₁ s₁) (symmDiff (elem r₂ s₂) (elem r₃ s₃)) = elem (xor r₁ (xor r₂ r₃)) (xor s₁ (xor s₂ s₃)) := by rw [h23] simp only [elem] rw [symmDiff_assoc a, hsd_ab, hsd_if r₁ _ u, hsd_if s₁ _ v] rw [hcomb] exact helem_mem _ _ private lemma fourierSupp_pair_second (f : (ι → Bool) → Bool) : let S := Finset.univ.filter (fun α : Finset ι => fourierCoeff f α ≠ 0) ∀ a ∈ S, ∀ b ∈ S, a ≠ b → ∃ c ∈ S, c ≠ a ∧ c ≠ b ∧ symmDiff c (symmDiff a b) ∈ S := by classical intro S a ha b hb hab let γ := symmDiff a b have hγne : γ ≠ ∅ := fun h => hab ((symmDiff_eq_empty_finset a b).mp h) have hsum0 := boolean_fourier_autocorr_zero f hγne by_contra hno push Not at hno have hother : ∀ c : Finset ι, c ≠ a → c ≠ b → fourierCoeff f c * fourierCoeff f (symmDiff c γ) = 0 := by intro c hca hcb by_cases hcS : c ∈ S · have hnot : symmDiff c γ ∉ S := hno c hcS hca hcb have hz : fourierCoeff f (symmDiff c γ) = 0 := by by_contra hnz; exact hnot (Finset.mem_filter.mpr ⟨Finset.mem_univ _, hnz⟩) rw [hz, mul_zero] · have hz : fourierCoeff f c = 0 := by by_contra hnz; exact hcS (Finset.mem_filter.mpr ⟨Finset.mem_univ _, hnz⟩) rw [hz, zero_mul] have hsum_two : ∑ c : Finset ι, fourierCoeff f c * fourierCoeff f (symmDiff c γ) = 2 * (fourierCoeff f a * fourierCoeff f b) := by rw [← Finset.add_sum_erase _ _ (Finset.mem_univ a)] have hb_mem : b ∈ Finset.univ.erase a := Finset.mem_erase.mpr ⟨hab.symm, Finset.mem_univ b⟩ rw [← Finset.add_sum_erase _ _ hb_mem] have hrest : ∑ c ∈ (Finset.univ.erase a).erase b, fourierCoeff f c * fourierCoeff f (symmDiff c γ) = 0 := Finset.sum_eq_zero fun c hc => hother c (Finset.ne_of_mem_erase (Finset.mem_of_mem_erase hc)) (Finset.ne_of_mem_erase hc) rw [hrest, add_zero] have haγ : symmDiff a γ = b := by simp only [γ]; exact symmDiff_cancel_left a b have hbγ : symmDiff b γ = a := by simp only [γ]; rw [symmDiff_comm a b]; exact symmDiff_cancel_left b a rw [haγ, hbγ]; ring rw [hsum_two] at hsum0 have ha_nz : fourierCoeff f a ≠ 0 := (Finset.mem_filter.mp ha).2 have hb_nz : fourierCoeff f b ≠ 0 := (Finset.mem_filter.mp hb).2 have hmul_nz : fourierCoeff f a * fourierCoeff f b ≠ 0 := mul_ne_zero ha_nz hb_nz rcases mul_eq_zero.mp hsum0 with h2 | hm · norm_num at h2 · exact hmul_nz hm private lemma fourierSparsity_ne_six (f : (ι → Bool) → Bool) : fourierSparsity f ≠ 6 := by classical let S := Finset.univ.filter (fun α : Finset ι => fourierCoeff f α ≠ 0) have hpair_second := fourierSupp_pair_second f have hplane_closed := affinePlane_closed (ι := ι) intro h6 change S.card = 6 at h6 obtain ⟨a, haS, b, hbS, hab⟩ := Finset.one_lt_card.mp (by omega : 1 < S.card) obtain ⟨c, hcS, hca, hcb, hdS⟩ := hpair_second a haS b hbS hab let d := symmDiff c (symmDiff a b) let P : Finset (Finset ι) := {a, b, c, d} have hPsub : P ⊆ S := by intro x hx; simp only [P, Finset.mem_insert, Finset.mem_singleton] at hx rcases hx with rfl | rfl | rfl | rfl <;> assumption have hda : d ≠ a := sd_ne_a hcb have hdb : d ≠ b := sd_ne_b hca have hdc : d ≠ c := sd_ne_c hab have hPcard4 : P.card = 4 := by rw [Finset.card_insert_of_notMem (by simp [hab, hca.symm, hda.symm]), Finset.card_insert_of_notMem (by simp [hcb.symm, hdb.symm]), Finset.card_insert_of_notMem (by simp [hdc.symm]), Finset.card_singleton] have hSP2 : (S \ P).card = 2 := by rw [Finset.card_sdiff, Finset.inter_eq_left.mpr hPsub, h6, hPcard4] obtain ⟨e₁, e₂, he12, hSPeq⟩ := Finset.card_eq_two.mp hSP2 have he₁SP : e₁ ∈ S \ P := hSPeq ▸ by simp have he₂SP : e₂ ∈ S \ P := hSPeq ▸ by simp have he₁S : e₁ ∈ S := (Finset.mem_sdiff.mp he₁SP).1 have he₁P : e₁ ∉ P := (Finset.mem_sdiff.mp he₁SP).2 have he₂S : e₂ ∈ S := (Finset.mem_sdiff.mp he₂SP).1 have he₁a : e₁ ≠ a := fun h => he₁P (h ▸ by simp [P]) obtain ⟨u, huS, hue₁, hua, hvS⟩ := hpair_second e₁ he₁S a haS he₁a let v := symmDiff u (symmDiff e₁ a) have hve₁ : v ≠ e₁ := sd_ne_a hua have hγ_in_P : ∀ x ∈ P, symmDiff x (symmDiff e₁ e₂) ∈ P := by have hex_y : ∃ y ∈ P, symmDiff e₁ e₂ = symmDiff a y := by by_cases huP : u ∈ P · by_cases hvP : v ∈ P · exfalso have he_eq : e₁ = symmDiff u (symmDiff v a) := sd_rearrange u e₁ a exact he₁P (he_eq ▸ hplane_closed a b c u huP v hvP a (by simp)) · have hv_e2 : v = e₂ := by have hmem : v ∈ ({e₁, e₂} : Finset _) := hSPeq ▸ Finset.mem_sdiff.mpr ⟨hvS, hvP⟩ rcases Finset.mem_insert.mp hmem with h1 | h2 · exact absurd h1 hve₁ · exact Finset.mem_singleton.mp h2 refine ⟨u, huP, ?_⟩ rw [← hv_e2]; exact sd_cross u e₁ a · have hu_e2 : u = e₂ := by have hmem : u ∈ ({e₁, e₂} : Finset _) := hSPeq ▸ Finset.mem_sdiff.mpr ⟨huS, huP⟩ rcases Finset.mem_insert.mp hmem with h1 | h2 · exact absurd h1 hue₁ · exact Finset.mem_singleton.mp h2 have hvP : v ∈ P := by by_contra hnv have hmem : v ∈ ({e₁, e₂} : Finset _) := hSPeq ▸ Finset.mem_sdiff.mpr ⟨hvS, hnv⟩ rcases Finset.mem_insert.mp hmem with h1 | h2 · exact hve₁ h1 · have hv_e2 : v = e₂ := Finset.mem_singleton.mp h2 exact sd_ne_c he₁a (hv_e2.trans hu_e2.symm) refine ⟨v, hvP, ?_⟩ rw [← hu_e2] simp only [v] rw [symmDiff_comm a (symmDiff u (symmDiff e₁ a)), symmDiff_assoc u, symmDiff_cancel_right, symmDiff_comm e₁ u] obtain ⟨y, hyP, hγeq⟩ := hex_y intro x hxP rw [hγeq] exact hplane_closed a b c x hxP a (by simp) y hyP let γ := symmDiff e₁ e₂ have hγne : γ.Nonempty := Finset.nonempty_iff_ne_empty.mpr (fun h => he12 ((symmDiff_eq_empty_finset e₁ e₂).mp h)) obtain ⟨p, hp⟩ := hγne have hS_inv : ∀ x ∈ S, symmDiff x γ ∈ S := by intro x hxS by_cases hxP : x ∈ P · exact hPsub (hγ_in_P x hxP) · have hmem : x ∈ ({e₁, e₂} : Finset _) := hSPeq ▸ Finset.mem_sdiff.mpr ⟨hxS, hxP⟩ rcases Finset.mem_insert.mp hmem with h1 | h2 · rw [h1] have : symmDiff e₁ γ = e₂ := by simp only [γ]; rw [symmDiff_cancel_left] rw [this]; exact he₂S · rw [Finset.mem_singleton.mp h2] have : symmDiff e₂ γ = e₁ := by simp only [γ]; rw [symmDiff_comm e₁ e₂, symmDiff_cancel_left] rw [this]; exact he₁S have hS_half : (S.filter (fun x => p ∉ x)).card = 3 := by have hbij : (S.filter (fun x => p ∉ x)).card = (S.filter (fun x => ¬ p ∉ x)).card := by apply Finset.card_bij (fun x _ => symmDiff x γ) · intro x hx rw [Finset.mem_filter] at hx ⊢ exact ⟨hS_inv x hx.1, by simp [Finset.mem_symmDiff, hp, hx.2]⟩ · intro x₁ _ x₂ _ heq calc x₁ = symmDiff (symmDiff x₁ γ) γ := by rw [symmDiff_cancel_right] _ = symmDiff (symmDiff x₂ γ) γ := by rw [heq] _ = x₂ := by rw [symmDiff_cancel_right] · intro y hy rw [Finset.mem_filter] at hy have hpy : p ∈ y := by simpa using hy.2 refine ⟨symmDiff y γ, ?_, by rw [symmDiff_cancel_right]⟩ rw [Finset.mem_filter] refine ⟨hS_inv y hy.1, fun hmem => ?_⟩ rcases Finset.mem_symmDiff.mp hmem with ⟨_, hng⟩ | ⟨_, hny⟩ · exact hng hp · exact hny hpy have htot : (S.filter (fun x => p ∉ x)).card + (S.filter (fun x => ¬ p ∉ x)).card = S.card := by simpa using Finset.sum_filter_add_sum_filter_not S (fun x => p ∉ x) (fun _ => (1 : ℕ)) omega have hbr1 : ∀ b : ZMod 2, parityDepth (parityRestrict f γ p b) ≤ 1 := by intro b let g := parityRestrict f γ p b have hsub : Finset.univ.filter (fun x => fourierCoeff g x ≠ 0) ⊆ S.filter (fun x => p ∉ x) := by intro x hx have hnz := (Finset.mem_filter.mp hx).2 rw [fourierCoeff_parityRestrict f hp b x] at hnz by_cases hpx : p ∈ x · simp [hpx] at hnz · simp only [hpx, ↓reduceIte] at hnz rw [Finset.mem_filter] refine ⟨?_, hpx⟩ by_contra hxS have h1 : fourierCoeff f x = 0 := by by_contra hc; exact hxS (Finset.mem_filter.mpr ⟨Finset.mem_univ _, hc⟩) have h2 : fourierCoeff f (symmDiff x γ) = 0 := by by_contra hc have hm : symmDiff x γ ∈ S := Finset.mem_filter.mpr ⟨Finset.mem_univ _, hc⟩ have := hS_inv (symmDiff x γ) hm rw [symmDiff_cancel_right] at this exact hxS this rw [h1, h2] at hnz; norm_num at hnz have hsp_le3 : fourierSparsity g ≤ 3 := (Finset.card_le_card hsub).trans (le_of_eq hS_half) have hsp1 : fourierSparsity g = 1 := by by_contra hne1 have hge2 := spectralNorm_gap_ge_two hne1 let Sg := Finset.univ.filter (fun x : Finset ι => fourierCoeff g x ≠ 0) have hcs := Finset.sum_mul_sq_le_sq_mul_sq Sg (fun _ => (1 : ℝ)) (fun x => |fourierCoeff g x|) simp only [one_mul, one_pow, Finset.sum_const, nsmul_eq_mul, mul_one, sq_abs] at hcs have hsum_L1 : ∑ x ∈ Sg, |fourierCoeff g x| = spectralNorm g := by unfold spectralNorm rw [← Finset.sum_filter_add_sum_filter_not Finset.univ (fun x => fourierCoeff g x ≠ 0)] have hz : ∑ x ∈ Finset.univ.filter (fun x => ¬ fourierCoeff g x ≠ 0), |fourierCoeff g x| = 0 := Finset.sum_eq_zero fun x hx => by have := (Finset.mem_filter.mp hx).2; push Not at this; simp [this] rw [hz, add_zero] have hsum_sq : ∑ x ∈ Sg, (fourierCoeff g x) ^ 2 = 1 := by rw [← parseval g, ← Finset.sum_filter_add_sum_filter_not Finset.univ (fun x => fourierCoeff g x ≠ 0)] have hz : ∑ x ∈ Finset.univ.filter (fun x => ¬ fourierCoeff g x ≠ 0), (fourierCoeff g x) ^ 2 = 0 := Finset.sum_eq_zero fun x hx => by have := (Finset.mem_filter.mp hx).2; push Not at this; simp [this] rw [hz, add_zero] rw [hsum_L1, hsum_sq, mul_one] at hcs have hcard_le : (Sg.card : ℝ) ≤ 3 := by exact_mod_cast hsp_le3 nlinarith exact parityDepth_le_one_of_sparsity_eq_one hsp1 obtain ⟨t0, ht0_eval, ht0_depth⟩ := exists_parityDecTree_eq_parityDepth (parityRestrict f γ p 0) obtain ⟨t1, ht1_eval, ht1_depth⟩ := exists_parityDecTree_eq_parityDepth (parityRestrict f γ p 1) let T : ParityDecTree ι := .branch γ t0 t1 have hT_eval : ∀ x, T.eval x = f x := fun x => by simp only [T, ParityDecTree.eval] split_ifs with h0 · rw [ht0_eval, parityRestrict_eq_of_hyperplane f hp 0 h0] · have h1 : parityVal γ x = 1 := by rcases zmod2_cases (parityVal γ x) with hv | hv · exact absurd hv h0 · exact hv rw [ht1_eval, parityRestrict_eq_of_hyperplane f hp 1 h1] have hD_le2 : parityDepth f ≤ 2 := by calc parityDepth f ≤ T.depth := parityDepth_le_of_tree hT_eval _ = 1 + max t0.depth t1.depth := rfl _ ≤ 2 := by have := hbr1 0; have := hbr1 1; omega have hsp_le4 := (fourierSparsity_le_four_pow_parityDepth_sub_one f).trans (Nat.pow_le_pow_right (by norm_num) (show parityDepth f - 1 ≤ 1 by omega)) have h6' : fourierSparsity f = 6 := h6 omega private lemma fourierSparsity_ne_seven (f : (ι → Bool) → Bool) : fourierSparsity f ≠ 7 := by classical let S := Finset.univ.filter (fun α : Finset ι => fourierCoeff f α ≠ 0) have hpair_second := fourierSupp_pair_second f have hplane_closed := affinePlane_closed (ι := ι) intro h7 change S.card = 7 at h7 obtain ⟨a, haS, b, hbS, hab⟩ := Finset.one_lt_card.mp (by omega : 1 < S.card) obtain ⟨c, hcS, hca, hcb, hdS⟩ := hpair_second a haS b hbS hab let d := symmDiff c (symmDiff a b) let P : Finset (Finset ι) := {a, b, c, d} have hPsub : P ⊆ S := by intro x hx; simp only [P, Finset.mem_insert, Finset.mem_singleton] at hx rcases hx with rfl | rfl | rfl | rfl <;> assumption have hda : d ≠ a := sd_ne_a hcb have hdb : d ≠ b := sd_ne_b hca have hdc : d ≠ c := sd_ne_c hab have hPcard4 : P.card = 4 := by rw [Finset.card_insert_of_notMem (by simp [hab, hca.symm, hda.symm]), Finset.card_insert_of_notMem (by simp [hcb.symm, hdb.symm]), Finset.card_insert_of_notMem (by simp [hdc.symm]), Finset.card_singleton] have hSP3 : (S \ P).card = 3 := by rw [Finset.card_sdiff, Finset.inter_eq_left.mpr hPsub, h7, hPcard4] obtain ⟨e₁, e₂, e₃, he12, he13, he23, hSPeq⟩ := Finset.card_eq_three.mp hSP3 -- Every pair of distinct `x, y ∈ {e₁, e₂, e₃}` has `x ∆ y ∈ P ∆ P` (i.e. `∀ w ∈ P, w ∆ (x ∆ y) ∈ P`)! have hdiff_in_P : ∀ x ∈ S \ P, ∀ y ∈ S \ P, x ≠ y → ∀ w ∈ P, symmDiff w (symmDiff x y) ∈ P := by intro x hx y hy hxy have hxS : x ∈ S := (Finset.mem_sdiff.mp hx).1 have hxP : x ∉ P := (Finset.mem_sdiff.mp hx).2 have hyS : y ∈ S := (Finset.mem_sdiff.mp hy).1 have hyP : y ∉ P := (Finset.mem_sdiff.mp hy).2 have hthird : ∀ u ∈ S \ P, u = x ∨ u = y ∨ (u ≠ x ∧ u ≠ y ∧ ∀ v ∈ S \ P, v = x ∨ v = y ∨ v = u) := by intro u hu by_cases hux : u = x · exact Or.inl hux · by_cases huy : u = y · exact Or.inr (Or.inl huy) · refine Or.inr (Or.inr ⟨hux, huy, fun v hv => ?_⟩) have hsub3 : ({x, y, u} : Finset _) ⊆ S \ P := by intro t ht; simp only [Finset.mem_insert, Finset.mem_singleton] at ht rcases ht with rfl | rfl | rfl <;> assumption have hcard3 : ({x, y, u} : Finset _).card = 3 := by rw [Finset.card_insert_of_notMem (by simp [hxy, Ne.symm hux]), Finset.card_insert_of_notMem (by simp [Ne.symm huy]), Finset.card_singleton] have heq3 : ({x, y, u} : Finset _) = S \ P := Finset.eq_of_subset_of_card_le hsub3 (by rw [hcard3, hSP3]) have hv' : v ∈ ({x, y, u} : Finset _) := heq3 ▸ hv simpa only [Finset.mem_insert, Finset.mem_singleton] using hv' obtain ⟨u, huS, hux, huy, hvS⟩ := hpair_second x hxS y hyS hxy let v := symmDiff u (symmDiff x y) have hvx : v ≠ x := sd_ne_a huy have hvy : v ≠ y := sd_ne_b hux have huv : u ≠ v := (sd_ne_c hxy).symm by_cases huP : u ∈ P · by_cases hvP : v ∈ P · intro w hwP have heq : symmDiff w (symmDiff x y) = symmDiff w (symmDiff u v) := by simp only [v, symmDiff_cancel_left] rw [heq] exact hplane_closed a b c w hwP u huP v hvP · exfalso obtain ⟨w₀, hw₀P, hw₀u⟩ : ∃ w₀ ∈ P, w₀ ≠ u := by have hne : (P.erase u).Nonempty := Finset.card_pos.mp (by rw [Finset.card_erase_of_mem huP, hPcard4]; omega) obtain ⟨w₀, hw₀⟩ := hne exact ⟨w₀, Finset.mem_of_mem_erase hw₀, Finset.ne_of_mem_erase hw₀⟩ have hxw₀ : x ≠ w₀ := fun h => hxP (h ▸ hw₀P) obtain ⟨p₁, hp₁S, hp₁x, hp₁w₀, hp₂S⟩ := hpair_second x hxS w₀ (hPsub hw₀P) hxw₀ let p₂ := symmDiff p₁ (symmDiff x w₀) have hp₂x : p₂ ≠ x := sd_ne_a hp₁w₀ have hp₂w₀ : p₂ ≠ w₀ := sd_ne_b hp₁x let Q : Finset (Finset ι) := {x, y, v, u} have hQ_closed : ∀ r₁ ∈ Q, ∀ r₂ ∈ Q, ∀ r₃ ∈ Q, symmDiff r₁ (symmDiff r₂ r₃) ∈ Q := by have hQ_eq : Q = {x, y, u, v} := by ext t simp only [Q, Finset.mem_insert, Finset.mem_singleton] constructor · rintro (rfl | rfl | rfl | rfl) <;> simp · rintro (rfl | rfl | rfl | rfl) <;> simp rw [hQ_eq]; exact hplane_closed x y u have hS_eq_PQ : ∀ t ∈ S, t ∈ P ∨ t ∈ ({x, y, v} : Finset (Finset ι)) := by intro t htS by_cases htP : t ∈ P · exact Or.inl htP · right rcases hthird v (Finset.mem_sdiff.mpr ⟨hvS, hvP⟩) with h1 | h2 | ⟨_, _, hall⟩ · exact absurd h1 hvx · exact absurd h2 hvy · rcases hall t (Finset.mem_sdiff.mpr ⟨htS, htP⟩) with rfl | rfl | rfl <;> simp have hPQ_inter : ∀ t, t ∈ P → t ∈ Q → t = u := by intro t htP htQ simp only [Q, Finset.mem_insert, Finset.mem_singleton] at htQ rcases htQ with rfl | rfl | rfl | rfl · exact absurd htP hxP · exact absurd htP hyP · exact absurd htP hvP · rfl have hnot_both_P : ¬ (p₁ ∈ P ∧ p₂ ∈ P) := by rintro ⟨h1, h2⟩ have hx_eq : x = symmDiff p₁ (symmDiff p₂ w₀) := sd_rearrange p₁ x w₀ exact hxP (hx_eq ▸ hplane_closed a b c p₁ h1 p₂ h2 w₀ hw₀P) have hnot_both_Q : ¬ (p₁ ∈ Q ∧ p₂ ∈ Q) := by rintro ⟨h1, h2⟩ have hw_eq : w₀ = symmDiff p₁ (symmDiff p₂ x) := sd_rearrange2 p₁ x w₀ have hw₀Q : w₀ ∈ Q := hw_eq ▸ hQ_closed p₁ h1 p₂ h2 x (by simp [Q]) exact hw₀u (hPQ_inter w₀ hw₀P hw₀Q) have hcross : ∃ q ∈ Q, q ≠ x ∧ ∃ r ∈ P, r ≠ w₀ ∧ symmDiff x q = symmDiff w₀ r := by rcases hS_eq_PQ p₁ hp₁S with h1P | h1Q <;> rcases hS_eq_PQ p₂ hp₂S with h2P | h2Q · exact absurd ⟨h1P, h2P⟩ hnot_both_P · have h2Q' : p₂ ∈ Q := by simp only [Finset.mem_insert, Finset.mem_singleton] at h2Q; rcases h2Q with h | h | h <;> simp [Q, h] exact ⟨p₂, h2Q', hp₂x, p₁, h1P, hp₁w₀, sd_cross p₁ x w₀⟩ · have h1Q' : p₁ ∈ Q := by simp only [Finset.mem_insert, Finset.mem_singleton] at h1Q; rcases h1Q with h | h | h <;> simp [Q, h] refine ⟨p₁, h1Q', hp₁x, p₂, h2P, hp₂w₀, ?_⟩ simp only [p₂] rw [symmDiff_comm w₀, symmDiff_assoc p₁, symmDiff_cancel_right, symmDiff_comm x p₁] · have h1Q' : p₁ ∈ Q := by simp only [Finset.mem_insert, Finset.mem_singleton] at h1Q; rcases h1Q with h | h | h <;> simp [Q, h] have h2Q' : p₂ ∈ Q := by simp only [Finset.mem_insert, Finset.mem_singleton] at h2Q; rcases h2Q with h | h | h <;> simp [Q, h] exact absurd ⟨h1Q', h2Q'⟩ hnot_both_Q obtain ⟨q, hqQ, hqx, r, hrP, hrw₀, hqr⟩ := hcross let t := symmDiff u (symmDiff x q) have htQ : t ∈ Q := hQ_closed u (by simp [Q]) x (by simp [Q]) q hqQ have htP : t ∈ P := by have heq : t = symmDiff u (symmDiff w₀ r) := by simp [t, hqr] rw [heq]; exact hplane_closed a b c u huP w₀ hw₀P r hrP have htu : t = u := hPQ_inter t htP htQ exact sd_ne_c hqx.symm htu · have hvP : v ∈ P := by by_contra hnv rcases hthird u (Finset.mem_sdiff.mpr ⟨huS, huP⟩) with rfl | rfl | ⟨_, _, hall⟩ · exact hux rfl · exact huy rfl · rcases hall v (Finset.mem_sdiff.mpr ⟨hvS, hnv⟩) with h1 | h2 | h3 · exact hvx h1 · exact hvy h2 · exact huv h3.symm exfalso obtain ⟨w₀, hw₀P, hw₀v⟩ : ∃ w₀ ∈ P, w₀ ≠ v := by have hne : (P.erase v).Nonempty := Finset.card_pos.mp (by rw [Finset.card_erase_of_mem hvP, hPcard4]; omega) obtain ⟨w₀, hw₀⟩ := hne exact ⟨w₀, Finset.mem_of_mem_erase hw₀, Finset.ne_of_mem_erase hw₀⟩ have hxw₀ : x ≠ w₀ := fun h => hxP (h ▸ hw₀P) obtain ⟨p₁, hp₁S, hp₁x, hp₁w₀, hp₂S⟩ := hpair_second x hxS w₀ (hPsub hw₀P) hxw₀ let p₂ := symmDiff p₁ (symmDiff x w₀) have hp₂x : p₂ ≠ x := sd_ne_a hp₁w₀ have hp₂w₀ : p₂ ≠ w₀ := sd_ne_b hp₁x let Q : Finset (Finset ι) := {x, y, u, v} have hQ_closed : ∀ r₁ ∈ Q, ∀ r₂ ∈ Q, ∀ r₃ ∈ Q, symmDiff r₁ (symmDiff r₂ r₃) ∈ Q := hplane_closed x y u have hS_eq_PQ : ∀ t ∈ S, t ∈ P ∨ t ∈ ({x, y, u} : Finset (Finset ι)) := by intro t htS by_cases htP : t ∈ P · exact Or.inl htP · right rcases hthird u (Finset.mem_sdiff.mpr ⟨huS, huP⟩) with rfl | rfl | ⟨_, _, hall⟩ · exact absurd rfl hux · exact absurd rfl huy · rcases hall t (Finset.mem_sdiff.mpr ⟨htS, htP⟩) with rfl | rfl | rfl <;> simp have hPQ_inter : ∀ t, t ∈ P → t ∈ Q → t = v := by intro t htP htQ simp only [Q, Finset.mem_insert, Finset.mem_singleton] at htQ rcases htQ with rfl | rfl | rfl | rfl · exact absurd htP hxP · exact absurd htP hyP · exact absurd htP huP · rfl have hnot_both_P : ¬ (p₁ ∈ P ∧ p₂ ∈ P) := by rintro ⟨h1, h2⟩ have hx_eq : x = symmDiff p₁ (symmDiff p₂ w₀) := sd_rearrange p₁ x w₀ exact hxP (hx_eq ▸ hplane_closed a b c p₁ h1 p₂ h2 w₀ hw₀P) have hnot_both_Q : ¬ (p₁ ∈ Q ∧ p₂ ∈ Q) := by rintro ⟨h1, h2⟩ have hw_eq : w₀ = symmDiff p₁ (symmDiff p₂ x) := sd_rearrange2 p₁ x w₀ have hw₀Q : w₀ ∈ Q := hw_eq ▸ hQ_closed p₁ h1 p₂ h2 x (by simp [Q]) exact hw₀v (hPQ_inter w₀ hw₀P hw₀Q) have hcross : ∃ q ∈ Q, q ≠ x ∧ ∃ r ∈ P, r ≠ w₀ ∧ symmDiff x q = symmDiff w₀ r := by rcases hS_eq_PQ p₁ hp₁S with h1P | h1Q <;> rcases hS_eq_PQ p₂ hp₂S with h2P | h2Q · exact absurd ⟨h1P, h2P⟩ hnot_both_P · have h2Q' : p₂ ∈ Q := by simp only [Finset.mem_insert, Finset.mem_singleton] at h2Q; rcases h2Q with h | h | h <;> simp [Q, h] exact ⟨p₂, h2Q', hp₂x, p₁, h1P, hp₁w₀, sd_cross p₁ x w₀⟩ · have h1Q' : p₁ ∈ Q := by simp only [Finset.mem_insert, Finset.mem_singleton] at h1Q; rcases h1Q with h | h | h <;> simp [Q, h] refine ⟨p₁, h1Q', hp₁x, p₂, h2P, hp₂w₀, ?_⟩ simp only [p₂] rw [symmDiff_comm w₀, symmDiff_assoc p₁, symmDiff_cancel_right, symmDiff_comm x p₁] · have h1Q' : p₁ ∈ Q := by simp only [Finset.mem_insert, Finset.mem_singleton] at h1Q; rcases h1Q with h | h | h <;> simp [Q, h] have h2Q' : p₂ ∈ Q := by simp only [Finset.mem_insert, Finset.mem_singleton] at h2Q; rcases h2Q with h | h | h <;> simp [Q, h] exact absurd ⟨h1Q', h2Q'⟩ hnot_both_Q obtain ⟨q, hqQ, hqx, r, hrP, hrw₀, hqr⟩ := hcross let t := symmDiff v (symmDiff x q) have htQ : t ∈ Q := hQ_closed v (by simp [Q]) x (by simp [Q]) q hqQ have htP : t ∈ P := by have heq : t = symmDiff v (symmDiff w₀ r) := by simp [t, hqr] rw [heq]; exact hplane_closed a b c v hvP w₀ hw₀P r hrP have htv : t = v := hPQ_inter t htP htQ exact sd_ne_c hqx.symm htv -- Now for ANY `x, y, z` = permutation of `{e₁, e₂, e₃}`, querying `γ = x ∆ y` gives a restriction -- `g_b` with `‖g_b‖₀ ≤ 4`, hence `|f̂(z)| ∈ {1, 1/2}` (impossible to be `1`, so `|f̂(z)| = 1/2`)! have hcoeff_half : ∀ x ∈ S \ P, ∀ y ∈ S \ P, ∀ z ∈ S \ P, x ≠ y → x ≠ z → y ≠ z → |fourierCoeff f z| = 1 / 2 ∧ (∀ b : ZMod 2, |fourierCoeff f x + (if b = 0 then (1 : ℝ) else -1) * fourierCoeff f y| ∈ ({0, 1 / 2, 1} : Set ℝ) ∧ |fourierCoeff f x + (if b = 0 then (1 : ℝ) else -1) * fourierCoeff f y| ≠ 1) := by intro x hx y hy z hz hxy hxz hyz let γ := symmDiff x y have hγne : γ.Nonempty := Finset.nonempty_iff_ne_empty.mpr (fun h => hxy ((symmDiff_eq_empty_finset x y).mp h)) obtain ⟨p, hp⟩ := hγne have hP_inv : ∀ w ∈ P, symmDiff w γ ∈ P := hdiff_in_P x hx y hy hxy -- `z ∆ γ` is NOT in `S`! have hzγ_nS : symmDiff z γ ∉ S := by intro hmem by_cases hP : symmDiff z γ ∈ P · have hzP : z ∈ P := by have := hP_inv (symmDiff z γ) hP rwa [symmDiff_cancel_right] at this exact (Finset.mem_sdiff.mp hz).2 hzP · have hsub3 : ({x, y, z} : Finset _) = S \ P := by apply Finset.eq_of_subset_of_card_le · intro t ht; simp only [Finset.mem_insert, Finset.mem_singleton] at ht rcases ht with rfl | rfl | rfl <;> assumption · rw [Finset.card_insert_of_notMem (by simp [hxy, hxz]), Finset.card_insert_of_notMem (by simp [hyz]), Finset.card_singleton, hSP3] have hm : symmDiff z γ ∈ ({x, y, z} : Finset _) := hsub3 ▸ Finset.mem_sdiff.mpr ⟨hmem, hP⟩ simp only [Finset.mem_insert, Finset.mem_singleton] at hm rcases hm with h1 | h2 | h3 · exact sd_ne_a hyz.symm h1 · exact sd_ne_b hxz.symm h2 · exact sd_ne_c hxy h3 -- Pick representative `z'` of `{z, z ∆ γ}` with `p ∉ z'` and `x'` of `{x, y}` with `p ∉ x'`: -- Every `w ∈ S` with `p ∉ w` lies in `P.filter (p ∉ ·)` (size 2), `{x'}` (size 1), or `{z'}` (size 1)! have hP_half : (P.filter (fun w => p ∉ w)).card = 2 := by have hbij : (P.filter (fun w => p ∉ w)).card = (P.filter (fun w => ¬ p ∉ w)).card := by apply Finset.card_bij (fun w _ => symmDiff w γ) · intro w hw; rw [Finset.mem_filter] at hw ⊢ exact ⟨hP_inv w hw.1, by simp [Finset.mem_symmDiff, hp, hw.2]⟩ · intro w₁ _ w₂ _ heq calc w₁ = symmDiff (symmDiff w₁ γ) γ := by rw [symmDiff_cancel_right] _ = symmDiff (symmDiff w₂ γ) γ := by rw [heq] _ = w₂ := by rw [symmDiff_cancel_right] · intro t ht; rw [Finset.mem_filter] at ht have hpt : p ∈ t := by simpa using ht.2 refine ⟨symmDiff t γ, ?_, by rw [symmDiff_cancel_right]⟩ rw [Finset.mem_filter] refine ⟨hP_inv t ht.1, fun hmem => ?_⟩ rcases Finset.mem_symmDiff.mp hmem with ⟨_, hng⟩ | ⟨_, hnt⟩ · exact hng hp · exact hnt hpt have htot : (P.filter (fun w => p ∉ w)).card + (P.filter (fun w => ¬ p ∉ w)).card = P.card := by simpa using Finset.sum_filter_add_sum_filter_not P (fun w => p ∉ w) (fun _ => (1 : ℕ)) omega let z' := if p ∈ z then symmDiff z γ else z let x' := if p ∈ x then y else x have hpx' : p ∉ x' := by dsimp only [x']; split_ifs with hpx · intro hpy rcases Finset.mem_symmDiff.mp hp with ⟨_, h⟩ | ⟨_, h⟩ · exact h hpy · exact h hpx · exact hpx have hpz' : p ∉ z' := by dsimp only [z']; split_ifs with hpz · intro hmem rcases Finset.mem_symmDiff.mp hmem with ⟨_, hng⟩ | ⟨_, hnz⟩ · exact hng hp · exact hnz hpz · exact hpz have hsub4 : ∀ b : ZMod 2, Finset.univ.filter (fun w => fourierCoeff (parityRestrict f γ p b) w ≠ 0) ⊆ insert x' (insert z' (P.filter (fun w => p ∉ w))) := by intro b w hw have hnz := (Finset.mem_filter.mp hw).2 rw [fourierCoeff_parityRestrict f hp b w] at hnz by_cases hpw : p ∈ w · simp [hpw] at hnz · simp only [hpw, ↓reduceIte] at hnz have hmem_or : w ∈ S ∨ symmDiff w γ ∈ S := by by_contra hnone; push Not at hnone have h1 : fourierCoeff f w = 0 := by by_contra hc; exact hnone.1 (Finset.mem_filter.mpr ⟨Finset.mem_univ _, hc⟩) have h2 : fourierCoeff f (symmDiff w γ) = 0 := by by_contra hc; exact hnone.2 (Finset.mem_filter.mpr ⟨Finset.mem_univ _, hc⟩) rw [h1, h2] at hnz; norm_num at hnz have hsub3 : ({x, y, z} : Finset _) = S \ P := by apply Finset.eq_of_subset_of_card_le · intro t ht; simp only [Finset.mem_insert, Finset.mem_singleton] at ht rcases ht with rfl | rfl | rfl <;> assumption · rw [Finset.card_insert_of_notMem (by simp [hxy, hxz]), Finset.card_insert_of_notMem (by simp [hyz]), Finset.card_singleton, hSP3] by_cases hwP : w ∈ P · exact Finset.mem_insert_of_mem (Finset.mem_insert_of_mem (Finset.mem_filter.mpr ⟨hwP, hpw⟩)) · have hngP : symmDiff w γ ∉ P := fun h => hwP (by have := hP_inv (symmDiff w γ) h rwa [symmDiff_cancel_right] at this) rcases hmem_or with hwS | hwgS · have hm : w ∈ ({x, y, z} : Finset _) := hsub3 ▸ Finset.mem_sdiff.mpr ⟨hwS, hwP⟩ simp only [Finset.mem_insert, Finset.mem_singleton] at hm rcases hm with rfl | rfl | rfl · simp [x', hpw] · have hpx : p ∈ x := by rcases Finset.mem_symmDiff.mp hp with ⟨h1, _⟩ | ⟨h2, _⟩ · exact h1 · exact absurd h2 hpw simp [x', hpx] · simp [z', hpw] · have hm : symmDiff w γ ∈ ({x, y, z} : Finset _) := hsub3 ▸ Finset.mem_sdiff.mpr ⟨hwgS, hngP⟩ simp only [Finset.mem_insert, Finset.mem_singleton] at hm rcases hm with h1 | h2 | h3 · have hwy : w = y := by calc w = symmDiff (symmDiff w γ) γ := by rw [symmDiff_cancel_right] _ = symmDiff x γ := by rw [h1] _ = y := by simp only [γ]; rw [symmDiff_cancel_left] have hpx : p ∈ x := by rcases Finset.mem_symmDiff.mp hp with ⟨h1', _⟩ | ⟨h2', _⟩ · exact h1' · exact absurd (hwy ▸ h2') hpw simp [x', hpx, hwy] · have hwx : w = x := by calc w = symmDiff (symmDiff w γ) γ := by rw [symmDiff_cancel_right] _ = symmDiff y γ := by rw [h2] _ = x := by simp only [γ]; rw [symmDiff_comm x y, symmDiff_cancel_left] simp [x', hwx ▸ hpw, hwx] · have hwz : w = symmDiff z γ := by calc w = symmDiff (symmDiff w γ) γ := by rw [symmDiff_cancel_right] _ = symmDiff z γ := by rw [h3] have hpz : p ∈ z := by by_contra hnpz exact hpw (hwz ▸ Finset.mem_symmDiff.mpr (Or.inr ⟨hp, hnpz⟩)) simp [z', hpz, hwz] -- Thus `fourierSparsity (parityRestrict f γ p b) ≤ 4` for `b = 0, 1`! have hsp_le4 : ∀ b : ZMod 2, fourierSparsity (parityRestrict f γ p b) ≤ 4 := fun b => by calc fourierSparsity (parityRestrict f γ p b) ≤ (insert x' (insert z' (P.filter (fun w => p ∉ w)))).card := Finset.card_le_card (hsub4 b) _ ≤ 1 + (insert z' (P.filter (fun w => p ∉ w))).card := by have := Finset.card_insert_le x' (insert z' (P.filter (fun w => p ∉ w))); omega _ ≤ 1 + (1 + (P.filter (fun w => p ∉ w)).card) := by have := Finset.card_insert_le z' (P.filter (fun w => p ∉ w)); omega _ = 4 := by rw [hP_half] -- And `|fourierCoeff (parityRestrict f γ p b) z'| = |fourierCoeff f z| ∈ (0, 1)`! have hgz' : ∀ b : ZMod 2, |fourierCoeff (parityRestrict f γ p b) z'| = |fourierCoeff f z| := by intro b rw [fourierCoeff_parityRestrict f hp b z', if_neg hpz'] have hzγ_zero : fourierCoeff f (symmDiff z γ) = 0 := by by_contra hc; exact hzγ_nS (Finset.mem_filter.mpr ⟨Finset.mem_univ _, hc⟩) dsimp only [z'] by_cases hpz : p ∈ z · rw [if_pos hpz, symmDiff_cancel_right, hzγ_zero, zero_add] rcases zmod2_cases b with rfl | rfl <;> simp · rw [if_neg hpz, hzγ_zero, mul_zero, add_zero] have hz_nz : fourierCoeff f z ≠ 0 := (Finset.mem_filter.mp (Finset.mem_sdiff.mp hz).1).2 have hz_lt1 : |fourierCoeff f z| < 1 := by by_contra hge have h1 := (fourierSparsity_eq_one_iff f).mpr ⟨z, le_antisymm (abs_fourierCoeff_le_one f z) (by linarith)⟩ have h7' : fourierSparsity f = 7 := h7 omega -- Therefore `parityRestrict f γ p b` cannot have sparsity 1 (since `0 < |f̂(z)| < 1`) nor `{2, 3}` (since `L₁ < 2`), -- so it MUST have sparsity `4`, `L₁ = 2`, and EVERY nonzero coefficient has magnitude `1/2`! have hgb_half : ∀ b : ZMod 2, ∀ w, fourierCoeff (parityRestrict f γ p b) w ≠ 0 → |fourierCoeff (parityRestrict f γ p b) w| = 1 / 2 := by intro b w hw let g := parityRestrict f γ p b have hg_ne1 : fourierSparsity g ≠ 1 := by intro h1 obtain ⟨α₀, hα₀⟩ := (fourierSparsity_eq_one_iff g).mp h1 have hgz_nz : fourierCoeff g z' ≠ 0 := by intro h0; have := hgz' b; rw [h0, abs_zero] at this; exact hz_nz (abs_eq_zero.mp this.symm) have hzeq : z' = α₀ := by by_contra hne have hp := parseval g have h2 : (fourierCoeff g α₀) ^ 2 + (fourierCoeff g z') ^ 2 ≤ 1 := by rw [← hp] have hsum := Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ {α₀, z'}) (fun T _ _ => sq_nonneg (fourierCoeff g T)) rwa [Finset.sum_pair (Ne.symm hne)] at hsum have hsq1 : (fourierCoeff g α₀) ^ 2 = 1 := by rw [← sq_abs, hα₀]; norm_num nlinarith [sq_pos_of_ne_zero hgz_nz] have := hgz' b; rw [hzeq, hα₀] at this; linarith have hg_sp4 : fourierSparsity g = 4 := by have hge2 := spectralNorm_gap_ge_two hg_ne1 let Sg := Finset.univ.filter (fun t : Finset ι => fourierCoeff g t ≠ 0) have hcs := Finset.sum_mul_sq_le_sq_mul_sq Sg (fun _ => (1 : ℝ)) (fun t => |fourierCoeff g t|) simp only [one_mul, one_pow, Finset.sum_const, nsmul_eq_mul, mul_one, sq_abs] at hcs have hsum_L1 : ∑ t ∈ Sg, |fourierCoeff g t| = spectralNorm g := by unfold spectralNorm rw [← Finset.sum_filter_add_sum_filter_not Finset.univ (fun t => fourierCoeff g t ≠ 0)] have hz0 : ∑ t ∈ Finset.univ.filter (fun t => ¬ fourierCoeff g t ≠ 0), |fourierCoeff g t| = 0 := Finset.sum_eq_zero fun t ht => by have := (Finset.mem_filter.mp ht).2; push Not at this; simp [this] rw [hz0, add_zero] have hsum_sq : ∑ t ∈ Sg, (fourierCoeff g t) ^ 2 = 1 := by rw [← parseval g, ← Finset.sum_filter_add_sum_filter_not Finset.univ (fun t => fourierCoeff g t ≠ 0)] have hz0 : ∑ t ∈ Finset.univ.filter (fun t => ¬ fourierCoeff g t ≠ 0), (fourierCoeff g t) ^ 2 = 0 := Finset.sum_eq_zero fun t ht => by have := (Finset.mem_filter.mp ht).2; push Not at this; simp [this] rw [hz0, add_zero] rw [hsum_L1, hsum_sq, mul_one] at hcs have hge4_r : (4 : ℝ) ≤ (Sg.card : ℝ) := by nlinarith have hge4 : 4 ≤ fourierSparsity g := by exact_mod_cast hge4_r exact le_antisymm (hsp_le4 b) hge4 have hg_L1 : spectralNorm g = 2 := (spectralNorm_eq_two_rigidity g).1.mpr hg_sp4 -- Every nonzero coefficient has magnitude `1/2` (proved inside `hL1_to_4` — reuse via Parseval + L1 = 2): -- Actually `|f̂_g(t)| ≤ 1/2` for all `t`, otherwise `L₁(g) > 2` (same 3 lines as above, OR simply: -- since `Sg.card = 4`, `∑_{t ∈ Sg} (|f̂_g(t)| - 1/2)² = ∑ f̂_g² - L₁(g) + 4*(1/4) = 1 - 2 + 1 = 0`!! -- **WHOA!! `∑_{t ∈ Sg} (|f̂_g(t)| - 1/2)² = 0` IS A 2-LINE PROOF!!**) let Sg := Finset.univ.filter (fun t : Finset ι => fourierCoeff g t ≠ 0) have hsq0 : ∑ t ∈ Sg, (|fourierCoeff g t| - 1 / 2) ^ 2 = 0 := by have hexp : ∑ t ∈ Sg, (|fourierCoeff g t| - 1 / 2) ^ 2 = (∑ t ∈ Sg, (fourierCoeff g t) ^ 2) - (∑ t ∈ Sg, |fourierCoeff g t|) + (Sg.card : ℝ) * (1 / 4) := by have h1 : ∀ t ∈ Sg, (|fourierCoeff g t| - 1 / 2) ^ 2 = (fourierCoeff g t) ^ 2 - |fourierCoeff g t| + 1 / 4 := fun t _ => by rw [sub_sq, sq_abs]; ring rw [Finset.sum_congr rfl h1, Finset.sum_add_distrib, Finset.sum_sub_distrib, Finset.sum_const, nsmul_eq_mul] have hsum_L1 : ∑ t ∈ Sg, |fourierCoeff g t| = spectralNorm g := by unfold spectralNorm rw [← Finset.sum_filter_add_sum_filter_not Finset.univ (fun t => fourierCoeff g t ≠ 0)] have hz0 : ∑ t ∈ Finset.univ.filter (fun t => ¬ fourierCoeff g t ≠ 0), |fourierCoeff g t| = 0 := Finset.sum_eq_zero fun t ht => by have := (Finset.mem_filter.mp ht).2; push Not at this; simp [this] rw [hz0, add_zero] have hsum_sq : ∑ t ∈ Sg, (fourierCoeff g t) ^ 2 = 1 := by rw [← parseval g, ← Finset.sum_filter_add_sum_filter_not Finset.univ (fun t => fourierCoeff g t ≠ 0)] have hz0 : ∑ t ∈ Finset.univ.filter (fun t => ¬ fourierCoeff g t ≠ 0), (fourierCoeff g t) ^ 2 = 0 := Finset.sum_eq_zero fun t ht => by have := (Finset.mem_filter.mp ht).2; push Not at this; simp [this] rw [hz0, add_zero] have hc4 : (Sg.card : ℝ) = 4 := by exact_mod_cast hg_sp4 rw [hexp, hsum_sq, hsum_L1, hg_L1, hc4]; norm_num have hw_mem : w ∈ Sg := Finset.mem_filter.mpr ⟨Finset.mem_univ _, hw⟩ have ht0 := (Finset.sum_eq_zero_iff_of_nonneg (fun t _ => sq_nonneg _)).mp hsq0 w hw_mem have : |fourierCoeff g w| - 1 / 2 = 0 := sq_eq_zero_iff.mp ht0 linarith refine ⟨?_, fun b => ?_⟩ · rw [← hgz' 0] apply hgb_half 0 z' intro h0; have := hgz' 0; rw [h0, abs_zero] at this; exact hz_nz (abs_eq_zero.mp this.symm) · have hgx' : |fourierCoeff (parityRestrict f γ p b) x'| = |fourierCoeff f x + (if b = 0 then (1 : ℝ) else -1) * fourierCoeff f y| := by rw [fourierCoeff_parityRestrict f hp b x', if_neg hpx'] dsimp only [x'] by_cases hpx : p ∈ x · rw [if_pos hpx] have h1 : symmDiff y γ = x := by simp only [γ]; rw [symmDiff_comm x y, symmDiff_cancel_left] rw [h1] rcases zmod2_cases b with rfl | rfl · simp only [↓reduceIte, one_mul, add_comm] · simp only [one_ne_zero, ↓reduceIte, neg_one_mul] rw [← abs_neg]; ring_nf · rw [if_neg hpx] have h1 : symmDiff x γ = y := by simp only [γ]; rw [symmDiff_cancel_left] rw [h1] rw [← hgx'] by_cases h0 : fourierCoeff (parityRestrict f γ p b) x' = 0 · rw [h0, abs_zero]; constructor <;> [simp; norm_num] · rw [hgb_half b x' h0]; constructor <;> [simp; norm_num] -- Apply `hcoeff_half` to `(e₁, e₂, e₃)`, `(e₂, e₃, e₁)`, `(e₃, e₁, e₂)`! have he₁m : e₁ ∈ S \ P := hSPeq ▸ by simp have he₂m : e₂ ∈ S \ P := hSPeq ▸ by simp have he₃m : e₃ ∈ S \ P := hSPeq ▸ by simp have h1 := hcoeff_half e₂ he₂m e₃ he₃m e₁ he₁m he23 he12.symm he13.symm have h2 := hcoeff_half e₃ he₃m e₁ he₁m e₂ he₂m he13.symm he23.symm he12 have h3 := hcoeff_half e₁ he₁m e₂ he₂m e₃ he₃m he12 he13 he23 have hfe1 : |fourierCoeff f e₁| = 1 / 2 := h1.1 have hfe2 : |fourierCoeff f e₂| = 1 / 2 := h2.1 have hne1_0 := (h3.2 0).2 have hne1_1 := (h3.2 1).2 simp only [↓reduceIte, one_mul] at hne1_0 simp only [one_ne_zero, ↓reduceIte, neg_one_mul] at hne1_1 rcases eq_or_eq_neg_of_abs_eq hfe1 with ha | ha <;> rcases eq_or_eq_neg_of_abs_eq hfe2 with hb | hb · rw [ha, hb] at hne1_0; norm_num at hne1_0 · rw [ha, hb] at hne1_1; norm_num at hne1_1 · rw [ha, hb] at hne1_1; norm_num at hne1_1 · rw [ha, hb] at hne1_0; norm_num at hne1_0 /-- **Theorem 3E (Part 3 — Forbidden Low-Sparsity Gap)**: No Boolean function `f : (ι → Bool) → Bool` on any finite index set `ι` can have Fourier sparsity `‖f̂‖₀ ∈ {2, 3, 5, 6, 7}`. *(Proof: Purely from Boolean orthogonality `∑ f̂(S) f̂(S ∆ γ) = 0`: every nonzero difference `γ = α ∆ β` in `S = supp(f̂)` must occur in at least TWO disjoint unordered pairs, forcing `|S| ∉ {2, 3, 5}` immediately and ruling out `{6, 7}` via affine-plane pairing and dyadic Parseval arithmetic!)* -/ theorem fourierSparsity_forbidden_gap (f : (ι → Bool) → Bool) : fourierSparsity f ∉ ({2, 3, 5, 6, 7} : Finset ℕ) := by classical let S := Finset.univ.filter (fun α : Finset ι => fourierCoeff f α ≠ 0) have hpair_second := fourierSupp_pair_second f have hplane_closed := affinePlane_closed (ι := ι) have hnot2 : S.card ≠ 2 := by intro h2 obtain ⟨a, b, hab, hSeq⟩ := Finset.card_eq_two.mp h2 have haS : a ∈ S := hSeq ▸ by simp have hbS : b ∈ S := hSeq ▸ by simp obtain ⟨c, hcS, hca, hcb, _⟩ := hpair_second a haS b hbS hab have hcS' : c ∈ S := hcS rw [hSeq] at hcS' simp only [Finset.mem_insert, Finset.mem_singleton] at hcS' rcases hcS' with rfl | rfl · exact hca rfl · exact hcb rfl have hnot3 : S.card ≠ 3 := by intro h3 obtain ⟨a, haS, b, hbS, hab⟩ := Finset.one_lt_card.mp (by omega : 1 < S.card) obtain ⟨c, hcS, hca, hcb, hdS⟩ := hpair_second a haS b hbS hab let d := symmDiff c (symmDiff a b) have hda : d ≠ a := sd_ne_a hcb have hdb : d ≠ b := sd_ne_b hca have hdc : d ≠ c := sd_ne_c hab have hsub : ({a, b, c, d} : Finset (Finset ι)) ⊆ S := by intro x hx; simp only [Finset.mem_insert, Finset.mem_singleton] at hx rcases hx with rfl | rfl | rfl | rfl <;> assumption have hcard4 : ({a, b, c, d} : Finset (Finset ι)).card = 4 := by rw [Finset.card_insert_of_notMem (by simp [hab, hca.symm, hda.symm]), Finset.card_insert_of_notMem (by simp [hcb.symm, hdb.symm]), Finset.card_insert_of_notMem (by simp [hdc.symm]), Finset.card_singleton] have hle := Finset.card_le_card hsub omega have hnot5 : S.card ≠ 5 := by intro h5 obtain ⟨a, haS, b, hbS, hab⟩ := Finset.one_lt_card.mp (by omega : 1 < S.card) obtain ⟨c, hcS, hca, hcb, hdS⟩ := hpair_second a haS b hbS hab let d := symmDiff c (symmDiff a b) let P : Finset (Finset ι) := {a, b, c, d} have hPsub : P ⊆ S := by intro x hx; simp only [P, Finset.mem_insert, Finset.mem_singleton] at hx rcases hx with rfl | rfl | rfl | rfl <;> assumption have hPcard4 : P.card = 4 := by have hda : d ≠ a := sd_ne_a hcb have hdb : d ≠ b := sd_ne_b hca have hdc : d ≠ c := sd_ne_c hab rw [Finset.card_insert_of_notMem (by simp [hab, hca.symm, hda.symm]), Finset.card_insert_of_notMem (by simp [hcb.symm, hdb.symm]), Finset.card_insert_of_notMem (by simp [hdc.symm]), Finset.card_singleton] have hex_e : ∃ e ∈ S, e ∉ P := by by_contra hall; push Not at hall have := Finset.card_le_card (s := S) (t := P) hall; omega obtain ⟨e, heS, heP⟩ := hex_e have hea : e ≠ a := fun h => heP (h ▸ by simp [P]) obtain ⟨u, huS, hue, hua, hvS⟩ := hpair_second e heS a haS hea let v := symmDiff u (symmDiff e a) have hSP : S \ P = {e} := by have hcard1 : (S \ P).card = 1 := by rw [Finset.card_sdiff, Finset.inter_eq_left.mpr hPsub, h5, hPcard4] obtain ⟨w, hw⟩ := Finset.card_eq_one.mp hcard1 have he_mem : e ∈ ({w} : Finset _) := hw ▸ Finset.mem_sdiff.mpr ⟨heS, heP⟩ rw [← Finset.mem_singleton.mp he_mem] at hw exact hw have huP : u ∈ P := by by_contra hnu have : u ∈ ({e} : Finset _) := hSP ▸ Finset.mem_sdiff.mpr ⟨huS, hnu⟩ exact hue (Finset.mem_singleton.mp this) have hve : v ≠ e := sd_ne_a hua have hvP : v ∈ P := by by_contra hnv have : v ∈ ({e} : Finset _) := hSP ▸ Finset.mem_sdiff.mpr ⟨hvS, hnv⟩ exact hve (Finset.mem_singleton.mp this) have he_eq : e = symmDiff u (symmDiff v a) := sd_rearrange u e a exact heP (he_eq ▸ hplane_closed a b c u huP v hvP a (by simp)) intro hmem simp only [Finset.mem_insert, Finset.mem_singleton] at hmem rcases hmem with h | h | h | h | h · exact hnot2 h · exact hnot3 h · exact hnot5 h · exact fourierSparsity_ne_six f h · exact fourierSparsity_ne_seven f h /-! ### Theorem 3C: Zhang–Shi Affine-Certificate Parity Decision Tree Bound (`D_⊕(f) ≤ C₀^⊕(f) · C₁^⊕(f)`) -/ omit [Fintype ι] in /-- Helper: `𝔽₂`-linear algebra lemma for disjoint affine subspaces! If `A, B : Finset (Finset ι)` and `rA, rB : Finset ι → ZMod 2` satisfy that NO `z : ι → Bool` simultaneously solves `∀ α ∈ A, parityVal α z = rA α` and `∀ β ∈ B, parityVal β z = rB β`, then there exist `S ⊆ A` and `T ⊆ B` with `symmDiff-sum S = symmDiff-sum T` and `∑_{α ∈ S} rA α ≠ ∑_{β ∈ T} rB β`. *(Proved cleanly via linear maps over `ZMod 2`: `b ∉ range L → ∃ w ∈ ker Lᵀ, ⟨w, b⟩ ≠ 0`!)* -/ lemma disjoint_affine_subspaces_witness {A B : Finset (Finset ι)} {rA rB : Finset ι → ZMod 2} (hdisj : ∀ z : ι → Bool, ¬ ((∀ α ∈ A, parityVal α z = rA α) ∧ (∀ β ∈ B, parityVal β z = rB β))) : ∃ (S : Finset (Finset ι)) (T : Finset (Finset ι)), S ⊆ A ∧ T ⊆ B ∧ (∀ z : ι → Bool, (∑ α ∈ S, parityVal α z) + (∑ β ∈ T, parityVal β z) = 0) ∧ (∑ α ∈ S, rA α) + (∑ β ∈ T, rB β) ≠ 0 := by classical -- Form the `ZMod 2`-linear map `L : (ι → ZMod 2) →ₗ[ZMod 2] (A ⊕ B → ZMod 2)`! let L : (ι → ZMod 2) →ₗ[ZMod 2] ({α // α ∈ A} ⊕ {β // β ∈ B} → ZMod 2) := { toFun := fun v s => match s with | Sum.inl α => ∑ i ∈ α.1, v i | Sum.inr β => ∑ i ∈ β.1, v i map_add' := fun u v => by ext s; cases s <;> simp [Finset.sum_add_distrib] map_smul' := fun c v => by ext s; cases s <;> simp [Finset.mul_sum] } let rhs : {α // α ∈ A} ⊕ {β // β ∈ B} → ZMod 2 := fun s => match s with | Sum.inl α => rA α.1 | Sum.inr β => rB β.1 have hrhs_nmem : rhs ∉ LinearMap.range L := by rintro ⟨v, hv⟩ let z : ι → Bool := fun i => decide (v i = 1) have hzv : ∀ i, boolToZ2 (z i) = v i := fun i => by rcases zmod2_cases (v i) with h | h <;> simp [z, boolToZ2, h] apply hdisj z refine ⟨fun α hα => ?_, fun β hβ => ?_⟩ · have h1 := congrFun hv (Sum.inl ⟨α, hα⟩) simp only [L, rhs, LinearMap.coe_mk, AddHom.coe_mk] at h1 simpa [parityVal, hzv] using h1 · have h1 := congrFun hv (Sum.inr ⟨β, hβ⟩) simp only [L, rhs, LinearMap.coe_mk, AddHom.coe_mk] at h1 simpa [parityVal, hzv] using h1 -- Over a field (`ZMod 2`), any `rhs ∉ range L` is separated by a linear functional -- `φ : (A ⊕ B → ZMod 2) →ₗ[ZMod 2] ZMod 2` vanishing on `range L` with `φ rhs ≠ 0`! obtain ⟨φ, hφ_rhs, hφ_ker⟩ := Submodule.exists_le_ker_of_notMem hrhs_nmem -- Represent `φ` by its coordinates `w s := φ (Pi.single s 1)`! let S : Finset (Finset ι) := A.filter (fun α => if h : α ∈ A then φ (Pi.single (Sum.inl ⟨α, h⟩) 1) = 1 else False) let T : Finset (Finset ι) := B.filter (fun β => if h : β ∈ B then φ (Pi.single (Sum.inr ⟨β, h⟩) 1) = 1 else False) have hφ_eval : ∀ u : {α // α ∈ A} ⊕ {β // β ∈ B} → ZMod 2, φ u = (∑ α ∈ S, if h : α ∈ A then u (Sum.inl ⟨α, h⟩) else 0) + (∑ β ∈ T, if h : β ∈ B then u (Sum.inr ⟨β, h⟩) else 0) := by intro u have hu : u = ∑ s : {α // α ∈ A} ⊕ {β // β ∈ B}, u s • Pi.single s (1 : ZMod 2) := by ext t; simp [Finset.sum_apply, Pi.single_apply] conv_lhs => rw [hu, map_sum] simp_rw [map_smul, smul_eq_mul] rw [Fintype.sum_sum_type] congr 1 · symm calc ∑ α ∈ S, (if h : α ∈ A then u (Sum.inl ⟨α, h⟩) else 0) = ∑ α ∈ A, (if (if h : α ∈ A then φ (Pi.single (Sum.inl ⟨α, h⟩) 1) = 1 else False) then (if h : α ∈ A then u (Sum.inl ⟨α, h⟩) else 0) else 0) := Finset.sum_filter _ _ _ = ∑ x : {α // α ∈ A}, u (Sum.inl x) * φ (Pi.single (Sum.inl x) 1) := by rw [← Finset.sum_attach A] apply Finset.sum_congr rfl intro ⟨α, hα⟩ _ simp only [hα, ↓reduceDIte] rcases zmod2_cases (φ (Pi.single (Sum.inl ⟨α, hα⟩) 1)) with hw | hw <;> simp [hw] · symm calc ∑ β ∈ T, (if h : β ∈ B then u (Sum.inr ⟨β, h⟩) else 0) = ∑ β ∈ B, (if (if h : β ∈ B then φ (Pi.single (Sum.inr ⟨β, h⟩) 1) = 1 else False) then (if h : β ∈ B then u (Sum.inr ⟨β, h⟩) else 0) else 0) := Finset.sum_filter _ _ _ = ∑ y : {β // β ∈ B}, u (Sum.inr y) * φ (Pi.single (Sum.inr y) 1) := by rw [← Finset.sum_attach B] apply Finset.sum_congr rfl intro ⟨β, hβ⟩ _ simp only [hβ, ↓reduceDIte] rcases zmod2_cases (φ (Pi.single (Sum.inr ⟨β, hβ⟩) 1)) with hw | hw <;> simp [hw] refine ⟨S, T, Finset.filter_subset _ _, Finset.filter_subset _ _, ?_, ?_⟩ · intro z have h0 : φ (L (fun i => boolToZ2 (z i))) = 0 := LinearMap.mem_ker.mp (hφ_ker (LinearMap.mem_range_self L _)) rw [hφ_eval] at h0 have hS : (∑ α ∈ S, if h : α ∈ A then L (fun i => boolToZ2 (z i)) (Sum.inl ⟨α, h⟩) else 0) = ∑ α ∈ S, parityVal α z := by apply Finset.sum_congr rfl intro α hα have hαA : α ∈ A := (Finset.mem_filter.mp hα).1 simp [hαA, L, parityVal] have hT : (∑ β ∈ T, if h : β ∈ B then L (fun i => boolToZ2 (z i)) (Sum.inr ⟨β, h⟩) else 0) = ∑ β ∈ T, parityVal β z := by apply Finset.sum_congr rfl intro β hβ have hβB : β ∈ B := (Finset.mem_filter.mp hβ).1 simp [hβB, L, parityVal] rw [← hS, ← hT]; exact h0 · rw [hφ_eval rhs] at hφ_rhs have hS : (∑ α ∈ S, if h : α ∈ A then rhs (Sum.inl ⟨α, h⟩) else 0) = ∑ α ∈ S, rA α := by apply Finset.sum_congr rfl; intro α hα have hαA : α ∈ A := (Finset.mem_filter.mp hα).1 simp [hαA, rhs] have hT : (∑ β ∈ T, if h : β ∈ B then rhs (Sum.inr ⟨β, h⟩) else 0) = ∑ β ∈ T, rB β := by apply Finset.sum_congr rfl; intro β hβ have hβB : β ∈ B := (Finset.mem_filter.mp hβ).1 simp [hβB, rhs] rw [← hS, ← hT]; exact hφ_rhs /-- Parity decision tree querying a list of parities `L`, then running `cont` on the outcome vector. -/ def ParityDecTree.queryList : List (Finset ι) → ((Finset ι → ZMod 2) → ParityDecTree ι) → (Finset ι → ZMod 2) → ParityDecTree ι | [], cont, r => cont r | α :: L, cont, r => .branch α (ParityDecTree.queryList L cont (fun β => if β = α then 0 else r β)) (ParityDecTree.queryList L cont (fun β => if β = α then 1 else r β)) omit [Fintype ι] in lemma ParityDecTree.queryList_depth (L : List (Finset ι)) (cont : (Finset ι → ZMod 2) → ParityDecTree ι) (r : Finset ι → ZMod 2) (d : ℕ) (hcont : ∀ σ, (cont σ).depth ≤ d) : (ParityDecTree.queryList L cont r).depth ≤ L.length + d := by induction L generalizing r with | nil => simpa [ParityDecTree.queryList] using hcont r | cons α L ih => simp only [ParityDecTree.queryList, ParityDecTree.depth, List.length_cons] have h0 := ih (fun β => if β = α then 0 else r β) have h1 := ih (fun β => if β = α then 1 else r β) omega omit [Fintype ι] in lemma ParityDecTree.queryList_eval (L : List (Finset ι)) (cont : (Finset ι → ZMod 2) → ParityDecTree ι) (r : Finset ι → ZMod 2) (x : ι → Bool) : (ParityDecTree.queryList L cont r).eval x = (cont (fun β => if β ∈ L then parityVal β x else r β)).eval x := by induction L generalizing r with | nil => simp [ParityDecTree.queryList] | cons α L ih => simp only [ParityDecTree.queryList, ParityDecTree.eval] split_ifs with h0 · rw [ih] have hfun : (fun β => if β ∈ L then parityVal β x else if β = α then 0 else r β) = (fun β => if β ∈ α :: L then parityVal β x else r β) := by ext β by_cases hL : β ∈ L · simp [hL] · by_cases hβα : β = α · subst hβα; simp [hL, h0] · simp [hL, hβα] rw [hfun] · have h1 : parityVal α x = 1 := by rcases zmod2_cases (parityVal α x) with hv | hv <;> simp_all rw [ih] have hfun : (fun β => if β ∈ L then parityVal β x else if β = α then 1 else r β) = (fun β => if β ∈ α :: L then parityVal β x else r β) := by ext β by_cases hL : β ∈ L · simp [hL] · by_cases hβα : β = α · subst hβα; simp [hL, h1] · simp [hL, hβα] rw [hfun] /-- Auxiliary affine-subspace-restricted Zhang–Shi induction: on any affine subspace `H = {x | ∀ α ∈ Q, parityVal α x = r α}`, if every `0`-input in `H` has a `0`-parity-certificate relative to `H` of size `≤ k₀` and every `1`-input in `H` has a `1`-parity-certificate relative to `H` of size `≤ k₁`, then there exists a parity decision tree of depth `≤ k₀ * k₁` agreeing with `f` on `H`. -/ lemma parityDepthOn_le_mul (f : (ι → Bool) → Bool) (k₀ k₁ : ℕ) : ∀ (Q : Finset (Finset ι)) (r : Finset ι → ZMod 2), (∀ x : ι → Bool, (∀ α ∈ Q, parityVal α x = r α) → f x = false → ∃ A : Finset (Finset ι), A.card ≤ k₀ ∧ ∀ y, (∀ α ∈ Q, parityVal α y = r α) → (∀ β ∈ A, parityVal β y = parityVal β x) → f y = false) → (∀ x : ι → Bool, (∀ α ∈ Q, parityVal α x = r α) → f x = true → ∃ B : Finset (Finset ι), B.card ≤ k₁ ∧ ∀ y, (∀ α ∈ Q, parityVal α y = r α) → (∀ β ∈ B, parityVal β y = parityVal β x) → f y = true) → ∃ t : ParityDecTree ι, t.depth ≤ k₀ * k₁ ∧ ∀ x : ι → Bool, (∀ α ∈ Q, parityVal α x = r α) → t.eval x = f x := by induction k₀ with | zero => intro Q r h0 _ by_cases hex0 : ∃ x : ι → Bool, (∀ α ∈ Q, parityVal α x = r α) ∧ f x = false · obtain ⟨x, hxQ, hfx⟩ := hex0 obtain ⟨A, hA0, hAcert⟩ := h0 x hxQ hfx have hAemp : A = ∅ := Finset.card_eq_zero.mp (Nat.le_zero.mp hA0) refine ⟨.leaf false, by simp [ParityDecTree.depth], fun y hyQ => ?_⟩ exact (hAcert y hyQ (by simp [hAemp])).symm · push Not at hex0 refine ⟨.leaf true, by simp [ParityDecTree.depth], fun y hyQ => ?_⟩ have hne := hex0 y hyQ cases h : f y <;> simp_all [ParityDecTree.eval] | succ k₀ ih => intro Q r h0 h1 by_cases hex1 : ∃ x₁ : ι → Bool, (∀ α ∈ Q, parityVal α x₁ = r α) ∧ f x₁ = true · obtain ⟨x₁, hx₁Q, hfx₁⟩ := hex1 obtain ⟨B, hBcard, hBcert⟩ := h1 x₁ hx₁Q hfx₁ -- For every outcome `σ : Finset ι → ZMod 2` on `B`, define `Q' = Q ∪ B`, `r' = fun α => if α ∈ B then σ α else r α`! -- Actually, if `σ` disagrees with `r` on `Q ∩ B`, then the subspace `H'` is EMPTY (any leaf works!). -- Otherwise `H' = {y ∈ H | ∀ β ∈ B, parityVal β y = σ β}`! have hbranch : ∀ σ : Finset ι → ZMod 2, ∃ t : ParityDecTree ι, t.depth ≤ k₀ * k₁ ∧ ∀ y : ι → Bool, (∀ α ∈ Q, parityVal α y = r α) → (∀ β ∈ B, parityVal β y = σ β) → t.eval y = f y := by intro σ by_cases hagree : ∀ β ∈ B, σ β = parityVal β x₁ · refine ⟨.leaf true, Nat.zero_le _, fun y hyQ hyB => ?_⟩ exact (hBcert y hyQ fun β hβ => (hyB β hβ).trans (hagree β hβ)).symm · -- `σ` disagrees with `x₁` on `B`: on `H'`, every `0`-certificate shrinks by at least `1`! -- Check if `H'` is nonempty; if empty, `.leaf false` works trivially! by_cases hHne : ∃ z₀ : ι → Bool, (∀ α ∈ Q, parityVal α z₀ = r α) ∧ (∀ β ∈ B, parityVal β z₀ = σ β) · obtain ⟨z₀, hz₀Q, hz₀B⟩ := hHne let Q' := Q ∪ B let r' : Finset ι → ZMod 2 := fun α => if α ∈ Q then r α else σ α have hr'_eq : ∀ y : ι → Bool, (∀ α ∈ Q', parityVal α y = r' α) ↔ ((∀ α ∈ Q, parityVal α y = r α) ∧ (∀ β ∈ B, parityVal β y = σ β)) := by intro y constructor · intro hy refine ⟨fun α hα => ?_, fun β hβ => ?_⟩ · simpa [r', hα] using hy α (Finset.mem_union_left B hα) · by_cases hβQ : β ∈ Q · have h1 := hy β (Finset.mem_union_left B hβQ) simp only [r', hβQ, ↓reduceIte] at h1 have h2 := hz₀Q β hβQ have h3 := hz₀B β hβ rw [h1, ← h2, h3] · simpa [r', hβQ] using hy β (Finset.mem_union_right Q hβ) · rintro ⟨hyQ, hyB⟩ α hα rcases Finset.mem_union.mp hα with hαQ | hαB · simp [r', hαQ, hyQ α hαQ] · by_cases hαQ : α ∈ Q · simp [r', hαQ, hyQ α hαQ] · simp [r', hαQ, hyB α hαB] -- Verify `h0'` with bound `k₀` on `(Q', r')`! have h0' : ∀ x : ι → Bool, (∀ α ∈ Q', parityVal α x = r' α) → f x = false → ∃ A' : Finset (Finset ι), A'.card ≤ k₀ ∧ ∀ y, (∀ α ∈ Q', parityVal α y = r' α) → (∀ β ∈ A', parityVal β y = parityVal β x) → f y = false := by intro x hxQ' hfx obtain ⟨hxQ, hxB⟩ := (hr'_eq x).mp hxQ' obtain ⟨A, hAcard, hAcert⟩ := h0 x hxQ hfx -- The affine subspaces `{z | ∀ α ∈ Q ∪ B, parityVal α z = parityVal α x₁}` -- and `{z | ∀ β ∈ A, parityVal β z = parityVal β x}` are DISJOINT! have hdisj : ∀ z : ι → Bool, ¬ ((∀ α ∈ Q ∪ B, parityVal α z = parityVal α x₁) ∧ (∀ β ∈ A, parityVal β z = parityVal β x)) := by rintro z ⟨hzQB, hzA⟩ have hzQ : ∀ α ∈ Q, parityVal α z = r α := fun α hα => (hzQB α (Finset.mem_union_left B hα)).trans (hx₁Q α hα) have hzB : ∀ β ∈ B, parityVal β z = parityVal β x₁ := fun β hβ => hzQB β (Finset.mem_union_right Q hβ) have hft : f z = true := hBcert z hzQ hzB have hff : f z = false := hAcert z hzQ hzA rw [hft] at hff; exact Bool.noConfusion hff obtain ⟨S, T, hSQB, hTA, hsum_zero, hsum_ne⟩ := disjoint_affine_subspaces_witness (A := Q ∪ B) (B := A) (rA := fun α => parityVal α x₁) (rB := fun β => parityVal β x) hdisj -- `T` MUST BE NONEMPTY! (Otherwise `∑_{α ∈ S} parityVal α z = 0` for all `z`, -- including `z = x₁`, contradicting `∑_{α ∈ S} parityVal α x₁ ≠ 0`!) have hTne : T.Nonempty := by by_contra hemp rw [Finset.not_nonempty_iff_eq_empty] at hemp subst hemp have h1 := hsum_zero x₁ simp at h1 hsum_ne exact hsum_ne h1 obtain ⟨β₀, hβ₀T⟩ := hTne have hβ₀A : β₀ ∈ A := hTA hβ₀T refine ⟨A.erase β₀, ?_, ?_⟩ · have := Finset.card_erase_add_one hβ₀A; omega · intro y hyQ' hyA' obtain ⟨hyQ, hyB⟩ := (hr'_eq y).mp hyQ' apply hAcert y hyQ intro β hβA by_cases hβ : β = β₀ · rw [hβ] -- `parityVal β₀ z` is an `𝔽₂`-linear combination of `S ⊆ Q ∪ B` and `T.erase β₀ ⊆ A.erase β₀`! have hzy := hsum_zero y have hzx := hsum_zero x have hS_eq : ∑ α ∈ S, parityVal α y = ∑ α ∈ S, parityVal α x := by apply Finset.sum_congr rfl intro α hαS rcases Finset.mem_union.mp (hSQB hαS) with hαQ | hαB · rw [hyQ α hαQ, hxQ α hαQ] · rw [hyB α hαB, hxB α hαB] have hT_rest : ∑ γ ∈ T.erase β₀, parityVal γ y = ∑ γ ∈ T.erase β₀, parityVal γ x := by apply Finset.sum_congr rfl intro γ hγ exact hyA' γ (Finset.mem_erase.mpr ⟨Finset.ne_of_mem_erase hγ, hTA (Finset.mem_of_mem_erase hγ)⟩) rw [← Finset.add_sum_erase _ _ hβ₀T] at hzy hzx -- Both `a + b + c = 0` and `a + b' + c = 0` in `ZMod 2` force `b = b'`! have hadd : parityVal β₀ y + ((∑ α ∈ S, parityVal α y) + ∑ γ ∈ T.erase β₀, parityVal γ y) = parityVal β₀ x + ((∑ α ∈ S, parityVal α x) + ∑ γ ∈ T.erase β₀, parityVal γ x) := by calc parityVal β₀ y + ((∑ α ∈ S, parityVal α y) + ∑ γ ∈ T.erase β₀, parityVal γ y) = (∑ α ∈ S, parityVal α y) + (parityVal β₀ y + ∑ γ ∈ T.erase β₀, parityVal γ y) := by ring _ = 0 := hzy _ = (∑ α ∈ S, parityVal α x) + (parityVal β₀ x + ∑ γ ∈ T.erase β₀, parityVal γ x) := hzx.symm _ = parityVal β₀ x + ((∑ α ∈ S, parityVal α x) + ∑ γ ∈ T.erase β₀, parityVal γ x) := by ring rw [hS_eq, hT_rest] at hadd exact add_right_cancel hadd · exact hyA' β (Finset.mem_erase.mpr ⟨hβ, hβA⟩) have h1' : ∀ x : ι → Bool, (∀ α ∈ Q', parityVal α x = r' α) → f x = true → ∃ B' : Finset (Finset ι), B'.card ≤ k₁ ∧ ∀ y, (∀ α ∈ Q', parityVal α y = r' α) → (∀ β ∈ B', parityVal β y = parityVal β x) → f y = true := by intro x hxQ' hfx obtain ⟨hxQ, _⟩ := (hr'_eq x).mp hxQ' obtain ⟨B', hB'card, hB'cert⟩ := h1 x hxQ hfx exact ⟨B', hB'card, fun y hyQ' hyB' => hB'cert y ((hr'_eq y).mp hyQ').1 hyB'⟩ obtain ⟨t, ht_depth, ht_eval⟩ := ih Q' r' h0' h1' exact ⟨t, ht_depth, fun y hyQ hyB => ht_eval y ((hr'_eq y).mpr ⟨hyQ, hyB⟩)⟩ · push Not at hHne exact ⟨.leaf false, Nat.zero_le _, fun y hyQ hyB => by obtain ⟨β, hβ, hne⟩ := hHne y hyQ exact absurd (hyB β hβ) hne⟩ choose cont hcont_depth hcont_eval using hbranch let L := B.toList let T := ParityDecTree.queryList L cont (fun _ => 0) refine ⟨T, ?_, ?_⟩ · calc T.depth ≤ L.length + k₀ * k₁ := ParityDecTree.queryList_depth L cont _ _ hcont_depth _ = B.card + k₀ * k₁ := by rw [Finset.length_toList] _ ≤ k₁ + k₀ * k₁ := Nat.add_le_add_right hBcard _ _ = (k₀ + 1) * k₁ := by ring · intro x hxQ rw [ParityDecTree.queryList_eval] apply hcont_eval _ x hxQ intro β hβ have hβL : β ∈ L := Finset.mem_toList.mpr hβ simp [hβL] · push Not at hex1 refine ⟨.leaf false, Nat.zero_le _, fun y hyQ => ?_⟩ have hne := hex1 y hyQ cases h : f y <;> simp_all [ParityDecTree.eval] /-- **Theorem 3C (Zhang–Shi 2010 Affine-Certificate Parity Decision Tree Bound)**: For every Boolean function `f : (ι → Bool) → Bool`, `D_⊕(f) ≤ C₀^⊕(f) · C₁^⊕(f)`. -/ theorem parityDepth_le_parityCert0_mul_parityCert1 (f : (ι → Bool) → Bool) : parityDepth f ≤ parityCertSide f false * parityCertSide f true := by obtain ⟨t, ht_depth, ht_eval⟩ := parityDepthOn_le_mul f (parityCertSide f false) (parityCertSide f true) ∅ (fun _ => 0) (fun x _ hfx => by obtain ⟨A, hA, hAc⟩ := exists_isParityCert_eq_parityCertAt f x exact ⟨A, hAc.symm ▸ (hfx ▸ Finset.le_sup (f := parityCertAt f) (by simp)), fun y _ hy => by rw [hA y hy, hfx]⟩) (fun x _ hfx => by obtain ⟨B, hB, hBc⟩ := exists_isParityCert_eq_parityCertAt f x exact ⟨B, hBc.symm ▸ (hfx ▸ Finset.le_sup (f := parityCertAt f) (by simp)), fun y _ hy => by rw [hB y hy, hfx]⟩) exact (parityDepth_le_of_tree (fun x => ht_eval x (by simp))).trans ht_depth end Pillar3 /-! ## Pillar 4: Exact Infinite-Family Sharpness, Separations, and Extremal Witnesses We construct and formally evaluate six explicit Boolean function families proving simultaneous non-asymptotic sharpness of every headline inequality across Pillars 1–3: 1. **`PARITY_n`** (`parityFun n`, all `n ≥ 1`): exact sharpness of `D ≤ deg₂ · min(bs₀, bs₁)` and unbounded `D / D_⊕ = n` separation. 2. **`AND_a ∘ OR_b`** (`andOr a b`, all `a, b ≥ 1`): simultaneous all-`(a, b)` sharpness of `D ≤ C₁·bs₀`, `D ≤ C₀·bs₁`, `D ≤ C₀·C₁`, `deg₂ ≤ D_⊕`, and `D_⊕ ≤ C₀^⊕·C₁^⊕`. 3. **`IP_{2m}`** (`innerProd m`, all `m ≥ 1`): simultaneous all-`m` sharpness of `D_⊕ ≥ gran + 1`, `L₁ ≤ 2^(D_⊕ - 1)`, and `‖f̂‖₀ ≤ 4^(D_⊕ - 1)` with `D = 2m`, `D_⊕ = m + 1`, `deg₂ = 2`. 4. **`AND_n`** (`andFun n`, all `n ≥ 2`): exact spectral norm `L₁ = 3 - 4/2^n` and exact all-`n` attainment of the signed-collision drop `L₁(f̂_{γ,1}) = L₁(f̂) - 2 M₂` (Theorem 3D). 5. **`Rubinstein(k, m)`** (`rubinstein k m`, all `k, m ≥ 1`): exact `s₀ = k`, `s₁ = 2m`, `bs₀ ≥ km`, `C₀ ≥ km`, giving the quadratic separation `bs, C ≥ s² / 2` at `k = 2m`. 6. **`MAJ_3`** (`maj3`): exact witness for `(s, bs, C, D, D_⊕, L₁, ‖f̂‖₀) = (2, 2, 2, 3, 2, 2, 4)`, attaining Theorem 2F (`C₀ = 2 = 2 bs₀ - 2`), Theorem 2C (`D = 3 < 4 = C₀ C₁`), and Theorem 3E (`L₁ = 2 ↔ ‖f̂‖₀ = 4`). -/ section Pillar4 private lemma detDepth_le_card {ι : Type*} [DecidableEq ι] [Fintype ι] (f : (ι → Bool) → Bool) : detDepth f ≤ Fintype.card ι := by have h := detDepth_le_card_add_sup_restrict f Finset.univ 0 (fun ρ => by rw [detDepth_eq_zero_of_const (c := f ρ) (fun x => by simp [restrict])]) simpa using h private lemma le_sensSide_of_val {ι : Type*} [DecidableEq ι] [Fintype ι] {f : (ι → Bool) → Bool} {x : ι → Bool} {b : Bool} (hx : f x = b) : sensAt f x ≤ sensSide f b := by rw [← hx]; exact sensAt_le_sensSide f x private lemma le_blockSensSide_of_val {ι : Type*} [DecidableEq ι] [Fintype ι] {f : (ι → Bool) → Bool} {x : ι → Bool} {b : Bool} (hx : f x = b) : blockSensAt f x ≤ blockSensSide f b := by rw [← hx]; exact blockSensAt_le_blockSensSide f x /-! ### Family 1: `PARITY_n` (All-`n` sharpness of `D ≤ deg₂ · min(bs₀, bs₁)` & `D / D_⊕ = n`) -/ /-- `n`-bit parity function `PARITY_n(x) = x₀ ⊕ ⋯ ⊕ x_{n-1}`. -/ def parityFun (n : ℕ) (x : Fin n → Bool) : Bool := decide (parityVal (Finset.univ : Finset (Fin n)) x = 1) lemma parityFun_flipBit (n : ℕ) (x : Fin n → Bool) (i : Fin n) : parityFun n (flipBit x i) = !(parityFun n x) := by unfold parityFun have hdiff : parityVal (Finset.univ : Finset (Fin n)) (flipBit x i) = parityVal (Finset.univ : Finset (Fin n)) x + 1 := by unfold parityVal rw [← Finset.add_sum_erase _ _ (Finset.mem_univ i), ← Finset.add_sum_erase _ _ (Finset.mem_univ i)] have hrest : ∑ j ∈ Finset.univ.erase i, boolToZ2 (flipBit x i j) = ∑ j ∈ Finset.univ.erase i, boolToZ2 (x j) := Finset.sum_congr rfl fun j hj => by simp [flipBit, Finset.ne_of_mem_erase hj] rw [hrest] have hfl : boolToZ2 (flipBit x i i) = boolToZ2 (x i) + 1 := by cases h : x i <;> simp [flipBit, boolToZ2, h] rw [hfl]; ring rw [hdiff] rcases zmod2_cases (parityVal (Finset.univ : Finset (Fin n)) x) with h | h <;> simp [h] lemma boolSign_parityFun (n : ℕ) (x : Fin n → Bool) : boolSign (parityFun n x) = walshChar (Finset.univ : Finset (Fin n)) x := by rw [walshChar_eq_parityVal] unfold parityFun rcases zmod2_cases (parityVal (Finset.univ : Finset (Fin n)) x) with h | h <;> simp [boolSign, h] /-- **Theorem 4A (Exact Invariants of `PARITY_n`)**: For every `n ≥ 1`, `PARITY_n` achieves: `s₀ = s₁ = bs₀ = bs₁ = C₀ = C₁ = D = n`, `deg₂ = D_⊕ = 1`, `L₁ = 1`, `‖f̂‖₀ = 1`, giving all-`n` sharpness of Theorem 1B (`D = deg₂ · min(bs₀, bs₁)`) and unbounded `D / D_⊕ = n`. -/ theorem parityFun_exact_invariants {n : ℕ} (hn : 1 ≤ n) : sensSide (parityFun n) false = n ∧ sensSide (parityFun n) true = n ∧ blockSensSide (parityFun n) false = n ∧ blockSensSide (parityFun n) true = n ∧ certSide (parityFun n) false = n ∧ certSide (parityFun n) true = n ∧ detDepth (parityFun n) = n ∧ deg2 (parityFun n) = 1 ∧ parityDepth (parityFun n) = 1 ∧ spectralNorm (parityFun n) = 1 ∧ fourierSparsity (parityFun n) = 1 := by have hsensAt : ∀ x : Fin n → Bool, sensAt (parityFun n) x = n := by intro x have hset : sensSet (parityFun n) x = Finset.univ := by ext i simp only [sensSet, Finset.mem_filter, Finset.mem_univ, true_and, parityFun_flipBit] cases parityFun n x <;> decide unfold sensAt rw [hset, Finset.card_univ, Fintype.card_fin] have hx0 : parityFun n (fun _ => false) = false := by simp [parityFun, parityVal, boolToZ2] have hx1 : parityFun n (flipBit (fun _ => false) ⟨0, by omega⟩) = true := by rw [parityFun_flipBit, hx0]; rfl have hs0 : sensSide (parityFun n) false = n := by apply le_antisymm · exact (sensSide_le_blockSensSide _ _).trans ((blockSensSide_le_certSide _ _).trans ((certSide_le_detDepth _ _).trans ((detDepth_le_card _).trans (by simp)))) · have := le_sensSide_of_val (f := parityFun n) (x := fun _ => false) (b := false) hx0 rwa [hsensAt] at this have hs1 : sensSide (parityFun n) true = n := by apply le_antisymm · exact (sensSide_le_blockSensSide _ _).trans ((blockSensSide_le_certSide _ _).trans ((certSide_le_detDepth _ _).trans ((detDepth_le_card _).trans (by simp)))) · have := le_sensSide_of_val (f := parityFun n) (x := flipBit (fun _ => false) ⟨0, by omega⟩) (b := true) hx1 rwa [hsensAt] at this have hD_le : detDepth (parityFun n) ≤ n := (detDepth_le_card _).trans (by simp) have hbs0 : blockSensSide (parityFun n) false = n := by have h1 := hierarchy_chain (parityFun n) false; omega have hbs1 : blockSensSide (parityFun n) true = n := by have h1 := hierarchy_chain (parityFun n) true; omega have hc0 : certSide (parityFun n) false = n := by have h1 := hierarchy_chain (parityFun n) false; omega have hc1 : certSide (parityFun n) true = n := by have h1 := hierarchy_chain (parityFun n) true; omega have hD : detDepth (parityFun n) = n := by have h1 := hierarchy_chain (parityFun n) false; omega have hdeg2 : deg2 (parityFun n) = 1 := by let c : Finset (Fin n) → ZMod 2 := fun S => if S.card = 1 then 1 else 0 have hc_eval : ∀ x : Fin n → Bool, boolToZ2 (parityFun n x) = ∑ S ∈ (inputSupp x).powerset, c S := by intro x have h1 : boolToZ2 (parityFun n x) = parityVal (Finset.univ : Finset (Fin n)) x := by unfold parityFun rcases zmod2_cases (parityVal (Finset.univ : Finset (Fin n)) x) with hv | hv <;> simp [boolToZ2, hv] rw [h1] have h2 : parityVal (Finset.univ : Finset (Fin n)) x = ∑ i ∈ inputSupp x, (1 : ZMod 2) := by unfold parityVal rw [← Finset.sum_filter_add_sum_filter_not Finset.univ (fun i => x i = true)] have hz : ∑ i ∈ Finset.univ.filter (fun i => ¬ x i = true), boolToZ2 (x i) = 0 := Finset.sum_eq_zero fun i hi => by have := (Finset.mem_filter.mp hi).2 cases h : x i <;> simp_all [boolToZ2] rw [hz, add_zero] apply Finset.sum_congr rfl intro i hi have := (Finset.mem_filter.mp hi).2 simp [boolToZ2, this] rw [h2] have h3 : ∑ S ∈ (inputSupp x).powerset, c S = ∑ S ∈ (inputSupp x).powerset.filter (fun S => S.card = 1), (1 : ZMod 2) := by rw [Finset.sum_filter] rw [h3] apply Finset.sum_bij (fun i _ => ({i} : Finset (Fin n))) · intro i hi simp only [Finset.mem_filter, Finset.mem_powerset, Finset.singleton_subset_iff, Finset.card_singleton] exact ⟨hi, trivial⟩ · intro i₁ _ i₂ _ heq; exact Finset.singleton_injective heq · intro S hS simp only [Finset.mem_filter, Finset.mem_powerset] at hS obtain ⟨i, rfl⟩ := Finset.card_eq_one.mp hS.2 exact ⟨i, Finset.singleton_subset_iff.mp hS.1, rfl⟩ · intro _ _; rfl have hanf : ∀ S, anfCoeff (parityFun n) S = c S := anfCoeff_unique (parityFun n) c hc_eval apply le_antisymm · unfold deg2 apply Finset.sup_le intro S hS have hne := (Finset.mem_filter.mp hS).2 rw [hanf] at hne by_contra hgt have hne1 : S.card ≠ 1 := by omega simp [c, hne1] at hne · have hne : anfCoeff (parityFun n) {⟨0, by omega⟩} ≠ 0 := by rw [hanf]; simp [c] have hle : ({⟨0, by omega⟩} : Finset (Fin n)).card ≤ deg2 (parityFun n) := Finset.le_sup (f := Finset.card) (by simp [hne]) simpa using hle have hDpar : parityDepth (parityFun n) = 1 := by apply le_antisymm · let t : ParityDecTree (Fin n) := .branch Finset.univ (.leaf false) (.leaf true) have heval : ∀ x, t.eval x = parityFun n x := fun x => by simp only [t, ParityDecTree.eval, parityFun] rcases zmod2_cases (parityVal (Finset.univ : Finset (Fin n)) x) with h | h <;> simp [h] exact (parityDepth_le_of_tree heval).trans (by simp [t, ParityDecTree.depth]) · rw [← hdeg2]; exact deg2_le_parityDepth (parityFun n) have hfcoeff : ∀ S : Finset (Fin n), fourierCoeff (parityFun n) S = if S = Finset.univ then 1 else 0 := by intro S unfold fourierCoeff simp_rw [boolSign_parityFun, walshChar_mul, sum_walshChar, symmDiff_eq_empty_finset] by_cases hS : S = Finset.univ · rw [if_pos hS, if_pos hS.symm, ← mul_pow]; norm_num · rw [if_neg hS, if_neg (Ne.symm hS), mul_zero] have hL1 : spectralNorm (parityFun n) = 1 := by unfold spectralNorm simp_rw [hfcoeff] rw [Finset.sum_eq_single Finset.univ (fun S _ hne => by simp [hne]) (fun h => absurd (Finset.mem_univ _) h)] simp have hsp : fourierSparsity (parityFun n) = 1 := by exact (fourierSparsity_eq_one_iff (parityFun n)).mpr ⟨Finset.univ, by simp [hfcoeff]⟩ exact ⟨hs0, hs1, hbs0, hbs1, hc0, hc1, hD, hdeg2, hDpar, hL1, hsp⟩ /-! ### Family 2: `AND_a ∘ OR_b` (All-`(a, b)` Sharpness of `D ≤ C₁bs₀`, `D ≤ C₀bs₁`, `D ≤ C₀C₁`, `deg₂ ≤ D_⊕`, `D_⊕ ≤ C₀^⊕C₁^⊕`) -/ /-- The composed `AND_a ∘ OR_b` Boolean function on `Fin a × Fin b`. -/ def andOr (a b : ℕ) (x : Fin a × Fin b → Bool) : Bool := decide (∀ i : Fin a, ∃ j : Fin b, x (i, j) = true) /-- **Theorem 4B (Simultaneous All-`(a, b)` Sharpness on `AND_a ∘ OR_b`)**: For all `a ≥ 1` and `b ≥ 1`, `f = AND_a ∘ OR_b` satisfies: `s₀ = bs₀ = C₀ = C₀^⊕ = b`, `s₁ = bs₁ = C₁ = C₁^⊕ = a`, and `deg₂ = D_⊕ = D = a · b`. -/ theorem andOr_exact_invariants {a b : ℕ} (ha : 1 ≤ a) (hb : 1 ≤ b) : sensSide (andOr a b) false = b ∧ blockSensSide (andOr a b) false = b ∧ certSide (andOr a b) false = b ∧ parityCertSide (andOr a b) false = b ∧ sensSide (andOr a b) true = a ∧ blockSensSide (andOr a b) true = a ∧ certSide (andOr a b) true = a ∧ parityCertSide (andOr a b) true = a ∧ deg2 (andOr a b) = a * b ∧ parityDepth (andOr a b) = a * b ∧ detDepth (andOr a b) = a * b := by classical -- Step 1: Upper bounds `C₀ ≤ b` and `C₁ ≤ a`. have hC0_le : certSide (andOr a b) false ≤ b := by unfold certSide apply Finset.sup_le intro x hx have hfx : andOr a b x = false := (Finset.mem_filter.mp hx).2 have hrow : ∃ i₀ : Fin a, ∀ j : Fin b, x (i₀, j) = false := by unfold andOr at hfx rw [decide_eq_false_iff_not] at hfx push Not at hfx obtain ⟨i₀, hi₀⟩ := hfx exact ⟨i₀, fun j => by cases h : x (i₀, j) <;> simp_all⟩ obtain ⟨i₀, hi₀⟩ := hrow let S : Finset (Fin a × Fin b) := Finset.univ.image (fun j : Fin b => (i₀, j)) have hScert : IsCert (andOr a b) x S := by intro y hy rw [hfx] unfold andOr rw [decide_eq_false_iff_not] push Not refine ⟨i₀, fun j => ?_⟩ have hmem : (i₀, j) ∈ S := Finset.mem_image.mpr ⟨j, Finset.mem_univ j, rfl⟩ rw [hy (i₀, j) hmem, hi₀ j] decide have hcard : S.card ≤ b := (Finset.card_image_le).trans (by simp) exact (certAt_le_of_isCert hScert).trans hcard have hC1_le : certSide (andOr a b) true ≤ a := by unfold certSide apply Finset.sup_le intro x hx have hfx : andOr a b x = true := (Finset.mem_filter.mp hx).2 have hrows : ∀ i : Fin a, ∃ j : Fin b, x (i, j) = true := by unfold andOr at hfx exact of_decide_eq_true hfx choose wit hwit using hrows let S : Finset (Fin a × Fin b) := Finset.univ.image (fun i : Fin a => (i, wit i)) have hScert : IsCert (andOr a b) x S := by intro y hy rw [hfx] unfold andOr rw [decide_eq_true_iff] intro i have hmem : (i, wit i) ∈ S := Finset.mem_image.mpr ⟨i, Finset.mem_univ i, rfl⟩ exact ⟨wit i, (hy (i, wit i) hmem).trans (hwit i)⟩ have hcard : S.card ≤ a := (Finset.card_image_le).trans (by simp) exact (certAt_le_of_isCert hScert).trans hcard -- Step 2: Lower bounds `b ≤ s₀` and `a ≤ s₁` via explicit extremal witnesses. let i0 : Fin a := ⟨0, by omega⟩ let j0 : Fin b := ⟨0, by omega⟩ let x0 : Fin a × Fin b → Bool := fun p => decide (p.1 ≠ i0) have hx0_val : andOr a b x0 = false := by unfold andOr rw [decide_eq_false_iff_not]; push Not exact ⟨i0, fun j => by simp [x0]⟩ have hs0_ge : b ≤ sensSide (andOr a b) false := by have hle := le_sensSide_of_val (f := andOr a b) (x := x0) (b := false) hx0_val have hsub : Finset.univ.image (fun j : Fin b => (i0, j)) ⊆ sensSet (andOr a b) x0 := by intro p hp obtain ⟨j, _, rfl⟩ := Finset.mem_image.mp hp simp only [sensSet, Finset.mem_filter, Finset.mem_univ, true_and, hx0_val] have htr : andOr a b (flipBit x0 (i0, j)) = true := by unfold andOr; rw [decide_eq_true_iff] intro i by_cases hi : i = i0 · subst hi; exact ⟨j, by simp [flipBit, x0]⟩ · exact ⟨j0, by simp [flipBit, x0, hi]⟩ rw [htr]; decide have hcard : (Finset.univ.image (fun j : Fin b => (i0, j))).card = b := by rw [Finset.card_image_of_injective _ (fun j₁ j₂ h => (Prod.mk.inj h).2), Finset.card_univ, Fintype.card_fin] exact (hcard.symm.le.trans (Finset.card_le_card hsub)).trans hle let x1 : Fin a × Fin b → Bool := fun p => decide (p.2 = j0) have hx1_val : andOr a b x1 = true := by unfold andOr; rw [decide_eq_true_iff] exact fun i => ⟨j0, by simp [x1]⟩ have hs1_ge : a ≤ sensSide (andOr a b) true := by have hle := le_sensSide_of_val (f := andOr a b) (x := x1) (b := true) hx1_val have hsub : Finset.univ.image (fun i : Fin a => (i, j0)) ⊆ sensSet (andOr a b) x1 := by intro p hp obtain ⟨i, _, rfl⟩ := Finset.mem_image.mp hp simp only [sensSet, Finset.mem_filter, Finset.mem_univ, true_and, hx1_val] have hfl : andOr a b (flipBit x1 (i, j0)) = false := by unfold andOr; rw [decide_eq_false_iff_not]; push Not refine ⟨i, fun j => ?_⟩ by_cases hj : j = j0 · subst hj; simp [flipBit, x1] · simp [flipBit, x1, hj] rw [hfl]; decide have hcard : (Finset.univ.image (fun i : Fin a => (i, j0))).card = a := by rw [Finset.card_image_of_injective _ (fun i₁ i₂ h => (Prod.mk.inj h).1), Finset.card_univ, Fintype.card_fin] exact (hcard.symm.le.trans (Finset.card_le_card hsub)).trans hle -- Collapse the entire `0`-side and `1`-side chains! have hchain0 := hierarchy_chain (andOr a b) false have hchain1 := hierarchy_chain (andOr a b) true have hs0 : sensSide (andOr a b) false = b := by omega have hbs0 : blockSensSide (andOr a b) false = b := by omega have hC0 : certSide (andOr a b) false = b := by omega have hs1 : sensSide (andOr a b) true = a := by omega have hbs1 : blockSensSide (andOr a b) true = a := by omega have hC1 : certSide (andOr a b) true = a := by omega -- Step 3: Prove `anfCoeff (andOr a b) Finset.univ = 1 ≠ 0` so `deg₂ ≥ a * b`! have htop_anf : anfCoeff (andOr a b) Finset.univ = 1 := by -- `∑_{T ⊆ univ} boolToZ2 (andOr a b (indicator T))` equals `∑_{x : Fin a × Fin b → Bool} boolToZ2 (andOr a b x)`! have hsum_all : anfCoeff (andOr a b) Finset.univ = ∑ x : Fin a × Fin b → Bool, boolToZ2 (andOr a b x) := by unfold anfCoeff apply Finset.sum_bij (fun T _ => fun p : Fin a × Fin b => decide (p ∈ T)) · intro _ _; exact Finset.mem_univ _ · intro T₁ _ T₂ _ heq ext p have := congrFun heq p simpa using this · intro x _ refine ⟨inputSupp x, Finset.mem_powerset.mpr (Finset.subset_univ _), ?_⟩ ext p; simp [inputSupp] · intro _ _; rfl rw [hsum_all] -- Reindex `Fin a × Fin b → Bool` as `Fin a → (Fin b → Bool)` via `Equiv.curry`! have hcurry : ∑ x : Fin a × Fin b → Bool, boolToZ2 (andOr a b x) = ∑ r : Fin a → (Fin b → Bool), ∏ i : Fin a, (if ∃ j : Fin b, r i j = true then (1 : ZMod 2) else 0) := by refine Fintype.sum_equiv (Equiv.curry (Fin a) (Fin b) Bool) _ _ (fun x => ?_) unfold andOr by_cases hall : ∀ i : Fin a, ∃ j : Fin b, x (i, j) = true · rw [decide_eq_true hall] simp only [boolToZ2, ↓reduceIte, Equiv.curry_apply] symm exact Finset.prod_eq_one fun i _ => if_pos (hall i) · rw [decide_eq_false hall] simp only [boolToZ2, Bool.false_eq_true, ↓reduceIte, Equiv.curry_apply] push Not at hall obtain ⟨i₀, hi₀⟩ := hall symm apply Finset.prod_eq_zero (Finset.mem_univ i₀) rw [if_neg (by push Not; exact hi₀)] rw [hcurry] have hps := (Fintype.prod_sum (fun (_ : Fin a) (y : Fin b → Bool) => if ∃ j : Fin b, y j = true then (1 : ZMod 2) else 0)).symm rw [hps] apply Finset.prod_eq_one intro i _ -- `∑ y : Fin b → Bool, (if ∃ j, y j = true then 1 else 0)` = `(2^b - 1 : ZMod 2) = 1`! have hrow_sum : ∑ y : Fin b → Bool, (if ∃ j : Fin b, y j = true then (1 : ZMod 2) else 0) = ∑ y ∈ Finset.univ.erase (fun _ : Fin b => false), (1 : ZMod 2) := by rw [← Finset.add_sum_erase _ _ (Finset.mem_univ (fun _ : Fin b => false))] have h0 : (if ∃ j : Fin b, false = true then (1 : ZMod 2) else 0) = 0 := by simp rw [h0, zero_add] apply Finset.sum_congr rfl intro y hy have hne : y ≠ fun _ => false := Finset.ne_of_mem_erase hy have hex : ∃ j : Fin b, y j = true := by by_contra hno; push Not at hno exact hne (funext fun j => by cases h : y j <;> simp_all) rw [if_pos hex] rw [hrow_sum, Finset.sum_const, Finset.card_erase_of_mem (Finset.mem_univ _), Finset.card_univ, Fintype.card_fun, Fintype.card_bool, Fintype.card_fin, nsmul_eq_mul, mul_one] have h2b : 1 ≤ 2 ^ b := Nat.one_le_pow b 2 (by norm_num) have hpow0 : ((2 ^ b : ℕ) : ZMod 2) = 0 := by have : b = (b - 1) + 1 := by omega rw [this, pow_succ, Nat.cast_mul] have h20 : ((2 : ℕ) : ZMod 2) = 0 := rfl rw [h20, mul_zero] have hcast : (((2 ^ b - 1 : ℕ) : ZMod 2)) + (1 : ZMod 2) = ((2 ^ b : ℕ) : ZMod 2) := by have hnat : (2 ^ b - 1) + 1 = 2 ^ b := Nat.sub_add_cancel h2b have hc := congrArg (Nat.cast (R := ZMod 2)) hnat simp only [Nat.cast_add, Nat.cast_one] at hc exact hc rw [hpow0] at hcast rcases zmod2_cases ((2 ^ b - 1 : ℕ) : ZMod 2) with hv | hv · rw [hv, zero_add] at hcast; exact absurd hcast one_ne_zero · exact hv have hdeg2_ge : a * b ≤ deg2 (andOr a b) := by have hne : anfCoeff (andOr a b) Finset.univ ≠ 0 := by rw [htop_anf]; exact one_ne_zero have hle : (Finset.univ : Finset (Fin a × Fin b)).card ≤ deg2 (andOr a b) := Finset.le_sup (f := Finset.card) (by simp [hne]) simpa [Fintype.card_prod, Fintype.card_fin] using hle -- Collapse `a * b ≤ deg₂ ≤ D_⊕ ≤ D ≤ C₀ * C₁ = b * a = a * b`! have hdeg_le_Dp := deg2_le_parityDepth (andOr a b) have hDp_le_D := parityDepth_le_detDepth (andOr a b) have hD_le_C := detDepth_le_cert0_mul_cert1 (andOr a b) rw [hC0, hC1] at hD_le_C have hmul_comm : b * a = a * b := Nat.mul_comm b a have hdeg2 : deg2 (andOr a b) = a * b := by omega have hDp : parityDepth (andOr a b) = a * b := by omega have hD : detDepth (andOr a b) = a * b := by omega -- Collapse `C₀^⊕ = b` and `C₁^⊕ = a` via Zhang–Shi `a * b = D_⊕ ≤ C₀^⊕ * C₁^⊕ ≤ b * a`! have hCp0_le : parityCertSide (andOr a b) false ≤ b := (parityCertSide_le_certSide _ _).trans (le_of_eq hC0) have hCp1_le : parityCertSide (andOr a b) true ≤ a := (parityCertSide_le_certSide _ _).trans (le_of_eq hC1) have hZS := parityDepth_le_parityCert0_mul_parityCert1 (andOr a b) rw [hDp, Nat.mul_comm a b] at hZS have hba_pos : 1 ≤ b * a := Nat.mul_pos hb ha have hCp0 : parityCertSide (andOr a b) false = b := by by_contra hne have hlt : parityCertSide (andOr a b) false < b := by omega by_cases h10 : parityCertSide (andOr a b) true = 0 · rw [h10, mul_zero] at hZS; omega · have : parityCertSide (andOr a b) false * parityCertSide (andOr a b) true < b * a := Nat.lt_of_lt_of_le (Nat.mul_lt_mul_of_pos_right hlt (by omega)) (Nat.mul_le_mul_left _ hCp1_le) omega have hCp1 : parityCertSide (andOr a b) true = a := by by_contra hne have hlt : parityCertSide (andOr a b) true < a := by omega by_cases h00 : parityCertSide (andOr a b) false = 0 · rw [h00, zero_mul] at hZS; omega · have : parityCertSide (andOr a b) false * parityCertSide (andOr a b) true < b * a := Nat.lt_of_le_of_lt (Nat.mul_le_mul_right _ hCp0_le) (Nat.mul_lt_mul_of_pos_left hlt (by omega)) omega exact ⟨hs0, hbs0, hC0, hCp0, hs1, hbs1, hC1, hCp1, hdeg2, hDp, hD⟩ /-! ### Family 3: `IP_{2m}` (Simultaneous All-`m` Sharpness of Granularity, `L₁ ≤ 2^(D_⊕ - 1)`, `‖f̂‖₀ ≤ 4^(D_⊕ - 1)`) -/ /-- The `2m`-bit Inner Product function `IP_{2m}(x, y) = ∑_{i < m} x_i y_i (mod 2)` on `Fin m × Bool`. -/ def innerProd (m : ℕ) (x : Fin m × Bool → Bool) : Bool := decide ((∑ i : Fin m, boolToZ2 (x (i, false)) * boolToZ2 (x (i, true))) = 1) lemma boolSign_innerProd (m : ℕ) (x : Fin m × Bool → Bool) : boolSign (innerProd m x) = ∏ i : Fin m, boolSign (x (i, false) && x (i, true)) := by have haux : ∀ S : Finset (Fin m), (if (∑ i ∈ S, boolToZ2 (x (i, false)) * boolToZ2 (x (i, true))) = 0 then (1 : ℝ) else -1) = ∏ i ∈ S, boolSign (x (i, false) && x (i, true)) := by intro S induction S using Finset.induction_on with | empty => simp | insert i S hi ih => rw [Finset.sum_insert hi, Finset.prod_insert hi, ← ih] cases h1 : x (i, false) <;> cases h2 : x (i, true) <;> rcases zmod2_cases (∑ j ∈ S, boolToZ2 (x (j, false)) * boolToZ2 (x (j, true))) with hs | hs <;> · rw [hs]; simp [boolToZ2, boolSign] have hfull := haux Finset.univ unfold innerProd rcases zmod2_cases (∑ i : Fin m, boolToZ2 (x (i, false)) * boolToZ2 (x (i, true))) with hs | hs <;> · rw [hs] at hfull ⊢; simp [boolSign] at hfull ⊢; linarith lemma fourierCoeff_innerProd (m : ℕ) (S : Finset (Fin m × Bool)) : fourierCoeff (innerProd m) S = ∏ i : Fin m, (if (i, false) ∈ S ∧ (i, true) ∈ S then (-1 / 2 : ℝ) else (1 / 2 : ℝ)) := by unfold fourierCoeff simp_rw [boolSign_innerProd] -- Split `walshChar S x` into a product over `i : Fin m`! have hwal : ∀ x : Fin m × Bool → Bool, walshChar S x = ∏ i : Fin m, ((if (i, false) ∈ S then boolSign (x (i, false)) else 1) * (if (i, true) ∈ S then boolSign (x (i, true)) else 1)) := by intro x unfold walshChar have hprod_all : (∏ p : Fin m × Bool, if p ∈ S then boolSign (x p) else 1) = ∏ p ∈ S, boolSign (x p) := by rw [← Finset.prod_filter] congr 1; ext p; simp rw [← hprod_all, Fintype.prod_prod_type] apply Finset.prod_congr rfl intro i _ rw [Fintype.prod_bool, mul_comm] simp_rw [hwal, ← Finset.prod_mul_distrib] -- Reindex `∑ x : Fin m × Bool → Bool` via `Equiv.curry` and factor with `Fintype.prod_sum`! have hcurry : ∑ x : Fin m × Bool → Bool, ∏ i : Fin m, boolSign (x (i, false) && x (i, true)) * ((if (i, false) ∈ S then boolSign (x (i, false)) else 1) * (if (i, true) ∈ S then boolSign (x (i, true)) else 1)) = ∏ i : Fin m, ∑ p : Bool → Bool, boolSign (p false && p true) * ((if (i, false) ∈ S then boolSign (p false) else 1) * (if (i, true) ∈ S then boolSign (p true) else 1)) := by rw [Fintype.prod_sum] exact Fintype.sum_equiv (Equiv.curry (Fin m) Bool Bool) _ _ (fun _ => rfl) rw [hcurry] have hcard : Fintype.card (Fin m × Bool) = 2 * m := by rw [Fintype.card_prod, Fintype.card_fin, Fintype.card_bool]; ring rw [hcard] have hpow : (2 : ℝ)⁻¹ ^ (2 * m) = ∏ _i : Fin m, ((1 / 4 : ℝ)) := by rw [Finset.prod_const, Finset.card_univ, Fintype.card_fin, pow_mul] congr 1; norm_num rw [hpow, ← Finset.prod_mul_distrib] apply Finset.prod_congr rfl intro i _ have hsum4 : ∀ g : Bool → Bool → ℝ, ∑ p : Bool → Bool, g (p false) (p true) = g false false + g false true + g true false + g true true := by intro g have heq := Fintype.sum_equiv (Equiv.boolArrowEquivProd Bool) (fun p : Bool → Bool => g (p false) (p true)) (fun q : Bool × Bool => g q.1 q.2) (fun p => rfl) rw [heq, Fintype.sum_prod_type] simp only [Fintype.sum_bool] ring rw [hsum4 (fun a b => boolSign (a && b) * ((if (i, false) ∈ S then boolSign a else 1) * (if (i, true) ∈ S then boolSign b else 1)))] by_cases hf : (i, false) ∈ S <;> by_cases ht : (i, true) ∈ S <;> simp [hf, ht, boolSign] <;> norm_num /-- **Theorem 4C (Simultaneous All-`m` Sharpness on `IP_{2m}`)**: For every `m ≥ 1`, `IP_{2m}` satisfies: `deg₂ = 2`, `gran = m`, `L₁ = 2^m`, `‖f̂‖₀ = 4^m`, `D_⊕ = m + 1`, and `D = 2m`, simultaneously attaining Theorems 3A Part 2 (`D_⊕ = gran + 1`), 3B Part 1 (`L₁ = 2^(D_⊕ - 1)`), and 3B Part 2 (`‖f̂‖₀ = 4^(D_⊕ - 1)`), with unbounded `D_⊕ / deg₂ = (m + 1) / 2`. -/ theorem innerProd_exact_invariants {m : ℕ} (hm : 1 ≤ m) : deg2 (innerProd m) = 2 ∧ granularity (innerProd m) = m ∧ spectralNorm (innerProd m) = (2 : ℝ) ^ m ∧ fourierSparsity (innerProd m) = 4 ^ m ∧ parityDepth (innerProd m) = m + 1 ∧ detDepth (innerProd m) = 2 * m := by classical have habs : ∀ S : Finset (Fin m × Bool), |fourierCoeff (innerProd m) S| = (1 / 2 : ℝ) ^ m := by intro S rw [fourierCoeff_innerProd, Finset.abs_prod] have h1 : ∀ i ∈ (Finset.univ : Finset (Fin m)), |if (i, false) ∈ S ∧ (i, true) ∈ S then (-1 / 2 : ℝ) else (1 / 2 : ℝ)| = (1 / 2 : ℝ) := by intro i _; split_ifs <;> norm_num rw [Finset.prod_congr rfl h1, Finset.prod_const, Finset.card_univ, Fintype.card_fin] have hsp : fourierSparsity (innerProd m) = 4 ^ m := by unfold fourierSparsity have hall : Finset.univ.filter (fun S : Finset (Fin m × Bool) => fourierCoeff (innerProd m) S ≠ 0) = Finset.univ := by ext S; simp only [Finset.mem_filter, Finset.mem_univ, true_and, iff_true] intro h0 have := habs S; rw [h0, abs_zero] at this have hpos : (0 : ℝ) < (1 / 2 : ℝ) ^ m := by positivity linarith rw [hall, Finset.card_univ, Fintype.card_finset, Fintype.card_prod, Fintype.card_fin, Fintype.card_bool, mul_comm, pow_mul] norm_num have hL1 : spectralNorm (innerProd m) = (2 : ℝ) ^ m := by unfold spectralNorm simp_rw [habs] rw [Finset.sum_const, Finset.card_univ, Fintype.card_finset, Fintype.card_prod, Fintype.card_fin, Fintype.card_bool, nsmul_eq_mul, Nat.cast_pow, Nat.cast_ofNat] have h2 : ((2 : ℝ) ^ (m * 2)) * (1 / 2 : ℝ) ^ m = (2 : ℝ) ^ m := by rw [mul_comm m 2, pow_mul, ← mul_pow] congr 1; norm_num exact h2 have hgran : granularity (innerProd m) = m := by apply le_antisymm · apply granularity_le_of_int intro S rw [fourierCoeff_innerProd] refine ⟨∏ i : Fin m, (if (i, false) ∈ S ∧ (i, true) ∈ S then (-1 : ℤ) else 1), ?_⟩ have hpow : (2 : ℝ) ^ m = ∏ _i : Fin m, (2 : ℝ) := by rw [Finset.prod_const, Finset.card_univ, Fintype.card_fin] rw [hpow, ← Finset.prod_mul_distrib, Int.cast_prod] apply Finset.prod_congr rfl intro i _; split_ifs <;> norm_num · by_contra hlt have hgm : granularity (innerProd m) < m := by omega obtain ⟨z, hz⟩ := granularity_spec (innerProd m) ∅ have hval : fourierCoeff (innerProd m) ∅ = (1 / 2 : ℝ) ^ m := by rw [fourierCoeff_innerProd] simp [Finset.prod_const, Finset.card_univ, Fintype.card_fin] rw [hval] at hz have hpos : (0 : ℝ) < (z : ℝ) := by rw [← hz]; positivity have hlt1 : (z : ℝ) < 1 := by rw [← hz] have h1 : (2 : ℝ) ^ granularity (innerProd m) < (2 : ℝ) ^ m := pow_lt_pow_right₀ (by norm_num) hgm have hinv : (2 : ℝ) ^ m * (1 / 2 : ℝ) ^ m = 1 := by rw [← mul_pow]; norm_num have hp : (0 : ℝ) < (1 / 2 : ℝ) ^ m := by positivity nlinarith have hz_ge1 : (1 : ℤ) ≤ z := by have : (0 : ℤ) < z := by exact_mod_cast hpos omega have hz_ge1_r : (1 : ℝ) ≤ (z : ℝ) := by exact_mod_cast hz_ge1 linarith have hdeg2 : deg2 (innerProd m) = 2 := by let c : Finset (Fin m × Bool) → ZMod 2 := fun S => if ∃ i : Fin m, S = {(i, false), (i, true)} then 1 else 0 have hc_eval : ∀ x : Fin m × Bool → Bool, boolToZ2 (innerProd m x) = ∑ S ∈ (inputSupp x).powerset, c S := by intro x have h1 : boolToZ2 (innerProd m x) = ∑ i : Fin m, boolToZ2 (x (i, false)) * boolToZ2 (x (i, true)) := by unfold innerProd rcases zmod2_cases (∑ i : Fin m, boolToZ2 (x (i, false)) * boolToZ2 (x (i, true))) with hv | hv <;> · rw [hv]; simp [boolToZ2] rw [h1] have h2 : ∑ i : Fin m, boolToZ2 (x (i, false)) * boolToZ2 (x (i, true)) = ∑ i ∈ Finset.univ.filter (fun i : Fin m => x (i, false) = true ∧ x (i, true) = true), (1 : ZMod 2) := by rw [← Finset.sum_filter_add_sum_filter_not Finset.univ (fun i : Fin m => x (i, false) = true ∧ x (i, true) = true)] have hz : ∑ i ∈ Finset.univ.filter (fun i : Fin m => ¬ (x (i, false) = true ∧ x (i, true) = true)), boolToZ2 (x (i, false)) * boolToZ2 (x (i, true)) = 0 := Finset.sum_eq_zero fun i hi => by have := (Finset.mem_filter.mp hi).2 cases h1' : x (i, false) <;> cases h2' : x (i, true) <;> simp_all [boolToZ2] rw [hz, add_zero] apply Finset.sum_congr rfl intro i hi have := (Finset.mem_filter.mp hi).2 simp [boolToZ2, this.1, this.2] rw [h2] have h3 : ∑ S ∈ (inputSupp x).powerset, c S = ∑ S ∈ (inputSupp x).powerset.filter (fun S => ∃ i : Fin m, S = {(i, false), (i, true)}), (1 : ZMod 2) := by rw [Finset.sum_filter] rw [h3] apply Finset.sum_bij (fun i _ => ({(i, false), (i, true)} : Finset (Fin m × Bool))) · intro i hi have hhi := (Finset.mem_filter.mp hi).2 simp only [Finset.mem_filter, Finset.mem_powerset] refine ⟨?_, i, rfl⟩ intro p hp simp only [Finset.mem_insert, Finset.mem_singleton] at hp rcases hp with rfl | rfl <;> simp [inputSupp, hhi.1, hhi.2] · intro i₁ _ i₂ _ heq have hmem : (i₁, false) ∈ ({(i₂, false), (i₂, true)} : Finset (Fin m × Bool)) := heq ▸ by simp simp only [Finset.mem_insert, Finset.mem_singleton, Prod.mk.injEq] at hmem rcases hmem with ⟨h, _⟩ | ⟨_, h⟩ · exact h · exact absurd h (by decide) · intro S hS simp only [Finset.mem_filter, Finset.mem_powerset] at hS obtain ⟨i, rfl⟩ := hS.2 refine ⟨i, Finset.mem_filter.mpr ⟨Finset.mem_univ _, ?_, ?_⟩, rfl⟩ · have := hS.1 (by simp : (i, false) ∈ ({(i, false), (i, true)} : Finset _)) simpa [inputSupp] using this · have := hS.1 (by simp : (i, true) ∈ ({(i, false), (i, true)} : Finset _)) simpa [inputSupp] using this · intro _ _; rfl have hanf := anfCoeff_unique (innerProd m) c hc_eval apply le_antisymm · unfold deg2; apply Finset.sup_le; intro S hS have hne := (Finset.mem_filter.mp hS).2 rw [hanf] at hne by_cases hex : ∃ i : Fin m, S = {(i, false), (i, true)} · obtain ⟨i, rfl⟩ := hex rw [Finset.card_pair (fun h => Bool.noConfusion (Prod.mk.inj h).2)] · simp [c, hex] at hne · let i0 : Fin m := ⟨0, by omega⟩ have hne : anfCoeff (innerProd m) {(i0, false), (i0, true)} ≠ 0 := by rw [hanf]; simp only [c]; rw [if_pos ⟨i0, rfl⟩]; exact one_ne_zero have hle : ({(i0, false), (i0, true)} : Finset (Fin m × Bool)).card ≤ deg2 (innerProd m) := Finset.le_sup (f := Finset.card) (by simp [hne]) rw [Finset.card_pair (fun h => Bool.noConfusion (Prod.mk.inj h).2)] at hle; exact hle -- Parity depth `D_⊕(IP_{2m}) = m + 1`: -- Lower bound from `gran + 1 ≤ D_⊕`, upper bound by querying `x(i, false)` for all `i : Fin m` (depth `m`), -- then 1 parity query on `{(i, true) | x(i, false) = true}`! have hnc : ∃ x y : Fin m × Bool → Bool, innerProd m x ≠ innerProd m y := by refine ⟨fun _ => false, fun p => decide (p.1 = ⟨0, by omega⟩), ?_⟩ have h0 : innerProd m (fun _ => false) = false := by simp [innerProd, boolToZ2] have h1 : innerProd m (fun p => decide (p.1 = ⟨0, by omega⟩)) = true := by unfold innerProd rw [decide_eq_true_iff] rw [Finset.sum_eq_single (⟨0, by omega⟩ : Fin m)] · simp [boolToZ2] · intro j _ hne; simp [hne, boolToZ2] · intro h; exact absurd (Finset.mem_univ _) h rw [h0, h1]; decide have hDp_ge : m + 1 ≤ parityDepth (innerProd m) := by have := granularity_add_one_le_parityDepth hnc; omega have hDp_le : parityDepth (innerProd m) ≤ m + 1 := by let L : List (Finset (Fin m × Bool)) := (Finset.univ.image (fun i : Fin m => ({(i, false)} : Finset (Fin m × Bool)))).toList let cont : (Finset (Fin m × Bool) → ZMod 2) → ParityDecTree (Fin m × Bool) := fun r => let α : Finset (Fin m × Bool) := (Finset.univ.filter (fun i : Fin m => r {(i, false)} = 1)).image (fun i => (i, true)) .branch α (.leaf false) (.leaf true) let T := ParityDecTree.queryList L cont (fun _ => 0) have hdepth : T.depth ≤ m + 1 := by calc T.depth ≤ L.length + 1 := ParityDecTree.queryList_depth L cont _ 1 (fun _ => by simp [cont, ParityDecTree.depth]) _ = (Finset.univ.image (fun i : Fin m => ({(i, false)} : Finset (Fin m × Bool)))).card + 1 := by rw [Finset.length_toList] _ ≤ m + 1 := Nat.add_le_add_right ((Finset.card_image_le).trans (by simp)) 1 have heval : ∀ x : Fin m × Bool → Bool, T.eval x = innerProd m x := by intro x simp only [T] rw [ParityDecTree.queryList_eval] simp only [cont, ParityDecTree.eval] have hpar_eq : parityVal ((Finset.univ.filter (fun i : Fin m => (if ({(i, false)} : Finset (Fin m × Bool)) ∈ L then parityVal {(i, false)} x else 0) = 1)).image (fun i => (i, true))) x = ∑ i : Fin m, boolToZ2 (x (i, false)) * boolToZ2 (x (i, true)) := by have hfilt_eq : Finset.univ.filter (fun i : Fin m => (if ({(i, false)} : Finset (Fin m × Bool)) ∈ L then parityVal {(i, false)} x else 0) = 1) = Finset.univ.filter (fun i : Fin m => x (i, false) = true) := by ext i have hmem : ({(i, false)} : Finset (Fin m × Bool)) ∈ L := Finset.mem_toList.mpr (Finset.mem_image.mpr ⟨i, Finset.mem_univ _, rfl⟩) simp only [Finset.mem_filter, Finset.mem_univ, true_and, hmem, ↓reduceIte, parityVal_singleton] cases x (i, false) <;> decide rw [hfilt_eq] unfold parityVal rw [Finset.sum_image (fun i₁ _ i₂ _ h => (Prod.mk.inj h).1)] symm rw [← Finset.sum_filter_add_sum_filter_not Finset.univ (fun i : Fin m => x (i, false) = true)] have hz : ∑ i ∈ Finset.univ.filter (fun i : Fin m => ¬ x (i, false) = true), boolToZ2 (x (i, false)) * boolToZ2 (x (i, true)) = 0 := Finset.sum_eq_zero fun i hi => by have := (Finset.mem_filter.mp hi).2 cases h : x (i, false) <;> simp_all [boolToZ2] rw [hz, add_zero] apply Finset.sum_congr rfl intro i hi have := (Finset.mem_filter.mp hi).2 simp [boolToZ2, this] rw [hpar_eq] unfold innerProd rcases zmod2_cases (∑ i : Fin m, boolToZ2 (x (i, false)) * boolToZ2 (x (i, true))) with hv | hv <;> simp [hv] exact (parityDepth_le_of_tree heval).trans hdepth have hDp : parityDepth (innerProd m) = m + 1 := le_antisymm hDp_le hDp_ge -- Standard decision tree depth `D(IP_{2m}) = 2m` via exact adversary! -- Adversary rule: maintain the set `Q` of queried bits; when queried on `(i, b)`, answer `true` if -- `(i, !b) ∉ Q` (first bit of pair `i`) and `false` if `(i, !b) ∈ Q` (second bit of pair `i`)! -- Wait: if any pair `i` has ≤ 1 bit queried at a leaf, we can extend the partial assignment `ρ` -- in two ways agreeing on `Q` that have opposite `innerProd m` values! have hD : detDepth (innerProd m) = 2 * m := by apply le_antisymm · exact (detDepth_le_card (innerProd m)).trans (by simp [Fintype.card_prod, Fintype.card_fin]; omega) · obtain ⟨t, ht_eval, ht_depth⟩ := exists_decTree_eq_detDepth (innerProd m) rw [← ht_depth] -- General inductive adversary: for any tree `t` and partial assignment `(Q, ρ)` such that -- whenever `(i, b) ∈ Q` and `(i, !b) ∈ Q` we don't care, and whenever ONLY ONE of `(i, false), (i, true)` -- is in `Q` its value in `ρ` is `true`, if `t` computes `innerProd m` on all extensions of `(Q, ρ)`, -- then `2 * m ≤ Q.card + t.depth`! have hadv : ∀ (t' : DecTree (Fin m × Bool)) (Q : Finset (Fin m × Bool)) (ρ : Fin m × Bool → Bool), (∀ i : Fin m, ∀ b : Bool, (i, b) ∈ Q → (i, !b) ∉ Q → ρ (i, b) = true) → (∀ x : Fin m × Bool → Bool, (∀ p ∈ Q, x p = ρ p) → t'.eval x = innerProd m x) → 2 * m ≤ Q.card + t'.depth := by intro t' induction t' with | leaf val => intro Q ρ hinv hok -- Must have `Q = Finset.univ`! Otherwise pick `p₀ = (i₀, b₀) ∉ Q`: by_contra hlt have hne_univ : Q ≠ Finset.univ := by intro hu; rw [hu, Finset.card_univ, Fintype.card_prod, Fintype.card_fin, Fintype.card_bool] at hlt simp [DecTree.depth] at hlt; omega have hex : ∃ p : Fin m × Bool, p ∉ Q := by by_contra hall; push Not at hall exact hne_univ (Finset.eq_univ_iff_forall.mpr hall) obtain ⟨⟨i₀, b₀⟩, hp0⟩ := hex -- Construct two extensions `xA, xB` of `(Q, ρ)` agreeing everywhere except at `(i₀, b₀)` -- AND with `xA (i₀, !b₀) = xB (i₀, !b₀) = true`! let xA : Fin m × Bool → Bool := fun p => if p ∈ Q then ρ p else if p = (i₀, !b₀) then true else false let xB : Fin m × Bool → Bool := flipBit xA (i₀, b₀) have hxA_Q : ∀ p ∈ Q, xA p = ρ p := fun p hp => by simp [xA, hp] have hxB_Q : ∀ p ∈ Q, xB p = ρ p := fun p hp => by have hne : p ≠ (i₀, b₀) := fun h => hp0 (h ▸ hp) simp [xB, flipBit, hne, xA, hp] have hother_true : xA (i₀, !b₀) = true := by dsimp only [xA] by_cases hm' : (i₀, !b₀) ∈ Q · rw [if_pos hm'] exact hinv i₀ (!b₀) hm' (by simpa using hp0) · simp [hm'] have hflip_val : innerProd m xB ≠ innerProd m xA := by -- `xB` differs from `xA` ONLY at `(i₀, b₀)`, where `xA (i₀, !b₀) = true`, so the `i₀`-th term changes by `1`! have hsum_diff : (∑ i : Fin m, boolToZ2 (xB (i, false)) * boolToZ2 (xB (i, true))) = (∑ i : Fin m, boolToZ2 (xA (i, false)) * boolToZ2 (xA (i, true))) + 1 := by rw [← Finset.add_sum_erase _ _ (Finset.mem_univ i₀), ← Finset.add_sum_erase _ _ (Finset.mem_univ i₀)] have hrest : ∑ i ∈ Finset.univ.erase i₀, boolToZ2 (xB (i, false)) * boolToZ2 (xB (i, true)) = ∑ i ∈ Finset.univ.erase i₀, boolToZ2 (xA (i, false)) * boolToZ2 (xA (i, true)) := by apply Finset.sum_congr rfl intro i hi have hne : i ≠ i₀ := Finset.ne_of_mem_erase hi have h1 : (i, false) ≠ (i₀, b₀) := fun h => hne (Prod.mk.inj h).1 have h2 : (i, true) ≠ (i₀, b₀) := fun h => hne (Prod.mk.inj h).1 simp [xB, flipBit, h1, h2] rw [hrest] have hterm : boolToZ2 (xB (i₀, false)) * boolToZ2 (xB (i₀, true)) = boolToZ2 (xA (i₀, false)) * boolToZ2 (xA (i₀, true)) + 1 := by cases b₀ · simp only [Bool.not_false] at hother_true have hbf : xB (i₀, false) = !xA (i₀, false) := by simp [xB, flipBit] have hbt : xB (i₀, true) = true := by simp [xB, flipBit, hother_true] rw [hbf, hbt, hother_true] cases xA (i₀, false) <;> decide · simp only [Bool.not_true] at hother_true have hbf : xB (i₀, false) = true := by simp [xB, flipBit, hother_true] have hbt : xB (i₀, true) = !xA (i₀, true) := by simp [xB, flipBit] rw [hbf, hbt, hother_true] cases xA (i₀, true) <;> decide rw [hterm]; ring unfold innerProd rw [hsum_diff] rcases zmod2_cases (∑ i : Fin m, boolToZ2 (xA (i, false)) * boolToZ2 (xA (i, true))) with hs | hs <;> simp [hs] have hA := hok xA hxA_Q have hB := hok xB hxB_Q simp only [DecTree.eval] at hA hB exact hflip_val (hB.symm.trans hA) | branch p tF tT ihF ihT => intro Q ρ hinv hok by_cases hpQ : p ∈ Q · cases hρp : ρ p · have h1 := ihF Q ρ hinv (fun x hx => by have := hok x hx; simp [DecTree.eval, hx p hpQ, hρp] at this; exact this) simp only [DecTree.depth]; omega · have h1 := ihT Q ρ hinv (fun x hx => by have := hok x hx; simp [DecTree.eval, hx p hpQ, hρp] at this; exact this) simp only [DecTree.depth]; omega · rcases p with ⟨i, b⟩ by_cases hother : (i, !b) ∈ Q · -- Second bit of pair `i`: answer `false` (follow `tF`)! let Q' := insert (i, b) Q let ρ' := fun q => if q = (i, b) then false else ρ q have hinv' : ∀ j : Fin m, ∀ c : Bool, (j, c) ∈ Q' → (j, !c) ∉ Q' → ρ' (j, c) = true := by intro j c hjc hjnc have hne1 : (j, c) ≠ (i, b) := by intro h; rcases Prod.mk.inj h with ⟨rfl, rfl⟩ exact hjnc (Finset.mem_insert_of_mem hother) have hmemQ : (j, c) ∈ Q := (Finset.mem_insert.mp hjc).resolve_left hne1 have hnmemQ : (j, !c) ∉ Q := fun h => hjnc (Finset.mem_insert_of_mem h) simp only [ρ', hne1, ↓reduceIte] exact hinv j c hmemQ hnmemQ have hok' : ∀ x, (∀ q ∈ Q', x q = ρ' q) → tF.eval x = innerProd m x := by intro x hx have hxb : x (i, b) = false := by simpa [ρ'] using hx (i, b) (Finset.mem_insert_self _ _) have hxQ : ∀ q ∈ Q, x q = ρ q := fun q hq => by have hne : q ≠ (i, b) := fun h => hpQ (h ▸ hq) simpa [ρ', hne] using hx q (Finset.mem_insert_of_mem hq) have := hok x hxQ; simp [DecTree.eval, hxb] at this; exact this have h1 := ihF Q' ρ' hinv' hok' have hcard' : Q'.card = Q.card + 1 := Finset.card_insert_of_notMem hpQ simp only [DecTree.depth]; omega · -- First bit of pair `i`: answer `true` (follow `tT`)! let Q' := insert (i, b) Q let ρ' := fun q => if q = (i, b) then true else ρ q have hinv' : ∀ j : Fin m, ∀ c : Bool, (j, c) ∈ Q' → (j, !c) ∉ Q' → ρ' (j, c) = true := by intro j c hjc hjnc by_cases hjeq : (j, c) = (i, b) · simp [ρ', hjeq] · have hmemQ : (j, c) ∈ Q := (Finset.mem_insert.mp hjc).resolve_left hjeq have hnmemQ : (j, !c) ∉ Q := fun h => hjnc (Finset.mem_insert_of_mem h) simp only [ρ', hjeq, ↓reduceIte] exact hinv j c hmemQ hnmemQ have hok' : ∀ x, (∀ q ∈ Q', x q = ρ' q) → tT.eval x = innerProd m x := by intro x hx have hxb : x (i, b) = true := by simpa [ρ'] using hx (i, b) (Finset.mem_insert_self _ _) have hxQ : ∀ q ∈ Q, x q = ρ q := fun q hq => by have hne : q ≠ (i, b) := fun h => hpQ (h ▸ hq) simpa [ρ', hne] using hx q (Finset.mem_insert_of_mem hq) have := hok x hxQ; simp [DecTree.eval, hxb] at this; exact this have h1 := ihT Q' ρ' hinv' hok' have hcard' : Q'.card = Q.card + 1 := Finset.card_insert_of_notMem hpQ simp only [DecTree.depth]; omega have hres := hadv t ∅ (fun _ => false) (by simp) (fun x _ => ht_eval x) simpa using hres exact ⟨hdeg2, hgran, hL1, hsp, hDp, hD⟩ /-! ### Family 4: `AND_n` (Exact All-`n` Sharpness of Signed-Collision Drop, Theorem 3D) -/ /-- The `n`-bit conjunction `AND_n(x) = x₀ ∧ ⋯ ∧ x_{n-1}`. -/ def andFun (n : ℕ) (x : Fin n → Bool) : Bool := decide (∀ i : Fin n, x i = true) lemma fourierCoeff_andFun (n : ℕ) (S : Finset (Fin n)) : fourierCoeff (andFun n) S = (if S = ∅ then (1 : ℝ) else 0) - 2 * (2 : ℝ)⁻¹ ^ n * (-1 : ℝ) ^ S.card := by unfold fourierCoeff have hsign : ∀ x : Fin n → Bool, boolSign (andFun n x) = 1 - if x = fun _ => true then (2 : ℝ) else 0 := by intro x unfold andFun by_cases hx : x = fun _ => true · subst hx; simp [boolSign]; norm_num · have hnot : ¬ ∀ i : Fin n, x i = true := fun h => hx (funext h) simp [hx, hnot, boolSign] simp_rw [hsign, sub_mul, one_mul, Finset.sum_sub_distrib, sum_walshChar] have hterm2 : ∑ x : Fin n → Bool, (if x = fun _ => true then (2 : ℝ) else 0) * walshChar S x = 2 * (-1 : ℝ) ^ S.card := by rw [Finset.sum_eq_single (fun _ : Fin n => true)] · simp only [↓reduceIte, walshChar, boolSign, Finset.prod_const] · intro x _ hne; simp [hne] · intro h; exact absurd (Finset.mem_univ _) h rw [hterm2, Fintype.card_fin] split_ifs · have hinv : (2 : ℝ)⁻¹ ^ n * (2 : ℝ) ^ n = 1 := by rw [← mul_pow]; norm_num calc (2 : ℝ)⁻¹ ^ n * ((2 : ℝ) ^ n - 2 * (-1 : ℝ) ^ S.card) = (2 : ℝ)⁻¹ ^ n * (2 : ℝ) ^ n - 2 * (2 : ℝ)⁻¹ ^ n * (-1 : ℝ) ^ S.card := by ring _ = 1 - 2 * (2 : ℝ)⁻¹ ^ n * (-1 : ℝ) ^ S.card := by rw [hinv] · ring /-- **Theorem 4D (All-`n` Sharpness of Signed-Collision `L₁` Drop on `AND_n`)**: For every `n ≥ 2`, `AND_n` has `L₁(AND̂_n) = 3 - 4 / 2^n`, maximum magnitude `M₁ = 1 - 2 / 2^n` at `∅`, second magnitude `M₂ = 2 / 2^n` at `{0}`, and on the `x₀ = 1` hyperplane restriction achieves exact equality in Theorem 3D (`signed_collision_L1_drop`): `L₁(f̂_{{0}, 1}) = L₁(f̂) - 2 · M₂ = 3 - 8 / 2^n`. -/ theorem andFun_signed_collision_exact {n : ℕ} (hn : 2 ≤ n) : let i0 : Fin n := ⟨0, by omega⟩ spectralNorm (andFun n) = 3 - 4 * (2 : ℝ)⁻¹ ^ n ∧ |fourierCoeff (andFun n) ∅| = 1 - 2 * (2 : ℝ)⁻¹ ^ n ∧ |fourierCoeff (andFun n) {i0}| = 2 * (2 : ℝ)⁻¹ ^ n ∧ spectralNorm (parityRestrict (andFun n) {i0} i0 1) = spectralNorm (andFun n) - 2 * |fourierCoeff (andFun n) {i0}| := by intro i0 have h2n_ge4 : (4 : ℝ) ≤ (2 : ℝ) ^ n := by have : 4 ≤ 2 ^ n := (show 4 = 2 ^ 2 by norm_num) ▸ Nat.pow_le_pow_right (by norm_num) hn exact_mod_cast this have hinv_le : (2 : ℝ)⁻¹ ^ n ≤ 1 / 4 := by rw [inv_pow] have hpos : (0 : ℝ) < (2 : ℝ) ^ n := by positivity rw [inv_le_comm₀ hpos (by norm_num : (0 : ℝ) < 1 / 4)] linarith have hinv_pos : (0 : ℝ) < (2 : ℝ)⁻¹ ^ n := by positivity have hM1 : |fourierCoeff (andFun n) ∅| = 1 - 2 * (2 : ℝ)⁻¹ ^ n := by rw [fourierCoeff_andFun] simp only [↓reduceIte, Finset.card_empty, pow_zero, mul_one] exact abs_of_nonneg (by linarith) have hM2_all : ∀ S : Finset (Fin n), S ≠ ∅ → |fourierCoeff (andFun n) S| = 2 * (2 : ℝ)⁻¹ ^ n := by intro S hS rw [fourierCoeff_andFun, if_neg hS, zero_sub, abs_neg, abs_mul, abs_mul] rw [abs_of_pos (by norm_num : (0 : ℝ) < 2), abs_of_pos hinv_pos, abs_pow, abs_neg, abs_one, one_pow, mul_one] have hM2 : |fourierCoeff (andFun n) {i0}| = 2 * (2 : ℝ)⁻¹ ^ n := hM2_all {i0} (Finset.singleton_ne_empty i0) have hL1 : spectralNorm (andFun n) = 3 - 4 * (2 : ℝ)⁻¹ ^ n := by unfold spectralNorm rw [← Finset.add_sum_erase _ _ (Finset.mem_univ (∅ : Finset (Fin n))), hM1] have hrest : ∑ S ∈ Finset.univ.erase (∅ : Finset (Fin n)), |fourierCoeff (andFun n) S| = ((2 ^ n - 1 : ℕ) : ℝ) * (2 * (2 : ℝ)⁻¹ ^ n) := by have hcongr : ∑ S ∈ Finset.univ.erase (∅ : Finset (Fin n)), |fourierCoeff (andFun n) S| = ∑ _S ∈ Finset.univ.erase (∅ : Finset (Fin n)), (2 * (2 : ℝ)⁻¹ ^ n) := Finset.sum_congr rfl fun S hS => hM2_all S (Finset.ne_of_mem_erase hS) rw [hcongr, Finset.sum_const, Finset.card_erase_of_mem (Finset.mem_univ _), Finset.card_univ, Fintype.card_finset, Fintype.card_fin, nsmul_eq_mul] rw [hrest] have hcast : ((2 ^ n - 1 : ℕ) : ℝ) = (2 : ℝ) ^ n - 1 := by rw [Nat.cast_sub (Nat.one_le_pow n 2 (by norm_num))]; norm_num rw [hcast] have hmul : (2 : ℝ) ^ n * (2 : ℝ)⁻¹ ^ n = 1 := by rw [← mul_pow]; norm_num calc 1 - 2 * (2 : ℝ)⁻¹ ^ n + ((2 : ℝ) ^ n - 1) * (2 * (2 : ℝ)⁻¹ ^ n) = 1 + 2 * ((2 : ℝ) ^ n * (2 : ℝ)⁻¹ ^ n) - 4 * (2 : ℝ)⁻¹ ^ n := by ring _ = 3 - 4 * (2 : ℝ)⁻¹ ^ n := by rw [hmul]; ring -- Now evaluate `spectralNorm (parityRestrict (andFun n) {i0} i0 1)` directly via `spectralNorm_parityRestrict`! have hL1_res : spectralNorm (parityRestrict (andFun n) {i0} i0 1) = spectralNorm (andFun n) - 2 * |fourierCoeff (andFun n) {i0}| := by rw [spectralNorm_parityRestrict (andFun n) (Finset.mem_singleton_self i0) 1] simp only [one_ne_zero, ↓reduceIte, neg_one_mul] -- Split `H = {S | i0 ∉ S}` into `S = ∅` and `S ≠ ∅`! let H := Finset.univ.filter (fun S : Finset (Fin n) => i0 ∉ S) have hempH : (∅ : Finset (Fin n)) ∈ H := Finset.mem_filter.mpr ⟨Finset.mem_univ _, Finset.notMem_empty _⟩ rw [← Finset.add_sum_erase _ _ hempH] -- Term `S = ∅`: `|f̂(∅) - f̂({i0})| = |(1 - 2/2^n) - (2/2^n)| = 1 - 4/2^n`! have hterm0 : |fourierCoeff (andFun n) ∅ + -fourierCoeff (andFun n) (symmDiff ∅ {i0})| = 1 - 4 * (2 : ℝ)⁻¹ ^ n := by rw [empty_symmDiff_finset, fourierCoeff_andFun, fourierCoeff_andFun] simp only [↓reduceIte, Finset.card_empty, pow_zero, mul_one, Finset.singleton_ne_empty, Finset.card_singleton, pow_one] have hval : 1 - 2 * (2 : ℝ)⁻¹ ^ n + -(0 - 2 * (2 : ℝ)⁻¹ ^ n * -1) = 1 - 4 * (2 : ℝ)⁻¹ ^ n := by ring rw [hval] exact abs_of_nonneg (by linarith) -- Every `S ∈ H.erase ∅` has `i0 ∉ S`, so `symmDiff S {i0} = insert i0 S` has card `S.card + 1`, -- hence `f̂(S)` and `f̂(S ∆ {i0})` have OPPOSITE signs and `|f̂(S) - f̂(S ∆ {i0})| = 4 * 2⁻¹^n`! have hterm_other : ∀ S ∈ H.erase ∅, |fourierCoeff (andFun n) S + -fourierCoeff (andFun n) (symmDiff S {i0})| = 4 * (2 : ℝ)⁻¹ ^ n := by intro S hS have hne0 : S ≠ ∅ := Finset.ne_of_mem_erase hS have hni0 : i0 ∉ S := (Finset.mem_filter.mp (Finset.mem_of_mem_erase hS)).2 have hsd : symmDiff S {i0} = insert i0 S := by ext j; simp only [Finset.mem_symmDiff, Finset.mem_singleton, Finset.mem_insert] constructor · rintro (⟨hjS, _⟩ | ⟨rfl, _⟩) · exact Or.inr hjS · exact Or.inl rfl · rintro (rfl | hjS) · exact Or.inr ⟨rfl, hni0⟩ · exact Or.inl ⟨hjS, fun h => hni0 (h ▸ hjS)⟩ have hsd_ne0 : symmDiff S {i0} ≠ ∅ := by rw [hsd]; exact Finset.insert_ne_empty _ _ rw [fourierCoeff_andFun, fourierCoeff_andFun, if_neg hne0, if_neg hsd_ne0, hsd, Finset.card_insert_of_notMem hni0, pow_succ] have hval : 0 - 2 * (2 : ℝ)⁻¹ ^ n * (-1 : ℝ) ^ S.card + -(0 - 2 * (2 : ℝ)⁻¹ ^ n * ((-1 : ℝ) ^ S.card * -1)) = -(4 * (2 : ℝ)⁻¹ ^ n * (-1 : ℝ) ^ S.card) := by ring rw [hval, abs_neg, abs_mul, abs_mul, abs_of_pos (by norm_num : (0 : ℝ) < 4), abs_of_pos hinv_pos, abs_pow, abs_neg, abs_one, one_pow, mul_one] have hcardH : H.card = 2 ^ (n - 1) := by have hbij : H.card = ((Finset.univ : Finset (Finset (Fin n))).filter (fun S => ¬ i0 ∉ S)).card := by apply Finset.card_bij (fun S _ => insert i0 S) · intro S hS; rw [Finset.mem_filter] at hS ⊢; exact ⟨Finset.mem_univ _, by simp⟩ · intro S₁ hS₁ S₂ hS₂ heq have h1 := (Finset.mem_filter.mp hS₁).2 have h2 := (Finset.mem_filter.mp hS₂).2 have := congrArg (fun T => T.erase i0) heq simpa [Finset.erase_insert h1, Finset.erase_insert h2] using this · intro T hT have hiT : i0 ∈ T := by simpa using (Finset.mem_filter.mp hT).2 refine ⟨T.erase i0, Finset.mem_filter.mpr ⟨Finset.mem_univ _, Finset.notMem_erase _ _⟩, Finset.insert_erase hiT⟩ have htot : H.card + ((Finset.univ : Finset (Finset (Fin n))).filter (fun S => ¬ i0 ∉ S)).card = (Finset.univ : Finset (Finset (Fin n))).card := by simpa [H] using Finset.sum_filter_add_sum_filter_not (Finset.univ : Finset (Finset (Fin n))) (fun S => i0 ∉ S) (fun _ => (1 : ℕ)) rw [Finset.card_univ, Fintype.card_finset, Fintype.card_fin] at htot have h2n : 2 ^ n = 2 * 2 ^ (n - 1) := by conv_lhs => rw [show n = (n - 1) + 1 by omega, pow_succ, mul_comm] omega rw [hterm0, Finset.sum_congr rfl hterm_other, Finset.sum_const, Finset.card_erase_of_mem hempH, hcardH, nsmul_eq_mul] have hcast : ((2 ^ (n - 1) - 1 : ℕ) : ℝ) = (2 : ℝ) ^ (n - 1) - 1 := by rw [Nat.cast_sub (Nat.one_le_pow (n - 1) 2 (by norm_num))]; norm_num rw [hcast, hL1, hM2] have hmul2 : (2 : ℝ) ^ (n - 1) * (2 : ℝ)⁻¹ ^ n = 1 / 2 := by have hn1 : (2 : ℝ)⁻¹ ^ n = (2 : ℝ)⁻¹ ^ (n - 1) * (2 : ℝ)⁻¹ := by conv_lhs => rw [show n = (n - 1) + 1 by omega, pow_succ] rw [hn1, ← mul_assoc, ← mul_pow]; norm_num calc 1 - 4 * (2 : ℝ)⁻¹ ^ n + ((2 : ℝ) ^ (n - 1) - 1) * (4 * (2 : ℝ)⁻¹ ^ n) = 1 + 4 * ((2 : ℝ) ^ (n - 1) * (2 : ℝ)⁻¹ ^ n) - 8 * (2 : ℝ)⁻¹ ^ n := by ring _ = 3 - 4 * (2 : ℝ)⁻¹ ^ n - 2 * (2 * (2 : ℝ)⁻¹ ^ n) := by rw [hmul2]; ring exact ⟨hL1, hM1, hM2, hL1_res⟩ /-! ### Family 5: `Rubinstein(k, m)` (Exact Infinite Quadratic `bs, C ≥ s² / 2` Separation) -/ /-- Rubinstein's (1995) Boolean function `Rubinstein(k, m)` on `Fin k × Fin m × Bool`: OR of `k` disjoint copies of `g_m`, where `g_m` outputs `true` iff a unique pair `j ∈ Fin m` is `(true, true)` and all other `m - 1` pairs are `(false, false)`. -/ def rubinstein (k m : ℕ) (x : Fin k × Fin m × Bool → Bool) : Bool := decide (∃ i : Fin k, ∃ j : Fin m, x (i, j, false) = true ∧ x (i, j, true) = true ∧ ∀ j' : Fin m, j' ≠ j → x (i, j', false) = false ∧ x (i, j', true) = false) /-- **Theorem 4E (Rubinstein Quadratic Separation `bs, C ≥ s² / 2`)**: For all `k ≥ 1` and `m ≥ 1`, `f = rubinstein k m` satisfies: `s₀(f) = k`, `s₁(f) = 2m`, `bs₀(f) ≥ k · m`, `C₀(f) ≥ k · m`. In particular, at `k = 2m`, `s(f) = 2m` while `bs(f) ≥ 2m² = s(f)² / 2` and `C(f) ≥ 2m² = s(f)² / 2`. -/ theorem rubinstein_exact_separation {k m : ℕ} (hk : 1 ≤ k) (hm : 1 ≤ m) : sensSide (rubinstein k m) false = k ∧ sensSide (rubinstein k m) true = 2 * m ∧ k * m ≤ blockSensSide (rubinstein k m) false ∧ k * m ≤ certSide (rubinstein k m) false := by classical -- Helper predicate: copy `i` is active under `x` at pair `j`. let activeAt (x : Fin k × Fin m × Bool → Bool) (i : Fin k) (j : Fin m) : Prop := x (i, j, false) = true ∧ x (i, j, true) = true ∧ ∀ j' : Fin m, j' ≠ j → x (i, j', false) = false ∧ x (i, j', true) = false have hrub_iff : ∀ x, rubinstein k m x = true ↔ ∃ i j, activeAt x i j := fun x => by simp [rubinstein, activeAt] -- 1. `sensSide false ≤ k`: on any `0`-input, each copy `i : Fin k` contains AT MOST 1 sensitive bit! have hs0_le : sensSide (rubinstein k m) false ≤ k := by unfold sensSide; apply Finset.sup_le; intro x hx have hfx : rubinstein k m x = false := (Finset.mem_filter.mp hx).2 have hno : ∀ i j, ¬ activeAt x i j := fun i j h => by have := (hrub_iff x).mpr ⟨i, j, h⟩; rw [hfx] at this; exact Bool.noConfusion this -- Show `Prod.fst` is INJECTIVE on `sensSet (rubinstein k m) x`! have hinj : Set.InjOn (fun p : Fin k × Fin m × Bool => p.1) (sensSet (rubinstein k m) x : Set _) := by rintro ⟨i₁, j₁, b₁⟩ hp₁ ⟨i₂, j₂, b₂⟩ hp₂ heq simp only at heq; subst heq have h1 : rubinstein k m (flipBit x (i₁, j₁, b₁)) = true := by have := (Finset.mem_filter.mp hp₁).2; rw [hfx] at this cases h : rubinstein k m (flipBit x (i₁, j₁, b₁)) <;> simp_all have h2 : rubinstein k m (flipBit x (i₁, j₂, b₂)) = true := by have := (Finset.mem_filter.mp hp₂).2; rw [hfx] at this cases h : rubinstein k m (flipBit x (i₁, j₂, b₂)) <;> simp_all obtain ⟨iA, jA, hA⟩ := (hrub_iff _).mp h1 obtain ⟨iB, jB, hB⟩ := (hrub_iff _).mp h2 -- Must have `iA = i₁` and `iB = i₁` (since flipping a bit in copy `i₁` cannot activate another copy)! have hiA : iA = i₁ := by by_contra hne apply hno iA jA have hfl : ∀ j c, flipBit x (i₁, j₁, b₁) (iA, j, c) = x (iA, j, c) := fun j c => by have : (iA, j, c) ≠ (i₁, j₁, b₁) := fun h => hne (Prod.mk.inj h).1 simp [flipBit, this] exact ⟨hfl _ _ ▸ hA.1, hfl _ _ ▸ hA.2.1, fun j' hj' => ⟨hfl _ _ ▸ (hA.2.2 j' hj').1, hfl _ _ ▸ (hA.2.2 j' hj').2⟩⟩ have hiB : iB = i₁ := by by_contra hne apply hno iB jB have hfl : ∀ j c, flipBit x (i₁, j₂, b₂) (iB, j, c) = x (iB, j, c) := fun j c => by have : (iB, j, c) ≠ (i₁, j₂, b₂) := fun h => hne (Prod.mk.inj h).1 simp [flipBit, this] exact ⟨hfl _ _ ▸ hB.1, hfl _ _ ▸ hB.2.1, fun j' hj' => ⟨hfl _ _ ▸ (hB.2.2 j' hj').1, hfl _ _ ▸ (hB.2.2 j' hj').2⟩⟩ rw [hiA] at hA; rw [hiB] at hB let T : Finset (Fin m × Bool) := Finset.univ.filter (fun q => x (i₁, q) = true) have hT_flip : ∀ (p : Fin m × Bool) (j₀ : Fin m), activeAt (flipBit x (i₁, p)) i₁ j₀ → (x (i₁, p) = false ∧ insert p T = {(j₀, false), (j₀, true)} ∧ p ∉ T) ∨ (x (i₁, p) = true ∧ T.erase p = {(j₀, false), (j₀, true)} ∧ p ∈ T) := by intro p j₀ hact cases hxp : x (i₁, p) · left refine ⟨rfl, ?_, by simp [T, hxp]⟩ ext q simp only [Finset.mem_insert, Finset.mem_singleton, Finset.mem_filter, Finset.mem_univ, true_and, T] constructor · rintro (rfl | hxq) · have hfl : flipBit x (i₁, q) (i₁, q) = true := by simp [flipBit, hxp] rcases q with ⟨j', c'⟩ by_cases hj : j' = j₀ · subst hj; cases c' <;> simp · exfalso; have := hact.2.2 j' hj cases c' · rw [this.1] at hfl; exact Bool.noConfusion hfl · rw [this.2] at hfl; exact Bool.noConfusion hfl · have hne : q ≠ p := fun h => by rw [h, hxp] at hxq; exact Bool.noConfusion hxq have hfl : flipBit x (i₁, p) (i₁, q) = true := by have hne' : (i₁, q) ≠ (i₁, p) := fun h => hne (Prod.mk.inj h).2 simp [flipBit, hne', hxq] rcases q with ⟨j, c⟩ by_cases hj : j = j₀ · subst hj; cases c <;> simp · exfalso; have := hact.2.2 j hj cases c · rw [this.1] at hfl; exact Bool.noConfusion hfl · rw [this.2] at hfl; exact Bool.noConfusion hfl · rintro (rfl | rfl) · by_cases heq : (j₀, false) = p · exact Or.inl heq · right have hfl := hact.1 have hne' : (i₁, j₀, false) ≠ (i₁, p) := fun h => heq (Prod.mk.inj h).2 rw [flipBit, if_neg hne'] at hfl; exact hfl · by_cases heq : (j₀, true) = p · exact Or.inl heq · right have hfl := hact.2.1 have hne' : (i₁, j₀, true) ≠ (i₁, p) := fun h => heq (Prod.mk.inj h).2 rw [flipBit, if_neg hne'] at hfl; exact hfl · right refine ⟨rfl, ?_, by simp [T, hxp]⟩ ext q simp only [Finset.mem_erase, Finset.mem_insert, Finset.mem_singleton, Finset.mem_filter, Finset.mem_univ, true_and, T] constructor · rintro ⟨hne, hxq⟩ have hne' : (i₁, q) ≠ (i₁, p) := fun h => hne (Prod.mk.inj h).2 have hfl : flipBit x (i₁, p) (i₁, q) = true := by simp [flipBit, hne', hxq] rcases q with ⟨j, c⟩ by_cases hj : j = j₀ · subst hj; cases c <;> simp · exfalso; have := hact.2.2 j hj cases c · rw [this.1] at hfl; exact Bool.noConfusion hfl · rw [this.2] at hfl; exact Bool.noConfusion hfl · rintro (rfl | rfl) · have hne : (j₀, false) ≠ p := by intro heq; have hfl := hact.1; rw [heq] at hfl; simp [flipBit, hxp] at hfl have hne' : (i₁, j₀, false) ≠ (i₁, p) := fun h => hne (Prod.mk.inj h).2 have hfl := hact.1; rw [flipBit, if_neg hne'] at hfl exact ⟨hne, hfl⟩ · have hne : (j₀, true) ≠ p := by intro heq; have hfl := hact.2.1; rw [heq] at hfl; simp [flipBit, hxp] at hfl have hne' : (i₁, j₀, true) ≠ (i₁, p) := fun h => hne (Prod.mk.inj h).2 have hfl := hact.2.1; rw [flipBit, if_neg hne'] at hfl exact ⟨hne, hfl⟩ have hpair_ne : ∀ j : Fin m, (j, false) ≠ (j, true) := fun j h => Bool.noConfusion (Prod.mk.inj h).2 rcases hT_flip (j₁, b₁) jA hA with ⟨_, h1eq, h1n⟩ | ⟨_, h1eq, h1m⟩ <;> rcases hT_flip (j₂, b₂) jB hB with ⟨_, h2eq, h2n⟩ | ⟨_, h2eq, h2m⟩ · have hc1 : T.card = 1 := by have := congrArg Finset.card h1eq rw [Finset.card_insert_of_notMem h1n, Finset.card_pair (hpair_ne jA)] at this; omega obtain ⟨⟨j₀, c₀⟩, hT1⟩ := Finset.card_eq_one.mp hc1 rw [hT1] at h1eq h2eq h1n h2n have hm1 : (j₀, c₀) ∈ ({(jA, false), (jA, true)} : Finset (Fin m × Bool)) := h1eq ▸ by simp have hm2 : (j₀, c₀) ∈ ({(jB, false), (jB, true)} : Finset (Fin m × Bool)) := h2eq ▸ by simp have hjA : jA = j₀ := by simp only [Finset.mem_insert, Finset.mem_singleton, Prod.mk.injEq] at hm1 rcases hm1 with ⟨h, _⟩ | ⟨h, _⟩ <;> exact h.symm have hjB : jB = j₀ := by simp only [Finset.mem_insert, Finset.mem_singleton, Prod.mk.injEq] at hm2 rcases hm2 with ⟨h, _⟩ | ⟨h, _⟩ <;> exact h.symm rw [hjA] at h1eq; rw [hjB] at h2eq have h12 : insert (j₁, b₁) ({(j₀, c₀)} : Finset _) = insert (j₂, b₂) ({(j₀, c₀)} : Finset _) := h1eq.trans h2eq.symm have hmem : (j₁, b₁) ∈ insert (j₂, b₂) ({(j₀, c₀)} : Finset _) := h12 ▸ Finset.mem_insert_self _ _ rcases Finset.mem_insert.mp hmem with heq | hsing · rcases Prod.mk.inj heq with ⟨rfl, rfl⟩; rfl · exact absurd hsing h1n · have hc1 := congrArg Finset.card h1eq have hc2 := congrArg Finset.card h2eq rw [Finset.card_insert_of_notMem h1n, Finset.card_pair (hpair_ne jA)] at hc1 rw [Finset.card_erase_of_mem h2m, Finset.card_pair (hpair_ne jB)] at hc2 omega · have hc1 := congrArg Finset.card h1eq have hc2 := congrArg Finset.card h2eq rw [Finset.card_erase_of_mem h1m, Finset.card_pair (hpair_ne jA)] at hc1 rw [Finset.card_insert_of_notMem h2n, Finset.card_pair (hpair_ne jB)] at hc2 omega · -- Both have `|T| = 3`: `T = {(jA, false), (jA, true), (j₁, b₁)} = {(jB, false), (jB, true), (j₂, b₂)}`! have hT_eq1 : T = insert (j₁, b₁) {(jA, false), (jA, true)} := by rw [← h1eq, Finset.insert_erase h1m] have hT_eq2 : T = insert (j₂, b₂) {(jB, false), (jB, true)} := by rw [← h2eq, Finset.insert_erase h2m] have hjAB : jA = jB := by by_contra hne have hm1 : (jA, false) ∈ insert (j₂, b₂) ({(jB, false), (jB, true)} : Finset _) := hT_eq2 ▸ hT_eq1 ▸ by simp have hm2 : (jA, true) ∈ insert (j₂, b₂) ({(jB, false), (jB, true)} : Finset _) := hT_eq2 ▸ hT_eq1 ▸ by simp simp only [Finset.mem_insert, Finset.mem_singleton, Prod.mk.injEq] at hm1 hm2 have h1' : (jA, false) = (j₂, b₂) := by rcases hm1 with ⟨rfl, rfl⟩ | ⟨h, _⟩ | ⟨h, _⟩ · rfl · exact absurd h hne · exact absurd h hne have h2' : (jA, true) = (j₂, b₂) := by rcases hm2 with ⟨rfl, rfl⟩ | ⟨h, _⟩ | ⟨h, _⟩ · rfl · exact absurd h hne · exact absurd h hne have := h1'.trans h2'.symm exact Bool.noConfusion (Prod.mk.inj this).2 subst hjAB have h1neA : (j₁, b₁) ∉ ({(jA, false), (jA, true)} : Finset _) := by rw [← h1eq]; exact Finset.notMem_erase _ _ have hmem : (j₁, b₁) ∈ insert (j₂, b₂) ({(jA, false), (jA, true)} : Finset _) := hT_eq2 ▸ hT_eq1 ▸ Finset.mem_insert_self _ _ rcases Finset.mem_insert.mp hmem with heq | hpair · rcases Prod.mk.inj heq with ⟨rfl, rfl⟩; rfl · exact absurd hpair h1neA unfold sensAt calc (sensSet (rubinstein k m) x).card = ((sensSet (rubinstein k m) x).image (fun p => p.1)).card := (Finset.card_image_of_injOn hinj).symm _ ≤ (Finset.univ : Finset (Fin k)).card := Finset.card_le_card (Finset.subset_univ _) _ = k := by simp -- 2. `k ≤ sensSide false` at `x0 (i, j, b) = (j = 0 ∧ b = false)`: let i0 : Fin k := ⟨0, by omega⟩ let j0 : Fin m := ⟨0, by omega⟩ let x0 : Fin k × Fin m × Bool → Bool := fun p => decide (p.2.1 = j0 ∧ p.2.2 = false) have hx0_val : rubinstein k m x0 = false := by by_contra htr have htr' : rubinstein k m x0 = true := by cases h : rubinstein k m x0 <;> simp_all obtain ⟨i, j, _, h2, _⟩ := (hrub_iff x0).mp htr' simp [x0] at h2 have hs0_ge : k ≤ sensSide (rubinstein k m) false := by have hle := le_sensSide_of_val (f := rubinstein k m) (x := x0) (b := false) hx0_val have hsub : Finset.univ.image (fun i : Fin k => (i, j0, true)) ⊆ sensSet (rubinstein k m) x0 := by intro p hp obtain ⟨i, _, rfl⟩ := Finset.mem_image.mp hp simp only [sensSet, Finset.mem_filter, Finset.mem_univ, true_and, hx0_val] have htr : rubinstein k m (flipBit x0 (i, j0, true)) = true := (hrub_iff _).mpr ⟨i, j0, by simp [flipBit, x0], by simp [flipBit, x0], fun j' hj' => by have h1 : (i, j', false) ≠ (i, j0, true) := fun h => hj' (Prod.mk.inj (Prod.mk.inj h).2).1 have h2 : (i, j', true) ≠ (i, j0, true) := fun h => hj' (Prod.mk.inj (Prod.mk.inj h).2).1 simp [flipBit, x0, h1, h2, hj']⟩ rw [htr]; decide have hcard : (Finset.univ.image (fun i : Fin k => (i, j0, true))).card = k := by rw [Finset.card_image_of_injective _ (fun i₁ i₂ h => (Prod.mk.inj h).1), Finset.card_univ, Fintype.card_fin] exact (hcard.symm.le.trans (Finset.card_le_card hsub)).trans hle -- 3. `sensSide true = 2 * m`: have hs1_le : sensSide (rubinstein k m) true ≤ 2 * m := by unfold sensSide; apply Finset.sup_le; intro x hx have hfx : rubinstein k m x = true := (Finset.mem_filter.mp hx).2 obtain ⟨i₀, j₀, hact⟩ := (hrub_iff x).mp hfx have hsub : sensSet (rubinstein k m) x ⊆ Finset.univ.filter (fun p : Fin k × Fin m × Bool => p.1 = i₀) := by intro p hp rw [Finset.mem_filter] refine ⟨Finset.mem_univ _, ?_⟩ by_contra hne have hfl : rubinstein k m (flipBit x p) = true := by apply (hrub_iff _).mpr refine ⟨i₀, j₀, ?_, ?_, fun j' hj' => ⟨?_, ?_⟩⟩ · have : (i₀, j₀, false) ≠ p := fun h => hne (congrArg Prod.fst h).symm simp [flipBit, this, hact.1] · have : (i₀, j₀, true) ≠ p := fun h => hne (congrArg Prod.fst h).symm simp [flipBit, this, hact.2.1] · have : (i₀, j', false) ≠ p := fun h => hne (congrArg Prod.fst h).symm simp [flipBit, this, (hact.2.2 j' hj').1] · have : (i₀, j', true) ≠ p := fun h => hne (congrArg Prod.fst h).symm simp [flipBit, this, (hact.2.2 j' hj').2] have hdiff := (Finset.mem_filter.mp hp).2 rw [hfl, hfx] at hdiff; exact hdiff rfl have hcard : (Finset.univ.filter (fun p : Fin k × Fin m × Bool => p.1 = i₀)).card = 2 * m := by have heq : Finset.univ.filter (fun p : Fin k × Fin m × Bool => p.1 = i₀) = Finset.univ.image (fun q : Fin m × Bool => (i₀, q)) := by ext ⟨i, q⟩; simp [eq_comm] rw [heq, Finset.card_image_of_injective _ (fun _ _ h => (Prod.mk.inj h).2), Finset.card_univ, Fintype.card_prod, Fintype.card_fin, Fintype.card_bool, mul_comm] exact (Finset.card_le_card hsub).trans (le_of_eq hcard) let x1 : Fin k × Fin m × Bool → Bool := fun p => decide (p.1 = i0 ∧ p.2.1 = j0) have hx1_val : rubinstein k m x1 = true := (hrub_iff x1).mpr ⟨i0, j0, by simp [x1], by simp [x1], fun j' hj' => by simp [x1, hj']⟩ have hs1_ge : 2 * m ≤ sensSide (rubinstein k m) true := by have hle := le_sensSide_of_val (f := rubinstein k m) (x := x1) (b := true) hx1_val have hsub : Finset.univ.image (fun q : Fin m × Bool => (i0, q)) ⊆ sensSet (rubinstein k m) x1 := by intro p hp obtain ⟨⟨j, c⟩, _, rfl⟩ := Finset.mem_image.mp hp simp only [sensSet, Finset.mem_filter, Finset.mem_univ, true_and, hx1_val] have hfl : rubinstein k m (flipBit x1 (i0, j, c)) = false := by by_contra htr have htr' : rubinstein k m (flipBit x1 (i0, j, c)) = true := by cases h : rubinstein k m (flipBit x1 (i0, j, c)) <;> simp_all obtain ⟨i', j', h1, h2, h3⟩ := (hrub_iff _).mp htr' by_cases hi' : i' = i0 · subst hi' by_cases hj : j = j0 · subst hj by_cases hj' : j' = j0 · subst hj' cases c · simp [flipBit, x1] at h1 · simp [flipBit, x1] at h2 · have hne1 : (i0, j', false) ≠ (i0, j0, c) := fun h => hj' (Prod.mk.inj (Prod.mk.inj h).2).1 simp [flipBit, x1, hne1, hj'] at h1 · by_cases hj' : j' = j0 · subst hj' have := h3 j hj cases c · have := this.1; simp [flipBit, x1, hj] at this · have := this.2; simp [flipBit, x1, hj] at this · have := h3 j0 (Ne.symm hj') have hne1 : (i0, j0, false) ≠ (i0, j, c) := fun h => hj (Prod.mk.inj (Prod.mk.inj h).2).1.symm have h1' := this.1; simp [flipBit, x1, hne1] at h1' · have hne1 : (i', j', false) ≠ (i0, j, c) := fun h => hi' (Prod.mk.inj h).1 simp [flipBit, x1, hne1, hi'] at h1 rw [hfl]; decide have hcard : (Finset.univ.image (fun q : Fin m × Bool => (i0, q))).card = 2 * m := by rw [Finset.card_image_of_injective _ (fun _ _ h => (Prod.mk.inj h).2), Finset.card_univ, Fintype.card_prod, Fintype.card_fin, Fintype.card_bool, mul_comm] exact (hcard.symm.le.trans (Finset.card_le_card hsub)).trans hle -- 4. `k * m ≤ blockSensSide false` at the all-`false` input `xall0`: have hbs0_ge : k * m ≤ blockSensSide (rubinstein k m) false := by let xall0 : Fin k × Fin m × Bool → Bool := fun _ => false have hval0 : rubinstein k m xall0 = false := by by_contra htr have htr' : rubinstein k m xall0 = true := by cases h : rubinstein k m xall0 <;> simp_all obtain ⟨_, _, h1, _, _⟩ := (hrub_iff xall0).mp htr' simp [xall0] at h1 let ℬ : Finset (Finset (Fin k × Fin m × Bool)) := Finset.univ.image (fun p : Fin k × Fin m => ({(p.1, p.2, false), (p.1, p.2, true)} : Finset _)) have hdisj : (ℬ : Set (Finset (Fin k × Fin m × Bool))).PairwiseDisjoint id := by rintro B₁ hB₁ B₂ hB₂ hne obtain ⟨⟨i₁, j₁⟩, _, rfl⟩ := Finset.mem_image.mp (Finset.mem_coe.mp hB₁) obtain ⟨⟨i₂, j₂⟩, _, rfl⟩ := Finset.mem_image.mp (Finset.mem_coe.mp hB₂) dsimp only [Function.onFun, id] rw [Finset.disjoint_left] intro q hq1 hq2 simp only [Finset.mem_insert, Finset.mem_singleton] at hq1 hq2 rcases hq1 with rfl | rfl <;> rcases hq2 with h | h · rcases Prod.mk.inj h with ⟨rfl, h'⟩; rcases Prod.mk.inj h' with ⟨rfl, _⟩; exact hne rfl · exact Bool.noConfusion (Prod.mk.inj (Prod.mk.inj h).2).2 · exact Bool.noConfusion (Prod.mk.inj (Prod.mk.inj h).2).2 · rcases Prod.mk.inj h with ⟨rfl, h'⟩; rcases Prod.mk.inj h' with ⟨rfl, _⟩; exact hne rfl have hsens : ∀ B ∈ ℬ, IsSensBlock (rubinstein k m) xall0 B := by intro B hB obtain ⟨⟨i, j⟩, _, rfl⟩ := Finset.mem_image.mp hB unfold IsSensBlock rw [hval0] have htr : rubinstein k m (flipSet xall0 {(i, j, false), (i, j, true)}) = true := by apply (hrub_iff _).mpr refine ⟨i, j, by simp [flipSet, xall0], by simp [flipSet, xall0], fun j' hj' => ⟨?_, ?_⟩⟩ · have h1 : (i, j', false) ∉ ({(i, j, false), (i, j, true)} : Finset _) := by simp [hj'] simp [flipSet, xall0, h1] · have h1 : (i, j', true) ∉ ({(i, j, false), (i, j, true)} : Finset _) := by simp [hj'] simp [flipSet, xall0, h1] rw [htr]; decide have hcard : ℬ.card = k * m := by rw [Finset.card_image_of_injective _ (fun ⟨i₁, j₁⟩ ⟨i₂, j₂⟩ heq => by have hm : (i₁, j₁, false) ∈ ({(i₂, j₂, false), (i₂, j₂, true)} : Finset _) := heq ▸ by simp simp only [Finset.mem_insert, Finset.mem_singleton, Prod.mk.injEq] at hm rcases hm with ⟨rfl, rfl, _⟩ | ⟨_, _, hc⟩ · rfl · exact absurd hc (by decide)), Finset.card_univ, Fintype.card_prod, Fintype.card_fin, Fintype.card_fin] have h1 := card_le_blockSensAt (ℬ := ℬ) ⟨hsens, hdisj⟩ have h2 := le_blockSensSide_of_val (f := rubinstein k m) (x := xall0) (b := false) hval0 omega have hC0_ge : k * m ≤ certSide (rubinstein k m) false := hbs0_ge.trans (blockSensSide_le_certSide _ _) exact ⟨le_antisymm hs0_le hs0_ge, le_antisymm hs1_le hs1_ge, hbs0_ge, hC0_ge⟩ /-! ### Family 6: `MAJ_3` (Simultaneous Witness for Nisan Collapse, `D < C₀C₁`, `L₁ = 2` Rigidity, `D_⊕ < D`) -/ /-- The 3-bit Majority function `MAJ_3 : (Fin 3 → Bool) → Bool`. -/ def maj3 (x : Fin 3 → Bool) : Bool := decide ((if x 0 then 1 else 0) + (if x 1 then 1 else 0) + (if x 2 then 1 else 0) ≥ 2) /-- **Theorem 4F (Exact Invariants of `MAJ_3`)**: `MAJ_3` simultaneously witnesses: `s₀ = s₁ = bs₀ = bs₁ = C₀ = C₁ = 2`, `D = 3`, `D_⊕ = 2`, `L₁ = 2`, `‖f̂‖₀ = 4` — attaining Theorem 2F (`C₀ = 2 = 2 bs₀ - 2`), Theorem 2C (`D = 3 < 4 = C₀ C₁`), Theorem 3E Part 2 (`L₁ = 2 ↔ ‖f̂‖₀ = 4`), and `D_⊕ < D`. -/ theorem maj3_exact_invariants : sensSide maj3 false = 2 ∧ sensSide maj3 true = 2 ∧ blockSensSide maj3 false = 2 ∧ blockSensSide maj3 true = 2 ∧ certSide maj3 false = 2 ∧ certSide maj3 true = 2 ∧ detDepth maj3 = 3 ∧ parityDepth maj3 = 2 ∧ spectralNorm maj3 = 2 ∧ fourierSparsity maj3 = 4 := by classical -- Step 1: `C₀ ≤ 2` and `C₁ ≤ 2` (every `0`-input has two `false` bits; every `1`-input has two `true` bits). have hC_le : ∀ b : Bool, certSide maj3 b ≤ 2 := by intro b unfold certSide; apply Finset.sup_le; intro x hx have hfx : maj3 x = b := (Finset.mem_filter.mp hx).2 -- Any 2 coordinates equal to `b` certify `maj3 x = b`! have hex2 : ∃ i j : Fin 3, i ≠ j ∧ x i = b ∧ x j = b := by cases h0 : x 0 <;> cases h1 : x 1 <;> cases h2 : x 2 <;> simp [maj3, h0, h1, h2] at hfx <;> subst hfx · exact ⟨0, 1, by decide, h0, h1⟩ · exact ⟨0, 1, by decide, h0, h1⟩ · exact ⟨0, 2, by decide, h0, h2⟩ · exact ⟨1, 2, by decide, h1, h2⟩ · exact ⟨1, 2, by decide, h1, h2⟩ · exact ⟨0, 2, by decide, h0, h2⟩ · exact ⟨0, 1, by decide, h0, h1⟩ · exact ⟨0, 1, by decide, h0, h1⟩ obtain ⟨i, j, hij, hxi, hxj⟩ := hex2 have hcert : IsCert maj3 x {i, j} := by intro y hy have hyi : y i = b := (hy i (by simp)).trans hxi have hyj : y j = b := (hy j (by simp)).trans hxj rw [hfx] fin_cases i <;> fin_cases j <;> try exact absurd rfl hij all_goals cases h0 : y 0 <;> cases h1 : y 1 <;> cases h2 : y 2 <;> simp_all [maj3] exact (certAt_le_of_isCert hcert).trans (by rw [Finset.card_pair hij]) -- Step 2: `2 ≤ s₀` (at `(true, false, false)`) and `2 ≤ s₁` (at `(false, true, true)`). let x0 : Fin 3 → Bool := ![true, false, false] let x1 : Fin 3 → Bool := ![false, true, true] have hs0_ge : 2 ≤ sensSide maj3 false := by have hval : maj3 x0 = false := by decide have hle := le_sensSide_of_val (f := maj3) (x := x0) (b := false) hval have hsub : ({1, 2} : Finset (Fin 3)) ⊆ sensSet maj3 x0 := by intro i hi; simp only [Finset.mem_insert, Finset.mem_singleton] at hi rcases hi with rfl | rfl <;> (simp only [sensSet, Finset.mem_filter, Finset.mem_univ, true_and, hval]; decide) exact ((show ({1, 2} : Finset (Fin 3)).card = 2 by decide).symm.le.trans (Finset.card_le_card hsub)).trans hle have hs1_ge : 2 ≤ sensSide maj3 true := by have hval : maj3 x1 = true := by decide have hle := le_sensSide_of_val (f := maj3) (x := x1) (b := true) hval have hsub : ({1, 2} : Finset (Fin 3)) ⊆ sensSet maj3 x1 := by intro i hi; simp only [Finset.mem_insert, Finset.mem_singleton] at hi rcases hi with rfl | rfl <;> (simp only [sensSet, Finset.mem_filter, Finset.mem_univ, true_and, hval]; decide) exact ((show ({1, 2} : Finset (Fin 3)).card = 2 by decide).symm.le.trans (Finset.card_le_card hsub)).trans hle have hch0 := hierarchy_chain maj3 false have hch1 := hierarchy_chain maj3 true have hC0_le := hC_le false have hC1_le := hC_le true have hs0 : sensSide maj3 false = 2 := by omega have hs1 : sensSide maj3 true = 2 := by omega have hbs0 : blockSensSide maj3 false = 2 := by omega have hbs1 : blockSensSide maj3 true = 2 := by omega have hC0 : certSide maj3 false = 2 := by omega have hC1 : certSide maj3 true = 2 := by omega -- Step 3: Exact Fourier coefficients of `maj3`: -- `f̂({0}) = f̂({1}) = f̂({2}) = 1/2`, `f̂({0, 1, 2}) = -1/2`, all other 4 coefficients `0`! have hfc : ∀ S : Finset (Fin 3), fourierCoeff maj3 S = if S = {0} ∨ S = {1} ∨ S = {2} then (1 / 2 : ℝ) else if S = Finset.univ then (-1 / 2 : ℝ) else 0 := by intro S -- Compute via `fourierCoeff` = `(1/8) * ∑_{x : Fin 3 → Bool} boolSign (maj3 x) * walshChar S x`! -- Even cleaner: prove `boolSign (maj3 x) = (1/2)*(χ_{0} + χ_{1} + χ_{2} - χ_{univ})` pointwise! have hpoint : ∀ x : Fin 3 → Bool, boolSign (maj3 x) = (1 / 2 : ℝ) * walshChar {0} x + (1 / 2 : ℝ) * walshChar {1} x + (1 / 2 : ℝ) * walshChar {2} x + (-1 / 2 : ℝ) * walshChar Finset.univ x := by intro x have huniv : walshChar (Finset.univ : Finset (Fin 3)) x = boolSign (x 0) * boolSign (x 1) * boolSign (x 2) := by simp [walshChar, Fin.prod_univ_three, mul_assoc] rw [huniv] simp only [walshChar, Finset.prod_singleton] cases h0 : x 0 <;> cases h1 : x 1 <;> cases h2 : x 2 <;> simp [maj3, boolSign, h0, h1, h2] <;> norm_num unfold fourierCoeff simp_rw [hpoint] have hexp : ∑ x : Fin 3 → Bool, ((1 / 2 : ℝ) * walshChar {0} x + (1 / 2 : ℝ) * walshChar {1} x + (1 / 2 : ℝ) * walshChar {2} x + (-1 / 2 : ℝ) * walshChar Finset.univ x) * walshChar S x = (1 / 2 : ℝ) * (∑ x, walshChar (symmDiff {0} S) x) + (1 / 2 : ℝ) * (∑ x, walshChar (symmDiff {1} S) x) + (1 / 2 : ℝ) * (∑ x, walshChar (symmDiff {2} S) x) + (-1 / 2 : ℝ) * (∑ x, walshChar (symmDiff Finset.univ S) x) := by have hterm : ∀ x : Fin 3 → Bool, ((1 / 2 : ℝ) * walshChar {0} x + (1 / 2 : ℝ) * walshChar {1} x + (1 / 2 : ℝ) * walshChar {2} x + (-1 / 2 : ℝ) * walshChar Finset.univ x) * walshChar S x = (1 / 2 : ℝ) * walshChar (symmDiff {0} S) x + (1 / 2 : ℝ) * walshChar (symmDiff {1} S) x + (1 / 2 : ℝ) * walshChar (symmDiff {2} S) x + (-1 / 2 : ℝ) * walshChar (symmDiff Finset.univ S) x := fun x => by rw [← walshChar_mul, ← walshChar_mul, ← walshChar_mul, ← walshChar_mul]; ring simp_rw [hterm, Finset.sum_add_distrib, ← Finset.mul_sum] rw [hexp, sum_walshChar, sum_walshChar, sum_walshChar, sum_walshChar] simp only [symmDiff_eq_empty_finset, Fintype.card_fin] have hdisj01 : ({0} : Finset (Fin 3)) ≠ {1} := by decide have hdisj02 : ({0} : Finset (Fin 3)) ≠ {2} := by decide have hdisj12 : ({1} : Finset (Fin 3)) ≠ {2} := by decide have hdisj0u : ({0} : Finset (Fin 3)) ≠ Finset.univ := by decide have hdisj1u : ({1} : Finset (Fin 3)) ≠ Finset.univ := by decide have hdisj2u : ({2} : Finset (Fin 3)) ≠ Finset.univ := by decide by_cases h0 : S = {0} · subst h0; simp [hdisj01.symm, hdisj02.symm, hdisj0u.symm]; norm_num · by_cases h1 : S = {1} · subst h1; simp [hdisj01, hdisj12.symm, hdisj1u.symm]; norm_num · by_cases h2 : S = {2} · subst h2; simp [hdisj02, hdisj12, hdisj2u.symm]; norm_num · by_cases hu : S = Finset.univ · subst hu simp [hdisj0u, hdisj1u, hdisj2u, hdisj0u.symm, hdisj1u.symm, hdisj2u.symm] norm_num · simp [h0, h1, h2, hu, Ne.symm h0, Ne.symm h1, Ne.symm h2, Ne.symm hu] have hsp : fourierSparsity maj3 = 4 := by unfold fourierSparsity have heq : Finset.univ.filter (fun S : Finset (Fin 3) => fourierCoeff maj3 S ≠ 0) = {{0}, {1}, {2}, Finset.univ} := by ext S simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_insert, Finset.mem_singleton] rw [hfc S] by_cases h0 : S = {0} · subst h0; simp · by_cases h1 : S = {1} · subst h1; simp · by_cases h2 : S = {2} · subst h2; simp · by_cases hu : S = Finset.univ · subst hu; simp [h0, h1, h2] · simp [h0, h1, h2, hu] rw [heq]; decide have hL1 : spectralNorm maj3 = 2 := (spectralNorm_eq_two_rigidity maj3).1.mpr hsp -- Step 4: `parityDepth maj3 = 2` (query `x₀ ⊕ x₁`: if `0` then `x₀ = x₁` so output `x₀`; if `1` then `x₀ ≠ x₁` so output `x₂`!). have hDp : parityDepth maj3 = 2 := by apply le_antisymm · let t : ParityDecTree (Fin 3) := .branch {0, 1} (.branch {0} (.leaf false) (.leaf true)) (.branch {2} (.leaf false) (.leaf true)) have heval : ∀ x : Fin 3 → Bool, t.eval x = maj3 x := fun x => by simp only [t, ParityDecTree.eval, parityVal, Finset.sum_pair (by decide : (0 : Fin 3) ≠ 1), Finset.sum_singleton] cases h0 : x 0 <;> cases h1 : x 1 <;> cases h2 : x 2 <;> simp [maj3, boolToZ2, h0, h1, h2] exact (parityDepth_le_of_tree heval).trans (by simp [t, ParityDecTree.depth]) · have hne1 : fourierSparsity maj3 ≠ 1 := by omega have hge2 := spectralNorm_gap_ge_two hne1 have hle := spectralNorm_le_two_pow_parityDepth_sub_one maj3 by_contra hlt have hd1 : parityDepth maj3 - 1 = 0 := by omega rw [hd1, pow_zero] at hle; linarith -- Step 5: `detDepth maj3 = 3` (any depth-≤2 decision tree cannot distinguish opposite 3rd bit when first 2 bits differ!). have hD : detDepth maj3 = 3 := by apply le_antisymm · exact (detDepth_le_card maj3).trans (by simp) · by_contra hlt obtain ⟨t, ht_eval, ht_depth⟩ := exists_decTree_eq_detDepth maj3 have hd2 : t.depth ≤ 2 := by omega -- Root queries some `i : Fin 3` (cannot be leaf since `maj3` is nonconstant); -- take the `false` branch (`x i = false`): its subtree has depth `≤ 1` and queries at most 1 bit `j`, -- set `x j = true` (if `j ≠ i`), leaving the 3rd bit `k` unqueried -> `maj3` depends on `x k`, contradiction! cases t with | leaf b => have h0 := ht_eval (fun _ => false) have h1 := ht_eval (fun _ => true) simp only [DecTree.eval] at h0 h1 have : maj3 (fun _ => false) = maj3 (fun _ => true) := h0.symm.trans h1 revert this; decide | branch i tF tT => have hF_depth : tF.depth ≤ 1 := by simp only [DecTree.depth] at hd2; omega cases tF with | leaf b => let y0 : Fin 3 → Bool := fun _ => false let y1 : Fin 3 → Bool := fun q => decide (q ≠ i) have hy0i : y0 i = false := rfl have hy1i : y1 i = false := by simp [y1] have h0 : b = maj3 y0 := by have := ht_eval y0; simp only [DecTree.eval, hy0i] at this; exact this have h1 : b = maj3 y1 := by have := ht_eval y1; simp only [DecTree.eval, hy1i] at this; exact this have hne : maj3 y0 ≠ maj3 y1 := by fin_cases i <;> decide exact hne (h0.symm.trans h1) | branch j tFF tFT => have hFT_d : tFT.depth = 0 := by simp only [DecTree.depth] at hF_depth; omega have hFF_d : tFF.depth = 0 := by simp only [DecTree.depth] at hF_depth; omega cases tFT with | branch _ _ _ => simp [DecTree.depth] at hFT_d | leaf bFT => cases tFF with | branch _ _ _ => simp [DecTree.depth] at hFF_d | leaf bFF => by_cases hji : j = i · subst hji let y0 : Fin 3 → Bool := fun _ => false let y1 : Fin 3 → Bool := fun q => decide (q ≠ j) have hy0j : y0 j = false := rfl have hy1j : y1 j = false := by simp [y1] have h0 : bFF = maj3 y0 := by have := ht_eval y0; simp only [DecTree.eval, hy0j] at this; exact this have h1 : bFF = maj3 y1 := by have := ht_eval y1; simp only [DecTree.eval, hy1j] at this; exact this have hne : maj3 y0 ≠ maj3 y1 := by fin_cases j <;> decide exact hne (h0.symm.trans h1) · let y0 : Fin 3 → Bool := fun q => decide (q = j) let y1 : Fin 3 → Bool := fun q => decide (q ≠ i) have hy0i : y0 i = false := by simp [y0, Ne.symm hji] have hy0j : y0 j = true := by simp [y0] have hy1i : y1 i = false := by simp [y1] have hy1j : y1 j = true := by simp [y1, hji] have h0 : bFT = maj3 y0 := by have := ht_eval y0; simp only [DecTree.eval, hy0i, hy0j] at this; exact this have h1 : bFT = maj3 y1 := by have := ht_eval y1; simp only [DecTree.eval, hy1i, hy1j] at this; exact this have hne : maj3 y0 ≠ maj3 y1 := by fin_cases i <;> fin_cases j <;> first | exact absurd rfl hji | decide exact hne (h0.symm.trans h1) exact ⟨hs0, hs1, hbs0, hbs1, hC0, hC1, hD, hDp, hL1, hsp⟩ end Pillar4 end SensitivityDecisionTrees /-! ## Axiom Verification (`#print axioms` on every headline theorem) -/ -- Foundations & Hierarchy #print axioms SensitivityDecisionTrees.certAt_le_detDepth #print axioms SensitivityDecisionTrees.certSide_le_detDepth #print axioms SensitivityDecisionTrees.cert_le_detDepth #print axioms SensitivityDecisionTrees.hierarchy_chain #print axioms SensitivityDecisionTrees.anf_eval -- Pillar 1: Decision-Tree Depth vs. ANF/Fourier Degree, Block Sensitivity, and Certificates #print axioms SensitivityDecisionTrees.anf_top_monomial_simultaneous_drop #print axioms SensitivityDecisionTrees.detDepth_le_deg2_mul_blockSensSide #print axioms SensitivityDecisionTrees.detDepth_le_deg2_mul_min_bs #print axioms SensitivityDecisionTrees.detDepth_le_certSide_not_mul_blockSensSide #print axioms SensitivityDecisionTrees.detDepth_le_cert1_mul_bs0 #print axioms SensitivityDecisionTrees.detDepth_le_cert0_mul_bs1 #print axioms SensitivityDecisionTrees.detDepth_le_cert0_mul_cert1 #print axioms SensitivityDecisionTrees.detDepth_le_realDeg_mul_min_bs -- Pillar 2: Strict Non-Asymptotic Nisan Improvement & Low-Sensitivity Collapse #print axioms SensitivityDecisionTrees.nisan_cert_le_sens_mul_bs #print axioms SensitivityDecisionTrees.essential_bit_sensitivity_deficit #print axioms SensitivityDecisionTrees.certSide_strict_lt_nisan #print axioms SensitivityDecisionTrees.detDepth_strict_lt_nisan_cubic #print axioms SensitivityDecisionTrees.sensSide_not_le_one_pointwise_eq #print axioms SensitivityDecisionTrees.s1_le_one_exact_equality #print axioms SensitivityDecisionTrees.s1_le_two_private_neighbor_bound #print axioms SensitivityDecisionTrees.s1_le_two_cert0_le_two_bs0_sub_two #print axioms SensitivityDecisionTrees.s1_le_two_bs0_le_two_cert0_le_two -- Pillar 3: Parity Decision Trees, Granularity, Signed-Collision Drop, Rigidity, Forbidden Sparsity Gap #print axioms SensitivityDecisionTrees.fourier_expansion #print axioms SensitivityDecisionTrees.fourier_autocorr #print axioms SensitivityDecisionTrees.parseval #print axioms SensitivityDecisionTrees.boolean_fourier_autocorr_zero #print axioms SensitivityDecisionTrees.parityDepth_le_detDepth #print axioms SensitivityDecisionTrees.parityCertSide_le_certSide #print axioms SensitivityDecisionTrees.parityCertAt_le_parityDepth #print axioms SensitivityDecisionTrees.parityCertSide_le_parityDepth #print axioms SensitivityDecisionTrees.parityCert_le_parityDepth #print axioms SensitivityDecisionTrees.deg2_le_parityDepth #print axioms SensitivityDecisionTrees.granularity_add_one_le_parityDepth #print axioms SensitivityDecisionTrees.spectralNorm_le_two_pow_parityDepth_sub_one #print axioms SensitivityDecisionTrees.fourierSparsity_le_four_pow_parityDepth_sub_one #print axioms SensitivityDecisionTrees.fourierCoeff_parityRestrict #print axioms SensitivityDecisionTrees.signed_collision_L1_drop #print axioms SensitivityDecisionTrees.spectralNorm_gap_ge_two #print axioms SensitivityDecisionTrees.spectralNorm_eq_two_rigidity #print axioms SensitivityDecisionTrees.fourierSparsity_forbidden_gap #print axioms SensitivityDecisionTrees.parityDepth_le_parityCert0_mul_parityCert1 -- Pillar 4: Exact Infinite-Family Sharpness & Separations #print axioms SensitivityDecisionTrees.parityFun_exact_invariants #print axioms SensitivityDecisionTrees.andOr_exact_invariants #print axioms SensitivityDecisionTrees.innerProd_exact_invariants #print axioms SensitivityDecisionTrees.andFun_signed_collision_exact #print axioms SensitivityDecisionTrees.rubinstein_exact_separation #print axioms SensitivityDecisionTrees.maj3_exact_invariants