Documentation

CslibFrontier.Computability.Circuit.Boolean.GF2Rank

De Morgan circuits for the rank of a matrix over ZMod 2 #

A matrix A x : Matrix (Fin r) (Fin c) (ZMod 2) that depends on the circuit input x is given to a circuit through the bits of its entries (Cslib.Circuits.Boolean.entryBits), using the ring isomorphism Cslib.BitString.bitEquiv : ZMod 2 ≃+* Bool. This file synthesises the bits of the Gauss–Jordan stages of Matrix.GaussJordan from those bits, and then the threshold test t ≤ (A x).rank, over the De Morgan basis.

One stage at column k follows Matrix.GaussJordan.stage_apply_zmod_two. Each row tests whether it is a candidate (zero before k, one at k), then whether it is the first candidate (the pivot, Matrix.GaussJordan.pivotRow_eq_some_iff). The pivot row's entries are an exclusive or over the rows, gated by the pivot test, and each new entry is the old entry exclusive-or the pivot row's entry when the row has a one at k and is not the pivot. A stage costs 14 (r + 1) (r + c + 1) gates. The rank is the number of nonzero rows of Matrix.GaussJordan.reduce (Matrix.GaussJordan.rank_eq_card_reduce_ne_zero), which a threshold circuit (Cslib.Circuits.Boolean.synthesis_atLeast) compares with t.

The bounds count gates only. The construction chains one stage per column; its depth is not certified here. The gate counts are this library's, not a source's.

Main definitions #

Main results #

References #

Computing a rank over ZMod 2 by a polynomial-size circuit is the constructivity step of the rank property in Razborov and Rudich, §3.2, who note that rank is in NC² without giving an explicit circuit or a gate count.

The bits of the entries of a matrix over ZMod 2 that depends on the input x.

theorem Cslib.Circuits.Boolean.mem_entryBits {n r c : ℕ} {A : BitString n → Matrix (Fin r) (Fin c) (ZMod 2)} {f : BooleanFunction n} :
f ∈ entryBits A ↔ ∃ (i : Fin r) (l : Fin c), (fun (x : BitString n) => BitString.bitEquiv (A x i l)) = f
theorem Cslib.Circuits.Boolean.entry_mem_entryBits {n r c : ℕ} (A : BitString n → Matrix (Fin r) (Fin c) (ZMod 2)) (i : Fin r) (l : Fin c) :
(fun (x : BitString n) => BitString.bitEquiv (A x i l)) ∈ entryBits A

One stage #

theorem Cslib.Circuits.Boolean.synthesis_entryBits_stage {n r c : ℕ} (A : BitString n → Matrix (Fin r) (Fin c) (ZMod 2)) (k : Fin c) {s : Set (BooleanFunction n)} (hA : entryBits A ⊆ s) :
Synthesis interpretation s (entryBits fun (x : BitString n) => Matrix.GaussJordan.stage (A x) k) (14 * (r + 1) * (r + c + 1))

One Gauss–Jordan stage over ZMod 2: the bits of stage (A x) k cost at most 14 (r + 1) (r + c + 1) gates on top of the bits of A x.

All stages and the rank #

theorem Cslib.Circuits.Boolean.synthesis_entryBits_reduceUpTo {n r c : ℕ} (A : BitString n → Matrix (Fin r) (Fin c) (ZMod 2)) {s : Set (BooleanFunction n)} (hA : entryBits A ⊆ s) (k : ℕ) :
Synthesis interpretation s (entryBits fun (x : BitString n) => Matrix.GaussJordan.reduceUpTo (A x) k) (k * (14 * (r + 1) * (r + c + 1)))

The bits of the first k stages cost at most k times the cost of a stage.

theorem Cslib.Circuits.Boolean.synthesis_entryBits_reduce {n r c : ℕ} (A : BitString n → Matrix (Fin r) (Fin c) (ZMod 2)) {s : Set (BooleanFunction n)} (hA : entryBits A ⊆ s) :
Synthesis interpretation s (entryBits fun (x : BitString n) => Matrix.GaussJordan.reduce (A x)) (c * (14 * (r + 1) * (r + c + 1)))

Gauss–Jordan elimination over ZMod 2: the bits of reduce (A x) cost at most 14 c (r + 1) (r + c + 1) gates on top of the bits of A x. Only the number of gates is bounded; depth is not certified.

theorem Cslib.Circuits.Boolean.synthesis_le_rank {n r c : ℕ} (A : BitString n → Matrix (Fin r) (Fin c) (ZMod 2)) {s : Set (BooleanFunction n)} (hA : entryBits A ⊆ s) {t : ℕ} (ht : t ≤ r + 1) :
Synthesis interpretation s {fun (x : BitString n) => decide (t ≤ (A x).rank)} (14 * (c + 1) * (r + 1) * (r + c + 1))

The rank threshold over ZMod 2: the test t ≤ (A x).rank, for t ≤ r + 1, costs at most 14 (c + 1) (r + 1) (r + c + 1) gates on top of the bits of A x. It reduces A x and counts the nonzero rows (Matrix.GaussJordan.rank_eq_card_reduce_ne_zero). Only the number of gates is bounded; depth is not certified.

theorem Cslib.Circuits.Boolean.synthesis_le_rank_of_synthesis {n r c : ℕ} (A : BitString n → Matrix (Fin r) (Fin c) (ZMod 2)) {s : Set (BooleanFunction n)} {cost : ℕ} (hA : Synthesis interpretation s (entryBits A) cost) {t : ℕ} (ht : t ≤ r + 1) :
Synthesis interpretation s {fun (x : BitString n) => decide (t ≤ (A x).rank)} (cost + 14 * (c + 1) * (r + 1) * (r + c + 1))

The rank threshold when the bits of the entries are themselves synthesised, for example from the circuit inputs.