Abstract¶ The mathematical formulation of a broad class of classical error correcting codes.
Keywords: bits bit-flips repetition code ¶ In this section, we will give a mathematical description of a broad class of binary classical error correcting codes called linear codes, which includes the repetition code and parity check codes introduced in the previous section.
Three methods of representing a classical linear code will be given. For each, the parity error detection and correction examples will be detailed.
Finally, in this section we will denoted an n n n bit-strings as an n n n dimensional vectors in the vector space F 2 n \mathbb{F}^n_2 F 2 n , i.e,
a 1 a 2 … a n → a = [ a 1 a 2 ⋮ a n ] w h e r e a i ∈ F 2 1 . a_1a_2 \ldots a_n \rightarrow \bm{a} = \begin{bmatrix}
a_{1} \\
a_{2} \\
\vdots \\
a_{n}
\end{bmatrix} ~ ~ ~{\rm where} ~ ~a_i \in \mathbb{F}^1_2. a 1 a 2 … a n → a = ⎣ ⎡ a 1 a 2 ⋮ a n ⎦ ⎤ where a i ∈ F 2 1 . Definition ¶ A classical linear code is a subspace C ⊆ F 2 n \mathcal{C} \subseteq \mathbb{F}^n_2 C ⊆ F 2 n . All of elements of C \mathcal{C} C are the code words of the error correction code.
As C \mathcal{C} C is a subspace, it holds that for any a , b ∈ C \bm{a}, \bm{b} \in \mathcal{C} a , b ∈ C that
a + b ∈ C , \bm{a} + \bm{b} \in \mathcal{C}, a + b ∈ C , where all addition is modulo 2. Hence, the sum of any two code words is another code word.
If k k k logical bits are encoded, then d i m ( C ) = k {\rm dim}(\mathcal{C})=k dim ( C ) = k .
Code Representation ¶ List Code Words ¶ The most obvious — but expensive — method for representing a code is to list all of its code words.
Examples
Logical bit-string → \rightarrow → Code Word:
000 → [ 0000 ] t 001 → [ 0011 ] t 010 → [ 0101 ] t 011 → [ 0110 ] t 100 → [ 1001 ] t 101 → [ 1010 ] t 110 → [ 1100 ] t 111 → [ 1111 ] t \begin{align*}
&000 \rightarrow [0000]^t \\
&001 \rightarrow [0011]^t \\
&010 \rightarrow [0101]^t \\
&011 \rightarrow [0110]^t \\
&100 \rightarrow [1001]^t \\
&101 \rightarrow [1010]^t \\
&110 \rightarrow [1100]^t \\
&111 \rightarrow [1111]^t \\
\end{align*} 000 → [ 0000 ] t 001 → [ 0011 ] t 010 → [ 0101 ] t 011 → [ 0110 ] t 100 → [ 1001 ] t 101 → [ 1010 ] t 110 → [ 1100 ] t 111 → [ 1111 ] t Logical bit-string → \rightarrow → Code Word:
000 → [ 000 , 000 ] t 001 → [ 001 , 011 ] t 010 → [ 010 , 101 ] t 011 → [ 011 , 110 ] t 100 → [ 100 , 110 ] t 101 → [ 101 , 101 ] t 110 → [ 110 , 011 ] t 111 → [ 111 , 000 ] t \begin{align*}
&000 \rightarrow [000,000]^t \\
&001 \rightarrow [001,011]^t \\
&010 \rightarrow [010,101]^t \\
&011 \rightarrow [011,110]^t \\
&100 \rightarrow [100,110]^t \\
&101 \rightarrow [101,101]^t \\
&110 \rightarrow [110,011]^t \\
&111 \rightarrow [111,000]^t \\
\end{align*} 000 → [ 000 , 000 ] t 001 → [ 001 , 011 ] t 010 → [ 010 , 101 ] t 011 → [ 011 , 110 ] t 100 → [ 100 , 110 ] t 101 → [ 101 , 101 ] t 110 → [ 110 , 011 ] t 111 → [ 111 , 000 ] t Generators ¶ A set of vectors u 1 , u 2 , … , u m ∈ C \bm{u}_1, \bm{u}_2, \ldots, \bm{u}_m \in \mathcal{C} u 1 , u 2 , … , u m ∈ C is said generate the code C \mathcal{C} C if
C = { α 1 u 1 + α 2 u 2 + … + α m u m : α i ∈ F 2 1 ∀ i } \mathcal{C} = \big\{ \alpha_1 \bm{u}_1 + \alpha_2 \bm{u}_2 + \ldots + \alpha_m \bm{u}_m : \alpha_i \in \mathbb{F}^1_2~\forall i \big\} C = { α 1 u 1 + α 2 u 2 + … + α m u m : α i ∈ F 2 1 ∀ i } If all u 1 , u 2 , … , u m ∈ C \bm{u}_1, \bm{u}_2, \ldots, \bm{u}_m \in \mathcal{C} u 1 , u 2 , … , u m ∈ C are linearly independent then the set is called a minimal generating set.
From this definition, it can be see that a minimal generating set of a code is a basis for the subspace C \mathcal{C} C , meaning m = k m=k m = k .
Consider now a code encoding k k k logical bits into n n n physical bits, such that p = n − k p=n-k p = n − k parity bits are used for the error correction. Then, from a minimal generating set of a code (they are not unique), a generating matrix G G G can be created as follows
G = [ I k × k A p × k ] , G = \left[
\begin{array}{cc}
\mathbb{I}_{k \times k} \\
\hline
A_{p \times k}
\end{array}
\right], G = [ I k × k A p × k ] , such that I k × k \mathbb{I}_{k \times k} I k × k is the k × k k \times k k × k identity matrix and A p × k A_{p \times k} A p × k is an p × k p \times k p × k matrix that encodes which parity checks occur.
If x ∈ F 2 k \bm{x} \in \mathbb{F}^k_2 x ∈ F 2 k is an unencoded bit-string, then its encoded bit-string y ∈ C ⊆ F 2 n \bm{y} \in \mathcal{C} \subseteq \mathbb{F}^n_2 y ∈ C ⊆ F 2 n , which includes its parity bits, is given by
y = G x , \bm{y} = G \bm{x}, y = G x , hence the term generating matrix for G G G .
Examples
A minimum generating set for this code is given by the code-words
001 → [ 0011 ] t 010 → [ 0101 ] t 100 → [ 1001 ] t \begin{align*}
&001 \rightarrow [0011]^t \\
&010 \rightarrow [0101]^t \\
&100 \rightarrow [1001]^t \\
\end{align*} 001 → [ 0011 ] t 010 → [ 0101 ] t 100 → [ 1001 ] t It can easily be see that for any arbitrary unencoded bit-string a 1 a 2 a 3 a_1a_2a_3 a 1 a 2 a 3 it follows that
[ a 1 a 2 a 3 p ( a ) ] = a 1 [ 1 0 0 1 ] + a 2 [ 0 1 0 1 ] + a 3 [ 0 0 1 1 ] \begin{bmatrix}
a_{1} \\
a_{2} \\
a_3 \\
p(\bm{a})
\end{bmatrix} = a_1 \begin{bmatrix}
1 \\
0 \\
0 \\
1
\end{bmatrix} + a_2 \begin{bmatrix}
0 \\
1 \\
0 \\
1
\end{bmatrix} + a_3 \begin{bmatrix}
0 \\
0 \\
1 \\
1
\end{bmatrix} ⎣ ⎡ a 1 a 2 a 3 p ( a ) ⎦ ⎤ = a 1 ⎣ ⎡ 1 0 0 1 ⎦ ⎤ + a 2 ⎣ ⎡ 0 1 0 1 ⎦ ⎤ + a 3 ⎣ ⎡ 0 0 1 1 ⎦ ⎤ The generating matrix is then
G = [ 1 0 0 0 1 0 0 0 1 1 1 1 ] . G = \left[
\begin{array}{ccc}
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & 1 \\
\hline
1 & 1 & 1
\end{array}
\right]. G = ⎣ ⎡ 1 0 0 1 0 1 0 1 0 0 1 1 ⎦ ⎤ . A minimum generating set for this code is given by the code-words
001 → [ 001 , 011 ] t 010 → [ 010 , 101 ] t 100 → [ 100 , 110 ] t \begin{align*}
&001 \rightarrow [001,011]^t \\
&010 \rightarrow [010,101]^t \\
&100 \rightarrow [100,110]^t \\
\end{align*} 001 → [ 001 , 011 ] t 010 → [ 010 , 101 ] t 100 → [ 100 , 110 ] t such that for any arbitrary unencoded bit-string a 1 a 2 a 3 a_1a_2a_3 a 1 a 2 a 3 it follows that
[ a 1 a 2 a 3 a 1 ⊕ a 2 a 1 ⊕ a 3 a 2 ⊕ a 3 ] = a 1 [ 1 0 0 1 1 0 ] + a 2 [ 0 1 0 1 0 1 ] + a 3 [ 0 0 1 0 1 1 ] \begin{bmatrix}
a_{1} \\
a_{2} \\
a_3 \\
a_1 \oplus a_2 \\
a_1 \oplus a_3 \\
a_2 \oplus a_3
\end{bmatrix} = a_1 \begin{bmatrix}
1 \\
0 \\
0 \\
1 \\
1 \\
0
\end{bmatrix} + a_2 \begin{bmatrix}
0 \\
1 \\
0 \\
1 \\
0 \\
1
\end{bmatrix} + a_3 \begin{bmatrix}
0 \\
0 \\
1 \\
0 \\
1 \\
1
\end{bmatrix} ⎣ ⎡ a 1 a 2 a 3 a 1 ⊕ a 2 a 1 ⊕ a 3 a 2 ⊕ a 3 ⎦ ⎤ = a 1 ⎣ ⎡ 1 0 0 1 1 0 ⎦ ⎤ + a 2 ⎣ ⎡ 0 1 0 1 0 1 ⎦ ⎤ + a 3 ⎣ ⎡ 0 0 1 0 1 1 ⎦ ⎤ The generating matrix is then
G = [ 1 0 0 0 1 0 0 0 1 1 1 0 1 0 1 0 1 1 ] . G = \left[
\begin{array}{ccc}
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & 1 \\
\hline
1 & 1 & 0 \\
1 & 0 & 1 \\
0 & 1 & 1
\end{array}
\right]. G = ⎣ ⎡ 1 0 0 1 1 0 0 1 0 1 0 1 0 0 1 0 1 1 ⎦ ⎤ . Parity Checks ¶ Let v 1 , v 2 , … , v m ∈ F 2 n \bm{v}_1, \bm{v}_2, \ldots, \bm{v}_m \in \mathbb{F}^n_2 v 1 , v 2 , … , v m ∈ F 2 n represented a set of parity checks. A codespace C \mathcal{C} C can then be defined as
C = { a ∈ F 2 n : a ⋅ v i = 0 ∀ i } . \mathcal{C} = \big\{ \bm{a} \in \mathbb{F}^n_2 : \bm{a} \cdot \bm{v}_i = 0 ~\forall~i \big\}. C = { a ∈ F 2 n : a ⋅ v i = 0 ∀ i } . In words, the code space is defined to be the set of vectors in F 2 n \mathbb{F}^n_2 F 2 n whose dot product with the set of vector v 1 , v 2 , … , v m ∈ F 2 n \bm{v}_1, \bm{v}_2, \ldots, \bm{v}_m \in \mathbb{F}^n_2 v 1 , v 2 , … , v m ∈ F 2 n is zero.
Consider a 3 bit string encoded as 4 physical bits,
a = [ a 1 a 2 a 3 a 1 ⊕ a 3 ] , \bm{a} = \begin{bmatrix}
a_1 \\
a_2 \\
a_3 \\
a_1 \oplus a_3
\end{bmatrix}, a = ⎣ ⎡ a 1 a 2 a 3 a 1 ⊕ a 3 ⎦ ⎤ , where the 4th physical bit stores the parity check bit a 1 ⊕ a 3 a_1 \oplus a_3 a 1 ⊕ a 3 .
If this is valid code word, and one wants to check to see if it remains a valid codeword, this can be done through the vector
v = [ 1 0 1 1 ] , \bm{v} = \begin{bmatrix}
1 \\
0 \\
1 \\
1
\end{bmatrix}, v = ⎣ ⎡ 1 0 1 1 ⎦ ⎤ , as
a ⋅ v = [ a 1 a 2 a 3 a 1 ⊕ a 3 ] ⋅ [ 1 0 1 1 ] = a 1 ⊕ a 3 ⊕ ( a 1 ⊕ a 3 ) . \bm{a} \cdot \bm{v} = \begin{bmatrix}
a_1 \\
a_2 \\
a_3 \\
a_1 \oplus a_3
\end{bmatrix} \cdot \begin{bmatrix}
1 \\
0 \\
1 \\
1
\end{bmatrix} = a_1 \oplus a_3 \oplus (a_1 \oplus a_3). a ⋅ v = ⎣ ⎡ a 1 a 2 a 3 a 1 ⊕ a 3 ⎦ ⎤ ⋅ ⎣ ⎡ 1 0 1 1 ⎦ ⎤ = a 1 ⊕ a 3 ⊕ ( a 1 ⊕ a 3 ) . Hence, if there has been a bit-flip on either the 1st, 3rd or 4th bit (the parity bit), then a ⋅ v ≠ 0 \bm{a} \cdot \bm{v} \neq 0 a ⋅ v = 0 .
As above, consider a code encoding k k k logical bits into n n n physical bits, such that p = n − k p=n-k p = n − k parity bits are used for the error correction. Then, the parity checks can be formulated in terms of a parity matrix H H H as
H = [ A p × k ∣ I p × p ] , H = \left[
\begin{array}{c}
A_{p \times k} ~ \vert ~ \mathbb{I}_{p \times p} \\
\end{array}
\right], H = [ A p × k ∣ I p × p ] , such that I p × p \mathbb{I}_{p \times p} I p × p is the k × k k \times k k × k identity matrix and A p × k A_{p \times k} A p × k is an p × k p \times k p × k matrix that encodes which parity checks occur. Note, A p × k A_{p \times k} A p × k is the same as in the generating matrix .
If y ∈ F 2 n \bm{y} \in \mathbb{F}^n_2 y ∈ F 2 n is an encoded bit-string, then its a code word if and only if
The codespace can therefore be defined more formally as the kernel of the parity check matrix.
Examples
The parity matrix of this code is
H = [ 1 1 1 ∣ 1 ] . H = \left[
\begin{array}{cccc}
1 & 1 & 1 ~\vert ~ 1
\end{array}
\right]. H = [ 1 1 1 ∣ 1 ] . Now, consider an arbitrary code work
a = [ a 1 a 2 a 3 a 1 ⊕ a 2 ⊕ a 3 ] . \bm{a} = \begin{bmatrix}
a_1 \\
a_2 \\
a_3 \\
a_1 \oplus a_2 \oplus a_3
\end{bmatrix}. a = ⎣ ⎡ a 1 a 2 a 3 a 1 ⊕ a 2 ⊕ a 3 ⎦ ⎤ . It can then be seen that
H a = [ 1 1 1 ∣ 1 ] [ a 1 a 2 a 3 a 1 ⊕ a 2 ⊕ a 3 ] = a 1 ⊕ a 2 ⊕ a 3 ⊕ ( a 1 ⊕ a 2 ⊕ a 3 ) = 0. \begin{align*}
H \bm{a} &= \left[
\begin{array}{cccc}
1 & 1 & 1 ~\vert ~ 1
\end{array}
\right] \begin{bmatrix}
a_1 \\
a_2 \\
a_3 \\
a_1 \oplus a_2 \oplus a_3
\end{bmatrix} \\
&= a_1 \oplus a_2 \oplus a_3 \oplus (a_1 \oplus a_2 \oplus a_3) \\
&= 0.
\end{align*} H a = [ 1 1 1 ∣ 1 ] ⎣ ⎡ a 1 a 2 a 3 a 1 ⊕ a 2 ⊕ a 3 ⎦ ⎤ = a 1 ⊕ a 2 ⊕ a 3 ⊕ ( a 1 ⊕ a 2 ⊕ a 3 ) = 0. The parity matrix of this code is
H = [ 1 1 0 ∣ 1 0 0 1 0 1 ∣ 0 1 0 0 1 1 ∣ 0 0 1 ] . H = \left[
\begin{array}{cccccc}
1 & 1 & 0 ~ \vert ~ 1 & 0 & 0 \\
1 & 0 & 1 ~ \vert ~ 0 & 1 & 0 \\
0 & 1 & 1 ~ \vert ~ 0 & 0 & 1
\end{array}
\right]. H = ⎣ ⎡ 1 1 0 1 0 1 0 ∣ 1 1 ∣ 0 1 ∣ 0 0 1 0 0 0 1 ⎦ ⎤ . Now, consider an arbitrary code work
a = [ a 1 a 2 a 3 a 1 ⊕ a 2 a 1 ⊕ a 3 a 2 ⊕ a 3 ] . \bm{a} = \begin{bmatrix}
a_1 \\
a_2 \\
a_3 \\
a_1 \oplus a_2 \\
a_1 \oplus a_3 \\
a_2 \oplus a_3 \\
\end{bmatrix}. a = ⎣ ⎡ a 1 a 2 a 3 a 1 ⊕ a 2 a 1 ⊕ a 3 a 2 ⊕ a 3 ⎦ ⎤ . It can then be seen that
H a = [ a 1 ⊕ a 2 ⊕ ( a 1 ⊕ a 2 ) a 1 ⊕ a 3 ⊕ ( a 1 ⊕ a 3 ) a 2 ⊕ a 3 ⊕ ( a 2 ⊕ a 3 ) ] = 0 . \begin{align*}
H \bm{a} &= \begin{bmatrix}
a_1 \oplus a_2 \oplus (a_1 \oplus a_2) \\
a_1 \oplus a_3 \oplus (a_1 \oplus a_3) \\
a_2 \oplus a_3 \oplus (a_2 \oplus a_3) \\
\end{bmatrix} \\
&= \bm{0}.
\end{align*} H a = ⎣ ⎡ a 1 ⊕ a 2 ⊕ ( a 1 ⊕ a 2 ) a 1 ⊕ a 3 ⊕ ( a 1 ⊕ a 3 ) a 2 ⊕ a 3 ⊕ ( a 2 ⊕ a 3 ) ⎦ ⎤ = 0 . Error Syndromes ¶ Given an unknown encoded bit-string y ′ ∈ F 2 n \bm{y}' \in \mathbb{F}^n_2 y ′ ∈ F 2 n , the syndrome of the code s ∈ F 2 p \bm{s} \in \mathbb{F}^p_2 s ∈ F 2 p is given by
s = H y ′ . \bm{s} = H \bm{y}'. s = H y ′ . The aim is then for the syndrome s ∈ F 2 p \bm{s} \in \mathbb{F}^p_2 s ∈ F 2 p to determine where an error occurred.
Examples
The parity matrix of this code is
H = [ 1 1 0 ∣ 1 0 0 1 0 1 ∣ 0 1 0 0 1 1 ∣ 0 0 1 ] . H = \left[
\begin{array}{cccccc}
1 & 1 & 0 ~ \vert ~ 1 & 0 & 0 \\
1 & 0 & 1 ~ \vert ~ 0 & 1 & 0 \\
0 & 1 & 1 ~ \vert ~ 0 & 0 & 1
\end{array}
\right]. H = ⎣ ⎡ 1 1 0 1 0 1 0 ∣ 1 1 ∣ 0 1 ∣ 0 0 1 0 0 0 1 ⎦ ⎤ . Now, consider an arbitrary code word y \bm{y} y where an error occurs on the 2 logical bit
y = [ y 1 y 2 y 3 y 1 ⊕ y 2 y 1 ⊕ y 3 y 2 ⊕ y 3 ] → y ′ = [ y 1 y 2 ⊕ 1 y 3 y 1 ⊕ y 2 y 1 ⊕ y 3 y 2 ⊕ y 3 ] . \bm{y} = \begin{bmatrix}
y_1 \\
y_2 \\
y_3 \\
y_1 \oplus y_2 \\
y_1 \oplus y_3 \\
y_2 \oplus y_3 \\
\end{bmatrix}
\rightarrow \bm{y}' = \begin{bmatrix}
y_1 \\
y_2 \oplus 1 \\
y_3 \\
y_1 \oplus y_2 \\
y_1 \oplus y_3 \\
y_2 \oplus y_3 \\
\end{bmatrix}. y = ⎣ ⎡ y 1 y 2 y 3 y 1 ⊕ y 2 y 1 ⊕ y 3 y 2 ⊕ y 3 ⎦ ⎤ → y ′ = ⎣ ⎡ y 1 y 2 ⊕ 1 y 3 y 1 ⊕ y 2 y 1 ⊕ y 3 y 2 ⊕ y 3 ⎦ ⎤ . It can then be seen that the syndrome will be
H y ′ = [ y 1 ⊕ ( y 2 ⊕ 1 ) ⊕ ( y 1 ⊕ y 2 ) y 1 ⊕ y 3 ⊕ ( y 1 ⊕ y 3 ) ( y 2 ⊕ 1 ) ⊕ y 3 ⊕ ( y 2 ⊕ y 3 ) ] = [ 1 0 1 ] , \begin{align*}
H \bm{y}' &= \begin{bmatrix}
y_1 \oplus (y_2 \oplus 1) \oplus (y_1 \oplus y_2) \\
y_1 \oplus y_3 \oplus (y_1 \oplus y_3) \\
(y_2 \oplus 1) \oplus y_3 \oplus (y_2 \oplus y_3) \\
\end{bmatrix} \\
&= \begin{bmatrix}
1 \\
0 \\
1
\end{bmatrix},
\end{align*} H y ′ = ⎣ ⎡ y 1 ⊕ ( y 2 ⊕ 1 ) ⊕ ( y 1 ⊕ y 2 ) y 1 ⊕ y 3 ⊕ ( y 1 ⊕ y 3 ) ( y 2 ⊕ 1 ) ⊕ y 3 ⊕ ( y 2 ⊕ y 3 ) ⎦ ⎤ = ⎣ ⎡ 1 0 1 ⎦ ⎤ , as expected from the error syndromes of the code detailed here .