Straight-line programs #
A program is a topologically ordered sequence of gates. Each Line records an
operation and its argument wires. The gate-count index ensures that wires refer
only to original inputs or earlier gates.
This file defines
- lines, their evaluation and depth, and
Line.mapWirestogether with the transport lemmasLine.eval_mapWiresandLine.eval_mapRenaming; - programs, their evaluation
Program.eval, the input-and-gate valuationProgram.trace, gate depths, and the bounded-fan-in predicateProgram.FanInAtMost; - folds over program lines in execution order (
Program.foldl) and reverse execution order (Program.foldr), withProgram.foldl_relandProgram.foldr_relfor proving that the steps preserve a relation between accumulators; - the scalar views
Program.gateFunctionandProgram.wireFunction, and the widened line collectionProgram.lineswithProgram.lines_eval.
Evaluation of lines and programs commutes with homomorphisms
(Line.map_eval, Program.map_eval, Program.map_trace).
One gate together with the wires supplying its arguments.
- op : σ.Op
The operation performed by the gate.
The wire supplying each argument of the operation.
Instances For
A line is an operation symbol together with a tuple of argument wires.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Apply a function to every wire read by a line.
Instances For
A nonempty program is a prefix followed by its last gate.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Fold the lines from the first gate to the last. The step accepts a line at any gate count, retaining its original bound on references to previous gates.
Equations
Instances For
Two left folds preserve a relation if their initial accumulators are related and each pair of steps preserves it. For example, use equality or an order relation.
Fold the lines from the last gate to the first. Each line retains its original bound on references to previous gates, and the step receives the line before the accumulator.
Equations
Instances For
Two right folds preserve a relation if their initial accumulators are related and each pair of steps preserves it.
Every gate in a program has at most r arguments.
Equations
- Cslib.Circuits.Program.empty.FanInAtMost x✝ = True
- (program.gate line).FanInAtMost x✝ = (program.FanInAtMost x✝ ∧ σ.Arity line.op ≤ x✝)
Instances For
Bounded fan-in is decidable for every concrete program.
Equations
Evaluate a line from the values of the inputs and preceding gates.
Instances For
Mapping a line's wires preserves evaluation when the new valuation agrees with the old valuation along the map. The source and target input namespaces may differ.
Specialization of Line.eval_mapWires to an input-fixing wire renaming.
Evaluating a line commutes with a homomorphism.
Evaluate every gate in a program, in program order.
Equations
Instances For
The depth of every gate in a program. Inputs have implicit depth zero.
Equations
- Cslib.Circuits.Program.empty.depths = Fin.elim0
- (q.gate line).depths = fun (i : Fin (gateCount_2 + 1)) => Fin.lastCases (line.depth (Cslib.Circuits.Wire.elim (fun (x : Fin inputCount) => 0) q.depths)) q.depths i
Instances For
The depth of every input or gate wire in a program.
Equations
- p.wireDepths = Cslib.Circuits.Wire.elim (fun (x : Fin inputCount) => 0) p.depths
Instances For
Evaluating a program commutes with a homomorphism.
The value of every input and gate wire.
Equations
- p.trace i x = Cslib.Circuits.Wire.elim x (p.eval i x)
Instances For
Evaluating every input and gate wire commutes with a homomorphism.
The scalar function computed by an internal gate.
Equations
- program.gateFunction interpretation gate input = program.eval interpretation input gate
Instances For
The scalar function carried by an input or internal-gate wire.
Equations
- program.wireFunction interpretation wire input = program.trace interpretation input wire
Instances For
The program's lines, each widened to the final wire namespace.
Equations
- One or more equations did not get rendered due to their size.
- Cslib.Circuits.Program.empty.lines = Fin.elim0
Instances For
A widened line evaluates to the value of its corresponding program gate.
A valuation satisfying every gate equation is the program's evaluation.