import Mathlib.Data.ZMod.Basic import Mathlib.Data.Finset.Powerset import Mathlib.Data.Finset.Sort import Mathlib.Data.Nat.Choose.Central import Mathlib.Data.Nat.Factorial.Basic import Mathlib.GroupTheory.Perm.Fin import Mathlib.Analysis.SpecialFunctions.Log.Basic import Mathlib.Analysis.SpecialFunctions.Log.Deriv import Mathlib.Analysis.SpecialFunctions.ExpDeriv import Mathlib.Analysis.SpecialFunctions.Trigonometric.Basic import Mathlib.Analysis.SpecialFunctions.Trigonometric.DerivHyp import Mathlib.Analysis.Convex.SpecificFunctions.Basic import Mathlib.Analysis.Convex.Jensen import Mathlib.Analysis.Calculus.MeanValue import Mathlib.Tactic /-! # A Sub-Gaussian Bollobás Lower Bound for Fonollosa's Minimum-Modulus Problem This file proves a new asymptotic lower bound for the minimum modulus `N` admitting a valid `n`-element residue set `A ⊆ ZMod N` in Fonollosa's unique multiset-sum problem (`arXiv:2607.08366`, formalized in `FormalConjectures/Arxiv/2607.08366/MinModulus.lean`). ## Main Results 1. **Bollobás Two-Families Inequality** (`bollobas_two_families`): Self-contained Katona random-permutation proof that for any cross-intersecting family `ℱ` of disjoint set pairs `(S, T)` in a finite ground set, `∑ p ∈ ℱ, (Nat.choose (|p.1|+|p.2|) |p.1|)⁻¹ ≤ 1`. 2. **Sub-Gaussian Hypercube Tail Bound** (`subgaussian_cube_sum_bound`): Self-contained proof of `Real.cosh x ≤ Real.exp (x ^ 2 / 2)`, the exact Boolean-cube MGF, and the resulting Jensen–Hoeffding upper bound on `∑ S ∈ E₁, (|S| - m/2) + ∑ T ∈ E₂, (m/2 - |T|)`. 3. **Level-Preserving Collision Bounds** (`card_same_le_half`, `card_same_le_seven_sixteenths`): For a valid `n`-set `A ⊆ ZMod N` containing `0` and any `a ∈ A \ {0}`: - If `2 * a ≠ 0`, at most `2 ^ (n - 3)` subset sums of `A \ {0, a}` preserve cardinality under `+ 2 * a`. - If `4 * a ≠ 0` (which always exists for `n ≥ 5` by cyclicity of `ZMod N`), at most `(7 / 16) * 2 ^ (n - 2)` subset sums preserve cardinality under `+ 2 * a`. 4. **Main World-Record Lower Bounds**: - `fonollosa_subgaussian_implicit_ge_three`: for every `n ≥ 3` and valid `n`-set `A ⊆ ZMod N`, letting `t = N - 2 ^ (n - 1)`, we have `1 ≤ t` and `(1 / 2) * 2 ^ (n - 2) ≤ t * (1 + √(2 * (n - 2) * log (2 ^ (n - 2) / t)))`. - `fonollosa_subgaussian_implicit_ge_five`: for every `n ≥ 5` and valid `n`-set `A ⊆ ZMod N`, letting `t = N - 2 ^ (n - 1)`, we have `1 ≤ t` and `(9 / 16) * 2 ^ (n - 2) ≤ t * (1 + √(2 * (n - 2) * log (2 ^ (n - 2) / t)))`. - `fonollosa_explicit_lower_bound`: for every `n ≥ 5` and valid `n`-set `A ⊆ ZMod N`, `2 ^ (n - 1) + (9 / 16) * 2 ^ (n - 2) / (1 + √(2 * (n - 2) * log (4 * (n - 2)))) ≤ N`. - `fonollosa_beats_sitjar_asymptotically`: for every `C : ℝ`, there exists `n₀ : ℕ` such that for all `n ≥ n₀` and every valid `n`-set `A ⊆ ZMod N`, `N - 2 ^ (n - 1) ≥ C * (2 ^ (n - 1) / (n - 1))`, strictly beating Sitjar's (Nov 2026) `2 ^ (n - 1) + Θ(2 ^ n / n)` bound by an unbounded factor of `Θ(√(n / log n))`. -/ open Finset BigOperators namespace FonollosaLowerBound /-! ## Section 1: Bollobás Two-Families Inequality (Katona's Permutation Proof) -/ section Bollobas /-- Permutations of `Fin M` in which every element of `A` precedes every element of `B`. -/ def goodPerms {M : ℕ} (A B : Finset (Fin M)) : Finset (Equiv.Perm (Fin M)) := Finset.univ.filter fun π => ∀ a ∈ A, ∀ b ∈ B, π a < π b lemma mem_goodPerms {M : ℕ} {A B : Finset (Fin M)} {π : Equiv.Perm (Fin M)} : π ∈ goodPerms A B ↔ ∀ a ∈ A, ∀ b ∈ B, π a < π b := by simp [goodPerms] /-- If `A₁ ∩ B₂ ≠ ∅` and `A₂ ∩ B₁ ≠ ∅`, no permutation places both `A₁` before `B₁` and `A₂` before `B₂`. -/ lemma disjoint_goodPerms {M : ℕ} {A₁ B₁ A₂ B₂ : Finset (Fin M)} (h12 : ¬ Disjoint A₁ B₂) (h21 : ¬ Disjoint A₂ B₁) : Disjoint (goodPerms A₁ B₁) (goodPerms A₂ B₂) := by rw [Finset.disjoint_left] intro π hπ1 hπ2 rw [mem_goodPerms] at hπ1 hπ2 rw [Finset.not_disjoint_iff] at h12 h21 obtain ⟨x, hxA1, hxB2⟩ := h12 obtain ⟨y, hyA2, hyB1⟩ := h21 exact lt_asymm (hπ1 x hxA1 y hyB1) (hπ2 y hyA2 x hxB2) /-- Right-composing by a permutation sending `A₁ ↦ A₂` and `B₁ ↦ B₂` gives a bijection between `goodPerms A₂ B₂` and `goodPerms A₁ B₁`. -/ lemma card_goodPerms_eq_of_card_eq {M : ℕ} {A₁ B₁ A₂ B₂ : Finset (Fin M)} (hdisj₁ : Disjoint A₁ B₁) (hdisj₂ : Disjoint A₂ B₂) (hA : A₁.card = A₂.card) (hB : B₁.card = B₂.card) : (goodPerms A₁ B₁).card = (goodPerms A₂ B₂).card := by have hU12 : (A₁ ∪ B₁).card = (A₂ ∪ B₂).card := by rw [Finset.card_union_of_disjoint hdisj₁, Finset.card_union_of_disjoint hdisj₂, hA, hB] have hC12 : (A₁ ∪ B₁)ᶜ.card = (A₂ ∪ B₂)ᶜ.card := by rw [Finset.card_compl, Finset.card_compl, hU12] let eA : {x // x ∈ A₁} ≃ {y // y ∈ A₂} := Fintype.equivOfCardEq (by rw [Fintype.card_coe, Fintype.card_coe, hA]) let eB : {x // x ∈ B₁} ≃ {y // y ∈ B₂} := Fintype.equivOfCardEq (by rw [Fintype.card_coe, Fintype.card_coe, hB]) let eC : {x // x ∈ (A₁ ∪ B₁)ᶜ} ≃ {y // y ∈ (A₂ ∪ B₂)ᶜ} := Fintype.equivOfCardEq (by rw [Fintype.card_coe, Fintype.card_coe, hC12]) let f : Fin M → Fin M := fun x => if hxA : x ∈ A₁ then (eA ⟨x, hxA⟩).1 else if hxB : x ∈ B₁ then (eB ⟨x, hxB⟩).1 else (eC ⟨x, by simp [hxA, hxB]⟩).1 let g : Fin M → Fin M := fun y => if hyA : y ∈ A₂ then (eA.symm ⟨y, hyA⟩).1 else if hyB : y ∈ B₂ then (eB.symm ⟨y, hyB⟩).1 else (eC.symm ⟨y, by simp [hyA, hyB]⟩).1 have hfg : Function.LeftInverse g f := by intro x by_cases hxA : x ∈ A₁ · have hf : f x = (eA ⟨x, hxA⟩).1 := by simp [f, hxA] have hmem : (eA ⟨x, hxA⟩).1 ∈ A₂ := (eA ⟨x, hxA⟩).2 rw [hf] simp only [g, dif_pos hmem, Subtype.coe_eta, Equiv.symm_apply_apply] · by_cases hxB : x ∈ B₁ · have hf : f x = (eB ⟨x, hxB⟩).1 := by simp [f, hxA, hxB] have hmem : (eB ⟨x, hxB⟩).1 ∈ B₂ := (eB ⟨x, hxB⟩).2 have hnotA : (eB ⟨x, hxB⟩).1 ∉ A₂ := Finset.disjoint_right.mp hdisj₂ hmem rw [hf] simp only [g, dif_neg hnotA, dif_pos hmem, Subtype.coe_eta, Equiv.symm_apply_apply] · have hxC : x ∈ (A₁ ∪ B₁)ᶜ := by simp [hxA, hxB] have hf : f x = (eC ⟨x, hxC⟩).1 := by simp [f, hxA, hxB] have hmem : (eC ⟨x, hxC⟩).1 ∈ (A₂ ∪ B₂)ᶜ := (eC ⟨x, hxC⟩).2 have hnotA : (eC ⟨x, hxC⟩).1 ∉ A₂ := fun h => (Finset.mem_compl.mp hmem) (Finset.mem_union_left _ h) have hnotB : (eC ⟨x, hxC⟩).1 ∉ B₂ := fun h => (Finset.mem_compl.mp hmem) (Finset.mem_union_right _ h) rw [hf] simp only [g, dif_neg hnotA, dif_neg hnotB, Subtype.coe_eta, Equiv.symm_apply_apply] have hgf : Function.RightInverse g f := by intro y by_cases hyA : y ∈ A₂ · have hg : g y = (eA.symm ⟨y, hyA⟩).1 := by simp [g, hyA] have hmem : (eA.symm ⟨y, hyA⟩).1 ∈ A₁ := (eA.symm ⟨y, hyA⟩).2 rw [hg] simp only [f, dif_pos hmem, Subtype.coe_eta, Equiv.apply_symm_apply] · by_cases hyB : y ∈ B₂ · have hg : g y = (eB.symm ⟨y, hyB⟩).1 := by simp [g, hyA, hyB] have hmem : (eB.symm ⟨y, hyB⟩).1 ∈ B₁ := (eB.symm ⟨y, hyB⟩).2 have hnotA : (eB.symm ⟨y, hyB⟩).1 ∉ A₁ := Finset.disjoint_right.mp hdisj₁ hmem rw [hg] simp only [f, dif_neg hnotA, dif_pos hmem, Subtype.coe_eta, Equiv.apply_symm_apply] · have hyC : y ∈ (A₂ ∪ B₂)ᶜ := by simp [hyA, hyB] have hg : g y = (eC.symm ⟨y, hyC⟩).1 := by simp [g, hyA, hyB] have hmem : (eC.symm ⟨y, hyC⟩).1 ∈ (A₁ ∪ B₁)ᶜ := (eC.symm ⟨y, hyC⟩).2 have hnotA : (eC.symm ⟨y, hyC⟩).1 ∉ A₁ := fun h => (Finset.mem_compl.mp hmem) (Finset.mem_union_left _ h) have hnotB : (eC.symm ⟨y, hyC⟩).1 ∉ B₁ := fun h => (Finset.mem_compl.mp hmem) (Finset.mem_union_right _ h) rw [hg] simp only [f, dif_neg hnotA, dif_neg hnotB, Subtype.coe_eta, Equiv.apply_symm_apply] let σ : Equiv.Perm (Fin M) := ⟨f, g, hfg, hgf⟩ have hσA : ∀ x ∈ A₁, σ x ∈ A₂ := fun x hx => by change f x ∈ A₂; simp only [f, dif_pos hx]; exact (eA ⟨x, hx⟩).2 have hσB : ∀ x ∈ B₁, σ x ∈ B₂ := fun x hx => by have hxnotA : x ∉ A₁ := Finset.disjoint_right.mp hdisj₁ hx change f x ∈ B₂; simp only [f, dif_neg hxnotA, dif_pos hx]; exact (eB ⟨x, hx⟩).2 have hσsymA : ∀ y ∈ A₂, σ.symm y ∈ A₁ := fun y hy => by change g y ∈ A₁; simp only [g, dif_pos hy]; exact (eA.symm ⟨y, hy⟩).2 have hσsymB : ∀ y ∈ B₂, σ.symm y ∈ B₁ := fun y hy => by have hynotA : y ∉ A₂ := Finset.disjoint_right.mp hdisj₂ hy change g y ∈ B₁; simp only [g, dif_neg hynotA, dif_pos hy]; exact (eB.symm ⟨y, hy⟩).2 refine Finset.card_bij (fun π _ => π * σ⁻¹) ?_ ?_ ?_ · intro π hπ rw [mem_goodPerms] at hπ ⊢ intro a ha b hb simpa [Equiv.Perm.mul_apply] using hπ (σ.symm a) (hσsymA a ha) (σ.symm b) (hσsymB b hb) · intro π₁ _ π₂ _ h exact mul_right_cancel h · intro τ hτ refine ⟨τ * σ, ?_, by simp [mul_assoc]⟩ rw [mem_goodPerms] at hτ ⊢ intro a ha b hb simpa [Equiv.Perm.mul_apply] using hτ (σ a) (hσA a ha) (σ b) (hσB b hb) /-- Exact count of permutations placing `A` before `B`: `(goodPerms A B).card * (A.card + B.card).choose A.card = M!`. -/ lemma card_goodPerms_mul_choose {M : ℕ} {A B : Finset (Fin M)} (hdisj : Disjoint A B) : (goodPerms A B).card * (A.card + B.card).choose A.card = M.factorial := by set U := A ∪ B with hU_def set k := A.card with hk_def have hUcard : U.card = A.card + B.card := Finset.card_union_of_disjoint hdisj have hdisj_fam : (U.powersetCard k : Set (Finset (Fin M))).PairwiseDisjoint (fun C => goodPerms C (U \ C)) := by intro C₁ hC₁ C₂ hC₂ hne rw [Finset.mem_coe, Finset.mem_powersetCard] at hC₁ hC₂ have h12 : ¬ Disjoint C₁ (U \ C₂) := by have hnsub : ¬ C₁ ⊆ C₂ := fun hsub => hne (Finset.eq_of_subset_of_card_le hsub (by omega)) obtain ⟨x, hx1, hx2⟩ := Finset.not_subset.mp hnsub exact Finset.not_disjoint_iff.mpr ⟨x, hx1, Finset.mem_sdiff.mpr ⟨hC₁.1 hx1, hx2⟩⟩ have h21 : ¬ Disjoint C₂ (U \ C₁) := by have hnsub : ¬ C₂ ⊆ C₁ := fun hsub => hne.symm (Finset.eq_of_subset_of_card_le hsub (by omega)) obtain ⟨y, hy2, hy1⟩ := Finset.not_subset.mp hnsub exact Finset.not_disjoint_iff.mpr ⟨y, hy2, Finset.mem_sdiff.mpr ⟨hC₂.1 hy2, hy1⟩⟩ exact disjoint_goodPerms h12 h21 have hcover : (U.powersetCard k).biUnion (fun C => goodPerms C (U \ C)) = Finset.univ := by ext π simp only [Finset.mem_biUnion, Finset.mem_powersetCard, Finset.mem_univ, iff_true] set V := U.image π with hV_def have hVcard : V.card = U.card := Finset.card_image_of_injective U π.injective have hk_le : k ≤ V.card := by omega let emb : Fin V.card ↪o Fin M := V.orderEmbOfFin rfl let Cvals : Finset (Fin M) := (Finset.univ : Finset (Fin k)).image (fun i => emb ⟨i.val, lt_of_lt_of_le i.isLt hk_le⟩) let C : Finset (Fin M) := Cvals.image π.symm have hCvals_sub : Cvals ⊆ V := by intro v hv rcases Finset.mem_image.mp hv with ⟨i, _, rfl⟩ exact Finset.orderEmbOfFin_mem V rfl _ have hCsub : C ⊆ U := by intro x hx rcases Finset.mem_image.mp hx with ⟨v, hv, rfl⟩ have hvV := hCvals_sub hv rcases Finset.mem_image.mp hvV with ⟨u, huU, rfl⟩ simpa using huU have hCvals_card : Cvals.card = k := by rw [Finset.card_image_of_injective] · simp · intro i j hij have := emb.injective hij exact Fin.ext (by simpa using congrArg Fin.val this) have hCcard : C.card = k := by rw [Finset.card_image_of_injective _ π.symm.injective, hCvals_card] refine ⟨C, ⟨hCsub, hCcard⟩, ?_⟩ rw [mem_goodPerms] intro a ha b hb rcases Finset.mem_sdiff.mp hb with ⟨hbU, hbnotC⟩ have haV : π a ∈ Cvals := by rcases Finset.mem_image.mp ha with ⟨v, hv, rfl⟩ simpa using hv have hbV : π b ∈ V := Finset.mem_image_of_mem π hbU have hbnotCvals : π b ∉ Cvals := fun h => hbnotC (Finset.mem_image.mpr ⟨π b, h, by simp⟩) rcases Finset.mem_image.mp haV with ⟨ia, _, hia⟩ have hrange : Set.range emb = (V : Set (Fin M)) := Finset.range_orderEmbOfFin V rfl have hbmem : π b ∈ Set.range emb := by rw [hrange]; exact hbV rcases hbmem with ⟨ib, hib⟩ have hib_ge : k ≤ ib.val := by by_contra hlt have hlt' : ib.val < k := Nat.lt_of_not_ge hlt apply hbnotCvals exact Finset.mem_image.mpr ⟨⟨ib.val, hlt'⟩, Finset.mem_univ _, by simpa using hib⟩ rw [← hia, ← hib] exact emb.strictMono (Fin.mk_lt_mk.mpr (lt_of_lt_of_le ia.isLt hib_ge)) have hcard_eq : ∀ C ∈ U.powersetCard k, (goodPerms C (U \ C)).card = (goodPerms A B).card := by intro C hC rw [Finset.mem_powersetCard] at hC refine card_goodPerms_eq_of_card_eq disjoint_sdiff_self_right hdisj hC.2 ?_ have hsd := Finset.card_sdiff_add_card_eq_card hC.1 omega have hsum := Finset.card_biUnion hdisj_fam rw [hcover, Finset.card_univ, Fintype.card_perm, Fintype.card_fin] at hsum rw [Finset.sum_congr rfl hcard_eq, Finset.sum_const, smul_eq_mul, Finset.card_powersetCard, hUcard, mul_comm] at hsum exact hsum.symm /-- **Bollobás's Two-Families Inequality (1965)** on `Fin M`: if `ℱ` is a family of disjoint pairs `(A, B)` in `Fin M` such that `A₁ ∩ B₂ ≠ ∅` for all distinct `(A₁, B₁), (A₂, B₂) ∈ ℱ`, then `∑ p ∈ ℱ, ((|p.1| + |p.2|).choose |p.1| : ℝ)⁻¹ ≤ 1`. -/ theorem bollobas_two_families_fin {M : ℕ} (ℱ : Finset (Finset (Fin M) × Finset (Fin M))) (hdisj : ∀ p ∈ ℱ, Disjoint p.1 p.2) (hcross : ∀ p ∈ ℱ, ∀ q ∈ ℱ, p ≠ q → ¬ Disjoint p.1 q.2) : ∑ p ∈ ℱ, (((p.1.card + p.2.card).choose p.1.card : ℝ))⁻¹ ≤ 1 := by have hpw : (ℱ : Set (Finset (Fin M) × Finset (Fin M))).PairwiseDisjoint (fun p => goodPerms p.1 p.2) := by intro p hp q hq hne exact disjoint_goodPerms (hcross p hp q hq hne) (hcross q hq p hp hne.symm) have hcard_le : ∑ p ∈ ℱ, (goodPerms p.1 p.2).card ≤ M.factorial := by calc ∑ p ∈ ℱ, (goodPerms p.1 p.2).card = (ℱ.biUnion (fun p => goodPerms p.1 p.2)).card := (Finset.card_biUnion hpw).symm _ ≤ (Finset.univ : Finset (Equiv.Perm (Fin M))).card := Finset.card_le_card (Finset.subset_univ _) _ = M.factorial := by rw [Finset.card_univ, Fintype.card_perm, Fintype.card_fin] have hfac_pos : (0 : ℝ) < (M.factorial : ℝ) := Nat.cast_pos.mpr (Nat.factorial_pos M) have hterm : ∀ p ∈ ℱ, (((p.1.card + p.2.card).choose p.1.card : ℝ))⁻¹ = ((goodPerms p.1 p.2).card : ℝ) / (M.factorial : ℝ) := by intro p hp have hmul : ((goodPerms p.1 p.2).card : ℝ) * ((p.1.card + p.2.card).choose p.1.card : ℝ) = (M.factorial : ℝ) := by exact_mod_cast card_goodPerms_mul_choose (hdisj p hp) have hch_pos : (0 : ℝ) < ((p.1.card + p.2.card).choose p.1.card : ℝ) := Nat.cast_pos.mpr (Nat.choose_pos (Nat.le_add_right _ _)) rw [eq_div_iff hfac_pos.ne', inv_mul_eq_iff_eq_mul₀ hch_pos.ne', mul_comm] exact hmul.symm rw [Finset.sum_congr rfl hterm, ← Finset.sum_div, div_le_one hfac_pos] exact_mod_cast hcard_le /-- **Bollobás's Two-Families Inequality** on an arbitrary finite type `α`. -/ theorem bollobas_two_families {α : Type*} [Fintype α] [DecidableEq α] (ℱ : Finset (Finset α × Finset α)) (hdisj : ∀ p ∈ ℱ, Disjoint p.1 p.2) (hcross : ∀ p ∈ ℱ, ∀ q ∈ ℱ, p ≠ q → ¬ Disjoint p.1 q.2) : ∑ p ∈ ℱ, (((p.1.card + p.2.card).choose p.1.card : ℝ))⁻¹ ≤ 1 := by let e : α ≃ Fin (Fintype.card α) := Fintype.equivFin α let mapPair : Finset α × Finset α → Finset (Fin (Fintype.card α)) × Finset (Fin (Fintype.card α)) := fun p => (p.1.map e.toEmbedding, p.2.map e.toEmbedding) have hmap_inj : Function.Injective mapPair := by intro p q h have h1 := congrArg Prod.fst h have h2 := congrArg Prod.snd h exact Prod.ext (Finset.map_injective e.toEmbedding h1) (Finset.map_injective e.toEmbedding h2) let ℱ' := ℱ.image mapPair have hdisj' : ∀ p' ∈ ℱ', Disjoint p'.1 p'.2 := by intro p' hp' rcases Finset.mem_image.mp hp' with ⟨p, hp, rfl⟩ rw [Finset.disjoint_left] intro y hy1 hy2 rcases Finset.mem_map.mp hy1 with ⟨x1, hx1, rfl⟩ rcases Finset.mem_map.mp hy2 with ⟨x2, hx2, hEq⟩ have hxEq : x2 = x1 := e.injective hEq subst hxEq exact Finset.disjoint_left.mp (hdisj p hp) hx1 hx2 have hcross' : ∀ p' ∈ ℱ', ∀ q' ∈ ℱ', p' ≠ q' → ¬ Disjoint p'.1 q'.2 := by intro p' hp' q' hq' hne rcases Finset.mem_image.mp hp' with ⟨p, hp, rfl⟩ rcases Finset.mem_image.mp hq' with ⟨q, hq, rfl⟩ have hpq : p ≠ q := fun h => hne (by rw [h]) intro hd apply hcross p hp q hq hpq rw [Finset.disjoint_left] intro x hx1 hx2 exact Finset.disjoint_left.mp hd (Finset.mem_map_of_mem e.toEmbedding hx1) (Finset.mem_map_of_mem e.toEmbedding hx2) have hbound := bollobas_two_families_fin ℱ' hdisj' hcross' rw [Finset.sum_image (fun x _ y _ h => hmap_inj h)] at hbound simpa [mapPair] using hbound /-- Recurrence for central binomial coefficients: `(k + 1) * C(2(k+1), k+1) = 2 * (2k + 1) * C(2k, k)`. -/ lemma centralBinom_recurrence (k : ℕ) : (k + 1) * (2 * (k + 1)).choose (k + 1) = 2 * (2 * k + 1) * (2 * k).choose k := by have h1 : (2 * k + 2) * (2 * k + 1).choose k = (2 * k + 2).choose (k + 1) * (k + 1) := Nat.add_one_mul_choose_eq (2 * k + 1) k have h2 : (2 * k + 1) * (2 * k).choose k = (2 * k + 1).choose (k + 1) * (k + 1) := Nat.add_one_mul_choose_eq (2 * k) k have hsym : (2 * k + 1).choose k = (2 * k + 1).choose (k + 1) := by have h := @Nat.choose_symm_add k (k + 1) simpa [show k + (k + 1) = 2 * k + 1 by omega] using h have h2k : 2 * (k + 1) = 2 * k + 2 := by omega rw [h2k] nlinarith [h1, h2, hsym] /-- For every `r ≥ 1`, `C(2r, r) ≤ 2 ^ (2r - 1)`. -/ lemma centralBinom_le_half_four_pow {r : ℕ} (hr : 1 ≤ r) : (2 * r).choose r ≤ 2 ^ (2 * r - 1) := by induction r with | zero => omega | succ k ih => cases k with | zero => decide | succ j => have hprev := ih (by omega) have hrec := centralBinom_recurrence (j + 1) have hpow : 2 ^ (2 * (j + 2) - 1) = 4 * 2 ^ (2 * (j + 1) - 1) := by rw [show 2 * (j + 2) - 1 = (2 * (j + 1) - 1) + 2 by omega, pow_add]; ring rw [hpow] have hle2 : 2 * (2 * (j + 1) + 1) ≤ 4 * (j + 2) := by omega have hmul : (j + 2) * (2 * (j + 2)).choose (j + 2) ≤ (j + 2) * (4 * 2 ^ (2 * (j + 1) - 1)) := by calc (j + 2) * (2 * (j + 2)).choose (j + 2) = 2 * (2 * (j + 1) + 1) * (2 * (j + 1)).choose (j + 1) := hrec _ ≤ (4 * (j + 2)) * 2 ^ (2 * (j + 1) - 1) := Nat.mul_le_mul hle2 hprev _ = (j + 2) * (4 * 2 ^ (2 * (j + 1) - 1)) := by ring exact Nat.le_of_mul_le_mul_left hmul (by omega) /-- For every `r ≥ 2`, `8 * C(2r, r) ≤ 3 * 2 ^ (2r)`. -/ lemma eight_mul_centralBinom_le_three_mul_four_pow {r : ℕ} (hr : 2 ≤ r) : 8 * (2 * r).choose r ≤ 3 * 2 ^ (2 * r) := by induction r with | zero => omega | succ k ih => cases k with | zero => omega | succ j => cases j with | zero => decide | succ i => have hprev := ih (by omega) have hrec := centralBinom_recurrence (i + 2) have hpow : 2 ^ (2 * (i + 3)) = 4 * 2 ^ (2 * (i + 2)) := by rw [show 2 * (i + 3) = 2 * (i + 2) + 2 by omega, pow_add]; ring rw [hpow] have hle2 : 2 * (2 * (i + 2) + 1) ≤ 4 * (i + 3) := by omega have hmul : (i + 3) * (8 * (2 * (i + 3)).choose (i + 3)) ≤ (i + 3) * (3 * (4 * 2 ^ (2 * (i + 2)))) := by calc (i + 3) * (8 * (2 * (i + 3)).choose (i + 3)) = 8 * ((i + 3) * (2 * (i + 3)).choose (i + 3)) := by ring _ = 8 * (2 * (2 * (i + 2) + 1) * (2 * (i + 2)).choose (i + 2)) := by rw [hrec] _ = (2 * (2 * (i + 2) + 1)) * (8 * (2 * (i + 2)).choose (i + 2)) := by ring _ ≤ (4 * (i + 3)) * (3 * 2 ^ (2 * (i + 2))) := Nat.mul_le_mul hle2 hprev _ = (i + 3) * (3 * (4 * 2 ^ (2 * (i + 2)))) := by ring exact Nat.le_of_mul_le_mul_left hmul (by omega) /-- Subcube weight bound (general `1/2` bound): if `ℱ` is a Bollobás family of balanced nonempty pairs (`|S| = |T| ≥ 1`), then `∑ p ∈ ℱ, 2 ^ (-2 * |p.1|) ≤ 1 / 2`. -/ lemma bollobas_balanced_weight_le_half {α : Type*} [Fintype α] [DecidableEq α] (ℱ : Finset (Finset α × Finset α)) (hdisj : ∀ p ∈ ℱ, Disjoint p.1 p.2) (hcross : ∀ p ∈ ℱ, ∀ q ∈ ℱ, p ≠ q → ¬ Disjoint p.1 q.2) (hbal : ∀ p ∈ ℱ, p.1.card = p.2.card) (hpos : ∀ p ∈ ℱ, 1 ≤ p.1.card) : ∑ p ∈ ℱ, ((2 : ℝ) ^ (2 * p.1.card))⁻¹ ≤ 1 / 2 := by have hbol := bollobas_two_families ℱ hdisj hcross have hterm : ∀ p ∈ ℱ, ((2 : ℝ) ^ (2 * p.1.card))⁻¹ ≤ (1 / 2 : ℝ) * (((p.1.card + p.2.card).choose p.1.card : ℝ))⁻¹ := by intro p hp have hbalp := hbal p hp have hposp := hpos p hp rw [← hbalp, ← two_mul] have hcb : ((2 * p.1.card).choose p.1.card : ℝ) ≤ (2 : ℝ) ^ (2 * p.1.card - 1) := by exact_mod_cast centralBinom_le_half_four_pow hposp have hpow : (2 : ℝ) ^ (2 * p.1.card) = 2 * (2 : ℝ) ^ (2 * p.1.card - 1) := by rw [← pow_succ', show 2 * p.1.card - 1 + 1 = 2 * p.1.card by omega] have hch_pos : (0 : ℝ) < ((2 * p.1.card).choose p.1.card : ℝ) := Nat.cast_pos.mpr (Nat.choose_pos (by omega)) have h2_pos : (0 : ℝ) < (2 : ℝ) ^ (2 * p.1.card) := by positivity rw [one_div, ← mul_inv, inv_le_inv₀ h2_pos (by positivity), hpow] linarith calc ∑ p ∈ ℱ, ((2 : ℝ) ^ (2 * p.1.card))⁻¹ ≤ ∑ p ∈ ℱ, (1 / 2 : ℝ) * (((p.1.card + p.2.card).choose p.1.card : ℝ))⁻¹ := Finset.sum_le_sum hterm _ = (1 / 2 : ℝ) * ∑ p ∈ ℱ, (((p.1.card + p.2.card).choose p.1.card : ℝ))⁻¹ := by rw [← Finset.mul_sum] _ ≤ (1 / 2 : ℝ) * 1 := by linarith _ = 1 / 2 := by ring /-- Refined subcube weight bound (`7/16` bound): if `ℱ` is a Bollobás family of balanced nonempty pairs (`|S| = |T| ≥ 1`) with at most ONE pair of size `(1, 1)`, then `∑ p ∈ ℱ, 2 ^ (-2 * |p.1|) ≤ 7 / 16`. -/ lemma bollobas_balanced_weight_le_seven_sixteenths {α : Type*} [Fintype α] [DecidableEq α] (ℱ : Finset (Finset α × Finset α)) (hdisj : ∀ p ∈ ℱ, Disjoint p.1 p.2) (hcross : ∀ p ∈ ℱ, ∀ q ∈ ℱ, p ≠ q → ¬ Disjoint p.1 q.2) (hbal : ∀ p ∈ ℱ, p.1.card = p.2.card) (hpos : ∀ p ∈ ℱ, 1 ≤ p.1.card) (hone : (ℱ.filter (fun p => p.1.card = 1)).card ≤ 1) : ∑ p ∈ ℱ, ((2 : ℝ) ^ (2 * p.1.card))⁻¹ ≤ 7 / 16 := by have hbol := bollobas_two_families ℱ hdisj hcross set ℱ₁ := ℱ.filter (fun p => p.1.card = 1) set ℱ₂ := ℱ.filter (fun p => p.1.card ≠ 1) have hsplit_w : ∑ p ∈ ℱ, ((2 : ℝ) ^ (2 * p.1.card))⁻¹ = ∑ p ∈ ℱ₁, ((2 : ℝ) ^ (2 * p.1.card))⁻¹ + ∑ p ∈ ℱ₂, ((2 : ℝ) ^ (2 * p.1.card))⁻¹ := (Finset.sum_filter_add_sum_filter_not ℱ (fun p => p.1.card = 1) _).symm have hsplit_b : ∑ p ∈ ℱ, (((p.1.card + p.2.card).choose p.1.card : ℝ))⁻¹ = ∑ p ∈ ℱ₁, (((p.1.card + p.2.card).choose p.1.card : ℝ))⁻¹ + ∑ p ∈ ℱ₂, (((p.1.card + p.2.card).choose p.1.card : ℝ))⁻¹ := (Finset.sum_filter_add_sum_filter_not ℱ (fun p => p.1.card = 1) _).symm have h1_w : ∑ p ∈ ℱ₁, ((2 : ℝ) ^ (2 * p.1.card))⁻¹ = (ℱ₁.card : ℝ) * (1 / 4 : ℝ) := by have hcongr : ∀ p ∈ ℱ₁, ((2 : ℝ) ^ (2 * p.1.card))⁻¹ = (1 / 4 : ℝ) := by intro p hp have hcard : p.1.card = 1 := (Finset.mem_filter.mp hp).2 rw [hcard]; norm_num rw [Finset.sum_congr rfl hcongr, Finset.sum_const, nsmul_eq_mul] have h1_b : ∑ p ∈ ℱ₁, (((p.1.card + p.2.card).choose p.1.card : ℝ))⁻¹ = (ℱ₁.card : ℝ) * (1 / 2 : ℝ) := by have hcongr : ∀ p ∈ ℱ₁, (((p.1.card + p.2.card).choose p.1.card : ℝ))⁻¹ = (1 / 2 : ℝ) := by intro p hp have hpℱ : p ∈ ℱ := (Finset.mem_filter.mp hp).1 have hcard : p.1.card = 1 := (Finset.mem_filter.mp hp).2 have hcard2 : p.2.card = 1 := by rw [← hbal p hpℱ, hcard] rw [hcard, hcard2]; norm_num rw [Finset.sum_congr rfl hcongr, Finset.sum_const, nsmul_eq_mul] have h2_le : ∑ p ∈ ℱ₂, ((2 : ℝ) ^ (2 * p.1.card))⁻¹ ≤ (3 / 8 : ℝ) * ∑ p ∈ ℱ₂, (((p.1.card + p.2.card).choose p.1.card : ℝ))⁻¹ := by rw [Finset.mul_sum] refine Finset.sum_le_sum fun p hp => ?_ have hpℱ : p ∈ ℱ := (Finset.mem_filter.mp hp).1 have hne1 : p.1.card ≠ 1 := (Finset.mem_filter.mp hp).2 have hge2 : 2 ≤ p.1.card := by have := hpos p hpℱ; omega have hbalp := hbal p hpℱ rw [← hbalp, ← two_mul] have hcb : (8 : ℝ) * ((2 * p.1.card).choose p.1.card : ℝ) ≤ 3 * (2 : ℝ) ^ (2 * p.1.card) := by exact_mod_cast eight_mul_centralBinom_le_three_mul_four_pow hge2 have hch_pos : (0 : ℝ) < ((2 * p.1.card).choose p.1.card : ℝ) := Nat.cast_pos.mpr (Nat.choose_pos (by omega)) have h2_pos : (0 : ℝ) < (2 : ℝ) ^ (2 * p.1.card) := by positivity rw [div_mul_eq_mul_div, le_div_iff₀ (by norm_num : (0 : ℝ) < 8)] have hmul : (8 : ℝ) * ((2 : ℝ) ^ (2 * p.1.card))⁻¹ ≤ 3 * (((2 * p.1.card).choose p.1.card : ℝ))⁻¹ := by rw [← div_eq_mul_inv, ← div_eq_mul_inv, div_le_div_iff₀ h2_pos hch_pos] linarith linarith have hℱ1_le : (ℱ₁.card : ℝ) ≤ 1 := by exact_mod_cast hone have h2_b_le : ∑ p ∈ ℱ₂, (((p.1.card + p.2.card).choose p.1.card : ℝ))⁻¹ ≤ 1 - (ℱ₁.card : ℝ) * (1 / 2 : ℝ) := by linarith [hbol, hsplit_b, h1_b] calc ∑ p ∈ ℱ, ((2 : ℝ) ^ (2 * p.1.card))⁻¹ = (ℱ₁.card : ℝ) * (1 / 4 : ℝ) + ∑ p ∈ ℱ₂, ((2 : ℝ) ^ (2 * p.1.card))⁻¹ := by rw [hsplit_w, h1_w] _ ≤ (ℱ₁.card : ℝ) * (1 / 4 : ℝ) + (3 / 8 : ℝ) * (1 - (ℱ₁.card : ℝ) * (1 / 2 : ℝ)) := by linarith [h2_le, h2_b_le] _ = 3 / 8 + (ℱ₁.card : ℝ) * (1 / 16) := by ring _ ≤ 3 / 8 + 1 * (1 / 16) := by linarith _ = 7 / 16 := by ring end Bollobas /-! ## Section 2: Sub-Gaussian Hypercube Tail Bound -/ section SubGaussian /-- Elementary inequality `sinh x ≤ x * cosh x` for `0 ≤ x`. -/ lemma sinh_le_mul_cosh {x : ℝ} (hx : 0 ≤ x) : Real.sinh x ≤ x * Real.cosh x := by let φ : ℝ → ℝ := fun t => t * Real.cosh t - Real.sinh t have hderiv : ∀ t, HasDerivAt φ (t * Real.sinh t) t := fun t => by have h1 : HasDerivAt (fun s : ℝ => s * Real.cosh s) (1 * Real.cosh t + t * Real.sinh t) t := (hasDerivAt_id t).mul (Real.hasDerivAt_cosh t) have h2 := Real.hasDerivAt_sinh t have hsub := h1.sub h2 rwa [show (1 : ℝ) * Real.cosh t + t * Real.sinh t - Real.cosh t = t * Real.sinh t by ring] at hsub have hmono : MonotoneOn φ (Set.Ici 0) := by refine monotoneOn_of_deriv_nonneg (convex_Ici 0) ?_ ?_ ?_ · exact fun t _ => (hderiv t).continuousAt.continuousWithinAt · exact fun t _ => (hderiv t).differentiableAt.differentiableWithinAt · intro t ht rw [interior_Ici] at ht rw [(hderiv t).deriv] exact mul_nonneg ht.le (Real.sinh_nonneg_iff.mpr ht.le) have h0 : φ 0 ≤ φ x := hmono (Set.mem_Ici.mpr (le_refl 0)) hx hx simp only [φ, zero_mul, Real.sinh_zero, sub_zero] at h0 linarith /-- Classic sub-Gaussian inequality `cosh x ≤ exp (x ^ 2 / 2)` for all `x : ℝ`. -/ lemma cosh_le_exp_half_sq (x : ℝ) : Real.cosh x ≤ Real.exp (x ^ 2 / 2) := by suffices hnonneg : ∀ y : ℝ, 0 ≤ y → Real.cosh y ≤ Real.exp (y ^ 2 / 2) by rcases le_total 0 x with hx | hx · exact hnonneg x hx · have := hnonneg (-x) (neg_nonneg.mpr hx) simpa [Real.cosh_neg] using this intro y hy let g : ℝ → ℝ := fun t => Real.exp (-(t ^ 2 / 2)) * Real.cosh t have hderiv : ∀ t, HasDerivAt g (Real.exp (-(t ^ 2 / 2)) * (Real.sinh t - t * Real.cosh t)) t := by intro t have hsq : HasDerivAt (fun s : ℝ => -(s ^ 2 / 2)) (-t) t := by have h1 : HasDerivAt (fun s : ℝ => s ^ 2) (2 * t) t := by simpa using hasDerivAt_pow 2 t have h2 : HasDerivAt (fun s : ℝ => -(s ^ 2 / 2)) (-(2 * t / 2)) t := (h1.div_const 2).neg rwa [show -(2 * t / 2) = -t by ring] at h2 have hexp : HasDerivAt (fun s : ℝ => Real.exp (-(s ^ 2 / 2))) (Real.exp (-(t ^ 2 / 2)) * (-t)) t := hsq.exp have hprod := hexp.mul (Real.hasDerivAt_cosh t) rwa [show Real.exp (-(t ^ 2 / 2)) * -t * Real.cosh t + Real.exp (-(t ^ 2 / 2)) * Real.sinh t = Real.exp (-(t ^ 2 / 2)) * (Real.sinh t - t * Real.cosh t) by ring] at hprod have hanti : AntitoneOn g (Set.Ici 0) := by refine antitoneOn_of_deriv_nonpos (convex_Ici 0) ?_ ?_ ?_ · exact fun t _ => (hderiv t).continuousAt.continuousWithinAt · exact fun t _ => (hderiv t).differentiableAt.differentiableWithinAt · intro t ht rw [interior_Ici] at ht rw [(hderiv t).deriv] have hsub : Real.sinh t - t * Real.cosh t ≤ 0 := by linarith [sinh_le_mul_cosh ht.le] exact mul_nonpos_of_nonneg_of_nonpos (Real.exp_pos _).le hsub have hle : g y ≤ g 0 := hanti (Set.mem_Ici.mpr (le_refl 0)) hy hy simp only [g, sq, zero_mul, zero_div, neg_zero, Real.exp_zero, Real.cosh_zero, mul_one] at hle have hpos : 0 < Real.exp (y ^ 2 / 2) := Real.exp_pos _ calc Real.cosh y = Real.exp (y ^ 2 / 2) * (Real.exp (-(y ^ 2 / 2)) * Real.cosh y) := by rw [← mul_assoc, ← Real.exp_add, add_neg_cancel, Real.exp_zero, one_mul] _ ≤ Real.exp (y ^ 2 / 2) * 1 := by have : Real.exp (-(y ^ 2 / 2)) * Real.cosh y ≤ 1 := by simpa [sq] using hle exact mul_le_mul_of_nonneg_left this hpos.le _ = Real.exp (y ^ 2 / 2) := mul_one _ /-- Exact moment generating function on the Boolean cube `U.powerset`: `∑ S ∈ U.powerset, exp (λ * (|S| - |U| / 2)) = 2 ^ |U| * (cosh (λ / 2)) ^ |U|`. -/ lemma sum_powerset_exp_centered {α : Type*} [DecidableEq α] (U : Finset α) (lam : ℝ) : ∑ S ∈ U.powerset, Real.exp (lam * ((S.card : ℝ) - (U.card : ℝ) / 2)) = (2 : ℝ) ^ U.card * (Real.cosh (lam / 2)) ^ U.card := by induction U using Finset.induction_on with | empty => simp | @insert a U ha ih => rw [Finset.powerset_insert, Finset.sum_union] · have hcardU : ((insert a U).card : ℝ) = (U.card : ℝ) + 1 := by rw [Finset.card_insert_of_notMem ha]; push_cast; ring have h1 : ∑ S ∈ U.powerset, Real.exp (lam * ((S.card : ℝ) - ((insert a U).card : ℝ) / 2)) = Real.exp (-(lam / 2)) * ∑ S ∈ U.powerset, Real.exp (lam * ((S.card : ℝ) - (U.card : ℝ) / 2)) := by rw [Finset.mul_sum] refine Finset.sum_congr rfl fun S _ => ?_ rw [hcardU, ← Real.exp_add] congr 1; ring have h2 : ∑ S ∈ U.powerset.image (insert a), Real.exp (lam * ((S.card : ℝ) - ((insert a U).card : ℝ) / 2)) = Real.exp (lam / 2) * ∑ S ∈ U.powerset, Real.exp (lam * ((S.card : ℝ) - (U.card : ℝ) / 2)) := by rw [Finset.sum_image] · rw [Finset.mul_sum] refine Finset.sum_congr rfl fun S hS => ?_ have haS : a ∉ S := fun h => ha (Finset.mem_powerset.mp hS h) rw [Finset.card_insert_of_notMem haS, hcardU, ← Real.exp_add] congr 1; push_cast; ring · intro S₁ hS₁ S₂ hS₂ h have ha₁ : a ∉ S₁ := fun hmem => ha (Finset.mem_powerset.mp hS₁ hmem) have ha₂ : a ∉ S₂ := fun hmem => ha (Finset.mem_powerset.mp hS₂ hmem) have := congrArg (fun T => T.erase a) h simpa [Finset.erase_insert ha₁, Finset.erase_insert ha₂] using this rw [h1, h2, ← add_mul, ih, Finset.card_insert_of_notMem ha] have hcosh : Real.exp (-(lam / 2)) + Real.exp (lam / 2) = 2 * Real.cosh (lam / 2) := by rw [Real.cosh_eq]; ring rw [hcosh, pow_succ, pow_succ] ring · rw [Finset.disjoint_left] intro S hS1 hS2 rcases Finset.mem_image.mp hS2 with ⟨T, _, rfl⟩ exact ha (Finset.mem_powerset.mp hS1 (Finset.mem_insert_self a T)) /-- Sub-Gaussian MGF upper bound on the Boolean cube: `∑ S ∈ U.powerset, exp (λ * (|S| - |U| / 2)) ≤ 2 ^ |U| * exp (λ ^ 2 * |U| / 8)`. -/ lemma sum_powerset_exp_centered_le {α : Type*} [DecidableEq α] (U : Finset α) (lam : ℝ) : ∑ S ∈ U.powerset, Real.exp (lam * ((S.card : ℝ) - (U.card : ℝ) / 2)) ≤ (2 : ℝ) ^ U.card * Real.exp (lam ^ 2 * (U.card : ℝ) / 8) := by rw [sum_powerset_exp_centered] have hcosh_le : Real.cosh (lam / 2) ≤ Real.exp ((lam / 2) ^ 2 / 2) := cosh_le_exp_half_sq (lam / 2) have hcosh_nonneg : 0 ≤ Real.cosh (lam / 2) := (Real.cosh_pos _).le have hpow : (Real.cosh (lam / 2)) ^ U.card ≤ (Real.exp ((lam / 2) ^ 2 / 2)) ^ U.card := pow_le_pow_left₀ hcosh_nonneg hcosh_le U.card rw [← Real.exp_nat_mul] at hpow have hexp_eq : (U.card : ℝ) * ((lam / 2) ^ 2 / 2) = lam ^ 2 * (U.card : ℝ) / 8 := by ring rw [hexp_eq] at hpow exact mul_le_mul_of_nonneg_left hpow (by positivity) /-- Jensen–Hoeffding upper bound for a single nonempty subset `E ⊆ U.powerset` of size `t`: for any `λ > 0`, `∑ S ∈ E, (|S| - |U|/2) ≤ t * (log (2 ^ |U| / t) / λ + λ * |U| / 8)`. -/ lemma subgaussian_subset_sum_le_lam {α : Type*} [DecidableEq α] {U : Finset α} {E : Finset (Finset α)} (hEsub : E ⊆ U.powerset) (hEne : E.Nonempty) {lam : ℝ} (hlam : 0 < lam) : ∑ S ∈ E, ((S.card : ℝ) - (U.card : ℝ) / 2) ≤ (E.card : ℝ) * (Real.log ((2 : ℝ) ^ U.card / (E.card : ℝ)) / lam + lam * (U.card : ℝ) / 8) := by set t : ℝ := (E.card : ℝ) with ht_def have ht_pos : 0 < t := Nat.cast_pos.mpr hEne.card_pos have hw0 : ∀ S ∈ E, (0 : ℝ) ≤ t⁻¹ := fun _ _ => inv_nonneg.mpr ht_pos.le have hw1 : ∑ _S ∈ E, t⁻¹ = 1 := by rw [Finset.sum_const, nsmul_eq_mul, ← ht_def, mul_inv_cancel₀ ht_pos.ne'] let p : Finset α → ℝ := fun S => lam * ((S.card : ℝ) - (U.card : ℝ) / 2) have hjensen := convexOn_exp.map_sum_le (t := E) (w := fun _ => t⁻¹) (p := p) hw0 hw1 (fun _ _ => Set.mem_univ _) simp only [smul_eq_mul, p] at hjensen have hjensen' : Real.exp (t⁻¹ * ∑ S ∈ E, (lam * ((S.card : ℝ) - (U.card : ℝ) / 2))) ≤ t⁻¹ * ∑ S ∈ E, Real.exp (lam * ((S.card : ℝ) - (U.card : ℝ) / 2)) := by simpa [Finset.mul_sum] using hjensen have hsub_sum : ∑ S ∈ E, Real.exp (lam * ((S.card : ℝ) - (U.card : ℝ) / 2)) ≤ ∑ S ∈ U.powerset, Real.exp (lam * ((S.card : ℝ) - (U.card : ℝ) / 2)) := Finset.sum_le_sum_of_subset_of_nonneg hEsub (fun _ _ _ => (Real.exp_pos _).le) have hmgf := sum_powerset_exp_centered_le U lam have hexp_le : Real.exp (t⁻¹ * ∑ S ∈ E, (lam * ((S.card : ℝ) - (U.card : ℝ) / 2))) ≤ ((2 : ℝ) ^ U.card / t) * Real.exp (lam ^ 2 * (U.card : ℝ) / 8) := by calc Real.exp (t⁻¹ * ∑ S ∈ E, (lam * ((S.card : ℝ) - (U.card : ℝ) / 2))) ≤ t⁻¹ * ∑ S ∈ E, Real.exp (lam * ((S.card : ℝ) - (U.card : ℝ) / 2)) := hjensen' _ ≤ t⁻¹ * ((2 : ℝ) ^ U.card * Real.exp (lam ^ 2 * (U.card : ℝ) / 8)) := mul_le_mul_of_nonneg_left (hsub_sum.trans hmgf) (inv_nonneg.mpr ht_pos.le) _ = ((2 : ℝ) ^ U.card / t) * Real.exp (lam ^ 2 * (U.card : ℝ) / 8) := by ring have hratio_pos : 0 < (2 : ℝ) ^ U.card / t := by positivity rw [← Real.exp_log hratio_pos, ← Real.exp_add] at hexp_le have harg := Real.exp_le_exp.mp hexp_le rw [← Finset.mul_sum] at harg have hmul : lam * ∑ S ∈ E, ((S.card : ℝ) - (U.card : ℝ) / 2) ≤ t * (Real.log ((2 : ℝ) ^ U.card / t) + lam ^ 2 * (U.card : ℝ) / 8) := by have := mul_le_mul_of_nonneg_left harg ht_pos.le rwa [← mul_assoc, mul_inv_cancel₀ ht_pos.ne', one_mul] at this have hdiv := (le_div_iff₀ hlam).mpr (by linarith : (∑ S ∈ E, ((S.card : ℝ) - (U.card : ℝ) / 2)) * lam ≤ t * (Real.log ((2 : ℝ) ^ U.card / t) + lam ^ 2 * (U.card : ℝ) / 8)) calc ∑ S ∈ E, ((S.card : ℝ) - (U.card : ℝ) / 2) ≤ t * (Real.log ((2 : ℝ) ^ U.card / t) + lam ^ 2 * (U.card : ℝ) / 8) / lam := hdiv _ = t * (Real.log ((2 : ℝ) ^ U.card / t) / lam + lam * (U.card : ℝ) / 8) := by field_simp /-- Optimized single-subset sub-Gaussian tail bound: `∑ S ∈ E, (|S| - |U|/2) ≤ t * √(|U| * log (2 ^ |U| / t) / 2)`. -/ lemma subgaussian_subset_sum_le {α : Type*} [DecidableEq α] {U : Finset α} {E : Finset (Finset α)} (hEsub : E ⊆ U.powerset) (hEne : E.Nonempty) : ∑ S ∈ E, ((S.card : ℝ) - (U.card : ℝ) / 2) ≤ (E.card : ℝ) * Real.sqrt ((U.card : ℝ) * Real.log ((2 : ℝ) ^ U.card / (E.card : ℝ)) / 2) := by set m : ℝ := (U.card : ℝ) set t : ℝ := (E.card : ℝ) have ht_pos : 0 < t := Nat.cast_pos.mpr hEne.card_pos have hE_le : E.card ≤ 2 ^ U.card := by simpa [Finset.card_powerset] using Finset.card_le_card hEsub have hratio_ge : 1 ≤ (2 : ℝ) ^ U.card / t := by rw [le_div_iff₀ ht_pos, one_mul] have hE_le' : (E.card : ℝ) ≤ (2 : ℝ) ^ U.card := by exact_mod_cast hE_le exact hE_le' have hlog_nonneg : 0 ≤ Real.log ((2 : ℝ) ^ U.card / t) := Real.log_nonneg hratio_ge by_cases hU0 : U.card = 0 · have hE0 : ∀ S ∈ E, S.card = 0 := fun S hS => by have hsub := Finset.mem_powerset.mp (hEsub hS) exact Nat.eq_zero_of_le_zero (by simpa [hU0] using Finset.card_le_card hsub) have hsum0 : ∑ S ∈ E, ((S.card : ℝ) - m / 2) = 0 := by refine Finset.sum_eq_zero fun S hS => ?_ simp [m, hU0, hE0 S hS] rw [hsum0] positivity · by_cases hlog0 : Real.log ((2 : ℝ) ^ U.card / t) = 0 · have hratio_eq : (2 : ℝ) ^ U.card / t = 1 := by have := congrArg Real.exp hlog0 rwa [Real.exp_log (by positivity), Real.exp_zero] at this have hcard_eq : E.card = 2 ^ U.card := by have : (E.card : ℝ) = (2 : ℝ) ^ U.card := ((div_eq_one_iff_eq ht_pos.ne').mp hratio_eq).symm exact_mod_cast this have hE_eq : E = U.powerset := Finset.eq_of_subset_of_card_le hEsub (by simp [hcard_eq]) rw [hE_eq, hlog0, mul_zero, zero_div, Real.sqrt_zero, mul_zero] have hinv : ∑ S ∈ U.powerset, ((S.card : ℝ) - m / 2) = ∑ S ∈ U.powerset, (((U \ S).card : ℝ) - m / 2) := by refine Finset.sum_bij (fun S _ => U \ S) ?_ ?_ ?_ ?_ · intro S _; exact Finset.mem_powerset.mpr Finset.sdiff_subset · intro S₁ hS₁ S₂ hS₂ h have hs1 := Finset.mem_powerset.mp hS₁ have hs2 := Finset.mem_powerset.mp hS₂ have := congrArg (fun T => U \ T) h simpa [Finset.sdiff_sdiff_eq_self hs1, Finset.sdiff_sdiff_eq_self hs2] using this · intro S hS refine ⟨U \ S, Finset.mem_powerset.mpr Finset.sdiff_subset, Finset.sdiff_sdiff_eq_self (Finset.mem_powerset.mp hS)⟩ · intro S hS rw [Finset.sdiff_sdiff_eq_self (Finset.mem_powerset.mp hS)] have hneg : ∑ S ∈ U.powerset, (((U \ S).card : ℝ) - m / 2) = -(∑ S ∈ U.powerset, ((S.card : ℝ) - m / 2)) := by rw [← Finset.sum_neg_distrib] refine Finset.sum_congr rfl fun S hS => ?_ have hs := Finset.mem_powerset.mp hS have hsd : ((U \ S).card : ℝ) + (S.card : ℝ) = (U.card : ℝ) := by exact_mod_cast Finset.card_sdiff_add_card_eq_card hs linarith linarith · have hm_pos : 0 < m := Nat.cast_pos.mpr (Nat.pos_of_ne_zero hU0) have hlog_pos : 0 < Real.log ((2 : ℝ) ^ U.card / t) := lt_of_le_of_ne hlog_nonneg (Ne.symm hlog0) set L := Real.log ((2 : ℝ) ^ U.card / t) set lam := Real.sqrt (8 * L / m) have hlam_pos : 0 < lam := Real.sqrt_pos.mpr (by positivity) have hbound := subgaussian_subset_sum_le_lam hEsub hEne hlam_pos have hopt : L / lam + lam * m / 8 = Real.sqrt (m * L / 2) := by have hlam_sq : lam ^ 2 = 8 * L / m := Real.sq_sqrt (by positivity) have hlhs_nonneg : 0 ≤ L / lam + lam * m / 8 := by positivity rw [← Real.sqrt_sq hlhs_nonneg] congr 1 have hlam_ne : lam ≠ 0 := hlam_pos.ne' have hm_ne : m ≠ 0 := hm_pos.ne' have hL_ne : L ≠ 0 := hlog_pos.ne' calc (L / lam + lam * m / 8) ^ 2 = L ^ 2 / lam ^ 2 + L * m / 4 + lam ^ 2 * m ^ 2 / 64 := by field_simp; ring _ = L ^ 2 / (8 * L / m) + L * m / 4 + (8 * L / m) * m ^ 2 / 64 := by rw [hlam_sq] _ = m * L / 2 := by field_simp; ring simpa [m, t, L, hopt] using hbound /-- Two-sided sub-Gaussian hypercube tail bound: for any two subsets `E₁, E₂ ⊆ U.powerset` of the same positive cardinality `t`, `∑ S ∈ E₁, (|S| - |U|/2) + ∑ T ∈ E₂, (|U|/2 - |T|) ≤ t * √(2 * |U| * log (2 ^ |U| / t))`. -/ theorem subgaussian_cube_sum_bound {α : Type*} [DecidableEq α] {U : Finset α} {E₁ E₂ : Finset (Finset α)} (hE₁ : E₁ ⊆ U.powerset) (hE₂ : E₂ ⊆ U.powerset) (hcard : E₁.card = E₂.card) (hEne : E₁.Nonempty) : ∑ S ∈ E₁, ((S.card : ℝ) - (U.card : ℝ) / 2) + ∑ T ∈ E₂, ((U.card : ℝ) / 2 - (T.card : ℝ)) ≤ (E₁.card : ℝ) * Real.sqrt (2 * (U.card : ℝ) * Real.log ((2 : ℝ) ^ U.card / (E₁.card : ℝ))) := by have h1 := subgaussian_subset_sum_le hE₁ hEne let E₂' : Finset (Finset α) := E₂.image (fun T => U \ T) have hcomp_inj : Set.InjOn (fun T => U \ T) (E₂ : Set (Finset α)) := by intro T₁ hT₁ T₂ hT₂ h have hs1 := Finset.mem_powerset.mp (hE₂ hT₁) have hs2 := Finset.mem_powerset.mp (hE₂ hT₂) have := congrArg (fun S => U \ S) h simpa [Finset.sdiff_sdiff_eq_self hs1, Finset.sdiff_sdiff_eq_self hs2] using this have hE₂'_sub : E₂' ⊆ U.powerset := by intro S hS rcases Finset.mem_image.mp hS with ⟨T, _, rfl⟩ exact Finset.mem_powerset.mpr Finset.sdiff_subset have hE₂'_card : E₂'.card = E₁.card := by rw [Finset.card_image_of_injOn hcomp_inj, hcard] have hE₂'_ne : E₂'.Nonempty := Finset.card_pos.mp (by rw [hE₂'_card]; exact hEne.card_pos) have h2 := subgaussian_subset_sum_le hE₂'_sub hE₂'_ne rw [hE₂'_card] at h2 have h2_eq : ∑ T ∈ E₂, ((U.card : ℝ) / 2 - (T.card : ℝ)) = ∑ S ∈ E₂', ((S.card : ℝ) - (U.card : ℝ) / 2) := by rw [Finset.sum_image hcomp_inj] refine Finset.sum_congr rfl fun T hT => ?_ have hs := Finset.mem_powerset.mp (hE₂ hT) have hsd : ((U \ T).card : ℝ) + (T.card : ℝ) = (U.card : ℝ) := by exact_mod_cast Finset.card_sdiff_add_card_eq_card hs linarith have hsqrt : 2 * Real.sqrt ((U.card : ℝ) * Real.log ((2 : ℝ) ^ U.card / (E₁.card : ℝ)) / 2) = Real.sqrt (2 * (U.card : ℝ) * Real.log ((2 : ℝ) ^ U.card / (E₁.card : ℝ))) := by have hlog_nonneg : 0 ≤ Real.log ((2 : ℝ) ^ U.card / (E₁.card : ℝ)) := by apply Real.log_nonneg rw [le_div_iff₀ (Nat.cast_pos.mpr hEne.card_pos), one_mul] have hle : E₁.card ≤ 2 ^ U.card := by simpa [Finset.card_powerset] using Finset.card_le_card hE₁ exact_mod_cast hle rw [show (2 : ℝ) = Real.sqrt 4 by norm_num, ← Real.sqrt_mul (by norm_num)] congr 1; ring rw [h2_eq] have hadd : ∑ S ∈ E₁, ((S.card : ℝ) - (U.card : ℝ) / 2) + ∑ S ∈ E₂', ((S.card : ℝ) - (U.card : ℝ) / 2) ≤ (E₁.card : ℝ) * (2 * Real.sqrt ((U.card : ℝ) * Real.log ((2 : ℝ) ^ U.card / (E₁.card : ℝ)) / 2)) := by linarith [h1, h2] rwa [hsqrt] at hadd end SubGaussian /-! ## Section 3: Fonollosa's Valid Residue Sets and Cyclic Structure -/ section ValidMod /-- Exact definition from `FormalConjectures/Arxiv/2607.08366/MinModulus.lean`: `A ⊆ ZMod N` is *valid mod `N`* when the all-ones multiset is the unique size-`#A` multiset drawn from `A` whose sum matches `∑ a ∈ A, a`. -/ def IsValidMod {N : ℕ} (A : Finset (ZMod N)) : Prop := ∀ m : ZMod N → ℕ, ∑ a ∈ A, m a = A.card → ∑ a ∈ A, (m a : ZMod N) * a = ∑ a ∈ A, a → ∀ a ∈ A, m a = 1 /-- Validity is invariant under translation in `ZMod N`. -/ lemma isValidMod_translate {N : ℕ} {A : Finset (ZMod N)} (hA : IsValidMod A) (c : ZMod N) : IsValidMod (A.image (fun x => x - c)) := by have hinj : Function.Injective (fun x : ZMod N => x - c) := fun x y h => sub_left_inj.mp h intro m hcard hsum y hy rcases Finset.mem_image.mp hy with ⟨x, hx, rfl⟩ let m' : ZMod N → ℕ := fun z => m (z - c) have hcard' : ∑ a ∈ A, m' a = A.card := by have h1 : ∑ b ∈ A.image (fun z => z - c), m b = ∑ a ∈ A, m' a := Finset.sum_image (fun u _ v _ h => hinj h) rw [← h1, hcard, Finset.card_image_of_injective _ hinj] have hsum' : ∑ a ∈ A, (m' a : ZMod N) * a = ∑ a ∈ A, a := by have h1 : ∑ b ∈ A.image (fun z => z - c), (m b : ZMod N) * b = ∑ a ∈ A, (m' a : ZMod N) * (a - c) := Finset.sum_image (fun u _ v _ h => hinj h) have h2 : ∑ b ∈ A.image (fun z => z - c), b = ∑ a ∈ A, (a - c) := Finset.sum_image (fun u _ v _ h => hinj h) rw [h1, h2] at hsum have hlhs : ∑ a ∈ A, (m' a : ZMod N) * (a - c) = (∑ a ∈ A, (m' a : ZMod N) * a) - (∑ a ∈ A, (m' a : ZMod N)) * c := by simp_rw [mul_sub, Finset.sum_sub_distrib, ← Finset.sum_mul] have hrhs : ∑ a ∈ A, (a - c) = (∑ a ∈ A, a) - (A.card : ZMod N) * c := by simp_rw [Finset.sum_sub_distrib, Finset.sum_const, nsmul_eq_mul] have hm'c : (∑ a ∈ A, (m' a : ZMod N)) = (A.card : ZMod N) := by rw [← Nat.cast_sum, hcard'] rw [hlhs, hrhs, hm'c] at hsum exact sub_left_inj.mp hsum exact hA m' hcard' hsum' x hx /-- If `A` is valid mod `N` and `0 ∈ A`, then all `2 ^ (A.card - 1)` subset sums of `A.erase 0` are distinct in `ZMod N`. -/ lemma subset_sum_injOn {N : ℕ} {A : Finset (ZMod N)} (hA : IsValidMod A) (h0 : (0 : ZMod N) ∈ A) : Set.InjOn (fun S : Finset (ZMod N) => ∑ x ∈ S, x) ((A.erase 0).powerset : Set (Finset (ZMod N))) := by set A' := A.erase 0 with hA'_def have h0A' : (0 : ZMod N) ∉ A' := Finset.notMem_erase 0 A have hA_eq : insert (0 : ZMod N) A' = A := Finset.insert_erase h0 suffices hle : ∀ S₁ ∈ A'.powerset, ∀ S₂ ∈ A'.powerset, S₁.card ≤ S₂.card → (∑ x ∈ S₁, x) = (∑ x ∈ S₂, x) → S₁ = S₂ by intro S₁ hS₁ S₂ hS₂ heq rcases le_total S₁.card S₂.card with h | h · exact hle S₁ hS₁ S₂ hS₂ h heq · exact (hle S₂ hS₂ S₁ hS₁ h heq.symm).symm intro S₁ hS₁ S₂ hS₂ hcard heq have hS₁sub : S₁ ⊆ A' := Finset.mem_powerset.mp hS₁ have hS₂sub : S₂ ⊆ A' := Finset.mem_powerset.mp hS₂ let m : ZMod N → ℕ := fun x => if x = 0 then 1 + S₂.card - S₁.card else 1 + (if x ∈ S₁ then 1 else 0) - (if x ∈ S₂ then 1 else 0) have hm_sum_A' : ∑ x ∈ A', m x + S₂.card = A'.card + S₁.card := by have hpt : ∀ x ∈ A', m x + (if x ∈ S₂ then 1 else 0) = 1 + (if x ∈ S₁ then 1 else 0) := by intro x hx have hx0 : x ≠ 0 := fun h => h0A' (h ▸ hx) dsimp only [m] rw [if_neg hx0] split_ifs <;> omega have hsum := Finset.sum_congr rfl hpt rw [Finset.sum_add_distrib, Finset.sum_add_distrib, Finset.sum_const, smul_eq_mul, mul_one] at hsum have h1 : ∑ x ∈ A', (if x ∈ S₁ then 1 else 0) = S₁.card := by rw [Finset.sum_boole, Finset.filter_mem_eq_inter, Finset.inter_eq_right.mpr hS₁sub] simp have h2 : ∑ x ∈ A', (if x ∈ S₂ then 1 else 0) = S₂.card := by rw [Finset.sum_boole, Finset.filter_mem_eq_inter, Finset.inter_eq_right.mpr hS₂sub] simp rw [h1, h2] at hsum exact hsum have hm_card : ∑ a ∈ A, m a = A.card := by rw [← hA_eq, Finset.sum_insert h0A', Finset.card_insert_of_notMem h0A'] have hm0 : m 0 = 1 + S₂.card - S₁.card := by simp [m] omega have hm_sum : ∑ a ∈ A, (m a : ZMod N) * a = ∑ a ∈ A, a := by rw [← hA_eq, Finset.sum_insert h0A', Finset.sum_insert h0A', mul_zero, zero_add, zero_add] have hpt : ∀ x ∈ A', (m x : ZMod N) * x + (if x ∈ S₂ then x else 0) = x + (if x ∈ S₁ then x else 0) := by intro x hx have hx0 : x ≠ 0 := fun h => h0A' (h ▸ hx) dsimp only [m] rw [if_neg hx0] split_ifs <;> (simp; try ring) have hsum := Finset.sum_congr rfl hpt rw [Finset.sum_add_distrib, Finset.sum_add_distrib] at hsum have h1 : ∑ x ∈ A', (if x ∈ S₁ then x else 0) = ∑ x ∈ S₁, x := by rw [← Finset.sum_filter, Finset.filter_mem_eq_inter, Finset.inter_eq_right.mpr hS₁sub] have h2 : ∑ x ∈ A', (if x ∈ S₂ then x else 0) = ∑ x ∈ S₂, x := by rw [← Finset.sum_filter, Finset.filter_mem_eq_inter, Finset.inter_eq_right.mpr hS₂sub] rw [h1, h2, heq] at hsum exact add_right_cancel hsum have hall1 := hA m hm_card hm_sum ext x constructor <;> intro hx · have hxA' : x ∈ A' := hS₁sub hx have hxA : x ∈ A := Finset.mem_of_mem_erase hxA' have hx0 : x ≠ 0 := fun h => h0A' (h ▸ hxA') have hmx := hall1 x hxA dsimp only [m] at hmx rw [if_neg hx0, if_pos hx] at hmx by_contra hnot rw [if_neg hnot] at hmx omega · have hxA' : x ∈ A' := hS₂sub hx have hxA : x ∈ A := Finset.mem_of_mem_erase hxA' have hx0 : x ≠ 0 := fun h => h0A' (h ▸ hxA') have hmx := hall1 x hxA dsimp only [m] at hmx rw [if_neg hx0, if_pos hx] at hmx by_contra hnot rw [if_neg hnot] at hmx omega /-- **Inal's bound (2026)**: every valid `n`-set in `ZMod N` (`N > 0`, `n ≥ 1`) satisfies `2 ^ (n - 1) ≤ N`. -/ theorem inal_lower_bound {N n : ℕ} [NeZero N] {A : Finset (ZMod N)} (hcard : A.card = n) (hn : 1 ≤ n) (hA : IsValidMod A) : 2 ^ (n - 1) ≤ N := by have hAne : A.Nonempty := Finset.card_pos.mp (by omega) obtain ⟨a₀, ha₀⟩ := hAne let B := A.image (fun x => x - a₀) have hB : IsValidMod B := isValidMod_translate hA a₀ have h0B : (0 : ZMod N) ∈ B := Finset.mem_image.mpr ⟨a₀, ha₀, sub_self a₀⟩ have hBcard : B.card = n := by rw [Finset.card_image_of_injective _ (fun x y h => sub_left_inj.mp h), hcard] have hinj := subset_sum_injOn hB h0B have himg_card : ((B.erase 0).powerset.image (fun S => ∑ x ∈ S, x)).card = 2 ^ (n - 1) := by rw [Finset.card_image_of_injOn hinj, Finset.card_powerset, Finset.card_erase_of_mem h0B, hBcard] calc 2 ^ (n - 1) = ((B.erase 0).powerset.image (fun S => ∑ x ∈ S, x)).card := himg_card.symm _ ≤ (Finset.univ : Finset (ZMod N)).card := Finset.card_le_card (Finset.subset_univ _) _ = N := by rw [Finset.card_univ, ZMod.card] /-- In `ZMod N` (`N > 0`), at most two elements satisfy `2 * x = 0`, so any set `A'` of at least `2` nonzero elements contains some `a` with `2 * a ≠ 0`. -/ lemma exists_two_mul_ne_zero {N : ℕ} [NeZero N] {A' : Finset (ZMod N)} (h0 : (0 : ZMod N) ∉ A') (hcard : 2 ≤ A'.card) : ∃ a ∈ A', (2 : ZMod N) * a ≠ 0 := by by_contra h push Not at h have hNpos : 0 < N := NeZero.pos N have hsub : A' ⊆ ({((N / 2 : ℕ) : ZMod N)} : Finset (ZMod N)) := by intro x hx have hx0 : x ≠ 0 := fun heq => h0 (heq ▸ hx) have h2x : (2 : ZMod N) * x = 0 := h x hx have hdvd : N ∣ 2 * x.val := by have hcast : ((2 * x.val : ℕ) : ZMod N) = 0 := by simpa [Nat.cast_mul, ZMod.natCast_zmod_val] using h2x exact (ZMod.natCast_eq_zero_iff (2 * x.val) N).mp hcast have hxlt : x.val < N := x.val_lt have hxval_pos : 0 < x.val := by by_contra hle have hv0 : x.val = 0 := by omega apply hx0 rw [← ZMod.natCast_zmod_val x, hv0, Nat.cast_zero] rcases hdvd with ⟨q, hq⟩ have hq1 : q = 1 := by nlinarith subst hq1 have hxval : x.val = N / 2 := by omega rw [Finset.mem_singleton, ← ZMod.natCast_zmod_val x, hxval] have := Finset.card_le_card hsub simp at this omega /-- In `ZMod N` (`N > 0`), at most four elements satisfy `4 * x = 0` (at most three nonzero), so any set `A'` of at least `4` nonzero elements contains some `a` with `4 * a ≠ 0`. -/ lemma exists_four_mul_ne_zero {N : ℕ} [NeZero N] {A' : Finset (ZMod N)} (h0 : (0 : ZMod N) ∉ A') (hcard : 4 ≤ A'.card) : ∃ a ∈ A', (4 : ZMod N) * a ≠ 0 := by by_contra h push Not at h have hNpos : 0 < N := NeZero.pos N let S : Finset (ZMod N) := {((N / 4 : ℕ) : ZMod N), (((2 * N) / 4 : ℕ) : ZMod N), (((3 * N) / 4 : ℕ) : ZMod N)} have hsub : A' ⊆ S := by intro x hx have hx0 : x ≠ 0 := fun heq => h0 (heq ▸ hx) have h4x : (4 : ZMod N) * x = 0 := h x hx have hdvd : N ∣ 4 * x.val := by have hcast : ((4 * x.val : ℕ) : ZMod N) = 0 := by simpa [Nat.cast_mul, ZMod.natCast_zmod_val] using h4x exact (ZMod.natCast_eq_zero_iff (4 * x.val) N).mp hcast have hxlt : x.val < N := x.val_lt have hxval_pos : 0 < x.val := by by_contra hle have hv0 : x.val = 0 := by omega apply hx0 rw [← ZMod.natCast_zmod_val x, hv0, Nat.cast_zero] rcases hdvd with ⟨q, hq⟩ have hq_pos : 1 ≤ q := by by_contra hq0 have : q = 0 := by omega subst this omega have hq_lt : q ≤ 3 := by by_contra hq4 have : 4 ≤ q := by omega nlinarith have hq_cases : q = 1 ∨ q = 2 ∨ q = 3 := by omega simp only [S, Finset.mem_insert, Finset.mem_singleton] rcases hq_cases with rfl | rfl | rfl · left; rw [← ZMod.natCast_zmod_val x]; congr 1; omega · right; left; rw [← ZMod.natCast_zmod_val x]; congr 1; omega · right; right; rw [← ZMod.natCast_zmod_val x]; congr 1; omega have hScard : S.card ≤ 3 := by calc S.card ≤ ({(((2 * N) / 4 : ℕ) : ZMod N), (((3 * N) / 4 : ℕ) : ZMod N)} : Finset (ZMod N)).card + 1 := Finset.card_insert_le _ _ _ ≤ ({(((3 * N) / 4 : ℕ) : ZMod N)} : Finset (ZMod N)).card + 1 + 1 := by have := Finset.card_insert_le (((2 * N) / 4 : ℕ) : ZMod N) {(((3 * N) / 4 : ℕ) : ZMod N)} omega _ = 3 := by simp have := Finset.card_le_card hsub omega end ValidMod /-! ## Section 4: Level-Monotonicity, Bollobás Collision Bound, and Telescoping -/ section LevelDrop /-- **Level-Monotonicity Lemma**: if `A` is valid mod `N`, `0 ∈ A`, `a ∈ A.erase 0`, and `S, T ⊆ (A.erase 0).erase a` satisfy `(∑ x ∈ S, x) + 2 * a = ∑ x ∈ T, x`, then `T.card ≤ S.card`. -/ lemma level_monotone_two_mul {N : ℕ} {A : Finset (ZMod N)} (hA : IsValidMod A) (h0 : (0 : ZMod N) ∈ A) {a : ZMod N} (ha : a ∈ A.erase 0) {S T : Finset (ZMod N)} (hS : S ⊆ (A.erase 0).erase a) (hT : T ⊆ (A.erase 0).erase a) (heq : (∑ x ∈ S, x) + 2 * a = ∑ x ∈ T, x) : T.card ≤ S.card := by by_contra hlt have hge : S.card + 1 ≤ T.card := by omega set A' := A.erase 0 set U := A'.erase a have h0A' : (0 : ZMod N) ∉ A' := Finset.notMem_erase 0 A have haU : a ∉ U := Finset.notMem_erase a A' have h0U : (0 : ZMod N) ∉ U := fun h => h0A' (Finset.mem_of_mem_erase h) have ha0 : a ≠ 0 := Finset.ne_of_mem_erase ha have hA_eq : insert (0 : ZMod N) (insert a U) = A := by rw [Finset.insert_erase ha, Finset.insert_erase h0] let m : ZMod N → ℕ := fun x => if x = 0 then T.card - S.card - 1 else if x = a then 3 else 1 + (if x ∈ S then 1 else 0) - (if x ∈ T then 1 else 0) have hm_sum_U : ∑ x ∈ U, m x + T.card = U.card + S.card := by have hpt : ∀ x ∈ U, m x + (if x ∈ T then 1 else 0) = 1 + (if x ∈ S then 1 else 0) := by intro x hx have hx0 : x ≠ 0 := fun h => h0U (h ▸ hx) have hxa : x ≠ a := fun h => haU (h ▸ hx) dsimp only [m] rw [if_neg hx0, if_neg hxa] split_ifs <;> omega have hsum := Finset.sum_congr rfl hpt rw [Finset.sum_add_distrib, Finset.sum_add_distrib, Finset.sum_const, smul_eq_mul, mul_one] at hsum have h1 : ∑ x ∈ U, (if x ∈ S then 1 else 0) = S.card := by rw [Finset.sum_boole, Finset.filter_mem_eq_inter, Finset.inter_eq_right.mpr hS]; simp have h2 : ∑ x ∈ U, (if x ∈ T then 1 else 0) = T.card := by rw [Finset.sum_boole, Finset.filter_mem_eq_inter, Finset.inter_eq_right.mpr hT]; simp rw [h1, h2] at hsum exact hsum have h0ins : (0 : ZMod N) ∉ insert a U := by simp [ha0.symm, h0U] have hm_card : ∑ x ∈ A, m x = A.card := by rw [← hA_eq, Finset.sum_insert h0ins, Finset.sum_insert haU, Finset.card_insert_of_notMem h0ins, Finset.card_insert_of_notMem haU] have hm0 : m 0 = T.card - S.card - 1 := by simp [m] have hma : m a = 3 := by simp [m, ha0] omega have hm_sum : ∑ x ∈ A, (m x : ZMod N) * x = ∑ x ∈ A, x := by rw [← hA_eq, Finset.sum_insert h0ins, Finset.sum_insert haU, Finset.sum_insert h0ins, Finset.sum_insert haU] have hma : m a = 3 := by simp [m, ha0] rw [mul_zero, zero_add, zero_add, hma] have hpt : ∀ x ∈ U, (m x : ZMod N) * x + (if x ∈ T then x else 0) = x + (if x ∈ S then x else 0) := by intro x hx have hx0 : x ≠ 0 := fun h => h0U (h ▸ hx) have hxa : x ≠ a := fun h => haU (h ▸ hx) dsimp only [m] rw [if_neg hx0, if_neg hxa] split_ifs <;> (simp; try ring) have hsum := Finset.sum_congr rfl hpt rw [Finset.sum_add_distrib, Finset.sum_add_distrib] at hsum have h1 : ∑ x ∈ U, (if x ∈ S then x else 0) = ∑ x ∈ S, x := by rw [← Finset.sum_filter, Finset.filter_mem_eq_inter, Finset.inter_eq_right.mpr hS] have h2 : ∑ x ∈ U, (if x ∈ T then x else 0) = ∑ x ∈ T, x := by rw [← Finset.sum_filter, Finset.filter_mem_eq_inter, Finset.inter_eq_right.mpr hT] rw [h1, h2] at hsum have hUeq : ∑ x ∈ U, (m x : ZMod N) * x = (∑ x ∈ U, x) - 2 * a := by have : (∑ x ∈ U, (m x : ZMod N) * x) + ((∑ x ∈ S, x) + 2 * a) = (∑ x ∈ U, x) + (∑ x ∈ S, x) := by rw [heq]; exact hsum linear_combination this rw [hUeq] push_cast ring have h1 := hA m hm_card hm_sum a (Finset.mem_of_mem_erase ha) have hma : m a = 3 := by simp [m, ha0] omega /-- For `S, T ⊆ U = (A.erase 0).erase a`, `(∑ x ∈ S, x) + 2 * a` can never equal `(∑ x ∈ T, x) + a`. -/ lemma add_two_mul_ne_add_one {N : ℕ} {A : Finset (ZMod N)} (hA : IsValidMod A) (h0 : (0 : ZMod N) ∈ A) {a : ZMod N} (ha : a ∈ A.erase 0) {S T : Finset (ZMod N)} (hS : S ⊆ (A.erase 0).erase a) (hT : T ⊆ (A.erase 0).erase a) : (∑ x ∈ S, x) + 2 * a ≠ (∑ x ∈ T, x) + a := by intro h have h1 : (∑ x ∈ S, x) + a = ∑ x ∈ T, x := by linear_combination h have haS : a ∉ S := fun hm => Finset.notMem_erase a (A.erase 0) (hS hm) have haT : a ∉ T := fun hm => Finset.notMem_erase a (A.erase 0) (hT hm) have hins_sum : ∑ x ∈ insert a S, x = ∑ x ∈ T, x := by rw [Finset.sum_insert haS]; linear_combination h1 have hins_sub : insert a S ∈ (A.erase 0).powerset := by rw [Finset.mem_powerset] exact Finset.insert_subset ha (hS.trans (Finset.erase_subset a _)) have hT_sub : T ∈ (A.erase 0).powerset := Finset.mem_powerset.mpr (hT.trans (Finset.erase_subset a _)) have heq := subset_sum_injOn hA h0 hins_sub hT_sub hins_sum exact haT (heq ▸ Finset.mem_insert_self a S) /-- **Symmetric Bollobás Cross-Intersection for Minimal Level-Preserving Pairs**: if `(S₁, T₁)` and `(S₂, T₂)` are distinct disjoint balanced pairs in `U = (A.erase 0).erase a` both satisfying `σ(Sᵢ) + 2a = σ(Tᵢ)`, then `S₁ ∩ T₂ ≠ ∅`. -/ lemma cross_intersect_minimal_pairs {N : ℕ} {A : Finset (ZMod N)} (hA : IsValidMod A) (_h0 : (0 : ZMod N) ∈ A) {a : ZMod N} (_ha : a ∈ A.erase 0) {S₁ T₁ S₂ T₂ : Finset (ZMod N)} (hS₁ : S₁ ⊆ (A.erase 0).erase a) (hT₁ : T₁ ⊆ (A.erase 0).erase a) (hS₂ : S₂ ⊆ (A.erase 0).erase a) (hT₂ : T₂ ⊆ (A.erase 0).erase a) (hd₁ : Disjoint S₁ T₁) (hd₂ : Disjoint S₂ T₂) (hb₁ : S₁.card = T₁.card) (hb₂ : S₂.card = T₂.card) (heq₁ : (∑ x ∈ S₁, x) + 2 * a = ∑ x ∈ T₁, x) (heq₂ : (∑ x ∈ S₂, x) + 2 * a = ∑ x ∈ T₂, x) (hne : (S₁, T₁) ≠ (S₂, T₂)) : ¬ Disjoint S₁ T₂ := by intro hd12 set A' := A.erase 0 set U := A'.erase a have hUsub : U ⊆ A := (Finset.erase_subset a A').trans (Finset.erase_subset 0 A) -- Since Disjoint S₁ T₂, the multiplicity m x = 1 + 1_{T₁} + 1_{S₂} - 1_{S₁} - 1_{T₂} never underflows! let m : ZMod N → ℕ := fun x => 1 + (if x ∈ T₁ then 1 else 0) + (if x ∈ S₂ then 1 else 0) - (if x ∈ S₁ then 1 else 0) - (if x ∈ T₂ then 1 else 0) have hm_pt_nat : ∀ x ∈ A, m x + (if x ∈ S₁ then 1 else 0) + (if x ∈ T₂ then 1 else 0) = 1 + (if x ∈ T₁ then 1 else 0) + (if x ∈ S₂ then 1 else 0) := by intro x _ dsimp only [m] by_cases h1 : x ∈ S₁ · have h2 : x ∉ T₂ := Finset.disjoint_left.mp hd12 h1 simp only [if_pos h1, if_neg h2] split_ifs <;> omega · simp only [if_neg h1] split_ifs <;> omega have hS₁A : S₁ ⊆ A := hS₁.trans hUsub have hT₁A : T₁ ⊆ A := hT₁.trans hUsub have hS₂A : S₂ ⊆ A := hS₂.trans hUsub have hT₂A : T₂ ⊆ A := hT₂.trans hUsub have hm_card : ∑ x ∈ A, m x = A.card := by have hsum := Finset.sum_congr rfl hm_pt_nat simp_rw [Finset.sum_add_distrib, Finset.sum_const, smul_eq_mul, mul_one] at hsum have hc : ∀ R : Finset (ZMod N), R ⊆ A → ∑ x ∈ A, (if x ∈ R then 1 else 0) = R.card := by intro R hR rw [Finset.sum_boole, Finset.filter_mem_eq_inter, Finset.inter_eq_right.mpr hR]; simp rw [hc S₁ hS₁A, hc T₂ hT₂A, hc T₁ hT₁A, hc S₂ hS₂A] at hsum omega have hm_sum : ∑ x ∈ A, (m x : ZMod N) * x = ∑ x ∈ A, x := by have hpt : ∀ x ∈ A, (m x : ZMod N) * x + (if x ∈ S₁ then x else 0) + (if x ∈ T₂ then x else 0) = x + (if x ∈ T₁ then x else 0) + (if x ∈ S₂ then x else 0) := by intro x hx have hnat := hm_pt_nat x hx have hz : ((m x : ZMod N) + (if x ∈ S₁ then (1 : ZMod N) else 0) + (if x ∈ T₂ then (1 : ZMod N) else 0)) = 1 + (if x ∈ T₁ then (1 : ZMod N) else 0) + (if x ∈ S₂ then (1 : ZMod N) else 0) := by have hcast := congrArg (Nat.cast (R := ZMod N)) hnat simp only [Nat.cast_add, Nat.cast_one, apply_ite Nat.cast, Nat.cast_zero] at hcast exact hcast have hmul := congrArg (· * x) hz simp only [add_mul, one_mul, ite_mul, zero_mul] at hmul exact hmul have hsum := Finset.sum_congr rfl hpt simp_rw [Finset.sum_add_distrib] at hsum have hs : ∀ R : Finset (ZMod N), R ⊆ A → ∑ x ∈ A, (if x ∈ R then x else 0) = ∑ x ∈ R, x := by intro R hR rw [← Finset.sum_filter, Finset.filter_mem_eq_inter, Finset.inter_eq_right.mpr hR] rw [hs S₁ hS₁A, hs T₂ hT₂A, hs T₁ hT₁A, hs S₂ hS₂A] at hsum linear_combination hsum - heq₁ + heq₂ have hall1 := hA m hm_card hm_sum -- Deduce S₁ = S₂ and T₁ = T₂ from m x = 1 for all x ∈ A have hS₁eq : S₁ = S₂ := by ext x constructor <;> intro hx · have hmx := hm_pt_nat x (hS₁A hx) rw [hall1 x (hS₁A hx)] at hmx have hxT₁ : x ∉ T₁ := Finset.disjoint_left.mp hd₁ hx have hxT₂ : x ∉ T₂ := Finset.disjoint_left.mp hd12 hx simp only [if_pos hx, if_neg hxT₁, if_neg hxT₂] at hmx by_contra hnot rw [if_neg hnot] at hmx omega · have hmx := hm_pt_nat x (hS₂A hx) rw [hall1 x (hS₂A hx)] at hmx have hxT₂ : x ∉ T₂ := Finset.disjoint_left.mp hd₂ hx simp only [if_pos hx, if_neg hxT₂] at hmx by_contra hnot rw [if_neg hnot] at hmx split_ifs at hmx <;> omega have hT₁eq : T₁ = T₂ := by ext x constructor <;> intro hx · have hmx := hm_pt_nat x (hT₁A hx) rw [hall1 x (hT₁A hx)] at hmx have hxS₁ : x ∉ S₁ := Finset.disjoint_right.mp hd₁ hx simp only [if_pos hx, if_neg hxS₁] at hmx by_contra hnot rw [if_neg hnot] at hmx split_ifs at hmx <;> omega · have hmx := hm_pt_nat x (hT₂A hx) rw [hall1 x (hT₂A hx)] at hmx have hxS₁ : x ∉ S₁ := Finset.disjoint_right.mp hd12 hx have hxS₂ : x ∉ S₂ := Finset.disjoint_right.mp hd₂ hx simp only [if_pos hx, if_neg hxS₁, if_neg hxS₂] at hmx by_contra hnot rw [if_neg hnot] at hmx omega exact hne (Prod.ext hS₁eq hT₁eq) /-- Count of subsets `S ∈ U.powerset` satisfying `P ⊆ S` and `Disjoint Q S` is `2 ^ (U.card - P.card - Q.card)`. -/ lemma card_subcube {α : Type*} [DecidableEq α] {U P Q : Finset α} (hP : P ⊆ U) (hQ : Q ⊆ U) (hd : Disjoint P Q) : (U.powerset.filter fun S => P ⊆ S ∧ Disjoint Q S).card = 2 ^ (U.card - (P.card + Q.card)) := by let R := U \ (P ∪ Q) have hRcard : R.card = U.card - (P.card + Q.card) := by have hPQsub : P ∪ Q ⊆ U := Finset.union_subset hP hQ have hsd := Finset.card_sdiff_add_card_eq_card hPQsub rw [Finset.card_union_of_disjoint hd] at hsd dsimp only [R] omega rw [← hRcard, ← Finset.card_powerset] refine Finset.card_bij (fun S _ => S \ P) ?_ ?_ ?_ · intro S hS rcases Finset.mem_filter.mp hS with ⟨hSU, _, hQS⟩ rw [Finset.mem_powerset] intro x hx rcases Finset.mem_sdiff.mp hx with ⟨hxS, hxP⟩ refine Finset.mem_sdiff.mpr ⟨Finset.mem_powerset.mp hSU hxS, ?_⟩ rw [Finset.mem_union] rintro (h1 | h2) · exact hxP h1 · exact Finset.disjoint_left.mp hQS h2 hxS · intro S₁ hS₁ S₂ hS₂ h have hP₁ : P ⊆ S₁ := (Finset.mem_filter.mp hS₁).2.1 have hP₂ : P ⊆ S₂ := (Finset.mem_filter.mp hS₂).2.1 calc S₁ = (S₁ \ P) ∪ P := (Finset.sdiff_union_of_subset hP₁).symm _ = (S₂ \ P) ∪ P := by rw [h] _ = S₂ := Finset.sdiff_union_of_subset hP₂ · intro K hK have hKR : K ⊆ R := Finset.mem_powerset.mp hK have hKP : Disjoint K P := by rw [Finset.disjoint_left] intro x hxK hxP exact (Finset.mem_sdiff.mp (hKR hxK)).2 (Finset.mem_union_left Q hxP) have hKQ : Disjoint Q K := by rw [Finset.disjoint_left] intro x hxQ hxK exact (Finset.mem_sdiff.mp (hKR hxK)).2 (Finset.mem_union_right P hxQ) refine ⟨K ∪ P, Finset.mem_filter.mpr ⟨?_, Finset.subset_union_right, ?_⟩, ?_⟩ · rw [Finset.mem_powerset] exact Finset.union_subset (hKR.trans Finset.sdiff_subset) hP · exact Finset.disjoint_union_right.mpr ⟨hKQ, hd.symm⟩ · exact Finset.union_sdiff_cancel_right hKP /-- Monotonicity transfer for `x ↦ x * (1 + √(2m log(M / x)))` when `α ≤ 9/16`: if `0 < s ≤ t` and `α * M ≤ s * (1 + √(2m log(M / s)))`, then `α * M ≤ t * (1 + √(2m log(M / t)))`. -/ lemma subgaussian_monotone_transfer {M m α s t : ℝ} (hM : 0 < M) (hm : 0 ≤ m) (hα : α ≤ 9 / 16) (hs : 0 < s) (hst : s ≤ t) (hineq : α * M ≤ s * (1 + Real.sqrt (2 * m * Real.log (M / s)))) : α * M ≤ t * (1 + Real.sqrt (2 * m * Real.log (M / t))) := by by_cases ht_big : α * M ≤ t · have hsqrt_nn : 0 ≤ Real.sqrt (2 * m * Real.log (M / t)) := Real.sqrt_nonneg _ nlinarith · push Not at ht_big have hexp_half : (9 / 16 : ℝ) ≤ Real.exp (-(1 / 2 : ℝ)) := by have hq : (3 / 4 : ℝ) ≤ Real.exp (-(1 / 4 : ℝ)) := by linarith [Real.add_one_le_exp (-(1 / 4 : ℝ))] have hsq : (3 / 4 : ℝ) ^ 2 ≤ (Real.exp (-(1 / 4 : ℝ))) ^ 2 := by nlinarith rw [← Real.exp_nat_mul] at hsq have hsimp : (2 : ℕ) * (-(1 / 4 : ℝ)) = -(1 / 2 : ℝ) := by norm_num rw [hsimp] at hsq linarith have ht_lt_em : t ≤ Real.exp (-(1 / 2 : ℝ)) * M := by nlinarith let f : ℝ → ℝ := fun x => x ^ 2 * Real.log (M / x) have hf_deriv : ∀ x ∈ Set.Ioo (0 : ℝ) (Real.exp (-(1 / 2 : ℝ)) * M), HasDerivAt f (x * (2 * Real.log (M / x) - 1)) x := by intro x hx have hx_pos : 0 < x := hx.1 have h1 : HasDerivAt (fun r : ℝ => r ^ 2) (2 * x) x := by simpa using hasDerivAt_pow 2 x have h3 : HasDerivAt (fun r : ℝ => Real.log (M / r)) (-(x⁻¹)) x := by have hsub : HasDerivAt (fun r : ℝ => Real.log M - Real.log r) (0 - x⁻¹) x := (hasDerivAt_const x (Real.log M)).sub (Real.hasDerivAt_log hx_pos.ne') rw [zero_sub] at hsub refine hsub.congr_of_eventuallyEq ?_ filter_upwards [eventually_gt_nhds hx_pos] with r hr exact Real.log_div hM.ne' hr.ne' have hprod := h1.mul h3 rwa [show 2 * x * Real.log (M / x) + x ^ 2 * -x⁻¹ = x * (2 * Real.log (M / x) - 1) by have hxne : x ≠ 0 := hx_pos.ne' field_simp; ring] at hprod have hf_mono : MonotoneOn f (Set.Ioc 0 (Real.exp (-(1 / 2 : ℝ)) * M)) := by refine monotoneOn_of_deriv_nonneg (convex_Ioc 0 (Real.exp (-(1 / 2 : ℝ)) * M)) ?_ ?_ ?_ · intro x hx have hcont1 : ContinuousAt (fun r : ℝ => r ^ 2) x := (continuous_pow 2).continuousAt have hcont2 : ContinuousAt (fun r : ℝ => Real.log (M / r)) x := (Real.continuousAt_log (div_pos hM hx.1).ne').comp (continuousAt_const.div continuousAt_id hx.1.ne') exact (hcont1.mul hcont2).continuousWithinAt · intro x hx rw [interior_Ioc] at hx exact (hf_deriv x hx).differentiableAt.differentiableWithinAt · intro x hx rw [interior_Ioc] at hx rw [(hf_deriv x hx).deriv] have hlog_ge : (1 / 2 : ℝ) ≤ Real.log (M / x) := by rw [← Real.log_exp (1 / 2 : ℝ)] apply Real.log_le_log (Real.exp_pos _) rw [le_div_iff₀ hx.1] have h1 : Real.exp (1 / 2 : ℝ) * x ≤ Real.exp (1 / 2 : ℝ) * (Real.exp (-(1 / 2 : ℝ)) * M) := mul_le_mul_of_nonneg_left hx.2.le (Real.exp_pos _).le rw [← mul_assoc, ← Real.exp_add, add_neg_cancel, Real.exp_zero, one_mul] at h1 linarith exact mul_nonneg hx.1.le (by linarith) have hs_mem : s ∈ Set.Ioc 0 (Real.exp (-(1 / 2 : ℝ)) * M) := ⟨hs, hst.trans ht_lt_em⟩ have ht_mem : t ∈ Set.Ioc 0 (Real.exp (-(1 / 2 : ℝ)) * M) := ⟨lt_of_lt_of_le hs hst, ht_lt_em⟩ have hf_le : f s ≤ f t := hf_mono hs_mem ht_mem hst have hexp_le1 : Real.exp (-(1 / 2 : ℝ)) ≤ 1 := by rw [Real.exp_le_one_iff]; norm_num have hlogs : 0 ≤ Real.log (M / s) := by apply Real.log_nonneg; rw [le_div_iff₀ hs, one_mul]; nlinarith [hs_mem.2] have hlogt : 0 ≤ Real.log (M / t) := by apply Real.log_nonneg; rw [le_div_iff₀ ht_mem.1, one_mul]; nlinarith [ht_mem.2] have hsq_le : (s * Real.sqrt (2 * m * Real.log (M / s))) ^ 2 ≤ (t * Real.sqrt (2 * m * Real.log (M / t))) ^ 2 := by rw [mul_pow, mul_pow, Real.sq_sqrt (by positivity), Real.sq_sqrt (by positivity)] have hmul := mul_le_mul_of_nonneg_left hf_le (by positivity : (0 : ℝ) ≤ 2 * m) dsimp only [f] at hmul linarith have hnn1 : 0 ≤ s * Real.sqrt (2 * m * Real.log (M / s)) := mul_nonneg hs.le (Real.sqrt_nonneg _) have hnn2 : 0 ≤ t * Real.sqrt (2 * m * Real.log (M / t)) := mul_nonneg ht_mem.1.le (Real.sqrt_nonneg _) have hprod_le : s * Real.sqrt (2 * m * Real.log (M / s)) ≤ t * Real.sqrt (2 * m * Real.log (M / t)) := by nlinarith nlinarith /-- **Bollobás Level-Preserving Bound**: for `a ∈ A.erase 0` with `2 * a ≠ 0`, the set `E_same` of subsets `S ⊆ U = (A.erase 0).erase a` whose shift by `+ 2 * a` hits another subset of `U` of the SAME cardinality satisfies `|E_same| ≤ (1 - α_coeff) * 2 ^ |U|`, with `α_coeff = 1/2` in general and `α_coeff = 9/16` when `4 * a ≠ 0`. -/ lemma card_same_le_of_valid {N : ℕ} [NeZero N] {A : Finset (ZMod N)} (hA : IsValidMod A) (h0 : (0 : ZMod N) ∈ A) {a : ZMod N} (ha : a ∈ A.erase 0) (h2a : (2 : ZMod N) * a ≠ 0) {α_coeff : ℝ} (hα : α_coeff = 1 / 2 ∨ (α_coeff = 9 / 16 ∧ (4 : ZMod N) * a ≠ 0)) : let U := (A.erase 0).erase a let σ : Finset (ZMod N) → ZMod N := fun S => ∑ x ∈ S, x let E_same := U.powerset.filter fun S => ∃ T ∈ U.powerset, σ S + 2 * a = σ T ∧ T.card = S.card (E_same.card : ℝ) ≤ (1 - α_coeff) * (2 : ℝ) ^ U.card := by intro U σ E_same let ℱ : Finset (Finset (ZMod N) × Finset (ZMod N)) := (U.powerset ×ˢ U.powerset).filter fun p => Disjoint p.1 p.2 ∧ p.1.card = p.2.card ∧ 1 ≤ p.1.card ∧ σ p.1 + 2 * a = σ p.2 have hℱ_disj : ∀ p ∈ ℱ, Disjoint p.1 p.2 := fun p hp => (Finset.mem_filter.mp hp).2.1 have hℱ_bal : ∀ p ∈ ℱ, p.1.card = p.2.card := fun p hp => (Finset.mem_filter.mp hp).2.2.1 have hℱ_pos : ∀ p ∈ ℱ, 1 ≤ p.1.card := fun p hp => (Finset.mem_filter.mp hp).2.2.2.1 have hℱ_cross : ∀ p ∈ ℱ, ∀ q ∈ ℱ, p ≠ q → ¬ Disjoint p.1 q.2 := by intro p hp q hq hne rcases Finset.mem_filter.mp hp with ⟨hpU, hdp, hbp, _, heqp⟩ rcases Finset.mem_filter.mp hq with ⟨hqU, hdq, hbq, _, heqq⟩ rcases Finset.mem_product.mp hpU with ⟨hp1, hp2⟩ rcases Finset.mem_product.mp hqU with ⟨hq1, hq2⟩ exact cross_intersect_minimal_pairs hA h0 ha (Finset.mem_powerset.mp hp1) (Finset.mem_powerset.mp hp2) (Finset.mem_powerset.mp hq1) (Finset.mem_powerset.mp hq2) hdp hdq hbp hbq heqp heqq hne have hEsame_sub : E_same ⊆ ℱ.biUnion (fun p => U.powerset.filter fun S => p.1 ⊆ S ∧ Disjoint p.2 S) := by intro S hS rcases Finset.mem_filter.mp hS with ⟨hSU, T, hTU, hTeq, hTcard⟩ let S' := S \ T let T' := T \ S have hS'sub : S' ⊆ U := Finset.sdiff_subset.trans (Finset.mem_powerset.mp hSU) have hT'sub : T' ⊆ U := Finset.sdiff_subset.trans (Finset.mem_powerset.mp hTU) have hdisjST : Disjoint S' T' := disjoint_sdiff_sdiff have hcardST : S'.card = T'.card := by have h1 := Finset.card_sdiff_add_card_inter S T have h2 := Finset.card_sdiff_add_card_inter T S rw [Finset.inter_comm] at h2 dsimp only [S', T'] omega have hsumST : σ S' + 2 * a = σ T' := by have hd1 : Disjoint (S \ T) (S ∩ T) := Finset.disjoint_left.mpr fun x hx1 hx2 => (Finset.mem_sdiff.mp hx1).2 (Finset.mem_inter.mp hx2).2 have hd2 : Disjoint (T \ S) (T ∩ S) := Finset.disjoint_left.mpr fun x hx1 hx2 => (Finset.mem_sdiff.mp hx1).2 (Finset.mem_inter.mp hx2).2 have h1 : σ S' + σ (S ∩ T) = σ S := by dsimp only [σ, S'] rw [← Finset.sum_union hd1, Finset.sdiff_union_inter] have h2 : σ T' + σ (T ∩ S) = σ T := by dsimp only [σ, T'] rw [← Finset.sum_union hd2, Finset.sdiff_union_inter] rw [Finset.inter_comm] at h2 linear_combination hTeq + h1 - h2 have hposST : 1 ≤ S'.card := by by_contra h0c have hS'0 : S' = ∅ := Finset.card_eq_zero.mp (by omega) have hT'0 : T' = ∅ := Finset.card_eq_zero.mp (by omega) rw [hS'0, hT'0] at hsumST simp [σ] at hsumST exact h2a hsumST refine Finset.mem_biUnion.mpr ⟨(S', T'), ?_, ?_⟩ · refine Finset.mem_filter.mpr ⟨Finset.mem_product.mpr ⟨Finset.mem_powerset.mpr hS'sub, Finset.mem_powerset.mpr hT'sub⟩, hdisjST, hcardST, hposST, hsumST⟩ · exact Finset.mem_filter.mpr ⟨hSU, Finset.sdiff_subset, disjoint_sdiff_self_left⟩ have hEsame_le_real : (E_same.card : ℝ) ≤ (2 : ℝ) ^ U.card * ∑ p ∈ ℱ, ((2 : ℝ) ^ (2 * p.1.card))⁻¹ := by have hnat : E_same.card ≤ ∑ p ∈ ℱ, 2 ^ (U.card - 2 * p.1.card) := by calc E_same.card ≤ (ℱ.biUnion (fun p => U.powerset.filter fun S => p.1 ⊆ S ∧ Disjoint p.2 S)).card := Finset.card_le_card hEsame_sub _ ≤ ∑ p ∈ ℱ, (U.powerset.filter fun S => p.1 ⊆ S ∧ Disjoint p.2 S).card := Finset.card_biUnion_le _ = ∑ p ∈ ℱ, 2 ^ (U.card - 2 * p.1.card) := by refine Finset.sum_congr rfl fun p hp => ?_ rcases Finset.mem_filter.mp hp with ⟨hpU, hdp, hbp, _, _⟩ rcases Finset.mem_product.mp hpU with ⟨hp1, hp2⟩ rw [card_subcube (Finset.mem_powerset.mp hp1) (Finset.mem_powerset.mp hp2) hdp, ← hbp, ← two_mul] have hreal : (E_same.card : ℝ) ≤ ∑ p ∈ ℱ, (2 : ℝ) ^ (U.card - 2 * p.1.card) := by exact_mod_cast hnat rw [Finset.mul_sum] refine hreal.trans (Finset.sum_le_sum fun p hp => ?_) rcases Finset.mem_filter.mp hp with ⟨hpU, hdp, hbp, _, _⟩ rcases Finset.mem_product.mp hpU with ⟨hp1, hp2⟩ have h2le : 2 * p.1.card ≤ U.card := by have hu : (p.1 ∪ p.2).card ≤ U.card := Finset.card_le_card (Finset.union_subset (Finset.mem_powerset.mp hp1) (Finset.mem_powerset.mp hp2)) rw [Finset.card_union_of_disjoint hdp, ← hbp, ← two_mul] at hu exact hu have hpow_eq : (2 : ℝ) ^ U.card = (2 : ℝ) ^ (U.card - 2 * p.1.card) * (2 : ℝ) ^ (2 * p.1.card) := by rw [← pow_add, Nat.sub_add_cancel h2le] rw [hpow_eq, mul_assoc, mul_inv_cancel₀ (by positivity), mul_one] rcases hα with rfl | ⟨rfl, h4a⟩ · have hw := bollobas_balanced_weight_le_half ℱ hℱ_disj hℱ_cross hℱ_bal hℱ_pos nlinarith [hEsame_le_real, hw, show (0 : ℝ) ≤ (2 : ℝ) ^ U.card by positivity] · have hone : (ℱ.filter fun p => p.1.card = 1).card ≤ 1 := by rw [Finset.card_le_one] intro p hp q hq by_contra hne rcases Finset.mem_filter.mp hp with ⟨hpℱ, hp1⟩ rcases Finset.mem_filter.mp hq with ⟨hqℱ, hq1⟩ have hp2 : p.2.card = 1 := by rw [← hℱ_bal p hpℱ, hp1] have hq2 : q.2.card = 1 := by rw [← hℱ_bal q hqℱ, hq1] obtain ⟨x, hx⟩ := Finset.card_eq_one.mp hp1 obtain ⟨y, hy⟩ := Finset.card_eq_one.mp hp2 obtain ⟨z, hz⟩ := Finset.card_eq_one.mp hq1 obtain ⟨w, hw⟩ := Finset.card_eq_one.mp hq2 have h12 := Finset.not_disjoint_iff.mp (hℱ_cross p hpℱ q hqℱ hne) have h21 := Finset.not_disjoint_iff.mp (hℱ_cross q hqℱ p hpℱ (Ne.symm hne)) rcases h12 with ⟨u, hu1, hu2⟩ rcases h21 with ⟨v, hv1, hv2⟩ rw [hx, Finset.mem_singleton] at hu1 rw [hw, Finset.mem_singleton] at hu2 rw [hz, Finset.mem_singleton] at hv1 rw [hy, Finset.mem_singleton] at hv2 have hxw : x = w := hu1.symm.trans hu2 have hzy : z = y := hv1.symm.trans hv2 have heqp := (Finset.mem_filter.mp hpℱ).2.2.2.2 have heqq := (Finset.mem_filter.mp hqℱ).2.2.2.2 rw [hx, hy] at heqp rw [hz, hw] at heqq simp only [σ, Finset.sum_singleton] at heqp heqq apply h4a rw [hxw] at heqp rw [hzy] at heqq linear_combination heqp + heqq have hw := bollobas_balanced_weight_le_seven_sixteenths ℱ hℱ_disj hℱ_cross hℱ_bal hℱ_pos hone nlinarith [hEsame_le_real, hw, show (0 : ℝ) ≤ (2 : ℝ) ^ U.card by positivity] /-- **Core Level-Preserving & Sub-Gaussian Inequality** for a fixed `a ∈ A.erase 0` with `2 * a ≠ 0`: letting `m = A.card - 2`, `t = N - 2 ^ (A.card - 1)`: - In general (`2 * a ≠ 0`), `(1 / 2) * 2 ^ m ≤ t * (1 + √(2 * m * log (2 ^ m / t)))`. - If moreover `4 * a ≠ 0`, `(9 / 16) * 2 ^ m ≤ t * (1 + √(2 * m * log (2 ^ m / t)))`. -/ lemma core_subgaussian_inequality {N : ℕ} [NeZero N] {A : Finset (ZMod N)} (hA : IsValidMod A) (h0 : (0 : ZMod N) ∈ A) {a : ZMod N} (ha : a ∈ A.erase 0) (h2a : (2 : ZMod N) * a ≠ 0) {α_coeff : ℝ} (hα : α_coeff = 1 / 2 ∨ (α_coeff = 9 / 16 ∧ (4 : ZMod N) * a ≠ 0)) : let m := A.card - 2 let t := N - 2 ^ (A.card - 1) 1 ≤ t ∧ α_coeff * (2 : ℝ) ^ m ≤ (t : ℝ) * (1 + Real.sqrt (2 * (m : ℝ) * Real.log ((2 : ℝ) ^ m / (t : ℝ)))) := by let A' := A.erase 0 let U := A'.erase a have hUcard : U.card = A.card - 2 := by dsimp only [U, A'] rw [Finset.card_erase_of_mem ha, Finset.card_erase_of_mem h0] omega have hA'card : A'.card = A.card - 1 := Finset.card_erase_of_mem h0 have hinjA' := subset_sum_injOn hA h0 have hUsubA' : U.powerset ⊆ A'.powerset := Finset.powerset_mono.mpr (Finset.erase_subset a A') have hinjU : Set.InjOn (fun S : Finset (ZMod N) => ∑ x ∈ S, x) (U.powerset : Set (Finset (ZMod N))) := hinjA'.mono (by exact_mod_cast hUsubA') let σ : Finset (ZMod N) → ZMod N := fun S => ∑ x ∈ S, x let X : Finset (ZMod N) := U.powerset.image σ let E_out : Finset (Finset (ZMod N)) := U.powerset.filter fun S => σ S + 2 * a ∉ X let E_in : Finset (Finset (ZMod N)) := U.powerset.filter fun T => σ T - 2 * a ∉ X let E_stay : Finset (Finset (ZMod N)) := U.powerset.filter fun S => σ S + 2 * a ∈ X let E_same : Finset (Finset (ZMod N)) := U.powerset.filter fun S => ∃ T ∈ U.powerset, σ S + 2 * a = σ T ∧ T.card = S.card let E_drop : Finset (Finset (ZMod N)) := U.powerset.filter fun S => ∃ T ∈ U.powerset, σ S + 2 * a = σ T ∧ T.card < S.card -- 1. E_out is nonempty (∅ ∈ E_out because 2 * a ≠ 0) have hEout_ne : E_out.Nonempty := by refine ⟨∅, Finset.mem_filter.mpr ⟨Finset.empty_mem_powerset U, ?_⟩⟩ intro hmem rcases Finset.mem_image.mp hmem with ⟨T, hT, hTeq⟩ have hTsub : T ⊆ U := Finset.mem_powerset.mp hT have hTle := level_monotone_two_mul hA h0 ha (Finset.empty_subset U) hTsub (by simpa [σ] using hTeq.symm) have hT0 : T = ∅ := Finset.card_eq_zero.mp (Nat.eq_zero_of_le_zero hTle) subst hT0 simp [σ] at hTeq exact h2a hTeq.symm -- 2. E_out.card ≤ N - 2 ^ (A.card - 1) have hEout_le_gap : 2 ^ (A.card - 1) + E_out.card ≤ N := by let SigmaSet : Finset (ZMod N) := A'.powerset.image σ let Gset : Finset (ZMod N) := E_out.image (fun S => σ S + 2 * a) have hSigmaCard : SigmaSet.card = 2 ^ (A.card - 1) := by rw [Finset.card_image_of_injOn hinjA', Finset.card_powerset, hA'card] have hGcard : Gset.card = E_out.card := by refine Finset.card_image_of_injOn fun S₁ hS₁ S₂ hS₂ h => ?_ have hS₁U := (Finset.mem_filter.mp hS₁).1 have hS₂U := (Finset.mem_filter.mp hS₂).1 exact hinjU hS₁U hS₂U (add_right_cancel h) have hdisjSG : Disjoint SigmaSet Gset := by rw [Finset.disjoint_left] intro z hzS hzG rcases Finset.mem_image.mp hzS with ⟨R, hR, rfl⟩ rcases Finset.mem_image.mp hzG with ⟨S, hS, hSeq⟩ have hSU : S ⊆ U := Finset.mem_powerset.mp (Finset.mem_filter.mp hS).1 have hSnotX : σ S + 2 * a ∉ X := (Finset.mem_filter.mp hS).2 have hRA' : R ⊆ A' := Finset.mem_powerset.mp hR by_cases haR : a ∈ R · let T := R.erase a have hTU : T ⊆ U := Finset.erase_subset_erase a hRA' have hσR : σ R = σ T + a := by dsimp only [σ, T] have hadd := Finset.add_sum_erase R (fun x => x) haR rw [add_comm] at hadd exact hadd.symm exact add_two_mul_ne_add_one hA h0 ha hSU hTU (hSeq.trans hσR) · have hRU : R ⊆ U := Finset.subset_erase.mpr ⟨hRA', haR⟩ exact hSnotX (Finset.mem_image.mpr ⟨R, Finset.mem_powerset.mpr hRU, hSeq.symm⟩) calc 2 ^ (A.card - 1) + E_out.card = SigmaSet.card + Gset.card := by rw [hSigmaCard, hGcard] _ = (SigmaSet ∪ Gset).card := (Finset.card_union_of_disjoint hdisjSG).symm _ ≤ (Finset.univ : Finset (ZMod N)).card := Finset.card_le_card (Finset.subset_univ _) _ = N := by rw [Finset.card_univ, ZMod.card] -- 3. E_out.card = E_in.card via the stay bijection have hstay_eq_in : E_stay.card = (U.powerset.filter fun T => σ T - 2 * a ∈ X).card := by refine Finset.card_bij (fun S hS => Classical.choose (Finset.mem_image.mp (Finset.mem_filter.mp hS).2)) ?_ ?_ ?_ · intro S hS have hspec := Classical.choose_spec (Finset.mem_image.mp (Finset.mem_filter.mp hS).2) refine Finset.mem_filter.mpr ⟨hspec.1, Finset.mem_image.mpr ⟨S, (Finset.mem_filter.mp hS).1, ?_⟩⟩ linear_combination -hspec.2 · intro S₁ hS₁ S₂ hS₂ h have h1 := (Classical.choose_spec (Finset.mem_image.mp (Finset.mem_filter.mp hS₁).2)).2 have h2 := (Classical.choose_spec (Finset.mem_image.mp (Finset.mem_filter.mp hS₂).2)).2 rw [h] at h1 exact hinjU (Finset.mem_filter.mp hS₁).1 (Finset.mem_filter.mp hS₂).1 (add_right_cancel (h1.symm.trans h2)) · intro T hT rcases Finset.mem_filter.mp hT with ⟨hTU, hmem⟩ rcases Finset.mem_image.mp hmem with ⟨S, hSU, hSeq⟩ have hSstay : S ∈ E_stay := Finset.mem_filter.mpr ⟨hSU, Finset.mem_image.mpr ⟨T, hTU, by linear_combination -hSeq⟩⟩ refine ⟨S, hSstay, ?_⟩ have hspec := Classical.choose_spec (Finset.mem_image.mp (Finset.mem_filter.mp hSstay).2) exact hinjU hspec.1 hTU (by linear_combination hspec.2 + hSeq) have hEout_eq_Ein : E_out.card = E_in.card := by have h1 : E_stay.card + E_out.card = U.powerset.card := by have hsum := Finset.sum_filter_add_sum_filter_not U.powerset (fun S => σ S + 2 * a ∈ X) (fun _ => (1 : ℕ)) simpa [E_stay, E_out] using hsum have h2 : (U.powerset.filter fun T => σ T - 2 * a ∈ X).card + E_in.card = U.powerset.card := by have hsum := Finset.sum_filter_add_sum_filter_not U.powerset (fun T => σ T - 2 * a ∈ X) (fun _ => (1 : ℕ)) simpa [E_in] using hsum omega -- 4. Partition E_stay = E_same ∪ E_drop (disjoint) have hdisj_sd : Disjoint E_same E_drop := by rw [Finset.disjoint_left] intro S hS1 hS2 rcases (Finset.mem_filter.mp hS1).2 with ⟨T₁, hT₁, heq₁, hc₁⟩ rcases (Finset.mem_filter.mp hS2).2 with ⟨T₂, hT₂, heq₂, hc₂⟩ have hTeq : T₁ = T₂ := hinjU hT₁ hT₂ (heq₁.symm.trans heq₂) subst hTeq omega have hstay_union : E_stay = E_same ∪ E_drop := by ext S simp only [E_stay, E_same, E_drop, X, Finset.mem_union, Finset.mem_filter, Finset.mem_image] constructor · rintro ⟨hSU, T, hTU, hTeq⟩ have hle := level_monotone_two_mul hA h0 ha (Finset.mem_powerset.mp hSU) (Finset.mem_powerset.mp hTU) hTeq.symm rcases eq_or_lt_of_le hle with h | h · exact Or.inl ⟨hSU, T, hTU, hTeq.symm, h⟩ · exact Or.inr ⟨hSU, T, hTU, hTeq.symm, h⟩ · rintro (⟨hSU, T, hTU, hTeq, _⟩ | ⟨hSU, T, hTU, hTeq, _⟩) · exact ⟨hSU, T, hTU, hTeq.symm⟩ · exact ⟨hSU, T, hTU, hTeq.symm⟩ have hpart_card : E_out.card + E_same.card + E_drop.card = 2 ^ U.card := by have h1 : E_stay.card + E_out.card = U.powerset.card := by have hsum := Finset.sum_filter_add_sum_filter_not U.powerset (fun S => σ S + 2 * a ∈ X) (fun _ => (1 : ℕ)) simpa [E_stay, E_out] using hsum rw [hstay_union, Finset.card_union_of_disjoint hdisj_sd, Finset.card_powerset] at h1 omega -- 5. Bollobás bound on E_same have hEsame_bound : (E_same.card : ℝ) ≤ (1 - α_coeff) * (2 : ℝ) ^ U.card := card_same_le_of_valid hA h0 ha h2a hα -- 6. Level-Drop Telescoping have hdrop_le : (E_drop.card : ℝ) ≤ ∑ T ∈ E_in, ((T.card : ℝ) - (U.card : ℝ) / 2) + ∑ S ∈ E_out, ((U.card : ℝ) / 2 - (S.card : ℝ)) := by let φ : Finset (ZMod N) → Finset (ZMod N) := fun S => if hS : S ∈ E_stay then Classical.choose (Finset.mem_image.mp (Finset.mem_filter.mp hS).2) else ∅ have hφ_spec : ∀ S ∈ E_stay, φ S ∈ U.powerset ∧ σ S + 2 * a = σ (φ S) := by intro S hS have hs := Classical.choose_spec (Finset.mem_image.mp (Finset.mem_filter.mp hS).2) exact ⟨by simp only [φ, dif_pos hS]; exact hs.1, by simp only [φ, dif_pos hS]; exact hs.2.symm⟩ have hsum_stay_phi : ∑ S ∈ E_stay, ((φ S).card : ℝ) = ∑ T ∈ U.powerset.filter (fun T => σ T - 2 * a ∈ X), (T.card : ℝ) := by refine Finset.sum_bij (fun S _ => φ S) ?_ ?_ ?_ (fun _ _ => rfl) · intro S hS have ⟨hU, heq⟩ := hφ_spec S hS refine Finset.mem_filter.mpr ⟨hU, Finset.mem_image.mpr ⟨S, (Finset.mem_filter.mp hS).1, ?_⟩⟩ linear_combination heq · intro S₁ hS₁ S₂ hS₂ h have ⟨_, heq₁⟩ := hφ_spec S₁ hS₁ have ⟨_, heq₂⟩ := hφ_spec S₂ hS₂ rw [h] at heq₁ exact hinjU (Finset.mem_filter.mp hS₁).1 (Finset.mem_filter.mp hS₂).1 (add_right_cancel (heq₁.trans heq₂.symm)) · intro T hT rcases Finset.mem_filter.mp hT with ⟨hTU, hmem⟩ rcases Finset.mem_image.mp hmem with ⟨S, hSU, hSeq⟩ have hSstay : S ∈ E_stay := Finset.mem_filter.mpr ⟨hSU, Finset.mem_image.mpr ⟨T, hTU, by linear_combination -hSeq⟩⟩ refine ⟨S, hSstay, ?_⟩ have ⟨hφU, hφeq⟩ := hφ_spec S hSstay exact hinjU hφU hTU (by linear_combination -hφeq + hSeq) have htelescope : ∑ S ∈ E_stay, ((S.card : ℝ) - ((φ S).card : ℝ)) = ∑ T ∈ E_in, (T.card : ℝ) - ∑ S ∈ E_out, (S.card : ℝ) := by rw [Finset.sum_sub_distrib, hsum_stay_phi] have h1 : ∑ S ∈ E_stay, (S.card : ℝ) + ∑ S ∈ E_out, (S.card : ℝ) = ∑ S ∈ U.powerset, (S.card : ℝ) := Finset.sum_filter_add_sum_filter_not U.powerset (fun S => σ S + 2 * a ∈ X) (fun S => (S.card : ℝ)) have h2 : ∑ T ∈ U.powerset.filter (fun T => σ T - 2 * a ∈ X), (T.card : ℝ) + ∑ T ∈ E_in, (T.card : ℝ) = ∑ T ∈ U.powerset, (T.card : ℝ) := Finset.sum_filter_add_sum_filter_not U.powerset (fun T => σ T - 2 * a ∈ X) (fun T => (T.card : ℝ)) linarith have hcenter : ∑ T ∈ E_in, (T.card : ℝ) - ∑ S ∈ E_out, (S.card : ℝ) = ∑ T ∈ E_in, ((T.card : ℝ) - (U.card : ℝ) / 2) + ∑ S ∈ E_out, ((U.card : ℝ) / 2 - (S.card : ℝ)) := by simp_rw [Finset.sum_sub_distrib, Finset.sum_const, nsmul_eq_mul, hEout_eq_Ein] ring have hdrop_le_tel : (E_drop.card : ℝ) ≤ ∑ S ∈ E_stay, ((S.card : ℝ) - ((φ S).card : ℝ)) := by rw [hstay_union, Finset.sum_union hdisj_sd] have hsame_nn : 0 ≤ ∑ S ∈ E_same, ((S.card : ℝ) - ((φ S).card : ℝ)) := by refine Finset.sum_nonneg fun S hS => ?_ have hSstay : S ∈ E_stay := by rw [hstay_union]; exact Finset.mem_union_left _ hS have ⟨hφU, hφeq⟩ := hφ_spec S hSstay have hle := level_monotone_two_mul hA h0 ha (Finset.mem_powerset.mp (Finset.mem_filter.mp hS).1) (Finset.mem_powerset.mp hφU) hφeq have hleR : ((φ S).card : ℝ) ≤ (S.card : ℝ) := by exact_mod_cast hle linarith have hdrop_ge1 : (E_drop.card : ℝ) ≤ ∑ S ∈ E_drop, ((S.card : ℝ) - ((φ S).card : ℝ)) := by have hpt : ∀ S ∈ E_drop, (1 : ℝ) ≤ (S.card : ℝ) - ((φ S).card : ℝ) := by intro S hS have hSstay : S ∈ E_stay := by rw [hstay_union]; exact Finset.mem_union_right _ hS have ⟨hφU, hφeq⟩ := hφ_spec S hSstay rcases (Finset.mem_filter.mp hS).2 with ⟨T, hTU, hTeq, hTlt⟩ have hφT : φ S = T := hinjU hφU hTU (hφeq.symm.trans hTeq) rw [hφT] have h1 : T.card + 1 ≤ S.card := hTlt have h1R : (T.card : ℝ) + 1 ≤ (S.card : ℝ) := by exact_mod_cast h1 linarith calc (E_drop.card : ℝ) = ∑ _S ∈ E_drop, (1 : ℝ) := by rw [Finset.sum_const, nsmul_eq_mul, mul_one] _ ≤ ∑ S ∈ E_drop, ((S.card : ℝ) - ((φ S).card : ℝ)) := Finset.sum_le_sum hpt linarith linarith [hdrop_le_tel, htelescope, hcenter] -- 7. Combine with Sub-Gaussian Cube Tail Bound! have hEin_ne : E_in.Nonempty := Finset.card_pos.mp (by rw [← hEout_eq_Ein]; exact hEout_ne.card_pos) have hsubg := subgaussian_cube_sum_bound (Finset.filter_subset _ U.powerset) (Finset.filter_subset _ U.powerset) hEout_eq_Ein.symm hEin_ne rw [← hEout_eq_Ein] at hsubg have hEout_ineq : α_coeff * (2 : ℝ) ^ U.card ≤ (E_out.card : ℝ) * (1 + Real.sqrt (2 * (U.card : ℝ) * Real.log ((2 : ℝ) ^ U.card / (E_out.card : ℝ)))) := by have hpartR : (E_out.card : ℝ) + (E_same.card : ℝ) + (E_drop.card : ℝ) = (2 : ℝ) ^ U.card := by exact_mod_cast hpart_card linarith [hEsame_bound, hdrop_le, hsubg, hpartR] -- 8. Transfer from E_out.card ≤ t = N - 2 ^ (A.card - 1) have ht_ge1 : 1 ≤ N - 2 ^ (A.card - 1) := by have := hEout_ne.card_pos omega refine ⟨ht_ge1, ?_⟩ rw [← hUcard] have hEout_le_tR : (E_out.card : ℝ) ≤ ((N - 2 ^ (A.card - 1) : ℕ) : ℝ) := by exact_mod_cast (by omega : E_out.card ≤ N - 2 ^ (A.card - 1)) have hα_le : α_coeff ≤ 9 / 16 := by rcases hα with rfl | ⟨rfl, _⟩ <;> norm_num exact subgaussian_monotone_transfer (by positivity) (by positivity) hα_le (Nat.cast_pos.mpr hEout_ne.card_pos) hEout_le_tR hEout_ineq end LevelDrop /-! ## Section 5: Main World-Record Lower Bounds & Dominance over Sitjar (Nov 2026) -/ section MainTheorems /-- **Theorem 1 (Implicit Sub-Gaussian Lower Bound for all `n ≥ 3`)**: For every valid `n`-set `A ⊆ ZMod N` with `n ≥ 3` and `N > 0`, letting `t = N - 2 ^ (n - 1)`: `1 ≤ t` and `(1 / 2) * 2 ^ (n - 2) ≤ t * (1 + √(2 * (n - 2) * log (2 ^ (n - 2) / t)))`. -/ theorem fonollosa_subgaussian_implicit_ge_three {N n : ℕ} [NeZero N] {A : Finset (ZMod N)} (hcard : A.card = n) (hn : 3 ≤ n) (hA : IsValidMod A) : let t := N - 2 ^ (n - 1) 1 ≤ t ∧ (1 / 2 : ℝ) * (2 : ℝ) ^ (n - 2) ≤ (t : ℝ) * (1 + Real.sqrt (2 * ((n - 2 : ℕ) : ℝ) * Real.log ((2 : ℝ) ^ (n - 2) / (t : ℝ)))) := by have hAne : A.Nonempty := Finset.card_pos.mp (by omega) obtain ⟨a₀, ha₀⟩ := hAne let B := A.image (fun x => x - a₀) have hB : IsValidMod B := isValidMod_translate hA a₀ have h0B : (0 : ZMod N) ∈ B := Finset.mem_image.mpr ⟨a₀, ha₀, sub_self a₀⟩ have hBcard : B.card = n := by rw [Finset.card_image_of_injective _ (fun x y h => sub_left_inj.mp h), hcard] have hB'card : 2 ≤ (B.erase 0).card := by rw [Finset.card_erase_of_mem h0B, hBcard]; omega obtain ⟨a, ha, h2a⟩ := exists_two_mul_ne_zero (Finset.notMem_erase 0 B) hB'card have hcore := core_subgaussian_inequality hB h0B ha h2a (α_coeff := 1 / 2) (Or.inl rfl) simpa [hBcard] using hcore /-- **Theorem 2 (Refined Implicit Sub-Gaussian Lower Bound for all `n ≥ 5`)**: Using the existence of an element `a ∈ A \ {0}` with `4 * a ≠ 0` in the cyclic group `ZMod N`, the constant `1/2` sharpens to `9/16`: for every valid `n`-set `A ⊆ ZMod N` (`n ≥ 5`, `N > 0`), letting `t = N - 2 ^ (n - 1)`: `1 ≤ t` and `(9 / 16) * 2 ^ (n - 2) ≤ t * (1 + √(2 * (n - 2) * log (2 ^ (n - 2) / t)))`. -/ theorem fonollosa_subgaussian_implicit_ge_five {N n : ℕ} [NeZero N] {A : Finset (ZMod N)} (hcard : A.card = n) (hn : 5 ≤ n) (hA : IsValidMod A) : let t := N - 2 ^ (n - 1) 1 ≤ t ∧ (9 / 16 : ℝ) * (2 : ℝ) ^ (n - 2) ≤ (t : ℝ) * (1 + Real.sqrt (2 * ((n - 2 : ℕ) : ℝ) * Real.log ((2 : ℝ) ^ (n - 2) / (t : ℝ)))) := by have hAne : A.Nonempty := Finset.card_pos.mp (by omega) obtain ⟨a₀, ha₀⟩ := hAne let B := A.image (fun x => x - a₀) have hB : IsValidMod B := isValidMod_translate hA a₀ have h0B : (0 : ZMod N) ∈ B := Finset.mem_image.mpr ⟨a₀, ha₀, sub_self a₀⟩ have hBcard : B.card = n := by rw [Finset.card_image_of_injective _ (fun x y h => sub_left_inj.mp h), hcard] have hB'card : 4 ≤ (B.erase 0).card := by rw [Finset.card_erase_of_mem h0B, hBcard]; omega obtain ⟨a, ha, h4a⟩ := exists_four_mul_ne_zero (Finset.notMem_erase 0 B) hB'card have h2a : (2 : ZMod N) * a ≠ 0 := fun h => h4a (by linear_combination 2 * h) have hcore := core_subgaussian_inequality hB h0B ha h2a (α_coeff := 9 / 16) (Or.inr ⟨rfl, h4a⟩) simpa [hBcard] using hcore /-- Auxiliary inversion lemma for `p * (1 + √(2m log(1/p))) ≥ 9/16`: for all `m ≥ 3`, if `0 < p` and `(9 / 16) ≤ p * (1 + √(2m log(1/p)))`, then `(9 / 16) / (1 + √(2m log(4m))) ≤ p`. -/ lemma invert_subgaussian_bound {m : ℕ} (hm : 3 ≤ m) {p : ℝ} (hp : 0 < p) (hineq : (9 / 16 : ℝ) ≤ p * (1 + Real.sqrt (2 * (m : ℝ) * Real.log (1 / p)))) : (9 / 16 : ℝ) / (1 + Real.sqrt (2 * (m : ℝ) * Real.log (4 * (m : ℝ)))) ≤ p := by have hmr_base : (3 : ℝ) ≤ (m : ℝ) := by exact_mod_cast hm set mr : ℝ := (m : ℝ) have hmr : (3 : ℝ) ≤ mr := hmr_base have h4m_gt1 : (1 : ℝ) < 4 * mr := by linarith have hlog4m_pos : 0 < Real.log (4 * mr) := Real.log_pos h4m_gt1 set D : ℝ := 1 + Real.sqrt (2 * mr * Real.log (4 * mr)) have hD_pos : 0 < D := by positivity set p₀ : ℝ := (9 / 16 : ℝ) / D have hp₀_pos : 0 < p₀ := div_pos (by norm_num) hD_pos have hlog4_le2 : Real.log 4 ≤ 2 := by have h2e : (2 : ℝ) ≤ Real.exp 1 := by linarith [Real.add_one_le_exp (1 : ℝ)] have h4e : (4 : ℝ) ≤ Real.exp 2 := by calc (4 : ℝ) = 2 ^ 2 := by norm_num _ ≤ (Real.exp 1) ^ 2 := by nlinarith _ = Real.exp 2 := by rw [← Real.exp_nat_mul]; norm_num rw [← Real.log_exp 2] exact Real.log_le_log (by norm_num) h4e have hlog4m_le : Real.log (4 * mr) ≤ mr + 1 := by rw [Real.log_mul (by norm_num) (by linarith)] have hlm := Real.log_le_sub_one_of_pos (by linarith : (0 : ℝ) < mr) linarith have hD_le : D ≤ (9 / 4 : ℝ) * mr := by have hsq : 2 * mr * Real.log (4 * mr) ≤ ((9 / 4 : ℝ) * mr - 1) ^ 2 := by have h1 : 2 * mr * Real.log (4 * mr) ≤ 2 * mr * (mr + 1) := mul_le_mul_of_nonneg_left hlog4m_le (by linarith) nlinarith have hrt : Real.sqrt (2 * mr * Real.log (4 * mr)) ≤ (9 / 4 : ℝ) * mr - 1 := by rw [← Real.sqrt_sq (by linarith : 0 ≤ (9 / 4 : ℝ) * mr - 1)] exact Real.sqrt_le_sqrt hsq dsimp only [D] linarith have hinv_p₀ : 1 / p₀ ≤ 4 * mr := by dsimp only [p₀] rw [one_div_div, div_le_iff₀ (by norm_num : (0 : ℝ) < 9 / 16)] linarith have hexp_half : (9 / 16 : ℝ) ≤ Real.exp (-(1 / 2 : ℝ)) := by have hq : (3 / 4 : ℝ) ≤ Real.exp (-(1 / 4 : ℝ)) := by linarith [Real.add_one_le_exp (-(1 / 4 : ℝ))] have hsq : (3 / 4 : ℝ) ^ 2 ≤ (Real.exp (-(1 / 4 : ℝ))) ^ 2 := by nlinarith rw [← Real.exp_nat_mul] at hsq have hsimp : (2 : ℕ) * (-(1 / 4 : ℝ)) = -(1 / 2 : ℝ) := by norm_num rw [hsimp] at hsq linarith have hp₀_le_e : p₀ ≤ Real.exp (-(1 / 2 : ℝ)) := by have hD_ge1 : 1 ≤ D := by dsimp only [D]; linarith [Real.sqrt_nonneg (2 * mr * Real.log (4 * mr))] have : p₀ ≤ 9 / 16 := div_le_self (by norm_num) hD_ge1 linarith by_contra hlt push Not at hlt let g : ℝ → ℝ := fun x => x ^ 2 * Real.log (1 / x) have hg_deriv : ∀ x ∈ Set.Ioo (0 : ℝ) (Real.exp (-(1 / 2 : ℝ))), HasDerivAt g (x * (2 * Real.log (1 / x) - 1)) x := by intro x hx have h1 : HasDerivAt (fun s : ℝ => s ^ 2) (2 * x) x := by simpa using hasDerivAt_pow 2 x have h3 : HasDerivAt (fun s : ℝ => Real.log (1 / s)) (-(x⁻¹)) x := by have hneg := (Real.hasDerivAt_log hx.1.ne').neg refine hneg.congr_of_eventuallyEq ?_ filter_upwards [eventually_gt_nhds hx.1] with s _ rw [one_div, Real.log_inv] rfl have hprod := h1.mul h3 rwa [show 2 * x * Real.log (1 / x) + x ^ 2 * -x⁻¹ = x * (2 * Real.log (1 / x) - 1) by have hxne : x ≠ 0 := hx.1.ne' field_simp; ring] at hprod have hg_mono : MonotoneOn g (Set.Ioc 0 (Real.exp (-(1 / 2 : ℝ)))) := by refine monotoneOn_of_deriv_nonneg (convex_Ioc 0 (Real.exp (-(1 / 2 : ℝ)))) ?_ ?_ ?_ · intro x hx have h1 : ContinuousAt (fun s : ℝ => s ^ 2) x := (continuous_pow 2).continuousAt have h2 : ContinuousAt (fun s : ℝ => Real.log (1 / s)) x := (Real.continuousAt_log (div_pos one_pos hx.1).ne').comp (continuousAt_const.div continuousAt_id hx.1.ne') exact (h1.mul h2).continuousWithinAt · intro x hx rw [interior_Ioc] at hx exact (hg_deriv x hx).differentiableAt.differentiableWithinAt · intro x hx rw [interior_Ioc] at hx rw [(hg_deriv x hx).deriv] have hlog_ge : (1 / 2 : ℝ) ≤ Real.log (1 / x) := by rw [← Real.log_exp (1 / 2 : ℝ)] apply Real.log_le_log (Real.exp_pos _) rw [le_div_iff₀ hx.1] have h1 : Real.exp (1 / 2 : ℝ) * x ≤ Real.exp (1 / 2 : ℝ) * Real.exp (-(1 / 2 : ℝ)) := mul_le_mul_of_nonneg_left hx.2.le (Real.exp_pos _).le rw [← Real.exp_add, add_neg_cancel, Real.exp_zero] at h1 exact h1 exact mul_nonneg hx.1.le (by linarith) have hg_le : g p ≤ g p₀ := hg_mono ⟨hp, hlt.le.trans hp₀_le_e⟩ ⟨hp₀_pos, hp₀_le_e⟩ hlt.le have hlogp_nn : 0 ≤ Real.log (1 / p) := by apply Real.log_nonneg rw [le_div_iff₀ hp, one_mul] have : Real.exp (-(1 / 2 : ℝ)) ≤ 1 := by rw [Real.exp_le_one_iff]; norm_num linarith have hlogp₀_nn : 0 ≤ Real.log (1 / p₀) := by apply Real.log_nonneg rw [le_div_iff₀ hp₀_pos, one_mul] have : Real.exp (-(1 / 2 : ℝ)) ≤ 1 := by rw [Real.exp_le_one_iff]; norm_num linarith have hrt_le : p * Real.sqrt (2 * mr * Real.log (1 / p)) ≤ p₀ * Real.sqrt (2 * mr * Real.log (1 / p₀)) := by have hsq : (p * Real.sqrt (2 * mr * Real.log (1 / p))) ^ 2 ≤ (p₀ * Real.sqrt (2 * mr * Real.log (1 / p₀))) ^ 2 := by rw [mul_pow, mul_pow, Real.sq_sqrt (by positivity), Real.sq_sqrt (by positivity)] have hmul := mul_le_mul_of_nonneg_left hg_le (by positivity : (0 : ℝ) ≤ 2 * mr) dsimp only [g] at hmul linarith have hnn1 : 0 ≤ p * Real.sqrt (2 * mr * Real.log (1 / p)) := mul_nonneg hp.le (Real.sqrt_nonneg _) have hnn2 : 0 ≤ p₀ * Real.sqrt (2 * mr * Real.log (1 / p₀)) := mul_nonneg hp₀_pos.le (Real.sqrt_nonneg _) nlinarith have hlog_p₀_le : Real.log (1 / p₀) ≤ Real.log (4 * mr) := Real.log_le_log (div_pos one_pos hp₀_pos) hinv_p₀ have hrt_p₀_le : p₀ * Real.sqrt (2 * mr * Real.log (1 / p₀)) ≤ p₀ * Real.sqrt (2 * mr * Real.log (4 * mr)) := by refine mul_le_mul_of_nonneg_left (Real.sqrt_le_sqrt ?_) hp₀_pos.le exact mul_le_mul_of_nonneg_left hlog_p₀_le (by positivity) have hp₀_eq : p₀ * (1 + Real.sqrt (2 * mr * Real.log (4 * mr))) = 9 / 16 := by dsimp only [p₀, D] exact div_mul_cancel₀ (9 / 16 : ℝ) hD_pos.ne' linarith /-- **Theorem 3 (Explicit Closed-Form World-Record Lower Bound for all `n ≥ 5`)**: For every `n ≥ 5`, every `N > 0`, and every valid `n`-set `A ⊆ ZMod N`: $$N \ge 2^{n - 1} + \frac{\frac{9}{16} \cdot 2^{n - 2}}{1 + \sqrt{2(n - 2)\ln(4(n - 2))}}.$$ -/ theorem fonollosa_explicit_lower_bound {N n : ℕ} [NeZero N] {A : Finset (ZMod N)} (hcard : A.card = n) (hn : 5 ≤ n) (hA : IsValidMod A) : (2 : ℝ) ^ (n - 1) + ((9 / 16 : ℝ) * (2 : ℝ) ^ (n - 2)) / (1 + Real.sqrt (2 * ((n - 2 : ℕ) : ℝ) * Real.log (4 * ((n - 2 : ℕ) : ℝ)))) ≤ (N : ℝ) := by have hinal : 2 ^ (n - 1) ≤ N := inal_lower_bound hcard (by omega) hA have ⟨ht1, himp⟩ := fonollosa_subgaussian_implicit_ge_five hcard hn hA set m := n - 2 set t := N - 2 ^ (n - 1) have ht_pos : (0 : ℝ) < (t : ℝ) := Nat.cast_pos.mpr (by omega) have h2m_pos : (0 : ℝ) < (2 : ℝ) ^ m := by positivity set p : ℝ := (t : ℝ) / (2 : ℝ) ^ m have hp_pos : 0 < p := div_pos ht_pos h2m_pos have hinv_eq : (2 : ℝ) ^ m / (t : ℝ) = 1 / p := by dsimp only [p]; field_simp have hp_ineq : (9 / 16 : ℝ) ≤ p * (1 + Real.sqrt (2 * (m : ℝ) * Real.log (1 / p))) := by rw [← hinv_eq] dsimp only [p] rw [div_mul_eq_mul_div, le_div_iff₀ h2m_pos] exact himp have hp_ge := invert_subgaussian_bound (m := m) (by omega) hp_pos hp_ineq have ht_ge : ((9 / 16 : ℝ) * (2 : ℝ) ^ m) / (1 + Real.sqrt (2 * (m : ℝ) * Real.log (4 * (m : ℝ)))) ≤ (t : ℝ) := by have hmul := mul_le_mul_of_nonneg_right hp_ge h2m_pos.le dsimp only [p] at hmul rw [div_mul_cancel₀ _ h2m_pos.ne'] at hmul linarith [show (9 / 16 : ℝ) / (1 + Real.sqrt (2 * (m : ℝ) * Real.log (4 * (m : ℝ)))) * (2 : ℝ) ^ m = ((9 / 16 : ℝ) * (2 : ℝ) ^ m) / (1 + Real.sqrt (2 * (m : ℝ) * Real.log (4 * (m : ℝ)))) by ring] have hN_eq : (2 : ℝ) ^ (n - 1) + (t : ℝ) = (N : ℝ) := by have hnat : 2 ^ (n - 1) + t = N := Nat.add_sub_of_le hinal exact_mod_cast hnat linarith /-- **Theorem 4 (Asymptotic Dominance over Sitjar's November 2026 Bound)**: For every constant `C : ℝ`, there exists `n₀ : ℕ` such that for all `n ≥ n₀`, every `N > 0`, and every valid `n`-set `A ⊆ ZMod N`, $$N - 2^{n - 1} \ge C \cdot \frac{2^{n - 1}}{n - 1}.$$ In particular, our lower bound beats Sitjar's `2 ^ (n - 1) + ⌈(2 ^ (n - 1) - 1) / (n - 1)⌉` by an arbitrarily large multiplicative factor on the excess `N - 2 ^ (n - 1)`. -/ theorem fonollosa_beats_sitjar_asymptotically (C : ℝ) : ∃ n₀ : ℕ, ∀ n : ℕ, n₀ ≤ n → ∀ {N : ℕ} [NeZero N] {A : Finset (ZMod N)}, A.card = n → IsValidMod A → C * ((2 : ℝ) ^ (n - 1) / ((n - 1 : ℕ) : ℝ)) ≤ (N : ℝ) - (2 : ℝ) ^ (n - 1) := by -- Use elementary inequality: log (4 * m) ≤ 4 * m ^ (1/2) (in fact log x ≤ 2 * √x for x > 0!) -- Proof of log (4m) ≤ 2 * √(4m) = 4 * √m? Even better: log (4m) = 4 * log ((4m)^(1/4)) ≤ 4 * (4m)^(1/4) -- No, even simpler without fractional powers: log (4m) ≤ 4 * √(√(4m))! -- Because log y ≤ y for y > 0, so for y = √(√(4m)): log (y^4) = 4 log y ≤ 4 y! -- Then 2 * m * log(4m) ≤ 8 * m * √(√(4m)) = 8 * √(m^2 * √(4m))! -- And we only need (9 / 32) * (n - 1) ≥ C * (1 + √(2 * m * log (4 * m)))! -- With 2 * m * log(4m) ≤ 8 * m * √(√(4m)), √(2m log(4m)) ≤ √8 * m^(5/8), while LHS is linear in m!! -- Even simpler: let K = max 1 (⌈|C|⌉ + 1), choose n₀ = 2 + (32 * K)^4!! -- Check: for any m ≥ (32 * K)^4, let u := √(√(4 * m)) ≥ 32 * K: -- Wait: 4 * m = u^4 ⇒ m = u^4 / 4. -- log(4m) = log(u^4) = 4 * log u ≤ 4 * u! -- So 2 * m * log(4m) ≤ 2 * (u^4 / 4) * (4 * u) = 2 * u^5! -- And 1 + √(2 * m * log(4m)) ≤ 1 + √(2 * u^5) ≤ 2 * u^3! -- Meanwhile (9 / 32) * m = (9 / 128) * u^4! -- Since u ≥ 32 * K ≥ 32, (9 / 128) * u^4 / (2 * u^3) = (9 / 256) * u ≥ (9 / 256) * (32 * K) = (9 / 8) * K > K ≥ C!! -- ZERO FRACTIONAL POWERS! JUST TWO `Real.sqrt`s!! let K : ℕ := max 1 (Nat.ceil (max C 0) + 1) refine ⟨2 + (32 * K) ^ 4, fun n hn N _ A hcard hA => ?_⟩ have hn5 : 5 ≤ n := by have hK1 : 1 ≤ K := le_max_left _ _ have : 32 ≤ (32 * K) ^ 4 := by calc 32 ≤ 32 * K := by omega _ ≤ (32 * K) ^ 4 := Nat.le_self_pow (by decide) _ omega have hexp := fonollosa_explicit_lower_bound hcard hn5 hA set m := n - 2 have hm_ge : (32 * K) ^ 4 ≤ m := by omega have hmr_ge : ((32 * K : ℕ) : ℝ) ^ 4 ≤ (m : ℝ) := by exact_mod_cast hm_ge have hK_ge1 : (1 : ℝ) ≤ (K : ℝ) := by exact_mod_cast (le_max_left 1 (Nat.ceil (max C 0) + 1)) have hC_le_K : C ≤ (K : ℝ) := by have h1 : C ≤ max C 0 := le_max_left C 0 have h2 : max C 0 ≤ (Nat.ceil (max C 0) : ℝ) := Nat.le_ceil _ have h3 : (Nat.ceil (max C 0) : ℝ) + 1 ≤ (K : ℝ) := by exact_mod_cast le_max_right 1 (Nat.ceil (max C 0) + 1) linarith have hm_pos : (0 : ℝ) < (m : ℝ) := by have h1 : (1 : ℝ) ≤ ((32 * K : ℕ) : ℝ) := by have : 1 ≤ 32 * K := by have := le_max_left 1 (Nat.ceil (max C 0) + 1); omega exact_mod_cast this have h4 : (1 : ℝ) ≤ ((32 * K : ℕ) : ℝ) ^ 4 := one_le_pow₀ h1 linarith set u : ℝ := Real.sqrt (Real.sqrt (4 * (m : ℝ))) have hu_pos : 0 < u := Real.sqrt_pos.mpr (Real.sqrt_pos.mpr (by positivity)) have hu4 : u ^ 4 = 4 * (m : ℝ) := by have h1 : u ^ 2 = Real.sqrt (4 * (m : ℝ)) := Real.sq_sqrt (Real.sqrt_nonneg _) calc u ^ 4 = (u ^ 2) ^ 2 := by ring _ = (Real.sqrt (4 * (m : ℝ))) ^ 2 := by rw [h1] _ = 4 * (m : ℝ) := Real.sq_sqrt (by positivity) have hu_ge : 32 * (K : ℝ) ≤ u := by have h4 : (32 * (K : ℝ)) ^ 4 ≤ u ^ 4 := by rw [hu4] have hcast : ((32 * K : ℕ) : ℝ) = 32 * (K : ℝ) := by push_cast; ring rw [← hcast] linarith by_contra hlt push Not at hlt have hpow_lt : u ^ 4 < (32 * (K : ℝ)) ^ 4 := pow_lt_pow_left₀ hlt hu_pos.le (by decide) linarith have hlog_le : Real.log (4 * (m : ℝ)) ≤ 4 * u := by rw [← hu4, Real.log_pow] have hlu : Real.log u ≤ u := by linarith [Real.log_le_sub_one_of_pos hu_pos] push_cast linarith have hrad_le : 2 * (m : ℝ) * Real.log (4 * (m : ℝ)) ≤ 2 * u ^ 5 := by have hm_eq : (m : ℝ) = u ^ 4 / 4 := by linarith [hu4] calc 2 * (m : ℝ) * Real.log (4 * (m : ℝ)) ≤ 2 * (m : ℝ) * (4 * u) := mul_le_mul_of_nonneg_left hlog_le (by positivity) _ = 2 * (u ^ 4 / 4) * (4 * u) := by rw [hm_eq] _ = 2 * u ^ 5 := by ring have hD_le : 1 + Real.sqrt (2 * (m : ℝ) * Real.log (4 * (m : ℝ))) ≤ 2 * u ^ 3 := by have hu32 : (32 : ℝ) ≤ u := by linarith have hu3_ge1 : (1 : ℝ) ≤ u ^ 3 := one_le_pow₀ (by linarith) have hsq : 2 * u ^ 5 ≤ (2 * u ^ 3 - 1) ^ 2 := by have hu2 : (32 : ℝ) * u ≤ u ^ 2 := by nlinarith have hu3 : (32 : ℝ) * u ^ 2 ≤ u ^ 3 := by nlinarith have hu5 : (32 : ℝ) * u ^ 4 ≤ u ^ 5 := by nlinarith have hu6 : (32 : ℝ) * u ^ 5 ≤ u ^ 6 := by nlinarith nlinarith have hrt : Real.sqrt (2 * (m : ℝ) * Real.log (4 * (m : ℝ))) ≤ 2 * u ^ 3 - 1 := by rw [← Real.sqrt_sq (by linarith : (0 : ℝ) ≤ 2 * u ^ 3 - 1)] exact Real.sqrt_le_sqrt (hrad_le.trans hsq) linarith have hD_pos : 0 < 1 + Real.sqrt (2 * (m : ℝ) * Real.log (4 * (m : ℝ))) := by positivity have hnm1 : ((n - 1 : ℕ) : ℝ) = (m : ℝ) + 1 := by have : n - 1 = m + 1 := by omega rw [this]; push_cast; ring have h2pow : (2 : ℝ) ^ (n - 1) = 2 * (2 : ℝ) ^ m := by have : n - 1 = m + 1 := by omega rw [this, pow_succ]; ring have hkey : C * ((2 : ℝ) ^ (n - 1) / ((n - 1 : ℕ) : ℝ)) ≤ ((9 / 16 : ℝ) * (2 : ℝ) ^ m) / (1 + Real.sqrt (2 * (m : ℝ) * Real.log (4 * (m : ℝ)))) := by rw [hnm1, h2pow] have hm1_pos : (0 : ℝ) < (m : ℝ) + 1 := by linarith have hmain_mul : C * (2 * (2 : ℝ) ^ m) * (1 + Real.sqrt (2 * (m : ℝ) * Real.log (4 * (m : ℝ)))) ≤ ((9 / 16 : ℝ) * (2 : ℝ) ^ m) * ((m : ℝ) + 1) := by have h2m_nn : (0 : ℝ) ≤ (2 : ℝ) ^ m := by positivity suffices hcancel : C * 2 * (1 + Real.sqrt (2 * (m : ℝ) * Real.log (4 * (m : ℝ)))) ≤ (9 / 16 : ℝ) * ((m : ℝ) + 1) by calc C * (2 * (2 : ℝ) ^ m) * (1 + Real.sqrt (2 * (m : ℝ) * Real.log (4 * (m : ℝ)))) = (2 : ℝ) ^ m * (C * 2 * (1 + Real.sqrt (2 * (m : ℝ) * Real.log (4 * (m : ℝ))))) := by ring _ ≤ (2 : ℝ) ^ m * ((9 / 16 : ℝ) * ((m : ℝ) + 1)) := mul_le_mul_of_nonneg_left hcancel h2m_nn _ = ((9 / 16 : ℝ) * (2 : ℝ) ^ m) * ((m : ℝ) + 1) := by ring have h1 : C * 2 * (1 + Real.sqrt (2 * (m : ℝ) * Real.log (4 * (m : ℝ)))) ≤ (K : ℝ) * 2 * (2 * u ^ 3) := by have hstep1 : C * 2 ≤ (K : ℝ) * 2 := by linarith have hstep2 : (K : ℝ) * 2 * (1 + Real.sqrt (2 * (m : ℝ) * Real.log (4 * (m : ℝ)))) ≤ (K : ℝ) * 2 * (2 * u ^ 3) := mul_le_mul_of_nonneg_left hD_le (by positivity) have hstep3 : C * 2 * (1 + Real.sqrt (2 * (m : ℝ) * Real.log (4 * (m : ℝ)))) ≤ (K : ℝ) * 2 * (1 + Real.sqrt (2 * (m : ℝ) * Real.log (4 * (m : ℝ)))) := mul_le_mul_of_nonneg_right hstep1 hD_pos.le exact hstep3.trans hstep2 have h2 : (K : ℝ) * 2 * (2 * u ^ 3) ≤ (9 / 16 : ℝ) * (m : ℝ) := by have hm_eq : (m : ℝ) = u ^ 4 / 4 := by linarith [hu4] rw [hm_eq] -- 4 * K * u^3 ≤ (9/64) * u^4 ⇔ 256 * K ≤ 9 * u (true since u ≥ 32 * K ⇒ 9 * u ≥ 288 * K!) have hu3_pos : 0 < u ^ 3 := by positivity nlinarith [hu_ge, hu3_pos, show (u ^ 4 : ℝ) = u * u ^ 3 by ring] linarith rw [mul_div_assoc', div_le_div_iff₀ hm1_pos hD_pos] exact hmain_mul linarith [hexp, hkey] end MainTheorems end FonollosaLowerBound /-! ## Axiom Audit -/ #print axioms FonollosaLowerBound.bollobas_two_families #print axioms FonollosaLowerBound.subgaussian_cube_sum_bound #print axioms FonollosaLowerBound.inal_lower_bound #print axioms FonollosaLowerBound.fonollosa_subgaussian_implicit_ge_three #print axioms FonollosaLowerBound.fonollosa_subgaussian_implicit_ge_five #print axioms FonollosaLowerBound.fonollosa_explicit_lower_bound #print axioms FonollosaLowerBound.fonollosa_beats_sitjar_asymptotically