Current task: —

← Session 22 — ii′-1: liCoeff pairing fix + residue machinery

#1098 assistant 2026-08-22 08:15:38.632 UTC · 817→11577 tok open ⤢
thinking (29736 chars)
Committed. Now Section 5: identity principle + iterated derivatives + reindexing + final assembly. It's late but I'm in flow. Let me continue — this is the last big chunk for piece (A). Section 5 plan: ```lean /-! ## 5. The identity on the domain and the polygamma values -/ /-- digamma = DinfC on dpsiDomain (identity principle through the real segment). -/ lemma digamma_eq_DinfC_on : Set.EqOn Complex.digamma DinfC dpsiDomain := by apply AnalyticOnNhd.eqOn_of_preconnected_of_frequently_eq digamma_analyticOn DinfC_analyticOn dpsiDomain_convex.isPreconnected dpsiDomain_half -- ∃ᶠ z in 𝓝[≠] ↑(1/2), digamma z = DinfC z ... ``` The frequently argument: use the sequence x_n = 1/2 + 1/(n+2) : ℝ for n ≥ 1 (so 1/(n+2) ≤ 1/3 < 1/2 ⟹ x_n ∈ (0,1)): z_n := ↑x_n → ↑(1/2), z_n ≠ ↑(1/2), digamma z_n = DinfC z_n ✓. The frequently-from-sequence: there should be `Filter.Frequently` bridge: a sequence y_n → z₀ with y_n ≠ z₀ and P y_n for all n — then ∃ᶠ z in 𝓝[≠] z₀, P z — via: `frequently_nhdsWithin_...`? hmm. Let me think of the cleanest formalization: ∃ᶠ z in 𝓝[≠] z₀, P z — where P z := (digamma z = DinfC z). Take S := {z | P z}. The real-segment points ↑x with x ∈ (0,1), x ≠ 1/2 are in S (digamma_eq_DinfC_ofReal). So S ⊇ ofReal '' ((0,1) ∖ {1/2}). And ↑(1/2) is a limit of points in that image: the map ofReal is continuous + injective; (0,1)∖{1/2} has 1/2 as accumulation point (in ℝ). Formalization via `frequently_iff`: ∃ᶠ z in 𝓝[≠] z₀, P z ⟺ ∀ U ∈ 𝓝[≠] z₀, ∃ z ∈ U, P z. For U ∈ 𝓝[≠] ↑(1/2): U ∈ nhdsWithin — contains a punctured ball: from mem_nhdsWithin: ∃ V ∈ 𝓝 ↑(1/2), V ∩ {↑(1/2)}ᶜ ⊆ U. Take V ∈ 𝓝 ↑(1/2): the preimage ofReal⁻¹' V ∈ 𝓝 (1/2) (continuity of ofReal: `Complex.continuous_ofReal.tendsto` ✓) — so ∃ a real x with x ∈ ofReal⁻¹'V, x ≠ 1/2, x ∈ (0,1) — ofReal⁻¹'V is a nhd of 1/2 in ℝ, so it contains points of (0,1)∖{1/2} (every nhd of 1/2 does: ofReal⁻¹'V ∩ (Ioo 0 1 ∖ {1/2}) nonempty — since Ioo 0 1 ∖ {1/2} ∈ 𝓝[≠] (1/2)-ish and ofReal⁻¹'V ∈ 𝓝 (1/2) — the intersection of a nhd with a dense-ish punctured set is nonempty: ofReal⁻¹'V contains an interval (1/2 − δ, 1/2 + δ) (metric nhds) — pick x := 1/2 + min(δ/2, 1/4) ∈ (0,1), x ≠ 1/2, ↑x ∈ V, ↑x ≠ ↑(1/2) (injective) ⟹ ↑x ∈ V ∩ {↑(1/2)}ᶜ ⊆ U and P (↑x) ✓. Formalize: ```lean rw [frequently_iff_forall_exists?] -- check name: `Filter.frequently_iff`? ``` Let me use the direct: `Filter.Frequently` — there is `frequently_iff_forall_exists`? or `frequently_iff : (∃ᶠ x in l, P x) ↔ ∀ U ∈ l, ∃ x ∈ U, P x` — I'm fairly sure `Filter.frequently_iff` exists with that form... — hmm — actually I recall `frequently_iff : (∃ᶠ x in l, P x) ↔ ∀ {U}, U ∈ l → ∃ x ∈ U, P x` ✓. For U ∈ 𝓝[≠] z₀: extract via `mem_nhdsWithin_iff_exists_mem_nhds_inter`? — hmm the exact name: `mem_nhdsWithin_iff_exists_mem_nhds_inter : s ∈ 𝓝[t] a ↔ ∃ U ∈ 𝓝 a, U ∩ t ⊆ s`? — I recall `mem_nhdsWithin_iff_exists_mem_nhds_inter` ✓ exists. Then V ∈ 𝓝 ↑(1/2): Metric.mem_nhds_iff gives ball(↑(1/2), δ) ⊆ V for some δ > 0 — then the point z := ↑((1/2) + min (δ/2) (1/4)) — hmm as ℂ: ↑(1/2 + min (δ/2) (1/4)) — in the ball (dist = min(δ/2,1/4) < δ ✓) — ≠ ↑(1/2) (min > 0 ✓) — ∈ U via the inter-subset (z ∈ V since ball ⊆ V, z ∈ {↑(1/2)}ᶜ ✓) — and P z via digamma_eq_DinfC_ofReal with x := 1/2 + min(δ/2)(1/4) ∈ (0,1): min(δ/2, 1/4) ≤ 1/4 ⟹ x ≤ 3/4 < 1 ✓ and x > 1/2 > 0 ✓ so x ∈ Ioo 0 1 ✓. Hmm wait — I realize I need to double check the agreement lemma covers x ∈ (0,1) — digamma_eq_DinfC_ofReal (hx : x ∈ Set.Ioo 0 1) ✓ — and the point ↑x is in dpsiDomain? — for the frequently I only need P z = (digamma z = DinfC z) — which the ofReal lemma gives for x ∈ Ioo 0 1 ✓ — no domain membership needed for the frequently point itself (the identity principle's hfg is just about the equality set). ✓ Then digamma_eq_DinfC_on : EqOn digamma DinfC dpsiDomain ✓. Then the polygamma values at 1/2: ```lean /-- The iterated derivatives of the inv-shift terms on the domain. -/ lemma iteratedDerivWithin_neg_inv_add (k : ℕ) (c : ℂ) {s : ℂ} (hs : s + c ≠ 0) (hsU : s ∈ dpsiDomain) : iteratedDerivWithin k (fun s => -(s + c)⁻¹) dpsiDomain s = -((-1 : ℂ))^k * (k ! : ℂ) * (s + c) ^ (-(k : ℤ) - 1) := by induction k generalizing s with | zero => simp [dpsiDomain]... -- iteratedDerivWithin 0 = f: -(s+c)⁻¹ = -(0!·(s+c)^{-1}) ✓ | succ k ih => ... ``` Hmm — the Within forms + the point-dependence: iteratedDerivWithin at s needs s ∈ domain — the induction generalizing s is awkward (the succ step relates derivWithin at s of the k-th — the k-th as a FUNCTION on the domain...). Let me instead prove the UNrestricted version on the open domain: since dpsiDomain is open, iteratedDerivWithin k f dpsiDomain s = iteratedDeriv k f s for s ∈ dpsiDomain (iteratedDerivWithin_of_isOpen ✓ dpsiDomain_isOpen ✓). So prove the plain iteratedDeriv version: ```lean lemma iteratedDeriv_neg_inv_add_const (k : ℕ) (c : ℂ) (s : ℂ) (hs : s + c ≠ 0) : iteratedDeriv k (fun s => -(s + c)⁻¹) s = -((-1 : ℂ))^k * (k ! : ℂ) * (s + c) ^ (-(k : ℤ) - 1) := by induction k generalizing s with | zero => simp [iteratedDeriv_zero] -- -(s+c)⁻¹ = -(1·(s+c)^{-1}): the RHS: -(−1)⁰·0!·(s+c)^(0−1) = -(s+c)⁻¹ ✓ — zpow (−1:ℤ) = (·)⁻¹: zpow_neg_one ✓ simp | succ k ih => have e : (fun s => -(s + c)⁻¹) = fun s => -((s + c) ^ (-1 : ℤ)) := by funext s; rw [zpow_neg_one] rw [e] at ih ⊢ -- hmm the original function's form ... ``` Hmm — let me define the function as zpow from the start: claim for all k: iteratedDeriv k (fun s => -((s + c)^(-1:ℤ))) s = -(−1)^k·k!·(s+c)^(-(k+1:ℤ))... — let me use the clean zpow forms throughout. The induction step: iteratedDeriv (k+1) F s = deriv (iteratedDeriv k F) s [iteratedDeriv_succ'] — iteratedDeriv k F = fun s => −(−1)^k·k!·(s+c)^(−(k+1):ℤ) [as a function — ih is pointwise at s — for the deriv I need the function-level: funext from ih applied at all s with s + c ≠ 0 — but the deriv at s only sees a nhd — if s + c ≠ 0, on a small ball around s all points have +c ≠ 0 ✓ — so the function equality holds on a nhd — deriv congruent — need `EventuallyEq.deriv`-style. Manage via: show the function G_k := fun s => −(−1)^k·k!·(s+c)^z agrees with iteratedDeriv k F on the open set {s | s + c ≠ 0} — then deriv at s (in the open set) equal — `Set.EqOn.deriv`? — there's `Set.EqOn.deriv_eq`? hmm — or derivWithin route: derivWithin f U x = deriv f x for U open — then Set.EqOn.derivWithin ✓ (`Set.EqOn.derivWithin (h : EqOn f g s) (hx : x ∈ s)? : derivWithin f s x = derivWithin g s x`? — hmm — EqOn.derivWithin doesn't need hx I think: `Set.EqOn.derivWithin (h : EqOn f g s) : derivWithin f s = derivWithin g s`? — there's `Set.EqOn.derivWithin`? — I recall `Set.EqOn.derivWithin_eq`? ... let me just use the nhds argument: {s | s+c ≠ 0} is open (preimage of {0}ᶜ under continuous +c) — and s ∈ it — so f =ᶠ[𝓝 s] G_k (from the EqOn on the open set: `Set.EqOn.eventuallyEq_of_mem`? — `Set.EqOn.eventuallyEq (h : EqOn f g s) (hs : s ∈ 𝓝 x)? : f =ᶠ[𝓝 x] g`? — hmm — `Set.EqOn.eventuallyEq_of_mem (h : EqOn f g s) (hs : s ∈ 𝓝 x) : f =ᶠ[𝓝 x] g` ✓ something like that) — then EventuallyEq.deriv_eq : deriv f s = deriv g s ✓ (used in LiResidue ✓). So the induction: ```lean lemma iteratedDeriv_neg_inv_zpow_add_const (k : ℕ) (c : ℂ) {s : ℂ} (hs : s + c ≠ 0) : iteratedDeriv k (fun s => -((s + c) ^ (-1 : ℤ))) s = -((-1 : ℂ)) ^ k * (k ! : ℂ) * (s + c) ^ (-(k : ℤ) - 1) := by induction k generalizing s with | zero => simp | succ k ih => rw [iteratedDeriv_succ'] -- deriv (iteratedDeriv k F) s — replace by deriv G_k s via eventual eq have hopen : IsOpen {s : ℂ | s + c ≠ 0} := isOpen_compl_singleton... — {s | s + c ≠ 0} = preimage of {0}ᶜ under (·+c): isOpen_compl_singleton.preimage (continuous_add_const?) — or: {s | s + c ≠ 0} = {−c}ᶜ under the homeomorph... — use: (Homeomorph.addLeft (−c))... hmm — simplest: {s | s + c ≠ 0} = (fun s => s + c) ⁻¹' {0}ᶜ — continuous (continuous_add_const c? — `continuous_add_const (c : ℂ) : Continuous fun x => x + c`? hmm — or (continuous_add_left c)? — `continuous_id.add continuous_const` ✓) — isOpen_compl_singleton.preimage that ✓. have hev : (fun s => iteratedDeriv k (fun s => -((s + c) ^ (-1 : ℤ))) s) =ᶠ[𝓝 s] (fun s => -((-1 : ℂ)) ^ k * (k ! : ℂ) * (s + c) ^ (-(k : ℤ) - 1)) := by have hmem : {s : ℂ | s + c ≠ 0} ∈ 𝓝 s := hopen.mem_nhds hs filter_upwards [hmem] with y hy exact ih hy rw [hev.deriv_eq] -- compute deriv of G_k at s ... ``` The deriv computation: deriv (fun s => C·(s+c)^(-(k+1):ℤ)) s with C := −(−1)^k·k!: = C · (−(k+1):ℤ)·(s+c)^(−(k+1)−1)·1 — via deriv_const_mul + the zpow comp: hasDerivAt_zpow (−(k+1):ℤ) (s+c) (Or.inl hs) — comp with (s+c) (deriv 1) — then .deriv — pattern from deriv_Gprim (LiPrincipal) ✓. Then the algebra: −(−1)^k k! · (−(k+1))·(s+c)^(−(k+2))·... = −(−1)^{k+1}(k+1)!(s+c)^{−(k+2)}: (−(k+1):ℤ) as ℂ = −(k+1) — the casts: ((-(k+1 : ℤ)) : ℂ) — hmm — hasDerivAt_zpow gives the derivative ((m : ℤ) : ℂ) · x^(m−1) with m := −(k+1): the cast (−(k+1):ℤ)→ℂ — push_cast handles ✓. And k!→(k+1)!: Nat.factorial_succ ✓. The final form: −(−1)^{k+1}·(k+1)!·(s+c)^(−(k+2) : ℤ) — and the exponent: −(k+1)−1 = −(k+2) ✓ omega/push_cast. Then the assembly for the series: the k-th iteratedDerivWithin of the sum function — using iteratedDerivWithin_tsum with: - hsum : ∀ t ∈ dpsiDomain, Summable (fun m => dpsiTermC · t) ✓ dpsiTermC_summable. - h : ∀ k, 1 ≤ k → k ≤ m → SummableLocallyUniformlyOn (fun m => iteratedDerivWithin k (fun s => dpsiTermC s m) dpsiDomain) dpsiDomain: the iteratedDerivWithin of the term: dpsiTermC s m = 1/(↑m+1) − (s+↑m+1)⁻¹·... — = const + (−(s+↑m+1)⁻¹): iteratedDerivWithin k of a sum — sum rule (ContDiffOn needed) — the const's iteratedDerivWithin k = 0 for k ≥ 1 (iteratedDerivWithin_const? — there should be `iteratedDerivWithin_const (hn : 0 < k)?`... — check — there's iteratedDeriv_const (Defs.lean:357 — the if-form) and Within versions — iteratedDerivWithin_const exists presumably ✓). So the term's k-th iteratedDerivWithin = −(−1)^k·k!·(s+↑m+1)^{−(k+1)} (from the zpow lemma + Within-of-isOpen ✓). SummableLocallyUniformlyOn of THAT family on dpsiDomain: ‖−(−1)^k k!(s+↑m+1)^{−(k+1)}‖ = k!/‖s+↑m+1‖^{k+1} ≤ k!/(m+1)^{k+1}·(adjust) — for s ∈ dpsiDomain: ‖s+↑m+1‖ ≥ re s + m + 1 > m + 1 — so ≤ k!/(m+1)^{k+1} — summable for k ≥ 1 (k+1 ≥ 2 ✓) — via SummableLocallyUniformlyOn_of_locally_bounded (dpsiDomain_isOpen) with the compact argument: for K compact ⊆ dpsiDomain: min re on K ≥ c > 0 — hmm — actually simpler bound directly: ‖s+↑m+1‖ ≥ (m+1) — wait — ‖s + ↑m + 1‖ ≥ re(s+↑m+1) = re s + m + 1 ≥ m + 1 (re s > 0) — hmm — that gives ≤ k!/(m+1)^{k+1} — INDEPENDENT of K — so even SummableUniformlyOn-ish... the bound ‖s+↑m+1‖ ≥ re(s+↑m+1) needs (s+↑m+1).re ≥ 0 for the |re| step: re s + m + 1 > 0 ✓ — so ‖term‖ ≤ k!/(m+1)^{k+1} uniformly on the WHOLE domain ✓ — so HasSumUniformlyOn.of_norm_le_summable directly ✓ and SummableLocallyUniformlyOn from HasSumUniformlyOn... — `HasSumUniformlyOn.summableLocallyUniformlyOn`? — there's the of_locally_bounded lemma needing the compact argument — or maybe HasSumUniformlyOn implies SummableLocallyUniformlyOn directly — `HasSumUniformlyOn.summableLocallyUniformlyOn (hs : IsOpen s)?`? — from of_locally_bounded_eventually's proof: `HasSumLocallyUniformlyOn.summableLocallyUniformlyOn (g := ...)` — there's HasSumLocallyUniformlyOn.summableLocallyUniformlyOn — and HasSumUniformlyOn → HasSumLocallyUniformlyOn: `HasSumUniformlyOn.hasSumLocallyUniformlyOn`? — name... — I'll navigate at compile. - hf2 : the differentiability conditions ✓ (each term's iteratedDerivWithin is differentiable on the domain — they're zpow functions, differentiable off the pole ✓). Then iteratedDerivWithin_tsum m dpsiDomain_isOpen (1/2 ∈ domain) hsum h hf2 : iteratedDerivWithin m (fun s => ∑' n, dpsiTermC s n) dpsiDomain (1/2) = ∑' n, iteratedDerivWithin m (dpsiTermC · n) dpsiDomain (1/2) — then Within-of-isOpen both sides + the term values + the sum evaluation: Σ_{m≥0} −(−1)^k k!(1/2+↑m+1)^{−(k+1)} = −(−1)^k k! Σ_{m≥0}(1/2+m+1)^{−(k+1)} — hmm wait — the dpsiTermC's index m corresponds to 1/(m+1) − 1/(s+m+1) — so the pole-shift is m+1 — the sum Σ_{m≥0}(1/2 + m + 1)^{−(k+1)} = Σ_{m'≥1}(1/2+m')^{−(k+1)}·... — and then plus the −1/s term's contribution −(−1)^k k!(1/2)^{−(k+1)} — total Σ_{m'≥0}(1/2+m')^{−(k+1)} — via tsum shifts ✓. Hmm — wait — careful about the DinfC structure: DinfC s = −γ − 1/s + ∑' m, dpsiTermC s m — the iteratedDerivWithin k of the WHOLE DinfC = the (−γ − 1/s) part's + the series' — via iteratedDerivWithin_add (ContDiffOn of each ✓): the −γ − 1/s part gives 0 + (−(−1)^k k! s^{−(k+1)})... — wait −1/s = −s⁻¹ = −(s^(−1:ℤ)) — its k-th: −(−1)^k k! s^{−(k+1)} ✓. So: iteratedDeriv k DinfC (1/2) = −(−1)^k k!(1/2)^{−(k+1)} + Σ_{m≥0} [−(−1)^k k!(1/2+↑m+1)^{−(k+1)}] = −(−1)^k k! [ (1/2)^{−(k+1)} + Σ_{m≥0} (3/2+m)^{−(k+1)} ] [(1/2 + m + 1) = 3/2 + m] = −(−1)^k k! Σ_{m≥0} (1/2 + m)^{−(k+1)} [tsum_eq_zero_add: Σ_{m≥0}(1/2+m)^{−(k+1)} = (1/2)^{−(k+1)} + Σ_{m≥0}(1/2+(m+1))^{−(k+1)} ✓ the shift ✓] = −(−1)^k k! Σ_{m≥0} (m + 1/2)^{−(k+1)} ✓. For k = j ≥ 1: −(−1)^j = (−1)^{j+1} ✓. So iteratedDeriv j DinfC (1/2) = (−1)^{j+1} j! Σ_{m≥0}(m+1/2)^{−(j+1)} ✓✓ THE POLYGAMMA FORMULA. Then digamma's: via EqOn (digamma_eq_DinfC_on) + the eventualEq-iteratedDeriv helper. Hmm — I need the "iteratedDeriv of eventually-equal functions" helper. Let me write it: ```lean lemma iteratedDeriv_congr_of_eventuallyEq {f g : ℂ → ℂ} {x : ℂ} (h : f =ᶠ[𝓝 x] g) (n : ℕ) : iteratedDeriv n f x = iteratedDeriv n g x := by induction n with | zero => simp [iteratedDeriv_zero] -- f x = g x from h (self_of_nhds) | succ n ih => -- need f' =ᶠ g' eventually — from h on a nhd ... ``` The step: iteratedDeriv (n+1) f x = deriv (iteratedDeriv n f) x [succ'] — and iteratedDeriv n f =ᶠ[𝓝 x] iteratedDeriv n g — from h: on the nhd where f = g, the iterated derivs... — the induction hypothesis needs the eventual-eq of the n-th iterated derivs — which follows from the deriv-level argument: if f =ᶠ[𝓝 x] g then deriv f =ᶠ[𝓝 x] deriv g — is there `Filter.EventuallyEq.deriv`? — hmm. Let me think: f =ᶠ[𝓝 x] g means f = g on some nhd V of x. For y ∈ V: deriv f y = deriv g y? — deriv at y sees only a small nhd ⊆ V ✓ — deriv f y = deriv g y requires f =ᶠ[𝓝 y] g (which holds since V ∈ 𝓝 y for y ∈ V-open...). So deriv f = deriv g on V's interior ⊇ V (V open) — hence deriv f =ᶠ[𝓝 x] deriv g. The direct Mathlib lemma: `Filter.EventuallyEq.deriv`? Let me check — hmm — there's `Filter.EventuallyEq.deriv_eq (h : f =ᶠ[𝓝 x] g) : deriv f x = deriv g x` ✓ (used in LiResidue). For the within/nhd version of the DERIVED functions: `Filter.EventuallyEq.deriv (h : f =ᶠ[𝓝 x] g) : deriv f =ᶠ[𝓝 x] deriv g`? — I believe `EventuallyEq.deriv` might NOT exist... Let me search. If missing, prove via: obtain ⟨V, hV, hVopen?...⟩ — from h : ∃ U ∈ 𝓝 x, EqOn f g U — `EventuallyEq.exists_mem`? — then for the eventually-of-derivs: nhds within... OK let me just write: ```lean lemma eventuallyEq_deriv {f g : ℂ → ℂ} {x : ℂ} (h : f =ᶠ[𝓝 x] g) : deriv f =ᶠ[𝓝 x] deriv g := by obtain ⟨U, hU, hfg⟩ := h.exists_mem -- U ∈ 𝓝 x, EqOn f g U — `EventuallyEq.exists_mem : f =ᶠ[l] g → ∃ s ∈ l, Set.EqOn f g s`? — hmm — `Filter.EventuallyEq.exists_mem : f =ᶠ[l] g → ∃ s ∈ l, Set.EqOn f g s`? — I recall `EventuallyEq.exists_mem`... or use h directly: h is ∀ᶠ y in 𝓝 x, f y = g y — so the set S := {y | f y = g y} ∈ 𝓝 x. ... ``` Let me do: S := {y | f y = g y} ∈ 𝓝 x (from h). Interior S is open, x ∈ interior S (x ∈ S and S ∈ 𝓝 x ⟹ x ∈ interior S ✓ `mem_interior_iff_mem_nhds.mpr h`-ish). Then ∀ y ∈ interior S: f =ᶠ[𝓝 y] g (interior S ∈ 𝓝 y ✓ + subset) ⟹ deriv f y = deriv g y (EventuallyEq.deriv_eq). So {y | deriv f y = deriv g y} ⊇ interior S ∈ 𝓝 x ⟹ deriv f =ᶠ[𝓝 x] deriv g ✓. ```lean lemma eventuallyEq_deriv {f g : ℂ → ℂ} {x : ℂ} (h : f =ᶠ[𝓝 x] g) : deriv f =ᶠ[𝓝 x] deriv g := by have hS : {y | f y = g y} ∈ 𝓝 x := h have h2 : interior {y | f y = g y} ∈ 𝓝 x := interior_mem_nhds.mpr hS -- interior_mem_nhds : s ∈ 𝓝 x ↔ interior s ∈ 𝓝 x? — `interior_mem_nhds : s ∈ 𝓝 a ↔ interior s ∈ 𝓝 a`? — there's `interior_mem_nhds (h : s ∈ 𝓝 x) : interior s ∈ 𝓝 x`? — `interior_mem_nhds.mpr`? the iff is `mem_interior_iff_mem_nhds : x ∈ interior s ↔ s ∈ 𝓝 x` — I want: interior s ∈ 𝓝 x from s ∈ 𝓝 x: since interior s ⊆ ... no — interior s might not contain x?? — x ∈ interior s ⟺ s ∈ 𝓝 x (mem_interior_iff_mem_nhds) — so x ∈ interior S ✓ — then interior S ∈ 𝓝 x (a set containing a point in its... no — interior S is open and contains x ⟹ ∈ 𝓝 x via IsOpen.mem_nhds ✓ `IsOpen.mem_nhds isOpen_interior ‹x ∈ interior S›`) ✓. filter_upwards [IsOpen.mem_nhds isOpen_interior (mem_interior_iff_mem_nhds.mpr hS)] with y hy -- y ∈ interior S: f =ᶠ[𝓝 y] g (interior S ⊆ S, ∈ 𝓝 y) have h3 : f =ᶠ[𝓝 y] g := by apply Filter.eventually_of_mem (IsOpen.mem_nhds isOpen_interior hy) -- hmm the eventual statement about equality at points near y intro z hz exact interior_subset hz -- z ∈ S exact h3.deriv_eq ``` Hmm — Filter.eventually_of_mem (hs : s ∈ l) (h : ∀ x ∈ s, P x)? : ∀ᶠ x in l, P x — `Filter.eventually_of_mem (hl : s ∈ l) (h : ∀ x ∈ s, P x) : ∀ᶠ x in l, P x`? — there's `eventually_of_mem` ✓ (used in vendored code). And EventuallyEq.deriv_eq : (h : f =ᶠ[𝓝 x] g) → deriv f x = deriv g x ✓. Then: ```lean lemma iteratedDeriv_congr_of_eventuallyEq {f g : ℂ → ℂ} {x : ℂ} (h : f =ᶠ[𝓝 x] g) (n : ℕ) : iteratedDeriv n f x = iteratedDeriv n g x := by induction n with | zero => rw [iteratedDeriv_zero, iteratedDeriv_zero] exact h.self_of_nhds | succ n ih => rw [iteratedDeriv_succ', iteratedDeriv_succ'] -- deriv (iteratedDeriv n f) x = deriv (iteratedDeriv n g) x — need the eventuallyEq of the n-th have hev : iteratedDeriv n f =ᶠ[𝓝 x] iteratedDeriv n g := by -- from h via iteration of eventuallyEq_deriv — hmm the ih is pointwise... ``` Hmm — the induction structure: the IH should be the EVENTUAL-EQ of the n-th derivs, not the point value. Restructure: prove the stronger statement: iteratedDeriv n f =ᶠ[𝓝 x] iteratedDeriv n g by induction: - n = 0: iteratedDeriv 0 f = f ✓ h. - succ: iteratedDeriv (n+1) f = deriv (iteratedDeriv n f) =ᶠ[𝓝 x] deriv (iteratedDeriv n g) = iteratedDeriv (n+1) g — via eventuallyEq_deriv applied to the IH + the succ' rewrites (function-level: iteratedDeriv_succ' : iteratedDeriv (n+1) f = deriv (iteratedDeriv n f)? — from session-017 note: iteratedDeriv_succ' pushes deriv inside: iteratedDeriv (n+1) f = iteratedDeriv n (deriv f)!! — for the function-level deriv-of-iterated I need `iteratedDeriv_succ : iteratedDeriv (n+1) f = deriv (iteratedDeriv n f)` ✓ (the OTHER one). ```lean lemma eventuallyEq_iteratedDeriv {f g : ℂ → ℂ} {x : ℂ} (h : f =ᶠ[𝓝 x] g) (n : ℕ) : iteratedDeriv n f =ᶠ[𝓝 x] iteratedDeriv n g := by induction n with | zero => simpa [iteratedDeriv_zero] using h | succ n ih => rw [iteratedDeriv_succ, iteratedDeriv_succ] exact eventuallyEq_deriv ih lemma iteratedDeriv_congr_of_eventuallyEq {f g : ℂ → ℂ} {x : ℂ} (h : f =ᶠ[𝓝 x] g) (n : ℕ) : iteratedDeriv n f x = iteratedDeriv n g x := (eventuallyEq_iteratedDeriv h n).self_of_nhds ``` Hmm — `EventuallyEq.self_of_nhds : f =ᶠ[𝓝 x] g → f x = g x` ✓ (used in LiPrincipal: hfh.self_of_nhds ✓). OK. And the reindexing (A6): Σ_{m≥0} (↑m + 1/2)^{−(j+1)} = 2^{j+1}·lagariasA(j+1) as ℂ: - (↑m + 1/2 : ℂ)^{−(j+1)} — hmm zpow or 1/(·)^{j+1}? — let me use the 1/(m+1/2)^{j+1} npow form for the final series. From the iterated value: Σ_{m≥0}(1/2+↑m)^{−(j+1)} (zpow form) — convert: (1/2+↑m)^{−(j+1)} zpow = 1/(1/2+↑m)^{j+1} ✓ (zpow_neg_natCast? — `zpow_neg_natCast`? — zpow (−(j+1):ℤ) x = 1/x^(j+1) — `zpow_neg`+`zpow_natCast` ✓ or `zpow_neg_natCast...`? — there's `zpow_neg_natCast : x ^ (-(n:ℤ)) = 1 / x ^ n`? — roughly ✓). - (1/2 + ↑m)^{−(j+1)} = (2^{j+1})/(1+2↑m)^{j+1}: (1/2+↑m) = (1+2↑m)/2 — so (1/2+↑m)^{j+1} = (1+2↑m)^{j+1}/2^{j+1} — reciprocal ✓. - Σ_{m≥0} 1/(1+2↑m)^{j+1}·2^{j+1}... — the reindex to the odd sum: Σ_{m≥0} 1/(2m+1)^{j+1} = lagariasA(j+1): lagariasA(j+1) = 1 + Σ_{m : {odd ∧ ≥3}} (1/↑m)^{j+1} (if_neg since j+1 ≥ 2 ✓) — and Σ_{m≥0} 1/(2m+1)^{j+1} = 1/(2·0+1)^{j+1} + Σ_{m≥0} 1/(2(m+1)+1)^{j+1} [tsum_eq_zero_add] = 1 + Σ_{m≥0}1/(2m+3)^{j+1} — and Σ_{m≥0} 1/(2m+3)^{j+1} = Σ_{m : {odd ∧ ≥3}} 1/m^{j+1} via the equiv φ : ℕ → {m // Odd m ∧ 3 ≤ m}, φ(m) := ⟨2m+3, by odd, by omega⟩ — Equiv.ofBijective: injective: 2m+3 = 2m'+3 ⟹ m = m' ✓ (omega); surjective: ⟨m', odd, ≥3⟩: m' = 2k+1 (odd_iff), k ≥ 1 (3 ≤ 2k+1 ⟹ k ≥ 1), m' = 2(k−1)+3 ✓ take k−1 ✓. Then Equiv.tsum_eq: Σ_{m:ℕ} g(φ m) = Σ_{m' : subtype} g(m') — with g(m') := 1/(↑m')^{j+1} — need g(φ m) = 1/(2m+3)^{j+1} ✓ (↑(2m+3) = 2↑m+3 push_cast ✓). And the tsum forms: lagariasA's tail is over {m // Odd m ∧ 3 ≤ m} with summand (1/(m:ℝ))^j — REAL tsum! — and my series is COMPLEX (1/(2m+1:ℂ)^{j+1}) — so the reindexing happens in ℂ and then relate to the real lagariasA's cast: ↑(lagariasA (j+1)) = 1 + ↑(Σ_{subtype} (1/↑m:ℝ)^{j+1}) — cast the real subtype-tsum to ℂ: ↑(∑' m : subtype, (1/(m:ℝ))^(j+1)) = ∑' m, ↑((1/(m:ℝ))^(j+1)) = ∑' m, 1/(↑m:ℂ)^(j+1) — via ofRealCLM.map_tsum + push_cast ✓ (need the subtype-tail's summability — it's dominated by the p-series ✓ — need a small summability lemma for the tail: Summable (fun m : {m // Odd m ∧ 3 ≤ m} => (1/(m:ℝ))^(j+1)) — hmm — that's `oddSlice_summable`-ADJACENT — oddSlice_summable (LiSwaps) is for (1/(m:ℝ))^j with j ≥ 2 — my exponent here is j+1 with j ≥ 1 ⟹ j+1 ≥ 2 ✓ — so oddSlice_summable (j+1) (by omega) gives Summable (fun m : {odd ∧ ≥3} => (1/(m:ℝ))^(j+1)) ✓✓ REUSE!). So the reindexing chain (all in ℂ, for j ≥ 1): Σ_{m≥0} 1/(↑m + 1/2)^{j+1} = 2^{j+1}·Σ_{m≥0} 1/(2↑m+1)^{j+1} [factor per-term + tsum_mul_left] Σ_{m≥0} 1/(2↑m+1)^{j+1} = 1 + Σ_{m≥0} 1/(2↑m+3)^{j+1} [tsum_eq_zero_add] Σ_{m≥0} 1/(2↑m+3)^{j+1} = Σ_{m' ∈ {odd ∧ ≥3}} 1/(↑m')^{j+1} [the equiv + Equiv.tsum_eq] 1 + Σ_subtype = ↑(lagariasA (j+1)) [lagariasA def if_neg + ofRealCLM.map_tsum the other way] Combine: Σ_{m≥0} 1/(↑m+1/2)^{j+1} = 2^{j+1}·↑(lagariasA (j+1)) ✓. Then the FINAL assembly (in LiArchimedean.lean, since it has the split): ```lean theorem iteratedDeriv_logDeriv_Gammaℝ_one_add (j : ℕ) : iteratedDeriv j (fun s : ℂ => logDeriv Complex.Gammaℝ (1 + s)) 0 = (-1 : ℂ) ^ (j + 1) * (j ! : ℂ) * (lagariasA (j + 1) : ℝ) := by rcases eq_or_lt_of_le (Nat.zero_le j) with hj0 | hj -- j = 0 or j ≥ 1 · subst hj0 -- j = 0: iteratedDeriv 0 = the value = logDeriv Gammaℝ 1 = −lagariasA1 (PROVED) rw [iteratedDeriv_zero] -- RHS: (−1)^1 · 0! · ↑(lagariasA 1) = −↑lagariasA1 rw [lagariasA, if_pos rfl] simp [logDeriv_Gammaℝ_one] · -- j ≥ 1 have hj1 : 1 ≤ j := hj -- the function identity on a nhd of 0: logDeriv Gammaℝ (1+s) = −(log π)/2 + (1/2)·digamma((1+s)/2) have hev : (fun s : ℂ => logDeriv Complex.Gammaℝ (1 + s)) =ᶠ[𝓝 0] (fun s => -(Real.log Real.pi : ℂ) / 2 + (1 / 2) * Complex.digamma ((1 + s) / 2)) := by -- from logDeriv_Gammaℝ_one_add on a small ball where the hyps hold ... rw [iteratedDeriv_congr_of_eventuallyEq hev] -- iteratedDeriv j (const + (1/2)·digamma((1+·)/2)) 0 = (1/2)·iteratedDeriv j (digamma((1+·)/2)) 0 (j ≥ 1) ... -- the affine comp: = (1/2)·(1/2)^j·iteratedDeriv j digamma (1/2) ... -- = (1/2)^{j+1}·(−1)^{j+1} j! Σ_{m≥0}(↑m+1/2)^{−(j+1)} [the series values] -- = (−1)^{j+1} j! · ↑(lagariasA (j+1)) [the reindexing + the 2^{j+1} cancellation] ... ``` The nhd-eventual for the split: need ∀ᶠ s in 𝓝 0, [Gamma((1+s)/2) ≠ 0 ∧ ∀ m, (1+s)/2 ≠ −↑m]: Gamma((1+s)/2) ≠ 0 near 0: Gamma(1/2) ≠ 0 (Gamma_one_half_eq + cpow≠0 ✓) + continuity (Complex.continuousAt_Gamma (s) (hs : ∀ m, s ≠ −m) — exists (Deriv.lean:88)) — Tendsto (fun s => Gamma((1+s)/2)) (𝓝 0) (𝓝 (Gamma(1/2))) — then eventually ≠ 0 since Gamma(1/2) ≠ 0 ✓ (ContinuousAt.eventually_ne ✓). The pole-free: ∀ m, (1+s)/2 ≠ −↑m near 0: (1+s)/2 near 1/2 — the set {−↑m} is closed/discrete — 1/2 ∉ it — {s | (1+s)/2 ∉ {−m's}}: (1+s)/2 ∈ ball(1/2, 1/4)-ish avoids all −m (re > 1/4 > 0 ≥ −m) — so on ball(0, 1/2) (since |(1+s)/2 − 1/2| = |s|/2 < 1/4 for |s| < 1/2): re((1+s)/2) > 1/2 − 1/4 = 1/4 > 0 — and −↑m has re ≤ 0 — so (1+s)/2 ≠ −↑m ✓. So on Metric.ball 0 (1/2): both hyps ✓ — the ball ∈ 𝓝 0 ✓ then logDeriv_Gammaℝ_one_add applies pointwise ✓. The affine comp for digamma((1+s)/2): (1+s)/2 = 1/2 + s/2 = φ(s) with φ = (1/2 + ·)∘(·/2)? — (1+s)/2 — let me define ψ(s) := (1+s)/2 — iteratedDeriv j (digamma ∘ ψ) 0 = (1/2)^j iteratedDeriv j digamma (ψ 0) — ψ 0 = 1/2 ✓. The affine comp lemma — prove: ```lean lemma iteratedDeriv_comp_one_add_div_two (F : ℂ → ℂ) (j : ℕ) (hF : AnalyticAt ℂ F (1 / 2)) : iteratedDeriv j (fun s : ℂ => F ((1 + s) / 2)) 0 = (1 / 2 : ℂ) ^ j * iteratedDeriv j F (1 / 2) := by induction j with | zero => simp [iteratedDeriv_zero] | succ j ih => rw [iteratedDeriv_succ, iteratedDeriv_succ] -- deriv (iteratedDeriv j (F∘φ)) 0 = deriv (fun s => (1/2)^j · iteratedDeriv j F (φ s)) 0 [by ih as functions near 0] ... ``` The IH is pointwise at 0 — for the deriv I need the function equality near 0: iteratedDeriv j (F∘φ) = fun s => (1/2)^j · iteratedDeriv j F (φ s) on a nhd of 0 — the IH at OTHER points near 0 — the induction should be generalizing the point... let me restructure: prove the eventuallyEq version directly: ```lean lemma iteratedDeriv_comp_one_add_div_two' (F : ℂ → ℂ) (j : ℕ) (hF : AnalyticAt ℂ F (1 / 2)) : iteratedDeriv j (fun s : ℂ => F ((1 + s) / 2)) 0 = (1 / 2 : ℂ) ^ j * iteratedDeriv j F (1 / 2) := by induction j with | zero => simp [iteratedDeriv_zero] | succ j ih => have hFan : ∀ᶠ s in 𝓝 (0:ℂ), AnalyticAt ℂ F ((1+s)/2) := by -- (1+s)/2 → 1/2 as s → 0; F analytic at 1/2 ⟹ near 1/2 (eventually_analyticAt) have h1 : AnalyticAt ℂ F (1/2) := hF have h2 : Tendsto (fun s : ℂ => (1+s)/2) (𝓝 0) (𝓝 (1/2)) := by have : ContinuousAt (fun s : ℂ => (1+s)/2) 0 := (continuousAt_id.add continuousAt_const).div continuousAt_const simpa using this.tendsto exact h2.eventually h1.eventually_analyticAt -- the iteratedDeriv functions agree near 0 have hev : (fun s : ℂ => iteratedDeriv j (fun t => F ((1 + t) / 2)) s) =ᶠ[𝓝 0] (fun s => (1/2:ℂ)^j * iteratedDeriv j F ((1+s)/2)) := by filter_upwards [hFan] with s hs -- apply a pointwise version of the IH at s?? — the IH is at 0 only — RESTRUCTURE: prove a version at general points... ``` UGH — the point-generalizing induction. Let me just prove the general-point version directly: ```lean lemma iteratedDeriv_comp_affine (F : ℂ → ℂ) (a b : ℂ) (j : ℕ) {s : ℂ} (hF : AnalyticAt ℂ F (a + b * s)) (hF' : ∀ᶠ t in 𝓝 s, AnalyticAt ℂ F (a + b * t)) : iteratedDeriv j (fun t : ℂ => F (a + b * t)) s = b ^ j * iteratedDeriv j F (a + b * s) := by induction j generalizing s with | zero => simp [iteratedDeriv_zero] | succ j ih => rw [iteratedDeriv_succ, iteratedDeriv_succ] -- deriv (iteratedDeriv j (F∘φ)) s = deriv (fun t => b^j · iteratedDeriv j F (a+bt)) s have hev : (fun t => iteratedDeriv j (fun u => F (a + b * u)) t) =ᶠ[𝓝 s] (fun t => b ^ j * iteratedDeriv j F (a + b * t)) := by filter_upwards [hF'] with t ht exact ih ht (hF'.mono fun u hu => ?_) -- hmm the ∀ᶠ for the IH at t ``` The IH at t needs AnalyticAt F (a + b·t) ✓ (ht) and ∀ᶠ u in 𝓝 t, AnalyticAt F (a+b·u) ✓ (from ht.eventually_analyticAt + the continuity of a+b·u at t — Tendsto (fun u => a+b·u) (𝓝 t) (𝓝 (a+b·t)) then eventually composition: (that).eventually ht.eventually_analyticAt : ∀ᶠ u in 𝓝 t, AnalyticAt F (a+b·u) ✓). So: ```lean | succ j ih => rw [iteratedDeriv_succ, iteratedDeriv_succ] have hev : (fun t => iteratedDeriv j (fun u => F (a + b * u)) t) =ᶠ[𝓝 s] (fun t => b ^ j * iteratedDeriv j F (a + b * t)) := by filter_upwards [hF'] with t ht have ht' : ∀ᶠ u in 𝓝 t, AnalyticAt ℂ F (a + b * u) := by have hc : Tendsto (fun u : ℂ => a + b * u) (𝓝 t) (𝓝 (a + b * t)) := by have : ContinuousAt (fun u : ℂ => a + b * u) t := continuousAt_const.add (continuousAt_const.mul continuousAt_id) exact this.tendsto exact hc.eventually ht.eventually_analyticAt exact ih ht ht' rw [hev.deriv_eq] -- deriv (fun t => b^j · iteratedDeriv j F (a+bt)) s = b^j · b · iteratedDeriv (j+1) F (a+bs) rw [deriv_const_mul] -- deriv (iteratedDeriv j F ∘ φ) s = (iteratedDeriv j F)'(φ s) · b have hc : HasDerivAt (fun t : ℂ => a + b * t) b s := by simpa using (hasDerivAt_const s a).add (((hasDerivAt_id s).const_mul b)) have hd : HasDerivAt (iteratedDeriv j F) (iteratedDeriv (j+1) F (a + b*s)) (a + b*s) := by rw [← iteratedDeriv_succ] exact hF.deriv.differentiableAt.hasDerivAt -- iteratedDeriv j F differentiable at a+bs: from hF — AnalyticAt F ⟹ AnalyticAt (iteratedDeriv j F)? — there's `AnalyticAt.iteratedDeriv`? or via deriv j times ✓ — `AnalyticAt.deriv` iterates — hmm — is there AnalyticAt.iteratedDeriv? — there's `AnalyticAt.deriv : AnalyticAt f x → AnalyticAt (deriv f) x` ✓ — and iteratedDeriv j F = deriv^j F — a direct lemma `AnalyticAt.iteratedDeriv`? — maybe not — but (AnalyticAt.deriv)^j — there's `AnalyticAt.iteratedFDeriv`? Let me just note: AnalyticAt.deriv applied j times via a helper or a direct lemma — check for `AnalyticAt.iteratedDeriv` at compile. have hcomp := hd.comp s hc -- hcomp : HasDerivAt (iteratedDeriv j F ∘ (a+b·)) (b * iteratedDeriv (j+1) F (a+bs))?? — order f' * g' or g'•f' — ℂ: mul — f' * b or b * f'... ... ``` This is getting long — the affine comp is a standard-but-fiddly induction (~60 lines). OK. And `AnalyticAt.iteratedDeriv` — let me check it exists: grep.
Continuing. Quick check on `AnalyticAt.iteratedDeriv` and `eventually_of_mem`/`interior` names for the congruence helper.
tool: Bash ok
input
{
  "command": "cd \"D:/Python/Quantum/zeta-23-lean/.lake/packages/mathlib\" && grep -rn \"theorem AnalyticAt.iteratedDeriv\\|lemma AnalyticAt.iteratedDeriv\" Mathlib/Analysis/Calculus/ -r --include=\"*.lean\" | head -2; grep -rn \"theorem EventuallyEq.deriv_eq\\|lemma EventuallyEq.deriv_eq\" Mathlib/Analysis/Calculus/Deriv/*.lean Mathlib/Analysis/Calculus/FDeriv/*.lean 2>/dev/null | head -3; grep -rn \"theorem interior_mem_nhds\\|lemma interior_mem_nhds\" Mathlib/Topology/ --include=\"*.lean\" -r | head -2",
  "description": "Check AnalyticAt.iteratedDeriv, EventuallyEq.deriv_eq, interior_mem_nhds"
}
result 2026-08-22 08:15:38Z → 2026-08-26 08:44:43Z
Scratch.lean:2:8: error(lean.unknownIdentifier): Unknown identifier `MeasureTheory.RCLike.LinearIsometry.ContinuousLinearMap.Basic.intervalIntegral.intervalIntegral_conj`
raw content_json (database row)
[{"type":"thinking","thinking":"Committed. Now Section 5: identity principle + iterated derivatives + reindexing + final assembly. It's late but I'm in flow. Let me continue — this is the last big chunk for piece (A).\n\nSection 5 plan:\n\n```lean\n/-! ## 5. The identity on the domain and the polygamma values -/\n\n/-- digamma = DinfC on dpsiDomain (identity principle through the real segment). -/\nlemma digamma_eq_DinfC_on : Set.EqOn Complex.digamma DinfC dpsiDomain := by\n  apply AnalyticOnNhd.eqOn_of_preconnected_of_frequently_eq digamma_analyticOn DinfC_analyticOn\n    dpsiDomain_convex.isPreconnected dpsiDomain_half\n  -- ∃ᶠ z in 𝓝[≠] ↑(1/2), digamma z = DinfC z\n  ...\n```\nThe frequently argument: use the sequence x_n = 1/2 + 1/(n+2) : ℝ for n ≥ 1 (so 1/(n+2) ≤ 1/3 < 1/2 ⟹ x_n ∈ (0,1)): z_n := ↑x_n → ↑(1/2), z_n ≠ ↑(1/2), digamma z_n = DinfC z_n ✓. The frequently-from-sequence: there should be `Filter.Frequently` bridge: a sequence y_n → z₀ with y_n ≠ z₀ and P y_n for all n — then ∃ᶠ z in 𝓝[≠] z₀, P z — via: `frequently_nhdsWithin_...`? hmm. Let me think of the cleanest formalization:\n\n∃ᶠ z in 𝓝[≠] z₀, P z — where P z := (digamma z = DinfC z). Take S := {z | P z}. The real-segment points ↑x with x ∈ (0,1), x ≠ 1/2 are in S (digamma_eq_DinfC_ofReal). So S ⊇ ofReal '' ((0,1) ∖ {1/2}). And ↑(1/2) is a limit of points in that image: the map ofReal is continuous + injective; (0,1)∖{1/2} has 1/2 as accumulation point (in ℝ). \n\nFormalization via `frequently_iff`: ∃ᶠ z in 𝓝[≠] z₀, P z ⟺ ∀ U ∈ 𝓝[≠] z₀, ∃ z ∈ U, P z. For U ∈ 𝓝[≠] ↑(1/2): U ∈ nhdsWithin — contains a punctured ball: from mem_nhdsWithin: ∃ V ∈ 𝓝 ↑(1/2), V ∩ {↑(1/2)}ᶜ ⊆ U. Take V ∈ 𝓝 ↑(1/2): the preimage ofReal⁻¹' V ∈ 𝓝 (1/2) (continuity of ofReal: `Complex.continuous_ofReal.tendsto` ✓) — so ∃ a real x with x ∈ ofReal⁻¹'V, x ≠ 1/2, x ∈ (0,1) — ofReal⁻¹'V is a nhd of 1/2 in ℝ, so it contains points of (0,1)∖{1/2} (every nhd of 1/2 does: ofReal⁻¹'V ∩ (Ioo 0 1 ∖ {1/2}) nonempty — since Ioo 0 1 ∖ {1/2} ∈ 𝓝[≠] (1/2)-ish and ofReal⁻¹'V ∈ 𝓝 (1/2) — the intersection of a nhd with a dense-ish punctured set is nonempty: ofReal⁻¹'V contains an interval (1/2 − δ, 1/2 + δ) (metric nhds) — pick x := 1/2 + min(δ/2, 1/4) ∈ (0,1), x ≠ 1/2, ↑x ∈ V, ↑x ≠ ↑(1/2) (injective) ⟹ ↑x ∈ V ∩ {↑(1/2)}ᶜ ⊆ U and P (↑x) ✓.\n   Formalize: \n```lean\n  rw [frequently_iff_forall_exists?]  -- check name: `Filter.frequently_iff`? \n```\nLet me use the direct: `Filter.Frequently` — there is `frequently_iff_forall_exists`? or `frequently_iff : (∃ᶠ x in l, P x) ↔ ∀ U ∈ l, ∃ x ∈ U, P x` — I'm fairly sure `Filter.frequently_iff` exists with that form... — hmm — actually I recall `frequently_iff : (∃ᶠ x in l, P x) ↔ ∀ {U}, U ∈ l → ∃ x ∈ U, P x` ✓.\n\nFor U ∈ 𝓝[≠] z₀: extract via `mem_nhdsWithin_iff_exists_mem_nhds_inter`? — hmm the exact name: `mem_nhdsWithin_iff_exists_mem_nhds_inter : s ∈ 𝓝[t] a ↔ ∃ U ∈ 𝓝 a, U ∩ t ⊆ s`? — I recall `mem_nhdsWithin_iff_exists_mem_nhds_inter` ✓ exists. Then V ∈ 𝓝 ↑(1/2): Metric.mem_nhds_iff gives ball(↑(1/2), δ) ⊆ V for some δ > 0 — then the point z := ↑((1/2) + min (δ/2) (1/4)) — hmm as ℂ: ↑(1/2 + min (δ/2) (1/4)) — in the ball (dist = min(δ/2,1/4) < δ ✓) — ≠ ↑(1/2) (min > 0 ✓) — ∈ U via the inter-subset (z ∈ V since ball ⊆ V, z ∈ {↑(1/2)}ᶜ ✓) — and P z via digamma_eq_DinfC_ofReal with x := 1/2 + min(δ/2)(1/4) ∈ (0,1): min(δ/2, 1/4) ≤ 1/4 ⟹ x ≤ 3/4 < 1 ✓ and x > 1/2 > 0 ✓ so x ∈ Ioo 0 1 ✓.\n\nHmm wait — I realize I need to double check the agreement lemma covers x ∈ (0,1) — digamma_eq_DinfC_ofReal (hx : x ∈ Set.Ioo 0 1) ✓ — and the point ↑x is in dpsiDomain? — for the frequently I only need P z = (digamma z = DinfC z) — which the ofReal lemma gives for x ∈ Ioo 0 1 ✓ — no domain membership needed for the frequently point itself (the identity principle's hfg is just about the equality set). ✓\n\nThen digamma_eq_DinfC_on : EqOn digamma DinfC dpsiDomain ✓.\n\nThen the polygamma values at 1/2:\n```lean\n/-- The iterated derivatives of the inv-shift terms on the domain. -/\nlemma iteratedDerivWithin_neg_inv_add (k : ℕ) (c : ℂ) {s : ℂ} (hs : s + c ≠ 0) (hsU : s ∈ dpsiDomain) :\n    iteratedDerivWithin k (fun s => -(s + c)⁻¹) dpsiDomain s =\n      -((-1 : ℂ))^k * (k ! : ℂ) * (s + c) ^ (-(k : ℤ) - 1) := by\n  induction k generalizing s with\n  | zero => simp [dpsiDomain]...  -- iteratedDerivWithin 0 = f: -(s+c)⁻¹ = -(0!·(s+c)^{-1}) ✓\n  | succ k ih => ...\n```\nHmm — the Within forms + the point-dependence: iteratedDerivWithin at s needs s ∈ domain — the induction generalizing s is awkward (the succ step relates derivWithin at s of the k-th — the k-th as a FUNCTION on the domain...). Let me instead prove the UNrestricted version on the open domain: since dpsiDomain is open, iteratedDerivWithin k f dpsiDomain s = iteratedDeriv k f s for s ∈ dpsiDomain (iteratedDerivWithin_of_isOpen ✓ dpsiDomain_isOpen ✓). So prove the plain iteratedDeriv version:\n```lean\nlemma iteratedDeriv_neg_inv_add_const (k : ℕ) (c : ℂ) (s : ℂ) (hs : s + c ≠ 0) :\n    iteratedDeriv k (fun s => -(s + c)⁻¹) s = -((-1 : ℂ))^k * (k ! : ℂ) * (s + c) ^ (-(k : ℤ) - 1) := by\n  induction k generalizing s with\n  | zero =>\n    simp [iteratedDeriv_zero]  -- -(s+c)⁻¹ = -(1·(s+c)^{-1}): the RHS: -(−1)⁰·0!·(s+c)^(0−1) = -(s+c)⁻¹ ✓ — zpow (−1:ℤ) = (·)⁻¹: zpow_neg_one ✓ simp\n  | succ k ih =>\n    have e : (fun s => -(s + c)⁻¹) = fun s => -((s + c) ^ (-1 : ℤ)) := by\n      funext s; rw [zpow_neg_one]\n    rw [e] at ih ⊢  -- hmm the original function's form\n    ...\n```\nHmm — let me define the function as zpow from the start: claim for all k: iteratedDeriv k (fun s => -((s + c)^(-1:ℤ))) s = -(−1)^k·k!·(s+c)^(-(k+1:ℤ))... — let me use the clean zpow forms throughout. The induction step: iteratedDeriv (k+1) F s = deriv (iteratedDeriv k F) s [iteratedDeriv_succ'] — iteratedDeriv k F = fun s => −(−1)^k·k!·(s+c)^(−(k+1):ℤ) [as a function — ih is pointwise at s — for the deriv I need the function-level: funext from ih applied at all s with s + c ≠ 0 — but the deriv at s only sees a nhd — if s + c ≠ 0, on a small ball around s all points have +c ≠ 0 ✓ — so the function equality holds on a nhd — deriv congruent — need `EventuallyEq.deriv`-style. Manage via: show the function G_k := fun s => −(−1)^k·k!·(s+c)^z agrees with iteratedDeriv k F on the open set {s | s + c ≠ 0} — then deriv at s (in the open set) equal — `Set.EqOn.deriv`? — there's `Set.EqOn.deriv_eq`? hmm — or derivWithin route: derivWithin f U x = deriv f x for U open — then Set.EqOn.derivWithin ✓ (`Set.EqOn.derivWithin (h : EqOn f g s) (hx : x ∈ s)? : derivWithin f s x = derivWithin g s x`? — hmm — EqOn.derivWithin doesn't need hx I think: `Set.EqOn.derivWithin (h : EqOn f g s) : derivWithin f s = derivWithin g s`? — there's `Set.EqOn.derivWithin`? — I recall `Set.EqOn.derivWithin_eq`? ... let me just use the nhds argument: {s | s+c ≠ 0} is open (preimage of {0}ᶜ under continuous +c) — and s ∈ it — so f =ᶠ[𝓝 s] G_k (from the EqOn on the open set: `Set.EqOn.eventuallyEq_of_mem`? — `Set.EqOn.eventuallyEq (h : EqOn f g s) (hs : s ∈ 𝓝 x)? : f =ᶠ[𝓝 x] g`? — hmm — `Set.EqOn.eventuallyEq_of_mem (h : EqOn f g s) (hs : s ∈ 𝓝 x) : f =ᶠ[𝓝 x] g` ✓ something like that) — then EventuallyEq.deriv_eq : deriv f s = deriv g s ✓ (used in LiResidue ✓).\nSo the induction:\n```lean\nlemma iteratedDeriv_neg_inv_zpow_add_const (k : ℕ) (c : ℂ) {s : ℂ} (hs : s + c ≠ 0) :\n    iteratedDeriv k (fun s => -((s + c) ^ (-1 : ℤ))) s =\n      -((-1 : ℂ)) ^ k * (k ! : ℂ) * (s + c) ^ (-(k : ℤ) - 1) := by\n  induction k generalizing s with\n  | zero => simp\n  | succ k ih =>\n    rw [iteratedDeriv_succ']\n    -- deriv (iteratedDeriv k F) s — replace by deriv G_k s via eventual eq\n    have hopen : IsOpen {s : ℂ | s + c ≠ 0} := isOpen_compl_singleton... — {s | s + c ≠ 0} = preimage of {0}ᶜ under (·+c): isOpen_compl_singleton.preimage (continuous_add_const?) — or: {s | s + c ≠ 0} = {−c}ᶜ under the homeomorph... — use: (Homeomorph.addLeft (−c))... hmm — simplest: {s | s + c ≠ 0} = (fun s => s + c) ⁻¹' {0}ᶜ — continuous (continuous_add_const c? — `continuous_add_const (c : ℂ) : Continuous fun x => x + c`? hmm — or (continuous_add_left c)? — `continuous_id.add continuous_const` ✓) — isOpen_compl_singleton.preimage that ✓.\n    have hev : (fun s => iteratedDeriv k (fun s => -((s + c) ^ (-1 : ℤ))) s) =ᶠ[𝓝 s]\n        (fun s => -((-1 : ℂ)) ^ k * (k ! : ℂ) * (s + c) ^ (-(k : ℤ) - 1)) := by\n      have hmem : {s : ℂ | s + c ≠ 0} ∈ 𝓝 s := hopen.mem_nhds hs\n      filter_upwards [hmem] with y hy\n      exact ih hy\n    rw [hev.deriv_eq]\n    -- compute deriv of G_k at s\n    ...\n```\nThe deriv computation: deriv (fun s => C·(s+c)^(-(k+1):ℤ)) s with C := −(−1)^k·k!: = C · (−(k+1):ℤ)·(s+c)^(−(k+1)−1)·1 — via deriv_const_mul + the zpow comp: hasDerivAt_zpow (−(k+1):ℤ) (s+c) (Or.inl hs) — comp with (s+c) (deriv 1) — then .deriv — pattern from deriv_Gprim (LiPrincipal) ✓.\nThen the algebra: −(−1)^k k! · (−(k+1))·(s+c)^(−(k+2))·... = −(−1)^{k+1}(k+1)!(s+c)^{−(k+2)}: (−(k+1):ℤ) as ℂ = −(k+1) — the casts: ((-(k+1 : ℤ)) : ℂ) — hmm — hasDerivAt_zpow gives the derivative ((m : ℤ) : ℂ) · x^(m−1) with m := −(k+1): the cast (−(k+1):ℤ)→ℂ — push_cast handles ✓. And k!→(k+1)!: Nat.factorial_succ ✓. The final form: −(−1)^{k+1}·(k+1)!·(s+c)^(−(k+2) : ℤ) — and the exponent: −(k+1)−1 = −(k+2) ✓ omega/push_cast.\n\nThen the assembly for the series: the k-th iteratedDerivWithin of the sum function — using iteratedDerivWithin_tsum with:\n- hsum : ∀ t ∈ dpsiDomain, Summable (fun m => dpsiTermC · t) ✓ dpsiTermC_summable.\n- h : ∀ k, 1 ≤ k → k ≤ m → SummableLocallyUniformlyOn (fun m => iteratedDerivWithin k (fun s => dpsiTermC s m) dpsiDomain) dpsiDomain:\n  the iteratedDerivWithin of the term: dpsiTermC s m = 1/(↑m+1) − (s+↑m+1)⁻¹·... — = const + (−(s+↑m+1)⁻¹): iteratedDerivWithin k of a sum — sum rule (ContDiffOn needed) — the const's iteratedDerivWithin k = 0 for k ≥ 1 (iteratedDerivWithin_const? — there should be `iteratedDerivWithin_const (hn : 0 < k)?`... — check — there's iteratedDeriv_const (Defs.lean:357 — the if-form) and Within versions — iteratedDerivWithin_const exists presumably ✓).\n  So the term's k-th iteratedDerivWithin = −(−1)^k·k!·(s+↑m+1)^{−(k+1)} (from the zpow lemma + Within-of-isOpen ✓).\n  SummableLocallyUniformlyOn of THAT family on dpsiDomain: ‖−(−1)^k k!(s+↑m+1)^{−(k+1)}‖ = k!/‖s+↑m+1‖^{k+1} ≤ k!/(m+1)^{k+1}·(adjust) — for s ∈ dpsiDomain: ‖s+↑m+1‖ ≥ re s + m + 1 > m + 1 — so ≤ k!/(m+1)^{k+1} — summable for k ≥ 1 (k+1 ≥ 2 ✓) — via SummableLocallyUniformlyOn_of_locally_bounded (dpsiDomain_isOpen) with the compact argument: for K compact ⊆ dpsiDomain: min re on K ≥ c > 0 — hmm — actually simpler bound directly: ‖s+↑m+1‖ ≥ (m+1) — wait — ‖s + ↑m + 1‖ ≥ re(s+↑m+1) = re s + m + 1 ≥ m + 1 (re s > 0) — hmm — that gives ≤ k!/(m+1)^{k+1} — INDEPENDENT of K — so even SummableUniformlyOn-ish... the bound ‖s+↑m+1‖ ≥ re(s+↑m+1) needs (s+↑m+1).re ≥ 0 for the |re| step: re s + m + 1 > 0 ✓ — so ‖term‖ ≤ k!/(m+1)^{k+1} uniformly on the WHOLE domain ✓ — so HasSumUniformlyOn.of_norm_le_summable directly ✓ and SummableLocallyUniformlyOn from HasSumUniformlyOn... — `HasSumUniformlyOn.summableLocallyUniformlyOn`? — there's the of_locally_bounded lemma needing the compact argument — or maybe HasSumUniformlyOn implies SummableLocallyUniformlyOn directly — `HasSumUniformlyOn.summableLocallyUniformlyOn (hs : IsOpen s)?`? — from of_locally_bounded_eventually's proof: `HasSumLocallyUniformlyOn.summableLocallyUniformlyOn (g := ...)` — there's HasSumLocallyUniformlyOn.summableLocallyUniformlyOn — and HasSumUniformlyOn → HasSumLocallyUniformlyOn: `HasSumUniformlyOn.hasSumLocallyUniformlyOn`? — name... — I'll navigate at compile.\n- hf2 : the differentiability conditions ✓ (each term's iteratedDerivWithin is differentiable on the domain — they're zpow functions, differentiable off the pole ✓).\nThen iteratedDerivWithin_tsum m dpsiDomain_isOpen (1/2 ∈ domain) hsum h hf2 : iteratedDerivWithin m (fun s => ∑' n, dpsiTermC s n) dpsiDomain (1/2) = ∑' n, iteratedDerivWithin m (dpsiTermC · n) dpsiDomain (1/2) — then Within-of-isOpen both sides + the term values + the sum evaluation: Σ_{m≥0} −(−1)^k k!(1/2+↑m+1)^{−(k+1)} = −(−1)^k k! Σ_{m≥0}(1/2+m+1)^{−(k+1)} — hmm wait — the dpsiTermC's index m corresponds to 1/(m+1) − 1/(s+m+1) — so the pole-shift is m+1 — the sum Σ_{m≥0}(1/2 + m + 1)^{−(k+1)} = Σ_{m'≥1}(1/2+m')^{−(k+1)}·... — and then plus the −1/s term's contribution −(−1)^k k!(1/2)^{−(k+1)} — total Σ_{m'≥0}(1/2+m')^{−(k+1)} — via tsum shifts ✓.\n\nHmm — wait — careful about the DinfC structure: DinfC s = −γ − 1/s + ∑' m, dpsiTermC s m — the iteratedDerivWithin k of the WHOLE DinfC = the (−γ − 1/s) part's + the series' — via iteratedDerivWithin_add (ContDiffOn of each ✓): the −γ − 1/s part gives 0 + (−(−1)^k k! s^{−(k+1)})... — wait −1/s = −s⁻¹ = −(s^(−1:ℤ)) — its k-th: −(−1)^k k! s^{−(k+1)} ✓. So:\niteratedDeriv k DinfC (1/2) = −(−1)^k k!(1/2)^{−(k+1)} + Σ_{m≥0} [−(−1)^k k!(1/2+↑m+1)^{−(k+1)}]\n= −(−1)^k k! [ (1/2)^{−(k+1)} + Σ_{m≥0} (3/2+m)^{−(k+1)} ]   [(1/2 + m + 1) = 3/2 + m]\n= −(−1)^k k! Σ_{m≥0} (1/2 + m)^{−(k+1)}   [tsum_eq_zero_add: Σ_{m≥0}(1/2+m)^{−(k+1)} = (1/2)^{−(k+1)} + Σ_{m≥0}(1/2+(m+1))^{−(k+1)} ✓ the shift ✓]\n= −(−1)^k k! Σ_{m≥0} (m + 1/2)^{−(k+1)} ✓.\nFor k = j ≥ 1: −(−1)^j = (−1)^{j+1} ✓. So iteratedDeriv j DinfC (1/2) = (−1)^{j+1} j! Σ_{m≥0}(m+1/2)^{−(j+1)} ✓✓ THE POLYGAMMA FORMULA.\n\nThen digamma's: via EqOn (digamma_eq_DinfC_on) + the eventualEq-iteratedDeriv helper.\n\nHmm — I need the \"iteratedDeriv of eventually-equal functions\" helper. Let me write it:\n```lean\nlemma iteratedDeriv_congr_of_eventuallyEq {f g : ℂ → ℂ} {x : ℂ} (h : f =ᶠ[𝓝 x] g) (n : ℕ) :\n    iteratedDeriv n f x = iteratedDeriv n g x := by\n  induction n with\n  | zero => simp [iteratedDeriv_zero]  -- f x = g x from h (self_of_nhds)\n  | succ n ih =>\n    -- need f' =ᶠ g' eventually — from h on a nhd\n    ...\n```\nThe step: iteratedDeriv (n+1) f x = deriv (iteratedDeriv n f) x [succ'] — and iteratedDeriv n f =ᶠ[𝓝 x] iteratedDeriv n g — from h: on the nhd where f = g, the iterated derivs... — the induction hypothesis needs the eventual-eq of the n-th iterated derivs — which follows from the deriv-level argument: if f =ᶠ[𝓝 x] g then deriv f =ᶠ[𝓝 x] deriv g — is there `Filter.EventuallyEq.deriv`? — hmm. Let me think: f =ᶠ[𝓝 x] g means f = g on some nhd V of x. For y ∈ V: deriv f y = deriv g y? — deriv at y sees only a small nhd ⊆ V ✓ — deriv f y = deriv g y requires f =ᶠ[𝓝 y] g (which holds since V ∈ 𝓝 y for y ∈ V-open...). So deriv f = deriv g on V's interior ⊇ V (V open) — hence deriv f =ᶠ[𝓝 x] deriv g. The direct Mathlib lemma: `Filter.EventuallyEq.deriv`? Let me check — hmm — there's `Filter.EventuallyEq.deriv_eq (h : f =ᶠ[𝓝 x] g) : deriv f x = deriv g x` ✓ (used in LiResidue). For the within/nhd version of the DERIVED functions: `Filter.EventuallyEq.deriv (h : f =ᶠ[𝓝 x] g) : deriv f =ᶠ[𝓝 x] deriv g`? — I believe `EventuallyEq.deriv` might NOT exist... Let me search. If missing, prove via: obtain ⟨V, hV, hVopen?...⟩ — from h : ∃ U ∈ 𝓝 x, EqOn f g U — `EventuallyEq.exists_mem`? — then for the eventually-of-derivs: nhds within... OK let me just write:\n```lean\nlemma eventuallyEq_deriv {f g : ℂ → ℂ} {x : ℂ} (h : f =ᶠ[𝓝 x] g) :\n    deriv f =ᶠ[𝓝 x] deriv g := by\n  obtain ⟨U, hU, hfg⟩ := h.exists_mem  -- U ∈ 𝓝 x, EqOn f g U — `EventuallyEq.exists_mem : f =ᶠ[l] g → ∃ s ∈ l, Set.EqOn f g s`? — hmm — `Filter.EventuallyEq.exists_mem : f =ᶠ[l] g → ∃ s ∈ l, Set.EqOn f g s`? — I recall `EventuallyEq.exists_mem`... or use h directly: h is ∀ᶠ y in 𝓝 x, f y = g y — so the set S := {y | f y = g y} ∈ 𝓝 x.\n  ...\n```\nLet me do: S := {y | f y = g y} ∈ 𝓝 x (from h). Interior S is open, x ∈ interior S (x ∈ S and S ∈ 𝓝 x ⟹ x ∈ interior S ✓ `mem_interior_iff_mem_nhds.mpr h`-ish). Then ∀ y ∈ interior S: f =ᶠ[𝓝 y] g (interior S ∈ 𝓝 y ✓ + subset) ⟹ deriv f y = deriv g y (EventuallyEq.deriv_eq). So {y | deriv f y = deriv g y} ⊇ interior S ∈ 𝓝 x ⟹ deriv f =ᶠ[𝓝 x] deriv g ✓.\n```lean\nlemma eventuallyEq_deriv {f g : ℂ → ℂ} {x : ℂ} (h : f =ᶠ[𝓝 x] g) :\n    deriv f =ᶠ[𝓝 x] deriv g := by\n  have hS : {y | f y = g y} ∈ 𝓝 x := h\n  have h2 : interior {y | f y = g y} ∈ 𝓝 x := interior_mem_nhds.mpr hS  -- interior_mem_nhds : s ∈ 𝓝 x ↔ interior s ∈ 𝓝 x? — `interior_mem_nhds : s ∈ 𝓝 a ↔ interior s ∈ 𝓝 a`? — there's `interior_mem_nhds (h : s ∈ 𝓝 x) : interior s ∈ 𝓝 x`? — `interior_mem_nhds.mpr`? the iff is `mem_interior_iff_mem_nhds : x ∈ interior s ↔ s ∈ 𝓝 x` — I want: interior s ∈ 𝓝 x from s ∈ 𝓝 x: since interior s ⊆ ... no — interior s might not contain x?? — x ∈ interior s ⟺ s ∈ 𝓝 x (mem_interior_iff_mem_nhds) — so x ∈ interior S ✓ — then interior S ∈ 𝓝 x (a set containing a point in its... no — interior S is open and contains x ⟹ ∈ 𝓝 x via IsOpen.mem_nhds ✓ `IsOpen.mem_nhds isOpen_interior ‹x ∈ interior S›`) ✓.\n  filter_upwards [IsOpen.mem_nhds isOpen_interior (mem_interior_iff_mem_nhds.mpr hS)] with y hy\n  -- y ∈ interior S: f =ᶠ[𝓝 y] g (interior S ⊆ S, ∈ 𝓝 y)\n  have h3 : f =ᶠ[𝓝 y] g := by\n    apply Filter.eventually_of_mem (IsOpen.mem_nhds isOpen_interior hy)  -- hmm the eventual statement about equality at points near y\n    intro z hz\n    exact interior_subset hz  -- z ∈ S\n  exact h3.deriv_eq\n```\nHmm — Filter.eventually_of_mem (hs : s ∈ l) (h : ∀ x ∈ s, P x)? : ∀ᶠ x in l, P x — `Filter.eventually_of_mem (hl : s ∈ l) (h : ∀ x ∈ s, P x) : ∀ᶠ x in l, P x`? — there's `eventually_of_mem` ✓ (used in vendored code). And EventuallyEq.deriv_eq : (h : f =ᶠ[𝓝 x] g) → deriv f x = deriv g x ✓.\n\nThen:\n```lean\nlemma iteratedDeriv_congr_of_eventuallyEq {f g : ℂ → ℂ} {x : ℂ} (h : f =ᶠ[𝓝 x] g) (n : ℕ) :\n    iteratedDeriv n f x = iteratedDeriv n g x := by\n  induction n with\n  | zero =>\n    rw [iteratedDeriv_zero, iteratedDeriv_zero]\n    exact h.self_of_nhds\n  | succ n ih =>\n    rw [iteratedDeriv_succ', iteratedDeriv_succ']\n    -- deriv (iteratedDeriv n f) x = deriv (iteratedDeriv n g) x — need the eventuallyEq of the n-th\n    have hev : iteratedDeriv n f =ᶠ[𝓝 x] iteratedDeriv n g := by\n      -- from h via iteration of eventuallyEq_deriv — hmm the ih is pointwise...\n```\nHmm — the induction structure: the IH should be the EVENTUAL-EQ of the n-th derivs, not the point value. Restructure: prove the stronger statement: iteratedDeriv n f =ᶠ[𝓝 x] iteratedDeriv n g by induction:\n- n = 0: iteratedDeriv 0 f = f ✓ h.\n- succ: iteratedDeriv (n+1) f = deriv (iteratedDeriv n f) =ᶠ[𝓝 x] deriv (iteratedDeriv n g) = iteratedDeriv (n+1) g — via eventuallyEq_deriv applied to the IH + the succ' rewrites (function-level: iteratedDeriv_succ' : iteratedDeriv (n+1) f = deriv (iteratedDeriv n f)? — from session-017 note: iteratedDeriv_succ' pushes deriv inside: iteratedDeriv (n+1) f = iteratedDeriv n (deriv f)!! — for the function-level deriv-of-iterated I need `iteratedDeriv_succ : iteratedDeriv (n+1) f = deriv (iteratedDeriv n f)` ✓ (the OTHER one).\n```lean\nlemma eventuallyEq_iteratedDeriv {f g : ℂ → ℂ} {x : ℂ} (h : f =ᶠ[𝓝 x] g) (n : ℕ) :\n    iteratedDeriv n f =ᶠ[𝓝 x] iteratedDeriv n g := by\n  induction n with\n  | zero => simpa [iteratedDeriv_zero] using h\n  | succ n ih =>\n    rw [iteratedDeriv_succ, iteratedDeriv_succ]\n    exact eventuallyEq_deriv ih\nlemma iteratedDeriv_congr_of_eventuallyEq {f g : ℂ → ℂ} {x : ℂ} (h : f =ᶠ[𝓝 x] g) (n : ℕ) :\n    iteratedDeriv n f x = iteratedDeriv n g x :=\n  (eventuallyEq_iteratedDeriv h n).self_of_nhds\n```\nHmm — `EventuallyEq.self_of_nhds : f =ᶠ[𝓝 x] g → f x = g x` ✓ (used in LiPrincipal: hfh.self_of_nhds ✓).\n\nOK. And the reindexing (A6): Σ_{m≥0} (↑m + 1/2)^{−(j+1)} = 2^{j+1}·lagariasA(j+1) as ℂ:\n- (↑m + 1/2 : ℂ)^{−(j+1)} — hmm zpow or 1/(·)^{j+1}? — let me use the 1/(m+1/2)^{j+1} npow form for the final series. From the iterated value: Σ_{m≥0}(1/2+↑m)^{−(j+1)} (zpow form) — convert: (1/2+↑m)^{−(j+1)} zpow = 1/(1/2+↑m)^{j+1} ✓ (zpow_neg_natCast? — `zpow_neg_natCast`? — zpow (−(j+1):ℤ) x = 1/x^(j+1) — `zpow_neg`+`zpow_natCast` ✓ or `zpow_neg_natCast...`? — there's `zpow_neg_natCast : x ^ (-(n:ℤ)) = 1 / x ^ n`? — roughly ✓).\n- (1/2 + ↑m)^{−(j+1)} = (2^{j+1})/(1+2↑m)^{j+1}: (1/2+↑m) = (1+2↑m)/2 — so (1/2+↑m)^{j+1} = (1+2↑m)^{j+1}/2^{j+1} — reciprocal ✓.\n- Σ_{m≥0} 1/(1+2↑m)^{j+1}·2^{j+1}... — the reindex to the odd sum: Σ_{m≥0} 1/(2m+1)^{j+1} = lagariasA(j+1): lagariasA(j+1) = 1 + Σ_{m : {odd ∧ ≥3}} (1/↑m)^{j+1} (if_neg since j+1 ≥ 2 ✓) — and Σ_{m≥0} 1/(2m+1)^{j+1} = 1/(2·0+1)^{j+1} + Σ_{m≥0} 1/(2(m+1)+1)^{j+1} [tsum_eq_zero_add] = 1 + Σ_{m≥0}1/(2m+3)^{j+1} — and Σ_{m≥0} 1/(2m+3)^{j+1} = Σ_{m : {odd ∧ ≥3}} 1/m^{j+1} via the equiv φ : ℕ → {m // Odd m ∧ 3 ≤ m}, φ(m) := ⟨2m+3, by odd, by omega⟩ — Equiv.ofBijective: injective: 2m+3 = 2m'+3 ⟹ m = m' ✓ (omega); surjective: ⟨m', odd, ≥3⟩: m' = 2k+1 (odd_iff), k ≥ 1 (3 ≤ 2k+1 ⟹ k ≥ 1), m' = 2(k−1)+3 ✓ take k−1 ✓. Then Equiv.tsum_eq: Σ_{m:ℕ} g(φ m) = Σ_{m' : subtype} g(m') — with g(m') := 1/(↑m')^{j+1} — need g(φ m) = 1/(2m+3)^{j+1} ✓ (↑(2m+3) = 2↑m+3 push_cast ✓).\n  And the tsum forms: lagariasA's tail is over {m // Odd m ∧ 3 ≤ m} with summand (1/(m:ℝ))^j — REAL tsum! — and my series is COMPLEX (1/(2m+1:ℂ)^{j+1}) — so the reindexing happens in ℂ and then relate to the real lagariasA's cast: ↑(lagariasA (j+1)) = 1 + ↑(Σ_{subtype} (1/↑m:ℝ)^{j+1}) — cast the real subtype-tsum to ℂ: ↑(∑' m : subtype, (1/(m:ℝ))^(j+1)) = ∑' m, ↑((1/(m:ℝ))^(j+1)) = ∑' m, 1/(↑m:ℂ)^(j+1) — via ofRealCLM.map_tsum + push_cast ✓ (need the subtype-tail's summability — it's dominated by the p-series ✓ — need a small summability lemma for the tail: Summable (fun m : {m // Odd m ∧ 3 ≤ m} => (1/(m:ℝ))^(j+1)) — hmm — that's `oddSlice_summable`-ADJACENT — oddSlice_summable (LiSwaps) is for (1/(m:ℝ))^j with j ≥ 2 — my exponent here is j+1 with j ≥ 1 ⟹ j+1 ≥ 2 ✓ — so oddSlice_summable (j+1) (by omega) gives Summable (fun m : {odd ∧ ≥3} => (1/(m:ℝ))^(j+1)) ✓✓ REUSE!).\n  \nSo the reindexing chain (all in ℂ, for j ≥ 1):\n  Σ_{m≥0} 1/(↑m + 1/2)^{j+1} = 2^{j+1}·Σ_{m≥0} 1/(2↑m+1)^{j+1}   [factor per-term + tsum_mul_left]\n  Σ_{m≥0} 1/(2↑m+1)^{j+1} = 1 + Σ_{m≥0} 1/(2↑m+3)^{j+1}   [tsum_eq_zero_add]\n  Σ_{m≥0} 1/(2↑m+3)^{j+1} = Σ_{m' ∈ {odd ∧ ≥3}} 1/(↑m')^{j+1}   [the equiv + Equiv.tsum_eq]\n  1 + Σ_subtype = ↑(lagariasA (j+1))   [lagariasA def if_neg + ofRealCLM.map_tsum the other way]\nCombine: Σ_{m≥0} 1/(↑m+1/2)^{j+1} = 2^{j+1}·↑(lagariasA (j+1)) ✓.\n\nThen the FINAL assembly (in LiArchimedean.lean, since it has the split):\n```lean\ntheorem iteratedDeriv_logDeriv_Gammaℝ_one_add (j : ℕ) :\n    iteratedDeriv j (fun s : ℂ => logDeriv Complex.Gammaℝ (1 + s)) 0 =\n      (-1 : ℂ) ^ (j + 1) * (j ! : ℂ) * (lagariasA (j + 1) : ℝ) := by\n  rcases eq_or_lt_of_le (Nat.zero_le j) with hj0 | hj  -- j = 0 or j ≥ 1\n  · subst hj0\n    -- j = 0: iteratedDeriv 0 = the value = logDeriv Gammaℝ 1 = −lagariasA1 (PROVED)\n    rw [iteratedDeriv_zero]\n    -- RHS: (−1)^1 · 0! · ↑(lagariasA 1) = −↑lagariasA1\n    rw [lagariasA, if_pos rfl]\n    simp [logDeriv_Gammaℝ_one]\n  · -- j ≥ 1\n    have hj1 : 1 ≤ j := hj\n    -- the function identity on a nhd of 0: logDeriv Gammaℝ (1+s) = −(log π)/2 + (1/2)·digamma((1+s)/2)\n    have hev : (fun s : ℂ => logDeriv Complex.Gammaℝ (1 + s)) =ᶠ[𝓝 0]\n        (fun s => -(Real.log Real.pi : ℂ) / 2 + (1 / 2) * Complex.digamma ((1 + s) / 2)) := by\n      -- from logDeriv_Gammaℝ_one_add on a small ball where the hyps hold\n      ...\n    rw [iteratedDeriv_congr_of_eventuallyEq hev]\n    -- iteratedDeriv j (const + (1/2)·digamma((1+·)/2)) 0 = (1/2)·iteratedDeriv j (digamma((1+·)/2)) 0 (j ≥ 1)\n    ...\n    -- the affine comp: = (1/2)·(1/2)^j·iteratedDeriv j digamma (1/2)\n    ...\n    -- = (1/2)^{j+1}·(−1)^{j+1} j! Σ_{m≥0}(↑m+1/2)^{−(j+1)}  [the series values]\n    -- = (−1)^{j+1} j! · ↑(lagariasA (j+1))  [the reindexing + the 2^{j+1} cancellation]\n    ...\n```\n\nThe nhd-eventual for the split: need ∀ᶠ s in 𝓝 0, [Gamma((1+s)/2) ≠ 0 ∧ ∀ m, (1+s)/2 ≠ −↑m]: Gamma((1+s)/2) ≠ 0 near 0: Gamma(1/2) ≠ 0 (Gamma_one_half_eq + cpow≠0 ✓) + continuity (Complex.continuousAt_Gamma (s) (hs : ∀ m, s ≠ −m) — exists (Deriv.lean:88)) — Tendsto (fun s => Gamma((1+s)/2)) (𝓝 0) (𝓝 (Gamma(1/2))) — then eventually ≠ 0 since Gamma(1/2) ≠ 0 ✓ (ContinuousAt.eventually_ne ✓). The pole-free: ∀ m, (1+s)/2 ≠ −↑m near 0: (1+s)/2 near 1/2 — the set {−↑m} is closed/discrete — 1/2 ∉ it — {s | (1+s)/2 ∉ {−m's}}: (1+s)/2 ∈ ball(1/2, 1/4)-ish avoids all −m (re > 1/4 > 0 ≥ −m) — so on ball(0, 1/2) (since |(1+s)/2 − 1/2| = |s|/2 < 1/4 for |s| < 1/2): re((1+s)/2) > 1/2 − 1/4 = 1/4 > 0 — and −↑m has re ≤ 0 — so (1+s)/2 ≠ −↑m ✓. So on Metric.ball 0 (1/2): both hyps ✓ — the ball ∈ 𝓝 0 ✓ then logDeriv_Gammaℝ_one_add applies pointwise ✓.\n\nThe affine comp for digamma((1+s)/2): (1+s)/2 = 1/2 + s/2 = φ(s) with φ = (1/2 + ·)∘(·/2)? — (1+s)/2 — let me define ψ(s) := (1+s)/2 — iteratedDeriv j (digamma ∘ ψ) 0 = (1/2)^j iteratedDeriv j digamma (ψ 0) — ψ 0 = 1/2 ✓. The affine comp lemma — prove:\n```lean\nlemma iteratedDeriv_comp_one_add_div_two (F : ℂ → ℂ) (j : ℕ)\n    (hF : AnalyticAt ℂ F (1 / 2)) :\n    iteratedDeriv j (fun s : ℂ => F ((1 + s) / 2)) 0 = (1 / 2 : ℂ) ^ j * iteratedDeriv j F (1 / 2) := by\n  induction j with\n  | zero => simp [iteratedDeriv_zero]\n  | succ j ih =>\n    rw [iteratedDeriv_succ, iteratedDeriv_succ]\n    -- deriv (iteratedDeriv j (F∘φ)) 0 = deriv (fun s => (1/2)^j · iteratedDeriv j F (φ s)) 0 [by ih as functions near 0]\n    ...\n```\nThe IH is pointwise at 0 — for the deriv I need the function equality near 0: iteratedDeriv j (F∘φ) = fun s => (1/2)^j · iteratedDeriv j F (φ s) on a nhd of 0 — the IH at OTHER points near 0 — the induction should be generalizing the point... let me restructure: prove the eventuallyEq version directly:\n```lean\nlemma iteratedDeriv_comp_one_add_div_two' (F : ℂ → ℂ) (j : ℕ)\n    (hF : AnalyticAt ℂ F (1 / 2)) :\n    iteratedDeriv j (fun s : ℂ => F ((1 + s) / 2)) 0 = (1 / 2 : ℂ) ^ j * iteratedDeriv j F (1 / 2) := by\n  induction j with\n  | zero => simp [iteratedDeriv_zero]\n  | succ j ih =>\n    have hFan : ∀ᶠ s in 𝓝 (0:ℂ), AnalyticAt ℂ F ((1+s)/2) := by\n      -- (1+s)/2 → 1/2 as s → 0; F analytic at 1/2 ⟹ near 1/2 (eventually_analyticAt)\n      have h1 : AnalyticAt ℂ F (1/2) := hF\n      have h2 : Tendsto (fun s : ℂ => (1+s)/2) (𝓝 0) (𝓝 (1/2)) := by\n        have : ContinuousAt (fun s : ℂ => (1+s)/2) 0 :=\n          (continuousAt_id.add continuousAt_const).div continuousAt_const\n        simpa using this.tendsto\n      exact h2.eventually h1.eventually_analyticAt\n    -- the iteratedDeriv functions agree near 0\n    have hev : (fun s : ℂ => iteratedDeriv j (fun t => F ((1 + t) / 2)) s) =ᶠ[𝓝 0]\n        (fun s => (1/2:ℂ)^j * iteratedDeriv j F ((1+s)/2)) := by\n      filter_upwards [hFan] with s hs\n      -- apply a pointwise version of the IH at s?? — the IH is at 0 only — RESTRUCTURE: prove a version at general points...\n```\nUGH — the point-generalizing induction. Let me just prove the general-point version directly:\n```lean\nlemma iteratedDeriv_comp_affine (F : ℂ → ℂ) (a b : ℂ) (j : ℕ) {s : ℂ}\n    (hF : AnalyticAt ℂ F (a + b * s)) (hF' : ∀ᶠ t in 𝓝 s, AnalyticAt ℂ F (a + b * t)) :\n    iteratedDeriv j (fun t : ℂ => F (a + b * t)) s =\n      b ^ j * iteratedDeriv j F (a + b * s) := by\n  induction j generalizing s with\n  | zero => simp [iteratedDeriv_zero]\n  | succ j ih =>\n    rw [iteratedDeriv_succ, iteratedDeriv_succ]\n    -- deriv (iteratedDeriv j (F∘φ)) s = deriv (fun t => b^j · iteratedDeriv j F (a+bt)) s\n    have hev : (fun t => iteratedDeriv j (fun u => F (a + b * u)) t) =ᶠ[𝓝 s]\n        (fun t => b ^ j * iteratedDeriv j F (a + b * t)) := by\n      filter_upwards [hF'] with t ht\n      exact ih ht (hF'.mono fun u hu => ?_)  -- hmm the ∀ᶠ for the IH at t\n```\nThe IH at t needs AnalyticAt F (a + b·t) ✓ (ht) and ∀ᶠ u in 𝓝 t, AnalyticAt F (a+b·u) ✓ (from ht.eventually_analyticAt + the continuity of a+b·u at t — Tendsto (fun u => a+b·u) (𝓝 t) (𝓝 (a+b·t)) then eventually composition: (that).eventually ht.eventually_analyticAt : ∀ᶠ u in 𝓝 t, AnalyticAt F (a+b·u) ✓). So:\n```lean\n  | succ j ih =>\n    rw [iteratedDeriv_succ, iteratedDeriv_succ]\n    have hev : (fun t => iteratedDeriv j (fun u => F (a + b * u)) t) =ᶠ[𝓝 s]\n        (fun t => b ^ j * iteratedDeriv j F (a + b * t)) := by\n      filter_upwards [hF'] with t ht\n      have ht' : ∀ᶠ u in 𝓝 t, AnalyticAt ℂ F (a + b * u) := by\n        have hc : Tendsto (fun u : ℂ => a + b * u) (𝓝 t) (𝓝 (a + b * t)) := by\n          have : ContinuousAt (fun u : ℂ => a + b * u) t :=\n            continuousAt_const.add (continuousAt_const.mul continuousAt_id)\n          exact this.tendsto\n        exact hc.eventually ht.eventually_analyticAt\n      exact ih ht ht'\n    rw [hev.deriv_eq]\n    -- deriv (fun t => b^j · iteratedDeriv j F (a+bt)) s = b^j · b · iteratedDeriv (j+1) F (a+bs)\n    rw [deriv_const_mul]\n    -- deriv (iteratedDeriv j F ∘ φ) s = (iteratedDeriv j F)'(φ s) · b\n    have hc : HasDerivAt (fun t : ℂ => a + b * t) b s := by\n      simpa using (hasDerivAt_const s a).add (((hasDerivAt_id s).const_mul b))\n    have hd : HasDerivAt (iteratedDeriv j F) (iteratedDeriv (j+1) F (a + b*s)) (a + b*s) := by\n      rw [← iteratedDeriv_succ]\n      exact hF.deriv.differentiableAt.hasDerivAt  -- iteratedDeriv j F differentiable at a+bs: from hF — AnalyticAt F ⟹ AnalyticAt (iteratedDeriv j F)? — there's `AnalyticAt.iteratedDeriv`? or via deriv j times ✓ — `AnalyticAt.deriv` iterates — hmm — is there AnalyticAt.iteratedDeriv? — there's `AnalyticAt.deriv : AnalyticAt f x → AnalyticAt (deriv f) x` ✓ — and iteratedDeriv j F = deriv^j F — a direct lemma `AnalyticAt.iteratedDeriv`? — maybe not — but (AnalyticAt.deriv)^j — there's `AnalyticAt.iteratedFDeriv`? Let me just note: AnalyticAt.deriv applied j times via a helper or a direct lemma — check for `AnalyticAt.iteratedDeriv` at compile.\n    have hcomp := hd.comp s hc\n    -- hcomp : HasDerivAt (iteratedDeriv j F ∘ (a+b·)) (b * iteratedDeriv (j+1) F (a+bs))?? — order f' * g' or g'•f' — ℂ: mul — f' * b or b * f'...\n    ...\n```\nThis is getting long — the affine comp is a standard-but-fiddly induction (~60 lines). OK. And `AnalyticAt.iteratedDeriv` — let me check it exists: grep.","signature":""},{"type":"text","text":"Continuing. Quick check on `AnalyticAt.iteratedDeriv` and `eventually_of_mem`/`interior` names for the congruence helper."},{"type":"tool_use","id":"Bash_395","name":"Bash","input":{"command":"cd \"D:/Python/Quantum/zeta-23-lean/.lake/packages/mathlib\" && grep -rn \"theorem AnalyticAt.iteratedDeriv\\|lemma AnalyticAt.iteratedDeriv\" Mathlib/Analysis/Calculus/ -r --include=\"*.lean\" | head -2; grep -rn \"theorem EventuallyEq.deriv_eq\\|lemma EventuallyEq.deriv_eq\" Mathlib/Analysis/Calculus/Deriv/*.lean Mathlib/Analysis/Calculus/FDeriv/*.lean 2>/dev/null | head -3; grep -rn \"theorem interior_mem_nhds\\|lemma interior_mem_nhds\" Mathlib/Topology/ --include=\"*.lean\" -r | head -2","description":"Check AnalyticAt.iteratedDeriv, EventuallyEq.deriv_eq, interior_mem_nhds"},"extra_content":null}]