Documentation

CslibFrontier.Computability.Circuit.Boolean.SymAnd.ACC0

ACC⁰ circuits are quasi-polynomial SYM ∘ AND circuits #

Theorem (Yao; Beigel–Tarui [BeigelTarui1994, Theorem 1.1]). A circuit of size s and depth d on n inputs with NOT, unbounded AND/OR and MOD_m gates, m > 0 (Unbounded.extInterpretation (modGate m)), computes the same function as a SYM ∘ AND circuit (Circuits.Boolean.SymAnd) of fan-in at most (2B) ^ (5 ^ (d (m + 2))) and at most 2 ^ ((2B) ^ (5 ^ (d (m + 2)))) AND gates, where B = 3 ((m + 1) ^ 2 + ⌊log₂ (n + s)⌋ + 2) (Circuit.exists_symAnd_eval_eq). For fixed d and m this is fan-in polylog(n + s) and size 2 ^ polylog(n + s), so every language of AC0Mod m and of ACC0 is decided by SYM ∘ AND circuits of polylogarithmic fan-in and quasi-polynomial size (exists_symAnd_of_mem_AC0Mod, exists_symAnd_of_mem_ACC0).

Construction. Fix a seed r of the binary field 𝔽_{2^κ} (Cslib.BinaryField), with κ = 2 ⌊log₂ (n + s)⌋ + 4. Each seed runs its own tower of prime-modulus polynomial layers (Circuits.Boolean.ModPolyLayer) on one slot per wire of the circuit and one auxiliary slot per gate k, prime p and digit i. Every gate is evaluated by the polynomials below, and d rounds of the following layers make every gate of depth at most d correct:

The seeded OR test is wrong for a gate only if the seed is a root of a nonzero polynomial of degree below n + s (Cslib.BitString.card_filter_sum_pow_eq_zero_le), so on every input fewer than half of the seeds are bad. The majority over the seeds of the output slot is a SYM ∘ AND circuit of fan-in 1 on top of the towers; it collapses through them (SymAnd.collapseRun, from [BeigelTarui1994, Lemma 2.8]), and restricting the non-input slots to their initial value false (SymAnd.restrict) gives a circuit over the inputs.

Beigel and Tarui isolate a true argument of an OR gate by the Valiant–Vazirani lemma [BeigelTarui1994, Lemma 2.3]; the seeded OR test here instead uses the powering construction of Alon, Goldreich, Håstad and Peralta [AlonGoldreichHastadPeralta1992, §5, Construction 3 and Proposition 3, June 14, 1992, p. 10]: a seed is one element of 𝔽_{2^κ}, κ = O(log (n + s)) bits, and every test has degree κ. The source handles MOD_m through stratified circuits with one modulus m per level [BeigelTarui1994, Section 2.2]; here each MOD_m gate becomes MOD_p digit tests, so every layer of the tower has a prime modulus. The exponent 5 ^ (d (m + 2)) is not optimized.

The circuit is canonical: Circuit.toSymAnd C m is built from C and m by the steps above, with no witness taken from an existence proof (Circuit.eval_toSymAnd, Circuit.fanIn_toSymAnd_le, Circuit.size_toSymAnd_le): the seed field uses its least irreducible modulus and each collapse uses the canonical Möbius circuit. Equality in the seed field is decided classically, so the definition is not executable as a Lean term. Williams's algorithm needs the circuit to be constructed in time 2 ^ polylog(s) [Wil14]; that computation is not formalized here.

Main definitions #

Main results #

References #

@[reducible, inline]

The slots of one seed: one per wire of the circuit, and one per gate k, prime p and digit i, for the digit test C(c_k, p ^ i) ≢ 0 (mod p).

The prime p and digit i read by the MOD_m gates: p prime with p ^ (i + 1) ∣ m.

theorem Cslib.Circuits.Boolean.ACC0ToSymAnd.mem_rel {m : ℕ} {pi : Fin (m + 1) × Fin (m + 1)} :
pi ∈ rel m ↔ Nat.Prime ↑pi.1 ∧ ↑pi.1 ^ (↑pi.2 + 1) ∣ m

Membership in rel m.

