Building, measuring, and bounding CSLib programs #
This file extends CSLib's straight-line programs (Cslib.Circuits.Program):
Program.ofLinesbuilds the program whose gatejcomputes a given line reading the inputs and thejgates before it;Program.lines_ofLinesreads those lines back, widened byProgram.wireCastLE.Program.depths_eq_lines_depthstates CSLib's depth equation line by line, andProgram.wireDepths_lebounds every wire's depth by any certificate that bounds each line's depth at its own wire.Program.totalFanInandCircuit.totalFanIncount the wires read by all gates. They are the weighted costProgram.costfromComplexitylib.Algebraic.Costin which each operation costs its arity, so that API (for instanceProgram.cost_eq_sum_lines) applies to 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.
Main definitions #
Cslib.Circuits.Program.ofLines— a program from its linesCslib.Circuits.Program.wireCastLE— a wire of a shorter program, widenedCslib.Circuits.Program.totalFanIn,Cslib.Circuits.Circuit.totalFanIn— the total fan-in
Main results #
Cslib.Circuits.Program.lines_ofLines— the lines ofProgram.ofLinesCslib.Circuits.Program.depths_eq_lines_depth— CSLib's depth equation, line by lineCslib.Circuits.Program.wireDepths_le— bounding CSLib depth by a line-wise certificate
The program whose line j is F j, a line reading only the inputs and the
j gates before it.
Equations
- Cslib.Circuits.Program.ofLines 0 x_2 = Cslib.Circuits.Program.empty
- Cslib.Circuits.Program.ofLines g.succ F = (Cslib.Circuits.Program.ofLines g fun (j : Fin g) => F j.castSucc).gate (F (Fin.last g))
Instances For
Regard a wire of a program with j gates as a wire of a program with
g ≥ j gates, extending the first.
Equations
Instances For
Widening a wire keeps its index.
The lines of Program.ofLines are the given lines, widened.
Bounding CSLib depth by a line-wise certificate. If b bounds every
line's depth at the line's own wire, it bounds every wire's depth.
The total fan-in of a program: the number of wires read by all its gates, counted with multiplicity. It is the program's cost when every operation costs its arity.
Equations
Instances For
The total fan-in is the cost charging each operation its arity.
The empty program reads no wires.
A new gate adds its arity to the total fan-in.
The total fan-in of a circuit: the number of wires read by all its gates, counted with multiplicity. Designated outputs read nothing.
Equations
- c.totalFanIn = c.program.totalFanIn
Instances For
The total fan-in of a circuit is the cost charging each operation its arity.
A wiring has no gates, so it reads no wires.