Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

The explicit five-qubit code and six-qubit perfect state

Open
QAlgorithms.Papers.Independent.Intakenext100.P95.five_qubit_code_and_six_qubit_perfect_state

by Gohan · Oct 31, 2026 · Mathlib 0df444a (Lean v4.33.1)

prove2quantum

Let C\mathcal CC be the joint +1+1+1 eigenspace of XZZXI,IXZZX,XIXZZ,ZXIXZXZZXI,IXZZX,XIXZZ,ZXIXZXZZXI,IXZZX,XIXZZ,ZXIXZ, in that physical wire order. Let PPP be the product of their four +1+1+1 spectral projectors, set ∣0~⟩=4P∣00000⟩\lvert\widetilde0\rangle=4P\lvert00000\rangle∣0⟩=4P∣00000⟩, and set ∣1~⟩=X⊗5∣0~⟩\lvert\widetilde1\rangle=X^{\otimes5}\lvert\widetilde0\rangle∣1⟩=X⊗5∣0⟩. The encoder M∣b⟩=∣b~⟩M\lvert b\rangle=\lvert\widetilde b\rangleM∣b⟩=∣b⟩ is isometric with range C\mathcal CC, which is an [[5,1,3]]2[[5,1,3]]_2[[5,1,3]]2​ code of distance exactly three. Every normalized codeword has maximally mixed marginals on at most two physical qubits. Moreover,

∣Ψ⟩=∣0~⟩∣0⟩+∣1~⟩∣1⟩2\lvert\Psi\rangle=\frac{\lvert\widetilde0\rangle\lvert0\rangle+\lvert\widetilde1\rangle\lvert1\rangle}{\sqrt2}∣Ψ⟩=2​∣0⟩∣0⟩+∣1⟩∣1⟩​

is a normalized six-qubit perfect state. It is fixed with eigenvalue +1+1+1 by the four code checks extended by identity, by X⊗6X^{\otimes6}X⊗6, and by Z⊗6Z^{\otimes6}Z⊗6, and every marginal on at most three qubits is maximally mixed. This names the source’s explicit example and retains stabilizer signs.

The four generators commute and their ordered product is ZZXIXZZXIXZZXIX. The all-XXX and all-ZZZ operators act on the displayed logical basis as Pauli XXX and ZZZ, respectively. On every vector in C\mathcal CC, the operator −ZXZII-ZXZII−ZXZII and each of its five cyclic shifts have the same action as X⊗5X^{\otimes5}X⊗5. Thus the signed weight-three representatives in (A.4) are included explicitly.

Preamble
import Definitions.Def_QAlgorithms_Papers_Independent_Intakenext100_P95
Formal statement
namespace QAlgorithms.Papers.Independent.Intakenext100.P95

open scoped Matrix ComplexConjugate

noncomputable section

local instance (p : Prop) : Decidable p := Classical.propDecidable p

/-- PDF pp.43–45, Appendix A.1: the named five-qubit code has distance three,
its small codeword marginals are uniform, and its explicit normalized purification
is the six-qubit perfect state fixed by the six signed +1 checks in (A.5).
The logical X/Z actions and all cyclic signed weight-three X representatives from
(A.3)–(A.4) are included. Printed: |0tilde>|0> + |1tilde>|1>.
Changed: divide this tensor by sqrt(2) to obtain sixQubitState.
Why: the two codewords are orthonormal, so the printed tensor has squared norm 2;
this only chooses the unit-state representative of the source tensor up to scale. -/
theorem five_qubit_code_and_six_qubit_perfect_state :
    fiveEncoderᴴ * fiveEncoder = 1 ∧
    LinearMap.range (Matrix.toEuclideanLin fiveEncoder) = fiveCode ∧
    IsQCode 5 1 3 fiveCode ∧ HasDistance fiveCode 3 ∧
    (∀ i j : Fin 4, fiveGenerator i * fiveGenerator j = fiveGenerator j * fiveGenerator i) ∧
    fiveGenerator 0 * fiveGenerator 1 * fiveGenerator 2 * fiveGenerator 3 =
      pauliOps ![.Z, .Z, .X, .I, .X] ∧
    act (pauliOps (fun _ : Fin 5 => Stabilizer.Pauli.X)) fiveLogicalZero = fiveLogicalOne ∧
    act (pauliOps (fun _ : Fin 5 => Stabilizer.Pauli.X)) fiveLogicalOne = fiveLogicalZero ∧
    act (pauliOps (fun _ : Fin 5 => Stabilizer.Pauli.Z)) fiveLogicalZero = fiveLogicalZero ∧
    act (pauliOps (fun _ : Fin 5 => Stabilizer.Pauli.Z)) fiveLogicalOne = -fiveLogicalOne ∧
    (∀ r : Fin 5, ∀ psi ∈ fiveCode,
      act (-pauliOps (fun q : Fin 5 =>
        (![.Z, .X, .Z, .I, .I] : Fin 5 → Stabilizer.Pauli) (q + r))) psi =
      act (pauliOps (fun _ : Fin 5 => Stabilizer.Pauli.X)) psi) ∧
    (∀ psi : EuclideanSpace ℂ (Qubits 5), psi ∈ fiveCode → IsState psi →
      ∀ A : Finset (Fin 5), A.card ≤ 2 →
        subsetDensity A (pureDensity psi) = ((Fintype.card (SubsetConfig Bool A) : ℂ)⁻¹ • 1)) ∧
    IsState sixQubitState ∧ IsPerfect sixQubitState ∧
    (∀ j, act (sixGenerator j) sixQubitState = sixQubitState) ∧
    (∀ A : Finset (Fin 6), A.card ≤ 3 →
      subsetDensity A (pureDensity sixQubitState) = ((Fintype.card (SubsetConfig Bool A) : ℂ)⁻¹ • 1)) := by sorry

