MerLean-example

1 Rem 1: Stabilizer Code Convention

Throughout this work, we consider an \([[n,k,d]]\) quantum low-density parity-check (qLDPC) stabilizer code on \(n\) physical qubits, encoding \(k\) logical qubits with distance \(d\). The code is specified by a set of stabilizer checks \(\{ s_i\} \). A logical operator \(L\) is a Pauli operator that commutes with all stabilizers but is not itself a stabilizer. By choosing an appropriate single-qubit basis for each physical qubit, we ensure that the logical operator \(L\) being measured is a product of Pauli-\(X\) matrices:

\[ L = \prod _{v \in \operatorname {supp}(L)} X_v, \]

where \(\operatorname {supp}(L)\) denotes the set of qubits on which \(L\) acts non-trivially.

Definition 1 Single-Qubit Pauli Type
#

The four single-qubit Pauli operators form an inductive type StabPauliType with constructors:

  • \(I\) — the identity,

  • \(X\) — the Pauli-\(X\) (bit flip),

  • \(Y\) — the Pauli-\(Y\),

  • \(Z\) — the Pauli-\(Z\) (phase flip).

Definition 2 Pauli Multiplication
#

Multiplication of single-qubit Pauli types (ignoring global phase) is defined by the rules:

  • \(I \cdot p = p\) and \(p \cdot I = p\) for all \(p\),

  • \(X \cdot X = Y \cdot Y = Z \cdot Z = I\),

  • \(X \cdot Y = Z\), \(Y \cdot X = Z\), \(Y \cdot Z = X\), \(Z \cdot Y = X\), \(Z \cdot X = Y\), \(X \cdot Z = Y\).

Definition 3 Nontrivial Pauli
#

A single-qubit Pauli type \(p\) acts nontrivially if and only if \(p \neq I\). That is, isNontrivial returns true for \(X\), \(Y\), and \(Z\), and false for \(I\).

Definition 4 \(X\)-Type Pauli
#

A single-qubit Pauli type \(p\) is \(X\)-type if \(p \in \{ X, Y\} \); i.e., it involves the \(X\) component.

Definition 5 \(Z\)-Type Pauli
#

A single-qubit Pauli type \(p\) is \(Z\)-type if \(p \in \{ Z, Y\} \); i.e., it involves the \(Z\) component.

Definition 6 Single-Qubit Pauli Commutation
#

Two single-qubit Pauli types \(p\) and \(q\) commute if any of the following holds: one of them is \(I\), or \(p = q\). Explicitly, the only anticommuting pairs are \(\{ X,Z\} \), \(\{ X,Y\} \), and \(\{ Y,Z\} \).

Lemma 7 Commutativity of Single-Qubit Pauli Commutation
#

For all single-qubit Pauli types \(p\) and \(q\), \(\operatorname {commutes}(p, q) = \operatorname {commutes}(q, p)\).

Proof

We case-split on all combinations of \(p\) and \(q\). In each of the \(4 \times 4 = 16\) cases, the equality holds by reflexivity.

Definition 8 Multi-Qubit Pauli Operator
#

A Pauli operator on \(n\) qubits is a structure consisting of:

  • a function \(\texttt{paulis} : \operatorname {Fin}(n) \to \texttt{StabPauliType}\) assigning a single-qubit Pauli type to each qubit, and

  • a global phase \(\texttt{phase} \in \mathbb {Z}/4\mathbb {Z}\), where \(0 = +1\), \(1 = +i\), \(2 = -1\), \(3 = -i\).

Definition 9 Identity Pauli Operator
#

The identity operator on \(n\) qubits is defined as \(\texttt{paulis}(i) = I\) for all \(i \in \operatorname {Fin}(n)\) and \(\texttt{phase} = 0\).

Definition 10 Support of a Pauli Operator
#

The support of a Pauli operator \(P\) on \(n\) qubits is the finite set

\[ \operatorname {supp}(P) = \{ i \in \operatorname {Fin}(n) \mid P.\texttt{paulis}(i) \neq I\} . \]
Definition 11 \(X\)-Type Support
#

The \(X\)-type support of a Pauli operator \(P\) is the finite set of qubits where \(P\) acts as \(X\) or \(Y\):

\[ \operatorname {xSupp}(P) = \{ i \in \operatorname {Fin}(n) \mid P.\texttt{paulis}(i).\texttt{isXType} = \texttt{true}\} . \]
Definition 12 \(Z\)-Type Support
#

