STEP: 1499 / 公開日: 2026-08-28 / Test: 35/35 PASS / Lean 4: 13 theorem zero sorry / Type: 26 defer candidate 第 1 号 実装
❶ shannon_entropy_verdict = 分布 (List Nat 頻度) → Shannon エントロピー H(X) → D-FUMT₈ 8 verdict mapping の pure function。 STEP 1493 情報科学 arc 6 candidate の 第 1 号 実装。
❷ 姉妹 tool 群 に 連結: d8_verdict_from_measurement (STEP 1350 SNR) / d8_verdict_from_multi_trial (STEP 1371 BH FDR) / d8_verdict_from_sample_pair (STEP 1376 Welch t-test) と 同 pattern の determination-focused tool。
❸ 責務分離: TS (`src/mcp/shannon-entropy-verdict.ts`) が 実 entropy 計算 (Math.log2)、 Lean 4 (`data/lean4-transfer/step1499_*.lean`) が 決定表 骨格 (NEITHER/ZERO/TRUE) 静的 identity。 Mathlib 未 import で 実数精度 不可の 分業。
| # | Condition | Verdict | Reason |
|---|---|---|---|
| 1 | frequencies is empty | NEITHER | empty_distribution |
| 2 | total count = 0 | NEITHER | all_zero_counts |
| 3 | any negative frequency (NaN/-1 等) | NEITHER | negative_frequency |
| 4 | single-bin dominant (max ≥ 99% of total) | ZERO (〇) | deterministic_distribution |
| 5 | H(X) / H_max ≥ 0.95 (near uniform) | INFINITY (∞) | near_uniform_max_entropy |
| 6 | 0.5 ≤ H(X)/H_max < 0.95 | TRUE (⊤) | moderate_entropy |
| 7 | 0 < H(X)/H_max < 0.5 | BOTH | low_entropy_biased |
| 8 | H(X) = 0 (nonzero bins のみ 単一) | ZERO | zero_entropy_pure |
import { shannonEntropyVerdict } from './src/mcp/shannon-entropy-verdict';
// ケース A: 一様分布 (max entropy) → INFINITY
const rA = shannonEntropyVerdict({ frequencies: [25, 25, 25, 25] });
// { verdict: 'INFINITY', entropyBits: 2.0, normalizedEntropy: 1.0, ... }
// ケース B: 決定的分布 (single bin) → ZERO
const rB = shannonEntropyVerdict({ frequencies: [100, 0, 0, 0] });
// { verdict: 'ZERO', reason: 'deterministic_distribution', entropyBits: 0, ... }
// ケース C: moderate (70/30 分布) → TRUE
const rC = shannonEntropyVerdict({ frequencies: [70, 30] });
// { verdict: 'TRUE', reason: 'moderate_entropy', entropyBits: ~0.881, ... }
// ケース D: 偏り strong (90/10) → BOTH
const rD = shannonEntropyVerdict({ frequencies: [90, 10] });
// { verdict: 'BOTH', reason: 'low_entropy_biased', entropyBits: ~0.469, ... }
// ケース E: 空 or 全 0 or 負値 → NEITHER
const rE = shannonEntropyVerdict({ frequencies: [] });
// { verdict: 'NEITHER', reason: 'empty_distribution', ... }
// dominant を strict に (70% で ZERO 判定)
const r1 = shannonEntropyVerdict({
frequencies: [80, 20],
dominantThreshold: 0.7,
});
// { verdict: 'ZERO', ... }
// uniform を strict に (99% でないと INFINITY にしない)
const r2 = shannonEntropyVerdict({
frequencies: [60, 40],
uniformThreshold: 0.99,
});
// { verdict: 'TRUE', reason: 'moderate_entropy', ... }
ファイル: data/lean4-transfer/step1499_shannon_entropy_verdict.lean
-- 決定表 骨格 の 静的 identity (Nat 上) total_empty : total_count [] = 0 total_all_zero : total_count (replicate n 0) = 0 total_single : total_count [f] = f effective_empty : effective_bins [] = 0 effective_all_zero : effective_bins (replicate n 0) = 0 entropy_total_zero_gives_neither : total=0 → NEITHER entropy_effective_zero_gives_neither : effective=0 → NEITHER entropy_single_bin_gives_zero : effective=1 → ZERO entropy_dominant_gives_zero : 99% dominant → ZERO entropy_moderate_gives_true : non-dominant → TRUE is_dominant_total_zero : total=0 → dominant true (trivial) is_dominant_max_zero : max=0, total>0 → dominant false is_dominant_full : 100% → dominant true
| Category | Tests | Cases |
|---|---|---|
| Guard (NEITHER) | 10 | empty / negative / all-zero / NaN / Infinity |
| ZERO | 6 | single bin / near-deterministic 99.5% |
| INFINITY | 7 | 4-bin uniform / 8-bin uniform / 60/40 (~0.971) |
| TRUE | 5 | 70/30 moderate |
| BOTH | 3 | 90/10 low entropy biased |
| Custom threshold | 2 | dominant=0.7 / uniform=0.99 |
| Determinism | 3 | same input → same output (verdict + entropy + normalized) |
実行: npx tsx test/step1499-shannon-entropy-verdict-test.ts
| # | tool | 入力 | 目的 | STEP |
|---|---|---|---|---|
| 1 | d8_verdict_from_measurement | value + noise_floor + threshold_snr | SNR ≥ threshold → TRUE / < → NEITHER | 1350 |
| 2 | d8_verdict_from_multi_trial | p-value list + FDR α | BH FDR aggregate | 1371 |
| 3 | d8_verdict_from_sample_pair | 2 sample lists | Welch t-test + Cohen's d BOTH | 1376 + 1379 |
| 4 | shannonEntropyVerdict ★ | frequency list | H(X) → 8 verdict mapping | 1499 (本 tool) |
全 4 tool が pure function、 hardware 依存なし、 determination-focused。 4 tool 揃った ことで 「1 値」 「2 値比較」 「多試行 集約」 「分布 全体」 の 4 側面から D-FUMT₈ verdict 化 の コア完成。
❶ 実 entropy 計算 は Math.log2 の IEEE 754 double 精度 (~15-17 桁)。 huge n_bins (>2^50) では accumulation error あり、 実用範囲 (n_bins ≤ 1000) では 問題なし。
❷ Lean 4 side は 決定表 骨格 (NEITHER/ZERO/TRUE 3 verdict) の 静的 identity のみ 検証。 実 entropy 数値 (INFINITY/TRUE/BOTH の 境界) は Mathlib 未 import で 表現困難 のため TS 側 に 責務委譲。
❸ Kolmogorov 複雑度 は 計算不能 (Chaitin) のため 本 tool では 扱わず、 Shannon H(X) の 経験的 分布上 mapping のみ。 実 K(x) proxy は 別 candidate (kolmogorov_lower_bound) 側。
❹ MCP tool wire は 未実装 (rei-aios MCP server への 追加 は 別 STEP)。 現状 は 単体 module + test のみ。
❺ 「世界初」 主張なし。 Shannon (1948) の 既知 entropy formula の D-FUMT₈ verdict mapping。 novelty = 「8 verdict enum への 決定表 明示」 と 「4 姉妹 tool との API 統一」 の operational 側面。