Coin-reading trees on biased coins, and von Neumann's fair bit #
A Cslib.Probability.DDGTree is a possibly infinite absorbing prefix labelling: it reads coin
flips one at a time and commits to an outcome when it reaches a leaf. DDGTree.run reads fair
bits. This file runs the same trees on independent flips of a coin with an arbitrary law
c : PMF Bool. runWith c n T is the outcome after n flips, or none if more are needed. The
output law outputProbWith is its monotone limit, and expectedCostWith c w T = ∑ₙ w n P(T > n)
is the expected total cost when reading flip number n + 1 (index n) costs w n. With unit
weights it is the expected number of flips, expectedFlipsWith. For the fair coin all of these
agree with the fair-bit API (run_eq_runWith, outputProb_eq_outputProbWith,
expectedFlips_eq_expectedFlipsWith).
Such trees are the exact model of a sampler that loops until it stops. A program in
Cslib.OracleComp is a finite tree of calls, so it can express only a truncation of such a loop
(Cslib.OracleComp.retry), whose failure outcome is visible.
Von Neumann's extractor reads flips in pairs, outputs the first flip of the first unequal pair and
discards equal pairs. On independent flips of a coin of bias 0 < ρ < 1 it outputs an exactly
fair bit, with exactly 1 / (ρ (1 - ρ)) expected flips ([Arora and Barak, Lemma 7.15]).
The hypothesis 0 < ρ < 1 is necessary: a coin of bias 0 or 1 is deterministic, so a tree
reading it yields every outcome with probability 0 or 1, and no tree outputs a fair bit
(exists_generatesWith_coin_iff).
Main definitions #
Cslib.Probability.DDGTree.runWith,.outputProbWith,.GeneratesWith: running a tree on independent flips of a coin with lawc, and its output law.Cslib.Probability.DDGTree.expectedCostWith,.expectedFlipsWith: expected weighted and plain number of flips.Cslib.Probability.DDGTree.vonNeumann: von Neumann's repeat-until-different tree.
Main results #
Cslib.Probability.DDGTree.run_eq_runWith: the fair-bit run is the run on the fair coin.Cslib.Probability.DDGTree.runWith_pure: on a deterministic coin the tree is deterministic.Cslib.Probability.DDGTree.vonNeumann_generatesWith_coin: von Neumann's tree outputs a fair bit from a coin of bias0 < ρ < 1.Cslib.Probability.DDGTree.expectedFlipsWith_coin_vonNeumann: it reads exactly1 / (ρ (1 - ρ))flips in expectation.Cslib.Probability.DDGTree.exists_generatesWith_coin_iff: some tree outputs a fair bit from a coin of biasρexactly when0 < ρ < 1.
References #
- S. Arora, B. Barak, Computational Complexity: A Modern Approach, Lemma 7.15 (2007 draft numbering).
Running on a biased coin #
Fair bits are flips of the fair coin.
A finite expected number of flips forces the tree to halt almost surely.
Deterministic coins #
On a deterministic coin every outcome has probability 0 or 1.
A deterministic coin cannot produce a fair bit.
Von Neumann's extractor #
Von Neumann's repeat-until-different extractor.
Two more flips: an unequal pair stops with its first flip, an equal pair restarts.
Both outcomes are equally likely after any number of flips.
Von Neumann extraction, cost ([Arora and Barak, Lemma 7.15]): on a coin of bias
0 < ρ < 1 the loop reads exactly 1 / (ρ (1 - ρ)) flips in expectation.
Von Neumann extraction ([Arora and Barak, Lemma 7.15]): from independent flips of a coin
of bias 0 < ρ < 1 the repeat-until-different loop outputs an exactly fair bit.
The hypothesis 0 < ρ < 1 of von Neumann extraction is necessary and sufficient: some
coin-reading tree outputs an exactly fair bit from independent flips of a coin of bias ρ exactly
when 0 < ρ < 1.