The \(Z\)-type support of a Pauli operator \(P\) is the finite set of qubits where \(P\) acts as \(Z\) or \(Y\):

\[ \operatorname {zSupp}(P) = \{ i \in \operatorname {Fin}(n) \mid P.\texttt{paulis}(i).\texttt{isZType} = \texttt{true}\} . \]
Definition 13 Multi-Qubit Pauli Commutation
#

Two Pauli operators \(P\) and \(Q\) on \(n\) qubits commute (ignoring global phase) if and only if the number of positions where their single-qubit Pauli types anticommute is even:

\[ \bigl|\{ i \in \operatorname {Fin}(n) \mid \neg \operatorname {commutes}(P.\texttt{paulis}(i),\, Q.\texttt{paulis}(i))\} \bigr| \equiv 0 \pmod{2}. \]
Definition 14 Purely \(X\)-Type Operator
#

A Pauli operator \(P\) on \(n\) qubits is purely \(X\)-type if, for every qubit \(i\), \(P.\texttt{paulis}(i) \in \{ I, X\} \).

Definition 15 Pure \(X\) Constructor
#

Given a finite set \(S \subseteq \operatorname {Fin}(n)\), the pure \(X\)-type operator \(\operatorname {pureX}(S)\) is the Pauli operator with

\[ \operatorname {pureX}(S).\texttt{paulis}(i) = \begin{cases} X & \text{if } i \in S, \\ I & \text{if } i \notin S, \end{cases} \]

and phase \(0\).

Lemma 16 \(\operatorname {pureX}\) is Purely \(X\)-Type

For any finite set \(S \subseteq \operatorname {Fin}(n)\), the operator \(\operatorname {pureX}(S)\) is purely \(X\)-type.

Proof

Let \(i\) be an arbitrary qubit. By the definition of \(\operatorname {pureX}\), we split on whether \(i \in S\). If \(i \in S\), then \(\operatorname {pureX}(S).\texttt{paulis}(i) = X\). If \(i \notin S\), then \(\operatorname {pureX}(S).\texttt{paulis}(i) = I\). In both cases the result is in \(\{ I, X\} \), and the claim follows by simplification.

Lemma 17 Support of \(\operatorname {pureX}\)

For any finite set \(S \subseteq \operatorname {Fin}(n)\),

\[ \operatorname {supp}(\operatorname {pureX}(S)) = S. \]
Proof

By extensionality, it suffices to show that for each \(i\), \(i \in \operatorname {supp}(\operatorname {pureX}(S))\) if and only if \(i \in S\). We unfold the definitions of support and \(\operatorname {pureX}\) and split on whether \(i \in S\). If \(i \in S\), then \(\operatorname {pureX}(S).\texttt{paulis}(i) = X \neq I\), so \(i\) is in the support. If \(i \notin S\), then \(\operatorname {pureX}(S).\texttt{paulis}(i) = I\), so \(i\) is not in the support. Both directions follow by simplification.

Lemma 18 \(X\)-Support of \(\operatorname {pureX}\)

For any finite set \(S \subseteq \operatorname {Fin}(n)\),

\[ \operatorname {xSupp}(\operatorname {pureX}(S)) = S. \]
Proof

By extensionality, it suffices to show for each \(i\) that \(i \in \operatorname {xSupp}(\operatorname {pureX}(S))\) if and only if \(i \in S\). We unfold the definitions and split on whether \(i \in S\). If \(i \in S\), then \(\operatorname {pureX}(S).\texttt{paulis}(i) = X\), which is \(X\)-type. If \(i \notin S\), then \(\operatorname {pureX}(S).\texttt{paulis}(i) = I\), which is not \(X\)-type. Both cases follow by simplification using the definition of isXType.

Lemma 19 \(Z\)-Support of \(\operatorname {pureX}\) is Empty

For any finite set \(S \subseteq \operatorname {Fin}(n)\),

\[ \operatorname {zSupp}(\operatorname {pureX}(S)) = \emptyset . \]
Proof

By extensionality, it suffices to show for each \(i\) that \(i \notin \operatorname {zSupp}(\operatorname {pureX}(S))\). We unfold the definitions and split on whether \(i \in S\). If \(i \in S\), then \(\operatorname {pureX}(S).\texttt{paulis}(i) = X\), which is not \(Z\)-type. If \(i \notin S\), then \(\operatorname {pureX}(S).\texttt{paulis}(i) = I\), which is also not \(Z\)-type. In both cases the claim follows by simplification using the definition of isZType.

