Reachability by repeated Boolean matrix squaring #
An N × N Boolean matrix stored row by row in N * N bits via finProdFinEquiv is the adjacency
matrix of a relation on Fin N. Over the unbounded fan-in basis, squareCircuit N computes its
Boolean square: entry (i, j) is the disjunction over k of the conjunctions of entries (i, k)
and (k, j). This is a circuit of depth at most two (depth_squareCircuit_le, registered with
@[circuit_bound]) and N ^ 2 * (N + 1) gates (size_squareCircuit).
Composing t copies as (squareCircuit N).iterate t uses t * (N ^ 2 * (N + 1)) gates
(Circuit.size_iterate) and depth at most 2 * t (Circuit.depth_iterate_le). Its entry (i, j)
records a walk of exactly 2 ^ t steps from i to j
(eval_iterate_squareCircuit_iff_relatesInSteps); on general relations without self-loops it does
not add the diagonal. For a reflexive relation, once N ≤ 2 ^ t, a walk of 2 ^ t steps is
reachability (eval_iterate_squareCircuit_iff_reflTransGen). With t = ⌈log₂ N⌉ this computes
reflexive-transitive closure on reflexive adjacency matrices in depth 2 ⌈log₂ N⌉ and
⌈log₂ N⌉ * (N ^ 2 * (N + 1)) gates, the matrix-powering circuit step of
Arora and Barak, Chapter 6, Exercise 9.
Cslib.Complexity.NL_subset_AC_one applies it to machine configuration graphs.
Main definitions #
Cslib.Circuits.Boolean.squareCircuit: one Boolean matrix squaring onN * Nbits.
Main results #
Cslib.Circuits.Boolean.eval_squareCircuit,Cslib.Circuits.Boolean.size_squareCircuit,Cslib.Circuits.Boolean.depth_squareCircuit_le: semantics, exact gate count and@[circuit_bound]depth bound of one squaring.Cslib.Circuits.Boolean.eval_iterate_squareCircuit_iff_relatesInSteps:tsquarings record walks of2 ^ tsteps.Cslib.Circuits.Boolean.eval_iterate_squareCircuit_iff_reflTransGen: for a reflexive relation on at most2 ^ telements,tsquarings compute reachability.
References #
One Boolean matrix squaring. An N × N Boolean matrix is stored row by row in N * N
bits via finProdFinEquiv. Output (i, j) is the disjunction over k of the conjunctions of
input entries (i, k) and (k, j).
Entry (i, j) of the square is true iff some k has entries (i, k) and (k, j) true.
One squaring has N ^ 2 * (N + 1) gates: N conjunctions and one disjunction per entry.
One squaring has depth at most two.
t squarings record walks of 2 ^ t steps. If x is the adjacency matrix of r, entry
(i, j) of (squareCircuit N).iterate t is true iff r relates i to j in exactly 2 ^ t
steps.
Repeated squaring computes reachability on reflexive relations. If x is the adjacency
matrix of a reflexive relation r on Fin N and N ≤ 2 ^ t, entry (i, j) of
(squareCircuit N).iterate t is true iff j is reachable from i.