STEP 1418 — sympy Sum.is_convergent() 3 bug fix upstream contribution 準備
要旨
藤本さん問「ガブリエルのラッパは 数学上の 未確認問題を 解くのに 役立ちますか?」 を 起点 に、 積分/級数 収束判定 tool rei-critical-mcp 提案 → prior art audit で sympy Sum.is_convergent() が 既存 と 判明 → spot-check で sympy 3 bug 発見 → 藤本さん C 判断 (upstream contribution first) → 2 PR draft + git apply 可能 diff + submission guide 完成。
Rei prototype 20/20 test PASS + sympy 公式 test file 39 assert で wrong verdict 3→0 (誤答除去)、 12 baseline + 4 additional case 全 non-regression 100%。
藤本さん directive quote
「ガブリエルのラッパは、 数学上の 未確認問題を 解くのに 役立ちますか?」
(2026-08-26、 arc 起点)
「上記に 基づいて コネクタ用の ツール、 マシンには 出来ますか?」
(2026-08-26、 rei-critical-mcp 提案 契機)
「D → C で 問題ありません。」
(2026-08-26、 prior art audit 実施承認)
「C で お願い致します。」
(2026-08-26、 sympy upstream PR 3 件 準備 承認、 「一の再現 > 十の未検証」 discipline 直接適用)
3 bug root-cause + 実測 evidence
Bug 1 — 1 - cos(1/n) ~ 1/(2n²) 誤発散 (issue #12544)
Root cause: O(1-cos(1/n), (n,∞)).expr = 1 (loose upper bound、 true asymptotic 1/(2n²) を 捉えない) → p-series match で p=0、 0 ≥ -1 で S.false return。 Raabe test (fall-through で lim=2>1 → True 返せる) に 到達しない。
Verdict: stock wrong False → patched correct True
Bug 2 — depth-3 Bertrand 1/(n·log·loglog·logloglog) NotImplementedError
Root cause: 既存 Bertrand pattern が 1/(n^p·log^q·loglog^r) の 3 slot のみ、 4-nested log 対応不能 → terminal raise NotImplementedError に 到達。
Verdict: stock NotImplementedError → patched correct verdict 両方向 (`False` for depth-3 divergent、 `True` for `^2` suffix)
Bug 3 — sin(n)/n 誤発散
Root cause: O(sin(n)/n, (n,∞)).expr = 1/n (oscillatory 包絡上限)、 p=-1 で -1 ≥ -1 で S.false。 実際は Dirichlet で 条件収束。 sin(n)/n / (1/n) = sin(n) = AccumulationBounds(-1, 1) — tight 両側 asymptotic ではない。
Verdict: stock wrong False → patched honest NotImplementedError (sympy Dirichlet test が order.expr.is_Mul 制約で 1/n = Pow を 捉えない、 別 PR 候補)
Unified fix 設計
PR 1: Tightness guard (Bugs 1 + 3 統合)
O(f).expr を tight asymptotic として 扱う assumption が 誤り。 divergence 主張 は tight bound の 場合のみ 有効 (convergence 主張 は upper bound だけで OK)。 tightness を limit_seq(f / order.expr, sym) で 1 度 計算 → finite nonzero (not AccumulationBounds) の 場合のみ S.false return を 許可、 p-series test + 3-Bertrand test 両方の "return S.false" 分岐に guard 適用。 loose bound は Raabe / integral / Dirichlet の 後続 test に fall through。
try:
_tight_ratio = limit_seq(sequence_term / order.expr, sym)
except NotImplementedError:
_tight_ratio = None
o_bound_is_tight = (
_tight_ratio is not None
and _tight_ratio.is_finite is True
and _tight_ratio.is_zero is False
and not _tight_ratio.has(Limit)
and not isinstance(_tight_ratio, AccumulationBounds)
)
PR 2: 4-level Bertrand pattern (Bug 2、 PR 1 依存)
3-slot Bertrand pattern に 4-slot pattern 1/(n^p·log^q·loglog^r·logloglog^s) を 追加。 tie-breaking chain (p>1 / p=1∧q>1 / p=q=1∧r>1 / p=q=r=1∧s>1) は 標準 Cauchy 凝集 反復適用。 o_bound_is_tight guard は PR 1 から 継承。
Verification 実測
Rei prototype 20/20 PASS (test_patched.py)
- 4 previously-buggy case (Bug 1, 2, 3, 2-companion) — 全 fix or honest NIE
- 12 baseline case (basic p-series, exp decay, factorial, alternating, standard Bertrand) — 全 unchanged
- 4 additional docstring / edge case — 全 unchanged
Sympy 公式 test file 39 assert 抽出 (test_sums_products.py line 1052-1437)
| Status | Stock 1.13.3 | + PR 1 | + PR 1 & 2 |
|---|---|---|---|
| PASS | 37 | 36 | 36 |
| FAIL (wrong verdict) | 2 | 0 | 0 |
| NIE (honest) | 0 | 3 | 3 |
sin(n)/log(log(n)) は stock coincidental PASS 発覚 — sympy assert S.false 自体が 数学的に 誤り (Dirichlet で 収束するはず)、 stock は 誤答同士で 偶然一致 で PASS していた、 patched で NIE = 誠実。 sympy test 側 line 1136/1137/1197 3 件 更新必要 (PR に 含めることを 推奨)。
Deliverables (repo 版)
data/sympy-upstream-prep/step1418/:
PR1_tightness_guard.md+pr1_tightness_guard.patch— PR 1 説明 + git apply 可能 diffPR2_bertrand_4level.md+pr2_bertrand_4level.patch— PR 2 説明 + diffSUBMISSION_GUIDE.md—git/ghstep-by-step + 3 judgment pointclassify_series_v01.py— Rei prototype (~130 行、 21/21 test PASS)is_convergent_patched.py— standalone patched function (monkey-patch test 用)test_patched.py— Rei 20-case verification harnessrun_sympy_tests.py— sympy 公式 test file 39 assert 抽出 harness
藤本さん judgment 待ち (未実施)
- GitHub account 選択 —
fc0webから submit or sympy に事前相談 - PR strategy — 2 PR 順次 vs 1 combined (sympy maintainer は 通常 small focused 好むので 2 順次 推奨)
- sympy test 更新 を 同 PR に 含めるか — 含めない と CI red、 含める と 誠実 (推奨)