Definition 20 Stabilizer Group
#

A stabilizer group on \(n\) qubits is a structure consisting of:

  • a set of generating Pauli operators \(\texttt{generators} \subseteq \texttt{PauliOp}(n)\),

  • a proof that the generating set is finite,

  • a proof that all generators mutually commute: for all \(s_1, s_2 \in \texttt{generators}\), \(\operatorname {commutes}(s_1, s_2)\).

Definition 21 Stabilizer Code
#

An \([[n, k, d]]\) stabilizer code is a structure consisting of:

  • the number of physical qubits \(n \in \mathbb {N}\),

  • the number of logical qubits \(k \in \mathbb {N}\),

  • the code distance \(d \in \mathbb {N}\),

  • a stabilizer group on \(n\) qubits,

  • a constraint \(n \geq k\),

  • a positivity constraint \(d {\gt} 0\).

Definition 22 Commutes with Stabilizers

A Pauli operator \(P\) on \(C.n\) qubits commutes with the stabilizer group of a code \(C\) if and only if it commutes with every generator:

\[ \forall \, s \in C.\texttt{stabilizers}.\texttt{generators},\quad \operatorname {commutes}(P, s). \]
Definition 23 Centralizer
#

The centralizer of a stabilizer code \(C\) is the set of all Pauli operators on \(C.n\) qubits that commute with all stabilizers:

\[ \mathcal{C}(C) = \{ P \in \texttt{PauliOp}(C.n) \mid C.\operatorname {commutesWithStabilizers}(P)\} . \]
Definition 24 Membership in Stabilizer Group

A Pauli operator \(P\) is in the stabilizer group of code \(C\) if there exists a finite set of generators \(\texttt{gens} \subseteq C.\texttt{stabilizers}.\texttt{generators}\) such that:

  • if \(\texttt{gens} = \emptyset \) then \(P\) equals the identity, and

  • \(P\) is one of the generators, or \(P\) is the identity.

(This is a simplified definition; a full treatment would define the group generated by the generators.)

Definition 25 Logical Operator

A logical operator for a stabilizer code \(C\) is a structure consisting of:

  • an underlying Pauli operator \(\texttt{op} : \texttt{PauliOp}(C.n)\),

  • a proof that \(\texttt{op}\) commutes with all stabilizers,

  • a proof that \(\texttt{op}\) is not in the stabilizer group.

Definition 26 Support of a Logical Operator
#

The support of a logical operator \(L\) is \(\operatorname {supp}(L) := \operatorname {supp}(L.\texttt{op})\).

Definition 27 \(X\)-Support of a Logical Operator
#

The \(X\)-type support of a logical operator \(L\) is \(\operatorname {xSupp}(L) := \operatorname {xSupp}(L.\texttt{op})\).

Definition 28 \(Z\)-Support of a Logical Operator
#

The \(Z\)-type support of a logical operator \(L\) is \(\operatorname {zSupp}(L) := \operatorname {zSupp}(L.\texttt{op})\).

Definition 29 \(X\)-Type Logical Operator
#

An \(X\)-type logical operator for a stabilizer code \(C\) extends a logical operator with the additional property that the underlying Pauli operator is purely \(X\)-type. This captures the convention

\[ L = \prod _{v \in \operatorname {supp}(L)} X_v. \]

For an \(X\)-type logical operator \(L\), the support equals the \(X\)-type support:

\[ \operatorname {supp}(L) = \operatorname {xSupp}(L). \]
Proof

By extensionality, it suffices to show for each qubit \(i\) that \(i \in \operatorname {supp}(L) \Leftrightarrow i \in \operatorname {xSupp}(L)\). We unfold the definitions and use the fact that \(L\) is purely \(X\)-type, so \(L.\texttt{paulis}(i) \in \{ I, X\} \). We consider two cases:

  • If \(L.\texttt{paulis}(i) = I\), then \(i \notin \operatorname {supp}(L)\) (since \(I = I\)) and \(\texttt{isXType}(I) = \texttt{false}\), so \(i \notin \operatorname {xSupp}(L)\). By simplification, both sides are false.

  • If \(L.\texttt{paulis}(i) = X\), then \(X \neq I\) so \(i \in \operatorname {supp}(L)\), and \(\texttt{isXType}(X) = \texttt{true}\) so \(i \in \operatorname {xSupp}(L)\). Both directions are verified by the decide tactic.

