Documentation

CslibFrontier.Computability.Circuit.CompositionLines

Lines of composed circuits #

Continuing a program p by a program q keeps the lines of p, with their wires widened to the larger namespace (Program.lines_append_castAdd), and places after them the lines of q, with their input wires read from the feeding wires of p and their gate wires shifted past the gates of p (Program.lines_append_natAdd). Consequently every line of the side-by-side circuit Circuit.pi cs is a line of some cs j whose wires are renamed by a map that fixes original inputs and sends gates to gates (Circuit.exists_lines_pi), and its outputs are gates when those of every cs j are (Circuit.outputs_pi_eq_gate).

Main results #

@[simp]
theorem Cslib.Circuits.Program.appendedWire_castSucc {n k g₁ g₂ : ℕ} (feed : Fin k → Wire n g₁) (w : Wire k g₂) :

Reading a wire of the continuation commutes with widening it by one gate.

theorem Cslib.Circuits.Program.lines_append_castAdd {σ : Signature} {n k g₁ g₂ : ℕ} (p : Program σ n g₁) (feed : Fin k → Wire n g₁) (q : Program σ k g₂) (j : Fin g₁) :
(p.append feed q).lines (Fin.castAdd g₂ j) = (p.lines j).mapWires (Wire.castAdd g₂)

Continuing p by q keeps each line of p, with its wires widened past the gates of q.

theorem Cslib.Circuits.Program.lines_append_natAdd {σ : Signature} {n k g₁ g₂ : ℕ} (p : Program σ n g₁) (feed : Fin k → Wire n g₁) (q : Program σ k g₂) (j : Fin g₂) :
(p.append feed q).lines (Fin.natAdd g₁ j) = (q.lines j).mapWires (appendedWire feed)

The lines of q follow those of p in p.append feed q, reading their inputs from feed and their gates shifted past the gates of p.

theorem Cslib.Circuits.Circuit.exists_lines_pi {σ : Signature} {n m : ℕ} (cs : Fin m → Circuit σ n 1) (k : Fin (pi cs).size) :
∃ (j : Fin m) (k' : Fin (cs j).size) (f : Wire n (cs j).size → Wire n (pi cs).size), (∀ (i : Fin n), f (Wire.input i) = Wire.input i) ∧ (∀ (g : Fin (cs j).size), ∃ (g' : Fin (pi cs).size), f (Wire.gate g) = Wire.gate g') ∧ (pi cs).program.lines k = ((cs j).program.lines k').mapWires f

Every line of pi cs is a line of some cs j, with its wires renamed by a map f that fixes the original inputs and sends gates to gates.

theorem Cslib.Circuits.Circuit.outputs_pi_eq_gate {σ : Signature} {n m : ℕ} (cs : Fin m → Circuit σ n 1) (h : ∀ (j : Fin m), ∃ (g : Fin (cs j).size), (cs j).outputs 0 = Wire.gate g) (j : Fin m) :
∃ (g : Fin (pi cs).size), (pi cs).outputs j = Wire.gate g

If every circuit cs j outputs a gate, then every output of pi cs is a gate.