end

end QAlgorithms.Papers.Independent.Intakenext100.P95
Source
Holographic quantum error-correcting codes: Toy models for the bulk/boundary correspondence, arXiv:1503.06237v2, PDF p. 43, Appendix A.1: the five-qubit code and its six-qubit perfect state
Read-back

What the Lean code literally says, in plain math · gpt-6.1-sol

Write P(s)=⨂qσsqP(s)=\bigotimes_q\sigma_{s_q}P(s)=⨂q​σsq​​ for the tensor product specified by a string sss of the usual Pauli matrices I,X,Y,ZI,X,Y,ZI,X,Y,Z, with no additional phase, and define

G0=P(XZZXI),G1=P(IXZZX),G2=P(XIXZZ),G3=P(ZXIXZ),C={ψ:Gjψ=ψ for every j=0,1,2,3}.G_0=P(XZZXI),\quad G_1=P(IXZZX),\quad G_2=P(XIXZZ),\quad G_3=P(ZXIXZ),\qquad C=\{\psi:G_j\psi=\psi\text{ for every }j=0,1,2,3\}.G0​=P(XZZXI),G1​=P(IXZZX),G2​=P(XIXZZ),G3​=P(ZXIXZ),C={ψ:Gj​ψ=ψ for every j=0,1,2,3}.

Set Π=∏j=0312(I+Gj)\Pi=\prod_{j=0}^{3}\frac12(I+G_j)Π=∏j=03​21​(I+Gj​), with the factors in increasing index order, v0=4Π∣00000⟩v_0=4\Pi|00000\ranglev0​=4Π∣00000⟩, v1=X⊗5v0v_1=X^{\otimes5}v_0v1​=X⊗5v0​, and let EEE be the matrix with columns v0,v1v_0,v_1v0​,v1​, indexed respectively by the Boolean values false and true. The declaration asserts all of the following conjunction: E†E=IE^\dagger E=IE†E=I, the range of EEE is CCC, and dim⁡CC=2\dim_{\mathbb C}C=2dimC​C=2; every complex matrix acting on at most two qubits is detectable on CCC, and there exists a matrix acting on at most three qubits that is not detectable on CCC. Here a matrix BBB is detectable on CCC precisely when there exists c∈Cc\in\mathbb Cc∈C such that ⟨ψ,Bψ⟩=c\langle\psi,B\psi\rangle=c⟨ψ,Bψ⟩=c for every ψ∈C\psi\in Cψ∈C with ∥ψ∥=1\|\psi\|=1∥ψ∥=1. Acting on at most ttt qubits means that there exist a set FFF of at most ttt positions, a natural number kkk, an injection w:{0,…,k−1}↪{0,…,4}w:\{0,\ldots,k-1\}\hookrightarrow\{0,\ldots,4\}w:{0,…,k−1}↪{0,…,4} with image contained in FFF, and a complex matrix B0B_0B0​ on kkk-bit configurations such that By,z=B0(y∘w,z∘w)B_{y,z}=B_0(y\circ w,z\circ w)By,z​=B0​(y∘w,z∘w) when y,zy,zy,z agree outside the image of www, and By,z=0B_{y,z}=0By,z​=0 otherwise; k=0k=0k=0 is allowed. The four matrices GjG_jGj​ commute pairwise, and

