Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unbounded noised maximum using the sparse vector technique #61

Draft
wants to merge 44 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
5fc6495
code
mjdemedeiros Aug 2, 2024
f637d1b
Proof sketch
mjdemedeiros Aug 2, 2024
c855fbb
update plan
mjdemedeiros Aug 5, 2024
ea24303
lemmas about probWhileSplit
mjdemedeiros Aug 5, 2024
313e7f0
checkpoint progress towards eventually constant sequence
mjdemedeiros Aug 5, 2024
91fd85a
Apply eventually constant sequence lemma
mjdemedeiros Aug 5, 2024
c410ba5
checkpoint
mjdemedeiros Aug 5, 2024
c45981d
exploring alternative implementation
mjdemedeiros Aug 6, 2024
e50313c
checkpoint
mjdemedeiros Aug 6, 2024
eaff33a
add support for empty histories where possible
mjdemedeiros Aug 6, 2024
d03e01e
mono_conditional is enough to prove probWhileSplit_succ_r in the n>0 …
mjdemedeiros Aug 6, 2024
59a95c3
probBind_congr_strong
mjdemedeiros Aug 7, 2024
c1de02e
probWhileSplit_add_r'
mjdemedeiros Aug 7, 2024
82bc7c3
probWhileSplit_addd_r_pure
mjdemedeiros Aug 7, 2024
d8fd7ea
checkpoint progress on eventual constancy lemma
mjdemedeiros Aug 7, 2024
9a7e417
checkpoint
mjdemedeiros Aug 7, 2024
06b4bf4
closed form is enough to close limit lemma
mjdemedeiros Aug 7, 2024
f1f83ec
checkpoint
mjdemedeiros Aug 7, 2024
8e7a56e
sketch privMax_reduction_2 and privMax_reduction_3
mjdemedeiros Aug 7, 2024
fe4c2f9
State DP property
mjdemedeiros Aug 7, 2024
87a8aed
deterministic part of DP argument
mjdemedeiros Aug 7, 2024
a6524fa
checkpoint: fix off-by-one errors
mjdemedeiros Aug 8, 2024
1118a75
privMax_eval_cut_supp_bound, and example
mjdemedeiros Aug 8, 2024
6003d88
closed form, below the cut point
mjdemedeiros Aug 8, 2024
93ce8fa
reduce closed form to privMax_eval_cut_const_ind
mjdemedeiros Aug 8, 2024
c31508a
checkpoint
mjdemedeiros Aug 8, 2024
4a31d9c
checkpoint
mjdemedeiros Aug 9, 2024
29c2e3f
reduction 3 complete
mjdemedeiros Aug 9, 2024
432d5e8
sum_len_split_lemma
mjdemedeiros Aug 9, 2024
d75449d
checkpoint privMax_reduction_2
mjdemedeiros Aug 9, 2024
a9ac9ce
checkpoint before trying to fix strange off-by-one
mjdemedeiros Aug 9, 2024
ffd2544
adding extra iterate to privMax_eval_alt_loop_cut makes reduction_2 b…
mjdemedeiros Aug 9, 2024
1f14a3f
checkpoint
mjdemedeiros Aug 9, 2024
8f05142
Work on termination tracking version (like geometric sampler)
mjdemedeiros Aug 12, 2024
a35478f
organization
mjdemedeiros Aug 13, 2024
6fc9a42
checkpoint privacy proof
mjdemedeiros Aug 13, 2024
657db9b
privacy for hist=[] case
mjdemedeiros Aug 13, 2024
26127ba
nonzero history checkpoint
mjdemedeiros Aug 13, 2024
bc3fc7e
sketch end of nonempty history proof
mjdemedeiros Aug 13, 2024
49d0531
refactor privacy proof
mjdemedeiros Aug 14, 2024
16d082d
checkpoint
mjdemedeiros Aug 14, 2024
421bee6
exactDiffSum_neighbours (worse bound than in the literature)
mjdemedeiros Aug 14, 2024
1d75252
cleanup pure proof file
mjdemedeiros Aug 14, 2024
d3fa24b
checkpoint
mjdemedeiros Aug 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions SampCert.lean
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jean-Baptiste Tristan
-/
import SampCert.DifferentialPrivacy.Queries.UnboundedMax.Basic
import SampCert.DifferentialPrivacy.Queries.BoundedMean.Basic
import SampCert.DifferentialPrivacy.Queries.Histogram.Basic
import SampCert.DifferentialPrivacy.ZeroConcentrated.System
Expand Down
6 changes: 6 additions & 0 deletions SampCert/DifferentialPrivacy/Abstract.lean
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ lemma DPSystem_prop_ext [dps : DPSystem T] {ε₁ ε₂ : NNReal} (m : Mechanism
assumption


lemma DPSystem_mech_prop_ext [dps : DPSystem T] {ε : NNReal} (m1 m2 : Mechanism T U) (Hm : m1 = m2) (H : dps.prop m1 ε) :
dps.prop m2 ε := by
subst Hm
assumption


@[simp]
lemma bind_bind_indep (p : Mechanism T U) (q : Mechanism T V) (h : U → V → PMF A) :
(fun l => (p l) >>= (fun a : U => (q l) >>= fun b : V => h a b)) =
Expand Down
10 changes: 10 additions & 0 deletions SampCert/DifferentialPrivacy/Queries/UnboundedMax/Basic.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/-
Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jean-Baptiste Tristan
-/

import SampCert.DifferentialPrivacy.Queries.UnboundedMax.Code
import SampCert.DifferentialPrivacy.Queries.UnboundedMax.Properties
import SampCert.DifferentialPrivacy.Queries.UnboundedMax.Pure
import SampCert.DifferentialPrivacy.Queries.UnboundedMax.ZeroConcentrated
94 changes: 94 additions & 0 deletions SampCert/DifferentialPrivacy/Queries/UnboundedMax/Code.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/-
Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Jean-Baptiste Tristan
-/
import SampCert.DifferentialPrivacy.Abstract
import Init.Data.Fin.Basic
import Mathlib.Data.Vector.Basic

/-!
# ``privMax`` Implementation

This file implements a query for the noised max of a list, using the sparse vector technique.

In principle this can produce better pure DP bounds than the maximum obtained by the differentially
private histogram, and furthermore it does not require choosing a failure threshold a priori.
-/

noncomputable section

namespace SLang


/--
Sum over a list, clipping each element to a maximum.

Similar to exactBoundedSum, however exactClippedSum allows m = 0.
-/
def exactClippedSum (m : ℕ) (l : List ℕ) : ℤ :=
List.sum (List.map (fun n : ℕ => (Nat.min n m)) l)

/--
Rate at which a given clipping thresold is impacting the accuracy of the sum.

Always negative or zero.
-/
def exactDiffSum (m : ℕ) (l : List ℕ) : ℤ := exactClippedSum m l - exactClippedSum (m + 1) l

/--
Noise the constant 0 value using the abstract noise function.

This looks strange, but will specialize to Lap(ε₁/ε₂, 0) in the pure DP case.
-/
def privNoiseZero [dps : DPSystem ℕ] (ε₁ ε₂ : ℕ+) : SLang ℤ := dps.noise (fun _ => 0) 1 ε₁ ε₂ []

/--
privMax main loop guard

Terminate when exactDiffSum k l + vk >= τ
Continue when exactDiffSum k l + vk < τ
-/
def privMaxC (τ : ℤ) (l : List ℕ) (x : ℕ × ℤ) : Bool :=
decide (exactDiffSum x.1 l + x.2 < τ)

/--
privMax main loop body

Increase k, and sample the next vk
-/
def privMaxF [DPSystem ℕ] (ε₁ ε₂ : ℕ+) : ℕ × ℤ -> SLang (ℕ × ℤ) :=
(fun (km1, _) => do
let k := km1 + 1
let vk <- privNoiseZero ε₁ (4 * ε₂)
return (k, vk))


/--
Return the maximum element in the list, with some amount of noising.
-/
def privMax_eval [DPSystem ℕ] (ε₁ ε₂ : ℕ+) (l : List ℕ) : SLang ℕ := do
let τ <- privNoiseZero ε₁ (2 * ε₂)
let v0 <- privNoiseZero ε₁ (4 * ε₂)
let r <-
-- Invariant: When the loop state is (i, vi), we are about
-- to check if i is the noised max.
probWhile
(privMaxC τ l)
(privMaxF ε₁ ε₂)
(0, v0)
return r.1



lemma privMaxPMF_normalizes [DPSystem ℕ] : HasSum (privMax_eval ε₁ ε₂ l) 1 := sorry

/--
privMax is a PMF.

Using the Laplace mechanism, privMax is (ε₁/ε₂)-DP.
-/
def privMaxPMF [DPSystem ℕ] (ε₁ ε₂ : ℕ+) (l : List ℕ) : PMF ℕ :=
⟨ privMax_eval ε₁ ε₂ l, privMaxPMF_normalizes ⟩

end SLang
Loading