24.4 Linear Codes

When you are having a conversation with a friend over a cellular phone, your voice is turned into digital data that has an error correcting code applied to it before it is sent. When your friend receives the data, the errors in transmission must be accounted for by decoding the error correcting code. Only after decoding are the data turned into sound that represents your voice.

The amount of delay it takes for a packet of data to be decoded is critical in such an application. If it took several seconds, then the delay would become aggravating and make holding a conversation difficult.

The problem of efficiently decoding a code is therefore of critical importance. In order to decode quickly, it is helpful to have some structure in the code rather than taking the code to be a random subset of AnAn. This is one of the primary reasons for studying linear codes. For the remainder of this chapter, we restrict our attention to linear codes.

Henceforth, the alphabet AA will be a finite field FF. For an introduction to finite fields, see Section 3.11. For much of what we do, the reader can assume that FF is Z2={0, 1}Z2={0, 1} = the integers mod 2, in which case we are working with binary vectors. Another concrete example of a finite field is ZpZp = the integers mod a prime pp. For other examples, see Section 3.11. In particular, as is pointed out there, FF must be one of the finite fields GF(q)GF(q); but the present notation is more compact. Since we are working with arbitrary finite fields, we’ll use “=" instead of “" in our equations. If you want to think of FF as being Z2Z2, just replace all equalities between elements of FF with congruences mod 2.

The set of nn-dimensional vectors with entries in FF is denoted by FnFn. They form a vector space over FF. Recall that a subspace of FnFn is a nonempty subset SS that is closed under linear combinations, which means that if s1, s2s1, s2 are in SS and a1, a2a1, a2 are in FF, then a1s1+a2s2Sa1s1+a2s2S. By taking a1=a2=0a1=a2=0, for example, we see that (0, 0, , , 0)S(0, 0, , , 0)S.

Definition

A linear code of dimension kk and length nn over a field FF is a kk-dimensional subspace of FnFn. Such a code is called an [n,k][n,k] code. If the minimum distance of the code is dd, then the code is called an [n,k,d][n,k,d] code.

When F=Z2F=Z2, the definition can be given more simply. A binary code of length nn and dimension kk is a set of 2k2k binary nn-tuples (the codewords) such that the sum of any two codewords is always a codeword.

Many of the codes we have met are linear codes. For example, the binary repetition code {(0, 0, 0), (1, 1, 1)}{(0, 0, 0), (1, 1, 1)} is a one-dimensional subspace of Z32Z32. The parity check code from Exercise 2 in Section 24.1 is a linear code of dimension 7 and length 8. It consists of those binary vectors of length 8 such that the sum of the entries is 0 mod 2. It is not hard to show that the set of such vectors forms a subspace. The vectors

(1, 0, 0, 0, 0, 0, 0, 1),  (0, 1, 0, 0, 0, 0, 0, 1),  , (0, 0, 0, 0, 0, 0, 1, 1)
(1, 0, 0, 0, 0, 0, 0, 1),  (0, 1, 0, 0, 0, 0, 0, 1),  , (0, 0, 0, 0, 0, 0, 1, 1)

form a basis of this subspace. Since there are seven basis vectors, the subspace is seven-dimensional.

The Hamming [7, 4] code from Example 4 of Section 24.1 is a linear code of dimension 4 and length 7. Every codeword is a linear combination of the four rows of the matrix GG. Since these four rows span the code and are linearly independent, they form a basis.

The ISBN code (Example 5 of Section 24.1) is not linear. It consists of a set of 10-dimensional vectors with entries in Z11Z11. However, it is not closed under linear combinations since XX is not allowed as one of the first nine entries.

Let CC be a linear code of dimension kk over a field FF. If FF has qq elements, then CC has qkqk elements. This may be seen as follows. There is a basis of CC with kk elements; call them v1, , vkv1, , vk. Every element of CC can be written uniquely in the form a1v1++akvka1v1++akvk, with a1, , akFa1, , akF. There are qq choices for each aiai and there are kk numbers aiai. This means there are qkqk elements of CC, as claimed. Therefore, an [n, k, d][n, k, d] linear code is an (n, qk, d)(n, qk, d) code in the notation of Section 24.2.

For an arbitrary, possibly nonlinear, code, computing the minimum distance could require computing d(u, v)d(u, v) for every pair of codewords. For a linear code, the computation is much easier. Define the Hamming weight wt(u)wt(u) of a vector uu to be the number of nonzero places in uu. It equals d(u, 0)d(u, 0), where 0 denotes the vector (0, 0, , 0)(0, 0, , 0).

Proposition