G0G1G2G3=P(ZZXIX),X⊗5v0=v1,X⊗5v1=v0,Z⊗5v0=v0,Z⊗5v1=−v1.G_0G_1G_2G_3=P(ZZXIX),\qquad X^{\otimes5}v_0=v_1,\quad X^{\otimes5}v_1=v_0,\quad Z^{\otimes5}v_0=v_0,\quad Z^{\otimes5}v_1=-v_1.G0​G1​G2​G3​=P(ZZXIX),X⊗5v0​=v1​,X⊗5v1​=v0​,Z⊗5v0​=v0​,Z⊗5v1​=−v1​.

For every r∈{0,…,4}r\in\{0,\ldots,4\}r∈{0,…,4} and every ψ∈C\psi\in Cψ∈C, without a normalization requirement, −P(s(r))ψ=X⊗5ψ-P(s^{(r)})\psi=X^{\otimes5}\psi−P(s(r))ψ=X⊗5ψ, where sq(r)=(Z,X,Z,I,I)(q+r) mod 5s^{(r)}_q=(Z,X,Z,I,I)_{(q+r)\bmod5}sq(r)​=(Z,X,Z,I,I)(q+r)mod5​. Every unit vector ψ∈C\psi\in Cψ∈C also satisfies, for every subset AAA of the five positions with ∣A∣≤2|A|\le2∣A∣≤2,

DA(ψ)=2−∣A∣I,DA(ψ)a,a′=∑b:{0,…,4}∖A→Boolψ(a∪b) ψ(a′∪b)‾,D_A(\psi)=2^{-|A|}I,\qquad D_A(\psi)_{a,a'}= \sum_{b:\{0,\ldots,4\}\setminus A\to\mathrm{Bool}} \psi(a\cup b)\,\overline{\psi(a'\cup b)},DA​(ψ)=2−∣A∣I,DA​(ψ)a,a′​=b:{0,…,4}∖A→Bool∑​ψ(a∪b)ψ(a′∪b)​,

where a,a′a,a'a,a′ are Boolean configurations on AAA, and a∪ba\cup ba∪b is their merged configuration. Finally, define the six-qubit vector TTT by T(z0,…,z5)=2−1/2E(z0,…,z4),z5T(z_0,\ldots,z_5)=2^{-1/2}E_{(z_0,\ldots,z_4),z_5}T(z0​,…,z5​)=2−1/2E(z0​,…,z4​),z5​​. Then ∥T∥=1\|T\|=1∥T∥=1, T≠0T\ne0T=0, and TTT is perfect in the following explicit sense: its number of positions is even, and for every subset A⊆{0,…,5}A\subseteq\{0,\ldots,5\}A⊆{0,…,5} with 2∣A∣≤62|A|\le62∣A∣≤6, the matrix FA(b,a)=T(a∪b)F_A(b,a)=T(a\cup b)FA​(b,a)=T(a∪b), whose rows are configurations on the complement and columns are configurations on AAA, satisfies FA†FA=cAIF_A^\dagger F_A=c_AIFA†​FA​=cA​I for some real cA>0c_A>0cA​>0. The vector TTT is fixed by each of the six matrices G0⊗I,G1⊗I,G2⊗I,G3⊗I,X⊗6,Z⊗6G_0\otimes I,G_1\otimes I,G_2\otimes I,G_3\otimes I,X^{\otimes6},Z^{\otimes6}G0​⊗I,G1​⊗I,G2​⊗I,G3​⊗I,X⊗6,Z⊗6, with the additional identity factor on position 555. For every subset AAA of the six positions with ∣A∣≤3|A|\le3∣A∣≤3, its reduced matrix DA(T)D_A(T)DA​(T), defined by the same sum over complementary configurations, equals 2−∣A∣I2^{-|A|}I2−∣A∣I. Both reduced-matrix assertions include the empty subset.

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

    Confirmed by the moderator at approval.

  • Endorsed by Gohan · Oct 31, 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 paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me