There are at most (m + 1) ^ 2 digit tests per gate.

There are at most m + 1 primes p ≤ m.

@[reducible, inline]

The seeds: the binary field with 2 ^ (2ℓ + 2) elements.

noncomputable def Cslib.Circuits.Boolean.ACC0ToSymAnd.seedBasis (ℓ : ℕ) :
Module.Basis (Fin (2 * ℓ + 2)) (ZMod 2) (Seed ℓ)

The power basis of the seeds over 𝔽₂.

An injective numbering of the wires by [0, n + g).

theorem Cslib.Circuits.Boolean.ACC0ToSymAnd.widx_lt {n g : ℕ} (w : Wire n g) :
widx w < n + g

The wire numbering takes values below n + g.

The layers #

noncomputable def Cslib.Circuits.Boolean.ACC0ToSymAnd.linePoly {n g m ℓ : ℕ} (r : Seed ℓ) (k : Fin g) (L : Line Unbounded.extSignature n g) (u : Slot n g m → Bool) :

The integer polynomial evaluating gate k with line L from the slots u of seed r: NOT is 1 - y; OR is the seeded OR test and AND its dual; MOD_m is the OR of its digit tests.

noncomputable def Cslib.Circuits.Boolean.ACC0ToSymAnd.combineQ {n g m ℓ : ℕ} (P : Program Unbounded.extSignature n g) (r : Seed ℓ) :
Slot n g m → (Slot n g m → Bool) → ℤ

The MOD_2 layer polynomial of seed r: every gate is evaluated by linePoly; the other slots keep their values.

noncomputable def Cslib.Circuits.Boolean.ACC0ToSymAnd.digitPoly {n g m : ℕ} (L : Line Unbounded.extSignature n g) (e : ℕ) (u : Slot n g m → Bool) :

The sum of the e-element monomials of the arguments of L, which is C(c, e) for c the number of true arguments.

noncomputable def Cslib.Circuits.Boolean.ACC0ToSymAnd.digitQ {n g m : ℕ} (P : Program Unbounded.extSignature n g) (p₀ : ℕ) :
Slot n g m → (Slot n g m → Bool) → ℤ

The MOD_{p₀} layer polynomial: the digit test slots of p₀ read digitPoly; the other slots keep their values.

structure Cslib.Circuits.Boolean.ACC0ToSymAnd.SLayer (F : Type u_1) (S : Type u_2) :
Type (max u_1 u_2)

A layer of the towers: a modulus, and a slot polynomial for every seed.

  • p : ℕ

    The modulus.

  • q : F → S → (S → Bool) → ℤ

    The slot polynomials of each seed.

The layer of one seed.

All seeds side by side: the layer on F × S acting on each row by the layer of its seed.

theorem Cslib.Circuits.Boolean.ACC0ToSymAnd.SLayer.run_lift {F : Type u_1} {S : Type u_2} (Ls : List (SLayer F S)) (v : F × S → Bool) (r : F) (s : S) :
ModPolyLayer.run (List.map lift Ls) v (r, s) = ModPolyLayer.run (List.map (fun (L : SLayer F S) => L.atSeed r) Ls) (fun (s' : S) => v (r, s')) s

Running the lifted layers acts on each row as the layers of its seed.

noncomputable def Cslib.Circuits.Boolean.ACC0ToSymAnd.macroS {n g : ℕ} (P : Program Unbounded.extSignature n g) (m ℓ : ℕ) :
List (SLayer (Seed ℓ) (Slot n g m))

One round: the MOD_p digit layers for the primes p ≤ m, then the MOD_2 layer.

noncomputable def Cslib.Circuits.Boolean.ACC0ToSymAnd.towerS {n g : ℕ} (P : Program Unbounded.extSignature n g) (m ℓ a✝ : ℕ) :
List (SLayer (Seed ℓ) (Slot n g m))

d rounds.

d rounds have d (π(m) + 1) layers, for π(m) the number of primes p ≤ m.

Correctness for a good seed #

def Cslib.Circuits.Boolean.ACC0ToSymAnd.GoodAt {n g ℓ : ℕ} (r : Seed ℓ) (A : Finset (Wire n g)) (y : Wire n g → Bool) :

