Documentation

CslibFrontier.Languages.Probabilistic.Plurality

Plurality amplification for probabilistic computations #

For a list xs : List α over a type with decidable equality, Cslib.ProbComp.plurality default xs returns the element of xs occurring most frequently (breaking ties in favor of the first element in xs achieving the maximum frequency, and returning default on []). Whenever an element a appears strictly more than xs.length / 2 times, plurality default xs = a (Cslib.ProbComp.plurality_eq_of_length_lt_two_mul_count), because any two distinct elements appear at most xs.length times in total (Cslib.ProbComp.count_add_count_le_length_of_ne).

By Hoeffding's inequality (Cslib.Probability.PMF.pi_sum_le_mean_sub), if a probabilistic computation program : ProbComp α outputs a with probability at least 1 / 2 + γ (0 ≤ γ), then the plurality of k independent runs differs from a with probability at most exp (-2 * k * γ²) (Cslib.ProbComp.toOuterMeasure_plurality_replicate_ne_toReal_le), and therefore outputs a with probability at least 1 - exp (-2 * k * γ²) ≥ 1 - 2^{-(2 * γ² * k)} (Cslib.ProbComp.one_sub_exp_le_eval_plurality_replicate_toReal, Cslib.ProbComp.one_sub_two_rpow_le_eval_plurality_replicate_toReal).

Main definitions #

Main results #

def Cslib.ProbComp.plurality {α : Type u_1} [DecidableEq α] (default : α) (xs : List α) :
α

The most frequent element of xs, breaking ties in favor of the earliest element of xs achieving the maximum frequency, or default when xs is empty.

theorem Cslib.ProbComp.count_add_count_le_length_of_ne {α : Type u_1} [DecidableEq α] (xs : List α) {a b : α} (hab : a ≠ b) :

Two distinct elements appear at most xs.length times in total.

theorem Cslib.ProbComp.plurality_eq_of_length_lt_two_mul_count {α : Type u_1} [DecidableEq α] (default : α) {xs : List α} {a : α} (h : xs.length < 2 * List.count a xs) :
plurality default xs = a

Whenever a appears strictly more than half the time in xs, plurality default xs = a.

theorem Cslib.ProbComp.toOuterMeasure_plurality_replicate_ne_toReal_le {α : Type} [DecidableEq α] (default a : α) (k : ℕ) (program : ProbComp α) {γ : ℝ} (hγ : 0 ≤ γ) (hp : 1 / 2 + γ ≤ (program.eval a).toReal) :
((plurality default <$> OracleComp.replicate k program).eval.toOuterMeasure {y : α | y ≠ a}).toReal ≤ Real.exp (-2 * ↑k * γ ^ 2)

Plurality concentration for k independent trials. If a closed probabilistic program program : ProbComp α outputs a with probability at least 1 / 2 + γ (for 0 ≤ γ), then the plurality of k independent runs differs from a with probability at most exp (-2 * k * γ²).

theorem Cslib.ProbComp.one_sub_exp_le_eval_plurality_replicate_toReal {α : Type} [DecidableEq α] (default a : α) (k : ℕ) (program : ProbComp α) {γ : ℝ} (hγ : 0 ≤ γ) (hp : 1 / 2 + γ ≤ (program.eval a).toReal) :
1 - Real.exp (-2 * ↑k * γ ^ 2) ≤ ((plurality default <$> OracleComp.replicate k program).eval a).toReal

Plurality success probability for k independent trials. If program outputs a with probability at least 1 / 2 + γ (0 ≤ γ), then the plurality of k independent runs outputs a with probability at least 1 - exp (-2 * k * γ²) ≥ 1 - 2^{-(2 * γ² * k)}.

theorem Cslib.ProbComp.one_sub_two_rpow_le_eval_plurality_replicate_toReal {α : Type} [DecidableEq α] (default a : α) (k : ℕ) (program : ProbComp α) {γ : ℝ} (hγ : 0 ≤ γ) (hp : 1 / 2 + γ ≤ (program.eval a).toReal) :
1 - 2 ^ (-(2 * γ ^ 2 * ↑k)) ≤ ((plurality default <$> OracleComp.replicate k program).eval a).toReal

Base-2 exponential form of one_sub_exp_le_eval_plurality_replicate_toReal.