Lean / Reader
Lean reader

Growth.lean

118 lines11 declarationsno sorryimports ColourRestrictions Mathlib.Analysis.SpecialFunctions.Pow.Asymptotics Mathlib.Tactic.NormNum Mathlib.Tactic.Positivity

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

  1. import ColourRestrictions
  2. import Mathlib.Analysis.SpecialFunctions.Pow.Asymptotics
  3. import Mathlib.Tactic.NormNum
  4. import Mathlib.Tactic.Positivity
  5. open Filter Real Asymptotics
  6. open scoped Topology
  7. namespace ProgressionColours
  8. def Admits (N K : ℕ) := N=0 ∨ ∃ c : ℕ → Fin K, Valid N 2 c
  9. private theorem some_colouring (N : ℕ) : ∃ K, Admits N K := by
  10. let c (i : ℕ) : Fin (N+1) := ⟨min i N,by omega⟩
  11. refine ⟨N+1,Or.inr ⟨c,?_⟩⟩
  12. intro a d hd hi u v
  13. have h (j : ℕ) (hj : j≤2) : (c (a+j*d)).val=a+j*d := by
  14. change min _ _ = _; apply Nat.min_eq_left
  15. have := Nat.mul_le_mul_right d hj;omega
  16. by_contra! contra
  17. have hh (j : ℕ) (hj : j≤2) : a+j*d=u.val ∨ a+j*d=v.val := by
  18. have hc := contra _ (term_mem (a:=a) (d:=d) (show j≤2+1 by omega))
  19. by_cases eq : c (a+j*d)=u
  20. · exact Or.inl ((h j hj).symm.trans (congrArg Fin.val eq))
  21. · exact Or.inr ((h j hj).symm.trans (congrArg Fin.val (hc eq)))
  22. have := hh 0 (by decide); have := hh 1 (by decide); have := hh 2 (by decide);omega
  23. noncomputable def h (N : ℕ) : ℕ := by classical exact Nat.find (some_colouring N)
  24. theorem h_attained (N : ℕ) : Admits N (h N) := by classical exact Nat.find_spec (some_colouring N)
  25. theorem h_le_of_colouring {N K : ℕ} (hK : Admits N K) : h N ≤ K := by classical exact Nat.find_min' (some_colouring N) hK
  26. /-- The arithmetic-progression-free set estimate used as the external analytic input. -/
  27. def RothBound (b : ℝ) : Prop := ∃ c : ℝ, 0<c ∧ ∀ᶠ M : ℕ in atTop,
  28. ∀ A ⊆ Finset.range M, (∀ a d, 0<d → ¬ progression a d 2 ⊆ A) →
  29. (A.card : ℝ) ≤ M / exp (c*(log M)^b)
  30. theorem roth_to_colours {b : ℝ} (hb : 0<b) (hyp : RothBound b) :
  31. ∃ c' : ℝ, 0<c' ∧ ∀ᶠ N : ℕ in atTop, exp (c'*(log N)^b) ≤ h N := by
  32. obtain ⟨c,hc,hm⟩ := hyp
  33. refine ⟨c*(1/2:ℝ)^b,by positivity,?_⟩
  34. filter_upwards [(Nat.tendsto_div_const_atTop (by decide : 2≠0)).eventually hm,eventually_ge_atTop 10] with N hM hlarge
  35. let M := N/2
  36. let E := exp (c*(log M)^b)
  37. obtain ⟨colour,hval⟩ := (h_attained N).resolve_left (by omega)
  38. have hmpos : 0<M := by dsimp [M];omega
  39. have hmR : 0<(M:ℝ) := by exact_mod_cast hmpos
  40. have hE : 0<E := exp_pos _
  41. have bound := transfer_three_free_bound (M:=M) (R:=⌊(M:ℝ)/E⌋₊) colour hval
  42. (by dsimp [M];omega) (fun A hs ha => Nat.le_floor (hM A hs ha))
  43. have scaled : (M:ℝ)≤ ((M:ℝ)/E)*(h N:ℝ) := by
  44. calc (M:ℝ) ≤ (⌊(M:ℝ)/E⌋₊:ℝ) * (h N:ℝ) := by exact_mod_cast bound
  45. _ ≤ _ := mul_le_mul_of_nonneg_right (Nat.floor_le (by positivity)) (Nat.cast_nonneg _)
  46. have rhs : E ≤ (h N:ℝ) := by
  47. rw [div_mul_eq_mul_div,le_div_iff₀ hE] at scaled
  48. exact (mul_le_mul_iff_right₀ hmR).mp scaled
  49. have hn3 : 3≤M := by dsimp [M];omega
  50. have hn2 : N ≤ M+M+1 := by dsimp [M];omega
  51. have square : N≤M^2 := by nlinarith [Nat.mul_le_mul_right M hn3]
  52. have lg := Real.log_le_log (by positivity : 0<(N:ℝ)) (by exact_mod_cast square : (N:ℝ)≤(M:ℝ)^2)
  53. rw [Real.log_pow] at lg
  54. have pl := Real.rpow_le_rpow (mul_nonneg (by norm_num : (0:ℝ)≤1/2) (Real.log_natCast_nonneg N))
  55. (by norm_num at lg;linarith : (1/2:ℝ)*log N ≤ log M) hb.le
  56. rw [Real.mul_rpow (by norm_num) (Real.log_natCast_nonneg N)] at pl
  57. apply le_trans _ rhs
  58. apply Real.exp_le_exp.mpr
  59. dsimp [E];rw [mul_assoc];exact mul_le_mul_of_nonneg_left pl hc.le
  60. private theorem power_little {a b : ℝ} (hab : a<b) (ha : 0<a) (f : ℕ → ℝ)
  61. (hf : Tendsto f atTop atTop) (hn : ∀ n, 0≤f n) :
  62. (fun n => (f n)^a) =o[atTop] (fun n => (f n)^b) := by
  63. apply isLittleO_of_tendsto
  64. · intro n hx
  65. by_cases h : f n=0
  66. · simp [h,Real.zero_rpow ha.ne']
  67. · exact False.elim ((Real.rpow_pos_of_pos (lt_of_le_of_ne (hn n) (Ne.symm h)) b).ne' hx)
  68. · refine ((tendsto_rpow_neg_atTop (sub_pos.mpr hab)).comp hf).congr' ?_
  69. filter_upwards [hf.eventually_gt_atTop 0] with n hn'
  70. change (f n)^(-(b-a))= (f n)^a/(f n)^b
  71. rw [←Real.rpow_sub hn'];congr 1;ring
  72. theorem lower_comparison {a b C c : ℝ} (ha : 0<a) (hab : a<b) (hC : 0<C) (hc : 0<c) :
  73. (fun n : ℕ => exp (C*(log n)^a)) =o[atTop] (fun n => exp (c*(log n)^b)) := by
  74. let f : ℕ → ℝ := fun n => log n
  75. have hf : Tendsto f atTop atTop := Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTop
  76. have small := (power_little hab ha f hf Real.log_natCast_nonneg).bound (show 0<c/(2*C) by positivity)
  77. have big := (tendsto_rpow_atTop (ha.trans hab)).comp hf
  78. have bot : Tendsto (fun n => -(c/2)*(f n)^b) atTop atBot := (tendsto_const_mul_atBot_of_neg (by linarith)).2 big
  79. have diff : Tendsto (fun n => C*(f n)^a-c*(f n)^b) atTop atBot := by
  80. apply tendsto_atBot_mono' _ _ bot
  81. filter_upwards [small] with n hs
  82. rw [Real.norm_of_nonneg (Real.rpow_nonneg (Real.log_natCast_nonneg n) _),Real.norm_of_nonneg (Real.rpow_nonneg (Real.log_natCast_nonneg n) _)] at hs
  83. have H := mul_le_mul_of_nonneg_left hs hC.le
  84. change C*(f n)^a-c*(f n)^b ≤ -(c/2)*(f n)^b
  85. have eq : C*(c/(2*C)*(f n)^b)=c/2*(f n)^b := by field_simp
  86. rw [eq] at H;linarith
  87. apply isLittleO_of_tendsto (fun n h0 => False.elim ((Real.exp_pos _).ne' h0))
  88. simpa only [Function.comp_def,Real.exp_sub] using Real.tendsto_exp_atBot.comp diff
  89. theorem better_lower_from_roth (hr : RothBound (1/9)) : ∃ g : ℕ → ℝ,
  90. g =O[atTop] (fun n => (h n : ℝ)) ∧ ∀ C : ℝ, 0<C →
  91. (fun n : ℕ => exp (C*(log n)^(1/12:ℝ))) =o[atTop] g := by
  92. obtain ⟨c,hc,he⟩ := roth_to_colours (by norm_num) hr
  93. refine ⟨fun n => exp (c*(log n)^(1/9:ℝ)), IsBigO.of_bound' ?_, fun C hC => lower_comparison (by norm_num) (by norm_num) hC hc⟩
  94. filter_upwards [he] with n hn
  95. simpa only [Real.norm_of_nonneg (Real.exp_pos _).le,Real.norm_of_nonneg (Nat.cast_nonneg _)] using hn
  96. /-- Shi and Dong's external upper estimate is used in its `1/4 + ε` form. -/
  97. theorem better_upper_from_quarter (hu : ∀ ε : ℝ, 0<ε → ∀ᶠ n : ℕ in atTop,
  98. (h n : ℝ) ≤ (n:ℝ)^((1/4:ℝ)+ε)) : ∃ g : ℕ → ℝ,
  99. (fun n => (h n:ℝ)) =O[atTop] g ∧ g =o[atTop] (fun n => (n:ℝ)^(2/3:ℝ)) := by
  100. refine ⟨fun n => (n:ℝ)^(1/3:ℝ),IsBigO.of_bound' ?_,
  101. power_little (by norm_num) (by norm_num) (fun n => (n:ℝ)) tendsto_natCast_atTop_atTop Nat.cast_nonneg⟩
  102. filter_upwards [hu (1/12) (by norm_num)] with n hn
  103. norm_num at hn
  104. simpa only [Real.norm_of_nonneg (Nat.cast_nonneg _),Real.norm_of_nonneg (Real.rpow_nonneg (Nat.cast_nonneg _) _)] using hn
  105. end ProgressionColours