Documentation

CslibFrontier.Computability.Circuit.Prefix.Basic

Universal fanout-bounded prefix circuits and the Snir–Fich trade-off #

Following Sergeev [Ser25a], we formalize universal prefix circuits over the basis {mul, id} (Cslib.Circuits.Prefix.prefixSignature) that compute all prefix products s_j = x_0 * x_1 * ⋯ * x_j in every semigroup (S, *). Here the complexity binaryComplexity c counts binary mul gates, depth c.depth counts both mul and id gates along the longest input-to-output path, and fanout wireFanout c w counts both internal gate input slots reading w and external output designations equal to w.

We prove that universal correctness across all semigroups is equivalent to correctness over the single free semigroup FreeSemigroup (Fin N) (isUniversalPrefixCircuit_iff_freeSemigroup), giving decidability (instDecidableIsUniversalPrefixCircuit), and follows from contiguous-interval gate labeling (IsIntervalPrefixCircuit.isUniversalPrefixCircuit). Decomposing the DAG into its framework tree of mul ancestors of output N - 1 and its output-defining mul gates yields the Snir–Fich lower bound 2 * N - 2 ≤ binaryComplexity c + c.depth (two_mul_sub_two_le_binaryComplexity_add_depth), motivating optimal (zero-deficiency) prefix circuits (IsOptimalPrefixCircuit).

Main definitions #

Main results #

References #

Part 1: Universal fanout-bounded prefix circuits and zero-deficiency optimality #

Operations of a fanout-bounded prefix circuit: binary semigroup multiplication mul (x ◦ y) and unary identity buffer id (x) used to replicate values under bounded fanout.

Instances For
    @[reducible, inline]

    Arity of each prefix circuit operation: 2 for mul and 1 for id.

    @[reducible, inline]

    The circuit signature {mul, id} for fanout-bounded prefix circuits.

    @[reducible, inline]

    An N-input, N-output prefix circuit over {mul, id}.

    Interpretation of prefixSignature in any semigroup (S, *).

    def Cslib.Circuits.Prefix.prefixProd {S : Type u_1} [Semigroup S] {N : ℕ} (x : Fin N → S) (j : Fin N) :
    S

    The j-th prefix product x 0 * x 1 * ⋯ * x j of x : Fin N → S in a semigroup S.

    @[simp]
    theorem Cslib.Circuits.Prefix.prefixProd_zero {S : Type u_1} [Semigroup S] {N : ℕ} (h0 : 0 < N) (x : Fin N → S) :
    prefixProd x ⟨0, h0⟩ = x ⟨0, h0⟩
    @[simp]
    theorem Cslib.Circuits.Prefix.prefixProd_succ {S : Type u_1} [Semigroup S] {N m : ℕ} (hm : m + 1 < N) (x : Fin N → S) :
    prefixProd x ⟨m + 1, hm⟩ = prefixProd x ⟨m, ⋯⟩ * x ⟨m + 1, hm⟩

    A prefix circuit c is universal if it computes prefixProd in every semigroup (S, *) ([Ser25a], p. 1, Eq. (1)).

    Instances For

      Universal correctness over Type is equivalent to evaluating correctly on the canonical generators FreeSemigroup.of of FreeSemigroup (Fin N).

      A universal prefix circuit computes prefixProd in every semigroup in any universe.

      A prefix circuit is interval-labeled if every wire carries a nonempty contiguous input interval [lo w, hi w) with inputs carrying [i, i + 1), id preserving the interval, mul concatenating adjacent intervals [a, m) and [m, b), and output j carrying [0, j + 1) ([Sergeev2025PrefixDepth], p. 1).

      Every interval-labeled prefix circuit is a universal prefix circuit.

      Binary gate complexity of a prefix circuit: the total number of binary mul gates ([Ser25a], p. 1).

      Total fanout of wire w in c, counting both internal gate input slots reading w and external output poles equal to w ([Ser25a], pp. 1–3).

      A circuit has fanout bounded by k if every input and internal gate wire has total fanout at most k.

      Instances For

        A universal prefix circuit on N inputs is optimal (has zero deficiency) if binaryComplexity c + c.depth = 2 * N - 2 ([Ser25a], p. 1).

        Internal DAG decomposition for Snir–Fich and zero-deficiency circuits #

        Snir–Fich trade-off ([Ser25a], p. 1, citing Fich 1983 and Snir 1986): every universal prefix circuit on N ≥ 1 inputs satisfies 2 * N - 2 ≤ binaryComplexity c + c.depth.