Circuits #
A circuit is a straight-line Program together with a choice of output wires.
Any input or internal-gate wire may be designated as an output, and designating
an output is free: projections and duplicated outputs cost no gates. The size
of a circuit is its gate count and its depth is the maximum depth of a
designated output wire.
For the standard Boolean circuit model, see Arora and Barak, Section 6.1.
Here a topological ordering is part of the representation, and the Boolean gate
basis is generalized to an arbitrary Signature and Interpretation. Our size
counts only operation gates; Arora and Barak count all nodes, including inputs.
An output wire may also supply a later gate.
This file defines evaluation (Circuit.eval), the flattened views
Circuit.computation and Circuit.trace, the zero-gate identity circuit
Circuit.id, and the structural bounded-fan-in predicate
Circuit.FanInAtMost. Evaluation commutes with homomorphisms
(Circuit.map_eval).
References #
A straight-line program with designated output wires.
- program : Program σ inputCount gateCount
The internal gates of the circuit.
The input or internal-gate wire carrying each output.
Instances For
The zero-gate identity circuit, whose outputs are its inputs.
Equations
- Cslib.Circuits.Circuit.id σ inputCount = { program := Cslib.Circuits.Program.empty, outputs := fun (input : Fin inputCount) => Cslib.Circuits.Wire.input input }
Instances For
Every gate in a circuit has at most r arguments.
Equations
- c.FanInAtMost r = c.program.FanInAtMost r
Instances For
Bounded fan-in is decidable for every concrete circuit.
Equations
The depth of every designated output wire in a circuit.
Equations
- c.outputDepths = c.program.wireDepths ∘ c.outputs
Instances For
The maximum depth of a designated output wire in a circuit.
Equations
Instances For
Read the designated output wires after evaluating the program.
Instances For
A single-output circuit computes f when its output agrees with f on every input.
Instances For
Evaluating a circuit commutes with a homomorphism.
All internal-gate values followed by the designated output values.
Equations
- c.computation i✝ x i = Fin.addCases (c.program.eval i✝ x) (c.eval i✝ x) i
Instances For
The input and internal-gate values followed by the designated outputs.