When a codeword c is transmitted and vector r is received, the difference between the two is called the error vector e, i.e. r = c + e. If H is a parity-check matrix for the linear code C, then Hrt = H(c + e)t = Hct + Het = Het since Hct = 0 for any codeword. Hrt is called the syndrome of r.
If wt(e) <= 1 then the syndrome of r = Het is just a scalar multiple of a column of H. This observation leads to a simple decoding algorithm for 1-error correcting linear codes. First, calculate the syndrome of r. If the syndrome is 0, no error has occurred and r is a codeword. Otherwise, find the column of H which is a scalar multiple of the syndrome. If no such column exists then more than one error has occurred and the code can not correct it. If however, the syndrome is a times column j, say, then add the vector with -a in position j and 0's elsewhere to r. This corrects the error.
In the case of binary Hamming codes (which are 1-error correcting) this algorithm can be made even simpler. Since the parity-check matrix contains all the non-zero vectors of length n-k as columns, arrange these columns so that they are in numerical order as binary integers. A non-zero syndrome will then be the binary representation of the column where the error has occurred. This is called Hamming decoding.
Example: Consider the binary Hamming code with parity-check matrix
1 0 1 0 1 0 1 H = 0 1 1 0 0 1 1 0 0 0 1 1 1 1 .Notice that, for example, column 6 is (0 1 1)t, representing the integer 0(20) + 1(21) + 1(22) = 6. Suppose that c = (0 1 1 1 1 0 0) is transmitted and r = (0 1 1 1 1 1 0) is received. The syndrome Hrt = (0 1 1)t and the binary representation of this vector reveals bit 6 to be in error.
This procedure does not work for codes which are more than single error correcting. To deal with the more general situation, we introduce an equivalence relation on the vectors of V(n,q) with respect to the code C. We say that vectors x and y are equivalent with respect to C if and only if, x - y is in C. This is easily checked to be an equivalence relation, and the equivalence classes (which form a partition of V(n,q)) are called the cosets of C. An alternative way of viewing the cosets of C is to note that a coset consists of all the vectors that have the same syndrome. Indeed, if x - y is in C, then x - y = c for some c in C. Thus, x = c + y and
Hxt = H(c + y)t = Hct + Hyt = Hyt.
Furthermore, if two vectors have the same syndrome then they are equivalent. If Hxt = Hyt,
0 = Hxt - Hyt = H(x - y)t,
and so, x - y is in C.
Example: The table below lists the cosets of the binary (5,2) - code whose generator matrix is given by,
1 0 1 0 1 G = 0 1 1 1 0 .The cosets are the rows in the table, with the first row being the code C (which is also a coset).
00000 10101 01110 11011 00001 10100 01111 11010 00010 10111 01100 11001 00100 10001 01010 11111 01000 11101 00110 10011 10000 00101 11110 01011 11000 01101 10110 00011 10010 00111 11100 01001When the vectors of V(n,q) are arranged by cosets in this way it is called a standard array for the code. The parity-check matrix for this code is
1 1 1 0 0 H = 0 1 0 1 0 1 0 0 0 1and the syndromes for each row are given below
000 001 010 100 110 101 011 111In each coset we can select a vector of minimum weight (when there is a choice we can make the selection arbitrarily), this vector is called a coset leader. In the example above, the coset leaders were written in the first column of the standard array. We can use the coset leaders in a decoding algorithm. When a vector r is received, we find the coset that it is contained in (via the syndrome calculation) and then subtract the coset leader for that coset to obtain a codeword. This procedure is called syndrome decoding. That syndrome decoding gives the correct error correction is the content of the next theorem.
Theorem 4 : Let C be an (n,k) code over GF(q) with codewords cj, 0 <= j <= qk - 1. Let li, 0 <= i <= qn-k - 1 be a set of coset leaders for the cosets of this code. If r = li + ch then
d(r,ch) <= d(r,cj) for all j, 0 <= j <= qk - 1.
Proof: Expressing these distances in terms of weights we have,
d(r,ch) = d(li + ch,ch) = wt(li + ch - ch) = wt(li) and
d(r,cj) = d(li + ch,cj) = wt(li + ch - cj).
But li + ch - cj is in the same coset as li, and the coset leader has minimal weight.
Note that if the coset leader is unique then ch is the closest codeword (if it is not unique, then ch is still as close as any other codeword). We have the following result about uniqueness.
Theorem 5 : Let C be a linear code with minimum distance d. If x is any vector such that
then x is a unique element of minimum weight in its coset of C and hence is always a coset leader.
Proof: Suppose that there exists another vector y with the same weight as x in x's coset. Since x and y are in the same coset, x - y is in C, but
This contradicts the minimum distance of the code, unless x - y is the zero vector, i.e. x = y.
Example : In the previous example, the (5,2)-code had minimum distance 3 (the minimum non-zero weight of a codeword) and so the above theorem states that the zero vector and all vectors of weight 1 will be unique coset leaders as can easily be verified from the standard array.