Lean / Reader
Lean reader

DeskStatementAudit.lean

227 lines17 declarationsno sorryimports Mathlib.Combinatorics.SimpleGraph.Coloring Mathlib.Tactic.Cases Mathlib.Combinatorics.SimpleGraph.Clique Mathlib.Combinatorics.SimpleGraph.Copy Mathlib.Data.Nat.Lattice Mathlib.Tactic.FinCases +2
  1. import Mathlib.Combinatorics.SimpleGraph.Coloring
  2. import Mathlib.Tactic.Cases
  3. import Mathlib.Combinatorics.SimpleGraph.Clique
  4. import Mathlib.Combinatorics.SimpleGraph.Copy
  5. import Mathlib.Data.Nat.Lattice
  6. import Mathlib.Tactic.FinCases
  7. import Mathlib.Tactic.Linarith
  8. import Mathlib.Tactic.NormNum
  9. /-!
  10. # Basic definitions for Erdős Problem 550
  11. This file sets up the basic objects used throughout the formalisation of
  12. *A Resolution of Erdős Problem 550 on Tree versus Complete Multipartite
  13. Ramsey Numbers* (E. Li).
  14. We work with the standard graph-Ramsey-number convention: a red–blue colouring
  15. of the complete graph `K_N` is modelled by a single simple graph `G` on `Fin N`
  16. (the *red* graph), the *blue* graph being its complement `Gᶜ`. A *red copy* of a
  17. graph `J` is a graph-containment `J ⊑ G`, and a *blue copy* of `L` is
  18. `L ⊑ Gᶜ`.
  19. `SimpleGraph.IsContained` (notation `⊑`) is the (non-induced) subgraph-copy
  20. relation from Mathlib.
  21. -/
  22. open SimpleGraph
  23. namespace Erdos550
  24. /-- The (two-colour) Ramsey number `R(J, L)`: the least `N` such that every
  25. red–blue colouring of `K_N` (modelled by a red graph `G` on `Fin N`) contains a
  26. red copy of `J` or a blue copy of `L`. -/
  27. noncomputable def ramsey {α β : Type*} (J : SimpleGraph α) (L : SimpleGraph β) : ℕ :=
  28. sInf {N | ∀ G : SimpleGraph (Fin N), J ⊑ G ∨ L ⊑ Gᶜ}
  29. /-- The set of `N` that "witness" `R(J,L)`: those `N` for which every colouring of
  30. `K_N` already contains a red `J` or a blue `L`. -/
  31. def RamseyGood {α β : Type*} (J : SimpleGraph α) (L : SimpleGraph β) : Set ℕ :=
  32. {N | ∀ G : SimpleGraph (Fin N), J ⊑ G ∨ L ⊑ Gᶜ}
  33. /-- The complete multipartite graph `K_{m 0, …, m (k-1)}` whose `i`-th independent
  34. class has order `m i`. -/
  35. noncomputable def Kmult (k : ℕ) (m : Fin k → ℕ) :
  36. SimpleGraph ((i : Fin k) × Fin (m i)) :=
  37. completeMultipartiteGraph (fun i => Fin (m i))
  38. /-- The complete bipartite graph `K_{a,b}`. -/
  39. abbrev Kbip (a b : ℕ) : SimpleGraph (Fin a ⊕ Fin b) :=
  40. completeBipartiteGraph (Fin a) (Fin b)
  41. /-- To bound a Ramsey number from above it suffices to exhibit a witness `N`. -/
  42. theorem ramsey_le_of_mem {α β : Type*} (J : SimpleGraph α) (L : SimpleGraph β)
  43. {N : ℕ} (hN : N ∈ RamseyGood J L) : ramsey J L ≤ N :=
  44. Nat.sInf_le hN
  45. /-- If the family of witnesses is nonempty, then `R(J,L)` is itself a witness:
  46. every colouring of `K_{R(J,L)}` contains a red `J` or a blue `L`. -/
  47. theorem ramsey_mem {α β : Type*} (J : SimpleGraph α) (L : SimpleGraph β)
  48. (hne : (RamseyGood J L).Nonempty) : ramsey J L ∈ RamseyGood J L :=
  49. Nat.sInf_mem hne
  50. /-- Ramsey numbers against `Kmult k f` only depend on `f` (congruence under
  51. function equality), avoiding dependent-type rewriting. -/
  52. theorem ramsey_Kmult_congr {V : Type*} (T : SimpleGraph V) {k : ℕ}
  53. {f g : Fin k → ℕ} (h : f = g) : ramsey T (Kmult k f) = ramsey T (Kmult k g) := by
  54. subst h; rfl
  55. end Erdos550
  56. open SimpleGraph Finset
  57. namespace Erdos550
  58. /-- Ramsey numbers are invariant under isomorphism of the second graph. -/
  59. theorem ramsey_iso {VT : Type*} (T : SimpleGraph VT) {α β : Type*}
  60. (J : SimpleGraph α) (J' : SimpleGraph β) (e : J ≃g J') :
  61. ramsey T J = ramsey T J' := by
  62. unfold ramsey
  63. congr 1
  64. ext N
  65. constructor <;> intro h G <;> rcases h G with h1 | h2
  66. · exact Or.inl h1
  67. · exact Or.inr ((show J' ⊑ J from ⟨e.symm.toCopy⟩).trans h2)
  68. · exact Or.inl h1
  69. · exact Or.inr ((show J ⊑ J' from ⟨e.toCopy⟩).trans h2)
  70. /-
  71. `Kmult 2 g` is isomorphic to the complete bipartite graph `K_{g0,g1}`.
  72. -/
  73. theorem Kmult2_iso_Kbip (g : Fin 2 → ℕ) : Nonempty (Kmult 2 g ≃g Kbip (g 0) (g 1)) := by
  74. refine' ⟨ _, _ ⟩;
  75. refine' Equiv.ofBijective ( fun x => match x with | ⟨ 0, x ⟩ => Sum.inl x | ⟨ 1, x ⟩ => Sum.inr x ) ⟨ fun x y h => _, fun x => _ ⟩;
  76. all_goals norm_num [ Kbip, Kmult ];
  77. · rcases x with ⟨ i, x ⟩ ; rcases y with ⟨ j, y ⟩ ; fin_cases i <;> fin_cases j <;> simp +decide at h ⊢; all_goals exact h;
  78. · cases x <;> aesop;
  79. · intro a b; rcases a with ⟨ i, a ⟩ ; rcases b with ⟨ j, b ⟩ ; fin_cases i <;> fin_cases j <;> simp +decide ;
  80. /-
  81. Reindexing the parts of a complete multipartite graph along an index
  82. equivalence preserves the Ramsey number.
  83. -/
  84. theorem ramsey_Kmult_reindex {VT : Type*} (T : SimpleGraph VT) {k k' : ℕ}
  85. (e : Fin k ≃ Fin k') (m : Fin k → ℕ) (m' : Fin k' → ℕ)
  86. (h : ∀ i, m i = m' (e i)) :
  87. ramsey T (Kmult k m) = ramsey T (Kmult k' m') := by
  88. apply Erdos550.ramsey_iso;
  89. refine' ⟨ Equiv.sigmaCongr e _, _ ⟩;
  90. exact fun i => Fintype.equivOfCardEq ( by simp +decide [ h i ] );
  91. simp +decide [ Kmult, SimpleGraph.completeMultipartiteGraph ];
  92. simp +decide [ Equiv.sigmaCongr ]
  93. /-- `R(T, Kmult 2 g) = R(T, K_{g0,g1})`. -/
  94. theorem ramsey_Kmult2_Kbip {VT : Type*} (T : SimpleGraph VT) (g : Fin 2 → ℕ) :
  95. ramsey T (Kmult 2 g) = ramsey T (Kbip (g 0) (g 1)) := by
  96. obtain ⟨e⟩ := Kmult2_iso_Kbip g
  97. exact ramsey_iso T _ _ e
  98. theorem ramsey_symm {α β : Type*} (J : SimpleGraph α) (L : SimpleGraph β) :
  99. ramsey J L = ramsey L J := by
  100. unfold ramsey;
  101. congr! 3;
  102. constructor <;> intro h G <;> specialize h Gᶜ <;> aesop
  103. /-
  104. **Finite Ramsey theorem (clique form).** For all `s t`, there is `N` such
  105. that every finite graph on `≥ N` vertices has a clique of size `s` in `G` or a
  106. clique of size `t` in `Gᶜ`.
  107. -/
  108. set_option maxHeartbeats 1000000 in
  109. theorem exists_ramsey (s t : ℕ) :
  110. ∃ N : ℕ, ∀ {V : Type} [Fintype V] [DecidableEq V]
  111. (G : SimpleGraph V) [DecidableRel G.Adj],
  112. N ≤ Fintype.card V →
  113. (∃ K : Finset V, G.IsClique ↑K ∧ s ≤ K.card) ∨
  114. (∃ K : Finset V, Gᶜ.IsClique ↑K ∧ t ≤ K.card) := by
  115. induction' s with s ih generalizing t;
  116. · exact ⟨ 0, fun { V } _ _ G _ h => Or.inl ⟨ ∅, by simp +decide ⟩ ⟩;
  117. · induction' t with t ih';
  118. · exact ⟨ 0, fun { V } _ _ G _ h => Or.inr ⟨ ∅, by simp +decide ⟩ ⟩;
  119. · obtain ⟨ N₁, hN₁ ⟩ := ih ( t + 1 ) ; obtain ⟨ N₂, hN₂ ⟩ := ih' ; use N₁ + N₂ + 1 ; intros V _ _ G _ hV ; by_cases h : ∃ v : V, ( Finset.card ( Finset.filter ( fun w => G.Adj v w ) Finset.univ ) ) ≥ N₁ <;> simp_all +decide [ ] ;
  120. · obtain ⟨ v, hv ⟩ := h; specialize hN₁ ( G.induce { w | G.Adj v w } ) ; simp_all +decide [ Fintype.card_subtype ] ;
  121. rcases hN₁ with ( ⟨ K, hK₁, hK₂ ⟩ | ⟨ K, hK₁, hK₂ ⟩ );
  122. · refine Or.inl ⟨ Finset.image ( fun x : { x // G.Adj v x } => x.val ) K ∪ { v }, ?_, ?_ ⟩ <;> simp_all +decide [ SimpleGraph.IsClique, Finset.card_image_of_injective, Function.Injective ];
  123. intro x hx y hy hxy; obtain ⟨ u, hu, rfl ⟩ := hx; obtain ⟨ v, hv, rfl ⟩ := hy; specialize hK₁ hu hv; aesop;
  124. · refine Or.inr ⟨ K.image Subtype.val, ?_, ?_ ⟩ <;> simp_all +decide [ SimpleGraph.IsIndepSet ];
  125. · exact fun x hx y hy hxy => by obtain ⟨ u, hu, rfl ⟩ := hx; obtain ⟨ v, hv, rfl ⟩ := hy; exact hK₁ hu hv ( by aesop ) ;
  126. · rwa [ Finset.card_image_of_injective _ Subtype.coe_injective ];
  127. · obtain ⟨ v, hv ⟩ : ∃ v : V, ( Finset.card ( Finset.filter ( fun w => w ≠ v ∧ ¬G.Adj v w ) Finset.univ ) ) ≥ N₂ := by
  128. have h_card : ∀ v : V, (Finset.card (Finset.filter (fun w => w ≠ v ∧ ¬G.Adj v w) Finset.univ)) = (Fintype.card V - 1) - (Finset.card (Finset.filter (fun w => G.Adj v w) Finset.univ)) := by
  129. intro v; rw [ show ( Finset.univ.filter fun w => w ≠ v ∧ ¬G.Adj v w ) = Finset.univ \ ( { v } ∪ Finset.filter ( fun w => G.Adj v w ) Finset.univ ) by ext w; by_cases hw : w = v <;> aesop ] ; simp +decide [ Finset.card_sdiff, Finset.card_univ ] ;
  130. rw [ Nat.sub_sub, add_comm ];
  131. exact ⟨ Classical.choose ( Finset.card_pos.mp ( pos_of_gt hV ) ), by rw [ h_card ] ; exact le_tsub_of_add_le_left <| le_tsub_of_add_le_left <| by linarith [ h ( Classical.choose ( Finset.card_pos.mp ( pos_of_gt hV ) ) ) ] ⟩;
  132. specialize hN₂ ( G.induce { w : V | w ≠ v ∧ ¬G.Adj v w } ) ?_ <;> simp_all +decide [ SimpleGraph.IsClique, SimpleGraph.IsIndepSet ];
  133. · rw [ Fintype.card_subtype ] ; aesop;
  134. · rcases hN₂ with ( ⟨ K, hK₁, hK₂ ⟩ | ⟨ K, hK₁, hK₂ ⟩ );
  135. · refine Or.inl ⟨ K.image Subtype.val, ?_, ?_ ⟩ <;> simp_all +decide [ Finset.card_image_of_injective, Function.Injective ];
  136. exact Set.Pairwise.image hK₁;
  137. · refine Or.inr ⟨ Insert.insert v ( Finset.image Subtype.val K ), ?_, ?_ ⟩ <;> simp_all +decide [ Finset.card_image_of_injective, Function.Injective ];
  138. simp_all +decide [ Set.Pairwise ];
  139. exact fun a ha₁ ha₂ ha₃ => by rwa [ SimpleGraph.adj_comm ] ;
  140. /-
  141. The Ramsey witness set is nonempty: a sufficiently large complete graph,
  142. however 2-coloured, contains a red `J` or a blue `L`.
  143. -/
  144. theorem ramseyGood_nonempty {α β : Type} [Fintype α] [Fintype β]
  145. (J : SimpleGraph α) (L : SimpleGraph β) [DecidableRel J.Adj] [DecidableRel L.Adj] :
  146. (RamseyGood J L).Nonempty := by
  147. -- Obtain `⟨N, HN⟩ := exists_ramsey s t`.
  148. obtain ⟨N, HN⟩ := exists_ramsey (Fintype.card α) (Fintype.card β);
  149. refine' ⟨ N, fun G => _ ⟩;
  150. simp +zetaDelta at *;
  151. specialize HN G ( by simp );
  152. rcases HN with ( ⟨ K, hK₁, hK₂ ⟩ | ⟨ K, hK₁, hK₂ ⟩ );
  153. · -- Since $K$ is a clique in $G$ and $|K| \geq |α|$, there exists an injective function $f : α → K$.
  154. obtain ⟨f, hf_inj⟩ : ∃ f : α → K, Function.Injective f := by
  155. have := Fintype.truncEquivFin K;
  156. obtain ⟨ e ⟩ := Trunc.exists_rep this;
  157. exact ⟨ fun x => e.symm ( Fin.castLE ( by simpa using hK₂ ) ( Fintype.equivFin α x ) ), fun x y hxy => by simpa [ Fin.ext_iff ] using Fintype.equivFin α |>.injective <| Fin.castLE_injective _ <| e.symm.injective hxy ⟩;
  158. refine' Or.inl ⟨ _, _ ⟩;
  159. use fun x => f x |>.1;
  160. exact fun { a b } hab => hK₁ ( f a |>.2 ) ( f b |>.2 ) ( by simpa [ hf_inj.eq_iff ] using hab.ne );
  161. exact fun x y hxy => hf_inj <| Subtype.ext hxy;
  162. · -- Since $K$ is an independent set in $G$, it is a clique in $Gᶜ$.
  163. have hK_clique : Gᶜ.IsClique ↑K := by
  164. intro u hu v hv huv; specialize hK₁ hu hv; aesop;
  165. -- Since $K$ is a clique in $Gᶜ$, we can find an injection $f : β → K$.
  166. obtain ⟨f, hf⟩ : ∃ f : β → Fin N, Function.Injective f ∧ ∀ i, f i ∈ K := by
  167. have := Finset.exists_subset_card_eq hK₂;
  168. obtain ⟨ t, ht₁, ht₂ ⟩ := this;
  169. have := Finset.equivOfCardEq ( by aesop : Finset.card t = Fintype.card β );
  170. exact ⟨ fun i => this.symm ⟨ i, Finset.mem_univ i ⟩ |>.1, fun i j hij => by simpa [ Subtype.ext_iff ] using this.symm.injective ( Subtype.ext hij ), fun i => ht₁ <| this.symm ⟨ i, Finset.mem_univ i ⟩ |>.2 ⟩;
  171. refine' Or.inr ⟨ _, _ ⟩;
  172. use f;
  173. exact fun { a b } hab => hK_clique ( hf.2 a ) ( hf.2 b ) ( hf.1.ne hab.ne );
  174. exact hf.1
  175. /-- The part projection colors the graph, and one vertex from each part gives a k-clique. -/
  176. theorem desk_chromatic (k : ℕ) (m : Fin k → ℕ) (hm : ∀ i, 0 < m i) :
  177. (Kmult k m).chromaticNumber = k := by
  178. apply le_antisymm
  179. · exact Colorable.chromaticNumber_le ⟨Coloring.mk (fun v => v.1) (fun h => h)⟩
  180. · let choosePart : (⊤ : SimpleGraph (Fin k)) →g Kmult k m :=
  181. { toFun := fun i => ⟨i, ⟨0, hm i⟩⟩
  182. map_rel' := fun h => h }
  183. simpa only [chromaticNumber_top, Fintype.card_fin] using
  184. chromaticNumber_mono_of_hom choosePart
  185. /-- The exact final arithmetic and part restriction in the k = 2 proof branch. -/
  186. theorem desk_two {V : Type} (T : SimpleGraph V) (hk : 2 ≤ 2) (m : Fin 2 → ℕ)
  187. (hpos : 1 ≤ m (0 : Fin 2)) :
  188. ramsey T (Kmult 2 m) ≤ (2 - 1) * (ramsey T (Kmult 2 (fun j => m (Fin.castLE hk j))) - 1)
  189. + m ⟨0, by omega⟩ := by
  190. have hcast : (fun j => m (Fin.castLE hk j)) = m := by
  191. funext j; simp
  192. rw [ramsey_Kmult_congr T hcast]
  193. have h0 : 1 ≤ m ⟨0, by omega⟩ := hpos
  194. omega
  195. #print axioms ramsey_symm
  196. #print axioms ramsey_Kmult2_Kbip
  197. #print axioms ramseyGood_nonempty
  198. #print axioms desk_chromatic
  199. #print axioms desk_two
  200. end Erdos550