Detecting Codes Error-Correcting Codes Hamming Distance and its use in decoding.

Detecting Codes Error-Correcting Codes Hamming Distance and its use in decoding.

Write a 700- to 1,050-word paper on the following

Explain the theory in your own words based on the case study and suggested readings.

Include the following in your explanation:Error-Detecting CodesError-Correcting CodesHamming Distance and its use in decoding.

 

Choose 1 or 2 additional examples of error detecting and error correcting codes, and describe other methods that can be used for encoding messages or for detecting and correcting errors. You may consider including perfect codes, generator matrices, parity check matrices, hamming codes, etc.

 

Please make sure you provide a detailed explanation of how your examples are used in coding theory. Be sure to explain how each method you chose works to receive full credit.

 

Provide a few examples of how Coding Theory is used in applications.

 

Format citations in your paper according to APA guidelines. All work must be properly cited and referenced.

Coding Theory

Author: Kenneth H. Rosen, AT&T Laboratories.

Prerequisites: The prerequisites for this chapter are the basics of logic, set theory, number theory, matrices, and probability. See Sections 1.1, 2.1, 2.2, 3.4–3.7, and 6.1 of Discrete Mathematics and Its Applications.

Introduction The usual way to represent, manipulate, and transmit information is to use bit strings, that is, sequences of zeros and ones. It is extremely difficult, and often impossible, to prevent errors when data are stored, retrieved, operated on, or transmitted. Errors may occur from noisy communication channels, electrical interference, human error, or equipment error. Similarly, errors are introduced into data stored over a long period of time on magnetic tape as the tape deteriorates.

It is particularly important to ensure reliable transmission when large com- puter files are rapidly transmitted or when data are sent over long distances, such as data transmitted from space probes billions of miles away. Similarly, it is often important to recover data that have degraded while stored on a tape. To guarantee reliable transmission or to recover degraded data, techniques from coding theory are used. Messages, in the form of bit strings, are encoded by translating them into longer bit strings, called codewords. A set of codewords

73

74 Applications of Discrete Mathematics

is called a code. As we will see, we can detect errors when we use certain codes. That is, as long as not too many errors have been made, we can de- termine whether one or more errors have been introduced when a bit string was transmitted. Furthermore, when codes with more redundancy are used, we can correct errors. That is, as long as not too many errors were introduced in transmission, we can recover the codeword from the bit string received when this codeword was sent.

Coding theory, the study of codes, including error detecting and error correcting codes, has been studied extensively for the past forty years. It has become increasingly important with the development of new technologies for data communications and data storage. In this chapter we will study both error detecting and error correcting codes. We will introduce an important family of error correcting codes. To go beyond the coverage in this chapter and to learn about the latest applications of coding theory and the latest technical developments, the reader is referred to the references listed at the end of the chapter.

Error Detecting Codes A simple way to detect errors when a bit string is transmitted is to add a parity check bit at the end of the string. If the bit string contains an even number of 1s we put a 0 at the end of the string. If the bit string contains an odd number of 1s we put a 1 at the end of the string. In other words, we encode the message x1x2 . . . xn as x1x2 . . . xnxn+1, where the parity check bit xn+1 is given by

xn+1 = (x1 + x2 + . . . + xn) mod 2.

Adding the parity check bit guarantees that the number of 1s in the extended string must be even. It is easy to see that the codewords in this code are bit strings with an even number of 1s.

Note that when a parity check bit is added to a bit string, if a single error is made in the transmission of a codeword, the total number of 1s will be odd. Consequently, this error can be detected. However, if two errors are made, these errors cannot be detected, since the total number of 1s in the extended string with two errors will still be even. In general, any odd number of errors can be detected, while an even number of errors cannot be detected.

Example 1 Suppose that a parity check bit is added to a bit string before it is transmitted. What can you conclude if you receive the bit strings 1110011 and 10111101 as messages?

Solution: Since the string 1110011 contains an odd number of 1s, it cannot be a valid codeword (and must, therefore, contain an odd number of errors).

Chapter 5 Coding Theory 75

On the other hand, the string 10111101 contains an even number of 1s. Hence it is either a valid codeword or contains an even number of errors.

Another simple way to detect errors is to repeat each bit in a message twice, as is done in the following example.

Example 2 Encode the bit string 011001 by repeating each bit twice.

Solution: Repeating each bit twice produces the codeword 001111000011.

What errors can be detected when we repeat each bit of a codeword twice? Since the codewords are those bit strings that contain pairs of matching bits, that is, where the first two bits agree, the third and fourth bits agree, and so on, we can detect errors that change no more than one bit of each pair of these matching bits. For example, we can detect errors in the second bit, the third bit, and the eighth bit of when codewords have eight bits (such as detecting that 01101110, received when the codeword 00001111 was sent, has errors). On the other hand, we cannot detect an error when the third and fourth bit are both changed (such as detecting that 00111111, received when the codeword 00001111 was sent, has errors).

