← Session 18 — Lean tier (ii): finite-height proof + certified base points
thinking (14072 chars)
Both lemmas confirmed:
- `ConvexOn.monotoneOn_deriv (hfc : ConvexOn ℝ S f) (hfd : ∀ x ∈ S, DifferentiableAt ℝ f x) : MonotoneOn (deriv f) S`
- `exists_deriv_eq_slope (hab : a < b) (hfc : ContinuousOn f (Icc a b)) (hfd : DifferentiableOn ℝ f (Ioo a b)) : ∃ c ∈ Ioo a b, deriv f c = (f b − f a)/(b − a)` — need to check argument order: `exists_deriv_eq_slope f (deriv f) hab hfc ...` from the body: takes hab, hfc, hfd presumably in order f, hab (included var), hfc, hfd. Signature shows include hab hfc hfd. Let me check the variable declarations... standard usage: `exists_deriv_eq_slope (f := f) hab hfc hfd`. From the source line 152 it's `theorem exists_deriv_eq_slope : ∃ c ∈ Ioo a b, ...` with included hab hfc hfd. The section variables: let me not over-verify; I'll write `exists_deriv_eq_slope (f := marginTilde FAlt) hab hfc hfd` and fix at compile time.
Now update todos and start implementing. The design is settled:
**Session 012 sub-stages:**
- 12.1: refactor (chain_rule_sqrt_shift_on generalized; ContDiffOn F; drop hmaj), defs (sInftyLower/FAlt/Bn/Sf/SfBoundProp), margin identity, psiOf blocks + FAlt ψ < 0 + ContDiffOn FAlt, pos_of_convex_base, aux assembly theorem with hbase/hbase′ hypotheses. COMPILE GREEN.
- 12.2: base-point numerics (marginTilde FAlt 80000 > 0, deriv > 0) → main theorem keeps only (hRH)(hfinite)(hSf).
- 12.3: triage doc D-062 + session protocol.
Note: I should double check one thing — the `marginTilde_convex` refactor removing hmaj: also check whether anything else references hmaj... it's a hypothesis, fine.
One more check on `Real.log` for FAlt ContDiffOn (Ioi 1): need `ContDiffOn ℝ 2 Real.log (Set.Ioi 0)`... Mathlib: `contDiffOn_log`? In the file they used `(contDiffOn_id.add contDiffOn_const).log (fun x hx => ne_of_gt ...)`: that's `ContDiffOn.log (hf : ContDiffOn ℝ n f s) (h : ∀ x ∈ s, f x ≠ 0)`. ✓ So:
- contDiffOn_FAlt:
- t_log_t : ContDiffOn ℝ 2 (fun t => t * Real.log t) (Ioi 1) := contDiffOn_id.mul (contDiffOn_id.log (fun x hx => ne_of_gt (zero < 1 < x)))
- log_t : contDiffOn_id.log ...
- log_log_t : (contDiffOn_id.log ...).log (fun x hx => ne_of_gt (Real.log_pos (x > 1)))
- const: contDiffOn_const
- combine: (contDiffOn_const.mul t_log_t).add (contDiffOn_const.mul log_t)... etc.
psiOf computations: follow the file's existing patterns (deriv2_of_hasDerivAt_nhds).
ψ[T·log T]:
- D1: log T + 1 (HasDerivAt (fun t => t * log t) (log x + 1) x: (hasDerivAt_id' x).mul (Real.hasDerivAt_log hx_ne) — gives 1·log x + x·x⁻¹ = log x + 1 after field_simp)
- D2: 1/T (HasDerivAt (fun t => log t + 1) t⁻¹ T)
- ψ = 1/T − (log T + 1)/(T−1)
- sign for T > 1: ψ < 0 ⟺ (T−1) < T(log T + 1) (cross-multiply positive denominators) ⟺ −1 < T log T ✓ (T > 1 ⟹ log T > 0 ⟹ T log T > 0 > −1).
ψ[log T]:
- D1: 1/T; D2: −1/T². ψ = −1/T² − (1/T)/(T−1) = −1/T² − 1/(T(T−1)) < 0 for T > 1. ✓
ψ[log log T]:
- D1: (log T)⁻¹·T⁻¹; D2: −(log T + 1)/(T log T)². ψ = D2 − D1/(T−1) = −(log T+1)/(T log T)² − 1/(T log T (T−1)) < 0 for T > 1 ✓.
ψ[const K]: deriv (deriv (fun _ => K)) T = 0 (deriv2_const_val), deriv (fun _ => K) T = 0 (deriv_const). ψ = 0 − 0/(T−1) = 0.
psiOf_FAlt: FAlt = fun T => (1/(2π))*(T*log T) + 0.137*log T + 0.443*log(log T) + (7/8+1.588).
Structure as nested adds; apply psiOf_add × 3 + psiOf_const_mul × 3 + psiOf_const_val. Conditions for psiOf_add/const_mul at T > 1: need DifferentiableAt (deriv f) T and ∀ᶠ m ∈ 𝓝 T, DifferentiableAt f m for each piece. For blocks:
- deriv (fun t => t * log t) differentiable at T > 0: deriv = log + 1 eventually (need the eventual equality), differentiable since log smooth... Simpler: get these from ContDiffOn: each piece P has ContDiffOn ℝ 2 P (Ioi 1), then for T > 1: DifferentiableAt (deriv P) T := ((hCD.deriv_of_isOpen (m:=1) isOpen_Ioi one_lt_two...)).differentiableOn one_ne_zero).differentiableAt (Ioi_mem_nhds hT) — the same `hdd`/`hev` patterns as marginTilde_convex. ✓
Then psiOf_FAlt_neg: assemble closed forms with weights, all negative/ψ signs:
ψ[FAlt] = (1/2π)·ψ₁ + 0.137·ψ₃ + 0.443·ψ₄ + 0, each ≤ 0 with ψ₁ < 0 strictly and weight 1/(2π) > 0 ⟹ total < 0.
pos_of_convex_base:
```
theorem pos_of_convex_of_base {f : ℝ → ℝ} {N₀ x : ℝ}
(hconv : ConvexOn ℝ (Set.Ici 20) f)
(hcont : ContinuousOn f (Set.Ici 20))
(hdiff : ∀ y ∈ Set.Ioi 20, DifferentiableAt ℝ f y)
(hN : 20 < N₀) (hx : N₀ ≤ x) (h0 : 0 < f N₀) (h0' : 0 < deriv f N₀) :
0 < f x := by
rcases eq_or_lt_of_le hx with rfl | hlt
· exact h0
· obtain ⟨ξ, hξ, hξeq⟩ := exists_deriv_eq_slope (f := f) hlt
(hcont.mono (Set.Icc_subset_Ici (by linarith))) -- Icc N₀ x ⊆ Ici 20
(by intro y hy; exact (hdiff y (by ... y ∈ Ioi 20)).differentiableOn...)
-- monotoneOn_deriv: N₀ ≤ ξ both in Ici 20
have hmono := hconv.monotoneOn_deriv (fun y hy => hdiff y (Set.mem_Iio...)) -- hfd : ∀ y ∈ Ici 20, DifferentiableAt f y — from hdiff? Ici 20 vs Ioi 20: at y = 20, differentiable? Not necessarily (only Ioi 20). Hmm — monotoneOn_deriv needs hfd on ALL of S = Ici 20 including endpoint 20. Our f is differentiable only on Ioi 20. But I only need monotonicity on [N₀, ∞) ⊂ Ioi 20 — restrict S to Ici N₀ ⊆ Ioi 20: hconv.mono (Set.Ici_subset_Ici (by linarith : 20 ≤ N₀))... ConvexOn.mono : ConvexOn ℝ s f → t ⊆ s → ConvexOn ℝ t f. Then apply monotoneOn_deriv on S = Ici N₀ with hfd: ∀ y ∈ Ici N₀, DifferentiableAt f y (from hdiff since y ≥ N₀ > 20).
have hder : deriv f N₀ ≤ deriv f ξ := (hconv.mono ...).monotoneOn_deriv hfd' (mem_Ici N₀) (mem_Ici_of ξ ≥ N₀... ξ ∈ Ioo N₀ x ⟹ N₀ < ξ ⟹ ξ ∈ Ici N₀) (le_of_lt hξ.1)
-- f x = f N₀ + deriv f ξ · (x − N₀) ≥ f N₀ + deriv f N₀ (x−N₀) > 0
field_simp at hξeq; nlinarith/linarith
```
✓ workable.
Assembly:
```
theorem lambda_pos_finite_height
(hRH : RHUpTo (3 * 10 ^ 12)) (hfinite : LiVerifiedUpTo (5 * 10 ^ 5))
(hbase : 0 < marginTilde FAlt 80000) (hbase' : 0 < deriv (marginTilde FAlt) 80000)
(hSf : SfBoundProp) :
∀ n : ℕ, 1 ≤ n → (n : ℝ) ≤ (3 * 10 ^ 12 - 1 : ℝ) ^ 2 → 0 < (liCoeff n).re := by
intro n hn1 hnN
rcases lt_or_ge n 80000 with h | h
· exact hfinite n hn1 (by omega: n ≤ 500000) -- n < 80000 ≤ 500000
· -- 80000 ≤ n
have hn20 : 20 ≤ n := by omega
have h1 := sInfty_lower_bound n hn20 -- sInftyLower n ≤ SInfty n
have h2 := hSf n h hnN -- |Sf n| ≤ Bn FAlt n
have h3 : (liCoeff n).re = SInfty n - Sf n + 1 := by unfold Sf; ring
have h4 : marginTilde FAlt n = sInftyLower n - Bn FAlt n + 1 := marginTilde_eq_sub ..
have h5 : 0 < marginTilde FAlt n := pos_of_convex_of_base
(marginTilde_convex FAlt hFAlt hψFAlt) (continuousOn margin) hdiff (by norm_num) (n ≥ 80000 cast) hbase hbase'
-- combine
have : Sf n ≤ |Sf n| := le_abs_self _
-- sInftyLower n - Bn + 1 ≤ SInfty n - Sf n + 1 = (liCoeff n).re
rw [h3] -- goal 0 < SInfty n - Sf n + 1
-- h5: 0 < sInftyLower n - Bn + 1; h1: sInftyLower ≤ SInfty; h2+abs: Sf ≤ Bn
-- (n : ℝ) casts: Bn FAlt n where Bn takes ℝ — hSf stated with (n:ℝ) cast; marginTilde FAlt (↑n)... h4/h5 at (↑n : ℝ). Fine with pushes.
linarith [h1, h2, h5, this] -- maybe needs exact cast massage
```
Details: h5 gives 0 < marginTilde FAlt (↑n) where pos_of_convex_of_base's x = (↑n : ℝ), N₀ = 80000. Need (80000 : ℝ) ≤ ↑n from h : 80000 ≤ n (ℕ) — exact_mod_cast.
Wait — actually there's a subtlety with `hfinite`: LiVerifiedUpTo N := ∀ n : ℕ, 1 ≤ n → n ≤ N → 0 < (liCoeff n).re with N = 5*10^5 as ℕ. n < 80000 ⟹ n ≤ 500000 ✓ omega.
Another subtlety: `marginTilde_eq_sub`: marginTilde F n unfolds: let T := √n + 1; (sInftyLower-ish) − (big) + 1. sInftyLower n = (1/2)*n*log n + (lagariasC1 − γ/2)*n − 4 ✓ matches marginTilde's first group. Bn F n = the big parenthesized group. So marginTilde F n = sInftyLower n − Bn F n + 1 by `unfold marginTilde Bn sInftyLower; ring`? marginTilde has `let T := ...` — simp only [marginTilde] shows let; use `show` with both sides unfolded... The existing marginTilde_eq_expanded does: funext n; simp only [marginTilde, marginExpanded, ...]; ring. I'll mimic: theorem marginTilde_eq_sub (F : ℝ → ℝ) (n : ℝ) : marginTilde F n = sInftyLower n - Bn F n + 1 := by simp only [marginTilde, Bn, sInftyLower]; ring. The `let T :=` inside marginTilde — simp only with the def name unfolds the let too (dsimp part of simp only). OK.
Casts: Bn FAlt (↑n) — hSf gives |Sf n| ≤ Bn FAlt ↑n ✓ directly if SfBoundProp stated with (n : ℝ) cast: `|Sf n| ≤ Bn FAlt (n : ℝ)`. ✓
Now the refactor of chain_rule_sqrt_shift_on. Current signature:
```
theorem chain_rule_sqrt_shift_on (φ : ℝ → ℝ) (hφ : ContDiffOn ℝ 2 φ (Set.Ioi (-1))) (n : ℝ) (hn : 0 < n) : ...
```
Generalize:
```
theorem chain_rule_sqrt_shift_on (φ : ℝ → ℝ) {c : ℝ} (hc : c < 1) (hφ : ContDiffOn ℝ 2 φ (Set.Ioi c)) (n : ℝ) (hn : 0 < n) : ...
```
Body changes: hmem : Ioi c ∈ 𝓝 (√m + 1) needs c < √m + 1 ⟸ c < 1 ≤ √m + 1 ✓ (`Ioi_mem_nhds (by linarith [Real.sqrt_nonneg m])` — same). Everything else unchanged.
Call sites (8): `chain_rule_sqrt_shift_on _ contDiffOn_TL1 n hn0` → `chain_rule_sqrt_shift_on _ (by norm_num) contDiffOn_TL1 n hn0`.
vF currently uses `chain_rule_sqrt_shift F hF n hn0` (global version) → change to `chain_rule_sqrt_shift_on F (by norm_num) hF n hn0` with hF : ContDiffOn ℝ 2 F (Ioi 1).
contDiffOn_mFblock:
```
theorem contDiffOn_mFblock (F : ℝ → ℝ) (hF : ContDiffOn ℝ 2 F (Set.Ioi 1)) : ContDiffOn ℝ 2 (mFblock F) (Set.Ioi 20) :=
contDiffOn_const.mul (hF.comp contDiffOn_sqrt_shift mapsTo_sqrt_shift_Ioi1)
```
need `mapsTo_sqrt_shift_Ioi1 : Set.MapsTo (fun m => Real.sqrt m + 1) (Set.Ioi 20) (Set.Ioi 1)` — √m+1 > √20+1 > 1 ✓.
continuousOn_marginExpanded: `(hF.continuous.continuousOn.comp hT (Set.mapsTo_univ _ _))` → `(hF.continuousOn.comp hT hmapsIci)` where hmapsIci : MapsTo (√·+1) (Ici 20) (Ioi 1) — √m+1 ≥ √20+1 > 1 ✓. (The existing hmaps in that proof targets Ioi (−1); the F-comp uses mapsTo_univ — replace with the Ioi 1 map; hmaps for the OTHER blocks stays Ioi (−1).)
marginTilde_convex signature: `(F : ℝ → ℝ) (hF : ContDiffOn ℝ 2 F (Set.Ioi 1)) (hψ : ...)` — drop hmaj. Body: hCDFc := hF.comp contDiffOn_sqrt_shift mapsTo_sqrt_shift_Ioi1; vF := ... chain_rule_sqrt_shift_on F (by norm_num) hF n hn0 ...; the two rw [marginTilde_eq_expanded F] steps use continuousOn_marginExpanded/contDiffOn_marginExpanded with hF. Check other hF uses in body: contDiffOn_mFblock F hF (hCD1, hCD10 chain...), hev/hdd applications fine.
Also `Ioi_mem_nhds` for c: fine.
Now — one concern: `ContDiffOn.comp` signature: `ContDiffOn.comp (hg : ContDiffOn ℝ n g t) (hf : ContDiffOn ℝ n f s) (h : Set.MapsTo f s t) : ContDiffOn ℝ n (g ∘ f) s`. The existing code: `hF.contDiffOn.comp contDiffOn_sqrt_shift (Set.mapsTo_univ _ _)` — so hF : ContDiff ℝ 2 F, .contDiffOn gives ContDiffOn ℝ 2 F univ, .comp contDiffOn_sqrt_shift (mapsTo_univ). Target type ContDiffOn ℝ 2 (F ∘ (√·+1)) (Ioi 20) but mFblock F is fun m => (-2) * F (√m+1) — with const.mul wrapping. The composition produces (F ∘ g) — and the block is c * (F ∘ g)? mFblock F n = (-2) * F(√n+1) = ((-2) • ... the code: `contDiffOn_const.mul (hF.contDiffOn.comp ...)` gives ContDiffOn ℝ 2 ((fun _ => -2) * (F ∘ g))? mul of functions: ((fun _ => -2) * (F∘g)) m = -2 * F(g m) ✓ defeq to mFblock — and `unfold mFblock` at the start handles it. With hF : ContDiffOn ℝ 2 F (Ioi 1): `hF.comp contDiffOn_sqrt_shift mapsTo_sqrt_shift_Ioi1 : ContDiffOn ℝ 2 (F ∘ fun m => √m+1) (Ioi 20)` ✓ same shape.
Order of edits in the file — plan:
1. Add `mapsTo_sqrt_shift_Ioi1` + Ici variant near mapsTo_sqrt_shift.
2. Modify `chain_rule_sqrt_shift_on` (add c param) + update 8 call sites in marginTilde_convex.
3. Modify `contDiffOn_mFblock`, `continuousOn_marginExpanded`, `contDiffOn_marginExpanded`, `marginTilde_convex` signatures + bodies.
4. Add sInftyLower def + refactor sInfty_lower_bound statement.
5. Add FAlt/Bn/Sf/SfBoundProp defs + marginTilde_eq_sub.
6. Add psiOf block lemmas (#1 T·log T, #3 log, #4 log log, const) + psiOf_add/const_mul + psiOf_FAlt_neg + contDiffOn_FAlt.
7. pos_of_convex_of_base.
8. lambda_pos_finite_height assembly (hbase/hbase′ hypotheses interim).
9. Compile; fix; PrintAxioms.
Note the derivative base point (hbase′) — for the aux theorem I'll take hbase/hbase′ as hypotheses; 12.3 discharges. Actually — wait. Let me reconsider whether to even keep them as hypotheses in the FINAL main theorem or do 12.3 now. The final deliverable this session per notes: "state lambda_pos_finite_height with SfBound named hypothesis and discharge the full assembly conditional on it". If hbase/hbase′ remain hypotheses, the claim is "modulo SfBound + 2 elementary numeric evaluations" — slightly weaker than the notes' target but the numeric evaluations are CLEARLY computational-perimeter-class (E-028/E-029 verified). Best effort: try to discharge them this session (12.3); if it gets long, split.
Time to write code. Also update the file header comment (stage note) — minimal.
One more consideration: `SfBoundProp` — as a def Prop, then hypothesis (hSf : SfBoundProp). For the eventual triage the Prop must be exactly right. Also note N₀ = 80000 choice: with FAlt (slightly bigger than Trudgian F), margiñ(80000) ≈ 15 724 > 0 ✓ still fine (E-028's margiñ = 16020 was with Trudgian F; FAlt adds ~0.9·T ≈ 256... wait actually let me recheck: does E-028's B(n) use 2N ≤ 2F + 2S_b (F = Trudgian smooth part)? D-037 §4: "|Σ| ≤ 2N(T) ≤ 2F(T) + 2S_bnd(T)". So E-028's B has 2(F+S_b) with F_Tru. FAlt = (1/2π)T log T + S_b + 7/8 + ... vs F_Tru + S_b = (1/2π)T log(T/2πe) + S_b + 7/8. FAlt − (F_Tru+S_b) = (1/2π)[T log T − T log(T/2πe)] = (T/2π)·log(2πe) = (T/2π)(2.83788) ≈ 0.4516·T ≈ 128 at T = 283.8. Times 2 (the B term is 2F): +256 to B. margin 16020 → 15764. ✓ fine. margin′ effect: (log(2πe)/2π)·(1/2√n)·... derivative of 2·0.4516·(√n+1) w.r.t. n = 0.4516/√n ≈ 0.0016. margin′ 3.7 → 3.698 ✓.
OK. Also should double check `Real.exp 4` bounds availability for base points — later.
Let me also double-check the exact form of `exists_deriv_eq_slope` call: from source, section variables. Let me look at lines ~125-155 of MeanValue.lean to see variable binder order.
Both Mathlib lemmas confirmed. Checking `exists_deriv_eq_slope` binder order, then implementing.
tool: Bash
input
{
"command": "sed -n '100,152p' D:/Python/Quantum/zeta-23-lean/.lake/packages/mathlib/Mathlib/Analysis/Calculus/Deriv/MeanValue.lean | grep -n \"variable\\|theorem exists_deriv_eq_slope\" ",
"description": "Check variable binders for MVT theorem"
}
raw content_json (database row)
[{"type":"thinking","thinking":"Both lemmas confirmed:\n- `ConvexOn.monotoneOn_deriv (hfc : ConvexOn ℝ S f) (hfd : ∀ x ∈ S, DifferentiableAt ℝ f x) : MonotoneOn (deriv f) S`\n- `exists_deriv_eq_slope (hab : a < b) (hfc : ContinuousOn f (Icc a b)) (hfd : DifferentiableOn ℝ f (Ioo a b)) : ∃ c ∈ Ioo a b, deriv f c = (f b − f a)/(b − a)` — need to check argument order: `exists_deriv_eq_slope f (deriv f) hab hfc ...` from the body: takes hab, hfc, hfd presumably in order f, hab (included var), hfc, hfd. Signature shows include hab hfc hfd. Let me check the variable declarations... standard usage: `exists_deriv_eq_slope (f := f) hab hfc hfd`. From the source line 152 it's `theorem exists_deriv_eq_slope : ∃ c ∈ Ioo a b, ...` with included hab hfc hfd. The section variables: let me not over-verify; I'll write `exists_deriv_eq_slope (f := marginTilde FAlt) hab hfc hfd` and fix at compile time.\n\nNow update todos and start implementing. The design is settled:\n\n**Session 012 sub-stages:**\n- 12.1: refactor (chain_rule_sqrt_shift_on generalized; ContDiffOn F; drop hmaj), defs (sInftyLower/FAlt/Bn/Sf/SfBoundProp), margin identity, psiOf blocks + FAlt ψ < 0 + ContDiffOn FAlt, pos_of_convex_base, aux assembly theorem with hbase/hbase′ hypotheses. COMPILE GREEN.\n- 12.2: base-point numerics (marginTilde FAlt 80000 > 0, deriv > 0) → main theorem keeps only (hRH)(hfinite)(hSf).\n- 12.3: triage doc D-062 + session protocol.\n\nNote: I should double check one thing — the `marginTilde_convex` refactor removing hmaj: also check whether anything else references hmaj... it's a hypothesis, fine.\n\nOne more check on `Real.log` for FAlt ContDiffOn (Ioi 1): need `ContDiffOn ℝ 2 Real.log (Set.Ioi 0)`... Mathlib: `contDiffOn_log`? In the file they used `(contDiffOn_id.add contDiffOn_const).log (fun x hx => ne_of_gt ...)`: that's `ContDiffOn.log (hf : ContDiffOn ℝ n f s) (h : ∀ x ∈ s, f x ≠ 0)`. ✓ So:\n- contDiffOn_FAlt: \n - t_log_t : ContDiffOn ℝ 2 (fun t => t * Real.log t) (Ioi 1) := contDiffOn_id.mul (contDiffOn_id.log (fun x hx => ne_of_gt (zero < 1 < x)))\n - log_t : contDiffOn_id.log ...\n - log_log_t : (contDiffOn_id.log ...).log (fun x hx => ne_of_gt (Real.log_pos (x > 1)))\n - const: contDiffOn_const\n - combine: (contDiffOn_const.mul t_log_t).add (contDiffOn_const.mul log_t)... etc.\n\npsiOf computations: follow the file's existing patterns (deriv2_of_hasDerivAt_nhds). \n\nψ[T·log T]: \n- D1: log T + 1 (HasDerivAt (fun t => t * log t) (log x + 1) x: (hasDerivAt_id' x).mul (Real.hasDerivAt_log hx_ne) — gives 1·log x + x·x⁻¹ = log x + 1 after field_simp)\n- D2: 1/T (HasDerivAt (fun t => log t + 1) t⁻¹ T)\n- ψ = 1/T − (log T + 1)/(T−1)\n- sign for T > 1: ψ < 0 ⟺ (T−1) < T(log T + 1) (cross-multiply positive denominators) ⟺ −1 < T log T ✓ (T > 1 ⟹ log T > 0 ⟹ T log T > 0 > −1).\n\nψ[log T]:\n- D1: 1/T; D2: −1/T². ψ = −1/T² − (1/T)/(T−1) = −1/T² − 1/(T(T−1)) < 0 for T > 1. ✓\n\nψ[log log T]:\n- D1: (log T)⁻¹·T⁻¹; D2: −(log T + 1)/(T log T)². ψ = D2 − D1/(T−1) = −(log T+1)/(T log T)² − 1/(T log T (T−1)) < 0 for T > 1 ✓.\n\nψ[const K]: deriv (deriv (fun _ => K)) T = 0 (deriv2_const_val), deriv (fun _ => K) T = 0 (deriv_const). ψ = 0 − 0/(T−1) = 0. \n\npsiOf_FAlt: FAlt = fun T => (1/(2π))*(T*log T) + 0.137*log T + 0.443*log(log T) + (7/8+1.588).\nStructure as nested adds; apply psiOf_add × 3 + psiOf_const_mul × 3 + psiOf_const_val. Conditions for psiOf_add/const_mul at T > 1: need DifferentiableAt (deriv f) T and ∀ᶠ m ∈ 𝓝 T, DifferentiableAt f m for each piece. For blocks: \n- deriv (fun t => t * log t) differentiable at T > 0: deriv = log + 1 eventually (need the eventual equality), differentiable since log smooth... Simpler: get these from ContDiffOn: each piece P has ContDiffOn ℝ 2 P (Ioi 1), then for T > 1: DifferentiableAt (deriv P) T := ((hCD.deriv_of_isOpen (m:=1) isOpen_Ioi one_lt_two...)).differentiableOn one_ne_zero).differentiableAt (Ioi_mem_nhds hT) — the same `hdd`/`hev` patterns as marginTilde_convex. ✓\n\nThen psiOf_FAlt_neg: assemble closed forms with weights, all negative/ψ signs:\nψ[FAlt] = (1/2π)·ψ₁ + 0.137·ψ₃ + 0.443·ψ₄ + 0, each ≤ 0 with ψ₁ < 0 strictly and weight 1/(2π) > 0 ⟹ total < 0. \n\npos_of_convex_base:\n```\ntheorem pos_of_convex_of_base {f : ℝ → ℝ} {N₀ x : ℝ}\n (hconv : ConvexOn ℝ (Set.Ici 20) f)\n (hcont : ContinuousOn f (Set.Ici 20))\n (hdiff : ∀ y ∈ Set.Ioi 20, DifferentiableAt ℝ f y)\n (hN : 20 < N₀) (hx : N₀ ≤ x) (h0 : 0 < f N₀) (h0' : 0 < deriv f N₀) :\n 0 < f x := by\n rcases eq_or_lt_of_le hx with rfl | hlt\n · exact h0\n · obtain ⟨ξ, hξ, hξeq⟩ := exists_deriv_eq_slope (f := f) hlt\n (hcont.mono (Set.Icc_subset_Ici (by linarith))) -- Icc N₀ x ⊆ Ici 20\n (by intro y hy; exact (hdiff y (by ... y ∈ Ioi 20)).differentiableOn...) \n -- monotoneOn_deriv: N₀ ≤ ξ both in Ici 20\n have hmono := hconv.monotoneOn_deriv (fun y hy => hdiff y (Set.mem_Iio...)) -- hfd : ∀ y ∈ Ici 20, DifferentiableAt f y — from hdiff? Ici 20 vs Ioi 20: at y = 20, differentiable? Not necessarily (only Ioi 20). Hmm — monotoneOn_deriv needs hfd on ALL of S = Ici 20 including endpoint 20. Our f is differentiable only on Ioi 20. But I only need monotonicity on [N₀, ∞) ⊂ Ioi 20 — restrict S to Ici N₀ ⊆ Ioi 20: hconv.mono (Set.Ici_subset_Ici (by linarith : 20 ≤ N₀))... ConvexOn.mono : ConvexOn ℝ s f → t ⊆ s → ConvexOn ℝ t f. Then apply monotoneOn_deriv on S = Ici N₀ with hfd: ∀ y ∈ Ici N₀, DifferentiableAt f y (from hdiff since y ≥ N₀ > 20). \n have hder : deriv f N₀ ≤ deriv f ξ := (hconv.mono ...).monotoneOn_deriv hfd' (mem_Ici N₀) (mem_Ici_of ξ ≥ N₀... ξ ∈ Ioo N₀ x ⟹ N₀ < ξ ⟹ ξ ∈ Ici N₀) (le_of_lt hξ.1)\n -- f x = f N₀ + deriv f ξ · (x − N₀) ≥ f N₀ + deriv f N₀ (x−N₀) > 0\n field_simp at hξeq; nlinarith/linarith\n```\n✓ workable.\n\nAssembly:\n```\ntheorem lambda_pos_finite_height\n (hRH : RHUpTo (3 * 10 ^ 12)) (hfinite : LiVerifiedUpTo (5 * 10 ^ 5))\n (hbase : 0 < marginTilde FAlt 80000) (hbase' : 0 < deriv (marginTilde FAlt) 80000)\n (hSf : SfBoundProp) :\n ∀ n : ℕ, 1 ≤ n → (n : ℝ) ≤ (3 * 10 ^ 12 - 1 : ℝ) ^ 2 → 0 < (liCoeff n).re := by\n intro n hn1 hnN\n rcases lt_or_ge n 80000 with h | h\n · exact hfinite n hn1 (by omega: n ≤ 500000) -- n < 80000 ≤ 500000\n · -- 80000 ≤ n\n have hn20 : 20 ≤ n := by omega\n have h1 := sInfty_lower_bound n hn20 -- sInftyLower n ≤ SInfty n\n have h2 := hSf n h hnN -- |Sf n| ≤ Bn FAlt n\n have h3 : (liCoeff n).re = SInfty n - Sf n + 1 := by unfold Sf; ring\n have h4 : marginTilde FAlt n = sInftyLower n - Bn FAlt n + 1 := marginTilde_eq_sub ..\n have h5 : 0 < marginTilde FAlt n := pos_of_convex_of_base\n (marginTilde_convex FAlt hFAlt hψFAlt) (continuousOn margin) hdiff (by norm_num) (n ≥ 80000 cast) hbase hbase'\n -- combine\n have : Sf n ≤ |Sf n| := le_abs_self _\n -- sInftyLower n - Bn + 1 ≤ SInfty n - Sf n + 1 = (liCoeff n).re\n rw [h3] -- goal 0 < SInfty n - Sf n + 1\n -- h5: 0 < sInftyLower n - Bn + 1; h1: sInftyLower ≤ SInfty; h2+abs: Sf ≤ Bn\n -- (n : ℝ) casts: Bn FAlt n where Bn takes ℝ — hSf stated with (n:ℝ) cast; marginTilde FAlt (↑n)... h4/h5 at (↑n : ℝ). Fine with pushes.\n linarith [h1, h2, h5, this] -- maybe needs exact cast massage\n```\nDetails: h5 gives 0 < marginTilde FAlt (↑n) where pos_of_convex_of_base's x = (↑n : ℝ), N₀ = 80000. Need (80000 : ℝ) ≤ ↑n from h : 80000 ≤ n (ℕ) — exact_mod_cast. \n\nWait — actually there's a subtlety with `hfinite`: LiVerifiedUpTo N := ∀ n : ℕ, 1 ≤ n → n ≤ N → 0 < (liCoeff n).re with N = 5*10^5 as ℕ. n < 80000 ⟹ n ≤ 500000 ✓ omega.\n\nAnother subtlety: `marginTilde_eq_sub`: marginTilde F n unfolds: let T := √n + 1; (sInftyLower-ish) − (big) + 1. sInftyLower n = (1/2)*n*log n + (lagariasC1 − γ/2)*n − 4 ✓ matches marginTilde's first group. Bn F n = the big parenthesized group. So marginTilde F n = sInftyLower n − Bn F n + 1 by `unfold marginTilde Bn sInftyLower; ring`? marginTilde has `let T := ...` — simp only [marginTilde] shows let; use `show` with both sides unfolded... The existing marginTilde_eq_expanded does: funext n; simp only [marginTilde, marginExpanded, ...]; ring. I'll mimic: theorem marginTilde_eq_sub (F : ℝ → ℝ) (n : ℝ) : marginTilde F n = sInftyLower n - Bn F n + 1 := by simp only [marginTilde, Bn, sInftyLower]; ring. The `let T :=` inside marginTilde — simp only with the def name unfolds the let too (dsimp part of simp only). OK.\n\nCasts: Bn FAlt (↑n) — hSf gives |Sf n| ≤ Bn FAlt ↑n ✓ directly if SfBoundProp stated with (n : ℝ) cast: `|Sf n| ≤ Bn FAlt (n : ℝ)`. ✓\n\nNow the refactor of chain_rule_sqrt_shift_on. Current signature:\n```\ntheorem chain_rule_sqrt_shift_on (φ : ℝ → ℝ) (hφ : ContDiffOn ℝ 2 φ (Set.Ioi (-1))) (n : ℝ) (hn : 0 < n) : ...\n```\nGeneralize:\n```\ntheorem chain_rule_sqrt_shift_on (φ : ℝ → ℝ) {c : ℝ} (hc : c < 1) (hφ : ContDiffOn ℝ 2 φ (Set.Ioi c)) (n : ℝ) (hn : 0 < n) : ...\n```\nBody changes: hmem : Ioi c ∈ 𝓝 (√m + 1) needs c < √m + 1 ⟸ c < 1 ≤ √m + 1 ✓ (`Ioi_mem_nhds (by linarith [Real.sqrt_nonneg m])` — same). Everything else unchanged.\n\nCall sites (8): `chain_rule_sqrt_shift_on _ contDiffOn_TL1 n hn0` → `chain_rule_sqrt_shift_on _ (by norm_num) contDiffOn_TL1 n hn0`. \n\nvF currently uses `chain_rule_sqrt_shift F hF n hn0` (global version) → change to `chain_rule_sqrt_shift_on F (by norm_num) hF n hn0` with hF : ContDiffOn ℝ 2 F (Ioi 1).\n\ncontDiffOn_mFblock: \n```\ntheorem contDiffOn_mFblock (F : ℝ → ℝ) (hF : ContDiffOn ℝ 2 F (Set.Ioi 1)) : ContDiffOn ℝ 2 (mFblock F) (Set.Ioi 20) :=\n contDiffOn_const.mul (hF.comp contDiffOn_sqrt_shift mapsTo_sqrt_shift_Ioi1)\n```\nneed `mapsTo_sqrt_shift_Ioi1 : Set.MapsTo (fun m => Real.sqrt m + 1) (Set.Ioi 20) (Set.Ioi 1)` — √m+1 > √20+1 > 1 ✓.\n\ncontinuousOn_marginExpanded: `(hF.continuous.continuousOn.comp hT (Set.mapsTo_univ _ _))` → `(hF.continuousOn.comp hT hmapsIci)` where hmapsIci : MapsTo (√·+1) (Ici 20) (Ioi 1) — √m+1 ≥ √20+1 > 1 ✓. (The existing hmaps in that proof targets Ioi (−1); the F-comp uses mapsTo_univ — replace with the Ioi 1 map; hmaps for the OTHER blocks stays Ioi (−1).)\n\nmarginTilde_convex signature: `(F : ℝ → ℝ) (hF : ContDiffOn ℝ 2 F (Set.Ioi 1)) (hψ : ...)` — drop hmaj. Body: hCDFc := hF.comp contDiffOn_sqrt_shift mapsTo_sqrt_shift_Ioi1; vF := ... chain_rule_sqrt_shift_on F (by norm_num) hF n hn0 ...; the two rw [marginTilde_eq_expanded F] steps use continuousOn_marginExpanded/contDiffOn_marginExpanded with hF. Check other hF uses in body: contDiffOn_mFblock F hF (hCD1, hCD10 chain...), hev/hdd applications fine.\n\nAlso `Ioi_mem_nhds` for c: fine.\n\nNow — one concern: `ContDiffOn.comp` signature: `ContDiffOn.comp (hg : ContDiffOn ℝ n g t) (hf : ContDiffOn ℝ n f s) (h : Set.MapsTo f s t) : ContDiffOn ℝ n (g ∘ f) s`. The existing code: `hF.contDiffOn.comp contDiffOn_sqrt_shift (Set.mapsTo_univ _ _)` — so hF : ContDiff ℝ 2 F, .contDiffOn gives ContDiffOn ℝ 2 F univ, .comp contDiffOn_sqrt_shift (mapsTo_univ). Target type ContDiffOn ℝ 2 (F ∘ (√·+1)) (Ioi 20) but mFblock F is fun m => (-2) * F (√m+1) — with const.mul wrapping. The composition produces (F ∘ g) — and the block is c * (F ∘ g)? mFblock F n = (-2) * F(√n+1) = ((-2) • ... the code: `contDiffOn_const.mul (hF.contDiffOn.comp ...)` gives ContDiffOn ℝ 2 ((fun _ => -2) * (F ∘ g))? mul of functions: ((fun _ => -2) * (F∘g)) m = -2 * F(g m) ✓ defeq to mFblock — and `unfold mFblock` at the start handles it. With hF : ContDiffOn ℝ 2 F (Ioi 1): `hF.comp contDiffOn_sqrt_shift mapsTo_sqrt_shift_Ioi1 : ContDiffOn ℝ 2 (F ∘ fun m => √m+1) (Ioi 20)` ✓ same shape.\n\nOrder of edits in the file — plan:\n1. Add `mapsTo_sqrt_shift_Ioi1` + Ici variant near mapsTo_sqrt_shift.\n2. Modify `chain_rule_sqrt_shift_on` (add c param) + update 8 call sites in marginTilde_convex.\n3. Modify `contDiffOn_mFblock`, `continuousOn_marginExpanded`, `contDiffOn_marginExpanded`, `marginTilde_convex` signatures + bodies.\n4. Add sInftyLower def + refactor sInfty_lower_bound statement.\n5. Add FAlt/Bn/Sf/SfBoundProp defs + marginTilde_eq_sub.\n6. Add psiOf block lemmas (#1 T·log T, #3 log, #4 log log, const) + psiOf_add/const_mul + psiOf_FAlt_neg + contDiffOn_FAlt.\n7. pos_of_convex_of_base.\n8. lambda_pos_finite_height assembly (hbase/hbase′ hypotheses interim).\n9. Compile; fix; PrintAxioms.\n\nNote the derivative base point (hbase′) — for the aux theorem I'll take hbase/hbase′ as hypotheses; 12.3 discharges. Actually — wait. Let me reconsider whether to even keep them as hypotheses in the FINAL main theorem or do 12.3 now. The final deliverable this session per notes: \"state lambda_pos_finite_height with SfBound named hypothesis and discharge the full assembly conditional on it\". If hbase/hbase′ remain hypotheses, the claim is \"modulo SfBound + 2 elementary numeric evaluations\" — slightly weaker than the notes' target but the numeric evaluations are CLEARLY computational-perimeter-class (E-028/E-029 verified). Best effort: try to discharge them this session (12.3); if it gets long, split.\n\nTime to write code. Also update the file header comment (stage note) — minimal.\n\nOne more consideration: `SfBoundProp` — as a def Prop, then hypothesis (hSf : SfBoundProp). For the eventual triage the Prop must be exactly right. Also note N₀ = 80000 choice: with FAlt (slightly bigger than Trudgian F), margiñ(80000) ≈ 15 724 > 0 ✓ still fine (E-028's margiñ = 16020 was with Trudgian F; FAlt adds ~0.9·T ≈ 256... wait actually let me recheck: does E-028's B(n) use 2N ≤ 2F + 2S_b (F = Trudgian smooth part)? D-037 §4: \"|Σ| ≤ 2N(T) ≤ 2F(T) + 2S_bnd(T)\". So E-028's B has 2(F+S_b) with F_Tru. FAlt = (1/2π)T log T + S_b + 7/8 + ... vs F_Tru + S_b = (1/2π)T log(T/2πe) + S_b + 7/8. FAlt − (F_Tru+S_b) = (1/2π)[T log T − T log(T/2πe)] = (T/2π)·log(2πe) = (T/2π)(2.83788) ≈ 0.4516·T ≈ 128 at T = 283.8. Times 2 (the B term is 2F): +256 to B. margin 16020 → 15764. ✓ fine. margin′ effect: (log(2πe)/2π)·(1/2√n)·... derivative of 2·0.4516·(√n+1) w.r.t. n = 0.4516/√n ≈ 0.0016. margin′ 3.7 → 3.698 ✓.\n\nOK. Also should double check `Real.exp 4` bounds availability for base points — later.\n\nLet me also double-check the exact form of `exists_deriv_eq_slope` call: from source, section variables. Let me look at lines ~125-155 of MeanValue.lean to see variable binder order.","signature":""},{"type":"text","text":"Both Mathlib lemmas confirmed. Checking `exists_deriv_eq_slope` binder order, then implementing."},{"type":"tool_use","id":"Bash_27","name":"Bash","input":{"command":"sed -n '100,152p' D:/Python/Quantum/zeta-23-lean/.lake/packages/mathlib/Mathlib/Analysis/Calculus/Deriv/MeanValue.lean | grep -n \"variable\\|theorem exists_deriv_eq_slope\" ","description":"Check variable binders for MVT theorem"},"extra_content":null}]