Current task: —

← Session 21 — Tier ii′ planning + launch: close SfBoundProp in Lean (D-064)

#916 assistant 2026-08-21 19:30:26.593 UTC · 820→4775 tok open ⤢
thinking (4343 chars)
Now it's clear: in this Mathlib, the recommended form is `starRingEnd ℂ` (available as notation `conj` only inside the `ComplexConjugate` scope). And `star z` for ℂ IS the star operation (StarRing instance shown here). So: - `star z` works directly (the StarRing ℂ instance). - `Complex.add_conj : z + conj z = ...` — with conj = starRingEnd ℂ (via the scope). `star z` and `(starRingEnd ℂ) z` are both the star operation — defeq but different head constants. Simplest robust approach: use `starRingEnd ℂ` explicitly (the bundled hom — map_ lemmas apply). In the def: `(starRingEnd ℂ) (ρ:ℂ)`. And for liSummand_eq, instead of Complex.add_conj, use the star-based lemma: is there `star_add_self` or `Complex.star_def`? There's `RCLike` generic: `star_def`? Simpler: `Complex.add_conj` is about `starRingEnd ℂ z` (since conj in that file = starRingEnd ℂ via scope) — so with my def using starRingEnd ℂ, the lemma applies directly! Let me confirm: in Mathlib/Data/Complex/Basic.lean, line 45 `open ComplexConjugate` — so within that file, `conj` = the scoped notation for starRingEnd ℂ. So `Complex.add_conj : z + starRingEnd ℂ z = ((2 * z.re : ℝ) : ℂ)` ✓. So in my code, write `(starRingEnd ℂ)` instead of `conj`, and Complex.add_conj will match (pattern `?z + starRingEnd ℂ ?z` — my term has exactly `starRingEnd ℂ f` ✓). And summand_conj becomes: ``` lemma summand_conj (n : ℕ) (z : ℂ) : (1 : ℂ) - (1 - 1 / ((starRingEnd ℂ) z)) ^ n = (starRingEnd ℂ) ((1 - (1 - 1 / z) ^ n)) := by rw [map_sub, map_one, map_pow, map_sub, map_one, map_div₀, map_one] ``` map_sub (starRingEnd ℂ) — these generic map_ lemmas apply to bundled ring homs ✓. Now the other fixes: - hSn1/rw [hSn1] at * — restructure: rw [hSn1] BEFORE the calc (at goal ‖S − n‖ ≤ ...). - The `↑(∑ ...)` cast issue: annotate `(1 + 1 / (2 * (n : ℝ))) ^ (n - 1)` — with (n:ℝ) cast inside, the whole body elaborates at ℝ ✓. I'll introduce a local abbreviation `M : ℝ := 1 + 1 / (2 * n)` — with (n:ℝ) — and use M everywhere to avoid repeated elaboration issues. Since n : ℕ, writing `(2 * (n : ℝ))` forces ℝ. Let me define at the top of re_li_summand_le: `set M : ℝ := 1 + 1 / (2 * (n : ℝ)) with hM` — then hwmax : max 1 ‖w‖ ≤ M, hpow : M^(n-1) ≤ 2, etc. Cleaner. Also "No goals to be solved" at line 97 — that was in hsumj area? Line 97 col 18: looking at previous version line numbers — it was in the `rw [hSn1] at *` region or `h := Finset.sum_range_id_mul_two n; h2 ... linarith` — actually 97:18 in the last file is in the h2 sub-proof of hbound (`rw [← h]; ring` — where after rw [← h] the goal might already be closed by rw's rfl). Let me make h2's proof robust: have h2 : w ^ j - 1 = -(1 / z) * ∑ i ∈ Finset.range j, w ^ i := by rw [← hgeomj, hw1] After rw [← hgeomj]: goal (w−1)·∑ = −(1/z)·∑; rw [hw1]: −(1/z)·∑ = −(1/z)·∑ — rfl by rw ✓ closed automatically. But earlier I had `have h := hgeomj; rw [hw1] at h; rw [← h]; ring` — the rw [← h] closed it and ring had no goals. New version handles cleanly. Also hgeomj line: `have hgeomj : (w - 1) * ∑ i ∈ Finset.range j, w ^ i = w ^ j - 1 := mul_geom_sum w j` ✓. One more from the error list: 114:49 unsolved goals — that was inside the hpow/hb chain probably (hb3.trans (by ring_nf)) — ring_nf might not fully close `(1/‖z‖) * (2 * (n^2/2)) = n^2/‖z‖`? ring_nf should prove equality of the form a*(2*(b/2)) = a*b — it's `mul` arithmetic — actually (1/‖z‖)*(2*(n²/2)) = (1/‖z‖)*n² = n²/‖z‖ ✓ ring_nf should handle. The unsolved goals error was probably cascading from earlier errors. Let me rewrite the full file with all fixes and iterate. Also `pow_le_pow_right₀ (by positivity) (Nat.sub_le n 1)` — signature (ha : 1 ≤ a) (hmn : m ≤ n): `by positivity` proves 1 ≤ 1+1/(2n)? positivity proves 0 < x — not 1 ≤ x. Use `by have : (0:ℝ) ≤ 1/(2*(n:ℝ)) := by positivity; linarith` or `le_add_of_nonneg_left`... 1 ≤ 1+x ⟸ 0 ≤ x: `le_add_of_nonneg_right (by positivity)`. But the x here: M = 1+1/(2n) with n:ℝ: 0 ≤ 1/(2n) by positivity ✓. So (le_add_of_nonneg_right (by positivity) : (1:ℝ) ≤ M). Similarly in h2 (pow_le_pow_right₀ (by positivity)): same fix. And in pow_one_add_inv_two_mul_le there's pow_le_pow_left₀ (by positivity) hbase n — pow_le_pow_left₀ (ha : 0 ≤ a) (hab : a ≤ b) (n : ℕ) — (by positivity) proves 0 ≤ 1+1/(2n) ✓ fine (0 ≤ is positivity). Let me rewrite the file completely with the M abbreviation.
`conj` is scope-locked notation for `starRingEnd ℂ` — I'll use the bundled form directly. Rewriting with all fixes plus an `M` abbreviation to kill the Nat-literal elaboration trap.
tool: Write
input
{
  "file_path": "D:\\Python\\Quantum\\research\\lean\\NguyenRH1\\Scratch.lean",
  "content": "/- Session 015 scratch: ii\u2032-1a \u2014 paired liSummand + summability (D-064 \u00a71).\n   When green, merge into LiSkeleton.lean \u00a71 replacing the defective liCoeff. -/\nimport Mathlib\nimport Zeta23.WeilEF.ZeroSummability\nimport Zeta23.Statement.SeamClosed\n\nopen Zeta23 Complex Filter Topology\n\nnoncomputable section\n\nnamespace NguyenRH1\n\n/-- The paired (symmetrized) Li summand: \u00bd\u00b7mult\u00b7(f \u03c1 + f \u03c1\u0304),\nf \u03c1 = 1 \u2212 (1\u22121/\u03c1)\u207f. Manifestly real-valued (`liSummand_eq`), absolutely\nsummable (`liSummable`) \u2014 the correct Keiper\u2013Li coefficient (D-064 \u00a71:\nthe plain unordered sum of f over the zeros is not absolutely\nsummable; the pairing is the classical Bombieri\u2013Lagarias convention). -/\ndef liSummand (n : \u2115) (\u03c1 : {\u03c1 : \u2102 // IsNontrivialZero \u03c1}) : \u2102 :=\n  (zeroMult \u03c1 : \u2102) / 2 *\n    ((1 - (1 - 1 / (\u03c1 : \u2102)) ^ n) + (1 - (1 - 1 / ((starRingEnd \u2102) (\u03c1 : \u2102))) ^ n))\n\nlemma summand_conj (n : \u2115) (z : \u2102) :\n    (1 : \u2102) - (1 - 1 / ((starRingEnd \u2102) z)) ^ n = (starRingEnd \u2102) ((1 - (1 - 1 / z) ^ n)) := by\n  rw [map_sub, map_one, map_pow, map_sub, map_one, map_div\u2080, map_one]\n\nlemma liSummand_eq (n : \u2115) (\u03c1 : {\u03c1 : \u2102 // IsNontrivialZero \u03c1}) :\n    liSummand n \u03c1 = (zeroMult \u03c1 : \u2102) * (((1 - (1 - 1 / (\u03c1 : \u2102)) ^ n).re) : \u2102) := by\n  rw [liSummand, summand_conj, Complex.add_conj]\n  push_cast\n  ring\n\n/-! ### The geometric-sum estimate: |Re(1 \u2212 w\u207f)| \u2264 2n\u00b2/\u2016z\u2016\u00b2 for w = 1\u22121/z -/\n\n/-- (1 + 1/(2n))\u207f \u2264 2 for n \u2265 1. Via (1+x)\u207f \u2264 exp(nx) and exp(1/2) \u2264 2. -/\nlemma pow_one_add_inv_two_mul_le (n : \u2115) (hn : 1 \u2264 n) :\n    ((1 : \u211d) + 1 / (2 * n)) ^ n \u2264 2 := by\n  have hn0 : (0 : \u211d) < n := by exact_mod_cast hn\n  have hbase : (1 : \u211d) + 1 / (2 * n) \u2264 Real.exp (1 / (2 * n)) := by\n    have h := Real.add_one_le_exp (1 / (2 * (n : \u211d)))\n    linarith\n  have h1 : ((1 : \u211d) + 1 / (2 * n)) ^ n \u2264 Real.exp (1 / 2) := by\n    calc ((1 : \u211d) + 1 / (2 * n)) ^ n\n        \u2264 (Real.exp (1 / (2 * n))) ^ n := pow_le_pow_left\u2080 (by positivity) hbase n\n      _ = Real.exp (\u2191n * (1 / (2 * n))) := by rw [Real.exp_nat_mul]\n      _ = Real.exp (1 / 2) := by congr 1; field_simp\n  have h2 : Real.exp (1 / 2 : \u211d) \u2264 2 := by\n    have h3 : (1 : \u211d) / 2 \u2264 Real.log 2 := by\n      have h := Real.log_two_gt_d9\n      linarith\n    calc Real.exp (1 / 2 : \u211d) \u2264 Real.exp (Real.log 2) := Real.exp_le_exp.mpr h3\n      _ = 2 := Real.exp_log (by norm_num)\n  exact h1.trans h2\n\n/-- Key estimate: for n \u2265 1, z with re z \u2208 [0,1], 2n \u2264 \u2016z\u2016:\n|Re(1 \u2212 (1\u22121/z)\u207f)| \u2264 2n\u00b2/\u2016z\u2016\u00b2. -/\nlemma re_li_summand_le {n : \u2115} (hn : 1 \u2264 n) {z : \u2102}\n    (hzre0 : 0 \u2264 z.re) (hzre1 : z.re \u2264 1) (hz : 2 * n \u2264 \u2016z\u2016) :\n    |(1 - (1 - 1 / z) ^ n).re| \u2264 2 * n ^ 2 / \u2016z\u2016 ^ 2 := by\n  have hn0 : (0 : \u211d) < n := by exact_mod_cast hn\n  have hz0 : z \u2260 0 := by\n    intro h; rw [h, norm_zero] at hz; linarith\n  have hzn : (0 : \u211d) < \u2016z\u2016 := norm_pos_iff.mpr hz0\n  have hnsq : Complex.normSq z = \u2016z\u2016 ^ 2 := Complex.normSq_eq_norm_sq z\n  set M : \u211d := 1 + 1 / (2 * (n : \u211d)) with hM\n  have hM0 : (0 : \u211d) \u2264 1 / (2 * (n : \u211d)) := by positivity\n  have hM1 : (1 : \u211d) \u2264 M := le_add_of_nonneg_right hM0\n  set w : \u2102 := 1 - 1 / z with hw\n  -- kernel identity: 1 \u2212 w\u207f = (1/z)\u00b7S, S = \u03a3_{j<n} w^j\n  have hgeom : (w - 1) * \u2211 j \u2208 Finset.range n, w ^ j = w ^ n - 1 := mul_geom_sum w n\n  have hw1 : w - 1 = -(1 / z) := by rw [hw]; ring\n  have hf : (1 : \u2102) - w ^ n = (1 / z) * \u2211 j \u2208 Finset.range n, w ^ j := by\n    have e : (1 : \u2102) - w ^ n = -(w ^ n - 1) := by ring\n    rw [e, \u2190 hgeom, hw1]; ring\n  set S : \u2102 := \u2211 j \u2208 Finset.range n, w ^ j\n  have hS : S = (n : \u2102) + (S - n) := by ring\n  -- \u2016w\u2016 \u2264 1 + 1/\u2016z\u2016\n  have hwnorm : \u2016w\u2016 \u2264 1 + 1 / \u2016z\u2016 := by\n    have e : w = 1 - z\u207b\u00b9 := by rw [hw, div_eq_mul_inv, one_mul]\n    rw [e]\n    calc \u2016(1 : \u2102) - z\u207b\u00b9\u2016 \u2264 \u2016(1 : \u2102)\u2016 + \u2016z\u207b\u00b9\u2016 := norm_sub_le _ _\n      _ = 1 + 1 / \u2016z\u2016 := by rw [norm_one, norm_inv, inv_eq_one_div]\n  have h1z : 1 / \u2016z\u2016 \u2264 1 / (2 * n) :=\n    one_div_le_one_div_of_le (by positivity) (by exact_mod_cast hz)\n  have hwmax : max 1 \u2016w\u2016 \u2264 M := by\n    apply max_le hM1\n    exact hwnorm.trans (by rw [hM]; linarith)\n  -- |S \u2212 n| \u2264 n\u00b2/\u2016z\u2016\n  have hSn : \u2016S - n\u2016 \u2264 n ^ 2 / \u2016z\u2016 := by\n    have hSn1 : S - n = \u2211 j \u2208 Finset.range n, (w ^ j - 1) := by\n      have e : (n : \u2102) = \u2211 j \u2208 Finset.range n, (1 : \u2102) := by\n        simp [Finset.sum_const, Finset.card_range]\n      rw [e, \u2190 Finset.sum_sub_distrib]\n    rw [hSn1]\n    have hbound : \u2200 j \u2208 Finset.range n,\n        \u2016w ^ j - 1\u2016 \u2264 (1 / \u2016z\u2016) * (j * M ^ (n - 1)) := by\n      intro j hj\n      have hgeomj : (w - 1) * \u2211 i \u2208 Finset.range j, w ^ i = w ^ j - 1 := mul_geom_sum w j\n      have h2 : w ^ j - 1 = -(1 / z) * \u2211 i \u2208 Finset.range j, w ^ i := by\n        rw [\u2190 hgeomj, hw1]\n      rw [h2, norm_mul, norm_neg, norm_div, norm_one]\n      have hsum : \u2016\u2211 i \u2208 Finset.range j, w ^ i\u2016 \u2264 j * M ^ (n - 1) := by\n        calc \u2016\u2211 i \u2208 Finset.range j, w ^ i\u2016\n            \u2264 \u2211 i \u2208 Finset.range j, \u2016w ^ i\u2016 := norm_sum_le _ _\n          _ \u2264 \u2211 i \u2208 Finset.range j, M ^ (n - 1) := by\n              apply Finset.sum_le_sum\n              intro i hi\n              rw [norm_pow]\n              have hij : i < j := Finset.mem_range.mp hi\n              have hjn : j \u2264 n := le_of_lt (Finset.mem_range.mp hj)\n              have h1 : \u2016w\u2016 ^ i \u2264 M ^ i :=\n                pow_le_pow_left\u2080 (norm_nonneg _)\n                  (le_trans (le_max_right 1 \u2016w\u2016) hwmax) i\n              have h2 : M ^ i \u2264 M ^ (n - 1) := pow_le_pow_right\u2080 hM1 (by omega)\n              exact h1.trans h2\n          _ = j * M ^ (n - 1) := by\n              rw [Finset.sum_const, Finset.card_range, nsmul_eq_mul]\n      exact mul_le_mul_of_nonneg_left hsum (by positivity)\n    calc \u2211 j \u2208 Finset.range n, \u2016w ^ j - 1\u2016\n        \u2264 \u2211 j \u2208 Finset.range n, (1 / \u2016z\u2016) * (j * M ^ (n - 1)) :=\n          Finset.sum_le_sum hbound\n      _ = ((1 / \u2016z\u2016) * M ^ (n - 1)) * \u2211 j \u2208 Finset.range n, j := by\n          rw [\u2190 Finset.mul_sum]\n          apply Finset.sum_congr rfl\n          intro j _; ring\n      _ \u2264 n ^ 2 / \u2016z\u2016 := by\n          have hsumj : (\u2211 j \u2208 Finset.range n, j : \u211d) = n * (n - 1) / 2 := by\n            have h := Finset.sum_range_id_mul_two n\n            have h2 : ((\u2211 j \u2208 Finset.range n, j : \u2115) : \u211d) * 2 = n * (n - 1) := by\n              exact_mod_cast h\n            linarith\n          rw [hsumj]\n          have hpow : M ^ (n - 1) \u2264 2 :=\n            le_trans (pow_le_pow_right\u2080 hM1 (Nat.sub_le n 1))\n              (pow_one_add_inv_two_mul_le n hn)\n          have hb1 : (n : \u211d) * (n - 1) / 2 \u2264 n ^ 2 / 2 := by nlinarith [hn0]\n          have hb2 : M ^ (n - 1) * (n * (n - 1) / 2) \u2264 2 * (n ^ 2 / 2) :=\n            mul_le_mul_of_nonneg hpow hb1 (by positivity) (by positivity)\n          have hb3 : ((1 : \u211d) / \u2016z\u2016) * M ^ (n - 1) * (n * (n - 1) / 2)\n              \u2264 (1 / \u2016z\u2016) * (2 * (n ^ 2 / 2)) :=\n            mul_le_mul_of_nonneg_left hb2 (by positivity)\n          exact hb3.trans (by ring_nf)\n  -- Re(f) = n\u00b7z.re/\u2016z\u2016\u00b2 + ((S\u2212n)/z).re\n  have hre1 : ((n : \u2102) * (1 / z)).re = n * z.re / \u2016z\u2016 ^ 2 := by\n    have hinv : ((1 : \u2102) / z).re = z.re / \u2016z\u2016 ^ 2 := by\n      rw [one_div, Complex.inv_re, hnsq]\n    rw [Complex.mul_re]\n    simp [hinv]\n  have hfre : (1 - w ^ n).re = n * z.re / \u2016z\u2016 ^ 2 + ((S - n) / z).re := by\n    rw [hf, hS, Complex.add_re]\n    congr 1\n    rw [mul_comm, div_eq_mul_inv]\n    exact hre1\n  rw [hfre]\n  have hA : |n * z.re / \u2016z\u2016 ^ 2| \u2264 n / \u2016z\u2016 ^ 2 := by\n    rw [abs_div, abs_mul, abs_of_nonneg hn0.le,\n      abs_of_nonneg (sq_nonneg \u2016z\u2016)]\n    apply (div_le_div_right (by positivity)).mpr\n    apply mul_le_mul_of_nonneg_left _ hn0.le\n    exact abs_le.mpr \u27e8hzre0, hzre1\u27e9\n  have hB : |((S - n) / z).re| \u2264 n ^ 2 / \u2016z\u2016 ^ 2 := by\n    have h1 : |((S - n) / z).re| \u2264 \u2016(S - n) / z\u2016 := Complex.abs_re_le_norm _\n    have h2 : \u2016(S - n) / z\u2016 \u2264 (n ^ 2 / \u2016z\u2016) / \u2016z\u2016 := by\n      rw [norm_div]\n      exact (div_le_div_right hzn).mpr hSn\n    exact h1.trans (h2.trans (by rw [div_div, \u2190 pow_two]))\n  have hnn : (n : \u211d) \u2264 n ^ 2 := by\n    have h : (1 : \u211d) \u2264 n := by exact_mod_cast hn\n    nlinarith\n  calc |n * z.re / \u2016z\u2016 ^ 2 + ((S - n) / z).re|\n      \u2264 n / \u2016z\u2016 ^ 2 + n ^ 2 / \u2016z\u2016 ^ 2 := (abs_add _ _).trans (add_le_add hA hB)\n    _ = (n + n ^ 2) / \u2016z\u2016 ^ 2 := by ring\n    _ \u2264 2 * n ^ 2 / \u2016z\u2016 ^ 2 := by\n        apply (div_le_div_right (by positivity)).mpr\n        linarith\n\nend NguyenRH1\n"
}
raw content_json (database row)
[{"type":"thinking","thinking":"Now it's clear: in this Mathlib, the recommended form is `starRingEnd ℂ` (available as notation `conj` only inside the `ComplexConjugate` scope). And `star z` for ℂ IS the star operation (StarRing instance shown here). So:\n- `star z` works directly (the StarRing ℂ instance).\n- `Complex.add_conj : z + conj z = ...` — with conj = starRingEnd ℂ (via the scope). `star z` and `(starRingEnd ℂ) z` are both the star operation — defeq but different head constants.\n\nSimplest robust approach: use `starRingEnd ℂ` explicitly (the bundled hom — map_ lemmas apply). In the def: `(starRingEnd ℂ) (ρ:ℂ)`. And for liSummand_eq, instead of Complex.add_conj, use the star-based lemma: is there `star_add_self` or `Complex.star_def`? There's `RCLike` generic: `star_def`? Simpler: `Complex.add_conj` is about `starRingEnd ℂ z` (since conj in that file = starRingEnd ℂ via scope) — so with my def using starRingEnd ℂ, the lemma applies directly!\n\nLet me confirm: in Mathlib/Data/Complex/Basic.lean, line 45 `open ComplexConjugate` — so within that file, `conj` = the scoped notation for starRingEnd ℂ. So `Complex.add_conj : z + starRingEnd ℂ z = ((2 * z.re : ℝ) : ℂ)` ✓. So in my code, write `(starRingEnd ℂ)` instead of `conj`, and Complex.add_conj will match (pattern `?z + starRingEnd ℂ ?z` — my term has exactly `starRingEnd ℂ f` ✓).\n\nAnd summand_conj becomes:\n```\nlemma summand_conj (n : ℕ) (z : ℂ) :\n    (1 : ℂ) - (1 - 1 / ((starRingEnd ℂ) z)) ^ n = (starRingEnd ℂ) ((1 - (1 - 1 / z) ^ n)) := by\n  rw [map_sub, map_one, map_pow, map_sub, map_one, map_div₀, map_one]\n```\nmap_sub (starRingEnd ℂ) — these generic map_ lemmas apply to bundled ring homs ✓.\n\nNow the other fixes:\n- hSn1/rw [hSn1] at * — restructure: rw [hSn1] BEFORE the calc (at goal ‖S − n‖ ≤ ...).\n- The `↑(∑ ...)` cast issue: annotate `(1 + 1 / (2 * (n : ℝ))) ^ (n - 1)` — with (n:ℝ) cast inside, the whole body elaborates at ℝ ✓. I'll introduce a local abbreviation `M : ℝ := 1 + 1 / (2 * n)` — with (n:ℝ) — and use M everywhere to avoid repeated elaboration issues. Since n : ℕ, writing `(2 * (n : ℝ))` forces ℝ.\n\nLet me define at the top of re_li_summand_le: `set M : ℝ := 1 + 1 / (2 * (n : ℝ)) with hM` — then hwmax : max 1 ‖w‖ ≤ M, hpow : M^(n-1) ≤ 2, etc. Cleaner.\n\nAlso \"No goals to be solved\" at line 97 — that was in hsumj area? Line 97 col 18: looking at previous version line numbers — it was in the `rw [hSn1] at *` region or `h := Finset.sum_range_id_mul_two n; h2 ... linarith` — actually 97:18 in the last file is in the h2 sub-proof of hbound (`rw [← h]; ring` — where after rw [← h] the goal might already be closed by rw's rfl). Let me make h2's proof robust:\nhave h2 : w ^ j - 1 = -(1 / z) * ∑ i ∈ Finset.range j, w ^ i := by\n  rw [← hgeomj, hw1]\nAfter rw [← hgeomj]: goal (w−1)·∑ = −(1/z)·∑; rw [hw1]: −(1/z)·∑ = −(1/z)·∑ — rfl by rw ✓ closed automatically. But earlier I had `have h := hgeomj; rw [hw1] at h; rw [← h]; ring` — the rw [← h] closed it and ring had no goals. New version handles cleanly.\n\nAlso hgeomj line: `have hgeomj : (w - 1) * ∑ i ∈ Finset.range j, w ^ i = w ^ j - 1 := mul_geom_sum w j` ✓.\n\nOne more from the error list: 114:49 unsolved goals — that was inside the hpow/hb chain probably (hb3.trans (by ring_nf)) — ring_nf might not fully close `(1/‖z‖) * (2 * (n^2/2)) = n^2/‖z‖`? ring_nf should prove equality of the form a*(2*(b/2)) = a*b — it's `mul` arithmetic — actually (1/‖z‖)*(2*(n²/2)) = (1/‖z‖)*n² = n²/‖z‖ ✓ ring_nf should handle. The unsolved goals error was probably cascading from earlier errors. Let me rewrite the full file with all fixes and iterate.\n\nAlso `pow_le_pow_right₀ (by positivity) (Nat.sub_le n 1)` — signature (ha : 1 ≤ a) (hmn : m ≤ n): `by positivity` proves 1 ≤ 1+1/(2n)? positivity proves 0 < x — not 1 ≤ x. Use `by have : (0:ℝ) ≤ 1/(2*(n:ℝ)) := by positivity; linarith` or `le_add_of_nonneg_left`... 1 ≤ 1+x ⟸ 0 ≤ x: `le_add_of_nonneg_right (by positivity)`. But the x here: M = 1+1/(2n) with n:ℝ: 0 ≤ 1/(2n) by positivity ✓. So (le_add_of_nonneg_right (by positivity) : (1:ℝ) ≤ M).\n\nSimilarly in h2 (pow_le_pow_right₀ (by positivity)): same fix.\n\nAnd in pow_one_add_inv_two_mul_le there's pow_le_pow_left₀ (by positivity) hbase n — pow_le_pow_left₀ (ha : 0 ≤ a) (hab : a ≤ b) (n : ℕ) — (by positivity) proves 0 ≤ 1+1/(2n) ✓ fine (0 ≤ is positivity).\n\nLet me rewrite the file completely with the M abbreviation.","signature":""},{"type":"text","text":"`conj` is scope-locked notation for `starRingEnd ℂ` — I'll use the bundled form directly. Rewriting with all fixes plus an `M` abbreviation to kill the Nat-literal elaboration trap."},{"type":"tool_use","id":"Write_102","name":"Write","input":{"file_path":"D:\\Python\\Quantum\\research\\lean\\NguyenRH1\\Scratch.lean","content":"/- Session 015 scratch: ii′-1a — paired liSummand + summability (D-064 §1).\n   When green, merge into LiSkeleton.lean §1 replacing the defective liCoeff. -/\nimport Mathlib\nimport Zeta23.WeilEF.ZeroSummability\nimport Zeta23.Statement.SeamClosed\n\nopen Zeta23 Complex Filter Topology\n\nnoncomputable section\n\nnamespace NguyenRH1\n\n/-- The paired (symmetrized) Li summand: ½·mult·(f ρ + f ρ̄),\nf ρ = 1 − (1−1/ρ)ⁿ. Manifestly real-valued (`liSummand_eq`), absolutely\nsummable (`liSummable`) — the correct Keiper–Li coefficient (D-064 §1:\nthe plain unordered sum of f over the zeros is not absolutely\nsummable; the pairing is the classical Bombieri–Lagarias convention). -/\ndef liSummand (n : ℕ) (ρ : {ρ : ℂ // IsNontrivialZero ρ}) : ℂ :=\n  (zeroMult ρ : ℂ) / 2 *\n    ((1 - (1 - 1 / (ρ : ℂ)) ^ n) + (1 - (1 - 1 / ((starRingEnd ℂ) (ρ : ℂ))) ^ n))\n\nlemma summand_conj (n : ℕ) (z : ℂ) :\n    (1 : ℂ) - (1 - 1 / ((starRingEnd ℂ) z)) ^ n = (starRingEnd ℂ) ((1 - (1 - 1 / z) ^ n)) := by\n  rw [map_sub, map_one, map_pow, map_sub, map_one, map_div₀, map_one]\n\nlemma liSummand_eq (n : ℕ) (ρ : {ρ : ℂ // IsNontrivialZero ρ}) :\n    liSummand n ρ = (zeroMult ρ : ℂ) * (((1 - (1 - 1 / (ρ : ℂ)) ^ n).re) : ℂ) := by\n  rw [liSummand, summand_conj, Complex.add_conj]\n  push_cast\n  ring\n\n/-! ### The geometric-sum estimate: |Re(1 − wⁿ)| ≤ 2n²/‖z‖² for w = 1−1/z -/\n\n/-- (1 + 1/(2n))ⁿ ≤ 2 for n ≥ 1. Via (1+x)ⁿ ≤ exp(nx) and exp(1/2) ≤ 2. -/\nlemma pow_one_add_inv_two_mul_le (n : ℕ) (hn : 1 ≤ n) :\n    ((1 : ℝ) + 1 / (2 * n)) ^ n ≤ 2 := by\n  have hn0 : (0 : ℝ) < n := by exact_mod_cast hn\n  have hbase : (1 : ℝ) + 1 / (2 * n) ≤ Real.exp (1 / (2 * n)) := by\n    have h := Real.add_one_le_exp (1 / (2 * (n : ℝ)))\n    linarith\n  have h1 : ((1 : ℝ) + 1 / (2 * n)) ^ n ≤ Real.exp (1 / 2) := by\n    calc ((1 : ℝ) + 1 / (2 * n)) ^ n\n        ≤ (Real.exp (1 / (2 * n))) ^ n := pow_le_pow_left₀ (by positivity) hbase n\n      _ = Real.exp (↑n * (1 / (2 * n))) := by rw [Real.exp_nat_mul]\n      _ = Real.exp (1 / 2) := by congr 1; field_simp\n  have h2 : Real.exp (1 / 2 : ℝ) ≤ 2 := by\n    have h3 : (1 : ℝ) / 2 ≤ Real.log 2 := by\n      have h := Real.log_two_gt_d9\n      linarith\n    calc Real.exp (1 / 2 : ℝ) ≤ Real.exp (Real.log 2) := Real.exp_le_exp.mpr h3\n      _ = 2 := Real.exp_log (by norm_num)\n  exact h1.trans h2\n\n/-- Key estimate: for n ≥ 1, z with re z ∈ [0,1], 2n ≤ ‖z‖:\n|Re(1 − (1−1/z)ⁿ)| ≤ 2n²/‖z‖². -/\nlemma re_li_summand_le {n : ℕ} (hn : 1 ≤ n) {z : ℂ}\n    (hzre0 : 0 ≤ z.re) (hzre1 : z.re ≤ 1) (hz : 2 * n ≤ ‖z‖) :\n    |(1 - (1 - 1 / z) ^ n).re| ≤ 2 * n ^ 2 / ‖z‖ ^ 2 := by\n  have hn0 : (0 : ℝ) < n := by exact_mod_cast hn\n  have hz0 : z ≠ 0 := by\n    intro h; rw [h, norm_zero] at hz; linarith\n  have hzn : (0 : ℝ) < ‖z‖ := norm_pos_iff.mpr hz0\n  have hnsq : Complex.normSq z = ‖z‖ ^ 2 := Complex.normSq_eq_norm_sq z\n  set M : ℝ := 1 + 1 / (2 * (n : ℝ)) with hM\n  have hM0 : (0 : ℝ) ≤ 1 / (2 * (n : ℝ)) := by positivity\n  have hM1 : (1 : ℝ) ≤ M := le_add_of_nonneg_right hM0\n  set w : ℂ := 1 - 1 / z with hw\n  -- kernel identity: 1 − wⁿ = (1/z)·S, S = Σ_{j<n} w^j\n  have hgeom : (w - 1) * ∑ j ∈ Finset.range n, w ^ j = w ^ n - 1 := mul_geom_sum w n\n  have hw1 : w - 1 = -(1 / z) := by rw [hw]; ring\n  have hf : (1 : ℂ) - w ^ n = (1 / z) * ∑ j ∈ Finset.range n, w ^ j := by\n    have e : (1 : ℂ) - w ^ n = -(w ^ n - 1) := by ring\n    rw [e, ← hgeom, hw1]; ring\n  set S : ℂ := ∑ j ∈ Finset.range n, w ^ j\n  have hS : S = (n : ℂ) + (S - n) := by ring\n  -- ‖w‖ ≤ 1 + 1/‖z‖\n  have hwnorm : ‖w‖ ≤ 1 + 1 / ‖z‖ := by\n    have e : w = 1 - z⁻¹ := by rw [hw, div_eq_mul_inv, one_mul]\n    rw [e]\n    calc ‖(1 : ℂ) - z⁻¹‖ ≤ ‖(1 : ℂ)‖ + ‖z⁻¹‖ := norm_sub_le _ _\n      _ = 1 + 1 / ‖z‖ := by rw [norm_one, norm_inv, inv_eq_one_div]\n  have h1z : 1 / ‖z‖ ≤ 1 / (2 * n) :=\n    one_div_le_one_div_of_le (by positivity) (by exact_mod_cast hz)\n  have hwmax : max 1 ‖w‖ ≤ M := by\n    apply max_le hM1\n    exact hwnorm.trans (by rw [hM]; linarith)\n  -- |S − n| ≤ n²/‖z‖\n  have hSn : ‖S - n‖ ≤ n ^ 2 / ‖z‖ := by\n    have hSn1 : S - n = ∑ j ∈ Finset.range n, (w ^ j - 1) := by\n      have e : (n : ℂ) = ∑ j ∈ Finset.range n, (1 : ℂ) := by\n        simp [Finset.sum_const, Finset.card_range]\n      rw [e, ← Finset.sum_sub_distrib]\n    rw [hSn1]\n    have hbound : ∀ j ∈ Finset.range n,\n        ‖w ^ j - 1‖ ≤ (1 / ‖z‖) * (j * M ^ (n - 1)) := by\n      intro j hj\n      have hgeomj : (w - 1) * ∑ i ∈ Finset.range j, w ^ i = w ^ j - 1 := mul_geom_sum w j\n      have h2 : w ^ j - 1 = -(1 / z) * ∑ i ∈ Finset.range j, w ^ i := by\n        rw [← hgeomj, hw1]\n      rw [h2, norm_mul, norm_neg, norm_div, norm_one]\n      have hsum : ‖∑ i ∈ Finset.range j, w ^ i‖ ≤ j * M ^ (n - 1) := by\n        calc ‖∑ i ∈ Finset.range j, w ^ i‖\n            ≤ ∑ i ∈ Finset.range j, ‖w ^ i‖ := norm_sum_le _ _\n          _ ≤ ∑ i ∈ Finset.range j, M ^ (n - 1) := by\n              apply Finset.sum_le_sum\n              intro i hi\n              rw [norm_pow]\n              have hij : i < j := Finset.mem_range.mp hi\n              have hjn : j ≤ n := le_of_lt (Finset.mem_range.mp hj)\n              have h1 : ‖w‖ ^ i ≤ M ^ i :=\n                pow_le_pow_left₀ (norm_nonneg _)\n                  (le_trans (le_max_right 1 ‖w‖) hwmax) i\n              have h2 : M ^ i ≤ M ^ (n - 1) := pow_le_pow_right₀ hM1 (by omega)\n              exact h1.trans h2\n          _ = j * M ^ (n - 1) := by\n              rw [Finset.sum_const, Finset.card_range, nsmul_eq_mul]\n      exact mul_le_mul_of_nonneg_left hsum (by positivity)\n    calc ∑ j ∈ Finset.range n, ‖w ^ j - 1‖\n        ≤ ∑ j ∈ Finset.range n, (1 / ‖z‖) * (j * M ^ (n - 1)) :=\n          Finset.sum_le_sum hbound\n      _ = ((1 / ‖z‖) * M ^ (n - 1)) * ∑ j ∈ Finset.range n, j := by\n          rw [← Finset.mul_sum]\n          apply Finset.sum_congr rfl\n          intro j _; ring\n      _ ≤ n ^ 2 / ‖z‖ := by\n          have hsumj : (∑ j ∈ Finset.range n, j : ℝ) = n * (n - 1) / 2 := by\n            have h := Finset.sum_range_id_mul_two n\n            have h2 : ((∑ j ∈ Finset.range n, j : ℕ) : ℝ) * 2 = n * (n - 1) := by\n              exact_mod_cast h\n            linarith\n          rw [hsumj]\n          have hpow : M ^ (n - 1) ≤ 2 :=\n            le_trans (pow_le_pow_right₀ hM1 (Nat.sub_le n 1))\n              (pow_one_add_inv_two_mul_le n hn)\n          have hb1 : (n : ℝ) * (n - 1) / 2 ≤ n ^ 2 / 2 := by nlinarith [hn0]\n          have hb2 : M ^ (n - 1) * (n * (n - 1) / 2) ≤ 2 * (n ^ 2 / 2) :=\n            mul_le_mul_of_nonneg hpow hb1 (by positivity) (by positivity)\n          have hb3 : ((1 : ℝ) / ‖z‖) * M ^ (n - 1) * (n * (n - 1) / 2)\n              ≤ (1 / ‖z‖) * (2 * (n ^ 2 / 2)) :=\n            mul_le_mul_of_nonneg_left hb2 (by positivity)\n          exact hb3.trans (by ring_nf)\n  -- Re(f) = n·z.re/‖z‖² + ((S−n)/z).re\n  have hre1 : ((n : ℂ) * (1 / z)).re = n * z.re / ‖z‖ ^ 2 := by\n    have hinv : ((1 : ℂ) / z).re = z.re / ‖z‖ ^ 2 := by\n      rw [one_div, Complex.inv_re, hnsq]\n    rw [Complex.mul_re]\n    simp [hinv]\n  have hfre : (1 - w ^ n).re = n * z.re / ‖z‖ ^ 2 + ((S - n) / z).re := by\n    rw [hf, hS, Complex.add_re]\n    congr 1\n    rw [mul_comm, div_eq_mul_inv]\n    exact hre1\n  rw [hfre]\n  have hA : |n * z.re / ‖z‖ ^ 2| ≤ n / ‖z‖ ^ 2 := by\n    rw [abs_div, abs_mul, abs_of_nonneg hn0.le,\n      abs_of_nonneg (sq_nonneg ‖z‖)]\n    apply (div_le_div_right (by positivity)).mpr\n    apply mul_le_mul_of_nonneg_left _ hn0.le\n    exact abs_le.mpr ⟨hzre0, hzre1⟩\n  have hB : |((S - n) / z).re| ≤ n ^ 2 / ‖z‖ ^ 2 := by\n    have h1 : |((S - n) / z).re| ≤ ‖(S - n) / z‖ := Complex.abs_re_le_norm _\n    have h2 : ‖(S - n) / z‖ ≤ (n ^ 2 / ‖z‖) / ‖z‖ := by\n      rw [norm_div]\n      exact (div_le_div_right hzn).mpr hSn\n    exact h1.trans (h2.trans (by rw [div_div, ← pow_two]))\n  have hnn : (n : ℝ) ≤ n ^ 2 := by\n    have h : (1 : ℝ) ≤ n := by exact_mod_cast hn\n    nlinarith\n  calc |n * z.re / ‖z‖ ^ 2 + ((S - n) / z).re|\n      ≤ n / ‖z‖ ^ 2 + n ^ 2 / ‖z‖ ^ 2 := (abs_add _ _).trans (add_le_add hA hB)\n    _ = (n + n ^ 2) / ‖z‖ ^ 2 := by ring\n    _ ≤ 2 * n ^ 2 / ‖z‖ ^ 2 := by\n        apply (div_le_div_right (by positivity)).mpr\n        linarith\n\nend NguyenRH1\n"},"extra_content":null}]