Prove2Me
Navigate
DiscoverCollectionsFormalpediaBlogsUsersMomentumMy Missions+
Prove2Me
⌕
Log in
← Formalpedia

A fault-tolerant circuit simulates the ideal circuit with errors at the bad ExRecs

Open
QAlgorithms.GottesmanIntro.output_eq_tilde

by Goku · Oct 13, 2026 · Mathlib 0df444a (Lean v4.33.1)

gottesman-introlecture-notesquantum-information

Fix an [[n,1,2t+1]][[n,1,2t+1]][[n,1,2t+1]] quantum code together with fault-tolerant gadgets for preparation of ∣0⟩|0\rangle∣0⟩, standard-basis measurement, the gates HHH, Rπ/8R_{\pi/8}Rπ/8​, CNOT, the wait location, and error correction (Definitions 2–5), all location gadgets having a common depth. Let CCC be a circuit on NNN qubits divided into time steps as in Definition 6 (no input, every qubit prepared first and measured last), and let C′C'C′ be its fault-tolerant circuit, obtained by replacing every location by its gadget and inserting EC gadgets between consecutive locations. Let WWW be a ∗*∗-decoder for the ideal decoder, i.e. a unitary from a code block to one qubit ⊗\otimes⊗ a syndrome register {0,…,σ−1}\{0,\dots,\sigma-1\}{0,…,σ−1} whose syndrome-discarded version is the ideal decoder.

Let a Pauli fault arrangement be placed on the locations of C′C'C′, and let BBB be the set of locations of CCC whose extended rectangles are bad, assigned from the end of the circuit by the truncation procedure of Definition 10. Then there are an initial state σ0\sigma_0σ0​ of NNN syndrome registers (one per qubit of CCC) and a circuit C~\tilde CC~ obtained from CCC as follows:

  1. at a location Ci∉BC_i\notin BCi​∈/B, the ideal operation of CiC_iCi​ on the data, followed by some quantum operation ViV_iVi​ acting only on the syndrome registers of the qubits of CiC_iCi​;
  2. at a location Ci∈BC_i\in BCi​∈B, the ideal operation followed by some quantum operation Ui′U'_iUi′​ on the qubits of CiC_iCi​ together with their syndrome registers,

such that

