@@ -4,100 +4,118 @@ Released under Apache 2.0 license as described in the file LICENSE.
44Authors: Ching-Tsun Chou, Chris Wong
55-/
66import LeanCamCombi.Mathlib.Data.Fintype.Card
7- import LeanCamCombi.PlainCombi.ProbLYM
8- import Mathlib.Probability.UniformOn
7+ import LeanCamCombi.Mathlib.Data.Nat.Choose.Cast
8+ import Mathlib.Data.Finset.Density
9+ import Mathlib.Data.Fintype.Prod
10+ import Mathlib.Data.Fintype.Perm
911
1012/-!
11- # The LYM inequality using probability theory
13+ # The Katona circle method
1214
13- This file proves the LYM inequality using (very elementary) probability theory.
15+ This file provides tooling to use the Katona circle method, which is double-counting ways to order
16+ `n` elements on a circle under some condition.
17+ -/
1418
15- ## References
19+ open Fintype Finset Nat
1620
17- This proof formalizes Section 1.2 of Prof. Yufei Zhao's lecture notes for MIT 18.226:
21+ variable {α : Type *} [Fintype α]
1822
19- <https://yufeizhao.com/pm/probmethod_notes.pdf>
23+ variable (α) in
24+ /-- A numbering of a fintype `α` is a bijection between `α` and `Fin (card α)`. -/
25+ abbrev Numbering : Type _ := α ≃ Fin (card α)
2026
21- A video of Prof. Zhao's lecture is available on YouTube:
27+ @[simp] lemma Fintype.card_numbering [DecidableEq α] : card (Numbering α) = (card α)! :=
28+ card_equiv (equivFin _)
2229
23- <https://youtu.be/exBXHYl4po8>
30+ namespace Numbering
31+ variable {f : Numbering α} {s t : Finset α}
2432
25- The proof of Theorem 1.10, Lecture 3 in the Cambridge lecture notes on combinatorics:
33+ /-- `IsPrefix f s` means that the elements of `s` precede the elements of `sᶜ`
34+ in the numbering `f`. -/
35+ def IsPrefix (f : Numbering α) (s : Finset α) := ∀ x, x ∈ s ↔ f x < #s
2636
27- <https://github.com/YaelDillies/maths-notes/blob/master/combinatorics.pdf>
37+ lemma IsPrefix.subset_of_card_le_card (hs : IsPrefix f s) (ht : IsPrefix f t) (hst : #s ≤ #t) :
38+ s ⊆ t := fun a ha ↦ (ht a).mpr <| ((hs a).mp ha).trans_le hst
2839
29- is basically the same proof, except without using probability theory.
30- -/
40+ variable [DecidableEq α]
41+
42+ instance : Decidable (IsPrefix f s) := by unfold IsPrefix; infer_instance
3143
32- open BigOperators Fintype Finset Set MeasureTheory ProbabilityTheory
33- open MeasureTheory.Measure
34- open scoped ENNReal
35-
36- noncomputable section
37-
38- private lemma auxLemma {k m n : ℕ} (hn : 0 < n) (heq : k * m = n) :
39- (↑ m : ENNReal) / (↑ n : ENNReal) = 1 / (↑ k : ENNReal) := by
40- -- The following proof is due to Aaron Liu.
41- subst heq
42- have hm : m ≠ 0 := by rintro rfl ; simp at hn
43- have hk : k ≠ 0 := by rintro rfl ; simp at hn
44- refine (ENNReal.toReal_eq_toReal ?_ ?_).mp ?_
45- · intro h
46- apply_fun ENNReal.toReal at h
47- simp [hm, hk] at h
48- · intro h
49- apply_fun ENNReal.toReal at h
50- simp [hk] at h
51- · field_simp
52- ring
53-
54- variable {α : Type *} [Fintype α] [DecidableEq α]
55-
56- instance : MeasurableSpace (Numbering α) := ⊤
57-
58- theorem count_PrefixedNumbering (s : Finset α) :
59- count (PrefixedNumbering s).toSet = ↑((#s).factorial * (card α - #s).factorial) := by
60- rw [← card_PrefixedNumbering s, count_apply_finset]
61-
62- theorem prob_PrefixedNumbering (s : Finset α) :
63- uniformOn Set.univ (PrefixedNumbering s).toSet = 1 / (card α).choose #s := by
64- rw [uniformOn_univ, count_PrefixedNumbering s, card_Numbering]
65- apply auxLemma (Nat.factorial_pos (card α))
66- rw [← mul_assoc]
67- exact Nat.choose_mul_factorial_mul_factorial (Finset.card_le_univ s)
68-
69- theorem disj_PrefixedNumbering {s t : Finset α} (h_st : ¬ s ⊆ t) (h_ts : ¬ t ⊆ s) :
70- Disjoint (PrefixedNumbering s).toSet (PrefixedNumbering t).toSet := by
71- refine Set.disjoint_iff.mpr ?_
72- intro p
73- simp only [mem_inter_iff, Finset.mem_coe, mem_empty_iff_false, imp_false, not_and]
74- simp [PrefixedNumbering]
75- intro h_s h_t
76- rcases Nat.le_total #s t.card with h_st' | h_ts'
77- · exact h_st (subset_IsPrefix_IsPrefix h_s h_t h_st')
78- · exact h_ts (subset_IsPrefix_IsPrefix h_t h_s h_ts')
79-
80- variable {𝓐 : Finset (Finset α)}
81-
82- theorem prob_biUnion_antichain (h𝓐 : IsAntichain (· ⊆ ·) 𝓐.toSet) :
83- uniformOn Set.univ (⋃ s ∈ 𝓐, (PrefixedNumbering s).toSet) =
84- ∑ s ∈ 𝓐, uniformOn Set.univ (PrefixedNumbering s).toSet := by
85- have hd : 𝓐.toSet.PairwiseDisjoint (fun s ↦ (PrefixedNumbering s).toSet) := by
86- intro s h_s t h_t h_ne
87- simp only [Function.onFun]
88- have h_st := h𝓐 h_s h_t h_ne
89- have h_ts := h𝓐 h_t h_s h_ne.symm
90- exact disj_PrefixedNumbering h_st h_ts
91- have hm : ∀ s ∈ 𝓐, MeasurableSet (PrefixedNumbering s).toSet := by
92- intro s h_s ; exact trivial
93- rw [measure_biUnion_finset hd hm (μ := uniformOn Set.univ)]
94-
95- theorem LYM_inequality (h𝓐 : IsAntichain (· ⊆ ·) 𝓐.toSet) :
96- ∑ s ∈ 𝓐, ((1 : ENNReal) / (card α).choose #s) ≤ 1 := by
97- have h1 s (hs : s ∈ 𝓐) :
98- (1 : ENNReal) / (card α).choose #s = uniformOn Set.univ (PrefixedNumbering s).toSet := by
99- rw [prob_PrefixedNumbering]
100- rw [Finset.sum_congr (rfl : 𝓐 = 𝓐) h1, ← prob_biUnion_antichain h𝓐]
101- exact prob_le_one
102-
103- end
44+ /-- The set of numberings of which `s` is a prefix. -/
45+ def prefixed (s : Finset α) : Finset (Numbering α) := {f | IsPrefix f s}
46+
47+ @[simp] lemma mem_prefixed : f ∈ prefixed s ↔ IsPrefix f s := by simp [prefixed]
48+
49+ /-- Decompose a numbering of which `s` is a prefix into a numbering of `s` and a numbering on `sᶜ`.
50+ -/
51+ def prefixedEquiv (s : Finset α) : prefixed s ≃ Numbering s × Numbering ↑(sᶜ) where
52+ toFun f :=
53+ { fst.toFun x := ⟨f.1 x, by simp [← mem_prefixed.1 f.2 x]⟩
54+ fst.invFun n :=
55+ ⟨f.1 .symm ⟨n, n.2 .trans_le <| by simpa using s.card_le_univ⟩, by
56+ rw [mem_prefixed.1 f.2 ]; simpa using n.2 ⟩
57+ fst.left_inv x := by simp
58+ fst.right_inv n := by simp
59+ snd.toFun x := ⟨f.1 x - #s, by
60+ have := (mem_prefixed.1 f.2 x).not.1 (Finset.mem_compl.1 x.2 )
61+ simp at this ⊢
62+ omega⟩
63+ snd.invFun n :=
64+ ⟨f.1 .symm ⟨n + #s, Nat.add_lt_of_lt_sub <| by simpa using n.2 ⟩, by
65+ rw [s.mem_compl, mem_prefixed.1 f.2 ]; simp⟩
66+ snd.left_inv := by
67+ rintro ⟨x, hx⟩
68+ rw [s.mem_compl, mem_prefixed.1 f.2 , not_lt] at hx
69+ simp [Nat.sub_add_cancel hx]
70+ snd.right_inv := by rintro ⟨n, hn⟩; simp }
71+ invFun := fun (g, g') ↦
72+ { val.toFun x :=
73+ if hx : x ∈ s then
74+ g ⟨x, hx⟩ |>.castLE Fintype.card_subtype_le'
75+ else
76+ g' ⟨x, by simpa⟩ |>.addNat #s |>.cast (by simp [card_le_univ])
77+ val.invFun n :=
78+ if hn : n < #s then
79+ g.symm ⟨n, by simpa using hn⟩
80+ else
81+ g'.symm ⟨n - #s, by simp; omega⟩
82+ val.left_inv x := by
83+ by_cases hx : x ∈ s
84+ · have : g ⟨x, hx⟩ < #s := by simpa using (g ⟨x, hx⟩).2
85+ simp [hx, this]
86+ · simp [hx, Equiv.symm_apply_eq]
87+ val.right_inv n := by
88+ obtain hns | hsn := lt_or_le n.1 #s
89+ · simp [hns]
90+ · simp [hsn.not_lt, hsn, dif_neg (mem_compl.1 <| Subtype.prop _), Fin.ext_iff,
91+ Fintype.card_subtype_le']
92+ property := mem_prefixed.2 fun x ↦ by
93+ constructor
94+ · intro hx
95+ simpa [hx, -Fin.is_lt] using (g _).is_lt
96+ · by_cases hx : x ∈ s <;> simp [hx] }
97+ left_inv f := by
98+ ext x
99+ by_cases hx : x ∈ s
100+ · simp [hx]
101+ · rw [mem_prefixed.1 f.2 , not_lt] at hx
102+ simp [hx]
103+ right_inv g := by simp +contextual [Prod.ext_iff, DFunLike.ext_iff]
104+
105+ lemma card_prefixed (s : Finset α) : #(prefixed s) = (#s)! * (card α - #s)! := by
106+ simpa [-mem_prefixed] using Fintype.card_congr (prefixedEquiv s)
107+
108+ @[simp]
109+ lemma dens_prefixed (s : Finset α) : (prefixed s).dens = ((card α).choose #s : ℚ≥0 )⁻¹ := by
110+ simp [dens, card_prefixed, Nat.cast_choose' _ s.card_le_univ]
111+
112+ -- TODO: This can be strengthened to an iff
113+ lemma disjoint_prefixed_prefixed (hst : ¬ s ⊆ t) (hts : ¬ t ⊆ s) :
114+ Disjoint (prefixed s) (prefixed t) := by
115+ simp only [Finset.disjoint_left, mem_prefixed]
116+ intro f hs ht
117+ obtain hst' | hts' := Nat.le_total #s #t
118+ · exact hst <| hs.subset_of_card_le_card ht hst'
119+ · exact hts <| ht.subset_of_card_le_card hs hts'
120+
121+ end Numbering
0 commit comments