Discrete distribution generating trees #
A discrete distribution generating (DDG) tree reads independent fair bits and eventually commits to
an outcome. Following [KY76] and [CT06], Section 5.11, it is a possibly infinite
complete binary tree whose leaves carry outcomes. Here such a tree is presented by its prefix
labelling output : List Bool → Option α: output w = some a means that the walk along w has
reached a leaf labelled a, and none means it is still at an internal node. Leaves are absorbing.
Running on n fair bits gives run T n : PMF (Option α). run T n none is the probability
P(T > n) that more than n flips are needed. The output law is the monotone limit
outputProb T a = ⨆ n, run T n (some a). The expected number of flips is the tail sum
expectedFlips T = ∑ₙ P(T > n). expectedFlips_eq_tsum_mul identifies it with
∑ₖ (k + 1) P(T = k + 1) whenever the tree halts almost surely, as every tree generating a PMF
distribution does (tendsto_run_none_of_generates). expectedFlips_eq_top covers trees that
fail to halt with positive probability.
Main definitions #
Cslib.Probability.DDGTree: binary decision trees over fair bits with outcome-labelled leaves.Cslib.Probability.DDGTree.run: the outcome after readingnfair bits, ornone.Cslib.Probability.DDGTree.outputProb,.Generates: the distribution of the eventual output.Cslib.Probability.DDGTree.expectedFlips: the expected number of fair bits read.Cslib.Probability.DDGTree.ofCounts: a tree with a prescribed number of depth-kpositions lying at or below a leaf labelleda, for every depthkand outcomea.
Main results #
Cslib.Probability.DDGTree.run_ofCounts:ofCounts tstops with outcomeawithinnflips with probabilityt n a / 2 ^ n, provided the counts are inherited (2 * t k a ≤ t (k + 1) a) and fit the Kraft-type budget∑ₐ t k a ≤ 2 ^ k.Cslib.Probability.DDGTree.expectedFlips_eq_tsum_mul: tail-sum formula for the expected stopping time.Cslib.Probability.DDGTree.tendsto_run_none_of_generates: generators ofPMFdistributions halt almost surely.
References #
Probability that the tree eventually outputs a.
Expected number of fair bits read before a leaf is reached: the tail sum ∑ₙ P(T > n) of the
stopping time T. It is ⊤ when the tree fails to halt with positive probability.
The tail-sum formula #
For a tree that halts almost surely, expectedFlips is the expectation
∑ₖ (k + 1) P(T = k + 1) of the stopping time, where
P(T = k + 1) = P(T > k) - P(T > k + 1).
Realizing a depth profile #
A tree in which t k a of the 2 ^ k depth-k positions lie at or below a leaf labelled a,
provided t is inherited (2 * t k a ≤ t (k + 1) a) and fits the Kraft-type budget
∑ₐ t k a ≤ 2 ^ k (see run_ofCounts). A leaf at depth j ≤ k accounts for 2 ^ (k - j) of them,
so t k a / 2 ^ k is the probability of having output a within k flips. The depth-k positions
are ordered so that positions below leaves of depth < k come first, then the new leaves of depth
k, then the internal nodes.
If the counts are inherited along each level (2 * t k a ≤ t (k + 1) a: both children of a
position at or below an a-leaf are again such positions) and fit at every depth
(∑ₐ t k a ≤ 2 ^ k, a Kraft-type budget), then ofCounts t reaches a leaf labelled a within
n flips with probability exactly t n a / 2 ^ n.