Documentation

CslibFrontier.Probability.BitString.CoinFlips

Fair coin flips #

Cslib.BitString.coinFlips is the probability measure on infinite bit tapes ℕ → Bool under which the bits are independent fair coins: the product MeasureTheory.Measure.infinitePi of uniform distributions on Bool. An event determined by the first N bits of the tape has probability equal to the fraction of the 2 ^ N words of length N that it contains (coinFlips_setOf_eq_card_mul); a word y : Fin N → Bool is read as a tape by padding it with false, as Function.extend Fin.val y fun _ => false. This reduces probabilistic statements about algorithms reading a bounded prefix of a random tape to counting words.

Main definitions #

Main results #

Independent fair coin flips: the product of uniform distributions on Bool.

Instances For
    def Cslib.BitString.prefixCylinder {N : ℕ} (y : Fin N → Bool) :
    Set (ℕ → Bool)

    The tapes beginning with the word y.

    theorem Cslib.BitString.mem_prefixCylinder {N : ℕ} {y : Fin N → Bool} {x : ℕ → Bool} :
    x ∈ prefixCylinder y ↔ ∀ (i : Fin N), x ↑i = y i
    theorem Cslib.BitString.prefixCylinder_eq_pi {N : ℕ} (y : Fin N → Bool) :
    prefixCylinder y = (↑(Finset.range N)).pi fun (i : ℕ) => {Function.extend Fin.val y (fun (x : ℕ) => false) i}

    A given word of length N begins the tape with probability 2⁻ᴺ.

    theorem Cslib.BitString.setOf_eq_biUnion_prefixCylinder {N : ℕ} {P : (ℕ → Bool) → Prop} [DecidablePred P] (hP : ∀ (x y : ℕ → Bool), (∀ i < N, x i = y i) → (P x ↔ P y)) :
    {x : ℕ → Bool | P x} = ⋃ y ∈ {y : Fin N → Bool | P (Function.extend Fin.val y fun (x : ℕ) => false)}, prefixCylinder y

    An event determined by the first N bits of the tape is the union of the cylinders of the words of length N in it.

    theorem Cslib.BitString.measurableSet_setOf_of_prefix {N : ℕ} {P : (ℕ → Bool) → Prop} (hP : ∀ (x y : ℕ → Bool), (∀ i < N, x i = y i) → (P x ↔ P y)) :

    An event determined by the first N bits of the tape is measurable.

    theorem Cslib.BitString.coinFlips_setOf_eq_card_mul {N : ℕ} {P : (ℕ → Bool) → Prop} [DecidablePred P] (hP : ∀ (x y : ℕ → Bool), (∀ i < N, x i = y i) → (P x ↔ P y)) :
    coinFlips {x : ℕ → Bool | P x} = ↑{y : Fin N → Bool | P (Function.extend Fin.val y fun (x : ℕ) => false)}.card * (2 ^ N)⁻¹

    The probability of an event determined by the first N bits of the tape is the fraction of the words of length N in it.