Hamming weight and binary Hamming balls #
The weight of a Boolean vector is its number of true coordinates (BitString.weight), Mathlib's
Hamming norm with false as 0 (BitString.weight_eq_hammingNorm), so the Hamming distance of two
bit strings is the weight of their sum (BitString.hammingDist_eq_weight_add)
MacWilliams and Sloane, Chapter 1. For x : BitString n, the weight is the
number of true entries of List.ofFn x (BitString.count_true_ofFn) and is at most n
(BitString.weight_le_length). The words of weight k in BitString n form the k-th layer of
the cube (BitString.weightLayer), of size n.choose k (BitString.card_weightLayer), and the
words of weight at most e form a Hamming ball of size B(n, e) = ∑ j ∈ range (e + 1), n.choose j
(BitString.ballSize, BitString.card_filter_weight_le,
BitString.card_filter_weight_le_eq_ballSize).
Main definitions #
Cslib.BitString.weight: the number of true coordinates.Cslib.BitString.weightLayer: the strings ofnbits of a given weight.Cslib.BitString.ballSize: the size∑ j ∈ range (e + 1), q.choose jof the binary Hamming ball of radiuseinBitString q.
Main results #
Cslib.BitString.weight_eq_hammingNorm,Cslib.BitString.hammingDist_eq_weight_add: the weight is the Hamming norm.Cslib.BitString.weight_le,Cslib.BitString.weight_le_length: the weight is at most the number of coordinates.Cslib.BitString.count_true_ofFn:(List.ofFn x).count true = weight x.Cslib.BitString.monotone_weight: the weight is monotone.Cslib.BitString.card_weightLayer: there aren.choose kstrings ofnbits of weightk.Cslib.BitString.card_filter_weight_le,Cslib.BitString.card_filter_weight_le_eq_ballSize: the exact binomial-sum size of a Hamming ball.Cslib.BitString.ballSize_succ_succ: Pascal recurrence for Hamming-ball sizes.Cslib.BitString.card_image_le_sum_choose: bound a finite family of words by a Hamming ball.
References #
- [F. J. MacWilliams, N. J. A. Sloane, The Theory of Error-Correcting Codes] [MWS77]
The weight is Mathlib's Hamming norm, the bit false being 0.
The Hamming distance between two bit strings is the weight of their sum.
The weight is at most the number of coordinates.
The number of true entries in List.ofFn x is the weight of x.
Setting a false coordinate to true adds one to the weight.
Setting a true coordinate to false takes one from the weight.
The words ι → Bool of weight r number |ι|.choose r: they are the indicators of the
r-element sets of coordinates.
The words of weight at most e form a Hamming ball with the exact binomial-sum size.
The radius may exceed the number of coordinates.
Size B(q, e) = ∑ j ∈ range (e + 1), q.choose j of the Hamming ball of radius e in
{0, 1}^q.
Instances For
The Hamming ball of any radius in the cube of dimension 0 has one point.
The Hamming ball of radius 0 has one point.
A finite family of words of weight at most e attains at most the Hamming-ball size.
The map need not be injective, and the radius may exceed the number of coordinates.
The layer of weight k of the cube: the strings of n bits with k true bits.
Instances For
A string lies in the layer of weight k exactly when its weight is k.
The layer of weight k has n.choose k strings.
The layer of weight k of the cube of n bits is nonempty when k ≤ n.