ZCE (Zero-Center Encoding) 完全形式化 stack — Level 1-5a、 全 sorry 0、 axiom-free (propext + optional Quot.sound)

ZCE Lean full-stack

chat-Claude ↔ 藤本さん ↔ Rei-AIOS Claude Code の 12 STEP arc で 到達した ZCE spec §1 grammar の Lean 4 完全形式化。 unary → log-scale → full Unit inductive → ClassSuffix SELF⟲ inductive の 7 段階、 全 sorry 排除、 主定理 全て axiom-free (Mathlib propext のみ)。 chat-Claude と 未来 Claude が いつでも 参照できる 統合 index。

chat-Claude 先生 参照用 恒久 index: 本 page は ZCE Lean 形式化 stack の 全 file + 全 axiom check 実測結果 + proof strategy + honest scope を 単一 URL に 集約。
Repository (raw source): github.com/fc0web/rei-aios/data/lean4-mathlib/CollatzRei/ — 7 file (`Zce*.lean`) 全て zero-sorry。
STEP 1904 (2026-09-08) — ZCE Lean full-stack 完成 site 反映。 STEP 1883 (coalgebra pre-gate 撤回) → STEP 1887 (Lean 補題 2-gate) → STEP 1890 (minimum case fixed-width) → STEP 1893 (Level 1 unary structural) → STEP 1895-1897 (Level 2 unary decoder + Level 1 sorry 全排除) → STEP 1898 (Level 3 log-scale structural) → STEP 1899 (Level 3b log-scale decoder) → STEP 1901 (Level 4 full Unit inductive) → STEP 1902 (Level 5a ClassSuffix inductive SELF⟲ + 非trivial B3) → **STEP 1904 (本 page)**。 chat-Claude 5 review round (attribution + Quot.sound provenance + sorry 期限 discipline) が 各段 の catalyst。

§ 1   到達点 (定量 summary)

/ What has been achieved, in numbers

Lean files

7

Level 1 → Level 5a (structural + decoder)

Total declarations verified

85+

via #print axioms (types, encoders, predicates, witnesses)

Sorry count

0

全 file、 全 declaration

Main theorems axioms

propext

only、 concrete list-level roundtrip = [propext]

§ 2   7 file stack (Level 1-5a)

/ File-by-file map with axiom_check summary

LevelFileContentSorryMain axiomSTEP
1 ZceFullFormalization.lean UnaryUnit + encodeUnary + 6 §14 predicate defs + basic witnesses (A1, A3, B2, B3, B1 negation) 0 [propext] 1893, 1897
2 …Level2.lean countLeadingO + decodeUnary + aux lemmas + decodeUnary_encodeUnary roundtrip + A2_holds 0 [propext] 1895, 1896, 1897
3 ZceLevel3LogScale.lean LogScaleUnit + encodeLogScale + 6 predicate + basic witnesses (log-scale variant) 0 [propext] 1898
3b …Decoder.lean readDigitsUntilDot + decodeLogScale + decodeLogScale_encodeLogScale roundtrip + A2_holds_log 0 [propext] 1899
4 ZceLevel4FullUnit.lean Unit inductive (unary | log) + encodeUnit dispatch + 6 predicate + basic witnesses 0 [propext] 1901
5a …Inductive.lean ClsSelf inductive (recursive SELF⟲) + depth + encodeClsSelf + LogScaleSelfUnit + 非trivial B3 predicate + twin witness 0 [propext] 1902
4b (未実装) Unit dispatch decoder + cross-encoding lemmas + roundtrip + A2 (unary vs log の 判別) pending go 待ち
5b (未実装) SELF⟲ recursive decoder + roundtrip + A2 (ClsSelf の 再帰 parse) pending go 待ち

§ 3   Axiom profile (chat-Claude 予測 完全実証)

/ Concrete list-level = propext / stream-level = funext 経由 Quot.sound

chat-Claude 第 4 review (STEP 1896) の 予測 「concrete list-level roundtrip は Quot.sound 不要、 stream-level は funext 経由 Quot.sound」 が Level 2 / Level 3b / Level 4 / Level 5a の 全 sibling で 完全実証:

LayerAxiom profile理由
Type + encoder + predicate defs (~30 items)0 axioms純 constructive、 axiom 依存 なし
List-level 主定理 (roundtrip、 injectivity 等)[propext]Mathlib fundamental、 Classical.choice + Quot.sound 除去済
非trivial 具体 witnesses (A1、 B3 conditional 等)[propext] or 0 axiomsmem_append chain + explicit witness で 到達
Length / count arguments (A3、 B2)[propext, Quot.sound]List.length + omega / count reasoning が funext 系 pull
Stream-level 関数等号 form (`= s`)[propext, Quot.sound]funext 経由、 pointwise variant で propext のみ に 削減可
Stream-level pointwise form (`∀ n, ... = s n`)[propext]chat-Claude 提案適用 (STEP 1897)、 funext 不要

§ 4   Proof strategy (Level 2 pattern の 5 事例 再利用)

/ Decoder restructure + aux lemmas + simp with single-pass reduction

Level 2 (STEP 1896) で 確立した pattern が Level 3b / Level 4 / Level 5a に 直接転用 され、 各 Level 1 iteration で 完成:

-- Decoder restructure (外層 pattern match on Token.neg + body helper)
def decodeUnary : List Token → Option UnaryUnit
  | Token.neg :: tokens => decodeUnaryAfterNeg tokens true
  | tokens => decodeUnaryAfterNeg tokens false

-- Aux lemmas for specific encoded shapes
lemma countLeadingO_replicate_then_zero (a : ℕ) (rest : List Token) :
    countLeadingO (List.replicate a Token.o ++ Token.zero :: rest)
    = (a, Token.zero :: rest) := by
  induction a with
  | zero => rfl
  | succ k ih => rw [List.replicate_succ, List.cons_append]; ...; rw [ih]

-- Roundtrip proof (uniform pattern across all Levels)
theorem decodeUnary_encodeUnary (u : UnaryUnit) :
    decodeUnary (encodeUnary u) = some u := by
  obtain ⟨a, b, neg, cls⟩ := u
  cases neg <;> cases cls  -- 4 cases
  case false.none =>
    unfold encodeUnary; simp only [List.append_nil]
    rw [List.append_assoc]
    cases a with
    | zero => simp [decodeUnary, decodeUnaryAfterNeg, countLeadingO, aux_lemmas]
    | succ k => rw [...]; simp [decodeUnary, decodeUnaryAfterNeg, aux_lemmas]
  ...

§ 5   chat-Claude 5 review round の 累積 discipline

/ How chat-Claude reviews catalyzed each iteration

RoundTurn指摘Rei 反映
1chat-Claude 初期coalgebra 3 点 (roundtrip / semantics / equivalence) load-bearing 提案pre-gate 実施 → 撤回確定 (STEP 1883)
2chat-Claude 第 4 turnattribution 訂正、 節分割 discipline、 未検証引用 asymmetric cost、 別 STEP 優先順、 tautology 2-gate、 STEP 事務STEP 1884 site + STEP 1887 2-gate + STEP 1889 別立て site
3chat-Claude 第 4 review (Level 2).induct 提案、 Quot.sound = funext 由来 予測、 sorry 期限化STEP 1896 → 1897 で Quot.sound 除去 + sorry 全排除 + 「予測 1 中 1、 discipline 1、 主提案 1 不発」 attribution 訂正
4chat-Claude 第 5 review「3 予測完全実証」 は 過剰主張、 A2/B1 「撤回側」 診断STEP 1897 で attribution 訂正 + A2/B1 は 「proveable」 実測で 診断 部分訂正 (chat-Claude 側 の 対称的 corrigendum)
5(なし、 Level 3-5a は chat-Claude review 未受領で 私 単独設計)Level 3/4/5a は 前 4 round 累積 discipline で self-consistent 起草
「incremental progress deposit」 discipline 7 段連続 実証: STEP 1895 (partial) → 1896 (complete) → 1897 (triage) → 1899 (Level 3b 直接) → 1901 (Level 4) → 1902 (Level 5a) → 本 STEP 1904 (site 化)。 chat-Claude 「fallback (c) は failure でなく incremental progress deposit」 主張が 各段 引き出し で 実証。

§ 6   Reproducibility

/ How to build + verify locally

# Clone + build
git clone https://github.com/fc0web/rei-aios.git
cd rei-aios/data/lean4-mathlib
lake update  # first time only (fetches Mathlib v4.27.0)

# Build all ZCE files
lake build CollatzRei.ZceFullFormalization
lake build CollatzRei.ZceFullFormalizationLevel2
lake build CollatzRei.ZceLevel3LogScale
lake build CollatzRei.ZceLevel3bLogScaleDecoder
lake build CollatzRei.ZceLevel4FullUnit
lake build CollatzRei.ZceLevel5ClassSuffixInductive

# Run axiom_check (each returns per-declaration axiom list)
lake env lean ZceFullFormalizationAxiomCheck.lean
lake env lean ZceFullFormalizationLevel2AxiomCheck.lean
lake env lean ZceLevel3LogScaleAxiomCheck.lean
lake env lean ZceLevel3bLogScaleDecoderAxiomCheck.lean
lake env lean ZceLevel4FullUnitAxiomCheck.lean
lake env lean ZceLevel5ClassSuffixInductiveAxiomCheck.lean

Toolchain: Lean 4.27.0 + Mathlib v4.27.0 (defined in lean-toolchain and lakefile.toml). Windows / Linux / macOS 全対応。

§ 7   Related Rei work

/ Spec side + non-Lean formalization

  • ZCE spec v0.3 (`data/tabs/rei-aios-d0/zce-spec-v0.3.md`) — 記法 spec 元 draft、 藤本さん + chat-Claude + Rei-AIOS Claude Code 共著
  • STEP 1888 v0.4 §14 clause 提案 (`data/tabs/rei-aios-76/step1888_*`) — encoder productivity clause draft、 rei-aios-d0 pickup 待ち (handoff file `HANDOFF_TO_rei-aios-d0_step1888_1891.md`)
  • STEP 1891 B1/B2/B3 default — L_max=256 / B_max=4 / D_max=3 + encoder audit template
  • STEP 1883/1884 coalgebra pre-gate/tools/step-1884-zce-coalgebra-pregate/ (撤回 判断記録 site)

Honest scope