So far we have discussed codes that can be used to detect errors. When errors are detected, all we can do to obtain the correct codeword is to ask for retransmission and hope that no errors will occur when this is done. However, there are more powerful codes that can not only detect but can also correct errors. We now turn our attention to these codes, called error correcting codes.

Error Correcting Codes We have seen that when redundancy is included in codewords, such as when a parity check bit is added to a bit string, we can detect transmission errors. We can do even better if we include more redundancy. We will not only be able to detect errors, but we will also be able to correct errors. More precisely, if sufficiently few errors have been made in the transmission of a codeword, we can determine which codeword was sent. This is illustrated by the following example.

Example 3 To encode a message we can use the triple repetition code. We repeat a message three times. That is, if the message is x1x2x3, we encode it as x1x2x3x4x5x6x7x8x9 where x1 = x4 = x7, x2 = x5 = x8, and x3 = x6 = x9. The valid codewords are 000000000, 001001001, 010010010, 011011011, 100100100, 101101101, 110110110, and 111111111.

76 Applications of Discrete Mathematics

We decode a bit string, which may contain errors, using the simple majority rule. For example, to determine x1, we look at x1, x4, and x7. If two or three of these bits are 1, we conclude that x1 = 1. Otherwise, if two or three of these bits are 0, we conclude that x1 = 0. In general, we look at the three bits corresponding to each bit in the original message. We decide that a bit in the message is 1 if a majority of bits in the string received in positions corresponding to this bit are 1s and we decide this bit is a 0 otherwise. Using this procedure, we correctly decode the message as long as at most one error has been made in the bits corresponding to each bit of the original message.

For example, when a triple repetition code is used, if we receive 011111010, we conclude that the message sent was 011. (For instance, we decided that the first bit of the message was 0 since the first bit is 0, the fourth bit is 1, and the seventh bit is 0, leading us to conclude that the fourth bit is wrong.)

To make the ideas introduced by the triple repetition code more precise we need to introduce some ideas about the distance between codewords and the probability of errors. We will develop several important concepts before returning to error correcting codes.

Hamming Distance There is a simple way to measure the distance between two bit strings. We look at the number of positions in which these bit strings differ. This approach was used by Richard Hamming* in his fundamental work in coding theory.

Definition 1 The Hamming distance d(x,y) between the bit strings x = x1x2 . . . xn and y = y1y2 . . . yn is the number of positions in which these strings differ, that is, the number of i (i = 1, 2, . . . , n) for which xi �= yi.

Note that the Hamming distance between two bit strings equals the number of changes in individual bits needed to change one of the strings into the other.

* Richard Hamming (1915–1998) was one of the founders of modern coding theory. He was born in Chicago and received his B.S. from the University of Chicago, his M.A.

from the University of Nebraska, and his Ph.D. from the University of Illinois in 1942.

He was employed by the University of Illinois from 1942 to 1944 and the University

of Louisville from 1944 to 1945. From 1945 until 1946 he was on the staff of the

Manhattan Project in Los Alamos. He joined Bell Telephone Laboratories in 1946,

where he worked until 1976. His research included work in the areas of coding theory,

numerical methods, statistics, and digital filtering. Hamming joined the faculty of the

Naval Postgraduate School in 1976. Among the awards he won are the Turing Prize

from the ACM and the IEEE Hamming Medal (named after him).

Chapter 5 Coding Theory 77

We will find this observation useful later.

Example 4 Find the Hamming distance between the bit strings 01110 and 11011 and the Hamming distance between the bit strings 00000 and 11111.

Solution: Since 01110 and 11011 differ in their first, third, and fifth bits, d(01110, 11011) = 3. Since 00000 and 11111 differ in all five bits, we conclude that d(00000, 11111) = 5.

The Hamming distance satisfies all the properties of a distance function (or metric), as the following theorem demonstrates.

Theorem 1 Let d(x,y) represent the Hamming distance between the bit strings x and y of length n. Then

(i) d(x,y) ≥ 0 for all x, y (ii) d(x,y) = 0 if and only if x = y

(iii) d(x,y) = d(y,x) for all x, y

(iv) d(x,y) ≤ d(x, z) + d(z,y) for all x, y, z. Proof: Properties (i), (ii), and (iii) follow immediately from the definition of the Hamming distance. To prove (iv), we use the fact that d(x,y) is the number of changes of bits required to change x into y. Note that for every string z of length n the number of changes needed to change x into y does not exceed the number of changes required to change x into z and to then change z into y.

