Lean / Reader
Lean reader

DecayClassification.lean

120 lines9 declarationsno sorryimports DecayRamseyPacking

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

  1. import DecayRamseyPacking
  2. namespace DecayClassification
  3. /-- Unordered edges are represented once, with the smaller vertex first. -/
  4. def edges (n : ℕ) : Finset (Fin n × Fin n) :=
  5. Finset.univ.filter fun e => e.1 < e.2
  6. def Bounded {n : ℕ} (a : ℕ → ℝ) (c : Fin n × Fin n → ℕ) : Prop :=
  7. ∀ i, (((edges n).filter fun e => c e = i).card : ℝ) ≤ a i * (edges n).card
  8. def MonoClique {n : ℕ} (k : ℕ) (c : Fin n × Fin n → ℕ) : Prop :=
  9. ∃ s : Finset (Fin n), s.card = k ∧ ∃ i, ∀ x ∈ s, ∀ y ∈ s, x < y → c (x,y) = i
  10. /-- Color indices start at zero, so the source's color i+1 is represented by i. -/
  11. def DecayRamsey (a : ℕ → ℝ) : Prop :=
  12. ∀ k ≥ 2, ∃ N, ∀ n ≥ N, ∀ c : Fin n × Fin n → ℕ, Bounded a c → MonoClique k c
  13. /-- A strict bound for the full nonnegative tail, expressed by a uniform upper
  14. bound on its finite partial sums. This includes the divergent-series case. -/
  15. def TailTest (a : ℕ → ℝ) : Prop :=
  16. ∀ C : ℕ, 0 < C → ∀ N : ℕ, ∃ r : ℕ, r ≥ max 2 N ∧ ∃ u : ℝ,
  17. u * (r : ℝ)^(C*r) < 1 ∧ ∀ l, ∑ i ∈ Finset.Ico r l, a i ≤ u
  18. def Admissible (a : ℕ → ℝ) : Prop :=
  19. Antitone a ∧ (∀ i, 0 < a i) ∧ ∃ m, 1 < ∑ i ∈ Finset.range m, a i
  20. /-- The source classification stated as a proposition. -/
  21. def Classification : Prop := ∀ a, Admissible a → (DecayRamsey a ↔ TailTest a)
  22. theorem take_mass (w : ℕ → ℝ) (target atom : ℝ) (hatom : 0 ≤ atom)
  23. (s : Finset ℕ) (small : ∀ i ∈ s, w i ≤ atom) (enough : target ≤ ∑ i ∈ s, w i) :
  24. ∃ t ⊆ s, target ≤ ∑ i ∈ t, w i ∧ ∑ i ∈ t, w i ≤ max target 0 + atom := by
  25. classical
  26. induction s using Finset.induction_on with
  27. | empty => exact ⟨∅, Finset.Subset.rfl, enough, by simp; positivity⟩
  28. | @insert i s hi ih =>
  29. by_cases ht : target ≤ ∑ x ∈ s, w x
  30. · obtain ⟨t, hts, hlow, hhigh⟩ := ih (fun j hj => small j (Finset.mem_insert_of_mem hj)) ht
  31. exact ⟨t, hts.trans (Finset.subset_insert _ _), hlow, hhigh⟩
  32. · refine ⟨insert i s, Finset.Subset.rfl, enough, ?_⟩
  33. rw [Finset.sum_insert hi]
  34. have := small i (Finset.mem_insert_self ..)
  35. linarith [le_max_left target (0:ℝ)]
  36. /-- Assign each deficient provisional color its own even-label pool. -/
  37. theorem pack_shared (d b : ℕ → ℝ) (hd : ∀ i, 0 ≤ d i) (hb : ∀ j, 0 ≤ b j)
  38. (block : ℕ → Finset ℕ) (S : Finset ℕ)
  39. (supply : ∀ j ∈ S, 16*b j ≤ ∑ i ∈ block j, d i)
  40. (small : ∀ j ∈ S, ∀ i ∈ block j, d i ≤ 4*b j)
  41. (tail : ∀ j ∈ S, ∑ h ∈ S.filter (j < ·), b h ≤ b j) :
  42. ∃ A : ℕ → Finset ℕ,
  43. (∀ j ∈ S, A j ⊆ block j ∧ 2*b j ≤ ∑ i ∈ A j, d i ∧ ∑ i ∈ A j, d i ≤ 6*b j) ∧
  44. (∀ j ∈ S, ∀ h ∈ S, j ≠ h → Disjoint (A j) (A h)) := by
  45. classical
  46. induction S using Finset.induction_on_min with
  47. | h0 => exact ⟨fun _ => ∅, by simp, by simp⟩
  48. | step j S lower ih =>
  49. have hj : j ∉ S := fun h => (lt_irrefl j) (lower j h)
  50. have incl : S ⊆ insert j S := Finset.subset_insert _ _
  51. obtain ⟨A, ha, hdis⟩ := ih (fun h hh => supply h (incl hh)) (fun h hh => small h (incl hh))
  52. (fun h hh => le_trans (Finset.sum_le_sum_of_subset_of_nonneg
  53. (Finset.filter_subset_filter _ incl) (fun i _ _ => hb i)) (tail h (incl hh)))
  54. let used := S.biUnion A
  55. let available := block j \ used
  56. have bound : ∑ i ∈ used, d i ≤ ∑ h ∈ S, (6*b h) := by
  57. exact (DecayRamseyPacking.cover_mass d hd used S A
  58. (fun _ h => Finset.mem_biUnion.mp h)).trans
  59. (Finset.sum_le_sum (fun h hh => (ha h hh).2.2))
  60. have ht : ∑ h ∈ S, b h ≤ b j := by
  61. have heq : (insert j S).filter (j < ·) = S := by
  62. ext x
  63. simp only [Finset.mem_filter, Finset.mem_insert]
  64. constructor
  65. · rintro ⟨h | h, hx⟩
  66. · omega
  67. · exact h
  68. · exact fun hx => ⟨Or.inr hx, lower x hx⟩
  69. simpa [heq] using tail j (Finset.mem_insert_self ..)
  70. have hcovered : ∑ i ∈ block j, d i ≤ ∑ i ∈ available, d i + ∑ i ∈ used, d i := by
  71. have hp := Finset.sum_inter_add_sum_diff (block j) used d
  72. have hh := Finset.sum_le_sum_of_subset_of_nonneg (Finset.inter_subset_right (s₁ := block j) (s₂ := used)) (fun i _ _ => hd i)
  73. dsimp [available]
  74. linarith
  75. rw [← Finset.mul_sum] at bound
  76. have ha2 : 2*b j ≤ ∑ i ∈ available, d i := by
  77. linarith [supply j (Finset.mem_insert_self ..), hb j]
  78. obtain ⟨t, hsub, hmass, hmass'⟩ := take_mass d (2*b j) (4*b j) (by linarith [hb j]) available
  79. (fun i hi => small j (Finset.mem_insert_self ..) i ((Finset.mem_sdiff.mp hi).1)) ha2
  80. let A' := Function.update A j t
  81. have h_old : ∀ h ∈ S, A' h = A h := fun h hh => Function.update_of_ne (lower h hh).ne' _ _
  82. have h_new : A' j = t := Function.update_self ..
  83. have apart : ∀ h ∈ S, Disjoint t (A h) := by
  84. intro h hh
  85. rw [Finset.disjoint_left]
  86. exact fun i hi hih => (Finset.mem_sdiff.mp (hsub hi)).2 (Finset.mem_biUnion.mpr ⟨h,hh,hih⟩)
  87. refine ⟨A', ?_, ?_⟩
  88. · intro h hh
  89. rcases Finset.mem_insert.mp hh with eq | old
  90. · subst h
  91. rw [h_new]
  92. refine ⟨fun i hi => (Finset.mem_sdiff.mp (hsub hi)).1, hmass, ?_⟩
  93. rw [max_eq_left (by linarith [hb j] : (0:ℝ) ≤ 2*b j)] at hmass'
  94. linarith
  95. · rw [h_old h old]; exact ha h old
  96. · intro x hx y hy hxy
  97. rcases Finset.mem_insert.mp hx with eqx | hxs
  98. · subst x
  99. have hys := (Finset.mem_insert.mp hy).resolve_left hxy.symm
  100. rw [h_new, h_old _ hys]
  101. exact apart _ hys
  102. · rcases Finset.mem_insert.mp hy with eqy | hys
  103. · subst y
  104. rw [h_old _ hxs, h_new]
  105. exact (apart _ hxs).symm
  106. · rw [h_old _ hxs, h_old _ hys]
  107. exact hdis _ hxs _ hys hxy
  108. end DecayClassification