Four data bits go in; three parity bits are computed to form a seven-bit codeword. Corrupt any single bit in transit and the decoder's three-bit syndrome names exactly which bit flipped — then flips it back and hands the four data bits out, whole. Not detection: self-correction, live, over all 16×7 cases. The blue team builds it; the red team corrupts the decoder to break it.
source R. W. Hamming, Error Detecting and Error Correcting Codes, Bell System Technical Journal 29(2):147–160 (1950) — archive.org/details/bstj29-2-147. Rendered, not quoted.
Data bits d1 d2 d3 d4 sit at positions 3,5,6,7. Parity bits fill the powers of two — positions 1,2,4 — each covering the positions whose binary index carries its bit:
Live, for the current data word:
Each parity check is one row of the parity-check matrix H. The three checks over a received word give a 3-bit syndrome; read as a binary number it is the position of the flipped bit — Hamming's trick of placing parity at powers of two.
Shannon proved, the year before, that codes near the channel limit must exist — an existence theorem with no construction (the-entropy). Hamming, in the next office at Bell Labs, tired of weekend jobs killed by a single card error, built one you can watch correct itself.
Shannon says a code exists; Hamming hands you the code. Each sphere is the next one's premise — the proof of possibility folds into the proof by construction.
The blue team's live check: run the decoder over every one of the 16 data words with a clean channel and with each of the 7 single-bit flips — 128 cases — and confirm every one recovers the original data. If red corrupts H, this is where it shows.
The message is four bits: d1 d2 d3 d4 — 16 possible words. They are fed to the encoder, which appends three parity bits. Then a noisy channel may flip exactly one of the seven bits in transit; you choose which (or none).
A single flip is the whole design target: Hamming(7,4) has minimum distance 3 — it corrects one bit error and detects two. Feed the bits and pick a flip below.
The decoder computes the syndrome from H, locates the error, flips that bit back, and reads out the four data bits — all on the spot, never looked up.
What the machine produces, proven: the four data bits, recovered exactly. The current run's result: —. Across the whole space — every one of the 16 data words under a clean channel and under each of the 7 single-bit flips, 128 cases — the decoder returns the original data every time.
The blue team's witness (left) confirms all 128 live; the red team (right) corrupts H to make some of them wrong.
And the rate is only 4/7 ≈ 0.57 — far from Shannon's limit. Modern codes (Reed–Solomon, LDPC, turbo) correct bursts and approach capacity, leaving Hamming to textbooks, ECC-cache lines, and this window. It is the first correcting code, not the best.
"A Hamming code can correct any error." Cut. Only a single bit. A double error is silently mis-corrected — the engine's own tamper demonstrates exactly this kind of mis-location.
"Hamming(7,4) corrects one error and detects two." Cut. Not both at once. Detecting a double error needs an extra overall parity bit — the SECDED extension, Hamming(8,4). Plain (7,4) that meets a double error mis-corrects it.
"The parity bits can go anywhere." Kept, corrected. They can — but only at positions 1,2,4 does the syndrome come out equal to the error's index. That placement is the elegance, not a convenience.
The red team's move: corrupt one row of the decoder's parity-check matrix H — drop position 7 from the top check. Now position 7's column collides with position 3's, so a flip at bit 7 is mis-located to bit 3 and the wrong bit is "corrected." The witness (window 7) is watching.
Corrupt the row and bit-7 flips (and the collisions they cause) decode to the wrong data word — the witness recomputes all 128 cases, finds 48 broken, and turns red. Nothing is faked; the mis-correction is real and it is caught.