How can the Hamming distance be used in decoding? In particular, sup- pose that when a codeword x from a code C is sent, the bit string y is received. If the transmission was error-free, then y would be the same as x. But if errors were introduced by the transmission, for instance by a noisy line, then y is not the same as x. How can we correct errors, that is, how can we recover x?

One approach would be to compute the Hamming distance between y and each of the codewords in C. Then to decode y, we take the codeword of minimum Hamming distance from y, if such a codeword is unique. If the distance between the closest codewords in C is large enough and if sufficiently few errors were made in transmission, this codeword should be x, the codeword sent. This type of decoding is called nearest neighbor decoding.

Example 5 Use nearest neighbor decoding to determine which code word

78 Applications of Discrete Mathematics

was sent from the code C = {0000, 1110, 1011} if 0110 is received. Solution: We first find the distance between 0110 and each of the codewords. We find that

d(0000, 0110) = 2,

d(1110, 0110) = 1,

d(1011, 0110) = 3.

Since the closest codeword to 0110 is 1110, we conclude that 1110 was the codeword sent.

Will nearest neighbor decoding produce the most likely codeword that was sent from a binary string that was received? It is not hard to see that it will if each bit sent has the same probability p of being received incorrectly and p < 1/2. We call a transmission channel with this property a binary symmetric channel. Such a channel is displayed in Figure 1.

Figure 1. A binary symmetric channel.

Example 6 Suppose that when a bit is sent over a binary symmetric channel the probability it is received incorrectly is 0.01. What is the probability that the bit string 100010 is received when the bit string 000000 is sent?

Solution: Since the probability a bit is received incorrectly is 0.01, the prob- ability that a bit is received correctly is 1 − 0.01 = 0.99. For 100010 to be received, when 000000 is sent, it is necessary for the first and fifth bits to be received incorrectly and the other four bits to be received correctly. The prob- ability that this occurs is

(0.99)4(0.01)2 = 0.000096059601.

We will now show that nearest neighbor decoding gives us the most likely codeword sent, so that it is also maximum likelihood decoding.

Chapter 5 Coding Theory 79

Theorem 2 Suppose codewords of a binary code C are transmitted using a binary symmetric channel. Then, nearest neighbor decoding of a bit string received produces the most likely codeword sent.

Proof: To prove this theorem we first need to find the probability that when a codeword of length n is sent, a bit string with k errors in specified positions is received. Since the probability each bit is received correctly is 1 − p and the probability each bit is received in error is p, it follows that the probability of k errors in specified positions is pk(1 − p)n−k. Since p < 1/2 and 1 − p > 1/2, it follows that

pi(1 − p)n−i > pj(1 − p)n−j

whenever i < j. Hence, if i < j, the probability that a bit string with i specified errors is received is greater than the probability that a bit string with j specified errors is received. Since is more likely that errors were made in fewer specified positions when a codeword was transmitted, nearest neighbor decoding produces the most likely codeword.

The Hamming distance between codewords in a binary code determines its ability to detect and/or correct errors. We need to make the following definition before introducing two key theorems relating to this ability.

Definition 2 The minimum distance of a binary code C is the smallest distance between two distinct codewords, that is,

d(C) = min{d(x,y)|x,y ∈ C,x �= y}.

Example 7 Find the minimum distance of the code

C = {00000, 01110, 10011, 11111}.

Solution: To compute the minimum distance of this code we will find the distance between each pair of codewords and then find the smallest such dis- tance. We have d(00000, 01110) = 3, d(00000, 10011) = 3, d(00000, 11111) = 5, d(01110, 10011) = 4, d(01110, 11111) = 2, and d(10011, 11111) = 2. We see that the minimum distance of C is 2.

Example 8 Find the minimum distance of the code

C = {000000, 111111}.

80 Applications of Discrete Mathematics

Solution: Since there are only two codewords and d(000000, 111111) = 6, the minimum distance of this code is 6.

The minimum distance of a code tells us how many errors it can detect and how many errors it can correct, as the following two theorems show.

Theorem 3 A binary code C can detect up to k errors in any codeword if and only if d(C) ≥ k + 1. Proof: Suppose that C is a binary code with d(C) ≥ k + 1. Suppose that a codeword x is transmitted and is received with k or fewer errors. Since the minimum distance between codewords is at least k + 1, the bit string received cannot be another codeword. Hence, the receiver can detect these errors.

Now suppose that C can detect up to k errors and that d(C) ≤ k. Then there are two codewords in C that differ in no more than k bits. It is then possible for k errors to be introduced when one of these codewords is transmitted so that the other codeword is received, contradicting the fact that C can detect up to k errors.

