Lean / Reader
Lean reader

PrimeRaceLogDerivative.lean

231 lines30 declarationsno sorryimports PrimeRaceZeroBudget Mathlib.Analysis.Complex.LocallyUniformLimit Mathlib.Analysis.NormedSpace.MultipliableUniformlyOn Mathlib.NumberTheory.Harmonic.GammaDeriv Mathlib.Analysis.Calculus.LogDeriv

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

  1. import PrimeRaceZeroBudget
  2. import Mathlib.Analysis.Complex.LocallyUniformLimit
  3. import Mathlib.Analysis.NormedSpace.MultipliableUniformlyOn
  4. import Mathlib.NumberTheory.Harmonic.GammaDeriv
  5. import Mathlib.Analysis.Calculus.LogDeriv
  6. /-! The logarithmic derivative of the completed cubic Euler product at two. -/
  7. noncomputable section
  8. open Filter Topology Complex
  9. namespace CubicPrimeRace
  10. /-- The shift of a reciprocal local Euler polynomial from its constant term. -/
  11. private def delta (r : ℕ) (t : ℂ) : ℂ :=
  12. if r = 1 then -t^2 else if r = 0 then t+t^2 else -2*t+t^2
  13. private def parameter (n : ℕ) (s : ℂ) : ℂ := Complex.exp (-(Real.log n : ℂ)*s)
  14. /-- The difference between the reciprocal Euler polynomial at p⁻ˢ and one. -/
  15. def correction (n : ℕ) (s : ℂ) : ℂ :=
  16. if 3 < n ∧ n.Prime then delta (rootCount n) (parameter n s) else 0
  17. private def logLocal (n : ℕ) (s : ℂ) : ℂ := -Complex.log (1+correction n s)
  18. /-- This definition represents the cubic Euler product on the right half-plane.
  19. Values of this total Lean function outside convergence are never used. -/
  20. def cubicEuler (s : ℂ) : ℂ := Complex.exp (∑' n, logLocal n s)
  21. def cubicConductorScale : ℝ := Real.sqrt 108 / (2 * Real.pi)
  22. def completedEuler (s : ℂ) : ℂ :=
  23. Complex.exp ((Real.log cubicConductorScale : ℂ)*s) * Complex.Gamma s * cubicEuler s
  24. private def region : Set ℂ := {s | 3/2 < s.re}
  25. private theorem open_region : IsOpen region := isOpen_lt continuous_const Complex.continuous_re
  26. private theorem two_mem : (2 : ℂ) ∈ region := by norm_num [region]
  27. private theorem delta_norm (r : ℕ) (t : ℂ) (ht : ‖t‖ ≤ 1) : ‖delta r t‖ ≤ 3*‖t‖ := by
  28. have h : ‖t^2‖ ≤ ‖t‖ := by rw [norm_pow]; nlinarith [mul_nonneg (norm_nonneg t) (sub_nonneg.mpr ht)]
  29. unfold delta
  30. split_ifs
  31. · rw [norm_neg]; linarith [norm_nonneg t]
  32. · exact (norm_add_le _ _).trans (by linarith [norm_nonneg t])
  33. · apply (norm_add_le _ _).trans
  34. rw [norm_mul, norm_neg, Complex.norm_ofNat]
  35. linarith
  36. private theorem correction_bounds (n : ℕ) {s : ℂ} (hs : s ∈ region) :
  37. ‖correction n s‖ ≤ 3*(n:ℝ)^(-(3/2):ℝ) ∧ ‖correction n s‖ ≤ 1/2 := by
  38. by_cases h : 3 < n ∧ n.Prime
  39. · have hn : (4:ℝ) ≤ n := by exact_mod_cast h.1
  40. have hn0 : 0 < (n:ℝ) := by linarith
  41. have hu : ‖parameter n s‖ = (n:ℝ)^(-s.re) := by
  42. rw [parameter, Complex.norm_exp, Real.rpow_def_of_pos hn0]
  43. congr 1
  44. simp only [Complex.mul_re, Complex.neg_re, Complex.neg_im, Complex.ofReal_re, Complex.ofReal_im]; ring
  45. have he : ‖parameter n s‖ ≤ (n:ℝ)^(-(3/2):ℝ) := by
  46. rw [hu]
  47. exact Real.rpow_le_rpow_of_exponent_le (by linarith) (neg_le_neg (le_of_lt hs))
  48. have hb : (n:ℝ)^(-(3/2):ℝ) ≤ 1/8 := by
  49. calc _ ≤ (4:ℝ)^(-(3/2):ℝ) := Real.rpow_le_rpow_of_nonpos (by norm_num) hn (by norm_num)
  50. _ = _ := by
  51. rw [show (4:ℝ) = 2^(2:ℕ) by norm_num, ← Real.rpow_natCast_mul (by norm_num)]
  52. norm_num
  53. rw [correction, if_pos h]
  54. have hd := delta_norm (rootCount n) (parameter n s) (by linarith)
  55. constructor <;> linarith
  56. · simp only [correction, if_neg h, norm_zero]
  57. exact ⟨by positivity, by norm_num⟩
  58. private theorem correction_diff (n : ℕ) : Differentiable ℂ (correction n) := by
  59. intro s
  60. unfold correction
  61. split_ifs
  62. · unfold delta parameter; split_ifs <;> fun_prop
  63. · fun_prop
  64. private theorem local_slit (n : ℕ) {s : ℂ} (hs : s ∈ region) :
  65. 1+correction n s ∈ Complex.slitPlane := by
  66. apply Or.inl
  67. have hk := (correction_bounds n hs).2
  68. have h := Complex.abs_re_le_norm (correction n s)
  69. simp only [Complex.add_re, Complex.one_re]
  70. linarith [(abs_le.mp h).1]
  71. private theorem logLocal_diff (n : ℕ) : DifferentiableOn ℂ (logLocal n) region := by
  72. intro s hs
  73. have hg : DifferentiableAt ℂ (fun z => 1+correction n z) s := (correction_diff n s).const_add _
  74. exact (hg.clog (local_slit n hs)).neg.differentiableWithinAt
  75. private theorem local_majorant (n : ℕ) {s : ℂ} (hs : s ∈ region) :
  76. ‖logLocal n s‖ ≤ 5*(n:ℝ)^(-(3/2):ℝ) := by
  77. rw [logLocal, norm_neg]
  78. have h := correction_bounds n hs
  79. have hlog := Complex.norm_log_one_add_half_le_self h.2
  80. linarith [Real.rpow_nonneg (Nat.cast_nonneg n) (-(3/2):ℝ)]
  81. private theorem majorant_summable : Summable (fun n : ℕ => 5*(n:ℝ)^(-(3/2):ℝ)) :=
  82. (Real.summable_nat_rpow.mpr (by norm_num)).mul_left _
  83. private theorem sumLog_diff : DifferentiableOn ℂ (fun s => ∑' n, logLocal n s) region :=
  84. Complex.differentiableOn_tsum_of_summable_norm majorant_summable logLocal_diff open_region
  85. (fun n _ hs => local_majorant n hs)
  86. /-- The prime-side function is genuinely the product of the reciprocal local factors. -/
  87. theorem cubicEuler_eq_tprod {s : ℂ} (hs : 3/2 < s.re) :
  88. cubicEuler s = ∏' n, (1+correction n s)⁻¹ := by
  89. have hg : Summable (fun n => logLocal n s) :=
  90. Summable.of_norm_bounded majorant_summable (fun n => local_majorant n hs)
  91. have h := hg.hasSum.cexp
  92. have he (n : ℕ) : Complex.exp (logLocal n s) = (1+correction n s)⁻¹ := by
  93. rw [logLocal, Complex.exp_neg, Complex.exp_log (Complex.slitPlane_ne_zero (local_slit n hs))]
  94. simpa only [Function.comp_apply, he, cubicEuler] using h.tprod_eq.symm
  95. private theorem parameter_two {n : ℕ} (hn : 0 < n) :
  96. parameter n 2 = ((1/(n:ℝ)^2 : ℝ) : ℂ) := by
  97. have h : 0 < (n:ℝ) := by exact_mod_cast hn
  98. rw [parameter, show -(Real.log n : ℂ)*2 = -((Real.log n : ℂ)+(Real.log n : ℂ)) by ring,
  99. Complex.exp_neg, Complex.exp_add, ← Complex.ofReal_exp, Real.exp_log h]
  100. push_cast
  101. ring
  102. private theorem delta_ofReal (r : ℕ) (t : ℝ) :
  103. 1+delta r t = (eulerDenominator r t : ℂ) := by
  104. unfold delta eulerDenominator
  105. split_ifs <;> push_cast <;> ring
  106. private theorem complexPoly_diff (r : ℕ) (t : ℂ) : DifferentiableAt ℂ (fun z => 1+delta r z) t := by
  107. unfold delta
  108. split_ifs <;> fun_prop
  109. private theorem local_derivative_two (n : ℕ) :
  110. deriv (logLocal n) 2 = (eulerTermAtTwo n : ℂ) := by
  111. by_cases h : 3 < n ∧ n.Prime
  112. · let t : ℝ := 1/(n:ℝ)^2
  113. let P : ℂ → ℂ := fun z => 1+delta (rootCount n) z
  114. have hp : HasDerivAt P ((deriv (eulerDenominator (rootCount n)) t : ℝ) : ℂ) (t:ℂ) := by
  115. have hP := (complexPoly_diff (rootCount n) (t:ℂ)).hasDerivAt
  116. have hr := (complexPoly_diff (rootCount n) t).hasDerivAt.real_of_complex
  117. have heq : (fun u : ℝ => (P u).re) = eulerDenominator (rootCount n) := by
  118. ext u; simp only [P, delta_ofReal, Complex.ofReal_re]
  119. change HasDerivAt (fun u : ℝ => (P u).re) _ t at hr
  120. rw [heq] at hr
  121. have hf : (fun u : ℝ => P (u:ℂ)) = fun u : ℝ => ((eulerDenominator (rootCount n) u : ℝ):ℂ) :=
  122. funext (delta_ofReal _)
  123. have hh := hP.comp_ofReal
  124. change HasDerivAt (fun u : ℝ => P (u:ℂ)) _ t at hh
  125. rw [hf] at hh
  126. exact hP.congr_deriv (hh.unique (hr.differentiableAt.hasDerivAt.ofReal_comp))
  127. have ht : HasDerivAt (parameter n) ((t:ℂ) * (-(Real.log n : ℂ))) 2 := by
  128. have ht' := ((hasDerivAt_id (2:ℂ)).const_mul (-(Real.log n : ℂ))).cexp
  129. change HasDerivAt (parameter n) (parameter n 2 * (-(Real.log n : ℂ)*1)) 2 at ht'
  130. rw [parameter_two (show 0 < n by omega), mul_one] at ht'
  131. exact ht'
  132. have htval := parameter_two (show 0 < n by omega : 0 < n)
  133. change parameter n 2 = (t:ℂ) at htval
  134. have hp' := (htval.symm ▸ hp).comp 2 ht
  135. have hcut : P (parameter n 2) ∈ Complex.slitPlane := by
  136. simpa [P, correction, h] using local_slit n two_mem
  137. have hd := (hp'.clog hcut).neg
  138. have he := eulerTerm_eq_local_log_derivative h
  139. rw [he]
  140. simp only [Complex.ofReal_div, Complex.ofReal_mul]
  141. have hg : logLocal n = fun s => -Complex.log (P (parameter n s)) := by
  142. funext s; simp [logLocal, correction, h, P]
  143. rw [hg]
  144. rw [show deriv (fun s => -Complex.log (P (parameter n s))) 2 = _ from hd.deriv, Function.comp_apply, htval]
  145. change -( _ / (1+delta (rootCount n) (t:ℂ))) = _
  146. rw [delta_ofReal]
  147. dsimp [t]
  148. push_cast
  149. ring
  150. · have he : logLocal n = fun _ => 0 := by ext; simp [logLocal, correction, h]
  151. rw [he]; simp [eulerTermAtTwo, h]
  152. private theorem euler_diff : DifferentiableAt ℂ cubicEuler 2 :=
  153. ((sumLog_diff.differentiableAt (open_region.mem_nhds two_mem)).cexp)
  154. /-- No hypothesis on the zeros, continuation, or Euler product. -/
  155. theorem logDeriv_cubicEuler_two :
  156. logDeriv cubicEuler 2 = ((∑' n, eulerTermAtTwo n : ℝ) : ℂ) := by
  157. have hd := Complex.hasSum_deriv_of_summable_norm majorant_summable logLocal_diff open_region
  158. (fun n _ hs => local_majorant n hs) two_mem
  159. simp_rw [local_derivative_two] at hd
  160. have he := (sumLog_diff.differentiableAt (open_region.mem_nhds two_mem)).hasDerivAt.cexp
  161. change deriv _ 2 / Complex.exp _ = _
  162. rw [show deriv cubicEuler 2 = _ from he.deriv, mul_div_cancel_left₀ _ (Complex.exp_ne_zero _)]
  163. rw [← hd.tsum_eq, Complex.ofReal_tsum]
  164. private theorem gamma_two_value : Complex.Gamma 2 = 1 := by
  165. simp
  166. private theorem gamma_two_deriv : HasDerivAt Complex.Gamma
  167. ((1-Real.eulerMascheroniConstant : ℝ):ℂ) 2 := by
  168. convert Complex.hasDerivAt_Gamma_nat 1 using 1 <;> norm_num [harmonic_succ]; ring
  169. private theorem conductor_diff (s : ℂ) :
  170. HasDerivAt (fun z : ℂ => Complex.exp ((Real.log cubicConductorScale : ℂ)*z))
  171. (Complex.exp ((Real.log cubicConductorScale : ℂ)*s) * (Real.log cubicConductorScale : ℂ)) s := by
  172. simpa only [mul_one] using ((hasDerivAt_id s).const_mul (Real.log cubicConductorScale : ℂ)).cexp
  173. theorem completed_two_ne : completedEuler 2 ≠ 0 := by
  174. unfold completedEuler cubicEuler
  175. rw [gamma_two_value]; exact mul_ne_zero (mul_ne_zero (Complex.exp_ne_zero _) one_ne_zero) (Complex.exp_ne_zero _)
  176. /-- This is the arithmetic side of the paper's identity as the logarithmic
  177. derivative of an actual holomorphic germ. -/
  178. theorem logDeriv_completedEuler_two :
  179. logDeriv completedEuler 2 =
  180. ((Real.log cubicConductorScale + 1 - Real.eulerMascheroniConstant +
  181. ∑' n, eulerTermAtTwo n : ℝ):ℂ) := by
  182. let C := fun s : ℂ => Complex.exp ((Real.log cubicConductorScale : ℂ)*s)
  183. have hc : C 2 ≠ 0 := Complex.exp_ne_zero _
  184. have hg : Complex.Gamma 2 ≠ 0 := gamma_two_value.trans_ne one_ne_zero
  185. have hf : cubicEuler 2 ≠ 0 := Complex.exp_ne_zero _
  186. have hd := (conductor_diff 2).differentiableAt
  187. change logDeriv (fun s => (C s * Complex.Gamma s) * cubicEuler s) 2 = _
  188. rw [logDeriv_mul (f := fun s => C s * Complex.Gamma s) (g := cubicEuler) 2 (mul_ne_zero hc hg) hf (hd.mul gamma_two_deriv.differentiableAt) euler_diff,
  189. logDeriv_mul (f := C) (g := Complex.Gamma) 2 hc hg hd gamma_two_deriv.differentiableAt, logDeriv_cubicEuler_two,
  190. logDeriv_apply, logDeriv_apply, (conductor_diff 2).deriv, gamma_two_deriv.deriv, gamma_two_value]
  191. change C 2 * _ / C 2 + _ / 1 + _ = _
  192. rw [mul_div_cancel_left₀ _ hc]
  193. push_cast
  194. ring
  195. end CubicPrimeRace
  196. #print axioms CubicPrimeRace.cubicEuler_eq_tprod
  197. #print axioms CubicPrimeRace.logDeriv_cubicEuler_two
  198. #print axioms CubicPrimeRace.logDeriv_completedEuler_two