Lemma 31 \(Z\)-Support is Empty for \(X\)-Type Logicals

For an \(X\)-type logical operator \(L\), the \(Z\)-type support is empty:

\[ \operatorname {zSupp}(L) = \emptyset . \]
Proof

By extensionality, it suffices to show that no qubit \(i\) belongs to \(\operatorname {zSupp}(L)\). We unfold the definitions and use the purely \(X\)-type property of \(L\), so \(L.\texttt{paulis}(i) \in \{ I, X\} \). We consider two cases:

  • If \(L.\texttt{paulis}(i) = I\), then \(\texttt{isZType}(I) = \texttt{false}\), so \(i \notin \operatorname {zSupp}(L)\).

  • If \(L.\texttt{paulis}(i) = X\), then \(\texttt{isZType}(X) = \texttt{false}\), so \(i \notin \operatorname {zSupp}(L)\).

Both cases follow by simplification.

Definition 32 Constructing an \(X\)-Type Logical from Support

Given a stabilizer code \(C\) and a finite set \(S \subseteq \operatorname {Fin}(C.n)\), together with proofs that \(\operatorname {pureX}(S)\) commutes with all stabilizers and is not in the stabilizer group, we construct an \(X\)-type logical operator with underlying operator \(\operatorname {pureX}(S)\). The purely \(X\)-type property follows from the lemma that \(\operatorname {pureX}(S)\) is purely \(X\)-type.

Lemma 33 Support of \(\operatorname {fromSupport}\)

For a stabilizer code \(C\), a finite set \(S\), and appropriate proofs \(h_1, h_2\),

\[ \operatorname {supp}(\operatorname {fromSupport}(C, S, h_1, h_2)) = S. \]
Proof

By simplification using the definitions of fromSupport and LogicalOp.support, together with the lemma that \(\operatorname {supp}(\operatorname {pureX}(S)) = S\).

Theorem 34 Product Representation of \(X\)-Type Logicals

For an \(X\)-type logical operator \(L\) over a stabilizer code \(C\), the Pauli content of \(L\) on each qubit matches \(\operatorname {pureX}\) applied to its support. That is,

\[ L.\texttt{op}.\texttt{paulis} = \operatorname {pureX}(\operatorname {supp}(L)).\texttt{paulis}. \]

This is the formal statement that \(L = \prod _{v \in \operatorname {supp}(L)} X_v\) (ignoring global phase).

Proof

By extensionality, it suffices to show that for each qubit \(i\), \(L.\texttt{op}.\texttt{paulis}(i) = \operatorname {pureX}(\operatorname {supp}(L)).\texttt{paulis}(i)\). We unfold the definitions and split on whether \(i \in \operatorname {supp}(L)\):

  • If \(i \in \operatorname {supp}(L)\): By the definition of support, \(L.\texttt{paulis}(i) \neq I\). Since \(L\) is purely \(X\)-type, \(L.\texttt{paulis}(i) \in \{ I, X\} \). Because \(L.\texttt{paulis}(i) \neq I\), we conclude \(L.\texttt{paulis}(i) = X\). On the other hand, \(\operatorname {pureX}(\operatorname {supp}(L)).\texttt{paulis}(i) = X\) since \(i \in \operatorname {supp}(L)\).

  • If \(i \notin \operatorname {supp}(L)\): By the definition of support (filtering and double negation elimination), \(L.\texttt{paulis}(i) = I\). On the other hand, \(\operatorname {pureX}(\operatorname {supp}(L)).\texttt{paulis}(i) = I\) since \(i \notin \operatorname {supp}(L)\).

In both cases the equality holds.

Definition 35 LDPC Property
#

A stabilizer code \(C\) is Low-Density Parity-Check (LDPC) if there exist constants bounding:

  • Maximum check weight \(w_{\max } \in \mathbb {N}\): for every generator \(s \in C.\texttt{stabilizers}.\texttt{generators}\), \(|\operatorname {supp}(s)| \leq w_{\max }\).

  • Maximum qubit degree \(\Delta _{\max } \in \mathbb {N}\): for every qubit \(i \in \operatorname {Fin}(C.n)\), the number of generators whose support contains \(i\) is at most \(\Delta _{\max }\).