Principal declarations
def Recurrent.serialize
Module NimRecurrent
(lean/phase3/NimRecurrent.lean, lines 57–59) · file SHA-256 1f2994aefc75e7f5…
Serialise positions: rows then SEP, position after position.
Statement as elaborated and printed by Lean 4.26.0
List (List ℕ) → List NimAudit.Recurrent.Token
Exact source text, lines 57–59
57/-- Serialise positions: rows then SEP, position after position. -/58def serialize (Ps : List (List Nat)) : List Token :=59 Ps.flatMap (fun P => P.map Token.row ++ [Token.sep])
Project declarations in the statement: Recurrent.Token
Project declarations used by the proof or definition body
Recurrent.Token, Recurrent.Token.row, Recurrent.Token.sep
def Recurrent.step
Module NimRecurrent
(lean/phase3/NimRecurrent.lean, lines 47–50) · file SHA-256 1f2994aefc75e7f5…
One recurrent update; SEP produces an output.
Statement as elaborated and printed by Lean 4.26.0
NimAudit.Recurrent.State →
NimAudit.Recurrent.Token → NimAudit.Recurrent.State × Option NimAudit.Recurrent.Out
Exact source text, lines 47–50
47/-- One recurrent update; SEP produces an output. -/48def step (s : State) : Token → State × Option Out49 | .row x => (⟨s.acc ^^^ x, s.prev, s.valid⟩, none)50 | .sep => (⟨0, s.acc, true⟩, some ⟨s.acc, if s.valid then some (s.prev ^^^ s.acc) else none⟩)
Project declarations in the statement: Recurrent.Out, Recurrent.State, Recurrent.Token
Project declarations used by the proof or definition body
Recurrent.Out, Recurrent.Out.mk, Recurrent.State, Recurrent.State.acc, Recurrent.State.mk, Recurrent.State.prev, Recurrent.State.valid, Recurrent.Token, Recurrent.Token.casesOn, Recurrent.Token.row, Recurrent.Token.sep
theorem Recurrent.sep_resets
Module NimRecurrent
(lean/phase3/NimRecurrent.lean, lines 130–133) · file SHA-256 1f2994aefc75e7f5… Axioms reported by the fresh build: propext
RESET BEHAVIOUR: after SEP the accumulator is 0, the summary is retained and the
validity bit is set; rows never change prev or valid.
Statement as elaborated and printed by Lean 4.26.0
∀ (s : NimAudit.Recurrent.State),
(NimAudit.Recurrent.step s NimAudit.Recurrent.Token.sep).1 =
{ acc := 0, prev := s.acc, valid := true }
Exact source text, lines 130–133
130/-- RESET BEHAVIOUR: after SEP the accumulator is 0, the summary is retained and the131 validity bit is set; rows never change prev or valid. -/132theorem sep_resets (s : State) :133 (step s Token.sep).1 = ⟨0, s.acc, true⟩ := rfl
Project declarations in the statement: Recurrent.Out, Recurrent.State, Recurrent.State.acc, Recurrent.State.mk, Recurrent.Token.sep, Recurrent.step
Project declarations used by the proof or definition body
Recurrent.Out, Recurrent.State, Recurrent.Token.sep, Recurrent.step
theorem Recurrent.fold_invariant
Module NimRecurrent
(lean/phase3/NimRecurrent.lean, lines 95–109) · file SHA-256 1f2994aefc75e7f5… Axioms reported by the fresh build: propext, Quot.sound
FOLD INVARIANT. From any state with empty accumulator, for ANY finite sequence
of positions (empty positions allowed): the t-th output is
(sigma(P_t), Delta) where Delta = prev XOR sigma(P_1) if the starting state is
valid (none otherwise) for t = 1 and sigma(P_{t-1}) XOR sigma(P_t) for t ≥ 2;
the final state retains the last summary with valid = true and acc = 0.
Statement as elaborated and printed by Lean 4.26.0
∀ (s : NimAudit.Recurrent.State),
s.acc = 0 →
∀ (Ps : List (List ℕ)),
NimAudit.Recurrent.run s (NimAudit.Recurrent.serialize Ps) =
(NimAudit.Recurrent.expectedState s Ps, NimAudit.Recurrent.expectedOuts s.valid s.prev Ps)
Exact source text, lines 95–109
95/-- FOLD INVARIANT. From any state with empty accumulator, for ANY finite sequence96 of positions (empty positions allowed): the t-th output is97 (sigma(P_t), Delta) where Delta = prev XOR sigma(P_1) if the starting state is98 valid (none otherwise) for t = 1 and sigma(P_{t-1}) XOR sigma(P_t) for t ≥ 2;99 the final state retains the last summary with valid = true and acc = 0. -/100theorem fold_invariant (s : State) (hs : s.acc = 0) (Ps : List (List Nat)) :101 run s (serialize Ps) = (expectedState s Ps, expectedOuts s.valid s.prev Ps) := by102 induction Ps generalizing s with103 | nil => simp [serialize, run, expectedState, expectedOuts]104 | cons P Ps ih =>105 have e : serialize (P :: Ps) = (P.map Token.row ++ [Token.sep]) ++ serialize Ps := by106 simp [serialize]107 rw [e, run_append, run_position, hs, Nat.zero_xor]108 rw [ih ⟨0, nimSum P, true⟩ rfl]109 simp [expectedState, expectedOuts]
Project declarations in the statement: Recurrent.Out, Recurrent.State, Recurrent.State.acc, Recurrent.State.prev, Recurrent.State.valid, Recurrent.expectedOuts, Recurrent.expectedState, Recurrent.run, Recurrent.serialize
Project declarations used by the proof or definition body
Recurrent.Out, Recurrent.Out.mk, Recurrent.State, Recurrent.State.acc, Recurrent.State.mk, Recurrent.State.prev, Recurrent.State.valid, Recurrent.Token, Recurrent.Token.row, Recurrent.Token.sep, Recurrent.expectedOuts, Recurrent.expectedState, Recurrent.run, Recurrent.run_append, Recurrent.run_position, Recurrent.serialize, nimSum
Definitions these statements use
inductive Recurrent.Token
Module NimRecurrent
(lean/phase3/NimRecurrent.lean, lines 32–34) · file SHA-256 1f2994aefc75e7f5…
Statement as elaborated and printed by Lean 4.26.0
Type
Exact source text, lines 32–34
32inductive Token where33 | row (x : Nat)34 | sep
Project declarations in the statement: none
Project declarations used by the proof or definition body
none
inductive Recurrent.Out
Module NimRecurrent
(lean/phase3/NimRecurrent.lean, lines 41–43) · file SHA-256 1f2994aefc75e7f5…
Statement as elaborated and printed by Lean 4.26.0
Type
Exact source text, lines 41–43
41structure Out where42 summary : Nat43 diff : Option Nat
Project declarations in the statement: none
Project declarations used by the proof or definition body
none
inductive Recurrent.State
Module NimRecurrent
(lean/phase3/NimRecurrent.lean, lines 36–39) · file SHA-256 1f2994aefc75e7f5…
Statement as elaborated and printed by Lean 4.26.0
Type
Exact source text, lines 36–39
36structure State where37 acc : Nat38 prev : Nat39 valid : Bool
Project declarations in the statement: none
Project declarations used by the proof or definition body
none
def Recurrent.State.acc
Module NimRecurrent
(lean/phase3/NimRecurrent.lean, lines 37–37) · file SHA-256 1f2994aefc75e7f5…
Statement as elaborated and printed by Lean 4.26.0
NimAudit.Recurrent.State → ℕ
Exact source text, lines 37–37
37 acc : Nat
Project declarations in the statement: Recurrent.State
Project declarations used by the proof or definition body
Recurrent.State
def Recurrent.State.prev
Module NimRecurrent
(lean/phase3/NimRecurrent.lean, lines 38–38) · file SHA-256 1f2994aefc75e7f5…
Statement as elaborated and printed by Lean 4.26.0
NimAudit.Recurrent.State → ℕ
Exact source text, lines 38–38
38 prev : Nat
Project declarations in the statement: Recurrent.State
Project declarations used by the proof or definition body
Recurrent.State
def Recurrent.State.valid
Module NimRecurrent
(lean/phase3/NimRecurrent.lean, lines 39–39) · file SHA-256 1f2994aefc75e7f5…
Statement as elaborated and printed by Lean 4.26.0
NimAudit.Recurrent.State → Bool
Exact source text, lines 39–39
39 valid : Bool
Project declarations in the statement: Recurrent.State
Project declarations used by the proof or definition body
Recurrent.State
def Recurrent.expectedOuts
Module NimRecurrent
(lean/phase3/NimRecurrent.lean, lines 84–88) · file SHA-256 1f2994aefc75e7f5…
Expected outputs for a sequence of positions from a state with empty accumulator.
Statement as elaborated and printed by Lean 4.26.0
Bool → ℕ → List (List ℕ) → List NimAudit.Recurrent.Out
Exact source text, lines 84–88
84/-- Expected outputs for a sequence of positions from a state with empty accumulator. -/85def expectedOuts : Bool → Nat → List (List Nat) → List Out86 | _, _, [] => []87 | v, q, P :: Ps =>88 ⟨nimSum P, if v then some (q ^^^ nimSum P) else none⟩ :: expectedOuts true (nimSum P) Ps
Project declarations in the statement: Recurrent.Out
Project declarations used by the proof or definition body
Recurrent.Out, Recurrent.Out.mk, nimSum
def Recurrent.expectedState
Module NimRecurrent
(lean/phase3/NimRecurrent.lean, lines 90–93) · file SHA-256 1f2994aefc75e7f5…
Expected final state.
Statement as elaborated and printed by Lean 4.26.0
NimAudit.Recurrent.State → List (List ℕ) → NimAudit.Recurrent.State
Exact source text, lines 90–93
90/-- Expected final state. -/91def expectedState : State → List (List Nat) → State92 | s, [] => s93 | _, P :: Ps => expectedState ⟨0, nimSum P, true⟩ Ps
Project declarations in the statement: Recurrent.State
Project declarations used by the proof or definition body
Recurrent.State, Recurrent.State.mk, nimSum
def Recurrent.run
Module NimRecurrent
(lean/phase3/NimRecurrent.lean, lines 52–55) · file SHA-256 1f2994aefc75e7f5…
Run the recurrence over a token list, collecting outputs.
Statement as elaborated and printed by Lean 4.26.0
NimAudit.Recurrent.State →
List NimAudit.Recurrent.Token → NimAudit.Recurrent.State × List NimAudit.Recurrent.Out
Exact source text, lines 52–55
52/-- Run the recurrence over a token list, collecting outputs. -/53def run : State → List Token → State × List Out54 | s, [] => (s, [])55 | s, t :: ts => ((run (step s t).1 ts).1, (step s t).2.toList ++ (run (step s t).1 ts).2)
Project declarations in the statement: Recurrent.Out, Recurrent.State, Recurrent.Token
Project declarations used by the proof or definition body
Recurrent.Out, Recurrent.State, Recurrent.Token, Recurrent.step
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).