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

Appendix C, “Realisation with fixed-scale threshold gates”Compiler from formulas to {0,1}-weight threshold networks: ≤2d+2 layers, ≤(2d+1)S+K gates, widths ≤ S+n

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

1 Paper text

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.

Generated from paper_jmlr.tex, lines 1513–1515.

2 Explain this

Any of these Boolean circuits can be turned into a network of the paper's fixed-scale gates with weights and thresholds in {0,1}\{0,1\}: an OR gate is a threshold-1 gate; NOT is a negated literal; AND is built by De Morgan from ORs and negations, so no threshold ever needs to equal a growing fan-in. For KK output formulas of depth at most dd and total size SS on fewer than nn inputs, the compiler builds one network with at most 2d+22d+2 layers, at most (2d+1)S+K(2d+1)S+K gates, and widths and fan-ins at most S+nS+n, and every output equals its formula on every input.

From Boolean formulas to threshold layers

Exact trace and teaching example The checked compiler’s exact output is shown beside a hand-made teaching circuit; each part is labelled.

Every gate in these networks has weights and thresholds in {0,1}\{0,1\}. An OR gate fires when at least one of its literals is 1. NOT is a negated literal. An AND needs two layers: an OR of the negated inputs (that is, NOT AND), then a negated copy. Choose a formula and set the inputs. The hand-made circuit on the left uses the fewest layers possible in this gate model. The grid on the right is exactly what the checked compiler of Figure 8 builds for the same formula, with the value of every wire at every layer. The two answer the same truth table, but only the compiler comes with a general proof.

Formula: XOR(a, b) (Lean term: xor2 (input 0) (input 1) = or [and [a, not b], and [not a, b]]). Boolean depth d = 3, formula size 9.

Input: a = 1 b = 0

Teaching example A hand-made circuit

2 threshold layers, the fewest possible in this gate model. Every gate is an OR of literals with weights 1 and threshold 1, so an AND needs two layers (De Morgan).

LayerGates
1u = OR(¬a, b) → 0
v = OR(a, ¬b) → 1
2OR(¬u, ¬v) = XOR(a, b) → 1

Output: 1

Exact construction trace What the checked compiler builds

The network ThresholdNet.compileF produces for this formula, as Lean computes it: 8 layers (the bound is 2d + 2 = 8); each of the 7 computing layers has one wire per program gate (S = 9); 64 gates in total (the bound is (2d + 1)S + K = 64). Each cell shows what that wire does at that layer and its value on the input above. “·” is an idle wire (constant 0 until its inputs are ready); “copy” is an identity buffer. Layer 1 reads the inputs into the construction and the last layer arranges the outputs: these are the two extra layers in 2d + 2, and the factor 2 lets every Boolean level cost as much as an AND.

Program gate1234567out
g0 = input ain
1
copy
1
copy
1
copy
1
copy
1
copy
1
copy
1
g1 = input bin
0
copy
0
copy
0
copy
0
copy
0
copy
0
copy
0
g2 = NOT g1·
0
NOT
1
copy
1
copy
1
copy
1
copy
1
copy
1
g3 = AND(g0, g2)·
0
·
0
AND₁
0
AND₂
1
copy
1
copy
1
copy
1
g4 = input ain
1
copy
1
copy
1
copy
1
copy
1
copy
1
copy
1
g5 = NOT g4·
0
NOT
0
copy
0
copy
0
copy
0
copy
0
copy
0
g6 = input bin
0
copy
0
copy
0
copy
0
copy
0
copy
0
copy
0
g7 = AND(g5, g6)·
0
·
0
AND₁
1
AND₂
0
copy
0
copy
0
copy
0
g8 = OR(g3, g7)·
0
·
0
·
0
·
0
OR
1
copy
1
copy
1
out
1

Output: 1

Truth table

a bformulateaching circuitcompiled network
0 0000agree
0 1111agree
1 0111agree
1 1000agree

The two-frame selector’s depth bound is a sum of bounds for composed subcircuits:

  • 4 · frame difference
  • 4 · candidate tests and replacement bits
  • 9 · selection, fallback and output
  • 3 · binary index

