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

Beneath statements, small controls open three further levels: Explain this, How this is formalised and Lean statement and source. They never change the paper text. Every level has its own link.

Overcoming a Learning Bottleneck in Impartial Games:
A Circuit Complexity Approach

Søren Riis

s.riis@qmul.ac.uk

Centre for Fundamentals of AI and Computational Theory
Queen Mary University of London
Mile End Road, London E1 4NS, United Kingdom

Abstract

Why can neural networks struggle to learn optimal play in a game with a simple, efficient solution algorithm? Motivated by empirical difficulties with parity in impartial games, we use NIM to study a representational bottleneck and three ways around it. We show that a restricted model of shallow, fixed-scale quantised networks lies in AC0\AC^0, a circuit class unable to compute parity on arbitrarily large inputs. This prevents optimal single-position play across all board sizes within the model. The obstruction also guides architectural design: two-frame inputs allow restoration from a known zero-nim-sum position; complementary rollout policies reveal the missing invariant; and persistent recurrence accumulates it row by row. Each route retains shallow network components while supplying additional information or processing time. Supervised experiments illustrate the benefits of two-frame restoration and multiple rollout heads; recurrence is a theoretical construction. These results establish representational possibilities, not guarantees of successful training: AC0\AC^0 does not characterise practical learnability. Core mathematical results and constructions have been checked in Lean, with classical complexity results as explicit external inputs. The interactive edition and complete Lean sources are available online (Riis, 2026a,b).

Informal interpretation

Summary of the results; each is stated and qualified in the body of the paper

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

Keywords: Impartial games; NIM; circuit complexity; quantised inference; learning bottlenecks.

1 Introduction

Game play has historically served as the “Formula 1” of artificial intelligence: a high-speed, controlled proving ground where engineering limits are tested and new paradigms are born. From Deep Blue in chess to AlphaGo in Go, games have repeatedly driven advances in search, planning, and reinforcement learning (Silver et al., 2016, 2017, 2018; Schrittwieser et al., 2020). Minsky and Papert’s analysis of perceptron limitations illustrates how representational restrictions can motivate architectural changes (Minsky and Papert, 1969).

In NIM, two players take turns removing any positive number of tokens from a single heap; the player taking the last token wins. It belongs to the broad class of impartial games: both players have the same legal moves from a given position. Many such board games can be thought of as games with shared pieces, whereas in partisan games, such as chess, legal moves depend on which player is to move. NIM is central to impartial-game theory because every finite terminating impartial position under the last-move-wins convention is equivalent, in sums of games, to a single NIM heap (Section 4).

Informal interpretation

NIM rules, impartiality and why NIM is central

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

NIM poses a particularly revealing challenge: optimal moves can be found by a simple, efficient algorithm, yet learning that algorithm can be difficult. The puzzle is the gap between the ease of computing the solution once the rule is known and the difficulty of discovering it through training. Friedman’s 2017 AI challenge asked whether a system could discover perfect NIM play without being given the winning strategy (Friedman, 2017a).

Our earlier work with Bei Zhou provides the empirical starting point. In Impartial Games: A Challenge for Reinforcement Learning, Zhou and Riis found that AlphaZero-style learning deteriorated as NIM boards grew (Zhou and Riis, 2026). Subsequent parity experiments examined how noisy labels can obstruct curriculum learning (Zhou and Riis, 2023); see also Zhou’s thesis (Zhou, 2024). These findings make parity a useful test of the gap between learning familiar patterns and discovering an exact rule that works across positions.

External cited result

Earlier experiments (Zhou and Riis) found AlphaZero-style learning deteriorating on larger NIM boards

A published result used as background or input; not proved in Lean here.

Explain this How this is formalised

Here we turn that difficulty into a question about computation. The class AC0\AC^0 consists of polynomial-size Boolean circuits built from AND, OR and NOT gates, with a number of layers that remains fixed as the input grows. Such circuits can combine many local tests, but cannot compute global parity: whether the total number of input 1s is odd or even. This is the feature that makes the class useful here: it provides a precise model with a provable version of the parity limitation seen in the experiments. We establish the connection for an explicitly restricted neural model, rather than assuming that all neural networks lie in AC0\AC^0.

External cited result

AC0 circuits cannot compute global parity; the connection is made for an explicitly restricted model

A published result used as background or input; not proved in Lean here.

Explain this How this is formalised

The value of identifying a bottleneck is that it tells us what an architectural change must supply. Instead of asking a shallow network to rediscover a global invariant from every board, we can expose a useful transition, obtain complementary information from rollouts, or accumulate the invariant over time. Our contribution is this barrier-to-bypass approach: a computational obstruction guides three concrete constructions. Representability in AC0\AC^0 is a necessary condition for a fixed-latency computation in our restricted model; it is neither sufficient for successful training nor a universal condition on what neural networks can learn.

Informal interpretation

AC0 representability is necessary within the restricted model, not sufficient for training and not universal

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

NIM itself does not depend on game history: the current position completely determines its legal moves and optimal play. History can nevertheless supply useful computational context to a restricted network. The first and third bypasses use such context in different ways: an earlier board exposes a local change, while recurrent memory retains information accumulated during row processing and across positions.

Informal interpretation

History supplies computational context without changing optimal play

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

The central observation is that while the state can be hard to process, the transition can be easy: under the promise that the preceding position has nim-sum zero, short history converts winning-move selection into local difference computation and restoration. A second route uses distinct rollout policies to extract complementary bits of the invariant. A third route processes each position sequentially, retaining recurrent state as rows and then successive positions arrive. Here a sequence of simple updates computes the global invariant, and memory connects the new position to the preceding one. These mechanisms use different resources: explicit transition information, multiple rollout channels, or a growing recurrent computation horizon. The distinction between a shallow component and the complete computation is essential. Two-frame restoration is a shallow map on a promised pair of boards. In the other two constructions, each policy step or recurrent update is shallow, but generating the information needed for a decision takes a sequence of such steps. Thus the bypasses preserve simple network components while changing the input information or total processing time. The complete sequential computation need not itself lie in AC0\AC^0. Figure 1 summarises the three routes for NIM.

Informal interpretation

Shallow components versus the complete sequential computation in the three bypasses

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised
Four rows of boxes and arrows. (a) Barrier, single-frame, single-head: input P_t (global) feeds a single-head network whose output is marked with a cross, labelled "Cannot compute global parity in this model". (b) Bypass 1, multi-frame input: input (P_{t-1}, P_t) (transition) feeds a single-head network whose output is marked with a check, labelled "Computes local difference Delta". (c) Bypass 2, multiple rollout heads: input P_t splits into heads pi_0 through pi_{B-1}, which join at a check mark labelled "Rollout outcomes recover B bits". (d) Bypass 3, persistent recurrence: rows of P_t then P_{t+1} feed a recurrent state s <- s XOR x_i, ending at a check mark labelled "Nim-sum after N row updates (growing latency)".
Figure 1: The parity barrier and three structural bypasses. (a) Fixed-scale quantised inference (FSQI) with fixed latency cannot compute global parity across arbitrarily large boards. Here fixed latency means a bounded number of sequential computation steps, independent of board size. (b) Two frames expose Δ\Delta for restoration when the predecessor has nim-sum zero. (c) Distinct policy heads recover complementary information through complete rollouts. (d) Persistent recurrence accumulates the nim-sum row by row and retains summaries across positions. Each update has constant depth; the full scan has depth growing with NN.
Informal interpretation

Schematic of the barrier and the three bypasses

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

1.1 Contributions

