Linear code

From HandWiki
Revision as of 14:26, 6 February 2024 by Wincert (talk | contribs) (linkage)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Short description: Class of error-correcting code

In coding theory, a linear code is an error-correcting code for which any linear combination of codewords is also a codeword. Linear codes are traditionally partitioned into block codes and convolutional codes, although turbo codes can be seen as a hybrid of these two types.[1] Linear codes allow for more efficient encoding and decoding algorithms than other codes (cf. syndrome decoding).[citation needed]

Linear codes are used in forward error correction and are applied in methods for transmitting symbols (e.g., bits) on a communications channel so that, if errors occur in the communication, some errors can be corrected or detected by the recipient of a message block. The codewords in a linear block code are blocks of symbols that are encoded using more symbols than the original value to be sent.[2] A linear code of length n transmits blocks containing n symbols. For example, the [7,4,3] Hamming code is a linear binary code which represents 4-bit messages using 7-bit codewords. Two distinct codewords differ in at least three bits. As a consequence, up to two errors per codeword can be detected while a single error can be corrected.[3] This code contains 24=16 codewords.

Definition and parameters

A linear code of length n and dimension k is a linear subspace C with dimension k of the vector space [math]\displaystyle{ \mathbb{F}_q^n }[/math] where [math]\displaystyle{ \mathbb{F}_q }[/math] is the finite field with q elements. Such a code is called a q-ary code. If q = 2 or q = 3, the code is described as a binary code, or a ternary code respectively. The vectors in C are called codewords. The size of a code is the number of codewords and equals qk.

The weight of a codeword is the number of its elements that are nonzero and the distance between two codewords is the Hamming distance between them, that is, the number of elements in which they differ. The distance d of the linear code is the minimum weight of its nonzero codewords, or equivalently, the minimum distance between distinct codewords. A linear code of length n, dimension k, and distance d is called an [n,k,d] code (or, more precisely, [math]\displaystyle{ [n,k,d]_q }[/math] code).

We want to give [math]\displaystyle{ \mathbb{F}_q^n }[/math] the standard basis because each coordinate represents a "bit" that is transmitted across a "noisy channel" with some small probability of transmission error (a binary symmetric channel). If some other basis is used then this model cannot be used and the Hamming metric does not measure the number of errors in transmission, as we want it to.

Generator and check matrices

As a linear subspace of [math]\displaystyle{ \mathbb{F}_q^n }[/math], the entire code C (which may be very large) may be represented as the span of a set of [math]\displaystyle{ k }[/math] codewords (known as a basis in linear algebra). These basis codewords are often collated in the rows of a matrix G known as a generating matrix for the code C. When G has the block matrix form [math]\displaystyle{ \boldsymbol{G} = [I_k | P] }[/math], where [math]\displaystyle{ I_k }[/math] denotes the [math]\displaystyle{ k \times k }[/math] identity matrix and P is some [math]\displaystyle{ k \times (n-k) }[/math] matrix, then we say G is in standard form.

A matrix H representing a linear function [math]\displaystyle{ \phi : \mathbb{F}_q^n\to \mathbb{F}_q^{n-k} }[/math] whose kernel is C is called a check matrix of C (or sometimes a parity check matrix). Equivalently, H is a matrix whose null space is C. If C is a code with a generating matrix G in standard form, [math]\displaystyle{ \boldsymbol{G} = [I_k | P] }[/math], then [math]\displaystyle{ \boldsymbol{H} = [-P^{T} | I_{n-k} ] }[/math] is a check matrix for C. The code generated by H is called the dual code of C. It can be verified that G is a [math]\displaystyle{ k \times n }[/math] matrix, while H is a [math]\displaystyle{ (n-k) \times n }[/math] matrix.

Linearity guarantees that the minimum Hamming distance d between a codeword c0 and any of the other codewords c ≠ c0 is independent of c0. This follows from the property that the difference c − c0 of two codewords in C is also a codeword (i.e., an element of the subspace C), and the property that d(c, c0) = d(c − c0, 0). These properties imply that

