Documentation

CsdLean4.Mathlib.QuantumInfo.ReedMuller15Decoder

The decoder of the [[15, 1, 3]] protocol as an explicit CNOT circuit #

Category: 1-Mathlib (CSD-free; staged for upstream). BACKLOG #79, the last part of R-004's protocol (specs/magic-plan.md, "The split"): #77 read the output off the logical coefficients of the accepted state, and this file decodes it with a circuit.

The [15, 4] simplex code has a linear logical-Z readout. Columns 1, 2, 3 of the parity-check matrix sum to zero, so f(x) = xโ‚€ + xโ‚ + xโ‚‚ vanishes on every codeword (logicalBit_codeword) and is 1 on the all-ones shift codeword a + ๐Ÿ™ (logicalBit_add_one). The decoder therefore needs no Hadamard: sixteen CNOTs suffice.

The CNOT layer (general m, namespace Controlled) #

cnotAct a b is the label action of CNOT, an involution once a โ‰  b (cnotAct_cnotAct), and โ˜… cnotGate'_apply identifies #83's matrix as its permutation matrix โ€” the bridge from the entry algebra of ControlledGate.lean to a map on bitstrings, in the same shape as xGate_apply. On amplitudes a CNOT is a pullback, โ˜… cnotGate'_mulVec_apply: (C v)(k) = v (cnotAct a b k), and โ˜…โ˜… cnotListMat_mulVec_apply iterates that over a list of CNOTs (cnotListMat, the product with the first gate of the list rightmost, unitary by cnotListMat_mem_unitaryGroup): the amplitude map is the reversed composition cnotListPull.

The decoder (m = 15) #

The mechanism in one line is decodeLabelInv_update_one: decodeLabelInv (k[0 โ†ฆ 1]) = decodeLabelInv (k[0 โ†ฆ 0]) + ๐Ÿ™. The 1-sector of wire 0 pulls back to the coset C + ๐Ÿ™, which is exactly where |1ฬ„โŸฉ lives, and the 0-sector pulls back into the kernel of the readout, where |1ฬ„โŸฉ has no amplitude at all (logical1_apply_of_logicalBit_zero).

Honest scope #

โš ๏ธ The fourteen residual wires are not exhibited as a tensor factor: what is proved is the amplitude ratio at every residual label, the same statement in coordinates. A factorised form would need the relabelling (Fin 15 โ†’ Fin 2) โ‰ƒ Fin 2 ร— (Fin 14 โ†’ Fin 2). โš ๏ธ No measurement of the residual wires is modelled here; the row's "measures the fourteen syndrome qubits" is covered only in the sense above, that the ratio does not depend on their label. โš ๏ธ The circuit is a product of CNOTs, hence Clifford, but the corpus has no IsClifford predicate: the claim is carried by the explicit list decoderList and by unitarity (decoderCircuit_mem_unitaryGroup). BACKLOG #79 priced a CNOT/H circuit; the Hadamard turned out to be unnecessary for this code. โš ๏ธ Nothing here normalises anything: logical0, logical1 and outQubit are the unnormalised states of #76 and #77.

Source #

