Lean / Reader
Lean reader

DecayForcing.lean

142 lines5 declarationsno sorryimports DecayClassification

Lean 4 Web has Mathlib, so it can check files that import only Mathlib. This one also imports DecayClassification, which it does not have: you can read it there, but it will not check. Build the project itself to check it.

  1. import DecayClassification
  2. namespace DecayClassification
  3. /-- Every M-set contains a late edge. Count the pairs consisting of an M-set
  4. and a late edge it contains. -/
  5. theorem finite_density {n M : ℕ} (hM : 2 ≤ M) (hn : M ≤ n)
  6. (late : Finset (Fin n × Fin n)) (ordered : late ⊆ edges n)
  7. (hit : ∀ s : Finset (Fin n), s.card = M → ∃ e ∈ late, e.1 ∈ s ∧ e.2 ∈ s) :
  8. n.choose 2 ≤ late.card * M.choose 2 := by
  9. classical
  10. let sets := (Finset.univ : Finset (Fin n)).powersetCard M
  11. let family (e : Fin n × Fin n) := sets.filter fun s => e.1 ∈ s ∧ e.2 ∈ s
  12. have cover : sets ⊆ late.biUnion family := by
  13. intro s hs
  14. obtain ⟨e,he,hes⟩ := hit s (Finset.mem_powersetCard.mp hs).2
  15. exact Finset.mem_biUnion.mpr ⟨e,he,Finset.mem_filter.mpr ⟨hs,hes⟩⟩
  16. have counts : ∀ e ∈ late, (family e).card ≤ (n-2).choose (M-2) := by
  17. intro e he
  18. have hlt : e.1 < e.2 := (Finset.mem_filter.mp (ordered he)).2
  19. let pair : Finset (Fin n) := {e.1,e.2}
  20. have cp : pair.card = 2 := by simp [pair,hlt.ne]
  21. let residual := (Finset.univ \ pair).powersetCard (M-2)
  22. have maps {s} (hs : s ∈ family e) : pair ⊆ s := by
  23. obtain ⟨_,hx,hy⟩ := Finset.mem_filter.mp hs
  24. intro x h
  25. simp only [pair, Finset.mem_insert, Finset.mem_singleton] at h
  26. rcases h with rfl | rfl <;> assumption
  27. have bound : (family e).card ≤ residual.card := by
  28. apply Finset.card_le_card_of_injOn (fun s => s \ pair)
  29. · intro s hs
  30. change s ∈ (Finset.univ.powersetCard M).filter (fun u => e.1 ∈ u ∧ e.2 ∈ u) at hs
  31. change s \ pair ∈ (Finset.univ \ pair).powersetCard (M-2)
  32. apply Finset.mem_powersetCard.mpr
  33. refine ⟨Finset.sdiff_subset_sdiff (Finset.subset_univ _) (by rfl),?_⟩
  34. rw [Finset.card_sdiff_of_subset (maps hs),cp]
  35. exact congrArg (· - 2) (Finset.mem_powersetCard.mp (Finset.mem_filter.mp hs).1).2
  36. · intro s hs t ht eq
  37. have h := congrArg (fun a : Finset (Fin n) => a ∪ pair) eq
  38. simpa only [Finset.sdiff_union_of_subset (maps hs), Finset.sdiff_union_of_subset (maps ht)] using h
  39. simpa [residual,Finset.card_powersetCard,Finset.card_sdiff_of_subset (Finset.subset_univ pair),cp] using bound
  40. have hcount : n.choose M ≤ late.card * (n-2).choose (M-2) := by
  41. calc
  42. _ = sets.card := by simp [sets]
  43. _ ≤ (late.biUnion family).card := Finset.card_le_card cover
  44. _ ≤ ∑ e ∈ late, (family e).card := Finset.card_biUnion_le
  45. _ ≤ ∑ _ ∈ late, (n-2).choose (M-2) := Finset.sum_le_sum counts
  46. _ = _ := by simp
  47. have times := Nat.mul_le_mul_right (M.choose 2) hcount
  48. rw [Nat.choose_mul hM] at times
  49. have pos := Nat.choose_pos (show M-2 ≤ n-2 by omega)
  50. exact Nat.le_of_mul_le_mul_right (by simpa only [mul_assoc,mul_comm,mul_left_comm] using times) pos
  51. theorem edge_count_le (n : ℕ) : (edges n).card ≤ n.choose 2 := by
  52. classical
  53. let dst := (Finset.univ : Finset (Fin n)).powersetCard 2
  54. have maps : (edges n).card ≤ dst.card := by
  55. apply Finset.card_le_card_of_injOn (fun x => ({x.1,x.2} : Finset (Fin n)))
  56. · intro e he
  57. have lt : e.1 < e.2 := (Finset.mem_filter.mp he).2
  58. change ({e.1,e.2} : Finset (Fin n)) ∈ Finset.univ.powersetCard 2
  59. exact Finset.mem_powersetCard.mpr ⟨Finset.subset_univ _,by simp [lt.ne]⟩
  60. · intro a ha b hb h
  61. have la : a.1 < a.2 := (Finset.mem_filter.mp ha).2
  62. have lb : b.1 < b.2 := (Finset.mem_filter.mp hb).2
  63. change ({a.1,a.2} : Finset (Fin n)) = {b.1,b.2} at h
  64. have ma : a.1 ∈ ({b.1,b.2} : Finset (Fin n)) := by rw [← h]; simp
  65. have mb : a.2 ∈ ({b.1,b.2} : Finset (Fin n)) := by rw [← h]; simp
  66. simp only [Finset.mem_insert,Finset.mem_singleton] at ma mb
  67. exact Prod.ext (by rcases ma with h | h <;> rcases mb with h' | h' <;> omega)
  68. (by rcases ma with h | h <;> rcases mb with h' | h' <;> omega)
  69. simpa [dst] using maps
  70. theorem late_budget {n : ℕ} (a : ℕ → ℝ) (c : Fin n × Fin n → ℕ) (r : ℕ) (u : ℝ)
  71. (hb : Bounded a c) (hu : ∀ l, ∑ i ∈ Finset.Ico r l, a i ≤ u) :
  72. (((edges n).filter (fun e => r ≤ c e)).card : ℝ) ≤ u*(edges n).card := by
  73. let E := edges n
  74. let l := E.sup c + 1
  75. let T := Finset.Ico r l
  76. have heq : E.filter (fun e => c e ∈ T) = E.filter (fun e => r ≤ c e) := by
  77. ext e
  78. simp only [Finset.mem_filter, T, Finset.mem_Ico]
  79. constructor
  80. · exact fun h => ⟨h.1,h.2.1⟩
  81. · intro h
  82. exact ⟨h.1,h.2,Nat.lt_succ_of_le (Finset.le_sup h.1)⟩
  83. have hc := Finset.sum_card_fiberwise_eq_card_filter E T c
  84. rw [heq] at hc
  85. change ((E.filter (fun e => r ≤ c e)).card : ℝ) ≤ u*E.card
  86. rw [← hc,Nat.cast_sum]
  87. apply (Finset.sum_le_sum (fun i (_ : i ∈ T) => hb i)).trans
  88. rw [← Finset.sum_mul]
  89. exact mul_le_mul_of_nonneg_right (hu l) (by positivity)
  90. /-- A finite Ramsey bound supplies a front-color clique on any M-set if no
  91. edge of that set uses the tail palette. -/
  92. def RamseySupplier : Prop :=
  93. ∀ r k : ℕ, 2 ≤ r → 2 ≤ k → ∃ M : ℕ, 2 ≤ M ∧ M ≤ r^(r*k) ∧
  94. ∀ n (c : Fin n × Fin n → ℕ) (s : Finset (Fin n)), s.card = M →
  95. (∀ x ∈ s, ∀ y ∈ s, x < y → c (x,y) < r) → MonoClique k c
  96. theorem forcing_of_tail (ramsey : RamseySupplier) (a : ℕ → ℝ) (test : TailTest a) :
  97. DecayRamsey a := by
  98. classical
  99. intro k hk
  100. obtain ⟨r,hr,u,hu,hpartial⟩ := test (2*k) (by omega) 2
  101. have hr2 : 2 ≤ r := by omega
  102. have u0 : 0 ≤ u := by simpa using hpartial r
  103. obtain ⟨M,hM,hm,force⟩ := ramsey r k hr2 hk
  104. refine ⟨M,?_⟩
  105. intro n hn c budget
  106. by_contra no
  107. let late := (edges n).filter fun e => r ≤ c e
  108. have hit : ∀ s : Finset (Fin n), s.card = M → ∃ e ∈ late, e.1 ∈ s ∧ e.2 ∈ s := by
  109. intro s hs
  110. by_contra! fail
  111. apply no (force n c s hs ?_)
  112. intro x hx y hy hxy
  113. by_contra! high
  114. exact fail (x,y) (Finset.mem_filter.mpr ⟨by simpa [edges] using hxy,high⟩) hx hy
  115. have lower := finite_density hM hn late (Finset.filter_subset _ _) hit
  116. have lreal : (n.choose 2 : ℝ) ≤ (late.card : ℝ) * (M.choose 2 : ℝ) := by exact_mod_cast lower
  117. have upper := late_budget a c r u budget hpartial
  118. change (late.card : ℝ) ≤ u*(edges n).card at upper
  119. have esc : ((edges n).card : ℝ) ≤ (n.choose 2 : ℝ) := by exact_mod_cast edge_count_le n
  120. have cm : M.choose 2 ≤ M*M := by
  121. rw [Nat.choose_two_right]
  122. exact (Nat.div_le_self _ _).trans (Nat.mul_le_mul_left _ (Nat.sub_le ..))
  123. have cp : M.choose 2 ≤ r^((2*k)*r) := by
  124. calc
  125. _ ≤ M*M := cm
  126. _ ≤ r^(r*k)*r^(r*k) := Nat.mul_le_mul hm hm
  127. _ = _ := by rw [← pow_add]; congr 1; ring
  128. have p0 : (0:ℝ) < (n.choose 2 : ℝ) := by exact_mod_cast Nat.choose_pos (hM.trans hn)
  129. have cp' : (M.choose 2 : ℝ) ≤ (r : ℝ)^((2*k)*r) := by exact_mod_cast cp
  130. have ur := mul_lt_mul_of_pos_right hu p0
  131. have est := mul_le_mul (upper.trans (mul_le_mul_of_nonneg_left esc u0)) cp'
  132. (show (0:ℝ) ≤ (M.choose 2 : ℝ) by positivity) (by positivity)
  133. nlinarith
  134. end DecayClassification