The standard-form encoding network maps |c⟩ to the encoded basis state (4.8)
OpenQAlgorithms.GottesmanThesis.stabEncoder_encodesLet a stabilizer on qubits ( generators) be given in the standard form (4.3) of §4.1,
with rows in the first block, and assume its rows commute: . For a binary row write (the real form, sign ). Let be the generators and let be the logical operators in the standard form of p.40: with the -th row of and the -th row of .
Let be the encoding network of §4.2 (with the author's errata): first, for each , the controlled-NOTs that apply without its final , controlled on qubit ; then, for in turn, the Hadamard on qubit , a on qubit if , and without its qubit- factor, controlled on qubit (controlled- gates). Then for every ,
and in particular the vector on the right-hand side is nonzero.
This is the correctness of Gottesman's general encoding circuit for stabilizer codes: the network prepares exactly the encoded basis states, with no leftover global phase.
Formalization Note The errata are built in: the Hadamard on qubit comes just before that qubit's control operations, controlled- gates are controlled- gates in the real form, and every generator has sign . The page writes encoded states unnormalized; the unitary network yields the normalized vector. Since the real form , a generator with an odd number of positions is times a Hermitian Pauli operator; the identity is the one the page's network computes in this convention.
import Definitions.Def_QAlgorithms_Defs_BinaryStabilizer set_option autoImplicit false
namespace QAlgorithms.GottesmanThesis
/-- Gottesman thesis pp.41–43, §4.2 (unnumbered; equation (4.8)), with the author's errata:
for a stabilizer in standard form (4.3) with rank parameter `r` and commuting rows, and the
logical `X̄` operators in the standard form of p.40 (`U₃ = I`, `V₃ = 0`, `U₂ = Eᵀ`,
`V₁ = EᵀC₁ᵀ + C₂ᵀ`), the encoding network of §4.2 maps the input `|0…0⟩|c₁…c_k⟩` (the first
`n − k` qubits in `|0⟩`, `|c_i⟩` in qubit `n − k + i`) to the normalized encoded basis state
`(I + M₁)⋯(I + M_{n−k}) X̄₁^{c₁}⋯X̄_k^{c_k} |0…0⟩`.
The network (`stabEncoder`) is the controlled-NOT step (each `X̄_i` without its last `σx`,
controlled on qubit `n − k + i`), followed, for `i = 1, …, r` in turn, by `R` on qubit `i`, `σz`
on qubit `i` if `B_ii = 1`, and `M_i` (without its qubit-`i` factor) controlled on qubit `i`
(erratum: Hadamard just before the qubit's control dots). Generators and `X̄`'s are the
real-form Pauli products `σz^b σx^a` with sign `+1` (errata: controlled-`Y` is controlled-`XZ`;
the method needs every generator of sign `+1`). -/
theorem stabEncoder_encodes {m k r : ℕ} (Hx Hz : Matrix (Fin m) (Fin (m + k)) (ZMod 2))
(hstd : IsStandardForm r Hx Hz) (hcomm : SymplecticCommuting Hx Hz) (c : Qubits k) :
act (stabEncoder r Hx Hz).unitary (ket (Fin.append (fun _ : Fin m => false) c)) =
normalizedVec (stabEncodedState r Hx Hz c) := by
sorry
end QAlgorithms.GottesmanThesis
Read-back
What the Lean code literally says, in plain math · claude-opus-5-5
Setting. Fix natural numbers and matrices over . The register has qubits on wires . Basis states are labelled by bit strings , with wire the most significant.
Hypotheses.
- Standard form with parameter :
- ;
- for ;
- row of is zero for every ;
- for and .
- Symplectic commutation: over .
No linear-independence hypothesis is assumed.
Input. Take an arbitrary . The input is the basis state : wires are and wire carries .
The circuit. The encoder is a list of gates applied in list order, first gate first. If the list is , its unitary is . Each acts as the gate's matrix on its wires (in the listed order) and as the identity on all other wires.
A controlled gate with control wire and target wire acts as
Here , , and is the Hadamard gate.
The gate list is the concatenation of two parts.
- Part 1. For in order, and within that for in order:
- if and , apply with control wire and target wire .
- Part 2. For in order, and only when :
- apply on wire ;
- then, if , apply on wire ;
- then, for in order with and , apply with control wire and target wire , where
Rows contribute no gates.
The target vector. For , define the unphased Pauli operator
In particular, appears as .
For each , the logical operator is , where:
- for :
- for : if , and otherwise;
- for :
computed in ;
- for : .
Define
In each product the factor with index is applied first. The factors carry no .
Conclusion.
The normalization uses the convention . So if , the right-hand side is the zero vector.
Degenerate case. When the circuit is empty, so .
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.