Lean / Reader
Lean reader

DecayProducts.lean

112 lines9 declarationsno sorryimports Mathlib.Tactic
  1. import Mathlib.Tactic
  2. namespace DecayProducts
  3. def OneColor {V L : Type*} (c : V → V → L) (p : L) (s : Finset V) : Prop :=
  4. ∀ x ∈ s, ∀ y ∈ s, x ≠ y → c x y = p
  5. def BoundedCliques {V L : Type*} (c : V → V → L) (k : ℕ) : Prop :=
  6. ∀ p s, OneColor c p s → s.card ≤ k
  7. def lexSame {U V L : Type*} [DecidableEq U] (c : U → U → L) (d : V → V → L)
  8. (x y : U × V) : L := if x.1 = y.1 then d x.2 y.2 else c x.1 y.1
  9. def lexApart {U V L H : Type*} [DecidableEq U] (c : U → U → L) (d : V → V → H)
  10. (x y : U × V) : L ⊕ H := if x.1 = y.1 then Sum.inr (d x.2 y.2) else Sum.inl (c x.1 y.1)
  11. section Finite
  12. variable {U V L H : Type*} [DecidableEq U] [DecidableEq V] [Fintype V]
  13. def fiber (s : Finset (U × V)) (u : U) : Finset V := Finset.univ.filter fun v => (u,v) ∈ s
  14. theorem count_fibers (s : Finset (U × V)) (p q : ℕ)
  15. (first : (s.image Prod.fst).card ≤ p)
  16. (rest : ∀ u ∈ s.image Prod.fst, (fiber s u).card ≤ q) : s.card ≤ p*q := by
  17. classical
  18. calc
  19. s.card ≤ ((s.image Prod.fst).sigma (fiber s)).card := by
  20. apply Finset.card_le_card_of_injOn (fun z => (⟨z.1,z.2⟩ : Σ _ : U, V))
  21. · intro z hz
  22. exact Finset.mem_sigma.mpr ⟨Finset.mem_image_of_mem _ hz,by simpa [fiber] using hz⟩
  23. · intro a _ b _ heq
  24. exact congrArg (fun v : Σ _ : U, V => (v.1,v.2)) heq
  25. _ = ∑ u ∈ s.image Prod.fst, (fiber s u).card := Finset.card_sigma _ _
  26. _ ≤ ∑ _u ∈ s.image Prod.fst, q := Finset.sum_le_sum rest
  27. _ ≤ p*q := by simpa using Nat.mul_le_mul_right q first
  28. theorem lex_same_clique (c : U → U → L) (d : V → V → L) {p q : ℕ}
  29. (hc : BoundedCliques c p) (hd : BoundedCliques d q) :
  30. BoundedCliques (lexSame c d) (p*q) := by
  31. intro col s hmono
  32. apply count_fibers s p q
  33. · apply hc col
  34. intro u hu v hv ne
  35. obtain ⟨x,hx,rfl⟩ := Finset.mem_image.mp hu
  36. obtain ⟨y,hy,rfl⟩ := Finset.mem_image.mp hv
  37. have neq : x ≠ y := fun eq => ne (congrArg Prod.fst eq)
  38. simpa [lexSame,ne] using hmono x hx y hy neq
  39. · intro u _
  40. apply hd col
  41. intro v hv w hw ne
  42. have hx : (u,v) ∈ s := by simpa [fiber] using hv
  43. have hy : (u,w) ∈ s := by simpa [fiber] using hw
  44. simpa [lexSame] using hmono (u,v) hx (u,w) hy (fun eq => ne (congrArg Prod.snd eq))
  45. theorem lex_apart_clique (c : U → U → L) (d : V → V → H) {p q : ℕ}
  46. (hc : BoundedCliques c p) (hd : BoundedCliques d q) :
  47. BoundedCliques (lexApart c d) (max p q) := by
  48. intro col s hmono
  49. cases col with
  50. | inl col =>
  51. apply le_trans _ (le_max_left p q)
  52. rw [← Nat.mul_one p]
  53. apply count_fibers
  54. · apply hc col
  55. intro u hu v hv ne
  56. obtain ⟨x,hx,rfl⟩ := Finset.mem_image.mp hu
  57. obtain ⟨y,hy,rfl⟩ := Finset.mem_image.mp hv
  58. have neq : x ≠ y := fun eq => ne (congrArg Prod.fst eq)
  59. simpa [lexApart,ne] using hmono x hx y hy neq
  60. · intro u _
  61. apply Finset.card_le_one.mpr
  62. intro v hv w hw
  63. by_contra ne
  64. have hx : (u,v) ∈ s := by simpa [fiber] using hv
  65. have hy : (u,w) ∈ s := by simpa [fiber] using hw
  66. have bad := hmono (u,v) hx (u,w) hy (fun eq => ne (congrArg Prod.snd eq))
  67. simp [lexApart] at bad
  68. | inr col =>
  69. apply le_trans _ (le_max_right p q)
  70. rw [← Nat.one_mul q]
  71. apply count_fibers
  72. · apply Finset.card_le_one.mpr
  73. intro u hu v hv
  74. by_contra ne
  75. obtain ⟨x,hx,rfl⟩ := Finset.mem_image.mp hu
  76. obtain ⟨y,hy,rfl⟩ := Finset.mem_image.mp hv
  77. have bad := hmono x hx y hy (fun eq => ne (congrArg Prod.fst eq))
  78. simp [lexApart,ne] at bad
  79. · intro u _
  80. apply hd col
  81. intro v hv w hw ne
  82. have hx : (u,v) ∈ s := by simpa [fiber] using hv
  83. have hy : (u,w) ∈ s := by simpa [fiber] using hw
  84. simpa [lexApart] using hmono (u,v) hx (u,w) hy (fun eq => ne (congrArg Prod.snd eq))
  85. /-- The fraction of edges internal to P equal fibers is at most 1/P. -/
  86. theorem equal_fibers (P m : ℕ) (hP : 0 < P) : P*(P * m.choose 2) ≤ (P*m).choose 2 := by
  87. have h1 : m.choose 2 * 2 = m*(m-1) := by simpa using Nat.choose_succ_right_eq m 1
  88. have h2 : (P*m).choose 2 * 2 = (P*m)*(P*m-1) := by
  89. simpa using Nat.choose_succ_right_eq (P*m) 1
  90. have le : P*(m-1) ≤ P*m-1 := by rw [Nat.mul_sub, Nat.mul_one]; omega
  91. have big := Nat.mul_le_mul_left (P*m) le
  92. have replace : P*(P*(m.choose 2))*2 = (P*m)*(P*(m-1)) := by
  93. calc
  94. _ = (P*P)*(m.choose 2 * 2) := by ring
  95. _ = _ := by rw [h1]; ring
  96. omega
  97. end Finite
  98. end DecayProducts