Pr⁡C′[decoded record=r]=Pr⁡C~[record=r]for every measurement record r of C.\Pr_{C'}[\text{decoded record}=r] = \Pr_{\tilde C}[\text{record}=r]\quad\text{for every measurement record } r \text{ of } C.C′Pr​[decoded record=r]=C~Pr​[record=r]for every measurement record r of C.

The output of C′C'C′ is decoded classically, block by block, by the decoding of the measurement gadgets. The theorem says that a fault-tolerant circuit behaves like the ideal circuit with errors only at the bad extended rectangles, and is the basis of the level-reduction theorem.

Formalization Note The error U′U'U′ “from eq. (82)” is whatever makes that diagram hold, so it is quantified existentially; the syndrome registers of C~\tilde CC~ are the ∗*∗-decoder syndromes, which is why good locations may act on them by the operation VVV of eq. (83).

Preamble
import Definitions.Def_QAlgorithms_Defs_FTCircuit
import Definitions.Def_QAlgorithms_GottesmanIntro_Ch05b_Model
set_option autoImplicit false
Formal statement
namespace QAlgorithms.GottesmanIntro




/-- Gottesman intro p.39, Theorem 8: "Suppose we have a fault-tolerant circuit `C′` for `C`.
Assign good and bad extended rectangles to `C′`, and produce a circuit `C̃` as follows: If the
ExRec for `C_i` is good, include `C_i` unchanged in `C̃`. If the ExRec for `C_i` is bad, replace
`C_i` by the erroneous gate `U′` from eq. (82) … The circuit `C̃` uses ancilla registers to
control the types of `U′` errors. Then the output distribution of `C′` is the same as the output
distribution of `C̃`."

Let `P` be a fault-tolerant protocol, `C` a Def. 6 circuit, `fa` a Pauli fault arrangement on
`C′ = ftCircuit P C`, and `W` a *-decoder for the ideal decoder with syndrome register `Fin σ`.
Let `B` be the set of bad locations of `C` assigned by Def. 10 from the faulty locations of `C′`.
Then there are an initial state `σ0` of the syndrome registers (one per qubit of `C`) and errors
forming a circuit `C̃` (`IsTildeErrors`: at a good location, the ideal operation on the data
followed by some operation `V` on the syndrome registers of its qubits only; at a bad location,
the ideal operation followed by an arbitrary quantum operation `U′` on its qubits and their
syndrome registers) such that the decoded output distribution of the faulty `C′` equals the output
distribution of `C̃`. -/
theorem output_eq_tilde (P : FTProtocol) (hP : P.IsFaultTolerant) (hdepth : P.HasUniformDepth)
    {N : ℕ} (C : LocCircuit N) (hC : C.IsIdealCircuit) (fa : PauliArrangement) {σ : ℕ}
    (W : Matrix (Bool × Fin σ) (Qubits P.n) ℂ) (hW : IsStarDecoder P.dec W) :
    ∃ (σ0 : Matrix (Fin N → Fin σ) (Fin N → Fin σ) ℂ) (err : ErrAssign N (Fin N → Fin σ)),
      IsDensityMatrix σ0 ∧
      IsTildeErrors C (badAssignment P C (faultyLocs (ftCircuit P C) fa)) σ err ∧
      pushDist (ftDecode P C) ((ftCircuit P C).outDist (pauliErr (ftCircuit P C) fa) 1) =
        C.outDist err σ0 := by
  sorry



end QAlgorithms.GottesmanIntro
Source
Daniel Gottesman, An Introduction to Quantum Error Correction and Fault-Tolerant Quantum Computation, 2009, v1, PDF p. 39, Theorem 8. https://arxiv.org/pdf/0904.2557v1
Read-back

What the Lean code literally says, in plain math · claude-opus-5-5

Data. The statement takes:

  • a fault-tolerant protocol PPP;
  • a circuit CCC of locations on NNN wires;
  • an arbitrary Pauli fault arrangement f ⁣af\!afa;
  • a natural number σ\sigmaσ;
  • a complex matrix WWW with rows indexed by {0,1}×{0,…,σ−1}\{0,1\}\times\{0,\dots,\sigma-1\}{0,1}×{0,…,σ−1} and columns indexed by nnn-bit strings.

The protocol PPP. It consists of:

  • natural numbers n,t,An, t, An,t,A;
  • a subspace C⊆C2n\mathcal C\subseteq\mathbb C^{2^n}C⊆C2n, the code;
  • a 2n×22^n\times 22n×2 matrix enc\mathrm{enc}enc;
  • a superoperator D\mathcal DD from nnn-qubit matrices to 2×22\times 22×2 matrices, the decoder;
  • for each location kind κ∈{prep,H,T,CNOT,meas,wait}\kappa\in\{\text{prep},H,T,\text{CNOT},\text{meas},\text{wait}\}κ∈{prep,H,T,CNOT,meas,wait}, a gadget circuit GκG_\kappaGκ​ on ar(κ)(n+A)\mathrm{ar}(\kappa)(n+A)ar(κ)(n+A) wires, where ar(CNOT)=2\mathrm{ar}(\text{CNOT})=2ar(CNOT)=2 and the other kinds have arity 111;
  • an error-correction circuit GecG_{ec}Gec​ on n+An+An+A wires;
  • a classical decoding map measDecode\mathrm{measDecode}measDecode from bit lists to bits.

Block iii, position jjj is wire i(n+A)+ji(n+A)+ji(n+A)+j. Positions j<nj<nj<n are data wires and the rest are ancillas.

Fault semantics. A Pauli fault arrangement assigns to some location ids ℓ=(s,j)\ell=(s,j)ℓ=(s,j) a pair of Paulis (P1,P2)(P_1,P_2)(P1​,P2​). At a location of the circuit, it acts as conjugation by the Pauli string that has P1P_1P1​ on the location's first wire and P2P_2P2​ on its others. This Pauli acts after the location's ideal action, or before it at a measurement. The faults carry a trivial one-dimensional environment.

For any f ⁣af\!afa, write f(G,f ⁣a)f(G,f\!a)f(G,fa) for the number of locations of GGG at which f ⁣af\!afa is defined. Every gadget superoperator is computed the same way:

  1. the input is placed on the data wires with all ancillas in ∣0⟩|0\rangle∣0⟩;
  2. the gadget is run with these Pauli faults;
  3. the outputs are summed over all measurement records;
  4. the ancillas are traced out.

This yields the following superoperators:

  • gateOpκ(f ⁣a)\mathrm{gateOp}_\kappa(f\!a)gateOpκ​(fa) on ar(κ)\mathrm{ar}(\kappa)ar(κ) blocks;
  • ecOp(f ⁣a)\mathrm{ecOp}(f\!a)ecOp(fa) on one block;
  • the matrix prep(f ⁣a)\mathrm{prep}(f\!a)prep(fa), obtained by starting from ∣0⋯0⟩|0\cdots0\rangle∣0⋯0⟩ on all wires;
  • the functional measF(f ⁣a,β)(ρ)\mathrm{measF}(f\!a,\beta)(\rho)measF(fa,β)(ρ), the trace of the meas-gadget output summed only over records rrr with measDecode(r)=β\mathrm{measDecode}(r)=\betameasDecode(r)=β.

Let Fr\mathcal F_rFr​ be conjugation by the orthogonal projection onto span{Pc:P a Pauli string of weight≤r, c∈C}\mathrm{span}\{Pc : P \text{ a Pauli string of weight}\le r,\ c\in\mathcal C\}span{Pc:P a Pauli string of weight≤r, c∈C}. Let ⨂\bigotimes⨂ denote the tensor product of superoperators, defined on matrix units and extended linearly.

Hypothesis "PPP is fault tolerant". All of the following hold:

  1. dim⁡C=2\dim\mathcal C=2dimC=2. Every operator acting nontrivially on at most 2t2t2t qubits is detectable: ⟨ψ∣Eψ⟩\langle\psi|E\psi\rangle⟨ψ∣Eψ⟩ is the same constant for all unit ψ∈C\psi\in\mathcal Cψ∈C.
  2. enc†enc=I2\mathrm{enc}^\dagger\mathrm{enc}=I_2enc†enc=I2​ and range⁡(enc)=C\operatorname{range}(\mathrm{enc})=\mathcal Crange(enc)=C.
  3. D\mathcal DD is a channel with a finite Kraus family satisfying ∑Kj†Kj=I\sum K_j^\dagger K_j=I∑Kj†​Kj​=I. For every EEE in the complex span of Pauli strings of weight ≤t\le t≤t and every unit ψ∈C2\psi\in\mathbb C^2ψ∈C2,
D(∣E enc ψ⟩⟨E enc ψ∣)=∥E enc ψ∥2 ∣ψ⟩⟨ψ∣.\mathcal D\big(|E\,\mathrm{enc}\,\psi\rangle\langle E\,\mathrm{enc}\,\psi|\big)=\|E\,\mathrm{enc}\,\psi\|^2\,|\psi\rangle\langle\psi|.D(∣Eencψ⟩⟨Eencψ∣)=∥Eencψ∥2∣ψ⟩⟨ψ∣.
  1. Each gadget is well formed with respect to its live wires:

    • GprepG_{\text{prep}}Gprep​ goes from no live wires to the data wires;
    • GmeasG_{\text{meas}}Gmeas​ goes from the data wires to none;
    • GH,GT,GCNOT,Gwait,GecG_H, G_T, G_{\text{CNOT}}, G_{\text{wait}}, G_{ec}GH​,GT​,GCNOT​,Gwait​,Gec​ go from data wires to data wires.

    Well formed means that in each step, locations touch disjoint wires and every live wire is touched. Preparations act only on non-live wires and other locations only on live wires. Preparations add live wires and measurements remove them, and the final live set is the stated one.

  2. Meas. Whenever r+f(Gmeas,f ⁣a)≤tr+f(G_{\text{meas}},f\!a)\le tr+f(Gmeas​,fa)≤t, for all β\betaβ and ρ\rhoρ:

measF(f ⁣a,β)(Frρ)=D(Frρ)ββ.\mathrm{measF}(f\!a,\beta)(\mathcal F_r\rho)=\mathcal D(\mathcal F_r\rho)_{\beta\beta}.measF(fa,β)(Fr​ρ)=D(Fr​ρ)ββ​.
  1. Prep A. If f(Gprep,f ⁣a)≤tf(G_{\text{prep}},f\!a)\le tf(Gprep​,fa)≤t, then Ff(Gprep,f ⁣a)(prep(f ⁣a))=prep(f ⁣a)\mathcal F_{f(G_{\text{prep}},f\!a)}(\mathrm{prep}(f\!a))=\mathrm{prep}(f\!a)Ff(Gprep​,fa)​(prep(fa))=prep(fa).
  2. Prep B. If f(Gprep,f ⁣a)≤tf(G_{\text{prep}},f\!a)\le tf(Gprep​,fa)≤t, then D(prep(f ⁣a))=∣0⟩⟨0∣\mathcal D(\mathrm{prep}(f\!a))=|0\rangle\langle0|D(prep(fa))=∣0⟩⟨0∣.
  3. Gate A. For κ∈{H,T,CNOT,wait}\kappa\in\{H,T,\text{CNOT},\text{wait}\}κ∈{H,T,CNOT,wait} and ri∈Nr_i\in\mathbb Nri​∈N with f+∑iri≤tf+\sum_i r_i\le tf+∑i​ri​≤t, where f=f(Gκ,f ⁣a)f=f(G_\kappa,f\!a)f=f(Gκ​,fa):
⨂Ff+∑ri∘gateOpκ∘⨂iFri=gateOpκ∘⨂iFri.\textstyle\bigotimes\mathcal F_{f+\sum r_i}\circ\mathrm{gateOp}_\kappa\circ\bigotimes_i\mathcal F_{r_i}=\mathrm{gateOp}_\kappa\circ\bigotimes_i\mathcal F_{r_i}.⨂Ff+∑ri​​∘gateOpκ​∘⨂i​Fri​​=gateOpκ​∘⨂i​Fri​​.
  1. Gate B. Under the same conditions:
⨂D∘gateOpκ∘⨂Fri=(Uκ⋅Uκ†)∘⨂D∘⨂Fri.\textstyle\bigotimes\mathcal D\circ\mathrm{gateOp}_\kappa\circ\bigotimes\mathcal F_{r_i}=(U_\kappa\cdot U_\kappa^\dagger)\circ\bigotimes\mathcal D\circ\bigotimes\mathcal F_{r_i}.⨂D∘gateOpκ​∘⨂Fri​​=(Uκ​⋅Uκ†​)∘⨂D∘⨂Fri​​.

Here UκU_\kappaUκ​ is, respectively, the Hadamard, diag(1,eiπ/4)\mathrm{diag}(1,e^{i\pi/4})diag(1,eiπ/4), CNOT with the first wire as control, or the identity. 10. EC A. If f=f(Gec,f ⁣a)≤tf=f(G_{ec},f\!a)\le tf=f(Gec​,fa)≤t, then Ff∘ecOp=ecOp\mathcal F_f\circ\mathrm{ecOp}=\mathrm{ecOp}Ff​∘ecOp=ecOp. 11. EC B. If r+f(Gec,f ⁣a)≤tr+f(G_{ec},f\!a)\le tr+f(Gec​,fa)≤t, then D∘ecOp∘Fr=D∘Fr\mathcal D\circ\mathrm{ecOp}\circ\mathcal F_r=\mathcal D\circ\mathcal F_rD∘ecOp∘Fr​=D∘Fr​.

Further hypotheses.

  • Uniform depth: every gadget has as many time steps as GprepG_{\text{prep}}Gprep​.
  • CCC is ideal: it is well formed from no live wires to no live wires, and every location's classical condition is constantly true.
  • WWW is a ∗*∗-decoder for D\mathcal DD: W†W=IW^\dagger W=IW†W=I, WW†=IWW^\dagger=IWW†=I, and Trσ(WρW†)=D(ρ)\mathrm{Tr}_{\sigma}(W\rho W^\dagger)=\mathcal D(\rho)Trσ​(WρW†)=D(ρ) for all ρ\rhoρ, where Trσ\mathrm{Tr}_\sigmaTrσ​ traces out the σ\sigmaσ-dimensional factor. In particular, this forces 2σ=2n2\sigma=2^n2σ=2n. For σ=0\sigma=0σ=0 the hypothesis is unsatisfiable.

The circuits. C′C'C′ is the fault-tolerant circuit FTP(C)\mathrm{FT}_P(C)FTP​(C) on N(n+A)N(n+A)N(n+A) wires. Each time step of CCC becomes two phases:

  • a gadget phase, in which each location is replaced by its gadget on the blocks of its wires;
  • an EC phase, in which GecG_{ec}Gec​ runs on the block of every wire whose location at that step is not a measurement.

Gadget conditions are conjoined with the original location's condition evaluated on decoded logical outcomes.

ftDecode\mathrm{ftDecode}ftDecode maps a C′C'C′ record to the list, over the measurement locations of CCC in order, of measDecode\mathrm{measDecode}measDecode applied to the outcomes of that location's meas gadget. Missing outcomes are read as false. For a decoding map dec\mathrm{dec}dec, the push-forward of a distribution μ\muμ is

pushdecμ(r)=∑r′: dec(r′)=rμ(r′).\mathrm{push}_{\mathrm{dec}}\mu(r)=\sum_{r':\,\mathrm{dec}(r')=r}\mu(r').pushdec​μ(r)=r′:dec(r′)=r∑​μ(r′).

Output distributions. out(C,err,σ0)(r)\mathrm{out}(C,\mathrm{err},\sigma_0)(r)out(C,err,σ0​)(r) is Re⁡Tr⁡\operatorname{Re}\operatorname{Tr}ReTr of the classical–quantum run of CCC at record rrr. The run starts from ∣0⋯0⟩⟨0⋯0∣⊗σ0|0\cdots0\rangle\langle0\cdots0|\otimes\sigma_0∣0⋯0⟩⟨0⋯0∣⊗σ0​ with the empty record. The error superoperator err(ℓ)\mathrm{err}(\ell)err(ℓ) is applied after location ℓ\ellℓ, or before it at a measurement.

The bad set. Bad(S)\mathrm{Bad}(S)Bad(S) is defined for a set SSS of C′C'C′ locations, scanning the steps of CCC from last to first. A location ℓ\ellℓ of CCC is bad if more than ttt elements of SSS lie in its ExRec. The ExRec of ℓ\ellℓ consists of:

  • ℓ\ellℓ's gadget;
  • the EC instances on ℓ\ellℓ's wires from the preceding step, if ℓ\ellℓ is not a preparation;
  • the EC instances on ℓ\ellℓ's wires from the same step, if ℓ\ellℓ is not a measurement, omitting wires that are also wires of a bad location in the next step.

Conclusion. There exist a matrix σ0\sigma_0σ0​ on the environment indexed by {0,…,σ−1}N\{0,\dots,\sigma-1\}^N{0,…,σ−1}N (one σ\sigmaσ-dimensional register per wire) and an error assignment err\mathrm{err}err such that:

  • σ0\sigma_0σ0​ is a density matrix (PSD with trace 111);
  • err\mathrm{err}err is a "tilde" error assignment for B=Bad(faulty locations of C′ under f ⁣a)B=\mathrm{Bad}(\text{faulty locations of }C'\text{ under }f\!a)B=Bad(faulty locations of C′ under fa), defined as follows:
    • err(ℓ)\mathrm{err}(\ell)err(ℓ) is absent wherever CCC has no location;
    • at each location lll, err(ℓ)\mathrm{err}(\ell)err(ℓ) is some channel Ψ\PsiΨ acting on lll's wires together with their σ\sigmaσ-registers, extended by the identity elsewhere;
    • if ℓ∉B\ell\notin Bℓ∈/B, then Ψ=idqubits⊗V\Psi=\mathrm{id}_{\text{qubits}}\otimes VΨ=idqubits​⊗V for some channel VVV on the σ\sigmaσ-registers alone;
  • the decoded faulty output equals the output of CCC under these errors:
pushftDecode(out(C′,Pauli faults f ⁣a, 1))=out(C,err,σ0).\mathrm{push}_{\mathrm{ftDecode}}\big(\mathrm{out}(C',\text{Pauli faults }f\!a,\,1)\big)=\mathrm{out}(C,\mathrm{err},\sigma_0).pushftDecode​(out(C′,Pauli faults fa,1))=out(C,err,σ0​).

No bound on the number of faults in f ⁣af\!afa is assumed.

Human review
  • Endorsed by Shuze Chen · Oct 13, 2026

    Confirmed by the moderator at approval.

  • Endorsed by Goku · Oct 13, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paper
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me