Let CC be a linear code. Then d(C)d(C) equals the smallest Hamming weight of all nonzero code vectors: d(C)=min{wt(u) | 0uC}d(C)=min{wt(u) | 0uC}.

Proof. Since wt(u)=d(u, 0)wt(u)=d(u, 0) is the distance between two codewords, we have wt(u)d(C)wt(u)d(C) for all codewords uu. It remains to show that there is a codeword with weight equal to d(C)d(C). Note that d(v, w)=wt(vw)d(v, w)=wt(vw) for any two vectors v, wv, w. This is because an entry of vwvw is nonzero, and hence gets counted in wt(vw)wt(vw), if and only if vv and ww differ in that entry. Choose vv and ww to be distinct codewords such that d(v, w)=d(C)d(v, w)=d(C). Then wt(vw)=d(C)wt(vw)=d(C), so the minimum weight of the nonzero codewords equals d(C)d(C).

To construct a linear [n, k][n, k] code, we have to construct a kk-dimensional subspace of FnFn. The easiest way to do this is to choose kk linearly independent vectors and take their span. This can be done by choosing a k×nk×n generating matrix GG of rank kk, with entries in FF. The set of vectors of the form vGvG, where vv runs through all row vectors in FkFk, then gives the subspace.

For our purposes, we’ll usually take G=[Ik, P]G=[Ik, P], where IkIk is the k×kk×k identity matrix and PP is a k×(nk)k×(nk) matrix. The rows of GG are the basis for a kk-dimensional subspace of the space of all vectors of length nn. This subspace is our linear code CC. In other words, every codeword is uniquely expressible as a linear combination of rows of GG. If we use a matrix G=[Ik, P]G=[Ik, P] to construct a code, the first kk columns determine the codewords. The remaining nknk columns provide the redundancy.

The code in the second half of Example 1, Section 24.1, has

G=(101010010101).
G=(100110011001).

The codewords 101010 and 010101 appear as rows in the matrix and the codeword 111111 is the sum of these two rows. This is a [6, 2][6, 2] code.

The code in Example 2 has

G=(10000001010000010010000100010001000010010000010100000011).
G=10000000100000001000000010000000100000001000000011111111.

For example, the codeword 11001001 is the sum mod 2 of the first, second, and fifth rows, and hence is obtained by multiplying (1, 1, 0, 0, 1, 0, 0)(1, 1, 0, 0, 1, 0, 0) times GG. This is an [8, 7][8, 7] code.

In Exercise 4, the matrix GG is given in the description of the code. As you can guess from its name, it is a [7, 4][7, 4] code.

As mentioned previously, we could start with any k×nk×n matrix of rank kk. Its rows would generate an [n, k][n, k] code. However, row and column operations can be used to transform the matrix to the form of GG we are using, so we usually do not work with the more general situation. A code described by a matrix G=[Ik, P]G=[Ik, P] as before is said to be systematic. In this case, the first kk bits are the information symbols and the last nknk symbols are the check symbols.

Suppose we have G=[Ik, P]G=[Ik, P] as the generating matrix for a code CC. Let

H=[PT, Ink], 
H=[PT, Ink], 

where PTPT is the transpose of PP. In Exercise 4 of Section 24.1, this is the matrix that was used to correct errors. For Exercise 2, we have H=[1, 1, 1, 1, 1, 1, 1, 1]H=[1, 1, 1, 1, 1, 1, 1, 1]. Note that in this case a binary string vv is a codeword if and only if the number of nonzero bits is even, which is the same as saying that its dot product with HH is zero. This can be rewritten as vHT=0vHT=0, where HTHT is the transpose of HH.

More generally, suppose we have a linear code CFnCFn. A matrix HH is called a parity check matrix for CC if HH has the property that a vector vFnvFn is in CC if and only if vHT=0vHT=0. We have the following useful result.

Theorem

If G=[Ik, P]G=[Ik, P] is the generating matrix for a code CC, then H=[PT, Ink]H=[PT, Ink] is a parity check matrix for CC.

Proof. Consider the iith row of GG, which has the form

vi=(0, , 1, , 0, pi, 1, , pi, nk), 
vi=(0, , 1, , 0, pi, 1, , pi, nk), 

where the 1 is in the iith position. This is a vector of the code CC. The jjth column of HTHT is the vector

(p1, j, , pnk, j, 0, , 1, , 0), 
(p1, j, , pnk, j, 0, , 1, , 0), 

where the 1 is in the (nk+j)(nk+j)th position. To obtain the jjth element of viHTviHT, take the dot product of these two vectors, which yields

1(pi, j)+pi, j1=0.
1(pi, j)+pi, j1=0.

