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

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

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

1 Paper text

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

Generated from paper_jmlr.tex, lines 1467–1467.

2 Explain this

Appendix C is the engineering behind the bypasses. All constructions share a few shallow operations: a heap is a BB-bit block; a move is a validity bit, a binary heap index and a BB-bit value. The circuits have polynomial size in their supplied input length and depth independent of NN and BB. Every XOR called shallow combines two bits (or a fixed number under a bounded-change promise); an XOR of arbitrarily many rows is never treated as a primitive.

3 How this is formalised

The appendix is checked piece by piece; see Appendix C, “Local differences and candidate moves”, Appendix C, “A binary index is part of the circuit”, Appendix C, “The recurrent update”, Appendix C, “Realisation with fixed-scale threshold gates”, Appendix C, table and Section C, “Outer-controller storage and time”. Headline theorems: PriorityEncoder.encode_correct (binary output), ThresholdNet.compileF_spec and ThresholdNet.compileF_fixed_grid (the threshold compiler), BoardStore.bs_net (one instance).

Coverage record
Paper anchorapp:impl (manuscript label)
Displayed asAppendix C
ClaimShared shallow operations: candidate tests, binary index, recurrent update, threshold realisation
Coverage categoryChecked theorem
Statement sourcepaper_jmlr.tex lines 1467–1467; SHA-256 of the normalised block source 5173677bae34efd7…
Lean declarations
Depends onAppendix C, “Local differences and candidate moves”, Appendix C, “A binary index is part of the circuit”, Appendix C, “The recurrent update”, Appendix C, “Realisation with fixed-scale threshold gates”, Appendix C, table
Audited correspondence rowsapp:impl
Explanationsexplain/app:impl, formal/app:impl
Build evidencefresh isolated rebuild, audit report

4 Lean statement and source

Principal declarations

theorem PriorityEncoder.encode_correct

Module PriorityEncoder (lean/phase5/PriorityEncoder.lean, lines 67–107) · file SHA-256 1be04943f5455fc1… Axioms reported by the fresh build: propext, Quot.sound

PRIORITY-ENCODER CORRECTNESS, for every input assignment: the binary output decodes to exactly the selection readout (first true flag, value bits), and to `none` when the readout is invalid or no flag is true.

Statement as elaborated and printed by Lean 4.26.0

∀ (R : NimAudit.CorrBridge.RCirc) (N r : ℕ),
  R.sel.length = N →
    N ≤ 2 ^ r →
      ∀ (z : ℕ → Bool),
        NimAudit.PriorityEncoder.binSem (NimAudit.PriorityEncoder.encode R N r) N z =
          NimAudit.SelectCircuit.selReadout R z
