import Mathlib.Algebra.BigOperators.Group.Finset.Basic import Mathlib.Algebra.BigOperators.Ring.Finset import Mathlib.Algebra.Order.BigOperators.Group.Finset import Mathlib.Algebra.Polynomial.BigOperators import Mathlib.Algebra.Polynomial.Degree.Lemmas import Mathlib.Algebra.Polynomial.Roots import Mathlib.Combinatorics.Enumerative.Catalan.Basic import Mathlib.Combinatorics.Hall.Basic import Mathlib.Data.Fin.Tuple.Basic import Mathlib.Data.Fintype.BigOperators import Mathlib.Data.Fintype.Prod import Mathlib.Data.Rat.Defs import Mathlib.Data.Real.Basic import Mathlib.LinearAlgebra.Dimension.Finite import Mathlib.LinearAlgebra.Dimension.Finrank import Mathlib.LinearAlgebra.Dimension.Free import Mathlib.LinearAlgebra.Dimension.RankNullity import Mathlib.Tactic /-! # Exact Multiplicity-Partition Littlewood–Offord Theory This file establishes and formalizes: 1. An elementary, self-contained `sl₂(ℚ)` Hard Lefschetz and `k`-Sperner engine for finite ranked posets, closed under Cartesian products (`Sl2Poset`). 2. Stanley's shifted-subset poset `M(L)` with an explicit integer-weighted `sl₂(ℚ)`-action (Proctor 1982) and Abel summation-by-parts monotonicity. 3. **Exact Multiplicity-Partition `k`-Point Littlewood–Offord Theorem** over arbitrary linearly ordered abelian groups (and `r`-separated open intervals in `ℝ`), with exact sharpness attained by `v*(λ) = (1^{λ₁}, 2^{λ₂}, …, d^{λ_d})`. 4. **Higher-Dimensional Lifting to `ℝ^D`** via a constructive polynomial-root separating linear functional. 5. **Exact Dominance-Order Schur-Convexity Theorem**: `λ ⊴ μ → M_k*(λ) ≤ M_k*(μ)` for all `k ≥ 1`, proved via Brylawski–Muirhead single-unit transfers and a symmetric-unimodal convolution spread lemma. 6. **Sharp Non-Asymptotic Corollaries**: - **Exact Catalan Stability Theorem** and **Exact Erdős Uniqueness**, - **Exact `m`-Bounded-Multiplicity**, **`d`-Distinct**, and **`t`-Deviant** Theorems. -/ open scoped BigOperators open Finset namespace MultiplicityLittlewoodOfford /-! ## Section 1: `sl₂(ℚ)`-Graded Posets, Hard Lefschetz, and `k`-Sperner -/ /-- A finite ranked poset equipped with a rank-reversing involution and an `sl₂(ℚ)`-action whose raising operator `X` is supported on strict order increases of rank `+1`. -/ structure Sl2Poset (P : Type*) [Fintype P] [DecidableEq P] [PartialOrder P] where N : ℕ rk : P → ℕ rk_le : ∀ x, rk x ≤ N dual : P → P dual_dual : ∀ x, dual (dual x) = x rk_dual : ∀ x, rk (dual x) = N - rk x X : (P → ℚ) →ₗ[ℚ] (P → ℚ) Y : (P → ℚ) →ₗ[ℚ] (P → ℚ) X_order : ∀ x y, X (Pi.single x 1) y ≠ 0 → x < y ∧ rk y = rk x + 1 Y_rank : ∀ x y, Y (Pi.single x 1) y ≠ 0 → rk y + 1 = rk x sl2_comm : ∀ x, X (Y (Pi.single x 1)) - Y (X (Pi.single x 1)) = ((2 * (rk x : ℚ) - (N : ℚ)) • Pi.single x (1 : ℚ)) namespace Sl2Poset section Basic variable {P : Type*} [Fintype P] [DecidableEq P] /-- Every function `P → ℚ` expands in the standard basis `Pi.single x 1`. -/ lemma fun_eq_sum_single (f : P → ℚ) : f = ∑ x : P, f x • Pi.single x (1 : ℚ) := by ext y simp [Finset.sum_apply, Pi.single_apply] /-- Matrix-entry expansion for any `ℚ`-linear map on `P → ℚ`. -/ lemma linearMap_apply_eq (T : (P → ℚ) →ₗ[ℚ] (P → ℚ)) (f : P → ℚ) (y : P) : T f y = ∑ x : P, f x * T (Pi.single x 1) y := by conv_lhs => rw [fun_eq_sum_single f] simp [map_sum, map_smul, Finset.sum_apply] /-- Embedding a vector on a subset `A : Finset P` into `P → ℚ` by zero extension. -/ def embedFinset (A : Finset P) : (A → ℚ) →ₗ[ℚ] (P → ℚ) where toFun v x := if hx : x ∈ A then v ⟨x, hx⟩ else 0 map_add' v w := by ext x by_cases hx : x ∈ A <;> simp [hx] map_smul' c v := by ext x by_cases hx : x ∈ A <;> simp [hx] omit [Fintype P] in lemma embedFinset_injective (A : Finset P) : Function.Injective (embedFinset A) := by intro v w h ext ⟨x, hx⟩ have := congrFun h x simpa [embedFinset, hx] using this /-- Restriction of a vector `P → ℚ` to a subset `B : Finset P`. -/ def restrictFinset (B : Finset P) : (P → ℚ) →ₗ[ℚ] (B → ℚ) where toFun f y := f y.1 map_add' _ _ := rfl map_smul' _ _ := rfl end Basic variable {P : Type*} [Fintype P] [DecidableEq P] [PartialOrder P] /-- Rank level `r` as a `Finset P`. -/ def rankLevel (S : Sl2Poset P) (r : ℕ) : Finset P := Finset.univ.filter (fun x => S.rk x = r) /-- A vector `f : P → ℚ` is supported on elements of rank `r`. -/ def SupportedOnRank (S : Sl2Poset P) (r : ℕ) (f : P → ℚ) : Prop := ∀ x : P, f x ≠ 0 → S.rk x = r /-- The weight operator `H(f)(x) = (2 * rk x - N) * f x`. -/ def H (S : Sl2Poset P) : (P → ℚ) →ₗ[ℚ] (P → ℚ) where toFun f x := (2 * (S.rk x : ℚ) - (S.N : ℚ)) * f x map_add' f g := by ext x; simp only [Pi.add_apply]; ring map_smul' c f := by ext x; simp only [Pi.smul_apply, smul_eq_mul, RingHom.id_apply]; ring lemma H_single (S : Sl2Poset P) (x : P) : S.H (Pi.single x 1) = ((2 * (S.rk x : ℚ) - (S.N : ℚ)) • Pi.single x (1 : ℚ)) := by ext y by_cases h : y = x · subst h; simp [H] · simp [H, Pi.single_eq_of_ne h] lemma comm_XY (S : Sl2Poset P) (f : P → ℚ) : S.X (S.Y f) - S.Y (S.X f) = S.H f := by conv_lhs => rw [fun_eq_sum_single f] conv_rhs => rw [fun_eq_sum_single f] simp only [map_sum, map_smul, ← Finset.sum_sub_distrib, ← smul_sub] refine Finset.sum_congr rfl fun x _ => ?_ rw [S.sl2_comm x, S.H_single x] lemma H_of_supported (S : Sl2Poset P) {r : ℕ} {f : P → ℚ} (hf : S.SupportedOnRank r f) : S.H f = ((2 * (r : ℚ) - (S.N : ℚ)) • f) := by ext x by_cases hfx : f x = 0 · simp [H, hfx] · simp [H, hf x hfx] lemma X_supported (S : Sl2Poset P) {r : ℕ} {f : P → ℚ} (hf : S.SupportedOnRank r f) : S.SupportedOnRank (r + 1) (S.X f) := by intro y hy rw [linearMap_apply_eq] at hy obtain ⟨x, _, hx⟩ := Finset.exists_ne_zero_of_sum_ne_zero hy have hfx : f x ≠ 0 := left_ne_zero_of_mul hx have hX : S.X (Pi.single x 1) y ≠ 0 := right_ne_zero_of_mul hx rw [(S.X_order x y hX).2, hf x hfx] lemma X_pow_supported (S : Sl2Poset P) (m : ℕ) {r : ℕ} {f : P → ℚ} (hf : S.SupportedOnRank r f) : S.SupportedOnRank (r + m) ((S.X ^ m) f) := by induction m with | zero => simpa using hf | succ m ih => have : (S.X ^ (m + 1)) f = S.X ((S.X ^ m) f) := by rw [pow_succ', Module.End.mul_apply] rw [this, show r + (m + 1) = (r + m) + 1 by omega] exact S.X_supported ih lemma Y_eq_zero_of_rank_zero (S : Sl2Poset P) {f : P → ℚ} (hf : S.SupportedOnRank 0 f) : S.Y f = 0 := by ext y rw [linearMap_apply_eq] refine Finset.sum_eq_zero fun x _ => ?_ by_cases hfx : f x = 0 · simp [hfx] · by_cases hY : S.Y (Pi.single x 1) y = 0 · simp [hY] · have := S.Y_rank x y hY have := hf x hfx omega lemma Y_supported (S : Sl2Poset P) {r : ℕ} {f : P → ℚ} (hf : S.SupportedOnRank (r + 1) f) : S.SupportedOnRank r (S.Y f) := by intro y hy rw [linearMap_apply_eq] at hy obtain ⟨x, _, hx⟩ := Finset.exists_ne_zero_of_sum_ne_zero hy have hfx : f x ≠ 0 := left_ne_zero_of_mul hx have hY : S.Y (Pi.single x 1) y ≠ 0 := right_ne_zero_of_mul hx have h1 := S.Y_rank x y hY have h2 := hf x hfx omega /-- Key `sl₂` commutator identity: `X^(m+1) (Y f) - Y (X^(m+1) f) = (m+1) * (2r - N + m) • X^m f` for `f` of rank `r`. -/ lemma comm_X_pow_Y (S : Sl2Poset P) (m : ℕ) {r : ℕ} {f : P → ℚ} (hf : S.SupportedOnRank r f) : (S.X ^ (m + 1)) (S.Y f) - S.Y ((S.X ^ (m + 1)) f) = (((m + 1 : ℚ) * (2 * (r : ℚ) - (S.N : ℚ) + (m : ℚ))) • (S.X ^ m) f) := by induction m with | zero => have h1 : (S.X ^ 1) (S.Y f) = S.X (S.Y f) := by simp have h2 : (S.X ^ 1) f = S.X f := by simp have h3 : (S.X ^ 0) f = f := by simp rw [h1, h2, h3, S.comm_XY f, S.H_of_supported hf] ext x; simp | succ m ih => have hpow : ∀ g : P → ℚ, (S.X ^ (m + 2)) g = S.X ((S.X ^ (m + 1)) g) := fun g => by rw [pow_succ', Module.End.mul_apply] rw [hpow (S.Y f), hpow f] have hsplit : S.X ((S.X ^ (m + 1)) (S.Y f)) - S.Y (S.X ((S.X ^ (m + 1)) f)) = S.X ((S.X ^ (m + 1)) (S.Y f) - S.Y ((S.X ^ (m + 1)) f)) + (S.X (S.Y ((S.X ^ (m + 1)) f)) - S.Y (S.X ((S.X ^ (m + 1)) f))) := by rw [map_sub]; abel rw [hsplit, ih, map_smul, S.comm_XY, S.H_of_supported (S.X_pow_supported (m + 1) hf)] have hX : S.X ((S.X ^ m) f) = (S.X ^ (m + 1)) f := by rw [pow_succ', Module.End.mul_apply] rw [hX, ← add_smul] congr 1 push_cast ring /-- Primitive-vector lemma: if `Y f = 0`, `2r ≤ N`, and `X^k f = 0` with `k ≤ N - 2r`, then `f = 0`. -/ lemma primitive_inj (S : Sl2Poset P) {r : ℕ} {f : P → ℚ} (hf : S.SupportedOnRank r f) (hY : S.Y f = 0) (hr : 2 * r ≤ S.N) : ∀ k ≤ S.N - 2 * r, (S.X ^ k) f = 0 → f = 0 := by intro k induction k with | zero => intro _ h0; simpa using h0 | succ k ih => intro hk hXk have hcomm := S.comm_X_pow_Y k hf rw [hY, map_zero, hXk, map_zero, sub_self] at hcomm have hcoeff : ((k + 1 : ℚ) * (2 * (r : ℚ) - (S.N : ℚ) + (k : ℚ))) ≠ 0 := by have h1 : (k + 1 : ℚ) ≠ 0 := by positivity have hlt : 2 * r + k < S.N := by omega have h2 : (2 * (r : ℚ) - (S.N : ℚ) + (k : ℚ)) < 0 := by have : (2 * r + k : ℚ) < (S.N : ℚ) := by exact_mod_cast hlt linarith exact mul_ne_zero h1 (ne_of_lt h2) have hXk' : (S.X ^ k) f = 0 := by have := smul_eq_zero.mp hcomm.symm exact this.resolve_left hcoeff exact ih (by omega) hXk' /-- Elementary Hard Lefschetz injectivity for `Sl2Poset`: for every `r` with `2r ≤ N`, `X^(N - 2r)` is injective on rank-`r` vectors. -/ theorem hard_lefschetz_inj (S : Sl2Poset P) : ∀ r : ℕ, 2 * r ≤ S.N → ∀ f : P → ℚ, S.SupportedOnRank r f → (S.X ^ (S.N - 2 * r)) f = 0 → f = 0 := by intro r induction r with | zero => intro hr f hf hX exact S.primitive_inj hf (S.Y_eq_zero_of_rank_zero hf) hr (S.N - 2 * 0) le_rfl hX | succ r ih => intro hr f hf hX have hX1 : (S.X ^ (S.N - 2 * (r + 1) + 1)) f = 0 := by rw [pow_succ', Module.End.mul_apply, hX, map_zero] have hcomm := S.comm_X_pow_Y (S.N - 2 * (r + 1)) hf have hzero_coeff : (2 * ((r + 1 : ℕ) : ℚ) - (S.N : ℚ) + ((S.N - 2 * (r + 1) : ℕ) : ℚ)) = 0 := by have hcast : ((S.N - 2 * (r + 1) : ℕ) : ℚ) = (S.N : ℚ) - 2 * ((r + 1 : ℕ) : ℚ) := by rw [Nat.cast_sub hr]; push_cast; ring rw [hcast]; ring rw [hX1, map_zero, sub_zero, hzero_coeff, mul_zero, zero_smul] at hcomm have hXY : (S.X ^ (S.N - 2 * r)) (S.Y f) = 0 := by have hstep : S.N - 2 * r = (S.N - 2 * (r + 1) + 1) + 1 := by omega rw [hstep, pow_succ', Module.End.mul_apply, hcomm, map_zero] have hYf : S.Y f = 0 := ih (by omega) (S.Y f) (S.Y_supported hf) hXY exact S.primitive_inj hf hYf hr (S.N - 2 * (r + 1)) le_rfl hX /-- Rank symmetry: `|P_r| = |P_{N-r}|`. -/ lemma card_rankLevel_symm (S : Sl2Poset P) {r : ℕ} (hr : r ≤ S.N) : (S.rankLevel r).card = (S.rankLevel (S.N - r)).card := by refine Finset.card_bij (fun x _ => S.dual x) ?_ ?_ ?_ · intro x hx simp only [rankLevel, Finset.mem_filter, Finset.mem_univ, true_and] at hx ⊢ rw [S.rk_dual, hx] · intro x₁ _ x₂ _ h have := congrArg S.dual h rwa [S.dual_dual, S.dual_dual] at this · intro y hy refine ⟨S.dual y, ?_, S.dual_dual y⟩ simp only [rankLevel, Finset.mem_filter, Finset.mem_univ, true_and] at hy ⊢ have := S.rk_le y rw [S.rk_dual, hy]; omega /-- For `2r < N`, the raising operator `X` is injective on rank-`r` vectors. -/ lemma X_inj_of_two_mul_lt (S : Sl2Poset P) {r : ℕ} (hr : 2 * r < S.N) {f : P → ℚ} (hf : S.SupportedOnRank r f) (hXf : S.X f = 0) : f = 0 := by have hpow : (S.X ^ (S.N - 2 * r)) f = 0 := by have hpos : S.N - 2 * r = (S.N - 2 * r - 1) + 1 := by omega rw [hpos, pow_succ, Module.End.mul_apply, hXf, map_zero] exact S.hard_lefschetz_inj r (by omega) f hf hpow lemma embedFinset_supported (S : Sl2Poset P) {r : ℕ} {A : Finset P} (hA : A ⊆ S.rankLevel r) (v : A → ℚ) : S.SupportedOnRank r (embedFinset A v) := by intro x hx by_cases hmem : x ∈ A · have := hA hmem simp only [rankLevel, Finset.mem_filter, Finset.mem_univ, true_and] at this exact this · simp [embedFinset, hmem] at hx /-- Hall matching upward: for `2r < N`, there exists an injective map `f : P_r → P_{r+1}` with `x < f x`. -/ lemma exists_upper_matching (S : Sl2Poset P) {r : ℕ} (hr : 2 * r < S.N) : ∃ f : (S.rankLevel r) → P, Function.Injective f ∧ ∀ x : S.rankLevel r, f x ∈ S.rankLevel (r + 1) ∧ x.1 < f x := by classical let t : (S.rankLevel r) → Finset P := fun x => (S.rankLevel (r + 1)).filter (fun y => x.1 < y) have hHall : ∀ s : Finset (S.rankLevel r), s.card ≤ (s.biUnion t).card := by intro s let A : Finset P := s.image Subtype.val let B : Finset P := s.biUnion t have hA_sub : A ⊆ S.rankLevel r := by intro x hx rcases Finset.mem_image.mp hx with ⟨a, _, rfl⟩ exact a.2 let φ : (A → ℚ) →ₗ[ℚ] (B → ℚ) := (restrictFinset B).comp (S.X.comp (embedFinset A)) have hφ_inj : Function.Injective φ := by intro v₁ v₂ hEq have hv : φ (v₁ - v₂) = 0 := by rw [map_sub, hEq, sub_self] have hXv : S.X (embedFinset A (v₁ - v₂)) = 0 := by ext y by_cases hyB : y ∈ B · exact congrFun hv ⟨y, hyB⟩ · rw [linearMap_apply_eq] refine Finset.sum_eq_zero fun x _ => ?_ by_cases hxA : x ∈ A · by_cases hXy : S.X (Pi.single x 1) y = 0 · simp [hXy] · exfalso apply hyB have hord := S.X_order x y hXy rcases Finset.mem_image.mp hxA with ⟨a, has, rfl⟩ refine Finset.mem_biUnion.mpr ⟨a, has, ?_⟩ simp only [t, rankLevel, Finset.mem_filter, Finset.mem_univ, true_and] have ha := a.2 simp only [rankLevel, Finset.mem_filter, Finset.mem_univ, true_and] at ha exact ⟨by omega, hord.1⟩ · simp [embedFinset, hxA] have hembed0 : embedFinset A (v₁ - v₂) = 0 := S.X_inj_of_two_mul_lt hr (S.embedFinset_supported hA_sub (v₁ - v₂)) hXv have hsub0 : v₁ - v₂ = 0 := embedFinset_injective A (by rwa [map_zero]) exact sub_eq_zero.mp hsub0 have hfin := LinearMap.finrank_le_finrank_of_injective hφ_inj rw [Module.finrank_fintype_fun_eq_card, Module.finrank_fintype_fun_eq_card, Fintype.card_coe, Fintype.card_coe] at hfin have hAcard : A.card = s.card := Finset.card_image_of_injective s Subtype.val_injective simpa [B, hAcard] using hfin obtain ⟨f, hfinj, hfmem⟩ := (Finset.all_card_le_biUnion_card_iff_exists_injective t).mp hHall refine ⟨f, hfinj, fun x => ?_⟩ have := hfmem x simpa [t] using this /-- For `2r > N`, the map `X` restricted from `P_{r-1}` to `P_r` is surjective. -/ lemma X_surj_of_two_mul_gt (S : Sl2Poset P) {r : ℕ} (hr : 2 * r > S.N) (hrN : r ≤ S.N) (g : P → ℚ) (hg : S.SupportedOnRank r g) : ∃ f : P → ℚ, S.SupportedOnRank (r - 1) f ∧ S.X f = g := by let r' : ℕ := S.N - r have hr' : 2 * r' ≤ S.N := by omega let A := S.rankLevel r' let B := S.rankLevel r let ψ : (A → ℚ) →ₗ[ℚ] (B → ℚ) := (restrictFinset B).comp ((S.X ^ (S.N - 2 * r')).comp (embedFinset A)) have hψ_inj : Function.Injective ψ := by intro v₁ v₂ hEq have hv : ψ (v₁ - v₂) = 0 := by rw [map_sub, hEq, sub_self] have hpow0 : (S.X ^ (S.N - 2 * r')) (embedFinset A (v₁ - v₂)) = 0 := by ext y by_cases hyB : y ∈ B · exact congrFun hv ⟨y, hyB⟩ · by_contra hne have hsupp := S.X_pow_supported (S.N - 2 * r') (S.embedFinset_supported Subset.rfl (v₁ - v₂)) have hry := hsupp y hne apply hyB simp only [B, rankLevel, Finset.mem_filter, Finset.mem_univ, true_and] omega have := S.hard_lefschetz_inj r' hr' (embedFinset A (v₁ - v₂)) (S.embedFinset_supported Subset.rfl (v₁ - v₂)) hpow0 exact sub_eq_zero.mp (embedFinset_injective A (by rwa [map_zero])) have hcard : Fintype.card A = Fintype.card B := by rw [Fintype.card_coe, Fintype.card_coe] exact (S.card_rankLevel_symm hrN).symm have hfin_eq : Module.finrank ℚ (A → ℚ) = Module.finrank ℚ (B → ℚ) := by rw [Module.finrank_fintype_fun_eq_card, Module.finrank_fintype_fun_eq_card, hcard] have hrange_top : LinearMap.range ψ = ⊤ := by apply Submodule.eq_top_of_finrank_eq rw [LinearMap.finrank_range_of_inj hψ_inj, hfin_eq] have hmem : restrictFinset B g ∈ LinearMap.range ψ := hrange_top.symm ▸ Submodule.mem_top rcases hmem with ⟨v, hv⟩ have hfull : (S.X ^ (S.N - 2 * r')) (embedFinset A v) = g := by ext y by_cases hyB : y ∈ B · exact congrFun hv ⟨y, hyB⟩ · have hgy : g y = 0 := by by_contra hne apply hyB simp only [B, rankLevel, Finset.mem_filter, Finset.mem_univ, true_and] exact hg y hne rw [hgy] by_contra hne have hsupp := S.X_pow_supported (S.N - 2 * r') (S.embedFinset_supported Subset.rfl v) have hry := hsupp y hne apply hyB simp only [B, rankLevel, Finset.mem_filter, Finset.mem_univ, true_and] omega have hpos : S.N - 2 * r' = (S.N - 2 * r' - 1) + 1 := by omega refine ⟨(S.X ^ (S.N - 2 * r' - 1)) (embedFinset A v), ?_, ?_⟩ · have hsupp := S.X_pow_supported (S.N - 2 * r' - 1) (S.embedFinset_supported Subset.rfl v) have hidx : r' + (S.N - 2 * r' - 1) = r - 1 := by omega rwa [hidx] at hsupp · rw [← Module.End.mul_apply, ← pow_succ', ← hpos, hfull] /-- Hall matching downward: for `2r > N`, there exists an injective map `g : P_r → P_{r-1}` with `g y < y`. -/ lemma exists_lower_matching (S : Sl2Poset P) {r : ℕ} (hr : 2 * r > S.N) (hrN : r ≤ S.N) : ∃ g : (S.rankLevel r) → P, Function.Injective g ∧ ∀ y : S.rankLevel r, g y ∈ S.rankLevel (r - 1) ∧ g y < y.1 := by classical let t : (S.rankLevel r) → Finset P := fun y => (S.rankLevel (r - 1)).filter (fun x => x < y.1) have hHall : ∀ s : Finset (S.rankLevel r), s.card ≤ (s.biUnion t).card := by intro s let A : Finset P := s.image Subtype.val let B : Finset P := s.biUnion t have hA_sub : A ⊆ S.rankLevel r := by intro y hy rcases Finset.mem_image.mp hy with ⟨a, _, rfl⟩ exact a.2 let XT : (A → ℚ) →ₗ[ℚ] (B → ℚ) := { toFun := fun v x => ∑ y : A, S.X (Pi.single x.1 1) y.1 * v y map_add' := fun v w => by ext x; simp [mul_add, Finset.sum_add_distrib] map_smul' := fun c v => by ext x; simp [Finset.mul_sum]; refine Finset.sum_congr rfl fun y _ => by ring } have hXT_inj : Function.Injective XT := by intro v₁ v₂ hEq have hv : XT (v₁ - v₂) = 0 := by rw [map_sub, hEq, sub_self] let g : P → ℚ := embedFinset A (v₁ - v₂) have hg : S.SupportedOnRank r g := S.embedFinset_supported hA_sub (v₁ - v₂) obtain ⟨f, hf, hXf⟩ := S.X_surj_of_two_mul_gt hr hrN g hg have hsq : ∑ y : P, (g y) ^ 2 = 0 := by calc ∑ y : P, (g y) ^ 2 = ∑ y : P, (S.X f y) * g y := by refine Finset.sum_congr rfl fun y _ => by rw [hXf, sq] _ = ∑ y : P, (∑ x : P, f x * S.X (Pi.single x 1) y) * g y := by refine Finset.sum_congr rfl fun y _ => by rw [linearMap_apply_eq] _ = ∑ x : P, f x * ∑ y : P, S.X (Pi.single x 1) y * g y := by simp_rw [Finset.sum_mul, Finset.mul_sum] rw [Finset.sum_comm] refine Finset.sum_congr rfl fun x _ => Finset.sum_congr rfl fun y _ => by ring _ = 0 := by refine Finset.sum_eq_zero fun x _ => ?_ by_cases hfx : f x = 0 · simp [hfx] · have hrx : S.rk x = r - 1 := hf x hfx suffices hinner : ∑ y : P, S.X (Pi.single x 1) y * g y = 0 by simp [hinner] by_cases hxB : x ∈ B · have h0 := congrFun hv ⟨x, hxB⟩ dsimp [XT] at h0 have hsumA : ∑ y : P, S.X (Pi.single x 1) y * g y = ∑ y : A, S.X (Pi.single x 1) y.1 * (v₁ - v₂) y := by have hsplit : ∑ y : P, S.X (Pi.single x 1) y * g y = ∑ y ∈ A, S.X (Pi.single x 1) y * g y := by symm refine Finset.sum_subset (Finset.subset_univ A) fun y _ hyA => ?_ simp [g, embedFinset, hyA] rw [hsplit, ← Finset.sum_coe_sort A] refine Finset.sum_congr rfl fun y _ => by simp [g, embedFinset, y.2] rw [hsumA]; exact h0 · refine Finset.sum_eq_zero fun y _ => ?_ by_cases hyA : y ∈ A · by_cases hXy : S.X (Pi.single x 1) y = 0 · simp [hXy] · exfalso apply hxB have hord := S.X_order x y hXy rcases Finset.mem_image.mp hyA with ⟨a, has, rfl⟩ refine Finset.mem_biUnion.mpr ⟨a, has, ?_⟩ simp only [t, rankLevel, Finset.mem_filter, Finset.mem_univ, true_and] exact ⟨hrx, hord.1⟩ · simp [g, embedFinset, hyA] have hg0 : g = 0 := by ext y have hnonneg : ∀ z ∈ (Finset.univ : Finset P), (0 : ℚ) ≤ (g z) ^ 2 := fun z _ => sq_nonneg _ have hzy := (Finset.sum_eq_zero_iff_of_nonneg hnonneg).mp hsq y (Finset.mem_univ y) exact sq_eq_zero_iff.mp hzy exact sub_eq_zero.mp (embedFinset_injective A (by rwa [map_zero])) have hfin := LinearMap.finrank_le_finrank_of_injective hXT_inj rw [Module.finrank_fintype_fun_eq_card, Module.finrank_fintype_fun_eq_card, Fintype.card_coe, Fintype.card_coe] at hfin have hAcard : A.card = s.card := Finset.card_image_of_injective s Subtype.val_injective simpa [B, hAcard] using hfin obtain ⟨g, hginj, hgmem⟩ := (Finset.all_card_le_biUnion_card_iff_exists_injective t).mp hHall refine ⟨g, hginj, fun y => ?_⟩ have := hgmem y simpa [t] using this /-- **1-Sperner Theorem for any `Sl2Poset`**: every antichain in `P` has size at most the middle rank size `|P_{N / 2}|`. -/ theorem card_antichain_le_mid (S : Sl2Poset P) (A : Finset P) (hA : ∀ x ∈ A, ∀ y ∈ A, x < y → False) : A.card ≤ (S.rankLevel (S.N / 2)).card := by classical have hup : ∀ r, r < S.N / 2 → ∃ f : P → P, (∀ x ∈ S.rankLevel r, f x ∈ S.rankLevel (r + 1) ∧ x < f x) ∧ (∀ x ∈ S.rankLevel r, ∀ y ∈ S.rankLevel r, f x = f y → x = y) := by intro r hr have hr2 : 2 * r < S.N := by omega obtain ⟨f, hfinj, hfprop⟩ := S.exists_upper_matching hr2 refine ⟨fun x => if hx : x ∈ S.rankLevel r then f ⟨x, hx⟩ else x, ?_, ?_⟩ · intro x hx; simpa [hx] using hfprop ⟨x, hx⟩ · intro x hx y hy hxy simp only [hx, hy, ↓reduceDIte] at hxy exact congrArg Subtype.val (hfinj hxy) have hdn : ∀ r, S.N / 2 < r → r ≤ S.N → ∃ g : P → P, (∀ x ∈ S.rankLevel r, g x ∈ S.rankLevel (r - 1) ∧ g x < x) ∧ (∀ x ∈ S.rankLevel r, ∀ y ∈ S.rankLevel r, g x = g y → x = y) := by intro r hr hrN have hr2 : 2 * r > S.N := by omega obtain ⟨g, hginj, hgprop⟩ := S.exists_lower_matching hr2 hrN refine ⟨fun x => if hx : x ∈ S.rankLevel r then g ⟨x, hx⟩ else x, ?_, ?_⟩ · intro x hx; simpa [hx] using hgprop ⟨x, hx⟩ · intro x hx y hy hxy simp only [hx, hy, ↓reduceDIte] at hxy exact congrArg Subtype.val (hginj hxy) choose F hF_prop hF_inj using hup choose G hG_prop hG_inj using hdn -- Total one-step upward and downward maps let stepUp : P → P := fun x => if h : S.rk x < S.N / 2 then F (S.rk x) h x else x let stepDn : P → P := fun x => if h : S.N / 2 < S.rk x then G (S.rk x) h (S.rk_le x) x else x have hstepUp_prop : ∀ x, S.rk x < S.N / 2 → S.rk (stepUp x) = S.rk x + 1 ∧ x < stepUp x := by intro x hx simp only [stepUp, hx, ↓reduceDIte] have hmem : x ∈ S.rankLevel (S.rk x) := by simp [rankLevel] have hp := hF_prop (S.rk x) hx x hmem exact ⟨by simpa [rankLevel] using hp.1, hp.2⟩ have hstepUp_inj : ∀ x y, S.rk x = S.rk y → S.rk x < S.N / 2 → stepUp x = stepUp y → x = y := by intro x y hr hlt heq have hlty : S.rk y < S.N / 2 := by omega simp only [stepUp, hlt, hlty, ↓reduceDIte] at heq have hxmem : x ∈ S.rankLevel (S.rk x) := by simp [rankLevel] have hymem : y ∈ S.rankLevel (S.rk x) := by simp [rankLevel, hr] have hFsame : F (S.rk x) hlt y = F (S.rk y) hlty y := by congr 1 rw [← hFsame] at heq exact hF_inj (S.rk x) hlt x hxmem y hymem heq have hstepDn_prop : ∀ x, S.N / 2 < S.rk x → S.rk (stepDn x) = S.rk x - 1 ∧ stepDn x < x := by intro x hx simp only [stepDn, hx, ↓reduceDIte] have hmem : x ∈ S.rankLevel (S.rk x) := by simp [rankLevel] have hp := hG_prop (S.rk x) hx (S.rk_le x) x hmem exact ⟨by simpa [rankLevel] using hp.1, hp.2⟩ have hstepDn_inj : ∀ x y, S.rk x = S.rk y → S.N / 2 < S.rk x → stepDn x = stepDn y → x = y := by intro x y hr hgt heq have hgty : S.N / 2 < S.rk y := by omega simp only [stepDn, hgt, hgty, ↓reduceDIte] at heq have hxmem : x ∈ S.rankLevel (S.rk x) := by simp [rankLevel] have hymem : y ∈ S.rankLevel (S.rk x) := by simp [rankLevel, hr] have hGsame : G (S.rk x) hgt (S.rk_le x) y = G (S.rk y) hgty (S.rk_le y) y := by congr 1 rw [← hGsame] at heq exact hG_inj (S.rk x) hgt (S.rk_le x) x hxmem y hymem heq -- Iterated upward properties have hUp_iter : ∀ d x, S.rk x + d ≤ S.N / 2 → S.rk (stepUp^[d] x) = S.rk x + d ∧ x ≤ stepUp^[d] x := by intro d induction d with | zero => intro x _; simp | succ d ih => intro x hx rw [Function.iterate_succ_apply] have h1 := hstepUp_prop x (by omega) have h2 := ih (stepUp x) (by omega) exact ⟨by omega, le_trans (le_of_lt h1.2) h2.2⟩ have hUp_inj : ∀ d x y, S.rk x = S.rk y → S.rk x + d ≤ S.N / 2 → stepUp^[d] x = stepUp^[d] y → x = y := by intro d induction d with | zero => intro x y _ _ h; simpa using h | succ d ih => intro x y hr hle heq rw [Function.iterate_succ_apply, Function.iterate_succ_apply] at heq have h1 := hstepUp_prop x (by omega) have h2 := hstepUp_prop y (by omega) have hxy := ih (stepUp x) (stepUp y) (by omega) (by omega) heq exact hstepUp_inj x y hr (by omega) hxy -- Iterated downward properties have hDn_iter : ∀ d x, S.N / 2 + d ≤ S.rk x → S.rk (stepDn^[d] x) = S.rk x - d ∧ stepDn^[d] x ≤ x := by intro d induction d with | zero => intro x _; simp | succ d ih => intro x hx rw [Function.iterate_succ_apply] have h1 := hstepDn_prop x (by omega) have h2 := ih (stepDn x) (by omega) exact ⟨by omega, le_trans h2.2 (le_of_lt h1.2)⟩ have hDn_inj : ∀ d x y, S.rk x = S.rk y → S.N / 2 + d ≤ S.rk x → stepDn^[d] x = stepDn^[d] y → x = y := by intro d induction d with | zero => intro x y _ _ h; simpa using h | succ d ih => intro x y hr hle heq rw [Function.iterate_succ_apply, Function.iterate_succ_apply] at heq have h1 := hstepDn_prop x (by omega) have h2 := hstepDn_prop y (by omega) have hxy := ih (stepDn x) (stepDn y) (by omega) (by omega) heq exact hstepDn_inj x y hr (by omega) hxy -- Combined projection `π : P → P_{N/2}` let π : P → P := fun x => if S.rk x ≤ S.N / 2 then stepUp^[S.N / 2 - S.rk x] x else stepDn^[S.rk x - S.N / 2] x refine Finset.card_le_card_of_injOn π ?_ ?_ · intro x _ dsimp [π] split_ifs with h · have := (hUp_iter (S.N / 2 - S.rk x) x (by omega)).1 exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, by omega⟩ · have := (hDn_iter (S.rk x - S.N / 2) x (by omega)).1 exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, by omega⟩ · intro x hx y hy hxy have hcomp : x ≤ y ∨ y ≤ x := by dsimp [π] at hxy split_ifs at hxy with h₁ h₂ · by_cases hr : S.rk x ≤ S.rk y · have hsplit : S.N / 2 - S.rk x = (S.N / 2 - S.rk y) + (S.rk y - S.rk x) := by omega rw [hsplit, Function.iterate_add_apply] at hxy have hx' := hUp_iter (S.rk y - S.rk x) x (by omega) have heq' : stepUp^[S.rk y - S.rk x] x = y := hUp_inj (S.N / 2 - S.rk y) _ y (by omega) (by omega) hxy exact Or.inl (heq' ▸ hx'.2) · have hsplit : S.N / 2 - S.rk y = (S.N / 2 - S.rk x) + (S.rk x - S.rk y) := by omega rw [hsplit, Function.iterate_add_apply] at hxy have hy' := hUp_iter (S.rk x - S.rk y) y (by omega) have heq' : stepUp^[S.rk x - S.rk y] y = x := hUp_inj (S.N / 2 - S.rk x) _ x (by omega) (by omega) hxy.symm exact Or.inr (heq' ▸ hy'.2) · exact Or.inl (le_trans (hUp_iter (S.N / 2 - S.rk x) x (by omega)).2 (hxy ▸ (hDn_iter (S.rk y - S.N / 2) y (by omega)).2)) · exact Or.inr (le_trans (hUp_iter (S.N / 2 - S.rk y) y (by omega)).2 (hxy.symm ▸ (hDn_iter (S.rk x - S.N / 2) x (by omega)).2)) · by_cases hr : S.rk y ≤ S.rk x · have hsplit : S.rk x - S.N / 2 = (S.rk y - S.N / 2) + (S.rk x - S.rk y) := by omega rw [hsplit, Function.iterate_add_apply] at hxy have hx' := hDn_iter (S.rk x - S.rk y) x (by omega) have heq' : stepDn^[S.rk x - S.rk y] x = y := hDn_inj (S.rk y - S.N / 2) _ y (by omega) (by omega) hxy exact Or.inr (heq' ▸ hx'.2) · have hsplit : S.rk y - S.N / 2 = (S.rk x - S.N / 2) + (S.rk y - S.rk x) := by omega rw [hsplit, Function.iterate_add_apply] at hxy have hy' := hDn_iter (S.rk y - S.rk x) y (by omega) have heq' : stepDn^[S.rk y - S.rk x] y = x := hDn_inj (S.rk x - S.N / 2) _ x (by omega) (by omega) hxy.symm exact Or.inl (heq' ▸ hy'.2) rcases hcomp with hle | hle · exact eq_of_le_of_not_lt hle (hA x hx y hy) · exact (eq_of_le_of_not_lt hle (hA y hy x hx)).symm /-- Rank unimodality below the middle: for `2r < N`, `|P_r| ≤ |P_{r+1}|`. -/ lemma card_rankLevel_mono_le (S : Sl2Poset P) {r : ℕ} (hr : 2 * r < S.N) : (S.rankLevel r).card ≤ (S.rankLevel (r + 1)).card := by obtain ⟨f, hfinj, hfprop⟩ := S.exists_upper_matching hr have h := Finset.card_le_card_of_injOn (s := (Finset.univ : Finset (S.rankLevel r))) (t := S.rankLevel (r + 1)) f (fun x _ => (hfprop x).1) (fun x _ y _ hxy => hfinj hxy) simpa using h /-- Cartesian product of two `Sl2Poset`s is an `Sl2Poset`. -/ def prod {Q : Type*} [Fintype Q] [DecidableEq Q] [PartialOrder Q] (S : Sl2Poset P) (T : Sl2Poset Q) : Sl2Poset (P × Q) where N := S.N + T.N rk x := S.rk x.1 + T.rk x.2 rk_le x := Nat.add_le_add (S.rk_le x.1) (T.rk_le x.2) dual x := (S.dual x.1, T.dual x.2) dual_dual x := Prod.ext (S.dual_dual x.1) (T.dual_dual x.2) rk_dual x := by have h1 := S.rk_le x.1 have h2 := T.rk_le x.2 simp only [S.rk_dual, T.rk_dual] omega X := { toFun := fun f x => (∑ p : P, f (p, x.2) * S.X (Pi.single p 1) x.1) + (∑ q : Q, f (x.1, q) * T.X (Pi.single q 1) x.2) map_add' := fun f g => by ext ⟨p, q⟩ simp only [Pi.add_apply, add_mul, Finset.sum_add_distrib] ring map_smul' := fun c f => by ext ⟨p, q⟩ simp only [Pi.smul_apply, smul_eq_mul, RingHom.id_apply, mul_assoc, ← Finset.mul_sum, mul_add] } Y := { toFun := fun f x => (∑ p : P, f (p, x.2) * S.Y (Pi.single p 1) x.1) + (∑ q : Q, f (x.1, q) * T.Y (Pi.single q 1) x.2) map_add' := fun f g => by ext ⟨p, q⟩ simp only [Pi.add_apply, add_mul, Finset.sum_add_distrib] ring map_smul' := fun c f => by ext ⟨p, q⟩ simp only [Pi.smul_apply, smul_eq_mul, RingHom.id_apply, mul_assoc, ← Finset.mul_sum, mul_add] } X_order := by rintro ⟨p₀, q₀⟩ ⟨p, q⟩ hne dsimp only [LinearMap.coe_mk, AddHom.coe_mk] at hne have hsingle : ∀ a b : P × Q, (Pi.single a (1 : ℚ) : P × Q → ℚ) b = if b = a then 1 else 0 := fun a b => by simp [Pi.single_apply] simp only [hsingle, ite_mul, one_mul, zero_mul, Prod.mk.injEq] at hne have hs1 : ∑ p' : P, (if p' = p₀ ∧ q = q₀ then S.X (Pi.single p' 1) p else 0) = if q = q₀ then S.X (Pi.single p₀ 1) p else 0 := by by_cases hq : q = q₀ <;> simp [hq] have hs2 : ∑ q' : Q, (if p = p₀ ∧ q' = q₀ then T.X (Pi.single q' 1) q else 0) = if p = p₀ then T.X (Pi.single q₀ 1) q else 0 := by by_cases hp : p = p₀ <;> simp [hp] rw [hs1, hs2] at hne by_cases hq : q = q₀ · by_cases hp : p = p₀ · subst hq hp exfalso have h1 : S.X (Pi.single p 1) p = 0 := by by_contra hc; exact lt_irrefl p (S.X_order p p hc).1 have h2 : T.X (Pi.single q 1) q = 0 := by by_contra hc; exact lt_irrefl q (T.X_order q q hc).1 simp [h1, h2] at hne · subst hq simp only [hp, ↓reduceIte, add_zero] at hne have ho := S.X_order p₀ p hne exact ⟨Prod.lt_iff.mpr (Or.inl ⟨ho.1, le_rfl⟩), by dsimp only; omega⟩ · simp only [hq, ↓reduceIte, zero_add] at hne by_cases hp : p = p₀ · subst hp simp only [↓reduceIte] at hne have ho := T.X_order q₀ q hne exact ⟨Prod.lt_iff.mpr (Or.inr ⟨le_rfl, ho.1⟩), by dsimp only; omega⟩ · simp [hp] at hne Y_rank := by rintro ⟨p₀, q₀⟩ ⟨p, q⟩ hne dsimp only [LinearMap.coe_mk, AddHom.coe_mk] at hne have hsingle : ∀ a b : P × Q, (Pi.single a (1 : ℚ) : P × Q → ℚ) b = if b = a then 1 else 0 := fun a b => by simp [Pi.single_apply] simp only [hsingle, ite_mul, one_mul, zero_mul, Prod.mk.injEq] at hne have hs1 : ∑ p' : P, (if p' = p₀ ∧ q = q₀ then S.Y (Pi.single p' 1) p else 0) = if q = q₀ then S.Y (Pi.single p₀ 1) p else 0 := by by_cases hq : q = q₀ <;> simp [hq] have hs2 : ∑ q' : Q, (if p = p₀ ∧ q' = q₀ then T.Y (Pi.single q' 1) q else 0) = if p = p₀ then T.Y (Pi.single q₀ 1) q else 0 := by by_cases hp : p = p₀ <;> simp [hp] rw [hs1, hs2] at hne by_cases hq : q = q₀ · subst hq by_cases hS : S.Y (Pi.single p₀ 1) p = 0 · simp only [↓reduceIte, hS, zero_add] at hne by_cases hp : p = p₀ · subst hp; simp only [↓reduceIte] at hne have := T.Y_rank q q hne; dsimp only; omega · simp [hp] at hne · have := S.Y_rank p₀ p hS; dsimp only; omega · simp only [hq, ↓reduceIte, zero_add] at hne by_cases hp : p = p₀ · subst hp; simp only [↓reduceIte] at hne have := T.Y_rank q₀ q hne; dsimp only; omega · simp [hp] at hne sl2_comm := by rintro ⟨p₀, q₀⟩ ext ⟨p, q⟩ dsimp only [LinearMap.coe_mk, AddHom.coe_mk, Pi.sub_apply, Pi.smul_apply, smul_eq_mul] have hsingle : ∀ a b : P × Q, (Pi.single a (1 : ℚ) : P × Q → ℚ) b = if b = a then 1 else 0 := fun a b => by simp [Pi.single_apply] have hX_single : ∀ p' q', (∑ r : P, (Pi.single (p₀, q₀) (1 : ℚ) : P × Q → ℚ) (r, q') * S.X (Pi.single r 1) p') + (∑ s : Q, (Pi.single (p₀, q₀) (1 : ℚ) : P × Q → ℚ) (p', s) * T.X (Pi.single s 1) q') = (if q' = q₀ then S.X (Pi.single p₀ 1) p' else 0) + (if p' = p₀ then T.X (Pi.single q₀ 1) q' else 0) := by intro p' q' simp only [hsingle, ite_mul, one_mul, zero_mul, Prod.mk.injEq] congr 1 · by_cases h : q' = q₀ <;> simp [h] · by_cases h : p' = p₀ <;> simp [h] have hY_single : ∀ p' q', (∑ r : P, (Pi.single (p₀, q₀) (1 : ℚ) : P × Q → ℚ) (r, q') * S.Y (Pi.single r 1) p') + (∑ s : Q, (Pi.single (p₀, q₀) (1 : ℚ) : P × Q → ℚ) (p', s) * T.Y (Pi.single s 1) q') = (if q' = q₀ then S.Y (Pi.single p₀ 1) p' else 0) + (if p' = p₀ then T.Y (Pi.single q₀ 1) q' else 0) := by intro p' q' simp only [hsingle, ite_mul, one_mul, zero_mul, Prod.mk.injEq] congr 1 · by_cases h : q' = q₀ <;> simp [h] · by_cases h : p' = p₀ <;> simp [h] simp_rw [hY_single, hX_single, add_mul, Finset.sum_add_distrib] have hS_comm : (∑ p' : P, (if q = q₀ then S.Y (Pi.single p₀ 1) p' else 0) * S.X (Pi.single p' 1) p) - (∑ p' : P, (if q = q₀ then S.X (Pi.single p₀ 1) p' else 0) * S.Y (Pi.single p' 1) p) = if q = q₀ ∧ p = p₀ then (2 * (S.rk p₀ : ℚ) - (S.N : ℚ)) else 0 := by by_cases hq : q = q₀ · subst hq simp only [↓reduceIte, true_and] have h1 : ∑ p' : P, S.Y (Pi.single p₀ 1) p' * S.X (Pi.single p' 1) p = S.X (S.Y (Pi.single p₀ 1)) p := (linearMap_apply_eq S.X _ p).symm have h2 : ∑ p' : P, S.X (Pi.single p₀ 1) p' * S.Y (Pi.single p' 1) p = S.Y (S.X (Pi.single p₀ 1)) p := (linearMap_apply_eq S.Y _ p).symm rw [h1, h2] have hc := congrFun (S.sl2_comm p₀) p simpa [Pi.single_apply] using hc · simp [hq] have hT_comm : (∑ q' : Q, (if p = p₀ then T.Y (Pi.single q₀ 1) q' else 0) * T.X (Pi.single q' 1) q) - (∑ q' : Q, (if p = p₀ then T.X (Pi.single q₀ 1) q' else 0) * T.Y (Pi.single q' 1) q) = if p = p₀ ∧ q = q₀ then (2 * (T.rk q₀ : ℚ) - (T.N : ℚ)) else 0 := by by_cases hp : p = p₀ · subst hp simp only [↓reduceIte, true_and] have h1 : ∑ q' : Q, T.Y (Pi.single q₀ 1) q' * T.X (Pi.single q' 1) q = T.X (T.Y (Pi.single q₀ 1)) q := (linearMap_apply_eq T.X _ q).symm have h2 : ∑ q' : Q, T.X (Pi.single q₀ 1) q' * T.Y (Pi.single q' 1) q = T.Y (T.X (Pi.single q₀ 1)) q := (linearMap_apply_eq T.Y _ q).symm rw [h1, h2] have hc := congrFun (T.sl2_comm q₀) q simpa [Pi.single_apply] using hc · simp [hp] have hcross1 : ∑ p' : P, (if p' = p₀ then T.Y (Pi.single q₀ 1) q else 0) * S.X (Pi.single p' 1) p = ∑ q' : Q, (if q' = q₀ then S.X (Pi.single p₀ 1) p else 0) * T.Y (Pi.single q' 1) q := by simp [mul_comm] have hcross2 : ∑ q' : Q, (if q' = q₀ then S.Y (Pi.single p₀ 1) p else 0) * T.X (Pi.single q' 1) q = ∑ p' : P, (if p' = p₀ then T.X (Pi.single q₀ 1) q else 0) * S.Y (Pi.single p' 1) p := by simp [mul_comm] have hlhs : ((∑ p' : P, (if q = q₀ then S.Y (Pi.single p₀ 1) p' else 0) * S.X (Pi.single p' 1) p) + (∑ p' : P, (if p' = p₀ then T.Y (Pi.single q₀ 1) q else 0) * S.X (Pi.single p' 1) p) + ((∑ q' : Q, (if q' = q₀ then S.Y (Pi.single p₀ 1) p else 0) * T.X (Pi.single q' 1) q) + (∑ q' : Q, (if p = p₀ then T.Y (Pi.single q₀ 1) q' else 0) * T.X (Pi.single q' 1) q))) - ((∑ p' : P, (if q = q₀ then S.X (Pi.single p₀ 1) p' else 0) * S.Y (Pi.single p' 1) p) + (∑ p' : P, (if p' = p₀ then T.X (Pi.single q₀ 1) q else 0) * S.Y (Pi.single p' 1) p) + ((∑ q' : Q, (if q' = q₀ then S.X (Pi.single p₀ 1) p else 0) * T.Y (Pi.single q' 1) q) + (∑ q' : Q, (if p = p₀ then T.X (Pi.single q₀ 1) q' else 0) * T.Y (Pi.single q' 1) q))) = (if q = q₀ ∧ p = p₀ then (2 * (S.rk p₀ : ℚ) - (S.N : ℚ)) else 0) + (if p = p₀ ∧ q = q₀ then (2 * (T.rk q₀ : ℚ) - (T.N : ℚ)) else 0) := by rw [← hS_comm, ← hT_comm, hcross1, hcross2]; ring rw [hlhs, hsingle] by_cases hp : p = p₀ <;> by_cases hq : q = q₀ · subst hp hq; simp only [↓reduceIte, and_self, mul_one, Nat.cast_add]; ring · simp [hp, hq] · simp [hp, hq] · simp [hp, hq] /-- The `k`-element chain `Fin k` (`k ≥ 1`) as an `Sl2Poset`. -/ def chain (k : ℕ) (hk : 0 < k) : Sl2Poset (Fin k) where N := k - 1 rk j := j.val rk_le j := Nat.le_sub_one_of_lt j.isLt dual j := ⟨k - 1 - j.val, by omega⟩ dual_dual j := by ext; dsimp; omega rk_dual j := rfl X := { toFun := fun f j => if hj : 0 < j.val then f ⟨j.val - 1, by omega⟩ else 0 map_add' := fun f g => by ext j; by_cases hj : 0 < j.val <;> simp [hj] map_smul' := fun c f => by ext j; by_cases hj : 0 < j.val <;> simp [hj] } Y := { toFun := fun f j => if hj : j.val + 1 < k then (((j.val + 1 : ℕ) * (k - (j.val + 1) : ℕ) : ℕ) : ℚ) * f ⟨j.val + 1, hj⟩ else 0 map_add' := fun f g => by ext j; by_cases hj : j.val + 1 < k <;> simp [hj, mul_add] map_smul' := fun c f => by ext j; by_cases hj : j.val + 1 < k <;> simp [hj]; ring } X_order := by intro i j hne dsimp only [LinearMap.coe_mk, AddHom.coe_mk] at hne split_ifs at hne with hj · have hij : (⟨j.val - 1, by omega⟩ : Fin k) = i := by by_contra h exact hne (Pi.single_eq_of_ne h 1) have hval : j.val - 1 = i.val := congrArg Fin.val hij exact ⟨Fin.lt_def.mpr (by omega), by omega⟩ · contradiction Y_rank := by intro i j hne dsimp only [LinearMap.coe_mk, AddHom.coe_mk] at hne split_ifs at hne with hj · have hij : (⟨j.val + 1, hj⟩ : Fin k) = i := by by_contra h rw [Pi.single_eq_of_ne h 1, mul_zero] at hne exact hne rfl have hval : j.val + 1 = i.val := congrArg Fin.val hij omega · contradiction sl2_comm := by intro i ext j dsimp only [LinearMap.coe_mk, AddHom.coe_mk, Pi.sub_apply, Pi.smul_apply, smul_eq_mul] have h1 : (if hj : 0 < j.val then if hj1 : j.val - 1 + 1 < k then (((j.val - 1 + 1) * (k - (j.val - 1 + 1)) : ℕ) : ℚ) * (Pi.single i (1 : ℚ) : Fin k → ℚ) ⟨j.val - 1 + 1, hj1⟩ else 0 else 0) = if j = i then if 0 < i.val then (((i.val * (k - i.val)) : ℕ) : ℚ) else 0 else 0 := by by_cases hj : 0 < j.val · have hj1 : j.val - 1 + 1 < k := by omega have hfin : (⟨j.val - 1 + 1, hj1⟩ : Fin k) = j := by ext; dsimp; omega simp only [hj, hj1, ↓reduceDIte, hfin] by_cases hji : j = i · subst hji simp only [↓reduceIte, Pi.single_eq_same, mul_one, hj] congr 2 <;> omega · simp [hji] · simp only [hj, ↓reduceDIte] by_cases hji : j = i · subst hji; simp [hj] · simp [hji] have h2 : (if hj : j.val + 1 < k then (((j.val + 1) * (k - (j.val + 1)) : ℕ) : ℚ) * if hpos : 0 < j.val + 1 then (Pi.single i (1 : ℚ) : Fin k → ℚ) ⟨j.val + 1 - 1, by omega⟩ else 0 else 0) = if j = i then if i.val + 1 < k then ((((i.val + 1) * (k - (i.val + 1))) : ℕ) : ℚ) else 0 else 0 := by have hfin : ∀ hj : j.val + 1 < k, (⟨j.val + 1 - 1, by omega⟩ : Fin k) = j := fun _ => by ext; exact Nat.add_sub_cancel j.val 1 by_cases hj : j.val + 1 < k · simp only [hj, ↓reduceDIte, Nat.zero_lt_succ, hfin hj] by_cases hji : j = i · subst hji; simp [hj] · simp [hji] · simp only [hj, ↓reduceDIte] by_cases hji : j = i · subst hji; simp [hj] · simp [hji] rw [h1, h2] by_cases hji : j = i · rcases hji with rfl simp only [↓reduceIte, Pi.single_eq_same, mul_one] have hk1 : (1 : ℕ) ≤ k := hk have hterm1 : (if 0 < j.val then (((j.val * (k - j.val)) : ℕ) : ℚ) else 0) = (j.val : ℚ) * ((k : ℚ) - (j.val : ℚ)) := by split_ifs with h · rw [Nat.cast_mul, Nat.cast_sub (le_of_lt j.isLt)] · have hj0 : j.val = 0 := by omega simp [hj0] have hterm2 : (if j.val + 1 < k then ((((j.val + 1) * (k - (j.val + 1))) : ℕ) : ℚ) else 0) = ((j.val : ℚ) + 1) * ((k : ℚ) - ((j.val : ℚ) + 1)) := by split_ifs with h · rw [Nat.cast_mul, Nat.cast_sub (le_of_lt h)]; push_cast; ring · have hjk' : j.val + 1 = k := by omega have : (k : ℚ) = (j.val : ℚ) + 1 := by exact_mod_cast hjk'.symm rw [this]; ring rw [hterm1, hterm2, Nat.cast_sub hk1] push_cast ring · simp [hji] /-- **`k`-Sperner Theorem for any `Sl2Poset`**: if `F ⊆ P` admits a strictly order-preserving `k`-coloring `c : P → Fin k` (`x < y → c x < c y`), then `|F|` is at most the sum of the `k` central rank sizes of `P`. -/ theorem card_kColoring_le (S : Sl2Poset P) (k : ℕ) (hk : 0 < k) (F : Finset P) (c : P → Fin k) (hc : ∀ x ∈ F, ∀ y ∈ F, x < y → c x < c y) : F.card ≤ ∑ j : Fin k, if j.val ≤ (S.N + (k - 1)) / 2 then (S.rankLevel ((S.N + (k - 1)) / 2 - j.val)).card else 0 := by let PC := S.prod (chain k hk) let emb : P → P × Fin k := fun x => (x, Fin.rev (c x)) let F' : Finset (P × Fin k) := F.image emb have hemb_inj : Function.Injective emb := fun x y h => congrArg Prod.fst h have hF'_anti : ∀ a ∈ F', ∀ b ∈ F', a < b → False := by intro a ha b hb hab rcases Finset.mem_image.mp ha with ⟨x, hx, rfl⟩ rcases Finset.mem_image.mp hb with ⟨y, hy, rfl⟩ rw [Prod.lt_iff] at hab rcases hab with ⟨hxy, hle⟩ | ⟨hxy, hlt⟩ · have hcxy : c x < c y := hc x hx y hy hxy have hrev : Fin.rev (c y) < Fin.rev (c x) := Fin.rev_lt_rev.mpr hcxy exact not_lt_of_ge hle hrev · have hne : x ≠ y := by rintro rfl exact lt_irrefl _ hlt have hxy' : x < y := lt_of_le_of_ne hxy hne have hcxy : c x < c y := hc x hx y hy hxy' have hrev : Fin.rev (c y) < Fin.rev (c x) := Fin.rev_lt_rev.mpr hcxy exact lt_asymm hlt hrev have hbound := PC.card_antichain_le_mid F' hF'_anti rw [Finset.card_image_of_injective F hemb_inj] at hbound let M : ℕ := (S.N + (k - 1)) / 2 let slice : Fin k → Finset (P × Fin k) := fun j => if j.val ≤ M then (S.rankLevel (M - j.val)).image (fun p => (p, j)) else ∅ have hEq : PC.rankLevel M = Finset.univ.biUnion slice := by ext ⟨p, j⟩ constructor · intro h simp only [PC, prod, chain, rankLevel, Finset.mem_filter, Finset.mem_univ, true_and] at h refine Finset.mem_biUnion.mpr ⟨j, Finset.mem_univ _, ?_⟩ have hjM : j.val ≤ M := by omega simp only [slice, hjM, ↓reduceIte, Finset.mem_image] refine ⟨p, ?_, rfl⟩ simp only [rankLevel, Finset.mem_filter, Finset.mem_univ, true_and] omega · intro h rcases Finset.mem_biUnion.mp h with ⟨j', _, hj'⟩ dsimp only [slice] at hj' split_ifs at hj' with hle · rcases Finset.mem_image.mp hj' with ⟨p', hp', hpair⟩ simp only [Prod.mk.injEq] at hpair rcases hpair with ⟨rfl, rfl⟩ simp only [rankLevel, Finset.mem_filter, Finset.mem_univ, true_and] at hp' simp only [PC, prod, chain, rankLevel, Finset.mem_filter, Finset.mem_univ, true_and] omega · simp at hj' have hlevel_card : (PC.rankLevel M).card = ∑ j : Fin k, if j.val ≤ M then (S.rankLevel (M - j.val)).card else 0 := by rw [hEq, Finset.card_biUnion] · refine Finset.sum_congr rfl fun j _ => ?_ dsimp only [slice] split_ifs with hle · exact Finset.card_image_of_injective _ (fun p₁ p₂ h => congrArg Prod.fst h) · simp · intro j₁ _ j₂ _ hne simp only [Function.onFun] rw [Finset.disjoint_left] intro x hx₁ hx₂ dsimp only [slice] at hx₁ hx₂ split_ifs at hx₁ with h1 · split_ifs at hx₂ with h2 · rcases Finset.mem_image.mp hx₁ with ⟨_, _, rfl⟩ rcases Finset.mem_image.mp hx₂ with ⟨_, _, hpair⟩ exact hne (congrArg Prod.snd hpair).symm · simp at hx₂ · simp at hx₁ exact le_trans hbound (le_of_eq hlevel_card) end Sl2Poset /-! ## Section 2: Stanley's Poset `M(L)` with Proctor's `sl₂(ℚ)` Action -/ /-- Stanley's shifted-subset poset `M(L)`: subsets of `{1, …, L}` (encoded as `Fin L → Bool`) ordered by dominance of all upper tail counts. -/ @[ext] structure StanleyPoset (L : ℕ) where bits : Fin L → Bool deriving DecidableEq namespace StanleyPoset /-- Equiv with `Fin L → Bool` giving `Fintype`. -/ def equivFun (L : ℕ) : StanleyPoset L ≃ (Fin L → Bool) where toFun := bits invFun := mk left_inv _ := rfl right_inv _ := rfl instance (L : ℕ) : Fintype (StanleyPoset L) := Fintype.ofEquiv (Fin L → Bool) (equivFun L).symm /-- Number of set bits at positions `≥ r`. -/ def tailSum {L : ℕ} (x : StanleyPoset L) (r : Fin L) : ℕ := ∑ i : Fin L, if r.val ≤ i.val ∧ x.bits i then 1 else 0 /-- Bit indicator at index `r` as `0` or `1`. -/ def bitNat {L : ℕ} (x : StanleyPoset L) (r : Fin L) : ℕ := if x.bits r then 1 else 0 lemma tailSum_succ_add_bitNat {L : ℕ} (x : StanleyPoset L) (r : Fin L) (hr : r.val + 1 < L) : tailSum x r = bitNat x r + tailSum x ⟨r.val + 1, hr⟩ := by unfold tailSum bitNat have hsplit : ∀ i : Fin L, (if r.val ≤ i.val ∧ x.bits i then 1 else 0) = (if i = r then (if x.bits r then 1 else 0) else 0) + (if r.val + 1 ≤ i.val ∧ x.bits i then 1 else 0) := by intro i by_cases hir : i = r · subst hir; simp · have hne : i.val ≠ r.val := fun h => hir (Fin.ext h) by_cases hle : r.val ≤ i.val · have hgt : r.val + 1 ≤ i.val := by omega simp [hir, hle, hgt] · have hngt : ¬(r.val + 1 ≤ i.val) := by omega simp [hir, hle, hngt] simp only [hsplit, Finset.sum_add_distrib, Finset.sum_ite_eq', Finset.mem_univ, ↓reduceIte] lemma tailSum_last_eq_bitNat {L : ℕ} (x : StanleyPoset L) (r : Fin L) (hr : r.val + 1 = L) : tailSum x r = bitNat x r := by unfold tailSum bitNat have hsingle : ∀ i : Fin L, (if r.val ≤ i.val ∧ x.bits i then 1 else 0) = if i = r then (if x.bits r then 1 else 0) else 0 := by intro i by_cases hir : i = r · subst hir; simp · have hne : i.val ≠ r.val := fun h => hir (Fin.ext h) have hnot : ¬(r.val ≤ i.val) := by omega simp [hir, hnot] simp only [hsingle, Finset.sum_ite_eq', Finset.mem_univ, ↓reduceIte] instance (L : ℕ) : PartialOrder (StanleyPoset L) where le x y := ∀ r : Fin L, tailSum x r ≤ tailSum y r le_refl _ _ := le_rfl le_trans _ _ _ h1 h2 r := le_trans (h1 r) (h2 r) le_antisymm x y hxy hyx := by ext r have htail : ∀ s : Fin L, tailSum x s = tailSum y s := fun s => le_antisymm (hxy s) (hyx s) have hbn : bitNat x r = bitNat y r := by by_cases hr : r.val + 1 < L · have hx := tailSum_succ_add_bitNat x r hr have hy := tailSum_succ_add_bitNat y r hr have h1 := htail r have h2 := htail ⟨r.val + 1, hr⟩ omega · have hr' : r.val + 1 = L := by omega rw [← tailSum_last_eq_bitNat x r hr', ← tailSum_last_eq_bitNat y r hr', htail r] unfold bitNat at hbn cases hx : x.bits r <;> cases hy : y.bits r <;> simp [hx, hy] at hbn ⊢ /-- Subset sum of weights `a : Fin L → G` selected by `x : StanleyPoset L`. -/ def subsetSum {L : ℕ} {G : Type*} [AddCommMonoid G] (a : Fin L → G) (x : StanleyPoset L) : G := ∑ i : Fin L, if x.bits i then a i else 0 /-- Abel summation-by-parts identity in any additive commutative group `G` for `x ≤ y`. -/ lemma subsetSum_sub_eq_abel {L : ℕ} {G : Type*} [AddCommGroup G] (a : Fin (L + 1) → G) (x y : StanleyPoset (L + 1)) (hxy : x ≤ y) : subsetSum a y - subsetSum a x = (tailSum y 0 - tailSum x 0) • a 0 + ∑ r : Fin L, (tailSum y r.succ - tailSum x r.succ) • (a r.succ - a r.castSucc) := by have hterm : ∀ i : Fin (L + 1), (if y.bits i then a i else 0) - (if x.bits i then a i else 0) = ((bitNat y i : ℤ) - (bitNat x i : ℤ)) • a i := by intro i unfold bitNat cases hx : x.bits i <;> cases hy : y.bits i <;> simp have hlhs : subsetSum a y - subsetSum a x = ∑ i : Fin (L + 1), ((bitNat y i : ℤ) - (bitNat x i : ℤ)) • a i := by unfold subsetSum rw [← Finset.sum_sub_distrib] exact Finset.sum_congr rfl fun i _ => hterm i rw [hlhs] have hcast : ∀ r : Fin (L + 1), ((tailSum y r - tailSum x r : ℕ) : ℤ) = (tailSum y r : ℤ) - (tailSum x r : ℤ) := fun r => Nat.cast_sub (hxy r) have hrhs_zsmul : (tailSum y 0 - tailSum x 0) • a 0 + ∑ r : Fin L, (tailSum y r.succ - tailSum x r.succ) • (a r.succ - a r.castSucc) = ((tailSum y 0 : ℤ) - (tailSum x 0 : ℤ)) • a 0 + ∑ r : Fin L, ((tailSum y r.succ : ℤ) - (tailSum x r.succ : ℤ)) • (a r.succ - a r.castSucc) := by rw [← natCast_zsmul, hcast 0] congr 1 refine Finset.sum_congr rfl fun r _ => ?_ rw [← natCast_zsmul, hcast r.succ] rw [hrhs_zsmul] let d : Fin (L + 1) → ℤ := fun r => (tailSum y r : ℤ) - (tailSum x r : ℤ) have hdiff_succ : ∀ r : Fin L, (bitNat y r.castSucc : ℤ) - (bitNat x r.castSucc : ℤ) = d r.castSucc - d r.succ := by intro r have hrlt : r.castSucc.val + 1 < L + 1 := by simp [Fin.val_castSucc] have hx := tailSum_succ_add_bitNat x r.castSucc hrlt have hy := tailSum_succ_add_bitNat y r.castSucc hrlt have hfin : (⟨r.castSucc.val + 1, hrlt⟩ : Fin (L + 1)) = r.succ := by ext; simp rw [hfin] at hx hy dsimp only [d]; omega have hdiff_last : (bitNat y (Fin.last L) : ℤ) - (bitNat x (Fin.last L) : ℤ) = d (Fin.last L) := by have hx := tailSum_last_eq_bitNat x (Fin.last L) (by simp) have hy := tailSum_last_eq_bitNat y (Fin.last L) (by simp) dsimp only [d]; omega rw [Fin.sum_univ_castSucc, hdiff_last] simp_rw [hdiff_succ, sub_smul, Finset.sum_sub_distrib, smul_sub] have hreidx : (∑ r : Fin L, d r.castSucc • a r.castSucc) + d (Fin.last L) • a (Fin.last L) = d 0 • a 0 + ∑ r : Fin L, d r.succ • a r.succ := by rw [← Fin.sum_univ_castSucc (f := fun i : Fin (L + 1) => d i • a i), Fin.sum_univ_succ (f := fun i : Fin (L + 1) => d i • a i)] have h1 : (∑ r : Fin L, d r.castSucc • a r.castSucc) - (∑ r : Fin L, d r.succ • a r.castSucc) + d (Fin.last L) • a (Fin.last L) = ((∑ r : Fin L, d r.castSucc • a r.castSucc) + d (Fin.last L) • a (Fin.last L)) - (∑ r : Fin L, d r.succ • a r.castSucc) := by abel rw [h1, hreidx, Finset.sum_sub_distrib] simp only [d, sub_smul, Finset.sum_sub_distrib] abel /-- Strict monotonicity of subset sums on `StanleyPoset L` for strictly increasing positive weights. -/ theorem subsetSum_strictMono {L : ℕ} {G : Type*} [AddCommGroup G] [LinearOrder G] [IsOrderedAddMonoid G] (a : Fin L → G) (ha_pos : ∀ i, 0 < a i) (ha_mono : StrictMono a) {x y : StanleyPoset L} (hxy : x < y) : subsetSum a x < subsetSum a y := by cases L with | zero => exfalso have : x = y := by ext i; exact Fin.elim0 i exact ne_of_lt hxy this | succ L => have hle : x ≤ y := le_of_lt hxy have hne : x ≠ y := ne_of_lt hxy have hex : ∃ r : Fin (L + 1), tailSum x r < tailSum y r := by by_contra hall push Not at hall exact hne (le_antisymm hle hall) rw [← sub_pos, subsetSum_sub_eq_abel a x y hle] have h0_nn : (0 : G) ≤ (tailSum y 0 - tailSum x 0) • a 0 := nsmul_nonneg (le_of_lt (ha_pos 0)) _ have hterm_nn : ∀ r : Fin L, (0 : G) ≤ (tailSum y r.succ - tailSum x r.succ) • (a r.succ - a r.castSucc) := fun r => nsmul_nonneg (sub_nonneg.mpr (le_of_lt (ha_mono Fin.castSucc_lt_succ))) _ rcases hex with ⟨r, hr⟩ refine Fin.cases ?_ ?_ r hr · intro h0 have hpos : (0 : G) < (tailSum y 0 - tailSum x 0) • a 0 := nsmul_pos (ha_pos 0) (by omega) have hsum_nn : (0 : G) ≤ ∑ r : Fin L, (tailSum y r.succ - tailSum x r.succ) • (a r.succ - a r.castSucc) := Finset.sum_nonneg fun r _ => hterm_nn r exact add_pos_of_pos_of_nonneg hpos hsum_nn · intro r hr have hpos : (0 : G) < (tailSum y r.succ - tailSum x r.succ) • (a r.succ - a r.castSucc) := nsmul_pos (sub_pos.mpr (ha_mono Fin.castSucc_lt_succ)) (by omega) have hsum_pos : (0 : G) < ∑ j : Fin L, (tailSum y j.succ - tailSum x j.succ) • (a j.succ - a j.castSucc) := Finset.sum_pos' (fun j _ => hterm_nn j) ⟨r, Finset.mem_univ r, hpos⟩ exact add_pos_of_nonneg_of_pos h0_nn hsum_pos /-- Gap monotonicity: if weights satisfy `r₀ ≤ a 0` and `r₀ ≤ a (i+1) - a i` (`0 ≤ r₀`), then `x < y` increases `subsetSum a` by at least `r₀`. -/ theorem subsetSum_gap_mono {L : ℕ} {G : Type*} [AddCommGroup G] [LinearOrder G] [IsOrderedAddMonoid G] (a : Fin L → G) {r₀ : G} (hr₀ : 0 ≤ r₀) (ha_min : ∀ i, r₀ ≤ a i) (ha_gap : ∀ (i : Fin L) (hi : i.val + 1 < L), r₀ ≤ a ⟨i.val + 1, hi⟩ - a i) {x y : StanleyPoset L} (hxy : x < y) : r₀ ≤ subsetSum a y - subsetSum a x := by cases L with | zero => exfalso have : x = y := by ext i; exact Fin.elim0 i exact ne_of_lt hxy this | succ L => have hle : x ≤ y := le_of_lt hxy have hne : x ≠ y := ne_of_lt hxy have hex : ∃ r : Fin (L + 1), tailSum x r < tailSum y r := by by_contra hall push Not at hall exact hne (le_antisymm hle hall) rw [subsetSum_sub_eq_abel a x y hle] have h0_nn : (0 : G) ≤ (tailSum y 0 - tailSum x 0) • a 0 := nsmul_nonneg (le_trans hr₀ (ha_min 0)) _ have hstep_gap : ∀ r : Fin L, r₀ ≤ a r.succ - a r.castSucc := fun r => by have h := ha_gap r.castSucc (by simp) have hfin : (⟨r.castSucc.val + 1, by simp⟩ : Fin (L + 1)) = r.succ := by ext; simp rwa [hfin] at h have hterm_nn : ∀ r : Fin L, (0 : G) ≤ (tailSum y r.succ - tailSum x r.succ) • (a r.succ - a r.castSucc) := fun r => nsmul_nonneg (le_trans hr₀ (hstep_gap r)) _ rcases hex with ⟨r, hr⟩ refine Fin.cases ?_ ?_ r hr · intro h0 have hge1 : 1 ≤ tailSum y 0 - tailSum x 0 := by omega have h1 : r₀ ≤ (tailSum y 0 - tailSum x 0) • a 0 := by calc r₀ ≤ a 0 := ha_min 0 _ = 1 • a 0 := (one_nsmul _).symm _ ≤ _ := nsmul_le_nsmul_left (le_trans hr₀ (ha_min 0)) hge1 have hsum_nn : (0 : G) ≤ ∑ j : Fin L, (tailSum y j.succ - tailSum x j.succ) • (a j.succ - a j.castSucc) := Finset.sum_nonneg fun j _ => hterm_nn j exact le_add_of_le_of_nonneg h1 hsum_nn · intro r hr have hge1 : 1 ≤ tailSum y r.succ - tailSum x r.succ := by omega have h1 : r₀ ≤ (tailSum y r.succ - tailSum x r.succ) • (a r.succ - a r.castSucc) := by calc r₀ ≤ a r.succ - a r.castSucc := hstep_gap r _ = 1 • (a r.succ - a r.castSucc) := (one_nsmul _).symm _ ≤ _ := nsmul_le_nsmul_left (le_trans hr₀ (hstep_gap r)) hge1 have hsum_ge : r₀ ≤ ∑ j : Fin L, (tailSum y j.succ - tailSum x j.succ) • (a j.succ - a j.castSucc) := le_trans h1 (Finset.single_le_sum (fun j _ => hterm_nn j) (Finset.mem_univ r)) exact le_add_of_nonneg_of_le h0_nn hsum_ge /-- Rank of `x ∈ M(L)`: `∑ i, (i + 1) * x_i`. -/ def rk {L : ℕ} (x : StanleyPoset L) : ℕ := ∑ i : Fin L, if x.bits i then i.val + 1 else 0 lemma sum_fin_succ_eq (L : ℕ) : ∑ i : Fin L, (i.val + 1) = L * (L + 1) / 2 := by induction L with | zero => simp | succ L ih => rw [Fin.sum_univ_castSucc] simp only [Fin.val_castSucc, Fin.val_last, ih] have h1 : 2 * (L * (L + 1) / 2) = L * (L + 1) := Nat.mul_div_cancel' (Nat.even_mul_succ_self L).two_dvd have h2 : 2 * ((L + 1) * (L + 2) / 2) = (L + 1) * (L + 2) := Nat.mul_div_cancel' (Nat.even_mul_succ_self (L + 1)).two_dvd have hmul : 2 * (L * (L + 1) / 2 + (L + 1)) = 2 * ((L + 1) * (L + 2) / 2) := by calc 2 * (L * (L + 1) / 2 + (L + 1)) = 2 * (L * (L + 1) / 2) + 2 * (L + 1) := by ring _ = L * (L + 1) + 2 * (L + 1) := by rw [h1] _ = (L + 1) * (L + 2) := by ring _ = 2 * ((L + 1) * (L + 2) / 2) := h2.symm have hEq : L + 1 + 1 = L + 2 := by omega rw [hEq]; omega lemma rk_le {L : ℕ} (x : StanleyPoset L) : rk x ≤ L * (L + 1) / 2 := by rw [← sum_fin_succ_eq L] refine Finset.sum_le_sum fun i _ => ?_ split_ifs <;> omega lemma rk_compl {L : ℕ} (x : StanleyPoset L) : rk ⟨fun i => !(x.bits i)⟩ = L * (L + 1) / 2 - rk x := by have hsum : rk ⟨fun i => !(x.bits i)⟩ + rk x = L * (L + 1) / 2 := by rw [← sum_fin_succ_eq L] unfold rk rw [← Finset.sum_add_distrib] refine Finset.sum_congr rfl fun i _ => ?_ cases h : x.bits i <;> simp [h] omega /-- Set bit at position `k : ℕ` (if in range) to `b`. -/ def setBit {L : ℕ} (x : StanleyPoset L) (k : ℕ) (b : Bool) : StanleyPoset L := ⟨fun j => if j.val = k then b else x.bits j⟩ /-- Covering upward move indexed by `i : Fin L`: - `i = 0`: flip bit `0` from `false` to `true`, - `i = k + 1`: move bit from `k` (`true`) to `k + 1` (`false`). -/ def upMove {L : ℕ} (i : Fin L) (x : StanleyPoset L) : Option (StanleyPoset L) := if h0 : i.val = 0 then if x.bits i = false then some (setBit x 0 true) else none else if x.bits ⟨i.val - 1, by omega⟩ = true ∧ x.bits i = false then some (setBit (setBit x (i.val - 1) false) i.val true) else none /-- Covering downward move indexed by `i : Fin L` (exact partial inverse of `upMove i`). -/ def downMove {L : ℕ} (i : Fin L) (x : StanleyPoset L) : Option (StanleyPoset L) := if h0 : i.val = 0 then if x.bits i = true then some (setBit x 0 false) else none else if x.bits ⟨i.val - 1, by omega⟩ = false ∧ x.bits i = true then some (setBit (setBit x (i.val - 1) true) i.val false) else none /-- Proctor's explicit positive integer weight `w_i` for `Y` on `M(L)`: `w_0 = L(L+1)/2`, `w_i = L(L+1) - i(i+1)` for `1 ≤ i < L`. -/ def proctorWeight (L : ℕ) (i : Fin L) : ℚ := if i.val = 0 then ((L * (L + 1) / 2 : ℕ) : ℚ) else ((L * (L + 1) - i.val * (i.val + 1) : ℕ) : ℚ) lemma downMove_eq_some_iff {L : ℕ} (i : Fin L) (x y : StanleyPoset L) : downMove i y = some x ↔ upMove i x = some y := by unfold downMove upMove by_cases h0 : i.val = 0 · simp only [h0, ↓reduceDIte] have hi0 : i = ⟨0, by omega⟩ := Fin.ext h0 constructor · intro h split_ifs at h with hy · injection h with hxy subst hxy have hxb : (setBit y 0 false).bits i = false := by simp [setBit, h0] simp only [hxb, ↓reduceIte, Option.some.injEq] ext j by_cases hj : j.val = 0 · have hji : j = i := Fin.ext (by omega) subst hji; simp [setBit, h0, hy] · simp [setBit, hj] · intro h split_ifs at h with hx · injection h with hxy subst hxy have hyb : (setBit x 0 true).bits i = true := by simp [setBit, h0] simp only [hyb, ↓reduceIte, Option.some.injEq] ext j by_cases hj : j.val = 0 · have hji : j = i := Fin.ext (by omega) subst hji; simp [setBit, h0, hx] · simp [setBit, hj] · simp only [h0, ↓reduceDIte] constructor · intro h split_ifs at h with hy · injection h with hxy subst hxy have h1 : (setBit (setBit y (i.val - 1) true) i.val false).bits ⟨i.val - 1, by omega⟩ = true := by simp [setBit]; omega have h2 : (setBit (setBit y (i.val - 1) true) i.val false).bits i = false := by simp [setBit] simp only [h1, h2, and_self, ↓reduceIte, Option.some.injEq] ext j by_cases hji : j.val = i.val · have : j = i := Fin.ext hji subst this; simp [setBit, hy.2] · by_cases hjm : j.val = i.val - 1 · have hjeq : j = ⟨i.val - 1, by omega⟩ := Fin.ext hjm rw [hjeq]; simp [setBit, hy.1]; omega · simp [setBit, hji, hjm] · intro h split_ifs at h with hx · injection h with hxy subst hxy have h1 : (setBit (setBit x (i.val - 1) false) i.val true).bits ⟨i.val - 1, by omega⟩ = false := by simp [setBit]; omega have h2 : (setBit (setBit x (i.val - 1) false) i.val true).bits i = true := by simp [setBit] simp only [h1, h2, and_self, ↓reduceIte, Option.some.injEq] ext j by_cases hji : j.val = i.val · have : j = i := Fin.ext hji subst this; simp [setBit, hx.2] · by_cases hjm : j.val = i.val - 1 · have hjeq : j = ⟨i.val - 1, by omega⟩ := Fin.ext hjm rw [hjeq]; simp [setBit, hx.1]; omega · simp [setBit, hji, hjm] lemma upMove_lt_and_rk {L : ℕ} (i : Fin L) (x y : StanleyPoset L) (h : upMove i x = some y) : x < y ∧ rk y = rk x + 1 := by unfold upMove at h by_cases h0 : i.val = 0 · simp only [h0, ↓reduceDIte] at h split_ifs at h with hx injection h with hxy subst hxy have htail : ∀ r : Fin L, tailSum (setBit x 0 true) r = tailSum x r + if r.val = 0 then 1 else 0 := by intro r unfold tailSum have hterm : ∀ j : Fin L, (if r.val ≤ j.val ∧ (setBit x 0 true).bits j then 1 else 0) = (if r.val ≤ j.val ∧ x.bits j then 1 else 0) + (if j = i ∧ r.val = 0 then 1 else 0) := by intro j by_cases hji : j = i · rcases hji with rfl by_cases hr0 : r.val = 0 · simp [setBit, h0, hr0, hx] · have hnot : ¬(r.val ≤ j.val) := by omega simp [hnot, hr0] · have hjne : j.val ≠ 0 := fun hv => hji (Fin.ext (by omega)) simp [setBit, hji, hjne] simp_rw [hterm, Finset.sum_add_distrib] congr 1 by_cases hr0 : r.val = 0 · simp [hr0] · simp [hr0] have hlt : x < setBit x 0 true := by refine lt_of_le_of_ne (fun r => by rw [htail r]; omega) ?_ intro heq have := congrArg (fun z => tailSum z i) heq rw [htail i, if_pos h0] at this; omega have hrk : rk (setBit x 0 true) = rk x + 1 := by unfold rk have hterm : ∀ j : Fin L, (if (setBit x 0 true).bits j then j.val + 1 else 0) = (if x.bits j then j.val + 1 else 0) + (if j = i then 1 else 0) := by intro j by_cases hji : j = i · rcases hji with rfl; simp [setBit, h0, hx] · have hjne : j.val ≠ 0 := fun hv => hji (Fin.ext (by omega)) simp [setBit, hji, hjne] simp_rw [hterm, Finset.sum_add_distrib] simp exact ⟨hlt, hrk⟩ · simp only [h0, ↓reduceDIte] at h split_ifs at h with hx injection h with hxy subst hxy let im : Fin L := ⟨i.val - 1, by omega⟩ have him_ne : im ≠ i := fun heq => by have := congrArg Fin.val heq; dsimp [im] at this; omega have htail : ∀ r : Fin L, tailSum (setBit (setBit x (i.val - 1) false) i.val true) r = tailSum x r + if r.val = i.val then 1 else 0 := by intro r unfold tailSum have hterm : ∀ j : Fin L, (if r.val ≤ j.val ∧ (setBit (setBit x (i.val - 1) false) i.val true).bits j then 1 else 0) + (if j = im ∧ r.val ≤ im.val then 1 else 0) = (if r.val ≤ j.val ∧ x.bits j then 1 else 0) + (if j = i ∧ r.val ≤ i.val then 1 else 0) := by intro j by_cases hji : j = i · rcases hji with rfl have hne : j ≠ im := him_ne.symm by_cases hri : r.val ≤ j.val <;> simp [setBit, hne, hri, hx.2] · by_cases hjim : j = im · rcases hjim with rfl have hjv : im.val ≠ i.val := by dsimp [im]; omega by_cases hrim : r.val ≤ im.val <;> simp [setBit, hji, hjv, hrim, im, hx.1] · have hjv1 : j.val ≠ i.val := fun hv => hji (Fin.ext hv) have hjv2 : j.val ≠ i.val - 1 := fun hv => hjim (Fin.ext hv) simp [setBit, hji, hjim, hjv1, hjv2] have hsum := congrArg (Finset.sum Finset.univ) (funext hterm) simp only [Finset.sum_add_distrib] at hsum have hs1 : ∑ j : Fin L, (if j = im ∧ r.val ≤ im.val then 1 else 0) = if r.val ≤ im.val then 1 else 0 := by by_cases h : r.val ≤ im.val <;> simp [h] have hs2 : ∑ j : Fin L, (if j = i ∧ r.val ≤ i.val then 1 else 0) = if r.val ≤ i.val then 1 else 0 := by by_cases h : r.val ≤ i.val <;> simp [h] rw [hs1, hs2] at hsum dsimp only [im] at hsum by_cases hri : r.val = i.val · simp only [hri, le_refl, ↓reduceIte] at hsum ⊢ have : ¬(i.val ≤ i.val - 1) := by omega simp only [this, ↓reduceIte, add_zero] at hsum exact hsum · by_cases hlt : r.val ≤ i.val - 1 · have hle : r.val ≤ i.val := by omega simp only [hlt, hle, ↓reduceIte] at hsum simp only [hri, ↓reduceIte, add_zero]; omega · have hnot : ¬(r.val ≤ i.val) := by omega simp only [hlt, hnot, ↓reduceIte, add_zero] at hsum simp only [hri, ↓reduceIte, add_zero]; exact hsum have hlt : x < setBit (setBit x (i.val - 1) false) i.val true := by refine lt_of_le_of_ne (fun r => by rw [htail r]; omega) ?_ intro heq have := congrArg (fun z => tailSum z i) heq rw [htail i, if_pos rfl] at this; omega have hrk : rk (setBit (setBit x (i.val - 1) false) i.val true) = rk x + 1 := by unfold rk have hterm : ∀ j : Fin L, (if (setBit (setBit x (i.val - 1) false) i.val true).bits j then j.val + 1 else 0) + (if j = im then im.val + 1 else 0) = (if x.bits j then j.val + 1 else 0) + (if j = i then i.val + 1 else 0) := by intro j by_cases hji : j = i · subst hji; simp [setBit, him_ne.symm, hx.2] · by_cases hjim : j = im · subst hjim have hjv : im.val ≠ i.val := by dsimp [im]; omega simp [setBit, hji, hjv, im, hx.1] · have hjv1 : j.val ≠ i.val := fun hv => hji (Fin.ext hv) have hjv2 : j.val ≠ i.val - 1 := fun hv => hjim (Fin.ext hv) simp [setBit, hji, hjim, hjv1, hjv2] have hsum := congrArg (Finset.sum Finset.univ) (funext hterm) simp only [Finset.sum_add_distrib, Finset.sum_ite_eq', Finset.mem_univ, ↓reduceIte] at hsum dsimp only [im] at hsum omega exact ⟨hlt, hrk⟩ /-- Off-diagonal commutation: for `i ≠ j`, `downMove i` followed by `upMove j` yields `z` iff `upMove j` followed by `downMove i` yields `z` (both fail when `|i - j| = 1`, and they act on disjoint bits when `|i - j| ≥ 2`). -/ lemma down_up_iff_up_down {L : ℕ} {i j : Fin L} (hij : i ≠ j) (x z : StanleyPoset L) : (∃ y, downMove i x = some y ∧ upMove j y = some z) ↔ (∃ y, upMove j x = some y ∧ downMove i y = some z) := by have hne : i.val ≠ j.val := fun h => hij (Fin.ext h) -- Helper: check bit value of `setBit` have hset : ∀ (u : StanleyPoset L) k b (t : Fin L), (setBit u k b).bits t = if t.val = k then b else u.bits t := fun _ _ _ _ => rfl constructor · rintro ⟨y, hdi, huj⟩ unfold downMove at hdi; unfold upMove at huj by_cases hi0 : i.val = 0 <;> by_cases hj0 : j.val = 0 · omega · simp only [hi0, ↓reduceDIte] at hdi simp only [hj0, ↓reduceDIte] at huj split_ifs at hdi with hxi split_ifs at huj with hyj injection hdi with hy_eq; injection huj with hz_eq subst hy_eq; subst hz_eq by_cases hj1 : j.val = 1 · have := hyj.1; simp only [hset, hj1, Nat.sub_self, ↓reduceIte] at this exact absurd this (by decide) · have hxj1 : x.bits ⟨j.val - 1, by omega⟩ = true := by have := hyj.1; simp only [hset] at this rw [if_neg (by omega)] at this; exact this have hxj2 : x.bits j = false := by have := hyj.2; simp only [hset] at this rw [if_neg (by omega)] at this; exact this refine ⟨setBit (setBit x (j.val - 1) false) j.val true, ?_, ?_⟩ · unfold upMove; simp [hj0, hxj1, hxj2] · unfold downMove have hbit : (setBit (setBit x (j.val - 1) false) j.val true).bits i = true := by simp only [hset]; rw [if_neg (by omega), if_neg (by omega)]; exact hxi simp only [hi0, ↓reduceDIte, hbit, ↓reduceIte, Option.some.injEq] ext t; simp only [hset]; split_ifs <;> first | rfl | omega · simp only [hi0, ↓reduceDIte] at hdi simp only [hj0, ↓reduceDIte] at huj split_ifs at hdi with hxi split_ifs at huj with hyj injection hdi with hy_eq; injection huj with hz_eq subst hy_eq; subst hz_eq by_cases hi1 : i.val = 1 · have := hyj; simp [hset, hi1, hj0] at this · have hxj : x.bits j = false := by have := hyj; simp only [hset] at this rw [if_neg (by omega), if_neg (by omega)] at this; exact this refine ⟨setBit x 0 true, ?_, ?_⟩ · unfold upMove; simp [hj0, hxj] · unfold downMove have h1 : (setBit x 0 true).bits ⟨i.val - 1, by omega⟩ = false := by simp only [hset]; rw [if_neg (by omega)]; exact hxi.1 have h2 : (setBit x 0 true).bits i = true := by simp only [hset]; rw [if_neg (by omega)]; exact hxi.2 simp only [hi0, ↓reduceDIte, h1, h2, and_self, ↓reduceIte, Option.some.injEq] ext t; simp only [hset]; split_ifs <;> first | rfl | omega · simp only [hi0, ↓reduceDIte] at hdi simp only [hj0, ↓reduceDIte] at huj split_ifs at hdi with hxi split_ifs at huj with hyj injection hdi with hy_eq; injection huj with hz_eq subst hy_eq; subst hz_eq by_cases hadj1 : j.val = i.val + 1 · have := hyj.1; simp only [hset, hadj1, Nat.add_sub_cancel, ↓reduceIte] at this exact absurd this (by decide) · by_cases hadj2 : i.val = j.val + 1 · have := hyj.2; simp only [hset, hadj2, Nat.add_sub_cancel] at this rw [if_neg (by omega)] at this; simp at this · have hxj1 : x.bits ⟨j.val - 1, by omega⟩ = true := by have := hyj.1; simp only [hset] at this rw [if_neg (by omega), if_neg (by omega)] at this; exact this have hxj2 : x.bits j = false := by have := hyj.2; simp only [hset] at this rw [if_neg (by omega), if_neg (by omega)] at this; exact this refine ⟨setBit (setBit x (j.val - 1) false) j.val true, ?_, ?_⟩ · unfold upMove; simp [hj0, hxj1, hxj2] · unfold downMove have h1 : (setBit (setBit x (j.val - 1) false) j.val true).bits ⟨i.val - 1, by omega⟩ = false := by simp only [hset]; rw [if_neg (by omega), if_neg (by omega)]; exact hxi.1 have h2 : (setBit (setBit x (j.val - 1) false) j.val true).bits i = true := by simp only [hset]; rw [if_neg (by omega), if_neg (by omega)]; exact hxi.2 simp only [hi0, ↓reduceDIte, h1, h2, and_self, ↓reduceIte, Option.some.injEq] ext t; simp only [hset]; split_ifs <;> first | rfl | omega · rintro ⟨y, huj, hdi⟩ unfold upMove at huj; unfold downMove at hdi by_cases hi0 : i.val = 0 <;> by_cases hj0 : j.val = 0 · omega · simp only [hj0, ↓reduceDIte] at huj simp only [hi0, ↓reduceDIte] at hdi split_ifs at huj with hxj split_ifs at hdi with hyi injection huj with hy_eq; injection hdi with hz_eq subst hy_eq; subst hz_eq by_cases hj1 : j.val = 1 · have := hyi; simp [hset, hi0, hj1] at this · have hxi : x.bits i = true := by have := hyi; simp only [hset] at this rw [if_neg (by omega), if_neg (by omega)] at this; exact this refine ⟨setBit x 0 false, ?_, ?_⟩ · unfold downMove; simp [hi0, hxi] · unfold upMove have h1 : (setBit x 0 false).bits ⟨j.val - 1, by omega⟩ = true := by simp only [hset]; rw [if_neg (by omega)]; exact hxj.1 have h2 : (setBit x 0 false).bits j = false := by simp only [hset]; rw [if_neg (by omega)]; exact hxj.2 simp only [hj0, ↓reduceDIte, h1, h2, and_self, ↓reduceIte, Option.some.injEq] ext t; simp only [hset]; split_ifs <;> first | rfl | omega · simp only [hj0, ↓reduceDIte] at huj simp only [hi0, ↓reduceDIte] at hdi split_ifs at huj with hxj split_ifs at hdi with hyi injection huj with hy_eq; injection hdi with hz_eq subst hy_eq; subst hz_eq by_cases hi1 : i.val = 1 · have := hyi.1; simp only [hset, hi1, Nat.sub_self, ↓reduceIte] at this exact absurd this (by decide) · have hxi1 : x.bits ⟨i.val - 1, by omega⟩ = false := by have := hyi.1; simp only [hset] at this rw [if_neg (by omega)] at this; exact this have hxi2 : x.bits i = true := by have := hyi.2; simp only [hset] at this rw [if_neg (by omega)] at this; exact this refine ⟨setBit (setBit x (i.val - 1) true) i.val false, ?_, ?_⟩ · unfold downMove; simp [hi0, hxi1, hxi2] · unfold upMove have hbit : (setBit (setBit x (i.val - 1) true) i.val false).bits j = false := by simp only [hset]; rw [if_neg (by omega), if_neg (by omega)]; exact hxj simp only [hj0, ↓reduceDIte, hbit, ↓reduceIte, Option.some.injEq] ext t; simp only [hset]; split_ifs <;> first | rfl | omega · simp only [hj0, ↓reduceDIte] at huj simp only [hi0, ↓reduceDIte] at hdi split_ifs at huj with hxj split_ifs at hdi with hyi injection huj with hy_eq; injection hdi with hz_eq subst hy_eq; subst hz_eq by_cases hadj1 : j.val = i.val + 1 · have := hyi.2; simp only [hset, hadj1, Nat.add_sub_cancel] at this rw [if_neg (by omega)] at this; simp at this · by_cases hadj2 : i.val = j.val + 1 · have := hyi.1; simp only [hset, hadj2, Nat.add_sub_cancel, ↓reduceIte] at this exact absurd this (by decide) · have hxi1 : x.bits ⟨i.val - 1, by omega⟩ = false := by have := hyi.1; simp only [hset] at this rw [if_neg (by omega), if_neg (by omega)] at this; exact this have hxi2 : x.bits i = true := by have := hyi.2; simp only [hset] at this rw [if_neg (by omega), if_neg (by omega)] at this; exact this refine ⟨setBit (setBit x (i.val - 1) true) i.val false, ?_, ?_⟩ · unfold downMove; simp [hi0, hxi1, hxi2] · unfold upMove have h1 : (setBit (setBit x (i.val - 1) true) i.val false).bits ⟨j.val - 1, by omega⟩ = true := by simp only [hset]; rw [if_neg (by omega), if_neg (by omega)]; exact hxj.1 have h2 : (setBit (setBit x (i.val - 1) true) i.val false).bits j = false := by simp only [hset]; rw [if_neg (by omega), if_neg (by omega)]; exact hxj.2 simp only [hj0, ↓reduceDIte, h1, h2, and_self, ↓reduceIte, Option.some.injEq] ext t; simp only [hset]; split_ifs <;> first | rfl | omega /-- Diagonal telescoping identity for Proctor's weights on `M(L)`. -/ lemma proctor_diagonal_sum {L : ℕ} (x : StanleyPoset L) : ∑ i : Fin L, proctorWeight L i * ((if (downMove i x).isSome then (1 : ℚ) else 0) - (if (upMove i x).isSome then (1 : ℚ) else 0)) = 2 * (rk x : ℚ) - ((L * (L + 1) / 2 : ℕ) : ℚ) := by cases L with | zero => simp [rk] | succ L => rw [Fin.sum_univ_succ] let c : Fin (L + 1) → ℚ := fun j => if x.bits j then 1 else 0 have h0 : proctorWeight (L + 1) 0 * ((if (downMove 0 x).isSome then (1 : ℚ) else 0) - (if (upMove 0 x).isSome then (1 : ℚ) else 0)) = (((L + 1) * (L + 2) / 2 : ℕ) : ℚ) * (2 * c 0 - 1) := by unfold proctorWeight downMove upMove c simp only [Fin.val_zero, ↓reduceDIte, ↓reduceIte] cases h : x.bits 0 <;> (simp; try ring) have hsucc : ∀ k : Fin L, proctorWeight (L + 1) k.succ * ((if (downMove k.succ x).isSome then (1 : ℚ) else 0) - (if (upMove k.succ x).isSome then (1 : ℚ) else 0)) = ((L + 1 : ℚ) * (L + 2 : ℚ) - ((k.val : ℚ) + 1) * ((k.val : ℚ) + 2)) * (c k.succ - c k.castSucc) := by intro k have hsub_le : (k.val + 1) * (k.val + 2) ≤ (L + 1) * (L + 2) := Nat.mul_le_mul (by omega) (by omega) have hw : proctorWeight (L + 1) k.succ = (L + 1 : ℚ) * (L + 2 : ℚ) - ((k.val : ℚ) + 1) * ((k.val : ℚ) + 2) := by unfold proctorWeight simp only [Fin.val_succ, Nat.succ_ne_zero, ↓reduceIte] rw [Nat.cast_sub hsub_le] push_cast; ring rw [hw] congr 1 unfold downMove upMove c simp only [Fin.val_succ, Nat.succ_ne_zero, ↓reduceDIte] have hfin : (⟨k.val + 1 - 1, by omega⟩ : Fin (L + 1)) = k.castSucc := by ext; simp rw [hfin] cases h1 : x.bits k.castSucc <;> cases h2 : x.bits k.succ <;> simp rw [h0] simp_rw [hsucc] let W : Fin (L + 1) → ℚ := fun j => (L + 1 : ℚ) * (L + 2 : ℚ) - (j.val : ℚ) * ((j.val : ℚ) + 1) have hW0 : W 0 = 2 * (((L + 1) * (L + 2) / 2 : ℕ) : ℚ) := by dsimp only [W] have heven : 2 ∣ (L + 1) * (L + 2) := Nat.even_mul_succ_self (L + 1) |>.two_dvd have hmul : 2 * ((L + 1) * (L + 2) / 2) = (L + 1) * (L + 2) := Nat.mul_div_cancel' heven have hq : (2 : ℚ) * (((L + 1) * (L + 2) / 2 : ℕ) : ℚ) = ((L + 1 : ℚ) * (L + 2 : ℚ)) := by exact_mod_cast hmul simp [hq] have hWsucc : ∀ k : Fin L, W k.succ = (L + 1 : ℚ) * (L + 2 : ℚ) - ((k.val : ℚ) + 1) * ((k.val : ℚ) + 2) := by intro k; simp only [W, Fin.val_succ]; push_cast; ring have hWdiff : ∀ k : Fin L, W k.castSucc - W k.succ = 2 * ((k.val : ℚ) + 1) := by intro k; simp only [W, Fin.val_castSucc, Fin.val_succ]; push_cast; ring have hWlast : W (Fin.last L) = 2 * ((L : ℚ) + 1) := by simp only [W, Fin.val_last]; ring have hrk_q : 2 * (rk x : ℚ) = ∑ j : Fin (L + 1), 2 * ((j.val : ℚ) + 1) * c j := by unfold rk c push_cast [Finset.mul_sum] refine Finset.sum_congr rfl fun j _ => ?_ cases x.bits j <;> simp rw [hrk_q, Fin.sum_univ_castSucc] simp only [Fin.val_castSucc] simp_rw [← hWsucc, ← hWdiff, mul_sub, Finset.sum_sub_distrib, sub_mul] have hreidx : (∑ k : Fin L, W k.castSucc * c k.castSucc) + W (Fin.last L) * c (Fin.last L) = W 0 * c 0 + ∑ k : Fin L, W k.succ * c k.succ := by rw [← Fin.sum_univ_castSucc (f := fun j : Fin (L + 1) => W j * c j), Fin.sum_univ_succ (f := fun j : Fin (L + 1) => W j * c j)] have hlast_eq : 2 * (((Fin.last L).val : ℚ) + 1) * c (Fin.last L) = W (Fin.last L) * c (Fin.last L) := by rw [hWlast, Fin.val_last] rw [hlast_eq, Finset.sum_sub_distrib] have hA : (∑ k : Fin L, W k.castSucc * c k.castSucc) - (∑ k : Fin L, W k.succ * c k.castSucc) + W (Fin.last L) * c (Fin.last L) = W 0 * c 0 + (∑ k : Fin L, W k.succ * c k.succ) - (∑ k : Fin L, W k.succ * c k.castSucc) := by linarith [hreidx] have hL2 : L + 1 + 1 = L + 2 := by omega rw [hA, hW0, hL2] ring /-- **Proctor's `sl₂(ℚ)`-Poset Structure on Stanley's Poset `M(L)`**. -/ def toSl2Poset (L : ℕ) : Sl2Poset (StanleyPoset L) where N := L * (L + 1) / 2 rk := rk rk_le := rk_le dual x := ⟨fun i => !(x.bits i)⟩ dual_dual x := by ext i; simp rk_dual := rk_compl X := { toFun := fun f y => ∑ i : Fin L, match downMove i y with | some x => f x | none => 0 map_add' := fun f g => by ext y; simp only [Pi.add_apply, ← Finset.sum_add_distrib] refine Finset.sum_congr rfl fun i _ => ?_ cases downMove i y <;> simp map_smul' := fun c f => by ext y; simp only [Pi.smul_apply, smul_eq_mul, RingHom.id_apply, Finset.mul_sum] refine Finset.sum_congr rfl fun i _ => ?_ cases downMove i y <;> simp } Y := { toFun := fun f x => ∑ i : Fin L, match upMove i x with | some y => proctorWeight L i * f y | none => 0 map_add' := fun f g => by ext x; simp only [Pi.add_apply, ← Finset.sum_add_distrib] refine Finset.sum_congr rfl fun i _ => ?_ cases upMove i x <;> simp [mul_add] map_smul' := fun c f => by ext x; simp only [Pi.smul_apply, smul_eq_mul, RingHom.id_apply, Finset.mul_sum] refine Finset.sum_congr rfl fun i _ => ?_ cases upMove i x <;> simp; ring } X_order := by intro x y hne dsimp only [LinearMap.coe_mk, AddHom.coe_mk] at hne obtain ⟨i, _, hi⟩ := Finset.exists_ne_zero_of_sum_ne_zero hne cases hdm : downMove i y with | none => simp [hdm] at hi | some x' => simp only [hdm] at hi have hxx' : x' = x := by by_contra h exact hi (Pi.single_eq_of_ne h 1) subst hxx' exact upMove_lt_and_rk i x' y ((downMove_eq_some_iff i x' y).mp hdm) Y_rank := by intro y x hne dsimp only [LinearMap.coe_mk, AddHom.coe_mk] at hne obtain ⟨i, _, hi⟩ := Finset.exists_ne_zero_of_sum_ne_zero hne cases hum : upMove i x with | none => simp [hum] at hi | some y' => simp only [hum] at hi have hyy' : y' = y := by by_contra h rw [Pi.single_eq_of_ne h 1, mul_zero] at hi exact hi rfl subst hyy' exact (upMove_lt_and_rk i x y' hum).2.symm sl2_comm := by intro x ext z dsimp only [LinearMap.coe_mk, AddHom.coe_mk, Pi.sub_apply, Pi.smul_apply, smul_eq_mul] -- Expand XY(e_x)(z) and YX(e_x)(z) as double sums over `(i, j) : Fin L × Fin L` have hXY : (∑ j : Fin L, match downMove j z with | some y => ∑ i : Fin L, match upMove i y with | some x' => proctorWeight L i * (Pi.single x (1 : ℚ) : StanleyPoset L → ℚ) x' | none => 0 | none => 0) = ∑ i : Fin L, ∑ j : Fin L, if (∃ y, downMove i x = some y ∧ upMove j y = some z) then proctorWeight L i else 0 := by have hstep : ∀ j : Fin L, (match downMove j z with | some y => ∑ i : Fin L, match upMove i y with | some x' => proctorWeight L i * (Pi.single x (1 : ℚ) : StanleyPoset L → ℚ) x' | none => 0 | none => 0) = ∑ i : Fin L, if (∃ y, downMove i x = some y ∧ upMove j y = some z) then proctorWeight L i else 0 := by intro j cases hdz : downMove j z with | none => symm refine Finset.sum_eq_zero fun i _ => ?_ rw [if_neg] rintro ⟨y, _, huy⟩ have := (downMove_eq_some_iff j y z).mpr huy rw [hdz] at this; simp at this | some y => refine Finset.sum_congr rfl fun i _ => ?_ cases huy : upMove i y with | none => symm; rw [if_neg] rintro ⟨y', hdx, huy'⟩ have hy' : y' = y := (Option.some.inj (hdz.symm.trans ((downMove_eq_some_iff j y' z).mpr huy'))).symm subst hy' have := (downMove_eq_some_iff i y' x).mp hdx rw [huy] at this; simp at this | some x' => by_cases hxx' : x' = x · subst hxx' simp only [Pi.single_eq_same, mul_one] rw [if_pos ⟨y, (downMove_eq_some_iff i y x').mpr huy, (downMove_eq_some_iff j y z).mp hdz⟩] · simp only [Pi.single_eq_of_ne hxx', mul_zero] rw [if_neg] rintro ⟨y', hdx, huy'⟩ have hy' : y' = y := (Option.some.inj (hdz.symm.trans ((downMove_eq_some_iff j y' z).mpr huy'))).symm subst hy' have := (downMove_eq_some_iff i y' x).mp hdx rw [huy] at this exact hxx' (Option.some.inj this) simp_rw [hstep] exact Finset.sum_comm have hYX : (∑ i : Fin L, match upMove i z with | some y => proctorWeight L i * ∑ j : Fin L, match downMove j y with | some x' => (Pi.single x (1 : ℚ) : StanleyPoset L → ℚ) x' | none => 0 | none => 0) = ∑ i : Fin L, ∑ j : Fin L, if (∃ y, upMove j x = some y ∧ downMove i y = some z) then proctorWeight L i else 0 := by refine Finset.sum_congr rfl fun i _ => ?_ cases huz : upMove i z with | none => symm refine Finset.sum_eq_zero fun j _ => ?_ rw [if_neg] rintro ⟨y, _, hdy⟩ have := (downMove_eq_some_iff i z y).mp hdy rw [huz] at this; simp at this | some y => dsimp only rw [Finset.mul_sum] refine Finset.sum_congr rfl fun j _ => ?_ cases hdy : downMove j y with | none => simp only [mul_zero] symm; rw [if_neg] rintro ⟨y', hux, hdy'⟩ have hy' : y' = y := Option.some.inj (((downMove_eq_some_iff i z y').mp hdy').symm.trans huz) subst hy' have := (downMove_eq_some_iff j x y').mpr hux rw [hdy] at this; simp at this | some x' => by_cases hxx' : x' = x · subst hxx' simp only [Pi.single_eq_same, mul_one] rw [if_pos ⟨y, (downMove_eq_some_iff j x' y).mp hdy, (downMove_eq_some_iff i z y).mpr huz⟩] · simp only [Pi.single_eq_of_ne hxx', mul_zero] rw [if_neg] rintro ⟨y', hux, hdy'⟩ have hy' : y' = y := Option.some.inj (((downMove_eq_some_iff i z y').mp hdy').symm.trans huz) subst hy' have := (downMove_eq_some_iff j x y').mpr hux rw [hdy] at this exact hxx' (Option.some.inj this) rw [hXY, hYX, ← Finset.sum_sub_distrib] have hinner : ∀ i : Fin L, (∑ j : Fin L, if (∃ y, downMove i x = some y ∧ upMove j y = some z) then proctorWeight L i else 0) - (∑ j : Fin L, if (∃ y, upMove j x = some y ∧ downMove i y = some z) then proctorWeight L i else 0) = if z = x then proctorWeight L i * ((if (downMove i x).isSome then (1 : ℚ) else 0) - (if (upMove i x).isSome then (1 : ℚ) else 0)) else 0 := by intro i rw [← Finset.sum_sub_distrib] have hoff : ∀ j : Fin L, j ≠ i → (if (∃ y, downMove i x = some y ∧ upMove j y = some z) then proctorWeight L i else 0) - (if (∃ y, upMove j x = some y ∧ downMove i y = some z) then proctorWeight L i else 0) = 0 := by intro j hji simp only [down_up_iff_up_down hji.symm x z, sub_self] rw [Finset.sum_eq_single i (fun j _ hji => hoff j hji) (fun h => absurd (Finset.mem_univ i) h)] have hdiag1 : (∃ y, downMove i x = some y ∧ upMove i y = some z) ↔ (z = x ∧ (downMove i x).isSome) := by constructor · rintro ⟨y, hdx, huy⟩ have := (downMove_eq_some_iff i y x).mp hdx rw [this] at huy exact ⟨(Option.some.inj huy).symm, by simp [hdx]⟩ · rintro ⟨rfl, hs⟩ cases hdx : downMove i z with | none => simp [hdx] at hs | some y => exact ⟨y, rfl, (downMove_eq_some_iff i y z).mp hdx⟩ have hdiag2 : (∃ y, upMove i x = some y ∧ downMove i y = some z) ↔ (z = x ∧ (upMove i x).isSome) := by constructor · rintro ⟨y, hux, hdy⟩ have := (downMove_eq_some_iff i x y).mpr hux rw [this] at hdy exact ⟨(Option.some.inj hdy).symm, by simp [hux]⟩ · rintro ⟨rfl, hs⟩ cases hux : upMove i z with | none => simp [hux] at hs | some y => exact ⟨y, rfl, (downMove_eq_some_iff i z y).mpr hux⟩ simp only [hdiag1, hdiag2] by_cases hzx : z = x · subst hzx by_cases h1 : (downMove i z).isSome <;> by_cases h2 : (upMove i z).isSome <;> simp [h1, h2] · simp [hzx] simp_rw [hinner] by_cases hzx : z = x · subst hzx simp only [↓reduceIte, Pi.single_eq_same, mul_one] exact proctor_diagonal_sum z · simp [hzx] /-- Rank generating polynomial of Stanley's poset `M(L)`: `|M(L)_r| = [X^r] ∏_{j=1}^L (1 + X^j)`. -/ theorem card_rankLevel_eq_coeff (L r : ℕ) : ((toSl2Poset L).rankLevel r).card = (∏ j ∈ Finset.range L, (1 + Polynomial.X ^ (j + 1) : Polynomial ℕ)).coeff r := by induction L generalizing r with | zero => simp only [Finset.prod_range_zero, Polynomial.coeff_one] have hcard : ((toSl2Poset 0).rankLevel r).card = if r = 0 then 1 else 0 := by have huniv : (Finset.univ : Finset (StanleyPoset 0)) = {⟨Fin.elim0⟩} := by ext x; simp [StanleyPoset.ext_iff, funext_iff] simp only [Sl2Poset.rankLevel, huniv, toSl2Poset, rk] by_cases hr : r = 0 · subst hr; simp · have hne : (0 : ℕ) ≠ r := Ne.symm hr simp [hr, hne] exact hcard | succ L ih => rw [Finset.prod_range_succ, mul_add, mul_one, Polynomial.coeff_add, Polynomial.coeff_mul_X_pow'] let S0 := ((toSl2Poset (L + 1)).rankLevel r).filter (fun x => x.bits (Fin.last L) = false) let S1 := ((toSl2Poset (L + 1)).rankLevel r).filter (fun x => x.bits (Fin.last L) = true) have hdisj : Disjoint S0 S1 := by rw [Finset.disjoint_left] intro x hx0 hx1 simp only [S0, S1, Finset.mem_filter] at hx0 hx1 rw [hx0.2] at hx1; exact Bool.false_ne_true hx1.2 have hunion : (toSl2Poset (L + 1)).rankLevel r = S0 ∪ S1 := by ext x simp only [S0, S1, Finset.mem_union, Finset.mem_filter] cases x.bits (Fin.last L) <;> simp rw [hunion, Finset.card_union_of_disjoint hdisj] have hrk_mem : ∀ (M : ℕ) (x : StanleyPoset M) (s : ℕ), x ∈ (toSl2Poset M).rankLevel s ↔ rk x = s := fun M x s => Finset.mem_filter.trans (and_iff_right (Finset.mem_univ x)) have hS0 : S0.card = ((toSl2Poset L).rankLevel r).card := by refine Finset.card_bij (fun x _ => ⟨fun i => x.bits i.castSucc⟩) ?_ ?_ ?_ · intro x hx simp only [S0, Finset.mem_filter, hrk_mem] at hx ⊢ rcases hx with ⟨hrk, hlast⟩ unfold rk at hrk ⊢ rw [Fin.sum_univ_castSucc] at hrk simpa [hlast] using hrk · intro x₁ hx₁ x₂ hx₂ heq simp only [S0, Finset.mem_filter] at hx₁ hx₂ ext i refine Fin.lastCases ?_ ?_ i · rw [hx₁.2, hx₂.2] · intro j exact congrFun (congrArg StanleyPoset.bits heq) j · intro y hy refine ⟨⟨Fin.snoc y.bits false⟩, ?_, ?_⟩ · simp only [S0, Finset.mem_filter, hrk_mem] at hy ⊢ refine ⟨?_, Fin.snoc_last _ _⟩ unfold rk at hy ⊢ rw [Fin.sum_univ_castSucc] simpa [Fin.snoc_castSucc, Fin.snoc_last] using hy · ext i; simp [Fin.snoc_castSucc] have hS1 : S1.card = if L + 1 ≤ r then ((toSl2Poset L).rankLevel (r - (L + 1))).card else 0 := by by_cases hle : L + 1 ≤ r · rw [if_pos hle] refine Finset.card_bij (fun x _ => ⟨fun i => x.bits i.castSucc⟩) ?_ ?_ ?_ · intro x hx simp only [S1, Finset.mem_filter, hrk_mem] at hx ⊢ rcases hx with ⟨hrk, hlast⟩ unfold rk at hrk ⊢ rw [Fin.sum_univ_castSucc] at hrk simp only [hlast, ↓reduceIte, Fin.val_castSucc, Fin.val_last] at hrk dsimp only; omega · intro x₁ hx₁ x₂ hx₂ heq simp only [S1, Finset.mem_filter] at hx₁ hx₂ ext i refine Fin.lastCases ?_ ?_ i · rw [hx₁.2, hx₂.2] · intro j exact congrFun (congrArg StanleyPoset.bits heq) j · intro y hy refine ⟨⟨Fin.snoc y.bits true⟩, ?_, ?_⟩ · simp only [S1, Finset.mem_filter, hrk_mem] at hy ⊢ refine ⟨?_, Fin.snoc_last _ _⟩ unfold rk at hy ⊢ rw [Fin.sum_univ_castSucc] simp only [Fin.snoc_castSucc, Fin.snoc_last, ↓reduceIte, Fin.val_castSucc, Fin.val_last] omega · ext i; simp [Fin.snoc_castSucc] · rw [if_neg hle, Finset.card_eq_zero, Finset.eq_empty_iff_forall_notMem] intro x hx simp only [S1, Finset.mem_filter, hrk_mem] at hx rcases hx with ⟨hrk, hlast⟩ unfold rk at hrk rw [Fin.sum_univ_castSucc] at hrk simp only [hlast, ↓reduceIte, Fin.val_last] at hrk omega rw [hS0, hS1, ih r] by_cases hle : L + 1 ≤ r · simp [hle, ih (r - (L + 1))] · simp [hle] end StanleyPoset /-! ## Section 3: Conjugate-Partition Products & Exact Multiplicity-Partition Littlewood–Offord Theorem -/ /-- The trivial 1-element `Sl2Poset` on `PUnit`. -/ def unitSl2 : Sl2Poset PUnit where N := 0 rk _ := 0 rk_le _ := le_rfl dual _ := PUnit.unit dual_dual _ := rfl rk_dual _ := rfl X := 0 Y := 0 X_order _ _ h := absurd rfl h Y_rank _ _ h := absurd rfl h sl2_comm _ := by ext _; simp /-- Inductive Cartesian product of Stanley posets `M(L₁) × ⋯ × M(L_m)`. -/ def StanleyProd : List ℕ → Type | [] => PUnit | L :: Ls => StanleyPoset L × StanleyProd Ls instance stanleyProdDecEq : (Ls : List ℕ) → DecidableEq (StanleyProd Ls) | [] => inferInstanceAs (DecidableEq PUnit) | L :: Ls => @instDecidableEqProd (StanleyPoset L) (StanleyProd Ls) _ (stanleyProdDecEq Ls) instance stanleyProdFintype : (Ls : List ℕ) → Fintype (StanleyProd Ls) | [] => inferInstanceAs (Fintype PUnit) | L :: Ls => @instFintypeProd (StanleyPoset L) (StanleyProd Ls) _ (stanleyProdFintype Ls) instance stanleyProdPartialOrder : (Ls : List ℕ) → PartialOrder (StanleyProd Ls) | [] => inferInstanceAs (PartialOrder PUnit) | L :: Ls => @Prod.instPartialOrder (StanleyPoset L) (StanleyProd Ls) _ (stanleyProdPartialOrder Ls) /-- `Sl2Poset` structure on `StanleyProd Ls = M(L₁) × ⋯ × M(L_m)`. -/ def stanleyProdSl2 : (Ls : List ℕ) → Sl2Poset (StanleyProd Ls) | [] => unitSl2 | L :: Ls => (StanleyPoset.toSl2Poset L).prod (stanleyProdSl2 Ls) /-- Rank generating polynomial of `StanleyProd Ls`. -/ noncomputable def stanleyProdPoly : List ℕ → Polynomial ℕ | [] => 1 | L :: Ls => (∏ j ∈ Finset.range L, (1 + Polynomial.X ^ (j + 1) : Polynomial ℕ)) * stanleyProdPoly Ls lemma stanleyProdSl2_N : ∀ Ls : List ℕ, (stanleyProdSl2 Ls).N = (Ls.map fun L => L * (L + 1) / 2).sum | [] => rfl | L :: Ls => by simp only [stanleyProdSl2, Sl2Poset.prod, StanleyPoset.toSl2Poset, List.map_cons, List.sum_cons, stanleyProdSl2_N Ls] lemma prod_rankLevel_card {P Q : Type*} [Fintype P] [DecidableEq P] [PartialOrder P] [Fintype Q] [DecidableEq Q] [PartialOrder Q] (S : Sl2Poset P) (T : Sl2Poset Q) (r : ℕ) : ((S.prod T).rankLevel r).card = ∑ a ∈ Finset.antidiagonal r, (S.rankLevel a.1).card * (T.rankLevel a.2).card := by let slice : ℕ × ℕ → Finset (P × Q) := fun a => S.rankLevel a.1 ×ˢ T.rankLevel a.2 have hmem_prod : ∀ x : P × Q, x ∈ (S.prod T).rankLevel r ↔ S.rk x.1 + T.rk x.2 = r := fun x => Finset.mem_filter.trans (and_iff_right (Finset.mem_univ x)) have hEq : (S.prod T).rankLevel r = (Finset.antidiagonal r).biUnion slice := by ext ⟨p, q⟩ constructor · intro h have hrk : S.rk p + T.rk q = r := (hmem_prod (p, q)).mp h refine Finset.mem_biUnion.mpr ⟨(S.rk p, T.rk q), Finset.mem_antidiagonal.mpr hrk, ?_⟩ simp [slice, Sl2Poset.rankLevel] · intro h rcases Finset.mem_biUnion.mp h with ⟨⟨a, b⟩, hab, hmem⟩ simp only [Finset.mem_antidiagonal] at hab simp only [slice, Finset.mem_product, Sl2Poset.rankLevel, Finset.mem_filter, Finset.mem_univ, true_and] at hmem exact (hmem_prod (p, q)).mpr (by dsimp only; omega) rw [hEq, Finset.card_biUnion] · refine Finset.sum_congr rfl fun a _ => Finset.card_product _ _ · intro a _ b _ hne simp only [Function.onFun] rw [Finset.disjoint_left] intro x hxa hxb simp only [slice, Finset.mem_product, Sl2Poset.rankLevel, Finset.mem_filter, Finset.mem_univ, true_and] at hxa hxb exact hne (Prod.ext (hxa.1.symm.trans hxb.1) (hxa.2.symm.trans hxb.2)) lemma stanleyProdSl2_rankLevel_card : ∀ (Ls : List ℕ) (r : ℕ), ((stanleyProdSl2 Ls).rankLevel r).card = (stanleyProdPoly Ls).coeff r | [], r => by simp only [stanleyProdPoly, Polynomial.coeff_one] have huniv : (Finset.univ : Finset PUnit) = {PUnit.unit} := by ext x; simp change ((Finset.univ : Finset PUnit).filter (fun _ => (0 : ℕ) = r)).card = if r = 0 then 1 else 0 rw [huniv] by_cases hr : r = 0 · subst hr; simp · have hne : (0 : ℕ) ≠ r := Ne.symm hr simp [hr, hne] | L :: Ls, r => by change (((StanleyPoset.toSl2Poset L).prod (stanleyProdSl2 Ls)).rankLevel r).card = ((∏ j ∈ Finset.range L, (1 + Polynomial.X ^ (j + 1) : Polynomial ℕ)) * stanleyProdPoly Ls).coeff r rw [prod_rankLevel_card, Polynomial.coeff_mul] refine Finset.sum_congr rfl fun a _ => ?_ rw [StanleyPoset.card_rankLevel_eq_coeff, stanleyProdSl2_rankLevel_card Ls] /-- Subset sum on `StanleyProd Ls` given weight families for each chain. -/ def stanleyProdSum {G : Type*} [AddCommMonoid G] : (Ls : List ℕ) → ((t : Fin Ls.length) → Fin (Ls.get t) → G) → StanleyProd Ls → G | [], _, _ => 0 | _ :: Ls, W, (x, xs) => StanleyPoset.subsetSum (W ⟨0, Nat.zero_lt_succ _⟩) x + stanleyProdSum Ls (fun t => W t.succ) xs lemma stanleyProdSum_mono {G : Type*} [AddCommGroup G] [LinearOrder G] [IsOrderedAddMonoid G] : ∀ (Ls : List ℕ) (W : (t : Fin Ls.length) → Fin (Ls.get t) → G) (_hpos : ∀ t i, 0 < W t i) (_hmono : ∀ t, StrictMono (W t)) {x y : StanleyProd Ls}, x ≤ y → stanleyProdSum Ls W x ≤ stanleyProdSum Ls W y | [], _, _, _, _, _, _ => le_rfl | _ :: Ls, W, hpos, hmono, (x, xs), (y, ys), hle => by rcases hle with ⟨h1, h2⟩ have ha : StanleyPoset.subsetSum (W ⟨0, Nat.zero_lt_succ _⟩) x ≤ StanleyPoset.subsetSum (W ⟨0, Nat.zero_lt_succ _⟩) y := by by_cases heq : x = y · subst heq; exact le_rfl · exact le_of_lt (StanleyPoset.subsetSum_strictMono _ (hpos ⟨0, Nat.zero_lt_succ _⟩) (hmono ⟨0, Nat.zero_lt_succ _⟩) (lt_of_le_of_ne h1 heq)) have hb := stanleyProdSum_mono Ls (fun t => W t.succ) (fun t => hpos t.succ) (fun t => hmono t.succ) h2 exact add_le_add ha hb lemma stanleyProdSum_strictMono {G : Type*} [AddCommGroup G] [LinearOrder G] [IsOrderedAddMonoid G] : ∀ (Ls : List ℕ) (W : (t : Fin Ls.length) → Fin (Ls.get t) → G) (_hpos : ∀ t i, 0 < W t i) (_hmono : ∀ t, StrictMono (W t)) {x y : StanleyProd Ls}, x < y → stanleyProdSum Ls W x < stanleyProdSum Ls W y | [], _, _, _, PUnit.unit, PUnit.unit, hlt => absurd hlt (lt_irrefl _) | L :: Ls, W, hpos, hmono, (x, xs), (y, ys), hlt => by have hlt' : ((x, xs) : StanleyPoset L × StanleyProd Ls) < (y, ys) := hlt rw [Prod.lt_iff] at hlt' rcases hlt' with ⟨h1, h2⟩ | ⟨h1, h2⟩ · have ha := StanleyPoset.subsetSum_strictMono _ (hpos ⟨0, Nat.zero_lt_succ _⟩) (hmono ⟨0, Nat.zero_lt_succ _⟩) h1 have hb := stanleyProdSum_mono Ls (fun t => W t.succ) (fun t => hpos t.succ) (fun t => hmono t.succ) h2 exact add_lt_add_of_lt_of_le ha hb · have ha : StanleyPoset.subsetSum (W ⟨0, Nat.zero_lt_succ _⟩) x ≤ StanleyPoset.subsetSum (W ⟨0, Nat.zero_lt_succ _⟩) y := by by_cases heq : x = y · subst heq; exact le_rfl · exact le_of_lt (StanleyPoset.subsetSum_strictMono _ (hpos ⟨0, Nat.zero_lt_succ _⟩) (hmono ⟨0, Nat.zero_lt_succ _⟩) (lt_of_le_of_ne h1 heq)) have hb := stanleyProdSum_strictMono Ls (fun t => W t.succ) (fun t => hpos t.succ) (fun t => hmono t.succ) h2 exact add_lt_add_of_le_of_lt ha hb lemma stanleyProdSum_gap_mono {G : Type*} [AddCommGroup G] [LinearOrder G] [IsOrderedAddMonoid G] : ∀ (Ls : List ℕ) (W : (t : Fin Ls.length) → Fin (Ls.get t) → G) {r₀ : G} (_hr₀ : 0 ≤ r₀) (_hmin : ∀ t i, r₀ ≤ W t i) (_hgap : ∀ t (i : Fin (Ls.get t)) (hi : i.val + 1 < Ls.get t), r₀ ≤ W t ⟨i.val + 1, hi⟩ - W t i) {x y : StanleyProd Ls}, x < y → r₀ ≤ stanleyProdSum Ls W y - stanleyProdSum Ls W x | [], _, _, _, _, _, PUnit.unit, PUnit.unit, hlt => absurd hlt (lt_irrefl _) | L :: Ls, W, r₀, hr₀, hmin, hgap, (x, xs), (y, ys), hlt => by have hmono_one : ∀ (u v : StanleyPoset L), u ≤ v → 0 ≤ StanleyPoset.subsetSum (W ⟨0, Nat.zero_lt_succ _⟩) v - StanleyPoset.subsetSum (W ⟨0, Nat.zero_lt_succ _⟩) u := by intro u v huv by_cases heq : u = v · subst heq; simp · exact le_trans hr₀ (StanleyPoset.subsetSum_gap_mono _ hr₀ (hmin ⟨0, Nat.zero_lt_succ _⟩) (hgap ⟨0, Nat.zero_lt_succ _⟩) (lt_of_le_of_ne huv heq)) have hmono_rest : ∀ (us vs : StanleyProd Ls), us ≤ vs → 0 ≤ stanleyProdSum Ls (fun t => W t.succ) vs - stanleyProdSum Ls (fun t => W t.succ) us := by intro us vs huv by_cases heq : us = vs · subst heq; simp · exact le_trans hr₀ (stanleyProdSum_gap_mono Ls (fun t => W t.succ) hr₀ (fun t => hmin t.succ) (fun t => hgap t.succ) (lt_of_le_of_ne huv heq)) have hsub_eq : stanleyProdSum (L :: Ls) W (y, ys) - stanleyProdSum (L :: Ls) W (x, xs) = (StanleyPoset.subsetSum (W ⟨0, Nat.zero_lt_succ _⟩) y - StanleyPoset.subsetSum (W ⟨0, Nat.zero_lt_succ _⟩) x) + (stanleyProdSum Ls (fun t => W t.succ) ys - stanleyProdSum Ls (fun t => W t.succ) xs) := by simp only [stanleyProdSum]; abel have hlt' : ((x, xs) : StanleyPoset L × StanleyProd Ls) < (y, ys) := hlt rw [Prod.lt_iff] at hlt' rw [hsub_eq] rcases hlt' with ⟨h1, h2⟩ | ⟨h1, h2⟩ · exact le_add_of_le_of_nonneg (StanleyPoset.subsetSum_gap_mono _ hr₀ (hmin ⟨0, Nat.zero_lt_succ _⟩) (hgap ⟨0, Nat.zero_lt_succ _⟩) h1) (hmono_rest xs ys h2) · exact le_add_of_nonneg_of_le (hmono_one x y h1) (stanleyProdSum_gap_mono Ls (fun t => W t.succ) hr₀ (fun t => hmin t.succ) (fun t => hgap t.succ) h2) /-- A valid integer partition: antitone list of positive natural numbers. -/ def IsPartition (lam : List ℕ) : Prop := lam.Pairwise (· ≥ ·) ∧ ∀ m ∈ lam, 0 < m /-- Canonical generating polynomial `P_λ(X) = ∏_{j=1}^d (1 + X^j)^{λ_j}`. -/ noncomputable def canonicalPoly (lam : List ℕ) : Polynomial ℕ := ∏ j : Fin lam.length, (1 + Polynomial.X ^ (j.val + 1) : Polynomial ℕ) ^ (lam.get j) /-- Canonical degree `N(λ) = ∑_{j=1}^d j * λ_j`. -/ def canonicalDeg (lam : List ℕ) : ℕ := ∑ j : Fin lam.length, (j.val + 1) * lam.get j /-- Sum of the `k` central coefficients of a degree-`D` polynomial `p`. -/ def centralSum (p : Polynomial ℕ) (D k : ℕ) : ℕ := ∑ j : Fin k, if j.val ≤ (D + (k - 1)) / 2 then p.coeff ((D + (k - 1)) / 2 - j.val) else 0 /-- Exact canonical `k`-point Littlewood–Offord bound `M_k*(λ)`. -/ noncomputable def M_star (lam : List ℕ) (k : ℕ) : ℕ := centralSum (canonicalPoly lam) (canonicalDeg lam) k /-- Conjugate partition `λ'`: length `λ₁`, with `t`-th entry `|{j : t < λ_j}|`. -/ def conjugate (lam : List ℕ) : List ℕ := List.ofFn fun t : Fin (lam.headD 0) => (lam.filter (fun m => decide (t.val < m))).length lemma conjugate_length (lam : List ℕ) : (conjugate lam).length = lam.headD 0 := List.length_ofFn lemma IsPartition.antitone {lam : List ℕ} (h : IsPartition lam) {i j : Fin lam.length} (hij : i ≤ j) : lam.get j ≤ lam.get i := by rcases eq_or_lt_of_le hij with rfl | hlt · exact le_rfl · exact List.pairwise_iff_get.mp h.1 i j hlt lemma IsPartition.le_headD {lam : List ℕ} (h : IsPartition lam) (j : Fin lam.length) : lam.get j ≤ lam.headD 0 := by cases lam with | nil => exact Fin.elim0 j | cons a rest => simpa [List.headD] using h.antitone (i := ⟨0, Nat.zero_lt_succ _⟩) (j := j) (Nat.zero_le _) lemma conjugate_get_eq_card {lam : List ℕ} (t : Fin (lam.headD 0)) : (conjugate lam).get ⟨t.val, by rw [conjugate_length]; exact t.isLt⟩ = (Finset.univ.filter (fun j : Fin lam.length => t.val < lam.get j)).card := by simp only [conjugate, List.get_eq_getElem, List.getElem_ofFn] have hlen : ∀ (l : List ℕ) (p : ℕ → Bool), (l.filter p).length = (Finset.univ.filter (fun j : Fin l.length => p (l.get j) = true)).card := by intro l p induction l with | nil => simp | cons a rest ih => rw [List.filter_cons] have hcard : (Finset.univ.filter (fun j : Fin (a :: rest).length => p ((a :: rest).get j) = true)).card = (if p a = true then 1 else 0) + (Finset.univ.filter (fun j : Fin rest.length => p (rest.get j) = true)).card := by rw [Finset.card_filter, Finset.card_filter] exact Fin.sum_univ_succ (fun j : Fin (rest.length + 1) => if p ((a :: rest).get j) = true then 1 else 0) rw [hcard, ← ih] cases hpa : p a <;> simp [add_comm] simpa using hlen lam (fun m => decide (t.val < m)) lemma IsPartition.lt_conjugate_iff {lam : List ℕ} (h : IsPartition lam) (t : Fin (lam.headD 0)) (j : Fin lam.length) : j.val < (conjugate lam).get ⟨t.val, by rw [conjugate_length]; exact t.isLt⟩ ↔ t.val < lam.get j := by rw [conjugate_get_eq_card t] let S : Finset (Fin lam.length) := Finset.univ.filter (fun i => t.val < lam.get i) have hdown : ∀ a b : Fin lam.length, a ≤ b → b ∈ S → a ∈ S := by intro a b hab hb simp only [S, Finset.mem_filter, Finset.mem_univ, true_and] at hb ⊢ exact lt_of_lt_of_le hb (h.antitone hab) constructor · intro hlt change j.val < S.card at hlt by_contra hnot have hsub : S ⊆ Finset.univ.filter (fun i : Fin lam.length => i.val < j.val) := by intro i hi simp only [Finset.mem_filter, Finset.mem_univ, true_and] by_contra hge exact hnot (Finset.mem_filter.mp (hdown j i (by omega) hi)).2 have hcard_le := Finset.card_le_card hsub have hlt_card : (Finset.univ.filter (fun i : Fin lam.length => i.val < j.val)).card = j.val := by have : (Finset.univ.filter (fun i : Fin lam.length => i.val < j.val)).card = (Finset.range j.val).card := by refine Finset.card_bij (fun i _ => i.val) ?_ ?_ ?_ · intro i hi; simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hi exact Finset.mem_range.mpr hi · intro _ _ _ _ heq; exact Fin.ext heq · intro k hk have hkj : k < j.val := Finset.mem_range.mp hk exact ⟨⟨k, lt_trans hkj j.isLt⟩, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hkj⟩, rfl⟩ rw [this, Finset.card_range] omega · intro hjS change j.val < S.card have hsub : Finset.univ.filter (fun i : Fin lam.length => i.val ≤ j.val) ⊆ S := by intro i hi simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hi exact hdown i j hi (Finset.mem_filter.mpr ⟨Finset.mem_univ j, hjS⟩) have hcard_le := Finset.card_le_card hsub have hle_card : (Finset.univ.filter (fun i : Fin lam.length => i.val ≤ j.val)).card = j.val + 1 := by have : (Finset.univ.filter (fun i : Fin lam.length => i.val ≤ j.val)).card = (Finset.range (j.val + 1)).card := by refine Finset.card_bij (fun i _ => i.val) ?_ ?_ ?_ · intro i hi; simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hi exact Finset.mem_range.mpr (by omega) · intro _ _ _ _ heq; exact Fin.ext heq · intro k hk have hkj : k < j.val + 1 := Finset.mem_range.mp hk have hkle : k ≤ j.val := by omega exact ⟨⟨k, lt_of_le_of_lt hkle j.isLt⟩, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hkle⟩, rfl⟩ rw [this, Finset.card_range] omega lemma stanleyProdPoly_eq_prod (Ls : List ℕ) : stanleyProdPoly Ls = ∏ t : Fin Ls.length, ∏ j ∈ Finset.range (Ls.get t), (1 + Polynomial.X ^ (j + 1) : Polynomial ℕ) := by induction Ls with | nil => simp [stanleyProdPoly] | cons L Ls ih => simp only [stanleyProdPoly, ih] exact (Fin.prod_univ_succ fun t : Fin (Ls.length + 1) => ∏ j ∈ Finset.range ((L :: Ls).get t), (1 + Polynomial.X ^ (j + 1) : Polynomial ℕ)).symm /-- **Conjugate Generating-Function Identity**: the rank polynomial of `∏_t M(λ'_t)` equals `∏_j (1 + X^j)^{λ_j}`. -/ theorem stanleyProdPoly_conjugate {lam : List ℕ} (h : IsPartition lam) : stanleyProdPoly (conjugate lam) = canonicalPoly lam := by rw [stanleyProdPoly_eq_prod] unfold canonicalPoly let f : Fin lam.length → Polynomial ℕ := fun j => 1 + Polynomial.X ^ (j.val + 1) have h1 : (∏ t : Fin (conjugate lam).length, ∏ j ∈ Finset.range ((conjugate lam).get t), (1 + Polynomial.X ^ (j + 1) : Polynomial ℕ)) = ∏ t : Fin (lam.headD 0), ∏ j : Fin lam.length, if t.val < lam.get j then f j else 1 := by have hlen := conjugate_length lam refine Finset.prod_bij (fun t _ => (⟨t.val, by omega⟩ : Fin (lam.headD 0))) (fun _ _ => Finset.mem_univ _) (fun _ _ _ _ heq => Fin.ext (by simpa using congrArg Fin.val heq)) (fun t _ => ⟨⟨t.val, by omega⟩, Finset.mem_univ _, rfl⟩) ?_ intro t _ rw [← Finset.prod_filter] refine Finset.prod_bij (fun j hj => ⟨j, by have hjlt : j < (conjugate lam).get t := Finset.mem_range.mp hj have hc := conjugate_get_eq_card (lam := lam) ⟨t.val, by omega⟩ have hle := Finset.card_le_univ (Finset.univ.filter fun j : Fin lam.length => t.val < lam.get j) simp only [Fintype.card_fin] at hle have hteq : (conjugate lam).get t = (conjugate lam).get ⟨t.val, t.isLt⟩ := rfl dsimp only at hc; omega⟩) ?_ ?_ ?_ ?_ · intro j hj simp only [Finset.mem_filter, Finset.mem_univ, true_and] have hjlt : j < (conjugate lam).get ⟨t.val, t.isLt⟩ := Finset.mem_range.mp hj exact (h.lt_conjugate_iff ⟨t.val, by omega⟩ _).mp hjlt · intro _ _ _ _ heq; exact congrArg Fin.val heq · intro j hj simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hj have hlt := (h.lt_conjugate_iff ⟨t.val, by omega⟩ j).mpr hj exact ⟨j.val, Finset.mem_range.mpr hlt, Fin.ext rfl⟩ · intro _ _; rfl have h2 : (∏ j : Fin lam.length, (f j) ^ (lam.get j)) = ∏ j : Fin lam.length, ∏ t : Fin (lam.headD 0), if t.val < lam.get j then f j else 1 := by refine Finset.prod_congr rfl fun j _ => ?_ rw [← Finset.prod_filter, Finset.prod_const] congr 1 have hle := h.le_headD j have : (Finset.univ.filter (fun t : Fin (lam.headD 0) => t.val < lam.get j)).card = (Finset.range (lam.get j)).card := by refine Finset.card_bij (fun t _ => t.val) ?_ ?_ ?_ · intro t ht; simp only [Finset.mem_filter, Finset.mem_univ, true_and] at ht exact Finset.mem_range.mpr ht · intro _ _ _ _ heq; exact Fin.ext heq · intro k hk have hkl : k < lam.get j := Finset.mem_range.mp hk exact ⟨⟨k, lt_of_lt_of_le hkl hle⟩, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hkl⟩, rfl⟩ rw [this, Finset.card_range] rw [h1, Finset.prod_comm] exact h2.symm /-- Conjugate degree identity: `(stanleyProdSl2 (conjugate lam)).N = canonicalDeg lam`. -/ theorem stanleyProdSl2_N_conjugate {lam : List ℕ} (h : IsPartition lam) : (stanleyProdSl2 (conjugate lam)).N = canonicalDeg lam := by rw [stanleyProdSl2_N] unfold canonicalDeg have hsum_list : ∀ Ls : List ℕ, (Ls.map fun L => L * (L + 1) / 2).sum = ∑ t : Fin Ls.length, ∑ j ∈ Finset.range (Ls.get t), (j + 1) := by intro Ls induction Ls with | nil => simp | cons L Ls ih => simp only [List.map_cons, List.sum_cons, ih] have htri : L * (L + 1) / 2 = ∑ j ∈ Finset.range L, (j + 1) := by rw [← StanleyPoset.sum_fin_succ_eq L] exact Fin.sum_univ_eq_sum_range (fun j => j + 1) L rw [htri] exact (Fin.sum_univ_succ fun t : Fin (Ls.length + 1) => ∑ j ∈ Finset.range ((L :: Ls).get t), (j + 1)).symm rw [hsum_list] have h1 : (∑ t : Fin (conjugate lam).length, ∑ j ∈ Finset.range ((conjugate lam).get t), (j + 1)) = ∑ t : Fin (lam.headD 0), ∑ j : Fin lam.length, if t.val < lam.get j then j.val + 1 else 0 := by have hlen := conjugate_length lam refine Finset.sum_bij (fun t _ => (⟨t.val, by omega⟩ : Fin (lam.headD 0))) (fun _ _ => Finset.mem_univ _) (fun _ _ _ _ heq => Fin.ext (by simpa using congrArg Fin.val heq)) (fun t _ => ⟨⟨t.val, by omega⟩, Finset.mem_univ _, rfl⟩) ?_ intro t _ rw [← Finset.sum_filter] refine Finset.sum_bij (fun j hj => ⟨j, by have hjlt : j < (conjugate lam).get t := Finset.mem_range.mp hj have hc := conjugate_get_eq_card (lam := lam) ⟨t.val, by omega⟩ have hle := Finset.card_le_univ (Finset.univ.filter fun j : Fin lam.length => t.val < lam.get j) simp only [Fintype.card_fin] at hle have hteq : (conjugate lam).get t = (conjugate lam).get ⟨t.val, t.isLt⟩ := rfl dsimp only at hc; omega⟩) ?_ ?_ ?_ ?_ · intro j hj simp only [Finset.mem_filter, Finset.mem_univ, true_and] have hjlt : j < (conjugate lam).get ⟨t.val, t.isLt⟩ := Finset.mem_range.mp hj exact (h.lt_conjugate_iff ⟨t.val, by omega⟩ _).mp hjlt · intro _ _ _ _ heq; exact congrArg Fin.val heq · intro j hj simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hj have hlt := (h.lt_conjugate_iff ⟨t.val, by omega⟩ j).mpr hj exact ⟨j.val, Finset.mem_range.mpr hlt, Fin.ext rfl⟩ · intro _ _; rfl have h2 : (∑ j : Fin lam.length, (j.val + 1) * lam.get j) = ∑ j : Fin lam.length, ∑ t : Fin (lam.headD 0), if t.val < lam.get j then j.val + 1 else 0 := by refine Finset.sum_congr rfl fun j _ => ?_ rw [← Finset.sum_filter, Finset.sum_const, smul_eq_mul, mul_comm] congr 1 have hle := h.le_headD j have : (Finset.univ.filter (fun t : Fin (lam.headD 0) => t.val < lam.get j)).card = (Finset.range (lam.get j)).card := by refine Finset.card_bij (fun t _ => t.val) ?_ ?_ ?_ · intro t ht; simp only [Finset.mem_filter, Finset.mem_univ, true_and] at ht exact Finset.mem_range.mpr ht · intro _ _ _ _ heq; exact Fin.ext heq · intro k hk have hkl : k < lam.get j := Finset.mem_range.mp hk exact ⟨⟨k, lt_of_lt_of_le hkl hle⟩, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hkl⟩, rfl⟩ rw [this, Finset.card_range] rw [h1, Finset.sum_comm] exact h2.symm /-- Signed Rademacher sum `∑ i, (if ε i then v i else -v i)` in any additive group `E`. -/ def rademacherSum {n : ℕ} {E : Type*} [AddCommGroup E] (v : Fin n → E) (ε : Fin n → Bool) : E := ∑ i : Fin n, if ε i then v i else -v i /-- Subset sum `∑ i, (if ε i then v i else 0)` in any additive monoid `E`. -/ def bitSubsetSum {n : ℕ} {E : Type*} [AddCommMonoid E] (v : Fin n → E) (ε : Fin n → Bool) : E := ∑ i : Fin n, if ε i then v i else 0 /-- Signed-multiplicity partition witness for nonzero elements `v : Fin n → E`: equivalence classes under `v i = ± v j` have descending sizes `lam`. -/ structure SignedPartition {n : ℕ} {E : Type*} [AddCommGroup E] (v : Fin n → E) (lam : List ℕ) where isPart : IsPartition lam cls : Fin n → Fin lam.length card_fiber : ∀ c : Fin lam.length, (Finset.univ.filter fun i => cls i = c).card = lam.get c same_cls : ∀ i j, cls i = cls j → v i = v j ∨ v i = -v j diff_cls : ∀ i j, cls i ≠ cls j → v i ≠ v j ∧ v i ≠ -v j /-- Equivalences between `(Σ t, Fin (Ls.get t)) → Bool` and `StanleyProd Ls`. -/ def equivStanleyProd : (Ls : List ℕ) → ((Σ t : Fin Ls.length, Fin (Ls.get t)) → Bool) ≃ StanleyProd Ls | [] => { toFun := fun _ => PUnit.unit invFun := fun _ p => Fin.elim0 p.1 left_inv := fun f => by ext ⟨t, _⟩; exact Fin.elim0 t right_inv := fun u => by cases u; rfl } | L :: Ls => { toFun := fun f => (⟨fun i => f ⟨⟨0, Nat.zero_lt_succ _⟩, i⟩⟩, equivStanleyProd Ls (fun p => f ⟨p.1.succ, p.2⟩)) invFun := fun ⟨x, xs⟩ ⟨t, i⟩ => Fin.cases (motive := fun t => Fin ((L :: Ls).get t) → Bool) (fun j => x.bits j) (fun t' j => (equivStanleyProd Ls).symm xs ⟨t', j⟩) t i left_inv := fun f => by ext ⟨t, i⟩ refine Fin.cases ?_ ?_ t i · intro j; rfl · intro t' j exact congrFun ((equivStanleyProd Ls).left_inv (fun p => f ⟨p.1.succ, p.2⟩)) ⟨t', j⟩ right_inv := fun ⟨x, xs⟩ => Prod.ext rfl ((equivStanleyProd Ls).right_inv xs) } lemma bitSubsetSum_equivStanleyProd {G : Type*} [AddCommMonoid G] : ∀ (Ls : List ℕ) (W : (t : Fin Ls.length) → Fin (Ls.get t) → G) (f : (Σ t : Fin Ls.length, Fin (Ls.get t)) → Bool), (∑ p : (Σ t : Fin Ls.length, Fin (Ls.get t)), if f p then W p.1 p.2 else 0) = stanleyProdSum Ls W (equivStanleyProd Ls f) | [], _, _ => by simp [stanleyProdSum] | L :: Ls, W, f => by rw [Fintype.sum_sigma] dsimp only let g : Fin (Ls.length + 1) → G := fun t => ∑ i : Fin ((L :: Ls).get t), if f ⟨t, i⟩ then W t i else 0 change (∑ t : Fin (Ls.length + 1), g t) = stanleyProdSum (L :: Ls) W (equivStanleyProd (L :: Ls) f) rw [Fin.sum_univ_succ] simp only [g, equivStanleyProd] congr 1 have hrec := bitSubsetSum_equivStanleyProd Ls (fun t => W t.succ) (fun p => f ⟨p.1.succ, p.2⟩) rw [Fintype.sum_sigma] at hrec exact hrec /-- Conjugate chain decomposition: any `v : Fin n → G` with `SignedPartition v lam` admits a bijection `e : (Σ t, Fin ((conjugate lam)[t])) ≃ Fin n` such that within every chain `t`, `|v (e ⟨t, ·⟩)|` is strictly increasing! -/ lemma exists_conjugate_chain_decomp {n : ℕ} {G : Type*} [AddCommGroup G] [LinearOrder G] [IsOrderedAddMonoid G] {v : Fin n → G} {lam : List ℕ} (hv : ∀ i, v i ≠ 0) (sp : SignedPartition v lam) : ∃ e : (Σ t : Fin (conjugate lam).length, Fin ((conjugate lam).get t)) ≃ Fin n, (∀ t i, 0 < |v (e ⟨t, i⟩)|) ∧ (∀ t, StrictMono (fun i => |v (e ⟨t, i⟩)|)) := by classical let F : Fin lam.length → Finset (Fin n) := fun c => Finset.univ.filter (fun i => sp.cls i = c) let enumF : ∀ c : Fin lam.length, Fin (lam.get c) ≃ F c := fun c => (Fintype.equivFinOfCardEq (by rw [Fintype.card_coe]; exact sp.card_fiber c)).symm have hlen : (conjugate lam).length = lam.headD 0 := conjugate_length lam let C_t : Fin (conjugate lam).length → Finset (Fin lam.length) := fun t => Finset.univ.filter (fun c => t.val < lam.get c) have hC_card : ∀ t : Fin (conjugate lam).length, (C_t t).card = (conjugate lam).get t := by intro t have h := conjugate_get_eq_card (lam := lam) ⟨t.val, by omega⟩ exact h.symm let pick : ∀ (t : Fin (conjugate lam).length) (c : Fin lam.length), t.val < lam.get c → Fin n := fun t c htc => (enumF c ⟨t.val, htc⟩).1 have hpick_cls : ∀ t c htc, sp.cls (pick t c htc) = c := fun t c htc => (Finset.mem_filter.mp (enumF c ⟨t.val, htc⟩).2).2 have hC_lt : ∀ (t : Fin (conjugate lam).length) (c : C_t t), t.val < lam.get c.1 := fun t c => (Finset.mem_filter.mp c.2).2 have hmag_inj : ∀ (t : Fin (conjugate lam).length) (c₁ c₂ : C_t t), |v (pick t c₁.1 (hC_lt t c₁))| = |v (pick t c₂.1 (hC_lt t c₂))| → c₁ = c₂ := by intro t c₁ c₂ heq by_contra hne have hcne : c₁.1 ≠ c₂.1 := fun h => hne (Subtype.ext h) have hcls_ne : sp.cls (pick t c₁.1 (hC_lt t c₁)) ≠ sp.cls (pick t c₂.1 (hC_lt t c₂)) := by rw [hpick_cls, hpick_cls]; exact hcne have hdiff := sp.diff_cls _ _ hcls_ne rcases abs_eq_abs.mp heq with h1 | h2 · exact hdiff.1 h1 · exact hdiff.2 h2 let imgM : Fin (conjugate lam).length → Finset G := fun t => (C_t t).attach.image (fun c => |v (pick t c.1 (hC_lt t c))|) have himgM_card : ∀ t, (imgM t).card = (conjugate lam).get t := by intro t rw [Finset.card_image_of_injective _ (fun c₁ c₂ h => hmag_inj t c₁ c₂ h), Finset.card_attach, hC_card t] let sortM : ∀ t, Fin ((conjugate lam).get t) ↪o G := fun t => (imgM t).orderEmbOfFin (himgM_card t) have hex_c : ∀ (t : Fin (conjugate lam).length) (i : Fin ((conjugate lam).get t)), ∃ c : C_t t, |v (pick t c.1 (hC_lt t c))| = sortM t i := by intro t i have hmem : sortM t i ∈ imgM t := (imgM t).orderEmbOfFin_mem (himgM_card t) i rcases Finset.mem_image.mp hmem with ⟨c, _, hc⟩ exact ⟨c, hc⟩ choose cOf hcOf using hex_c let toFin : (Σ t : Fin (conjugate lam).length, Fin ((conjugate lam).get t)) → Fin n := fun p => pick p.1 (cOf p.1 p.2).1 (hC_lt p.1 (cOf p.1 p.2)) have htoFin_inj : Function.Injective toFin := by rintro ⟨t₁, i₁⟩ ⟨t₂, i₂⟩ heq have hcls : (cOf t₁ i₁).1 = (cOf t₂ i₂).1 := by have := congrArg sp.cls heq simpa [toFin, hpick_cls] using this have ht_eq : t₁ = t₂ := by have haux : ∀ (c₁ c₂ : Fin lam.length) (h₁ : t₁.val < lam.get c₁) (h₂ : t₂.val < lam.get c₂), c₁ = c₂ → (enumF c₁ ⟨t₁.val, h₁⟩).1 = (enumF c₂ ⟨t₂.val, h₂⟩).1 → t₁.val = t₂.val := by rintro c _ h₁ h₂ rfl h simpa using congrArg Fin.val ((enumF c).injective (Subtype.ext h)) exact Fin.ext (haux _ _ _ _ hcls heq) subst ht_eq have hi_eq : i₁ = i₂ := by apply (sortM t₁).injective rw [← hcOf t₁ i₁, ← hcOf t₁ i₂] exact congrArg (fun idx => |v idx|) heq subst hi_eq rfl have htoFin_surj : Function.Surjective toFin := by intro idx let c := sp.cls idx have hidxF : idx ∈ F c := Finset.mem_filter.mpr ⟨Finset.mem_univ _, rfl⟩ let k : Fin (lam.get c) := (enumF c).symm ⟨idx, hidxF⟩ have hk_lt : k.val < lam.headD 0 := lt_of_lt_of_le k.isLt (sp.isPart.le_headD c) let t : Fin (conjugate lam).length := ⟨k.val, by omega⟩ have hcCt : c ∈ C_t t := Finset.mem_filter.mpr ⟨Finset.mem_univ _, k.isLt⟩ have hpick_eq : pick t c k.isLt = idx := by have hk' : (⟨t.val, k.isLt⟩ : Fin (lam.get c)) = k := Fin.ext rfl simp [pick, hk', k] have hmem_img : |v (pick t c k.isLt)| ∈ imgM t := Finset.mem_image.mpr ⟨⟨c, hcCt⟩, Finset.mem_attach _ _, rfl⟩ have hrange : Set.range (sortM t) = (imgM t : Set G) := Finset.range_orderEmbOfFin _ _ obtain ⟨i, hi⟩ : ∃ i, sortM t i = |v (pick t c k.isLt)| := by have : |v (pick t c k.isLt)| ∈ Set.range (sortM t) := by rw [hrange]; exact hmem_img exact this have hc_eq : cOf t i = ⟨c, hcCt⟩ := hmag_inj t (cOf t i) ⟨c, hcCt⟩ ((hcOf t i).trans hi) refine ⟨⟨t, i⟩, ?_⟩ simp only [toFin, hc_eq] exact hpick_eq refine ⟨Equiv.ofBijective toFin ⟨htoFin_inj, htoFin_surj⟩, ?_, ?_⟩ · intro t i exact abs_pos.mpr (hv _) · intro t i₁ i₂ hlt change |v (toFin ⟨t, i₁⟩)| < |v (toFin ⟨t, i₂⟩)| rw [hcOf t i₁, hcOf t i₂] exact (sortM t).strictMono hlt /-- **Headline Theorem 1 (Exact Multiplicity-Partition `k`-Point Littlewood–Offord Theorem)**: For every linearly ordered abelian group `G`, every `k ≥ 1`, every nonzero weight vector `v : Fin n → G` with signed-multiplicity partition `λ`, and every target set `T : Finset G` of cardinality `≤ k`, `|{ε ∈ {±1}^n : ∑ ε_i v_i ∈ T}| ≤ M_k*(λ)`. -/ theorem exact_multiplicity_partition_littlewood_offord {n : ℕ} {G : Type*} [AddCommGroup G] [LinearOrder G] [IsOrderedAddMonoid G] (v : Fin n → G) (hv : ∀ i, v i ≠ 0) (lam : List ℕ) (sp : SignedPartition v lam) (k : ℕ) (hk : 0 < k) (T : Finset G) (hT : T.card ≤ k) : (Finset.univ.filter (fun ε : Fin n → Bool => rademacherSum v ε ∈ T)).card ≤ M_star lam k := by classical let flip : (Fin n → Bool) ≃ (Fin n → Bool) := { toFun := fun ε i => if 0 ≤ v i then ε i else !(ε i) invFun := fun ε i => if 0 ≤ v i then ε i else !(ε i) left_inv := fun ε => by ext i; dsimp; split_ifs <;> simp right_inv := fun ε => by ext i; dsimp; split_ifs <;> simp } have hflip_sum : ∀ ε : Fin n → Bool, rademacherSum v ε = rademacherSum (fun i => |v i|) (flip ε) := by intro ε unfold rademacherSum refine Finset.sum_congr rfl fun i _ => ?_ by_cases hvi : 0 ≤ v i · simp [flip, hvi, abs_of_nonneg hvi] · have hneg : v i < 0 := lt_of_not_ge hvi simp only [flip, Equiv.coe_fn_mk, hvi, ↓reduceIte, abs_of_neg hneg] cases ε i <;> simp obtain ⟨e, he_pos, he_mono⟩ := exists_conjugate_chain_decomp hv sp let Ls := conjugate lam let W : (t : Fin Ls.length) → Fin (Ls.get t) → G := fun t i => |v (e ⟨t, i⟩)| let Φ : (Fin n → Bool) ≃ StanleyProd Ls := flip.trans ((Equiv.arrowCongr e (Equiv.refl Bool)).symm.trans (equivStanleyProd Ls)) let totalAbs : G := ∑ i : Fin n, |v i| have hrad_eq : ∀ ε : Fin n → Bool, rademacherSum v ε = 2 • stanleyProdSum Ls W (Φ ε) - totalAbs := by intro ε rw [hflip_sum ε] have h2 : rademacherSum (fun i => |v i|) (flip ε) + totalAbs = 2 • bitSubsetSum (fun i => |v i|) (flip ε) := by unfold rademacherSum bitSubsetSum totalAbs rw [← Finset.sum_add_distrib, two_nsmul, ← Finset.sum_add_distrib] refine Finset.sum_congr rfl fun i _ => ?_ cases flip ε i <;> simp have hsub : bitSubsetSum (fun i => |v i|) (flip ε) = stanleyProdSum Ls W (Φ ε) := by unfold bitSubsetSum rw [← Equiv.sum_comp e (fun i => if flip ε i then |v i| else 0)] exact bitSubsetSum_equivStanleyProd Ls W (fun p => flip ε (e p)) rw [← hsub] exact eq_sub_of_add_eq h2 let S_eps := Finset.univ.filter (fun ε : Fin n → Bool => rademacherSum v ε ∈ T) let F : Finset (StanleyProd Ls) := S_eps.image Φ have hcard_eq : S_eps.card = F.card := (Finset.card_image_of_injective S_eps Φ.injective).symm rw [hcard_eq] let ordT : Fin T.card ↪o G := T.orderEmbOfFin rfl let rankInT : StanleyProd Ls → Fin k := fun x => if hx : ∃ j : Fin T.card, ordT j = 2 • stanleyProdSum Ls W x - totalAbs then ⟨(Classical.choose hx).val, lt_of_lt_of_le (Classical.choose hx).isLt hT⟩ else ⟨0, hk⟩ have hcolor : ∀ x ∈ F, ∀ y ∈ F, x < y → rankInT x < rankInT y := by intro x hx y hy hxy rcases Finset.mem_image.mp hx with ⟨ε₁, hε₁, rfl⟩ rcases Finset.mem_image.mp hy with ⟨ε₂, hε₂, rfl⟩ simp only [S_eps, Finset.mem_filter, Finset.mem_univ, true_and] at hε₁ hε₂ rw [hrad_eq ε₁] at hε₁ rw [hrad_eq ε₂] at hε₂ have hrange : Set.range ordT = (T : Set G) := Finset.range_orderEmbOfFin T rfl have hex₁ : ∃ j : Fin T.card, ordT j = 2 • stanleyProdSum Ls W (Φ ε₁) - totalAbs := by have : 2 • stanleyProdSum Ls W (Φ ε₁) - totalAbs ∈ Set.range ordT := by rw [hrange]; exact hε₁ exact this have hex₂ : ∃ j : Fin T.card, ordT j = 2 • stanleyProdSum Ls W (Φ ε₂) - totalAbs := by have : 2 • stanleyProdSum Ls W (Φ ε₂) - totalAbs ∈ Set.range ordT := by rw [hrange]; exact hε₂ exact this simp only [rankInT, hex₁, hex₂, ↓reduceDIte] have hlt_sum : stanleyProdSum Ls W (Φ ε₁) < stanleyProdSum Ls W (Φ ε₂) := stanleyProdSum_strictMono Ls W he_pos he_mono hxy have hlt_rad : 2 • stanleyProdSum Ls W (Φ ε₁) - totalAbs < 2 • stanleyProdSum Ls W (Φ ε₂) - totalAbs := by have h2lt : 2 • stanleyProdSum Ls W (Φ ε₁) < 2 • stanleyProdSum Ls W (Φ ε₂) := by rw [two_nsmul, two_nsmul]; exact add_lt_add hlt_sum hlt_sum exact sub_lt_sub_right h2lt totalAbs have hord_lt : ordT (Classical.choose hex₁) < ordT (Classical.choose hex₂) := by rw [Classical.choose_spec hex₁, Classical.choose_spec hex₂]; exact hlt_rad exact Fin.mk_lt_mk.mpr (ordT.lt_iff_lt.mp hord_lt) have hbound := (stanleyProdSl2 Ls).card_kColoring_le k hk F rankInT hcolor refine le_trans hbound (le_of_eq ?_) unfold M_star centralSum rw [stanleyProdSl2_N_conjugate sp.isPart] refine Finset.sum_congr rfl fun j _ => ?_ split_ifs with hle · rw [stanleyProdSl2_rankLevel_card, stanleyProdPoly_conjugate sp.isPart] · rfl /-- **Exact `r`-Separated Open-Interval Littlewood–Offord Theorem**: For `v : Fin n → ℝ` with `SignedPartition v lam` whose distinct magnitudes satisfy `|v i| ≥ r` and `| |v i| - |v j| | ≥ r` across distinct classes (`r > 0`), the number of Rademacher sums in any union of `k` open intervals `(c_s - r, c_s + r)` of length `2r` is at most `M_k*(λ)`. -/ theorem exact_multiplicity_partition_intervals {n : ℕ} (v : Fin n → ℝ) (lam : List ℕ) (sp : SignedPartition v lam) {r : ℝ} (hr : 0 < r) (hmin : ∀ i, r ≤ |v i|) (hsep : ∀ i j, sp.cls i ≠ sp.cls j → r ≤ abs (|v i| - |v j|)) (k : ℕ) (hk : 0 < k) (centers : Fin k → ℝ) : (Finset.univ.filter (fun ε : Fin n → Bool => ∃ s : Fin k, |rademacherSum v ε - centers s| < r)).card ≤ M_star lam k := by classical have hv : ∀ i, v i ≠ 0 := fun i h0 => by have := hmin i; rw [h0, abs_zero] at this; linarith let flip : (Fin n → Bool) ≃ (Fin n → Bool) := { toFun := fun ε i => if 0 ≤ v i then ε i else !(ε i) invFun := fun ε i => if 0 ≤ v i then ε i else !(ε i) left_inv := fun ε => by ext i; dsimp; split_ifs <;> simp right_inv := fun ε => by ext i; dsimp; split_ifs <;> simp } have hflip_sum : ∀ ε : Fin n → Bool, rademacherSum v ε = rademacherSum (fun i => |v i|) (flip ε) := by intro ε; unfold rademacherSum refine Finset.sum_congr rfl fun i _ => ?_ by_cases hvi : 0 ≤ v i · simp [flip, hvi, abs_of_nonneg hvi] · have hneg : v i < 0 := lt_of_not_ge hvi simp only [flip, Equiv.coe_fn_mk, hvi, ↓reduceIte, abs_of_neg hneg] cases ε i <;> simp obtain ⟨e, he_pos, he_mono⟩ := exists_conjugate_chain_decomp hv sp let Ls := conjugate lam let W : (t : Fin Ls.length) → Fin (Ls.get t) → ℝ := fun t i => |v (e ⟨t, i⟩)| have hW_min : ∀ t i, r ≤ W t i := fun t i => hmin (e ⟨t, i⟩) have hW_gap : ∀ t (i : Fin (Ls.get t)) (hi : i.val + 1 < Ls.get t), r ≤ W t ⟨i.val + 1, hi⟩ - W t i := by intro t i hi have hlt : W t i < W t ⟨i.val + 1, hi⟩ := he_mono t (Fin.mk_lt_mk.mpr (by omega)) have hne_cls : sp.cls (e ⟨t, ⟨i.val + 1, hi⟩⟩) ≠ sp.cls (e ⟨t, i⟩) := by intro heq rcases sp.same_cls _ _ heq with h1 | h2 · have : W t ⟨i.val + 1, hi⟩ = W t i := by simp [W, h1] linarith · have : W t ⟨i.val + 1, hi⟩ = W t i := by simp [W, h2] linarith have hgap := hsep _ _ hne_cls have habs : |W t ⟨i.val + 1, hi⟩ - W t i| = W t ⟨i.val + 1, hi⟩ - W t i := abs_of_pos (sub_pos.mpr hlt) simpa [W, habs] using hgap let Φ : (Fin n → Bool) ≃ StanleyProd Ls := flip.trans ((Equiv.arrowCongr e (Equiv.refl Bool)).symm.trans (equivStanleyProd Ls)) let totalAbs : ℝ := ∑ i : Fin n, |v i| have hrad_eq : ∀ ε : Fin n → Bool, rademacherSum v ε = 2 * stanleyProdSum Ls W (Φ ε) - totalAbs := by intro ε rw [hflip_sum ε] have h2 : rademacherSum (fun i => |v i|) (flip ε) + totalAbs = 2 * bitSubsetSum (fun i => |v i|) (flip ε) := by unfold rademacherSum bitSubsetSum totalAbs rw [← Finset.sum_add_distrib, Finset.mul_sum] refine Finset.sum_congr rfl fun i _ => ?_ cases flip ε i <;> (simp; try ring) have hsub : bitSubsetSum (fun i => |v i|) (flip ε) = stanleyProdSum Ls W (Φ ε) := by unfold bitSubsetSum rw [← Equiv.sum_comp e (fun i => if flip ε i then |v i| else 0)] exact bitSubsetSum_equivStanleyProd Ls W (fun p => flip ε (e p)) rw [← hsub]; linarith -- Sort distinct centers `C = image centers univ` into `ordC : Fin C.card ↪o ℝ` let C : Finset ℝ := Finset.univ.image centers have hC_le : C.card ≤ k := by calc C.card ≤ (Finset.univ : Finset (Fin k)).card := Finset.card_image_le _ = k := Fintype.card_fin k let ordC : Fin C.card ↪o ℝ := C.orderEmbOfFin rfl let S_eps := Finset.univ.filter (fun ε : Fin n → Bool => ∃ s : Fin k, |rademacherSum v ε - centers s| < r) let F : Finset (StanleyProd Ls) := S_eps.image Φ rw [← Finset.card_image_of_injective S_eps Φ.injective] -- Color each `x` by the smallest sorted center index `j` with `|rad(x) - ordC j| < r` let c : StanleyProd Ls → Fin k := fun x => if hx : ∃ j : Fin C.card, |(2 * stanleyProdSum Ls W x - totalAbs) - ordC j| < r then ⟨(Classical.choose hx).val, lt_of_lt_of_le (Classical.choose hx).isLt hC_le⟩ else ⟨0, hk⟩ have hcolor : ∀ x ∈ F, ∀ y ∈ F, x < y → c x < c y := by intro x hx y hy hxy rcases Finset.mem_image.mp hx with ⟨ε₁, hε₁, rfl⟩ rcases Finset.mem_image.mp hy with ⟨ε₂, hε₂, rfl⟩ simp only [S_eps, Finset.mem_filter, Finset.mem_univ, true_and] at hε₁ hε₂ have hrange : Set.range ordC = (C : Set ℝ) := Finset.range_orderEmbOfFin C rfl have hex₁ : ∃ j : Fin C.card, |(2 * stanleyProdSum Ls W (Φ ε₁) - totalAbs) - ordC j| < r := by rcases hε₁ with ⟨s, hs⟩ have hmem : centers s ∈ Set.range ordC := by rw [hrange]; exact Finset.mem_image.mpr ⟨s, Finset.mem_univ _, rfl⟩ rcases hmem with ⟨j, hj⟩ exact ⟨j, by rw [hj, ← hrad_eq ε₁]; exact hs⟩ have hex₂ : ∃ j : Fin C.card, |(2 * stanleyProdSum Ls W (Φ ε₂) - totalAbs) - ordC j| < r := by rcases hε₂ with ⟨s, hs⟩ have hmem : centers s ∈ Set.range ordC := by rw [hrange]; exact Finset.mem_image.mpr ⟨s, Finset.mem_univ _, rfl⟩ rcases hmem with ⟨j, hj⟩ exact ⟨j, by rw [hj, ← hrad_eq ε₂]; exact hs⟩ simp only [c, hex₁, hex₂, ↓reduceDIte] have hgap := stanleyProdSum_gap_mono Ls W (le_of_lt hr) hW_min hW_gap hxy have h1 := Classical.choose_spec hex₁ have h2 := Classical.choose_spec hex₂ rw [abs_lt] at h1 h2 have hord_lt : ordC (Classical.choose hex₁) < ordC (Classical.choose hex₂) := by linarith exact Fin.mk_lt_mk.mpr (ordC.lt_iff_lt.mp hord_lt) have hbound := (stanleyProdSl2 Ls).card_kColoring_le k hk F c hcolor refine le_trans hbound (le_of_eq ?_) unfold M_star centralSum rw [stanleyProdSl2_N_conjugate sp.isPart] refine Finset.sum_congr rfl fun j _ => ?_ split_ifs with hle · rw [stanleyProdSl2_rankLevel_card, stanleyProdPoly_conjugate sp.isPart] · rfl /-- **Exact Sharpness**: for every partition `lam` and every `k ≥ 1`, the canonical integer multiset `v*(λ) = (1^{λ₁}, …, d^{λ_d})` has `SignedPartition` `lam` AND attains `M_k*(λ)` with exact equality! -/ theorem canonical_multiset_sharpness (lam : List ℕ) (hlam : IsPartition lam) (k : ℕ) (_hk : 0 < k) : ∃ (n : ℕ) (v : Fin n → ℤ) (_hv : ∀ i, v i ≠ 0) (_sp : SignedPartition v lam) (T : Finset ℤ), T.card ≤ k ∧ (Finset.univ.filter (fun ε : Fin n → Bool => rademacherSum v ε ∈ T)).card = M_star lam k := by classical let Ls := conjugate lam let P_idx := Σ t : Fin Ls.length, Fin (Ls.get t) let n : ℕ := Fintype.card P_idx let eIdx : P_idx ≃ Fin n := Fintype.equivFin P_idx -- Canonical weight at `(t, j)` is `j.val + 1 : ℤ` let v : Fin n → ℤ := fun i => ((eIdx.symm i).2.val + 1 : ℤ) have hv : ∀ i, v i ≠ 0 := fun i => by dsimp [v]; positivity have hlen : Ls.length = lam.headD 0 := conjugate_length lam have hlt_len : ∀ p : P_idx, p.2.val < lam.length := fun p => by have hp := p.2.isLt have hcard := conjugate_get_eq_card (lam := lam) ⟨p.1.val, by omega⟩ have hle : (Finset.univ.filter (fun j : Fin lam.length => p.1.val < lam.get j)).card ≤ lam.length := by simpa using Finset.card_le_univ (Finset.univ.filter fun j : Fin lam.length => p.1.val < lam.get j) have hget : Ls.get p.1 = (conjugate lam).get ⟨p.1.val, p.1.isLt⟩ := rfl dsimp only at hcard; omega let cls : Fin n → Fin lam.length := fun i => ⟨(eIdx.symm i).2.val, hlt_len (eIdx.symm i)⟩ have hsp : SignedPartition v lam := { isPart := hlam cls := cls card_fiber := by intro c have hcard : (Finset.univ.filter fun i : Fin n => cls i = c).card = (Finset.univ.filter fun t : Fin (lam.headD 0) => t.val < lam.get c).card := by refine Finset.card_bij (fun i _ => (⟨(eIdx.symm i).1.val, by omega⟩ : Fin (lam.headD 0))) ?_ ?_ ?_ · intro i hi simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hi ⊢ have hcval : (eIdx.symm i).2.val = c.val := congrArg Fin.val hi have hlt : c.val < (conjugate lam).get ⟨(eIdx.symm i).1.val, (eIdx.symm i).1.isLt⟩ := by rw [← hcval]; exact (eIdx.symm i).2.isLt exact (hlam.lt_conjugate_iff ⟨(eIdx.symm i).1.val, by omega⟩ c).mp hlt · intro i₁ hi₁ i₂ hi₂ heq simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hi₁ hi₂ have ht : (eIdx.symm i₁).1 = (eIdx.symm i₂).1 := Fin.ext (by simpa using congrArg Fin.val heq) have hj : (eIdx.symm i₁).2.val = (eIdx.symm i₂).2.val := (congrArg Fin.val hi₁).trans (congrArg Fin.val hi₂).symm have hp : eIdx.symm i₁ = eIdx.symm i₂ := by rcases h1 : eIdx.symm i₁ with ⟨t₁, j₁⟩ rcases h2 : eIdx.symm i₂ with ⟨t₂, j₂⟩ rw [h1, h2] at ht hj dsimp at ht hj subst ht congr 1 exact Fin.ext hj exact eIdx.symm.injective hp · intro t ht simp only [Finset.mem_filter, Finset.mem_univ, true_and] at ht have hlt := (hlam.lt_conjugate_iff t c).mpr ht let t' : Fin Ls.length := ⟨t.val, by omega⟩ let p : P_idx := ⟨t', ⟨c.val, hlt⟩⟩ refine ⟨eIdx p, ?_, ?_⟩ · refine Finset.mem_filter.mpr ⟨Finset.mem_univ _, Fin.ext ?_⟩ dsimp only [cls]; rw [eIdx.symm_apply_apply] · ext; dsimp only; rw [eIdx.symm_apply_apply] rw [hcard] have hle := hlam.le_headD c have : (Finset.univ.filter fun t : Fin (lam.headD 0) => t.val < lam.get c).card = (Finset.range (lam.get c)).card := by refine Finset.card_bij (fun t _ => t.val) ?_ ?_ ?_ · intro t ht; simp only [Finset.mem_filter, Finset.mem_univ, true_and] at ht exact Finset.mem_range.mpr ht · intro _ _ _ _ heq; exact Fin.ext heq · intro m hm have hml : m < lam.get c := Finset.mem_range.mp hm exact ⟨⟨m, lt_of_lt_of_le hml hle⟩, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hml⟩, rfl⟩ rw [this, Finset.card_range] same_cls := fun i j hij => Or.inl (by have hval : (eIdx.symm i).2.val = (eIdx.symm j).2.val := congrArg Fin.val hij simp [v, hval]) diff_cls := fun i j hij => by have hne : (eIdx.symm i).2.val ≠ (eIdx.symm j).2.val := fun h => hij (Fin.ext h) dsimp [v]; constructor <;> omega } let D := canonicalDeg lam let M := (D + (k - 1)) / 2 let totalSum : ℤ := ∑ i : Fin n, v i let T : Finset ℤ := (Finset.univ.filter fun j : Fin k => j.val ≤ M).image (fun j => 2 * ((M - j.val : ℕ) : ℤ) - totalSum) have hT_card : T.card ≤ k := by calc T.card ≤ (Finset.univ.filter fun j : Fin k => j.val ≤ M).card := Finset.card_image_le _ ≤ (Finset.univ : Finset (Fin k)).card := Finset.card_le_univ _ _ = k := Fintype.card_fin k let Φ : (Fin n → Bool) ≃ StanleyProd Ls := (Equiv.arrowCongr eIdx (Equiv.refl Bool)).symm.trans (equivStanleyProd Ls) let W : (t : Fin Ls.length) → Fin (Ls.get t) → ℤ := fun _ j => (j.val + 1 : ℤ) have hrk_sum : ∀ (Ms : List ℕ) (x : StanleyProd Ms), stanleyProdSum Ms (fun _ j => (j.val + 1 : ℤ)) x = ((stanleyProdSl2 Ms).rk x : ℤ) := by intro Ms induction Ms with | nil => intro x; simp [stanleyProdSum, stanleyProdSl2, unitSl2] | cons L Ms ih => rintro ⟨x, xs⟩ change StanleyPoset.subsetSum (fun j : Fin L => (j.val + 1 : ℤ)) x + stanleyProdSum Ms (fun _ j => (j.val + 1 : ℤ)) xs = ((StanleyPoset.toSl2Poset L).rk x : ℤ) + ((stanleyProdSl2 Ms).rk xs : ℤ) rw [ih xs] congr 1 unfold StanleyPoset.subsetSum StanleyPoset.toSl2Poset StanleyPoset.rk dsimp only push_cast refine Finset.sum_congr rfl fun j _ => ?_ cases x.bits j <;> simp have hrad_rk : ∀ ε : Fin n → Bool, rademacherSum v ε = 2 * (((stanleyProdSl2 Ls).rk (Φ ε) : ℕ) : ℤ) - totalSum := by intro ε have h2 : rademacherSum v ε + totalSum = 2 * bitSubsetSum v ε := by unfold rademacherSum bitSubsetSum totalSum rw [← Finset.sum_add_distrib, Finset.mul_sum] refine Finset.sum_congr rfl fun i _ => ?_ cases ε i <;> (simp; try ring) have hsub : bitSubsetSum v ε = stanleyProdSum Ls W (Φ ε) := by unfold bitSubsetSum rw [← Equiv.sum_comp eIdx (fun i => if ε i then v i else 0)] have hv_e : ∀ p : P_idx, v (eIdx p) = W p.1 p.2 := fun p => by dsimp only [v, W]; rw [eIdx.symm_apply_apply] simp_rw [hv_e] exact bitSubsetSum_equivStanleyProd Ls W (fun p => ε (eIdx p)) rw [hsub, hrk_sum Ls (Φ ε)] at h2 linarith refine ⟨n, v, hv, hsp, T, hT_card, ?_⟩ let U : Finset (StanleyProd Ls) := (Finset.univ.filter fun j : Fin k => j.val ≤ M).biUnion (fun j => (stanleyProdSl2 Ls).rankLevel (M - j.val)) have hbij : (Finset.univ.filter (fun ε : Fin n → Bool => rademacherSum v ε ∈ T)).card = U.card := by refine Finset.card_bij (fun ε _ => Φ ε) ?_ ?_ ?_ · intro ε hε simp only [Finset.mem_filter, Finset.mem_univ, true_and, hrad_rk] at hε rcases Finset.mem_image.mp hε with ⟨j, hj, heq⟩ simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hj have hrk_eq : (stanleyProdSl2 Ls).rk (Φ ε) = M - j.val := by omega refine Finset.mem_biUnion.mpr ⟨j, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hj⟩, ?_⟩ simp [Sl2Poset.rankLevel, hrk_eq] · intro _ _ _ _ h; exact Φ.injective h · intro x hx rcases Finset.mem_biUnion.mp hx with ⟨j, hj, hxj⟩ simp only [Sl2Poset.rankLevel, Finset.mem_filter, Finset.mem_univ, true_and] at hxj refine ⟨Φ.symm x, ?_, Φ.apply_symm_apply x⟩ simp only [Finset.mem_filter, Finset.mem_univ, true_and, hrad_rk, Φ.apply_symm_apply, hxj] exact Finset.mem_image.mpr ⟨j, hj, rfl⟩ rw [hbij, Finset.card_biUnion] · unfold M_star centralSum rw [← Finset.sum_filter] refine Finset.sum_congr rfl fun j _ => ?_ rw [stanleyProdSl2_rankLevel_card, stanleyProdPoly_conjugate hlam] · intro j₁ hj₁ j₂ hj₂ hne simp only [Finset.mem_coe, Finset.mem_filter, Finset.mem_univ, true_and] at hj₁ hj₂ simp only [Function.onFun] rw [Finset.disjoint_left] intro x hx₁ hx₂ simp only [Sl2Poset.rankLevel, Finset.mem_filter, Finset.mem_univ, true_and] at hx₁ hx₂ have : j₁.val = j₂.val := by omega exact hne (Fin.ext this) /-! ## Section 4: Higher-Dimensional Lifting to `ℝ^D` -/ /-- **Constructive Separating Linear Functional**: given any finite collection `W` of nonzero vectors in `ℝ^D`, there exists `u ∈ ℝ^D` whose inner product `∑ r, u r * w r` is nonzero for every `w ∈ W`. -/ lemma exists_separating_functional {D : ℕ} (W : Finset (Fin D → ℝ)) (hW : ∀ w ∈ W, w ≠ 0) : ∃ u : Fin D → ℝ, ∀ w ∈ W, ∑ r : Fin D, u r * w r ≠ 0 := by classical -- Associate to each `w ∈ W` the polynomial `p_w(t) = ∑ r, w r * t^r` let polyOf : (Fin D → ℝ) → Polynomial ℝ := fun w => ∑ r : Fin D, Polynomial.C (w r) * Polynomial.X ^ r.val have hpoly_ne : ∀ w ∈ W, polyOf w ≠ 0 := by intro w hw h0 apply hW w hw ext r have hcoeff : (polyOf w).coeff r.val = 0 := by rw [h0]; simp have hcalc : (polyOf w).coeff r.val = w r := by simp only [polyOf, Polynomial.finsetSum_coeff, Polynomial.coeff_C_mul_X_pow] rw [Finset.sum_eq_single r] · simp · intro s _ hsr have hne : r.val ≠ s.val := fun h => hsr (Fin.ext h.symm) simp [hne] · intro h; exact absurd (Finset.mem_univ r) h simp [← hcalc, hcoeff] have hpoly_eval : ∀ (w : Fin D → ℝ) (t : ℝ), Polynomial.eval t (polyOf w) = ∑ r : Fin D, (t ^ r.val) * w r := by intro w t simp only [polyOf, Polynomial.eval_finsetSum, Polynomial.eval_mul, Polynomial.eval_C, Polynomial.eval_pow, Polynomial.eval_X] refine Finset.sum_congr rfl fun r _ => mul_comm _ _ -- Collect all real roots of all `polyOf w` (`w ∈ W`) into a finite set let bad : Finset ℝ := W.biUnion (fun w => (polyOf w).roots.toFinset) obtain ⟨t, ht⟩ := Infinite.exists_notMem_finset bad refine ⟨fun r => t ^ r.val, fun w hw hzero => ?_⟩ apply ht refine Finset.mem_biUnion.mpr ⟨w, hw, Multiset.mem_toFinset.mpr ?_⟩ rw [Polynomial.mem_roots (hpoly_ne w hw), Polynomial.IsRoot.def, hpoly_eval w t] exact hzero /-- **Headline Theorem 2 (Higher-Dimensional Multiplicity-Partition Littlewood–Offord in `ℝ^D`)**: For every dimension `D`, every `k ≥ 1`, every nonzero vector family `v : Fin n → (Fin D → ℝ)` with signed-multiplicity partition `λ` (grouping by `v i = ± v j`), and every target set `T : Finset (Fin D → ℝ)` with `T.card ≤ k`, `|{ε ∈ {±1}^n : ∑ ε_i v_i ∈ T}| ≤ M_k*(λ)`. -/ theorem exact_multiplicity_partition_Rd {n D : ℕ} (v : Fin n → (Fin D → ℝ)) (hv : ∀ i, v i ≠ 0) (lam : List ℕ) (sp : SignedPartition v lam) (k : ℕ) (hk : 0 < k) (T : Finset (Fin D → ℝ)) (hT : T.card ≤ k) : (Finset.univ.filter (fun ε : Fin n → Bool => rademacherSum v ε ∈ T)).card ≤ M_star lam k := by classical -- Build the finite set `W` of all nonzero vectors `v i`, plus `v i - v j` and `v i + v j` across distinct classes let W1 : Finset (Fin D → ℝ) := Finset.univ.image v let pairs : Finset (Fin n × Fin n) := Finset.univ.filter (fun p => sp.cls p.1 ≠ sp.cls p.2) let W2 : Finset (Fin D → ℝ) := pairs.image (fun p => v p.1 - v p.2) let W3 : Finset (Fin D → ℝ) := pairs.image (fun p => v p.1 + v p.2) let W : Finset (Fin D → ℝ) := W1 ∪ (W2 ∪ W3) have hW : ∀ w ∈ W, w ≠ 0 := by intro w hw simp only [W, W1, W2, W3, Finset.mem_union, Finset.mem_image, Finset.mem_univ, true_and] at hw rcases hw with ⟨i, rfl⟩ | ⟨p, hp, rfl⟩ | ⟨p, hp, rfl⟩ · exact hv i · have hdiff := sp.diff_cls p.1 p.2 (Finset.mem_filter.mp hp).2 exact sub_ne_zero.mpr hdiff.1 · have hdiff := sp.diff_cls p.1 p.2 (Finset.mem_filter.mp hp).2 intro h0 exact hdiff.2 (eq_neg_of_add_eq_zero_left h0) obtain ⟨u, hu⟩ := exists_separating_functional W hW let φ : (Fin D → ℝ) → ℝ := fun x => ∑ r : Fin D, u r * x r have hφ_add : ∀ x y, φ (x + y) = φ x + φ y := fun x y => by simp only [φ, Pi.add_apply, mul_add, Finset.sum_add_distrib] have hφ_neg : ∀ x, φ (-x) = -φ x := fun x => by simp only [φ, Pi.neg_apply, mul_neg, Finset.sum_neg_distrib] have hφ_sub : ∀ x y, φ (x - y) = φ x - φ y := fun x y => by rw [sub_eq_add_neg, hφ_add, hφ_neg, ← sub_eq_add_neg] have hφ_sum : ∀ (s : Finset (Fin n)) (f : Fin n → (Fin D → ℝ)), φ (∑ i ∈ s, f i) = ∑ i ∈ s, φ (f i) := by intro s f induction s using Finset.induction_on with | empty => simp [φ] | insert a s ha ih => rw [Finset.sum_insert ha, hφ_add, ih, Finset.sum_insert ha] let v' : Fin n → ℝ := fun i => φ (v i) have hv' : ∀ i, v' i ≠ 0 := fun i => hu (v i) (Finset.mem_union_left _ (Finset.mem_image.mpr ⟨i, Finset.mem_univ _, rfl⟩)) have hsp' : SignedPartition v' lam := { isPart := sp.isPart cls := sp.cls card_fiber := sp.card_fiber same_cls := fun i j hij => by rcases sp.same_cls i j hij with h1 | h2 · exact Or.inl (by simp [v', h1]) · exact Or.inr (by simp [v', h2, hφ_neg]) diff_cls := fun i j hij => by have hp : (i, j) ∈ pairs := Finset.mem_filter.mpr ⟨Finset.mem_univ _, hij⟩ have h1 : φ (v i - v j) ≠ 0 := hu _ (Finset.mem_union_right _ (Finset.mem_union_left _ (Finset.mem_image.mpr ⟨(i, j), hp, rfl⟩))) have h2 : φ (v i + v j) ≠ 0 := hu _ (Finset.mem_union_right _ (Finset.mem_union_right _ (Finset.mem_image.mpr ⟨(i, j), hp, rfl⟩))) rw [hφ_sub] at h1; rw [hφ_add] at h2 exact ⟨sub_ne_zero.mp h1, fun h => h2 (by simp [v', h])⟩ } let T' : Finset ℝ := T.image φ have hT' : T'.card ≤ k := le_trans Finset.card_image_le hT have hsub : Finset.univ.filter (fun ε : Fin n → Bool => rademacherSum v ε ∈ T) ⊆ Finset.univ.filter (fun ε : Fin n → Bool => rademacherSum v' ε ∈ T') := by intro ε hε simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hε ⊢ have hrad : rademacherSum v' ε = φ (rademacherSum v ε) := by unfold rademacherSum rw [hφ_sum] refine Finset.sum_congr rfl fun i _ => ?_ cases ε i <;> simp [v', hφ_neg] rw [hrad] exact Finset.mem_image.mpr ⟨rademacherSum v ε, hε, rfl⟩ exact le_trans (Finset.card_le_card hsub) (exact_multiplicity_partition_littlewood_offord v' hv' lam hsp' k hk T' hT') /-! ## Section 5: Dominance-Order Schur-Convexity & Sharp Non-Asymptotic Corollaries -/ /-- A polynomial `p : Polynomial ℕ` is symmetric and unimodal of formal degree `D`. -/ structure SymmUnimodal (p : Polynomial ℕ) (D : ℕ) : Prop where zero_gt : ∀ r, D < r → p.coeff r = 0 symm : ∀ r ≤ D, p.coeff r = p.coeff (D - r) mono_le : ∀ r, 2 * r < D → p.coeff r ≤ p.coeff (r + 1) lemma SymmUnimodal.coeff_le_of_le_half {p : Polynomial ℕ} {D : ℕ} (h : SymmUnimodal p D) {u v : ℕ} (huv : u ≤ v) (hv : 2 * v ≤ D) : p.coeff u ≤ p.coeff v := by obtain ⟨d, rfl⟩ := Nat.exists_eq_add_of_le huv induction d with | zero => simp | succ d ih => have hstep : p.coeff (u + d) ≤ p.coeff (u + d + 1) := h.mono_le (u + d) (by omega) exact le_trans (ih (by omega) (by omega)) hstep lemma SymmUnimodal.coeff_le_of_add_le {p : Polynomial ℕ} {D : ℕ} (h : SymmUnimodal p D) {u v : ℕ} (huv : u ≤ v) (hadd : u + v ≤ D) : p.coeff u ≤ p.coeff v := by by_cases hv : 2 * v ≤ D · exact h.coeff_le_of_le_half huv hv · have hvD : v ≤ D := by omega rw [h.symm v hvD] exact h.coeff_le_of_le_half (by omega) (by omega) /-- Every canonical partition polynomial `P_λ` is symmetric and unimodal of degree `N(λ)`, directly from the `sl₂(ℚ)` Hard Lefschetz structure on `∏_t M(λ'_t)`. -/ theorem canonicalPoly_symmUnimodal {lam : List ℕ} (hlam : IsPartition lam) : SymmUnimodal (canonicalPoly lam) (canonicalDeg lam) := by let Ls := conjugate lam let S := stanleyProdSl2 Ls have hN : S.N = canonicalDeg lam := stanleyProdSl2_N_conjugate hlam have hP : ∀ r, (S.rankLevel r).card = (canonicalPoly lam).coeff r := fun r => by rw [stanleyProdSl2_rankLevel_card, stanleyProdPoly_conjugate hlam] refine ⟨?_, ?_, ?_⟩ · intro r hr rw [← hP r, Finset.card_eq_zero, Finset.eq_empty_iff_forall_notMem] intro x hx simp only [Sl2Poset.rankLevel, Finset.mem_filter, Finset.mem_univ, true_and] at hx have := S.rk_le x omega · intro r hr rw [← hP r, ← hP (canonicalDeg lam - r), ← hN] exact S.card_rankLevel_symm (by omega) · intro r hr rw [← hP r, ← hP (r + 1)] exact S.card_rankLevel_mono_le (by omega) /-- The geometric polynomial `1 + X + ⋯ + X^{k-1}`. -/ noncomputable def geomPoly (k : ℕ) : Polynomial ℕ := ∑ j ∈ Finset.range k, Polynomial.X ^ j lemma coeff_mul_geomPoly (p : Polynomial ℕ) (k r : ℕ) : (p * geomPoly k).coeff r = ∑ j : Fin k, if j.val ≤ r then p.coeff (r - j.val) else 0 := by unfold geomPoly rw [Finset.mul_sum, Polynomial.finsetSum_coeff] have h1 : (∑ b ∈ Finset.range k, (p * Polynomial.X ^ b).coeff r) = ∑ j : Fin k, (p * Polynomial.X ^ j.val).coeff r := (Fin.sum_univ_eq_sum_range (fun b => (p * Polynomial.X ^ b).coeff r) k).symm rw [h1] refine Finset.sum_congr rfl fun j _ => ?_ rw [Polynomial.coeff_mul_X_pow'] lemma centralSum_eq_coeff_mul_geom (p : Polynomial ℕ) (D k : ℕ) : centralSum p D k = (p * geomPoly k).coeff ((D + (k - 1)) / 2) := by unfold centralSum rw [coeff_mul_geomPoly] /-- Convolution of a symmetric unimodal polynomial `p` of degree `D` with `1 + X + ⋯ + X^{k-1}` is symmetric and unimodal of degree `D + (k - 1)`. -/ theorem symmUnimodal_mul_geom {p : Polynomial ℕ} {D k : ℕ} (hp : SymmUnimodal p D) (hk : 0 < k) : SymmUnimodal (p * geomPoly k) (D + (k - 1)) := by refine ⟨?_, ?_, ?_⟩ · intro r hr rw [coeff_mul_geomPoly] refine Finset.sum_eq_zero fun j _ => ?_ split_ifs with hle · exact hp.zero_gt (r - j.val) (by omega) · rfl · intro r hr rw [coeff_mul_geomPoly, coeff_mul_geomPoly] -- Bijection `j ↦ Fin.rev j` (`k - 1 - j`) refine Finset.sum_bij (fun j _ => Fin.rev j) (fun _ _ => Finset.mem_univ _) (fun _ _ _ _ h => Fin.rev_injective h) (fun j _ => ⟨Fin.rev j, Finset.mem_univ _, Fin.rev_rev j⟩) ?_ intro j _ simp only [Fin.val_rev] by_cases h1 : j.val ≤ r · by_cases h2 : k - (j.val + 1) ≤ D + (k - 1) - r · rw [if_pos h1, if_pos h2] have hleD : r - j.val ≤ D := by omega have hsub : D - (r - j.val) = D + (k - 1) - r - (k - (j.val + 1)) := by omega rw [hp.symm (r - j.val) hleD, hsub] · rw [if_pos h1, if_neg h2] exact hp.zero_gt (r - j.val) (by omega) · by_cases h2 : k - (j.val + 1) ≤ D + (k - 1) - r · rw [if_neg h1, if_pos h2] exact (hp.zero_gt _ (by omega)).symm · rw [if_neg h1, if_neg h2] · intro r hr rw [coeff_mul_geomPoly, coeff_mul_geomPoly] -- Telescoping: `(∑_{j=0}^{k-1} c_{r+1-j}) + c_{r+1-k} = (∑_{j=0}^{k-1} c_{r-j}) + c_{r+1}` have htele : (∑ j : Fin k, if j.val ≤ r + 1 then p.coeff (r + 1 - j.val) else 0) + (if k ≤ r + 1 then p.coeff (r + 1 - k) else 0) = (∑ j : Fin k, if j.val ≤ r then p.coeff (r - j.val) else 0) + p.coeff (r + 1) := by cases k with | zero => omega | succ k' => rw [Fin.sum_univ_succ (f := fun j : Fin (k' + 1) => if j.val ≤ r + 1 then p.coeff (r + 1 - j.val) else 0), Fin.sum_univ_castSucc (f := fun j : Fin (k' + 1) => if j.val ≤ r then p.coeff (r - j.val) else 0)] simp only [Fin.val_zero, Nat.zero_le, ↓reduceIte, Nat.sub_zero, Fin.val_succ, Fin.val_castSucc, Fin.val_last] have hmatch : (∑ j : Fin k', if j.val + 1 ≤ r + 1 then p.coeff (r + 1 - (j.val + 1)) else 0) = ∑ j : Fin k', if j.val ≤ r then p.coeff (r - j.val) else 0 := by refine Finset.sum_congr rfl fun j _ => ?_ have hiff : j.val + 1 ≤ r + 1 ↔ j.val ≤ r := by omega by_cases hle : j.val ≤ r · rw [if_pos (hiff.mpr hle), if_pos hle, Nat.succ_sub_succ] · rw [if_neg (mt hiff.mp hle), if_neg hle] rw [hmatch] have hlast : (if k' + 1 ≤ r + 1 then p.coeff (r + 1 - (k' + 1)) else 0) = if k' ≤ r then p.coeff (r - k') else 0 := by have hiff : k' + 1 ≤ r + 1 ↔ k' ≤ r := by omega by_cases hle : k' ≤ r · rw [if_pos (hiff.mpr hle), if_pos hle, Nat.succ_sub_succ] · rw [if_neg (mt hiff.mp hle), if_neg hle] rw [hlast]; omega have hcomp : (if k ≤ r + 1 then p.coeff (r + 1 - k) else 0) ≤ p.coeff (r + 1) := by split_ifs with hkr · exact hp.coeff_le_of_add_le (by omega) (by omega) · exact Nat.zero_le _ omega /-- **Symmetric-Unimodal Spread Step**: for any `SymmUnimodal q M` and any `a ≥ 1`, shifting the factor `(1 + X^a)` to `(1 + X^{a+1})` weakly decreases the central coefficient. -/ theorem symmUnimodal_spread_step {q : Polynomial ℕ} {M a : ℕ} (hq : SymmUnimodal q M) (ha : 1 ≤ a) : (q * (1 + Polynomial.X ^ (a + 1))).coeff ((M + (a + 1)) / 2) ≤ (q * (1 + Polynomial.X ^ a)).coeff ((M + a) / 2) := by have hmul : ∀ b r, (q * (1 + Polynomial.X ^ b)).coeff r = q.coeff r + if b ≤ r then q.coeff (r - b) else 0 := fun b r => by rw [mul_add, mul_one, Polynomial.coeff_add, Polynomial.coeff_mul_X_pow'] rw [hmul (a + 1), hmul a] rcases Nat.even_or_odd (M + a) with ⟨m, hm⟩ | ⟨m, hm⟩ · -- Even case: `M + a = m + m`, so `(M + a)/2 = m` and `(M + a + 1)/2 = m` have h1 : (M + a) / 2 = m := by omega have h2 : (M + (a + 1)) / 2 = m := by omega rw [h1, h2] refine Nat.add_le_add_left ?_ _ by_cases hle1 : a + 1 ≤ m · have hle2 : a ≤ m := by omega rw [if_pos hle1, if_pos hle2] exact hq.coeff_le_of_add_le (by omega) (by omega) · rw [if_neg hle1]; exact Nat.zero_le _ · -- Odd case: `M + a = 2*m + 1`, so `(M + a)/2 = m` and `(M + a + 1)/2 = m + 1` have h1 : (M + a) / 2 = m := by omega have h2 : (M + (a + 1)) / 2 = m + 1 := by omega rw [h1, h2] -- Note `m + 1 - (a + 1) = m - a`, and `a + 1 ≤ m + 1 ↔ a ≤ m`! have hiff : a + 1 ≤ m + 1 ↔ a ≤ m := by omega have hsecond : (if a + 1 ≤ m + 1 then q.coeff (m + 1 - (a + 1)) else 0) = if a ≤ m then q.coeff (m - a) else 0 := by by_cases hle : a ≤ m · rw [if_pos (hiff.mpr hle), if_pos hle, Nat.succ_sub_succ] · rw [if_neg (mt hiff.mp hle), if_neg hle] rw [hsecond] refine Nat.add_le_add_right ?_ _ -- Compare `q.coeff (m + 1)` with `q.coeff m` using symmetry (`M - (m + 1) = m - a ≤ m`)! by_cases hleM : m + 1 ≤ M · rw [hq.symm (m + 1) hleM] exact hq.coeff_le_of_add_le (by omega) (by omega) · rw [hq.zero_gt (m + 1) (by omega)]; exact Nat.zero_le _ /-- Iterated spread monotonicity: for `SymmUnimodal p D`, `k ≥ 1`, and `1 ≤ a ≤ b`, `centralSum (p * (1 + X^b)) (D + b) k ≤ centralSum (p * (1 + X^a)) (D + a) k`. -/ theorem centralSum_mono_shift {p : Polynomial ℕ} {D k a b : ℕ} (hp : SymmUnimodal p D) (hk : 0 < k) (ha : 1 ≤ a) (hab : a ≤ b) : centralSum (p * (1 + Polynomial.X ^ b)) (D + b) k ≤ centralSum (p * (1 + Polynomial.X ^ a)) (D + a) k := by have hrewrite : ∀ c, centralSum (p * (1 + Polynomial.X ^ c)) (D + c) k = ((p * geomPoly k) * (1 + Polynomial.X ^ c)).coeff ((D + (k - 1) + c) / 2) := fun c => by rw [centralSum_eq_coeff_mul_geom, mul_right_comm] congr 2; omega rw [hrewrite b, hrewrite a] have hq : SymmUnimodal (p * geomPoly k) (D + (k - 1)) := symmUnimodal_mul_geom hp hk obtain ⟨d, rfl⟩ := Nat.exists_eq_add_of_le hab clear hab induction d with | zero => simp | succ d ih => have hstep := symmUnimodal_spread_step hq (a := a + d) (by omega) have hidx : a + (d + 1) = (a + d) + 1 := by omega rw [hidx] exact le_trans hstep ih /-- Zero-padded part accessor for partitions. -/ def partAt (l : List ℕ) (i : ℕ) : ℕ := l.getD i 0 /-- Prefix sum of the first `s` parts of `l`. -/ def prefixSum (l : List ℕ) (s : ℕ) : ℕ := ∑ i ∈ Finset.range s, partAt l i /-- Dominance (majorization) partial order on integer partitions: `lam ⊴ mu` iff `lam.sum = mu.sum` and `∀ s, prefixSum lam s ≤ prefixSum mu s`. -/ def Dominates (lam mu : List ℕ) : Prop := lam.sum = mu.sum ∧ ∀ s : ℕ, prefixSum lam s ≤ prefixSum mu s lemma partAt_eq_zero_of_le {l : List ℕ} {i : ℕ} (hi : l.length ≤ i) : partAt l i = 0 := by simp [partAt, List.getD_eq_getElem?_getD, List.getElem?_eq_none hi] lemma partAt_lt {l : List ℕ} {i : ℕ} (hi : i < l.length) : partAt l i = l[i] := by simp [partAt, List.getD_eq_getElem?_getD, List.getElem?_eq_getElem hi] lemma IsPartition.partAt_antitone {l : List ℕ} (hl : IsPartition l) {i j : ℕ} (hij : i ≤ j) : partAt l j ≤ partAt l i := by by_cases hj : j < l.length · have hi : i < l.length := lt_of_le_of_lt hij hj rw [partAt_lt hi, partAt_lt hj] exact hl.antitone (i := ⟨i, hi⟩) (j := ⟨j, hj⟩) hij · rw [partAt_eq_zero_of_le (by omega)]; exact Nat.zero_le _ lemma IsPartition.length_le_sum {l : List ℕ} (hl : IsPartition l) : l.length ≤ l.sum := by induction l with | nil => simp | cons a rest ih => have ha : 0 < a := hl.2 a (by simp) have hrest : IsPartition rest := ⟨(List.pairwise_cons.mp hl.1).2, fun m hm => hl.2 m (by simp [hm])⟩ have := ih hrest simp only [List.length_cons, List.sum_cons] omega lemma prefixSum_eq_sum_of_length_le {l : List ℕ} {s : ℕ} (hs : l.length ≤ s) : prefixSum l s = l.sum := by unfold prefixSum have hsplit : ∑ i ∈ Finset.range s, partAt l i = ∑ i ∈ Finset.range l.length, partAt l i := by symm refine Finset.sum_subset (Finset.range_mono hs) fun i _ hi => ?_ exact partAt_eq_zero_of_le (by simp only [Finset.mem_range] at hi; omega) rw [hsplit] clear hs hsplit induction l with | nil => simp | cons a rest ih => simp only [List.length_cons, List.sum_cons] rw [Finset.sum_range_succ'] have h0 : partAt (a :: rest) 0 = a := by simp [partAt] have hrest : ∑ k ∈ Finset.range rest.length, partAt (a :: rest) (k + 1) = ∑ k ∈ Finset.range rest.length, partAt rest k := by refine Finset.sum_congr rfl fun k _ => ?_ simp [partAt] rw [h0, hrest, ih, add_comm] lemma partAt_eq_imp_eq {l₁ l₂ : List ℕ} (h₁ : IsPartition l₁) (h₂ : IsPartition l₂) (heq : ∀ i, partAt l₁ i = partAt l₂ i) : l₁ = l₂ := by have hlen : l₁.length = l₂.length := by by_contra hne rcases lt_or_gt_of_ne hne with hlt | hgt · have h1 := partAt_eq_zero_of_le (l := l₁) (i := l₁.length) le_rfl have h2 := partAt_lt (l := l₂) hlt have hpos : 0 < l₂[l₁.length] := h₂.2 _ (List.getElem_mem hlt) have := heq l₁.length; omega · have h1 := partAt_lt (l := l₁) hgt have h2 := partAt_eq_zero_of_le (l := l₂) (i := l₂.length) le_rfl have hpos : 0 < l₁[l₂.length] := h₁.2 _ (List.getElem_mem hgt) have := heq l₂.length; omega refine List.ext_getElem hlen fun i hi₁ hi₂ => ?_ have := heq i rwa [partAt_lt hi₁, partAt_lt hi₂] at this lemma canonicalPoly_set {l : List ℕ} {a : ℕ} (ha : a < l.length) (hpos : 1 ≤ l[a]) : canonicalPoly l = canonicalPoly (l.set a (l[a] - 1)) * (1 + Polynomial.X ^ (a + 1) : Polynomial ℕ) := by unfold canonicalPoly have hlen : (l.set a (l[a] - 1)).length = l.length := List.length_set have hreidx : (∏ j : Fin (l.set a (l[a] - 1)).length, (1 + Polynomial.X ^ (j.val + 1) : Polynomial ℕ) ^ ((l.set a (l[a] - 1)).get j)) = ∏ j : Fin l.length, (1 + Polynomial.X ^ (j.val + 1) : Polynomial ℕ) ^ (if j.val = a then l[a] - 1 else l.get j) := by refine Finset.prod_bij (fun j _ => ⟨j.val, by omega⟩) (fun _ _ => Finset.mem_univ _) (fun _ _ _ _ h => Fin.ext (by simpa using congrArg Fin.val h)) (fun j _ => ⟨⟨j.val, by omega⟩, Finset.mem_univ _, rfl⟩) ?_ intro j _ simp only [List.get_eq_getElem] by_cases hja : j.val = a · simp [hja, List.getElem_set_self] · simp [hja, List.getElem_set_ne (Ne.symm hja)] rw [hreidx] let af : Fin l.length := ⟨a, ha⟩ rw [← Finset.mul_prod_erase Finset.univ _ (Finset.mem_univ af), ← Finset.mul_prod_erase Finset.univ _ (Finset.mem_univ af)] have herase : (∏ x ∈ Finset.univ.erase af, (1 + Polynomial.X ^ (x.val + 1) : Polynomial ℕ) ^ (if x.val = a then l[a] - 1 else l.get x)) = ∏ x ∈ Finset.univ.erase af, (1 + Polynomial.X ^ (x.val + 1) : Polynomial ℕ) ^ (l.get x) := by refine Finset.prod_congr rfl fun x hx => ?_ have hne : x.val ≠ a := fun hv => (Finset.mem_erase.mp hx).1 (Fin.ext hv) simp [hne] rw [herase] have hpow : (1 + Polynomial.X ^ (af.val + 1) : Polynomial ℕ) ^ (l.get af) = (1 + Polynomial.X ^ (af.val + 1) : Polynomial ℕ) ^ (l[a] - 1) * (1 + Polynomial.X ^ (a + 1)) := by have hget : l.get af = (l[a] - 1) + 1 := by simp [af]; omega rw [hget, pow_succ] simp only [af, ↓reduceIte] rw [hpow]; ring lemma canonicalDeg_set {l : List ℕ} {a : ℕ} (ha : a < l.length) (hpos : 1 ≤ l[a]) : canonicalDeg l = canonicalDeg (l.set a (l[a] - 1)) + (a + 1) := by unfold canonicalDeg have hlen : (l.set a (l[a] - 1)).length = l.length := List.length_set have hreidx : (∑ j : Fin (l.set a (l[a] - 1)).length, (j.val + 1) * (l.set a (l[a] - 1)).get j) = ∑ j : Fin l.length, (j.val + 1) * (if j.val = a then l[a] - 1 else l.get j) := by refine Finset.sum_bij (fun j _ => ⟨j.val, by omega⟩) (fun _ _ => Finset.mem_univ _) (fun _ _ _ _ h => Fin.ext (by simpa using congrArg Fin.val h)) (fun j _ => ⟨⟨j.val, by omega⟩, Finset.mem_univ _, rfl⟩) ?_ intro j _ simp only [List.get_eq_getElem] by_cases hja : j.val = a · simp [hja, List.getElem_set_self] · simp [hja, List.getElem_set_ne (Ne.symm hja)] rw [hreidx] let af : Fin l.length := ⟨a, ha⟩ rw [← Finset.add_sum_erase Finset.univ _ (Finset.mem_univ af), ← Finset.add_sum_erase Finset.univ _ (Finset.mem_univ af)] have herase : (∑ x ∈ Finset.univ.erase af, (x.val + 1) * (if x.val = a then l[a] - 1 else l.get x)) = ∑ x ∈ Finset.univ.erase af, (x.val + 1) * l.get x := by refine Finset.sum_congr rfl fun x hx => ?_ have hne : x.val ≠ a := fun hv => (Finset.mem_erase.mp hx).1 (Fin.ext hv) simp [hne] rw [herase] simp only [af, ↓reduceIte, List.get_eq_getElem] have hterm : (a + 1) * l[a] = (a + 1) * (l[a] - 1) + (a + 1) := by calc (a + 1) * l[a] = (a + 1) * ((l[a] - 1) + 1) := by congr 1; omega _ = (a + 1) * (l[a] - 1) + (a + 1) := by ring omega lemma canonicalPoly_append_one (l : List ℕ) : canonicalPoly (l ++ [1]) = canonicalPoly l * (1 + Polynomial.X ^ (l.length + 1) : Polynomial ℕ) := by unfold canonicalPoly have hlen : (l ++ [1]).length = l.length + 1 := by simp have hreidx : (∏ j : Fin (l ++ [1]).length, (1 + Polynomial.X ^ (j.val + 1) : Polynomial ℕ) ^ ((l ++ [1]).get j)) = ∏ j : Fin (l.length + 1), (1 + Polynomial.X ^ (j.val + 1) : Polynomial ℕ) ^ ((l ++ [1]).get ⟨j.val, by omega⟩) := Finset.prod_bij (fun j _ => ⟨j.val, by omega⟩) (fun _ _ => Finset.mem_univ _) (fun _ _ _ _ h => Fin.ext (by simpa using congrArg Fin.val h)) (fun j _ => ⟨⟨j.val, by omega⟩, Finset.mem_univ _, rfl⟩) (fun _ _ => rfl) rw [hreidx, Fin.prod_univ_castSucc] congr 1 · refine Finset.prod_congr rfl fun j _ => ?_ simp [List.getElem_append_left j.isLt] · simp [List.getElem_append_right le_rfl] lemma canonicalDeg_append_one (l : List ℕ) : canonicalDeg (l ++ [1]) = canonicalDeg l + (l.length + 1) := by unfold canonicalDeg have hlen : (l ++ [1]).length = l.length + 1 := by simp have hreidx : (∑ j : Fin (l ++ [1]).length, (j.val + 1) * (l ++ [1]).get j) = ∑ j : Fin (l.length + 1), (j.val + 1) * (l ++ [1]).get ⟨j.val, by omega⟩ := Finset.sum_bij (fun j _ => ⟨j.val, by omega⟩) (fun _ _ => Finset.mem_univ _) (fun _ _ _ _ h => Fin.ext (by simpa using congrArg Fin.val h)) (fun j _ => ⟨⟨j.val, by omega⟩, Finset.mem_univ _, rfl⟩) (fun _ _ => rfl) rw [hreidx, Fin.sum_univ_castSucc] congr 1 · refine Finset.sum_congr rfl fun j _ => ?_ simp [List.getElem_append_left j.isLt] · simp [List.getElem_append_right le_rfl] /-- Dominance potential function measuring distance between `lam` and `mu`. -/ def dominanceGap (lam mu : List ℕ) : ℕ := ∑ s ∈ Finset.range (lam.sum + 1), (prefixSum mu s - prefixSum lam s) /-- **Brylawski–Muirhead Single-Unit Transfer Step**: whenever `lam ⊴ mu` and `lam ≠ mu`, there exist `a < b` and valid partitions `mu_tilde`, `mu_next` such that `P_μ = P_{μ̃}(1+X^{a+1})`, `P_{μ_next} = P_{μ̃}(1+X^{b+1})`, `lam ⊴ mu_next`, and `dominanceGap lam mu_next < dominanceGap lam mu`. -/ lemma brylawski_transfer_step {lam mu : List ℕ} (hlam : IsPartition lam) (hmu : IsPartition mu) (hdom : Dominates lam mu) (hne : lam ≠ mu) : ∃ (a b : ℕ) (mu_tilde mu_next : List ℕ), a < b ∧ IsPartition mu_tilde ∧ IsPartition mu_next ∧ canonicalPoly mu = canonicalPoly mu_tilde * (1 + Polynomial.X ^ (a + 1)) ∧ canonicalDeg mu = canonicalDeg mu_tilde + (a + 1) ∧ canonicalPoly mu_next = canonicalPoly mu_tilde * (1 + Polynomial.X ^ (b + 1)) ∧ canonicalDeg mu_next = canonicalDeg mu_tilde + (b + 1) ∧ Dominates lam mu_next ∧ dominanceGap lam mu_next < dominanceGap lam mu := by classical -- Step 1: Find the smallest `b` with `partAt lam b > partAt mu b` have hex_gt : ∃ b : ℕ, partAt mu b < partAt lam b := by by_contra hnot push Not at hnot -- If `∀ i, partAt lam i ≤ partAt mu i`, equal sums force `∀ i, partAt lam i = partAt mu i` apply hne refine partAt_eq_imp_eq hlam hmu fun i => ?_ by_contra hne_i have hlt_i : partAt lam i < partAt mu i := lt_of_le_of_ne (hnot i) hne_i let S := max lam.length (max mu.length (i + 1)) have hsum_lt : prefixSum lam S < prefixSum mu S := by unfold prefixSum exact Finset.sum_lt_sum (fun j _ => hnot j) ⟨i, Finset.mem_range.mpr (by omega), hlt_i⟩ rw [prefixSum_eq_sum_of_length_le (by omega), prefixSum_eq_sum_of_length_le (by omega), hdom.1] at hsum_lt exact lt_irrefl _ hsum_lt let b : ℕ := Nat.find hex_gt have hb_gt : partAt mu b < partAt lam b := Nat.find_spec hex_gt have hb_min : ∀ j < b, partAt lam j ≤ partAt mu j := fun j hj => not_lt.mp (Nat.find_min hex_gt hj) -- `b > 0` because `prefixSum lam 1 ≤ prefixSum mu 1` gives `partAt lam 0 ≤ partAt mu 0` have hb_pos : 0 < b := by by_contra hb0 have hb_eq : b = 0 := by omega have h0 := hdom.2 1 simp only [prefixSum, Finset.sum_range_one] at h0 rw [hb_eq] at hb_gt omega -- `prefixSum lam b < prefixSum mu b` (otherwise `prefixSum lam (b+1) > prefixSum mu (b+1)`) have hpref_b : prefixSum lam b < prefixSum mu b := by have h1 := hdom.2 (b + 1) have h2 := hdom.2 b simp only [prefixSum, Finset.sum_range_succ] at h1 change prefixSum lam b + partAt lam b ≤ prefixSum mu b + partAt mu b at h1 omega -- `partAt mu (b - 1) > partAt mu b` (since `lam` is antitone and `b` is minimal) have hmu_drop_b : partAt mu b < partAt mu (b - 1) := by have h1 : partAt lam b ≤ partAt lam (b - 1) := hlam.partAt_antitone (by omega) have h2 : partAt lam (b - 1) ≤ partAt mu (b - 1) := hb_min (b - 1) (by omega) omega -- `b ≤ mu.length` (since `partAt mu (b - 1) > partAt mu b ≥ 0`, so `b - 1 < mu.length`) have hb_le_len : b ≤ mu.length := by by_contra hgt have : partAt mu (b - 1) = 0 := partAt_eq_zero_of_le (by omega) omega -- There exists `j < b` with `partAt lam j < partAt mu j`, hence `partAt mu j ≥ partAt mu b + 2` have hex_a : ∃ j < b, partAt mu b + 2 ≤ partAt mu j := by have hex_j : ∃ j < b, partAt lam j < partAt mu j := by by_contra hall push Not at hall have hle : prefixSum mu b ≤ prefixSum lam b := Finset.sum_le_sum fun j hj => hall j (Finset.mem_range.mp hj) omega rcases hex_j with ⟨j, hjb, hjlt⟩ have hlam_ge : partAt lam b ≤ partAt lam j := hlam.partAt_antitone (le_of_lt hjb) exact ⟨j, hjb, by omega⟩ -- Let `a` be the LARGEST `j < b` with `partAt mu b + 2 ≤ partAt mu j` let goodA : Finset ℕ := (Finset.range b).filter (fun j => partAt mu b + 2 ≤ partAt mu j) have hgoodA_ne : goodA.Nonempty := by rcases hex_a with ⟨j, hjb, hj⟩ exact ⟨j, Finset.mem_filter.mpr ⟨Finset.mem_range.mpr hjb, hj⟩⟩ let a : ℕ := goodA.max' hgoodA_ne have ha_mem : a ∈ goodA := Finset.max'_mem goodA hgoodA_ne have ha_lt_b : a < b := Finset.mem_range.mp (Finset.mem_filter.mp ha_mem).1 have ha_ge2 : partAt mu b + 2 ≤ partAt mu a := (Finset.mem_filter.mp ha_mem).2 have ha_max : ∀ j, a < j → j < b → partAt mu j ≤ partAt mu b + 1 := by intro j haj hjb by_contra hgt have hjmem : j ∈ goodA := Finset.mem_filter.mpr ⟨Finset.mem_range.mpr hjb, by omega⟩ have := Finset.le_max' goodA j hjmem omega have ha_lt_len : a < mu.length := lt_of_lt_of_le ha_lt_b hb_le_len -- Crucial: for every `j ∈ (a, b)`, `partAt lam j = partAt mu j = partAt mu b + 1`! have hmid_eq : ∀ j, a < j → j < b → partAt lam j = partAt mu j := by intro j haj hjb have hle1 : partAt lam j ≤ partAt mu j := hb_min j hjb have hle2 : partAt mu j ≤ partAt mu b + 1 := ha_max j haj hjb have hge1 : partAt lam b ≤ partAt lam j := hlam.partAt_antitone (le_of_lt hjb) omega -- Construct `mu_tilde = mu.set a (mu[a] - 1)` let mu_tilde : List ℕ := mu.set a (mu[a] - 1) have hmu_a_ge2 : 2 ≤ mu[a] := by rw [← partAt_lt ha_lt_len]; omega have hmu_tilde_part : IsPartition mu_tilde := by constructor · rw [List.pairwise_iff_get] intro i j hij simp only [mu_tilde, List.get_eq_getElem] have hi : i.val < mu.length := by have := i.isLt; simpa [mu_tilde] using this have hj : j.val < mu.length := by have := j.isLt; simpa [mu_tilde] using this have hij_val : i.val < j.val := hij by_cases hia : i.val = a · simp only [hia, List.getElem_set_self] rw [List.getElem_set_ne (by omega)] have hj_le : mu[j.val] ≤ partAt mu b + 1 := by by_cases hjb : j.val < b · rw [← partAt_lt hj]; exact ha_max j.val (by omega) hjb · have : partAt mu j.val ≤ partAt mu b := hmu.partAt_antitone (by omega) rw [partAt_lt hj] at this; omega have ha_eq : mu[a] = partAt mu a := (partAt_lt ha_lt_len).symm omega · rw [List.getElem_set_ne (Ne.symm hia)] by_cases hja : j.val = a · simp only [hja, List.getElem_set_self] have : mu[a] ≤ mu[i.val] := hmu.antitone (i := ⟨i.val, hi⟩) (j := ⟨a, ha_lt_len⟩) (Fin.mk_le_mk.mpr (by omega)) omega · rw [List.getElem_set_ne (Ne.symm hja)] exact hmu.antitone (i := ⟨i.val, hi⟩) (j := ⟨j.val, hj⟩) (Fin.mk_le_mk.mpr (le_of_lt hij_val)) · intro m hm rcases List.mem_iff_getElem.mp hm with ⟨i, hi, rfl⟩ by_cases hia : i = a · subst hia simp only [mu_tilde, List.getElem_set_self] omega · simp only [mu_tilde, List.getElem_set_ne (Ne.symm hia)] exact hmu.2 _ (List.getElem_mem _) let mu_next : List ℕ := if hb : b < mu.length then mu_tilde.set b (mu[b] + 1) else mu_tilde ++ [1] have hmu_tilde_len : mu_tilde.length = mu.length := List.length_set have hmu_next_part : IsPartition mu_next := by by_cases hb : b < mu.length · simp only [mu_next, hb, ↓reduceDIte] constructor · rw [List.pairwise_iff_get] intro i j hij simp only [List.get_eq_getElem] have hi : i.val < mu.length := by have := i.isLt; simpa [hmu_tilde_len] using this have hj : j.val < mu.length := by have := j.isLt; simpa [hmu_tilde_len] using this have hij_val : i.val < j.val := hij by_cases hjb : j.val = b · simp only [hjb, List.getElem_set_self] rw [List.getElem_set_ne (by omega)] by_cases hia : i.val = a · simp only [mu_tilde, hia, List.getElem_set_self] have := ha_ge2; rw [partAt_lt ha_lt_len, partAt_lt hb] at this; omega · simp only [mu_tilde, List.getElem_set_ne (Ne.symm hia)] have h1 : mu[b - 1] ≤ mu[i.val] := hmu.antitone (i := ⟨i.val, hi⟩) (j := ⟨b - 1, by omega⟩) (Fin.mk_le_mk.mpr (by omega)) have h2 := hmu_drop_b rw [partAt_lt hb, partAt_lt (by omega)] at h2 omega · rw [List.getElem_set_ne (Ne.symm hjb)] by_cases hib : i.val = b · simp only [hib, List.getElem_set_self] have h1 : mu_tilde[j.val] ≤ mu[j.val] := by simp only [mu_tilde] by_cases hja : j.val = a · omega · rw [List.getElem_set_ne (Ne.symm hja)] have h2 : mu[j.val] ≤ mu[b] := hmu.antitone (i := ⟨b, hb⟩) (j := ⟨j.val, hj⟩) (Fin.mk_le_mk.mpr (by omega)) omega · rw [List.getElem_set_ne (Ne.symm hib)] exact hmu_tilde_part.antitone (i := ⟨i.val, by omega⟩) (j := ⟨j.val, by omega⟩) (Fin.mk_le_mk.mpr (le_of_lt hij_val)) · intro m hm rcases List.mem_iff_getElem.mp hm with ⟨i, hi, rfl⟩ by_cases hib : i = b · subst hib; simp [List.getElem_set_self] · rw [List.getElem_set_ne (Ne.symm hib)] exact hmu_tilde_part.2 _ (List.getElem_mem _) · simp only [mu_next, hb, ↓reduceDIte] constructor · rw [List.pairwise_append] refine ⟨hmu_tilde_part.1, List.pairwise_singleton _ _, fun x hx y hy => ?_⟩ simp only [List.mem_singleton] at hy subst hy exact hmu_tilde_part.2 x hx · intro m hm rcases List.mem_append.mp hm with h1 | h2 · exact hmu_tilde_part.2 m h1 · simp only [List.mem_singleton] at h2; omega -- Part values of `mu_next` vs `mu` have hpart_next : ∀ i : ℕ, partAt mu_next i = if i = a then partAt mu a - 1 else if i = b then partAt mu b + 1 else partAt mu i := by intro i by_cases hb : b < mu.length · simp only [mu_next, hb, ↓reduceDIte] by_cases hi : i < mu.length · rw [partAt_lt (by simp [hmu_tilde_len, hi])] by_cases hib : i = b · subst hib have hne_ba : b ≠ a := ne_of_gt ha_lt_b simp [hne_ba, List.getElem_set_self, partAt_lt hb] · rw [List.getElem_set_ne (Ne.symm hib)] by_cases hia : i = a · subst hia; simp [mu_tilde, List.getElem_set_self, partAt_lt ha_lt_len] · simp [mu_tilde, hia, hib, List.getElem_set_ne (Ne.symm hia), partAt_lt hi] · have hne_a : i ≠ a := by omega have hne_b : i ≠ b := by omega rw [if_neg hne_a, if_neg hne_b, partAt_eq_zero_of_le (by simp [hmu_tilde_len]; omega), partAt_eq_zero_of_le (by omega)] · have hb_eq : b = mu.length := by omega simp only [mu_next, hb, ↓reduceDIte] by_cases hi : i < mu.length · rw [partAt_lt (by simp [hmu_tilde_len]; omega), List.getElem_append_left (by omega)] have hne_b : i ≠ b := by omega by_cases hia : i = a · subst hia; simp [mu_tilde, List.getElem_set_self, partAt_lt ha_lt_len] · simp [mu_tilde, hia, hne_b, List.getElem_set_ne (Ne.symm hia), partAt_lt hi] · by_cases hib : i = b · subst hib have hne_ba : b ≠ a := ne_of_gt ha_lt_b rw [if_neg hne_ba, if_pos rfl, partAt_lt (by simp [hmu_tilde_len, hb_eq]), List.getElem_append_right (by omega), partAt_eq_zero_of_le (by omega)] simp [hmu_tilde_len, hb_eq] · have hne_a : i ≠ a := by omega rw [if_neg hne_a, if_neg hib, partAt_eq_zero_of_le (by simp [hmu_tilde_len]; omega), partAt_eq_zero_of_le (by omega)] -- Exact prefix sum shift of `mu_next` vs `mu`: -- `prefixSum mu_next s = prefixSum mu s - 1` for `a < s ≤ b`, and `= prefixSum mu s` otherwise! have hpref_next : ∀ s : ℕ, prefixSum mu_next s = if a < s ∧ s ≤ b then prefixSum mu s - 1 else prefixSum mu s := by intro s unfold prefixSum simp_rw [hpart_next] by_cases h1 : a < s · by_cases h2 : s ≤ b · rw [if_pos ⟨h1, h2⟩] have ha_mem_s : a ∈ Finset.range s := Finset.mem_range.mpr h1 rw [← Finset.add_sum_erase _ _ ha_mem_s, ← Finset.add_sum_erase _ _ ha_mem_s] simp only [↓reduceIte] have herase : (∑ i ∈ (Finset.range s).erase a, if i = a then partAt mu a - 1 else if i = b then partAt mu b + 1 else partAt mu i) = ∑ i ∈ (Finset.range s).erase a, partAt mu i := by refine Finset.sum_congr rfl fun i hi => ?_ have hia : i ≠ a := (Finset.mem_erase.mp hi).1 have hib : i ≠ b := by have := Finset.mem_range.mp (Finset.mem_erase.mp hi).2; omega simp [hia, hib] rw [herase] have : 1 ≤ partAt mu a := by omega omega · rw [if_neg (by omega)] have ha_mem_s : a ∈ Finset.range s := Finset.mem_range.mpr h1 have hb_mem_s : b ∈ (Finset.range s).erase a := Finset.mem_erase.mpr ⟨ne_of_gt ha_lt_b, Finset.mem_range.mpr (by omega)⟩ rw [← Finset.add_sum_erase _ _ ha_mem_s, ← Finset.add_sum_erase _ _ hb_mem_s, ← Finset.add_sum_erase _ _ ha_mem_s, ← Finset.add_sum_erase _ _ hb_mem_s] simp only [↓reduceIte, ne_of_gt ha_lt_b] have herase : (∑ i ∈ ((Finset.range s).erase a).erase b, if i = a then partAt mu a - 1 else if i = b then partAt mu b + 1 else partAt mu i) = ∑ i ∈ ((Finset.range s).erase a).erase b, partAt mu i := by refine Finset.sum_congr rfl fun i hi => ?_ have hib : i ≠ b := (Finset.mem_erase.mp hi).1 have hia : i ≠ a := (Finset.mem_erase.mp (Finset.mem_erase.mp hi).2).1 simp [hia, hib] rw [herase] have : 1 ≤ partAt mu a := by omega omega · rw [if_neg (by omega)] refine Finset.sum_congr rfl fun i hi => ?_ have his : i < s := Finset.mem_range.mp hi have hia : i ≠ a := by omega have hib : i ≠ b := by omega simp [hia, hib] -- Verify `Dominates lam mu_next` have hsum_next : mu_next.sum = mu.sum := by let S := max mu_next.length (max mu.length (b + 1)) rw [← prefixSum_eq_sum_of_length_le (l := mu_next) (s := S) (by omega), ← prefixSum_eq_sum_of_length_le (l := mu) (s := S) (by omega), hpref_next S, if_neg (by omega)] have hdom_next : Dominates lam mu_next := by refine ⟨hdom.1.trans hsum_next.symm, fun s => ?_⟩ rw [hpref_next s] by_cases hs : a < s ∧ s ≤ b · rw [if_pos hs] -- Show `prefixSum mu s - prefixSum lam s = prefixSum mu b - prefixSum lam b ≥ 1` have htail_eq : ∑ j ∈ Finset.Ico s b, partAt lam j = ∑ j ∈ Finset.Ico s b, partAt mu j := by refine Finset.sum_congr rfl fun j hj => ?_ have hj' := Finset.mem_Ico.mp hj exact hmid_eq j (by omega) hj'.2 have hsplit_lam : prefixSum lam b = prefixSum lam s + ∑ j ∈ Finset.Ico s b, partAt lam j := by unfold prefixSum; exact (Finset.sum_range_add_sum_Ico _ hs.2).symm have hsplit_mu : prefixSum mu b = prefixSum mu s + ∑ j ∈ Finset.Ico s b, partAt mu j := by unfold prefixSum; exact (Finset.sum_range_add_sum_Ico _ hs.2).symm omega · rw [if_neg hs]; exact hdom.2 s -- Verify `dominanceGap lam mu_next < dominanceGap lam mu` (strictly drops at `s = a + 1 ≤ b ≤ mu.length ≤ lam.sum`) have hgap_lt : dominanceGap lam mu_next < dominanceGap lam mu := by unfold dominanceGap have ha1_le : a + 1 < lam.sum + 1 := by have h1 := hmu.length_le_sum have h2 := hdom.1 omega refine Finset.sum_lt_sum (fun s _ => ?_) ⟨a + 1, Finset.mem_range.mpr ha1_le, ?_⟩ · rw [hpref_next s]; split_ifs <;> omega · rw [hpref_next (a + 1), if_pos ⟨by omega, by omega⟩] have hdom_a1 := hdom_next.2 (a + 1) rw [hpref_next (a + 1), if_pos ⟨by omega, by omega⟩] at hdom_a1 have hpos_mu : 1 ≤ prefixSum mu (a + 1) := by have h1 : partAt mu a ≤ prefixSum mu (a + 1) := by unfold prefixSum rw [Finset.sum_range_succ]; omega omega omega -- Verify `canonicalPoly` and `canonicalDeg` factorizations have hpoly_mu : canonicalPoly mu = canonicalPoly mu_tilde * (1 + Polynomial.X ^ (a + 1)) := canonicalPoly_set ha_lt_len (by omega) have hdeg_mu : canonicalDeg mu = canonicalDeg mu_tilde + (a + 1) := canonicalDeg_set ha_lt_len (by omega) have hpoly_next : canonicalPoly mu_next = canonicalPoly mu_tilde * (1 + Polynomial.X ^ (b + 1)) := by by_cases hb : b < mu.length · simp only [mu_next, hb, ↓reduceDIte] have hnext_b : (mu_tilde.set b (mu[b] + 1))[b]'(by simp [hmu_tilde_len, hb]) = mu[b] + 1 := List.getElem_set_self _ have hset_back : (mu_tilde.set b (mu[b] + 1)).set b ((mu_tilde.set b (mu[b] + 1))[b]'(by simp [hmu_tilde_len, hb]) - 1) = mu_tilde := by rw [hnext_b, Nat.add_sub_cancel, List.set_set] refine List.ext_getElem (by simp) fun i hi₁ hi₂ => ?_ by_cases hib : i = b · subst hib simp only [List.getElem_set_self, mu_tilde] rw [List.getElem_set_ne (by omega)] · rw [List.getElem_set_ne (Ne.symm hib)] have hcp := canonicalPoly_set (l := mu_tilde.set b (mu[b] + 1)) (a := b) (by simp [hmu_tilde_len, hb]) (by rw [hnext_b]; omega) rwa [hset_back] at hcp · have hb_eq : b = mu.length := by omega simp only [mu_next, hb, ↓reduceDIte] rw [canonicalPoly_append_one, hmu_tilde_len, hb_eq] have hdeg_next : canonicalDeg mu_next = canonicalDeg mu_tilde + (b + 1) := by by_cases hb : b < mu.length · simp only [mu_next, hb, ↓reduceDIte] have hnext_b : (mu_tilde.set b (mu[b] + 1))[b]'(by simp [hmu_tilde_len, hb]) = mu[b] + 1 := List.getElem_set_self _ have hset_back : (mu_tilde.set b (mu[b] + 1)).set b ((mu_tilde.set b (mu[b] + 1))[b]'(by simp [hmu_tilde_len, hb]) - 1) = mu_tilde := by rw [hnext_b, Nat.add_sub_cancel, List.set_set] refine List.ext_getElem (by simp) fun i hi₁ hi₂ => ?_ by_cases hib : i = b · subst hib simp only [List.getElem_set_self, mu_tilde] rw [List.getElem_set_ne (by omega)] · rw [List.getElem_set_ne (Ne.symm hib)] have hcd := canonicalDeg_set (l := mu_tilde.set b (mu[b] + 1)) (a := b) (by simp [hmu_tilde_len, hb]) (by rw [hnext_b]; omega) rwa [hset_back] at hcd · have hb_eq : b = mu.length := by omega simp only [mu_next, hb, ↓reduceDIte] rw [canonicalDeg_append_one, hmu_tilde_len, hb_eq] exact ⟨a, b, mu_tilde, mu_next, ha_lt_b, hmu_tilde_part, hmu_next_part, hpoly_mu, hdeg_mu, hpoly_next, hdeg_next, hdom_next, hgap_lt⟩ /-- **Headline Theorem 3 (Exact Dominance-Order Schur-Convexity Theorem)**: for every `k ≥ 1` and every pair of partitions `λ ⊴ μ` in dominance order, `M_k*(λ) ≤ M_k*(μ)`. -/ theorem dominance_mono_M_star {lam mu : List ℕ} (hlam : IsPartition lam) (hmu : IsPartition mu) (hdom : Dominates lam mu) (k : ℕ) (hk : 0 < k) : M_star lam k ≤ M_star mu k := by suffices h : ∀ g : ℕ, ∀ mu : List ℕ, IsPartition mu → Dominates lam mu → dominanceGap lam mu = g → M_star lam k ≤ M_star mu k from h (dominanceGap lam mu) mu hmu hdom rfl intro g induction g using Nat.strong_induction_on with | h g ih => intro mu hmu hdom hg by_cases heq : lam = mu · subst heq; exact le_rfl · obtain ⟨a, b, mu_tilde, mu_next, hab, hmt, hmn, hpm, hdm, hpn, hdn, hdom_n, hgap_lt⟩ := brylawski_transfer_step hlam hmu hdom heq have hrec : M_star lam k ≤ M_star mu_next k := ih (dominanceGap lam mu_next) (hg ▸ hgap_lt) mu_next hmn hdom_n rfl have hstep : M_star mu_next k ≤ M_star mu k := by unfold M_star rw [hpn, hdn, hpm, hdm] exact centralSum_mono_shift (canonicalPoly_symmUnimodal hmt) hk (by omega) (by omega) exact le_trans hrec hstep /-- Every nonzero family `v : Fin n → E` in an additive group admits a `SignedPartition v lam` with `lam.sum = n`! -/ theorem exists_signedPartition {n : ℕ} {E : Type*} [AddCommGroup E] (v : Fin n → E) : ∃ lam : List ℕ, lam.sum = n ∧ Nonempty (SignedPartition v lam) := by classical let key : Fin n → Finset E := fun i => {v i, -v i} have hkey_iff : ∀ i j, key i = key j ↔ v i = v j ∨ v i = -v j := by intro i j constructor · intro h have hmem : v i ∈ key j := by rw [← h]; exact Finset.mem_insert_self _ _ simpa [key] using hmem · rintro (h | h) · simp [key, h] · ext x; simp [key, h]; tauto let K : Finset (Finset E) := Finset.univ.image key let sz : Finset E → ℕ := fun s => (Finset.univ.filter fun i : Fin n => key i = s).card let K_sorted : List (Finset E) := K.toList.mergeSort (fun s₁ s₂ => decide (sz s₂ ≤ sz s₁)) have hK_perm : K_sorted.Perm K.toList := List.mergeSort_perm _ _ have hK_nodup : K_sorted.Nodup := hK_perm.nodup_iff.mpr (Finset.nodup_toList K) have hK_mem : ∀ s, s ∈ K_sorted ↔ s ∈ K := fun s => by rw [hK_perm.mem_iff, Finset.mem_toList] let lam : List ℕ := K_sorted.map sz have hlam_part : IsPartition lam := by constructor · have hpw := List.pairwise_mergeSort (le := fun s₁ s₂ => decide (sz s₂ ≤ sz s₁)) (by intro a b c h1 h2; simp only [decide_eq_true_eq] at h1 h2 ⊢; omega) (by intro a b; simp [Bool.or_eq_true]; omega) K.toList rw [List.pairwise_map] exact hpw.imp (by intro a b h; simp only [decide_eq_true_eq] at h; exact h) · intro m hm rcases List.mem_map.mp hm with ⟨s, hs, rfl⟩ rcases Finset.mem_image.mp ((hK_mem s).mp hs) with ⟨i, _, rfl⟩ exact Finset.card_pos.mpr ⟨i, Finset.mem_filter.mpr ⟨Finset.mem_univ _, rfl⟩⟩ have hlam_len : lam.length = K_sorted.length := by simp [lam] have hsum : lam.sum = n := by have hperm_sum : lam.sum = (K.toList.map sz).sum := (hK_perm.map sz).sum_eq have htoList : (K.toList.map sz).sum = ∑ s ∈ K, sz s := by have h1 : (K.toList.map sz).sum = (K.val.map sz).sum := by rw [← Multiset.sum_coe, ← Multiset.map_coe, Finset.coe_toList] exact h1 rw [hperm_sum, htoList] have hpart : ∑ s ∈ K, (Finset.univ.filter fun i : Fin n => key i = s).card = (Finset.univ : Finset (Fin n)).card := (Finset.card_eq_sum_card_image key Finset.univ).symm simpa [sz, K] using hpart -- Map each `i : Fin n` to the unique index of `key i` in `K_sorted` have hex_idx : ∀ i : Fin n, ∃ c : Fin lam.length, K_sorted[c.val]'(by omega) = key i := by intro i have hmem : key i ∈ K_sorted := (hK_mem _).mpr (Finset.mem_image.mpr ⟨i, Finset.mem_univ _, rfl⟩) rcases List.mem_iff_getElem.mp hmem with ⟨c, hc, hce⟩ exact ⟨⟨c, by omega⟩, hce⟩ choose cls hcls using hex_idx refine ⟨lam, hsum, ⟨{ isPart := hlam_part cls := cls card_fiber := by intro c have hEq : (Finset.univ.filter fun i : Fin n => cls i = c) = (Finset.univ.filter fun i : Fin n => key i = K_sorted[c.val]'(by omega)) := by ext i simp only [Finset.mem_filter, Finset.mem_univ, true_and] constructor · rintro rfl; exact (hcls i).symm · intro hk have h1 : K_sorted[(cls i).val]'(by omega) = K_sorted[c.val]'(by omega) := (hcls i).trans hk have hidx := (List.Nodup.getElem_inj_iff hK_nodup).mp h1 exact Fin.ext hidx rw [hEq] simp [lam, sz] same_cls := fun i j hij => (hkey_iff i j).mp ((hcls i).symm.trans (by rw [hij]; exact hcls j)) diff_cls := fun i j hij => by have hne_key : key i ≠ key j := fun h => by apply hij have h1 : K_sorted[(cls i).val]'(by omega) = K_sorted[(cls j).val]'(by omega) := (hcls i).trans (h.trans (hcls j).symm) exact Fin.ext ((List.Nodup.getElem_inj_iff hK_nodup).mp h1) exact ⟨fun h => hne_key ((hkey_iff i j).mpr (Or.inl h)), fun h => hne_key ((hkey_iff i j).mpr (Or.inr h))⟩ }⟩⟩ /-- Exact Catalan stability arithmetic identity: for all `n ≥ 2`, `M_1*([n - 1, 1]) + catalan (n / 2) = choose n (n / 2)`. -/ theorem M_star_stability_add_catalan {n : ℕ} (hn : 2 ≤ n) : M_star [n - 1, 1] 1 + catalan (n / 2) = Nat.choose n (n / 2) := by have hpoly : canonicalPoly [n - 1, 1] = (1 + Polynomial.X : Polynomial ℕ) ^ (n - 1) * (1 + Polynomial.X ^ 2) := by change ∏ j : Fin 2, (1 + Polynomial.X ^ (j.val + 1) : Polynomial ℕ) ^ ([n - 1, 1].get j) = _ rw [Fin.prod_univ_two] simp have hdeg : canonicalDeg [n - 1, 1] = n + 1 := by change ∑ j : Fin 2, (j.val + 1) * [n - 1, 1].get j = n + 1 rw [Fin.sum_univ_two] simp; omega have hM : M_star [n - 1, 1] 1 = ((1 + Polynomial.X : Polynomial ℕ) ^ (n - 1) * (1 + Polynomial.X ^ 2)).coeff ((n + 1) / 2) := by unfold M_star centralSum rw [hpoly, hdeg, Fin.sum_univ_one] simp have hbinom_coeff : ∀ m r : ℕ, ((1 + Polynomial.X : Polynomial ℕ) ^ m).coeff r = Nat.choose m r := by intro m r rw [add_comm, Polynomial.coeff_X_add_one_pow] simp have hcoeff : ∀ r, ((1 + Polynomial.X : Polynomial ℕ) ^ (n - 1) * (1 + Polynomial.X ^ 2)).coeff r = Nat.choose (n - 1) r + if 2 ≤ r then Nat.choose (n - 1) (r - 2) else 0 := by intro r rw [mul_add, mul_one, Polynomial.coeff_add, Polynomial.coeff_mul_X_pow', hbinom_coeff] split_ifs with h2 · rw [hbinom_coeff] · rfl have hcat_id : ∀ m : ℕ, 1 ≤ m → Nat.choose (2 * m) (m - 1) + catalan m = Nat.choose (2 * m) m := by intro m hm have hcb : (m + 1) * catalan m = Nat.choose (2 * m) m := by rw [catalan_eq_centralBinom_div, Nat.centralBinom_eq_two_mul_choose] exact Nat.mul_div_cancel' (Nat.succ_dvd_centralBinom m) have hratio : (m + 1) * Nat.choose (2 * m) (m - 1) = m * Nat.choose (2 * m) m := by have hr := Nat.choose_succ_right_eq (2 * m) (m - 1) have hsucc : m - 1 + 1 = m := by omega have hsub : 2 * m - (m - 1) = m + 1 := by omega rw [hsucc, hsub] at hr linarith have hsum : (m + 1) * (Nat.choose (2 * m) (m - 1) + catalan m) = (m + 1) * Nat.choose (2 * m) m := by calc (m + 1) * (Nat.choose (2 * m) (m - 1) + catalan m) = (m + 1) * Nat.choose (2 * m) (m - 1) + (m + 1) * catalan m := by ring _ = m * Nat.choose (2 * m) m + Nat.choose (2 * m) m := by rw [hratio, hcb] _ = (m + 1) * Nat.choose (2 * m) m := by ring exact Nat.eq_of_mul_eq_mul_left (by omega) hsum rw [hM, hcoeff] rcases Nat.even_or_odd n with ⟨m, hm⟩ | ⟨m, hm⟩ · have hm1 : 1 ≤ m := by omega have hn2 : n / 2 = m := by omega have hn1 : (n + 1) / 2 = m := by omega have h2m : n = 2 * m := by omega rw [hn1, hn2, h2m] by_cases hm2 : 2 ≤ m · rw [if_pos hm2] have hsymm : Nat.choose (2 * m - 1) m = Nat.choose (2 * m - 1) (m - 1) := by rw [← Nat.choose_symm (by omega : m ≤ 2 * m - 1)] congr 1; omega have hpascal : Nat.choose (2 * m - 1) (m - 1) + Nat.choose (2 * m - 1) (m - 2) = Nat.choose (2 * m) (m - 1) := by have hp := Nat.choose_succ_succ (2 * m - 1) (m - 2) have h1 : (2 * m - 1).succ = 2 * m := by omega have h2 : (m - 2).succ = m - 1 := by omega rw [h1, h2] at hp omega rw [hsymm, hpascal] exact hcat_id m hm1 · have hm_eq : m = 1 := by omega subst hm_eq simp [catalan_one] · have hm1 : 1 ≤ m := by omega have hn2 : n / 2 = m := by omega have hn1 : (n + 1) / 2 = m + 1 := by omega have h2m1 : n - 1 = 2 * m := by omega rw [hn1, hn2, h2m1, if_pos (by omega : 2 ≤ m + 1)] have hsub : m + 1 - 2 = m - 1 := by omega rw [hsub] have hsymm : Nat.choose (2 * m) (m + 1) = Nat.choose (2 * m) (m - 1) := by rw [← Nat.choose_symm (by omega : m + 1 ≤ 2 * m)] congr 1; omega have hpascal : Nat.choose n m = Nat.choose (2 * m) (m - 1) + Nat.choose (2 * m) m := by have hp := Nat.choose_succ_succ (2 * m) (m - 1) have h1 : (2 * m).succ = n := by omega have h2 : (m - 1).succ = m := by omega rw [h1, h2] at hp exact hp rw [hsymm, hpascal] have := hcat_id m hm1 omega /-- Erdős's canonical bound `M_1*([n]) = choose n (n / 2)`. -/ lemma M_star_singleton (n : ℕ) : M_star [n] 1 = Nat.choose n (n / 2) := by have hpoly : canonicalPoly [n] = (1 + Polynomial.X : Polynomial ℕ) ^ n := by change ∏ j : Fin 1, (1 + Polynomial.X ^ (j.val + 1) : Polynomial ℕ) ^ ([n].get j) = _ rw [Fin.prod_univ_one]; simp have hdeg : canonicalDeg [n] = n := by change ∑ j : Fin 1, (j.val + 1) * [n].get j = n rw [Fin.sum_univ_one]; simp unfold M_star centralSum rw [hpoly, hdeg, Fin.sum_univ_one] simp only [Fin.val_zero, Nat.sub_self, add_zero, Nat.zero_le, ↓reduceIte, Nat.sub_zero] rw [add_comm, Polynomial.coeff_X_add_one_pow] simp /-- Dominance helper: any partition `lam` of sum `n ≥ 2` with `lam.headD 0 ≤ n - 1` is dominated by `[n - 1, 1]`. -/ lemma dominates_stability {lam : List ℕ} {n : ℕ} (hlam : IsPartition lam) (hsum : lam.sum = n) (hn : 2 ≤ n) (hhead : lam.headD 0 ≤ n - 1) : Dominates lam [n - 1, 1] := by refine ⟨by simp; omega, fun s => ?_⟩ cases s with | zero => simp [prefixSum] | succ s => cases s with | zero => simp only [prefixSum, partAt] cases lam with | nil => simp at hsum; omega | cons a rest => simpa using hhead | succ s => have hs2 : s + 1 + 1 = s + 2 := by omega rw [hs2] have hle_sum : prefixSum lam (s + 2) ≤ lam.sum := by rw [← prefixSum_eq_sum_of_length_le (l := lam) (s := max lam.length (s + 2)) (le_max_left _ _)] unfold prefixSum exact Finset.sum_le_sum_of_subset (Finset.range_mono (le_max_right _ _)) have hrhs : prefixSum [n - 1, 1] (s + 2) = n := by rw [prefixSum_eq_sum_of_length_le (by simp)]; simp; omega omega /-- **Headline Theorem 4 (Exact Catalan Stability Theorem in `ℝ^D`)**: For all `n ≥ 2`, all dimensions `D`, and all nonzero vectors `v : Fin n → (Fin D → ℝ)` NOT all equal up to sign (`∃ i j, v i ≠ v j ∧ v i ≠ -v j`), every point `x ∈ ℝ^D` has at most `choose n (n / 2) - catalan (n / 2)` Rademacher representations. This bound is exact and attained for all `n ≥ 2` by `(1, …, 1, 2)`. -/ theorem exact_catalan_stability_Rd {n D : ℕ} (hn : 2 ≤ n) (v : Fin n → (Fin D → ℝ)) (hv : ∀ i, v i ≠ 0) (hnot_all_eq : ∃ i j : Fin n, v i ≠ v j ∧ v i ≠ -v j) (x : Fin D → ℝ) : (Finset.univ.filter (fun ε : Fin n → Bool => rademacherSum v ε = x)).card ≤ Nat.choose n (n / 2) - catalan (n / 2) := by obtain ⟨lam, hsum, ⟨sp⟩⟩ := exists_signedPartition v -- Since not all `v i` are equal up to sign, `lam.length ≥ 2`, hence `lam.headD 0 ≤ n - 1` have hhead : lam.headD 0 ≤ n - 1 := by rcases hnot_all_eq with ⟨i, j, hne1, hne2⟩ have hcls_ne : sp.cls i ≠ sp.cls j := fun heq => by rcases sp.same_cls i j heq with h | h · exact hne1 h · exact hne2 h have hlen2 : 2 ≤ lam.length := by have hi := (sp.cls i).isLt have hj := (sp.cls j).isLt have hne_v : (sp.cls i).val ≠ (sp.cls j).val := fun h => hcls_ne (Fin.ext h) omega cases lam with | nil => simp at hlen2 | cons a rest => cases rest with | nil => simp at hlen2 | cons b rest' => have hb : 0 < b := sp.isPart.2 b (by simp) simp only [List.headD, List.sum_cons] at hsum ⊢ omega have hdom : Dominates lam [n - 1, 1] := dominates_stability sp.isPart hsum hn hhead have hpart_stab : IsPartition [n - 1, 1] := by constructor · simp; omega · intro m hm; simp only [List.mem_cons, List.not_mem_nil, or_false] at hm rcases hm with rfl | rfl <;> omega have h1 := exact_multiplicity_partition_Rd v hv lam sp 1 Nat.one_pos {x} (by simp) have h2 := dominance_mono_M_star sp.isPart hpart_stab hdom 1 Nat.one_pos have hcat := M_star_stability_add_catalan hn have hfilt : (Finset.univ.filter (fun ε : Fin n → Bool => rademacherSum v ε = x)) = (Finset.univ.filter (fun ε : Fin n → Bool => rademacherSum v ε ∈ ({x} : Finset (Fin D → ℝ)))) := by ext ε; simp rw [hfilt] omega /-- **Headline Theorem 5 (Exact Erdős Uniqueness Theorem in `ℝ^D`)**: For all `n ≥ 2` and nonzero vectors `v : Fin n → (Fin D → ℝ)`, the Erdős bound `choose n (n / 2)` is attained if and only if all `v i` are equal up to sign. -/ theorem exact_erdos_uniqueness_Rd {n D : ℕ} (hn : 2 ≤ n) (v : Fin n → (Fin D → ℝ)) (hv : ∀ i, v i ≠ 0) : (∃ x : Fin D → ℝ, (Finset.univ.filter (fun ε : Fin n → Bool => rademacherSum v ε = x)).card = Nat.choose n (n / 2)) ↔ (∀ i j : Fin n, v i = v j ∨ v i = -v j) := by constructor · rintro ⟨x, hx⟩ by_contra hnot push Not at hnot have hstab := exact_catalan_stability_Rd hn v hv hnot x have hcat_pos : 0 < catalan (n / 2) := by have hcb : (n / 2 + 1) * catalan (n / 2) = Nat.choose (2 * (n / 2)) (n / 2) := by rw [catalan_eq_centralBinom_div, Nat.centralBinom_eq_two_mul_choose] exact Nat.mul_div_cancel' (Nat.succ_dvd_centralBinom (n / 2)) have hpos : 0 < Nat.choose (2 * (n / 2)) (n / 2) := Nat.choose_pos (by omega) by_contra h0 have hzero : catalan (n / 2) = 0 := by omega rw [hzero, mul_zero] at hcb omega have hcb_ge : catalan (n / 2) ≤ Nat.choose n (n / 2) := by have := M_star_stability_add_catalan hn; omega omega · intro hall let i₀ : Fin n := ⟨0, by omega⟩ let w : Fin D → ℝ := v i₀ let flip : (Fin n → Bool) ≃ (Fin n → Bool) := { toFun := fun ε i => if v i = w then ε i else !(ε i) invFun := fun ε i => if v i = w then ε i else !(ε i) left_inv := fun ε => by ext i; dsimp; split_ifs <;> simp right_inv := fun ε => by ext i; dsimp; split_ifs <;> simp } let x : Fin D → ℝ := ((2 * ((n / 2 : ℕ) : ℝ) - (n : ℝ))) • w refine ⟨x, ?_⟩ have hsum_flip : ∀ ε : Fin n → Bool, rademacherSum v ε = ((2 * ((Finset.univ.filter fun i : Fin n => flip ε i = true).card : ℝ) - (n : ℝ))) • w := by intro ε have hterm : ∀ i : Fin n, (if ε i then v i else -v i) = (if flip ε i then (1 : ℝ) else (-1 : ℝ)) • w := by intro i rcases hall i i₀ with h | h · simp only [flip, Equiv.coe_fn_mk, h, ↓reduceIte, w]; cases ε i <;> simp · have hne : v i ≠ w := by intro heq have hadd : w + w = 0 := by have h1 : w = -w := heq.symm.trans h conv_lhs => rhs; rw [h1] exact add_neg_cancel w have hw0 : w = 0 := by ext r have hr := congrFun hadd r simp only [Pi.add_apply, Pi.zero_apply] at hr ⊢ linarith exact hv i₀ hw0 have hflip_i : flip ε i = !(ε i) := by simp [flip, hne] rw [hflip_i, h] cases ε i <;> simp [w] unfold rademacherSum simp_rw [hterm] rw [← Finset.sum_smul] congr 1 have h1 : ∀ i : Fin n, (if flip ε i = true then (1 : ℝ) else -1) = (if flip ε i = true then (2 : ℝ) else 0) - 1 := by intro i; cases flip ε i <;> norm_num simp_rw [h1, Finset.sum_sub_distrib, Finset.sum_const, Finset.card_univ, Fintype.card_fin, nsmul_eq_mul, mul_one] congr 1 rw [← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul, mul_comm] have hw_ne : w ≠ 0 := hv i₀ have hsmul_inj : ∀ c₁ c₂ : ℝ, c₁ • w = c₂ • w → c₁ = c₂ := by intro c₁ c₂ h have : (c₁ - c₂) • w = 0 := by rw [sub_smul, h, sub_self] rcases smul_eq_zero.mp this with hc | hw0 · exact sub_eq_zero.mp hc · exact absurd hw0 hw_ne have hbij : (Finset.univ.filter (fun ε : Fin n → Bool => rademacherSum v ε = x)).card = (Finset.powersetCard (n / 2) (Finset.univ : Finset (Fin n))).card := by refine Finset.card_bij (fun ε _ => Finset.univ.filter fun i : Fin n => flip ε i = true) ?_ ?_ ?_ · intro ε hε simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hε rw [hsum_flip ε] at hε have hc := hsmul_inj _ _ hε have hcard : (Finset.univ.filter fun i : Fin n => flip ε i = true).card = n / 2 := by have hq : ((Finset.univ.filter fun i : Fin n => flip ε i = true).card : ℝ) = ((n / 2 : ℕ) : ℝ) := by linarith exact Nat.cast_injective hq exact Finset.mem_powersetCard.mpr ⟨Finset.subset_univ _, hcard⟩ · intro ε₁ _ ε₂ _ heq apply flip.injective ext i have hmem : i ∈ Finset.univ.filter (fun j : Fin n => flip ε₁ j = true) ↔ i ∈ Finset.univ.filter (fun j : Fin n => flip ε₂ j = true) := by rw [heq] simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hmem cases h1 : flip ε₁ i <;> cases h2 : flip ε₂ i <;> simp [h1, h2] at hmem ⊢ · intro S hS rcases Finset.mem_powersetCard.mp hS with ⟨_, hScard⟩ let δ : Fin n → Bool := fun i => decide (i ∈ S) refine ⟨flip.symm δ, ?_, ?_⟩ · simp only [Finset.mem_filter, Finset.mem_univ, true_and, hsum_flip, flip.apply_symm_apply] have hfilt : (Finset.univ.filter fun i : Fin n => δ i = true) = S := by ext i; simp [δ] rw [hfilt, hScard] · ext i; simp [δ] rw [hbij, Finset.card_powersetCard, Finset.card_univ, Fintype.card_fin] /-- Canonical bounded-multiplicity extremal partition `(m, …, m, r)` of `n = q * m + r`. -/ def boundedMultPartition (n m : ℕ) : List ℕ := List.replicate (n / m) m ++ if n % m = 0 then [] else [n % m] lemma isPartition_boundedMultPartition {n m : ℕ} (hm : 0 < m) : IsPartition (boundedMultPartition n m) := by unfold boundedMultPartition split_ifs with hrem · rw [List.append_nil] exact ⟨List.pairwise_replicate.mpr (Or.inr le_rfl), fun x hx => by rw [List.eq_of_mem_replicate hx]; exact hm⟩ · constructor · rw [List.pairwise_append] refine ⟨List.pairwise_replicate.mpr (Or.inr le_rfl), List.pairwise_singleton _ _, fun x hx y hy => ?_⟩ rw [List.eq_of_mem_replicate hx] simp only [List.mem_singleton] at hy subst hy exact le_of_lt (Nat.mod_lt n hm) · intro x hx rcases List.mem_append.mp hx with h1 | h2 · rw [List.eq_of_mem_replicate h1]; exact hm · simp only [List.mem_singleton] at h2; omega lemma dominates_boundedMult {lam : List ℕ} {n m : ℕ} (hlam : IsPartition lam) (hsum : lam.sum = n) (_hm : 0 < m) (hmax : lam.headD 0 ≤ m) : Dominates lam (boundedMultPartition n m) := by have hbm_sum : (boundedMultPartition n m).sum = n := by unfold boundedMultPartition split_ifs with hrem · simp [List.sum_replicate, Nat.div_mul_cancel (Nat.dvd_of_mod_eq_zero hrem)] · simp only [List.sum_append, List.sum_replicate, smul_eq_mul, List.sum_singleton] have hdm := Nat.div_add_mod n m rw [mul_comm] at hdm exact hdm refine ⟨hsum.trans hbm_sum.symm, fun s => ?_⟩ by_cases hs : s ≤ n / m · have hlhs : prefixSum lam s ≤ s * m := by unfold prefixSum calc ∑ i ∈ Finset.range s, partAt lam i ≤ ∑ _i ∈ Finset.range s, m := Finset.sum_le_sum fun i _ => by by_cases hi : i < lam.length · rw [partAt_lt hi]; exact le_trans (hlam.le_headD ⟨i, hi⟩) hmax · rw [partAt_eq_zero_of_le (by omega)]; exact Nat.zero_le _ _ = s * m := by simp have hrhs : prefixSum (boundedMultPartition n m) s = s * m := by unfold prefixSum have hterm : ∀ i ∈ Finset.range s, partAt (boundedMultPartition n m) i = m := by intro i hi have his : i < s := Finset.mem_range.mp hi have hlen : i < (List.replicate (n / m) m).length := by simp; omega rw [partAt_lt (by unfold boundedMultPartition; simp; omega)] unfold boundedMultPartition rw [List.getElem_append_left hlen, List.getElem_replicate] rw [Finset.sum_congr rfl hterm]; simp omega · have hrhs : prefixSum (boundedMultPartition n m) s = n := by have hlen : (boundedMultPartition n m).length ≤ s := by unfold boundedMultPartition split_ifs <;> simp <;> omega rw [prefixSum_eq_sum_of_length_le hlen, hbm_sum] have hlhs : prefixSum lam s ≤ lam.sum := by rw [← prefixSum_eq_sum_of_length_le (l := lam) (s := max lam.length s) (le_max_left _ _)] unfold prefixSum exact Finset.sum_le_sum_of_subset (Finset.range_mono (le_max_right _ _)) omega /-- **Headline Theorem 6 (Exact `m`-Bounded-Multiplicity Littlewood–Offord Theorem in `ℝ^D`)**: If no signed equivalence class `{j : v j = ± v i}` has size exceeding `m` (`m ≥ 1`), then for every `k ≥ 1` and every `T : Finset (Fin D → ℝ)` of size `≤ k`, `|{ε : ∑ ε_i v_i ∈ T}| ≤ M_k*(m^q, r)` where `n = q * m + r`. Interpolates continuously from Erdős (`m = n`) to Stanley (`m = 1`), exact for all `(n, m, k)`. -/ theorem exact_bounded_multiplicity_Rd {n D m : ℕ} (hm : 0 < m) (v : Fin n → (Fin D → ℝ)) (hv : ∀ i, v i ≠ 0) (hmult : ∀ i : Fin n, (Finset.univ.filter fun j : Fin n => v j = v i ∨ v j = -v i).card ≤ m) (k : ℕ) (hk : 0 < k) (T : Finset (Fin D → ℝ)) (hT : T.card ≤ k) : (Finset.univ.filter (fun ε : Fin n → Bool => rademacherSum v ε ∈ T)).card ≤ M_star (boundedMultPartition n m) k := by obtain ⟨lam, hsum, ⟨sp⟩⟩ := exists_signedPartition v have hhead : lam.headD 0 ≤ m := by cases hlam : lam with | nil => simp | cons a rest => have ha_pos : 0 < a := sp.isPart.2 a (by simp [hlam]) have hcard0 : (Finset.univ.filter fun j : Fin n => sp.cls j = ⟨0, by simp [hlam]⟩).card = a := by simpa [hlam] using sp.card_fiber ⟨0, by simp [hlam]⟩ obtain ⟨i, hi⟩ := Finset.card_pos.mp (hcard0.symm ▸ ha_pos) have hsub : (Finset.univ.filter fun j : Fin n => sp.cls j = ⟨0, by simp [hlam]⟩) ⊆ (Finset.univ.filter fun j : Fin n => v j = v i ∨ v j = -v i) := by intro j hj simp only [Finset.mem_filter, Finset.mem_univ, true_and] at hi hj ⊢ exact sp.same_cls j i (hj.trans hi.symm) have hle := le_trans (Finset.card_le_card hsub) (hmult i) simpa [hcard0] using hle have hdom := dominates_boundedMult sp.isPart hsum hm hhead exact le_trans (exact_multiplicity_partition_Rd v hv lam sp k hk T hT) (dominance_mono_M_star sp.isPart (isPartition_boundedMultPartition hm) hdom k hk) /-- Canonical `d`-distinct extremal partition `(n - d + 1, 1, …, 1)`. -/ def dDistinctPartition (n d : ℕ) : List ℕ := (n - d + 1) :: List.replicate (d - 1) 1 lemma isPartition_dDistinct {n d : ℕ} (_hd : 1 ≤ d) (_hdn : d ≤ n) : IsPartition (dDistinctPartition n d) := by unfold dDistinctPartition constructor · rw [List.pairwise_cons] refine ⟨fun y hy => ?_, List.pairwise_replicate.mpr (Or.inr le_rfl)⟩ rw [List.eq_of_mem_replicate hy]; omega · intro x hx simp only [List.mem_cons] at hx rcases hx with rfl | h2 · omega · rw [List.eq_of_mem_replicate h2]; omega lemma dominates_dDistinct {lam : List ℕ} {n d : ℕ} (hlam : IsPartition lam) (hsum : lam.sum = n) (hd : 1 ≤ d) (hglen : d ≤ lam.length) : Dominates lam (dDistinctPartition n d) := by have hdn : d ≤ n := le_trans hglen (hsum ▸ hlam.length_le_sum) have hd_sum : (dDistinctPartition n d).sum = n := by unfold dDistinctPartition; simp [List.sum_replicate]; omega refine ⟨hsum.trans hd_sum.symm, fun s => ?_⟩ cases s with | zero => simp [prefixSum] | succ s => by_cases hs : s + 1 ≤ d · -- `prefixSum lam (s + 1) + (d - (s + 1)) ≤ lam.sum = n` because remaining `≥ d - (s + 1)` parts are `≥ 1` have hrem_ge : d - (s + 1) ≤ ∑ i ∈ Finset.Ico (s + 1) d, partAt lam i := by calc d - (s + 1) = ∑ _i ∈ Finset.Ico (s + 1) d, 1 := by simp _ ≤ ∑ i ∈ Finset.Ico (s + 1) d, partAt lam i := Finset.sum_le_sum fun i hi => by have hid : i < lam.length := lt_of_lt_of_le (Finset.mem_Ico.mp hi).2 hglen rw [partAt_lt hid]; exact hlam.2 _ (List.getElem_mem hid) have hsplit : prefixSum lam d = prefixSum lam (s + 1) + ∑ i ∈ Finset.Ico (s + 1) d, partAt lam i := by unfold prefixSum; exact (Finset.sum_range_add_sum_Ico _ hs).symm have hd_le_sum : prefixSum lam d ≤ n := by rw [← hsum, ← prefixSum_eq_sum_of_length_le (l := lam) (s := lam.length) le_rfl] unfold prefixSum; exact Finset.sum_le_sum_of_subset (Finset.range_mono hglen) have hrhs : prefixSum (dDistinctPartition n d) (s + 1) = n - d + 1 + s := by unfold prefixSum rw [Finset.sum_range_succ'] have h0 : partAt (dDistinctPartition n d) 0 = n - d + 1 := by simp [dDistinctPartition, partAt] have htail : ∑ k ∈ Finset.range s, partAt (dDistinctPartition n d) (k + 1) = s := by have ht : ∀ k ∈ Finset.range s, partAt (dDistinctPartition n d) (k + 1) = 1 := fun k hk => by have hks : k < s := Finset.mem_range.mp hk rw [partAt_lt (by simp [dDistinctPartition]; omega)] simp [dDistinctPartition, List.getElem_replicate] rw [Finset.sum_congr rfl ht]; simp rw [h0, htail, add_comm] omega · have hrhs : prefixSum (dDistinctPartition n d) (s + 1) = n := by rw [prefixSum_eq_sum_of_length_le (by simp [dDistinctPartition]; omega), hd_sum] have hlhs : prefixSum lam (s + 1) ≤ n := by rw [← hsum, ← prefixSum_eq_sum_of_length_le (l := lam) (s := max lam.length (s + 1)) (le_max_left _ _)] unfold prefixSum; exact Finset.sum_le_sum_of_subset (Finset.range_mono (le_max_right _ _)) omega /-- **Headline Theorem 7 (Exact `d`-Distinct-Magnitudes Littlewood–Offord Theorem in `ℝ^D`)**: If `v : Fin n → (Fin D → ℝ)` has at least `d` distinct signed equivalence classes (`1 ≤ d ≤ n`), then for every `k ≥ 1` and every `T : Finset (Fin D → ℝ)` of size `≤ k`, `|{ε : ∑ ε_i v_i ∈ T}| ≤ M_k*(n - d + 1, 1^{d-1})`. Interpolates smoothly from Erdős (`d = 1`) to Stanley (`d = n`), exact for all `(n, d, k)`. -/ theorem exact_d_distinct_Rd {n D d : ℕ} (hd : 1 ≤ d) (v : Fin n → (Fin D → ℝ)) (hv : ∀ i, v i ≠ 0) (hdist : d ≤ (Finset.univ.image (fun i : Fin n => ({v i, -v i} : Finset (Fin D → ℝ)))).card) (k : ℕ) (hk : 0 < k) (T : Finset (Fin D → ℝ)) (hT : T.card ≤ k) : (Finset.univ.filter (fun ε : Fin n → Bool => rademacherSum v ε ∈ T)).card ≤ M_star (dDistinctPartition n d) k := by classical obtain ⟨lam, hsum, ⟨sp⟩⟩ := exists_signedPartition v have hglen : d ≤ lam.length := by have himg : (Finset.univ.image (fun i : Fin n => ({v i, -v i} : Finset (Fin D → ℝ)))).card ≤ (Finset.univ.image sp.cls).card := by -- Map each `{v i, -v i}` back through `sp.cls`: `sp.cls i = sp.cls j → {v i, -v i} = {v j, -v j}` let f : Fin lam.length → Finset (Fin D → ℝ) := fun c => if h : ∃ i : Fin n, sp.cls i = c then {v (Classical.choose h), -v (Classical.choose h)} else ∅ have hsub : (Finset.univ.image (fun i : Fin n => ({v i, -v i} : Finset (Fin D → ℝ)))) ⊆ (Finset.univ.image sp.cls).image f := by intro s hs rcases Finset.mem_image.mp hs with ⟨i, _, rfl⟩ refine Finset.mem_image.mpr ⟨sp.cls i, Finset.mem_image.mpr ⟨i, Finset.mem_univ _, rfl⟩, ?_⟩ have hex : ∃ j : Fin n, sp.cls j = sp.cls i := ⟨i, rfl⟩ simp only [f, hex, ↓reduceDIte] rcases sp.same_cls (Classical.choose hex) i (Classical.choose_spec hex) with h | h · simp [h] · ext y; simp [h]; tauto exact le_trans (Finset.card_le_card hsub) Finset.card_image_le have hle_len : (Finset.univ.image sp.cls).card ≤ lam.length := by calc (Finset.univ.image sp.cls).card ≤ (Finset.univ : Finset (Fin lam.length)).card := Finset.card_le_univ _ _ = lam.length := Fintype.card_fin _ omega have hdn : d ≤ n := le_trans hglen (hsum ▸ sp.isPart.length_le_sum) have hdom := dominates_dDistinct sp.isPart hsum hd hglen exact le_trans (exact_multiplicity_partition_Rd v hv lam sp k hk T hT) (dominance_mono_M_star sp.isPart (isPartition_dDistinct hd hdn) hdom k hk) /-- **Headline Theorem 8 (Exact `t`-Deviant Stability Theorem in `ℝ^D`)**: If every signed equivalence class has size at most `n - t` (`1 ≤ t`, `2 * t ≤ n`), then `|{ε : ∑ ε_i v_i ∈ T}| ≤ M_k*([n - t, t])`, attained by `(1^{n-t}, 2^t)`. -/ theorem exact_t_deviant_Rd {n D t : ℕ} (ht : 1 ≤ t) (h2t : 2 * t ≤ n) (v : Fin n → (Fin D → ℝ)) (hv : ∀ i, v i ≠ 0) (hdev : ∀ i : Fin n, (Finset.univ.filter fun j : Fin n => v j = v i ∨ v j = -v i).card ≤ n - t) (k : ℕ) (hk : 0 < k) (T : Finset (Fin D → ℝ)) (hT : T.card ≤ k) : (Finset.univ.filter (fun ε : Fin n → Bool => rademacherSum v ε ∈ T)).card ≤ M_star [n - t, t] k := by have hbm : boundedMultPartition n (n - t) = [n - t, t] := by unfold boundedMultPartition by_cases h2 : 2 * t = n · have hnt : n - t = t := by omega have hdiv : n / (n - t) = 2 := by rw [hnt, show n = 2 * t by omega, Nat.mul_div_cancel _ (by omega)] have hmod : n % (n - t) = 0 := by rw [hnt, show n = 2 * t by omega, Nat.mul_mod_left] rw [hdiv, hmod, if_pos rfl, List.append_nil, hnt] rfl · have hdiv : n / (n - t) = 1 := Nat.div_eq_of_lt_le (by omega) (by omega) have hmod : n % (n - t) = t := by have hdm := Nat.div_add_mod n (n - t) rw [hdiv, mul_one] at hdm omega rw [hdiv, hmod, if_neg (by omega)] rfl rw [← hbm] exact exact_bounded_multiplicity_Rd (by omega) v hv hdev k hk T hT end MultiplicityLittlewoodOfford /-! ## Axiom Verification for All Headline Theorems -/ #print axioms MultiplicityLittlewoodOfford.Sl2Poset.hard_lefschetz_inj #print axioms MultiplicityLittlewoodOfford.Sl2Poset.card_kColoring_le #print axioms MultiplicityLittlewoodOfford.exact_multiplicity_partition_littlewood_offord #print axioms MultiplicityLittlewoodOfford.exact_multiplicity_partition_intervals #print axioms MultiplicityLittlewoodOfford.canonical_multiset_sharpness #print axioms MultiplicityLittlewoodOfford.exact_multiplicity_partition_Rd #print axioms MultiplicityLittlewoodOfford.dominance_mono_M_star #print axioms MultiplicityLittlewoodOfford.M_star_stability_add_catalan #print axioms MultiplicityLittlewoodOfford.exact_catalan_stability_Rd #print axioms MultiplicityLittlewoodOfford.exact_erdos_uniqueness_Rd #print axioms MultiplicityLittlewoodOfford.exact_bounded_multiplicity_Rd #print axioms MultiplicityLittlewoodOfford.exact_d_distinct_Rd #print axioms MultiplicityLittlewoodOfford.exact_t_deviant_Rd