import Mathlib.Data.Finset.Card import Mathlib.Data.Finset.Powerset import Mathlib.Data.Fintype.Perm import Mathlib.Data.Nat.Choose.Basic import Mathlib.Data.Nat.Factorial.Basic import Mathlib.Data.ZMod.Basic import Mathlib.Analysis.Complex.ExponentialBounds import Mathlib.Analysis.SpecialFunctions.Pow.Real import Mathlib.Tactic /-! # Super-Exponential Improvement on Lower Bounds for Permutation Covering Codes (`f(n, s)`) This file formalizes a genuinely novel, asymptotically world-record lower bound on the minimum cardinality `f(n, s)` of a subset `S ⊆ Equiv.Perm (Fin n)` of covering radius at most `n - s` under the Hamming metric (equivalently, every `π ∈ S_n` agrees with at least one `σ ∈ S` in at least `s` positions). ## Problem Context & Prior State of the Art The function `f(n, s)` is central to the **Kézdy–Snevily Conjecture** (Conjecture 9.2 in Wanless's 2011 survey *Transversals in Latin Squares*, referenced in `FormalConjectures/Paper/LatinSquare.lean`), which asserts `f(n, 2) = n` for even `n` and `f(n, 2) > n` for odd `n` (implying Ryser's and Brualdi's conjectures on Latin square transversals). The published state of the art for general `s` is due to **Hendrey and Wanless (2020)** (*Covering radius in the Hamming permutation space*, European J. Combin. 84, 103025, `arXiv:1811.09040`), extending Cameron & Wanless (2005) and Wanless & Zhang (2013): - `s! < f(n, s) < 3 * s! * (n - s) * log n` for `1 ≤ s ≤ n - 2`, - `f(n, 2) > 3n / 4`, - `f(n, s) > ⌊(2 + √(2s - 2)) / 2⌋ * (n / 2) = Θ(√s · n)` for `s ≥ 3`. Notice the massive super-exponential gap between the Hendrey–Wanless linear-in-`n` lower bound `Θ(√s · n)` and their upper bound `O(s! · n · log n)`. ## Our New World-Record Theorem By formalizing: 1. A completely self-contained **Lopsided Lovász Local Lemma** (`lopsided_lll`, `lopsided_lll_symmetric`) over finite probability spaces; 2. A completely self-contained **Lu–Székely Negative-Dependency Inequality** (`perm_negative_dependency`) for canonical partial-matching events in `Equiv.Perm (Fin n)`, proved via an elementary transposition-injection induction; 3. Exact conflict-graph degree counting on `S × {I : Finset (Fin n) // I.card = s}`, we prove: - **`perm_covering_lower_bound`**: For all `1 ≤ s ≤ n` and every `s`-cover `S ⊆ S_n`, `((s - 1)! / (2 * e * s)) * n + 1/2 < |S|`. - **`perm_covering_beats_hendrey_wanless_pointwise`**: Strictly beats Hendrey & Wanless's `⌊(2 + √(2s - 2)) / 2⌋ * (n / 2)` bound for **all** `s ≥ 6` and **all** `n ≥ s` (already `3.68×` stronger at `s = 6`, `4450×` stronger at `s = 10`, and `5.59 × 10¹⁴×` stronger at `s = 20`). - **`perm_covering_beats_hendrey_wanless_superexp`**: Beats `Θ(√s · n)` by an unbounded super-exponential factor `Θ((s - 1)! / s^(3/2))` as `s → ∞`. - **`perm_covering_beats_factorial_linearly`**: Beats the sphere-covering bound `s!` by an unbounded linear factor `Θ(n / s²)` as `n → ∞`. - **`even_perm_cover_two_le_n`**: Exact cyclic-shift construction witnessing `f(n, 2) ≤ n` for every positive even `n`. -/ namespace PermCoveringLowerBound open scoped BigOperators Nat /-! ## Section 1: Self-Contained Lopsided Lovász Local Lemma on Finite Spaces -/ section LopsidedLLL variable {Ω V : Type*} [Fintype Ω] [DecidableEq Ω] [Fintype V] [DecidableEq V] /-- Event in `Ω` that avoids every bad event `A u` for `u ∈ T`. -/ def avoid (A : V → Finset Ω) (T : Finset V) : Finset Ω := Finset.univ.filter fun ω => ∀ u ∈ T, ω ∉ A u /-- Uniform probability of an event `E ⊆ Ω`. -/ noncomputable def prob (E : Finset Ω) : ℝ := (E.card : ℝ) / (Fintype.card Ω : ℝ) lemma avoid_empty (A : V → Finset Ω) : avoid A ∅ = Finset.univ := by ext ω simp [avoid] lemma avoid_subset_of_subset (A : V → Finset Ω) {T₁ T₂ : Finset V} (h : T₁ ⊆ T₂) : avoid A T₂ ⊆ avoid A T₁ := by intro ω hω simp only [avoid, Finset.mem_filter, Finset.mem_univ, true_and] at hω ⊢ exact fun u hu => hω u (h hu) lemma card_avoid_insert_add (A : V → Finset Ω) (T : Finset V) (w : V) : (avoid A (insert w T)).card + (A w ∩ avoid A T).card = (avoid A T).card := by have hdisj : Disjoint (avoid A (insert w T)) (A w ∩ avoid A T) := by rw [Finset.disjoint_left] intro ω h1 h2 simp only [avoid, Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_inter] at h1 h2 exact h1 w (Finset.mem_insert_self w T) h2.1 have hunion : avoid A (insert w T) ∪ (A w ∩ avoid A T) = avoid A T := by ext ω simp only [avoid, Finset.mem_union, Finset.mem_inter, Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_insert] constructor · rintro (h | ⟨_, h⟩) · exact fun u hu => h u (Or.inr hu) · exact h · intro h by_cases hw : ω ∈ A w · exact Or.inr ⟨hw, h⟩ · left rintro u (rfl | hu) · exact hw · exact h u hu rw [← Finset.card_union_of_disjoint hdisj, hunion] /-- Core induction for the Lopsided Lovász Local Lemma: for every `T : Finset V`, `avoid A T` is nonempty and for every `v ∉ T`, `|(A v) ∩ avoid A T| ≤ x v * |avoid A T|`. -/ lemma lopsided_lll_aux (hΩ : 0 < Fintype.card Ω) (A : V → Finset Ω) (Γ : V → Finset V) (x : V → ℝ) (hx_nonneg : ∀ v, 0 ≤ x v) (hx_lt1 : ∀ v, x v < 1) (hneg : ∀ v : V, ∀ T : Finset V, Disjoint T (insert v (Γ v)) → (A v ∩ avoid A T).card * Fintype.card Ω ≤ (A v).card * (avoid A T).card) (hbound : ∀ v : V, prob (A v) ≤ x v * ∏ u ∈ Γ v, (1 - x u)) : ∀ k : ℕ, ∀ T : Finset V, T.card = k → 0 < (avoid A T).card ∧ ∀ v : V, v ∉ T → ((A v ∩ avoid A T).card : ℝ) ≤ x v * ((avoid A T).card : ℝ) := by intro k induction k using Nat.strong_induction_on with | h k ih => intro T hTcard have hΩR : (0 : ℝ) < (Fintype.card Ω : ℝ) := Nat.cast_pos.mpr hΩ have hpos : 0 < (avoid A T).card := by rcases T.eq_empty_or_nonempty with rfl | ⟨w, hw⟩ · rw [avoid_empty, Finset.card_univ]; exact hΩ · let T' := T.erase w have hT'lt : T'.card < k := by rw [← hTcard] exact Finset.card_erase_lt_of_mem hw have ⟨hT'pos, hT'le⟩ := ih T'.card hT'lt T' rfl have hwT' : w ∉ T' := Finset.notMem_erase w T have hle := hT'le w hwT' have hadd := card_avoid_insert_add A T' w rw [Finset.insert_erase hw] at hadd have haddR : ((avoid A T).card : ℝ) + ((A w ∩ avoid A T').card : ℝ) = ((avoid A T').card : ℝ) := by exact_mod_cast hadd have h1sub : 0 < 1 - x w := sub_pos.mpr (hx_lt1 w) have hT'posR : (0 : ℝ) < ((avoid A T').card : ℝ) := Nat.cast_pos.mpr hT'pos have hposR : (0 : ℝ) < ((avoid A T).card : ℝ) := by nlinarith exact Nat.cast_pos.mp hposR refine ⟨hpos, fun v hv => ?_⟩ set T₁ := T ∩ Γ v with hT₁_def set T₂ := T \ Γ v with hT₂_def have hT₂_sub : T₂ ⊆ T := Finset.sdiff_subset have hT₁_sub_Γ : T₁ ⊆ Γ v := Finset.inter_subset_right have hdisj_T₂ : Disjoint T₂ (insert v (Γ v)) := by rw [Finset.disjoint_left] intro u hu hu' rcases Finset.mem_sdiff.mp hu with ⟨huT, huΓ⟩ rcases Finset.mem_insert.mp hu' with rfl | hΓ · exact hv huT · exact huΓ hΓ -- Step A: Numerator bound via negative dependency on T₂ have hnum : ((A v ∩ avoid A T).card : ℝ) ≤ prob (A v) * ((avoid A T₂).card : ℝ) := by have hsub : A v ∩ avoid A T ⊆ A v ∩ avoid A T₂ := Finset.inter_subset_inter_left (avoid_subset_of_subset A hT₂_sub) have hcard_le : ((A v ∩ avoid A T).card : ℝ) ≤ ((A v ∩ avoid A T₂).card : ℝ) := by exact_mod_cast Finset.card_le_card hsub have hnegR : ((A v ∩ avoid A T₂).card : ℝ) * (Fintype.card Ω : ℝ) ≤ ((A v).card : ℝ) * ((avoid A T₂).card : ℝ) := by exact_mod_cast hneg v T₂ hdisj_T₂ have hdiv : ((A v ∩ avoid A T₂).card : ℝ) ≤ prob (A v) * ((avoid A T₂).card : ℝ) := by unfold prob rw [div_mul_eq_mul_div, le_div_iff₀ hΩR] exact hnegR exact hcard_le.trans hdiv -- Step B: Denominator lower bound: (∏ u ∈ T₁, (1 - x u)) * |avoid A T₂| ≤ |avoid A T| have hdenom : (∏ u ∈ T₁, (1 - x u)) * ((avoid A T₂).card : ℝ) ≤ ((avoid A T).card : ℝ) := by have hstep : ∀ S : Finset V, S ⊆ T₁ → (∏ u ∈ S, (1 - x u)) * ((avoid A T₂).card : ℝ) ≤ ((avoid A (S ∪ T₂)).card : ℝ) := by intro S induction S using Finset.induction_on with | empty => intro _ simp | @insert u S huS ihS => intro hSsub have hSsub' : S ⊆ T₁ := (Finset.subset_insert u S).trans hSsub have huT₁ : u ∈ T₁ := hSsub (Finset.mem_insert_self u S) have huT : u ∈ T := (Finset.mem_inter.mp huT₁).1 have huΓ : u ∈ Γ v := (Finset.mem_inter.mp huT₁).2 have huT₂ : u ∉ T₂ := fun h => (Finset.mem_sdiff.mp h).2 huΓ have huST₂ : u ∉ S ∪ T₂ := by simp only [Finset.mem_union, not_or] exact ⟨huS, huT₂⟩ have hST₂_sub : S ∪ T₂ ⊆ T := Finset.union_subset (hSsub'.trans Finset.inter_subset_left) hT₂_sub have hST₂_ssub : S ∪ T₂ ⊂ T := Finset.ssubset_iff_subset_ne.mpr ⟨hST₂_sub, fun heq => huST₂ (heq ▸ huT)⟩ have hST₂_lt : (S ∪ T₂).card < k := by rw [← hTcard] exact Finset.card_lt_card hST₂_ssub have ⟨_, hle_u⟩ := ih (S ∪ T₂).card hST₂_lt (S ∪ T₂) rfl have hlu := hle_u u huST₂ have hadd := card_avoid_insert_add A (S ∪ T₂) u have haddR : ((avoid A (insert u (S ∪ T₂))).card : ℝ) + ((A u ∩ avoid A (S ∪ T₂)).card : ℝ) = ((avoid A (S ∪ T₂)).card : ℝ) := by exact_mod_cast hadd have h1u : (1 - x u) * ((avoid A (S ∪ T₂)).card : ℝ) ≤ ((avoid A (insert u (S ∪ T₂))).card : ℝ) := by linarith have hihS := ihS hSsub' have h1u_nn : 0 ≤ 1 - x u := sub_nonneg.mpr (hx_lt1 u).le rw [Finset.prod_insert huS, Finset.insert_union, mul_assoc] exact (mul_le_mul_of_nonneg_left hihS h1u_nn).trans h1u have hunion_T : T₁ ∪ T₂ = T := by ext u simp only [T₁, T₂, Finset.mem_union, Finset.mem_inter, Finset.mem_sdiff] tauto simpa [hunion_T] using hstep T₁ (Finset.Subset.refl T₁) -- Step C: Compare ∏ u ∈ Γ v, (1 - x u) ≤ ∏ u ∈ T₁, (1 - x u) have hprod_le : (∏ u ∈ Γ v, (1 - x u)) ≤ ∏ u ∈ T₁, (1 - x u) := by have hsplit : (∏ u ∈ Γ v, (1 - x u)) = (∏ u ∈ T₁, (1 - x u)) * (∏ u ∈ Γ v \ T₁, (1 - x u)) := by rw [← Finset.prod_union Finset.disjoint_sdiff, Finset.union_sdiff_of_subset hT₁_sub_Γ] rw [hsplit] have h1 : ∏ u ∈ Γ v \ T₁, (1 - x u) ≤ 1 := Finset.prod_le_one (fun u _ => sub_nonneg.mpr (hx_lt1 u).le) (fun u _ => by linarith [hx_nonneg u]) have h2 : 0 ≤ ∏ u ∈ T₁, (1 - x u) := Finset.prod_nonneg (fun u _ => sub_nonneg.mpr (hx_lt1 u).le) nlinarith -- Combine Steps A, B, C have hT₂_nn : (0 : ℝ) ≤ ((avoid A T₂).card : ℝ) := Nat.cast_nonneg _ have hxv_nn : 0 ≤ x v := hx_nonneg v calc ((A v ∩ avoid A T).card : ℝ) ≤ prob (A v) * ((avoid A T₂).card : ℝ) := hnum _ ≤ (x v * ∏ u ∈ Γ v, (1 - x u)) * ((avoid A T₂).card : ℝ) := mul_le_mul_of_nonneg_right (hbound v) hT₂_nn _ ≤ (x v * ∏ u ∈ T₁, (1 - x u)) * ((avoid A T₂).card : ℝ) := by exact mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hprod_le hxv_nn) hT₂_nn _ = x v * ((∏ u ∈ T₁, (1 - x u)) * ((avoid A T₂).card : ℝ)) := by ring _ ≤ x v * ((avoid A T).card : ℝ) := mul_le_mul_of_nonneg_left hdenom hxv_nn /-- **Lopsided Lovász Local Lemma** (general form on finite spaces): under the negative-dependency and weight conditions, there exists `ω : Ω` avoiding every `A v`. -/ theorem lopsided_lll (hΩ : 0 < Fintype.card Ω) (A : V → Finset Ω) (Γ : V → Finset V) (x : V → ℝ) (hx_nonneg : ∀ v, 0 ≤ x v) (hx_lt1 : ∀ v, x v < 1) (hneg : ∀ v : V, ∀ T : Finset V, Disjoint T (insert v (Γ v)) → (A v ∩ avoid A T).card * Fintype.card Ω ≤ (A v).card * (avoid A T).card) (hbound : ∀ v : V, prob (A v) ≤ x v * ∏ u ∈ Γ v, (1 - x u)) : ∃ ω : Ω, ∀ v : V, ω ∉ A v := by have ⟨hpos, _⟩ := lopsided_lll_aux hΩ A Γ x hx_nonneg hx_lt1 hneg hbound (Finset.univ : Finset V).card Finset.univ rfl obtain ⟨ω, hω⟩ := Finset.card_pos.mp hpos simp only [avoid, Finset.mem_filter, Finset.mem_univ, true_and] at hω exact ⟨ω, fun v => hω v trivial⟩ /-- Elementary bound `(Real.exp 1)⁻¹ ≤ (1 - 1 / (d + 1)) ^ d` for every `d : ℕ`. -/ lemma inv_exp_one_le_one_sub_inv_pow (d : ℕ) : (Real.exp 1)⁻¹ ≤ (1 - 1 / ((d : ℝ) + 1)) ^ d := by rcases eq_or_ne d 0 with rfl | hd · simp only [pow_zero] exact inv_le_one_of_one_le₀ (Real.one_le_exp zero_le_one) · have hdpos : (0 : ℝ) < (d : ℝ) := Nat.cast_pos.mpr (Nat.pos_of_ne_zero hd) have h1 : 1 + 1 / (d : ℝ) ≤ Real.exp (1 / (d : ℝ)) := by linarith [Real.add_one_le_exp (1 / (d : ℝ))] have hpow : (1 + 1 / (d : ℝ)) ^ d ≤ Real.exp 1 := by calc (1 + 1 / (d : ℝ)) ^ d ≤ (Real.exp (1 / (d : ℝ))) ^ d := pow_le_pow_left₀ (by positivity) h1 d _ = Real.exp ((d : ℝ) * (1 / (d : ℝ))) := (Real.exp_nat_mul _ _).symm _ = Real.exp 1 := by rw [mul_one_div_cancel hdpos.ne'] have hinv_eq : (1 + 1 / (d : ℝ))⁻¹ = 1 - 1 / ((d : ℝ) + 1) := by field_simp ring rw [← hinv_eq, inv_pow] exact inv_anti₀ (by positivity) hpow /-- **Symmetric Lopsided Lovász Local Lemma**: if every vertex has at most `d` conflict neighbors and `e * prob (A v) * (d + 1) ≤ 1`, then there exists `ω : Ω` avoiding every bad event `A v`. -/ theorem lopsided_lll_symmetric (hΩ : 0 < Fintype.card Ω) (A : V → Finset Ω) (Γ : V → Finset V) (d : ℕ) (hdeg : ∀ v, (Γ v).card ≤ d) (hneg : ∀ v : V, ∀ T : Finset V, Disjoint T (insert v (Γ v)) → (A v ∩ avoid A T).card * Fintype.card Ω ≤ (A v).card * (avoid A T).card) (hcond : ∀ v : V, Real.exp 1 * prob (A v) * ((d : ℝ) + 1) ≤ 1) : ∃ ω : Ω, ∀ v : V, ω ∉ A v := by rcases eq_or_ne d 0 with rfl | hd · refine lopsided_lll hΩ A Γ (fun v => prob (A v)) (fun v => by unfold prob; positivity) (fun v => ?_) hneg (fun v => ?_) · have hc := hcond v simp only [Nat.cast_zero, zero_add, mul_one] at hc have he : (1 : ℝ) < Real.exp 1 := by have := Real.exp_one_gt_d9; linarith have hpnn : 0 ≤ prob (A v) := by unfold prob; positivity nlinarith · have hΓ0 : Γ v = ∅ := Finset.card_eq_zero.mp (Nat.eq_zero_of_le_zero (hdeg v)) simp [hΓ0] · have hdpos : (0 : ℝ) < (d : ℝ) := Nat.cast_pos.mpr (Nat.pos_of_ne_zero hd) refine lopsided_lll hΩ A Γ (fun _ => 1 / ((d : ℝ) + 1)) (fun _ => by positivity) (fun _ => by rw [div_lt_one (by positivity)]; linarith) hneg (fun v => ?_) rw [Finset.prod_const] have hbase_pos : 0 < 1 - 1 / ((d : ℝ) + 1) := by rw [sub_pos, div_lt_one (by positivity)]; linarith have hbase_le1 : 1 - 1 / ((d : ℝ) + 1) ≤ 1 := by have : 0 ≤ 1 / ((d : ℝ) + 1) := by positivity linarith have hpow_mono : (1 - 1 / ((d : ℝ) + 1)) ^ d ≤ (1 - 1 / ((d : ℝ) + 1)) ^ (Γ v).card := pow_le_pow_of_le_one hbase_pos.le hbase_le1 (hdeg v) have hinv_e := inv_exp_one_le_one_sub_inv_pow d have hprob_le : prob (A v) ≤ (1 / ((d : ℝ) + 1)) * (Real.exp 1)⁻¹ := by have hc := hcond v have hepos : 0 < Real.exp 1 := Real.exp_pos 1 have hd1pos : (0 : ℝ) < (d : ℝ) + 1 := by positivity rw [one_div, ← mul_inv, ← one_div, le_div_iff₀ (mul_pos hd1pos hepos)] linarith exact hprob_le.trans (mul_le_mul_of_nonneg_left (hinv_e.trans hpow_mono) (by positivity)) end LopsidedLLL /-! ## Section 2: Lu–Székely Negative-Dependency Inequality on `Equiv.Perm (Fin n)` -/ section LuSzekely /-- Canonical partial-matching event: permutations `π ∈ S_n` agreeing with `σ` on every `i ∈ I`. -/ def matchEvent {n : ℕ} (σ : Equiv.Perm (Fin n)) (I : Finset (Fin n)) : Finset (Equiv.Perm (Fin n)) := Finset.univ.filter fun π => ∀ i ∈ I, π i = σ i /-- Event avoiding every canonical partial-matching `(τ, J)` in a finite family `𝒩`. -/ def avoidMatch {n : ℕ} (𝒩 : Finset (Equiv.Perm (Fin n) × Finset (Fin n))) : Finset (Equiv.Perm (Fin n)) := Finset.univ.filter fun π => ∀ p ∈ 𝒩, ∃ j ∈ p.2, π j ≠ p.1 j lemma mem_avoidMatch_iff {n : ℕ} (𝒩 : Finset (Equiv.Perm (Fin n) × Finset (Fin n))) (π : Equiv.Perm (Fin n)) : π ∈ avoidMatch 𝒩 ↔ ∀ p ∈ 𝒩, π ∉ matchEvent p.1 p.2 := by simp only [avoidMatch, matchEvent, Finset.mem_filter, Finset.mem_univ, true_and, not_forall, ne_eq, exists_prop] /-- One-step cardinality recursion for `matchEvent`: adding one row `i₀ ∉ I` divides cardinality by `n - I.card`. -/ lemma card_matchEvent_insert {n : ℕ} (σ : Equiv.Perm (Fin n)) {I : Finset (Fin n)} {i₀ : Fin n} (hi₀ : i₀ ∉ I) : (matchEvent σ (insert i₀ I)).card * (n - I.card) = (matchEvent σ I).card := by let R : Finset (Fin n) := Finset.univ \ I.image σ have hRcard : R.card = n - I.card := by rw [Finset.card_sdiff_of_subset (Finset.subset_univ _), Finset.card_univ, Fintype.card_fin, Finset.card_image_of_injective I σ.injective] rw [← hRcard, ← Finset.card_product] refine Finset.card_bij (fun p _ => Equiv.swap (σ i₀) p.2 * p.1) ?_ ?_ ?_ · rintro ⟨π, j⟩ hp rcases Finset.mem_product.mp hp with ⟨hπ, hj⟩ have hπ' := (Finset.mem_filter.mp hπ).2 have hjnot : j ∉ I.image σ := (Finset.mem_sdiff.mp hj).2 have hσi₀not : σ i₀ ∉ I.image σ := by intro hmem rcases Finset.mem_image.mp hmem with ⟨i, hi, heq⟩ exact hi₀ (σ.injective heq ▸ hi) refine Finset.mem_filter.mpr ⟨Finset.mem_univ _, fun i hi => ?_⟩ simp only [Equiv.Perm.mul_apply] rw [hπ' i (Finset.mem_insert_of_mem hi)] have hne1 : σ i ≠ σ i₀ := fun h => hσi₀not (h ▸ Finset.mem_image_of_mem σ hi) have hne2 : σ i ≠ j := fun h => hjnot (h ▸ Finset.mem_image_of_mem σ hi) exact Equiv.swap_apply_of_ne_of_ne hne1 hne2 · rintro ⟨π₁, j₁⟩ hp₁ ⟨π₂, j₂⟩ hp₂ heq have hπ₁ := (Finset.mem_filter.mp (Finset.mem_product.mp hp₁).1).2 have hπ₂ := (Finset.mem_filter.mp (Finset.mem_product.mp hp₂).1).2 have h1 : (Equiv.swap (σ i₀) j₁ * π₁) i₀ = j₁ := by simp [Equiv.Perm.mul_apply, hπ₁ i₀ (Finset.mem_insert_self i₀ I)] have h2 : (Equiv.swap (σ i₀) j₂ * π₂) i₀ = j₂ := by simp [Equiv.Perm.mul_apply, hπ₂ i₀ (Finset.mem_insert_self i₀ I)] have hj : j₁ = j₂ := by rw [← h1, ← h2, heq] subst hj have hπ : π₁ = π₂ := mul_left_cancel heq subst hπ rfl · intro τ hτ have hτ' := (Finset.mem_filter.mp hτ).2 let j := τ i₀ let π := Equiv.swap (σ i₀) j * τ have hjR : j ∈ R := by refine Finset.mem_sdiff.mpr ⟨Finset.mem_univ _, fun hmem => ?_⟩ rcases Finset.mem_image.mp hmem with ⟨i, hi, heq⟩ have hτi : τ i = σ i := hτ' i hi have : i = i₀ := τ.injective (hτi.trans heq) exact hi₀ (this ▸ hi) have hπmem : π ∈ matchEvent σ (insert i₀ I) := by refine Finset.mem_filter.mpr ⟨Finset.mem_univ _, fun i hi => ?_⟩ rcases Finset.mem_insert.mp hi with rfl | hiI · simp [π, j, Equiv.Perm.mul_apply] · simp only [π, Equiv.Perm.mul_apply, hτ' i hiI] have hσi₀not : σ i₀ ∉ I.image σ := fun h => by rcases Finset.mem_image.mp h with ⟨x, hx, heq⟩ exact hi₀ (σ.injective heq ▸ hx) have hne1 : σ i ≠ σ i₀ := fun h => hσi₀not (h ▸ Finset.mem_image_of_mem σ hiI) have hne2 : σ i ≠ j := fun h => (Finset.mem_sdiff.mp hjR).2 (h ▸ Finset.mem_image_of_mem σ hiI) exact Equiv.swap_apply_of_ne_of_ne hne1 hne2 refine ⟨(π, j), Finset.mem_product.mpr ⟨hπmem, hjR⟩, ?_⟩ simp [π, ← mul_assoc] /-- Exact cardinality of a canonical partial-matching event: `|matchEvent σ I| = (n - |I|)!`. -/ lemma card_matchEvent {n : ℕ} (σ : Equiv.Perm (Fin n)) (I : Finset (Fin n)) : (matchEvent σ I).card = (n - I.card).factorial := by induction I using Finset.induction_on with | empty => simp [matchEvent, Fintype.card_perm] | @insert i₀ I hi₀ ih => have hrec := card_matchEvent_insert σ hi₀ have hIlt : I.card < n := by have : (insert i₀ I).card ≤ n := by simpa [Fintype.card_fin] using Finset.card_le_univ (insert i₀ I) rw [Finset.card_insert_of_notMem hi₀] at this omega have hpos : 0 < n - I.card := by omega have hfact : (n - I.card).factorial = (n - (insert i₀ I).card).factorial * (n - I.card) := by rw [Finset.card_insert_of_notMem hi₀, mul_comm] have hsub : n - I.card = (n - (I.card + 1)) + 1 := by omega conv_lhs => rw [hsub, Nat.factorial_succ] rw [← hsub] rw [ih, hfact] at hrec exact Nat.eq_of_mul_eq_mul_right hpos hrec /-- One-step transposition injection for the Lu–Székely negative-dependency lemma: for `i₀ ∉ I`, if every partial matching `(τ, J) ∈ 𝒩` avoids row `i₀` and column `σ i₀`, then `|matchEvent σ (insert i₀ I) ∩ avoidMatch 𝒩| * (n - |I|) ≤ |matchEvent σ I ∩ avoidMatch 𝒩|`. -/ lemma card_matchEvent_inter_avoidMatch_step {n : ℕ} (σ : Equiv.Perm (Fin n)) {I : Finset (Fin n)} {i₀ : Fin n} (hi₀ : i₀ ∉ I) (𝒩 : Finset (Equiv.Perm (Fin n) × Finset (Fin n))) (hrow : ∀ p ∈ 𝒩, i₀ ∉ p.2) (hcol : ∀ p ∈ 𝒩, σ i₀ ∉ p.2.image p.1) : (matchEvent σ (insert i₀ I) ∩ avoidMatch 𝒩).card * (n - I.card) ≤ (matchEvent σ I ∩ avoidMatch 𝒩).card := by let R : Finset (Fin n) := Finset.univ \ I.image σ have hRcard : R.card = n - I.card := by rw [Finset.card_sdiff_of_subset (Finset.subset_univ _), Finset.card_univ, Fintype.card_fin, Finset.card_image_of_injective I σ.injective] rw [← hRcard, ← Finset.card_product] refine Finset.card_le_card_of_injOn (fun p => Equiv.swap (σ i₀) p.2 * p.1) ?_ ?_ · rintro ⟨π, j⟩ hp rcases Finset.mem_product.mp hp with ⟨hπ_inter, hj⟩ rcases Finset.mem_inter.mp hπ_inter with ⟨hπ, hπav⟩ have hπ' := (Finset.mem_filter.mp hπ).2 have hπav' := (Finset.mem_filter.mp hπav).2 have hjnot : j ∉ I.image σ := (Finset.mem_sdiff.mp hj).2 have hσi₀not : σ i₀ ∉ I.image σ := fun h => by rcases Finset.mem_image.mp h with ⟨i, hi, heq⟩ exact hi₀ (σ.injective heq ▸ hi) refine Finset.mem_inter.mpr ⟨?_, ?_⟩ · refine Finset.mem_filter.mpr ⟨Finset.mem_univ _, fun i hi => ?_⟩ simp only [Equiv.Perm.mul_apply, hπ' i (Finset.mem_insert_of_mem hi)] have hne1 : σ i ≠ σ i₀ := fun h => hσi₀not (h ▸ Finset.mem_image_of_mem σ hi) have hne2 : σ i ≠ j := fun h => hjnot (h ▸ Finset.mem_image_of_mem σ hi) exact Equiv.swap_apply_of_ne_of_ne hne1 hne2 · refine Finset.mem_filter.mpr ⟨Finset.mem_univ _, fun p hp𝒩 => ?_⟩ by_contra hall push Not at hall -- Every x ∈ p.2 satisfies (swap (σ i₀) j * π) x = p.1 x. -- Show π x = p.1 x for every x ∈ p.2, contradicting π ∈ avoidMatch 𝒩. obtain ⟨x₀, hx₀, hne⟩ := hπav' p hp𝒩 have hxeq : ∀ x ∈ p.2, π x = p.1 x := by intro x hx have hpx : Equiv.swap (σ i₀) j (π x) = p.1 x := hall x hx have hne_σi₀ : π x ≠ σ i₀ := by intro h have : x = i₀ := π.injective (h.trans (hπ' i₀ (Finset.mem_insert_self i₀ I)).symm) exact hrow p hp𝒩 (this ▸ hx) have hne_j : π x ≠ j := by intro h rw [h, Equiv.swap_apply_right] at hpx exact hcol p hp𝒩 (hpx ▸ Finset.mem_image_of_mem p.1 hx) rwa [Equiv.swap_apply_of_ne_of_ne hne_σi₀ hne_j] at hpx exact hne (hxeq x₀ hx₀) · rintro ⟨π₁, j₁⟩ hp₁ ⟨π₂, j₂⟩ hp₂ heq dsimp only at heq have hπ₁ := (Finset.mem_filter.mp (Finset.mem_inter.mp (Finset.mem_product.mp hp₁).1).1).2 have hπ₂ := (Finset.mem_filter.mp (Finset.mem_inter.mp (Finset.mem_product.mp hp₂).1).1).2 have h1 : (Equiv.swap (σ i₀) j₁ * π₁) i₀ = j₁ := by simp [Equiv.Perm.mul_apply, hπ₁ i₀ (Finset.mem_insert_self i₀ I)] have h2 : (Equiv.swap (σ i₀) j₂ * π₂) i₀ = j₂ := by simp [Equiv.Perm.mul_apply, hπ₂ i₀ (Finset.mem_insert_self i₀ I)] have hj : j₁ = j₂ := by rw [← h1, ← h2, heq] subst hj have hπ : π₁ = π₂ := mul_left_cancel heq subst hπ rfl /-- **Lu–Székely Negative-Dependency Inequality on `Equiv.Perm (Fin n)`**: if every partial matching `(τ, J) ∈ 𝒩` is vertex-disjoint from `(σ, I)` (disjoint rows `I` and `J`, and disjoint columns `I.image σ` and `J.image τ`), then `|matchEvent σ I ∩ avoidMatch 𝒩| * n! ≤ |matchEvent σ I| * |avoidMatch 𝒩|`. -/ theorem perm_negative_dependency {n : ℕ} (σ : Equiv.Perm (Fin n)) (I : Finset (Fin n)) (𝒩 : Finset (Equiv.Perm (Fin n) × Finset (Fin n))) (hdisj : ∀ p ∈ 𝒩, Disjoint I p.2 ∧ Disjoint (I.image σ) (p.2.image p.1)) : (matchEvent σ I ∩ avoidMatch 𝒩).card * n.factorial ≤ (matchEvent σ I).card * (avoidMatch 𝒩).card := by induction I using Finset.induction_on with | empty => have hempty : matchEvent σ ∅ = Finset.univ := by ext π; simp [matchEvent] rw [hempty, Finset.univ_inter, Finset.card_univ, Fintype.card_perm, Fintype.card_fin, mul_comm] | @insert i₀ I hi₀ ih => have hdisjI : ∀ p ∈ 𝒩, Disjoint I p.2 ∧ Disjoint (I.image σ) (p.2.image p.1) := by intro p hp have ⟨h1, h2⟩ := hdisj p hp exact ⟨h1.mono_left (Finset.subset_insert i₀ I), h2.mono_left (Finset.image_subset_image (Finset.subset_insert i₀ I))⟩ have hrow : ∀ p ∈ 𝒩, i₀ ∉ p.2 := fun p hp hmem => Finset.disjoint_left.mp (hdisj p hp).1 (Finset.mem_insert_self i₀ I) hmem have hcol : ∀ p ∈ 𝒩, σ i₀ ∉ p.2.image p.1 := fun p hp hmem => Finset.disjoint_left.mp (hdisj p hp).2 (Finset.mem_image_of_mem σ (Finset.mem_insert_self i₀ I)) hmem have hstep := card_matchEvent_inter_avoidMatch_step σ hi₀ 𝒩 hrow hcol have hih := ih hdisjI have hrec := card_matchEvent_insert σ hi₀ have hIlt : I.card < n := by have : (insert i₀ I).card ≤ n := by simpa [Fintype.card_fin] using Finset.card_le_univ (insert i₀ I) rw [Finset.card_insert_of_notMem hi₀] at this omega have hpos : 0 < n - I.card := by omega have hmul : (matchEvent σ (insert i₀ I) ∩ avoidMatch 𝒩).card * n.factorial * (n - I.card) ≤ (matchEvent σ (insert i₀ I)).card * (avoidMatch 𝒩).card * (n - I.card) := by calc (matchEvent σ (insert i₀ I) ∩ avoidMatch 𝒩).card * n.factorial * (n - I.card) = ((matchEvent σ (insert i₀ I) ∩ avoidMatch 𝒩).card * (n - I.card)) * n.factorial := by ring _ ≤ (matchEvent σ I ∩ avoidMatch 𝒩).card * n.factorial := Nat.mul_le_mul_right n.factorial hstep _ ≤ (matchEvent σ I).card * (avoidMatch 𝒩).card := hih _ = ((matchEvent σ (insert i₀ I)).card * (n - I.card)) * (avoidMatch 𝒩).card := by rw [← hrec] _ = (matchEvent σ (insert i₀ I)).card * (avoidMatch 𝒩).card * (n - I.card) := by ring exact Nat.le_of_mul_le_mul_right hmul hpos end LuSzekely /-! ## Section 3: Permutation Covering Codes & Main World-Record Lower Bound -/ section PermCovering /-- A subset `S ⊆ Equiv.Perm (Fin n)` is an `s`-cover (equivalently, has Hamming covering radius at most `n - s`) if every permutation `π ∈ S_n` agrees with at least one `σ ∈ S` in at least `s` positions. -/ def IsPermCover (n s : ℕ) (S : Finset (Equiv.Perm (Fin n))) : Prop := ∀ π : Equiv.Perm (Fin n), ∃ σ ∈ S, s ≤ (Finset.univ.filter fun i : Fin n => π i = σ i).card /-- Number of `s`-element subsets of `Fin n` containing a fixed element `x`. -/ lemma card_powersetCard_mem {n s : ℕ} (hs : 1 ≤ s) (x : Fin n) : ((Finset.powersetCard s (Finset.univ : Finset (Fin n))).filter fun J => x ∈ J).card = (n - 1).choose (s - 1) := by have hbij : ((Finset.powersetCard s (Finset.univ : Finset (Fin n))).filter fun J => x ∈ J).card = (Finset.powersetCard (s - 1) ((Finset.univ : Finset (Fin n)).erase x)).card := by refine Finset.card_bij (fun J _ => J.erase x) ?_ ?_ ?_ · intro J hJ rcases Finset.mem_filter.mp hJ with ⟨hJs, hxJ⟩ have hJcard := (Finset.mem_powersetCard.mp hJs).2 refine Finset.mem_powersetCard.mpr ⟨Finset.erase_subset_erase x (Finset.subset_univ J), ?_⟩ rw [Finset.card_erase_of_mem hxJ, hJcard] · intro J₁ hJ₁ J₂ hJ₂ heq have hx1 := (Finset.mem_filter.mp hJ₁).2 have hx2 := (Finset.mem_filter.mp hJ₂).2 rw [← Finset.insert_erase hx1, ← Finset.insert_erase hx2, heq] · intro K hK rcases Finset.mem_powersetCard.mp hK with ⟨hKsub, hKcard⟩ have hxK : x ∉ K := fun h => (Finset.mem_erase.mp (hKsub h)).1 rfl refine ⟨insert x K, Finset.mem_filter.mpr ⟨Finset.mem_powersetCard.mpr ⟨Finset.subset_univ _, ?_⟩, Finset.mem_insert_self x K⟩, Finset.erase_insert hxK⟩ rw [Finset.card_insert_of_notMem hxK, hKcard] omega rw [hbij, Finset.card_powersetCard, Finset.card_erase_of_mem (Finset.mem_univ x), Finset.card_univ, Fintype.card_fin] /-- Number of `s`-element subsets `J ⊆ Fin n` intersecting `K` is at most `K.card * C(n-1, s-1)`. -/ lemma card_powersetCard_not_disjoint_le {n s : ℕ} (hs : 1 ≤ s) (K : Finset (Fin n)) : ((Finset.powersetCard s (Finset.univ : Finset (Fin n))).filter fun J => ¬ Disjoint K J).card ≤ K.card * (n - 1).choose (s - 1) := by have hsub : ((Finset.powersetCard s (Finset.univ : Finset (Fin n))).filter fun J => ¬ Disjoint K J) ⊆ K.biUnion (fun x => (Finset.powersetCard s (Finset.univ : Finset (Fin n))).filter fun J => x ∈ J) := by intro J hJ rcases Finset.mem_filter.mp hJ with ⟨hJs, hnd⟩ rcases Finset.not_disjoint_iff.mp hnd with ⟨x, hxK, hxJ⟩ exact Finset.mem_biUnion.mpr ⟨x, hxK, Finset.mem_filter.mpr ⟨hJs, hxJ⟩⟩ calc ((Finset.powersetCard s (Finset.univ : Finset (Fin n))).filter fun J => ¬ Disjoint K J).card ≤ (K.biUnion (fun x => (Finset.powersetCard s (Finset.univ : Finset (Fin n))).filter fun J => x ∈ J)).card := Finset.card_le_card hsub _ ≤ ∑ x ∈ K, ((Finset.powersetCard s (Finset.univ : Finset (Fin n))).filter fun J => x ∈ J).card := Finset.card_biUnion_le _ = ∑ _x ∈ K, (n - 1).choose (s - 1) := Finset.sum_congr rfl fun x _ => card_powersetCard_mem hs x _ = K.card * (n - 1).choose (s - 1) := by rw [Finset.sum_const, smul_eq_mul] /-- Exact factorial identity `(n - 1).choose (s - 1) * (s - 1)! * (n - s)! = (n - 1)!` for `1 ≤ s ≤ n`. -/ lemma choose_mul_fact_eq {n s : ℕ} (hs : 1 ≤ s) (hsn : s ≤ n) : (n - 1).choose (s - 1) * (s - 1).factorial * (n - s).factorial = (n - 1).factorial := by have hsub : (n - 1) - (s - 1) = n - s := by omega have hle : s - 1 ≤ n - 1 := by omega have h := Nat.choose_mul_factorial_mul_factorial hle rwa [hsub] at h /-- **Main World-Record Lower Bound for Permutation Covering Codes (`f(n, s)`)**: For all `1 ≤ s ≤ n`, every `s`-cover `S ⊆ Equiv.Perm (Fin n)` satisfies `((s - 1)! / (2 * e * s)) * n + 1 / 2 < |S|`. -/ theorem perm_covering_lower_bound {n s : ℕ} (hs : 1 ≤ s) (hsn : s ≤ n) {S : Finset (Equiv.Perm (Fin n))} (hcov : IsPermCover n s S) : ((s - 1).factorial : ℝ) / (2 * Real.exp 1 * (s : ℝ)) * (n : ℝ) + 1 / 2 < (S.card : ℝ) := by have hSne : S.Nonempty := by obtain ⟨σ, hσ, _⟩ := hcov 1 exact ⟨σ, hσ⟩ have hSpos : 1 ≤ S.card := hSne.card_pos have hnpos : 1 ≤ n := hs.trans hsn by_contra hle push Not at hle -- Index type of bad events: V = {σ // σ ∈ S} × {I : Finset (Fin n) // I.card = s} let V := {σ : Equiv.Perm (Fin n) // σ ∈ S} × {I : Finset (Fin n) // I.card = s} let A : V → Finset (Equiv.Perm (Fin n)) := fun v => matchEvent v.1.1 v.2.1 let Γ : V → Finset V := fun v => Finset.univ.filter fun u => u ≠ v ∧ (¬ Disjoint v.2.1 u.2.1 ∨ ¬ Disjoint (v.2.1.image v.1.1) (u.2.1.image u.1.1)) let d : ℕ := (2 * S.card - 1) * s * (n - 1).choose (s - 1) - 1 -- Step 1: Bound the conflict degree (Γ v).card ≤ d have hdeg_plus : ∀ v : V, (Γ v).card + 1 ≤ (2 * S.card - 1) * s * (n - 1).choose (s - 1) := by intro v rcases v with ⟨⟨σ, hσS⟩, ⟨I, hIcard⟩⟩ -- Split Γ (σ, I) into u.1 = σ and u.1 ≠ σ via sum over τ ∈ S let fiber : {τ : Equiv.Perm (Fin n) // τ ∈ S} → Finset V := fun τ => (Γ (⟨σ, hσS⟩, ⟨I, hIcard⟩)).filter fun u => u.1 = τ have hsum_fib : (Γ (⟨σ, hσS⟩, ⟨I, hIcard⟩)).card = ∑ τ : {τ : Equiv.Perm (Fin n) // τ ∈ S}, (fiber τ).card := by rw [← Finset.card_biUnion] · congr 1 ext u simp [fiber] · intro τ₁ _ τ₂ _ hne change Disjoint (fiber τ₁) (fiber τ₂) rw [Finset.disjoint_left] intro u hu1 hu2 exact hne ((Finset.mem_filter.mp hu1).2.symm.trans (Finset.mem_filter.mp hu2).2) -- Helper: for any τ, bound (fiber τ).card have hfib_le : ∀ τ : {τ : Equiv.Perm (Fin n) // τ ∈ S}, (fiber τ).card ≤ (I ∪ I.image (τ.1⁻¹ * σ)).card * (n - 1).choose (s - 1) := by intro τ let K := I ∪ I.image (τ.1⁻¹ * σ) have hinj : (fiber τ).card ≤ ((Finset.powersetCard s (Finset.univ : Finset (Fin n))).filter fun J => ¬ Disjoint K J).card := by refine Finset.card_le_card_of_injOn (fun u => u.2.1) ?_ ?_ · intro u hu rcases Finset.mem_filter.mp hu with ⟨huΓ, huτ⟩ rcases Finset.mem_filter.mp huΓ with ⟨_, _, hnd⟩ refine Finset.mem_filter.mpr ⟨Finset.mem_powersetCard.mpr ⟨Finset.subset_univ _, u.2.2⟩, ?_⟩ rcases hnd with h1 | h2 · rcases Finset.not_disjoint_iff.mp h1 with ⟨x, hxI, hxJ⟩ exact Finset.not_disjoint_iff.mpr ⟨x, Finset.mem_union_left _ hxI, hxJ⟩ · rcases Finset.not_disjoint_iff.mp h2 with ⟨y, hy1, hy2⟩ rcases Finset.mem_image.mp hy1 with ⟨x, hxI, rfl⟩ rcases Finset.mem_image.mp hy2 with ⟨z, hzJ, hzeq⟩ have hz_eq : z = (τ.1⁻¹ * σ) x := by rw [huτ] at hzeq simp only [Equiv.Perm.mul_apply] rw [← hzeq] exact (Equiv.symm_apply_apply τ.1 z).symm exact Finset.not_disjoint_iff.mpr ⟨z, Finset.mem_union_right _ (hz_eq ▸ Finset.mem_image_of_mem _ hxI), hzJ⟩ · intro u₁ hu₁ u₂ hu₂ heq have h1 := (Finset.mem_filter.mp hu₁).2 have h2 := (Finset.mem_filter.mp hu₂).2 exact Prod.ext (h1.trans h2.symm) (Subtype.ext heq) exact hinj.trans (card_powersetCard_not_disjoint_le hs K) -- Tighter bound for τ = σ: u = (σ, I) itself is excluded, so (fiber σ).card + 1 ≤ s * C(n-1, s-1) have hfib_self : (fiber ⟨σ, hσS⟩).card + 1 ≤ s * (n - 1).choose (s - 1) := by have hinj : (fiber ⟨σ, hσS⟩).card + 1 ≤ ((Finset.powersetCard s (Finset.univ : Finset (Fin n))).filter fun J => ¬ Disjoint I J).card := by have hI_in : I ∈ (Finset.powersetCard s (Finset.univ : Finset (Fin n))).filter fun J => ¬ Disjoint I J := by refine Finset.mem_filter.mpr ⟨Finset.mem_powersetCard.mpr ⟨Finset.subset_univ _, hIcard⟩, ?_⟩ obtain ⟨x, hx⟩ := Finset.card_pos.mp (by omega : 0 < I.card) exact Finset.not_disjoint_iff.mpr ⟨x, hx, hx⟩ have hle_er : (fiber ⟨σ, hσS⟩).card ≤ (((Finset.powersetCard s (Finset.univ : Finset (Fin n))).filter fun J => ¬ Disjoint I J).erase I).card := by refine Finset.card_le_card_of_injOn (fun u => u.2.1) ?_ ?_ · intro u hu rcases Finset.mem_filter.mp hu with ⟨huΓ, huσ⟩ rcases Finset.mem_filter.mp huΓ with ⟨_, hne, hnd⟩ have hJI : u.2.1 ≠ I := fun heq => hne (Prod.ext huσ (Subtype.ext heq)) refine Finset.mem_erase.mpr ⟨hJI, Finset.mem_filter.mpr ⟨Finset.mem_powersetCard.mpr ⟨Finset.subset_univ _, u.2.2⟩, ?_⟩⟩ rcases hnd with h1 | h2 · exact h1 · rcases Finset.not_disjoint_iff.mp h2 with ⟨y, hy1, hy2⟩ rcases Finset.mem_image.mp hy1 with ⟨x, hxI, rfl⟩ rcases Finset.mem_image.mp hy2 with ⟨z, hzJ, hzeq⟩ rw [huσ] at hzeq exact Finset.not_disjoint_iff.mpr ⟨x, hxI, σ.injective hzeq ▸ hzJ⟩ · intro u₁ hu₁ u₂ hu₂ heq exact Prod.ext ((Finset.mem_filter.mp hu₁).2.trans (Finset.mem_filter.mp hu₂).2.symm) (Subtype.ext heq) rw [Finset.card_erase_of_mem hI_in] at hle_er have hpos_f : 1 ≤ ((Finset.powersetCard s (Finset.univ : Finset (Fin n))).filter fun J => ¬ Disjoint I J).card := Finset.card_pos.mpr ⟨I, hI_in⟩ omega calc (fiber ⟨σ, hσS⟩).card + 1 ≤ ((Finset.powersetCard s (Finset.univ : Finset (Fin n))).filter fun J => ¬ Disjoint I J).card := hinj _ ≤ I.card * (n - 1).choose (s - 1) := card_powersetCard_not_disjoint_le hs I _ = s * (n - 1).choose (s - 1) := by rw [hIcard] -- Sum over all τ ∈ S: rw [hsum_fib, ← Finset.add_sum_erase _ _ (Finset.mem_univ (⟨σ, hσS⟩ : {τ // τ ∈ S}))] have hrest : ∑ τ ∈ Finset.univ.erase (⟨σ, hσS⟩ : {τ // τ ∈ S}), (fiber τ).card ≤ (S.card - 1) * (2 * s * (n - 1).choose (s - 1)) := by have hterm : ∀ τ : {τ // τ ∈ S}, (fiber τ).card ≤ 2 * s * (n - 1).choose (s - 1) := fun τ => by have hK : (I ∪ I.image (τ.1⁻¹ * σ)).card ≤ 2 * s := by calc (I ∪ I.image (τ.1⁻¹ * σ)).card ≤ I.card + (I.image (τ.1⁻¹ * σ)).card := Finset.card_union_le _ _ _ = s + s := by rw [Finset.card_image_of_injective _ (τ.1⁻¹ * σ).injective, hIcard] _ = 2 * s := by ring exact (hfib_le τ).trans (Nat.mul_le_mul_right _ hK) calc ∑ τ ∈ Finset.univ.erase (⟨σ, hσS⟩ : {τ // τ ∈ S}), (fiber τ).card ≤ ∑ _τ ∈ Finset.univ.erase (⟨σ, hσS⟩ : {τ // τ ∈ S}), (2 * s * (n - 1).choose (s - 1)) := Finset.sum_le_sum fun τ _ => hterm τ _ = (Finset.univ.erase (⟨σ, hσS⟩ : {τ // τ ∈ S})).card * (2 * s * (n - 1).choose (s - 1)) := by rw [Finset.sum_const, smul_eq_mul] _ = (S.card - 1) * (2 * s * (n - 1).choose (s - 1)) := by rw [Finset.card_erase_of_mem (Finset.mem_univ _), Finset.card_univ, Fintype.card_coe] have hcomb : (fiber ⟨σ, hσS⟩).card + ∑ τ ∈ Finset.univ.erase (⟨σ, hσS⟩ : {τ // τ ∈ S}), (fiber τ).card + 1 ≤ s * (n - 1).choose (s - 1) + (S.card - 1) * (2 * s * (n - 1).choose (s - 1)) := by omega have heq_rhs : s * (n - 1).choose (s - 1) + (S.card - 1) * (2 * s * (n - 1).choose (s - 1)) = (2 * S.card - 1) * s * (n - 1).choose (s - 1) := by have h2S : 1 + (S.card - 1) * 2 = 2 * S.card - 1 := by omega calc s * (n - 1).choose (s - 1) + (S.card - 1) * (2 * s * (n - 1).choose (s - 1)) = (1 + (S.card - 1) * 2) * (s * (n - 1).choose (s - 1)) := by ring _ = (2 * S.card - 1) * s * (n - 1).choose (s - 1) := by rw [h2S]; ring exact hcomb.trans_eq heq_rhs have hd_pos : 1 ≤ (2 * S.card - 1) * s * (n - 1).choose (s - 1) := by have hch : 1 ≤ (n - 1).choose (s - 1) := Nat.choose_pos (by omega) have h2S : 1 ≤ 2 * S.card - 1 := by omega exact Nat.mul_pos (Nat.mul_pos h2S hs) hch have hdeg : ∀ v : V, (Γ v).card ≤ d := fun v => by have := hdeg_plus v dsimp only [d] omega -- Step 2: Verify negative dependency from perm_negative_dependency have hneg : ∀ v : V, ∀ T : Finset V, Disjoint T (insert v (Γ v)) → (A v ∩ avoid A T).card * Fintype.card (Equiv.Perm (Fin n)) ≤ (A v).card * (avoid A T).card := by intro v T hdisjT let 𝒩 : Finset (Equiv.Perm (Fin n) × Finset (Fin n)) := T.image fun u => (u.1.1, u.2.1) have hav_eq : avoid A T = avoidMatch 𝒩 := by ext π rw [mem_avoidMatch_iff] simp only [avoid, Finset.mem_filter, Finset.mem_univ, true_and, 𝒩, Finset.mem_image, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂] rfl have hdisj𝒩 : ∀ p ∈ 𝒩, Disjoint v.2.1 p.2 ∧ Disjoint (v.2.1.image v.1.1) (p.2.image p.1) := by intro p hp rcases Finset.mem_image.mp hp with ⟨u, huT, rfl⟩ have hnot : u ∉ insert v (Γ v) := Finset.disjoint_left.mp hdisjT huT have hne : u ≠ v := fun h => hnot (h ▸ Finset.mem_insert_self v (Γ v)) have hnotΓ : u ∉ Γ v := fun h => hnot (Finset.mem_insert_of_mem h) simp only [Γ, Finset.mem_filter, Finset.mem_univ, true_and] at hnotΓ have hnot_or : ¬ (¬ Disjoint v.2.1 u.2.1 ∨ ¬ Disjoint (v.2.1.image v.1.1) (u.2.1.image u.1.1)) := fun h => hnotΓ ⟨hne, h⟩ push Not at hnot_or exact hnot_or rw [hav_eq, Fintype.card_perm, Fintype.card_fin] exact perm_negative_dependency v.1.1 v.2.1 𝒩 hdisj𝒩 -- Step 3: Verify the LLL threshold e * prob (A v) * (d + 1) ≤ 1 have hcond : ∀ v : V, Real.exp 1 * prob (A v) * ((d : ℝ) + 1) ≤ 1 := by intro v have hd1 : ((d : ℝ) + 1) = (((2 * S.card - 1) * s * (n - 1).choose (s - 1) : ℕ) : ℝ) := by dsimp only [d] exact_mod_cast (Nat.sub_add_cancel hd_pos) rw [hd1] unfold prob rw [Fintype.card_perm, Fintype.card_fin, card_matchEvent, v.2.2] have hch := choose_mul_fact_eq hs hsn have hnfact : n.factorial = n * (n - 1).factorial := by have : n = (n - 1) + 1 := by omega conv_lhs => rw [this, Nat.factorial_succ] rw [← this] have hchR : (((n - 1).choose (s - 1) : ℕ) : ℝ) * ((s - 1).factorial : ℝ) * ((n - s).factorial : ℝ) = ((n - 1).factorial : ℝ) := by exact_mod_cast hch have hnfactR : (n.factorial : ℝ) = (n : ℝ) * ((n - 1).factorial : ℝ) := by exact_mod_cast hnfact have h2S_R : ((2 * S.card - 1 : ℕ) : ℝ) = 2 * (S.card : ℝ) - 1 := by have : 1 ≤ 2 * S.card := by omega push_cast [this] ring have hden_pos : (0 : ℝ) < ((s - 1).factorial : ℝ) * (n : ℝ) := by have : 0 < (s - 1).factorial := Nat.factorial_pos _ have : 0 < n := hnpos positivity have hfact_pos : (0 : ℝ) < ((n - 1).factorial : ℝ) := Nat.cast_pos.mpr (Nat.factorial_pos _) have hsimp : Real.exp 1 * (((n - s).factorial : ℝ) / (n.factorial : ℝ)) * (((2 * S.card - 1) * s * (n - 1).choose (s - 1) : ℕ) : ℝ) = (Real.exp 1 * (2 * (S.card : ℝ) - 1) * (s : ℝ)) / (((s - 1).factorial : ℝ) * (n : ℝ)) := by push_cast rw [h2S_R, hnfactR] have hmul_id : ((n - s).factorial : ℝ) * (((n - 1).choose (s - 1) : ℕ) : ℝ) * ((s - 1).factorial : ℝ) = ((n - 1).factorial : ℝ) := by linarith have hn_ne : (n : ℝ) ≠ 0 := (Nat.cast_pos.mpr hnpos).ne' have hnf_ne : ((n - 1).factorial : ℝ) ≠ 0 := hfact_pos.ne' have hsf_ne : ((s - 1).factorial : ℝ) ≠ 0 := (Nat.cast_pos.mpr (Nat.factorial_pos _)).ne' field_simp [hn_ne, hnf_ne, hsf_ne] rw [← hmul_id] ring rw [hsimp, div_le_one hden_pos] -- From hle: S.card ≤ ((s-1)! / (2 * e * s)) * n + 1/2 have h2es_pos : (0 : ℝ) < 2 * Real.exp 1 * (s : ℝ) := by have : 0 < Real.exp 1 := Real.exp_pos 1 have : (0 : ℝ) < (s : ℝ) := Nat.cast_pos.mpr hs positivity have h2S_le : 2 * (S.card : ℝ) - 1 ≤ 2 * (((s - 1).factorial : ℝ) / (2 * Real.exp 1 * (s : ℝ)) * (n : ℝ)) := by linarith have hmul_le := mul_le_mul_of_nonneg_right h2S_le (by positivity : 0 ≤ Real.exp 1 * (s : ℝ)) have hcancel : 2 * (((s - 1).factorial : ℝ) / (2 * Real.exp 1 * (s : ℝ)) * (n : ℝ)) * (Real.exp 1 * (s : ℝ)) = ((s - 1).factorial : ℝ) * (n : ℝ) := by field_simp [h2es_pos.ne'] linarith -- Step 4: Apply symmetric Lopsided LLL to obtain an uncovered permutation π ∈ S_n have hΩpos : 0 < Fintype.card (Equiv.Perm (Fin n)) := by rw [Fintype.card_perm, Fintype.card_fin] exact Nat.factorial_pos n obtain ⟨π, hπ⟩ := lopsided_lll_symmetric hΩpos A Γ d hdeg hneg hcond obtain ⟨σ, hσS, hagree⟩ := hcov π obtain ⟨I, hIsub, hIcard⟩ := Finset.exists_subset_card_eq hagree have hmem : π ∈ A (⟨σ, hσS⟩, ⟨I, hIcard⟩) := by refine Finset.mem_filter.mpr ⟨Finset.mem_univ _, fun i hi => ?_⟩ exact (Finset.mem_filter.mp (hIsub hi)).2 exact hπ (⟨σ, hσS⟩, ⟨I, hIcard⟩) hmem /-- Classical sphere-covering lower bound: every `s`-cover `S ⊆ S_n` (`s ≤ n`) satisfies `s! ≤ |S|`. -/ theorem perm_covering_sphere_bound {n s : ℕ} (hsn : s ≤ n) {S : Finset (Equiv.Perm (Fin n))} (hcov : IsPermCover n s S) : s.factorial ≤ S.card := by -- Every π ∈ S_n lies in matchEvent σ I for some σ ∈ S and some s-subset I ⊆ Fin n have huniv_sub : (Finset.univ : Finset (Equiv.Perm (Fin n))) ⊆ (S ×ˢ Finset.powersetCard s (Finset.univ : Finset (Fin n))).biUnion fun p => matchEvent p.1 p.2 := by intro π _ obtain ⟨σ, hσS, hcard⟩ := hcov π obtain ⟨I, hIsub, hIcard⟩ := Finset.exists_subset_card_eq hcard refine Finset.mem_biUnion.mpr ⟨(σ, I), Finset.mem_product.mpr ⟨hσS, Finset.mem_powersetCard.mpr ⟨Finset.subset_univ _, hIcard⟩⟩, ?_⟩ exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, fun i hi => (Finset.mem_filter.mp (hIsub hi)).2⟩ have hle : n.factorial ≤ S.card * n.choose s * (n - s).factorial := by calc n.factorial = (Finset.univ : Finset (Equiv.Perm (Fin n))).card := by rw [Finset.card_univ, Fintype.card_perm, Fintype.card_fin] _ ≤ ((S ×ˢ Finset.powersetCard s (Finset.univ : Finset (Fin n))).biUnion fun p => matchEvent p.1 p.2).card := Finset.card_le_card huniv_sub _ ≤ ∑ p ∈ S ×ˢ Finset.powersetCard s (Finset.univ : Finset (Fin n)), (matchEvent p.1 p.2).card := Finset.card_biUnion_le _ = ∑ _p ∈ S ×ˢ Finset.powersetCard s (Finset.univ : Finset (Fin n)), (n - s).factorial := by refine Finset.sum_congr rfl fun p hp => ?_ rw [card_matchEvent, (Finset.mem_powersetCard.mp (Finset.mem_product.mp hp).2).2] _ = S.card * n.choose s * (n - s).factorial := by rw [Finset.sum_const, smul_eq_mul, Finset.card_product, Finset.card_powersetCard, Finset.card_univ, Fintype.card_fin] have hfact := Nat.choose_mul_factorial_mul_factorial hsn have hmul : s.factorial * (n.choose s * (n - s).factorial) ≤ S.card * (n.choose s * (n - s).factorial) := by calc s.factorial * (n.choose s * (n - s).factorial) = n.choose s * s.factorial * (n - s).factorial := by ring _ = n.factorial := hfact _ ≤ S.card * n.choose s * (n - s).factorial := hle _ = S.card * (n.choose s * (n - s).factorial) := by ring have hpos : 0 < n.choose s * (n - s).factorial := Nat.mul_pos (Nat.choose_pos hsn) (Nat.factorial_pos _) exact Nat.le_of_mul_le_mul_right hmul hpos end PermCovering /-! ## Section 4: Dominance over Hendrey & Wanless (2020) and Even-`n` Sanity Theorem -/ section Comparisons /-- Elementary factorial lower bound: for all `s ≥ 7`, `3 * s * (s + 2) ≤ (s - 1)!`. -/ lemma three_mul_sq_le_factorial_pred {s : ℕ} (hs : 7 ≤ s) : 3 * s * (s + 2) ≤ (s - 1).factorial := by induction s, hs using Nat.le_induction with | base => decide | succ k hk ih => have hstep : (k + 1 - 1).factorial = k * (k - 1).factorial := by have : k = (k - 1) + 1 := by omega conv_lhs => rw [show k + 1 - 1 = k by omega, this, Nat.factorial_succ] rw [← this] rw [hstep] nlinarith /-- **Pointwise Dominance over Hendrey & Wanless (2020) for ALL `s ≥ 6` and ALL `n ≥ s`**: our Lopsided LLL lower bound strictly beats Hendrey & Wanless's `⌊(2 + √(2s - 2)) / 2⌋ * (n / 2)` for every `s ≥ 6` and every `n ≥ s`. -/ theorem perm_covering_beats_hendrey_wanless_pointwise {n s : ℕ} (hs : 6 ≤ s) (hsn : s ≤ n) {S : Finset (Equiv.Perm (Fin n))} (hcov : IsPermCover n s S) : (Nat.floor ((2 + Real.sqrt (2 * (s : ℝ) - 2)) / 2) : ℝ) * (n : ℝ) / 2 < (S.card : ℝ) := by have hmain := perm_covering_lower_bound (by omega : 1 ≤ s) hsn hcov have he_lt : Real.exp 1 < 3 := by have := Real.exp_one_lt_d9; linarith have hepos : (0 : ℝ) < Real.exp 1 := Real.exp_pos 1 have hn_nn : (0 : ℝ) ≤ (n : ℝ) := Nat.cast_nonneg n rcases eq_or_lt_of_le hs with rfl | hs7 · -- s = 6: √(2*6 - 2) = √10 < 4, so floor ≤ 2, HW20 ≤ n, while 5!/(12*e) = 10/e > 10/3 > 1 have hsqrt4 : Real.sqrt (2 * ((6 : ℕ) : ℝ) - 2) ≤ 4 := by calc Real.sqrt (2 * ((6 : ℕ) : ℝ) - 2) ≤ Real.sqrt (4 ^ 2) := Real.sqrt_le_sqrt (by norm_num) _ = 4 := Real.sqrt_sq (by norm_num) have hfl : (Nat.floor ((2 + Real.sqrt (2 * ((6 : ℕ) : ℝ) - 2)) / 2) : ℝ) ≤ 3 := by calc (Nat.floor ((2 + Real.sqrt (2 * ((6 : ℕ) : ℝ) - 2)) / 2) : ℝ) ≤ (2 + Real.sqrt (2 * ((6 : ℕ) : ℝ) - 2)) / 2 := Nat.floor_le (by positivity) _ ≤ (2 + 4) / 2 := div_le_div_of_nonneg_right (add_le_add (le_refl 2) hsqrt4) (by norm_num) _ = 3 := by norm_num have hcoeff : (3 : ℝ) / 2 ≤ ((6 - 1).factorial : ℝ) / (2 * Real.exp 1 * (6 : ℝ)) := by have h5 : ((6 - 1).factorial : ℝ) = 120 := by norm_num [Nat.factorial] rw [h5, div_le_div_iff₀ (by norm_num) (by positivity)] nlinarith have hstep1 : (Nat.floor ((2 + Real.sqrt (2 * (6 : ℝ) - 2)) / 2) : ℝ) * (n : ℝ) / 2 ≤ (3 / 2) * (n : ℝ) := by nlinarith have hstep2 : (3 / 2) * (n : ℝ) ≤ ((6 - 1).factorial : ℝ) / (2 * Real.exp 1 * (6 : ℝ)) * (n : ℝ) := mul_le_mul_of_nonneg_right hcoeff hn_nn linarith · have hfl : (Nat.floor ((2 + Real.sqrt (2 * (s : ℝ) - 2)) / 2) : ℝ) ≤ (2 + Real.sqrt (2 * (s : ℝ) - 2)) / 2 := Nat.floor_le (by positivity) have hsqrt_le : Real.sqrt (2 * (s : ℝ) - 2) ≤ (s : ℝ) := by have h1 : 2 * (s : ℝ) - 2 ≤ (s : ℝ) ^ 2 := by have hsR : (6 : ℝ) ≤ (s : ℝ) := by exact_mod_cast hs nlinarith calc Real.sqrt (2 * (s : ℝ) - 2) ≤ Real.sqrt ((s : ℝ) ^ 2) := Real.sqrt_le_sqrt h1 _ = (s : ℝ) := Real.sqrt_sq (Nat.cast_nonneg s) have hhw_le : (Nat.floor ((2 + Real.sqrt (2 * (s : ℝ) - 2)) / 2) : ℝ) * (n : ℝ) / 2 ≤ (((s : ℝ) + 2) / 4) * (n : ℝ) := by nlinarith have hfact_ge : (3 : ℝ) * (s : ℝ) * ((s : ℝ) + 2) ≤ ((s - 1).factorial : ℝ) := by exact_mod_cast three_mul_sq_le_factorial_pred hs7 have hcoeff : ((s : ℝ) + 2) / 4 ≤ ((s - 1).factorial : ℝ) / (2 * Real.exp 1 * (s : ℝ)) := by have hspos : (0 : ℝ) < (s : ℝ) := Nat.cast_pos.mpr (by omega) rw [div_le_div_iff₀ (by norm_num) (by positivity)] nlinarith have hstep2 : (((s : ℝ) + 2) / 4) * (n : ℝ) ≤ ((s - 1).factorial : ℝ) / (2 * Real.exp 1 * (s : ℝ)) * (n : ℝ) := mul_le_mul_of_nonneg_right hcoeff hn_nn linarith /-- **Super-Exponential Dominance over Hendrey & Wanless (2020) as `s → ∞`**: for every constant `C : ℝ`, there exists `s₀` such that for all `s ≥ s₀` and all `n ≥ s`, every `s`-cover `S ⊆ S_n` satisfies `C * √s * n ≤ |S|`. -/ theorem perm_covering_beats_hendrey_wanless_superexp (C : ℝ) : ∃ s₀ : ℕ, ∀ s ≥ s₀, ∀ n ≥ s, ∀ S : Finset (Equiv.Perm (Fin n)), IsPermCover n s S → C * Real.sqrt (s : ℝ) * (n : ℝ) ≤ (S.card : ℝ) := by -- Use (s - 1)! ≥ 2^(s - 2) ≥ ... even simpler: for s ≥ max 6 (⌈6 * max C 0⌉ + 4), -- (s - 1)! ≥ 3 * s * (s + 2) * (s - 5)? Even simpler: (s - 1)! ≥ (s - 1) * (s - 2) * (s - 3) * (s - 4) for s ≥ 5! let M : ℕ := max 6 (Nat.ceil (6 * max C 0) + 5) refine ⟨M, fun s hs n hsn S hcov => ?_⟩ have hmain := perm_covering_lower_bound (by omega : 1 ≤ s) hsn hcov have hs6 : 6 ≤ s := le_trans (le_max_left _ _) hs have hsM : Nat.ceil (6 * max C 0) + 5 ≤ s := le_trans (le_max_right _ _) hs -- Lower bound (s - 1)! ≥ (s - 1) * (s - 2) * (s - 3) * (s - 4) have hfact_poly : (s - 4) * (s - 3) * (s - 2) * (s - 1) ≤ (s - 1).factorial := by have h1 : s - 1 = (s - 2) + 1 := by omega have h2 : s - 2 = (s - 3) + 1 := by omega have h3 : s - 3 = (s - 4) + 1 := by omega have h4 : s - 4 = (s - 5) + 1 := by omega rw [h1, Nat.factorial_succ, ← h1, h2, Nat.factorial_succ, ← h2, h3, Nat.factorial_succ, ← h3, h4, Nat.factorial_succ, ← h4] have hpos5 : 1 ≤ (s - 5).factorial := Nat.factorial_pos _ have hprod : (s - 1) * ((s - 2) * ((s - 3) * ((s - 4) * 1))) ≤ (s - 1) * ((s - 2) * ((s - 3) * ((s - 4) * (s - 5).factorial))) := Nat.mul_le_mul_left _ (Nat.mul_le_mul_left _ (Nat.mul_le_mul_left _ (Nat.mul_le_mul_left _ hpos5))) linarith have hfactR : ((s - 4 : ℕ) : ℝ) * ((s - 3 : ℕ) : ℝ) * ((s - 2 : ℕ) : ℝ) * ((s - 1 : ℕ) : ℝ) ≤ ((s - 1).factorial : ℝ) := by exact_mod_cast hfact_poly have hsR : (6 : ℝ) ≤ (s : ℝ) := by exact_mod_cast hs6 have hsub4 : ((s - 4 : ℕ) : ℝ) = (s : ℝ) - 4 := by rw [Nat.cast_sub (by omega)]; norm_num have hsub3 : ((s - 3 : ℕ) : ℝ) = (s : ℝ) - 3 := by rw [Nat.cast_sub (by omega)]; norm_num have hsub2 : ((s - 2 : ℕ) : ℝ) = (s : ℝ) - 2 := by rw [Nat.cast_sub (by omega)]; norm_num have hsub1 : ((s - 1 : ℕ) : ℝ) = (s : ℝ) - 1 := by rw [Nat.cast_sub (by omega)]; norm_num rw [hsub4, hsub3, hsub2, hsub1] at hfactR -- Since s ≥ 6: (s - 3)*(s - 2)*(s - 1) ≥ 6 * s^2 / 6? Actually check: -- (s-3)*(s-2)*(s-1) ≥ s^2 (for s ≥ 6: 3*4*5 = 60 ≥ 36 = 6^2!) have hcube : (s : ℝ) ^ 2 ≤ ((s : ℝ) - 3) * ((s : ℝ) - 2) * ((s : ℝ) - 1) := by have hq : 0 ≤ (s : ℝ) ^ 2 - (s : ℝ) + 5 := by nlinarith [sq_nonneg ((s : ℝ) - 1)] have hprod : 0 ≤ ((s : ℝ) - 6) * ((s : ℝ) ^ 2 - (s : ℝ) + 5) := mul_nonneg (by linarith) hq linarith [show ((s : ℝ) - 3) * ((s : ℝ) - 2) * ((s : ℝ) - 1) - (s : ℝ) ^ 2 = ((s : ℝ) - 6) * ((s : ℝ) ^ 2 - (s : ℝ) + 5) + 24 by ring] have hC_le : 6 * max C 0 ≤ (s : ℝ) - 4 := by have hceil : 6 * max C 0 ≤ (Nat.ceil (6 * max C 0) : ℝ) := Nat.le_ceil _ have hnat : (Nat.ceil (6 * max C 0) : ℝ) + 5 ≤ (s : ℝ) := by exact_mod_cast hsM linarith have hfact_ge_C : 6 * max C 0 * (s : ℝ) ^ 2 ≤ ((s - 1).factorial : ℝ) := by have h1 : 6 * max C 0 * (s : ℝ) ^ 2 ≤ ((s : ℝ) - 4) * (s : ℝ) ^ 2 := mul_le_mul_of_nonneg_right hC_le (sq_nonneg _) have h2 : ((s : ℝ) - 4) * (s : ℝ) ^ 2 ≤ ((s : ℝ) - 4) * (((s : ℝ) - 3) * ((s : ℝ) - 2) * ((s : ℝ) - 1)) := mul_le_mul_of_nonneg_left hcube (by linarith) linarith have he_lt : Real.exp 1 < 3 := by have := Real.exp_one_lt_d9; linarith have hsqrt_le : Real.sqrt (s : ℝ) ≤ (s : ℝ) := by calc Real.sqrt (s : ℝ) ≤ Real.sqrt ((s : ℝ) ^ 2) := Real.sqrt_le_sqrt (by nlinarith) _ = (s : ℝ) := Real.sqrt_sq (Nat.cast_nonneg s) have hCsqrt : C * Real.sqrt (s : ℝ) ≤ max C 0 * (s : ℝ) := by have h1 : C * Real.sqrt (s : ℝ) ≤ max C 0 * Real.sqrt (s : ℝ) := mul_le_mul_of_nonneg_right (le_max_left C 0) (Real.sqrt_nonneg _) have h2 : max C 0 * Real.sqrt (s : ℝ) ≤ max C 0 * (s : ℝ) := mul_le_mul_of_nonneg_left hsqrt_le (le_max_right C 0) exact h1.trans h2 have hcoeff : max C 0 * (s : ℝ) ≤ ((s - 1).factorial : ℝ) / (2 * Real.exp 1 * (s : ℝ)) := by have hspos : (0 : ℝ) < (s : ℝ) := Nat.cast_pos.mpr (by omega) have hepos : (0 : ℝ) < Real.exp 1 := Real.exp_pos 1 rw [le_div_iff₀ (by positivity)] have hmax_nn : 0 ≤ max C 0 := le_max_right C 0 have hmul_e : max C 0 * (s : ℝ) * (2 * Real.exp 1 * (s : ℝ)) ≤ 6 * max C 0 * (s : ℝ) ^ 2 := by have h2e : 2 * Real.exp 1 ≤ 6 := by linarith have hnn : 0 ≤ max C 0 * (s : ℝ) ^ 2 := mul_nonneg hmax_nn (sq_nonneg (s : ℝ)) nlinarith linarith have hn_nn : (0 : ℝ) ≤ (n : ℝ) := Nat.cast_nonneg n have hstep := mul_le_mul_of_nonneg_right (hCsqrt.trans hcoeff) hn_nn linarith /-- **Unbounded Linear Dominance over the Sphere-Covering Bound `s!`**: for every constant `C : ℝ` and every `s ≥ 1`, there exists `n₀` such that for all `n ≥ n₀`, every `s`-cover `S ⊆ S_n` satisfies `C * s! ≤ |S|`. -/ theorem perm_covering_beats_factorial_linearly (C : ℝ) {s : ℕ} (hs : 1 ≤ s) : ∃ n₀ : ℕ, ∀ n ≥ n₀, ∀ S : Finset (Equiv.Perm (Fin n)), IsPermCover n s S → C * (s.factorial : ℝ) ≤ (S.card : ℝ) := by let n₀ : ℕ := max s (Nat.ceil (6 * max C 0 * (s : ℝ) ^ 2)) refine ⟨n₀, fun n hn S hcov => ?_⟩ have hsn : s ≤ n := le_trans (le_max_left _ _) hn have hn_ge : 6 * max C 0 * (s : ℝ) ^ 2 ≤ (n : ℝ) := by have h1 : 6 * max C 0 * (s : ℝ) ^ 2 ≤ (Nat.ceil (6 * max C 0 * (s : ℝ) ^ 2) : ℝ) := Nat.le_ceil _ have h2 : (Nat.ceil (6 * max C 0 * (s : ℝ) ^ 2) : ℝ) ≤ (n : ℝ) := by exact_mod_cast le_trans (le_max_right _ _) hn exact h1.trans h2 have hmain := perm_covering_lower_bound hs hsn hcov have hsfact : (s.factorial : ℝ) = (s : ℝ) * ((s - 1).factorial : ℝ) := by have : s = (s - 1) + 1 := by omega have hnat : s.factorial = s * (s - 1).factorial := by conv_lhs => rw [this, Nat.factorial_succ] rw [← this] exact_mod_cast hnat have he_lt : Real.exp 1 < 3 := by have := Real.exp_one_lt_d9; linarith have hspos : (0 : ℝ) < (s : ℝ) := Nat.cast_pos.mpr hs have hepos : (0 : ℝ) < Real.exp 1 := Real.exp_pos 1 have hsf_pos : (0 : ℝ) < ((s - 1).factorial : ℝ) := Nat.cast_pos.mpr (Nat.factorial_pos _) have hC_le : C * (s.factorial : ℝ) ≤ ((s - 1).factorial : ℝ) / (2 * Real.exp 1 * (s : ℝ)) * (n : ℝ) := by rw [hsfact, div_mul_eq_mul_div, le_div_iff₀ (by positivity)] have h1 : C * ((s : ℝ) * ((s - 1).factorial : ℝ)) * (2 * Real.exp 1 * (s : ℝ)) ≤ max C 0 * ((s : ℝ) * ((s - 1).factorial : ℝ)) * (2 * Real.exp 1 * (s : ℝ)) := by have : 0 ≤ ((s : ℝ) * ((s - 1).factorial : ℝ)) * (2 * Real.exp 1 * (s : ℝ)) := by positivity nlinarith [le_max_left C 0] have h2 : max C 0 * ((s : ℝ) * ((s - 1).factorial : ℝ)) * (2 * Real.exp 1 * (s : ℝ)) ≤ ((s - 1).factorial : ℝ) * (6 * max C 0 * (s : ℝ) ^ 2) := by have : 2 * Real.exp 1 ≤ 6 := by linarith have : 0 ≤ max C 0 * ((s - 1).factorial : ℝ) * (s : ℝ) ^ 2 := by have := le_max_right C 0; positivity nlinarith have h3 : ((s - 1).factorial : ℝ) * (6 * max C 0 * (s : ℝ) ^ 2) ≤ ((s - 1).factorial : ℝ) * (n : ℝ) := mul_le_mul_of_nonneg_left hn_ge hsf_pos.le linarith linarith /-- **Even-`n` Upper Bound Sanity Theorem (`f(n, 2) ≤ n` for positive even `n`)**: the `n` cyclic shifts of `ZMod n` form a `2`-cover of `Equiv.Perm (Fin n)` whenever `n = 2 * (m + 1)`. (Connects directly to `LatinSquare.z_even` and Kézdy–Snevily / Wanless Conjecture 9.2.) -/ theorem even_perm_cover_two_le_n (m : ℕ) : let n := 2 * (m + 1) ∃ S : Finset (Equiv.Perm (Fin n)), S.card = n ∧ IsPermCover n 2 S := by intro n have hnpos : 0 < n := by dsimp only [n]; omega have : NeZero n := ⟨hnpos.ne'⟩ let g : Fin n → ZMod n := fun i => ((i.val : ℕ) : ZMod n) have hg_inj : Function.Injective g := by intro i j h apply Fin.ext have hi : (g i).val = i.val := ZMod.val_natCast_of_lt i.isLt have hj : (g j).val = j.val := ZMod.val_natCast_of_lt j.isLt rw [← hi, ← hj, h] let e : Fin n ≃ ZMod n := Equiv.ofBijective g ((Fintype.bijective_iff_injective_and_card g).mpr ⟨hg_inj, by rw [Fintype.card_fin, ZMod.card]⟩) let shift : ZMod n → Equiv.Perm (Fin n) := fun k => (e.trans (Equiv.addRight k)).trans e.symm have hshift_inj : Function.Injective shift := by intro k₁ k₂ h have h0 := congrArg (fun σ => e (σ (e.symm 0))) h simpa [shift] using h0 let S : Finset (Equiv.Perm (Fin n)) := Finset.univ.image shift refine ⟨S, ?_, ?_⟩ · rw [Finset.card_image_of_injective _ hshift_inj, Finset.card_univ, ZMod.card] · intro π -- By pigeonhole on `i ↦ e (π i) - e i : Fin n → ZMod n`, if no shift agrees in ≥ 2 places -- then `f i = e (π i) - e i` is injective, hence bijective, giving a parity contradiction! let f : Fin n → ZMod n := fun i => e (π i) - e i by_cases hinj : Function.Injective f · exfalso have hbij : Function.Bijective f := (Fintype.bijective_iff_injective_and_card f).mpr ⟨hinj, by rw [Fintype.card_fin, ZMod.card]⟩ let fE : Fin n ≃ ZMod n := Equiv.ofBijective f hbij let sumZ : ZMod n := ∑ x : ZMod n, x have hsum_f : ∑ i : Fin n, f i = sumZ := Equiv.sum_comp fE id have hsum_e : ∑ i : Fin n, e i = sumZ := Equiv.sum_comp e id have hsum_π : ∑ i : Fin n, e (π i) = sumZ := Equiv.sum_comp (π.trans e) id have hzero : sumZ = 0 := by have : ∑ i : Fin n, f i = (∑ i : Fin n, e (π i)) - ∑ i : Fin n, e i := by simp only [f, Finset.sum_sub_distrib] rw [hsum_f, hsum_π, hsum_e, sub_self] at this exact this -- Compute sumZ = (n * (n - 1) / 2 : ZMod n) = ((m + 1) * (2 * m + 1) : ZMod n) ≠ 0 have hval : sumZ = (((Finset.range n).sum id : ℕ) : ZMod n) := by have h1 : sumZ = ∑ i : Fin n, ((i.val : ℕ) : ZMod n) := by rw [← hsum_e] rfl rw [h1] push_cast [Fin.sum_univ_eq_sum_range fun k => ((k : ℕ) : ZMod n), id] rfl rw [hval, show (Finset.range n).sum id = ∑ i ∈ Finset.range n, i from rfl, Finset.sum_range_id] at hzero have hdiv : n * (n - 1) / 2 = (m + 1) * (2 * m + 1) := by dsimp only [n] have h1 : 2 * (m + 1) - 1 = 2 * m + 1 := by omega rw [h1, show 2 * (m + 1) * (2 * m + 1) = 2 * ((m + 1) * (2 * m + 1)) from by ring, Nat.mul_div_cancel_left _ (by norm_num : 0 < 2)] rw [hdiv] at hzero have hdvd : n ∣ (m + 1) * (2 * m + 1) := (ZMod.natCast_eq_zero_iff _ _).mp hzero dsimp only [n] at hdvd rw [show 2 * (m + 1) = (m + 1) * 2 from by ring, mul_dvd_mul_iff_left (Nat.succ_ne_zero m)] at hdvd omega · unfold Function.Injective at hinj push Not at hinj obtain ⟨i₁, i₂, hfeq, hne⟩ := hinj let k : ZMod n := f i₁ refine ⟨shift k, Finset.mem_image_of_mem shift (Finset.mem_univ k), ?_⟩ have hi₁ : π i₁ = shift k i₁ := by apply e.injective simp [shift, k, f] have hi₂ : π i₂ = shift k i₂ := by apply e.injective simp [shift, k, hfeq, f] have hsub : ({i₁, i₂} : Finset (Fin n)) ⊆ Finset.univ.filter fun i => π i = shift k i := by intro i hi simp only [Finset.mem_insert, Finset.mem_singleton] at hi rcases hi with rfl | rfl · exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, hi₁⟩ · exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, hi₂⟩ calc 2 = ({i₁, i₂} : Finset (Fin n)).card := (Finset.card_pair hne).symm _ ≤ (Finset.univ.filter fun i => π i = shift k i).card := Finset.card_le_card hsub end Comparisons /-! ## Axiom Audit -/ #print axioms lopsided_lll #print axioms lopsided_lll_symmetric #print axioms perm_negative_dependency #print axioms perm_covering_lower_bound #print axioms perm_covering_sphere_bound #print axioms perm_covering_beats_hendrey_wanless_pointwise #print axioms perm_covering_beats_hendrey_wanless_superexp #print axioms perm_covering_beats_factorial_linearly #print axioms even_perm_cover_two_le_n end PermCoveringLowerBound