Theorem 4 A binary code C can correct up to k errors in any codeword if and only if d(C) ≥ 2k + 1. Proof: Suppose that C is a binary code with d(C) ≥ 2k + 1. Suppose that a codeword x is transmitted and received with k or fewer errors as the bit string z, so that d(x, z) ≤ k. To see that C can correct these errors, note that if y is a codeword other than x, then d(z,y) ≥ k + 1. To see this note that if d(z,y) ≤ k, then by the triangle inequality d(x,y) ≤ d(x, z) + d(z,y) ≤ k + k = 2k, contradicting the assumption that d(C) ≥ 2k + 1.

Conversely, suppose that C can correct up to k errors. If d(C) ≤ 2k, then there are two codewords that differ in 2k bits. Changing k of the bits in one of these codewords produces a bit string that differs from each of these two codewords in exactly k positions, thus making it impossible to correct these k errors.

Example 9 Let C be the code {00000000, 11111000, 01010111, 10101111}. How many errors can C detect and how many can it correct?

Solution: Computing the distance between codewords shows that the min- imum distance of C is 5. By Theorem 3, it follows that C can detect up to 5 − 1 = 4 errors. For example, when we use C to detect errors, we can de- tect the four errors made in transmission when we receive 11110000 when the codeword 00000000 was sent.

Chapter 5 Coding Theory 81

By Theorem 4, it follows that C can correct up to �(5 − 1)/2� = 2 errors. For example, when we use C to correct errors, we can correct the two er- rors introduced in transmission when we receive 11100000 when the codeword 11111000 was sent.

Perfect Codes To allow error correction we want to make the minimum distance between codewords large. But doing so limits how many codewords are available. Here we will develop a bound on the number of codewords in a binary code with a given minimum distance.

Lemma 1 Suppose x is a bit string of length n and that k is a nonnegative integer not exceeding n. Then there are

C(n, 0) + C(n, 1) + · · · + C(n, k). bit strings y of length n such that d(x,y) ≤ k (where d is the Hamming dis- tance).

Proof: Let i be a nonnegative integer. The number of bit strings y with d(x,y) = i equals the number of ways to select the i locations where x and y differ. This can be done in C(n, i) ways. It follows that there are

C(n, 0) + C(n, 1) + · · · + C(n, k) bit strings such that d(x,y) ≤ k.

We can describe the statement in Lemma 1 in geometric terms. By the sphere of radius k centered at x we mean the set of all bit strings y such that d(x,y) ≤ k. Lemma 1 says that there are exactly ∑ki=0 C(n, i) bit stings in the sphere of radius k centered at x.

Lemma 2 Let C be a binary code containing codewords of length n and let d(C) = 2k + 1. Then given a bit string y of length n, there is at most one codeword x such that y is in the sphere of radius k centered at x.

Proof: Suppose that y is in the sphere of radius k centered at two different codewords x1 and x2. Then d(x1,y) ≤ k and d(x2,y) ≤ k. By the triangle inequality for the Hamming distance this implies that

d(x1,x2) ≤ d(x1,y) + d(x2,y) ≤ k + k = 2k,

82 Applications of Discrete Mathematics

contradicting the fact that the minimum distance between codewords is 2k +1.

We can now give a useful bound on how many codewords can be in a code consisting of n-tuples that can correct a specified number of errors.

Theorem 5 The Sphere Packing or (Hamming) Bound Suppose that C is a code of bit strings of length n with d(C) = 2k+1. Then |C|, the number of codewords in C, cannot exceed

2n

C(n, 0) + C(n, 1) + · · · + C(n, k).

Proof: There are 2n bit strings of length n. By Lemma 1 the sphere of radius k centered at a codeword x contains

C(n, 0) + C(n, 1) + · · · + C(n, k)

bit strings. Since no bit string can be in two such spheres (by Lemma 2), it follows that the number of bit strings of length n is at least as large as the number of codewords times the number of bit strings in each such sphere. Hence,

2n ≥ |C|[C(n, 0) + C(n, 1) + · · · + C(n, k)]. We obtain the inequality we want by dividing by the second factor on the right- hand side of this inequality (and writing the inequality with the smaller term first).

Example 10 Find an upper bound for the number of codewords in a code C where codewords are bit strings of length seven and the minimum distance between codewords is three.

Solution: The minimum distance between codewords is 3 = 2k + 1, so that k = 1. Hence the sphere packing bound shows that there are no more than

27/[C(7, 0) + C(7, 1)] = 128/8 = 16

codewords in such a code.

The sphere packing bound gives us an upper bound for the number of codewords in a binary code with a given minimum distance where codewords are bit strings of length n. The codes that actually achieve this upper bound,