The results follow a single question: what must be added to a shallow learner to make the required strategy representable? We first identify the obstruction, then show how each bypass supplies a different missing resource.

  • AC0\AC^0 containment for fixed-scale quantised inference. We formalise a fixed-grid Boolean literal-threshold model and its bounded-unrolling recurrent extension. Both are simulable by AC0\AC^0 circuits (Theorem 2.4). An attention-style extension is covered only if its scoring, selection and aggregation operations can each be implemented by the permitted Boolean threshold gates. This is a restriction on the computation, not a requirement that every game have the same board size. Within a play sequence we use a fixed layout of NN heap rows and BB bits per heap, retaining empty heaps as zero rows. The asymptotic statements concern families of networks for growing input lengths NBNB.

  • Single-frame impossibility for strong mastery. Under this model, no single-frame policy/value network can strongly master NIM in the worst case (Theorem 5.2).

  • Two-frame bypass via local differences and restoration. With two consecutive frames, the agent can compute Δ(P,P′)\Delta(P,P') in AC0\AC^0 (Lemma 5.4). When PP has nim-sum zero, an AC0\AC^0 move selector restores zero after the opponent’s move (Proposition 5.5). This is conditional restoration mastery, not an arbitrary-start verifier.

  • Planning analysis and the single-policy bottleneck. We analyse a restricted measurement interface inspired by rollouts, rather than a general model of MCTS. With BB structured policies one can recover all nim-sum bits (Proposition 5.9). Root and one-heap-modification queries to one fixed member of that family expose only one unknown linear functional (Proposition 5.10). With an explicitly bounded readout, this yields the distributional bound in Theorem 5.12.

  • Persistent recurrence via sequential row updates. A constant-depth recurrent update accumulates the nim-sum over NN heap rows and retains a summary across position separators (Proposition 5.13). With a replay of the current board or stored heap rows, this supports optimal move selection. The construction relaxes fixed total latency, not fixed-scale quantisation (Section 5.5).

  • Controlled empirical comparison and learnability discussion. On 20-heap, 4-bit NIM with 10610^6 supervised restoration examples, a one-frame model has low restoration accuracy while a two-frame model learns restoration (Section 7.2). In a complementary single-frame experiment, multi-head FSM-controlled shootouts achieve perfect win/loss position classification while the single-head baseline remains bottlenecked by one-bit information (Section 7.3). We also discuss why AC0\AC^0 is a useful abstraction for what is robustly feasible under fixed-scale quantised inference (Section 6.3).

Informal interpretation

List of contributions; each item points to a precise statement

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

1.2 Scope and limitations

Our theorems are worst-case representational statements about what can be computed under explicit architectural constraints. They are not training-complexity results, and they intentionally abstract away from several practical details, such as continuous-valued activations, floating-point arithmetic, normalisation layers and the dynamics of optimisation.

  • Fixed-scale quantisation / fixed latency. The AC0\AC^0 simulation (Theorem 2.4) assumes constant depth and a fixed-scale, bounded-range quantisation regime: weights/thresholds lie on a fixed grid whose range/resolution do not scale with the input length (cf. Remark 2.2). Architectures that rely on fan-in dependent re-normalisation, biases/thresholds growing with dimension, or depth growing with nn fall outside this abstraction. In particular, a fixed recurrent update rule need not have fixed total latency: the third bypass deliberately allows NN successive row updates per position.

  • Formal model vs. experimental networks. The formal units have nonnegative weights on Boolean literals and bounded thresholds. The experiments instead use ordinary floating-point signed linear layers, ReLU and LayerNorm, with Log-Softmax in the loss. They test the benefit of transition information under the reported training protocol, not the asymptotic lower bound or the deployment behaviour of quantised networks.

  • Stylised planning interface. The single-channel lower bound permits only root and one-heap-modification queries to a fixed structured policy, and requires a polynomial-size, constant-depth final readout. It is not a bound on arbitrary rollout policies, unrestricted query transformations, or an unbounded adaptive MCTS controller.

  • No guarantee of learnability. The multi-policy-head and recurrent constructions concern existence of suitable computations; we do not claim that self-play efficiently discovers the structured heads or an exact recurrent accumulator. Our experiments use controlled supervised restoration and policy imitation; self-play discovery is left for a separate study.

Informal interpretation

Scope: worst-case representational statements under explicit constraints, not training results

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

1.3 Paper organisation

Section 2 introduces the fixed-scale quantised inference model and the AC0\AC^0 simulation theorem. Section 3 situates our contribution in circuit complexity, modern sequence models, and reinforcement learning for combinatorial games. Section 4 recalls NIM and the nim-sum characterisation. Section 5 presents the main impossibility and bypass results: two-frame restoration, rollout channels (Section 5.4), and persistent recurrence (Section 5.5). Section 6 discusses modelling choices and learnability considerations. Section 7 reports experiments. Appendices contain formal model definitions and proofs.

2 Theoretical framework and neural network models

2.1 Fixed-scale quantised inference and AC0\AC^0 simulation

We consider neural inference models that are (i) bounded depth, (ii) polynomial size, and (iii) operate in a fixed-scale quantised regime: all weights and thresholds lie on a fixed quantisation grid of bounded dynamic range that does not change with the input length. The fixed scale is motivated by limits on the effective precision of neural computation, including sensitivity to noise: distinctions that can be used reliably may be much coarser than the rounding resolution of 32-bit floating-point arithmetic. Noise motivates this abstraction; it does not by itself imply the gate and threshold assumptions below.

Our Boolean threshold gates sum nonnegative weights on inputs that may be negated. Negation allows inhibitory as well as excitatory effects: for a Boolean input xx, the identity −ax=a(1−x)−a-ax=a(1-x)-a replaces a negative coefficient by a positive weight on the negated input, with an adjustment to the threshold. The substantive restriction is that the resulting weights and thresholds remain on the fixed, bounded grid; this is not a model of arbitrary signed-weight or INT8/fixed-point inference.

Concretely, we fix constants:

  • a quantisation resolution parameter captured by a fixed denominator D∈ND\in\N (grid step 1/D1/D),

  • a dynamic-range bound W∈NW\in\N (maximum magnitude W/DW/D),

  • and (for recurrent/attention models) a finite time window T∈NT\in\N.

We define QW,D  =  {ℓD : ℓ∈{0,1,2,…,W}},\Qset_{W,D} \;=\; \Big\{ \frac{\ell}{D}\ :\ \ell\in\{0,1,2,\dots,W\}\Big\}, a finite set independent of input length. The threshold bound applies after choosing the literal representation. Replacing a signed term −ax-a x by a(1−x)a(1-x) raises the threshold by aa. With many such terms, the adjusted threshold may grow with the input length. What matters is the amount of evidence needed to activate a gate: our model bounds the number of satisfied input literals that suffice, whereas an unrestricted majority gate needs a number that grows with its inputs. Negative coefficients themselves are not the obstruction; the bound on the adjusted threshold is essential to the simulation.

Checked definition or construction

The fixed grid Q_{W,D}; rewriting a negative term as a literal raises the threshold

Lean contains the definition or construction, with checked properties.

Explain this How this is formalised Lean statement and source

Each neuron computes a thresholded weighted sum of Boolean inputs. Formal definitions for NN\NN, RNN\RNN and LTST\LTST are in Appendix A.

Definition 2.1 (Quantised inference) A network NN\NN in this class has constant depth and polynomially many threshold neurons, with weights and thresholds in QW,D\Qset_{W,D}. Analogously, fixed-scale quantised RNN\RNN and LTST\LTST models have constant depth and polynomial size per time step and operate within a fixed time window TT. For the simulation theorem, TT bounds the entire unrolled computation from an input-independent initial state, including any computation used to form a retained state.

Checked definition or construction

Fixed-scale quantised NN, RNN and LTST models: constant depth, polynomial size, fixed grid, bounded unrolling

Lean contains the definition or construction, with checked properties.

Explain this How this is formalised Lean statement and source

A bound on the number of preceding states consulted by one update is insufficient: even hr+1=hr⊕xrh_{r+1}=h_r\oplus x_r can accumulate parity over an arbitrarily long stream. Section 5.5 exploits precisely this distinction by allowing the number of recurrent updates to grow with the number of rows.

Checked theorem

A one-step recurrence h_{r+1}=h_r⊕x_r accumulates parity over an arbitrarily long stream

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

Why fixed-scale quantisation suggests an AC0\AC^0 abstraction. The key structural property is fixed scale: the smallest nonzero weight is 1/D1/D and the largest threshold is W/DW/D, with W,DW,D independent of the input length. Consequently, whenever a threshold unit outputs 11, there is a satisfying witness consisting of at most WW input literals whose contributions already cross the threshold. This yields a constant-width DNF expansion for each unit (Lemma B.1), and composing a constant number of layers yields an AC0\AC^0 simulation (Theorem 2.4).

Checked theorem

Fixed scale gives a witness of at most W literals, hence a constant-width DNF for each unit

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

We emphasise that this is not a statement about floating-point arithmetic per se. The abstraction intentionally excludes scale-adaptive regimes where thresholds/biases grow with fan-in or where weights shrink with dimension (e.g. 1/n1/n or 1/n1/\sqrt{n} normalisations), which move the analysis toward threshold-circuit classes such as TC0\TC^0. This class allows constant-depth, polynomial-size circuits with general threshold gates, including majority gates; unlike AC0\AC^0, it can compute parity.

Informal interpretation

The abstraction excludes scale-adaptive regimes, which move towards TC0

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

Remark 2.2 (Scope of the AC0\AC^0 abstraction) Theorem 2.4 formalises a fixed-latency fixed-scale quantised regime in which each unit uses parameters drawn from a bounded-range grid QW,D\Qset_{W,D} with W,DW,D independent of the input length. This yields the constant-witness property exploited in Lemma B.1.

The abstraction is deliberately conservative: it does not model architectures that rely on fan-in dependent re-scaling, numerically large signed biases/thresholds that grow with dimension, or deep computations whose depth scales with nn. Allowing such scale-adaptive behaviour leads naturally to richer threshold-circuit models (e.g. TC0\TC^0), in which parity-like computations can become representable.

(model scope)
Checked definition or construction

The model has bounded thresholds; a fan-in-dependent threshold such as majority lies outside it

Lean contains the definition or construction, with checked properties.

Explain this How this is formalised Lean statement and source
(TC0)
External cited result

Scale-adaptive threshold circuits (TC0) can represent parity-like computations

A published result used as background or input; not proved in Lean here.

Explain this How this is formalised

Remark 2.3 (Local vs. global parity) When we say “parity is hard” we mean global parity across the full Boolean input of length n=NBn=NB. In contrast, parity on O(1)O(1) bits is trivial in AC0\AC^0 (hardwire the truth table), and more generally XOR of a constant number of BB-bit blocks is AC0\AC^0-computable. This local/global separation underlies both the two-frame bypass via the nimber difference Δ(P,P′)\Delta(P,P') and the recurrent bypass, which composes local XOR updates over a growing number of steps.

(local XOR)
Checked theorem

XOR of a constant number of bits or B-bit blocks is computable in AC0

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source
(global parity)
Checked conditional theorem using named classical input

Global parity of n = NB bits is not in AC0

Lean checks the implication from a named, unproved classical hypothesis.

Explain this How this is formalised Lean statement and source
Property of deployed inferenceCaptured hereNot captured here
Fixed latency / bounded depthconstant depth LL (and window TT)depth growing with nn
Fixed-scale quantisation (bounded range)weights/thresholds in fixed grid QW,D\Qset_{W,D}fan-in dependent scaling or thresholds growing with nn
Parallel bit operationsunbounded fan-in AND/OR/NOTexact global counting / exact parity on unbounded inputs
Signed effectsvia input negations (Lemma B.1)large signed dot-product accumulation
Informal interpretation

What the model captures and does not capture about deployed inference

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

Notation convention (input length). We write NN for the number of heaps and BB (or kk in experiments) for the bit-width used to encode each heap size. The resulting Boolean input length is n:=NBn := NB. When we discuss AC0\AC^0 circuit size/depth, nn always refers to this Boolean input length.

Circuit complexity primer. AC0\AC^0 is the class of Boolean functions computable by constant-depth, polynomial-size circuits with unbounded fan-in AND/OR/NOT gates. A classical result is that PARITY∉AC0\mathrm{PARITY}\notin\AC^0. In contrast, TC0\TC^0 augments AC0\AC^0 with unbounded fan-in threshold gates and can compute parity. Our focus here is a fixed-scale quantised regime in which thresholds do not scale with fan-in; in that regime, each threshold unit admits a constant-witness DNF expansion and the overall computation collapses to AC0\AC^0 (Theorem 2.4).

External cited result

Circuit-complexity background: PARITY ∉ AC0, TC0 computes parity, fixed scale collapses to AC0

A published result used as background or input; not proved in Lean here.

Explain this How this is formalised

2.2 Simulation by circuits

We state the simulation theorem for the literal-threshold model and its explicitly gate-realised extensions.

Theorem 2.4 (Simulation by AC0\AC^0) Fix constants W,D∈NW,D\in\N and a time window T∈NT\in\N. Let {Mn}n≥1\{\mathcal{M}_n\}_{n\ge 1} be any family of models of type NN\NN, RNN\RNN (with window TT), or LTST\LTST (with window TT) such that:

  1. (1) (Polynomial size) the number of neurons/units in Mn\mathcal{M}_n is at most poly(n)\poly(n).

  2. (2) (Constant depth) the number of layers is a fixed constant LL (independent of nn); for RNN/LTST\RNN/\LTST the entire unrolled computation uses at most TT time steps from an input-independent initial state.

  3. (3) (Permitted primitives) every operation is realised by the Boolean literal-threshold gates of Definition A.1; all weights and thresholds lie in QW,D\Qset_{W,D}. For the attention-style extension this includes score computation, coefficient selection and aggregation.

Then the Boolean function computed by Mn\mathcal{M}_n can be computed by an AC0\AC^0 circuit family of polynomial size and constant depth (depending only on L,T,W,DL,T,W,D).

Checked theorem

Fixed-depth, fixed-grid literal-threshold networks (and bounded-unrolling extensions) are simulated by AC0 circuit families

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

3 Related Work

Circuit complexity and neural networks. Parity is outside AC0\AC^0 (Furst et al., 1984; Håstad, 1986), while constant-depth threshold circuits (TC0\TC^0) can compute it. Attention results depend on the precise model: Hao, Angluin and Frank analyse hard-attention variants, including AC0\AC^0 restrictions for unique hard attention (Hao et al., 2022). Merrill and Sabharwal study the additional power of intermediate decoding over a TC0\TC^0 baseline (Merrill and Sabharwal, 2024); that containment does not rule out parity. Their sequential-computation perspective is relevant to our recurrent bypass, although the architectures and formal assumptions differ. Our contribution applies these distinctions to NIM policies and a restricted rollout-measurement interface.

External cited result

Related results on parity, threshold circuits and attention models

A published result used as background or input; not proved in Lean here.

Explain this How this is formalised

Quantised inference and deployment constraints. Low-bit inference motivates studying bounded numerical resources (Jacob et al., 2018; Dettmers et al., 2022). Our constant-witness proof additionally requires nonnegative literal weights, bounded thresholds and Boolean intermediate states. These are explicit mathematical assumptions, not properties inferred merely from a quantisation format. Standard signed linear layers and scale-adaptive normalisation are outside the theorem unless separately reduced to the permitted gates.

Informal interpretation

The proof needs nonnegative literal weights, bounded thresholds and Boolean states, not just a quantisation format

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

Reinforcement learning in combinatorial games. While RL has mastered domains such as Go and chess, impartial games remain a useful stress test because optimality is governed by exact algebraic invariants rather than approximate pattern matching. Zhou and Riis (Zhou and Riis, 2026, 2023) studied reinforcement-learning difficulties in impartial games. Our lower bound identifies a representational obstruction in a restricted model; determining which mechanisms explain failures in ordinary neural training requires separate experiments.

External cited result

Prior work on RL difficulties in impartial games; the lower bound is about a restricted model

A published result used as background or input; not proved in Lean here.

Explain this How this is formalised

History and memory in RL. Using short history windows is standard in partially observable settings, where stacked frames recover hidden variables such as velocity (Mnih et al., 2015). Our point is different and perhaps surprising: even in Markovian, fully observable games—where the current state is informationally sufficient and the past is theoretically irrelevant—history can reduce computational complexity by exposing local differences that would otherwise require expensive search or unbounded-depth inference to extract from the current state alone. In our restoration setting, the previous frame carries a promise established by an earlier successful move: its nim-sum is zero. That promise makes a local difference sufficient for the next response. Establishing the promise initially remains a separate computational task.

Informal interpretation

History can reduce computational complexity even in fully observable games, given the zero-nim-sum promise

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

4 Impartial games and NIM

We briefly recall standard definitions; see (Berlekamp et al., 2001–2004) for extensive background.

4.1 Impartial games

Definition 4.1 (Impartial game) A finite terminating impartial game is a pair (P,M)(\mathcal{P},\mathcal{M}) where P\mathcal{P} is a nonempty set of positions and M(p)⊆P\mathcal{M}(p)\subseteq \mathcal{P} is the (finite) set of legal moves from pp, with the property that the move relation does not depend on which player is to play (symmetry). We assume the move relation is acyclic and play terminates. We use the last-move-wins convention, usually called normal play: a player with no legal move loses.

External cited result

Finite terminating impartial games under normal play

A published result used as background or input; not proved in Lean here.

Explain this How this is formalised

A position with no legal moves is terminal.

Checked definition or construction

A position with no legal moves is terminal

Lean contains the definition or construction, with checked properties.

Explain this How this is formalised Lean statement and source

The last-move-wins convention also provides a convenient encoding of other decisive endings. A move that wins by capturing a designated piece or creating a specified configuration can simply lead to a position with no further legal moves. If instead reaching a special position loses for the player who made the move, give the opponent one forced move to a new terminal position. These encodings preserve the winner of the individual play; they must retain player-independent move rules to remain impartial. The theory below concerns the resulting normal-play game.

Informal interpretation

Encoding decisive endings using terminal positions and a forced last move

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

4.2 NIM

Definition 4.2 (NIM) A NIM position consists of hh heaps with sizes x1,…,xh∈N0x_1,\dots,x_h\in\N_0. A legal move reduces exactly one heap: choose ii with xi>0x_i>0 and replace xix_i by some xi′<xix_i'<x_i.

Checked definition or construction

NIM positions and legal moves

Lean contains the definition or construction, with checked properties.

Explain this How this is formalised Lean statement and source

4.3 Sprague–Grundy theory and nim-sum

The breadth of impartial games makes the Sprague–Grundy theorem remarkable: every finite terminating impartial position under normal play is equivalent to a single NIM heap of some size, called its nimber or Grundy value. Equivalence here means that replacing the position by that heap preserves the winning or losing status of its sum with any other such game. In a disjunctive sum, a move is made in exactly one component. The nimber of a sum is the bitwise XOR of the component nimbers; in particular, the nimber of a NIM board is the XOR of its heap sizes.

External cited result

Sprague–Grundy theorem; for NIM the Grundy value is the XOR of the heaps

A published result used as background or input; not proved in Lean here.

Explain this How this is formalised

Definition 4.3 (Nim-sum) For heap sizes x1,…,xhx_1,\dots,x_h, define nim⁡(x1,…,xh)  =  x1⊕x2⊕⋯⊕xh,\operatorname{nim}(x_1,\dots,x_h) \;=\; x_1 \oplus x_2 \oplus \cdots \oplus x_h, where ⊕\oplus denotes bitwise XOR.

Checked definition or construction

The nim-sum is the bitwise XOR of the heap sizes

Lean contains the definition or construction, with checked properties.

Explain this How this is formalised Lean statement and source

Theorem 4.4 (Classical NIM characterisation) A NIM position (x1,…,xh)(x_1,\dots,x_h) is losing for the player to move iff nim⁡(x1,…,xh)=0\operatorname{nim}(x_1,\dots,x_h)=0. Moreover, from any winning position (nim-sum ≠0\neq 0) there is a move to a losing position (nim-sum =0=0).

Checked theorem

A NIM position is losing iff its nim-sum is zero; from a nonzero nim-sum there is a move to zero

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

Why NIM is a useful barrier example. For a disjunctive sum of independent impartial components, the Grundy value is the XOR of the component nimbers. If these nimbers can vary independently so that their aggregation contains an unbounded parity subproblem, NIM isolates the resulting aggregation obstruction. Learning NIM would therefore address a fundamental component of impartial-game play, but would not by itself solve self-play learning for the wider class: determining component nimbers can be computationally difficult (Section 8.3). Nor does every impartial game contain a hard parity aggregation task. Our unconditional lower bound concerns NIM; extensions require an explicit encoding and reduction.

Informal interpretation

NIM isolates the XOR aggregation obstruction; extensions to other games need explicit reductions

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

5 Main results: impossibility and possibility

We first establish the single-frame barrier under fixed total latency, then develop three bypasses: recent-history inputs, multiple rollout channels, and persistent row-wise recurrence.

5.1 Mastery notions

We distinguish three notions of mastery:

Definition 5.1 (Strong, weak, and restoration mastery) An agent achieves strong mastery of NIM if it chooses a winning move at every NN-position where it is to move, including positions reached by arbitrary legal play by both players. Reachability is relative to the specified initial positions and player role; unrestricted strong mastery allows every initial position.

It achieves weak mastery relative to an initial position p0p_0 and a designated player role if, whenever that role has a winning strategy from p0p_0, its own strategy wins against every opponent strategy. The guarantee concerns histories consistent with its own preceding actions, not every position reachable under arbitrary actions by both players. For asymptotic claims, the initial positions form a specified family. Strategies may depend on the complete history. Opponent moves are legal; a missing or illegal agent move counts as a loss. On an initially losing position the weak-mastery condition imposes no requirement.

It achieves restoration mastery if, whenever the opponent moves from a PP-position QQ with nim⁡(Q)=0\operatorname{nim}(Q)=0 to a position Q′Q', the agent responds with a move Q′→RQ'\to R such that nim⁡(R)=0\operatorname{nim}(R)=0.

Checked definition or construction

Strong, weak and restoration mastery

Lean contains the definition or construction, with checked properties.

Explain this How this is formalised Lean statement and source

We use standard impartial-game terminology: a PP-position is losing for the player to move, and an NN-position is winning. For NIM, Theorem 4.4 says that PP-positions are exactly the positions with nim-sum 00. Equivalently, weak mastery requires the agent to move to a PP-position at every one of its decision histories consistent with its own earlier actions, starting from an initial position winnable in its designated role. This distinction allows a simple strategy to master a family without solving positions it never encounters under its own play; Appendix D gives examples.

Checked theorem

Weak mastery = moving to a P-position at every decision history consistent with the agent's own play

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

5.2 Single-frame impossibility results

In a single-frame representation, the network sees only the current position. To play optimally, it must in effect determine whether the nim-sum is zero and, if not, find a move producing nim-sum zero. The core obstacle is that global nim-sum computation requires parity-like behaviour across many bits, and parity is not in AC0\AC^0 (Furst et al., 1984; Håstad, 1986; Smolensky, 1987; Razborov, 1987).

Theorem 5.2 (Single-frame parity barrier) Consider the restricted family of NIM positions P(b)=(2,b1,…,bm)P(\mathbf{b})=(2,b_1,\dots,b_m) where bi∈{0,1}b_i\in\{0,1\}. Any single-frame agent that achieves strong mastery must compute the parity b1⊕⋯⊕bmb_1\oplus\cdots\oplus b_m. Since PARITY∉AC0\mathrm{PARITY}\notin \AC^0, no polynomial-size, constant-depth fixed-scale quantised network can strongly master NIM.

(reduction)
Checked theorem

Strong mastery on the boards (2,b₁,…,b_m) forces the winning move to reveal the parity of b

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source
(barrier)
Checked conditional theorem using named classical input

No polynomial-size, constant-depth fixed-scale network family strongly masters NIM

Lean checks the implication from a named, unproved classical hypothesis.

Explain this How this is formalised Lean statement and source

Proof. Since each bi∈{0,1}b_i\in\{0,1\}, these positions have nimber 2⊕(b1⊕⋯⊕bm)2\oplus(b_1\oplus\cdots\oplus b_m), which is either 22 or 33. A winning move must change the first heap: changing any other heap leaves the leading binary digit of the nim-sum unchanged. To obtain nimber zero, the first heap must be reduced to b1⊕⋯⊕bmb_1\oplus\cdots\oplus b_m. Thus the unique winning move removes two tokens when this parity is zero and one when it is one. Encoding each heap in two bits uses only constants and wiring, and the low bit of the replacement heap is the input parity. This gives a constant-depth, polynomial-size reduction to winning-move selection, although every encoded position is winning.

5.3 First bypass: two-frame restoration

The fundamental idea is to avoid computing the global nim-sum from scratch. Instead, we exploit that each move changes only one heap, so the nimber difference between consecutive positions is locally computable.

Definition 5.3 (Nimber difference) Given consecutive positions PP and P′P' in a play sequence, define the nimber difference Δ(P,P′)  =  nim⁡(P) ⊕ nim⁡(P′).\Delta(P,P') \;=\; \operatorname{nim}(P)\ \oplus\ \operatorname{nim}(P').

Checked definition or construction

The nimber difference Δ(P,P') = nim(P) ⊕ nim(P')

Lean contains the definition or construction, with checked properties.

Explain this How this is formalised Lean statement and source

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.

Checked theorem

If one heap changes from x_i to x_i', then Δ = x_i ⊕ x_i'

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

Lemma 5.4 (Bounded-change differences) Fix a constant t∈Nt\in\N. Let PP and P′P' be NIM positions whose heap vectors differ in at most tt heaps. Then Δ(P,P′)\Delta(P,P') can be computed by an AC0\AC^0 circuit of polynomial size (in the input length).

Checked theorem

With at most t changed heaps (t fixed), Δ is computed by polynomial-size constant-depth circuits

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

Proof. See Appendix E.

Membership in AC0\AC^0 does not guarantee a small or readily learnable network. For the complete two-frame move selector built on this difference computation, our modular construction gives an upper bound of 42 threshold layers; one shootout-controller step has a bound of 70 (Appendix C). These are constructive bounds, not necessary depths. Any Boolean function has a depth-two AND–OR representation with negated inputs, but its size can be exponential; AC0\AC^0 requires polynomial size as the input grows. We have not optimised this depth–size trade-off. Removing the expressivity obstruction therefore leaves practical network design, training procedures and hyperparameter choices open. The layer bounds do not establish the cause of the experimental learning plateaus.

Informal interpretation

Explicit layer bounds, depth versus size, and remaining learning difficulties

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

5.3.1 Two-frame local restoration rule

The next observation is that if, after our move, we make the opponent face a zero nim-sum position, then the opponent’s next move produces some nimber difference δ\delta. If we respond with a move that produces the same nimber difference δ\delta, we restore nim-sum zero.

Proposition 5.5 (Local restoration principle) Suppose the opponent moves from a position QQ with nim⁡(Q)=0\operatorname{nim}(Q)=0 to a position Q′Q' (so it is now our turn). Let Δ(Q,Q′)=nim⁡(Q)⊕nim⁡(Q′)\Delta(Q,Q')=\operatorname{nim}(Q)\oplus \operatorname{nim}(Q') denote the nimber difference caused by the opponent’s move. If we respond with a move Q′→RQ' \to R such that Δ(Q′,R)  =  Δ(Q,Q′),\Delta(Q',R) \;=\; \Delta(Q,Q'), then nim⁡(R)=0\operatorname{nim}(R)=0.

Checked theorem

Matching the opponent's nimber difference restores nim-sum zero

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

Proof. By definition, nim⁡(Q′)=nim⁡(Q)⊕Δ(Q,Q′)\operatorname{nim}(Q') = \operatorname{nim}(Q) \oplus \Delta(Q,Q'). Since nim⁡(Q)=0\operatorname{nim}(Q)=0 (by hypothesis), we have nim⁡(Q′)=Δ(Q,Q′)\operatorname{nim}(Q') = \Delta(Q,Q'). The player’s move creates a new position RR with nim⁡(R)=nim⁡(Q′)⊕Δ(Q′,R)\operatorname{nim}(R) = \operatorname{nim}(Q') \oplus \Delta(Q',R). Substituting the condition Δ(Q′,R)=Δ(Q,Q′)\Delta(Q',R) = \Delta(Q,Q'): nim⁡(R)  =  nim⁡(Q′)⊕nim⁡(Q′)  =  0.\operatorname{nim}(R) \;=\; \operatorname{nim}(Q') \oplus \operatorname{nim}(Q') \;=\; 0. Thus, matching the opponent’s difference restores the invariant.

Moreover, a concrete restoration move can be selected in AC0\AC^0 from (Q,Q′)(Q,Q') by computing δ=Δ(Q,Q′)\delta=\Delta(Q,Q') and then choosing (with a fixed tie-break rule) a heap ii such that xi′=xi⊕δ<xix_i' = x_i \oplus \delta < x_i (Appendix C).

Checked theorem

A restoration move can be selected from (Q,Q') by a constant-depth circuit

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source
Three boxes from left to right. Start (Q): heaps {3, 5, 6}, nim-sum = 0 (green). An arrow labelled "Opponent moves 5 to 4, delta = 5 XOR 4 = 1" leads to After Opponent (Q'): heaps {3, 4, 6}, nim-sum = 1 (red). A blue arrow labelled "Agent restores 3 to 2, matches delta = 1 (3 XOR 2 = 1)" leads to Restored (R): heaps {2, 4, 6}, nim-sum = 0 (green).
Figure 2: A worked restoration example (three heaps). Starting from a PP-position QQ (green), the opponent changes heap 2 (5→45\to 4), creating a nimber difference δ=1\delta=1. The agent instantly restores the PP-position by changing heap 1 (3→23\to 2), which imposes the matching difference 3⊕2=13\oplus 2 = 1.
Checked theorem

Worked example: (3,5,6) → (3,4,6) → (2,4,6)

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

Interpretation (“mirror the delta”). Once we have made the opponent face a PP-position, we do not need to recompute nim⁡(⋅)\operatorname{nim}(\cdot) from scratch. We only need to mirror the observed change Δ(Q,Q′)\Delta(Q,Q') in our response move. Figure 2 illustrates this mechanism on a concrete three-heap instance.

Proposition 5.5 is structural: it describes a response pattern that keeps returning the game to nim-sum zero, provided the player can (i) compute δ=Δ(Q,Q′)\delta=\Delta(Q,Q') from the last two frames and (ii) choose a legal move Q′→RQ'\to R that realises the same δ\delta. In NIM, when the opponent changes exactly one heap, δ\delta is simply xi⊕xi′x_i\oplus x_i', and testing whether a candidate response move realises δ\delta is a local check on the heap being changed.

Checked theorem

Testing whether a candidate move realises δ is a local check on the heap being changed

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

The significance for learnability is representational. A two-frame policy network can condition its response on (Q,Q′)(Q,Q') and hence on the locally computable δ\delta, while a single-frame policy must reconstruct the relevant global information from Q′Q' alone. The experiments in Section 7 examine this contrast through supervised restoration learning and imitation-trained rollout policies. The reported networks are policy-only; these results do not establish that self-play discovers the constructions.

Informal interpretation

The significance of two frames for learning is representational

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

5.3.2 Implementation overview

An AC0\AC^0 implementation of the two-frame delta and restoration components can be organised into:

  • a binary encoding scheme for heap vectors (Appendix C),

  • a constant-depth detection of which heaps changed between frames,

  • an AC0\AC^0 circuit computing Δ\Delta on those changed heaps (Lemma 5.4),

  • an AC0\AC^0 selection mechanism for a response move realising a target δ\delta.

Checked definition or construction

The two-frame components: encoding, changed-heap detection, Δ, and a move selector for a target δ

Lean contains the definition or construction, with checked properties.

Explain this How this is formalised Lean statement and source

5.4 Second bypass: structured rollout policies

Theorem 5.2 shows that no AC0\AC^0 circuit can evaluate the nim-sum in a single forward pass. A natural follow-up is whether planning—testing candidate moves and simulating play, as in Monte-Carlo Tree Search (MCTS)—can compensate.

Informal interpretation

Restatement of the single-frame barrier as the motivation for rollouts

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

We analyse a stylised rollout interface: a planning algorithm queries a rollout policy π\pi by simulating a complete game in which both players follow π\pi from a start position, and it observes only the terminal win/loss bit. This abstraction isolates the information that a weak policy can expose through repeated simulation; it is not a claim about the optimisation dynamics of AlphaZero-style training (cf. Section 1.2).

Definition 5.6 (Rollout policy and rollout outcome) A deterministic rollout policy maps a nonterminal NBNB-bit NIM position to a legal move, encoded by a heap index and its new value; on the terminal position it outputs a halt symbol. It is AC0\AC^0-bounded when this map has polynomial-size, constant-depth circuits. A rollout has both players follow that policy until termination. Its outcome ROπ(P)\mathrm{RO}_{\pi}(P) is 1 if the first player wins and 0 otherwise, including at a terminal start. The interface returns only this terminal bit, not a trajectory or move count.

Checked definition or construction

Deterministic rollout policies and the rollout outcome bit

Lean contains the definition or construction, with checked properties.

Explain this How this is formalised Lean statement and source

Definition 5.7 (Restricted rollout measurements and readout) Fix a root position PP. An admissible query starts at PP or a position obtained by changing one heap of PP; the changed index and old/new values are known to the readout. A legal one-move successor is an admissible query. Arbitrary transformations of the whole root are excluded. For the single-channel lower bound, one fixes a policy πj\pi_j from Proposition 5.9, independently of PP. Writing β=ROπj(P)\beta=\mathrm{RO}_{\pi_j}(P), the agent’s final move must have the form FN(P,β)F_N(P,\beta), where FNF_N is a polynomial-size, constant-depth Boolean circuit family. Any value head, query corrections or other processing must be included in this readout bound. The number of queries alone does not impose that bound. A multi-channel construction may query distinct members of the same structured policy family and apply a polynomial-size, constant-depth readout to PP and their outcome bits. A policy head means a rollout policy, not simply a parallel output neuron. We count simulated game moves separately from the circuit work per move.

Checked definition or construction

The restricted measurement interface: root and one-heap queries to one fixed structured head, bounded readout

Lean contains the definition or construction, with checked properties.

Explain this How this is formalised Lean statement and source

Allowing arbitrary start positions would defeat the single-channel restriction: querying π0\pi_0 on heaps consisting of the kkth bits of PP returns σk(P)\sigma_k(P). Likewise, an unrestricted sequential controller could compute the nim-sum itself. The lower bound therefore concerns the stated measurement/readout model, not general MCTS or all single-policy algorithms.

Checked theorem

With arbitrary start positions, one rollout of π₀ on the boards of k-th bits returns σ_k(P)

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

Remark 5.8 (Why multiple heads are not redundant) Since AC0\AC^0 is closed under parallel composition, one could compute all kk policies simultaneously as a single AC0\AC^0 circuit. The distinction is not about computational power at the circuit level but about the rollout interface: each rollout query simulates a complete game under one policy, and at each game step only that policy determines the next move. A single rollout trajectory under a fixed policy π\pi produces one outcome bit; merging kk circuits into a single circuit does not change the fact that any one rollout follows a single deterministic rule, yielding a single bit of information. Multiple heads are useful because the agent can issue separate rollout queries under different policies πj\pi_j, producing different game trajectories that reveal independent linear functionals of the nim-sum (cf. Propositions 5.9 and 5.10).

Checked theorem

Each rollout follows one policy and yields one bit; different heads give independent linear functionals

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

Finite-state shootout controller (FSM over policy heads). The multi-channel classifier can stop early after a nonzero channel outcome, without changing its Boolean decision rule (the OR of all channel bits). This limited scheduling optimisation does not give the single-channel readout an unrestricted sequential controller. To make this adaptivity explicit (without changing the AC0\AC^0 constraints on each head), it is convenient to view head-selection as a small finite-state controller that sits outside the heads and only sees the terminal win/loss bit of each rollout.

Checked theorem

Early stopping after a nonzero outcome leaves the decision (the OR of all channel bits) unchanged

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

Formally, fix rollout heads π0,…,πk−1\pi_0,\dots,\pi_{k-1}. A finite-state shootout controller is a tuple C=(S,sinit,g,δ,halt),\mathcal{C} = (\mathcal{S}, s_{\mathrm{init}}, g, \delta, \mathsf{halt}), where S\mathcal{S} is a finite set of controller states, sinit∈Ss_{\mathrm{init}}\in\mathcal{S} is the initial state, g ⁣:S→{0,…,k−1}g\colon \mathcal{S}\to\{0,\dots,k-1\} selects which head to use for the next rollout query, δ ⁣:S×{0,1}→S\delta\colon \mathcal{S}\times\{0,1\}\to\mathcal{S} updates the controller state after observing a rollout outcome bit r=ROπg(s)(P)r=\mathrm{RO}_{\pi_{g(s)}}(P), and halt⊆S\mathsf{halt}\subseteq \mathcal{S} is a set of halting states associated with an output decision. (When halt=∅\mathsf{halt}=\emptyset, the controller simply runs for a fixed number of queries and outputs a decision at the end.)

Checked definition or construction

A finite-state shootout controller: states, head selection, transitions, halting states

Lean contains the definition or construction, with checked properties.

Explain this How this is formalised Lean statement and source

This viewpoint does not increase the per-step computational power of the rollout heads: each πj\pi_j remains AC0\AC^0-bounded. Instead, the controller organises which AC0\AC^0 head is iterated in a shootout and when to stop querying. Figure 3 depicts a particularly simple controller that turns the BB structured rollout heads from Proposition 5.9 into a sequential “bit-query” procedure for deciding whether σ(P)=nim⁡(P)\sigma(P)=\operatorname{nim}(P) is zero (and hence whether PP is a PP-position).

Informal interpretation

The controller organises which head is queried and when to stop; it adds no per-step power

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

The checked implementation includes the outer controller: it selects a head, executes its rollout, records the outcome and either reloads the original board for the next head or halts. For classification it stops at the first outcome 1. For move selection our implementation runs all BB heads, since an early classification decision need not supply the invariant bits required by the move readout. Each controller tick is itself an AC0\AC^0 map. The original board remains available as a read-only input throughout; it is not an oracle for its nim-sum. Appendix C specifies the storage and update costs.

Checked theorem

The implemented outer controller: early-exit classifier and all-head schedule for move selection

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source
A row of controller states q_0 (use pi_0), q_1 (use pi_1), dots, q_{B-1} (use pi_{B-1}), linked left to right by arrows labelled r_0 = 0, r_1 = 0 and r_j = 0. From each state an arrow labelled r_j = 1 (a dashed arrow "there exists j with r_j = 1" from the dots) leads to the halting box "sigma(P) is not 0 (declare N)" above. From q_{B-1} an arrow labelled r_{B-1} = 0 leads to the halting box "sigma(P) = 0 (declare P)" below.
Figure 3: A simple finite-state shootout controller for deciding whether σ(P)=nim⁡(P)\sigma(P)=\operatorname{nim}(P) is zero using the BB rollout heads of Proposition 5.9. The controller queries heads sequentially and halts as soon as it can certify σ(P)≠0\sigma(P)\neq 0. Reaching the final transition to σ(P)=0\sigma(P)=0 implicitly means r0=⋯=rB−1=0r_0=\cdots=r_{B-1}=0.
Checked theorem

The depicted controller decides whether σ(P) ≠ 0 using at most B queries

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

Integration (channels vs. protocol). It is helpful to reinterpret Part (ii) of Theorem 5.12 in an “information-channel” language: each policy head πj\pi_j defines a distinct rollout measurement channel which, when iterated to termination, returns a single bit rj=ROπj(P)r_j=\mathrm{RO}_{\pi_j}(P) that depends on the hidden BB-bit invariant σ(P)\sigma(P) (cf. the identities in Proposition 5.9). With a single head, repeated deterministic root rollouts return the same linear functional ℓ(σ)\ell(\sigma); admissible one-heap modifications give its known affine corrections (Proposition 5.10). These measurements supply no further unknown invariant bit. With multiple heads, the agent has access to linearly independent invariant measurements and can reconstruct σ(P)\sigma(P) from their outcomes (Proposition 5.9). The finite-state shootout controller introduced above is the natural generalisation of this idea: it does not change what any head can compute, but organises the heads into an adaptive querying protocol—the controller decides which channel to query next (and when to stop, or when to re-query for robustness) based on previously observed rollout outcomes. In this view, multi-head provides the channels, while the FSM provides the sequential control that turns those channels into a practical evaluation procedure.

Informal interpretation

Channels versus protocol: heads supply measurement channels, the FSM sequential control

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

Depth amplification. Although a single AC0\AC^0 circuit cannot compute parity, iterating an AC0\AC^0 policy for LL game steps yields an effective depth Θ(L)\Theta(L) computation, which can reveal parity information. The next proposition makes this explicit by exhibiting BB simple AC0\AC^0 rollout heads whose outcomes recover all BB bits of the nim-sum.

Informal interpretation

Iterating an AC0 policy for L game steps gives a depth-Θ(L) computation

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

Proposition 5.9 (Structured rollout sufficiency) The BB structured rollout policies below, followed by an AC0\AC^0 move selector, achieve strong mastery of NIM on NN heaps of bit-width BB. They use BB root rollouts and O(BN2B)O(BN2^B) simulated game moves per decision. Each policy update and the final readout have polynomial circuit size in NBNB. For B=O(log⁡N)B=O(\log N) the resulting bit work is polynomial in NN.

Checked theorem

B structured rollout heads recover all nim-sum bits; an AC0 readout then plays a winning move

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

Proof outline. For each j∈{0,…,B−1}j\in\{0,\dots,B-1\} define a deterministic rollout policy πj\pi_j that repeatedly subtracts 2j2^j from the leftmost heap of size at least 2j2^j (and otherwise subtracts 11 from the leftmost nonzero heap). Both simulated players follow this policy; the actual opponent may choose any legal move. A rollout under πj\pi_j has a well-defined total number of moves whose parity is ROπ0(P)=σ0,ROπj(P)=σj⊕σ0(j≥1),\mathrm{RO}_{\pi_0}(P)=\sigma_0,\qquad \mathrm{RO}_{\pi_j}(P)=\sigma_j\oplus\sigma_0\quad(j\ge 1), where σ=nim⁡(P)\sigma=\operatorname{nim}(P) and σj\sigma_j denotes its jjth bit. The search controller first queries π0\pi_0 to obtain σ0\sigma_0, then queries each πj\pi_j (j≥1j\ge 1) to obtain σj⊕σ0\sigma_j\oplus\sigma_0, and recovers σj=(σj⊕σ0)⊕σ0\sigma_j = (\sigma_j\oplus\sigma_0)\oplus\sigma_0; thus BB rollouts under BB distinct heads recover all BB bits of σ\sigma. Given σ≠0\sigma\ne0, select the first heap hih_i with hi⊕σ<hih_i\oplus\sigma<h_i and reduce it to hi⊕σh_i\oplus\sigma. If σ=0\sigma=0, take any legal move, or halt at the terminal position. No successor enumeration is needed. A complete proof is in Appendix G.

A single policy head yields only one bit. The preceding result relies on having multiple rollout channels. For one fixed member of this structured policy family, admissible queries reveal known affine functions of the same invariant bit. This statement does not concern arbitrary rollout policies.

Proposition 5.10 (Single-policy information bound) Fix jj and the rollout policy πj\pi_j from the proof outline of Proposition 5.9. For any position PP, the rollout outcome ROπj(P)\mathrm{RO}_{\pi_j}(P) is a fixed linear functional ℓj(σ(P))\ell_j(\sigma(P)) of the nim-sum bits (indeed, ℓ0(σ)=σ0\ell_0(\sigma)=\sigma_0 and ℓj(σ)=σj⊕σ0\ell_j(\sigma)=\sigma_j\oplus\sigma_0 for j≥1j\ge 1). Moreover, if PiP_i is obtained from PP by modifying one heap (as when evaluating candidate moves), then ROπj(Pi)=ℓj(σ(P))⊕ci,\mathrm{RO}_{\pi_j}(P_i)=\ell_j(\sigma(P))\oplus c_i, where the correction bit cic_i is computable from the known heap values and the chosen modification. Hence root and one-heap-modification queries to this fixed head reveal only known affine functions of ℓj(σ(P))\ell_j(\sigma(P)).

Checked theorem

One fixed structured head reveals only known affine functions of one linear functional of σ(P)

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

Proof. The linearity claim follows from the explicit formulas above. If PiP_i differs from PP by changing one heap from hh to h′h', then σ(Pi)=σ(P)⊕(h⊕h′)\sigma(P_i)=\sigma(P)\oplus(h\oplus h') and ℓj(σ(Pi))=ℓj(σ(P))⊕ℓj(h⊕h′)\ell_j(\sigma(P_i))=\ell_j(\sigma(P))\oplus \ell_j(h\oplus h'), where ℓj(h⊕h′)\ell_j(h\oplus h') is known from the candidate move.

Remark 5.11 (An illustrative independent outcome-flip model) Suppose an ideal terminal bit YY is corrupted as Y~=Y⊕E1⊕⋯⊕EL\widetilde Y=Y\oplus E_1\oplus\cdots\oplus E_L, where the EiE_i are independent Bernoulli variables of parameter 0≤ε<1/20\le\varepsilon<1/2. Then Pr⁡[Y~=Y]=1+(1−2ε)L2.\Pr[\widetilde Y=Y]=\frac{1+(1-2\varepsilon)^L}{2}. The formula follows by multiplying the expectations of (−1)Ei(-1)^{E_i}. With fresh independent flips for each repetition, the least number of observations needed to distinguish the two possible ideal bits with worst-case error at most 1/41/4 grows as a−2a^{-2}, where a=(1−2ε)La=(1-2\varepsilon)^L. Appendix F states and proves explicit bounds over real parameters. Repeating one corrupted observation with the same randomness supplies no additional information. At ε=0.01\varepsilon=0.01 and L=50L=50, agreement is approximately 0.6820.682, so this example is not yet close to a fair coin. This is a channel-noise illustration, not a theorem about erroneous game moves: a move error need not flip the terminal bit, and can change later states and rollout length. Correlated flips can cancel in pairs, eliminating the claimed decay. Exact structured rollouts have no such noise.

Checked theorem

Independent outcome flips: agreement (1+(1−2ε)^L)/2 and Θ(a⁻²) repetitions with fresh randomness

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

The initialisation boundary for restoration. Matching two successive differences yields nim⁡(R)=nim⁡(Q)\operatorname{nim}(R)=\operatorname{nim}(Q), whether or not that value is zero. Thus Proposition 5.5 does not supply a classifier for an arbitrary starting position. For example, complete a matching-delta policy by subtracting one from the first nonempty heap whenever no matching response exists or no previous frame is available. Starting from (2)(2), it plays (2)→(1)→(0)(2)\to(1)\to(0) and the first player loses, although (2)(2) is winning. The fallback after the first move is needed because its delta is 2⊕1=32\oplus1=3, which cannot be realised from (1)(1). This counterexample does not rule out every possible verifier construction; it shows that conditional restoration and an unspecified fallback do not establish one. We make no universal-verifier claim. Initial winning-move selection can instead use the multi-channel construction above or the growing recurrent scan in Section 5.5.

Checked theorem

Matching deltas preserves nim(Q); a completed matching-delta policy loses from the winning position (2)

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source
ResourceWhat stays in AC0\AC^0Additional information or time
One structured channelPolicy step and final readoutOne complete rollout; one invariant bit
BB structured channelsEach policy step; reconstruction and move selectionBB complete rollouts supply all invariant bits
Two-frame transitionLocal difference and binary move selectionPrevious zero-nim-sum board and a legal transition
Persistent row scanOne state update and its output bitsTwo scans per decision; O(B+log⁡N)O(B+\log N) state bits
Figure 4: The three bypasses use different resources. Conditional restoration does not classify arbitrary starting positions; the rollout and recurrent constructions supply additional sequential computation.
Informal interpretation

Resource table for the three bypasses

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

Theorem 5.12 (Restricted bound and bypasses) The following statements hold under Definition 5.7.

  1. (i) For each fixed B≥2B\ge2, let PP be uniform on {0,…,2B−1}N\{0,\ldots,2^B-1\}^N conditional on σ(P)≠0\sigma(P)\ne0. For one fixed structured head πj\pi_j and an AC0\AC^0 readout FN(P,ROπj(P))F_N(P,\mathrm{RO}_{\pi_j}(P)), winning-move success is at most 22B−1+negl⁡(N).\frac{2}{2^B-1}+\operatorname{negl}(N). Here N≥1N\ge1, and a negligible error is a nonnegative sequence smaller than every inverse polynomial for sufficiently large NN, with circuit depth, polynomial size exponent and BB fixed. More precisely, a uniform parity-correlation bound ηN\eta_N for the fixed-bit readout indicators gives the finite upper bound 2/(2B−1)+(2B−1)ηN2/(2^B-1)+(2^B-1)\eta_N; the indicators and correlation premise are specified in Appendix H. The leading constant is asymptotically attainable by guessing one nonzero nim-sum in each channel fibre.

  2. (ii) For any BB, the BB structured heads and an AC0\AC^0 readout select an optimal move using O(BN2B)O(BN2^B) rollout steps, as in Proposition 5.9.

  3. (iii) Given a legal transition from a known zero-nim-sum predecessor, a two-frame AC0\AC^0 selector restores zero. Once a player has established that invariant, it maintains it against every legal opponent response. This statement does not supply the initial winning move from an arbitrary position.

(i)
Checked conditional theorem using named classical input

One structured head plus an AC0 readout wins with probability at most 2/(2^B−1)+negl(N)

Lean checks the implication from a named, unproved classical hypothesis.

Explain this How this is formalised Lean statement and source
(ii)
Checked theorem

B structured heads and an AC0 readout select an optimal move with O(BN2^B) rollout steps

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source
(iii)
Checked theorem

From a known zero-nim-sum predecessor a two-frame AC0 selector restores zero and maintains it

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

Proof outline. For part (i), fixing the observed bit leaves an AC0\AC^0 move selector. The selected heap’s old and new values determine a proposed nim-sum. Expanding each exact nim-sum event into its finitely many parity characters and applying the AC0\AC^0 parity-correlation bound gives the displayed estimate; Appendix H gives the full reduction and conditional-probability calculation. Parts (ii) and (iii) follow from Propositions 5.9 and 5.5, with the selector described in Appendix C.

5.5 Third bypass: persistent row-wise recurrence

The two-frame construction supplies the relevant history explicitly, while the multi-head construction obtains additional information through complete rollouts. A third possibility is to let the agent build and retain its own state by processing the board sequentially. The recurrent update remains simple, but the number of updates is allowed to grow with the input. The construction uses the elementary running-XOR algorithm. In correspondence reproduced by Friedman (Friedman, 2017b), John Schulman proposed feeding NIM heaps one at a time to a recurrent network and reported preliminary supervised nim-sum experiments. Here we make the shallow updates, separator and state protocols, and move-selection constructions explicit, distinguishing their representational guarantees from learning through self-play.

Serialising positions and retaining state. Write position Pt=(xt,1,…,xt,N)P_t=(x_{t,1},\ldots,x_{t,N}), with each heap represented by one BB-bit row. Feed successive positions as the stream x1,1,…,x1,N⏟P1, SEP,x2,1,…,x2,N⏟P2, SEP,….\underbrace{x_{1,1},\ldots,x_{1,N}}_{P_1},\ \mathtt{SEP},\quad \underbrace{x_{2,1},\ldots,x_{2,N}}_{P_2},\ \mathtt{SEP},\quad\ldots . Each row arrives as a block of BB bits together with a row/separator tag. A separator marks the end of a complete position; the agent chooses a move only after that position has been read. The next observed position is then appended to the stream. For comparisons of individual heaps, indices remain aligned across positions, including rows for empty heaps. A scan of the current board suffices for nim-sum evaluation without earlier game positions; cross-position memory additionally supports the comparisons below. The hidden state is carried across rows and position boundaries. A separator resets the accumulator for the next scan while preserving selected information about the completed position; it does not reset the entire memory.

Checked definition or construction

Serialisation: rows of each position, a separator, aligned indices; the separator resets only the accumulator

Lean contains the definition or construction, with checked properties.

Explain this How this is formalised Lean statement and source

Proposition 5.13 (Sequential nim-sum accumulation) There is a recurrent Boolean update of constant depth and size O(B)O(B), implementable with fixed-scale quantised threshold gates, that computes the nim-sum of an NN-heap position after NN row updates. With O(B)O(B) state bits, it can also retain the previous completed nim-sum and report the XOR difference between consecutive completed positions.

Checked theorem

A constant-depth recurrent update computes the nim-sum after N row updates and reports consecutive differences

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

Proof. Initialise a BB-bit accumulator to zero and update it by st,0=0,st,i=st,i−1⊕xt,i(1≤i≤N).s_{t,0}=0,\qquad s_{t,i}=s_{t,i-1}\oplus x_{t,i}\quad (1\le i\le N). Induction on ii gives st,i=⨁j=1ixt,js_{t,i}=\bigoplus_{j=1}^{i}x_{t,j}, so the final accumulator is σt:=nim⁡(Pt)\sigma_t:=\operatorname{nim}(P_t). Each output bit of an update is the XOR of two bits, which has a constant-size, constant-depth AND/OR/NOT implementation. These gates can be realised with fixed-scale threshold gates and input negations, with constants independent of NN and BB. The summary state is (s,q,v)(s,q,v): two BB-bit registers and one validity bit, initialised to (0,0,0)(0,0,0). A row xx updates it to (s⊕x,q,v)(s\oplus x,q,v). At a separator, output ss and, when v=1v=1, the difference q⊕sq\oplus s; then update the state to (0,s,1)(0,s,1). The first separator therefore produces a summary but no previous-position difference. Induction over completed positions shows that qq stores exactly the preceding summary and ss is the XOR of the rows since the last separator. The summary mechanism uses 2B+12B+1 state bits; a reset between games restores (0,0,0)(0,0,0). All assignments have constant depth and size O(B)O(B).

From a summary to a move. Computing σt\sigma_t does not by itself retain the heap rows needed to choose a move. One implementation replays the current position after the first scan. If σt≠0\sigma_t\ne0, select the first row ii for which xt,i′=xt,i⊕σt<xt,i.x_{t,i}'=x_{t,i}\oplus\sigma_t<x_{t,i}. Such a row exists: choose a heap containing the highest set bit of σt\sigma_t. Replacing that heap by xt,i′x_{t,i}' leaves nim-sum zero. XOR, binary comparison and conditional selection are constant-depth operations; the replay uses O(B+log⁡N)O(B+\log N) state bits to retain the summary, a selected move and its row index. The explicit protocol is rows(Pt), SEP, rows(Pt), SEP.\mathtt{rows}(P_t),\ \mathtt{SEP},\ \mathtt{rows}(P_t),\ \mathtt{SEP}. The first separator stores the summary and switches to replay; the second emits the move and returns to scan mode. This takes exactly 2N+22N+2 updates, with one additional reset token at the start of a game. If σt=0\sigma_t=0, choose the first nonempty heap and decrement it, or report termination when all heaps are empty. Lean verifies the complete replay controller, including its binary move output and its fixed-scale threshold implementation. With an rr-bit counter satisfying N<2rN<2^r, its state uses 4+5B+3r4+5B+3r bits. The strict inequality allows the counter to hold the end value NN, whereas an output index alone only needs N≤2rN\le2^r. Alternatively, store the current board in O(NB)O(NB) bits during the initial scan and use a constant-depth selector at the separator, as in Appendix C. This avoids replay at the cost of board-sized memory. The distinction matters for a stream in which each position is supplied only once. Both variants have checked bit-level circuits, fixed-scale network implementations and winning-play guarantees. The board-storage variant uses NB+B+rNB+B+r state bits and N+1N+1 updates per decision, with N<2rN<2^r, plus a reset update when initialising the controller.

Checked theorem

Replay protocol rows,SEP,rows,SEP: 2N+2 updates, 4+5B+3r state bits, a legal winning move

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source
Checked theorem

Board-storage variant: NB+B+r state bits, N+1 updates per decision, plus a reset

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

Connecting recurrence to the history bypass. The retained summaries allow the agent to compare consecutive positions through σt−1⊕σt=nim⁡(Pt−1)⊕nim⁡(Pt)=Δ(Pt−1,Pt).\sigma_{t-1}\oplus\sigma_t =\operatorname{nim}(P_{t-1})\oplus\operatorname{nim}(P_t) =\Delta(P_{t-1},P_t). When one heap changes from aa to bb, this equals a⊕ba\oplus b. If the preceding position has nim-sum zero, the difference is exactly the invariant that the restoration rule must cancel. Storing the preceding board additionally permits direct row-by-row comparison as the new board arrives. A summary of O(B)O(B) bits preserves the invariant, rather than the full game history; arbitrary access to old positions requires additional storage or replay. The difference always refers to consecutive completed boards actually supplied to the controller. If these are only the boards at the player’s decision times, they usually span two game moves. Comparing just the opponent’s move instead requires the player’s own post-move board as the preceding frame. The initial scan also computes the invariant from an arbitrary starting position, without assuming an earlier zero-nim-sum frame. Thus memory across row updates is sufficient for this route; an earlier game position is useful for transition comparisons but is not required to compute the current nim-sum. This initialisation uses the growing recurrent horizon and is therefore an additional resource beyond the fixed-latency two-frame construction.

Checked theorem

Retained summaries give Δ of consecutive supplied boards; with decision-time boards only it spans two moves

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

Why the lower bound is respected. Unrolling NN constant-depth updates gives a computation of depth O(N)O(N), so Proposition 5.13 lies outside the fixed-TT premise of Theorem 2.4. A one-step recurrent dependency can nevertheless carry information accumulated over the whole stream. Merely appending positions and separators to a fixed-depth input does not supply this growing computation horizon. The bypass comes from sequential computation with retained state, not from the delimiter itself. For growing heap bit-width, the accumulator also needs O(B)O(B) bits; a fixed-width hidden state is not claimed to store arbitrary-size invariants or histories. The construction establishes representational sufficiency for NIM, but does not establish that training a recurrent network will discover the update or preserve it reliably over long games. We do not report recurrent training experiments here.

Checked conditional theorem using named classical input

N sequential updates have depth O(N): outside Theorem 2.4; the complete recurrent map is not AC0

Lean checks the implication from a named, unproved classical hypothesis.

Explain this How this is formalised Lean statement and source

5.6 What the three bypasses establish

Proposition 5.14 (Shallow components and complete strategies) For N≥1N\ge1 heaps of B≥1B\ge1 bits, the following constructions use polynomial-size, constant-depth Boolean components, realisable by literal-threshold networks with weights and thresholds in {0,1}\{0,1\}.

  1. (i) The two-frame selector maps a legal transition Q→Q′Q\to Q' from nim⁡(Q)=0\operatorname{nim}(Q)=0 to a legal binary-encoded response restoring zero. Retaining the response board as the next predecessor gives a winning strategy from this established invariant, with the opponent to move.

  2. (ii) Each structured rollout policy and the readout from the board and its BB outcome bits are shallow. Executing the rollouts and then the readout gives a winning strategy from any nonzero nim-sum board, using at most BN(2B−1)BN(2^B-1) simulated game moves per decision.

  3. (iii) The recurrent state update is shallow. Iterating it over the replay protocol gives a winning strategy from any nonzero nim-sum board, with O(B+log⁡N)O(B+\log N) memory and 2N+22N+2 updates per decision.

Here “winning strategy” quantifies over every legal opponent response. Polynomial size and constant depth refer to the indicated component, with depth independent of NN and BB; they do not bound the number of sequential component evaluations.

Checked theorem

Each bypass: shallow {0,1}-weight components and a complete strategy winning against every legal opponent

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source
(open item)
Open or deferred item

Bridge from the recurrent strategies' game semantics to the general weak-mastery history model

Explicitly left open, deferred or not yet connected.

Explain this How this is formalised

Proof outline. Appendix C gives explicit candidate tests, first-index encoding and a fixed-scale implementation. The two-frame circuit computes the changed heap’s XOR difference, which equals the current nim-sum under the stated promise. The multi-head readout reconstructs that same invariant from the executed rollout outcomes. The recurrent controller obtains it by accumulation and uses the stored result during replay. In each case the selected move restores zero; every legal opponent move makes the nim-sum nonzero, and every move decreases the total number of stones. This proves termination and the winning guarantee. For the two-frame strategy, the newly restored board is precisely the frame retained for the next response. For recurrence, the finite controller state persists between decisions. The rollout and recurrent step bounds are those proved above.

These are three ways around the same restricted inference problem, not three shallow algorithms for unrestricted parity. The two-frame construction changes the input and imposes a promise. The other constructions allow processing time to grow. Their complete board-to-winning-move maps cannot themselves form an AC0\AC^0 family: otherwise applying either to (2,b1,…,bm)(2,b_1,\ldots,b_m) would contradict Theorem 5.2. Parallel output heads alone do not supply the rollout computation, and separators alone do not supply a recurrent scan. Appendix C illustrates the explicit network constructions and explains their conservative depth and layer bounds.

Checked conditional theorem using named classical input

The complete multi-head and recurrent board-to-move maps are not AC0 families

Lean checks the implication from a named, unproved classical hypothesis.

Explain this How this is formalised Lean statement and source

6 Learning impartial games with neural networks

The results above are primarily representational: they identify what information a bounded-depth, fixed-scale quantised model can or cannot compute from its input, and how history, multiple rollout heads, or a growing recurrent horizon can supply the missing information. This section connects the theory to the training protocols used in Section 7 and highlights the main modelling choice (AC0\AC^0 vs. TC0\TC^0).

6.1 Practical takeaways

  • Single-frame is brittle to parity. In the worst case, fixed-scale quantised bounded-depth inference cannot reliably represent the nim-sum or a winning move selector (Section 5.2).

  • Three bypasses with different resources. A two-frame input exposes the transition signal Δ(P,P′)\Delta(P,P') and supports restoration (Section 5.3.1); multiple rollout heads recover the missing nim-sum bits through depth amplification (Section 5.4); persistent recurrence accumulates the invariant over sequential row updates and retains summaries across positions (Section 5.5). The last route trades fixed total latency for a growing processing horizon.

  • Optimisation remains nontrivial. Even when a solution is expressible in AC0\AC^0, discovering it from sparse win/loss rewards can be difficult; our experiments therefore isolate a dense restoration supervision signal and separately report rollout-based classification.

Informal interpretation

Practical takeaways: single-frame brittleness, three bypasses, optimisation still hard

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

6.2 Teacher-guided data as a controlled source of transitions

Let πopt\pi_{\mathrm{opt}} denote an optimal NIM policy (move to nim-sum 00 whenever possible). For a noise parameter ε∈[0,1]\varepsilon\in[0,1], define a noisy teacher πTε\pi_T^{\varepsilon} that plays according to πopt\pi_{\mathrm{opt}} with probability 1−ε1-\varepsilon and otherwise chooses a uniformly random legal move. Occasional random moves broaden state coverage and, crucially for two-frame agents, generate diverse transition pairs (Q,Q′)(Q,Q') from which the local difference signal Δ(Q,Q′)\Delta(Q,Q') can be inferred.

Informal interpretation

A noisy teacher plays optimally with probability 1−ε and otherwise uniformly at random

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

6.3 Approximate majority, parity, and the AC0\AC^0 abstraction

One might object that modern networks can implement majority-like decisions, suggesting TC0\TC^0 (threshold circuits) as the “right” complexity class. Indeed, if one allows scale-adaptive thresholds/biases or fan-in dependent re-scaling, constant-depth threshold models can represent parity-type computations.

External cited result

Scale-adaptive threshold models (TC0) can represent parity

A published result used as background or input; not proved in Lean here.

Explain this How this is formalised

Our focus is a restricted literal-threshold regime: fixed total depth, nonnegative weights on Boolean literals, and thresholds bounded in units of the smallest nonzero weight. In this regime, each gate has a constant-size witness and collapses to a constant-width DNF, yielding an AC0\AC^0 abstraction (Theorem 2.4). Constant-depth AC0\AC^0 circuits can implement approximate counting (Ajtai, 1993), yet they have exponentially small correlation with parity (Furst et al., 1984; Håstad, 1986; Smolensky, 1987; Razborov, 1987). Learning parity depends on the architecture and training setting; both difficulties and positive results have been studied (Thornton, 1996b,a; Daniely and Malach, 2020). The representational lower bound here applies only to the explicit gate model. Section 6.4 gives a complementary Fourier/spectral interpretation of this local-versus-global parity separation.

External cited result

In the restricted regime gates collapse to AC0; AC0 approximates counting but has tiny parity correlation

A published result used as background or input; not proved in Lean here.

Explain this How this is formalised

6.4 A spectral viewpoint: low-degree Fourier mass vs. parity

A useful complementary lens is Fourier analysis on the Boolean hypercube. Let f:{0,1}n→Rf:\bits^{n}\to\mathbb{R} and define the Walsh–Hadamard characters χS(x)  =  (−1)∑i∈Sxi,S⊆[n].\chi_S(x) \;=\; (-1)^{\sum_{i\in S} x_i}, \qquad S\subseteq[n]. The set {χS}S⊆[n]\{\chi_S\}_{S\subseteq[n]} is an orthonormal basis with respect to the uniform distribution on {0,1}n\bits^n. The Fourier coefficients are f^(S)  =  Ex∼U({0,1}n)[f(x)χS(x)],andf(x)=∑S⊆[n]f^(S)χS(x).\hat f(S)\;=\;\mathbb{E}_{x\sim U(\bits^n)}\bigl[f(x)\chi_S(x)\bigr], \qquad\text{and}\qquad f(x)=\sum_{S\subseteq[n]}\hat f(S)\chi_S(x). We refer to ∣S∣|S| as the Fourier degree (or “frequency”) of the coefficient f^(S)\hat f(S).

Checked theorem

Walsh–Hadamard characters are orthonormal; every f equals its Fourier expansion

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

Definition 6.1 (Fourier tail / spectral bandwidth) For k∈Nk\in\N, define the degree->k>k Fourier tail Tail>k(f)  =  ∑S⊆[n]: ∣S∣>kf^(S)2.\mathrm{Tail}_{>k}(f)\;=\;\sum_{S\subseteq[n]:\,|S|>k}\hat f(S)^2. For ε≥0\varepsilon\ge0, we say ff is (k,ε)(k,\varepsilon)-spectrally band-limited if Tail>k(f)≤ε\mathrm{Tail}_{>k}(f)\le \varepsilon.

Checked definition or construction

The degree->k Fourier tail and (k,ε)-spectral band-limitation

Lean contains the definition or construction, with checked properties.

Explain this How this is formalised Lean statement and source

Parity is a pure high-frequency character. For any nonempty S⊆[n]S\subseteq[n], the parity function PARITYS(x)=χS(x)\mathrm{PARITY}_S(x)=\chi_S(x) has Fourier expansion supported on a single set: PARITYS^(S)=1\widehat{\mathrm{PARITY}_S}(S)=1 and PARITYS^(T)=0\widehat{\mathrm{PARITY}_S}(T)=0 for T≠ST\neq S. Thus its spectral “frequency” is exactly ∣S∣|S|. More generally, if ff is (k,ε)(k,\varepsilon)-spectrally band-limited and ∣S∣>k|S|>k, then ∣E[f(x)χS(x)]∣2=f^(S)2≤Tail>k(f)≤ε.\bigl|\mathbb{E}[f(x)\chi_S(x)]\bigr|^2=\hat f(S)^2\le\mathrm{Tail}_{>k}(f)\le\varepsilon.(6.1) This elementary inequality is the link between concentration at low degree and small correlation with a high-degree parity.

Checked theorem

Parity is a single character; a (k,ε)-band-limited f has squared correlation ≤ ε with χ_S for |S|>k

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

AC0\AC^0 has little high-frequency mass. A seminal theorem of Linial–Mansour–Nisan shows that AC0\AC^0 functions have almost all Fourier mass on low degrees: for ff computed by an ACd0\AC^0_d circuit of size MM, the tail above degree kk decays rapidly with kk (see (Linial et al., 1993), and sharper bounds in (Tal, 2015)). For fixed depth and polynomial size, correlation with full parity under the uniform distribution is negligible in nn. Applying this statement to other subsets requires specifying their size relative to circuit depth and size, and it does not automatically apply under a nonuniform training distribution.

External cited result

Linial–Mansour–Nisan and Tal: AC0 functions have little Fourier mass above low degree

A published result used as background or input; not proved in Lean here.

Explain this How this is formalised

Local vs. global parity in NIM. In our encoding, the jjth bit of the nim-sum is the parity of the jjth bits across all NN heaps, hence a degree-NN character. Conditional on a specified changed heap ii, the sign encoding of the jjth delta bit is the two-coordinate character (−1)xi,j+xi,j′(-1)^{x_{i,j}+x'_{i,j}}. When the changed index is unknown, the delta bit is specified on pairs of boards differing in at most one heap. A shallow extension to all pairs is dj(P,P′)=⋁i=1N(xi,j⊕xi,j′).d_j(P,P')=\bigvee_{i=1}^{N}(x_{i,j}\oplus x'_{i,j}).(6.2) On the promised domain this is the required delta bit. For N≥2N\ge2, its sign encoding (−1)dj(-1)^{d_j} is not a single character, even up to sign; for N=1N=1 it is exactly a degree-two character. Thus local computability does not mean that the full unknown-index map has degree two. It follows from the explicit AC0\AC^0 construction in Lemma 5.4.

Checked theorem

A nim-sum bit is a degree-N character; for a known changed heap a delta bit is a two-coordinate character

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source
Checked theorem

The total OR-of-XORs extension equals Δ's bit on single-change pairs; not a character for N≥2; degree two for N=1

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

Connection to optimisation (informal). Fourier degree also aligns with a common empirical observation in deep learning: gradient-based training tends to fit low-frequency components before high-frequency ones (“spectral bias” / “frequency principle”) (Rahaman et al., 2019; Xu et al., 2019). This suggests a possible analogy for parity learning, but continuous-domain spectral-bias observations do not prove how SGD learns Boolean parity or restoration under our nonuniform data distribution. We treat that connection as a hypothesis requiring separate measurements.

Informal interpretation

Spectral bias suggests an analogy for parity learning; a hypothesis requiring separate measurements

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

6.5 From global invariants to local checks

The core representational point is that the global invariant nim⁡(P)\operatorname{nim}(P) is hard to compute from a single frame, whereas the transition quantity Δ(P,P′)\Delta(P,P') is locally computable from two frames (Lemma 5.4). Section 7.2 isolates this effect by training one-frame and two-frame models on the same restoration targets.

Informal interpretation

Global invariant hard from one frame; transition quantity local from two frames

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

7 Experiments

The stronger experimental goal would be to show that an AlphaZero-style learner discovers effective play through self-play once a bypass is available. We do not establish that here. The theoretical barrier concerns what the restricted network can represent, independently of training; removing it leaves open whether the required computation can be learned, with what data and under which training regime.

Informal interpretation

The experiments do not show that an AlphaZero-style learner discovers the bypasses by self-play

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

We take a controlled intermediate step: supervised restoration learning from teacher–random transitions (Section 7.2) and a complementary single-frame multi-head shootout evaluation with imitated policy heads (Section 7.3). These experiments supply guidance that outcome-only self-play would have to generate for itself. They test whether the proposed information and computation can be useful in training, while also exposing difficulties that remain after the input has been enriched. Unless otherwise stated, both one-frame (1F) and two-frame (2F) agents share the same action parameterisation and network architecture (Section 7.1).

7.1 Neural architecture and training objective

7.1.1 State and action representation

We use a fixed-width binary encoding of heap sizes with kk bits per heap. The single-frame input is the encoding of the current heap vector. The two-frame input concatenates the encodings of the previous and current heap vectors. When a previous frame is unavailable (e.g. on the first move of a game), we set the previous frame equal to the current position so that the input dimension is constant and the 2F policy remains well-defined.

Empirical result

Experimental state and action representation (binary heaps, set-heap actions, unmasked restoration argmax)

Supported by saved experimental runs, not by a proof.

Explain this How this is formalised

The action space is parameterised as “set heap ii to value vv” for i∈{1,…,N}i\in\{1,\dots,N\} and v∈{0,1,…,2k−1}v\in\{0,1,\dots,2^k-1\}, giving N⋅2kN\cdot 2^k logits. The saved restoration evaluation takes an unmasked argmax over all logits; illegal predictions count as incorrect. Legality masking is used in the separate game-playing and FSM rollout routines. These are distinct evaluation conventions.

7.1.2 Network architecture

Both restoration agents use a policy-only MLP with two hidden layers and N⋅2kN\cdot2^k output logits. There is no value head in the saved implementation. The two-frame input has dimension 2Nk2Nk; the single-frame input has dimension NkNk. The template and hidden width are shared, but parameter counts differ: the two-frame first layer adds NkH=20,480NkH=20{,}480 parameters in the reported setting. All layers use ordinary floating-point arithmetic; these networks are not literal implementations of the FSQI gate model.

ComponentTypeDimensionsActivation/Normalisation
InputState representationTwo-frame: 2Nk2Nk bits (1F: NkNk)None
Hidden 1Fully Connected1F: Nk→HNk\to H; 2F: 2Nk→H2Nk\to HLayerNorm + ReLU
Hidden 2Fully ConnectedH→HH\to HReLU
Policy HeadLinear OutputH→N⋅2kH\to N\cdot2^kRaw logits; Log-Softmax in loss
Table 1: Neural network architecture used in the experiments. HH denotes the hidden width (a fixed hyperparameter).
Empirical result

The policy-only MLP used in the experiments

Supported by saved experimental runs, not by a proof.

Explain this How this is formalised

7.1.3 Training targets and loss

For each training input (single-frame state or two-frame state-pair), the target is a soft distribution πopt(⋅∣p′)\pi_{\mathrm{opt}}(\cdot\mid p') over optimal restoration moves. The policy head is trained with cross-entropy to this target. The soft-target cross-entropy also uses unmasked logits. No value loss is used in this supervised restoration experiment.

Empirical result

Soft-target cross-entropy to the uniform distribution over optimal restoration moves

Supported by saved experimental runs, not by a proof.

Explain this How this is formalised

7.1.4 Evaluation criteria in this version

In this version we report two task-level notions of performance rather than full game-level Elo tournaments. Move-level restoration performance is measured by functional correctness: on a test position with nonzero nim-sum, a move is counted as correct if it produces a successor state with nim-sum zero. Positions with zero nim-sum have no winning move (Theorem 4.4); when reporting functional correctness we therefore condition on nonzero nim-sum positions. Position-level evaluation performance is measured by P/NP/N classification accuracy and NN-position recall in FSM-controlled shootouts (Section 7.3).

Empirical result

Evaluation by functional correctness on nonzero nim-sum positions and P/N classification

Supported by saved experimental runs, not by a proof.

Explain this How this is formalised

7.2 Supervised restoration learning from teacher–random transitions

This experiment isolates the restoration response as a supervised learning problem. In normal-play impartial games, a restoration response is the move that returns play to a losing (PP-)position after the opponent departs from it. In Nim, this is equivalent to selecting an optimal (winning) move from the post-opponent position: if the previous position had nim-sum 00, then after any opponent move the position is winning, and any optimal reply restores nim-sum 00.

Checked theorem

After any move from a zero-nim-sum position, every optimal reply restores nim-sum zero

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

Motivated by Sections 5.2–5.3, the experiment asks a separate empirical question under a fixed supervised training protocol: does access to the transition (p,p′)(p,p') (two frames) enable successful restoration learning under this protocol, even when the one-frame model fails? This benchmark builds on the observation that parity-type invariants pose a challenge for reinforcement learning in impartial games (Zhou and Riis, 2026, 2023), while explicitly providing the transition information needed by Proposition 5.5.

7.2.1 Game and representations

We consider Nim with N=20N=20 heaps. Each heap size is represented with k=4k=4 bits (little-endian), so heap values lie in {0,…,15}\{0,\ldots,15\}. Moves are represented in a fixed action space of size N⋅2k=20⋅16=320N\cdot 2^k = 20\cdot 16 = 320: an action chooses a heap index ii and a new heap value vv. Legality requires 0≤v<hi0\le v<h_i; the reported unmasked metric counts violations as errors.

A 1-frame (1F) policy receives only the current position p′p' (80-bit input), while a 2-frame (2F) policy receives the concatenation (p,p′)(p,p') of the previous and current positions (160-bit input). Both agents use the shared MLP architecture described in Section 7.1 (two hidden layers of width H=256H=256).

7.2.2 Dataset generation (teacher–random–teacher)

We generate a dataset of size D=106D=10^6 examples of the form (p,p′)↦πopt(⋅∣p′),(p, p') \mapsto \pi_{\mathrm{opt}}(\cdot \mid p') , where πopt(⋅∣p′)\pi_{\mathrm{opt}}(\cdot \mid p') is a soft target distribution over optimal moves from p′p'.

Empirical result

Teacher–random–teacher dataset of 10⁶ examples with soft optimal-move labels

Supported by saved experimental runs, not by a proof.

Explain this How this is formalised

Each example is generated as follows:

  1. 1. Sample a random winning Nim position ss (nim-sum ≠0\ne 0).

  2. 2. Apply an optimal teacher move from ss to obtain pp. For optimal play in Nim, pp has nim-sum 00 (a PP-position for the next player).

  3. 3. Apply a uniformly random legal move from pp to obtain p′p'.

  4. 4. Define the label πopt(⋅∣p′)\pi_{\mathrm{opt}}(\cdot \mid p') as the uniform distribution over all optimal (winning) moves from p′p'.

This construction ensures that each training input (p,p′)(p,p') corresponds to the canonical restoration setting: pp is a PP-position, the random move produces a winning position p′p', and the label is the set of restoration moves back to a PP-position.

Why teacher–random–teacher? We do not sample arbitrary triples (P,P′,a)(P,P',a) uniformly at random, because the restoration claim is about a specific interaction regime: the opponent departs a PP-position and the agent must restore it. The teacher step ensures PP is a genuine PP-position reachable under optimal play, the random move injects diversity in the departure P→P′P\to P', and the final teacher move provides a correct restoration label for P′P'.

Compared to earlier empirical studies of impartial games (Zhou and Riis, 2026, 2023), we “help” the learner in two ways: (i) we represent heap sizes in binary rather than as raw integers, and (ii) we train on perfectly labelled restoration targets (the full set of optimal moves), rather than requiring the agent to infer these targets from sparse win/loss outcomes.

We split the dataset into 80% train / 10% validation / 10% test using a seeded permutation (seed 0), shared by the two representations. The teacher uses the first winning heap; this induces a particular, nonuniform distribution of predecessor positions. The results do not establish invariance to heap permutations, unseen board sizes, or arbitrary self-play histories.

7.2.3 Training and checkpoints

We train each model with supervised learning using cross-entropy to the soft target distribution. We use Adam with learning rate 10−310^{-3} and batch size 512 for 200 epochs. To study performance as a function of training, we save C=10C=10 checkpoints per model at epochs {1,23,45,67,89,112,134,156,178,200}.\{1,23,45,67,89,112,134,156,178,200\}.

Empirical result

Training protocol and the ten saved checkpoints

Supported by saved experimental runs, not by a proof.

Explain this How this is formalised

7.2.4 Evaluation metrics

We evaluate restoration performance on held-out data:

Restoration accuracy (validation/test). Given a held-out example, the saved evaluation takes the argmax over all action logits and counts it as correct if it lies in the support of πopt(⋅∣p′)\pi_{\mathrm{opt}}(\cdot\mid p'). Illegal predictions therefore count as incorrect, and every legal optimal move is accepted. The saved implementation averages batch accuracies equally, including the shorter final batch, rather than weighting them by batch size. The reported decimals are those saved batch means, not exact correct-example counts divided by 100,000. The same convention applies to the displayed validation curve.

Empirical result

Restoration accuracy: unmasked argmax in the optimal support; batch-mean convention

Supported by saved experimental runs, not by a proof.

Explain this How this is formalised

7.2.5 Results

One-frame does not learn restoration; two-frame eventually does. Figure 5 shows validation restoration accuracy as a function of epoch. The 1F model has low test restoration accuracy throughout training, approximately 0.075–0.081 across saved checkpoints. We do not identify this range with a measured random-legal-move baseline, which is not supplied in the reported evaluation. In contrast, the 2F model learns the restoration mapping and reaches essentially perfect accuracy with enough training. On the test set (Figure 6), the 2F checkpoints achieve 0.209 at epoch 1, 0.538 at epoch 23, 0.876 at epoch 45, 0.989 at epoch 67, and 0.99998 by epoch 178 (remaining ≥0.99993\ge 0.99993 at epoch 200).

Empirical result

1F stays near 0.075–0.081; 2F rises to 0.99998 test accuracy by epoch 178 (one saved run)

Supported by saved experimental runs, not by a proof.

Explain this How this is formalised
Line plot titled "Validation accuracy vs epoch (restoration dataset)", epochs 0 to 200 on the horizontal axis, validation accuracy 0 to 1 on the vertical axis, legend "1F val acc" and "2F val acc". The 1F curve stays flat near 0.08 throughout. The 2F curve starts near 0.2, rises to a plateau near 0.54 until roughly epoch 30, rises steeply between roughly epochs 35 and 50, and stays near 1.0 from about epoch 60 to epoch 200.
Figure 5: Validation restoration accuracy vs. epoch on the restoration dataset (N=20N=20, k=4k=4, D=106D=10^6). In this saved run, the 1F model has low accuracy while the 2F model passes through an intermediate plateau around 0.54 before improving sharply towards near-perfect accuracy. The transition suggests a learning bottleneck that training eventually overcomes; it is distinct from the representational lower bound. Values use the saved batch-mean metric.
Empirical result

Saved validation curve: 1F low; 2F plateau near 0.54, then near-perfect

Supported by saved experimental runs, not by a proof.

Explain this How this is formalised
Line plot titled "Test accuracy of checkpointed agents" (legend "1F checkpoints" and "2F checkpoints") with markers at the ten saved checkpoints (epochs 1, 23, 45, 67, 89, 112, 134, 156, 178, 200). The 1F checkpoints stay near 0.08. The 2F checkpoints are about 0.21 at epoch 1, 0.54 at epoch 23, 0.88 at epoch 45, 0.99 at epoch 67 and essentially 1.0 from epoch 89 onwards.
Figure 6: Test restoration accuracy of checkpointed agents (N=20N=20, k=4k=4, D=106D=10^6). Checkpoints are saved at epochs {1,23,45,67,89,112,134,156,178,200}\{1,23,45,67,89,112,134,156,178,200\}. The 2F checkpoints confirm the improvement beyond the intermediate plateau; the more densely sampled validation curve in Figure 5 shows its timing.
Empirical result

Saved test accuracy at the ten checkpoints

Supported by saved experimental runs, not by a proof.

Explain this How this is formalised

Learning in stages: the plateau and subsequent improvement. The plateau near 0.540.54 and later rise in Figures 5–6 suggest a temporary learning bottleneck even with two-frame input. The learner makes substantial progress, remains at an intermediate level, and then improves sharply. This is evidence about training dynamics within the saved run, rather than a further circuit lower bound.

Empirical result

The plateau and rise suggest a temporary learning bottleneck; its cause is not established

Supported by saved experimental runs, not by a proof.

Explain this How this is formalised

A diagnostic of the saved checkpoints makes the remaining difficulty more concrete. For a predicted move setting heap ii to vv, compare its proposed change pi′⊕vp'_i\oplus v with the required nim-sum of p′p'. On the reconstructed and independently verified 100,000-position test set, the epoch-23 model makes only legal moves and gets the upper three bits of this change jointly correct on 99.998% of examples. Of its 46,206 failed moves, 46,204 differ from the correct change only in the lowest bit. At epoch 45 all 12,437 errors are confined to that bit; at epoch 178 only two errors remain, both of the same kind. These diagnostic counts weight examples equally, unlike the saved batch-mean accuracies plotted above.

Empirical result

Checkpoint diagnostic: almost all remaining errors differ from the required change only in the lowest bit

Supported by saved experimental runs, not by a proof.

Explain this How this is formalised

Thus the later improvement is accounted for at the output level by learning to select moves with the correct lowest bit while retaining the already accurate upper bits. This supports staged acquisition of the restoration behaviour. It does not identify an internal representation or explain why optimisation follows this order. Nor does the plateau’s proximity to 8/158/15 establish a random-bit guessing mechanism: that baseline assumes a particular distribution and prediction rule. Internal probes, interventions and independent training runs are needed to explain the transition and test its reproducibility.

Informal interpretation

Staged acquisition at the output level; no internal mechanism and no 8/15 explanation are established

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

Scope and provenance of the reported result. This controlled supervised run shows a large advantage for transition information at N=20N=20, k=4k=4, D=106D=10^6 and seed 0. It does not prove worst-case mastery, efficient self-play learning, or the asymptotic circuit lower bound. The checkpoint CSV is identified by run suffix 20260214_120801_cd18fc9f; the architecture and evaluation convention above follow its associated saved notebook. We report this documented configuration and do not make an unsupported claim of robustness across a hyperparameter or board-size sweep. Multiple independent seeds, matched-parameter controls and out-of-distribution evaluations remain useful follow-up experiments.

Empirical result

Scope and provenance: one configuration, seed 0, run 20260214_120801_cd18fc9f

Supported by saved experimental runs, not by a proof.

Explain this How this is formalised

7.3 Single-frame evaluation via FSM-controlled shootouts (multi-head)

Purpose. We complement the two-frame restoration study (Section 7.2) with an experiment targeting the single-frame bypass from Proposition 5.9: learned approximations to the structured rollout policies combined with a finite-state shootout controller (Figure 3). The trained floating-point networks are not claimed to satisfy the formal AC0\AC^0 gate restrictions. The goal is to test the rollout interface itself (how much information can be extracted by controlled shootouts), not to claim that self-play discovers the structured heads without additional inductive bias.

Setup. We consider NIM with N=20N=20 heaps and bit-width k=4k=4 (so B=k=4B=k=4 heads), matching the encoding of Section 7.1.1. We evaluate on a balanced test set of 2000 positions with 50%50\% PP-positions (σ=0\sigma=0) and 50%50\% NN-positions (σ≠0\sigma\neq 0).

Empirical result

FSM experiment setup: N=20, k=4, balanced test set of 2000 positions

Supported by saved experimental runs, not by a proof.

Explain this How this is formalised

Training the rollout heads. We train a shared-trunk network with B=4B=4 policy heads by imitation learning against the structured policies π0,…,πB−1\pi_0,\dots,\pi_{B-1} from Proposition 5.9. Each head πj\pi_j subtracts 2j2^j from the leftmost heap of size at least 2j2^j (falling back to subtracting 1 from the leftmost nonzero heap). When multiple heaps qualify for the same phase of πj\pi_j (e.g. several heaps have hi≥2jh_i \geq 2^j), any choice among them produces a rollout with the same total move count and hence the same parity outcome. We therefore train with soft targets: for each position and head jj, the label is uniform over all equivalent actions, and the loss is cross-entropy against this soft distribution. This avoids penalising the model for an arbitrary tie-breaking choice among equally valid heaps.

Checked theorem

Every tie-breaking rule gives the same rollout length, hence the same outcome bit

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

The network uses the same shared-trunk architecture as Table 1 (two hidden layers of width H=256H=256 with LayerNorm), with BB independent linear output heads each producing N⋅2k=320N \cdot 2^k = 320 action logits. Training uses Adam (learning rate 10−310^{-3}, batch size 1024) for 12 epochs on 2×1052\times10^5 imitation examples, with a separate 20,000-example validation set and seed 7 in the saved notebook.

Empirical result

Imitation training of the four heads (seed 7, 12 epochs, 2×10⁵ examples)

Supported by saved experimental runs, not by a proof.

Explain this How this is formalised

Rollout evaluation. Each rollout is deterministic: both players follow the same greedy policy head πj\pi_j (argmax over legal actions) until termination. The rollout outcome is 1 if the first player wins (makes the last move) and 0 otherwise. Since rollouts are deterministic, a single rollout per (position, head) pair suffices.

The per-head accuracy metric is whether the model’s rollout outcome matches the teacher’s rollout outcome—the correct channel bit—not whether it matches the P/NP/N label directly. Each exact teacher head computes a specified linear functional (r0=σ0r_0=\sigma_0; rj=σj⊕σ0r_j=\sigma_j\oplus\sigma_0 for j≥1j\ge1). The learned heads can make channel errors. The FSM uses an OR of the queried outcomes for P/NP/N classification, which is a different task from reconstructing every nim-sum bit.

Empirical result

Per-head accuracy compares channel bits with the exact teacher; the FSM uses the OR of queried outcomes

Supported by saved experimental runs, not by a proof.

Explain this How this is formalised

FSM-controlled shootout evaluation. Given a test position PP, the evaluator runs the controller of Figure 3: it queries head π0\pi_0 first; if r0=1r_0 = 1 it immediately declares σ(P)≠0\sigma(P) \neq 0 (N-position). Otherwise it queries heads π1,π2,…,πB−1\pi_1, \pi_2, \ldots, \pi_{B-1} sequentially, declaring N-position as soon as any rj=1r_j = 1, or declaring P-position if all BB bits are 0. Early stopping reduces the average number of rollouts below BB on N-positions. We report (i) overall P/NP/N evaluation accuracy and (ii) mean number of shootouts used.

Results. Table 2 reports the results.

Multi-head FSM achieves perfect classification. The saved output reports correct P/NP/N classification on all 2,000 test positions, matching the teacher’s final decisions. However, the saved per-head channel accuracies are 2000/20002000/2000, 2000/20002000/2000, 1469/20001469/2000 and 1480/20001480/2000, respectively: 1.00001.0000, 1.00001.0000, 0.73450.7345 and 0.74000.7400. Consequently, this result does not establish exact channel recovery or recovery of the full invariant by the learned model. Early stopping leaves some channels unqueried, and even queried channel errors need not change the final OR decision. These are transcribed saved outputs, not a fresh checkpoint evaluation; reached-head error counts and a reproducible end-to-end rerun are needed for a stronger claim.

Empirical result

Multi-head FSM classifies all 2,000 test positions correctly, with imperfect per-head channel accuracy

Supported by saved experimental runs, not by a proof.

Explain this How this is formalised

Single-head baseline. The single-head baseline achieves 0.768 overall accuracy and 0.536 N-position recall. These numbers have an exact theoretical explanation. With k=4k=4 bits, an N-position has nim-sum σ∈{1,…,15}\sigma \in \{1,\dots,15\}. Of these 15 values, exactly 8 are odd (σ0=1\sigma_0 = 1: the values 1,3,5,7,9,11,13,151,3,5,7,9,11,13,15) and 7 are even (σ0=0\sigma_0 = 0). Head π0\pi_0 detects an N-position only when σ0=1\sigma_0 = 1, so the theoretical N-position recall is 8/15≈0.5338/15 \approx 0.533 (observed: 0.536 on the finite test set). All P-positions are correctly classified (since σ=0\sigma = 0 implies σ0=0\sigma_0 = 0), so on a balanced test set the overall accuracy is 12⋅1+12⋅815=2330≈0.767\tfrac{1}{2}\cdot 1 + \tfrac{1}{2}\cdot\tfrac{8}{15} = \tfrac{23}{30} \approx 0.767 (observed: 0.768). This calculation describes the particular classifier that declares an N-position exactly when r0=1r_0=1. It is not the winning-move success bound of Theorem 5.12(i), and does not establish a limit on arbitrary classifiers or rollout policies.

(arithmetic)
Checked theorem

For k=4, the r₀ classifier detects 8 of 15 nonzero nim-sums; balanced accuracy 23/30

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source
(observed)
Empirical result

Observed single-head accuracy 0.768 and recall 0.536 on the finite test set

Supported by saved experimental runs, not by a proof.

Explain this How this is formalised

Different metrics. The recall 8/158/15 measures the fraction of nonzero nim-sums detected by the exact least-significant-bit channel. Restoration accuracy instead measures whether a complete selected move cancels the full nim-sum. A resemblance between the recall and a training plateau is not evidence that the same learned mechanism produces both.

Informal interpretation

Recall 8/15 and restoration accuracy measure different things

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

Early stopping. The average number of shootouts is 2.87 rather than the worst-case 4, because any N-position with σ0=1\sigma_0 = 1 is caught at head 0 (one rollout); only those with σ0=0\sigma_0 = 0 require further heads. Scope. We report the saved seed-7 configuration above. Perfect classification on this finite test set does not establish all-position correctness, robustness across seeds, or successful self-play discovery. We make no broader sweep claim without corresponding run records.

Empirical result

Average 2.87 shootouts because positions with σ₀=1 stop at head 0; scope of the result

Supported by saved experimental runs, not by a proof.

Explain this How this is formalised
MethodHeadsRolloutsAccuracyRecall
Single head (model)11.000.7680.536
Multi-head + FSM (model)42.871.0001.000
Single head (teacher)11.000.7680.536
Multi-head + FSM (teacher)42.871.0001.000
Table 2: Single-frame P/NP/N evaluation by FSM-controlled shootouts (N=20N=20, k=4k=4), reporting overall P/NP/N accuracy and NN-position recall.
Empirical result

Saved FSM shootout results for model and teacher heads

Supported by saved experimental runs, not by a proof.

Explain this How this is formalised

Reproducibility status. The restoration notebook, checkpoint-accuracy CSV and FSM notebook are retained with the local review materials. The public repository previously named for this work does not currently provide a reproducibility package; we therefore do not claim that code and data for all configurations are publicly available. The numerical results above remain tied to the saved runs and their stated limitations. A public versioned package and independently repeated evaluation are future work.

Open or deferred item

No public reproducibility package yet; a versioned package and repeated evaluation are future work

Explicitly left open, deferred or not yet connected.

Explain this How this is formalised

8 Discussion and broader implications

The three bypasses identify different resources for handling a global invariant: multi-frame inputs expose local transition information, multiple rollout heads provide complementary channels, and persistent recurrence accumulates the invariant through sequential updates. In the recurrent route, memory connects successive positions while the growing processing horizon supplies the depth needed for parity. The common design principle is to match the information and computation available to the agent to the invariant it must maintain. We briefly discuss directions beyond the specific NIM setting.

Informal interpretation

The three bypasses supply different resources for a global invariant

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

8.1 Theoretical idealisation vs. practical architecture

The simulation theorem concerns Boolean literal-threshold gates with nonnegative weights and bounded thresholds, including their permitted compositions. The experiments use floating-point signed linear layers and ReLU as well as LayerNorm and a Log-Softmax loss. Their difference from the theorem therefore extends beyond normalisation layers. A failure at one finite board size does not establish an asymptotic representational impossibility; success on a finite dataset does not establish strong mastery. The controlled comparison supports a narrower empirical conclusion: the reported transition representation is much easier to learn under this supervised protocol.

Informal interpretation

The experiments' networks differ from the theorem's gates; finite results do not settle asymptotic ones

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

8.2 Local information in combinatorial search

Exposing local invariants may also help guide combinatorial search. Our work on large Condorcet domains used structural constructions and local restrictions (Karpov et al., 2023; Zhou et al., 2024; Zhou, 2024). This is a motivating analogy, not an AC0\AC^0 reduction or a demonstrated parity lower bound for that search problem. Transferring the present argument requires a precisely encoded computational task.

Informal interpretation

Local restrictions in Condorcet-domain search: a motivating analogy, not a reduction

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

8.3 Beyond NIM: harder impartial games as benchmarks

By Sprague–Grundy theory, every finite impartial game position has a nimber. However, the computational complexity of determining nimbers varies widely. Some impartial games have PSPACE-complete winner problems, such as directed vertex Geography (Schaefer, 1978). Unless P=PSPACE\mathrm P=\mathrm{PSPACE}, no polynomial-time algorithm solves all such instances. Having a nimber does not supply an efficient way to compute it.

External cited result

Some impartial games (Geography) have PSPACE-complete winner problems

A published result used as background or input; not proved in Lean here.

Explain this How this is formalised

NIM is therefore a diagnostic starting point: its efficient optimal strategy lets us separate a representational obstruction from the difficulty of discovering a strategy. The longer-term benchmark is self-play on impartial games whose strategic structure is only partly understood or whose exact analysis becomes impractical as positions grow. Three candidates illustrate different challenges:

Informal interpretation

NIM is a diagnostic starting point for harder self-play benchmarks

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised
  • Sprouts. Players join spots by noncrossing curves, add a spot on each new curve, and keep every spot’s degree at most three. The normal-play outcome conjecture for the standard nn-spot opening remains open despite substantial progress with exact solvers (Čížek et al., 2026). Learning to exploit the evolving region structure, and to choose winning moves in intermediate positions, would be a stronger test than predicting opening outcomes from nn alone.

  • Chomp. A move removes a chosen square and all squares above and to its right; taking the distinguished corner loses. Strategy stealing establishes a first-player win on every nontrivial rectangle, but does not supply the winning moves (Berlekamp et al., 2001–2004). Larger boards and their irregular intermediate positions offer a challenge beyond solved special families; the analysis of Chomp continues to pose open problems (Nowakowski, 2025). The benchmark should test move selection and generalisation across shapes, not just the known opening winner.

  • Grundy’s game. A move splits one heap into two nonempty unequal heaps. Whether its nim-value sequence is eventually periodic remains an open problem (Nowakowski, 2025). This offers a test of whether self-play discovers useful structure in component values and how they combine. Testing unseen heap sizes and sums of heaps can distinguish such progress from memorising a finite table.

Informal interpretation

Sprouts, Chomp and Grundy's game offer distinct proposed self-play challenges

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

These are proposed learning challenges, not consequences of the present AC0\AC^0 lower bound. An unresolved structural question is not itself a complexity lower bound, and worst-case hardness need not make a chosen instance distribution difficult. A useful evaluation would reserve unseen sizes and positions, report both training and decision-time computation, and compare play with exact solvers where feasible and strong search baselines elsewhere. Beyond the range of exact verification, improved win rates are evidence of stronger play rather than a solution of an open mathematical problem. The central question is whether self-play discovers reusable strategic structure that extends the range of positions it can handle under a fixed computation budget.

Informal interpretation

Evaluate unseen sizes and positions with explicit computation budgets and solver baselines

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

8.4 What the rollout separation establishes

Theorem 5.12(i) bounds winning-move selection for fixed bit-width, a specified family of root/one-heap measurements and a polynomial-size, constant-depth readout. It does not bound general single-policy search. Within that interface, the BB structured channels reconstruct the invariant and permit direct move selection. The extra computational resource is the sequential rollout, not the number of neural output coordinates alone. Repeated deterministic measurements of the same affine channel cannot create additional channel bits, but changing the permitted query transformations or controller computation changes the model and can remove that restriction.

Informal interpretation

Theorem 5.12(i) bounds one restricted interface, not general single-policy search

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

8.5 Learning bottlenecks after the representational barrier

The constructions establish that the required computations can be expressed using the stated resources: a shallow restoration rule, structured rollout policies, or a shallow recurrent update iterated over the board. This removes one obstacle before training begins. It does not determine whether gradient descent will find those computations, whether sparse game rewards provide enough guidance, or whether the resulting behaviour generalises.

Informal interpretation

Representability removes one obstacle; it does not determine whether training finds the computation

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

The restoration experiment makes this distinction tangible. Even with transition information and correct supervision, learning passes through an intermediate plateau before reaching near-perfect measured accuracy. The checkpoint diagnostic in Section 7.2 associates the later improvement with the lowest bit of the selected move’s XOR change. We therefore have empirical evidence of a remaining learning bottleneck that is largely overcome in this run, alongside a theorem about a different, representational obstruction. The data do not establish how many distinct learning mechanisms produce the stages or why the transitions occur.

Informal interpretation

Empirical evidence of a remaining learning bottleneck alongside the representational theorem

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

The immediate experimental question is whether AlphaZero-style self-play can discover the restoration rule, complementary rollout policies or recurrent accumulator without their supervised targets. A follow-up should compare outcome-only training with curricula and auxiliary supervision, and examine the learned computations as well as win rates. For recurrence, this includes accurate accumulation and reliable state retention across separators. These controlled NIM tests would establish a basis for the harder benchmarks in Section 8.3; efficient self-play learning and the training regimes needed to achieve it remain open.

Open or deferred item

Whether AlphaZero-style self-play discovers the constructions is open

Explicitly left open, deferred or not yet connected.

Explain this How this is formalised

8.6 Significance and impact

Our results suggest several broader implications.

  • For learning theory: representational sufficiency and learnability are separate questions. A promised predecessor state, complementary measurements, or sequential computation can each alter the resources available for an invariant-based decision.

  • For neural architecture: short history windows (or difference features) can be a principled way to bypass parity-like barriers without scaling depth/width. When history is unavailable, multiple rollout heads offer an alternative within a single-frame architecture. When growing processing time is available, persistent recurrence offers a third route, building the invariant sequentially and retaining it across positions.

  • For practice: circuit complexity can help formulate architectural hypotheses, provided the implemented model satisfies the mathematical assumptions. Tests of those hypotheses should distinguish representation, training dynamics, task distribution and computation budget.

Informal interpretation

Broader implications for learning theory, architecture and practice

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

9 Conclusion

A fixed-depth Boolean literal-threshold model with nonnegative fixed-grid weights and bounded thresholds is simulable in AC0\AC^0. The NIM parity reduction then rules out strong single-frame mastery in that model.

Informal interpretation

Conclusion: AC0 simulation and the single-frame barrier, restated

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

Three constructions identify resources beyond that restricted inference problem. Two-frame access supports constant-depth restoration when the preceding position has nim-sum zero. Distinct structured rollout policies reveal complementary invariant bits; a single-channel limitation holds only under our explicit query and readout restrictions. Persistent recurrence implements running XOR over heap rows, exchanging fixed total latency for a growing sequence of simple updates. Cross-position memory additionally supports comparisons, while replay or board storage supplies the heaps needed for move selection.

Informal interpretation

Conclusion: what the three constructions supply

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

The saved floating-point experiments show a large supervised two-frame restoration advantage and perfect finite-test P/NP/N classification by a learned multi-head controller. The latter coexists with imperfect individual channel recovery. The restoration plateaus and checkpoint diagnostics also show that learning can proceed in stages after transition information is supplied. These observations do not certify the formal gate assumptions, worst-case mastery, or self-play discovery.

Informal interpretation

Conclusion: what the saved experiments do and do not show

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

The contribution is a separation of the information and computation needed for a decision from the training process that must discover it. Establishing when self-play learns the restoration rule, complementary rollout policies or recurrent accumulator remains a distinct experimental question.

10 Development, verification and author responsibility

The earlier version of this paper was developed solely by the author, with editorial feedback from AI assistants. The present version was developed interactively with the AI assistants Astra and Claude. Extensive feedback from the Lean formalisation and its audits helped to improve the presentation, clarify definitions and hypotheses, and make the scope of the claims more precise. The author takes sole responsibility for the paper, including its arguments, interpretation and use of AI assistance.

Informal interpretation

AI-assisted development and sole author responsibility

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

The accompanying Lean development (Riis, 2026b) connects the mathematical results to explicit Boolean circuits, fixed-scale networks and complete game strategies. It checks the parity reduction, the finite probability bound and its attainability, move selection with binary outputs, the rollout executors and both shootout schedules, and the recurrent protocols with replay or board storage. The general weak-mastery definition, Fourier expansion and the real-parameter noise calculation are also formalised. An independent rebuild checks 1,588 theorem and lemma declarations across 38 local Lean files, comprising 24,493 source lines; these counts include auxiliary results and exclude Lean and Mathlib themselves.

Informal interpretation

What the Lean development covers, and its size (1,588 theorem and lemma declarations, 38 files)

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

The boundary of this verification is explicit. Classical complexity results, notably Håstad’s parity hardness and correlation bounds and the Linial–Mansour–Nisan/Tal spectral bounds, remain external inputs (Håstad, 1986, 2014; Linial et al., 1993; Tal, 2015). The single-channel result is checked conditional on a stated negligible parity-correlation theorem, including its application to the readout and its probability calculation. The spectral discussion uses a separate Fourier-tail premise; its connection to the exact conventions of a published tail theorem is not part of the checked development. The conditional implication from a tail bound to small parity correlation is checked. Empirical measurements and training runs are supported by experimental code and saved results, rather than by Lean proofs.

Informal interpretation

The verification boundary: external classical inputs, conditional results, empirical runs

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised
(open item)
Open or deferred item

The Fourier-tail premise is not connected to a precise LMN/Tal statement with reconciled conventions

Explicitly left open, deferred or not yet connected.

Explain this How this is formalised

The author’s review of the formalisation focused on the interface between the paper and Lean: whether the formal definitions, hypotheses and conclusions express the intended mathematical claims. The author did not manually inspect every theorem or lemma declaration or every line of Lean source. Mechanical checking verifies the formal proofs relative to their definitions and stated hypotheses; it does not independently certify the correspondence with the prose, the suitability of the modelling assumptions, or the experimental results.

Informal interpretation

Author review of the paper–Lean correspondence is distinct from manual inspection of every proof

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

The accompanying interactive edition (Riis, 2026a) reproduces the paper text and links individual statements to their definitions, hypotheses and proofs, with optional explanations alongside them. The paper’s arguments remain self-contained at the level of its stated classical inputs; the interactive material supplies further detail rather than replacing a proof needed to understand a claim. Stable statement labels and a versioned correspondence record identify the formal results and any external assumptions. The edition includes the complete local Lean sources, pinned dependency information and reproducible build instructions. Claude generated the interactive edition and its link structure, which underwent a detailed, extensive audit by Astra. The author extensively cross-checked the edition but did not inspect every internal link and asset reference individually. An automated audit of this version verified the targets of 50,970 such references, including repeated occurrences. These navigation checks do not by themselves establish that each link provides the intended explanation or proof.

Neither the mathematical verification nor the experiments establish that gradient descent or self-play will discover the constructions in general.

Informal interpretation

Neither the verification nor the experiments show that gradient descent or self-play discovers the constructions

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

Acknowledgments and Disclosure of Funding

The author received no dedicated funding for this work.

Appendix A. Formal definitions of fixed-scale quantised neural models

This appendix provides formal definitions of the fixed-scale quantised neural models used throughout the paper.

A.1 Preliminaries: fixed-scale quantisation and representable parameters

Checked definition or construction

Representable parameters: a fixed finite grid independent of n; negations allowed on wires

Lean contains the definition or construction, with checked properties.

Explain this How this is formalised Lean statement and source

Fix constants W,D∈NW,D\in\N. Define the fixed finite set of representable parameters QW,D={ℓD:ℓ∈{0,1,…,W}}.\Qset_{W,D}=\Big\{\frac{\ell}{D}: \ell\in\{0,1,\dots,W\}\Big\}. In particular, the set of allowable weights/thresholds does not depend on input length nn. This models fixed-scale quantisation with bounded range: values lie on a fixed grid (step 1/D1/D) and saturate at magnitude W/DW/D, independent of the input length nn. It is a restricted Boolean gate abstraction; neither floating-point nor general signed fixed-point networks automatically satisfy it. In particular, mere finiteness of a floating-point format is not what drives our AC0\AC^0 containment; the key is that the effective range/scale of thresholds does not grow with fan-in as nn increases.

We will allow negations on wires (equivalently, AC0\AC^0 has NOT gates). This is standard in circuit complexity and avoids conflating two independent issues: (i) parity hardness vs (ii) monotonicity restrictions.

A.2 Feedforward model

Definition A.1 (Literal-threshold network) A fixed-scale quantised NN\NN of depth LL on nn Boolean inputs is specified by:

  • Layer widths m0=nm_0=n, m1,…,mLm_1,\dots,m_L, where mℓ≤poly(n)m_\ell\le \poly(n).

  • For each layer ℓ∈{1,…,L}\ell\in\{1,\dots,L\} and unit i∈{1,…,mℓ}i\in\{1,\dots,m_\ell\}:

    • weights wℓ,i,j∈QW,Dw_{\ell,i,j}\in \Qset_{W,D} for j∈{1,…,mℓ−1}j\in\{1,\dots,m_{\ell-1}\},

    • a threshold θℓ,i∈QW,D\theta_{\ell,i}\in \Qset_{W,D},

    • an optional negation bit ηℓ,i,j∈{0,1}\eta_{\ell,i,j}\in\{0,1\} indicating whether input jj is negated before weighting.

The computation proceeds as follows. Let y(0)=x∈{0,1}ny^{(0)}=x\in\bits^n. For ℓ≥1\ell\ge 1, yi(ℓ)  =  H ⁣(∑j=1mℓ−1wℓ,i,j⋅(yj(ℓ−1)⊕ηℓ,i,j)  −  θℓ,i),y^{(\ell)}_i \;=\; \Heav\!\Big(\sum_{j=1}^{m_{\ell-1}} w_{\ell,i,j}\cdot (y^{(\ell-1)}_j \oplus \eta_{\ell,i,j}) \;-\; \theta_{\ell,i}\Big), where H(z)=1\Heav(z)=1 if z≥0z\ge 0 and H(z)=0\Heav(z)=0 otherwise. The network output is y(L)y^{(L)} (or a designated subset of its coordinates).

Checked definition or construction

Literal-threshold network: layers of gates with grid weights, grid thresholds and negation bits

Lean contains the definition or construction, with checked properties.

Explain this How this is formalised Lean statement and source

A.3 Recurrent model (finite window)

Definition A.2 (Bounded-unrolling recurrence) Fix a time window T∈NT\in\N. A fixed-scale quantised RNN\RNN consists of:

  • input bits xt∈{0,1}nx_t\in\bits^n at time tt,

  • a hidden state ht∈{0,1}mh_t\in\bits^{m} for some m≤poly(n)m\le \poly(n),

  • an output ot∈{0,1}ko_t\in\bits^{k} for k≤poly(n)k\le \poly(n),

  • fixed-scale quantised parameters (weights/thresholds in QW,D\Qset_{W,D} and optional input negations) shared across time,

such that each update ht+1h_{t+1} and oto_t is computed by a depth-LL fixed-scale quantised threshold network over the current input and earlier states within the window. Each inference starts from an input-independent initial state, and the entire computation producing its output contains at most TT recurrent updates. No boundary state may carry additional input-dependent computation from before that window. Unrolling this bounded computation yields a feedforward computation of depth O(L⋅T)O(L\cdot T). A bound only on the lag between connected states does not imply this bound on total unrolling; the persistent model in Section 5.5 deliberately allows more than TT updates.

Checked definition or construction

Bounded-unrolling recurrence: at most T updates in total from an input-independent initial state

Lean contains the definition or construction, with checked properties.

Explain this How this is formalised Lean statement and source

A.4 Attention-style model (finite window)

Definition A.3 (Gate-realised attention-style model) Fix a time window T∈NT\in\N. A fixed-scale quantised LTST\LTST model processes a sequence (xt−T+1,…,xt)(x_{t-T+1},\dots,x_t) by:

  • computing short-term and long-term attention scores using fixed-scale quantised parameters in QW,D\Qset_{W,D},

  • combining attended summaries through a constant number of layers of fixed-scale quantised threshold computations,

  • producing outputs ot∈{0,1}ko_t\in\bits^k.

Every score computation, input-dependent coefficient selection, encoding and value aggregation is required to have a polynomial-size, constant-depth implementation in the Boolean literal-threshold gates of Definition A.1. Intermediate state is Boolean, and total unrolling is bounded as in Definition A.2. Under these explicit implementation assumptions, the simulation theorem applies by composition. Merely requiring parameters or coefficients to lie in a finite set is insufficient. This extension makes no claim about standard softmax attention without such a reduction.

Checked definition or construction

Gate-realised attention-style model: every operation implemented in the permitted gates

Lean contains the definition or construction, with checked properties.

Explain this How this is formalised Lean statement and source

Remark A.4 (Scope of the simulation) Theorem 2.4 applies because L,T,W,DL,T,W,D are constants and each unit’s parameters come from a finite set independent of nn. Appendix B gives an explicit circuit construction.

Informal interpretation

Theorem 2.4 applies because L, T, W, D are constants and parameters come from a finite grid

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

Appendix B. An AC0\AC^0 construction for simulating fixed-scale quantised networks

This appendix gives a clean circuit construction proving Theorem 2.4.

B.1 One threshold unit is in AC0\AC^0 under fixed-scale quantisation

We first show that a single fixed-scale quantised threshold unit (as in Definition A.1) is computed by a depth-2 AC0\AC^0 circuit of polynomial size.

Lemma B.1 (Fixed-scale quantised threshold gate ∈AC0\in\AC^0) Fix constants W,D∈NW,D\in\N. Let z1,…,zm∈{0,1}z_1,\dots,z_m\in\bits be Boolean inputs, and let w1,…,wm,θ∈QW,Dw_1,\dots,w_m,\theta\in\Qset_{W,D}. Consider the Boolean function f(z1,…,zm)  =  H ⁣(∑j=1mwjzj−θ).f(z_1,\dots,z_m) \;=\; \Heav\!\Big(\sum_{j=1}^m w_j z_j - \theta\Big). Then ff is computable by a depth-2 AC0\AC^0 circuit of size O(mK)O(m^K), where K:=WK:=W is a constant (depending only on W,DW,D).

Checked theorem

One fixed-scale threshold gate is a depth-2 DNF of size O(m^W)

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

Proof. Multiply the inequality by DD to clear denominators. Write wj=aj/Dw_j=a_j/D and θ=b/D\theta=b/D with aj∈{0,1,…,W}a_j\in\{0,1,\dots,W\} and b∈{0,1,…,W}b\in\{0,1,\dots,W\}. Then f(z)=1⟺∑j=1majzj  ≥  b.f(z)=1 \quad\Longleftrightarrow\quad \sum_{j=1}^m a_j z_j \;\ge\; b. If b=0b=0 the function is identically 11. Assume b≥1b\ge 1.

Because each aja_j is a nonnegative integer and each active input contributes at least 11 to the left-hand side whenever aj≥1a_j\ge 1, any satisfying assignment contains a subset of at most bb active variables whose coefficients already sum to at least bb. More formally: if ∑jajzj≥b\sum_j a_j z_j \ge b, let S={j:zj=1 and aj≥1}S=\{j:z_j=1 \text{ and } a_j\ge 1\}. Choose any multiset-free subset T⊆ST\subseteq S by greedily adding indices until the partial sum reaches ≥b\ge b. Since each added index increases the sum by at least 11, this process stops after at most bb steps. Because b≤Wb\le W, we get ∣T∣≤W=:K|T|\le W=:K.

Therefore, f(z)=1⟺⋁T⊆[m]∣T∣≤K∑j∈Taj≥b ⋀j∈Tzj.f(z)=1 \quad\Longleftrightarrow\quad \bigvee_{\substack{T\subseteq[m]\\ |T|\le K\\ \sum_{j\in T} a_j\ge b}} \ \bigwedge_{j\in T} z_j. This is a depth-2 DNF: an OR of ANDs. Here depth counts AND/OR layers; counting input negations as gates adds at most one layer, as in the implementation bounds below. The number of terms is at most ∑r=0K(mr)=O(mK)\sum_{r=0}^K \binom{m}{r}=O(m^K), polynomial since KK is constant. Unbounded fan-in AND/OR gates give an AC0\AC^0 circuit of depth 22 and size O(mK)O(m^K).

Remark B.2 (Negations) If some inputs are negated before weighting, i.e. (zj⊕ηj)(z_j\oplus \eta_j), this simply replaces zjz_j by either zjz_j or ¬zj\neg z_j in each conjunction term. Since AC0\AC^0 allows NOT gates, Lemma B.1 still applies.

Checked theorem

Negated inputs replace z_j by ¬z_j in each conjunction; the lemma still applies

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

B.2 From one unit to a full network

Lemma B.3 (One layer of fixed-scale quantised units is in AC0\AC^0) Fix W,DW,D and let a layer consist of m′m' threshold units whose inputs are outputs of a previous layer of width mm, with m,m′≤poly(n)m,m'\le \poly(n). Then the layer can be simulated by an AC0\AC^0 circuit of constant depth and polynomial size.

Checked theorem

A layer of polynomially many fixed-scale units is simulated with constant depth and polynomial size

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

Proof. Apply Lemma B.1 independently to each unit. Each unit yields a depth-2 circuit of size O(mK)O(m^K). Combine these m′m' circuits in parallel; the total size is m′⋅O(mK)=poly(n)m'\cdot O(m^K)=\poly(n) and depth remains 22.

Proof of Theorem 2.4. For a feedforward NN\NN of constant depth LL, repeatedly replace each layer by the AC0\AC^0 circuit from Lemma B.3, wiring outputs of layer ℓ−1\ell-1 circuits as inputs to layer ℓ\ell circuits. Depth multiplies by a constant factor: overall depth is O(L)O(L) (constant), and size remains polynomial as a composition of polynomial-size layers.

For RNN\RNN and LTST\LTST with time window TT, unroll the computation for TT steps (constant) to obtain a feedforward computation of depth O(LT)O(LT) (still constant). Apply the same layer-by-layer replacement.

Appendix C. Implementation details: shallow circuits and fixed-scale networks

Checked theorem

Shared shallow operations: candidate tests, binary index, recurrent update, threshold realisation

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

The constructions share a small collection of Boolean operations. Each heap is a BB-bit block, and a move is a validity bit, a binary heap index, and a BB-bit replacement value. The circuits below have polynomial size in their supplied input length. Their depth does not grow with the number of heaps or bits. All XORs described as shallow here combine two bits, or a fixed number under a bounded-change promise; an XOR of arbitrarily many heap rows is never treated as a primitive gate.

From a game rule to a network. The networks in this appendix are constructed explicitly from the game rules: their connections and weights are specified by an algorithm, rather than found by training. To see what the construction computes, revisit Figure 2. The preceding board Q=(3,5,6)Q=(3,5,6) has nim-sum zero; after the opponent changes 55 to 44, the current board is Q′=(3,4,6)Q'=(3,4,6). Comparing the frames gives δ=5⊕4=1\delta=5\oplus4=1. In parallel, the circuit proposes replacements (3⊕1,4⊕1,6⊕1)=(2,5,7)(3\oplus1,4\oplus1,6\oplus1)=(2,5,7) and tests which decrease their heaps. Only 2<32<3 passes, so the output selects heap index 00 with replacement value 22, giving (2,4,6)(2,4,6) with nim-sum zero. For B=3B=3 and a two-bit index, the output fields are validity 11, index 0000, and value 010010.

Informal interpretation

Worked two-frame construction: explicit weights and operations, not a trained network

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised
Six boxes connected in two rows: two frames (3,5,6) and (3,4,6), extraction of delta 1, proposed replacements (2,5,7), parallel decrease tests (true,false,false), selection of heap 0 and value 2, and output fields 1|00|010. Boxes group operations, not layers.
Figure 7: A schematic of the checked two-frame construction on one legal transition. Boxes group operations, not individual network layers. The general selector also handles multiple candidates, fallback moves and terminal boards.
Informal interpretation

Schematic restoration pipeline on (3,5,6) to (3,4,6)

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

The same move-selection operations are reused when rollout outcomes supply the target nim-sum. In the recurrent construction the target is accumulated over rows, and replay supplies the rows again for candidate testing. These interfaces explain how the constructions avoid asking one shallow network to extract parity from an arbitrary single board. More heaps require more parallel circuitry; executing a rollout or a recurrent scan still requires repeated evaluations.

Local differences and candidate moves. On a legal transition only one heap changes. Consequently, bit kk of the delta is δk=⋁i=0N−1(xi,k⊕xi,k′).\delta_k=\bigvee_{i=0}^{N-1}(x_{i,k}\oplus x'_{i,k}). The single-change promise makes OR equal to the required XOR across changed rows. For a target δ\delta supplied as input bits, form yi=xi⊕δy_i=x_i\oplus\delta in parallel. The test yi<xiy_i<x_i is shallow: OR over the possible highest differing bit, requiring equality at every higher bit and yi,k=0,xi,k=1y_{i,k}=0,x_{i,k}=1 at that bit. Each test has size polynomial in BB. When no cancelling candidate exists, use the first nonzero heap and subtract one. Bit kk of that decrement is xi,kx_{i,k} XOR the conjunction saying that all lower bits are zero. The validity bit is false exactly when the board is terminal. In restoration, the target comes from the two-frame delta; in the multi-head readout it comes from reconstruction of the rollout outcomes.

Checked theorem

Delta bits by OR under the single-change promise; the shallow test y_i < x_i; the subtract-one fallback

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

A binary index is part of the circuit. Let sis_i be the candidate flags after choosing between cancellation and fallback. More than one may be true. Define fi=si∧⋀j<i¬sj,Ik=⋁0≤i<Nbit k of i is 1fi.f_i=s_i\wedge\bigwedge_{j<i}\neg s_j, \qquad I_k=\bigvee_{\substack{0\le i<N\\\text{bit }k\text{ of }i\text{ is }1}}f_i. The fif_i flags select the first candidate; the IkI_k wires give its binary index. Masking the candidate replacement bits by fif_i and taking OR gives the value output. Combining validity with ⋁isi\bigvee_i s_i handles the absence of candidates. This uses constant additional depth and polynomial size, rather than an uncosted external search for the first true flag. The Lean priority encoder proves agreement for every flag pattern, including invalid outputs, no candidates, and the cases N=0N=0 and N=1N=1. A move index uses rr bits with N≤2rN\le2^r; the replay counter also stores NN and therefore requires N<2rN<2^r.

Checked theorem

The priority encoder produces the binary index of the first candidate, for every flag pattern

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

The recurrent update. Scan mode updates the accumulator by two-bit XORs. Replay mode tests the current row against the stored summary, retains the first cancelling candidate and a fallback, and increments the row counter. Counter bit kk changes exactly when all lower bits are one, so increment also has a shallow circuit. Mode, validity and reset flags select the appropriate register updates. Induction over well-formed token streams proves that every reachable register fits its allotted width and that the output move uses the summary from the same board’s first scan. The input protocol supplies the repeated rows; the controller does not secretly store the board.

Checked theorem

Scan and replay updates are shallow; bit-level refinement and register bounds hold on well-formed streams

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

Realisation with fixed-scale threshold gates. An OR gate uses weights 11 and threshold 11; a negated literal supplies NOT. Implement AND by De Morgan, as an OR of negated inputs followed by negation. This keeps the threshold bound fixed even when fan-in grows. Constants use no inputs and threshold 00 or 11. Thus all these circuits can use the fixed grid W=D=1W=D=1. More precisely, for KK output formulas of depth at most dd, total formula size SS, and input support below nn, the checked compiler constructs one network of at most 2d+22d+2 layers, at most (2d+1)S+K(2d+1)S+K gates, and layer widths and fan-ins at most S+nS+n. Identity buffers align layers; every output is proved equal to its source formula on the same finite input. Size counts duplicated formula nodes, and depth counts NOT gates, so these are conservative bounds.

Checked theorem

Compiler from formulas to {0,1}-weight threshold networks: ≤2d+2 layers, ≤(2d+1)S+K gates, widths ≤ S+n

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source
Four boxes connected left to right: Boolean formulas of depth at most d; translating OR and NOT into one layer and AND into two; copying values forward to align dependencies; arranging outputs with at most 2d+2 threshold layers. Weights and thresholds are 0 or 1.
Figure 8: The checked Boolean-to-threshold compiler, shown schematically. Negated input literals are permitted. AND uses an OR of negated inputs followed by negation, keeping weights and thresholds in {0,1}\{0,1\}. Copying and output stages give a uniform depth bound.
Informal interpretation

Schematic Boolean-to-threshold compiler with fixed weights and thresholds

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised
ComponentBoolean depthThreshold layers
Two-frame binary move selector≤20\le20≤42\le42
Multi-head binary readout, given outcomes≤19\le19≤40\le40
One structured policy’s binary move output≤17\le17≤36\le36
One recurrent state update and output≤8\le8≤18\le18
One shootout controller tick≤34\le34≤70\le70
Checked theorem

Certified depth and layer bounds for one evaluation of each component

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

These explicit Lean-checked bounds are not optimised. Together with the polynomial size bounds, they certify the components’ AC0\AC^0 resource requirements. They apply to one evaluation, not to an entire rollout or row scan. The whole-game proofs connect the resulting network outputs to the corresponding game moves and state updates; the time needed to repeat those evaluations remains part of the algorithm.

Where the layer counts come from. For the two-frame selector, the compositional Boolean-depth bound is 4+4+9+3=204+4+9+3=20: at most four levels extract the frame difference, four handle candidate tests and replacement bits, nine are allowed by the general selection construction (including fallback and output handling), and three encode the selected heap’s binary index. These are bounds on composed subcircuits, not necessarily the exact number of levels on a shortest implementation. The compiler then gives at most 2⋅20+2=422\cdot20+2=42 threshold layers. Similarly, Boolean depths 1919, 1717, 88 and 3434 give the other entries in the table.

Informal interpretation

Origin and limitations of the 20-to-42 layer bound

Motivation, interpretation or scope; not a formal claim.

Explain this How this is formalised

The factor of two allows every Boolean level the cost of an AND gate, even though OR and NOT need only one threshold layer. The two additional stages copy inputs into the construction and arrange the output wires; identity gates retain values until they are needed. This uniform construction makes correctness and resource accounting straightforward, but is not a depth optimisation. The table proves that networks within these bounds exist, not that these depths are necessary or that training will discover their weights. A more economical implementation may use fewer layers; establishing sharper bounds would require a separate construction and proof.

Outer-controller storage and time. For B,N≥1B,N\ge1 and B≤2rB\le2^r, the shootout controller uses NB+4+r+BNB+4+r+B state bits: a working board, control flags, a head index and the collected outcomes. Its input also contains the original NBNB-bit board, held fixed throughout the decision. This external storage is additional to the state count. The circuit handles head selection, board reload, outcome collection, increment and halt; the depth bound in the table applies to either the early-exit classifier or the all-head schedule.

Checked theorem

Shootout controller: NB+4+r+B state bits plus the read-only original board

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

Let MM be the total number of simulated legal moves in the all-head schedule. The implementation uses M+2B+2M+2B+2 component evaluations: MM move updates, BB terminal tests, BB outcome-consumption updates, one initial reset and one final move readout. Since M≤BN(2B−1)M\le BN(2^B-1), this agrees with the rollout-time bound in the main text while making the control overhead explicit. These are circuit evaluations, not measured processor time. The early-exit schedule uses only the visited heads and gives the same classification as the OR of all outcomes. These certificates concern the two specified schedules; the abstract definition of a finite-state controller does not certify arbitrary scheduling logic.

Checked theorem

All-head schedule: M+2B+2 component evaluations, with M ≤ BN(2^B−1)

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

Appendix D. Weak mastery examples

Example 1 (Pairing strategy) Consider positions (a,a,b,b,c,c,… )(a,a,b,b,c,c,\dots) consisting of pairs of equal heaps. The second player can mirror the first player’s move on the matching heap, maintaining the paired structure until termination, hence winning. The checked binary selector finds the first unequal pair and reduces its larger heap to match its partner. It has constant depth and polynomial size, and wins against every legal opponent from the paired family when playing second. For the first-player role every paired initial board is losing, so weak mastery there would be vacuous.

Checked theorem

Pairing strategy: a constant-depth mirror selector wins as second player on paired boards

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

The distinction from strong mastery is substantive. From the single heap (3)(3), a strategy that takes all three stones wins immediately, irrespective of what it would do elsewhere. It therefore weakly masters that initial position as first player. If it has no prescribed move at (1)(1), however, it fails strong mastery: arbitrary legal play can reach (3)→(2)→(1)(3)\to(2)\to(1) with the first player to move. That history is excluded by its own initial action. The general definition and this separation are checked in Lean.

Checked theorem

From (3), taking all stones weakly masters the position but is not strong mastery

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

Appendix E. Proof of Lemma 5.4

We provide an explicit AC0\AC^0 construction for computing nimber differences between positions differing in at most tt heaps.

Proof of Lemma 5.4. Let positions be encoded as hh blocks of length BB bits (heap sizes in binary), so total input length is n=hBn=hB.

Step 1: identify changed heaps. For each heap ii and bit position k∈[B]k\in[B], compute di,k=xi,k⊕xi,k′d_{i,k} = x_{i,k}\oplus x'_{i,k}. Then ci=⋁k∈[B]di,kc_i = \bigvee_{k\in[B]} d_{i,k} indicates whether heap ii changed. This is depth two after flattening the OR of the two-bit XOR DNFs, ignoring input negations in the usual convention.

Step 2: assume at most tt changes. By promise, ∑ici≤t\sum_i c_i \le t with tt constant.

Step 3: compute per-changed-heap XOR values. For each heap ii, define the block XOR value yi=xi⊕xi′y_i = x_i \oplus x'_i (bitwise XOR across the BB bits). Each output bit is XOR of two bits, hence AC0\AC^0.

Step 4: XOR the at-most-tt nonzero blocks. Since at most tt heaps changed, Δ=⨁i:ci=1yi\Delta = \bigoplus_{i:c_i=1} y_i is XOR of at most tt BB-bit numbers. The locations of the changed blocks must also be selected. For each S⊆[h]S\subseteq[h] with ∣S∣≤t|S|\le t, form an indicator that SS is exactly the changed set: ⋀i∈Sci∧⋀i∉S¬ci\bigwedge_{i\in S}c_i\wedge\bigwedge_{i\notin S}\neg c_i. Conjoin it with the constant-size truth table for the parity of {yi,k:i∈S}\{y_{i,k}:i\in S\}, and OR over all such SS. There are O(ht)O(h^t) choices, each using at most O(h)O(h) wires plus a constant-size parity table. This gives polynomial size and constant depth. On the single-change promise, each delta bit simplifies to ⋁iyi,k\bigvee_i y_{i,k}.

The overall circuit has constant depth and polynomial size in nn.

Appendix F. Independent noise and repetition

Remark 5.11 concerns a symmetric observation channel for an unknown bit YY. Each observation agrees with YY with probability (1+a)/2(1+a)/2, where 0<a≤1/20<a\le1/2, and observations are independent conditional on YY. A possibly randomised decision rule assigns a probability of outputting 1 to each observed bit vector. Let m∗(a)m_*(a) be the least sample count for which such a rule has error at most 1/41/4 for each possible value of YY.

Checked definition or construction

Symmetric channel with agreement (1+a)/2; m*(a) is the least sample count with both errors ≤ 1/4

Lean contains the definition or construction, with checked properties.

Explain this How this is formalised Lean statement and source

Proposition F.1 (Repetitions needed for a weakly informative bit) The minimum m∗(a)m_*(a) exists and satisfies 332a2≤m∗(a)≤⌈4a2⌉≤174a2.\frac{3}{32a^2}\le m_*(a)\le\left\lceil\frac{4}{a^2}\right\rceil \le\frac{17}{4a^2}. Majority voting, with ties declared 0, achieves the middle upper bound.

Checked theorem

3/(32a²) ≤ m*(a) ≤ ⌈4/a²⌉ ≤ 17/(4a²); majority with ties declared 0 attains the middle bound

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

Proof outline. Under either value of YY, the sum of mm correctness indicators has mean m(1+a)/2m(1+a)/2 and variance at most m/4m/4. The second-moment bound gives majority error at most 1/(ma2)1/(ma^2), so m=⌈4/a2⌉m=\lceil4/a^2\rceil suffices. This also proves that a least sufficient natural number exists. For necessity, the likelihood ratio between the two product laws has chi-square divergence (1+4a21−a2)m−1.\left(1+\frac{4a^2}{1-a^2}\right)^m-1. If ma2<3/32ma^2<3/32, use 1−a2≥3/41-a^2\ge3/4 and (1+u)m≤(1−mu)−1(1+u)^m\le(1-mu)^{-1} for u≥0u\ge0, mu<1mu<1, to bound this divergence strictly below 1. Cauchy–Schwarz then bounds total variation strictly below 1/21/2. A rule whose two errors are at most 1/41/4 would distinguish the laws with acceptance probabilities differing by at least 1/21/2, a contradiction. This applies to randomised rules as well. Finally, a2≤1/4a^2\le1/4 bounds the ceiling by 4/a2+1≤17/(4a2)4/a^2+1\le17/(4a^2).

For the flip model, a=(1−2ε)La=(1-2\varepsilon)^L. Fresh independent blocks of LL flips produce exactly the product observation law used above. When 0<ε<1/20<\varepsilon<1/2, the small-bias condition holds for every L≥⌈1/(2ε)⌉L\ge\lceil1/(2\varepsilon)\rceil; one elementary bound is (1−2ε)L≤(1+2εL)−1(1-2\varepsilon)^L\le(1+2\varepsilon L)^{-1}. If ε=0\varepsilon=0 or L=0L=0, one observation is exact. If a=0a=0, no number of observations permits error below 1/21/2 for both ideal bits. Reusing the same corrupted bit leaves the information content unchanged. The finite product laws, real-parameter bounds, minimum sample count and these boundary cases are checked in Lean.

Checked theorem

The flip model gives a=(1−2ε)^L; small bias eventually; ε=0 or L=0 exact; a=0 hopeless; reuse gives nothing

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

Appendix G. Additional proofs for the rollout analysis

Checked theorem

Full proof of Proposition 5.9: rollout counts, outcome identities, selector, winning, step bound

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

Proof of Proposition 5.9. Fix a position PP with heap sizes h1,…,hN∈{0,…,2B−1}h_1,\dots,h_N\in\{0,\dots,2^B-1\} and let σ=nim⁡(P)=h1⊕⋯⊕hN\sigma=\operatorname{nim}(P)=h_1\oplus\cdots\oplus h_N. For each j∈{0,…,B−1}j\in\{0,\dots,B-1\} define the deterministic rollout policy πj\pi_j:

“Subtract 2j2^j from the leftmost heap of size at least 2j2^j; if none exists, subtract 11 from the leftmost nonzero heap.”

Each πj\pi_j is AC0\AC^0-computable because it performs constant-depth comparisons to the threshold 2j2^j and selects the leftmost qualifying heap.

Consider a rollout under πj\pi_j from PP. While some heap is at least 2j2^j, every move subtracts exactly 2j2^j from some heap, so the number of such moves is L1=∑i=1N⌊hi/2j⌋L_1=\sum_{i=1}^N \lfloor h_i/2^j\rfloor. After this phase all heaps satisfy hi<2jh_i<2^j, and πj\pi_j falls back to subtracting 11 until termination, for a further L2=∑i=1N(hi mod 2j)L_2=\sum_{i=1}^N (h_i\bmod 2^j) moves. Thus the total number of moves is L=L1+L2L=L_1+L_2, and (normal play) the first player wins iff LL is odd, i.e. iff L mod 2=1L\bmod 2=1.

For each ii, the parity of ⌊hi/2j⌋\lfloor h_i/2^j\rfloor equals the jjth bit of hih_i, denoted hi(j)h_i^{(j)}, so L1 mod 2=⨁ihi(j)=σjL_1\bmod 2=\bigoplus_i h_i^{(j)}=\sigma_j. For j≥1j\ge1, (hi mod 2j) mod 2=hi(0)(h_i\bmod 2^j)\bmod2=h_i^{(0)}, so L2 mod 2=σ0L_2\bmod2=\sigma_0. For j=0j=0, every remainder is zero and L2=0L_2=0. Hence ROπ0(P)=σ0\mathrm{RO}_{\pi_0}(P)=\sigma_0 and ROπj(P)=σj⊕σ0\mathrm{RO}_{\pi_j}(P)=\sigma_j\oplus\sigma_0 for j≥1j\ge 1. From these BB outcomes the agent recovers σ\sigma.

When σ≠0\sigma\ne0, let kk be its highest set bit. Some heap has bit kk set; XOR with σ\sigma changes that bit to zero and leaves every higher bit unchanged, so a decreasing replacement exists. Choose the first such heap and set hi′=hi⊕σh_i'=h_i\oplus\sigma. The new nim-sum is σ⊕hi⊕hi′=0\sigma\oplus h_i\oplus h_i'=0. Comparisons, XOR and first-index selection are AC0\AC^0. When σ=0\sigma=0, output any legal move, or halt if every heap is zero.

This selector gives a winning strategy against every legal opponent response from a nonzero starting position. After the selected move, any opponent move changes one heap by a nonzero XOR difference and therefore makes the nim-sum nonzero again. The selector can restore zero on its next turn. Every legal move strictly decreases the total number of stones, so play terminates; since a nonterminal zero-nim-sum position cannot move directly to the terminal position, the selector makes the last move. The opponent need not follow any rollout policy.

Compute and retain each of the BB root outcomes once per decision. Each rollout has at most ∑ihi≤N(2B−1)\sum_i h_i\le N(2^B-1) moves, so their total is at most B∑ihi≤BN(2B−1)B\sum_i h_i\le BN(2^B-1). This counts simulated game moves, rather than elementary bit operations or elapsed time. Multiplying by the polynomial gate work per policy update gives a bit-work bound; it is polynomial in NN when B=O(log⁡N)B=O(\log N), and the displayed step bound is exponential in unrestricted binary heap width.

Appendix H. Proof of Theorem 5.12

Checked conditional theorem using named classical input

Full proof of Theorem 5.12: uniform σ, character expansion, finite bound, Håstad input, attainability

Lean checks the implication from a named, unproved classical hypothesis.

Explain this How this is formalised Lean statement and source

Proof. Part (i). Fix B≥2B\ge2, N≥1N\ge1 and put q=2Bq=2^B. Let UU be the uniform distribution on all NN independent BB-bit heaps, before conditioning on a nonzero nim-sum. For any fixed values of N−1N-1 heaps and any target nim-sum, exactly one value of the remaining heap gives that target. Thus σ\sigma is exactly uniform on F2B\mathbb F_2^B, and Pr⁡U[σ≠0]=(q−1)/q\Pr_U[\sigma\ne0]=(q-1)/q. Let ℓ=ℓj\ell=\ell_j be the nonzero linear functional returned by the fixed structured head, and let β=ℓ(σ)\beta=\ell(\sigma).

For each fixed b∈{0,1}b\in\{0,1\}, decode FN(P,b)F_N(P,b) as a proposed move (i,v)(i,v). On legal outputs define gb(P)=hi⊕vg_b(P)=h_i\oplus v, and set gb(P)=0g_b(P)=0 on invalid outputs. Selecting an indexed input block, checking legality and taking its XOR with the output use polynomial-size, constant-depth circuits. Thus for each a∈F2Ba\in\mathbb F_2^B, the indicator Hb,a(P)=1{gb(P)=a}H_{b,a}(P)=\mathbf1\{g_b(P)=a\} is in AC0\AC^0. On σ≠0\sigma\ne0, a legal move wins exactly when gβ(P)=σ(P)g_\beta(P)=\sigma(P); invalid outputs cannot satisfy that equality.

For u∈F2Bu\in\mathbb F_2^B, write χu(P)=(−1)⟨u,σ(P)⟩\chi_u(P)=(-1)^{\langle u,\sigma(P)\rangle}. First consider the finite probability calculation under the explicit assumption that some ηN≥0\eta_N\ge0 satisfies ∣EU[Hb,a(P)χu(P)]∣≤ηN\bigl|\mathbb E_U[H_{b,a}(P)\chi_u(P)]\bigr| \le \eta_N for every b∈{0,1}b\in\{0,1\}, a∈F2Ba\in\mathbb F_2^B and nonzero u∈F2Bu\in\mathbb F_2^B. This is a two-sided correlation bound under the unconditioned distribution UU; it does not assume independence between the readout and the nim-sum. Expanding the exact-value indicator gives 1{σ=a}=q−1∑u∈F2B(−1)⟨u,a⟩χu(P),\mathbf1\{\sigma=a\}=q^{-1}\sum_{u\in\mathbb F_2^B} (-1)^{\langle u,a\rangle}\chi_u(P), so ∣EU[Hb,a1{σ=a}]−q−1EUHb,a∣≤q−1qηN.\left|\mathbb E_U[H_{b,a}\mathbf1\{\sigma=a\}] -q^{-1}\mathbb E_U H_{b,a}\right| \le \frac{q-1}{q}\eta_N. For each fixed bb, the events gb(P)=ag_b(P)=a are disjoint. Therefore Pr⁡U[winning move and σ≠0]=∑a≠0EU[Hℓ(a),a1{σ=a}]≤q−1∑b∈{0,1}∑a≠0ℓ(a)=bEUHb,a+(q−1)2qηN≤2q+(q−1)2qηN.\begin{aligned}\Pr_U[\text{winning move and }\sigma\ne0] &=\sum_{a\ne0}\mathbb E_U[H_{\ell(a),a}\mathbf1\{\sigma=a\}]\\ &\le q^{-1}\sum_{b\in\{0,1\}}\sum_{\substack{a\ne0\\\ell(a)=b}} \mathbb E_U H_{b,a}+\frac{(q-1)^2}{q}\eta_N\\ &\le \frac{2}{q}+\frac{(q-1)^2}{q}\eta_N.\end{aligned} Dividing by Pr⁡U[σ≠0]=(q−1)/q\Pr_U[\sigma\ne0]=(q-1)/q gives the finite bound Pr⁡U[legal winning move∣σ≠0]≤2q−1+(q−1)ηN.\Pr_U[\text{legal winning move}\mid\sigma\ne0] \le \frac{2}{q-1}+(q-1)\eta_N.(H.1)

It remains to supply the correlation estimate for the circuit class. For u≠0u\ne0, χu\chi_u is parity on NN times the number of nonzero coordinates of uu, hence on at least NN input bits. Fix all coordinates outside this support. The restricted indicator remains a polynomial-size, fixed-depth AC0\AC^0 circuit, so the standard parity-correlation bound applies uniformly to every such restriction; averaging over the fixed coordinates preserves the bound (Håstad, 1986, 2014). Taking the maximum over the finitely many a,b,u≠0a,b,u\ne0 gives a nonnegative negligible ηN\eta_N. Since BB, the circuit depth and the polynomial size exponent are fixed, (q−1)ηN(q-1)\eta_N is also negligible. This yields the asserted asymptotic bound. The fixed-BB assumption is essential to this stated asymptotic conclusion.

For attainability of the leading constant, choose a nonzero aba_b from each fibre ℓ(a)=b\ell(a)=b, possible because B≥2B\ge2. After observing bb, try to cancel aba_b using the first heap hih_i with hi⊕ab<hih_i\oplus a_b<h_i, with any legal fallback if none exists. This is an AC0\AC^0 readout and wins whenever σ=a0\sigma=a_0 or a1a_1, an event of conditional probability 2/(q−1)2/(q-1). Any additional success is at most negligible by the upper bound. For B=2B=2 and π0\pi_0, the choices a0=2,a1=1a_0=2,a_1=1 give exactly 2/32/3: the case σ=3\sigma=3 is assigned a legal delta-1 move and cannot win.

Part (ii). The BB root rollout bits reconstruct σ\sigma. If it is nonzero, a heap containing its highest set bit can be decreased to hi⊕σh_i\oplus\sigma, leaving zero nim-sum. An AC0\AC^0 first-qualifying-heap selector implements this choice. With zero nim-sum, any legal move is optimal in the game-theoretic sense that no winning move exists. Each root rollout has at most N(2B−1)N(2^B-1) moves. Hence BB rollouts use O(BN2B)O(BN2^B) simulated moves, each with polynomial circuit work; no successor enumeration or unrestricted controller is used.

Part (iii). If the predecessor QQ has nim-sum zero and the opponent legally reaches Q′Q', then δ=Δ(Q,Q′)=nim⁡(Q′)≠0\delta=\Delta(Q,Q')=\operatorname{nim}(Q')\ne0. Select a decreasing heap hi→hi⊕δh_i\to h_i\oplus\delta as above. The two-frame difference and move selector are AC0\AC^0, and the response returns nim-sum zero. Repeating this response after the player’s own successful moves wins from the established invariant. No assertion about establishing it from an arbitrary start is used.

Checked theorem

Under the stated correlation premise η_N: success ≤ 2/(q−1) + (q−1)η_N

Lean checks a formal statement corresponding to this claim.

Explain this How this is formalised Lean statement and source

References

  1. Miklós Ajtai. Approximate counting with uniform constant-depth circuits. In Advances in Computational Complexity Theory, DIMACS Series in Discrete Mathematics and Theoretical Computer Science, vol. 13, pages 1–20, 1993.
  2. Elwyn R. Berlekamp, John H. Conway, and Richard K. Guy. Winning Ways for Your Mathematical Plays, Vols. 1–4. AK Peters/CRC Press, 2001–2004.
  3. Tomáš Čížek, Martin Balko, and Martin Schmid. Massively parallel proof-number search for impartial games and beyond. Proceedings of the AAAI Conference on Artificial Intelligence, 40(43):36838–36846, 2026. https://doi.org/10.1609/aaai.v40i43.41010.
  4. Amit Daniely and Eran Malach. Learning parities with neural networks. In Advances in Neural Information Processing Systems, 33, 2020.
  5. Tim Dettmers, Mike Lewis, Younes Belkada, and Luke Zettlemoyer. LLM.int8(): 8-bit matrix multiplication for transformers at scale. arXiv preprint arXiv:2208.07339, 2022.
  6. Harvey Friedman. AI Challenge. FOM mailing list, September 28, 2017. https://fomarchive.ugent.be/2017-September/020612.html.
  7. Harvey Friedman. NIM/Deep Learning. FOM mailing list, October 15, 2017. Includes correspondence from John Schulman, October 14–15, 2017. https://fomarchive.ugent.be/2017-October/020642.html.
  8. Merrick Furst, James B. Saxe, and Michael Sipser. Parity, circuits, and the polynomial-time hierarchy. Mathematical Systems Theory, 17(1):13–27, 1984.
  9. Yiding Hao, Dana Angluin, and Robert Frank. Formal language recognition by hard attention transformers: perspectives from circuit complexity. Transactions of the Association for Computational Linguistics, 10:800–810, 2022.
  10. Johan Håstad. Computational Limitations for Small Depth Circuits. PhD thesis, MIT, 1986.
  11. Johan Håstad. On the correlation of parity and small-depth circuits. SIAM Journal on Computing, 43(5):1699–1708, 2014. doi:10.1137/120897432.
  12. Benoit Jacob, Skirmantas Kligys, Bo Chen, Menglong Zhu, Matthew Tang, Andrew Howard, Hartwig Adam, and Dmitry Kalenichenko. Quantization and training of neural networks for efficient integer-arithmetic-only inference. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pages 2704–2713, 2018.
  13. Alexander Karpov, Klas Markström, Søren Riis, and Bei Zhou. Set-alternating schemes: A new class of large Condorcet domains. arXiv preprint arXiv:2308.02817, 2023.
  14. Nathan Linial, Yishay Mansour, and Noam Nisan. Constant depth circuits, Fourier transform, and learnability. Journal of the ACM, 40(3):607–620, 1993.
  15. William Merrill and Ashish Sabharwal. The expressive power of transformers with chain of thought. In International Conference on Learning Representations, 2024. https://arxiv.org/abs/2310.07923.
  16. Marvin Minsky and Seymour Papert. Perceptrons: An Introduction to Computational Geometry. MIT Press, 1969.
  17. Volodymyr Mnih, Koray Kavukcuoglu, David Silver, Andrei A. Rusu, Joel Veness, Marc G. Bellemare, Alex Graves, Martin Riedmiller, Andreas K. Fidjeland, Georg Ostrovski, et al. Human-level control through deep reinforcement learning. Nature, 518(7540):529–533, 2015.
  18. Yurii Nesterov. A method of solving a convex programming problem with convergence rate O(1/k2)O(1/k^2). Soviet Mathematics Doklady, 27(2):372–376, 1983.
  19. Hung Q. Ngo, Ely Porat, Christopher Ré, and Atri Rudra. Worst-case optimal join algorithms. Journal of the ACM, 65(3):16:1–16:40, 2018.
  20. Richard J. Nowakowski. Unsolved problems in combinatorial games. In Games of No Chance 6, MSRI Publications, vol. 71, pages 55–98, 2025. https://library.slmath.org/books/Book71/files/GONC6-04.pdf.
  21. Nasim Rahaman, Aristide Baratin, Devansh Arpit, et al. On the spectral bias of neural networks. In Proceedings of the 36th International Conference on Machine Learning (ICML), pages 5301–5310, 2019.
  22. Alexander A. Razborov. Lower bounds on the size of bounded depth circuits over a complete basis with logical addition. Mat. Zametki, 41(4):598–607, 1987.
  23. Søren Riis. Overcoming a learning bottleneck in impartial games: Interactive edition. 2026a. https://sr123.github.io/impartial-games-learning-lean/.
  24. Søren Riis. Overcoming a learning bottleneck in impartial games: Lean formalisation and archived interactive edition. Version 1.0.0, Zenodo, 2026b. https://doi.org/10.5281/zenodo.23289503. Lean sources: https://github.com/SR123/impartial-games-learning-lean/tree/main/lean.
  25. Thomas J. Schaefer. On the complexity of some two-person perfect-information games. Journal of Computer and System Sciences, 16(2):185–225, 1978.
  26. Julian Schrittwieser, Ioannis Antonoglou, Thomas Hubert, Karen Simonyan, Laurent Sifre, Simon Schmitt, Arthur Guez, Edward Lockhart, Demis Hassabis, Thore Graepel, et al. Mastering atari, go, chess and shogi by planning with a learned model. Nature, 588(7839):604–609, 2020.
  27. David Silver, Aja Huang, Chris J. Maddison, Arthur Guez, Laurent Sifre, George Van Den Driessche, Julian Schrittwieser, Ioannis Antonoglou, Veda Panneershelvam, Marc Lanctot, et al. Mastering the game of go with deep neural networks and tree search. Nature, 529(7587):484–489, 2016.
  28. David Silver, Julian Schrittwieser, Karen Simonyan, Ioannis Antonoglou, Aja Huang, Arthur Guez, Thomas Hubert, Lucas Baker, Matthew Lai, Adrian Bolton, et al. Mastering the game of go without human knowledge. Nature, 550(7676):354–359, 2017.
  29. David Silver, Thomas Hubert, Julian Schrittwieser, Ioannis Antonoglou, Matthew Lai, Arthur Guez, Marc Lanctot, Laurent Sifre, Dharshan Kumaran, Thore Graepel, et al. A general reinforcement learning algorithm that masters chess, shogi, and go through self-play. Science, 362(6419):1140–1144, 2018.
  30. Roman Smolensky. Algebraic methods in the theory of lower bounds for boolean circuit complexity. In Proceedings of the 19th Annual ACM Symposium on Theory of Computing, pages 77–82, 1987.
  31. Avishay Tal. Tight bounds on the Fourier spectrum of AC0\AC^0. Electronic Colloquium on Computational Complexity (ECCC), TR14-174, 2015.
  32. Christopher James Thornton. Backpropagation can’t do parity generalisation. University of Sussex, School of Cognitive and Computing Science, 1996.
  33. Chris Thornton. Parity: the problem that won’t go away. In Conference of the Canadian Society for Computational Studies of Intelligence, pages 362–374. Springer, 1996.
  34. Zhi-Qin John Xu, Yaoyu Zhang, and Yanyang Xiao. Frequency principle: Fourier analysis sheds light on deep neural networks. arXiv preprint arXiv:1901.06523, 2019.
  35. Bei Zhou. Reinforcement Learning for Impartial Games and Complex Combinatorial Optimisation Problems. PhD thesis, Queen Mary University of London, 2024.
  36. Bei Zhou, Klas Markström, and Søren Riis. CDL: A fast and flexible library for the study of permutation sets with structural restrictions. SoftwareX, 28:101951, 2024.
  37. Bei Zhou and Søren Riis. Exploring parity challenges in reinforcement learning through curriculum learning with noisy labels. arXiv preprint arXiv:2312.05379, 2023.
  38. Bei Zhou and Søren Riis. Impartial games: A challenge for reinforcement learning. Machine Learning, 115:54, 2026. First preprint 2022. https://doi.org/10.1007/s10994-026-06996-1.