Documentation

CslibFrontier.Computability.Circuit.Boolean.SemiCircuit.OfCircuit

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 #

Main results #

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.

@[simp]

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.

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 output of ofCircuitBinary C is the literal of its output wire.

@[simp]

The semi-circuit ofCircuitBinary C has no auxiliary variables.

@[simp]

The semi-circuit ofCircuitBinary C has no affine equations.

@[simp]

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.

theorem Cslib.Circuits.Boolean.SemiCircuit.out_eval_ofCircuitBinary {n : ℕ} (C : Circuit (fullSignature 2 Bool) n 1) {val : ℕ → Bool} (hval : (ofCircuitBinary C).Consistent val) :
(ofCircuitBinary C).out.eval val = C.eval fullInterpretation (fun (i : Fin n) => val ↑i) 0

On a consistent assignment, the output of ofCircuitBinary C equals the output of C on the values of the parameters.