Boolean depth ≤ 20 → the compiler’s rule 2d + 2 → at most 42 threshold layers.

For comparison, the actual formulas for small boards, measured by Lean (the compiler uses their real depth D, not the bound):

Board sizedepth Dlayers 2D + 2width S (formula nodes)gates (2D + 1)S + K
B = 2, N = 215322,00962,284
B = 3, N = 3153213,228410,074
B = 3, N = 4153234,1921,059,959
B = 4, N = 4153263,1451,957,503

The width counts every node of every output formula, duplicates included, so it is far from economical. These numbers describe the uniform construction, not an optimised network and not a trained one.

How this relates to the Lean proof. The grid is the output of ThresholdNet.compileF as Lean evaluates it on these formulas; the browser only evaluates the exported gates. ThresholdNet.compileF_spec proves, for any list of formulas of depth at most dd, that the network has at most 2d+22d+2 layers and computes every formula exactly. The selector bounds in the table of Appendix C come from this rule: Family.rest_ac0 (Boolean depth at most 20) and Family.rest_net (at most 42 layers with weights and thresholds 0 or 1).

What this does not show. The 42-layer figure is an upper bound for one explicit, deliberately uniform construction. It is not a lower bound, not a layer count measured in an experiment, and not a statement about which networks training finds. A more economical network may use fewer layers: for the small boards in the table, the selector formulas Lean builds have depth 15, so even the uniform compiler produces 32 layers, below the bound of 42. Proving a sharper general bound would need a separate construction and proof.

A truth-table expansion can reduce Boolean depth to two AND–OR levels with negated inputs, but may require exponentially many gates. The polynomial-size condition is therefore essential when comparing these depth bounds.

Depicted in Lean: ThresholdNet.orGate_eval, ThresholdNet.constGate_eval, ThresholdNet.layerAt, ThresholdNet.compileF, ThresholdNet.compileF_spec, ThresholdNet.compileF_fixed_grid, Family.rest_ac0, Family.rest_net. Explains the paper’s Figure 8.

