Lean / Reader
Lean reader

ExactValue.lean

83 lines6 declarationsno sorryimports Minimum61

Lean 4 Web has Mathlib, so it can check files that import only Mathlib. This one also imports Minimum61, which it does not have: you can read it there, but it will not check. Build the project itself to check it.

  1. import Minimum61
  2. namespace ReciprocalMinimum
  3. theorem total_eq_sum (pick : ℕ → Bool) (ds : List ℕ) (h : ds.Nodup) :
  4. total pick ds = ∑ n ∈ ds.toFinset, if pick n then weight n else 0 := by
  5. induction ds with
  6. | nil => simp [total]
  7. | cons n ds ih =>
  8. obtain ⟨hnot, htail⟩ := List.nodup_cons.mp h
  9. simp [total, ih htail, Finset.sum_insert, hnot]
  10. theorem scaled_sum (A : Finset ℕ) (hA : A ⊆ Finset.Icc 1 61) :
  11. (total (fun d => decide (d ∈ A)) denominators : ℝ) =
  12. (common : ℝ) * ∑ d ∈ A, (1 : ℝ) / d := by
  13. have nd : denominators.Nodup := by decide
  14. have allD : denominators.toFinset = Finset.Icc 1 61 := by decide
  15. have divs : ∀ d ∈ denominators, d ∣ common := by decide
  16. rw [total_eq_sum _ _ nd, allD]
  17. simp only [decide_eq_true_eq, Finset.sum_ite_mem, Finset.inter_eq_right.mpr hA,
  18. Nat.cast_sum, Finset.mul_sum]
  19. apply Finset.sum_congr rfl
  20. intro d hd
  21. have hmem := hA hd
  22. have hdpos : 0 < d := (Finset.mem_Icc.mp hmem).1
  23. have hn : (d : ℝ) ≠ 0 := by exact_mod_cast hdpos.ne'
  24. have hin : d ∈ denominators := by simpa [← allD] using hmem
  25. rw [weight, Nat.cast_div (divs d hin) hn, mul_one_div]
  26. theorem error_formula (A : Finset ℕ) (hA : A ⊆ Finset.Icc 1 61) :
  27. |1 - ∑ d ∈ A, (1 : ℝ) / d| =
  28. |(common : ℝ) - total (fun d => decide (d ∈ A)) denominators| / common := by
  29. have hc : (0 : ℝ) < common := by norm_num [common]
  30. calc
  31. _ = |((common : ℝ) - total (fun d => decide (d ∈ A)) denominators) / common| := by
  32. congr 1
  33. apply (eq_div_iff hc.ne').2
  34. rw [scaled_sum A hA]
  35. ring
  36. _ = _ := by rw [abs_div, abs_of_pos hc]
  37. theorem gap_le_error (A : Finset ℕ) (hA : A ⊆ Finset.Icc 1 61)
  38. (hnz : |1 - ∑ d ∈ A, (1 : ℝ) / d| ≠ 0) :
  39. (gap : ℝ) / common ≤ |1 - ∑ d ∈ A, (1 : ℝ) / d| := by
  40. have hc : (0 : ℝ) < common := by norm_num [common]
  41. rw [error_formula A hA] at hnz ⊢
  42. apply (div_le_div_iff_of_pos_right hc).mpr
  43. let pick (d : ℕ) := decide (d ∈ A)
  44. change (gap : ℝ) ≤ |(common : ℝ) - (total pick denominators : ℝ)|
  45. by_contra! hsmall
  46. obtain ⟨hlo, hhi⟩ := abs_lt.mp hsmall
  47. have hu : total pick denominators ≤ common + gap := by
  48. exact_mod_cast (show (total pick denominators : ℝ) ≤ (common : ℝ) + gap by linarith)
  49. have hl : common ≤ total pick denominators + gap := by
  50. exact_mod_cast (show (common : ℝ) ≤ (total pick denominators : ℝ) + gap by linarith)
  51. rcases near_one pick (by omega) hu with h | h
  52. · change |(common : ℝ) - (total pick denominators : ℝ)| / common ≠ 0 at hnz
  53. simp [h] at hnz
  54. · rw [h, Nat.cast_add] at hhi hlo
  55. linarith
  56. theorem witness_error : |1 - ∑ d ∈ witness.toFinset, (1 : ℝ) / d| = (gap : ℝ) / common := by
  57. have hs : witness.toFinset ⊆ Finset.Icc 1 61 := by decide
  58. rw [error_formula _ hs]
  59. have h : total (fun d => decide (d ∈ witness.toFinset)) denominators = common + gap := by
  60. decide +kernel
  61. rw [h, Nat.cast_add, sub_add_cancel_left, abs_neg, abs_of_nonneg (by positivity)]
  62. /-- The infimum used in the Formal Conjectures statement, specialized to N = 61. -/
  63. theorem delta_61 :
  64. sInf {x : ℝ | x ≠ 0 ∧ ∃ A ⊆ Finset.Icc (1 : ℕ) 61,
  65. x = |1 - ∑ d ∈ A, (1 : ℝ) / d|} = 1 / 65852004707580 := by
  66. have value : (gap : ℝ) / common = 1 / 65852004707580 := by norm_num [gap, common]
  67. rw [← value]
  68. apply IsLeast.csInf_eq
  69. constructor
  70. · exact ⟨by norm_num [gap, common], witness.toFinset, by decide, witness_error.symm⟩
  71. · rintro x ⟨hpos, A, hA, rfl⟩
  72. exact gap_le_error A hA hpos
  73. end ReciprocalMinimum