You're viewing the readable version of this site. The interactive extras (search, diagrams, read-aloud) need JavaScript and a current browser. Enable JavaScript; if it is already enabled, update your browser.

Learn · The Concrete Discrete Math of Real Systems

growing

Enough Distance Heals a Message

Add carefully chosen redundancy, measure how far a received word moved, and noise becomes a correctable geometric displacement.

·

discrete-math, hamming-distance, error-correction, coding-theory, learn

The author was led to the study given in this paper from a consideration of large scale computing machines.

Richard W. Hamming, “Error Detecting and Error Correcting Codes,” 1950

The previous chapter made a checksum from a remainder but left repair unexplained. Here you will treat bit strings as points; derive the exact minimum-distance conditions for detecting and correcting errors; build the Hamming (7,4)(7,4) syndrome locator; and distinguish promises that are often blurred in product claims.

Parity detects but cannot point

Append one bit so the total number of one-bits is even. Any single flipped bit changes parity, so the receiver detects it. But all bit positions produce the same complaint: “parity is odd.” The check provides one bit of evidence and cannot identify one of many locations.

To locate a single bad position among seven, the receiver needs at least three yes/no check outcomes, since three bits name 23=82^3=8 cases: no error plus seven possible positions. This is the pigeonhole principle returning as a design bound.

Three checks form an address

Number seven positions by the nonzero three-bit labels 001 through 111. Create three parity checks. The first covers positions whose first label bit is 1, the second those whose second bit is 1, and the third those whose third bit is 1.

If one transmitted bit flips, exactly the checks named by that position's label fail. Read the failed checks as a three-bit number—the syndrome—and it is the address of the damaged bit. Flip it back.

Four positions can carry data and three carry parity, producing the Hamming (7,4)(7,4) code. Every codeword has minimum distance 3: it corrects one error and detects two when used with the appropriate decoder. An additional overall parity bit yields the familiar extended SEC-DED profile: single-error correction, double-error detection.

Syndrome — the vector of parity-check failures. In a linear code it depends only on the error pattern, so decoding can use it to locate a correctable error without knowing the original message.

Completion — read the syndrome as a location.

The packing bound

There are 2n2^n binary words of length nn. A radius-tt ball contains

i=0t(ni) \sum_{i=0}^{t} \binom{n}{i}

words: choose which ii positions were changed. If a code has MM codewords and corrects tt errors, its disjoint balls must fit:

Mi=0t(ni)2n. M \sum_{i=0}^{t} \binom{n}{i} \le 2^n.

This Hamming bound says reliability consumes space. More codewords carry more information; wider separation corrects more damage. One cannot maximize both at fixed length.

Where the guarantee stops

  • Minimum distance states a worst-case bound, not a probability of failure. A channel model is needed for probabilities.
  • “Corrects one error” means per protected codeword, not per file or lifetime.
  • Plain Hamming (7,4)(7,4) cannot always distinguish two flips from one; SEC-DED requires the extended construction and a matching decoder.
  • Hashes, CRCs, and error-correcting codes have different aims. Detection against random corruption is not authentication against an adversary.

Lessons

  • Hamming distance turns corrupt messages into points in a metric space.
  • Minimum distance dd detects d1d-1 errors and corrects (d1)/2\lfloor(d-1)/2\rfloor.
  • A syndrome turns failed parity equations into the address of an error.
  • Redundancy is not waste; it is the geometric spacing that makes repair unambiguous.

Practice

  1. Compute the pairwise distances among 00000, 11100, and 00111. State the resulting detection and correction guarantees.
  2. Explain why repeating one bit twice detects a mismatch but cannot choose which copy is correct.
  3. Use the Hamming bound to test whether 32 length-7 binary codewords could all correct one error.
  4. One week later, reconstruct the correction radius by drawing two balls between codewords distance dd apart.

The next question is about memory

A decoder reads an input and chooses an output. But many systems cannot choose from the current input alone: whether a second 1 is alarming depends on whether the previous input was 1. The Boolean algebra from the opening chapter has acquired state. The next chapter reveals the machine that was hiding there all along.

References

  1. Hamming. “Error Detecting and Error Correcting Codes.” Bell System Technical Journal, 1950. — the primary paper introducing the geometric model and code construction
  2. Demaine and Devadas. “Error-Correcting Codes.” MIT 6.042J, 2010. — an accessible proof-oriented chapter
  3. Richard Wesley Hamming.” MacTutor. — institutional mathematical biography and bibliography