The grid is the network Lean itself computes for each formula; your browser only evaluates its gates (agreement with Lean's evaluation was checked for all 4 formulas and every input at build time). The hand-made circuit is a teaching example, not part of the checked construction.

3 How this is formalised

  • ThresholdNet.compileF_spec: for formulas reading inputs below nn with depth at most DD, the network ThresholdNet.compileF has exact outputs (and false beyond them), is valid for W=1W=1, reads only the nn inputs in its first layer, has at most 2D+22D+2 layers, widths and fan-ins at most S+nS+n, and at most (2D+1)S+K(2D+1)S+K gates.
  • ThresholdNet.compileF_fixed_grid: every compiled gate fires in the paper's rational form with D=1D=1 exactly when it fires in integer form.
  • ThresholdNet.compileF_bounded: the width and fan-in bound.
Coverage record
Paper anchorpar-realisation-with-fixed-scale-threshold-gates-p1 (website anchor; the manuscript has no label here)
Displayed asAppendix C, “Realisation with fixed-scale threshold gates”
ClaimCompiler from formulas to {0,1}-weight threshold networks: ≤2d+2 layers, ≤(2d+1)S+K gates, widths ≤ S+n
Coverage categoryChecked theorem
Statement sourcepaper_jmlr.tex lines 1513–1515; SHA-256 of the normalised block source 34cc9a8cd7d7624c…
Lean declarations
Audited correspondence rowsapp:impl
Explanationsexplain/c-threshold-realisation, formal/c-threshold-realisation
Build evidencefresh isolated rebuild, audit report

4 Lean statement and source

Principal declarations

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

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

BOUNDED WIDTH AND FAN-IN: every layer has ≤ S + n gates, every gate fan-in ≤ S + n, where S = Σ size(c_k) is the program size.

Statement as elaborated and printed by Lean 4.26.0

∀ (cs : List NimAudit.AC0.Circ) (n : ℕ),
  (∀ c ∈ cs, c.maxInput ≤ n) →
    NimAudit.AC0.NetBounded ((List.map NimAudit.AC0.Circ.size cs).sum + n)
      (NimAudit.ThresholdNet.compileF cs)
Exact source text, lines 639–682
639/-- BOUNDED WIDTH AND FAN-IN: every layer has ≤ S + n gates, every gate fan-in ≤ S + n,640    where S = Σ size(c_k) is the program size. -/641theorem compileF_bounded (cs : List Circ) (n : Nat) (hn : ∀ c ∈ cs, maxInput c ≤ n) :642    NetBounded ((cs.map size).sum + n) (compileF cs) := by643  have hmx : listMax (cs.map maxInput) ≤ n := listMax_le (fun a ha => by644    obtain ⟨c, hc, rfl⟩ := List.mem_map.mp ha; exact hn c hc)645  have hS := prog_length cs646  intro l hl647  simp only [compileF, List.mem_append, List.mem_map, List.mem_range, List.mem_singleton] at hl648  rcases hl with ⟨t, _, rfl⟩ | rfl649  · refine ⟨by simp only [layerAt]; split <;> simp [hS], ?_⟩650    intro g hg651    simp only [layerAt] at hg652    split at hg653    · simp only [List.mem_map, List.mem_range] at hg654      obtain ⟨g', hg', rfl⟩ := hg655      have hmem : (progOf cs).getD g' (.cst false) ∈ progOf cs := by656        rw [getD_eq_getElem' hg']; exact List.getElem_mem hg'657      have hr := emitL_reads 0 cs _ hmem658      generalize (progOf cs).getD g' (.cst false) = d at hr659      cases d with660      | inp i => simp only [gate1, orGate_fanin]; simp [gmax] at hr; omega661      | cst b => simp [gate1, constGate_fanin]662      | neg a => simp only [gate1]; split <;> simp [constGate_fanin]663      | disj as => simp [gate1, constGate_fanin]664      | conj as => simp only [gate1]; split <;> (try split) <;> simp [constGate_fanin]665    · simp only [List.mem_map, List.mem_range] at hg666      obtain ⟨g', _, rfl⟩ := hg667      generalize (progOf cs).getD g' (.cst false) = d668      unfold gateT669      split670      · rw [orGate_fanin]; omega671      · split672        · cases d <;> simp only <;> (try split) <;>673            first | (rw [orGate_fanin]; omega) | (rw [constGate_fanin]; omega)674        · split675          · cases d <;> simp only <;> (try split) <;>676              first | (rw [orGate_fanin]; omega) | (rw [constGate_fanin]; omega)677          · rw [constGate_fanin]; omega678  · refine ⟨by simp [outs_length]; have := cs_le_prog cs; omega, ?_⟩679    intro g hg680    simp only [List.mem_map] at hg681    obtain ⟨o, _, rfl⟩ := hg682    rw [orGate_fanin]; omega

Project declarations in the statement: AC0.Circ, AC0.Circ.maxInput, AC0.Circ.size, AC0.NetBounded, ThresholdNet.compileF

Project declarations used by the proof or definition body

AC0.Circ, AC0.Circ.listMax, AC0.Circ.listMax_le, AC0.Circ.maxInput, AC0.Circ.size, AC0.Gate, AC0.Gate.fanin, AC0.Layer, Shared.DGate, Shared.DGate.casesOn, Shared.DGate.conj, Shared.DGate.cst, Shared.DGate.disj, Shared.DGate.inp, Shared.DGate.neg, Shared.emitL_reads, Shared.gmax, ThresholdNet.compileF, ThresholdNet.constGate, ThresholdNet.constGate_fanin, ThresholdNet.cs_le_prog, ThresholdNet.gate1, ThresholdNet.gateT, ThresholdNet.gateT._sparseCasesOn_1, ThresholdNet.getD_eq_getElem', ThresholdNet.layerAt, ThresholdNet.lv, ThresholdNet.nLayers, ThresholdNet.orGate, ThresholdNet.orGate_fanin, ThresholdNet.outsOf, ThresholdNet.outs_length, ThresholdNet.progOf, ThresholdNet.prog_length

Definitions these statements use

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

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

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

Full modules

ModuleFileLinesImports
Circuitlean/phase3/Circuit.lean1151NimProbability
FiniteNetlean/phase4/FiniteNet.lean220Circuit
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).