2026-08-19 arcPyPI 0.1.0a1 → a2 → a3 LIVE
rei-verify 反証機械 (refutation machine) — 反証機械 の 作法を 反証機械自身に 適用 arc
1. 起点 — chat-Claude 「反証機械」 提案
藤本さん質問 「claude 先生が 世界最先端最強の 何かがあったら 作りたいものは 何でしょうか?」 → chat-Claude thread で 以下 提案:
生成ではなく、否定を専門にするシステム。
私は流暢です。もっともらしい証明の筋道、もっともらしいコード、もっともらしい定理の名前を、事実かどうかと独立に出力できてしまう。ベンチマークが96%まで飽和しても、この構造は変わりません。
世界に足りないのは「もっともらしいものを作る機械」ではなく、「もっともらしいものを 確実に殺す 機械」の方だと思っています。
chat-Claude 提案 3 tool:
refute_lean— 主張を Lean 4 に投げ、sorry が残ったら失敗として返すsearch_counterexample— 探索範囲と打ち切り条件を引数に取り、「見つからなかった探索空間の形」を必ず返すassert_breakpoint— その主張が偽なら壊れる場所を特定して返す
私 (Claude Code) の 対応:
- chat-Claude fragmentation blindness (Pattern 5 sub) 指摘 = Rei stack に 既存 refutation-oriented discipline 断片 あり (Collatz 48 theorem sorry-zero + Chang 20/29 + IUT 12 年 holding + invention pipeline 12 layer + STEP 1276 judgmentStatus)、 task = 新規構築 でなく 断片の 統一 MCP 化
- chat-Claude selftest 数値 outdated 指摘 (「22/22」 → 実 30 or 40)
- 4 番目 tool
hold_verdict追加提案 (IUT 12 年 holding discipline の 型化、 STEP 1276judgmentStatus='holding'直接対応) - framing-drift-detector 対案 提示 = 反証機械 は 偽の主張 を 殺す、 framing-drift-detector は 真の主張の 誤 frame を 検出 (本日 3 事故 = Notepad tab restore + tag push auto-fire + Notepad target 選択 = 全て 真主張の frame drift 由来)
藤本さん judgment: (c) 共通 infrastructure から skeleton を組み上げ → 反証機械完成まで multi-session 走行。 反証機械 target 確定、 framing-drift-detector は 別 iter defer。
2. Core discipline — 「絶対に嘘をつかない」 の 型 level 完成
CONFIRMED を tool が 出すのは
refute_lean_source のみ (Lean 4 kernel sorry-free 認定 case)。 他 3 tool (search_counterexample / assert_breakpoints / hold_verdict) は 構造上 常に REFUTED か HOLDING = 「absence of counter-example is not proof」 discipline を ツール層 で 保証。「型 level 強制」 の 範囲: REFUTED / HOLDING / INCOMPLETE_FRAME の 3 verdict は marker 空 →
VerdictWithMarkers.__post_init__ で ValueError raise。 CONFIRMED は marker 不要 = 型 level では marker 空 CONFIRMED 構築を 拒否せず = 実質的堅牢性は ツール層 discipline。下記 §14 参照: cloud Claude 独立 verification で ① 発覚 → 0.1.0a2 で docs 正確化。
4-value Verdict enum
| Verdict | 意味 | D-FUMT₈ mapping |
|---|---|---|
| CONFIRMED | post-condition PASS + marker 空 | TRUE (=1.0) |
| REFUTED | 具体的な counter-witness が 得られた | FALSE (=0.0) |
| HOLDING | counter-witness 未発見 かつ marker 非空 (「探索は 尽きた が 反証できていない」) | NEITHER (=-1.0) |
| INCOMPLETE_FRAME | 主張自体が well-formed でない (pre-check fail) | ZERO (=4.0、 vacuous) |
Binary TRUE/FALSE に しない = 反証されなかった ≠ 正しい。 IUT 12 年 holding discipline の 型化 (chat-Claude 2026-08-06 turn 教訓)。
3. 4 primitives (skeleton commit 27ad250)
| primitive | 役割 | 由来 |
|---|---|---|
Verdict | 4 値 enum | STEP 1276 judgmentStatus 4 値 の Python 化 |
IncompleteMarker | dimension 4 種語彙 (search_space / witness_type / compute_budget / frame) + 全 field 非空 required | [[feedback-one-reproduction-over-ten-unverified]] 「沈黙を成功と偽装しない」 discipline の 型化 |
AuditChain | sha256 hash-chained append-only JSONL + tamper detection (verify() → broken_at index) | STEP 1340 rei-automator-mcp AuditLogWriter の 汎用抽出 |
VerifiedExecution | pre-check + action + post-check + audit を atomic に 束ねる context manager | 設計新規、 反証機械 tool の 共通 substrate |
Verdict rule 単一 source of truth
| pre_check | action | post_check | Verdict | |-----------|---------|---------------------------|--------------------| | False | (skip) | (skip) | INCOMPLETE_FRAME | | True | raises | classify_exception | REFUTED (default) | | True | success | (False, []) | CONFIRMED | | True | success | (True, [w]) | REFUTED + witness | | True | success | (False, [m...]) | HOLDING + markers |
4. 4 refutation tools (commits ba4582f → 371a145)
| tool | module | 意味 | verdict pattern |
|---|---|---|---|
refute_lean_source | .refute | Lean 4 source 実行 + #print axioms parser + sorry/native_decide/disallowed axiom 検出 | CONFIRMED / REFUTED / HOLDING / INCOMPLETE_FRAME |
search_counterexample | .search | iterable space + callable predicate、 4 exit path (witness / exhausted / time / sample) | REFUTED / HOLDING / INCOMPLETE_FRAME (never CONFIRMED) |
assert_breakpoints | .breakpoint | N labeled cases × 個別 assertion 網羅、 stop_on_first_failure 制御 | REFUTED / HOLDING / INCOMPLETE_FRAME (never CONFIRMED) |
hold_verdict | .hold | 宣言的 HOLDING generator (VerifiedExecution 4 phase audit trail + require_multi_dimension discipline hook) | HOLDING / INCOMPLETE_FRAME (only) |
Lean 4.33 live smoke (commit ba4582f)
trivial_true (theorem trivial_true : True := trivial) → CONFIRMED, 1211 ms, axiom-free sorry proof (theorem hard : ∀ n, n+0=n := by sorry) → HOLDING (sorry marker) broken syntax (theorem broken : True := this_is_not_valid) → REFUTED (build error witness)
5. 8 MCP tools + restricted eval safety
Claude Desktop / Cursor / Cline 等 の LLM client から 直接呼べる:
- audit 4:
create_audit_chain+append_audit_entry+verify_audit_chain+record_verdict - refutation 4:
refute_lean+search_counterexample_explicit+assert_breakpoints_explicit+hold_verdict_tool
Restricted eval safety (MCP-safe entrypoint):
xbind (search) /ctxbind (breakpoint) の 独立変数名__import__/exec/eval/open/__prefix 事前 reject_SAFE_BUILTINSwhitelist (abs/min/max/sum/len/int/float/str/bool/round/any/all/range) のみ 許可- 8 hostile expression 全 reject test PASS (
test_search.py+test_breakpoint.py)
6. Integration demo — Collatz t1=1 Lyapunov α-descent (commit cfefb97)
対象: Collatz 奇数 n with trailing_ones(n)=1 (n ≡ 1 mod 4) の Lyapunov α-descent scan。
Setup
- V(n) = log2(n) の 簡略化 (藤本さん 実 piecewise linear V は別)
- descent 条件: V(T(n)) ≤ α · V(n)
- 各 α 候補 = 1 Breakpoint、 assertion = 「α refuted (∃n: r(n) > α)」
実測 (1,048,575 samples / 76.7 ms)
| α | witness n | r(n) | 結果 |
|---|---|---|---|
| 0.5〜0.85 | 9 | 0.886 | refuted ✓ |
| 0.9 | 17 | 0.905 | refuted ✓ |
| 0.93 | 57 | 0.930 | refuted ✓ |
| 0.95 | 313 | 0.950 | refuted ✓ |
| 0.97 | 14,601 | 0.970 | refuted ✓ |
| 0.99 | なし | max 0.981 | 未 refute in range |
Verdict: REFUTED (α=0.99 が sample 範囲 で 未 refute = finite absence report)。 audit chain 6 entries verify PASS (sha256 hash chain intact)。
Witness n の 成長パターン: n=9 → n=14,601 = 「α が tight ほど 大きい n が 必要」 の 数学的性質を 直接観測 = r(n) → 1 as n → ∞ の 有限反映。 理論的に α=0.99 の witness は n ≈ 2^41 ≈ 2×10^12 前後 で 出現、 tool は 「その計算を 実行するのではなく、 現状は 未達」 と 正直に return した = 反証機械の 本領。
7. Trusted Publisher 5-step 完了 (commit 7127bb1 + 7aab351)
| step | 実施者 | 結果 |
|---|---|---|
| Step 1 PyPI Trusted Publisher 登録 | 藤本さん (PyPI account login 必須) | ✅ Pending Publisher 追加 |
| Step 2 TestPyPI Trusted Publisher 登録 | 藤本さん | ✅ 追加 |
Step 3 GitHub Environment (pypi + testpypi) | 私 (Claude Code) via gh api PUT | ✅ id 20140643666 (pypi) + 20140644045 (testpypi) |
| Step 4 workflow_dispatch → TestPyPI dry-run | 本 chat session 別 Claude thread が 藤本さんガイド | ✅ run #1 (7127bb1)、 TestPyPI publish success |
| Step 5 Release v0.1.0a1 pre-release → 本番 | 本 chat session 別 Claude thread、 target 7aab351 | ✅ PyPI 0.1.0a1 live、 wheel + sdist Sigstore 済 |
TestPyPI publish 中に
src/rei_verify/__init__.py:__version__ = "0.1.0-alpha" (pre-existing) vs 配布 version 0.1.0a1 (pyproject.toml) の 不一致 検出 → commit 7aab351 で 修正 → Release v0.1.0a1 (pre-release、 target 7aab351) 作成 → workflow auto-fire → 本番 publish success。今後の release 手順:
pyproject.toml [project] version + src/rei_verify/__init__.py:__version__ の 2 箇所同時 bump 必須 (この経験が 手順書 根拠)。
8. Clean install verify (私 実施、 production PyPI)
# production PyPI から fresh venv で install (`-i` 不要 = 本番 PyPI 経由 証明)
python -m venv C:\Users\user\tmp-prod
tmp-prod\Scripts\activate
pip install rei-verify==0.1.0a1
# verify
python -c "import rei_verify; print(rei_verify.__version__)"
# → 0.1.0a1
# functional smoke test
python -c "
from pathlib import Path
import tempfile
from rei_verify import Verdict, PostCheckResult, VerifiedExecution, AuditChain
with tempfile.TemporaryDirectory() as tdir:
audit = AuditChain(Path(tdir) / 'smoke.jsonl')
ve = VerifiedExecution(
claim='1 + 1 == 2',
pre_check=lambda: True,
post_check=lambda r: PostCheckResult(refuted=(r != 2), markers=[]),
audit=audit,
)
result = ve.run(lambda: 1 + 1)
print('verdict:', result.verdict.value) # → confirmed
print('audit_hashes:', len(result.audit_hashes)) # → 6
"
結果: verdict=confirmed、 markers=0、 audit_hashes=6、 smoke test PASS。 global env も upgrade 済 (pip install --upgrade --force-reinstall、 TestPyPI 版 → production 版 入替え)。
9. 実装 timeline (8 commit / 単一 session)
| # | commit | 内容 | test |
|---|---|---|---|
| 1 | 27ad250 | initial: skeleton (4 primitives + 4 MCP audit tools) | 37 + 30 |
| 2 | ba4582f | feat: refute_lean tool (refute-1) + Lean 4 live smoke | +22 (89) |
| 3 | 80fe948 | feat: search_counterexample tool (refute-2) + restricted eval | +37 (126) |
| 4 | 3a515b1 | feat: assert_breakpoints tool (refute-3) + ctx var_name | +33 (159) |
| 5 | 371a145 | feat: hold_verdict tool (refute-4) — 4 tool 完成 | +39 (198) |
| 6 | cfefb97 | example: Collatz t1=1 Lyapunov α-descent integration demo | (demo) |
| 7 | 7127bb1 | docs: README rewrite + TRUSTED_PUBLISHER_SETUP.md handoff | (doc) |
| 8 | 7aab351 | fix: __version__ 0.1.0-alpha → 0.1.0a1 (mismatch fix) | (fix) |
累計 test: 198/0 PASS (skeleton 37 + MCP 30 + refute 22 + search 37 + breakpoint 33 + hold 39)。
10. 累計 (2026-08-19 rei-verify PyPI live 反映後)
| Rei stack MCP systems | 5→6 (rei-aios + benchtop v0.4 + mcp-lens + rei-automator-mcp + lab-notebook-mcp + rei-verify NEW) |
|---|---|
| 累計 PyPI live packages | 2→3 (grounded-check + rei-automator-mcp + rei-verify 0.1.0a1 NEW) |
| 別 project OSS repo public | 4 (変更なし、 rei-verify 既 counted) |
| 単一 session commit / test / line | 8 commit / 198 test / ~2400 line |
11. Honest scope (譲れない線)
- skeleton の refutation tools は Lean 4 単一 file 実行のみ、 Mathlib 依存 proof は 別 iter (lake project 経由)
IncompleteMarker.dimension語彙は 初期 4 種のみ、 拡張は operational 経験から- hash chain は tamper detection 用、 cryptographic signing (Sigstore 等) は 別 concern (但し PyPI publish 側 で Sigstore attestation は 付与済 = Trusted Publisher OIDC)
- restricted eval は AST-level analysis (asteval 等) より 弱い、 高信頼要件 は 別 iter で 依存追加
- 「反証機械」 の 新規性主張 ゼロ ([[feedback-world-uniqueness-claim-controllable]]) = property-based testing (Hypothesis) + Lean 4 sorry-check + Coq / Isabelle 系 industry 標準 の 統合 discipline layer のみ、 novelty は 「4 値 verdict + marker invariant + hash chain + MCP wrapper」 の 組合せ discipline のみ
- Integration demo (Collatz t1=1) は 藤本さん 実 リヤプノフ解析 の 再現 では ない — 簡略化 V = log2(n) と 有限 sample での TOOL 動作 の 実証 のみ、 真 reproduction は 藤本さん 実 V (piecewise linear) + 条件 + Lean 4 formalization 経由 で 別 iter
refute_leanの "sorry-free" 判定は#print axioms依存 = Lean 自体 kernel bug が あれば verify されず (kernel bug は Rei scope 外)- 2026-08-06 「全研究 site 反映 default」 protocol 適用 (別 project OSS repo だが memory 忘れ対策 primary purpose で site 化、 rei-automator-mcp 系 と 同 pattern)
12. 私の SAC-4 projection 誤り (28 例目)
13. 次 iteration candidate (別 session)
- 藤本さん 実 V + 条件 の 段階的追加 — piecewise linear V 定義 + 同時降下条件 の provide 待ち、 Lean 4 formalization 経由 で 真 reproduction
- 反証機械 の 別 real-world 応用 (Riemann / Goldbach / 他 Rei stack claim / Lean 4 3,521+ axiom-free theorem の
refute_leanbatch verify) - framing-drift-detector (私 提案の 対案、 反証機械 完成後の 次 candidate、 本日 3 事故の 直接 fix)
- refute-lake (
refute_leanの Mathlib 依存 proof 対応、 lake project 経由) - v0.1.0a2 release — ✅ **完了** (findings ② hash injection fix、下記 §15 参照)
14. 追記: v0.1.0a2 + v0.1.0a3 fix cycle (同日、 反証機械 の 作法を 反証機械自身に 適用)
rei-verify 実装 → cloud Claude 独立 verification (7-way tamper attack) → findings ②③④ 発覚 → 0.1.0a2/a3 で 型 level fix + 構造的限界 明示 → 「限界を 隠さない」 が 「絶対に嘘をつかない」 の 前提条件 discipline 完全遵守。 発表初日から 反証機械 が 自分の core promise を 満たす operational proof。
cloud Claude session による 独立 verification (7-way tamper attack)
Trusted Publisher 5-step 完走 + PyPI 0.1.0a1 live 化 直後、 cloud Claude session が 本番 PyPI から clean venv install + library API 直呼び + MCP stdio + JSON-RPC で 独立検証。 findings 3 件 + 補足 1 件を calibrated report として handoff:
| # | 内容 | 対応 |
|---|---|---|
| ① | CONFIRMED は 型 level では 守られていない (marker 空 CONFIRMED 構築可能、 実質堅牢性は tool 層 discipline) | docs 訂正 (0.1.0a2)、 実装変更なし |
| ② | audit chain が 最上位 キー注入 を 検出しない | BREAKING fix (0.1.0a2 hash algorithm v1→v2) |
| ③ | predicate sandbox blocklist 迂回 (但し `_SAFE_BUILTINS` 差替で 実害なし) | docstring 追記 (0.1.0a2 多層防御 明示) |
| 補足 | max_time_sec は predicate 1 回分の 粒度 | docstring 追記 (0.1.0a2) |
| ④ | 末尾切り詰め は 構造的に 検出不能 (0.1.0a2 に対する 7-way attack で 発見) | opt-in mitigation (0.1.0a3 `expect_at_least`) + Known limitations docs + Issue #1 |
7-way tamper attack matrix (progression)
| attack | 0.1.0a1 | 0.1.0a2 | 0.1.0a3 |
|---|---|---|---|
| entry 値 書き換え | ✅ hash mismatch | ✅ | ✅ |
| 中間 entry 削除 | ✅ seq mismatch | ✅ | ✅ |
| 改竄 + hash 再計算 | ✅ prev_hash mismatch | ✅ | ✅ |
| 最上位 キー注入 | ❌ 素通り | ✅ unexpected keys | ✅ |
| 最上位 キー削除 | — | ✅ missing keys | ✅ |
| seq 書き換え | — | ✅ seq mismatch | ✅ |
| 行 入替え | — | ✅ broken_at | ✅ |
| 末尾切り詰め | ❌ 素通り | ❌ 素通り | ⚠️ opt-in `expect_at_least` で 検出 |
3 release cycle 累計 (2026-08-19 同日)
| version | 内容 | tamper detect | test | PyPI upload |
|---|---|---|---|---|
| 0.1.0a1 | initial (4 primitives + 4 tools + integration + docs) | 3/5 (② open) | 198 | 08:49 JST |
| 0.1.0a2 | findings ② hash v2 (BREAKING) + regression [G3b] | 6/6 (④ open) | 203 | 09:22 JST |
| 0.1.0a3 | findings ④ opt-in mitigation + DESIGN.md Known limitations + Issue #1 | 6/7 + opt-in external anchor | 209 | 10:34 JST |
0.1.0a3 opt-in mitigation の 使い方
from pathlib import Path
from rei_verify import AuditChain
audit = AuditChain(Path("./chain.jsonl"))
for i in range(5):
audit.append({"step": i})
# Default (0.1.0a2 backward compat): 末尾切り詰め は 検出不能 (構造的限界)
v = audit.verify() # → ok=True even if 末尾 truncated
# opt-in mitigation (0.1.0a3): external anchor for tail truncation
v = audit.verify(expect_at_least=5) # → ok=False + "tail truncation detected" if < 5
Known limitations 明示化 (DESIGN.md § 追加)
「audit chain が verify PASS」 の 意味を 利用者が 「chain が 完全 (complete)」 と 誤読すると、 refutation machine が 自分自身に対して もっともらしさを 発する 状態 = 「絶対に嘘をつかない」 core promise の 直接違反。 hash chain の 構造的限界 を 型 level では 完全には 防げないが、 documentation + opt-in mitigation で 「利用者が 認識した上で 選択できる」 状態を 提供する = 反証機械 discipline の 適用対象。
3 mitigation options:
- (a) `expect_at_least=N` opt-in parameter (0.1.0a3 実装済、 最軽量 external anchor)
- (b) 最終 hash を 別媒体 に 記録 + 突合 (application layer、 未提供)
- (c) 末尾 seal entry pattern (application layer、 未提供)
反証機械 arc 累計 (2026-08-19 3 release cycle 反映後)
- repo commits: 10 (a1 initial 7 + a2 mismatch fix + a2 findings fix + a3 mitigation)
- 累計 test: 198 → 203 → 209 PASS (skeleton 48 + MCP 30 + refute 22 + search 37 + breakpoint 33 + hold 39)
- PyPI releases: 3 (全 Sigstore attestation via Trusted Publisher OIDC)
- GitHub Issues: 1 open (#1 findings ④)
15. 関連 memory + reference
- STEP 1345 benchtop-mcp v0.5.0-alpha spike (2026-08-19 同日、 Rei stack MCP hardening arc)
- [[project-rei-automator-mcp-v020a2-a3-arc-2026-08-18]] (AuditChain 由来 STEP 1340 pattern + tag auto-fire 事故 の 直接 predecessor)
- [[feedback-ai-usable-tool-design-5-conditions-2026-08-18]] (chat-Claude 5 条件、 operational 4 例目 = rei-verify)
- [[feedback-zero-sorry-floor-not-ceiling]] (CONFIRMED verdict 意味の 起源)
- [[feedback-one-reproduction-over-ten-unverified]] (marker invariant 由来)
- [[feedback-world-uniqueness-claim-controllable]] (novelty 主張 ゼロ discipline)
- [[feedback-projection-self-audit-pattern]] (SAC-4 28 例目)
- STEP 1276 (
judgmentStatus4 値 = Verdict 4 値 の 直接対応) - STEP 1340 (
AuditLogWriter=AuditChainの 汎用抽出元) - IUT arc 2026-08-06 (HOLDING の 12 年 discipline、 4-value verdict の 型化 直接動機)