Documentation

CslibFrontier.Privacy.DifferentialPrivacy.RandomizedResponse

Randomized response #

Randomized response [DworkRoth2014, §3.2] is a survey protocol for a yes/no question. The respondent flips a coin. On tails they answer truthfully; on heads they flip a second coin and answer "Yes" on heads and "No" on tails. randomizedResponse truth is this protocol as a ProbComp Bool program over fair coins, with true for "Yes" and for a truthful answer. The privacy statements apply DifferentiallyPrivate to its output law ProbComp.eval (randomizedResponse truth): the protocol is a finite program, and only its semantics is a PMF.

The answer agrees with the truth with probability 3/4 (eval_randomizedResponse_apply), so randomized response is (ln 3, 0)-differentially private for a single respondent (differentiallyPrivate_randomizedResponse) [DworkRoth2014, Claim 3.5], and ln 3 is optimal (differentiallyPrivate_randomizedResponse_iff).

randomizedResponseSurvey x lets each of n respondents answer independently. It is (ln 3, 0)-private for Hamming adjacency (differentiallyPrivate_randomizedResponseSurvey). The expected number of "Yes" answers is n / 4 + (number of true "Yes") / 2 (sum_eval_randomizedResponseSurvey_mul_card), so twice the fraction of "Yes" answers minus 1/2 is an unbiased estimator of the true fraction (sum_eval_randomizedResponseSurvey_mul_estimator) [DworkRoth2014, §2.3].

Main definitions #

Main results #

References #

noncomputable def Cslib.Privacy.randomizedResponse (truth : Bool) :

Randomized response [DworkRoth2014, §3.2]: flip a coin; on tails (truthful = true) answer truthfully, and on heads answer with a second fair coin.

theorem Cslib.Privacy.eval_randomizedResponse_apply (truth answer : Bool) :
(randomizedResponse truth).eval answer = if answer = truth then 3 / 4 else 1 / 4

Randomized response agrees with the truth with probability 3/4.

Randomized response is (ln 3, 0)-differentially private for a single respondent, whose datum may change arbitrarily [DworkRoth2014, Claim 3.5].

ln 3 is optimal: randomized response is (ε, 0)-differentially private exactly when ln 3 ≤ ε.

noncomputable def Cslib.Privacy.randomizedResponseSurvey {n : ℕ} (x : Fin n → Bool) :
ProbComp (Fin n → Bool)

The survey in which each of n respondents independently applies randomized response to their own answer.

The survey's answers are independent randomized responses.

The randomized-response survey is (ln 3, 0)-differentially private for Hamming adjacency.

theorem Cslib.Privacy.renyiDifferentiallyPrivate_randomizedResponse {α : ℝ} (hα : 1 < α) :
RenyiDifferentiallyPrivate (fun (x x_1 : Bool) => True) (fun (truth : Bool) => (randomizedResponse truth).eval) α (Real.log (3 / 4 * 3 ^ (α - 1) + 1 / 4 * 3 ^ (1 - α)) / (α - 1))

Randomized response satisfies (α, log ((3 / 4) · 3 ^ (α - 1) + (1 / 4) · 3 ^ (1 - α)) / (α - 1))-Rényi differential privacy for every 1 < α [Mironov2017, Proposition 5].

theorem Cslib.Privacy.renyiDifferentiallyPrivate_randomizedResponseSurvey (n : ℕ) {α : ℝ} (hα : 1 < α) :
RenyiDifferentiallyPrivate HammingAdjacent (fun (x : Fin n → Bool) => (randomizedResponseSurvey x).eval) α (Real.log (3 / 4 * 3 ^ (α - 1) + 1 / 4 * 3 ^ (1 - α)) / (α - 1))

The n-respondent randomized-response survey satisfies the same order-α Rényi differential privacy bound under HammingAdjacent for every 1 < α.

theorem Cslib.Privacy.sum_eval_randomizedResponseSurvey_mul_card {n : ℕ} (x : Fin n → Bool) :
∑ answers : Fin n → Bool, ((randomizedResponseSurvey x).eval answers).toReal * ↑{i : Fin n | answers i = true}.card = ↑n / 4 + ↑{i : Fin n | x i = true}.card / 2

The expected number of "Yes" answers is n / 4 + (number of true "Yes") / 2 [DworkRoth2014, §2.3].

theorem Cslib.Privacy.sum_eval_randomizedResponseSurvey_mul_estimator {n : ℕ} (hn : n ≠ 0) (x : Fin n → Bool) :
∑ answers : Fin n → Bool, ((randomizedResponseSurvey x).eval answers).toReal * (2 * (↑{i : Fin n | answers i = true}.card / ↑n) - 1 / 2) = ↑{i : Fin n | x i = true}.card / ↑n

The estimator 2 · (fraction of "Yes" answers) - 1/2 is unbiased for the fraction of respondents whose true answer is "Yes" [DworkRoth2014, §2.3].