Wire indices and the topological order of programs #
Wire.index numbers the wires of a program by listing the inputs first and then the gates in
program order. A gate reads only wires whose index is below its own (Program.lines_wires_lt),
which is the topological order of a straight-line program made numeric. The computation rules
Wire.lastCases_last and Wire.lastCases_castSucc complete CSLib's Wire.lastCases.
These declarations come from the complexitylib-integration branch of the author's CSLib fork
(commit 2a4389b), where they lived in Cslib.Computability.Circuit.Wire and
Cslib.Computability.Circuit.Program; upstream CSLib did not adopt them. This file lives in
Complexitylib/Cslib/ because it extends CSLib types in their home namespace Cslib.Circuits;
its contents are candidates for upstreaming to CSLib.
The position of a wire when the inputs are listed first, followed by the gates in program order. A gate reads only wires whose index is below its own.
Equations
- (Cslib.Circuits.Wire.input i).index = Fin.castAdd gateCount i
- (Cslib.Circuits.Wire.gate j).index = Fin.natAdd inputCount j