Lean / Reader
Lean readerDecayTail.lean
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.
import DecayClassificationnamespace DecayClassification/-- Extract the finite sums promised by failure of the strict tail test.This argument also applies to a divergent sequence. -/theorem witnesses_of_failure (a : ℕ → ℝ) (bad : ¬TailTest a) :∃ C : ℕ, 0 < C ∧ ∃ N : ℕ, ∀ r : ℕ, r ≥ max 2 N →∃ l, 1 < 2 * (r : ℝ)^(C*r) * (∑ i ∈ Finset.Ico r l, a i) := byunfold TailTest at badpush_neg at badobtain ⟨C,hC,N,hN⟩ := badrefine ⟨C,hC,N,?_⟩intro r hrhave hr0 : 0 < (r:ℝ) := by exact_mod_cast (show 0 < r by omega)let x := (r:ℝ)^(C*r)have hx : 0 < x := pow_pos hr0 _have hu : (1/(2*x))*x < 1 := by field_simp; linarithobtain ⟨l,hl⟩ := hN r hr (1/(2*x)) huexact ⟨l, by have := (div_lt_iff₀ (by positivity : 0 < 2*x)).mp hl; dsimp [x] at *; linarith⟩/-- Pairing consecutive positive-index terms bounds a true tail by twice thesum available in the shared pool. -/theorem paired_tail (a : ℕ → ℝ) (ha : Antitone a) (ha0 : ∀ i, 0 ≤ a i)(j l : ℕ) : ∑ i ∈ Finset.Ico (2*j+2) l, a i ≤ 2*∑ i ∈ Finset.Icc j l, a (2*i+1) := byclassicallet P (i : ℕ) : Finset ℕ := {2*i+1,2*i+2}have cover : ∀ x ∈ Finset.Ico (2*j+2) l, ∃ i ∈ Finset.Icc j l, x ∈ P i := byintro x hxobtain ⟨lo,hi⟩ := Finset.mem_Ico.mp hxrefine ⟨(x-1)/2, Finset.mem_Icc.mpr ⟨by omega,by omega⟩,?_⟩simp only [P,Finset.mem_insert,Finset.mem_singleton]omegaapply (DecayRamseyPacking.cover_mass a ha0 _ _ P cover).transrw [Finset.mul_sum]apply Finset.sum_le_sumintro i _simp only [P,Finset.sum_insert (by simp : 2*i+1 ∉ ({2*i+2}:Finset ℕ)),Finset.sum_singleton]linarith [ha (show 2*i+1 ≤ 2*i+2 by omega)]/-- One scaling factor supplies every provisional color, including the finiteinitial segment on which the tail comparison need not hold. -/theorem scaled_supply (a b : ℕ → ℝ) (ha : Antitone a) (ha0 : ∀ i, 0 < a i)(hb : ∀ i, 0 < b i) (C N M : ℕ) (K : ℝ) (hK : 0 < K)(witness : ∀ r : ℕ, r ≥ max 2 N →∃ l, 1 < 2*(r:ℝ)^(C*r)*(∑ i ∈ Finset.Ico r l, a i))(decay : ∀ j ≥ M, b j*((2*j+2:ℕ):ℝ)^(C*(2*j+2)) ≤ K) :∃ γ : ℝ, 1 ≤ γ ∧ ∀ j, ∃ l ≥ j, 40*b j < ∑ i ∈ Finset.Icc j l, γ*a (2*i+1) := byclassicallet B := max N Mlet init := ∑ i ∈ Finset.range B, 41*b i / a (2*i+1)let γ := 1 + 160*K + inithave init0 : 0 ≤ init := Finset.sum_nonneg (fun i _ => byexact div_nonneg (by linarith [hb i]) (ha0 _).le)have hscale : 160*K ≤ γ := by dsimp [γ]; linarithrefine ⟨γ,by dsimp [γ]; linarith,?_⟩intro jby_cases hj : j < B· refine ⟨j,le_rfl,?_⟩simp only [Finset.Icc_self,Finset.sum_singleton]have le : 41*b j/a (2*j+1) ≤ init := Finset.single_le_sum(s := Finset.range B) (f := fun i => 41*b i/a (2*i+1))(fun i _ => div_nonneg (by linarith [hb i]) (ha0 _).le) (Finset.mem_range.mpr hj)have hin : 41*b j/a (2*j+1) ≤ γ := by dsimp [γ]; linarithhave := (div_le_iff₀ (ha0 _)).mp hinlinarith [hb j]· have hNM : N ≤ j ∧ M ≤ j := by dsimp [B] at hj; omegalet r := 2*j+2let x := (r:ℝ)^(C*r)have hx : 0 < x := by dsimp [x,r]; positivityobtain ⟨l,hl⟩ := witness r (by dsimp [r]; omega)have bd : b j*x ≤ K := decay j hNM.2let pool := ∑ i ∈ Finset.Icc j l, a (2*i+1)have p0 : 0 ≤ pool := Finset.sum_nonneg (fun i _ => (ha0 _).le)have hpair := paired_tail a ha (fun i => (ha0 i).le) j lhave hlarge : 1 < (4*x)*pool := bychange 1 < 2*x*_ at hlhave step := mul_le_mul_of_nonneg_left hpair (by positivity : 0 ≤ 2*x)change _ ≤ 2*x*(2*pool) at stepdsimp only [r] at hllinarithhave hjl : j ≤ l := byby_contra! smallhave : pool = 0 := by simp [pool,Finset.Icc_eq_empty_of_lt small]rw [this] at hlarge; linarithrefine ⟨l,hjl,?_⟩rw [← Finset.mul_sum]change 40*b j < γ*poolhave hleft := mul_le_mul_of_nonneg_right bd (show 0 ≤ 40*pool by positivity)have hright := mul_lt_mul_of_pos_left hlarge (hb j)have hfinal := mul_le_mul_of_nonneg_right hscale p0nlinarithend DecayClassification