Unfolding circuits into formulas #
Every wire of a program carries the function of a formula: unfold the gates below it into a tree,
copying a gate once for each time it is read (Program.wireFormula). The formula of an output of a
circuit (Circuit.toFormula) computes that output (Circuit.eval_toFormula) and has exactly its
depth, whatever each operation costs (Circuit.depthWith_toFormula). Copying gates can make the
formula exponentially larger than the circuit, but no larger than its depth allows: over a basis
of fan-in at most r ≥ 2, the formula of an output of a circuit of depth d has fewer than
r ^ d operation nodes (Circuit.size_toFormula_lt). So circuits of fan-in two and logarithmic
depth are formulas of logarithmic depth and polynomial size Jukna, Chapter 6.
Main definitions #
Cslib.Circuits.Program.gateFormula,Cslib.Circuits.Program.wireFormula: the formulas unfolding the gates and the wires of a program.Cslib.Circuits.Circuit.toFormula: the formula unfolding an output of a circuit.
Main results #
Cslib.Circuits.Circuit.eval_toFormula,Cslib.Circuits.Circuit.Computes.toFormula: the formula of an output computes it.Cslib.Circuits.Circuit.depthWith_toFormula,Cslib.Circuits.Circuit.depth_toFormula_le: it is as deep as the output, so no deeper than the circuit.Cslib.Circuits.Circuit.size_toFormula_lt: under bounded fan-in, its size is at most exponential in the depth of the circuit.Cslib.Circuits.Program.gateFormula_eq_gate,Cslib.Circuits.Program.exists_wireFormula_eq_of_eq_gate: the formula of a gate is its operation applied to the formulas of the wires it reads, so the formulas of the wires are closed under taking arguments.Cslib.Circuits.Formula.toFormula_toCircuit,Cslib.Circuits.Formula.gateFormula_toCircuit_of_closed: the circuit of a formula unfolds to the formula, and the formulas of its gates are subformulas.
References #
Unfolding an input wire .input i gives the input formula .input i.
Unfolding a gate wire .gate k gives the gate formula p.gateFormula k.
The formula of the newly added last gate is line.op applied to the formulas of its argument
wires.
The formula of a gate is its operation applied to the formulas of the wires its line reads.
The arguments of the root of the formula of a wire are formulas of wires: the formulas of the wires of a program are closed under taking arguments.
The formula of a gate computes the gate.
The formula of a wire computes the wire.
The formula of a wire is as deep as the wire.
The formula of an output of a circuit computing f computes that output of f.
The formula of an output is as deep as the output.
Over a basis of fan-in at most r, where 2 ≤ r, the formula of an output of a circuit of
depth d has fewer than r ^ d operation nodes.
Unfolding the circuit of a formula #
The formulas of the gates of p continued by q on the inputs are formulas of gates of p
or of q.
The formulas of the gates of circuits side by side are formulas of gates of the circuits.
The formulas of the gates of the circuit of a formula F are subformulas of F: they satisfy
every property of F inherited by the arguments of operation nodes.