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

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

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

1 Paper text

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

Generated from paper_jmlr.tex, lines 1406–1415.

2 Explain this

Statement. A single unit f(z)=H(∑jwjzj−θ)f(z)=\mathbf H(\sum_j w_jz_j-\theta) with grid weights and threshold is computed by a depth-2 AC0 circuit (an OR of ANDs) of size O(mW)O(m^W).

Proof idea. Multiply by DD: f(z)=1f(z)=1 iff ∑jajzj≥b\sum_j a_jz_j\ge b with integers 0≤aj,b≤W0\le a_j,b\le W. If b=0b=0 the unit is constantly 11. Otherwise each active input contributes at least 11, so if the sum reaches bb, greedily choosing active inputs reaches bb after at most b≤Wb\le W steps. Hence f(z)=1f(z)=1 iff some set TT of at most WW inputs with ∑j∈Taj≥b\sum_{j\in T}a_j\ge b is all true: an OR over at most ∑r≤W(mr)=O(mW)\sum_{r\le W}\binom mr=O(m^W) ANDs.

Example. W=2W=2, D=1D=1, weights (1,1,2)(1,1,2), threshold 22: f=(z1∧z2)∨z3f=(z_1\wedge z_2)\vee z_3.

3 How this is formalised

  • AC0.Gate.bounded_witness: if the gate fires, an initial segment of its active literals, of length at most the threshold, already reaches the threshold.
  • AC0.gate_ac0: the DNF AC0.dnf computes the gate exactly; depth at most 33 when NOT nodes are counted; size at most 1+(m+1)W(2W+1)1+(m+1)^W(2W+1); it reads only the gate's inputs. Edge cases b=0b=0, m=0m=0 and W=0W=0 are included.
  • ClassicalBoundary.dnf_aoDepth: in the classical convention (negations on inputs not counted) the same DNF has AND/OR depth at most 22, as the lemma states.
Coverage record
Paper anchorlem:unit-ac0 (manuscript label)
Displayed asLemma B.1
ClaimOne fixed-scale threshold gate is a depth-2 DNF of size O(m^W)
Coverage categoryChecked theorem
Statement sourcepaper_jmlr.tex lines 1406–1415; SHA-256 of the normalised block source aab403d1ce883221…
Lean declarations
Prose-to-formal notes

Lean's depth counts NOT gates and gives depth at most 3; in the classical convention (negations on inputs not counted) the same DNF has AND/OR depth 2. The Lean size bound is 1+(m+1)W(2W+1)1+(m+1)^W(2W+1).

Audited correspondence rowslem:unit-ac0, app:oneunit
Explanationsexplain/lem:unit-ac0, formal/lem:unit-ac0
Build evidencefresh isolated rebuild, audit report

4 Lean statement and source

Principal declarations

theorem AC0.Gate.bounded_witness

Module Circuit (lean/phase3/Circuit.lean, lines 499–538) · file SHA-256 af97cc0eec7d8464… Axioms reported by the fresh build: propext, Quot.sound

