Uniform binary strings #
Uniform sampling from Fin n → Bool, represented as a list. The recursive equations connect
this finite uniform distribution to a program drawing one independent fair bit at a time.
Main definitions #
Cslib.BitString.uniformList: uniform fixed-length words represented as lists.
Main results #
Cslib.BitString.uniformList_succ,Cslib.BitString.uniformList_add: independent decomposition.Cslib.BitString.mem_support_uniformList_iff: support is exactly the requested length.Cslib.BitString.uniformList_map_of_bijective: length-preserving permutations preserve uniformity.Cslib.BitString.uniformList_map_apply,Cslib.BitString.toOuterMeasure_map_uniformList_toReal: the probability of a value or event under a map of a uniform word is the fraction of words of that length mapping into it.Cslib.BitString.uniformList_apply_le,Cslib.BitString.toOuterMeasure_uniformList_finset_le,Cslib.BitString.toOuterMeasure_lookup_uniformList_le: point-mass bound1 / 2 ^ n, finite-set union bounds.card * (1 / 2 ^ n), and finite-cache lookup union boundcache.length * (1 / 2 ^ n)foruniformList n.
References #
Adapted from Cslib/Probability/BitString.lean on the cslib crypto branch at
5ff69ca93402e7c947208dc56396d6d86203ccd8, placed in the shared bit-string namespace.
The uniform distribution on words of 0 bits is the point mass at the empty word.
A uniform nonempty string consists of a fair first bit and an independent uniform tail.
Concatenating independent uniform words gives a uniform word of the combined length.
Appending one independent fair bit gives a uniform word one bit longer.
Every sampled word has exactly the requested length.
Splitting a uniform tape gives two independent tapes, also when either length is zero.
A prefix of a uniform word is uniform, with no condition on the discarded suffix.
A length-preserving permutation sends a uniform word to a uniform word of the same length. This is a distributional fact and makes no assumption about computing the inverse.
The probability of a value of a function of a uniform word is the fraction of the words of that length giving it.
Every candidate word r has probability at most 1 / 2 ^ n under uniformList n.
Union bound on finite candidate sets: a uniform n-bit word lands in a finite set s with
outer measure at most s.card * (1 / 2 ^ n).