Hamming weight and symmetric Boolean functions #
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. The threshold function
threshold n j says that at least j of n bits are true, and majority (majority, at least
half) and strict majority (strictMajority, more than half) are threshold functions. A Boolean
function is symmetric when it depends only on the weight of its input
(BooleanFunction.IsSymmetric), and then it factors through the weight
(BooleanFunction.IsSymmetric.exists_eq_comp_weight) Jukna, Chapter 1.
Main definitions #
Cslib.BitString.weight: the number of true coordinates, andCslib.BitString.weightLayerthe strings of a given weight.Cslib.threshold,Cslib.majority,Cslib.strictMajority: threshold functions.Cslib.BooleanFunction.IsSymmetric: Boolean functions depending only on the weight.
Main results #
Cslib.BitString.weight_eq_hammingNorm,Cslib.BitString.hammingDist_eq_weight_add: the weight is the Hamming norm.Cslib.BitString.monotone_weight,Cslib.monotone_threshold: the weight and threshold functions are monotone.Cslib.BitString.card_weightLayer: there aren.choose kstrings ofnbits of weightk.Cslib.BitString.card_filter_weight_le: the exact binomial-sum size of a Hamming ball.Cslib.BitString.card_image_le_sum_choose: bound a finite family of words by a Hamming ball.Cslib.strictMajority_not: strict majority of the negated bits is the negation of majority.Cslib.BitString.strictMajorityOn: strict majority on a finite set of voting indices.Cslib.le_card_ne_of_strictMajority_ne: a wrong majority requires at least half wrong votes.Cslib.isSymmetric_threshold: threshold functions are symmetric.
References #
- [F. J. MacWilliams, N. J. A. Sloane, The Theory of Error-Correcting Codes] [MWS77]
- S. Jukna, Boolean Function Complexity: Advances and Frontiers
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.
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.
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.
A nonempty constant vote has its constant value.
The threshold function Th^n_j on n bits: whether at least j of them are true.
Instances For
The majority function on n bits: whether at least half of them are true, that is, the
threshold function Th^n_⌈n/2⌉.
Instances For
The strict majority function on n bits: whether more than half of them are true, so that a
tie is false. It is the threshold function Th^n_{⌊n/2⌋+1}.
Instances For
The threshold function Th^n_j is true exactly when at least j bits are true.
Strict majority is true exactly when more than n / 2 bits are true.
Strict majority is false exactly when at most n / 2 bits are true.
Strict majority on all coordinates agrees with the finite-set operation.
Strict majority of the negated bits is the negation of majority: fewer than half of the bits are true exactly when not at least half of them are.
A Boolean function is symmetric when it depends only on the weight of its input.
Instances For
A symmetric function factors through the weight.
Threshold functions are symmetric.
Strict majority is symmetric.