Recommended resources
The freely available resources this lesson will direct you to.
Hello! Welcome to your ninth lesson in the "Quantum Error Correction Fundamentals" module.
In the last few lessons, we've gone deep into the mechanics of a specific, powerful quantum code: the 9-qubit Shor code. We built it from the ground up, from encoding to syndrome measurement and finally to decoding and correction. You'll have noticed that the Shor code cleverly combines two simpler ideas: a 3-qubit code for bit-flips and another for phase-flips. These underlying codes behave very much like classical error-correcting codes.
This observation provides the motivation for today's lesson. To build more sophisticated and efficient quantum codes, we first need a solid grasp of their classical counterparts. We will therefore step back from the quantum realm for a moment to explore the mathematical framework of classical linear codes.
Our learning outcome for this lesson is to: Construct a classical linear code from its generator matrix, verify its parameters, and derive the parity-check matrix of its dual code.
This foray into classical coding theory is not a detour; it's a direct path to understanding the next major family of quantum codes, the Calderbank-Shor-Steane (CSS) codes, which are constructed directly from classical ones.
1. The Anatomy of a Classical Linear Code
At its heart, a classical binary code is simply a predefined subset of all possible n-bit strings. We send only strings from this subset (the codewords), and if the received string is not in the set, we know an error occurred.
A linear code has the convenient property that it forms a vector subspace over the field of two elements, (where addition is XOR). This means the sum (bitwise XOR) of any two codewords is also a valid codeword.
This subspace structure allows us to describe the entire code very compactly using linear algebra. We characterize a linear code C by three parameters, written as an [n, k, d] triplet:
n(block length): The total number of bits in a codeword.k(message length): The dimension of the code subspace. It means the code contains codewords, corresponding to the possiblek-bit messages we can encode.d(minimum distance): The minimum Hamming distance between any two distinct codewords. For a linear code, this is equivalent to the minimum Hamming weight (number of 1s) of any non-zero codeword. This parameter determines the code's error-detecting and error-correcting capability. A code with distancedcan detect up tod-1errors and correct up tofloor((d-1)/2)errors.
2. The Generator Matrix, G
A linear code C of dimension k can be fully specified by a basis of k linearly independent codewords. We arrange these basis vectors as the rows of a matrix called the generator matrix, G.
Any of the codewords can then be generated by taking a linear combination of these basis vectors. More simply, to encode a k-bit message vector m, we compute the matrix-vector product:
All arithmetic is performed modulo 2.
A particularly convenient form for G is the standard form, G = [I_k | A], where I_k is the k x k identity matrix and A is a k x (n-k) matrix. This form makes the encoding process transparent: the first k bits of the codeword are simply the message bits themselves, and the remaining n-k bits are parity checks computed from the message.
To make this concrete, let's examine the famous Hamming [7,4,3] code.
Notes on Classical & Quantum Error-Correcting Codes
These notes by physicist Pierre Ramond provide a concise, example-driven introduction to linear codes. We'll use the Hamming [7,4,3] code example to ground our discussion.
Please read the section '2 Canonical Description of Linear Codes', focusing on the definitions of the [n, k, d] parameters and the structure of the Generator Matrix G for the Hamming code. Note how a 4-bit message x is mapped to a 7-bit codeword w.
As shown in the notes, the generator for the Hamming [7,4,3] code is a matrix. It encodes message bits into an bit codeword. The minimum distance is d=3, meaning it can correct any single-bit error.
3. The Parity-Check Matrix, H
There's another, equally powerful way to define a linear code: as the set of all vectors that satisfy a certain set of linear equations. These equations are captured by the parity-check matrix, H.
A vector c is a codeword in C if and only if it satisfies:
This equation provides a simple test (a "parity check") for whether a given n-bit string is a valid codeword. The matrix H has dimensions .
The generator and parity-check matrices are intimately related. Since every codeword c is formed by c = mG, and every codeword must satisfy Hc^T = 0, it must be true that:
This implies the fundamental relationship:
(Or equivalently, G H^T = 0). This means that every row of H is orthogonal to every row of G. The row space of H is the orthogonal complement of the row space of G.
If G is in standard form G = [I_k | A], the corresponding parity-check matrix can be constructed directly as H = [A^T | I_{n-k}] (working in ).
Test your understanding!
For the Hamming [7,4,3] code, the generator matrix is given as G = [I_4 | A].
- Identify the matrix
AfromGin the notes you just read. - Use it to construct the parity-check matrix
H = [A^T | I_3]. - Verify that your constructed
Hmatches the one given in the notes.
Show answer
- From the resource LINK,
Gis: So,Ais the right-hand block: - We construct
H = [A^T | I_3]: - The parity-check matrix given in the notes is:
Wait, these are not identical. Why? Remember that the rows of
G(orH) form a basis for a vector space. Any set of basis vectors will define the same space. TheHmatrix in the notes is also a valid parity-check matrix. If we add the first row of our constructedHto its second row (mod 2), we get . This doesn't seem to lead to the other matrix easily. However, let's look closer at the resource text. The provided matrices areG = (I_4 | A)andH = (-A^T | I_3). The minus sign is irrelevant in . Let's check the matrices in the paper. The matrix A inGhas columns(1,0,1,1),(1,1,1,0),(1,1,0,1). The matrixHhas rows that are(1,0,1,1),(0,1,1,1),(1,1,0,1). The first and third rows ofA^Tmatch the first and third rows of theA^Tpart ofHin the paper. The second row does not. This is a subtle point: different basis choices can lead to matrices that look different but define the same code. The key relationshipGH^T=0holds for any valid pair. The constructionH = [A^T | I_{n-k}]is a standard convention that always works forG = [I_k | A]. The version in the notes appears to use a different basis choice.
4. The Dual Code, C^⊥
The orthogonality condition GH^T = 0 leads to a beautiful and powerful concept: the dual code.
Given a linear [n,k] code C, its dual code, denoted C^⊥, is the set of all n-bit vectors that are orthogonal to every codeword in C. Formally:
Here, the dot product is the standard vector dot product, calculated modulo 2.
From our discussion of G and H, the connection should be clear:
- The rows of
Hare, by definition, orthogonal to all codewords generated byG. - Therefore, the rows of
Hare themselves codewords of the dual codeC^⊥.
In fact, the (n-k) rows of H form a complete basis for C^⊥. This gives us the central result for dual codes:
The parity-check matrix of a code
Cis the generator matrix of its dual codeC^⊥.
It follows immediately that the generator matrix of C is the parity-check matrix of C^⊥.
The roles are perfectly swapped:
G_C = H_{C^⊥}H_C = G_{C^⊥}
This also tells us about the dimensions. If C is an [n, k] code, its generator matrix G_C has k rows. Its parity-check matrix H_C has n-k rows. Since H_C is the generator matrix for C^⊥, the dual code C^⊥ must have dimension n-k. So, if C is an [n, k]-code, C^⊥ is an [n, n-k]-code.
The following resource provides the formal definitions and proofs for these concepts.
Chapter 7 The Dual Code and the Parity-Check Matrix
This textbook chapter on coding theory provides a more rigorous, proof-based treatment of the dual code and its relationship with the generator and parity-check matrices.
Please read from the beginning of the chapter up to (and including) Theorem 7.11. Pay attention to: (1) The formal definition of the dual code C^⊥ (Definition 7.3). (2) Theorem 7.7, which proves that an [n,k] code has an [n, n-k] dual and shows the construction H = [-A^T | I_{n-k}]. (3) Theorem 7.11, which states that (C^⊥)^⊥ = C, completing the duality.
5. Practical Construction and Verification
Let's consolidate these ideas with a concrete exercise. Consider a linear code C defined by the following generator matrix:
Your task is to analyze this code and its dual.
- Verify the parameters
[n, k, d]forC:- What are
nandk? - List all codewords by computing
mGfor all possible 2-bit messagesm. - Find the minimum distance
dby finding the minimum weight of the non-zero codewords.
- What are
- Derive the parity-check matrix
HforC:- The given
Gis in standard form[I_k | A]. IdentifyA. - Construct
Husing the formulaH = [A^T | I_{n-k}].
- The given
- Derive the generator matrix for the dual code
C^⊥:- What is the relationship between
H_CandG_{C^⊥}?
- What is the relationship between
- Derive the parity-check matrix for the dual code
C^⊥:- What is the relationship between
G_CandH_{C^⊥}?
- What is the relationship between
Show solution walkthrough
-
Parameters for
C:Gis a matrix, sok=2andn=5.- The four messages are
00, 01, 10, 11. The codewords are:00 * G = [0,0,0,0,0]01 * G = [0,1,0,1,1](weight 3)10 * G = [1,0,1,1,0](weight 3)11 * G = 10*G + 01*G = [1,1,1,0,1](weight 4)
- The minimum weight of the non-zero codewords is 3. So,
d=3. - The code
Cis a [5, 2, 3] code.
-
Parity-check matrix
HforC:G = [I_2 | A], whereA = \begin{pmatrix} 1 & 1 & 0 \\ 0 & 1 & 1 \end{pmatrix}.n-k = 3. We constructH = [A^T | I_3]:
1 & 0 & 1 & 0 & 0 \\ 1 & 1 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 & 1 \end{pmatrix} $$- This is the parity-check matrix for
C. You can verify thatGH^T=0.
-
Generator matrix for
C^⊥:- The generator matrix for the dual code,
G_{C^⊥}, is simply the parity-check matrix of the original code,H_C. - So,
G_{C^⊥} = H = \begin{pmatrix} 1 & 0 & 1 & 0 & 0 \\ 1 & 1 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 & 1 \end{pmatrix}. C^⊥is an[n, n-k] = [5, 3]code.
- The generator matrix for the dual code,
-
Parity-check matrix for
C^⊥:- Following the duality, the parity-check matrix for the dual code,
H_{C^⊥}, is the generator matrix of the original code,G_C. - So,
H_{C^⊥} = G = \begin{pmatrix} 1 & 0 & 1 & 1 & 0 \\ 0 & 1 & 0 & 1 & 1 \end{pmatrix}.
- Following the duality, the parity-check matrix for the dual code,
Conclusion
In this lesson, we established the fundamental algebraic framework for classical linear error-correcting codes. You are now equipped to describe, analyze, and manipulate these codes using their generator and parity-check matrices.
Key Takeaways:
- A linear code is a vector subspace of , characterized by the parameters
[n, k, d]. - A
k x ngenerator matrixGdefines the code by providing a basis; codewords are generated viac = mG. - An
(n-k) x nparity-check matrixHdefines the code as the null space ofH; codewords are checked viaHc^T = 0. - These matrices are related by the orthogonality condition
GH^T = 0. - The dual code
C^⊥consists of all vectors orthogonal to the codeC. IfCis an[n, k]code,C^⊥is an[n, n-k]code. - The generator and parity-check matrices of a code and its dual are swapped:
G_{C^⊥} = H_CandH_{C^⊥} = G_C.
Preview of the next lesson:
Now that we have a firm grip on classical codes and their duals, we are ready to build a powerful class of quantum codes. In the next lesson, we will see how to construct a Calderbank-Shor-Steane (CSS) code from a pair of classical linear codes, C_1 and C_2. The critical requirement for this construction is a relationship between C_1 and the dual of C_2. Your understanding of dual codes from today's lesson will be essential.