A good seed for the argument set A under the values y: the vectors r ^ idx w of the true arguments sum to a nonzero element exactly when some argument is true.

Instances For
    @[instance_reducible]
    noncomputable instance Cslib.Circuits.Boolean.ACC0ToSymAnd.instDecidableGoodAt {n g ℓ : ℕ} (r : Seed ℓ) (A : Finset (Wire n g)) (y : Wire n g → Bool) :
    theorem Cslib.Circuits.Boolean.ACC0ToSymAnd.map_atSeed_macroS {n g m ℓ : ℕ} (P : Program Unbounded.extSignature n g) (r : Seed ℓ) :
    List.map (fun (L : SLayer (Seed ℓ) (Slot n g m)) => L.atSeed r) (macroS P m ℓ) = { p := 2, q := combineQ P r } :: List.map (fun (p₀ : ℕ) => { p := p₀, q := digitQ P p₀ }) (primes m)

    The layers of one round at seed r.

    def Cslib.Circuits.Boolean.ACC0ToSymAnd.WiresOK {n g : ℕ} (P : Program Unbounded.extSignature n g) (m : ℕ) (x : Fin n → Bool) (j : ℕ) (u : Slot n g m → Bool) :

    After j rounds, the slots u hold the correct value of every wire of depth at most j.

    def Cslib.Circuits.Boolean.ACC0ToSymAnd.Good {n g ℓ : ℕ} (P : Program Unbounded.extSignature n g) (m : ℕ) (x : Fin n → Bool) (r : Seed ℓ) :

    A seed is good on input x when it is good for the arguments of every gate, under their values and under their negations.

    Instances For
      @[instance_reducible]
      noncomputable instance Cslib.Circuits.Boolean.ACC0ToSymAnd.instDecidableGood {n g ℓ : ℕ} (P : Program Unbounded.extSignature n g) (m : ℕ) (x : Fin n → Bool) (r : Seed ℓ) :
      Decidable (Good P m x r)
      theorem Cslib.Circuits.Boolean.ACC0ToSymAnd.wiresOK_run_macro {n g m ℓ : ℕ} (P : Program Unbounded.extSignature n g) (hm : 0 < m) (x : Fin n → Bool) {r : Seed ℓ} (hr : Good P m x r) {j : ℕ} {u : Slot n g m → Bool} (hu : WiresOK P m x j u) :
      WiresOK P m x (j + 1) (ModPolyLayer.run (List.map (fun (L : SLayer (Seed ℓ) (Slot n g m)) => L.atSeed r) (macroS P m ℓ)) u)

      One round. For a good seed, a round makes every wire of depth at most j + 1 correct.

      def Cslib.Circuits.Boolean.ACC0ToSymAnd.init {n g m : ℕ} (x : Fin n → Bool) :
      Slot n g m → Bool

      The initial slot values on input x: the input wires hold x, and every other slot is false.

      theorem Cslib.Circuits.Boolean.ACC0ToSymAnd.wiresOK_run_towerS {n g m ℓ : ℕ} (P : Program Unbounded.extSignature n g) (hm : 0 < m) (x : Fin n → Bool) {r : Seed ℓ} (hr : Good P m x r) (d : ℕ) :
      WiresOK P m x d (ModPolyLayer.run (List.map (fun (L : SLayer (Seed ℓ) (Slot n g m)) => L.atSeed r) (towerS P m ℓ d)) (init x))

      The tower of a good seed. After d rounds from the initial values, every wire of depth at most d is correct.

      Counting the good seeds #

      theorem Cslib.Circuits.Boolean.ACC0ToSymAnd.card_not_goodAt_le {n g ℓ : ℕ} (A : Finset (Wire n g)) (y : Wire n g → Bool) :
      {r : Seed ℓ | ¬GoodAt r A y}.card ≤ n + g

      Few bad seeds for one argument set. At most n + g seeds are bad for A under y.

      theorem Cslib.Circuits.Boolean.ACC0ToSymAnd.card_not_good_le {n g ℓ : ℕ} (P : Program Unbounded.extSignature n g) (m : ℕ) (x : Fin n → Bool) :
      {r : Seed ℓ | ¬Good P m x r}.card ≤ g * (2 * (n + g))

      Few bad seeds. On every input, at most 2g (n + g) seeds are bad.

      The majority over the seeds #

      noncomputable def Cslib.Circuits.Boolean.ACC0ToSymAnd.top (ℓ : ℕ) {S : Type u_1} (o : S) :
      SymAnd (Seed ℓ × S)

      The majority over the seeds r of the slot (r, o), as a SYM ∘ AND circuit of fan-in 1.

      theorem Cslib.Circuits.Boolean.ACC0ToSymAnd.count_top {ℓ : ℕ} {S : Type u_1} (o : S) (v : Seed ℓ × S → Bool) :
      (top ℓ o).count v = {r : Seed ℓ | v (r, o) = true}.card

      The number of satisfied gates of top ℓ o is the number of seeds r with v (r, o).

      theorem Cslib.Circuits.Boolean.ACC0ToSymAnd.eval_top {ℓ : ℕ} {S : Type u_1} (o : S) (v : Seed ℓ × S → Bool) :
      (top ℓ o).eval v = decide (Fintype.card (Seed ℓ) < 2 * {r : Seed ℓ | v (r, o) = true}.card)

      top ℓ o is true when more than half of the seeds r have v (r, o).

      theorem Cslib.Circuits.Boolean.ACC0ToSymAnd.size_top {ℓ : ℕ} {S : Type u_1} (o : S) :
      (top ℓ o).size = Fintype.card (Seed ℓ)

      top ℓ o has one AND gate per seed.

      theorem Cslib.Circuits.Boolean.ACC0ToSymAnd.fanIn_top_le {ℓ : ℕ} {S : Type u_1} (o : S) :
      (top ℓ o).fanIn ≤ 1

      top ℓ o has fan-in at most 1.

      theorem Cslib.Circuits.Boolean.ACC0ToSymAnd.decide_majority {F : Type u_1} [Fintype F] (G : F → Prop) [DecidablePred G] (f : F → Bool) (b : Bool) (hG : ∀ (r : F), G r → f r = b) (hbad : 2 * {r : F | ¬G r}.card < Fintype.card F) :
      decide (Fintype.card F < 2 * {r : F | f r = true}.card) = b

      The majority is correct when it agrees with b on the good seeds and fewer than half of the seeds are bad.

      Degrees #

      theorem Cslib.Circuits.Boolean.ACC0ToSymAnd.linePoly_mem_lowDegree {n g m ℓ : ℕ} (r : Seed ℓ) (k : Fin g) (L : Line Unbounded.extSignature n g) :
      linePoly r k L ∈ BitString.lowDegree ℤ (Slot n g m) (2 * ℓ + 2 + (m + 1) ^ 2)

      The gate polynomials have degree at most 2ℓ + 2 + (m + 1) ^ 2.

      theorem Cslib.Circuits.Boolean.ACC0ToSymAnd.combineQ_mem_lowDegree {n g m ℓ : ℕ} (P : Program Unbounded.extSignature n g) (r : Seed ℓ) (s : Slot n g m) :
      combineQ P r s ∈ BitString.lowDegree ℤ (Slot n g m) (2 * ℓ + 2 + (m + 1) ^ 2)

      The MOD_2 layer polynomials have degree at most 2ℓ + 2 + (m + 1) ^ 2.

      theorem Cslib.Circuits.Boolean.ACC0ToSymAnd.digitQ_mem_lowDegree {n g m : ℕ} (P : Program Unbounded.extSignature n g) (hm : 0 < m) (p₀ : ℕ) (s : Slot n g m) :

      The digit layer polynomials have degree at most m, for m > 0.

      theorem Cslib.Circuits.Boolean.ACC0ToSymAnd.SLayer.lift_mem_lowDegree {F : Type u_1} {S : Type u_2} (L : SLayer F S) {D : ℕ} (h : ∀ (r : F) (s : S), L.q r s ∈ BitString.lowDegree ℤ S D) (t : F × S) :

      Lifting keeps the degrees.

      theorem Cslib.Circuits.Boolean.ACC0ToSymAnd.mem_macroS_of_mem_towerS {n g m ℓ : ℕ} (P : Program Unbounded.extSignature n g) {d : ℕ} {L : SLayer (Seed ℓ) (Slot n g m)} (hL : L ∈ towerS P m ℓ d) :
      L ∈ macroS P m ℓ

      Every layer of the towers is a layer of one round.

      theorem Cslib.Circuits.Boolean.ACC0ToSymAnd.layer_ok {n g m ℓ : ℕ} (P : Program Unbounded.extSignature n g) (hm : 0 < m) {L : SLayer (Seed ℓ) (Slot n g m)} (hL : L ∈ macroS P m ℓ) :
      Nat.Prime L.p ∧ L.p ≤ m + 2 ∧ ∀ (r : Seed ℓ) (s : Slot n g m), L.q r s ∈ BitString.lowDegree ℤ (Slot n g m) (2 * ℓ + 2 + (m + 1) ^ 2)

      Every layer of the towers has a prime modulus at most m + 2 and slot polynomials of degree at most 2ℓ + 2 + (m + 1) ^ 2.

      Size bounds #

      theorem Cslib.Circuits.Boolean.ACC0ToSymAnd.four_mul_lt_card_seed {n g ℓ : ℕ} (hN : n + g < 2 ^ ℓ) :
      4 * (g * (n + g)) < Fintype.card (Seed ℓ)

      4 g (n + g) < 2 ^ (2ℓ + 2) seeds when n + g < 2 ^ ℓ.

      theorem Cslib.Circuits.Boolean.ACC0ToSymAnd.card_seed_slot_lt {n g m ℓ : ℕ} (hN : n + g < 2 ^ ℓ) :
      Fintype.card (Seed ℓ × Slot n g m) < 2 ^ (3 * ℓ + 2 + (m + 1) ^ 2)

      The seeds and slots number at most 2 ^ (3ℓ + 2 + (m + 1) ^ 2) - 1 when n + g < 2 ^ ℓ.

      The theorem #

      The input read by each slot: the input wires of every seed read their input; the other slots read nothing (they start false).

      theorem Cslib.Circuits.Boolean.ACC0ToSymAnd.slotInput_elim {n g m ℓ : ℕ} (x : Fin n → Bool) (t : Seed ℓ × Slot n g m) :
      (slotInput t).elim false x = init x t.2

      Reading the inputs through slotInput gives the initial slot values.

      noncomputable def Cslib.Circuits.Boolean.ACC0ToSymAnd.compile {n g : ℕ} (P : Program Unbounded.extSignature n g) (m ℓ d : ℕ) (o : Wire n g) :

      The explicit SYM ∘ AND circuit of a program P with output wire o, for MOD_m gates, seeds of 2ℓ + 2 bits and d rounds: the majority over the seeds of slot o, collapsed through the towers (SymAnd.collapseRun with bound 3 ((m + 1) ^ 2 + ℓ + 1)) and restricted to the inputs.

      The explicit SYM ∘ AND circuit of an ACC⁰ circuit: compile with seeds of 2 (⌊log₂ (n + s)⌋ + 1) + 2 bits and d rounds, where s is the size and d the depth of C. It is specified only for m > 0 (Circuit.eval_toSymAnd); for m = 0 it is well-typed but no theorem describes it.

      What the explicit circuit computes (Yao; Beigel–Tarui [BeigelTarui1994, Theorem 1.1]): for m > 0, C.toSymAnd m computes the function of the circuit C with NOT, unbounded AND/OR and MOD_m gates.

      theorem Cslib.Circuits.Circuit.fanIn_toSymAnd_le {n : ℕ} (C : Circuit Boolean.Unbounded.extSignature n 1) {m : ℕ} (hm : 0 < m) :
      (C.toSymAnd m).fanIn ≤ (2 * (3 * ((m + 1) ^ 2 + Nat.log 2 (n + C.size) + 2))) ^ 5 ^ (C.depth * (m + 2))

      The explicit circuit has fan-in at most (2B) ^ (5 ^ (d (m + 2))), where B = 3 ((m + 1) ^ 2 + ⌊log₂ (n + s)⌋ + 2).

      theorem Cslib.Circuits.Circuit.size_toSymAnd_le {n : ℕ} (C : Circuit Boolean.Unbounded.extSignature n 1) {m : ℕ} (hm : 0 < m) :
      (C.toSymAnd m).size ≤ 2 ^ (2 * (3 * ((m + 1) ^ 2 + Nat.log 2 (n + C.size) + 2))) ^ 5 ^ (C.depth * (m + 2))

      The explicit circuit has at most 2 ^ ((2B) ^ (5 ^ (d (m + 2)))) AND gates, where B = 3 ((m + 1) ^ 2 + ⌊log₂ (n + s)⌋ + 2).

      theorem Cslib.Circuits.Circuit.exists_symAnd_eval_eq {n : ℕ} (C : Circuit Boolean.Unbounded.extSignature n 1) {m : ℕ} (hm : 0 < m) :
      ∃ (C' : Boolean.SymAnd (Fin n)), (C'.eval = fun (x : Fin n → Bool) => C.eval (Boolean.Unbounded.extInterpretation (Boolean.modGate m)) x 0) ∧ C'.fanIn ≤ (2 * (3 * ((m + 1) ^ 2 + Nat.log 2 (n + C.size) + 2))) ^ 5 ^ (C.depth * (m + 2)) ∧ C'.size ≤ 2 ^ (2 * (3 * ((m + 1) ^ 2 + Nat.log 2 (n + C.size) + 2))) ^ 5 ^ (C.depth * (m + 2))

      ACC⁰ circuits are quasi-polynomial SYM ∘ AND circuits (Yao; Beigel–Tarui [BeigelTarui1994, Theorem 1.1]). A circuit C with NOT, unbounded AND/OR and MOD_m gates, m > 0, of depth d, with s gates on n inputs, computes the same function as a SYM ∘ AND circuit of fan-in at most (2B) ^ (5 ^ (d (m + 2))) with at most 2 ^ ((2B) ^ (5 ^ (d (m + 2)))) AND gates, where B = 3 ((m + 1) ^ 2 + ⌊log₂ (n + s)⌋ + 2). The circuit is C.toSymAnd m.

      theorem Cslib.Circuits.Boolean.exists_symAnd_of_mem_ACC0 {L : Language Bool} (hL : L ∈ ACC0) :
      ∃ (c : ℕ), ∀ (n : ℕ), ∃ (C' : SymAnd (Fin n)), C'.eval = L.slice n ∧ C'.fanIn ≤ (c * (Nat.log 2 n + 1)) ^ c ∧ C'.size ≤ 2 ^ (c * (Nat.log 2 n + 1)) ^ c

      ACC⁰ has quasi-polynomial SYM ∘ AND circuits (Yao; Beigel–Tarui [BeigelTarui1994, Theorem 1.1]). Every language of ACC0 is decided at every length n by SYM ∘ AND circuits of fan-in at most (c (⌊log₂ n⌋ + 1)) ^ c with at most 2 ^ ((c (⌊log₂ n⌋ + 1)) ^ c) AND gates, for a constant c depending on the language.

      theorem Cslib.Circuits.Boolean.exists_symAnd_of_mem_AC0Mod {m : ℕ} {L : Language Bool} (hL : L ∈ AC0Mod m) :
      ∃ (c : ℕ), ∀ (n : ℕ), ∃ (C' : SymAnd (Fin n)), C'.eval = L.slice n ∧ C'.fanIn ≤ (c * (Nat.log 2 n + 1)) ^ c ∧ C'.size ≤ 2 ^ (c * (Nat.log 2 n + 1)) ^ c

      AC⁰[m] has quasi-polynomial SYM ∘ AND circuits. Every language of AC0Mod m is decided at every length n by SYM ∘ AND circuits of fan-in at most (c (⌊log₂ n⌋ + 1)) ^ c with at most 2 ^ ((c (⌊log₂ n⌋ + 1)) ^ c) AND gates, for a constant c depending on the language. The case m = 0 goes through AC0Mod 0 ⊆ ACC0 (AC0Mod_subset_ACC0).