Documentation

CslibFrontier.Computability.Circuit.Boolean.RepeatedSquaring

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 #

Main results #

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).

@[simp]

Entry (i, j) of the square is true iff some k has entries (i, k) and (k, j) true.

@[simp]

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.

theorem Cslib.Circuits.Boolean.eval_iterate_squareCircuit_iff_reflTransGen {N : ℕ} {r : Fin N → Fin N → Prop} {x : BitString (N * N)} (hx : ∀ (i j : Fin N), x (finProdFinEquiv (i, j)) = true ↔ r i j) (hr : ∀ (i : Fin N), r i i) {t : ℕ} (hN : N ≤ 2 ^ t) (i j : Fin N) :

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.