Exact source text, lines 67–107
67/-- PRIORITY-ENCODER CORRECTNESS, for every input assignment: the binary output decodes68    to exactly the selection readout (first true flag, value bits), and to `none` when69    the readout is invalid or no flag is true. -/70theorem encode_correct (R : RCirc) (N r : Nat) (hlen : R.sel.length = N) (hr : N ≤ 2 ^ r)71    (z : Nat → Bool) : binSem (encode R N r) N z = selReadout R z := by72  unfold binSem selReadout encode73  simp only74  by_cases hv : eval z R.valid = true75  · cases hft : firstTrue (R.sel.map (eval z)) with76    | none =>77      have hany : (R.sel.map (eval z)).any id = false := by78        have := firstTrue_isSome (R.sel.map (eval z)); rw [hft] at this; simpa using this.symm79      have hor : eval z (or ((List.range N).map (getC R.sel))) = false := by80        rw [eval_or, List.any_map]81        have e : ((List.range N).any (eval z ∘ getC R.sel)) = (R.sel.map (eval z)).any id := by82          rw [← flags_eq R.sel N hlen z, List.any_map]; rfl83        rw [e, hany]84      simp [hv, hor]85    | some i =>86      have hiN : i < N := by have := firstTrue_lt hft; simpa [hlen] using this87      have hflag : (R.sel.map (eval z)).getD i false = true := ((firstTrue_some_iff _ i).1 hft).2.188      have hor : eval z (or ((List.range N).map (getC R.sel))) = true := by89        rw [eval_or, List.any_map]90        apply List.any_eq_true.mpr91        exact ⟨i, List.mem_range.mpr hiN, by simp only [Function.comp_apply, eval_getC]; exact hflag⟩92      have hidx : toNatBE (((List.range r).map (idxBit R.sel N r)).map (eval z)) = i := by93        rw [List.map_map]94        apply toNatBE_of_bits (Nat.lt_of_lt_of_le hiN hr)95        intro q _96        simp only [Function.comp_apply]97        apply Bool.eq_iff_iff.mpr98        simp only [idxBit, eval_or, List.any_map, List.any_eq_true, List.mem_filter, List.mem_range,99          Function.comp_apply]100        constructor101        · rintro ⟨i', ⟨hi', hb⟩, he⟩102          rw [firstF_eval R.sel hlen z hi', hft, decide_eq_true_iff] at he103          cases he; exact hb104        · intro hb105          exact ⟨i, ⟨hiN, hb⟩, by rw [firstF_eval R.sel hlen z hiN, hft]; simp⟩106      simp only [eval_and, List.all_cons, List.all_nil, hv, hor, Bool.and_true, if_true, hidx, hiN]107  · simp [hv]

Project declarations in the statement: AC0.Circ, CorrBridge.RCirc, CorrBridge.RCirc.sel, PriorityEncoder.binSem, PriorityEncoder.encode, SelectCircuit.selReadout

Project declarations used by the proof or definition body

AC0.Circ, AC0.Circ.and, AC0.Circ.eval, AC0.Circ.eval_and, AC0.Circ.eval_or, AC0.Circ.or, AttainCircuit.firstTrue_lt, AttainCircuit.toNatBE_of_bits, BinReadout.BCirc.idx, BinReadout.BCirc.mk, BinReadout.BCirc.val, BinReadout.BCirc.valid, Bridge.toNatBE, CorrBridge.RCirc, CorrBridge.RCirc.sel, CorrBridge.RCirc.val, CorrBridge.RCirc.valid, CorrBridge.eval_getC, CorrBridge.firstTrue, CorrBridge.firstTrue_some_iff, CorrBridge.getC, PriorityEncoder.binSem, PriorityEncoder.encode, PriorityEncoder.firstF, PriorityEncoder.firstF_eval, PriorityEncoder.flags_eq, PriorityEncoder.idxBit, SelectCircuit.firstTrue_isSome, SelectCircuit.selReadout

theorem ThresholdNet.compileF_spec

Module ThresholdNet (lean/phase5/ThresholdNet.lean, lines 698–713) · file SHA-256 15c36f444487a1bd… Axioms reported by the fresh build: propext, Classical.choice, Quot.sound

THE COMPILER THEOREM (all properties of the one network `compileF cs`).

Statement as elaborated and printed by Lean 4.26.0

∀ (cs : List NimAudit.AC0.Circ) (n D : ℕ),
  (∀ c ∈ cs, c.maxInput ≤ n) →
    (∀ c ∈ cs, c.depth ≤ D) →
      (∀ (x : ℕ → Bool) (k : ℕ) (hk : k < cs.length),
          NimAudit.AC0.evalNet (NimAudit.ThresholdNet.compileF cs) x k =
            NimAudit.AC0.Circ.eval x cs[k]) ∧
        (∀ (x : ℕ → Bool) (k : ℕ),
            cs.length ≤ k → NimAudit.AC0.evalNet (NimAudit.ThresholdNet.compileF cs) x k = false) ∧
          NimAudit.AC0.NetValid 1 (NimAudit.ThresholdNet.compileF cs) ∧
            NimAudit.FiniteNet.Wired n (NimAudit.ThresholdNet.compileF cs) ∧
              (NimAudit.ThresholdNet.compileF cs).length ≤ 2 * D + 2 ∧
                NimAudit.AC0.NetBounded ((List.map NimAudit.AC0.Circ.size cs).sum + n)
                    (NimAudit.ThresholdNet.compileF cs) ∧
                  NimAudit.ThresholdNet.gateCount (NimAudit.ThresholdNet.compileF cs) ≤
                    (2 * D + 1) * (List.map NimAudit.AC0.Circ.size cs).sum + cs.length
Exact source text, lines 698–713
698/-- THE COMPILER THEOREM (all properties of the one network `compileF cs`). -/699theorem compileF_spec (cs : List Circ) (n D : Nat) (hn : ∀ c ∈ cs, maxInput c ≤ n)700    (hD : ∀ c ∈ cs, depth c ≤ D) :701    (∀ x : Nat → Bool, ∀ k (hk : k < cs.length), evalNet (compileF cs) x k = eval x cs[k]) ∧702    (∀ x : Nat → Bool, ∀ k, cs.length ≤ k → evalNet (compileF cs) x k = false) ∧703    NetValid 1 (compileF cs) ∧ Wired n (compileF cs) ∧704    (compileF cs).length ≤ 2 * D + 2 ∧705    NetBounded ((cs.map size).sum + n) (compileF cs) ∧706    gateCount (compileF cs) ≤ (2 * D + 1) * (cs.map size).sum + cs.length := by707  have hd : dmax cs ≤ D := listMax_le (fun a ha => by obtain ⟨c, hc, rfl⟩ := List.mem_map.mp ha; exact hD c hc)708  refine ⟨fun x k hk => compileF_eval cs x hk, fun x k hk => compileF_eval_out cs x hk, compileF_valid cs,709    compileF_wired cs n hn, by rw [compileF_length]; omega, compileF_bounded cs n hn, ?_⟩710  rw [compileF_gates]711  have : (2 * dmax cs + 1) * (cs.map size).sum ≤ (2 * D + 1) * (cs.map size).sum :=712    Nat.mul_le_mul_right _ (by omega)713  omega

Project declarations in the statement: AC0.Circ, AC0.Circ.depth, AC0.Circ.eval, AC0.Circ.maxInput, AC0.Circ.size, AC0.Layer, AC0.NetBounded, AC0.NetValid, AC0.evalNet, FiniteNet.Wired, ThresholdNet.compileF, ThresholdNet.gateCount

Project declarations used by the proof or definition body

AC0.Circ, AC0.Circ.depth, AC0.Circ.eval, AC0.Circ.listMax_le, AC0.Circ.maxInput, AC0.Circ.size, AC0.Layer, AC0.NetBounded, AC0.NetValid, AC0.evalNet, FiniteNet.Wired, ThresholdNet.compileF, ThresholdNet.compileF_bounded, ThresholdNet.compileF_eval, ThresholdNet.compileF_eval_out, ThresholdNet.compileF_gates, ThresholdNet.compileF_length, ThresholdNet.compileF_valid, ThresholdNet.compileF_wired, ThresholdNet.dmax, ThresholdNet.gateCount

theorem ThresholdNet.compileF_fixed_grid

Module ThresholdNet (lean/phase5/ThresholdNet.lean, lines 715–720) · file SHA-256 15c36f444487a1bd… Axioms reported by the fresh build: propext, Classical.choice, Quot.sound

FIXED GRID: every gate of a compiled network fires in the paper's rational form with denominator D = 1 exactly when it fires in integer form (weights in {0,1}, threshold in {0,1}).

Statement as elaborated and printed by Lean 4.26.0

∀ (cs : List NimAudit.AC0.Circ),
  ∀ l ∈ NimAudit.ThresholdNet.compileF cs,
    ∀ g ∈ l,
      NimAudit.AC0.Gate.Valid 1 g ∧ ∀ (z : ℕ → Bool), NimAudit.AC0.ratFires g 1 z ↔ g.eval z = true
Exact source text, lines 715–720
715/-- FIXED GRID: every gate of a compiled network fires in the paper's rational form with716    denominator D = 1 exactly when it fires in integer form (weights in {0,1}, threshold717    in {0,1}). -/718theorem compileF_fixed_grid (cs : List Circ) :719    ∀ l ∈ compileF cs, ∀ g ∈ l, Gate.Valid 1 g ∧ ∀ z, (ratFires g 1 z ↔ g.eval z = true) :=720  fun l hl g hg => ⟨compileF_valid cs l hl g hg, fun z => gate_rat_iff g (by decide) z⟩

Project declarations in the statement: AC0.Circ, AC0.Gate, AC0.Gate.Valid, AC0.Gate.eval, AC0.Layer, AC0.ratFires, ThresholdNet.compileF

Project declarations used by the proof or definition body

AC0.Circ, AC0.Gate, AC0.Gate.Valid, AC0.Gate.eval, AC0.Layer, AC0.gate_rat_iff, AC0.ratFires, ThresholdNet.compileF, ThresholdNet.compileF_valid

theorem BoardStore.bs_net

Module BoardStore (lean/phase6/BoardStore.lean, lines 753–775) · file SHA-256 c35ac76d5db6e833… Axioms reported by the fresh build: propext, Classical.choice, Quot.sound

BOARD-STORAGE NETWORK CERTIFICATE (W = 1, ≤ 34 layers).

Statement as elaborated and printed by Lean 4.26.0

NimAudit.Family.NetFam NimAudit.Family.restAdm NimAudit.BoardStore.bsLen NimAudit.BoardStore.bsNet 1
  34
Exact source text, lines 753–775
753/-- BOARD-STORAGE NETWORK CERTIFICATE (W = 1, ≤ 34 layers). -/754theorem bs_net : NetFam restAdm bsLen bsNet 1 34 := by755  have spec := fun i => compileF_spec (bsAll i) (bsLen i) 16756    (fun c hc => by757      rcases List.mem_append.mp hc with h | h758      · exact (bsForms_res _ _ _ c h).2.2759      · exact (bsOuts_res (rIdx_width i.2) c h).2.2)760    (fun c hc => by761      rcases List.mem_append.mp hc with h | h762      · have := (bsForms_res _ _ _ c h).1; omega763      · exact (bsOuts_res (rIdx_width i.2) c h).1)764  have hT := polyE bsLen_pos leafBN bs_leaves bsSizeE _ (fun i => (bsSizeE_eval i).symm)765  refine ⟨bsLen_pos, fun i _ => (spec i).2.2.1, fun i _ => (spec i).2.2.2.1, fun i _ => (spec i).2.2.2.2.1, ?_, ?_⟩766  · obtain ⟨c, k, h⟩ := polyIn_add bsLen_pos hT (polyIn_leaf (fun i _ => Nat.le_refl (bsLen i)))767    refine ⟨c, k, fun i hi => netBounded_mono (spec i).2.2.2.2.2.1 ?_⟩768    have := bsAll_tsize i; have := h i hi; dsimp only at *; unfold tsize at *; omega769  · refine polyIn_mono (fun i _ => ?_) (polyIn_mul (polyIn_const _ _ 34) hT)770    have g := (spec i).2.2.2.2.2.2771    have h1 := bsAll_tsize i772    have h2 := length_le_tsize (bsAll i)773    unfold tsize at h1 h2774    show gateCount (compileF (bsAll i)) ≤ 34 * _775    omega

Project declarations in the statement: BoardStore.bsLen, BoardStore.bsNet, Family.NetFam, Family.restAdm

Project declarations used by the proof or definition body

AC0.Circ, AC0.Circ.depth, AC0.Circ.eval, AC0.Circ.maxInput, AC0.Circ.size, AC0.Layer, AC0.NetBounded, AC0.NetValid, AC0.evalNet, BoardStore.bsAll, BoardStore.bsAll_tsize, BoardStore.bsForms, BoardStore.bsForms_res, BoardStore.bsLen, BoardStore.bsLen_pos, BoardStore.bsNet, BoardStore.bsOuts, BoardStore.bsOuts_res, BoardStore.bsSizeE, BoardStore.bsSizeE_eval, BoardStore.bs_leaves, BoardStore.sw, BoardStore.varSz, Family.NetFam.mk, Family.PE.eval, Family.PolyIn, Family.leafBN, Family.length_le_tsize, Family.netBounded_mono, Family.polyE, Family.polyIn_add, Family.polyIn_const, Family.polyIn_leaf, Family.polyIn_mono, Family.polyIn_mul, Family.rIdx_width, Family.restAdm, Family.tsize, FiniteNet.Wired, ThresholdNet.compileF, ThresholdNet.compileF_spec, ThresholdNet.gateCount, WholeGame.rIdx

Definitions these statements use

inductive AC0.Circ

Module Circuit (lean/phase3/Circuit.lean, lines 35–40) · file SHA-256 af97cc0eec7d8464…

Statement as elaborated and printed by Lean 4.26.0

Type
Exact source text, lines 35–40
35inductive Circ where36  | input (i : Nat)37  | const (b : Bool)38  | not (c : Circ)39  | and (cs : List Circ)40  | or (cs : List Circ)

Project declarations in the statement: none

Project declarations used by the proof or definition body

none

inductive CorrBridge.RCirc

Module NimCorrBridge (lean/phase3/NimCorrBridge.lean, lines 34–37) · file SHA-256 d3fb2e4a64db3e92…

Statement as elaborated and printed by Lean 4.26.0

Type
Exact source text, lines 34–37
34structure RCirc where35  valid : Circ36  sel : List Circ37  val : List Circ

Project declarations in the statement: none

Project declarations used by the proof or definition body

AC0.Circ

def CorrBridge.RCirc.sel

Module NimCorrBridge (lean/phase3/NimCorrBridge.lean, lines 36–36) · file SHA-256 d3fb2e4a64db3e92…

Statement as elaborated and printed by Lean 4.26.0

NimAudit.CorrBridge.RCirc → List NimAudit.AC0.Circ
Exact source text, lines 36–36
36  sel : List Circ

Project declarations in the statement: AC0.Circ, CorrBridge.RCirc

Project declarations used by the proof or definition body

CorrBridge.RCirc

def PriorityEncoder.binSem

Module PriorityEncoder (lean/phase5/PriorityEncoder.lean, lines 40–47) · file SHA-256 1be04943f5455fc1…

Binary-format semantics on an arbitrary input vector (an index ≥ N is invalid); on boards this is exactly `BinReadout.binReadoutOf`.

Statement as elaborated and printed by Lean 4.26.0

NimAudit.BinReadout.BCirc → ℕ → (ℕ → Bool) → Option (ℕ × ℕ)
Exact source text, lines 40–47
40/-- Binary-format semantics on an arbitrary input vector (an index ≥ N is invalid);41    on boards this is exactly `BinReadout.binReadoutOf`. -/42def binSem (S : BCirc) (N : Nat) (z : Nat → Bool) : Option (Nat × Nat) :=43  if eval z S.valid then44    if toNatBE (S.idx.map (eval z)) < N then45      some (toNatBE (S.idx.map (eval z)), toNatBE (S.val.map (eval z)))46    else none47  else none

Project declarations in the statement: BinReadout.BCirc

Project declarations used by the proof or definition body

AC0.Circ, AC0.Circ.eval, BinReadout.BCirc, BinReadout.BCirc.idx, BinReadout.BCirc.val, BinReadout.BCirc.valid, Bridge.toNatBE

def PriorityEncoder.encode

Module PriorityEncoder (lean/phase5/PriorityEncoder.lean, lines 34–38) · file SHA-256 1be04943f5455fc1…

THE PRIORITY ENCODER.

Statement as elaborated and printed by Lean 4.26.0

NimAudit.CorrBridge.RCirc → ℕ → ℕ → NimAudit.BinReadout.BCirc
Exact source text, lines 34–38
34/-- THE PRIORITY ENCODER. -/35def encode (R : RCirc) (N r : Nat) : BCirc :=36  ⟨and [R.valid, or ((List.range N).map (getC R.sel))],37   (List.range r).map (idxBit R.sel N r),38   R.val⟩

Project declarations in the statement: BinReadout.BCirc, CorrBridge.RCirc

Project declarations used by the proof or definition body

AC0.Circ, AC0.Circ.and, AC0.Circ.or, BinReadout.BCirc.mk, CorrBridge.RCirc, CorrBridge.RCirc.sel, CorrBridge.RCirc.val, CorrBridge.RCirc.valid, CorrBridge.getC, PriorityEncoder.idxBit

def SelectCircuit.selReadout

Module SelectCircuit (lean/phase4/SelectCircuit.lean, lines 26–32) · file SHA-256 922ee44ce0ababa9…

Evaluation of a move readout on an arbitrary input vector.

Statement as elaborated and printed by Lean 4.26.0

NimAudit.CorrBridge.RCirc → (ℕ → Bool) → Option (ℕ × ℕ)
Exact source text, lines 26–32
26/-- Evaluation of a move readout on an arbitrary input vector. -/27def selReadout (R : RCirc) (z : Nat → Bool) : Option (Nat × Nat) :=28  if eval z R.valid then29    match firstTrue (R.sel.map (eval z)) with30    | some i => some (i, toNatBE (R.val.map (eval z)))31    | none => none32  else none

Project declarations in the statement: CorrBridge.RCirc

Project declarations used by the proof or definition body

AC0.Circ, AC0.Circ.eval, Bridge.toNatBE, CorrBridge.RCirc, CorrBridge.RCirc.sel, CorrBridge.RCirc.val, CorrBridge.RCirc.valid, CorrBridge.firstTrue

def AC0.Circ.depth

Module Circuit (lean/phase3/Circuit.lean, lines 61–66) · file SHA-256 af97cc0eec7d8464…

Statement as elaborated and printed by Lean 4.26.0

NimAudit.AC0.Circ → ℕ
Exact source text, lines 61–66
61def depth : Circ → Nat62  | input _ => 063  | const _ => 064  | not c => depth c + 165  | and cs => listMax (cs.attach.map (fun ⟨c, _⟩ => depth c)) + 166  | or cs => listMax (cs.attach.map (fun ⟨c, _⟩ => depth c)) + 1

Project declarations in the statement: AC0.Circ

Project declarations used by the proof or definition body

AC0.Circ, AC0.Circ.and, AC0.Circ.casesOn, AC0.Circ.const, AC0.Circ.input, AC0.Circ.listMax, AC0.Circ.not, AC0.Circ.or, AC0.Circ.rec, AC0.Circ.rec_1

def AC0.Circ.eval

Module Circuit (lean/phase3/Circuit.lean, lines 44–49) · file SHA-256 af97cc0eec7d8464…

Statement as elaborated and printed by Lean 4.26.0

(ℕ → Bool) → NimAudit.AC0.Circ → Bool
Exact source text, lines 44–49
44def eval (x : Nat → Bool) : Circ → Bool45  | input i => x i46  | const b => b47  | not c => !(eval x c)48  | and cs => cs.attach.all (fun ⟨c, _⟩ => eval x c)49  | or cs => cs.attach.any (fun ⟨c, _⟩ => eval x c)

Project declarations in the statement: AC0.Circ

Project declarations used by the proof or definition body

AC0.Circ, AC0.Circ.and, AC0.Circ.casesOn, AC0.Circ.const, AC0.Circ.input, AC0.Circ.not, AC0.Circ.or, AC0.Circ.rec, AC0.Circ.rec_1

def AC0.Circ.maxInput

Module Circuit (lean/phase3/Circuit.lean, lines 68–74) · file SHA-256 af97cc0eec7d8464…

One more than the largest input index used (0 if none).

Statement as elaborated and printed by Lean 4.26.0

NimAudit.AC0.Circ → ℕ
Exact source text, lines 68–74
68/-- One more than the largest input index used (0 if none). -/69def maxInput : Circ → Nat70  | input i => i + 171  | const _ => 072  | not c => maxInput c73  | and cs => listMax (cs.attach.map (fun ⟨c, _⟩ => maxInput c))74  | or cs => listMax (cs.attach.map (fun ⟨c, _⟩ => maxInput c))

Project declarations in the statement: AC0.Circ

Project declarations used by the proof or definition body

AC0.Circ, AC0.Circ.and, AC0.Circ.casesOn, AC0.Circ.const, AC0.Circ.input, AC0.Circ.listMax, AC0.Circ.not, AC0.Circ.or, AC0.Circ.rec, AC0.Circ.rec_1

def AC0.Circ.size

Module Circuit (lean/phase3/Circuit.lean, lines 51–56) · file SHA-256 af97cc0eec7d8464…

Statement as elaborated and printed by Lean 4.26.0

NimAudit.AC0.Circ → ℕ
Exact source text, lines 51–56
51def size : Circ → Nat52  | input _ => 153  | const _ => 154  | not c => size c + 155  | and cs => (cs.attach.map (fun ⟨c, _⟩ => size c)).sum + 156  | or cs => (cs.attach.map (fun ⟨c, _⟩ => size c)).sum + 1

Project declarations in the statement: AC0.Circ

Project declarations used by the proof or definition body

AC0.Circ, AC0.Circ.and, AC0.Circ.casesOn, AC0.Circ.const, AC0.Circ.input, AC0.Circ.not, AC0.Circ.or, AC0.Circ.rec, AC0.Circ.rec_1

def AC0.Layer

Module Circuit (lean/phase3/Circuit.lean, lines 743–744) · file SHA-256 af97cc0eec7d8464…

A layer: a list of gates reading the previous layer's outputs (indexed by Nat).

Statement as elaborated and printed by Lean 4.26.0

Type
Exact source text, lines 743–744
743/-- A layer: a list of gates reading the previous layer's outputs (indexed by Nat). -/744abbrev Layer := List Gate

Project declarations in the statement: none

Project declarations used by the proof or definition body

AC0.Gate

def AC0.NetBounded

Module Circuit (lean/phase3/Circuit.lean, lines 768–769) · file SHA-256 af97cc0eec7d8464…

Fan-in and width bounded by M.

Statement as elaborated and printed by Lean 4.26.0

ℕ → List NimAudit.AC0.Layer → Prop
Exact source text, lines 768–769
768/-- Fan-in and width bounded by M. -/769def NetBounded (M : Nat) (ls : List Layer) : Prop := ∀ l ∈ ls, l.length ≤ M ∧ ∀ g ∈ l, g.fanin ≤ M

Project declarations in the statement: AC0.Layer

Project declarations used by the proof or definition body

AC0.Gate, AC0.Gate.fanin, AC0.Layer

def AC0.NetValid

Module Circuit (lean/phase3/Circuit.lean, lines 765–766) · file SHA-256 af97cc0eec7d8464…

All gates valid for W.

Statement as elaborated and printed by Lean 4.26.0

ℕ → List NimAudit.AC0.Layer → Prop
Exact source text, lines 765–766
765/-- All gates valid for W. -/766def NetValid (W : Nat) (ls : List Layer) : Prop := ∀ l ∈ ls, ∀ g ∈ l, Gate.Valid W g

Project declarations in the statement: AC0.Layer

Project declarations used by the proof or definition body

AC0.Gate, AC0.Gate.Valid, AC0.Layer

def AC0.evalNet

Module Circuit (lean/phase3/Circuit.lean, lines 751–754) · file SHA-256 af97cc0eec7d8464…

A network: layers applied in order.

Statement as elaborated and printed by Lean 4.26.0

List NimAudit.AC0.Layer → (ℕ → Bool) → ℕ → Bool
Exact source text, lines 751–754
751/-- A network: layers applied in order. -/752def evalNet : List Layer → (Nat → Bool) → (Nat → Bool)753  | [], z => z754  | l :: ls, z => evalNet ls (evalLayer l z)

Project declarations in the statement: AC0.Layer

Project declarations used by the proof or definition body

AC0.Layer, AC0.evalLayer

def FiniteNet.Wired

Module FiniteNet (lean/phase4/FiniteNet.lean, lines 75–78) · file SHA-256 1d45c47650006bb7…

First-layer gates read only the n input bits.

Statement as elaborated and printed by Lean 4.26.0

ℕ → List NimAudit.AC0.Layer → Prop
Exact source text, lines 75–78
75/-- First-layer gates read only the n input bits. -/76def Wired (n : Nat) : List Layer → Prop77  | [] => True78  | l :: _ => ∀ g ∈ l, g.fanin ≤ n

Project declarations in the statement: AC0.Layer

Project declarations used by the proof or definition body

AC0.Gate, AC0.Gate.fanin, AC0.Layer

def ThresholdNet.compileF

Module ThresholdNet (lean/phase5/ThresholdNet.lean, lines 480–484) · file SHA-256 15c36f444487a1bd…

THE COMPILED NETWORK for formulas cs on n input wires: 2·D + 1 computing layers of width S, then one output layer of width K = cs.length.

Statement as elaborated and printed by Lean 4.26.0

List NimAudit.AC0.Circ → List NimAudit.AC0.Layer
Exact source text, lines 480–484
480/-- THE COMPILED NETWORK for formulas cs on n input wires: 2·D + 1 computing layers of481    width S, then one output layer of width K = cs.length. -/482def compileF (cs : List Circ) : List Layer :=483  (List.range (nLayers cs)).map (fun t => layerAt (progOf cs) (t + 1)) ++484    [(outsOf cs).map (fun o => orGate (progOf cs).length (fun j => j == o) false)]

Project declarations in the statement: AC0.Circ, AC0.Layer

Project declarations used by the proof or definition body

AC0.Circ, AC0.Gate, AC0.Layer, Shared.DGate, ThresholdNet.layerAt, ThresholdNet.nLayers, ThresholdNet.orGate, ThresholdNet.outsOf, ThresholdNet.progOf

def ThresholdNet.gateCount

Module ThresholdNet (lean/phase5/ThresholdNet.lean, lines 684–685) · file SHA-256 15c36f444487a1bd…

Total number of gates: (2D + 1)·S computing gates and K output buffers.

Statement as elaborated and printed by Lean 4.26.0

List NimAudit.AC0.Layer → ℕ
Exact source text, lines 684–685
684/-- Total number of gates: (2D + 1)·S computing gates and K output buffers. -/685def gateCount (ls : List Layer) : Nat := (ls.map List.length).sum

Project declarations in the statement: AC0.Layer

Project declarations used by the proof or definition body

AC0.Gate, AC0.Layer

inductive AC0.Gate

Module Circuit (lean/phase3/Circuit.lean, lines 326–331) · file SHA-256 af97cc0eec7d8464…

A literal-threshold gate after clearing denominators: coefficients a_j, negation bits eta_j, threshold b. Its fan-in is `coeffs.length`.

Statement as elaborated and printed by Lean 4.26.0

Type
Exact source text, lines 326–331
326/-- A literal-threshold gate after clearing denominators: coefficients a_j,327    negation bits eta_j, threshold b.  Its fan-in is `coeffs.length`. -/328structure Gate where329  coeffs : List Nat330  negs : List Bool331  thr : Nat

Project declarations in the statement: none

Project declarations used by the proof or definition body

none

def AC0.Gate.Valid

Module Circuit (lean/phase3/Circuit.lean, lines 348–349) · file SHA-256 af97cc0eec7d8464…

Fixed-scale validity: threshold and coefficients in 0..W.

Statement as elaborated and printed by Lean 4.26.0

ℕ → NimAudit.AC0.Gate → Prop
Exact source text, lines 348–349
348/-- Fixed-scale validity: threshold and coefficients in 0..W. -/349def Valid (W : Nat) (g : Gate) : Prop := g.thr ≤ W ∧ ∀ a ∈ g.coeffs, a ≤ W

Project declarations in the statement: AC0.Gate

Project declarations used by the proof or definition body

AC0.Gate, AC0.Gate.coeffs, AC0.Gate.thr

def AC0.Gate.eval

Module Circuit (lean/phase3/Circuit.lean, lines 345–346) · file SHA-256 af97cc0eec7d8464…

The gate fires iff b ≤ Σ_j a_j [z_j XOR eta_j].

Statement as elaborated and printed by Lean 4.26.0

NimAudit.AC0.Gate → (ℕ → Bool) → Bool
Exact source text, lines 345–346
345/-- The gate fires iff b ≤ Σ_j a_j [z_j XOR eta_j]. -/346def eval (g : Gate) (z : Nat → Bool) : Bool := decide (g.thr ≤ g.wsum z)

Project declarations in the statement: AC0.Gate

Project declarations used by the proof or definition body

AC0.Gate, AC0.Gate.thr, AC0.Gate.wsum

def AC0.ratFires

Module Circuit (lean/phase3/Circuit.lean, lines 355–359) · file SHA-256 af97cc0eec7d8464…

Paper's form: weights a_j/D, threshold b/D, Heaviside(Σ w_j lit_j − θ).

Statement as elaborated and printed by Lean 4.26.0

NimAudit.AC0.Gate → ℕ → (ℕ → Bool) → Prop
Exact source text, lines 355–359
355/-- Paper's form: weights a_j/D, threshold b/D, Heaviside(Σ w_j lit_j − θ). -/356def ratFires (g : Gate) (D : Nat) (z : Nat → Bool) : Prop :=357  0 ≤ rsum (List.range g.fanin)358      (fun j => ((g.coeff j : Nat) : Rat) / (D : Rat) * (if g.lit z j then 1 else 0)) -359    ((g.thr : Nat) : Rat) / (D : Rat)

Project declarations in the statement: AC0.Gate

Project declarations used by the proof or definition body

AC0.Gate, AC0.Gate.coeff, AC0.Gate.fanin, AC0.Gate.lit, AC0.Gate.thr, Prob.rsum

def BoardStore.bsLen

Module BoardStore (lean/phase6/BoardStore.lean, lines 663–664) · file SHA-256 c35ac76d5db6e833…

Members (B, N), B, N ≥ 1, r = r' = log₂N + 1; input = registers + token.

Statement as elaborated and printed by Lean 4.26.0

ℕ × ℕ → ℕ
Exact source text, lines 663–664
663/-- Members (B, N), B, N ≥ 1, r = r' = log₂N + 1; input = registers + token. -/664def bsLen : Nat × Nat → Nat := fun i => sw i.1 i.2 (rIdx i.2) + 3 + i.1

Project declarations in the statement: none

Project declarations used by the proof or definition body

BoardStore.sw, WholeGame.rIdx

def BoardStore.bsNet

Module BoardStore (lean/phase6/BoardStore.lean, lines 713–713) · file SHA-256 c35ac76d5db6e833…

Statement as elaborated and printed by Lean 4.26.0

ℕ × ℕ → List NimAudit.AC0.Layer
Exact source text, lines 713–713
713def bsNet (i : Nat × Nat) : List Layer := compileF (bsAll i)

Project declarations in the statement: AC0.Layer

Project declarations used by the proof or definition body

BoardStore.bsAll, ThresholdNet.compileF

inductive Family.NetFam

Module Family (lean/phase6/Family.lean, lines 141–149) · file SHA-256 7a647f0a667d5ede…

NETWORK FAMILY CERTIFICATE: fixed grid W, at most L layers, valid gates, first layer reading only the len inputs, polynomial widths/fan-ins and polynomial gate count.

Statement as elaborated and printed by Lean 4.26.0

{ι : Type} → (ι → Prop) → (ι → ℕ) → (ι → List NimAudit.AC0.Layer) → ℕ → ℕ → Prop
Exact source text, lines 141–149
141/-- NETWORK FAMILY CERTIFICATE: fixed grid W, at most L layers, valid gates, first layer142    reading only the len inputs, polynomial widths/fan-ins and polynomial gate count. -/143structure NetFam {ι : Type} (adm : ι → Prop) (len : ι → Nat) (net : ι → List Layer) (W L : Nat) : Prop where144  pos : ∀ i, adm i → 1 ≤ len i145  valid : ∀ i, adm i → NetValid W (net i)146  wired : ∀ i, adm i → Wired (len i) (net i)147  layers : ∀ i, adm i → (net i).length ≤ L148  bounded : ∃ c k, ∀ i, adm i → NetBounded (c * len i ^ k) (net i)149  gates : PolyIn adm len (fun i => gateCount (net i))

Project declarations in the statement: AC0.Layer

Project declarations used by the proof or definition body

AC0.Layer, AC0.NetBounded, AC0.NetValid, Family.PolyIn, FiniteNet.Wired, ThresholdNet.gateCount

def Family.restAdm

Module Family (lean/phase6/Family.lean, lines 282–282) · file SHA-256 7a647f0a667d5ede…

Statement as elaborated and printed by Lean 4.26.0

ℕ × ℕ → Prop
Exact source text, lines 282–282
282def restAdm : Nat × Nat → Prop := fun i => 1 ≤ i.1 ∧ 1 ≤ i.2

Project declarations in the statement: none

Project declarations used by the proof or definition body

none

Full modules

ModuleFileLinesImports
BoardStorelean/phase6/BoardStore.lean824Bypass
Circuitlean/phase3/Circuit.lean1151NimProbability
Familylean/phase6/Family.lean574WholeGame
FiniteNetlean/phase4/FiniteNet.lean220Circuit
NimCorrBridgelean/phase3/NimCorrBridge.lean922BitBridge
PriorityEncoderlean/phase5/PriorityEncoder.lean430LocalRestore, BinaryReadout
SelectCircuitlean/phase4/SelectCircuit.lean1064ControllerBits
ThresholdNetlean/phase5/ThresholdNet.lean780SharedCircuit, FiniteNet

Build evidence: fresh isolated rebuild of all 38 bundled modules with Lean (version 4.26.0, started 2026-10-10T15:21:56Z, finished 2026-10-10T15:27:00Z: 38/38 modules compiled, 1588 axiom reports, no errors. See Build for the commands and the independent audit of 2026-10-10 (dated evidence).