Hamming Bound
Statement
A binary code can correct errors if distinct codewords have Hamming distance at least . The Hamming (sphere-packing) bound is
A code meeting this bound with equality is called perfect. The binary Hamming code corrects error and is perfect:
Visualization
The Hamming code generator matrix (systematic form):
G = [ 1 0 0 0 | 1 1 0 ]
[ 0 1 0 0 | 1 0 1 ]
[ 0 0 1 0 | 0 1 1 ]
[ 0 0 0 1 | 1 1 1 ]
Parity-check matrix (3 rows, 7 columns — columns are all nonzero 3-bit strings):
H = [ 1 0 1 0 1 0 1 ]
[ 0 1 1 0 0 1 1 ]
[ 0 0 0 1 1 1 1 ]
Sphere-packing count: 16 codewords, each surrounded by a Hamming ball of radius 1 containing binary strings. Total covered: . The balls partition all of — perfect packing.
Correcting a single error: if received word (flip of bit ), compute syndrome column of . That column gives the error position directly.
Proof Sketch
- For each codeword , define its Hamming ball . Each ball has size .
- The minimum distance implies balls around distinct codewords are disjoint.
- All balls are subsets of , which has elements.
- By disjointness: .
Connections
The Hamming bound is the coding-theory analogue of the Pigeonhole PrinciplePigeonhole PrincipleIf n+1 objects are placed into n boxes, some box contains at least two objectsRead more →: pack balls in a space, count elements. The parity-check matrix construction links to Rank-Nullity Theorem over .
Lean4 Proof
/-- Verify the Hamming bound for the [7,4,3] binary code:
16 codewords, t=1 errors, n=7 bits. -/
theorem hamming_bound_74 :
(16 : ℕ) * (Nat.choose 7 0 + Nat.choose 7 1) = 2 ^ 7 := by
native_decideReferenced by
- Singleton BoundInformation Theory