import Mathlib.Tacticnamespace ReciprocalRecordsnoncomputable sectiondef rate : ℝ := 625 / 766def tolerance : ℝ := 1 / 1000000/-- Two consecutive witnesses, the zero error, and the next record time. -/def PairBound (x y : ℝ) : Prop :=rate * (y + 2 * x) ≤ (5 / 2 + tolerance) * x/-- The ten differences among four distinct record witnesses and the zero error. -/def FourBound (h m n v : ℝ) : Prop :=rate * (v + 2 * n + 3 * m + 4 * h) ≤ (16 / 3 + tolerance) * n + (5 / 2) * mtheorem pair_ratio {x y : ℝ} (hx : 0 ≤ x) (hb : PairBound x y) :y ≤ (106401 / 100000 : ℝ) * x := byunfold PairBound rate tolerance at hblinarith/-- Each contraction uses the two preceding ratio bounds. -/theorem contract {q q' h m n v : ℝ} (hq : 0 < q) (hn : 0 ≤ n)(hcoeff : 5 / 2 ≤ rate * (3 + 4 / q))(hstep : 16 / 3 + tolerance + (5 / 2) / q ≤rate * (q' + 2 + 3 / q + 4 / q ^ 2))(hm : m ≤ q * h) (hh : n ≤ q * m) (hb : FourBound h m n v) :v ≤ q' * n := byhave hc : 0 < rate := by norm_num [rate]have hdiv : n / q ≤ m := (div_le_iff₀ hq).2 (by simpa [mul_comm] using hh)have hdiv' : m / q ≤ h := (div_le_iff₀ hq).2 (by simpa [mul_comm] using hm)have hcost := mul_le_mul_of_nonneg_right hstep hnhave hmpos := mul_le_mul_of_nonneg_left hdiv (sub_nonneg.mpr hcoeff)have hhpos := mul_le_mul_of_nonneg_left hdiv' (by positivity : 0 ≤ 4 * rate)unfold FourBound at hbapply le_of_mul_le_mul_left (a := rate) _ hclinear_combination (norm := (ring_nf; positivity)) hb + hcost + hmpos + hhposabbrev q₀ : ℝ := 106401 / 100000abbrev q₁ : ℝ := 10636 / 10000abbrev q₂ : ℝ := 1061 / 1000abbrev q₃ : ℝ := 105 / 100theorem step₁ {h m n v : ℝ} (hn : 0 ≤ n) (hm : m ≤ q₀*h) (hh : n ≤ q₀*m)(hb : FourBound h m n v) : v ≤ q₁*n := byapply contract (q := q₀) (by norm_num) hn _ _ hm hh hb <;> norm_num [rate, tolerance]theorem step₂ {h m n v : ℝ} (hn : 0 ≤ n) (hm : m ≤ q₁*h) (hh : n ≤ q₁*m)(hb : FourBound h m n v) : v ≤ q₂*n := byapply contract (q := q₁) (by norm_num) hn _ _ hm hh hb <;> norm_num [rate, tolerance]theorem step₃ {h m n v : ℝ} (hn : 0 ≤ n) (hm : m ≤ q₂*h) (hh : n ≤ q₂*m)(hb : FourBound h m n v) : v ≤ q₃*n := byapply contract (q := q₂) (by norm_num) hn _ _ hm hh hb <;> norm_num [rate, tolerance]theorem step₄ {h m n v : ℝ} (hn : 0 ≤ n) (hm : m ≤ q₃*h) (hh : n ≤ q₃*m)(hb : FourBound h m n v) : v ≤ n := bysimpa using contract (q := q₃) (q' := 1) (by norm_num) hn(by norm_num [rate]) (by norm_num [rate, tolerance]) hm hh hbtheorem ten_records (a : ℕ → ℝ) (ha : ∀ i, 0 ≤ a i) (hinc : a 8 < a 9)(hp : ∀ i < 9, PairBound (a i) (a (i+1)))(hf : ∀ i < 7, FourBound (a i) (a (i+1)) (a (i+2)) (a (i+3))) : False := byhave h0 (i) (hi : i < 9) : a (i+1) ≤ q₀ * a i := pair_ratio (ha _) (hp _ hi)have h1 (i) (hi : i < 7) : a (i+3) ≤ q₁ * a (i+2) :=step₁ (ha _) (h0 i (by omega)) (h0 (i+1) (by omega)) (hf _ hi)have h2 (i) (hi : i < 5) : a (i+5) ≤ q₂ * a (i+4) :=step₂ (ha _) (h1 i (by omega)) (h1 (i+1) (by omega)) (hf (i+2) (by omega))have h3 (i) (hi : i < 3) : a (i+7) ≤ q₃ * a (i+6) :=step₃ (ha _) (h2 i (by omega)) (h2 (i+1) (by omega)) (hf (i+4) (by omega))exact hinc.not_ge (step₄ (ha _) (h3 0 (by decide)) (h3 1 (by decide)) (hf 6 (by decide)))theorem interval_constants : (1 : ℝ) < rate * (123 / 100) ∧ (123 / 100 : ℝ)^10 < 8 := bynorm_num [rate]endend ReciprocalRecords