Typed circuits as CSLib straight-line programs #
This file proves that Circuit.toStraightLine, which turns a typed circuit
over a basis B into a CSLib circuit over B.signature, preserves the computed
function, the size, and the total fan-in, and that its outputs are gates
(Cslib.Circuits.Circuit.GatedOutputs). It is the correspondence on which the
move of Complexitylib's circuit developments to CSLib's model rests (see
ROADMAP.md, item 7). The correspondence proved here runs one way, from typed
circuits to CSLib circuits; the translation back is not yet formalized.
Main results #
Complexity.Basis.interpretation_kind— the interpretation of a gate's kind is the gate's evaluationComplexity.StraightLine.eval_ofLines— each gate of a program built from lines evaluates its line on the values of the earlier gatesComplexity.StraightLine.index_wireOfIndex— the wire with indexwin the typed layout has CSLib indexwComplexity.Circuit.eval_toStraightLine— the translation computes what the typed circuit computesComplexity.Circuit.size_toStraightLine— the translation has the typed circuit's sizeComplexity.Circuit.gatedOutputs_toStraightLine— every output of the translation is an internal gateComplexity.Circuit.totalFanIn_toStraightLine— the translation has the typed circuit's total fan-in
The interpretation of a gate's kind, applied to the values of the gate's
input wires, is the gate's evaluation: Basis.interpretation negates the
flagged inputs and applies the operation exactly as Gate.eval does.
Each gate of Program.ofLines g lines evaluates its line on the values of
the earlier gates.
The straight-line form has the typed circuit's total fan-in. CSLib's
Circuit.totalFanIn of the translation, the sum of the arities of its lines,
equals the typed circuit's Circuit.totalFanIn, the sum of the fan-ins of its
internal and output gates.