Lean / Reader
Lean readerRecordProducts.lean
Lean 4 Web has Mathlib, so it can check files that import only Mathlib. This one also imports RecordBounds, which it does not have: you can read it there, but it will not check. Build the project itself to check it.
import Mathlib.Tacticimport RecordBoundsnamespace ReciprocalRecordsnoncomputable sectiondef pairProduct (x y : ℝ) : ℝ := |x| * |y| * |x-y|def fourProduct (x y z u : ℝ) : ℝ :=|x| * |y| * |z| * |u| * |x-y| * |x-z| * |x-u| * |y-z| * |y-u| * |z-u|theorem gap_bound {x y : ℝ} (h : |y| ≤ |x|) : |x - y| ≤ 2 * |x| := bycalc |x-y| ≤ |x| + |y| := abs_sub _ __ ≤ 2 * |x| := by linariththeorem pairProduct_le {x y : ℝ} (h : |y| ≤ |x|) :pairProduct x y ≤ 2 * |x|^2 * |y| := bycalc_ ≤ |x| * |y| * (2 * |x|) := byunfold pairProductexact mul_le_mul_of_nonneg_left (gap_bound h) (by positivity)_ = _ := by ringtheorem fourProduct_le {x y z u : ℝ} (hxy : |y| ≤ |x|) (hyz : |z| ≤ |y|) (hzu : |u| ≤ |z|) :fourProduct x y z u ≤ 64 * |x|^4 * |y|^3 * |z|^2 * |u| := bycalc_ ≤ |x| * |y| * |z| * |u| * (2*|x|) * (2*|x|) * (2*|x|) *(2*|y|) * (2*|y|) * (2*|z|) := byunfold fourProductgcongr· exact gap_bound hxy· exact gap_bound (hyz.trans hxy)· exact gap_bound (hzu.trans (hyz.trans hxy))· exact gap_bound hyz· exact gap_bound (hzu.trans hyz)· exact gap_bound hzu_ = _ := by ring/-- If a common denominator rules out a good approximation at the left endpoint,equal minima at both endpoints are inconsistent with the proposed right bound. -/theorem interval_drop {d₀ d₁ L c y : ℝ} (hL : 0 < L)(h₀ : 1 / L ≤ d₀) (h₁ : d₁ ≤ Real.exp (-c*y))(hlog : Real.log L < c*y) : d₁ < d₀ := byapply lt_of_le_of_lt h₁apply lt_of_lt_of_le _ h₀rw [neg_mul, Real.exp_neg, one_div, inv_lt_inv₀ (Real.exp_pos _) hL]rwa [← Real.log_lt_log_iff hL (Real.exp_pos _), Real.log_exp]/-- Every good index supplies an interval of good earlier indices for a larger exponent. -/theorem density_interval {f : ℕ → ℝ} (hf : Antitone f) {m n : ℕ} (hmn : m ≤ n){c c' : ℝ} (hgood : Real.exp (-c * n) < f n) (hcut : c*n ≤ c'*m) :Real.exp (-c'*m) < f m := byapply lt_of_le_of_lt _ (lt_of_lt_of_le hgood (hf hmn))apply Real.exp_le_exp.mprlinarithendend ReciprocalRecords