BOUNDED WITNESS LEMMA. If the gate fires on z, there is a list T of at most b ≤ W distinct input positions, all with true literal and positive coefficient, whose coefficients sum to at least b; T is an initial segment of the active literals (T = active literals below a cut c').

Statement as elaborated and printed by Lean 4.26.0

∀ (g : NimAudit.AC0.Gate) (z : ℕ → Bool),
  g.eval z = true →
    ∃ c' ≤ g.fanin,
      (g.active z c').length ≤ g.thr ∧
        (∀ j ∈ g.active z c', g.lit z j = true ∧ 1 ≤ g.coeff j ∧ j < c') ∧
          g.thr ≤ NimAudit.AC0.nsum g.fanin fun j => if j ∈ g.active z c' then g.coeff j else 0
Exact source text, lines 499–538
499/-- BOUNDED WITNESS LEMMA.  If the gate fires on z, there is a list T of at most500    b ≤ W distinct input positions, all with true literal and positive coefficient,501    whose coefficients sum to at least b; T is an initial segment of the active502    literals (T = active literals below a cut c'). -/503theorem bounded_witness (g : Gate) (z : Nat → Bool) (h : g.eval z = true) :504    ∃ c' ≤ g.fanin,505      (g.active z c').length ≤ g.thr ∧506      (∀ j ∈ g.active z c', g.lit z j = true ∧ 1 ≤ g.coeff j ∧ j < c') ∧507      g.thr ≤ nsum g.fanin (fun j => if j ∈ g.active z c' then g.coeff j else 0) := by508  unfold eval wsum at h509  have h' : g.thr ≤ g.psum z g.fanin := of_decide_eq_true h510  obtain ⟨c', hc', h1, h2⟩ := exists_cut g z g.fanin h'511  refine ⟨c', hc', ?_, ?_, ?_⟩512  · -- length bound513    cases c' with514    | zero => simp [active]515    | succ c =>516      have hlt := h2 c (by omega)517      have hlen := active_length_le g z c518      have hstep : (g.active z (c + 1)).length ≤ (g.active z c).length + 1 := by519        unfold active520        rw [List.range_succ, List.filter_append, List.length_append]521        have : (List.filter (fun j => g.lit z j && decide (1 ≤ g.coeff j)) [c]).length ≤ 1 := by522          simp only [List.filter_cons, List.filter_nil]; split <;> simp523        omega524      omega525  · intro j hj526    unfold active at hj527    simp only [List.mem_filter, List.mem_range, Bool.and_eq_true, decide_eq_true_eq] at hj528    exact ⟨hj.2.1, hj.2.2, hj.1⟩529  · have e : nsum g.fanin (fun j => if j ∈ g.active z c' then g.coeff j else 0) =530        nsum g.fanin (fun j => if j < c' then g.coeff j * (if g.lit z j then 1 else 0) else 0) := by531      apply nsum_congr532      intro j _533      unfold active534      simp only [List.mem_filter, List.mem_range, Bool.and_eq_true, decide_eq_true_eq]535      by_cases hjc : j < c' <;> by_cases hl : g.lit z j = true <;>536        by_cases ha : 1 ≤ g.coeff j <;> simp [hjc, hl, ha] <;> omega537    rw [e, nsum_cut _ hc']538    exact h1

Project declarations in the statement: AC0.Gate, AC0.Gate.active, AC0.Gate.coeff, AC0.Gate.eval, AC0.Gate.fanin, AC0.Gate.lit, AC0.Gate.thr, AC0.nsum

Project declarations used by the proof or definition body

AC0.Gate, AC0.Gate.active, AC0.Gate.active_length_le, AC0.Gate.coeff, AC0.Gate.eval, AC0.Gate.exists_cut, AC0.Gate.fanin, AC0.Gate.lit, AC0.Gate.psum, AC0.Gate.thr, AC0.nsum, AC0.nsum_congr, AC0.nsum_cut

theorem AC0.gate_ac0

Module Circuit (lean/phase3/Circuit.lean, lines 735–739) · file SHA-256 af97cc0eec7d8464… Axioms reported by the fresh build: propext, Classical.choice, Quot.sound

ONE-GATE LEMMA (paper Lemma unit-ac0): exact, depth ≤ 3, size ≤ 1 + (m+1)^W (2W+1).

Statement as elaborated and printed by Lean 4.26.0

∀ {W : ℕ} (g : NimAudit.AC0.Gate),
  g.thr ≤ W →
    (∀ (z : ℕ → Bool), NimAudit.AC0.Circ.eval z (NimAudit.AC0.dnf W g) = g.eval z) ∧
      (NimAudit.AC0.dnf W g).depth ≤ 3 ∧
        (NimAudit.AC0.dnf W g).size ≤ 1 + (g.fanin + 1) ^ W * (2 * W + 1) ∧
          (NimAudit.AC0.dnf W g).maxInput ≤ g.fanin
Exact source text, lines 735–739
735/-- ONE-GATE LEMMA (paper Lemma unit-ac0): exact, depth ≤ 3, size ≤ 1 + (m+1)^W (2W+1). -/736theorem gate_ac0 {W : Nat} (g : Gate) (hW : g.thr ≤ W) :737    (∀ z, eval z (dnf W g) = g.eval z) ∧ depth (dnf W g) ≤ 3 ∧738      size (dnf W g) ≤ 1 + (g.fanin + 1) ^ W * (2 * W + 1) ∧ maxInput (dnf W g) ≤ g.fanin :=739  ⟨eval_dnf g hW, depth_dnf W g, size_dnf W g, maxInput_dnf W g⟩

Project declarations in the statement: AC0.Circ.depth, AC0.Circ.eval, AC0.Circ.maxInput, AC0.Circ.size, AC0.Gate, AC0.Gate.eval, AC0.Gate.fanin, AC0.Gate.thr, AC0.dnf

Project declarations used by the proof or definition body

AC0.Circ.depth, AC0.Circ.eval, AC0.Circ.maxInput, AC0.Circ.size, AC0.Gate, AC0.Gate.eval, AC0.Gate.fanin, AC0.Gate.thr, AC0.depth_dnf, AC0.dnf, AC0.eval_dnf, AC0.maxInput_dnf, AC0.size_dnf

theorem ClassicalBoundary.dnf_aoDepth

Module Classical (lean/phase6/Classical.lean, lines 211–229) · file SHA-256 ee9d365e1611d40c… Axioms reported by the fresh build: propext, Quot.sound

Lemma lem:unit-ac0 in the paper's convention: one fixed-scale gate is a DEPTH-2 DNF when negations on inputs are not counted (our NOT-counting depth bound was 3).

Statement as elaborated and printed by Lean 4.26.0

∀ (W : ℕ) (g : NimAudit.AC0.Gate), NimAudit.ClassicalBoundary.aoDepth (NimAudit.AC0.dnf W g) ≤ 2
Exact source text, lines 211–229
211/-- Lemma lem:unit-ac0 in the paper's convention: one fixed-scale gate is a DEPTH-2 DNF212    when negations on inputs are not counted (our NOT-counting depth bound was 3). -/213theorem dnf_aoDepth (W : Nat) (g : Gate) : aoDepth (dnf W g) ≤ 2 := by214  unfold dnf215  rw [aoDepth_or]216  have : listMax ((((boards (g.fanin + 1) W).filter (fun t => decide (g.thr ≤ selSum g t))).map (termC g)).map aoDepth) ≤ 1 := by217    apply listMax_le; intro a ha218    obtain ⟨c, hc, rfl⟩ := List.mem_map.mp ha219    obtain ⟨t, _, rfl⟩ := List.mem_map.mp hc220    unfold termC; rw [aoDepth_and]221    have : listMax ((t.filterMap (fun j => if j < g.fanin then some (litC g j) else none)).map aoDepth) ≤ 0 := by222      apply listMax_le; intro b hb223      obtain ⟨c', hc', rfl⟩ := List.mem_map.mp hb224      obtain ⟨j, _, hj⟩ := List.mem_filterMap.mp hc'225      split at hj226      · cases hj; unfold litC; split <;> simp [aoDepth]227      · cases hj228    omega229  omega

Project declarations in the statement: AC0.Gate, AC0.dnf, ClassicalBoundary.aoDepth

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.listMax_le, AC0.Circ.not, AC0.Circ.or, AC0.Circ.rec, AC0.Circ.rec_1, AC0.Gate, AC0.Gate.fanin, AC0.Gate.negs, AC0.Gate.thr, AC0.dnf, AC0.litC, AC0.selSum, AC0.termC, ClassicalBoundary.aoDepth, ClassicalBoundary.aoDepth_and, ClassicalBoundary.aoDepth_or, Prob.boards

Definitions these statements use

def AC0.dnf

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

DNF: OR over padded tuples t ∈ {0..m}^W with selSum ≥ b of termC t.

Statement as elaborated and printed by Lean 4.26.0

ℕ → NimAudit.AC0.Gate → NimAudit.AC0.Circ
Exact source text, lines 560–562
560/-- DNF: OR over padded tuples t ∈ {0..m}^W with selSum ≥ b of termC t. -/561def dnf (W : Nat) (g : Gate) : Circ :=562  or (((boards (g.fanin + 1) W).filter (fun t => decide (g.thr ≤ selSum g t))).map (termC g))

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

Project declarations used by the proof or definition body

AC0.Circ, AC0.Circ.or, AC0.Gate, AC0.Gate.fanin, AC0.Gate.thr, AC0.selSum, AC0.termC, Prob.boards

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

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

The active (true, positive-coefficient) literals among the first c inputs.

Statement as elaborated and printed by Lean 4.26.0

NimAudit.AC0.Gate → (ℕ → Bool) → ℕ → List ℕ
Exact source text, lines 473–475
473/-- The active (true, positive-coefficient) literals among the first c inputs. -/474def active (g : Gate) (z : Nat → Bool) (c : Nat) : List Nat :=475  (List.range c).filter (fun j => g.lit z j && decide (1 ≤ g.coeff j))

Project declarations in the statement: AC0.Gate

Project declarations used by the proof or definition body

AC0.Gate, AC0.Gate.coeff, AC0.Gate.lit

def AC0.Gate.coeff

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

Statement as elaborated and printed by Lean 4.26.0

NimAudit.AC0.Gate → ℕ → ℕ
Exact source text, lines 336–336
336def coeff (g : Gate) (j : Nat) : Nat := g.coeffs.getD j 0

Project declarations in the statement: AC0.Gate

Project declarations used by the proof or definition body

AC0.Gate, AC0.Gate.coeffs

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

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

Statement as elaborated and printed by Lean 4.26.0

NimAudit.AC0.Gate → ℕ
Exact source text, lines 335–335
335def fanin (g : Gate) : Nat := g.coeffs.length

Project declarations in the statement: AC0.Gate

Project declarations used by the proof or definition body

AC0.Gate, AC0.Gate.coeffs

def AC0.Gate.lit

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

Statement as elaborated and printed by Lean 4.26.0

NimAudit.AC0.Gate → (ℕ → Bool) → ℕ → Bool
Exact source text, lines 337–337
337def lit (g : Gate) (z : Nat → Bool) (j : Nat) : Bool := xor (z j) (g.negs.getD j false)

Project declarations in the statement: AC0.Gate

Project declarations used by the proof or definition body

AC0.Gate, AC0.Gate.negs

def AC0.Gate.thr

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

Statement as elaborated and printed by Lean 4.26.0

NimAudit.AC0.Gate → ℕ
Exact source text, lines 331–331
331  thr : Nat

Project declarations in the statement: AC0.Gate

Project declarations used by the proof or definition body

AC0.Gate

def AC0.nsum

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

Statement as elaborated and printed by Lean 4.26.0

ℕ → (ℕ → ℕ) → ℕ
Exact source text, lines 409–409
409def nsum (c : Nat) (f : Nat → Nat) : Nat := ((List.range c).map f).sum

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

Module Classical (lean/phase6/Classical.lean, lines 44–50) · file SHA-256 ee9d365e1611d40c…

AND/OR depth: NOT nodes and leaves contribute nothing.

Statement as elaborated and printed by Lean 4.26.0

NimAudit.AC0.Circ → ℕ
Exact source text, lines 44–50
44/-- AND/OR depth: NOT nodes and leaves contribute nothing. -/45def aoDepth : Circ → Nat46  | .input _ => 047  | .const _ => 048  | .not c => aoDepth c49  | .and cs => listMax (cs.attach.map (fun ⟨c, _⟩ => aoDepth c)) + 150  | .or cs => listMax (cs.attach.map (fun ⟨c, _⟩ => aoDepth 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

Full modules

ModuleFileLinesImports
Circuitlean/phase3/Circuit.lean1151NimProbability
Classicallean/phase6/Classical.lean587Bypass

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