NIM paper · interactive edition Interactive edition · paper, explanations and Lean proofs.

Section 5.3, paragraph 2If one heap changes from x_i to x_i', then Δ = x_i ⊕ x_i'

Checked theorem Lean checks a formal statement corresponding to this claim.

1 Paper text

In NIM, if P′P' is obtained from PP by changing heap ii from xix_i to xi′x_i', then Δ(P,P′)  =  xi⊕xi′,\Delta(P,P') \;=\; x_i \oplus x_i', a purely local computation on the changed heap.

Generated from paper_jmlr.tex, lines 496–500.

2 Explain this

When a move changes only heap ii from xix_i to xi′x_i', all other heaps appear in both nim-sums and cancel, so Δ(P,P′)=xi⊕xi′\Delta(P,P') = x_i\oplus x_i'. Example: (3,5,6)→(3,4,6)(3,5,6)\to(3,4,6) gives Δ=5⊕4=1\Delta = 5\oplus4 = 1.

So computing Δ\Delta needs only the changed heap, not a parity over all heaps.

3 How this is formalised

one_heap_difference: for lists pre\mathit{pre}, post\mathit{post} and values a,ba,b, the nim-sums of pre+ ⁣ ⁣+[a]+ ⁣ ⁣+post\mathit{pre}\mathbin{+\!\!+}[a]\mathbin{+\!\!+}\mathit{post} and $\mathit{pre}\mathbin{+!!+}[b]\mathbin{+!!+} \mathit{post}differbydiffer bya\oplus b$. Misc.delta_bit_local gives the bitwise form for any legal move: bit kk of the difference is ak⊕bka_k\oplus b_k.

Coverage record
Paper anchorsec:multiframe-p2 (website anchor; the manuscript has no label here)
Displayed asSection 5.3, paragraph 2
ClaimIf one heap changes from x_i to x_i', then Δ = x_i ⊕ x_i'
Coverage categoryChecked theorem
Statement sourcepaper_jmlr.tex lines 496–500; SHA-256 of the normalised block source da1455481e81fc88…
Lean declarations
Depends onDefinition 5.3
Explanationsexplain/c-delta-local, formal/c-delta-local
Build evidencefresh isolated rebuild, audit report

4 Lean statement and source

Principal declarations

theorem one_heap_difference

Module NimCore (lean/NimCore.lean, lines 37–39) · file SHA-256 b07db6c505210d5a… Axioms reported by the fresh build: propext, Quot.sound

Statement as elaborated and printed by Lean 4.26.0

∀ (pre post : List ℕ) (a b : ℕ),
  NimAudit.nimSum (pre ++ a :: post) ^^^ NimAudit.nimSum (pre ++ b :: post) = a ^^^ b
Exact source text, lines 37–39
37theorem one_heap_difference (pre post : List Nat) (a b : Nat) :38    nimSum (pre ++ a :: post) ^^^ nimSum (pre ++ b :: post) = a ^^^ b := by39  simp [nimSum_append, nimSum, Nat.xor_comm, xor_left_comm]

Project declarations in the statement: nimSum

Project declarations used by the proof or definition body

nimSum, nimSum_append, xor_left_comm

theorem Misc.delta_bit_local

Module Misc (lean/phase6/Misc.lean, lines 687–694) · file SHA-256 07766c03566dbfca… Axioms reported by the fresh build: propext, Quot.sound

DELTA BITS ARE TWO-COORDINATE CHARACTERS: across one legal move (heap value a → b), bit k of the difference is a_k ⊕ b_k.

Statement as elaborated and printed by Lean 4.26.0

∀ {Q Q' : List ℕ},
  NimAudit.Game.Move Q Q' →
    ∃ pre a post b,
      Q = pre ++ a :: post ∧
        Q' = pre ++ b :: post ∧
          ∀ (k : ℕ),
            (NimAudit.nimSum Q ^^^ NimAudit.nimSum Q').testBit k = (a.testBit k ^^ b.testBit k)
Exact source text, lines 687–694
687/-- DELTA BITS ARE TWO-COORDINATE CHARACTERS: across one legal move (heap value a → b),688    bit k of the difference is a_k ⊕ b_k. -/689theorem delta_bit_local {Q Q' : List Nat} (hm : Move Q Q') :690    ∃ pre a post b, Q = pre ++ a :: post ∧ Q' = pre ++ b :: post ∧691      ∀ k, (nimSum Q ^^^ nimSum Q').testBit k = xor (a.testBit k) (b.testBit k) := by692  obtain ⟨pre, a, post, b, h1, h2, _⟩ := hm693  refine ⟨pre, a, post, b, h1, h2, fun k => ?_⟩694  rw [h1, h2, one_heap_difference, Nat.testBit_xor]

Project declarations in the statement: Game.Move, nimSum

Project declarations used by the proof or definition body

Game.Move, nimSum, one_heap_difference

Definitions these statements use

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.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

Full modules

ModuleFileLinesImports
Misclean/phase6/Misc.lean912Bypass
NimCorelean/NimCore.lean139Std
NimGamelean/phase2/NimGame.lean634NimRollout

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).