Typed circuits as CSLib straight-line programs #
CSLib's circuits (Cslib.Circuits.Circuit) are straight-line programs over a
signature, and Basis.signature (in Complexitylib.Circuits.Basis.Defs) makes
each Complexitylib basis such a signature: an operation symbol of B.signature
is a whole gate kind of B, so Gate.kind turns each gate into one.
Circuit.toStraightLine translates a typed circuit Circuit B N M G into a
CSLib circuit over B.signature. The program lists the G internal gates and
then the M output gates, and the CSLib outputs are the last M gates, so the
translation has exactly G + M gates, the typed circuit's size.
Main definitions #
Complexity.Gate.kind— the gate kind of a gate, an operation symbol ofB.signatureComplexity.Circuit.toStraightLine— a typed circuit as a CSLib circuit
The CSLib wire with index w in the layout of typed circuits, where the
first N wires are the inputs and wire N + j is gate j.
Equations
- Complexity.StraightLine.wireOfIndex w hw = if h : w < N then Cslib.Circuits.Wire.input ⟨w, h⟩ else Cslib.Circuits.Wire.gate ⟨w - N, ⋯⟩
Instances For
Line j of the straight-line form of a typed circuit: internal gate j
for j < G, and output gate j - G otherwise.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The typed circuit c as a CSLib circuit over B.signature: its internal
gates followed by its output gates, with the output gates as outputs.
Equations
- c.toStraightLine = { size := G + M, program := Cslib.Circuits.Program.ofLines (G + M) c.straightLineAt, outputs := fun (o : Fin M) => Cslib.Circuits.Wire.gate (Fin.natAdd G o) }