Sampling finite choices with a fixed supply of fair bits
Lax253009.FreshBitSampling · concepts/Lax253009/FreshBitSampling.lean · lax-253009
No public endorsements yet.
Loading review…
Sign in with ORCIDNatural Language Statement
Theorem
To sample choices from possibilities, use independent bits per choice and reduce the binary integer modulo . This always returns a choice and uses exactly bits. Its effect on the probability of any event is at most . Thus the graph reduction's error becomes at most , while perfect completeness is unchanged.
The sampler uses explicit binary interpretation and natural-number remainder. The probability theorem does not certify its running time on the registered probabilistic Turing-machine model.
Concept map
Evidence
Lean source view on GitHub
| 1 | import Lax253009.FiniteProbability |
| 2 | import Mathlib.Algebra.BigOperators.Fin |
| 3 | import Mathlib.Data.Nat.Log |
| 4 | |
| 5 | /-! |
| 6 | --- |
| 7 | title: Sampling finite choices with a fixed supply of fair bits |
| 8 | type: theorem |
| 9 | --- |
| 10 | To sample choices from possibilities, use |
| 11 | independent bits per choice and reduce the |
| 12 | binary integer modulo . This always returns a choice and uses exactly |
| 13 | bits. Its effect on the probability of any event is at most . |
| 14 | Thus the graph reduction's error becomes at most , while perfect |
| 15 | completeness is unchanged. |
| 16 | |
| 17 | The sampler uses explicit binary interpretation and natural-number |
| 18 | remainder. The probability theorem does not certify its running time on |
| 19 | the registered probabilistic Turing-machine model. |
| 20 | -/ |
| 21 | |
| 22 | namespace Lax253009.FreshBitSampling |
| 23 | |
| 24 | open FiniteProbability |
| 25 | |
| 26 | def modulo {N r B : ℕ} (hr : 0 < r) (z : Fin N → Fin B) : Fin N → Fin r := |
| 27 | fun i ↦ ⟨(z i).val % r, Nat.mod_lt _ hr⟩ |
| 28 | |
| 29 | def bitsPerDraw (N r : ℕ) : ℕ := Nat.clog 2 (12 * N * r) |
| 30 | |
| 31 | def binaryEquiv (b : ℕ) : (Fin b → Bool) ≃ Fin (2 ^ b) := |
| 32 | (Equiv.piCongrRight (fun _ ↦ finTwoEquiv.symm)).trans finFunctionFinEquiv |
| 33 | |
| 34 | def sample {N r : ℕ} (hr : 0 < r) |
| 35 | (z : Fin N → Fin (bitsPerDraw N r) → Bool) : Fin N → Fin r := |
| 36 | modulo hr (fun i ↦ binaryEquiv (bitsPerDraw N r) (z i)) |
| 37 | |
| 38 | def coinEquiv (N b : ℕ) : (Fin (N * b) → Bool) ≃ (Fin N → Fin b → Bool) := |
| 39 | (Equiv.arrowCongr finProdFinEquiv.symm (Equiv.refl Bool)).trans (Equiv.curry _ _ _) |
| 40 | |
| 41 | def sampleFlat {N r : ℕ} (hr : 0 < r) |
| 42 | (coins : Fin (N * bitsPerDraw N r) → Bool) : Fin N → Fin r := |
| 43 | sample hr (coinEquiv N (bitsPerDraw N r) coins) |
| 44 | |
| 45 | axiom modulo_error {N r B : ℕ} (hr : 0 < r) (hB : 0 < B) |
| 46 | (P : (Fin N → Fin r) → Prop) : |
| 47 | probability (fun z : Fin N → Fin B ↦ P (modulo hr z)) ≤ |
| 48 | probability P + (N : ℝ) * r / B |
| 49 | |
| 50 | axiom sampling_error {N r : ℕ} (hN : 0 < N) (hr : 0 < r) |
| 51 | (P : (Fin N → Fin r) → Prop) : |
| 52 | probability (fun z : Fin N → Fin (bitsPerDraw N r) → Bool ↦ P (sample hr z)) ≤ |
| 53 | probability P + 1 / 12 |
| 54 | |
| 55 | axiom one_third_error {N r : ℕ} (hN : 0 < N) (hr : 0 < r) |
| 56 | (P : (Fin N → Fin r) → Prop) (hP : probability P ≤ 1 / 4) : |
| 57 | probability (fun z : Fin N → Fin (bitsPerDraw N r) → Bool ↦ P (sample hr z)) ≤ 1 / 3 |
| 58 | |
| 59 | axiom flat_one_third_error {N r : ℕ} (hN : 0 < N) (hr : 0 < r) |
| 60 | (P : (Fin N → Fin r) → Prop) (hP : probability P ≤ 1 / 4) : |
| 61 | probability (fun coins : Fin (N * bitsPerDraw N r) → Bool ↦ P (sampleFlat hr coins)) ≤ 1 / 3 |
| 62 | |
| 63 | axiom repeated_seed_bit_bound (N r k : ℕ) : |
| 64 | bitsPerDraw N (r ^ k) ≤ Nat.clog 2 (12 * N) + k * Nat.clog 2 r |
| 65 | |
| 66 | end Lax253009.FreshBitSampling |
| 67 |
Builds on
Discussion
Ask a question or add context. Endorsements and structured flags are kept in the review panel above.
0 comments