Therefore, HTHT annihilates every row vivi of GG. Since every element of CC is a sum of rows of GG, we find that vHT=0vHT=0 for all vCvC.

Recall the following fact from linear algebra: The left null space of an m×nm×n matrix of rank rr has dimension nrnr. Since HTHT contains InkInk as a submatrix, it has rank nknk. Therefore, its left null space has dimension kk. But we have just proved that CC is contained in this null space. Since CC also has dimension kk, it must equal the null space, which is what the theorem claims.

We now have a way of detecting errors: If vv is received during a transmission and vHT0vHT0, then there is an error. If vHT=0vHT=0, we cannot conclude that there is no error, but we do know that vv is a codeword. Since it is more likely that no errors occurred than enough errors occurred to change one codeword into another codeword, the best guess is that an error did not occur.

We can also use a parity check matrix to make the task of decoding easier. First, let’s look at an example.

Example

Let CC be the binary linear code with generator matrix

G=(10110110).
G=(10011110).

We are going to make a table of all binary vectors of length 4 according to the following procedure. First, list the four elements of the code in the first row, starting with (0, 0, 0, 0)(0, 0, 0, 0). Then, among the 12 remaining vectors, choose one of smallest weight (there might be several choices). Add this vector to the first row to obtain the second row. From the remaining eight vectors, again choose one with smallest weight and add it to the first row to obtain the third row. Finally, choose a vector with smallest weight from the remaining four vectors, add it to the first row, and obtain the fourth row. We obtain the following:

(0, 0, 0, 0)(1, 0, 1, 1)(0, 1, 1, 0)(1, 1, 0, 1)(1, 0, 0, 0)(0, 0, 1, 1)(1, 1, 1, 0)(0, 1, 0, 1)(0, 1, 0, 0)(1, 1, 1, 1)(0, 0, 1, 0)(1, 0, 0, 1)(0, 0, 0, 1)(1, 0, 1, 0)(0, 1, 1, 1)(1, 1, 0, 0).
(0, 0, 0, 0)(1, 0, 0, 0)(0, 1, 0, 0)(0, 0, 0, 1)(1, 0, 1, 1)(0, 0, 1, 1)(1, 1, 1, 1)(1, 0, 1, 0)(0, 1, 1, 0)(1, 1, 1, 0)(0, 0, 1, 0)(0, 1, 1, 1)(1, 1, 0, 1)(0, 1, 0, 1)(1, 0, 0, 1)(1, 1, 0, 0).

This can be used as a decoding table. When we receive a vector, find it in the table. Decode by changing the vector to the one at the top of its column. The error that is removed is first element of its row. For example, suppose we receive (0, 1, 0, 1)(0, 1, 0, 1). It is the last element of the second row. Decode it to (1, 1, 0, 1)(1, 1, 0, 1), which means removing the error (1, 0, 0, 0)(1, 0, 0, 0). In this small example, this is not exactly the same as nearest neighbor decoding, since (0, 0, 1, 0)(0, 0, 1, 0) decodes as (0, 1, 1, 0)(0, 1, 1, 0) when it has an equally close neighbor (0, 0, 0, 0)(0, 0, 0, 0). The problem is that the minimum distance of the code is 2, so general error correction is not possible. However, if we use a code that can correct up to tt errors, this procedure correctly decodes all vectors that are distance at most tt from a codeword.

In a large example, finding the vector in the table can be tedious. In fact, writing the table can be rather difficult (that’s why we used such a small example). This is where a parity check matrix HH comes to the rescue.

The first vector vv in a row is called the coset leader. Let rr be any vector in the same row as vv. Then r=v+cr=v+c for some codeword cc, since this is how the table was constructed. Therefore,

rHT=vHT+cHT=vHT, 
rHT=vHT+cHT=vHT, 

since cHT=0cHT=0 by the definition of a parity check matrix. The vector S(r)=rHTS(r)=rHT is called the syndrome of rr. What we have shown is that two vectors in the same row have the same syndrome. Replace the preceding table with the following much smaller table.

Coset Leader Syndrome
(0,  0,  0,  0)(0,  0,  0,  0) (0,  0)(0,  0)
(1,  0,  0,  0)(1,  0,  0,  0) (1,  1)(1,  1)
(0,  1,  0,  0)(0,  1,  0,  0) (1,  0)(1,  0)
(0,  0,  0,  1)(0,  0,  0,  1) (0,  1)(0,  1)

This table may be used for decoding as follows. For a received vector rr, calculate its syndrome S(r)=rHTS(r)=rHT. Find this syndrome on the list and subtract the corresponding coset leader from rr. This gives the same decoding as above. For example, if r=(0, 1, 0, 1)r=(0, 1, 0, 1), then

