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