Chapter 5 Coding Theory 83

that is, that have the most codewords possible, are of special interest because they are the most efficient error correcting codes. Such codes are known as perfect codes.

Example 11 Show that the code consisting of just two codewords 00000 and 11111 is a perfect binary code.

Solution: The minimum distance between codewords in this code is 5. The sphere packing bound states that there are at most

25/[C(5, 0) + C(5, 1) + C(5, 2)] = 32/16 = 2

codewords in a code consisting of 5-tuples with minimum distance 5. Since there are 2 codewords in this code, it is a perfect binary code.

The code in Example 11 is called a trivial perfect code since it only consists of the two codewords, one containing only 0s and the other containing only 1s. As Exercise 8 demonstrates, when n is an odd positive integer there are trivial perfect codes consisting of the two codewords which are bit strings of length n consisting of all 0s and of all 1s. Finding perfect binary codes different from the trivial codes has been one of the most important problems in coding theory. In the next section we will introduce a class of perfect binary codes known as Hamming codes.

Generator Matrices Before describing Hamming codes, we need to generalize the concept of a parity check bit. When we use a parity check bit, we encode a message x1x2 . . . xk as x1x2 . . . xkxk+1 where xk+1 = (x1 + x2 + · · · + xk) mod 2. To generalize this notion, we add more than one check bit. More precisely, we encode a message x1x2 . . . xk as x1x2 . . . xkxk+1 . . . xn, where the last n − k bits xk+1,…,xn, are parity check bits, obtained from the k bits in the message. We will describe how these parity check bits are specified.

Consider a k-bit message x1x2 · · ·xk as a 1× k matrix x. Let G be a k×n matrix that begins with the k × k identity matrix Ik. That is, G = (Ik|A), where A is a k × (n − k) matrix, known as a generator matrix. We encode x as E(x) = xG, where we do arithmetic modulo 2. Coding using a parity check bit and using the triple repetition code are special cases of this technique, as illustrated in Examples 12 and 13.

Example 12 We can represent encoding by adding a parity check bit to a

84 Applications of Discrete Mathematics

three-bit message as E(x) = xG, where

G =

⎛ ⎝ 1 0 0 10 1 0 1

0 0 1 1

⎞ ⎠ .

Note that to obtain G we add a column of 1s to I3, the 3 × 3 identity matrix. That is, G = (I3|A), where

A =

⎛ ⎝ 11

1

⎞ ⎠ .

Example 13 We can represent encoding using the triple repetition code for three-bit messages as E(x) = xG, where

G =

⎛ ⎝ 1 0 0 1 0 0 1 0 00 1 0 0 1 0 0 1 0

0 0 1 0 0 1 0 0 1

⎞ ⎠ .

Note that G is formed by repeating the identity matrix of order three, I3, three times, that is,

G = (I3|I3|I3).

We now consider an example which we will use to develop some important ideas.

Example 14 Suppose that

G =

⎛ ⎝ 1 0 0 1 1 10 1 0 1 1 0

0 0 1 1 0 1

⎞ ⎠ ,

that is, G = (I3|A), where

A =

⎛ ⎝ 1 1 11 1 0

1 0 1

⎞ ⎠ .

What are the codewords in the code generated by this generator matrix?

Chapter 5 Coding Theory 85

Solution: We encode each of the eight three-bit messages x = x1x2x3 as E(x) = xG. This produces the codewords 000000, 001101, 010110, 011011, 100111, 101010, 110001, and 111100. For example, we get the third of these by computing

E(010) = (0 1 0)G = (0 1 0)

⎛ ⎝ 1 0 0 1 1 10 1 0 1 1 0

0 0 1 1 0 1

⎞ ⎠ = (0 1 0 1 1 0).

It is easy to see that we can find the codewords in a binary code generated by a generator matrix G by taking all possible linear combinations of the rows of G (since arithmetic is modulo 2, this means all sums of subsets of the set of rows of G). The reader should verify this for codewords in the code in Example 14.

It is easy to see that the binary codes formed using generator matrices have the property that the sum of any two codewords is again a codeword. That is, they are linear codes. To see this, suppose that y1 and y2 are codewords generated by the generator matrix G. Then there are bit strings x1 and x2 such that E(x1) = y1 and E(x2) = y2, where E(x) = xG. It follows that y1 + y2 is also a codeword since E(x1 + x2) = y1 + y2. (Here we add bit strings by adding their components in the same positions using arithmetic modulo 2.)

We will see that there is an easy way to find the minimum distance of a linear code. Before we see this, we need to make the following definition.

Definition 3 The weight of a codeword x, denoted by w(x), in a binary code is the number of 1s in this codeword.