S(r)=(0,  1,  0,  1)(11101001)=(1,  1).
S(r)=(0,  1,  0,  1)11101001=(1,  1).

This is the syndrome for the second row. Subtract the coset leader (1, 0, 0, 0)(1, 0, 0, 0) from rr to obtain the codeword (1, 1, 0, 1)(1, 1, 0, 1).

We now consider the general situation. The method of the example leads us to two definitions.

Definition

Let CC be a linear code and let uu be an nn-dimensional vector. The set u+Cu+C given by

u+C={u+c | cC}
u+C={u+c | cC}

is called a coset of CC.

It is easy to see that if vu+Cvu+C, then the sets v+Cv+C and u+Cu+C are the same (Exercise 9).

Definition

A vector having minimum Hamming weight in a coset is called a coset leader.

The syndrome of a vector uu is defined to be S(u)=uHTS(u)=uHT. The following lemma allows us to determine the cosets easily.

Lemma

Two vectors uu and vv belong to the same coset if and only if they have the same syndrome.

Proof. Two vectors uu and vv to belong to the same coset if and only if their difference belongs to the code CC; that is, uvCuvC. This happens if and only if (uv)HT=0(uv)HT=0, which is equivalent to S(u)=uHT=vHT=S(v)S(u)=uHT=vHT=S(v).

Decoding can be achieved by building a syndrome lookup table, which consists of the coset leaders and their corresponding syndromes. With a syndrome lookup table, we can decode with the following steps:

  1. For a received vector rr, calculate its syndrome S(r)=rHTS(r)=rHT.

  2. Next, find the coset leader with the same syndrome as S(r)S(r). Call the coset leader c0c0.

  3. Decode rr as rc0rc0.

Syndrome decoding requires significantly fewer steps than searching for the nearest codeword to a received vector. However, for large codes it is still too inefficient to be practical. In general, the problem of finding the nearest neighbor in a general linear code is hard; in fact, it is what is known as an NP-complete problem. However, for certain special types of codes, efficient decoding is possible. We treat some examples in the next few sections.

24.4.1 Dual Codes

The vector space FnFn has a dot product, defined in the usual way:

(a1, , an)(b0, , bn)=a0b0++anbn.
(a1, , an)(b0, , bn)=a0b0++anbn.

For example, if F=Z2F=Z2, then

(0, 1, 0, 1, 1, 1)(0, 1, 0, 1, 1, 1)=0, 
(0, 1, 0, 1, 1, 1)(0, 1, 0, 1, 1, 1)=0, 

so we find the possibly surprising fact that the dot product of a nonzero vector with itself can sometimes be 0, in contrast to the situation with real numbers. Therefore, the dot product does not tell us the length of a vector. But it is still a useful concept.

If CC is a linear [n, k][n, k] code, define the dual code

C={uFn | uc=0 for all cC}.C={uFn  uc=0 for all cC}.

Proposition

If CC is a linear [n, k][n, k] code with generating matrix G=[Ik, P]G=[Ik, P], then CC is a linear [n, nk][n, nk] code with generating matrix H=[PT, Ink]H=[PT, Ink]. Moreover, GG is a parity check matrix for CC.

Proof. Since every element of CC is a linear combination of the rows of GG, a vector uu is in CC if and only if uGT=0uGT=0. This means that CC is the left null space of GTGT. Also, we see that GG is a parity check matrix for CC. Since GG has rank kk, so does GTGT. The left null space of GTGT therefore has dimension nk, so C has dimension nk. Because H is a parity check matrix for C, and the rows of G are in C, we have GHT=0. Taking the transpose of this relation, and recalling that transpose reverses order ((AB)T=BTAT), we find HGT=0. This means that the rows of H are in the left null space of GT; therefore, in C. Since H has rank nk, the span of its rows has dimension nk, which is the same as the dimension of C. It follows that the rows of H span C, so H is a generating matrix for C.

A code C is called self-dual is C=C. The Golay code G24 of Section 24.6 is an important example of a self-dual code.

Example

Let C={(0, 0, 0), (1, 1, 1)} be the binary repetition code. Since u(0, 0, 0)=0 for every u, a vector u is in C if and only if u(1, 1, 1)=0. This means that C is a parity check code: (a1, a2, a3)C if and only if a1+a2+a3=0.

Example

Let C be the binary code with generating matrix

G=(10010110).

The proposition says that C has generating matrix

H=(01101001).

This is G with the rows switched, so the rows of G and the rows of H generate the same subspace. Therefore, C=C, which says that C is self-dual.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset