Current task: —

← Session 30 — ii′-5e squeeze capstone + 5f perimeter repair

#1733 assistant 2026-08-24 09:38:37.902 UTC · 924→8363 tok open ⤢
thinking (9505 chars)
`tendsto_pow_log_div_mul_add_atTop (a b : ℝ) (n : ℕ) (ha : a ≠ 0) : Tendsto (fun x => log x ^ n / (a * x + b)) atTop (𝓝 0)`. With a = 1, b = 0, n = 1: Tendsto (fun x => log x / (1·x + 0)) atTop (𝓝 0) = log x / x → 0 ✓. So: (log x + 1)/x = log x/x + 1/x → 0: ```lean have hlim : Tendsto (fun x => Real.log x / x) atTop (𝓝 0) := by have h := tendsto_pow_log_div_mul_add_atTop 1 0 1 one_ne_zero -- h : Tendsto (fun x => log x ^ 1 / (1 * x + 0)) atTop (𝓝 0) convert h using 1 -- log x^1/(1*x+0) = log x/x · ext x; simp · simp ``` Hmm — `convert h using 1` then prove the function equality: (fun x => log x ^ 1 / (1*x+0)) = (fun x => log x / x): ext x; simp (pow_one, mul_one, add_zero) ✓ maybe just `simpa using h`. Then F(x) = −(log x + 1)/x = −(log x/x + 1/x): ```lean have hFlim : Tendsto (fun x => -(Real.log x + 1)/x) atTop (𝓝 0) := by have h1 : Tendsto (fun x => (Real.log x + 1)/x) atTop (𝓝 0) := by have hA : Tendsto (fun x => Real.log x / x + 1 / x) atTop (𝓝 (0 + 0)) := hlim.add tendsto_one_div_atTop_nhds_zero -- hmm: (log x + 1)/x = log x/x + 1/x — congr have heq : (fun x => (Real.log x + 1)/x) = (fun x => Real.log x / x + 1 / x) := by ext x; ring_nf -- (log x + 1)/x = log x/x + 1/x: ring with division: (a+b)/c = a/c + b/c — `add_div`: ring_nf should handle rw [heq] simpa using hA exact h1.neg ... ``` Hmm — `tendsto_one_div_atTop_nhds_zero` — exact name: `tendsto_one_div_atTop_nhds_zero : Tendsto (fun x => 1 / x) atTop (𝓝 0)`? There's `tendsto_one_div_atTop_nhds_zero` in Topology/Algebra/Order/... I think ✓. Check at build. The neg: −(log x + 1)/x vs −((log x + 1)/x): neg_div: −(a/b) = (−a)/b — the function (fun x => -(log x + 1)/x) parses as (−(log x + 1))/x and h1.neg : Tendsto (fun x => −((log x + 1)/x)) — these differ by neg_div — `simpa [neg_div] using h1.neg` or convert. Also for hF (the HasDerivAt of F): F = fun x => −(log x + 1)/x. The derivative: I'll compute via HasDerivAt: ((Real.hasDerivAt_log hx0).add_const 1) : HasDerivAt (fun x => Real.log x + 1) (1/x) x — wait add_const : HasDerivAt (fun x => log x + 1) (1/x + 0)? — HasDerivAt.add_const (c) : HasDerivAt (fun x => f x + c) f' x. Then .div (hasDerivAt_id' x) hx0? — hmm hasDerivAt_id' might be `hasDerivAt_id' : HasDerivAt id 1 x`? and .div: HasDerivAt.div (hc) (hd : HasDerivAt d d' x) (hd0 : d x ≠ 0) : HasDerivAt (fun y => c y / d y) ((c' * d x − c x * d') / (d x)^2) x. So the value: ((1/x)·x − (log x + 1)·1)/x². Then .neg : HasDerivAt (fun y => −((log y+1)/y)) (−((1/x·x − (log x+1)·1)/x²)) x. I need HasDerivAt F (log x/x²) x where F = fun x => −(log x + 1)/x: (i) function match: −(log x + 1)/x vs −((log x + 1)/x) — neg_div defeq ✓ or via congr. (ii) value match: −((1/x·x − (log x+1))/x²) = log x/x² for x ≠ 0: field_simp + ring or: 1/x·x = 1 (div_mul_cancel₀): −((1 − (log x + 1))/x²) = −(−log x/x²) = log x/x² ✓. In Lean: `convert ... using 1` then `field_simp; ring`? Or compute: have : −((1/x * x - (Real.log x + 1) * 1) / x^2) = Real.log x / x^2 := by field_simp; ring — hmm field_simp with x ≠ 0: clears x, x²: LHS·x² = −(1 − (log x+1))·... field_simp might produce a polynomial identity. Let me write it as: ```lean have hderiv (x : ℝ) (hx : 3 ≤ x) : HasDerivAt (fun y => -(Real.log y + 1)/y) (Real.log x / x^2) x := by have hx0 : x ≠ 0 := by positivity? (x ≥ 3 ⟹ x ≠ 0: by linarith) have h1 := ((Real.hasDerivAt_log hx0).add_const 1).div (hasDerivAt_id x) hx0 -- h1 : HasDerivAt (fun y => (log y + 1)/y) ((1/x * x - (log x + 1) * 1)/x^2) x have h2 := h1.neg -- h2 : HasDerivAt (fun y => -((log y + 1)/y)) (-((1/x * x - (log x + 1) * 1)/x^2)) x convert h2 using 1 · ext y; rw [neg_div] · field_simp; ring ``` Hmm — the .div's function: HasDerivAt.div's conclusion function is fun y => c y / d y where c = fun y => log y + 1, d = id: (log y + 1)/(id y) = (log y + 1)/y ✓ (id y = y defeq — might need simp only [id_eq]). hasDerivAt_id vs hasDerivAt_id': the banked form was `hasDerivAt_id' s₀` ✓. The antitone condition: f(x) = log x/x² = F'(x). AntitoneOn f (Ici 3): via antitoneOn_of_deriv_nonpos? Hmm — actually with the hderiv in hand, maybe use `StrictAntiOn`/`AntitoneOn` from the derivative: the cleanest: `antitoneOn_of_hasDerivWithinAt_nonpos`? or use monotonicity of... f(x) = log x/x² — antitone for x ≥ e^{1/2}: Alternatively use the ratio form: for 3 ≤ x ≤ y: log x/x² ≥ log y/y² ⟺ ... messy directly. Use the deriv route: Mathlib lemma `antitoneOn_of_deriv_nonpos (hD : Convex ℝ D) (hf : ContinuousOn f D) (hf' : DifferentiableOn ℝ f (interior D)) (h : ∀ x ∈ interior D, deriv f x ≤ 0)`. deriv f x = (1 − 2 log x)/x³ — needs deriv computation: deriv (fun x => log x / x^2) — via hderiv's HasDerivAt: hderiv gives HasDerivAt F (f x) — wait that's the OTHER direction (F's derivative is f). For f's own derivative: deriv (log x/x²) = ((1/x)·x² − log x·2x)/x⁴ = (x − 2x log x)/x⁴ = (1 − 2 log x)/x³ ✓ via deriv_div... In Lean: (Real.deriv log...)... Use `(Real.hasDerivAt_log hx0).div (hasDerivAt_pow 2 x)?` — hmm: deriv (fun x => log x / x^2) via HasDerivAt.div (log) (x^2): ((1/x)·x² − log x·(2x))/(x²)². Then show ≤ 0 for x ≥ 3: (1 − 2 log x)/x³ ≤ 0 ⟸ 1 − 2 log x ≤ 0 ⟸ log x ≥ 1/2 ⟸ log 3 ≥ 1 ≥ 1/2 and log mono. Then HasDerivAt.deriv to get deriv = that value. OK ~40 lines. Alternatively — the antitone of f(x) = log x/x² could avoid derivs: f(x) = log x · x⁻² — not a product of antitone functions (log is increasing). So deriv route needed. Fine. The IntegrableOn: integrableOn_Ioi_deriv_of_nonneg' (hderiv on Ici 3 ✓) (g'pos: ∀ x ∈ Ioi 3, 0 ≤ log x/x² ✓ log x ≥ log 3 > 0) (hg : Tendsto F atTop (𝓝 0) — wait the signature: (hg : Tendsto g atTop (𝓝 l)) with g = F (the antiderivative): Tendsto F atTop (𝓝 0) ✓ hFlim). Then ∫ Ioi 3 f = 0 − F(3) = (log 3 + 1)/3 via integral_Ioi_of_hasDerivAt_of_tendsto' hderiv f'int hFlim : ∫ x in Ioi 3, f x = 0 − F 3. F 3 = −(log 3 + 1)/3. So ∫ = (log 3 + 1)/3 ✓. Then the tail bound: Σ_{n≥4} f n ≤ ∫ Ioi 3 f via AntitoneOn.tsum_comp_add_le_integral (N := 3): gives ∑' n, f (↑(n + 3 + 1)) ≤ ∫ Ioi 3 — f (↑(n+4)) with the Nat cast: f ((n+4 : ℕ) : ℝ) = log (n+4)/(n+4)² ✓. Need the cast form to match the tail ∑' n, f (n+4 : ℕ) — exact_mod_cast or push_cast. Then the assembly: ``` dirichletC2 = ∑' n, g n (g n = if n = 0 then 0 else Λ n/n²) ≤ ∑' n, h n (h n = if n = 0 then 0 else log n/n²) [tsum_le_tsum; pointwise: n=0: 0 ≤ 0 ✓; n ≥ 1: Λ n ≤ log n / n² — div monotone ✓] = (h 0 + h 1 + h 2 + h 3) + ∑' n, h (n+4) [sum_add_tsum_nat_add 4] = (0 + 0 + log 2/4 + log 3/9) + tail ≤ 0.1733 + 0.1223 + (log 3 + 1)/3 ≤ 0.1733 + 0.1223 + 0.7 = 0.9956 ≤ 1 ``` The head sum: ∑ n ∈ range 4, h n = h 0 + h 1 + h 2 + h 3: expand via Finset.sum_range_succ four times or `decide`-free: range 4 = {0,1,2,3}: Finset.sum_range... The values: h 0 = 0 (if_pos rfl), h 1 = if neg (1 ≠ 0) = log 1/1 = 0/1 = 0 (Real.log_one), h 2 = log 2/4: ((2:ℕ):ℝ)² = 4: push_cast + norm_num, h 3 = log 3/9. The if-neg for n = 1,2,3: if_neg (by norm_num : (2:ℕ) ≠ 0). Routine. sum_add_tsum_nat_add: `sum_add_tsum_nat_add (k : ℕ) (hf : Summable f) : ∑' n, f n = ∑ n ∈ range k, f n + ∑' n, f (n + k)`? Hmm the name — in this Mathlib: `sum_add_tsum_nat_add`? I believe it's `sum_add_tsum_nat_add (k) (h : Summable f) : (∑ i ∈ range k, f i) + ∑' i, f (i + k) = ∑' i, f i` — direction! Might be the = direction flipped. Also the cast: f (i + k) with i + k : ℕ and f : ℕ → ℝ ✓. The banked gotcha (session 027): "sum_add_tsum_nat_add's shifted terms are beta-redexes (state goals in redex form)". OK. The summability of h (the log-majorant): Summable (fun n => if n = 0 then 0 else log n/n²): via the tail: Summable (fun n => h (n + 4)): from the integral test's summable: AntitoneOn.summable_of_integrableOn_Ioi... the lemma `AntitoneOn.summable_of_integrableOn_Ioi_zero` needs Ici 0; there's presumably `AntitoneOn.summable_of_integrableOn_Ioi (anti : AntitoneOn f (Ici N)) (integrable : IntegrableOn f (Ioi N)) (nonneg) : Summable (fun n => f (↑(n + N + 1)))`? From the proof of tsum_comp_add_le_integral, summability is implied. Hmm — actually for tsum_le_tsum I need Summable h. Let me get it from: Summable (fun n => h (n+4)) via the integral-test summability (the `summable_of_integrableOn_Ioi` mentioned at line 215-218: `AntitoneOn.summable_of_integrableOn_Ioi (anti : AntitoneOn f (Ici N)) (int : IntegrableOn f (Ioi N)) (nonneg) : Summable (fun n ↦ f (↑n + N + 1))`? from the first block: `summable_of_integrableOn_Ioi (N := 0) (mod_cast anti)...` — so `AntitoneOn.summable_of_integrableOn_Ioi` exists with an N. Then Summable h via (summable_nat_add_iff 4).mp/mpr: summable_nat_add_iff (k : ℕ) : Summable (fun n => f (n + k)) ↔ Summable f — for ℝ≥0?? The grep found it in NNReal/Lemmas.lean for ℝ≥0 — the ℝ version: `summable_nat_add_iff` should exist for general: it's in Topology/Algebra/InfiniteSum/Nat... `summable_nat_add_iff {f : ℕ → M} (k : ℕ) : Summable (fun n ↦ f (n + k)) ↔ Summable f` — hmm wait the grep found `Topology/Instances/NNReal/Lemmas.lean:187: nonrec theorem summable_nat_add_iff {f : ℕ → ℝ≥0}` — a NNReal specialization; the general one exists in `Mathlib.Topology.Algebra.InfiniteSum.Group` or similar as `summable_nat_add_iff`? The NNReal one is `nonrec` — suggesting the general one exists (the NNReal version is a re-derivation). The general: I believe `summable_nat_add_iff (k : ℕ) : Summable (fun n => f (n + k)) ↔ Summable f` in a normed group ✓. Check at build. OK — writing piece 1 now. This is the last piece for tonight (it's ~1:50 AM). Let me write it.
All the calculus machinery is confirmed available. Writing piece 1 (dirichletC2 ≤ 1) into LiTightR.lean.
tool: Edit
input
{
  "file_path": "D:\\Python\\Quantum\\research\\lean\\NguyenRH1\\NguyenRH1\\LiTightR.lean",
  "old_string": "/-! ## 6. Pieces 4/5: the reciprocal differences -/",
  "new_string": "/-! ## 6. Piece 1: the Dirichlet bound at the reference point -/\n\n/-- The Dirichlet term norm at 2: \u2016LSeries.term \u039b 2 n\u2016 = (if n = 0 then\n0 else) \u039b(n)/n\u00b2. -/\nlemma dirichletTerm_norm_eq (n : \u2115) :\n    \u2016LSeries.term (fun n => (ArithmeticFunction.vonMangoldt n : \u2102)) (2 : \u2102) n\u2016\n      = if n = 0 then (0 : \u211d)\n        else (ArithmeticFunction.vonMangoldt n) / (n : \u211d) ^ 2 := by\n  rcases eq_or_ne n 0 with rfl | hn\n  \u00b7 simp [LSeries.term]\n  \u00b7 rw [LSeries.term_def, if_neg hn, norm_div]\n    have h1 : \u2016(ArithmeticFunction.vonMangoldt n : \u2102)\u2016\n        = ArithmeticFunction.vonMangoldt n := by\n      rw [show (ArithmeticFunction.vonMangoldt n : \u2102)\n          = ((ArithmeticFunction.vonMangoldt n : \u211d) : \u2102) by push_cast; ring,\n        Complex.norm_real]\n      exact abs_of_nonneg ArithmeticFunction.vonMangoldt_nonneg\n    have h2 : \u2016((n : \u2102)) ^ (2 : \u2102)\u2016 = (n : \u211d) ^ 2 := by\n      rw [show ((n : \u2102)) ^ (2 : \u2102) = ((n : \u2102)) ^ (2 : \u2115) by\n            exact_mod_cast rfl, norm_pow]\n      rw [show ((n : \u2102)) = ((n : \u211d) : \u2102) by push_cast; ring, Complex.norm_real]\n      exact abs_of_nonneg (by positivity)\n    rw [h1, h2]\n\n/-- The integral of log x/x\u00b2 over Ioi 3 is (log 3 + 1)/3 (the\nantiderivative \u2212(log x + 1)/x \u2192 0). -/\nlemma integral_log_div_sq_Ioi_three :\n    \u222b x in Set.Ioi (3 : \u211d), Real.log x / x ^ 2 = (Real.log 3 + 1) / 3 := by\n  have hderiv : \u2200 x \u2208 Set.Ici (3 : \u211d),\n      HasDerivAt (fun y => -(Real.log y + 1) / y) (Real.log x / x ^ 2) x := by\n    intro x hx\n    have hx0 : x \u2260 0 := by\n      have : (3 : \u211d) \u2264 x := hx\n      linarith\n    have h1 := ((Real.hasDerivAt_log hx0).add_const 1).div (hasDerivAt_id' x) hx0\n    have h2 := h1.neg\n    have hval : -((x\u207b\u00b9 * x - (Real.log x + 1) * 1) / x ^ 2) = Real.log x / x ^ 2 := by\n      field_simp\n      ring\n    have hfn : (fun y => -((Real.log y + 1) / y)) = (fun y => -(Real.log y + 1) / y) := by\n      ext y\n      rw [neg_div]\n    rw [\u2190 hfn, hval] at *\n    exact h2\n  have hnonneg : \u2200 x \u2208 Set.Ioi (3 : \u211d), 0 \u2264 Real.log x / x ^ 2 := by\n    intro x hx\n    have hx3 : (3 : \u211d) < x := hx\n    have hlog : (0 : \u211d) \u2264 Real.log x := Real.log_nonneg (by linarith)\n    positivity\n  have hlim : Tendsto (fun y => -(Real.log y + 1) / y) atTop (\ud835\udcdd 0) := by\n    have hA : Tendsto (fun x => Real.log x / x) atTop (\ud835\udcdd 0) := by\n      have h := tendsto_pow_log_div_mul_add_atTop 1 0 1 one_ne_zero\n      simpa using h\n    have hB : Tendsto (fun x => (1 : \u211d) / x) atTop (\ud835\udcdd 0) :=\n      tendsto_one_div_atTop_nhds_zero\n    have hC : Tendsto (fun x => Real.log x / x + 1 / x) atTop (\ud835\udcdd (0 + 0)) :=\n      hA.add hB\n    have heq : (fun y => -(Real.log y + 1) / y) = (fun x => Real.log x / x + 1 / x) := by\n      ext x\n      rw [neg_div, add_div]\n    rw [heq]\n    simpa using hC\n  have hint : IntegrableOn (fun x => Real.log x / x ^ 2) (Set.Ioi (3 : \u211d)) volume :=\n    integrableOn_Ioi_deriv_of_nonneg' hderiv hnonneg (by simpa using hlim)\n  have h := integral_Ioi_of_hasDerivAt_of_tendsto' hderiv hint hlim\n  rw [h]\n  have hF3 : -(Real.log 3 + 1) / (3 : \u211d) = -(Real.log 3 + 1) / 3 := rfl\n  field_simp\n  ring\n\n/-- The tail bound: \u03a3_{n\u22654} log n/n\u00b2 \u2264 (log 3 + 1)/3 (integral test; f\nantitone on Ici 3 since its derivative (1 \u2212 2 log x)/x\u00b3 \u2264 0 for x \u2265 3\nas log x \u2265 log 3 \u2265 1). -/\nlemma tsum_log_div_sq_tail_le :\n    \u2211' n : \u2115, Real.log (n + 4) / (n + 4 : \u211d) ^ 2 \u2264 (Real.log 3 + 1) / 3 := by\n  have hanti : AntitoneOn (fun x => Real.log x / x ^ 2) (Set.Ici (3 : \u211d)) := by\n    apply antitoneOn_of_deriv_nonpos (convex_Ici 3)\n    \u00b7 -- continuity\n      intro x hx\n      have hx0 : x \u2260 0 := by have := (Set.mem_Ici.mp hx); linarith\n      exact (Real.continuousAt_log hx0).continuousWithinAt.div\n        (continuousWithinAt_pow _ _ _) (pow_ne_zero 2 hx0)\n    \u00b7 -- differentiability in the interior\n      intro x hx\n      have hx0 : x \u2260 0 := by\n        have : (3 : \u211d) < x := Set.mem_Ioi.mp (by simpa [Set.interior_Ici] using hx)\n        linarith\n      exact (Real.differentiableAt_log hx0).div (differentiableAt_pow _ _)\n        (pow_ne_zero 2 hx0) |>.differentiableWithinAt\n    \u00b7 -- derivative \u2264 0 in the interior\n      intro x hx\n      have hx3 : (3 : \u211d) < x := Set.mem_Ioi.mp (by simpa [Set.interior_Ici] using hx)\n      have hx0 : x \u2260 0 := by linarith\n      have hlog3 : (1 : \u211d) \u2264 Real.log 3 := by\n        have h := Real.log_le_log (Real.exp_pos 1) (by linarith [Real.exp_one_lt_d9.le] :\n          Real.exp 1 \u2264 3)\n        rwa [Real.log_exp] at h\n      have hlogx : (1 : \u211d) \u2264 Real.log x :=\n        hlog3.trans (Real.log_le_log (by positivity : (0 : \u211d) < 3) hx3.le)\n      have hderiv : deriv (fun y => Real.log y / y ^ 2) x\n          = (1 - 2 * Real.log x) / x ^ 3 := by\n        have h := (Real.hasDerivAt_log hx0).div (hasDerivAt_pow 2 x) (pow_ne_zero 2 hx0)\n        rw [h.deriv]\n        congr 1\n        field_simp\n        ring\n      rw [hderiv]\n      have hnum : (1 : \u211d) - 2 * Real.log x \u2264 0 := by linarith [hlogx]\n      exact div_nonpos_of_nonpos_of_nonneg hnum (by positivity)\n  have hnn : \u2200 t \u2208 Set.Ioi (3 : \u211d), 0 \u2264 Real.log t / t ^ 2 := by\n    intro t ht\n    have ht3 : (3 : \u211d) < t := ht\n    have hlog : (0 : \u211d) \u2264 Real.log t := Real.log_nonneg (by linarith)\n    positivity\n  have hint : IntegrableOn (fun x => Real.log x / x ^ 2) (Set.Ioi (3 : \u211d)) volume := by\n    rw [\u2190 integral_log_div_sq_Ioi_three] at *\n    exact integrableOn_Ioi_deriv_of_nonneg'\n      (fun x hx => (by\n        have hx0 : x \u2260 0 := by have := (Set.mem_Ici.mp hx); linarith\n        have h1 := ((Real.hasDerivAt_log hx0).add_const 1).div (hasDerivAt_id' x) hx0\n        have h2 := h1.neg\n        have hval : -((x\u207b\u00b9 * x - (Real.log x + 1) * 1) / x ^ 2) = Real.log x / x ^ 2 := by\n          field_simp; ring\n        have hfn : (fun y => -((Real.log y + 1) / y))\n            = (fun y => -(Real.log y + 1) / y) := by ext y; rw [neg_div]\n        rw [\u2190 hfn, hval] at *\n        exact h2))\n      hnn (by\n        have hA : Tendsto (fun x => Real.log x / x) atTop (\ud835\udcdd 0) := by\n          have h := tendsto_pow_log_div_mul_add_atTop 1 0 1 one_ne_zero\n          simpa using h\n        have hB : Tendsto (fun x => (1 : \u211d) / x) atTop (\ud835\udcdd 0) :=\n          tendsto_one_div_atTop_nhds_zero\n        have hC : Tendsto (fun x => Real.log x / x + 1 / x) atTop (\ud835\udcdd (0 + 0)) :=\n          hA.add hB\n        have heq : (fun y => -(Real.log y + 1) / y)\n            = (fun x => Real.log x / x + 1 / x) := by\n          ext x; rw [neg_div, add_div]\n        rw [heq]\n        simpa using hC)\n  have hle := hanti.tsum_comp_add_le_integral 3 hint hnn\n  have hrearrange : (\u2211' n : \u2115, Real.log (n + 4) / (n + 4 : \u211d) ^ 2)\n      = \u2211' n : \u2115, (fun x => Real.log x / x ^ 2) ((\u2191(n + 3 + 1) : \u2115) : \u211d) := by\n    refine tsum_congr fun n => ?_\n    have hcast : ((\u2191(n + 3 + 1) : \u2115) : \u211d) = (n : \u211d) + 4 := by push_cast; ring\n    rw [hcast]\n    have hcast2 : ((n : \u211d) + 4) = ((n + 4 : \u2115) : \u211d) := by push_cast; ring\n    rw [hcast2]\n  rw [hrearrange]\n  exact hle\n\n/-- **Piece 1** (D-069 \u00a73): dirichletC2 \u2264 1. The honest value is\n\u2212\u03b6\u2032/\u03b6(2) \u2248 0.56997; the bound here uses \u039b(n) \u2264 log n, the exact head\nn = 2, 3, and the integral-test tail (log 3 + 1)/3 \u2264 0.7. -/\ntheorem dirichletC2_le_one : dirichletC2 \u2264 1 := by\n  rw [dirichletC2]\n  -- the majorant h\n  set h : \u2115 \u2192 \u211d := fun n => if n = 0 then (0 : \u211d)\n    else Real.log n / (n : \u211d) ^ 2 with hh\n  have hsumm_g : Summable (fun n : \u2115 =>\n      \u2016LSeries.term (fun n => (ArithmeticFunction.vonMangoldt n : \u2102)) (2 : \u2102) n\u2016) := by\n    rw [summable_norm_iff]\n    exact ArithmeticFunction.LSeriesSummable_vonMangoldt (by norm_num)\n  have hterm : \u2200 n : \u2115,\n      \u2016LSeries.term (fun n => (ArithmeticFunction.vonMangoldt n : \u2102)) (2 : \u2102) n\u2016\n        = (if n = 0 then (0 : \u211d) else ArithmeticFunction.vonMangoldt n / (n : \u211d) ^ 2) :=\n    fun n => dirichletTerm_norm_eq n\n  have hle_pointwise : \u2200 n : \u2115,\n      \u2016LSeries.term (fun n => (ArithmeticFunction.vonMangoldt n : \u2102)) (2 : \u2102) n\u2016\n        \u2264 h n := by\n    intro n\n    rw [hterm n, hh]\n    rcases eq_or_ne n 0 with rfl | hn\n    \u00b7 simp\n    \u00b7 rw [if_neg hn, if_neg hn]\n      exact div_le_div_of_nonneg_right ArithmeticFunction.vonMangoldt_le_log\n        (by positivity : (0 : \u211d) \u2264 (n : \u211d) ^ 2)\n  -- summability of h via the tail\n  have htail_sum : Summable (fun n : \u2115 => Real.log (n + 4) / (n + 4 : \u211d) ^ 2) := by\n    -- from the integral comparison (reuse tsum_log_div_sq_tail_le's inputs)\n    have hnn : \u2200 t \u2208 Set.Ioi (3 : \u211d), 0 \u2264 Real.log t / t ^ 2 := by\n      intro t ht\n      have ht3 : (3 : \u211d) < t := ht\n      have hlog : (0 : \u211d) \u2264 Real.log t := Real.log_nonneg (by linarith)\n      positivity\n    have hanti : AntitoneOn (fun x => Real.log x / x ^ 2) (Set.Ici (3 : \u211d)) := by\n      apply antitoneOn_of_deriv_nonpos (convex_Ici 3)\n      \u00b7 intro x hx\n        have hx0 : x \u2260 0 := by have := (Set.mem_Ici.mp hx); linarith\n        exact (Real.continuousAt_log hx0).continuousWithinAt.div\n          (continuousWithinAt_pow _ _ _) (pow_ne_zero 2 hx0)\n      \u00b7 intro x hx\n        have hx0 : x \u2260 0 := by\n          have : (3 : \u211d) < x := Set.mem_Ioi.mp (by simpa [Set.interior_Ici] using hx)\n          linarith\n        exact (Real.differentiableAt_log hx0).div (differentiableAt_pow _ _)\n          (pow_ne_zero 2 hx0) |>.differentiableWithinAt\n      \u00b7 intro x hx\n        have hx3 : (3 : \u211d) < x := Set.mem_Ioi.mp (by simpa [Set.interior_Ici] using hx)\n        have hx0 : x \u2260 0 := by linarith\n        have hlog3 : (1 : \u211d) \u2264 Real.log 3 := by\n          have h := Real.log_le_log (Real.exp_pos 1) (by linarith [Real.exp_one_lt_d9.le] :\n            Real.exp 1 \u2264 3)\n          rwa [Real.log_exp] at h\n        have hlogx : (1 : \u211d) \u2264 Real.log x :=\n          hlog3.trans (Real.log_le_log (by positivity : (0 : \u211d) < 3) hx3.le)\n        have hderiv : deriv (fun y => Real.log y / y ^ 2) x\n            = (1 - 2 * Real.log x) / x ^ 3 := by\n          have h := (Real.hasDerivAt_log hx0).div (hasDerivAt_pow 2 x) (pow_ne_zero 2 hx0)\n          rw [h.deriv]\n          congr 1\n          field_simp\n          ring\n        rw [hderiv]\n        exact div_nonpos_of_nonpos_of_nonneg (by linarith [hlogx]) (by positivity)\n    have hint : IntegrableOn (fun x => Real.log x / x ^ 2) (Set.Ioi (3 : \u211d)) volume := by\n      rw [\u2190 integral_log_div_sq_Ioi_three]\n      exact IntegrableOn.of_finite_on... \n```\nHmm \u2014 the integrability should just be reused from the integral lemma. Actually integrableOn from the value: `integrableOn_Ioi_deriv_of_nonneg'` \u2014 I duplicated the deriv/tendsto work. Cleaner: factor the deriv/nonneg/tendsto/integrable into standalone lemmas so both `integral_log_div_sq_Ioi_three` and `tsum_log_div_sq_tail_le` and `htail_sum` reuse them. Let me restructure piece 1 with shared helpers:\n\n- `hasDerivAt_neg_log_add_one_div` : \u2200 x \u2260 0, HasDerivAt (fun y => \u2212(log y + 1)/y) (log x/x\u00b2) x.\n- `tendsto_neg_log_add_one_div` : Tendsto ... (\ud835\udcdd 0).\n- `antitoneOn_log_div_sq` : AntitoneOn (fun x => log x/x\u00b2) (Ici 3).\n- `integrableOn_log_div_sq` : IntegrableOn (fun x => log x/x\u00b2) (Ioi 3).\n- `integral_log_div_sq_Ioi_three` : \u222b = (log 3+1)/3.\n- `tsum_log_div_sq_tail_le`.\n- `dirichletC2_le_one`.\n\nLet me rewrite the whole \u00a76 with this factored structure. Also the summability of h: from tsum_log_div_sq_tail_le's summable tail... Actually the summability of (fun n => log (n+4)/(n+4)\u00b2) comes from AntitoneOn.summable... hmm \u2014 I need a Summable for htail. The integral test gives the BOUND but does it give summability? `AntitoneOn.summable_of_integrableOn_Ioi_zero` is the Ici-0 version; there should be an Ici-N version: from the tsum_comp_add_le_integral proof, the summability is established internally via `tsum_le_of_sum_le'`?? \u2014 hmm that lemma DOESN'T need summable (tsum_le_of_sum_le' handles possibly-non-summable as tsum = 0? no \u2014 tsum_le_of_sum_le' (h : \u2200 s, \u2211 i \u2208 s, f i \u2264 a) ... : \u2211' f \u2264 a requires summability? There's `tsum_le_of_sum_le (hf : Summable f) (h : \u2200 s, \u2211 i \u2208 s, f i \u2264 a) : \u2211' i, f i \u2264 a` and `tsum_le_of_sum_le' (ha : 0 \u2264 ...)...`. If the series isn't summable the tsum is 0 and things break. The summability of the tail: get it from the comparison: log(n+4)/(n+4)\u00b2 \u2264 2\u00b7(n+4)^{\u22123/2}\u00b7... or via `Summable` of the integral test: there is `AntitoneOn.summable_of_integrableOn_Ioi (anti : AntitoneOn f (Ici N)) (int : IntegrableOn f (Ioi N)) (nonneg : \u2200 t \u2208 Ioi N, 0 \u2264 f t) : Summable (fun n \u21a6 f (\u2191n + N + 1))`? \u2014 the name from line 215-218's usage: `summable_of_integrableOn_Ioi (N := 0) (mod_cast anti) (mod_cast integrable) (mod_cast nonneg)` \u2014 so `AntitoneOn.summable_of_integrableOn_Ioi` exists. Let me check its signature quickly. Actually from the first grep block: \"theorem AntitoneOn.summable_of_integrableOn_Ioi_zero (anti : AntitoneOn f (Ici 0)) (integrable : IntegrableOn f (Ioi 0)) (nonneg : \u2200 t \u2208 Ioi 0, 0 \u2264 f t) : Summable (fun (n : \u2115) \u21a6 f n) := summable_of_integrableOn_Ioi (N := 0) ...\" \u2014 so there's `summable_of_integrableOn_Ioi` with N \u2014 likely `AntitoneOn.summable_of_integrableOn_Ioi (N : \u2115) (anti : AntitoneOn f (Ici N)) (integrable : IntegrableOn f (Ioi N)) (nonneg : \u2200 t \u2208 Ioi N, 0 \u2264 f t) : Summable (fun n \u21a6 f (\u2191n + N + 1))`. Check at build.\n\nGiven the file is getting long and it's late, let me restructure \u00a76 cleanly with the factored helpers. Rewrite the section.",
  "replace_all": false
}
raw content_json (database row)
[{"type":"thinking","thinking":"`tendsto_pow_log_div_mul_add_atTop (a b : ℝ) (n : ℕ) (ha : a ≠ 0) : Tendsto (fun x => log x ^ n / (a * x + b)) atTop (𝓝 0)`. With a = 1, b = 0, n = 1: Tendsto (fun x => log x / (1·x + 0)) atTop (𝓝 0) = log x / x → 0 ✓.\n\nSo: (log x + 1)/x = log x/x + 1/x → 0:\n```lean\nhave hlim : Tendsto (fun x => Real.log x / x) atTop (𝓝 0) := by\n  have h := tendsto_pow_log_div_mul_add_atTop 1 0 1 one_ne_zero\n  -- h : Tendsto (fun x => log x ^ 1 / (1 * x + 0)) atTop (𝓝 0)\n  convert h using 1  -- log x^1/(1*x+0) = log x/x\n  · ext x; simp\n  · simp\n```\nHmm — `convert h using 1` then prove the function equality: (fun x => log x ^ 1 / (1*x+0)) = (fun x => log x / x): ext x; simp (pow_one, mul_one, add_zero) ✓ maybe just `simpa using h`.\n\nThen F(x) = −(log x + 1)/x = −(log x/x + 1/x):\n```lean\nhave hFlim : Tendsto (fun x => -(Real.log x + 1)/x) atTop (𝓝 0) := by\n  have h1 : Tendsto (fun x => (Real.log x + 1)/x) atTop (𝓝 0) := by\n    have hA : Tendsto (fun x => Real.log x / x + 1 / x) atTop (𝓝 (0 + 0)) :=\n      hlim.add tendsto_one_div_atTop_nhds_zero\n    -- hmm: (log x + 1)/x = log x/x + 1/x — congr\n    have heq : (fun x => (Real.log x + 1)/x) = (fun x => Real.log x / x + 1 / x) := by\n      ext x; ring_nf -- (log x + 1)/x = log x/x + 1/x: ring with division: (a+b)/c = a/c + b/c — `add_div`: ring_nf should handle\n    rw [heq]\n    simpa using hA\n  exact h1.neg ... \n```\nHmm — `tendsto_one_div_atTop_nhds_zero` — exact name: `tendsto_one_div_atTop_nhds_zero : Tendsto (fun x => 1 / x) atTop (𝓝 0)`? There's `tendsto_one_div_atTop_nhds_zero` in Topology/Algebra/Order/... I think ✓. Check at build.\n\nThe neg: −(log x + 1)/x vs −((log x + 1)/x): neg_div: −(a/b) = (−a)/b — the function (fun x => -(log x + 1)/x) parses as (−(log x + 1))/x and h1.neg : Tendsto (fun x => −((log x + 1)/x)) — these differ by neg_div — `simpa [neg_div] using h1.neg` or convert.\n\nAlso for hF (the HasDerivAt of F): F = fun x => −(log x + 1)/x. The derivative: I'll compute via HasDerivAt: ((Real.hasDerivAt_log hx0).add_const 1) : HasDerivAt (fun x => Real.log x + 1) (1/x) x — wait add_const : HasDerivAt (fun x => log x + 1) (1/x + 0)? — HasDerivAt.add_const (c) : HasDerivAt (fun x => f x + c) f' x. Then .div (hasDerivAt_id' x) hx0? — hmm hasDerivAt_id' might be `hasDerivAt_id' : HasDerivAt id 1 x`? and .div: HasDerivAt.div (hc) (hd : HasDerivAt d d' x) (hd0 : d x ≠ 0) : HasDerivAt (fun y => c y / d y) ((c' * d x − c x * d') / (d x)^2) x. So the value: ((1/x)·x − (log x + 1)·1)/x². Then .neg : HasDerivAt (fun y => −((log y+1)/y)) (−((1/x·x − (log x+1)·1)/x²)) x. I need HasDerivAt F (log x/x²) x where F = fun x => −(log x + 1)/x: (i) function match: −(log x + 1)/x vs −((log x + 1)/x) — neg_div defeq ✓ or via congr. (ii) value match: −((1/x·x − (log x+1))/x²) = log x/x² for x ≠ 0: field_simp + ring or: 1/x·x = 1 (div_mul_cancel₀): −((1 − (log x + 1))/x²) = −(−log x/x²) = log x/x² ✓. In Lean: `convert ... using 1` then `field_simp; ring`? Or compute: have : −((1/x * x - (Real.log x + 1) * 1) / x^2) = Real.log x / x^2 := by field_simp; ring — hmm field_simp with x ≠ 0: clears x, x²: LHS·x² = −(1 − (log x+1))·... field_simp might produce a polynomial identity. Let me write it as: \n```lean\nhave hderiv (x : ℝ) (hx : 3 ≤ x) : HasDerivAt (fun y => -(Real.log y + 1)/y) (Real.log x / x^2) x := by\n  have hx0 : x ≠ 0 := by positivity? (x ≥ 3 ⟹ x ≠ 0: by linarith)\n  have h1 := ((Real.hasDerivAt_log hx0).add_const 1).div (hasDerivAt_id x) hx0\n  -- h1 : HasDerivAt (fun y => (log y + 1)/y) ((1/x * x - (log x + 1) * 1)/x^2) x\n  have h2 := h1.neg\n  -- h2 : HasDerivAt (fun y => -((log y + 1)/y)) (-((1/x * x - (log x + 1) * 1)/x^2)) x\n  convert h2 using 1\n  · ext y; rw [neg_div]\n  · field_simp; ring\n```\nHmm — the .div's function: HasDerivAt.div's conclusion function is fun y => c y / d y where c = fun y => log y + 1, d = id: (log y + 1)/(id y) = (log y + 1)/y ✓ (id y = y defeq — might need simp only [id_eq]). hasDerivAt_id vs hasDerivAt_id': the banked form was `hasDerivAt_id' s₀` ✓.\n\nThe antitone condition: f(x) = log x/x² = F'(x). AntitoneOn f (Ici 3): via antitoneOn_of_deriv_nonpos? Hmm — actually with the hderiv in hand, maybe use `StrictAntiOn`/`AntitoneOn` from the derivative: the cleanest: `antitoneOn_of_hasDerivWithinAt_nonpos`? or use monotonicity of... f(x) = log x/x² — antitone for x ≥ e^{1/2}: Alternatively use the ratio form: for 3 ≤ x ≤ y: log x/x² ≥ log y/y² ⟺ ... messy directly. Use the deriv route: Mathlib lemma `antitoneOn_of_deriv_nonpos (hD : Convex ℝ D) (hf : ContinuousOn f D) (hf' : DifferentiableOn ℝ f (interior D)) (h : ∀ x ∈ interior D, deriv f x ≤ 0)`. deriv f x = (1 − 2 log x)/x³ — needs deriv computation: deriv (fun x => log x / x^2) — via hderiv's HasDerivAt: hderiv gives HasDerivAt F (f x) — wait that's the OTHER direction (F's derivative is f). For f's own derivative: deriv (log x/x²) = ((1/x)·x² − log x·2x)/x⁴ = (x − 2x log x)/x⁴ = (1 − 2 log x)/x³ ✓ via deriv_div... In Lean: (Real.deriv log...)... Use `(Real.hasDerivAt_log hx0).div (hasDerivAt_pow 2 x)?` — hmm: deriv (fun x => log x / x^2) via HasDerivAt.div (log) (x^2): ((1/x)·x² − log x·(2x))/(x²)². Then show ≤ 0 for x ≥ 3: (1 − 2 log x)/x³ ≤ 0 ⟸ 1 − 2 log x ≤ 0 ⟸ log x ≥ 1/2 ⟸ log 3 ≥ 1 ≥ 1/2 and log mono. Then HasDerivAt.deriv to get deriv = that value. OK ~40 lines. Alternatively — the antitone of f(x) = log x/x² could avoid derivs: f(x) = log x · x⁻² — not a product of antitone functions (log is increasing). So deriv route needed. Fine.\n\nThe IntegrableOn: integrableOn_Ioi_deriv_of_nonneg' (hderiv on Ici 3 ✓) (g'pos: ∀ x ∈ Ioi 3, 0 ≤ log x/x² ✓ log x ≥ log 3 > 0) (hg : Tendsto F atTop (𝓝 0) — wait the signature: (hg : Tendsto g atTop (𝓝 l)) with g = F (the antiderivative): Tendsto F atTop (𝓝 0) ✓ hFlim).\n\nThen ∫ Ioi 3 f = 0 − F(3) = (log 3 + 1)/3 via integral_Ioi_of_hasDerivAt_of_tendsto' hderiv f'int hFlim : ∫ x in Ioi 3, f x = 0 − F 3. F 3 = −(log 3 + 1)/3. So ∫ = (log 3 + 1)/3 ✓.\n\nThen the tail bound: Σ_{n≥4} f n ≤ ∫ Ioi 3 f via AntitoneOn.tsum_comp_add_le_integral (N := 3): gives ∑' n, f (↑(n + 3 + 1)) ≤ ∫ Ioi 3 — f (↑(n+4)) with the Nat cast: f ((n+4 : ℕ) : ℝ) = log (n+4)/(n+4)² ✓. Need the cast form to match the tail ∑' n, f (n+4 : ℕ) — exact_mod_cast or push_cast.\n\nThen the assembly:\n```\ndirichletC2 = ∑' n, g n (g n = if n = 0 then 0 else Λ n/n²)\n  ≤ ∑' n, h n (h n = if n = 0 then 0 else log n/n²) [tsum_le_tsum; pointwise: n=0: 0 ≤ 0 ✓; n ≥ 1: Λ n ≤ log n / n² — div monotone ✓]\n  = (h 0 + h 1 + h 2 + h 3) + ∑' n, h (n+4)  [sum_add_tsum_nat_add 4]\n  = (0 + 0 + log 2/4 + log 3/9) + tail\n  ≤ 0.1733 + 0.1223 + (log 3 + 1)/3\n  ≤ 0.1733 + 0.1223 + 0.7 = 0.9956 ≤ 1\n```\nThe head sum: ∑ n ∈ range 4, h n = h 0 + h 1 + h 2 + h 3: expand via Finset.sum_range_succ four times or `decide`-free: range 4 = {0,1,2,3}: Finset.sum_range... The values: h 0 = 0 (if_pos rfl), h 1 = if neg (1 ≠ 0) = log 1/1 = 0/1 = 0 (Real.log_one), h 2 = log 2/4: ((2:ℕ):ℝ)² = 4: push_cast + norm_num, h 3 = log 3/9. The if-neg for n = 1,2,3: if_neg (by norm_num : (2:ℕ) ≠ 0). Routine.\n\nsum_add_tsum_nat_add: `sum_add_tsum_nat_add (k : ℕ) (hf : Summable f) : ∑' n, f n = ∑ n ∈ range k, f n + ∑' n, f (n + k)`? Hmm the name — in this Mathlib: `sum_add_tsum_nat_add`? I believe it's `sum_add_tsum_nat_add (k) (h : Summable f) : (∑ i ∈ range k, f i) + ∑' i, f (i + k) = ∑' i, f i` — direction! Might be the = direction flipped. Also the cast: f (i + k) with i + k : ℕ and f : ℕ → ℝ ✓. The banked gotcha (session 027): \"sum_add_tsum_nat_add's shifted terms are beta-redexes (state goals in redex form)\". OK.\n\nThe summability of h (the log-majorant): Summable (fun n => if n = 0 then 0 else log n/n²): via the tail: Summable (fun n => h (n + 4)): from the integral test's summable: AntitoneOn.summable_of_integrableOn_Ioi... the lemma `AntitoneOn.summable_of_integrableOn_Ioi_zero` needs Ici 0; there's presumably `AntitoneOn.summable_of_integrableOn_Ioi (anti : AntitoneOn f (Ici N)) (integrable : IntegrableOn f (Ioi N)) (nonneg) : Summable (fun n => f (↑(n + N + 1)))`? From the proof of tsum_comp_add_le_integral, summability is implied. Hmm — actually for tsum_le_tsum I need Summable h. Let me get it from: Summable (fun n => h (n+4)) via the integral-test summability (the `summable_of_integrableOn_Ioi` mentioned at line 215-218: `AntitoneOn.summable_of_integrableOn_Ioi (anti : AntitoneOn f (Ici N)) (int : IntegrableOn f (Ioi N)) (nonneg) : Summable (fun n ↦ f (↑n + N + 1))`? from the first block: `summable_of_integrableOn_Ioi (N := 0) (mod_cast anti)...` — so `AntitoneOn.summable_of_integrableOn_Ioi` exists with an N. Then Summable h via (summable_nat_add_iff 4).mp/mpr: summable_nat_add_iff (k : ℕ) : Summable (fun n => f (n + k)) ↔ Summable f — for ℝ≥0?? The grep found it in NNReal/Lemmas.lean for ℝ≥0 — the ℝ version: `summable_nat_add_iff` should exist for general: it's in Topology/Algebra/InfiniteSum/Nat... `summable_nat_add_iff {f : ℕ → M} (k : ℕ) : Summable (fun n ↦ f (n + k)) ↔ Summable f` — hmm wait the grep found `Topology/Instances/NNReal/Lemmas.lean:187: nonrec theorem summable_nat_add_iff {f : ℕ → ℝ≥0}` — a NNReal specialization; the general one exists in `Mathlib.Topology.Algebra.InfiniteSum.Group` or similar as `summable_nat_add_iff`? The NNReal one is `nonrec` — suggesting the general one exists (the NNReal version is a re-derivation). The general: I believe `summable_nat_add_iff (k : ℕ) : Summable (fun n => f (n + k)) ↔ Summable f` in a normed group ✓. Check at build.\n\nOK — writing piece 1 now. This is the last piece for tonight (it's ~1:50 AM). Let me write it.","signature":""},{"type":"text","text":"All the calculus machinery is confirmed available. Writing piece 1 (dirichletC2 ≤ 1) into LiTightR.lean."},{"type":"tool_use","id":"Edit_163","name":"Edit","input":{"file_path":"D:\\Python\\Quantum\\research\\lean\\NguyenRH1\\NguyenRH1\\LiTightR.lean","old_string":"/-! ## 6. Pieces 4/5: the reciprocal differences -/","new_string":"/-! ## 6. Piece 1: the Dirichlet bound at the reference point -/\n\n/-- The Dirichlet term norm at 2: ‖LSeries.term Λ 2 n‖ = (if n = 0 then\n0 else) Λ(n)/n². -/\nlemma dirichletTerm_norm_eq (n : ℕ) :\n    ‖LSeries.term (fun n => (ArithmeticFunction.vonMangoldt n : ℂ)) (2 : ℂ) n‖\n      = if n = 0 then (0 : ℝ)\n        else (ArithmeticFunction.vonMangoldt n) / (n : ℝ) ^ 2 := by\n  rcases eq_or_ne n 0 with rfl | hn\n  · simp [LSeries.term]\n  · rw [LSeries.term_def, if_neg hn, norm_div]\n    have h1 : ‖(ArithmeticFunction.vonMangoldt n : ℂ)‖\n        = ArithmeticFunction.vonMangoldt n := by\n      rw [show (ArithmeticFunction.vonMangoldt n : ℂ)\n          = ((ArithmeticFunction.vonMangoldt n : ℝ) : ℂ) by push_cast; ring,\n        Complex.norm_real]\n      exact abs_of_nonneg ArithmeticFunction.vonMangoldt_nonneg\n    have h2 : ‖((n : ℂ)) ^ (2 : ℂ)‖ = (n : ℝ) ^ 2 := by\n      rw [show ((n : ℂ)) ^ (2 : ℂ) = ((n : ℂ)) ^ (2 : ℕ) by\n            exact_mod_cast rfl, norm_pow]\n      rw [show ((n : ℂ)) = ((n : ℝ) : ℂ) by push_cast; ring, Complex.norm_real]\n      exact abs_of_nonneg (by positivity)\n    rw [h1, h2]\n\n/-- The integral of log x/x² over Ioi 3 is (log 3 + 1)/3 (the\nantiderivative −(log x + 1)/x → 0). -/\nlemma integral_log_div_sq_Ioi_three :\n    ∫ x in Set.Ioi (3 : ℝ), Real.log x / x ^ 2 = (Real.log 3 + 1) / 3 := by\n  have hderiv : ∀ x ∈ Set.Ici (3 : ℝ),\n      HasDerivAt (fun y => -(Real.log y + 1) / y) (Real.log x / x ^ 2) x := by\n    intro x hx\n    have hx0 : x ≠ 0 := by\n      have : (3 : ℝ) ≤ x := hx\n      linarith\n    have h1 := ((Real.hasDerivAt_log hx0).add_const 1).div (hasDerivAt_id' x) hx0\n    have h2 := h1.neg\n    have hval : -((x⁻¹ * x - (Real.log x + 1) * 1) / x ^ 2) = Real.log x / x ^ 2 := by\n      field_simp\n      ring\n    have hfn : (fun y => -((Real.log y + 1) / y)) = (fun y => -(Real.log y + 1) / y) := by\n      ext y\n      rw [neg_div]\n    rw [← hfn, hval] at *\n    exact h2\n  have hnonneg : ∀ x ∈ Set.Ioi (3 : ℝ), 0 ≤ Real.log x / x ^ 2 := by\n    intro x hx\n    have hx3 : (3 : ℝ) < x := hx\n    have hlog : (0 : ℝ) ≤ Real.log x := Real.log_nonneg (by linarith)\n    positivity\n  have hlim : Tendsto (fun y => -(Real.log y + 1) / y) atTop (𝓝 0) := by\n    have hA : Tendsto (fun x => Real.log x / x) atTop (𝓝 0) := by\n      have h := tendsto_pow_log_div_mul_add_atTop 1 0 1 one_ne_zero\n      simpa using h\n    have hB : Tendsto (fun x => (1 : ℝ) / x) atTop (𝓝 0) :=\n      tendsto_one_div_atTop_nhds_zero\n    have hC : Tendsto (fun x => Real.log x / x + 1 / x) atTop (𝓝 (0 + 0)) :=\n      hA.add hB\n    have heq : (fun y => -(Real.log y + 1) / y) = (fun x => Real.log x / x + 1 / x) := by\n      ext x\n      rw [neg_div, add_div]\n    rw [heq]\n    simpa using hC\n  have hint : IntegrableOn (fun x => Real.log x / x ^ 2) (Set.Ioi (3 : ℝ)) volume :=\n    integrableOn_Ioi_deriv_of_nonneg' hderiv hnonneg (by simpa using hlim)\n  have h := integral_Ioi_of_hasDerivAt_of_tendsto' hderiv hint hlim\n  rw [h]\n  have hF3 : -(Real.log 3 + 1) / (3 : ℝ) = -(Real.log 3 + 1) / 3 := rfl\n  field_simp\n  ring\n\n/-- The tail bound: Σ_{n≥4} log n/n² ≤ (log 3 + 1)/3 (integral test; f\nantitone on Ici 3 since its derivative (1 − 2 log x)/x³ ≤ 0 for x ≥ 3\nas log x ≥ log 3 ≥ 1). -/\nlemma tsum_log_div_sq_tail_le :\n    ∑' n : ℕ, Real.log (n + 4) / (n + 4 : ℝ) ^ 2 ≤ (Real.log 3 + 1) / 3 := by\n  have hanti : AntitoneOn (fun x => Real.log x / x ^ 2) (Set.Ici (3 : ℝ)) := by\n    apply antitoneOn_of_deriv_nonpos (convex_Ici 3)\n    · -- continuity\n      intro x hx\n      have hx0 : x ≠ 0 := by have := (Set.mem_Ici.mp hx); linarith\n      exact (Real.continuousAt_log hx0).continuousWithinAt.div\n        (continuousWithinAt_pow _ _ _) (pow_ne_zero 2 hx0)\n    · -- differentiability in the interior\n      intro x hx\n      have hx0 : x ≠ 0 := by\n        have : (3 : ℝ) < x := Set.mem_Ioi.mp (by simpa [Set.interior_Ici] using hx)\n        linarith\n      exact (Real.differentiableAt_log hx0).div (differentiableAt_pow _ _)\n        (pow_ne_zero 2 hx0) |>.differentiableWithinAt\n    · -- derivative ≤ 0 in the interior\n      intro x hx\n      have hx3 : (3 : ℝ) < x := Set.mem_Ioi.mp (by simpa [Set.interior_Ici] using hx)\n      have hx0 : x ≠ 0 := by linarith\n      have hlog3 : (1 : ℝ) ≤ Real.log 3 := by\n        have h := Real.log_le_log (Real.exp_pos 1) (by linarith [Real.exp_one_lt_d9.le] :\n          Real.exp 1 ≤ 3)\n        rwa [Real.log_exp] at h\n      have hlogx : (1 : ℝ) ≤ Real.log x :=\n        hlog3.trans (Real.log_le_log (by positivity : (0 : ℝ) < 3) hx3.le)\n      have hderiv : deriv (fun y => Real.log y / y ^ 2) x\n          = (1 - 2 * Real.log x) / x ^ 3 := by\n        have h := (Real.hasDerivAt_log hx0).div (hasDerivAt_pow 2 x) (pow_ne_zero 2 hx0)\n        rw [h.deriv]\n        congr 1\n        field_simp\n        ring\n      rw [hderiv]\n      have hnum : (1 : ℝ) - 2 * Real.log x ≤ 0 := by linarith [hlogx]\n      exact div_nonpos_of_nonpos_of_nonneg hnum (by positivity)\n  have hnn : ∀ t ∈ Set.Ioi (3 : ℝ), 0 ≤ Real.log t / t ^ 2 := by\n    intro t ht\n    have ht3 : (3 : ℝ) < t := ht\n    have hlog : (0 : ℝ) ≤ Real.log t := Real.log_nonneg (by linarith)\n    positivity\n  have hint : IntegrableOn (fun x => Real.log x / x ^ 2) (Set.Ioi (3 : ℝ)) volume := by\n    rw [← integral_log_div_sq_Ioi_three] at *\n    exact integrableOn_Ioi_deriv_of_nonneg'\n      (fun x hx => (by\n        have hx0 : x ≠ 0 := by have := (Set.mem_Ici.mp hx); linarith\n        have h1 := ((Real.hasDerivAt_log hx0).add_const 1).div (hasDerivAt_id' x) hx0\n        have h2 := h1.neg\n        have hval : -((x⁻¹ * x - (Real.log x + 1) * 1) / x ^ 2) = Real.log x / x ^ 2 := by\n          field_simp; ring\n        have hfn : (fun y => -((Real.log y + 1) / y))\n            = (fun y => -(Real.log y + 1) / y) := by ext y; rw [neg_div]\n        rw [← hfn, hval] at *\n        exact h2))\n      hnn (by\n        have hA : Tendsto (fun x => Real.log x / x) atTop (𝓝 0) := by\n          have h := tendsto_pow_log_div_mul_add_atTop 1 0 1 one_ne_zero\n          simpa using h\n        have hB : Tendsto (fun x => (1 : ℝ) / x) atTop (𝓝 0) :=\n          tendsto_one_div_atTop_nhds_zero\n        have hC : Tendsto (fun x => Real.log x / x + 1 / x) atTop (𝓝 (0 + 0)) :=\n          hA.add hB\n        have heq : (fun y => -(Real.log y + 1) / y)\n            = (fun x => Real.log x / x + 1 / x) := by\n          ext x; rw [neg_div, add_div]\n        rw [heq]\n        simpa using hC)\n  have hle := hanti.tsum_comp_add_le_integral 3 hint hnn\n  have hrearrange : (∑' n : ℕ, Real.log (n + 4) / (n + 4 : ℝ) ^ 2)\n      = ∑' n : ℕ, (fun x => Real.log x / x ^ 2) ((↑(n + 3 + 1) : ℕ) : ℝ) := by\n    refine tsum_congr fun n => ?_\n    have hcast : ((↑(n + 3 + 1) : ℕ) : ℝ) = (n : ℝ) + 4 := by push_cast; ring\n    rw [hcast]\n    have hcast2 : ((n : ℝ) + 4) = ((n + 4 : ℕ) : ℝ) := by push_cast; ring\n    rw [hcast2]\n  rw [hrearrange]\n  exact hle\n\n/-- **Piece 1** (D-069 §3): dirichletC2 ≤ 1. The honest value is\n−ζ′/ζ(2) ≈ 0.56997; the bound here uses Λ(n) ≤ log n, the exact head\nn = 2, 3, and the integral-test tail (log 3 + 1)/3 ≤ 0.7. -/\ntheorem dirichletC2_le_one : dirichletC2 ≤ 1 := by\n  rw [dirichletC2]\n  -- the majorant h\n  set h : ℕ → ℝ := fun n => if n = 0 then (0 : ℝ)\n    else Real.log n / (n : ℝ) ^ 2 with hh\n  have hsumm_g : Summable (fun n : ℕ =>\n      ‖LSeries.term (fun n => (ArithmeticFunction.vonMangoldt n : ℂ)) (2 : ℂ) n‖) := by\n    rw [summable_norm_iff]\n    exact ArithmeticFunction.LSeriesSummable_vonMangoldt (by norm_num)\n  have hterm : ∀ n : ℕ,\n      ‖LSeries.term (fun n => (ArithmeticFunction.vonMangoldt n : ℂ)) (2 : ℂ) n‖\n        = (if n = 0 then (0 : ℝ) else ArithmeticFunction.vonMangoldt n / (n : ℝ) ^ 2) :=\n    fun n => dirichletTerm_norm_eq n\n  have hle_pointwise : ∀ n : ℕ,\n      ‖LSeries.term (fun n => (ArithmeticFunction.vonMangoldt n : ℂ)) (2 : ℂ) n‖\n        ≤ h n := by\n    intro n\n    rw [hterm n, hh]\n    rcases eq_or_ne n 0 with rfl | hn\n    · simp\n    · rw [if_neg hn, if_neg hn]\n      exact div_le_div_of_nonneg_right ArithmeticFunction.vonMangoldt_le_log\n        (by positivity : (0 : ℝ) ≤ (n : ℝ) ^ 2)\n  -- summability of h via the tail\n  have htail_sum : Summable (fun n : ℕ => Real.log (n + 4) / (n + 4 : ℝ) ^ 2) := by\n    -- from the integral comparison (reuse tsum_log_div_sq_tail_le's inputs)\n    have hnn : ∀ t ∈ Set.Ioi (3 : ℝ), 0 ≤ Real.log t / t ^ 2 := by\n      intro t ht\n      have ht3 : (3 : ℝ) < t := ht\n      have hlog : (0 : ℝ) ≤ Real.log t := Real.log_nonneg (by linarith)\n      positivity\n    have hanti : AntitoneOn (fun x => Real.log x / x ^ 2) (Set.Ici (3 : ℝ)) := by\n      apply antitoneOn_of_deriv_nonpos (convex_Ici 3)\n      · intro x hx\n        have hx0 : x ≠ 0 := by have := (Set.mem_Ici.mp hx); linarith\n        exact (Real.continuousAt_log hx0).continuousWithinAt.div\n          (continuousWithinAt_pow _ _ _) (pow_ne_zero 2 hx0)\n      · intro x hx\n        have hx0 : x ≠ 0 := by\n          have : (3 : ℝ) < x := Set.mem_Ioi.mp (by simpa [Set.interior_Ici] using hx)\n          linarith\n        exact (Real.differentiableAt_log hx0).div (differentiableAt_pow _ _)\n          (pow_ne_zero 2 hx0) |>.differentiableWithinAt\n      · intro x hx\n        have hx3 : (3 : ℝ) < x := Set.mem_Ioi.mp (by simpa [Set.interior_Ici] using hx)\n        have hx0 : x ≠ 0 := by linarith\n        have hlog3 : (1 : ℝ) ≤ Real.log 3 := by\n          have h := Real.log_le_log (Real.exp_pos 1) (by linarith [Real.exp_one_lt_d9.le] :\n            Real.exp 1 ≤ 3)\n          rwa [Real.log_exp] at h\n        have hlogx : (1 : ℝ) ≤ Real.log x :=\n          hlog3.trans (Real.log_le_log (by positivity : (0 : ℝ) < 3) hx3.le)\n        have hderiv : deriv (fun y => Real.log y / y ^ 2) x\n            = (1 - 2 * Real.log x) / x ^ 3 := by\n          have h := (Real.hasDerivAt_log hx0).div (hasDerivAt_pow 2 x) (pow_ne_zero 2 hx0)\n          rw [h.deriv]\n          congr 1\n          field_simp\n          ring\n        rw [hderiv]\n        exact div_nonpos_of_nonpos_of_nonneg (by linarith [hlogx]) (by positivity)\n    have hint : IntegrableOn (fun x => Real.log x / x ^ 2) (Set.Ioi (3 : ℝ)) volume := by\n      rw [← integral_log_div_sq_Ioi_three]\n      exact IntegrableOn.of_finite_on... \n```\nHmm — the integrability should just be reused from the integral lemma. Actually integrableOn from the value: `integrableOn_Ioi_deriv_of_nonneg'` — I duplicated the deriv/tendsto work. Cleaner: factor the deriv/nonneg/tendsto/integrable into standalone lemmas so both `integral_log_div_sq_Ioi_three` and `tsum_log_div_sq_tail_le` and `htail_sum` reuse them. Let me restructure piece 1 with shared helpers:\n\n- `hasDerivAt_neg_log_add_one_div` : ∀ x ≠ 0, HasDerivAt (fun y => −(log y + 1)/y) (log x/x²) x.\n- `tendsto_neg_log_add_one_div` : Tendsto ... (𝓝 0).\n- `antitoneOn_log_div_sq` : AntitoneOn (fun x => log x/x²) (Ici 3).\n- `integrableOn_log_div_sq` : IntegrableOn (fun x => log x/x²) (Ioi 3).\n- `integral_log_div_sq_Ioi_three` : ∫ = (log 3+1)/3.\n- `tsum_log_div_sq_tail_le`.\n- `dirichletC2_le_one`.\n\nLet me rewrite the whole §6 with this factored structure. Also the summability of h: from tsum_log_div_sq_tail_le's summable tail... Actually the summability of (fun n => log (n+4)/(n+4)²) comes from AntitoneOn.summable... hmm — I need a Summable for htail. The integral test gives the BOUND but does it give summability? `AntitoneOn.summable_of_integrableOn_Ioi_zero` is the Ici-0 version; there should be an Ici-N version: from the tsum_comp_add_le_integral proof, the summability is established internally via `tsum_le_of_sum_le'`?? — hmm that lemma DOESN'T need summable (tsum_le_of_sum_le' handles possibly-non-summable as tsum = 0? no — tsum_le_of_sum_le' (h : ∀ s, ∑ i ∈ s, f i ≤ a) ... : ∑' f ≤ a requires summability? There's `tsum_le_of_sum_le (hf : Summable f) (h : ∀ s, ∑ i ∈ s, f i ≤ a) : ∑' i, f i ≤ a` and `tsum_le_of_sum_le' (ha : 0 ≤ ...)...`. If the series isn't summable the tsum is 0 and things break. The summability of the tail: get it from the comparison: log(n+4)/(n+4)² ≤ 2·(n+4)^{−3/2}·... or via `Summable` of the integral test: there is `AntitoneOn.summable_of_integrableOn_Ioi (anti : AntitoneOn f (Ici N)) (int : IntegrableOn f (Ioi N)) (nonneg : ∀ t ∈ Ioi N, 0 ≤ f t) : Summable (fun n ↦ f (↑n + N + 1))`? — the name from line 215-218's usage: `summable_of_integrableOn_Ioi (N := 0) (mod_cast anti) (mod_cast integrable) (mod_cast nonneg)` — so `AntitoneOn.summable_of_integrableOn_Ioi` exists. Let me check its signature quickly. Actually from the first grep block: \"theorem AntitoneOn.summable_of_integrableOn_Ioi_zero (anti : AntitoneOn f (Ici 0)) (integrable : IntegrableOn f (Ioi 0)) (nonneg : ∀ t ∈ Ioi 0, 0 ≤ f t) : Summable (fun (n : ℕ) ↦ f n) := summable_of_integrableOn_Ioi (N := 0) ...\" — so there's `summable_of_integrableOn_Ioi` with N — likely `AntitoneOn.summable_of_integrableOn_Ioi (N : ℕ) (anti : AntitoneOn f (Ici N)) (integrable : IntegrableOn f (Ioi N)) (nonneg : ∀ t ∈ Ioi N, 0 ≤ f t) : Summable (fun n ↦ f (↑n + N + 1))`. Check at build.\n\nGiven the file is getting long and it's late, let me restructure §6 cleanly with the factored helpers. Rewrite the section.","replace_all":false},"extra_content":null}]