Documentation

CslibFrontier.MachineLearning.Replicable.Rounding

Randomized-threshold rounding rules #

This module formalizes the randomized-threshold and periodic grid rounding primitives from Impagliazzo–Lei–Pitassi–Sorrell [ILPS22]:

Main definitions #

Main results #

References #

noncomputable def Cslib.MachineLearning.Replicable.thresholdValue (a b : ℝ) (N : ℕ) (i : Fin N) :

Grid threshold at index i : Fin N partitioning [a, b).

noncomputable def Cslib.MachineLearning.Replicable.thresholdRound (a b : ℝ) (N : ℕ) (i : Fin N) (x : ℝ) :

Randomized-threshold boolean rounding on [a, b) using shared discrete seed i : Fin N.

noncomputable def Cslib.MachineLearning.Replicable.thresholdProg {X : Type} {m : ℕ} (a b : ℝ) (N : ℕ) [NeZero N] (est : (Fin m → X) → ℝ) :
Program X (Fin N) Bool m

ProbComp-backed ideal real-arithmetic threshold-rounding Program applied to a real estimator est (interpreted via Program.toAlgorithm).

noncomputable def Cslib.MachineLearning.Replicable.roundGridBin (w : ℝ) (N : ℕ) (i : Fin N) (x : ℝ) :

Periodic grid bin index of x with grid width w and discrete random phase i : Fin N.

noncomputable def Cslib.MachineLearning.Replicable.roundGrid (w : ℝ) (N : ℕ) (i : Fin N) (x : ℝ) :

Periodic randomized grid rounding: snaps x to the midpoint of its shifted w-bin.

noncomputable def Cslib.MachineLearning.Replicable.roundGridProg {X : Type} {m : ℕ} (w : ℝ) (N : ℕ) [NeZero N] (est : (Fin m → X) → ℝ) :
Program X (Fin N) ℝ m

ProbComp-backed ideal real-arithmetic periodic grid-rounding Program applied to a real estimator est (interpreted via Program.toAlgorithm).

Continuous randomized-threshold boolean rounding on [a, b] using u ∈ [0, 1).

Continuous periodic grid bin index with width w and shift u ∈ [0, 1).

Continuous periodic grid rounding with width w and shift u ∈ [0, 1).

theorem Cslib.MachineLearning.Replicable.thresholdRound_false_of_lt_left {a b : ℝ} (hab : a ≤ b) {N : ℕ} (i : Fin N) {x : ℝ} (hx : x < a) :
theorem Cslib.MachineLearning.Replicable.thresholdRound_true_of_right_le {a b : ℝ} (hab : a ≤ b) {N : ℕ} (i : Fin N) {x : ℝ} (hx : b ≤ x) :
theorem Cslib.MachineLearning.Replicable.abs_roundGrid_sub_le {w : ℝ} (hw : 0 < w) (N : ℕ) (i : Fin N) (x : ℝ) :
|roundGrid w N i x - x| ≤ w / 2

Deterministic discretization error of roundGrid: always within w / 2 of x.

Deterministic discretization error of continuousRoundGrid: always within w / 2 of x.

theorem Cslib.MachineLearning.Replicable.thresholdRound_disagree_le {a b : ℝ} (hab : a < b) {N : ℕ} [NeZero N] (x₁ x₂ : ℝ) :
((Probability.PMF.uniformOfFintype (Fin N)).toOuterMeasure {i : Fin N | thresholdRound a b N i x₁ ≠ thresholdRound a b N i x₂}).toReal ≤ |x₁ - x₂| / (b - a) + 1 / ↑N

Discrete randomized-threshold rounding lemma [ILPS22]: for any a < b and [NeZero N], two real numbers x₁, x₂ thresholded against a shared uniform seed i : Fin N on [a, b) disagree with probability at most |x₁ - x₂| / (b - a) + 1 / N.

theorem Cslib.MachineLearning.Replicable.roundGrid_disagree_le {w : ℝ} (hw : 0 < w) {N : ℕ} [NeZero N] (x₁ x₂ : ℝ) :
((Probability.PMF.uniformOfFintype (Fin N)).toOuterMeasure {i : Fin N | roundGrid w N i x₁ ≠ roundGrid w N i x₂}).toReal ≤ |x₁ - x₂| / w + 1 / ↑N

Periodic grid rounding lemma [ILPS22]: for any w > 0 and [NeZero N], two real numbers x₁, x₂ fall into different bins of roundGrid w N under a uniform shared seed i : Fin N with probability at most |x₁ - x₂| / w + 1 / N.

Continuous randomized-threshold rounding lemma: for a < b and u ~ Uniform([0, 1)), the disagreement measure is at most |x₁ - x₂| / (b - a).

Continuous periodic grid rounding lemma: for w > 0 and u ~ Uniform([0, 1)), the disagreement measure of continuousRoundGrid w u is at most |x₁ - x₂| / w.

theorem Cslib.MachineLearning.Replicable.isAccurateFor_roundGridProg_of_concentrates {X : Type} {m : ℕ} {w δ β : ℝ} (hw : 0 < w) (N : ℕ) [NeZero N] (est : (Fin m → X) → ℝ) (𝒟 : Set (PMF X)) (target : PMF X → ℝ) (hconc : ∀ D ∈ 𝒟, ((Probability.PMF.iid D m).toOuterMeasure {S : Fin m → X | δ < |est S - target D|}).toReal ≤ β) :
EstimatesFor (roundGridProg w N est).toAlgorithm 𝒟 target (w / 2 + δ) β

Accuracy of roundGridProg: whenever est S is within δ of target D except with probability β, rounding to a periodic grid of width w preserves estimation within w / 2 + δ with the same failure probability β.

theorem Cslib.MachineLearning.Replicable.isReplicableFor_roundGridProg_of_concentrates {X : Type} {m : ℕ} {w δ β : ℝ} (hw : 0 < w) (N : ℕ) [NeZero N] (est : (Fin m → X) → ℝ) (𝒟 : Set (PMF X)) (target : PMF X → ℝ) (hδ : 0 ≤ δ) (hβ : 0 ≤ β) (hconc : ∀ D ∈ 𝒟, ((Probability.PMF.iid D m).toOuterMeasure {S : Fin m → X | δ < |est S - target D|}).toReal ≤ β) :
IsReplicableFor (roundGridProg w N est).toAlgorithm 𝒟 (2 * δ / w + 1 / ↑N + 2 * β)

Replicability of roundGridProg: if est S concentrates within δ of target D except with probability β for every D ∈ 𝒟, then roundGridProg w N est is (2 * δ / w + 1 / N + 2 * β)-replicable over 𝒟.