Collapsing the uniform ensemble at a prefix code #
A header parser recognizes, in polynomial time, words that begin with a header: a word from a
prefix-free code that is recognized from any of its extensions. Flipping uniform bits until either
a header has been read or N bits have been flipped, and in the former case padding the header
with ones to length N, gives the distribution Cslib.Complexity.HeaderParser.ensemble. This is
how Bogdanov and Trevisan, §3.2 define the "uniform" ensemble U^BH of
instances of the bounded halting problem; this module develops the construction for an arbitrary
header parser.
The collapse map is monotone in the numeric order of words of each length, and it maps the block of
words with a given header to the top word of that block. Its cumulative distribution is therefore
an exact dyadic rational with a polynomial-time numerator
(Cslib.Complexity.HeaderParser.cdf_ensemble), so the collapsed ensemble is polynomial-time
computable, and a padded header h has probability exactly 2^{-|h|}.
Main definitions #
Cslib.Complexity.HeaderParser: a polynomial-time recognizer of a prefix-free code of headers.Cslib.Complexity.HeaderParser.collapse: pad the header of a word with ones.Cslib.Complexity.HeaderParser.ensemble: the image of the uniform ensemble under collapsing.
Main results #
Cslib.Complexity.HeaderParser.binaryValue_collapse_le_iff: the collapse map is monotone, with explicit thresholdsCslib.Complexity.HeaderParser.cdfNum.Cslib.Complexity.HeaderParser.cdf_ensemble: the cumulative distribution iscdfNum y / 2^{|y|}.Cslib.Complexity.HeaderParser.pComp_ensemble: the collapsed ensemble is polynomial-time computable.Cslib.Complexity.HeaderParser.ensemble_dist_collapse: a padded headerhhas probability2^{-|h|}.
References #
A header parser: a test valid for the words that begin with a header and the header
header r of such a word, a prefix of r that is recognized, as the same header, from every word
extending it. The headers thus form a prefix-free code.
Whether the word begins with a header.
The header at the start of the word, when
validholds.The header of a valid word is a prefix of it.
- valid_of_isPrefix (r r' : List Bool) : self.valid r = true → self.header r <+: r' → self.valid r' = true ∧ self.header r' = self.header r
A header is recognized from every word extending it.
Replace everything after the header of r by ones (r itself if it has no header).
The image under collapse of the uniform ensemble: flip uniform bits until a header has been
read, then pad the header with ones.
The block of a header #
The least value of a word of length |r| with the header of r.
One more than the greatest value of a word of length |r| with the header of r.
A valid word lies in the block of its header.
A word of the same length in the block of the header of r has that header.
A collapsed valid word is the top word of its block.
Two words of the same length collapse to the same word as a valid r exactly when they lie in
its block.
The cumulative distribution #
The numerator of the cumulative distribution of the collapsed ensemble at y: one more than the
value of y if y is a collapsed word, and otherwise the bottom of the block of y.
Monotonicity of collapsing. A word r of the length of y collapses to a word of value at
most that of y exactly when the value of r is below cdfNum y.
The collapsed ensemble is polynomial-time computable when the header parser is.