Lean / Reader
Lean reader

DecayTail.lean

95 lines3 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. /-- Extract the finite sums promised by failure of the strict tail test.
  4. This argument also applies to a divergent sequence. -/
  5. theorem witnesses_of_failure (a : ℕ → ℝ) (bad : ¬TailTest a) :
  6. ∃ C : ℕ, 0 < C ∧ ∃ N : ℕ, ∀ r : ℕ, r ≥ max 2 N →
  7. ∃ l, 1 < 2 * (r : ℝ)^(C*r) * (∑ i ∈ Finset.Ico r l, a i) := by
  8. unfold TailTest at bad
  9. push_neg at bad
  10. obtain ⟨C,hC,N,hN⟩ := bad
  11. refine ⟨C,hC,N,?_⟩
  12. intro r hr
  13. have hr0 : 0 < (r:ℝ) := by exact_mod_cast (show 0 < r by omega)
  14. let x := (r:ℝ)^(C*r)
  15. have hx : 0 < x := pow_pos hr0 _
  16. have hu : (1/(2*x))*x < 1 := by field_simp; linarith
  17. obtain ⟨l,hl⟩ := hN r hr (1/(2*x)) hu
  18. exact ⟨l, by have := (div_lt_iff₀ (by positivity : 0 < 2*x)).mp hl; dsimp [x] at *; linarith⟩
  19. /-- Pairing consecutive positive-index terms bounds a true tail by twice the
  20. sum available in the shared pool. -/
  21. theorem paired_tail (a : ℕ → ℝ) (ha : Antitone a) (ha0 : ∀ i, 0 ≤ a i)
  22. (j l : ℕ) : ∑ i ∈ Finset.Ico (2*j+2) l, a i ≤ 2*∑ i ∈ Finset.Icc j l, a (2*i+1) := by
  23. classical
  24. let P (i : ℕ) : Finset ℕ := {2*i+1,2*i+2}
  25. have cover : ∀ x ∈ Finset.Ico (2*j+2) l, ∃ i ∈ Finset.Icc j l, x ∈ P i := by
  26. intro x hx
  27. obtain ⟨lo,hi⟩ := Finset.mem_Ico.mp hx
  28. refine ⟨(x-1)/2, Finset.mem_Icc.mpr ⟨by omega,by omega⟩,?_⟩
  29. simp only [P,Finset.mem_insert,Finset.mem_singleton]
  30. omega
  31. apply (DecayRamseyPacking.cover_mass a ha0 _ _ P cover).trans
  32. rw [Finset.mul_sum]
  33. apply Finset.sum_le_sum
  34. intro i _
  35. simp only [P,Finset.sum_insert (by simp : 2*i+1 ∉ ({2*i+2}:Finset ℕ)),Finset.sum_singleton]
  36. linarith [ha (show 2*i+1 ≤ 2*i+2 by omega)]
  37. /-- One scaling factor supplies every provisional color, including the finite
  38. initial segment on which the tail comparison need not hold. -/
  39. theorem scaled_supply (a b : ℕ → ℝ) (ha : Antitone a) (ha0 : ∀ i, 0 < a i)
  40. (hb : ∀ i, 0 < b i) (C N M : ℕ) (K : ℝ) (hK : 0 < K)
  41. (witness : ∀ r : ℕ, r ≥ max 2 N →
  42. ∃ l, 1 < 2*(r:ℝ)^(C*r)*(∑ i ∈ Finset.Ico r l, a i))
  43. (decay : ∀ j ≥ M, b j*((2*j+2:ℕ):ℝ)^(C*(2*j+2)) ≤ K) :
  44. ∃ γ : ℝ, 1 ≤ γ ∧ ∀ j, ∃ l ≥ j, 40*b j < ∑ i ∈ Finset.Icc j l, γ*a (2*i+1) := by
  45. classical
  46. let B := max N M
  47. let init := ∑ i ∈ Finset.range B, 41*b i / a (2*i+1)
  48. let γ := 1 + 160*K + init
  49. have init0 : 0 ≤ init := Finset.sum_nonneg (fun i _ => by
  50. exact div_nonneg (by linarith [hb i]) (ha0 _).le)
  51. have hscale : 160*K ≤ γ := by dsimp [γ]; linarith
  52. refine ⟨γ,by dsimp [γ]; linarith,?_⟩
  53. intro j
  54. by_cases hj : j < B
  55. · refine ⟨j,le_rfl,?_⟩
  56. simp only [Finset.Icc_self,Finset.sum_singleton]
  57. have le : 41*b j/a (2*j+1) ≤ init := Finset.single_le_sum
  58. (s := Finset.range B) (f := fun i => 41*b i/a (2*i+1))
  59. (fun i _ => div_nonneg (by linarith [hb i]) (ha0 _).le) (Finset.mem_range.mpr hj)
  60. have hin : 41*b j/a (2*j+1) ≤ γ := by dsimp [γ]; linarith
  61. have := (div_le_iff₀ (ha0 _)).mp hin
  62. linarith [hb j]
  63. · have hNM : N ≤ j ∧ M ≤ j := by dsimp [B] at hj; omega
  64. let r := 2*j+2
  65. let x := (r:ℝ)^(C*r)
  66. have hx : 0 < x := by dsimp [x,r]; positivity
  67. obtain ⟨l,hl⟩ := witness r (by dsimp [r]; omega)
  68. have bd : b j*x ≤ K := decay j hNM.2
  69. let pool := ∑ i ∈ Finset.Icc j l, a (2*i+1)
  70. have p0 : 0 ≤ pool := Finset.sum_nonneg (fun i _ => (ha0 _).le)
  71. have hpair := paired_tail a ha (fun i => (ha0 i).le) j l
  72. have hlarge : 1 < (4*x)*pool := by
  73. change 1 < 2*x*_ at hl
  74. have step := mul_le_mul_of_nonneg_left hpair (by positivity : 0 ≤ 2*x)
  75. change _ ≤ 2*x*(2*pool) at step
  76. dsimp only [r] at hl
  77. linarith
  78. have hjl : j ≤ l := by
  79. by_contra! small
  80. have : pool = 0 := by simp [pool,Finset.Icc_eq_empty_of_lt small]
  81. rw [this] at hlarge; linarith
  82. refine ⟨l,hjl,?_⟩
  83. rw [← Finset.mul_sum]
  84. change 40*b j < γ*pool
  85. have hleft := mul_le_mul_of_nonneg_right bd (show 0 ≤ 40*pool by positivity)
  86. have hright := mul_lt_mul_of_pos_left hlarge (hb j)
  87. have hfinal := mul_le_mul_of_nonneg_right hscale p0
  88. nlinarith
  89. end DecayClassification