Principal declarations
theorem Game.restore_correct
Module NimGame
(lean/phase2/NimGame.lean, lines 412–425) · file SHA-256 23df6bb87ecfd344… Axioms reported by the fresh build: propext, Quot.sound
Statement as elaborated and printed by Lean 4.26.0
∀ {Q Q' : List ℕ},
NimAudit.nimSum Q = 0 →
NimAudit.Game.Move Q Q' →
∃ R, NimAudit.Game.restore Q Q' = some R ∧ NimAudit.Game.Move Q' R ∧ NimAudit.nimSum R = 0
Exact source text, lines 412–425
412theorem restore_correct {Q Q' : List Nat} (h0 : nimSum Q = 0) (hm : Move Q Q') :413 ∃ R, restore Q Q' = some R ∧ Move Q' R ∧ nimSum R = 0 := by414 have hne := move_from_zero hm h0415 have hd : nimSum Q ^^^ nimSum Q' = nimSum Q' := by rw [h0, Nat.zero_xor]416 obtain ⟨R, hsel, hmR, hR⟩ := selectMove_zero hne417 refine ⟨R, ?_, hmR, hR⟩418 unfold restore419 rw [hd]420 simp only [selectMove, hne, if_false] at hsel421 split at hsel422 · next q' hq' => cases hsel; exact hq'423 · next _ hnone =>424 obtain ⟨pre, x, post, hp, hlt, _⟩ := exists_decreasing_heap Q' hne425 exact absurd hlt (cancelFirst_none hnone x (by rw [hp]; simp))
Project declarations in the statement: Game.Move, Game.restore, nimSum
Project declarations used by the proof or definition body
Game.Move, Game.cancelFirst, Game.cancelFirst_none, Game.move_from_zero, Game.restore, Game.selectMove, Game.selectMove_zero, Rollout.exists_decreasing_heap, Rollout.subFirstPos, nimSum
theorem LocalRestore.restore_equiv
Module LocalRestore
(lean/phase4/LocalRestore.lean, lines 208–229) · file SHA-256 fc4c7f908b0c9c58… Axioms reported by the fresh build: propext, Quot.sound
LOCAL RESTORATION EQUIVALENCE: under the zero-predecessor / legal-transition
promise (nim(Q) = 0 and Q → Q' a legal move), the purely local circuit outputs a
move (i, v) whose application is exactly `NimGame.restore Q Q'`; the move is legal
and restores nim-sum 0.
Statement as elaborated and printed by Lean 4.26.0
∀ {B N : ℕ} {Q Q' : List ℕ},
Q.length = N →
Q'.length = N →
NimAudit.Game.Width B Q →
NimAudit.Game.Width B Q' →
NimAudit.nimSum Q = 0 →
NimAudit.Game.Move Q Q' →
∃ i v,
NimAudit.SelectCircuit.selReadout (NimAudit.LocalRestore.restC B N)
(NimAudit.LocalRestore.tf B N Q Q') =
some (i, v) ∧
NimAudit.Game.restore Q Q' = some (Q'.set i v) ∧
NimAudit.Game.Move Q' (Q'.set i v) ∧ NimAudit.nimSum (Q'.set i v) = 0
Exact source text, lines 208–229
208/-- LOCAL RESTORATION EQUIVALENCE: under the zero-predecessor / legal-transition209 promise (nim(Q) = 0 and Q → Q' a legal move), the purely local circuit outputs a210 move (i, v) whose application is exactly `NimGame.restore Q Q'`; the move is legal211 and restores nim-sum 0. -/212theorem restore_equiv {B N : Nat} {Q Q' : List Nat} (hQ : Q.length = N) (hQ' : Q'.length = N)213 (hw : Width B Q) (hw' : Width B Q') (h0 : nimSum Q = 0) (hm : Move Q Q') :214 ∃ i v, selReadout (restC B N) (tf B N Q Q') = some (i, v) ∧215 restore Q Q' = some (Q'.set i v) ∧ Move Q' (Q'.set i v) ∧ nimSum (Q'.set i v) = 0 := by216 rw [restC_eval hQ hQ' hw', localDelta_eq hQ hQ' hw hw' (oneChange_of_move hm)]217 obtain ⟨R, hR, hmR, hzR⟩ := restore_correct h0 hm218 have hR' := hR219 unfold restore at hR'220 rw [cancelFirst_eq] at hR'221 cases hc : cancelIdx (nimSum Q ^^^ nimSum Q') Q' with222 | none => rw [hc] at hR'; cases hR'223 | some m =>224 obtain ⟨i, v⟩ := m225 rw [hc] at hR'226 simp only [applyM, Option.some.injEq] at hR'227 subst hR'228 refine ⟨i, v, ?_, hR, hmR, hzR⟩229 unfold attainT; rw [hc]
Project declarations in the statement: Game.Move, Game.Width, Game.restore, LocalRestore.restC, LocalRestore.tf, SelectCircuit.selReadout, nimSum
Project declarations used by the proof or definition body
Attain.cancelIdx, Attain.decIdx, AttainCircuit.attainT, Game.Move, Game.Width, Game.cancelFirst, Game.restore, Game.restore_correct, LocalRestore.cancelFirst_eq, LocalRestore.localDelta, LocalRestore.localDelta_eq, LocalRestore.oneChange_of_move, LocalRestore.restC, LocalRestore.restC_eval, LocalRestore.tf, SelectCircuit.applyM, SelectCircuit.selReadout, nimSum
theorem WholeGame.twoFrame_wins
Module WholeGame
(lean/phase5/WholeGame.lean, lines 75–96) · file SHA-256 809a74ad589db609… Axioms reported by the fresh build: propext, Classical.choice, Quot.sound
TWO-FRAME WHOLE-GAME THEOREM: from an established zero-nim-sum stored board (opponent
to move), the network-driven two-frame player answers every legal opponent move
legally, keeps the zero invariant, the board length and the bit width, and every play
terminates with the player making the last move. Includes terminal and empty
boards (no opponent move exists).
Statement as elaborated and printed by Lean 4.26.0
∀ {B : ℕ} (Q : List ℕ),
NimAudit.Game.Width B Q →
NimAudit.nimSum Q = 0 → NimAudit.WholeGame.TwoFrameWins (NimAudit.WholeGame.restReply B) Q
Exact source text, lines 75–96
75/-- TWO-FRAME WHOLE-GAME THEOREM: from an established zero-nim-sum stored board (opponent76 to move), the network-driven two-frame player answers every legal opponent move77 legally, keeps the zero invariant, the board length and the bit width, and every play78 terminates with the player making the last move. Includes terminal and empty79 boards (no opponent move exists). -/80theorem twoFrame_wins {B : Nat} : ∀ (Q : List Nat), Width B Q → nimSum Q = 0 →81 TwoFrameWins (restReply B) Q := by82 intro Q83 induction Q using (measure List.sum).wf.induction with84 | h Q ih =>85 intro hw h086 refine TwoFrameWins.intro Q (fun Q' hm => ?_) (fun Q' R hm hR => ?_) (fun Q' R hm hR => ?_)87 · obtain ⟨R, h1, _⟩ := restReply_step hw h0 hm88 rw [h1]; rfl89 · obtain ⟨R', h1, _, h3, _⟩ := restReply_step hw h0 hm90 rw [h1] at hR; cases hR; exact h391 · obtain ⟨R', h1, _, h3, h4, _, h6⟩ := restReply_step hw h0 hm92 have hRR : R' = R := by rw [h1] at hR; exact Option.some.inj hR93 subst hRR94 refine ih R' ?_ h6 h495 have := move_sum_lt hm; have := move_sum_lt h396 show R'.sum < Q.sum; omega
Project declarations in the statement: Game.Width, WholeGame.TwoFrameWins, WholeGame.restReply, nimSum
Project declarations used by the proof or definition body
Game.Move, Game.Width, Game.move_sum_lt, Game.restore, WholeGame.TwoFrameWins, WholeGame.TwoFrameWins.intro, WholeGame.restReply, WholeGame.restReply_step, nimSum
Definitions these statements use
def Game.Move
Module NimGame
(lean/phase2/NimGame.lean, lines 24–26) · file SHA-256 23df6bb87ecfd344…
An ordinary legal Nim move: exactly one heap strictly decreases.
Statement as elaborated and printed by Lean 4.26.0
List ℕ → List ℕ → Prop
Exact source text, lines 24–26
24/-- An ordinary legal Nim move: exactly one heap strictly decreases. -/25def Move (p q : List Nat) : Prop :=26 ∃ pre x post y, p = pre ++ x :: post ∧ q = pre ++ y :: post ∧ y < x
Project declarations in the statement: none
Project declarations used by the proof or definition body
none
def Game.restore
Module NimGame
(lean/phase2/NimGame.lean, lines 407–410) · file SHA-256 23df6bb87ecfd344…
Two-frame restoration selector (paper Prop. restore / Thm search-gap (iii)):
from the predecessor Q and current board Q', cancel delta = nim(Q) XOR nim(Q').
Statement as elaborated and printed by Lean 4.26.0
List ℕ → List ℕ → Option (List ℕ)
Exact source text, lines 407–410
407/-- Two-frame restoration selector (paper Prop. restore / Thm search-gap (iii)):408 from the predecessor Q and current board Q', cancel delta = nim(Q) XOR nim(Q'). -/409def restore (Q Q' : List Nat) : Option (List Nat) :=410 cancelFirst (nimSum Q ^^^ nimSum Q') Q'
Project declarations in the statement: none
Project declarations used by the proof or definition body
Game.cancelFirst, nimSum
def nimSum
Module NimCore
(lean/NimCore.lean, lines 7–9) · file SHA-256 b07db6c505210d5a…
Statement as elaborated and printed by Lean 4.26.0
List ℕ → ℕ
Exact source text, lines 7–9
7def nimSum : List Nat → Nat8 | [] => 09 | h :: t => h ^^^ nimSum t
Project declarations in the statement: none
Project declarations used by the proof or definition body
none
def Game.Width
Module NimGame
(lean/phase2/NimGame.lean, lines 31–32) · file SHA-256 23df6bb87ecfd344…
B-bit board: every heap is below 2^B.
Statement as elaborated and printed by Lean 4.26.0
ℕ → List ℕ → Prop
Exact source text, lines 31–32
31/-- B-bit board: every heap is below 2^B. -/32def Width (B : Nat) (p : List Nat) : Prop := ∀ x ∈ p, x < 2 ^ B
Project declarations in the statement: none
Project declarations used by the proof or definition body
none
def LocalRestore.restC
Module LocalRestore
(lean/phase4/LocalRestore.lean, lines 181–181) · file SHA-256 fc4c7f908b0c9c58…
Statement as elaborated and printed by Lean 4.26.0
ℕ → ℕ → NimAudit.CorrBridge.RCirc
Exact source text, lines 181–181
181def restC (B N : Nat) : RCirc := substR (restSubst B N) (varSel B N)
Project declarations in the statement: CorrBridge.RCirc
Project declarations used by the proof or definition body
LocalRestore.restSubst, SelectCircuit.substR, SelectCircuit.varSel
def LocalRestore.tf
Module LocalRestore
(lean/phase4/LocalRestore.lean, lines 29–31) · file SHA-256 fc4c7f908b0c9c58…
Two-frame input vector.
Statement as elaborated and printed by Lean 4.26.0
ℕ → ℕ → List ℕ → List ℕ → ℕ → Bool
Exact source text, lines 29–31
29/-- Two-frame input vector. -/30def tf (B N : Nat) (Q Q' : List Nat) : Nat → Bool := fun j =>31 if j < B * N then boardBits B Q j else boardBits B Q' (j - B * N)
Project declarations in the statement: none
Project declarations used by the proof or definition body
CorrBridge.boardBits
def SelectCircuit.selReadout
Module SelectCircuit
(lean/phase4/SelectCircuit.lean, lines 26–32) · file SHA-256 922ee44ce0ababa9…
Evaluation of a move readout on an arbitrary input vector.
Statement as elaborated and printed by Lean 4.26.0
NimAudit.CorrBridge.RCirc → (ℕ → Bool) → Option (ℕ × ℕ)
Exact source text, lines 26–32
26/-- Evaluation of a move readout on an arbitrary input vector. -/27def selReadout (R : RCirc) (z : Nat → Bool) : Option (Nat × Nat) :=28 if eval z R.valid then29 match firstTrue (R.sel.map (eval z)) with30 | some i => some (i, toNatBE (R.val.map (eval z)))31 | none => none32 else none
Project declarations in the statement: CorrBridge.RCirc
Project declarations used by the proof or definition body
AC0.Circ, AC0.Circ.eval, Bridge.toNatBE, CorrBridge.RCirc, CorrBridge.RCirc.sel, CorrBridge.RCirc.val, CorrBridge.RCirc.valid, CorrBridge.firstTrue
inductive WholeGame.TwoFrameWins
Module WholeGame
(lean/phase5/WholeGame.lean, lines 41–50) · file SHA-256 809a74ad589db609…
Stateful two-frame game predicate (opponent to move at the stored board Q): every
legal opponent move is answered by a legal reply, the reply's board becomes the new
stored board, and play continues. Being inductive, every such play is finite; at a
terminal stored board the opponent cannot move and loses.
Statement as elaborated and printed by Lean 4.26.0
(List ℕ → List ℕ → Option (List ℕ)) → List ℕ → Prop
Exact source text, lines 41–50
41/-- Stateful two-frame game predicate (opponent to move at the stored board Q): every42 legal opponent move is answered by a legal reply, the reply's board becomes the new43 stored board, and play continues. Being inductive, every such play is finite; at a44 terminal stored board the opponent cannot move and loses. -/45inductive TwoFrameWins (reply : List Nat → List Nat → Option (List Nat)) : List Nat → Prop46 | intro (Q : List Nat) :47 (∀ Q', Move Q Q' → (reply Q Q').isSome = true) →48 (∀ Q' R, Move Q Q' → reply Q Q' = some R → Move Q' R) →49 (∀ Q' R, Move Q Q' → reply Q Q' = some R → TwoFrameWins reply R) →50 TwoFrameWins reply Q
Project declarations in the statement: none
Project declarations used by the proof or definition body
Game.Move
def WholeGame.restReply
Module WholeGame
(lean/phase5/WholeGame.lean, lines 35–39) · file SHA-256 809a74ad589db609…
The player's reply: evaluate the compiled restoration network on (Q, Q'), decode its
output wires and apply the decoded move to Q'. Index width r = log₂N + 1.
Statement as elaborated and printed by Lean 4.26.0
ℕ → List ℕ → List ℕ → Option (List ℕ)
Exact source text, lines 35–39
35/-- The player's reply: evaluate the compiled restoration network on (Q, Q'), decode its36 output wires and apply the decoded move to Q'. Index width r = log₂N + 1. -/37def restReply (B : Nat) (Q Q' : List Nat) : Option (List Nat) :=38 applyM Q' (netBinSem (restNet B Q'.length (Q'.length.log2 + 1)) Q'.length (Q'.length.log2 + 1) B39 (LocalRestore.tf B Q'.length Q Q'))
Project declarations in the statement: none
Project declarations used by the proof or definition body
LocalRestore.tf, SelectCircuit.applyM, ThresholdInst.netBinSem, ThresholdInst.restNet
Full modules
Build evidence: fresh isolated rebuild of all 38 bundled modules with Lean (version 4.26.0, started 2026-10-10T15:21:56Z, finished 2026-10-10T15:27:00Z: 38/38 modules compiled, 1588 axiom reports, no errors. See Build for the commands and the independent audit of 2026-10-10 (dated evidence).