Documentation

CslibFrontier.Computability.Complexity.Classes.AverageCase.Collapse

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 #

Main results #

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.

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.

theorem Cslib.Complexity.HeaderParser.lo_eq_of_header_eq (H : HeaderParser) {r r' : List Bool} (hh : H.header r' = H.header r) (hlen : r'.length = r.length) :
H.lo r' = H.lo r
theorem Cslib.Complexity.HeaderParser.hi_eq_of_header_eq (H : HeaderParser) {r r' : List Bool} (hh : H.header r' = H.header r) (hlen : r'.length = r.length) :
H.hi r' = H.hi r

A valid word lies in the block of its header.

theorem Cslib.Complexity.HeaderParser.valid_of_mem_block (H : HeaderParser) {r r' : List Bool} (hv : H.valid r = true) (hlen : r'.length = r.length) (h1 : H.lo r ≤ BitString.binaryValue r') (h2 : BitString.binaryValue r' < H.hi r) :
H.valid r' = true ∧ H.header r' = H.header r

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 cumulative distribution of the collapsed ensemble is the dyadic rational cdfNum y / 2^{|y|}.

Point masses #

A padded header has probability 2^{-|h|} under the collapsed ensemble.