Example 15 Find the weights of the codewords 00000, 10111, and 11111.

Solution: Counting the number of 1s in each of these codewords we find that w(00000) = 0, w(10111) = 4, and w(11111) = 5.

Lemma 3 Suppose that x and y are codewords in a linear code C. Then d(x,y) = w(x + y).

Proof: The positions with 1s in them in x+y are the positions where x and y differ. Hence d(x,y) = w(x + y).

We also will need the fact that 0, the bit string with all 0s, belongs to a linear code.

86 Applications of Discrete Mathematics

Lemma 4 Suppose that C is a nonempty linear code. Then 0 is a codeword in C.

Proof: Let x be a codeword in C. Since C is linear x+x = 0 belongs to C.

Theorem 6 The minimum distance of a linear code C equals the minimum weight of a nonzero codeword in C.

Proof: Suppose that the minimum distance of C is d. Then there are code- words x and y such that d(x,y) = d. By Lemma 3 it follows that w(x + y) = d. Hence w, the minimum weight of a codeword, is no larger than d.

Conversely, suppose that the codeword x is a nonzero codeword of min- imum weight. Then using Lemma 4 we see that w = w(x) = w(x + 0) = d(x,0) ≥ d. It follows that w = d, establishing the theorem.

Parity Check Matrices Note that in Example 14 the bit string x1x2x3 is encoded as x1x2x3x4x5x6 where x4 = x1 + x2 + x3, x5 = x1 + x2, and x6 = x1 + x3 (here, arithmetic is carried out modulo 2). Because we are doing arithmetic modulo 2, we see that

x1 + x2 + x3 + x4 = 0 x1 + x2 + x5 = 0 x1 + x3 + x6 = 0.

Furthermore, it is easy to see that x1x2x3x4x5x6 is a codeword if and only if it satisfies this system of equations.

We can express this system of equations as

⎛ ⎝ 1 1 1 1 0 01 1 0 0 1 0

1 0 1 0 0 1

⎞ ⎠ ⎛ ⎜⎜⎜⎜⎜⎝

x1 x2 x3 x4 x5 x6

⎞ ⎟⎟⎟⎟⎟⎠ =

⎛ ⎝ 00

0

⎞ ⎠ ,

that is, HE(x)t = 0,

where E(x)t is the transpose of E(x) and H, the parity check matrix, is given by

H =

⎛ ⎝ 1 1 1 1 0 01 1 0 0 1 0

1 0 1 0 0 1

⎞ ⎠ .

Chapter 5 Coding Theory 87

Note that H = (At|In−k). With this notation we see that x = x1x2x3x4x5x6 is a codeword if and only if Hxt = 0, since checking this equation is the same as checking whether the parity check equations hold.

In general, suppose that G is a k × n generator matrix with G = (Ik|A),

where A is a k× (n− k) matrix. To G we associate the parity check matrix H, where

H = (At|In−k). Then x is a codeword if and only if Hxt = 0. Note that from a generator matrix G we can find the associated parity check matrix H, and conversely, given a parity check matrix H, we can find the associated generator matrix G. More precisely, note that if H = (B|Ir), then G = (In−r|Bt).

We have seen that the parity check matrix can be used to detect errors. That is, to determine whether x is a codeword we check whether

Hxt = 0.

Not only can the parity check matrix be used to detect errors, but when the columns of this matrix are distinct and are all nonzero, it also can be used to correct errors. Under these assumptions, suppose that the codeword x is sent and that y is received, which may or may not be the same as x. Write y = x + e, where e is an error string. (We have e = 0 if no errors arose in the transmission). In general, the error string e has 1s in the positions where y differs from x and 0s in all other positions. Now suppose that only one error has been introduced when x was transmitted. Then e is a bit string that has only one nonzero bit which is in the position where x and y differ, say position j. Since Hxt = 0, it follows that

Hyt = H(xt + e)

= Hxt + et

= et

= cj

where cj is the jth column of H. Hence, if we receive y and assume that no more than one error is present,

we can find the codeword x that was sent by computing Hyt. If this is zero, we know that y is the codeword sent. Otherwise, it will equal the jth column of H for some integer j. This means that the jth bit of y should be changed to produce x.

Example 16 Use the parity check matrix to determine which codeword from the code in Example 14 was sent if 001111 was received. Assume that at most one error was made.

88 Applications of Discrete Mathematics

Solution: We find that

Hyt =

⎛ ⎝ 1 1 1 1 0 01 1 0 0 1 0

1 0 1 0 0 1

⎞ ⎠ ⎛ ⎜⎜⎜⎜⎜⎝

0 0 1 1 1 1

⎞ ⎟⎟⎟⎟⎟⎠ =

