Lean / Reader
Lean readerGrowth.lean
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.
import ColourRestrictionsimport Mathlib.Analysis.SpecialFunctions.Pow.Asymptoticsimport Mathlib.Tactic.NormNumimport Mathlib.Tactic.Positivityopen Filter Real Asymptoticsopen scoped Topologynamespace ProgressionColoursdef Admits (N K : ℕ) := N=0 ∨ ∃ c : ℕ → Fin K, Valid N 2 cprivate theorem some_colouring (N : ℕ) : ∃ K, Admits N K := bylet c (i : ℕ) : Fin (N+1) := ⟨min i N,by omega⟩refine ⟨N+1,Or.inr ⟨c,?_⟩⟩intro a d hd hi u vhave h (j : ℕ) (hj : j≤2) : (c (a+j*d)).val=a+j*d := bychange min _ _ = _; apply Nat.min_eq_lefthave := Nat.mul_le_mul_right d hj;omegaby_contra! contrahave hh (j : ℕ) (hj : j≤2) : a+j*d=u.val ∨ a+j*d=v.val := byhave hc := contra _ (term_mem (a:=a) (d:=d) (show j≤2+1 by omega))by_cases eq : c (a+j*d)=u· exact Or.inl ((h j hj).symm.trans (congrArg Fin.val eq))· exact Or.inr ((h j hj).symm.trans (congrArg Fin.val (hc eq)))have := hh 0 (by decide); have := hh 1 (by decide); have := hh 2 (by decide);omeganoncomputable def h (N : ℕ) : ℕ := by classical exact Nat.find (some_colouring N)theorem h_attained (N : ℕ) : Admits N (h N) := by classical exact Nat.find_spec (some_colouring N)theorem h_le_of_colouring {N K : ℕ} (hK : Admits N K) : h N ≤ K := by classical exact Nat.find_min' (some_colouring N) hK/-- The arithmetic-progression-free set estimate used as the external analytic input. -/def RothBound (b : ℝ) : Prop := ∃ c : ℝ, 0<c ∧ ∀ᶠ M : ℕ in atTop,∀ A ⊆ Finset.range M, (∀ a d, 0<d → ¬ progression a d 2 ⊆ A) →(A.card : ℝ) ≤ M / exp (c*(log M)^b)theorem roth_to_colours {b : ℝ} (hb : 0<b) (hyp : RothBound b) :∃ c' : ℝ, 0<c' ∧ ∀ᶠ N : ℕ in atTop, exp (c'*(log N)^b) ≤ h N := byobtain ⟨c,hc,hm⟩ := hyprefine ⟨c*(1/2:ℝ)^b,by positivity,?_⟩filter_upwards [(Nat.tendsto_div_const_atTop (by decide : 2≠0)).eventually hm,eventually_ge_atTop 10] with N hM hlargelet M := N/2let E := exp (c*(log M)^b)obtain ⟨colour,hval⟩ := (h_attained N).resolve_left (by omega)have hmpos : 0<M := by dsimp [M];omegahave hmR : 0<(M:ℝ) := by exact_mod_cast hmposhave hE : 0<E := exp_pos _have bound := transfer_three_free_bound (M:=M) (R:=⌊(M:ℝ)/E⌋₊) colour hval(by dsimp [M];omega) (fun A hs ha => Nat.le_floor (hM A hs ha))have scaled : (M:ℝ)≤ ((M:ℝ)/E)*(h N:ℝ) := bycalc (M:ℝ) ≤ (⌊(M:ℝ)/E⌋₊:ℝ) * (h N:ℝ) := by exact_mod_cast bound_ ≤ _ := mul_le_mul_of_nonneg_right (Nat.floor_le (by positivity)) (Nat.cast_nonneg _)have rhs : E ≤ (h N:ℝ) := byrw [div_mul_eq_mul_div,le_div_iff₀ hE] at scaledexact (mul_le_mul_iff_right₀ hmR).mp scaledhave hn3 : 3≤M := by dsimp [M];omegahave hn2 : N ≤ M+M+1 := by dsimp [M];omegahave square : N≤M^2 := by nlinarith [Nat.mul_le_mul_right M hn3]have lg := Real.log_le_log (by positivity : 0<(N:ℝ)) (by exact_mod_cast square : (N:ℝ)≤(M:ℝ)^2)rw [Real.log_pow] at lghave pl := Real.rpow_le_rpow (mul_nonneg (by norm_num : (0:ℝ)≤1/2) (Real.log_natCast_nonneg N))(by norm_num at lg;linarith : (1/2:ℝ)*log N ≤ log M) hb.lerw [Real.mul_rpow (by norm_num) (Real.log_natCast_nonneg N)] at plapply le_trans _ rhsapply Real.exp_le_exp.mprdsimp [E];rw [mul_assoc];exact mul_le_mul_of_nonneg_left pl hc.leprivate theorem power_little {a b : ℝ} (hab : a<b) (ha : 0<a) (f : ℕ → ℝ)(hf : Tendsto f atTop atTop) (hn : ∀ n, 0≤f n) :(fun n => (f n)^a) =o[atTop] (fun n => (f n)^b) := byapply isLittleO_of_tendsto· intro n hxby_cases h : f n=0· simp [h,Real.zero_rpow ha.ne']· exact False.elim ((Real.rpow_pos_of_pos (lt_of_le_of_ne (hn n) (Ne.symm h)) b).ne' hx)· refine ((tendsto_rpow_neg_atTop (sub_pos.mpr hab)).comp hf).congr' ?_filter_upwards [hf.eventually_gt_atTop 0] with n hn'change (f n)^(-(b-a))= (f n)^a/(f n)^brw [←Real.rpow_sub hn'];congr 1;ringtheorem lower_comparison {a b C c : ℝ} (ha : 0<a) (hab : a<b) (hC : 0<C) (hc : 0<c) :(fun n : ℕ => exp (C*(log n)^a)) =o[atTop] (fun n => exp (c*(log n)^b)) := bylet f : ℕ → ℝ := fun n => log nhave hf : Tendsto f atTop atTop := Real.tendsto_log_atTop.comp tendsto_natCast_atTop_atTophave small := (power_little hab ha f hf Real.log_natCast_nonneg).bound (show 0<c/(2*C) by positivity)have big := (tendsto_rpow_atTop (ha.trans hab)).comp hfhave bot : Tendsto (fun n => -(c/2)*(f n)^b) atTop atBot := (tendsto_const_mul_atBot_of_neg (by linarith)).2 bighave diff : Tendsto (fun n => C*(f n)^a-c*(f n)^b) atTop atBot := byapply tendsto_atBot_mono' _ _ botfilter_upwards [small] with n hsrw [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 hshave H := mul_le_mul_of_nonneg_left hs hC.lechange C*(f n)^a-c*(f n)^b ≤ -(c/2)*(f n)^bhave eq : C*(c/(2*C)*(f n)^b)=c/2*(f n)^b := by field_simprw [eq] at H;linarithapply isLittleO_of_tendsto (fun n h0 => False.elim ((Real.exp_pos _).ne' h0))simpa only [Function.comp_def,Real.exp_sub] using Real.tendsto_exp_atBot.comp difftheorem better_lower_from_roth (hr : RothBound (1/9)) : ∃ g : ℕ → ℝ,g =O[atTop] (fun n => (h n : ℝ)) ∧ ∀ C : ℝ, 0<C →(fun n : ℕ => exp (C*(log n)^(1/12:ℝ))) =o[atTop] g := byobtain ⟨c,hc,he⟩ := roth_to_colours (by norm_num) hrrefine ⟨fun n => exp (c*(log n)^(1/9:ℝ)), IsBigO.of_bound' ?_, fun C hC => lower_comparison (by norm_num) (by norm_num) hC hc⟩filter_upwards [he] with n hnsimpa only [Real.norm_of_nonneg (Real.exp_pos _).le,Real.norm_of_nonneg (Nat.cast_nonneg _)] using hn/-- Shi and Dong's external upper estimate is used in its `1/4 + ε` form. -/theorem better_upper_from_quarter (hu : ∀ ε : ℝ, 0<ε → ∀ᶠ n : ℕ in atTop,(h n : ℝ) ≤ (n:ℝ)^((1/4:ℝ)+ε)) : ∃ g : ℕ → ℝ,(fun n => (h n:ℝ)) =O[atTop] g ∧ g =o[atTop] (fun n => (n:ℝ)^(2/3:ℝ)) := byrefine ⟨fun n => (n:ℝ)^(1/3:ℝ),IsBigO.of_bound' ?_,power_little (by norm_num) (by norm_num) (fun n => (n:ℝ)) tendsto_natCast_atTop_atTop Nat.cast_nonneg⟩filter_upwards [hu (1/12) (by norm_num)] with n hnnorm_num at hnsimpa only [Real.norm_of_nonneg (Nat.cast_nonneg _),Real.norm_of_nonneg (Real.rpow_nonneg (Nat.cast_nonneg _) _)] using hnend ProgressionColours