Documentation

CslibFrontier.Computability.Circuit.Boolean.RepeatedSquaring.Encoding

Gate addresses for Boolean matrix squaring #

The circuit for one square puts the gates for an output entry consecutively. Its first N gates test two-step walks through the possible intermediate vertices, and its last gate takes their disjunction. The address formulas identify the wires that a serialized circuit generator must emit.

Main results #

References #

The matrix-powering construction is Arora and Barak, Chapter 6, Exercise 9(b–c), 2007 draft. The address formulas describe this library’s serialization.

def Cslib.Circuits.Boolean.squareGateList (N offset : ℕ) (input : Fin (N * N) → ℕ) :

Gate list of one Boolean square. The numerical address offset is the first fresh wire and input names the wires carrying the entries of the input matrix. Blocks are in row-major order and intermediate vertices within a block occur in numerical order.

theorem Cslib.Circuits.Boolean.code_squareCircuit_comp {n N : ℕ} (c : Circuit Unbounded.signature n (N * N)) :
((squareCircuit N).comp c).code = (c.code.1 ++ squareGateList N (n + c.size) fun (i : Fin (N * N)) => (c.outputs i).toNat, List.ofFn fun (o : Fin (N * N)) => n + c.size + ↑o * (N + 1) + N)

Appending a matrix squaring uses the current output wire addresses as its inputs. Its output wires are the disjunctions at the ends of the successive blocks.

Address of a matrix entry after t squarings, with N * N input wires. At zero the entry is still an input. At positive t its wire is the final disjunction of its last block.

theorem Cslib.Circuits.Boolean.code_iterate_squareCircuit (N t : ℕ) :
((squareCircuit N).iterate t).code = ((List.ofFn fun (r : Fin t) => squareGateList N (N * N + ↑r * (N ^ 2 * (N + 1))) fun (i : Fin (N * N)) => squareOutputWire N ↑r ↑i).flatten, List.ofFn fun (i : Fin (N * N)) => squareOutputWire N t ↑i)

All gates and designated output wires in the native serialization of iterated squaring. The gate list concatenates one block of N²(N+1) gates per round.