Lean / Reader
Lean reader

RecordBounds.lean

76 lines16 declarationsno sorryimports Mathlib.Tactic
  1. import Mathlib.Tactic
  2. namespace ReciprocalRecords
  3. noncomputable section
  4. def rate : ℝ := 625 / 766
  5. def tolerance : ℝ := 1 / 1000000
  6. /-- Two consecutive witnesses, the zero error, and the next record time. -/
  7. def PairBound (x y : ℝ) : Prop :=
  8. rate * (y + 2 * x) ≤ (5 / 2 + tolerance) * x
  9. /-- The ten differences among four distinct record witnesses and the zero error. -/
  10. def FourBound (h m n v : ℝ) : Prop :=
  11. rate * (v + 2 * n + 3 * m + 4 * h) ≤ (16 / 3 + tolerance) * n + (5 / 2) * m
  12. theorem pair_ratio {x y : ℝ} (hx : 0 ≤ x) (hb : PairBound x y) :
  13. y ≤ (106401 / 100000 : ℝ) * x := by
  14. unfold PairBound rate tolerance at hb
  15. linarith
  16. /-- Each contraction uses the two preceding ratio bounds. -/
  17. theorem contract {q q' h m n v : ℝ} (hq : 0 < q) (hn : 0 ≤ n)
  18. (hcoeff : 5 / 2 ≤ rate * (3 + 4 / q))
  19. (hstep : 16 / 3 + tolerance + (5 / 2) / q ≤
  20. rate * (q' + 2 + 3 / q + 4 / q ^ 2))
  21. (hm : m ≤ q * h) (hh : n ≤ q * m) (hb : FourBound h m n v) :
  22. v ≤ q' * n := by
  23. have hc : 0 < rate := by norm_num [rate]
  24. have hdiv : n / q ≤ m := (div_le_iff₀ hq).2 (by simpa [mul_comm] using hh)
  25. have hdiv' : m / q ≤ h := (div_le_iff₀ hq).2 (by simpa [mul_comm] using hm)
  26. have hcost := mul_le_mul_of_nonneg_right hstep hn
  27. have hmpos := mul_le_mul_of_nonneg_left hdiv (sub_nonneg.mpr hcoeff)
  28. have hhpos := mul_le_mul_of_nonneg_left hdiv' (by positivity : 0 ≤ 4 * rate)
  29. unfold FourBound at hb
  30. apply le_of_mul_le_mul_left (a := rate) _ hc
  31. linear_combination (norm := (ring_nf; positivity)) hb + hcost + hmpos + hhpos
  32. abbrev q₀ : ℝ := 106401 / 100000
  33. abbrev q₁ : ℝ := 10636 / 10000
  34. abbrev q₂ : ℝ := 1061 / 1000
  35. abbrev q₃ : ℝ := 105 / 100
  36. theorem step₁ {h m n v : ℝ} (hn : 0 ≤ n) (hm : m ≤ q₀*h) (hh : n ≤ q₀*m)
  37. (hb : FourBound h m n v) : v ≤ q₁*n := by
  38. apply contract (q := q₀) (by norm_num) hn _ _ hm hh hb <;> norm_num [rate, tolerance]
  39. theorem step₂ {h m n v : ℝ} (hn : 0 ≤ n) (hm : m ≤ q₁*h) (hh : n ≤ q₁*m)
  40. (hb : FourBound h m n v) : v ≤ q₂*n := by
  41. apply contract (q := q₁) (by norm_num) hn _ _ hm hh hb <;> norm_num [rate, tolerance]
  42. theorem step₃ {h m n v : ℝ} (hn : 0 ≤ n) (hm : m ≤ q₂*h) (hh : n ≤ q₂*m)
  43. (hb : FourBound h m n v) : v ≤ q₃*n := by
  44. apply contract (q := q₂) (by norm_num) hn _ _ hm hh hb <;> norm_num [rate, tolerance]
  45. theorem step₄ {h m n v : ℝ} (hn : 0 ≤ n) (hm : m ≤ q₃*h) (hh : n ≤ q₃*m)
  46. (hb : FourBound h m n v) : v ≤ n := by
  47. simpa using contract (q := q₃) (q' := 1) (by norm_num) hn
  48. (by norm_num [rate]) (by norm_num [rate, tolerance]) hm hh hb
  49. theorem ten_records (a : ℕ → ℝ) (ha : ∀ i, 0 ≤ a i) (hinc : a 8 < a 9)
  50. (hp : ∀ i < 9, PairBound (a i) (a (i+1)))
  51. (hf : ∀ i < 7, FourBound (a i) (a (i+1)) (a (i+2)) (a (i+3))) : False := by
  52. have h0 (i) (hi : i < 9) : a (i+1) ≤ q₀ * a i := pair_ratio (ha _) (hp _ hi)
  53. have h1 (i) (hi : i < 7) : a (i+3) ≤ q₁ * a (i+2) :=
  54. step₁ (ha _) (h0 i (by omega)) (h0 (i+1) (by omega)) (hf _ hi)
  55. have h2 (i) (hi : i < 5) : a (i+5) ≤ q₂ * a (i+4) :=
  56. step₂ (ha _) (h1 i (by omega)) (h1 (i+1) (by omega)) (hf (i+2) (by omega))
  57. have h3 (i) (hi : i < 3) : a (i+7) ≤ q₃ * a (i+6) :=
  58. step₃ (ha _) (h2 i (by omega)) (h2 (i+1) (by omega)) (hf (i+4) (by omega))
  59. exact hinc.not_ge (step₄ (ha _) (h3 0 (by decide)) (h3 1 (by decide)) (hf 6 (by decide)))
  60. theorem interval_constants : (1 : ℝ) < rate * (123 / 100) ∧ (123 / 100 : ℝ)^10 < 8 := by
  61. norm_num [rate]
  62. end
  63. end ReciprocalRecords