Syndrome extraction as a circuit #
Category: 1-Mathlib. Matrix algebra only; nothing here mentions CSD or a particular code. BACKLOG #94, split out of #62 (c1).
The corpus measures a syndrome as a projective measurement on the data register
(Empirical/QM/QEC/SyndromeRecovery.lean). A circuit-level fault-tolerance argument needs it as a
circuit: an ancilla block prepared in 0, a ladder of transversal CNOTs from data to ancilla,
and a measurement of the ancilla. This file builds that gadget and proves what it does when nothing
fails.
The whole construction is one observation: a CNOT ladder from data to ancilla is a permutation of
basis labels, (z, a) ↦ (z, a + H z) for the check map H, so it is permMat of
TransversalClifford.lean — no amplitudes to track, and the circuit's action on the computational
basis is a relabelling.
What is proved #
extractPerm H,extractMat H— the label permutation and its matrix, withextractPerm_involutive,extractMat_conjTranspose,extractMat_mul_selfand ★extractMat_mem_unitaryGroup: the gadget is a self-inverse unitary, exactly as aCNOTladder is. OnlyH z + H z = 0is needed — characteristic two, nothing else;ancInit— the ancilla preparationz ↦ (z, 0), an isometry (ancInit_conjTranspose_mul);ancProj s— the projector reading the ancilla block ass, andsynProj H sthe projector on the data onto{z | H z = s}; both are Hermitian idempotents summing to1(sum_ancProj,sum_synProj);- ★★
extractMat_mul_ancInit_apply— extraction tags the data with its syndrome: the circuit sends the basis statezwith a fresh ancilla to(z, H z), and that single matrix-entry computation is the content of the gadget; - ★★★
ancProj_mul_extractMat_mul_ancInit— extraction returns the syndrome: reading the ancilla assafter extraction is the same operator as projecting the data onto the syndrome-ssubspace. The circuit implements the projective measurement the corpus had been assuming; - ★★★
extractMat_mul_ancInit_mul_synProj_zeroand ★★★extractMat_conj_codeState— extraction leaves a code state alone: on the syndrome-0subspace the circuit acts as the identity, ancilla included, so for any operator supported on the code the extracted state is the input with a fresh ancilla and nothing else; - ★★
ancProj_zero_mul_extractMat_conj_codeState— and the syndrome-0outcome is then certain: the extracted code state is already in that branch; - ★
ancProj_mul_extractMat_mul_ancInit_of_ne— a syndrome the data does not have has zero amplitude, which is the statement that the measurement is not merely consistent but exhaustive.
Honest scope #
⚠️ No faults are modelled. Every theorem here is about the gadget when nothing fails: this is the fault-free extraction circuit, and the faulty version — a fault in the ladder or in the ancilla — is BACKLOG #95 (the verified ancilla) and #96 (the extended rectangle). Nothing here says the gadget is fault-tolerant; it says what it computes.
⚠️ The ancilla is one unverified block. ancInit prepares the all-zero ancilla and the gadget
reads it; no cat-state preparation, no verification step, and therefore no protection against a single
ancilla fault spreading to the data. That is exactly what #95 is for.
⚠️ One check map, measured once. H is a single map to the syndrome labels, applied once; nothing
here iterates extraction, interleaves it with gates, or composes rounds. Repeated extraction with
faults is #96's extended rectangle.
⚠️ X-type only, as a relabelling. The construction works because the ladder permutes
computational-basis labels. A Z-type check is the same statement in the conjugate basis and is
not derived here; combining both bases for a CSS code is further work.
⚠️ No decoder. The syndrome is produced, not interpreted: nothing here maps a syndrome to a correction, and the recovery maps of the corpus are not re-derived or connected.
References #
Mathlib/QuantumInfo/TransversalClifford.lean (permMat);
Empirical/QM/QEC/SyndromeRecovery.lean (the projective-measurement form this replaces with a
circuit); specs/BACKLOG.md #94, #95, #96, #62; specs/future-work.md.
The extraction gadget #
The label permutation a CNOT ladder performs: the data is untouched and the ancilla block
is shifted by the data's check value.
Instances For
The ladder is an involution — the only arithmetic the gadget needs is characteristic two.
The extraction circuit: the transversal CNOT ladder from data to ancilla, as the matrix of
its basis relabelling.
Equations
Instances For
★ The gadget is unitary, as a CNOT ladder must be.
The ancilla block: preparation and readout #
The ancilla preparation: adjoin a fresh ancilla block in the all-zero state.
Instances For
Preparing an ancilla is an isometry.
The ancilla readout: the projector onto the ancilla block reading s.
Equations
- QuantumInfo.ancProj s = Matrix.diagonal fun (p : α × β) => if p.2 = s then 1 else 0
Instances For
The syndrome projector on the data: the projector onto {z | H z = s}, which is what the
corpus's projective-measurement form of the syndrome is.
Equations
- QuantumInfo.synProj H s = Matrix.diagonal fun (z : α) => if H z = s then 1 else 0
Instances For
What the gadget computes #
★★ Extraction tags the data with its syndrome. The circuit takes the basis state z with a
fresh ancilla to (z, H z): one matrix entry, and the whole content of the gadget.
★★★ Extraction returns the syndrome. Reading the ancilla block as s after extraction is the
same operator as projecting the data onto the syndrome-s subspace: the circuit implements the
projective measurement that the corpus's SyndromeRecovery.lean form of the syndrome assumes.
★ A syndrome the data does not carry gets zero amplitude. The measurement is exhaustive, not merely consistent.
The prepared ancilla is already in the 0 branch.
★★★ On the code, extraction does nothing. Restricted to the syndrome-0 subspace the circuit
acts as the identity — the ancilla comes back to 0 and the data is untouched — so "extraction leaves
a code state alone" is an operator identity, not a statement about a particular state.
★★★ A code state is returned unchanged, ancilla included. For any operator supported on the
syndrome-0 subspace, extraction conjugates it to itself with a fresh ancilla.
★★ And the syndrome-0 outcome is certain on the code.