Documentation

CslibFrontier.Computability.Circuit.Monotone.Shift

Monotone circuit complexity of cyclic shift and permutation operators #

Following Sergeev [Ser20], an (n q + m, n q)-input operator on n Boolean vectors X = (x_0, …, x_{n-1}) of length q (packed via finProdFinEquiv : Fin n × Fin q ≃ Fin (n * q)) and an m-bit control vector Y : Fin m → Bool (appended via Fin.append X Y) implements:

Whenever 0 < q, monotonicity of Monotone.interpretation forces any code α (or β) computed by a monotone circuit to have pairwise incomparable codewords (ComputesMonotoneShift.not_le, ComputesMonotonePerm.not_le), hence an injective indexing of an antichain in Fin m → Bool (ComputesMonotoneShift.injective_and_isAntichain, ComputesMonotonePerm.injective_and_isAntichain).

On the upper-bound side (Theorem 1, [Ser20], pp. 3–4), from any monotone circuit cA computing the antichain monomials fun Y r => decide (α r ≤ Y) (which evaluate at α k to the one-hot indicator decide (r = k)), monotoneShiftCircuit q cA ORs the indicator wires into 2 ⌈log₂ n⌉ bit-value tests and feeds an explicit ⌈log₂ n⌉-stage monotone barrel shifter built from 3-gate monotone multiplexers (y₁ ∧ a) ∨ (y₀ ∧ b), achieving binaryCost ≤ cA.program.cost binaryCost + 4 * q * n * Nat.clog 2 n. On the weight-1 one-hot antichain oneHotShiftAntichain (L(A₁) = 0), oneHotShiftCircuit uses at most 4 * q * n * Nat.clog 2 n gates; on the dual-rail binary code dualRailShiftCode n b (b ≥ Nat.clog 2 n, covering both minimal width dualRailShiftAntichain n and Sergeev's b = Nat.log 2 n + 1), dualRailShiftCircuit reads the bit rails directly with zero indicator gates and exact cost 3 * q * n * Nat.clog 2 n. Sergeev's Theorem 2 (sorting-network upper bounds for P_{q, Π} via AKS) is not included in this module.

On the lower-bound side (Theorem 3 and Corollary, [Ser20], pp. 4–6, adapting Chashkin [Cha06] and Lamagna–Savage [LS74]), monotone projection isolation (eq_proj_or_eq_proj_of_or, eq_proj_or_eq_proj_of_and) traces for each shift k and input coordinate (i, b) a chain of {∧, ∨} gates computing X(i, b) from (i, b) to output ((i + k) mod n, b). For fixed k these gate sets are pairwise disjoint across all n q coordinates, while for fixed output (j, b) at most 2^d inputs reach the output wire within d gates, forcing the path lengths to sum to at least ∑_{t=1}^n ⌈log₂ t⌉ ≥ n ⌊log₂ n⌋ - n. Thus every monotone circuit computing S_{q, α} — and, by restriction along cyclicShiftPerm, every monotone circuit computing P_{q, β} — has binaryCost at least q * ∑_{t=1}^n Nat.clog 2 t ≥ q * n * Nat.log 2 n - q * n, independently of the choice of antichain α or β and control width m.

Main definitions #

Main results #

References #

Block permutations, cyclic shifts, and monotone operator specifications #

def Cslib.Circuits.Monotone.permuteVec {n q : ℕ} (X : Fin (n * q) → Bool) (π : Equiv.Perm (Fin n)) :
Fin (n * q) → Bool

Permute the n length-q blocks of X according to π: output block j receives input block π j (π(X) = (x_{π(0)}, …, x_{π(n-1)}), [Ser20], p. 3).

@[simp]
theorem Cslib.Circuits.Monotone.permuteVec_finProdFinEquiv {n q : ℕ} (X : Fin (n * q) → Bool) (π : Equiv.Perm (Fin n)) (j : Fin n) (b : Fin q) :

At coordinate (j, b), permuteVec X π reads coordinate (π j, b) of X.

The permutation of Fin n corresponding to a cyclic right shift by k positions: output position j reads input position (j - k) mod n, while input position i moves to output position (i + k) mod n.

def Cslib.Circuits.Monotone.cyclicShiftVec {n q : ℕ} (X : Fin (n * q) → Bool) (k : Fin n) :
Fin (n * q) → Bool

Cyclic right shift X ≫ k of n length-q Boolean vectors by k positions ([Ser20], p. 2): output block (i + k) mod n equals input block i.

@[simp]

Output block (i + k) mod n of cyclicShiftVec X k carries input block i.

Distinct shift amounts k₁ ≠ k₂ induce distinct permutations of Fin n.

def Cslib.Circuits.Monotone.ComputesMonotoneShift {n q m : ℕ} (c : Circuit signature (n * q + m) (n * q)) (α : Fin n → Fin m → Bool) :

A monotone circuit c computes the monotone cyclic shift operator S_{q, A} for control code α : Fin n → Fin m → Bool when c evaluates (X, α k) to cyclicShiftVec X k for all data vectors X and shift indices k ([Ser20], p. 2).

def Cslib.Circuits.Monotone.ComputesMonotonePerm {n q m : ℕ} (c : Circuit signature (n * q + m) (n * q)) (β : Equiv.Perm (Fin n) → Fin m → Bool) :

A monotone circuit c computes the monotone permutation operator P_{q, Π} for control code β : Equiv.Perm (Fin n) → Fin m → Bool when c evaluates (X, β π) to permuteVec X π for all data vectors X and permutations π ([Ser20], p. 3).

Restricting a monotone permutation circuit along cyclicShiftPerm yields a monotone cyclic shift circuit for fun k => β (cyclicShiftPerm k) ([Ser20], p. 3).

Monotonicity of circuit evaluation and antichain necessity #

theorem Cslib.Circuits.Monotone.ComputesMonotonePerm.not_le {n q m : ℕ} {c : Circuit signature (n * q + m) (n * q)} {β : Equiv.Perm (Fin n) → Fin m → Bool} (hc : ComputesMonotonePerm c β) (hq : 0 < q) {π₁ π₂ : Equiv.Perm (Fin n)} (hne : π₁ ≠ π₂) :
¬β π₁ ≤ β π₂

When 0 < q, any monotone circuit computing P_{q, Π} forces distinct permutations to have incomparable control codewords (¬ β π₁ ≤ β π₂).

theorem Cslib.Circuits.Monotone.ComputesMonotonePerm.injective_and_isAntichain {n q m : ℕ} {c : Circuit signature (n * q + m) (n * q)} {β : Equiv.Perm (Fin n) → Fin m → Bool} (hc : ComputesMonotonePerm c β) (hq : 0 < q) :
Function.Injective β ∧ IsAntichain (fun (x1 x2 : Fin m → Bool) => x1 ≤ x2) (Set.range β)

When 0 < q, any code β computed by a monotone permutation circuit is injective and its range is an antichain under the pointwise order on Fin m → Bool.

theorem Cslib.Circuits.Monotone.ComputesMonotoneShift.not_le {n q m : ℕ} {c : Circuit signature (n * q + m) (n * q)} {α : Fin n → Fin m → Bool} (hc : ComputesMonotoneShift c α) (hq : 0 < q) {k₁ k₂ : Fin n} (hne : k₁ ≠ k₂) :
¬α k₁ ≤ α k₂

When 0 < q, any monotone circuit computing S_{q, α} forces distinct shift amounts to have incomparable control codewords (¬ α k₁ ≤ α k₂).

theorem Cslib.Circuits.Monotone.ComputesMonotoneShift.injective_and_isAntichain {n q m : ℕ} {c : Circuit signature (n * q + m) (n * q)} {α : Fin n → Fin m → Bool} (hc : ComputesMonotoneShift c α) (hq : 0 < q) :
Function.Injective α ∧ IsAntichain (fun (x1 x2 : Fin m → Bool) => x1 ≤ x2) (Set.range α)

When 0 < q, any shift code α computed by a monotone shift circuit is injective and its range is an antichain under the pointwise order on Fin m → Bool.

Standard shift antichains: one-hot (A₁) and dual-rail binary (A₀) #

The weight-1 one-hot shift antichain A₁ ⊂ B^n ([Ser20], p. 2), sending k : Fin n to the indicator vector fun i => decide (i = k).

The range of oneHotShiftAntichain n is an antichain in Fin n → Bool.

Dual-rail binary shift code of bit-width b ([Ser20], p. 2, A₀), doubling the b-bit binary representation [k]_2 in the first b coordinates with its bitwise negation \overline{[k]_2} in the last b coordinates.

@[reducible, inline]

Minimal-width (2 * Nat.clog 2 n) dual-rail binary shift antichain; Sergeev's p. 2 width 2 * (⌊log₂ n⌋ + 1) is dualRailShiftCode n (Nat.log 2 n + 1).

Whenever n ≤ 2 ^ b (in particular for b = Nat.clog 2 n and b = Nat.log 2 n + 1), dualRailShiftCode n b is injective.

theorem Cslib.Circuits.Monotone.isAntichain_range_dualRailShiftCode {n b : ℕ} (hb : n ≤ 2 ^ b) :
IsAntichain (fun (x1 x2 : Fin (2 * b) → Bool) => x1 ≤ x2) (Set.range (dualRailShiftCode n b))

Whenever n ≤ 2 ^ b, the range of dualRailShiftCode n b is an antichain in Fin (2 * b) → Bool.

Theorem 1: Monotone barrel-shifter upper bounds #

Theorem 1 circuit construction ([Ser20], pp. 3–4): from any monotone circuit cA : Circuit signature m n computing the one-hot/monomial indicators of an n-element shift antichain, build a monotone circuit for S_{q, A} by ORing the indicators into 2 ⌈log₂ n⌉ rail bits and applying the ⌈log₂ n⌉-stage monotone barrel shifter (and pure zero-output wiring when q = 0).

theorem Cslib.Circuits.Monotone.computesMonotoneShift_monotoneShiftCircuit {n q m : ℕ} {α : Fin n → Fin m → Bool} {cA : Circuit signature m n} (hinj : Function.Injective α) (hanti : IsAntichain (fun (x1 x2 : Fin m → Bool) => x1 ≤ x2) (Set.range α)) (hcA : cA.Computes interpretation fun (Y : Fin m → Bool) (r : Fin n) => decide (α r ≤ Y)) :

Theorem 1 (correctness) ([Ser20], pp. 3–4): if α injectively indexes an antichain in Fin m → Bool and cA computes the antichain monomials fun Y r => decide (α r ≤ Y) (Y^{α_r} = ⋀_{α_{r,t} = 1} Y_t), then monotoneShiftCircuit q cA computes the monotone cyclic shift operator S_{q, α}.

Theorem 1 (cost bound) ([Ser20], pp. 3–4): monotoneShiftCircuit q cA has binary monotone gate cost at most cA.program.cost binaryCost + 4 * q * n * Nat.clog 2 n (L(S_{q, A}) ≤ L(A) + O(q n log n)).

Explicit monotone shift circuit for the weight-1 one-hot antichain A₁ ([Ser20], pp. 2–3), using Circuit.id (L(A₁) = 0) for the monomial stage.

oneHotShiftCircuit n q uses at most 4 * q * n * Nat.clog 2 n binary monotone gates ([Ser20], p. 3).

def Cslib.Circuits.Monotone.dualRailShiftCircuit (n q b : ℕ) (hb : Nat.clog 2 n ≤ b) :
Circuit signature (n * q + 2 * b) (n * q)

Explicit monotone shift circuit for dualRailShiftCode n b whenever Nat.clog 2 n ≤ b ([Ser20], pp. 2–4), wiring the first Nat.clog 2 n positive and negated shift bits directly into the barrel shifter with zero indicator gates.

dualRailShiftCircuit n q b hb uses exact binary monotone gate cost 3 * q * n * Nat.clog 2 n.

Theorem 3 and Permutation Corollary: Antichain-independent lower bounds #

theorem Cslib.Circuits.Monotone.eq_proj_or_eq_proj_of_or {N : ℕ} {f g : (Fin N → Bool) → Bool} {i : Fin N} (hf : Monotone f) (hg : Monotone g) (hor : ∀ (x : Fin N → Bool), (f x || g x) = x i) :
(∀ (x : Fin N → Bool), f x = x i) ∨ ∀ (x : Fin N → Bool), g x = x i

Monotone projection isolation at an OR gate ([Ser20], proof of Theorem 3, Step (a), p. 5): if f, g : (Fin N → Bool) → Bool are monotone and (f x || g x) = x i for all x, then either f or g equals the coordinate projection fun x => x i.

theorem Cslib.Circuits.Monotone.eq_proj_or_eq_proj_of_and {N : ℕ} {f g : (Fin N → Bool) → Bool} {i : Fin N} (hf : Monotone f) (hg : Monotone g) (hand : ∀ (x : Fin N → Bool), (f x && g x) = x i) :
(∀ (x : Fin N → Bool), f x = x i) ∨ ∀ (x : Fin N → Bool), g x = x i

Monotone projection isolation at an AND gate ([Ser20], proof of Theorem 3, Step (a), p. 5): if f, g : (Fin N → Bool) → Bool are monotone and (f x && g x) = x i for all x, then either f or g equals the coordinate projection fun x => x i.

theorem Cslib.Circuits.Monotone.mul_sum_clog_le_cost_of_computesMonotoneShift {n q m : ℕ} {c : Circuit signature (n * q + m) (n * q)} {α : Fin n → Fin m → Bool} (hc : ComputesMonotoneShift c α) :
q * ∑ t ∈ Finset.Icc 1 n, Nat.clog 2 t ≤ c.program.cost binaryCost

Theorem 3 (exact finite sum form) ([Ser20], pp. 4–6; after [Cha06] and [LS74]): for every control code α : Fin n → Fin m → Bool and every monotone circuit c computing S_{q, α}, q * (∑ t ∈ Icc 1 n, Nat.clog 2 t) ≤ c.program.cost binaryCost.

Theorem 3 (q n log₂ n - O(q n) form) ([Ser20], p. 4): for every control code α : Fin n → Fin m → Bool and every monotone circuit c computing S_{q, α}, q * n * Nat.log 2 n - q * n ≤ c.program.cost binaryCost.

Permutation Corollary (exact finite sum form) ([Ser20], p. 6): for every permutation code β : Equiv.Perm (Fin n) → Fin m → Bool and every monotone circuit c computing P_{q, Π}, q * (∑ t ∈ Icc 1 n, Nat.clog 2 t) ≤ c.program.cost binaryCost.

Permutation Corollary (q n log₂ n - O(q n) form) ([Ser20], p. 6): for every permutation code β : Equiv.Perm (Fin n) → Fin m → Bool and every monotone circuit c computing P_{q, Π}, q * n * Nat.log 2 n - q * n ≤ c.program.cost binaryCost.