Properties of the Hamming Code
The Hamming code is a linear code. This means that if a and b are both codewords, then a + b is also a codeword. To check that this is true, note that w is a codeword if and only if wH = 0 where H is the 3´7 matrix from the last handout. If a and b are both codewords, then aH = 0 and bH = 0, so by the distributive law (a + b)H = 0. Linear codes are nice because they can be built from matrix computations.
The Hamming code is a perfect code. We have 16 codewords in the Hamming (7,4) code, out of 128 seven-bit words possible. We define a ball of radius 1 about each codeword as the set of all words that differ from the codeword in at most 1 bit. (Note: a ball of radius 2 would be the set of all words that differ from the codeword in at most 2 bits and so on). There are eight words in the ball of radius 1 about each codeword: the codeword itself and the seven words that differ from the codeword in the first, second, third, fourth, fifth, sixth, and seventh bit respectively. There is no overlap between the different balls and every seven-bit word lies in one of the 16 balls, since, as we have noted before, for any seven-bit word there is a unique codeword that can be obtained by changing a single bit. A code for which every possible word lies in exactly one ball about a codeword is called a perfect code.
Perfect codes are quite rare. There is no perfect code with eight-bit words for example. We can see this just from counting. A ball of radius 1 about an eight-bit codeword must contain nine words, the codeword itself and the eight words that differ from the codeword in the first, second, third, fourth, fifth, sixth, seventh, and eighth bit respectively. But there are 28 = 256 possible eight-bit words, and you can't divide 256 words into balls of 9 words without any leftover, since 9 doesn't divide 256 evenly. This only shows that there are no perfect codes with eight bits using balls of radius 1, but you can similarly show there are no perfect codes with eight bits using balls of any radius. The numbers just won't work out right.
A code is cyclic if whenever a1a2a3a4a5a6a7
is a codeword, so is a7a1a2a3a4a5a6.
Note that it wouldn't change anything to replace a7a1a2a3a4a5a6
by a2a3a4a5a6a7a1.
One step in one direction is the same as taking six steps in the other
direction. The Hamming code as I have
presented it is cyclic. The 16 valid codewords of the Hamming code are 0000000 0010111 0001101 0101110 0011010 1011100 0110100 0111001 1101000 1110010 1010001 1100101 0100011 1001011 1000110 1111111 and you can easily check that the
code is cyclic. Many codes used in practice are
linear cyclic codes because they are easy to build and implement. They are easy
to build because they can be built in a more-or-less standard fashion from
polynomial rings over finite fields. We will build up to such structures by
first studying domains.
Even
if the numbers work out right, the geometry may not. Even when you put balls
together as tight as you can, there is still a little space between them. Just
because the numbers work out right doesn't mean you will be able to fit balls
together to get a perfect code with no word lost between the balls. These
questions lead to problems in high-dimensional geometry. For example, the
Hamming (7,4) code can be thought of as packing balls in 7 dimensional geometry,
since each word is specified by 7 coordinates - the 7 different bits. The codes
used for cross Atlantic phone calls in the 80's involved working with geometry
in space of more than 100 dimensions. If your students ever ask you if there
are any applications to geometry in more than 3 or 4 dimensions, you now have
an answer.