⎛ ⎝ 01

0

⎞ ⎠ .

This is the fifth column of H. If follows that the fifth bit of 001111 is incorrect. Hence the code word sent was 001101.

Hamming Codes We can now define the Hamming codes. We define them using parity check matrices.

Definition 4 A Hamming code of order r where r is a positive integer, is a code generated when we take as parity check matrix H an r × (2r − 1) matrix with columns that are all the 2r − 1 nonzero bit strings of length r in any order such that the last r columns form the identity matrix.

Interchanging the order of the columns leads to what is known as an equiv- alent code. For details on equivalence of codes the reader is referred to the references at the end of this chapter.

Example 17 Find the codewords in a Hamming code of order 2.

Solution: The parity check matrix of this code is

H = (

1 1 0 1 0 1

) .

We have H = (B|I2) where B = (

1 1

) . Hence, the generator matrix G of

this code equals G = (I3−2|Bt) = (1 1 1). Since the codewords are linear combinations of the rows of G, we see that this code has two codewords, 000 and 111. This is the linear repetition code of order 3.

Example 18 Find the codewords in a Hamming code of order 3.

Chapter 5 Coding Theory 89

Solution: For the parity check matrix of this code we use

H =

⎛ ⎝ 0 1 1 1 1 0 01 0 1 1 0 1 0

1 1 0 1 0 0 1

⎞ ⎠ .

We have H = (B|I3) where

B =

⎛ ⎝ 0 1 1 11 0 1 1

1 1 0 1

⎞ ⎠ .

Hence the generator matrix G of this code equals

G = (I7−3|Bt) =

⎛ ⎜⎝

1 0 0 0 0 1 1 0 1 0 0 1 0 1 0 0 1 0 1 1 0 0 0 0 1 1 1 1

⎞ ⎟⎠ .

The 16 codewords in this code C can be found by taking all possible sums of the rows of G. We leave this as an exercise at the end of the chapter.

To show that the Hamming codes are perfect codes we first need to establish two lemmas.

Lemma 5 A Hamming code of order r contains 2n−r codewords where n = 2r − 1. Proof: The parity check matrix of the Hamming code is an r × n matrix. It follows that the generator matrix for this code is a (n − r) × n matrix. Recall that the codewords are the linear combinations of the rows. As the reader can show, no two linear combinations of the rows are the same. Since there are 2n−r different linear combinations of row, there are 2n−r different codewords in a Hamming code of order r.

Lemma 6 The minimum distance of a Hamming code of order r is 3 when- ever r is a positive integer.

Proof: The parity check matrix Hr has columns which are all nonzero and no two of which are the same. Hence, from our earlier discussion, a Hamming code of order r can correct single errors. By Theorem 3 we conclude that the minimum distance of this code is at least 3. Among the columns of Hr are the

90 Applications of Discrete Mathematics

following three columns:

c1 =

⎛ ⎜⎜⎜⎜⎝

1 1 0 … 0

⎞ ⎟⎟⎟⎟⎠ , c2 =

⎛ ⎜⎜⎜⎜⎝

1 0 0 … 0

⎞ ⎟⎟⎟⎟⎠ , c3 =

⎛ ⎜⎜⎜⎜⎝

0 1 0 … 0

⎞ ⎟⎟⎟⎟⎠ .

Note that c1 + c2 + c3 = 0. Let x be the bit string with 1 in the positions of these columns and zero elsewhere. Then Hxt = 0, since it is c1 + c2 + c3. It follows that x is a codeword. Since w(x) = 3, by Theorem 6 it follows that the minimum distance is no more than 3. We conclude that the minimum distance of a Hamming code of order r is 3.

Theorem 7 The Hamming code of order r is a perfect code.

Proof: Let n = 2r −1. By Lemma 5 a Hamming code of order r contains 2n−r codewords, each of which is an n-tuple. By Lemma 6 the minimum distance of the Hamming code of order r is 3. We see that this code achieves the maximum number of codewords allowed by the sphere packing bound. To see this, note that

2n−r(1 + C(n, 1)) = 2n−r(1 + n) = 2n−r(1 + 2r − 1) = 2n. This is the upper bound of the sphere-packing bound. hence a Hamming code of order r is perfect.

By Theorem 7 we see that the Hamming codes are examples of perfect codes. The study of perfect codes has been one of the most important areas of research in coding theory and has lead to the development of many important results. See the references at the end of the chapter to learn about what is known about perfect codes.

Summary In this chapter we have studied how codes can be used for error detection and error correction. We have introduced an important class of codes known as the Hamming codes. However, we have only touched the surface of a fascinating and important subject that has become extremely important for modern computing and communications. The interested reader can consult the references listed at the end of this chapter to learn about many other classes of codes that have practical applications.

