STEP: 1507 / 公開日: 2026-08-28 / Test: 35/35 PASS / Lean 4: 13 theorem zero sorry / Type: STEP 1493 情報科学 arc candidate #2 実装
❶ hamming_distance_gate = bit string 対 (List Nat 0/1) → Hamming 距離 → 訂正可能性 verdict (TRUE/NEITHER/FALSE)。 STEP 1493 情報科学 arc 6 candidate 第 2 号 実装 (shannon_entropy_verdict = #1)。
❷ threshold-based classification: d ≤ threshold → TRUE (訂正可能) / d = threshold+1 → NEITHER (検出のみ) / d > threshold+1 → FALSE (訂正不能)。 default threshold=1 (single-bit-error correction)。
❸ STEP 1479 par2 recovery evidence の 抽象化: 「1116 blocks 中 1 byte 破損 → par2 -r10 で 完全復元」 の 実測 evidence を pure static verdict identity として 形式化。
| # | Condition | Verdict | Reason |
|---|---|---|---|
| 1 | a or b empty | NEITHER | empty_input |
| 2 | length mismatch | NEITHER | length_mismatch |
| 3 | invalid bits (non-0-1) | NEITHER | invalid_bit |
| 4 | d = 0 | TRUE (⊤) | identical |
| 5 | d ≤ correctionThreshold | TRUE | correctable |
| 6 | d = correctionThreshold + 1 | NEITHER | detection_only |
| 7 | d > correctionThreshold + 1 | FALSE (⊥) | uncorrectable |
import { hammingDistanceGate } from './src/mcp/hamming-distance-gate';
// A: identical → TRUE
const rA = hammingDistanceGate({ a: [1,0,1,0], b: [1,0,1,0] });
// { verdict: 'TRUE', reason: 'identical', distance: 0, length: 4, ... }
// B: 1-bit flip, threshold=1 → TRUE (correctable)
const rB = hammingDistanceGate({ a: [1,0,1,0], b: [1,1,1,0] });
// { verdict: 'TRUE', reason: 'correctable', distance: 1, ... }
// C: 2-bit flip, threshold=1 → NEITHER (detection only)
const rC = hammingDistanceGate({ a: [1,0,1,0], b: [1,1,0,0] });
// { verdict: 'NEITHER', reason: 'detection_only', distance: 2, ... }
// D: 3-bit flip, threshold=1 → FALSE (uncorrectable)
const rD = hammingDistanceGate({ a: [1,0,1,0], b: [0,1,0,0] });
// { verdict: 'FALSE', reason: 'uncorrectable', distance: 3, ... }
// E: custom threshold=2 (double-bit correction)
const rE = hammingDistanceGate({
a: [1,0,1,0], b: [1,1,0,0], correctionThreshold: 2
});
// { verdict: 'TRUE', reason: 'correctable', distance: 2, ... }
-- Hamming 距離 定義 (STEP 1493 継承、 disjoint patterns) hd_self_zero : ∀ xs, hamming_dist xs xs = 0 hd_single_diff : hamming_dist [1] [0] = 1 -- verdict 決定表 (★核 4 theorem) verdict_identical_gives_true : d=0 → TRUE verdict_correctable_gives_true : d≤threshold, d>0 → TRUE verdict_detection_gives_neither : d=threshold+1 → NEITHER verdict_uncorrectable_gives_false : d>threshold+1 → FALSE -- threshold=1 specialization (single-bit correction) verdict_d0_t1_true / d1_t1_true / d2_t1_neither / d3_t1_false -- threshold=0 specialization (strict identical only) verdict_d0_t0_true / d1_t0_neither / d2_t0_false
| Category | Tests |
|---|---|
| Guard (NEITHER) | 7 (empty / mismatch / invalid / negative) |
| TRUE (identical + correctable) | 7 |
| NEITHER (detection only) | 4 |
| FALSE (uncorrectable) | 5 |
| Custom threshold (0/2) | 6 |
| Edge (single bit) | 3 |
| Determinism | 3 |
実行: npx tsx test/step1507-hamming-distance-gate-test.ts
STEP 1479 (2026-08-27) で 「par2cmdline-turbo 1.1.1 で 1116 blocks 中 1 byte 破損 injection → repair で md5 完全一致復元」 を 実測。 本 tool は その 抽象化 identity:
- par2 redundancy 10% = correctionThreshold ~10% length 対応
- 1 byte 破損 = Hamming distance 1-8 bit (境界)
- 復元成功 = TRUE (correctable) verdict と 対応
本 tool は 実測 evidence の 静的 identity 層、 実 recovery は par2 layer に 委譲。
| # | tool | 入力 | 目的 | STEP |
|---|---|---|---|---|
| 1 | d8_verdict_from_measurement | value + noise + threshold | SNR verdict | 1350 |
| 2 | d8_verdict_from_multi_trial | p-value list + FDR α | BH FDR | 1371 |
| 3 | d8_verdict_from_sample_pair | 2 samples | Welch t-test | 1376+1379 |
| 4 | shannonEntropyVerdict | frequency list | H(X) → 8 verdict | 1499 |
| 5 | peaceAxiomVerdict | before/after payoffs | Peace Axiom #196 | 1506 |
| 6 | hammingDistanceGate ★ | 2 bit strings + threshold | 訂正可能性 verdict | 1507 (本 tool) |
6 tool 揃った ことで 「1 値 / 2 値比較 / 多試行 / 分布 / ゲーム / 誤り訂正」 の 6 側面 D-FUMT₈ verdict 化 core 拡張。
❶ bit 表現 は Nat (0/1) 制限、 byte string は 前処理で bit 展開必要。
❷ threshold-based classification は 完全 Hamming (Reed-Solomon 等) と 異なる、 単純な Hamming distance のみ。 error correction 実際は BCH / Reed-Solomon 等 の code-specific bound で 決定。
❸ Lean 4 側は 決定表 骨格 のみ、 Hamming code の 実装 (encoding / decoding) は 未形式化。
❹ 「世界初」 主張なし。 Hamming (1950) 既知構造 の D-FUMT₈ verdict mapping、 novelty = 6 姉妹 tool 統一 API 拡張。
❺ 累計 defer 46 → 45 candidate (本 tool 実装 済、 STEP 1499 + 1506 + 1507 で 3 tool 実装 済)。