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][AroraBarak09].
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.
A circuit computes a function with as many values as it has outputs when its designated outputs agree with the function on every input; a single-valued function is computed by a circuit with one output. Evaluation commutes with homomorphisms of interpretations.
References #
- [S. Arora and B. Barak, Computational Complexity: A Modern Approach, Section 6.1][AroraBarak09]
A straight-line program with designated output wires.
- size : ℕ
The number of gates in the program; inputs and designated outputs cost nothing.
The internal gates of the circuit.
The input or internal-gate wire carrying each output.
Instances For
The zero-gate circuit whose outputs are the inputs chosen by select. Projections,
duplications, and permutations of the inputs cost no gates.
Equations
- Cslib.Circuits.Circuit.wiring σ select = { size := 0, program := Cslib.Circuits.Program.empty, outputs := fun (output : Fin outputCount) => Cslib.Circuits.Wire.input (select output) }
Instances For
The zero-gate identity circuit, whose outputs are its inputs.
Equations
- Cslib.Circuits.Circuit.id σ inputCount = Cslib.Circuits.Circuit.wiring σ id
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
Output j of a wiring circuit is input select j.
A circuit computes f when its outputs agree with f on every input.
Instances For
A circuit computes f on the support S when its outputs agree with f on every input in
S; what f does outside S does not matter.
Equations
- c.ComputesOn interpretation S f = Set.EqOn (c.eval interpretation) f S
Instances For
Computing on every input is computing.
A circuit that computes f computes it on every support.
A wiring circuit computes the selection of its inputs.
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.
Equations
- c.trace i✝ x i = Fin.addCases (fun (i : Fin (inputCount + c.size)) => Fin.addCases x (c.program.eval i✝ x) i) (c.eval i✝ x) i