S. Bravyi, A. Kitaev, PRA 71 (2005) 022316 ยงIV; QuantumInfo/ReedMuller15Code.lean (#76), QuantumInfo/ReedMuller15Errors.lean (#77), QuantumInfo/ControlledGate.lean (#83); specs/magic-plan.md; specs/BACKLOG.md #79; specs/future-work.md.

CNOT as a permutation of the computational basis #

def QuantumInfo.Controlled.cnotAct {m : โ„•} (a b : Fin m) (x : Fin m โ†’ Fin 2) :
Fin m โ†’ Fin 2

The label action of CNOT with control a and target b: the target gains the control.

Equations
Instances For
    @[simp]
    theorem QuantumInfo.Controlled.cnotAct_apply_self {m : โ„•} (a b : Fin m) (x : Fin m โ†’ Fin 2) :
    cnotAct a b x b = x b + x a
    theorem QuantumInfo.Controlled.cnotAct_apply_of_ne {m : โ„•} {a b i : Fin m} (hi : i โ‰  b) (x : Fin m โ†’ Fin 2) :
    cnotAct a b x i = x i
    @[simp]
    theorem QuantumInfo.Controlled.cnotAct_cnotAct {m : โ„•} {a b : Fin m} (hab : a โ‰  b) (x : Fin m โ†’ Fin 2) :
    cnotAct a b (cnotAct a b x) = x

    CNOT is an involution on labels.

    theorem QuantumInfo.Controlled.cnotAct_eq_iff {m : โ„•} {a b : Fin m} (hab : a โ‰  b) {k x : Fin m โ†’ Fin 2} :
    cnotAct a b k = x โ†” k = cnotAct a b x

    The 2 ร— 2 block of CNOT is the bit flip, read as a condition on the two labels.

    theorem QuantumInfo.Controlled.cnotGate'_apply {m : โ„•} {a b : Fin m} (hab : a โ‰  b) (k l : Fin m โ†’ Fin 2) :
    cnotGate' a b k l = if l = cnotAct a b k then 1 else 0

    โ˜… CNOT is the permutation matrix of cnotAct โ€” the same shape as xGate_apply.

    theorem QuantumInfo.Controlled.cnotGate'_mulVec_apply {m : โ„•} {a b : Fin m} (hab : a โ‰  b) (v : (Fin m โ†’ Fin 2) โ†’ โ„‚) (k : Fin m โ†’ Fin 2) :
    (cnotGate' a b).mulVec v k = v (cnotAct a b k)

    โ˜… CNOT on amplitudes is the pullback along cnotAct.

    A list of CNOTs #

    noncomputable def QuantumInfo.Controlled.cnotListMat {m : โ„•} (l : List (Fin m ร— Fin m)) :
    Matrix (Fin m โ†’ Fin 2) (Fin m โ†’ Fin 2) โ„‚

    The matrix of a list of CNOTs: the first gate of the list acts first, so it is rightmost in the product.

    Equations
    Instances For
      def QuantumInfo.Controlled.cnotListPull {m : โ„•} (l : List (Fin m ร— Fin m)) (k : Fin m โ†’ Fin 2) :
      Fin m โ†’ Fin 2

      The label map a list of CNOTs pulls amplitudes back along: the reversed composition, so the last gate of the list is applied first.

      Equations
      Instances For
        @[simp]
        @[simp]
        theorem QuantumInfo.Controlled.cnotListPull_cons {m : โ„•} (p : Fin m ร— Fin m) (l : List (Fin m ร— Fin m)) (k : Fin m โ†’ Fin 2) :
        cnotListPull (p :: l) k = cnotAct p.1 p.2 (cnotListPull l k)
        theorem QuantumInfo.Controlled.cnotListMat_mulVec_apply {m : โ„•} (l : List (Fin m ร— Fin m)) :
        (โˆ€ p โˆˆ l, p.1 โ‰  p.2) โ†’ โˆ€ (v : (Fin m โ†’ Fin 2) โ†’ โ„‚) (k : Fin m โ†’ Fin 2), (cnotListMat l).mulVec v k = v (cnotListPull l k)

        โ˜…โ˜… A CNOT circuit acts on amplitudes as one label pullback.

        theorem QuantumInfo.Controlled.cnotListMat_mem_unitaryGroup {m : โ„•} (l : List (Fin m ร— Fin m)) :
        (โˆ€ p โˆˆ l, p.1 โ‰  p.2) โ†’ cnotListMat l โˆˆ Matrix.unitaryGroup (Fin m โ†’ Fin 2) โ„‚

        The logical readout of the simplex code #

        The logical Z readout f(x) = xโ‚€ + xโ‚ + xโ‚‚: zero on the code, one on its all-ones shift.

        Equations
        Instances For

          The readout vanishes on the code: columns 1, 2, 3 of the parity-check matrix sum to zero.

          theorem QuantumInfo.ReedMuller15.logicalBit_update_zero (k : Fin 15 โ†’ Fin 2) (v : Fin 2) :
          logicalBit (Function.update k 0 v) = v + k 1 + k 2

          The label map of the decoder and its inverse #

          def QuantumInfo.ReedMuller15.decodeLabel (x : Fin 15 โ†’ Fin 2) (j : Fin 15) :
          Fin 2

          What the decoder does to a label: the readout onto wire 0, cleared from the others.

          Equations
          Instances For
            theorem QuantumInfo.ReedMuller15.decodeLabel_of_ne {j : Fin 15} (hj : j โ‰  0) (x : Fin 15 โ†’ Fin 2) :
            def QuantumInfo.ReedMuller15.decodeLabelInv (y : Fin 15 โ†’ Fin 2) (j : Fin 15) :
            Fin 2

            The inverse label map: wire 0 is added back to the others, and the readout of the result lands on wire 0.

            Equations
            Instances For
              theorem QuantumInfo.ReedMuller15.decodeLabelInv_of_ne {j : Fin 15} (hj : j โ‰  0) (y : Fin 15 โ†’ Fin 2) :
              decodeLabelInv y j = y j + y 0

              The circuit #

              The targets of the clearing layer: every wire but 0.

              Equations
              Instances For

                The decoder: CNOT(1 โ†’ 0) and CNOT(2 โ†’ 0) compute the logical bit onto wire 0, then CNOT(0 โ†’ j) clears it from every other wire. Sixteen gates, no Hadamard.

                Equations
                Instances For
                  noncomputable def QuantumInfo.ReedMuller15.decoderCircuit :
                  Matrix (Fin 15 โ†’ Fin 2) (Fin 15 โ†’ Fin 2) โ„‚

                  The decoder circuit, as the product of its sixteen CNOT matrices.

                  Equations
                  Instances For
                    theorem QuantumInfo.ReedMuller15.cnotListPull_clean (l : List (Fin 15)) :
                    0 โˆ‰ l โ†’ l.Nodup โ†’ โˆ€ (y : Fin 15 โ†’ Fin 2) (j : Fin 15), Controlled.cnotListPull (List.map (fun (t : Fin 15) => (0, t)) l) y j = if j โˆˆ l then y j + y 0 else y j

                    The clearing layer adds wire 0 to each of its targets.

                    theorem QuantumInfo.ReedMuller15.decoderCircuit_mulVec_apply (v : (Fin 15 โ†’ Fin 2) โ†’ โ„‚) (z : Fin 15 โ†’ Fin 2) :

                    โ˜…โ˜… Every decoded amplitude.

                    The same, on register states.

                    โ˜… The forward reading: the circuit sends the basis label x to decodeLabel x, the logical bit on wire 0 and the all-ones component cleared from the rest.

                    The logical states under the decoder #

                    theorem QuantumInfo.ReedMuller15.logical0_apply (x : Fin 15 โ†’ Fin 2) :
                    logical0.ofLp x = โˆ‘ a : Fin 4 โ†’ Fin 2, if x = codeword a then 1 else 0
                    theorem QuantumInfo.ReedMuller15.logical1_apply (x : Fin 15 โ†’ Fin 2) :
                    logical1.ofLp x = โˆ‘ a : Fin 4 โ†’ Fin 2, if x = codeword a + 1 then 1 else 0

                    |1ฬ„โŸฉ has no amplitude where the readout vanishes: its labels are the coset C + ๐Ÿ™.

                    Wire 0 carries the logical qubit #

                    The mechanism. The 1-sector of wire 0 pulls back to the all-ones shift of the 0-sector โ€” the coset C + ๐Ÿ™, which is where |1ฬ„โŸฉ lives.

                    โ˜…โ˜… The decoded state carries the logical qubit on wire 0. Whatever the other fourteen wires do, the amplitude in the 1-sector of wire 0 is ฮป times the amplitude in the 0-sector: the decoded state is |0โŸฉ + ฮป|1โŸฉ on wire 0, uniformly in the residual label.

                    The pair above is not vacuous: the 0-sector carries amplitude 1 at the zero label.

                    The decoded output of the protocol #

                    theorem QuantumInfo.ReedMuller15.outQubit_apply_zero (e : Fin 15 โ†’ Fin 2) :
                    ((outQubit e).ofLp fun (x : Fin 1) => 0) = 1
                    theorem QuantumInfo.ReedMuller15.outQubit_apply_one (e : Fin 15 โ†’ Fin 2) :
                    ((outQubit e).ofLp fun (x : Fin 1) => 1) = signChar (parity e) * tPhaseInv

                    โ˜…โ˜…โ˜… The decoder outputs outQubit e on wire 0. For an undetected pattern e, the decoded amplitudes of the accepted state on wire 0 are exactly those of #77's outQubit e = |0โŸฉ + (โˆ’1)^{|e|} e^{โˆ’iฯ€/4}|1โŸฉ, at every label of the other fourteen wires.

                    โ˜…โ˜…โ˜… The output qubit, with its amplitudes. At the zero label of the other fourteen wires the decoded amplitudes are those of outQubit e: the protocol's output is โˆš2 ยท Z^{|e|} Tโ€ |+โŸฉ (outQubit_eq), the magic state up to the Clifford S (sGate_magicConj).