Documentation

CslibFrontier.Computability.Circuit.Quantum.Parallel

Circuits on parts of a larger register #

A circuit on m qubits runs on the qubits e : Fin m ↪ Fin N of a larger register (Cslib.Quantum.Circuit.mapWires). Its entries are those of the small circuit on the qubits e, provided the basis strings agree off e (Cslib.Quantum.Circuit.matrix_mapWires). Copies of one circuit on pairwise disjoint sets of qubits act independently: an entry of the whole is the product of the entries of the copies (Cslib.Quantum.Circuit.matrix_flatMap_mapWires). This is the tensor product structure behind running independent copies of a quantum computation in parallel.

For gate codes, shifting every qubit number by o (Cslib.Quantum.GateCode.shift) places the circuit on the block of qubits o, …, o + m - 1 (Cslib.Quantum.Circuit.ofCodes_map_shift).

Main definitions #

Main results #

Agreeing off part of a register #

def Cslib.Quantum.AgreeOff {ι : Type u_1} {N : ℕ} (e : ι ↪ Fin N) (y x : Fin N → Bool) :

The basis strings y and x agree off the qubits e.

Instances For
    @[instance_reducible]
    instance Cslib.Quantum.instDecidableAgreeOffOfFintype {ι : Type u_1} {N : ℕ} [Fintype ι] (e : ι ↪ Fin N) (y x : Fin N → Bool) :
    theorem Cslib.Quantum.AgreeOff.refl {ι : Type u_1} {N : ℕ} (e : ι ↪ Fin N) (x : Fin N → Bool) :
    AgreeOff e x x
    theorem Cslib.Quantum.AgreeOff.symm {ι : Type u_1} {N : ℕ} {e : ι ↪ Fin N} {y x : Fin N → Bool} (h : AgreeOff e y x) :
    AgreeOff e x y
    theorem Cslib.Quantum.AgreeOff.trans {ι : Type u_1} {N : ℕ} {e : ι ↪ Fin N} {z y x : Fin N → Bool} (h₁ : AgreeOff e z y) (h₂ : AgreeOff e y x) :
    AgreeOff e z x
    noncomputable def Cslib.Quantum.glue {ι : Type u_1} {N : ℕ} [Fintype ι] (e : ι ↪ Fin N) (z : ι → Bool) (x : Fin N → Bool) :
    Fin N → Bool

    The basis string x with the bits z on the qubits e.

    @[simp]
    theorem Cslib.Quantum.glue_apply_emb {ι : Type u_1} {N : ℕ} [Fintype ι] (e : ι ↪ Fin N) (z : ι → Bool) (x : Fin N → Bool) (i : ι) :
    glue e z x (e i) = z i
    theorem Cslib.Quantum.glue_of_not {ι : Type u_1} {N : ℕ} [Fintype ι] (e : ι ↪ Fin N) (z : ι → Bool) (x : Fin N → Bool) {j : Fin N} (hj : ∀ (i : ι), e i ≠ j) :
    glue e z x j = x j
    @[simp]
    theorem Cslib.Quantum.glue_comp {ι : Type u_1} {N : ℕ} [Fintype ι] (e : ι ↪ Fin N) (z : ι → Bool) (x : Fin N → Bool) :
    glue e z x ∘ ⇑e = z
    theorem Cslib.Quantum.agreeOff_glue {ι : Type u_1} {N : ℕ} [Fintype ι] (e : ι ↪ Fin N) (z : ι → Bool) (x : Fin N → Bool) :
    AgreeOff e (glue e z x) x
    theorem Cslib.Quantum.glue_comp_of_agreeOff {ι : Type u_1} {N : ℕ} [Fintype ι] {e : ι ↪ Fin N} {y x : Fin N → Bool} (h : AgreeOff e y x) :
    glue e (y ∘ ⇑e) x = y
    theorem Cslib.Quantum.sum_agreeOff {ι : Type u_1} {N : ℕ} [Fintype ι] [DecidableEq ι] {R : Type u_2} [AddCommMonoid R] (e : ι ↪ Fin N) (x : Fin N → Bool) (H : (Fin N → Bool) → R) :
    (∑ y : Fin N → Bool, if AgreeOff e y x then H y else 0) = ∑ z : ι → Bool, H (glue e z x)

    Summing over the basis strings that agree with x off e is summing over their bits on e.

    theorem Cslib.Quantum.sum_agreeOff_comp {ι : Type u_1} {N : ℕ} [Fintype ι] [DecidableEq ι] {R : Type u_2} [AddCommMonoid R] (e : ι ↪ Fin N) (x : Fin N → Bool) (F : (ι → Bool) → R) :
    (∑ y : Fin N → Bool, if AgreeOff e y x then F (y ∘ ⇑e) else 0) = ∑ z : ι → Bool, F z

    Summing a function of the bits on e over the basis strings that agree with x off e.

    Circuits on part of a register #

    The placed gate g on the qubits e of a larger register.

    theorem Cslib.Quantum.PlacedGate.matrix_mapWires {m N : ℕ} (e : Fin m ↪ Fin N) (g : PlacedGate m) (y x : Fin N → Bool) :
    ↑(mapWires e g).matrix y x = if AgreeOff e y x then ↑g.matrix (y ∘ ⇑e) (x ∘ ⇑e) else 0

    The entries of a gate on part of a register are those of the gate on the qubits e, when the basis strings agree off e.

    theorem Cslib.Quantum.Circuit.eval_ket_apply {m : ℕ} (C : Circuit m) (x y : Fin m → Bool) :
    (C.eval (ket x)).ofLp y = ↑C.matrix y x

    A circuit maps the basis state |x⟩ to its column x.

    theorem Cslib.Quantum.Circuit.ofCodes_flatMap {m : ℕ} {β : Type u_2} (l : List β) (f : β → List GateCode) :
    ofCodes m (List.flatMap f l) = List.flatMap (fun (b : β) => ofCodes m (f b)) l

    A circuit on m qubits with a list of gate codes; the codes of a concatenation of lists.

    def Cslib.Quantum.Circuit.mapWires {m N : ℕ} (e : Fin m ↪ Fin N) (C : Circuit m) :

    The circuit C on the qubits e of a larger register.

    @[simp]
    @[simp]
    theorem Cslib.Quantum.Circuit.mapWires_cons {m N : ℕ} (e : Fin m ↪ Fin N) (g : PlacedGate m) (C : Circuit m) :
    theorem Cslib.Quantum.Circuit.matrix_mapWires {m N : ℕ} (e : Fin m ↪ Fin N) (C : Circuit m) (y x : Fin N → Bool) :
    ↑(mapWires e C).matrix y x = if AgreeOff e y x then ↑C.matrix (y ∘ ⇑e) (x ∘ ⇑e) else 0

    The entries of a circuit on part of a register are those of the circuit on the qubits e, when the basis strings agree off e.

    theorem Cslib.Quantum.Circuit.matrix_flatMap_mapWires {m N : ℕ} (C : Circuit m) (L : List (Fin m ↪ Fin N)) (hL : List.Pairwise (fun (e e' : Fin m ↪ Fin N) => ∀ (i i' : Fin m), e i ≠ e' i') L) (y x : Fin N → Bool) :
    ↑(matrix (List.flatMap (fun (x : Fin m ↪ Fin N) => mapWires x C) L)) y x = if ∀ (j : Fin N), (∀ e ∈ L, ∀ (i : Fin m), e i ≠ j) → y j = x j then (List.map (fun (e : Fin m ↪ Fin N) => ↑C.matrix (y ∘ ⇑e) (x ∘ ⇑e)) L).prod else 0

    Copies of a circuit on disjoint parts of a register act independently: an entry of the whole is the product of the entries of the copies, when the basis strings agree off all parts.

    Shifted gate codes #

    The gate code g with every qubit number increased by o.

    def Cslib.Quantum.blockEmb {m N : ℕ} (o : ℕ) (h : o + m ≤ N) :
    Fin m ↪ Fin N

    The block of qubits o, …, o + m - 1 of an N-qubit register.

    @[simp]
    theorem Cslib.Quantum.blockEmb_apply_val {m N : ℕ} (o : ℕ) (h : o + m ≤ N) (i : Fin m) :
    ↑((blockEmb o h) i) = ↑i + o
    theorem Cslib.Quantum.glue_blockEmb_apply {m N o : ℕ} (h : o + m ≤ N) (r : Fin m → Bool) (X : Fin N → Bool) (i : Fin N) :
    glue (blockEmb o h) r X i = if h' : o ≤ ↑i ∧ ↑i < o + m then r ⟨↑i - o, ⋯⟩ else X i

    The bits of glue (blockEmb o h) r X: those of r on the block o, …, o + m - 1 and those of X elsewhere.

    A shifted well-formed gate code denotes the gate on the shifted block.

    theorem Cslib.Quantum.GateCode.WellFormed.shift {m N o : ℕ} (h : o + m ≤ N) {g : GateCode} (hg : WellFormed m g) :

    A well-formed gate code, shifted by o, is well formed on a register of at least o + m qubits.

    theorem Cslib.Quantum.Circuit.ofCodes_map_shift {m N o : ℕ} (h : o + m ≤ N) {gs : List GateCode} (hgs : ∀ g ∈ gs, GateCode.WellFormed m g) :

    Shifted gate codes denote the circuit on a block: shifting a well-formed circuit's qubit numbers by o runs it on the qubits o, …, o + m - 1.