[math]\displaystyle{ \min_{c \in C,\ c \neq c_0}d(c,c_0)=\min_{c \in C,\ c \neq c_0}d(c-c_0, 0)=\min_{c \in C,\ c \neq 0}d(c, 0)=d. }[/math]

In other words, in order to find out the minimum distance between the codewords of a linear code, one would only need to look at the non-zero codewords. The non-zero codeword with the smallest weight has then the minimum distance to the zero codeword, and hence determines the minimum distance of the code.

The distance d of a linear code C also equals the minimum number of linearly dependent columns of the check matrix H.

Proof: Because [math]\displaystyle{ \boldsymbol{H} \cdot \boldsymbol{c}^T = \boldsymbol{0} }[/math], which is equivalent to [math]\displaystyle{ \sum_{i=1}^n (c_i \cdot \boldsymbol{H_i}) = \boldsymbol{0} }[/math], where [math]\displaystyle{ \boldsymbol{H_i} }[/math] is the [math]\displaystyle{ i^{th} }[/math] column of [math]\displaystyle{ \boldsymbol{H} }[/math]. Remove those items with [math]\displaystyle{ c_i=0 }[/math], those [math]\displaystyle{ \boldsymbol{H_i} }[/math] with [math]\displaystyle{ c_i \neq 0 }[/math] are linearly dependent. Therefore, [math]\displaystyle{ d }[/math] is at least the minimum number of linearly dependent columns. On another hand, consider the minimum set of linearly dependent columns [math]\displaystyle{ \{ \boldsymbol{H_j} | j \in S \} }[/math] where [math]\displaystyle{ S }[/math] is the column index set. [math]\displaystyle{ \sum_{i=1}^n (c_i \cdot \boldsymbol{H_i}) = \sum_{j \in S} (c_j \cdot \boldsymbol{H_j}) + \sum_{j \notin S} (c_j \cdot \boldsymbol{H_j}) = \boldsymbol{0} }[/math]. Now consider the vector [math]\displaystyle{ \boldsymbol{c'} }[/math] such that [math]\displaystyle{ c_j'=0 }[/math] if [math]\displaystyle{ j \notin S }[/math]. Note [math]\displaystyle{ \boldsymbol{c'} \in C }[/math] because [math]\displaystyle{ \boldsymbol{H} \cdot \boldsymbol{c'}^T = \boldsymbol{0} }[/math] . Therefore, we have [math]\displaystyle{ d \le wt(\boldsymbol{c'}) }[/math], which is the minimum number of linearly dependent columns in [math]\displaystyle{ \boldsymbol{H} }[/math]. The claimed property is therefore proven.

Example: Hamming codes

Main page: Hamming code

As the first class of linear codes developed for error correction purpose, Hamming codes have been widely used in digital communication systems. For any positive integer [math]\displaystyle{ r \ge 2 }[/math], there exists a [math]\displaystyle{ [2^r-1, 2^r-r-1,3]_2 }[/math] Hamming code. Since [math]\displaystyle{ d=3 }[/math], this Hamming code can correct a 1-bit error.

Example : The linear block code with the following generator matrix and parity check matrix is a [math]\displaystyle{ [7,4,3]_2 }[/math] Hamming code.

[math]\displaystyle{ \boldsymbol{G}=\begin{pmatrix} 1\ 0\ 0\ 0\ 1\ 1\ 0 \\ 0\ 1\ 0\ 0\ 0\ 1\ 1 \\ 0\ 0\ 1\ 0\ 1\ 1\ 1 \\ 0\ 0\ 0\ 1\ 1\ 0\ 1 \end{pmatrix} , }[/math] [math]\displaystyle{ \boldsymbol{H}=\begin{pmatrix} 1\ 0\ 1\ 1\ 1\ 0\ 0 \\ 1\ 1\ 1\ 0\ 0\ 1\ 0 \\ 0\ 1\ 1\ 1\ 0\ 0\ 1 \end{pmatrix} }[/math]

Example: Hadamard codes

Main page: Hadamard code

Hadamard code is a [math]\displaystyle{ [2^r, r, 2^{r-1}]_2 }[/math] linear code and is capable of correcting many errors. Hadamard code could be constructed column by column : the [math]\displaystyle{ i^{th} }[/math] column is the bits of the binary representation of integer [math]\displaystyle{ i }[/math], as shown in the following example. Hadamard code has minimum distance [math]\displaystyle{ 2^{r-1} }[/math] and therefore can correct [math]\displaystyle{ 2^{r-2}-1 }[/math] errors.

Example: The linear block code with the following generator matrix is a [math]\displaystyle{ [8,3,4]_2 }[/math] Hadamard code: [math]\displaystyle{ \boldsymbol{G}_{Had}=\begin{pmatrix} 0\ 0\ 0\ 0\ 1\ 1\ 1\ 1\\ 0\ 0\ 1\ 1\ 0\ 0\ 1\ 1\\ 0\ 1\ 0\ 1\ 0\ 1\ 0\ 1\end{pmatrix} }[/math].

Hadamard code is a special case of Reed–Muller code. If we take the first column (the all-zero column) out from [math]\displaystyle{ \boldsymbol{G}_{Had} }[/math], we get [math]\displaystyle{ [7,3,4]_2 }[/math] simplex code, which is the dual code of Hamming code.

Nearest neighbor algorithm

The parameter d is closely related to the error correcting ability of the code. The following construction/algorithm illustrates this (called the nearest neighbor decoding algorithm):

Input: A received vector v in [math]\displaystyle{ \mathbb{F}_q^n }[/math] .

Output: A codeword [math]\displaystyle{ w }[/math] in [math]\displaystyle{ C }[/math] closest to [math]\displaystyle{ v }[/math], if any.

  • Starting with [math]\displaystyle{ t=0 }[/math], repeat the following two steps.
  • Enumerate the elements of the ball of (Hamming) radius [math]\displaystyle{ t }[/math] around the received word [math]\displaystyle{ v }[/math], denoted [math]\displaystyle{ B_t(v) }[/math].
    • For each [math]\displaystyle{ w }[/math] in [math]\displaystyle{ B_t(v) }[/math], check if [math]\displaystyle{ w }[/math] in [math]\displaystyle{ C }[/math]. If so, return [math]\displaystyle{ w }[/math] as the solution.
  • Increment [math]\displaystyle{ t }[/math]. Fail only when [math]\displaystyle{ t \gt (d - 1)/2 }[/math] so enumeration is complete and no solution has been found.

We say that a linear [math]\displaystyle{ C }[/math] is [math]\displaystyle{ t }[/math]-error correcting if there is at most one codeword in [math]\displaystyle{ B_t(v) }[/math], for each [math]\displaystyle{ v }[/math] in [math]\displaystyle{ \mathbb{F}_q^n }[/math].

Popular notation

Codes in general are often denoted by the letter C, and a code of length n and of rank k (i.e., having n code words in its basis and k rows in its generating matrix) is generally referred to as an (nk) code. Linear block codes are frequently denoted as [nkd] codes, where d refers to the code's minimum Hamming distance between any two code words.

(The [nkd] notation should not be confused with the (nMd) notation used to denote a non-linear code of length n, size M (i.e., having M code words), and minimum Hamming distance d.)

Singleton bound

Lemma (Singleton bound): Every linear [n,k,d] code C satisfies [math]\displaystyle{ k+d \leq n+1 }[/math].

A code C whose parameters satisfy k+d=n+1 is called maximum distance separable or MDS. Such codes, when they exist, are in some sense best possible.

If C1 and C2 are two codes of length n and if there is a permutation p in the symmetric group Sn for which (c1,...,cn) in C1 if and only if (cp(1),...,cp(n)) in C2, then we say C1 and C2 are permutation equivalent. In more generality, if there is an [math]\displaystyle{ n\times n }[/math] monomial matrix [math]\displaystyle{ M\colon \mathbb{F}_q^n \to \mathbb{F}_q^n }[/math] which sends C1 isomorphically to C2 then we say C1 and C2 are equivalent.

Lemma: Any linear code is permutation equivalent to a code which is in standard form.

Bonisoli's theorem

A code is defined to be equidistant if and only if there exists some constant d such that the distance between any two of the code's distinct codewords is equal to d.[4] In 1984 Arrigo Bonisoli determined the structure of linear one-weight codes over finite fields and proved that every equidistant linear code is a sequence of dual Hamming codes.[5]

Examples

Some examples of linear codes include:


Generalization

Hamming spaces over non-field alphabets have also been considered, especially over finite rings, most notably Galois rings over Z4. This gives rise to modules instead of vector spaces and ring-linear codes (identified with submodules) instead of linear codes. The typical metric used in this case the Lee distance. There exist a Gray isometry between [math]\displaystyle{ \mathbb{Z}_2^{2m} }[/math] (i.e. GF(22m)) with the Hamming distance and [math]\displaystyle{ \mathbb{Z}_4^m }[/math] (also denoted as GR(4,m)) with the Lee distance; its main attraction is that it establishes a correspondence between some "good" codes that are not linear over [math]\displaystyle{ \mathbb{Z}_2^{2m} }[/math] as images of ring-linear codes from [math]\displaystyle{ \mathbb{Z}_4^m }[/math].[6][7][8]

More recently,[when?] some authors have referred to such codes over rings simply as linear codes as well.[9]

See also

References

  1. William E. Ryan and Shu Lin (2009). Channel Codes: Classical and Modern. Cambridge University Press. p. 4. ISBN 978-0-521-84868-8. https://archive.org/details/channelcodesclas00ryan. 
  2. MacKay, David, J.C. (2003). Information Theory, Inference, and Learning Algorithms. Cambridge University Press. pp. 9. ISBN 9780521642989. Bibcode2003itil.book.....M. http://www.inference.phy.cam.ac.uk/itprnn/book.pdf. ""In a linear block code, the extra [math]\displaystyle{ N - K }[/math] bits are linear functions of the original [math]\displaystyle{ K }[/math] bits; these extra bits are called parity-check bits"" 
  3. Thomas M. Cover and Joy A. Thomas (1991). Elements of Information Theory. John Wiley & Sons, Inc. pp. 210–211. ISBN 978-0-471-06259-2. https://archive.org/details/elementsofinform0000cove/page/210. 
  4. Etzion, Tuvi; Raviv, Netanel (2013). "Equidistant codes in the Grassmannian". arXiv:1308.6231 [math.CO].
  5. Bonisoli, A. (1984). "Every equidistant linear code is a sequence of dual Hamming codes". Ars Combinatoria 18: 181–186. 
  6. Marcus Greferath (2009). "An Introduction to Ring-Linear Coding Theory". in Massimiliano Sala. Gröbner Bases, Coding, and Cryptography. Springer Science & Business Media. ISBN 978-3-540-93806-4. 
  7. "Encyclopedia of Mathematics". https://www.encyclopediaofmath.org/index.php/Main_Page. 
  8. J.H. van Lint (1999). Introduction to Coding Theory (3rd ed.). Springer. Chapter 8: Codes over ℤ4. ISBN 978-3-540-64133-9. https://archive.org/details/introductiontoco0000lint_a3b9. 
  9. S.T. Dougherty; J.-L. Kim; P. Sole (2015). "Open Problems in Coding Theory". in Steven Dougherty. Noncommutative Rings and Their Applications. American Mathematical Soc.. p. 80. ISBN 978-1-4704-1032-2. https://books.google.com/books?id=psrXBgAAQBAJ&pg=PA80. 

Bibliography

  • J. F. Humphreys; M. Y. Prest (2004). Numbers, Groups and Codes (2nd ed.). Cambridge University Press. ISBN 978-0-511-19420-7.  Chapter 5 contains a more gentle introduction (than this article) to the subject of linear codes.

External links