CSLib circuits whose outputs are gates #
A CSLib circuit (Cslib.Circuits.Circuit) may designate any wire as an output,
including an original input, and designating outputs is free. Complexitylib's
typed circuits instead end in M distinct output gates, each counted in the
size. This file names the CSLib circuits whose every output is an internal gate
Circuit.GatedOutputs.
Translating a typed circuit into CSLib's model gives a circuit with gated
outputs and the same size (Complexity.Circuit.gatedOutputs_toStraightLine and
Complexity.Circuit.size_toStraightLine, in
Complexitylib.Circuits.StraightLine). Gated outputs alone do not make the two
size conventions agree when there are several outputs: two outputs may name the
same gate, and an output gate may feed later gates, neither of which a typed
circuit allows. A gated CSLib circuit with two outputs can thus have a single
gate, while a typed circuit with two outputs has at least two. The converse
translation, from gated CSLib circuits back to typed circuits, is planned
(docs/CircuitMigration.md, step 2.3) but not yet formalized, so this library
proves no size comparison in that direction.
Sequential composition keeps this property when the outer circuit has it, and
parallel composition keeps it when both circuits do. The number of outputs
that forward an input, Circuit.inputOutputCount, measures how far a circuit
is from having it.
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.Wire.IsGate— a wire is the output of an internal gateCslib.Circuits.Wire.gateOf— the gate carrying a gate wireCslib.Circuits.Circuit.GatedOutputs— every output is an internal gateCslib.Circuits.Circuit.inputOutputCount— the number of outputs that forward an input
Main results #
Cslib.Circuits.Circuit.GatedOutputs.size_pos— a gated circuit with an output has a gateCslib.Circuits.Circuit.GatedOutputs.comp,Cslib.Circuits.Circuit.GatedOutputs.append— composition keeps gated outputsCslib.Circuits.Circuit.inputOutputCount_eq_zero_iff— no output forwards an input exactly when the outputs are gated
Whether a wire is the output of an internal gate rather than an original input.
Equations
- (Cslib.Circuits.Wire.input input).IsGate = False
- (Cslib.Circuits.Wire.gate gate).IsGate = True
Instances For
Whether a wire is a gate is decided by its constructor.
Equations
The gate carrying a gate wire. The input case is absurd, so this is computable.
Equations
- (Cslib.Circuits.Wire.gate j).gateOf x_2 = j
- (Cslib.Circuits.Wire.input input).gateOf h = False.elim h
Instances For
A gate wire of a continued program's second part is a gate.
Every designated output of c is an internal gate, never an original
input. Typed circuits translate to circuits with this property and the same
size (Complexity.Circuit.gatedOutputs_toStraightLine,
Complexity.Circuit.size_toStraightLine). The property alone does not match
CSLib's free outputs with the typed charge of one distinct gate per output: with
several outputs, gated outputs may share a gate or feed later gates.
Equations
- c.GatedOutputs = ∀ (o : Fin m), (c.outputs o).IsGate
Instances For
Whether every output is a gate is decidable, output by output.
A gated circuit with an output has a gate.
Sequential composition keeps gated outputs when the outer circuit has them: its outputs are gates after the inner circuit's gates.
Parallel composition keeps gated outputs when both circuits have them.
No output forwards an input exactly when the outputs are gated.
At most every output forwards an input.