The binary-gate semi-circuit of a circuit #
Under SemiCircuit.binaryB2Cost, which charges 1 only for the ten genuinely two-variable
operations of B₂ (fullSignature 2 Bool) and 0 for constants and unary projections /
negations, SemiCircuit.ofCircuitBinary folds all cost-0 lines directly into Lits without
creating gates. Input i becomes parameter i, each genuinely binary line g becomes gate
n + g with input literal negations absorbed into its operation, and the affine system is empty.
The resulting semi-circuit is well formed (SemiCircuit.wellFormed_ofCircuitBinary), has size
equal to C.program.cost binaryB2Cost (SemiCircuit.size_ofCircuitBinary), and evaluates to the
circuit's output on every consistent assignment (SemiCircuit.out_eval_ofCircuitBinary).
Main definitions #
Cslib.Circuits.Boolean.SemiCircuit.binaryB2Cost: cost charging1on genuinely binaryB₂gates and0on constants and unary operations.Cslib.Circuits.Boolean.SemiCircuit.ofCircuitBinary: the binary-gate semi-circuit folding constants and unary lines into literals.Cslib.Circuits.Boolean.SemiCircuit.lineBinaryLit,lineBinaryGate: the literal and gate of one line, on the literals of the earlier wires.Cslib.Circuits.Boolean.SemiCircuit.programGateLit,programWireLit,programBinaryGates,programBinaryGate: the folded literals of the gates and wires of a program, its binary gates and its gate map.
Main results #
Cslib.Circuits.Boolean.SemiCircuit.programGateLit_gate_castSucc,programGateLit_gate_last,mem_programBinaryGates_gate_of_ne,programBinaryGate_gate_of_ne,mem_programBinaryGates_gate_last,programBinaryGate_gate_last: appending a line keeps the earlier literals, binary gates and gate map; the new gate carries the literal of its line, the new name is a binary gate exactly when the line has binary cost1, and the gate map gives it the gate of its line.Cslib.Circuits.Boolean.SemiCircuit.programWireLit_wireInput,programWireLit_wireGate: the literals of input and gate wires.Cslib.Circuits.Boolean.SemiCircuit.mem_programBinaryGates_bounds,reads_programWireLit: binary gates are namedn + kfor earlier lines, and literals read only parameters and earlier binary gates.Cslib.Circuits.Boolean.SemiCircuit.ofCircuitBinary_gates,ofCircuitBinary_gate,ofCircuitBinary_out:ofCircuitBinaryin terms of the builder.Cslib.Circuits.Boolean.SemiCircuit.cost_binaryB2Cost_le_size,Cslib.Circuits.Boolean.SemiCircuit.size_ofCircuitBinary,Cslib.Circuits.Boolean.SemiCircuit.mem_gates_ofCircuitBinary,Cslib.Circuits.Boolean.SemiCircuit.wellFormed_ofCircuitBinary,Cslib.Circuits.Boolean.SemiCircuit.out_eval_ofCircuitBinary.
References #
Cost charging 1 for each genuinely two-variable operation of fullSignature 2 Bool (the
eight AND-type operations, XOR, and XNOR) and 0 for constants (.con c and constant .fn) and
unary projections / negated projections.
A constant operation .con c has binary B₂ cost 0.
Every operation of fullSignature 2 Bool has binary B₂ cost at most 1.
The binary B₂ cost of a circuit's program is at most its total gate count C.size.
Binary gate for a fullSignature 2 Bool line given the literals carried by earlier wires:
negations on input literals are absorbed into the gate's operation.
The literal computed by line when constant and unary lines fold into wLit and genuinely
binary lines introduce gate n + g.
The folded literal of each gate of p, read from a vector built in one pass over the program
(private). Separate calls may rebuild the vector. This module does not certify a running-time
bound.
The literal carried by any wire of p when constant and unary lines are folded.
An input wire carries the literal of its parameter.
A gate wire carries the folded literal of its gate.
Last line. The new gate carries the literal of its line, on the literals of the earlier wires.
Prefix. Appending a line keeps the literals of the earlier gates.
The indices n + k of genuinely binary gates in p.
The gate map of p on programBinaryGates p.
Every binary gate of p is named n + k for a line k < g.
Prefix. Appending a line keeps the binary gates other than the new name n + g.
Last line. The new name n + g is a binary gate exactly when the line has binary cost
1.
Prefix. Appending a line keeps the gate map away from the new name.
Last line. The gate of the new name is the gate of its line, on the literals of the earlier wires.
A wire's literal reads only parameters and binary gates of p, all below n + g.
The semi-circuit of a fullSignature 2 Bool circuit with constant and unary lines folded into
literals: its gate count equals C.program.cost binaryB2Cost.
The gates of ofCircuitBinary C are the binary gates of its program.
The gate map of ofCircuitBinary C is the gate map of its program.
The output of ofCircuitBinary C is the literal of its output wire.
The parameters of ofCircuitBinary C are Finset.range n.
The semi-circuit ofCircuitBinary C has no auxiliary variables.
The semi-circuit ofCircuitBinary C has no affine equations.
The size of ofCircuitBinary C equals the binary B₂ gate cost of C.
Every gate of ofCircuitBinary C is named n + j for a program line j < C.size.
The binary-gate semi-circuit ofCircuitBinary C is well formed.
On a consistent assignment, the output of ofCircuitBinary C equals the output of C on the
values of the parameters.