Chapter 5 Coding Theory 91

For example, pictures of the planets taken by space probes have been en- coded using powerful codes, such as a code known as the Reed-Muller code (see [5] for details). This code has been used to encode the bit string of length 6 representing the brightness of each pixel of an image by a bit string of length 32. This Reed-Muller code consists of 64 codewords, each a bit string of length 32, with minimum distance 16. Another interesting example is the use of a family of codes known as Reed-Solomon codes used in digital audio recording (see [5] for details). Finally, many concepts and techniques from both linear algebra and abstract algebra are used in coding theory. Studying coding theory may con- vince the skeptical reader about the applicability of some of the more abstract areas of mathematics.

Suggested Readings

1. E. Berlekamp, editor, Key Papers in the Development of Coding Theory , IEEE Press, New York, 1974.

2. R. Hamming, Coding and Information Theory, 2nd Edition, Prentice Hall, Upper Saddle River, N.J., 1986.

3. R. Hill, A First Course in Coding Theory, Oxford University Press, Oxford, 1990.

4. V. Pless, Introduction to the Theory of Error-Correcting Codes, 3rd Edi- tion, John Wiley & Sons, Hoboken, N.J., 1998.

5. S. Vanstone and P. van Oorschot, An Introduction to Error Correcting Codes with Applications, Springer, New York. 1989.

Exercises

1. Could the following bit strings have been received correctly if the last bit is a parity bit?

a) 1000011 b) 111111000 c) 10101010101 d) 110111011100

2. Find the Hamming distance between each of the following pairs of bit strings.

92 Applications of Discrete Mathematics

a) 00000,11111 b) 1010101,0011100 c) 000000001,111000000 d) 1111111111,0100100011

3. Suppose the bit string 01011 is sent using a binary symmetric channel where the probability a bit is received incorrectly is 0.01. What is the probability that

a) 01011, the bit string sent, is received? b) 11011 is received? c) 01101 is received? d) 10111 is received? e) no more than one error is present in the bit string received?

4. How many errors can each of the following binary codes detect and how many can it correct?

a) {0000000, 1111111} b) {00000, 00111, 10101, 11011} c) {00000000, 11111000, 01100111, 100101101}

5. Suppose that the probability of a bit error in transmission over a binary symmetric channel is 0.001. What is the probability that when a codeword with eight bits is sent from a code with minimum distance five, the bit string received is decoded as the codeword sent (when nearest neighbor decoding is used)?

�6. Show that if the minimum distance between codewords is four it is possible to correct an error in a single bit and to detect two bit errors without correction.

7. Use the sphere packing bound to give an upper bound on the number of codewords in a binary code where codewords are bit strings of length nine and the minimum distance between codewords is five.

8. Show that whenever n is an odd positive integer, the binary code consisting of the two bit strings of length n containing all 0s or all 1s is a perfect code.

9. Suppose that x and y are bit strings of length n and m is the number of positions where both x and y have 1s. Show that w(x+y) = w(x)+w(y)− 2m.

10. Find the parity check matrix associated with the code formed by adding a parity check bit to a bit string of length 4.

11. Find the parity check matrix associated with the triple repetition code for bit strings of length 3.

Chapter 5 Coding Theory 93

12. Suppose that the generator matrix for a binary code is

⎛ ⎜⎝

1 0 0 0 1 1 1 0 1 0 0 1 0 1 0 0 1 0 0 1 1 0 0 0 1 1 1 0

⎞ ⎟⎠ .

What is the parity check matrix H for this code?

13. Suppose that the parity check matrix for a binary code is⎛ ⎝ 1 0 1 0 01 1 0 1 0

0 1 0 0 1

⎞ ⎠ .

What is the generator matrix G for this code?

14. Find the 16 codewords in the Hamming code of order 3 described in Ex- ample 18.

�15. Sometimes, instead of errors, bits are erased during the transmission of a message or from a tape or other storage medium. The position, but not the value, of an erased bit is known. We say that a code C can correct r erasures if a message received with no errors and with no more than r erasures can be corrected to a unique codeword that agrees with the message received in all the positions that were not erased.

a) Show that a binary code of minimum distance d can correct d − 1 erasures.

b) Show that a binary code of minimum distance d can correct t errors and r erasures if d = 2t + r + 1.

Computer Projects

1. Given a binary code, determine the number of errors that it can detect and the number of errors that it can correct.

2. Given a binary code with minimum distance k, where k is a positive integer, write a program that will detect errors in codewords in as many as k − 1 positions and correct errors in as many as �(k − 1)/2� positions.

Order from us and get better grades. We are the service you have been looking for.