Replacing circuit gates with inputs #
Replacing cut gates with extra inputs carrying their original values preserves the full wire trace. The rebuilt program preserves fan-in bounds and realizes the residual wire depths.
Main definitions #
Cslib.Circuits.Program.residualDepths: gate depths with cut gates at depth0.Cslib.Circuits.Program.residualWireDepths: the corresponding depths of all wires.
Main results #
Cslib.Circuits.Program.residualWireDepths_empty: the empty cut recovers the original depths.Cslib.Circuits.Program.residualWireDepths_gate: the gate recurrence for residual depths.Cslib.Circuits.Program.exists_cutProgram: a program with cut gates replaced by extra inputs, with the same bounded fan-in and wire trace and with the specified residual depths.
@[simp]
theorem Cslib.Circuits.Program.residualWireDepths_gateWire {σ : Signature} {n g : ℕ} (p : Program σ n g) (cut : Finset (Fin g)) (j : Fin g) :
Every gate wire's residual depth is given by Program.residualDepths.
theorem Cslib.Circuits.Program.residualWireDepths_gate {σ : Signature} {n g : ℕ} (p : Program σ n g) (cut : Finset (Fin g)) (j : Fin g) :
p.residualWireDepths cut (Wire.gate j) = if j ∈ cut then 0 else (p.lines j).depth (p.residualWireDepths cut)
Gate equation for Program.residualWireDepths: cut gates have residual depth 0, while
uncut gates evaluate Line.depth over residualWireDepths (charging 1 to 0-ary gates).
@[simp]
theorem Cslib.Circuits.Program.residualWireDepths_empty {σ : Signature} {n g : ℕ} (p : Program σ n g) :
With an empty cut, residualWireDepths agrees identically with Program.wireDepths.
theorem Cslib.Circuits.Program.exists_cutProgram {σ : Signature} {n g : ℕ} (p : Program σ n g) (cut : Finset (Fin g)) :
∃ (q : Program σ (n + cut.card) (g - cut.card)) (wireMap : Wire n g → Wire (n + cut.card) (g - cut.card)) (cutGate :
Fin cut.card → Fin g),
(∀ (i : Fin cut.card), cutGate i ∈ cut) ∧ (∀ (r : ℕ), p.FanInAtMost r → q.FanInAtMost r) ∧ (∀ (w : Wire n g), q.wireDepths (wireMap w) = p.residualWireDepths cut w) ∧ (∀ (k : Fin (g - cut.card)), ∃ (j : Fin g), wireMap (Wire.gate j) = Wire.gate k) ∧ ∀ {U : Type u_1} (I : Interpretation σ U) (x : Fin n → U) (w : Wire n g),
q.trace I (Fin.append x fun (i : Fin cut.card) => p.eval I x (cutGate i)) (wireMap w) = p.trace I x w
Turning the gates in cut into cut.card extra inputs yields a program of g - cut.card
gates with the same bounded fan-in, wire depths equal to p.residualWireDepths cut, and identical
traces on Fin.append x (cut gate values).