chat-log math extract v0.3 (STEP 1473 v0.1 → STEP 1476 v0.2 → STEP 1492 v0.3 in-place upgrade)

藤本さん directive → chat-Claude 「後処理型ツール」 提案 → v0.1 minimal prototype (STEP 1473) → 「v0.2 candidate 全部やる」 → v0.2 upgrade (STEP 1476) → 「進化途中のモノを進めて」 → v0.3 upgrade (STEP 1492) · Rei-AIOS · 2026-08-27 → 2026-08-28
v0.3 変更点 (STEP 1492、 in-place upgrade):
  1. Implicit function application = LaTeX 慣用記法 `\sin^2 x → sin(x)**2`、 `\cos^2 \theta → cos(theta)**2`、 `\ln^{3} y → ln(y)**3`、 `\sin^2 (x+1) → sin(x+1)**2` (paren arg)。 従来 v0.2 で input_incomplete だった Landauer/Pythagorean 系 数式 が 直接 決定可能
  2. Numerical probe 20-point 拡張 = 5 point → **20 point** (8 fixed edge cases: 0/1/-1/2/3/5/7/-2 + 12 deterministic random in [-10,10]、 hash(expr) seed で reproducible)。 verified confidence 向上 + refuted 検出 sensitivity 向上、 singularity skip 追加
  3. Chained equality human summary = 現状 chainSubverdicts field に 加え、 detail field に pair0=OK(sympy-simplify), pair1=NG(sympy-numerical) 形式 の per-pair summary 埋め込み。 ASCII glyph (OK/NG/?) で cp932 Windows console 安全

v0.4 candidate defer: 台帳 aggregate (複数会話ログ → 統合 ledger + determination-rate trending)。

v0.2 変更点 (STEP 1476):
  1. LaTeX Greek 変換 (24 小 + 10 大)、 未登録 `\command` placeholder 化
  2. Reserved function juxtaposition (`ln 2 → ln(2)`)
  3. Implicit multiplication (`k_B T → k_B * T`)
  4. Chained equality (`a = b = c` support)
  5. D-FUMT₈ projection (verified→TRUE / refuted→FALSE / etc)

目的

会話ログ (text) を 入力に、 数式を 抽出 → 正規化 → SymPy 数値照合 → 台帳 JSON の 4 段 pipeline で 処理する minimal prototype。 chat-Claude 2026-08-27 応答 「後処理型ツール」 route の 直接実装。

discipline 3 条:

  1. 抽出のみ、 生成なし — 会話ログに 書かれた 式のみ 拾う。 ツール側で 新規に 式を作らない (chat-Claude 「形式化演劇」 risk 予防)
  2. 判定経路に LLM を入れない — SymPy Python subprocess で 純計算判定。 CHECKER_SPEC_v0 (STEP 1364) 原則継承
  3. 「登録数」 でなく 「決定率」 — success metric = (verified + refuted) / total、 台帳肥大 gaming 予防

chat-Claude 提案 (2026-08-27) — quote

「後処理型(ツール):会話ログを食わせて、式を抽出 → 正規化 → 検証 → 台帳に追記する。 こちらが本命だと思います。
率直に言うと『式を吐き出す』部分にはあまり価値がありません。 Claude も Gemini も式は既にいくらでも書けます。 ボトルネックは生成側ではなく、 検証と同一性管理です。」
...
「対策は単純で、 抽出はするが生成はさせないこと。 会話中に人間か AI が明示的に立てた式だけを拾い、 ツール側が式を新規に作らない。 台帳の評価指標も『登録数』ではなく決定率 (verified / refuted / undecided の割合) にする。」

本 STEP は 上記提案の 「後処理型 minimal prototype」 の 直接実装。 chat-Claude 提案 100% 認諾、 monitoring 型 (harness 常駐不能) は 採用せず、 offline 後処理 route のみ。

実装 (4 段 pipeline)

