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) #
decoderListis the circuit:CNOT(1 โ 0)andCNOT(2 โ 0)compute the logical bit onto wire0, thenCNOT(0 โ j)forj = 1, โฆ, 14clear the all-ones component from the other wires โ sixteen gates (decoderList_length), anddecoderCircuitis their product;- โ
cnotListPull_decoderList: the circuit pulls labels back bydecodeLabelInv, so โ โdecoderCircuit_mulVec_applyandtoEuclideanLin_decoderCircuit_applygive every decoded amplitude as(D ฯ)(z) = ฯ (decodeLabelInv z).decodeLabelInvis inverse todecodeLabel(decodeLabel_decodeLabelInv,decodeLabelInv_decodeLabel), which is the forward reading: โdecoderCircuit_mulVec_basisState,D|xโฉ = |decodeLabel xโฉ, the logical bit on wire0and the all-ones component cleared; - โ
โ
decoderCircuit_logical_update: wire0carries the logical qubit. For every labelkof the other fourteen wires the decoded amplitude atk[0 โฆ 1]isฮปtimes the one atk[0 โฆ 0], whereฮปis the logical coefficient of the input|0ฬโฉ + ฮป|1ฬโฉ. The ratio is the same whatever the fourteen residual wires carry, which is why measuring them does not disturb wire0. The pair is not vacuous:decoderCircuit_logical_apply_zerogives amplitude1at the zero label; - โ
โ
โ
decoderCircuit_encodedMagicanddecoderCircuit_encodedMagic_apply: the decoded output is #77'soutQubit e. For an undetected patternethe amplitudes on wire0are those ofoutQubit e = |0โฉ + (โ1)^{|e|} e^{โiฯ/4}|1โฉ, which isโ2 ยท Z^{|e|} Tโ |+โฉ(outQubit_eq) and the magic state up to the CliffordS(sGate_magicConj).
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 #
The label action of CNOT with control a and target b: the target gains the control.
Equations
- QuantumInfo.Controlled.cnotAct a b x = Function.update x b (x b + x a)
Instances For
The 2 ร 2 block of CNOT is the bit flip, read as a condition on the two labels.
A list of CNOTs #
The matrix of a list of CNOTs: the first gate of the list acts first, so it is rightmost
in the product.
Equations
- QuantumInfo.Controlled.cnotListMat l = List.foldr (fun (p : Fin m ร Fin m) (M : Matrix (Fin m โ Fin 2) (Fin m โ Fin 2) โ) => M * QuantumInfo.Controlled.cnotGate' p.1 p.2) 1 l
Instances For
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
- QuantumInfo.Controlled.cnotListPull l k = List.foldr (fun (p : Fin m ร Fin m) (y : Fin m โ Fin 2) => QuantumInfo.Controlled.cnotAct p.1 p.2 y) k l
Instances For
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
- QuantumInfo.ReedMuller15.logicalBit x = x 0 + x 1 + x 2
Instances For
The readout vanishes on the code: columns 1, 2, 3 of the parity-check matrix sum to
zero.
The label map of the decoder and its inverse #
What the decoder does to a label: the readout onto wire 0, cleared from the others.
Equations
Instances For
The inverse label map: wire 0 is added back to the others, and the readout of the result
lands on wire 0.
Equations
- QuantumInfo.ReedMuller15.decodeLabelInv y j = if j = 0 then QuantumInfo.ReedMuller15.logicalBit y else y j + y 0
Instances For
The circuit #
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
The decoder circuit, as the product of its sixteen CNOT matrices.
Equations
Instances For
The clearing layer adds wire 0 to each of its targets.
โ
The circuit pulls labels back by decodeLabelInv.
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 #
|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 #
โ
โ
โ
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).