|
| 1 | +/- |
| 2 | +Copyright (c) 2024-present Ching-Tsun Chou and Chris Wong. All rights reserved. |
| 3 | +Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | +Authors: Ching-Tsun Chou and Chris Wong |
| 5 | +-/ |
| 6 | + |
| 7 | +import Mathlib.Data.Fintype.Perm |
| 8 | +import Mathlib.Probability.UniformOn |
| 9 | + |
| 10 | +/-! |
| 11 | +# Proof of the LYM inequality using probability theory |
| 12 | +
|
| 13 | +This file contains a formalization of the proof of the LYM inequality using |
| 14 | +(very elementary) probability theory given in Section 1.2 of Prof. Yufei Zhao's |
| 15 | +lecture notes for MIT 18.226: |
| 16 | +
|
| 17 | +<https://yufeizhao.com/pm/probmethod_notes.pdf> |
| 18 | +
|
| 19 | +A video of Prof. Zhao's lecture on this proof is available on YouTube: |
| 20 | +
|
| 21 | +<https://youtu.be/exBXHYl4po8?si=aW8hhJ6zBrvWT1T0> |
| 22 | +
|
| 23 | +The proof of Theorem 1.10, Lecture 3 in the Cambridge lecture notes on combinatorics: |
| 24 | +
|
| 25 | +<https://github.com/YaelDillies/maths-notes/blob/master/combinatorics.pdf> |
| 26 | +
|
| 27 | +is basically the same proof, except with probability theory stripped out. |
| 28 | +-/ |
| 29 | + |
| 30 | +open BigOperators Fintype Finset Set MeasureTheory ProbabilityTheory |
| 31 | +open MeasureTheory.Measure |
| 32 | +open scoped ENNReal |
| 33 | + |
| 34 | +noncomputable section |
| 35 | + |
| 36 | +/-- A numbering is a bijective map from a finite type or set to a Fin type |
| 37 | +of the same cardinality. We cannot use the existing notion of permutations |
| 38 | +in mathlib because we need the special property `set_prefix_subset` below. -/ |
| 39 | + |
| 40 | +@[reducible] |
| 41 | +def Numbering (α : Type*) [Fintype α] := α ≃ Fin (card α) |
| 42 | + |
| 43 | +@[reducible] |
| 44 | +def NumberingOn {α : Type*} (s : Finset α) := {x // x ∈ s} ≃ Fin s.card |
| 45 | + |
| 46 | +variable {α : Type*} [Fintype α] [DecidableEq α] |
| 47 | + |
| 48 | +theorem numbering_card : card (Numbering α) = (card α).factorial := by |
| 49 | + exact Fintype.card_equiv (Fintype.equivFinOfCardEq rfl) |
| 50 | + |
| 51 | +omit [Fintype α] in |
| 52 | +theorem numbering_on_card (s : Finset α) : card (NumberingOn s) = s.card.factorial := by |
| 53 | + simp only [NumberingOn] |
| 54 | + have h1 : card {x // x ∈ s} = card (Fin s.card) := by simp |
| 55 | + have h2 : {x // x ∈ s} ≃ (Fin s.card) := by exact Fintype.equivOfCardEq h1 |
| 56 | + simp [Fintype.card_equiv h2] |
| 57 | + |
| 58 | +/-- `IsPrefix s f` means that the elements of `s` precede the elements of `sᶜ` |
| 59 | +in the numbering `f`. -/ |
| 60 | +def IsPrefix (s : Finset α) (f : Numbering α) := |
| 61 | + ∀ x, x ∈ s ↔ f x < s.card |
| 62 | + |
| 63 | +omit [DecidableEq α] in |
| 64 | +theorem is_prefix_subset {s1 s2 : Finset α} {f : Numbering α} |
| 65 | + (h_s1 : IsPrefix s1 f) (h_s2 : IsPrefix s2 f) (h_card : s1.card ≤ s2.card) : s1 ⊆ s2 := by |
| 66 | + intro a h_as1 |
| 67 | + exact (h_s2 a).mpr (lt_of_lt_of_le ((h_s1 a).mp h_as1) h_card) |
| 68 | + |
| 69 | +def is_prefix_equiv (s : Finset α) : {f // IsPrefix s f} ≃ NumberingOn s × NumberingOn sᶜ where |
| 70 | + toFun := fun ⟨f, hf⟩ ↦ |
| 71 | + ({ |
| 72 | + toFun := fun ⟨x, hx⟩ ↦ ⟨f x, by rwa [← hf x]⟩ |
| 73 | + invFun := fun ⟨n, hn⟩ ↦ ⟨f.symm ⟨n, by have := s.card_le_univ; omega⟩, by rw [hf]; simpa⟩ |
| 74 | + left_inv := by rintro ⟨x, hx⟩; simp |
| 75 | + right_inv := by rintro ⟨n, hn⟩; simp |
| 76 | + }, |
| 77 | + { |
| 78 | + toFun := fun ⟨x, hx⟩ ↦ ⟨f x - s.card, by |
| 79 | + rw [s.mem_compl, hf] at hx |
| 80 | + rw [s.card_compl] |
| 81 | + exact Nat.sub_lt_sub_right (by omega) (by omega) |
| 82 | + ⟩ |
| 83 | + invFun := fun ⟨n, hn⟩ ↦ ⟨f.symm ⟨n + s.card, by rw [s.card_compl] at hn; omega⟩, |
| 84 | + by rw [s.mem_compl, hf]; simp⟩ |
| 85 | + left_inv := by |
| 86 | + rintro ⟨x, hx⟩ |
| 87 | + rw [s.mem_compl, hf, not_lt] at hx |
| 88 | + simp [Nat.sub_add_cancel hx] |
| 89 | + right_inv := by rintro ⟨n, hn⟩; simp |
| 90 | + }) |
| 91 | + invFun := fun (g, g') ↦ ⟨ |
| 92 | + { |
| 93 | + toFun := fun x ↦ |
| 94 | + if hx : x ∈ s then |
| 95 | + g ⟨x, hx⟩ |>.castLE s.card_le_univ |
| 96 | + else |
| 97 | + g' ⟨x, by simpa⟩ |>.addNat s.card |>.cast (by simp) |
| 98 | + invFun := fun ⟨n, hn⟩ ↦ |
| 99 | + if hn' : n < s.card then |
| 100 | + g.symm ⟨n, hn'⟩ |
| 101 | + else |
| 102 | + g'.symm ⟨n - s.card, by rw [s.card_compl]; omega⟩ |
| 103 | + left_inv := by intro x; by_cases hx : x ∈ s <;> simp [hx] |
| 104 | + right_inv := by |
| 105 | + rintro ⟨n, hn⟩ |
| 106 | + by_cases hn' : n < s.card |
| 107 | + · simp [hn'] |
| 108 | + · simp [hn'] |
| 109 | + split_ifs |
| 110 | + · rename_i h |
| 111 | + have : ∀ x, ↑(g'.symm x) ∉ s := by |
| 112 | + intro x |
| 113 | + simp only [← Finset.mem_compl, Finset.coe_mem] |
| 114 | + exact this _ h |>.elim |
| 115 | + · simp [Nat.sub_add_cancel (not_lt.mp hn')] |
| 116 | + }, |
| 117 | + by |
| 118 | + intro x |
| 119 | + constructor |
| 120 | + · intro hx |
| 121 | + simp [hx] |
| 122 | + · by_cases hx : x ∈ s <;> simp [hx] |
| 123 | + ⟩ |
| 124 | + left_inv := by |
| 125 | + rintro ⟨f, hf⟩ |
| 126 | + ext x |
| 127 | + by_cases hx : x ∈ s |
| 128 | + · simp [hx] |
| 129 | + · rw [hf, not_lt] at hx |
| 130 | + simp [hx] |
| 131 | + right_inv := by |
| 132 | + rintro ⟨g, g'⟩ |
| 133 | + simp |
| 134 | + constructor |
| 135 | + · ext x |
| 136 | + simp |
| 137 | + · ext x |
| 138 | + rcases x with ⟨x, hx⟩ |
| 139 | + rw [Finset.mem_compl] at hx |
| 140 | + simp [hx] |
| 141 | + |
| 142 | +instance (s : Finset α) : |
| 143 | + DecidablePred fun f ↦ (IsPrefix s f) := by |
| 144 | + intro f ; exact Classical.propDecidable ((fun f ↦ IsPrefix s f) f) |
| 145 | + |
| 146 | +def SetPrefix (s : Finset α) : Finset (Numbering α) := |
| 147 | + {f | IsPrefix s f} |
| 148 | + |
| 149 | +theorem set_prefix_card (s : Finset α) : |
| 150 | + (SetPrefix s).card = s.card.factorial * (card α - s.card).factorial := by |
| 151 | + have h_eq:= Fintype.card_congr (is_prefix_equiv s) |
| 152 | + rw [Fintype.card_subtype] at h_eq |
| 153 | + rw [SetPrefix, h_eq, Fintype.card_prod, numbering_on_card s, numbering_on_card sᶜ, card_compl] |
| 154 | + |
| 155 | +private lemma aux_1 {k m n : ℕ} (hn : 0 < n) (heq : k * m = n) : |
| 156 | + (↑ m : ENNReal) / (↑ n : ENNReal) = 1 / (↑ k : ENNReal) := by |
| 157 | + -- The following proof is due to Aaron Liu. |
| 158 | + subst heq |
| 159 | + have hm : m ≠ 0 := by rintro rfl ; simp at hn |
| 160 | + have hk : k ≠ 0 := by rintro rfl ; simp at hn |
| 161 | + refine (ENNReal.toReal_eq_toReal ?_ ?_).mp ?_ |
| 162 | + · intro h |
| 163 | + apply_fun ENNReal.toReal at h |
| 164 | + simp [hm, hk] at h |
| 165 | + · intro h |
| 166 | + apply_fun ENNReal.toReal at h |
| 167 | + simp [hk] at h |
| 168 | + · field_simp |
| 169 | + ring |
| 170 | + |
| 171 | +instance : MeasurableSpace (Numbering α) := ⊤ |
| 172 | + |
| 173 | +theorem set_prefix_count (s : Finset α) : |
| 174 | + count (SetPrefix s).toSet = ↑(s.card.factorial * (card α - s.card).factorial) := by |
| 175 | + rw [← set_prefix_card s, count_apply_finset] |
| 176 | + |
| 177 | +theorem set_prefix_prob (s : Finset α) : |
| 178 | + uniformOn Set.univ (SetPrefix s).toSet = 1 / (card α).choose s.card := by |
| 179 | + rw [uniformOn_univ, set_prefix_count s, numbering_card] |
| 180 | + apply aux_1 (Nat.factorial_pos (card α)) |
| 181 | + rw [← mul_assoc] |
| 182 | + exact Nat.choose_mul_factorial_mul_factorial (Finset.card_le_univ s) |
| 183 | + |
| 184 | +theorem set_prefix_disj {s t : Finset α} (h_st : ¬ s ⊆ t) (h_ts : ¬ t ⊆ s) : |
| 185 | + Disjoint (SetPrefix s).toSet (SetPrefix t).toSet := by |
| 186 | + refine Set.disjoint_iff.mpr ?_ |
| 187 | + intro p |
| 188 | + simp only [mem_inter_iff, Finset.mem_coe, mem_empty_iff_false, imp_false, not_and] |
| 189 | + simp [SetPrefix] |
| 190 | + intro h_s h_t |
| 191 | + rcases Nat.le_total s.card t.card with h_st' | h_ts' |
| 192 | + · exact h_st (is_prefix_subset h_s h_t h_st') |
| 193 | + · exact h_ts (is_prefix_subset h_t h_s h_ts') |
| 194 | + |
| 195 | +variable {𝓐 : Finset (Finset α)} |
| 196 | + |
| 197 | +theorem antichain_union_prob (h𝓐 : IsAntichain (· ⊆ ·) 𝓐.toSet) : |
| 198 | + uniformOn Set.univ (⋃ s ∈ 𝓐, (SetPrefix s).toSet) = |
| 199 | + ∑ s ∈ 𝓐, uniformOn Set.univ (SetPrefix s).toSet := by |
| 200 | + have hd : 𝓐.toSet.PairwiseDisjoint (fun s ↦ (SetPrefix s).toSet) := by |
| 201 | + intro s h_s t h_t h_ne |
| 202 | + simp only [Function.onFun] |
| 203 | + have h_st := h𝓐 h_s h_t h_ne |
| 204 | + have h_ts := h𝓐 h_t h_s h_ne.symm |
| 205 | + exact set_prefix_disj h_st h_ts |
| 206 | + have hm : ∀ s ∈ 𝓐, MeasurableSet (SetPrefix s).toSet := by |
| 207 | + intro s h_s ; exact trivial |
| 208 | + rw [measure_biUnion_finset hd hm (μ := uniformOn Set.univ)] |
| 209 | + |
| 210 | +theorem LYM_inequality (h𝓐 : IsAntichain (· ⊆ ·) 𝓐.toSet) : |
| 211 | + ∑ s ∈ 𝓐, ((1 : ENNReal) / (card α).choose s.card) ≤ 1 := by |
| 212 | + have h1 : ∀ s ∈ 𝓐, |
| 213 | + (1 : ENNReal) / (card α).choose s.card = uniformOn Set.univ (SetPrefix s).toSet := by |
| 214 | + intro s h_s |
| 215 | + rw [set_prefix_prob] |
| 216 | + rw [Finset.sum_congr (rfl : 𝓐 = 𝓐) h1, ← antichain_union_prob h𝓐] |
| 217 | + exact prob_le_one |
| 218 | + |
| 219 | +end |
0 commit comments