Lean / Reader
Lean readerExactValue.lean
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.
import Minimum61namespace ReciprocalMinimumtheorem total_eq_sum (pick : ℕ → Bool) (ds : List ℕ) (h : ds.Nodup) :total pick ds = ∑ n ∈ ds.toFinset, if pick n then weight n else 0 := byinduction ds with| nil => simp [total]| cons n ds ih =>obtain ⟨hnot, htail⟩ := List.nodup_cons.mp hsimp [total, ih htail, Finset.sum_insert, hnot]theorem scaled_sum (A : Finset ℕ) (hA : A ⊆ Finset.Icc 1 61) :(total (fun d => decide (d ∈ A)) denominators : ℝ) =(common : ℝ) * ∑ d ∈ A, (1 : ℝ) / d := byhave nd : denominators.Nodup := by decidehave allD : denominators.toFinset = Finset.Icc 1 61 := by decidehave divs : ∀ d ∈ denominators, d ∣ common := by deciderw [total_eq_sum _ _ nd, allD]simp only [decide_eq_true_eq, Finset.sum_ite_mem, Finset.inter_eq_right.mpr hA,Nat.cast_sum, Finset.mul_sum]apply Finset.sum_congr rflintro d hdhave hmem := hA hdhave hdpos : 0 < d := (Finset.mem_Icc.mp hmem).1have hn : (d : ℝ) ≠ 0 := by exact_mod_cast hdpos.ne'have hin : d ∈ denominators := by simpa [← allD] using hmemrw [weight, Nat.cast_div (divs d hin) hn, mul_one_div]theorem error_formula (A : Finset ℕ) (hA : A ⊆ Finset.Icc 1 61) :|1 - ∑ d ∈ A, (1 : ℝ) / d| =|(common : ℝ) - total (fun d => decide (d ∈ A)) denominators| / common := byhave hc : (0 : ℝ) < common := by norm_num [common]calc_ = |((common : ℝ) - total (fun d => decide (d ∈ A)) denominators) / common| := bycongr 1apply (eq_div_iff hc.ne').2rw [scaled_sum A hA]ring_ = _ := by rw [abs_div, abs_of_pos hc]theorem gap_le_error (A : Finset ℕ) (hA : A ⊆ Finset.Icc 1 61)(hnz : |1 - ∑ d ∈ A, (1 : ℝ) / d| ≠ 0) :(gap : ℝ) / common ≤ |1 - ∑ d ∈ A, (1 : ℝ) / d| := byhave hc : (0 : ℝ) < common := by norm_num [common]rw [error_formula A hA] at hnz ⊢apply (div_le_div_iff_of_pos_right hc).mprlet pick (d : ℕ) := decide (d ∈ A)change (gap : ℝ) ≤ |(common : ℝ) - (total pick denominators : ℝ)|by_contra! hsmallobtain ⟨hlo, hhi⟩ := abs_lt.mp hsmallhave hu : total pick denominators ≤ common + gap := byexact_mod_cast (show (total pick denominators : ℝ) ≤ (common : ℝ) + gap by linarith)have hl : common ≤ total pick denominators + gap := byexact_mod_cast (show (common : ℝ) ≤ (total pick denominators : ℝ) + gap by linarith)rcases near_one pick (by omega) hu with h | h· change |(common : ℝ) - (total pick denominators : ℝ)| / common ≠ 0 at hnzsimp [h] at hnz· rw [h, Nat.cast_add] at hhi hlolinariththeorem witness_error : |1 - ∑ d ∈ witness.toFinset, (1 : ℝ) / d| = (gap : ℝ) / common := byhave hs : witness.toFinset ⊆ Finset.Icc 1 61 := by deciderw [error_formula _ hs]have h : total (fun d => decide (d ∈ witness.toFinset)) denominators = common + gap := bydecide +kernelrw [h, Nat.cast_add, sub_add_cancel_left, abs_neg, abs_of_nonneg (by positivity)]/-- The infimum used in the Formal Conjectures statement, specialized to N = 61. -/theorem delta_61 :sInf {x : ℝ | x ≠ 0 ∧ ∃ A ⊆ Finset.Icc (1 : ℕ) 61,x = |1 - ∑ d ∈ A, (1 : ℝ) / d|} = 1 / 65852004707580 := byhave value : (gap : ℝ) / common = 1 / 65852004707580 := by norm_num [gap, common]rw [← value]apply IsLeast.csInf_eqconstructor· exact ⟨by norm_num [gap, common], witness.toFinset, by decide, witness_error.symm⟩· rintro x ⟨hpos, A, hA, rfl⟩exact gap_le_error A hA hposend ReciprocalMinimum