Composing circuits #
A program can be continued by a second program whose inputs are read from wires of the first.
Reading them from the outputs of a circuit gives sequential composition, Circuit.comp, which
evaluates to the composite of the two functions. Reading them from the original inputs gives
parallel composition on shared inputs, Circuit.append, whose outputs are those of the first
circuit followed by those of the second. In both cases the gate counts add.
The wire of p.append feed q that carries a wire of q: an input of q is the wire of p
feeding it, and a gate of q comes after all the gates of p.
Equations
- Cslib.Circuits.Program.appendWire feed = Cslib.Circuits.Wire.elim (fun (i : Fin k) => Cslib.Circuits.Wire.castAdd g₂ (feed i)) fun (j : Fin g₂) => Cslib.Circuits.Wire.gate (Fin.natAdd g₁ j)
Instances For
Continue p by q, reading the inputs of q from the wires feed of p.
Equations
- p.append feed Cslib.Circuits.Program.empty = p
- p.append feed (q.gate line) = (p.append feed q).gate (line.mapWires (Cslib.Circuits.Program.appendWire feed))
Instances For
A wire of q carries, in the continued program, the value it has when q runs on the
values of the wires feeding it.
Feeding a circuit computing f into one computing g computes g ∘ f.
Circuits computing f and g, run side by side, compute their outputs together.
Feeding a circuit computing f on S into one computing g on the image of S computes
g ∘ f on S.
Circuits computing f and g on S, run side by side, compute their outputs together.