実装ファイル
抽出5 LaTeX pattern (\(...\) / \[...\] / $...$ / $$...$$ / ```math) + optional plain-heuristic modescripts/chat-log-extract.ts
正規化LaTeX → Python 最小変換 (\cdot → *, \frac{a}{b} → ((a)/(b)), ^{n} → **(n) 等)、 SHA256 前 16 hex で 安定 ID同上 (canonicalize / stableId)
照合SymPy subprocess: simplify(LHS - RHS) + 5 point numerical probe (nonzero → refuted、 zero → verified)scripts/chat-log-extract-verify.py
台帳JSON append with metrics: total / verified / refuted / undecided / determination-rate / verified-rate / byMethod同上 (buildLedger)

Verdict 分類 semantic

statusmethod意味
verifiedsympy-simplify / sympy-numericalLHS = RHS 代数的一致 or 5/5 数値 substitution 一致
refutedsympy-numericalsimplify(LHS - RHS) ≠ 0 かつ 少なくとも 1 つの substitution で 差 検出 = counter-example あり
undecidedchecker_gapSymPy parse OK だが simplify 未収束 / timeout / 5/5 zero だが simplified nonzero
undecidedinput_incompleteSymPy parse fail (LaTeX Greek 未変換、 implicit multiplication 等)
undecidednot-equation= を含まない = well-formedness のみ判定

Test 結果 (v0.1 + v0.2 + v0.3 = 141/141 PASS)

v0.1 regression (npm run test:step1473) = 52 passed, 0 failed

v0.2 regression (npm run test:step1476) = 61 passed, 0 failed (1 assertion 更新: version 'v0.2'→'v0.3')

v0.3 new tests (npm run test:step1492) = 28 passed, 0 failed

v0.3 test 群:

  1. Implicit function application (7 assertion) — \sin^2 x / \cos^2 \theta / \sin^{3} y / \sin^2 (x+1) / \tan/\ln/\exp
  2. Trig identities via implicit function (2 assertion) — Pythagorean 直接 verify
  3. Numerical probe 20-point + edge cases (4 assertion) — identity / never-true / x²=1
  4. Chained equality human summary (4 assertion) — pair-level OK/NG glyph 埋め込み
  5. E2E raw LaTeX Pythagorean (3 assertion)
  6. Chained + implicit function combined (5 assertion)
  7. Version bump v0.3 (1 assertion)
  8. Backwards compatibility (3 assertion)

v0.2 test 群:

  1. LaTeX Greek 拡張 (8 assertion) — 小文字 + 大文字 + 未登録 `\to` placeholder 化
  2. Reserved function juxtaposition (6 assertion) — `ln 2 / sin x / cos theta / log 10 / sqrt{x} / exp t`
  3. Implicit multiplication (8 assertion) — `k_B T / m c^2 / a b c / 3(x+1) / )( / \sin x safety`
  4. Chained equality (7 assertion) — all-verified / any-refuted / mixed / empty-side
  5. D-FUMT₈ projection (11 assertion) — distribution + numeric mapping + version
  6. projectToD8() pure function (6 assertion) — verified/refuted/chained-mixed/not-equation/checker_gap/input_incomplete
  7. E2E v0.2 (12 assertion) — Landauer + Fisher + chained trig identity 実測

実運用 sample 2 種

sample 1: chat-Claude 応答 自体 = 0 抽出 (discipline 実証)

入力: data/chat-log-ledger/sample-input-2026-08-27-chat-claude-monitoring-proposal.md (chat-Claude 2026-08-27 monitoring-tool proposal verbatim = pure prose、 明示的な LaTeX 数式 なし)

extracted:         0
verified:          0
refuted:           0
undecided:         0
determination-rate: 0.0%

0 抽出 = 正しい挙動。 「監視 → 生成」 されていれば prose から fabricate されるが、 discipline 通り 「書かれた 式のみ」 の 結果として 何も生成しない。 chat-Claude 提案 「抽出はするが生成させない」 の 直接 empirical 実証。

sample 2: Rei stack 数式 6 件 (v0.1 → v0.2 で determination-rate 50% → 66.7% 改善)

入力: data/chat-log-ledger/sample-input-2026-08-27-rei-stack-formulas.md

# v0.1 (STEP 1473)
extracted: 6 / verified: 2 / refuted: 1 / undecided: 3 (input_incomplete 2 + not-equation 1)
determination-rate: 50.0% / verified-rate: 33.3%

# v0.2 (STEP 1476) — same input
extracted: 6 / verified: 2 / refuted: 2 / undecided: 2 (checker_gap 1 + not-equation 1)
determination-rate: 66.7% / verified-rate: 33.3%
d8-projection: TRUE=2 FALSE=2 BOTH=0 NEITHER=1 INFINITY=1

改善内訳 (v0.1 input_incomplete 2 件 が v0.2 で 決定域に 移動):

sample 4: LaTeX raw implicit function (v0.3 新規) — determination-rate 100%

入力: data/chat-log-ledger/sample-input-2026-08-28-latex-implicit-func.md — Pythagorean identity を raw LaTeX \sin^2 x + \cos^2 x = 1 形で 記述 (v0.2 では input_incomplete だった)

extracted:         5
  verified:        4  (Pythagorean × 3 form + chained + implicit combined)
  refuted:         1  (\sin^2 x + \cos^2 x = 2 明らか偽)
  undecided:       0
determination-rate: 100.0% ← v0.3 で 100% 達成
verified-rate:      80.0%
d8-projection: TRUE=4 FALSE=1 BOTH=0 NEITHER=0 INFINITY=0

v0.2 → v0.3 の 実装 improvement 実証: LaTeX 慣用記法 \sin^2 x (= (sin(x))² の 数学意味) が Python/SymPy syntax として 不正 だった 問題 を canonicalize 段で 解決。 Pythagorean identity (Greek arg / braced exponent / chained + implicit combined) 全 form を 直接 決定可能。

sample 3: chained equality demo (v0.2 新規)

入力: data/chat-log-ledger/sample-input-2026-08-27-chained-equality.md(a+b)^2 = a^2+2ab+b^2 = (b+a)^2 等 5 chained 数式

extracted:         5
  verified:        3  (all-verified 3-part chain, 交換律 3-part chain, 非-chain baseline)
  refuted:         1  (2·3 = 6 = 5、 middle wrong で refuted)
  undecided:       1  (a = = b、 malformed empty middle side = input_incomplete)
determination-rate: 80.0%
verified-rate:      60.0%
d8-projection: TRUE=3 FALSE=1 BOTH=0 NEITHER=1 INFINITY=0

chained equality 判定 は 各 pair (N-1) を 独立 verify し、 aggregate rule = 全 verified → verified / 1 でも refute → refuted / 混在 → chained-mixed。 最後の malformed は input_incomplete path で honest 報告。

Rei stack 位置 — 既存素材との mapping

chat-Claude 提案要素Rei stack 既存状態
判定経路に LLM 入れないCHECKER_SPEC_v0 (STEP 1364) + rei-checker-mcp v0.3 (STEP 1401、 LeanBackend REPL + D-FUMT₈ ledger projection)既存
事前登録 + 「グリーン ≠ 検証済み」 disciplinerei-preregister v0.1 (STEP 1359)既存
記号表 + 安定 IDrei-critical-mcp (STEP 1445 (c) partial approve、 spec §3 保留 (2) γ defer 追認 STEP 1451)部分
会話ログ抽出 → 正規化 → SymPy 数値照合 → 台帳追記(なし)本 STEP で 新規

「抽出するが生成させない」 discipline は STEP 1253 (i) requireAuditedInventionLiteralBan (発明版 pool saturation 予防) と 同 root cause の 数式版。 台帳の 「決定率」 metric も 「登録数」 → 「使用率」 shift の 数式版 に 対応。

Honest scope (v0.3)

v0.3 で 解決 (v0.2 制約 の 3/4 項目 実装完了):

v0.2 で 解決済 (継続): LaTeX Greek 変換 + reserved function juxtaposition + implicit multiplication + chained equality + D-FUMT₈ projection export

v0.3 残 制約:

意図的に採用しなかった: (i) monitoring 型 (harness 常駐不能、 chat-Claude 分析 正当) / (ii) LLM 判定 (「判定経路に LLM 入れない」 discipline) / (iii) 抽出時 の 式生成 (「形式化演劇」 risk 予防)

Files

Usage (v0.2)

# extract + verify + write ledger
npx tsx scripts/chat-log-extract.ts --input path/to/chat.md \
    --output data/chat-log-ledger/my-session.json

# with D-FUMT₈ projection (rei-checker-mcp consumable format)
npx tsx scripts/chat-log-extract.ts --input path/to/chat.md \
    --output my-ledger.json --d8-projection my-d8.json

# with plain-heuristic (also picks up prose lines like "x = y + 1")
npx tsx scripts/chat-log-extract.ts --input path/to/chat.md --plain-heuristic

# run tests
npm run test:step1473  # v0.1 regression
npm run test:step1476  # v0.2 regression
npm run test:step1492  # v0.3 new