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

Pure and zero concentrated adaptive composition #26

Closed
wants to merge 123 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
1f7f8cb
proof skeleton
mjdemedeiros Jun 3, 2024
f702047
eod checkpoint
mjdemedeiros Jun 3, 2024
45ad46e
nit
mjdemedeiros Jun 3, 2024
6c536b7
checkpoint compose proof before changing side conditions
mjdemedeiros Jun 4, 2024
f9a515d
nit
mjdemedeiros Jun 4, 2024
6262ba8
done up to strengthening
mjdemedeiros Jun 4, 2024
1b7cd13
eliminate g top issue with classical
mjdemedeiros Jun 4, 2024
81749c4
restrict composition to only nonempty middle types
mjdemedeiros Jun 4, 2024
2576335
template adaptive composition
mjdemedeiros Jun 4, 2024
737d955
NonZeroNQ
mjdemedeiros Jun 4, 2024
a6d03f9
skech marginal-returning adaptive and conditioning chain rule
mjdemedeiros Jun 4, 2024
7d659b4
chain rule
mjdemedeiros Jun 5, 2024
e21a510
better pure proof w/ chain rule
mjdemedeiros Jun 5, 2024
1d4ad5e
adaptive composition proof skeleton
mjdemedeiros Jun 5, 2024
96ef09e
skeleton for renyi bound proof
mjdemedeiros Jun 5, 2024
9c8cb6c
nits
mjdemedeiros Jun 5, 2024
d8c6cea
some progress on main Renyi lemmas
mjdemedeiros Jun 5, 2024
2d0590a
close some side conditions
mjdemedeiros Jun 5, 2024
ca93118
refactor
mjdemedeiros Jun 6, 2024
db375c3
close some side conditions
mjdemedeiros Jun 6, 2024
a452caf
close some side conditions
mjdemedeiros Jun 6, 2024
44813a1
close some side conditions
mjdemedeiros Jun 6, 2024
4b40cc1
inline RentyDivergence_exp and fix build
mjdemedeiros Jun 6, 2024
546c565
more side conditions
mjdemedeiros Jun 7, 2024
2bb868f
try to move away from explicit iSup
mjdemedeiros Jun 7, 2024
23c422f
renyi bound proof
mjdemedeiros Jun 7, 2024
0c06bb2
some cleanup
mjdemedeiros Jun 7, 2024
a9e8d0d
close some side conditions
mjdemedeiros Jun 7, 2024
df5a7be
close more side conditions
mjdemedeiros Jun 7, 2024
4f04313
strengthen hypothesis: uniform bound on nq2
mjdemedeiros Jun 7, 2024
dd2dbad
checkpoint
mjdemedeiros Jun 7, 2024
107ccd5
modify boundedness hypothesis
mjdemedeiros Jun 7, 2024
bf48995
checkpoint
mjdemedeiros Jun 7, 2024
ae0265b
proofs closed
mjdemedeiros Jun 10, 2024
ee42d5f
tidy some bound hypotheses
mjdemedeiros Jun 10, 2024
ee98f4d
some cleanup
mjdemedeiros Jun 10, 2024
2312e14
extend system
mjdemedeiros Jun 10, 2024
e62af89
fix sorry
mjdemedeiros Jun 10, 2024
166e321
elog and eexp
mjdemedeiros Jun 13, 2024
0e71120
Change Renyi divergence type and stub proofs
mjdemedeiros Jun 14, 2024
7c64a91
Define ENReal -> ENNReal coercion
mjdemedeiros Jun 14, 2024
ee2d88d
copy RenyiDivergence_def_exp proof from other branch
mjdemedeiros Jun 14, 2024
8841b84
Implement RenyiDivergence_def_exp
mjdemedeiros Jun 14, 2024
202a6b1
prove closed form for expectation formula (absolute continuity assump…
mjdemedeiros Jun 14, 2024
a0c3a40
Move Jensen's inequality to Renyi
mjdemedeiros Jun 14, 2024
538baa3
Sketch Jensen's inequality for ENNReal
mjdemedeiros Jun 14, 2024
e68ed82
checkpoint log lemmas
mjdemedeiros Jun 14, 2024
634fa7c
checkpoint
mjdemedeiros Jun 17, 2024
73f66b8
checkpoint
mjdemedeiros Jun 17, 2024
7112e0d
main MemLP proof for Renyi
mjdemedeiros Jun 17, 2024
c2f7871
close side conditition
mjdemedeiros Jun 17, 2024
3fbe660
remove hypotheses from RenyiDivergence_def_exp
mjdemedeiros Jun 17, 2024
59b5fc9
checkpoint proof of nonnegativity from paper
mjdemedeiros Jun 17, 2024
eb3e7de
make postprocessing compile
mjdemedeiros Jun 18, 2024
cc447e5
composition compiles
mjdemedeiros Jun 18, 2024
ec6c9eb
Perperties compiles
mjdemedeiros Jun 18, 2024
01c4209
project compiles again
mjdemedeiros Jun 18, 2024
42999e7
checkpoint
mjdemedeiros Jun 18, 2024
b7c99a2
checkpoint
mjdemedeiros Jun 18, 2024
8529cb7
PMF cancellation lemmas
mjdemedeiros Jun 18, 2024
936bc8b
close reduct proof
mjdemedeiros Jun 18, 2024
91db8e0
close some side conditions in Renyi
mjdemedeiros Jun 18, 2024
1e76fc8
Reduction for the full Renyi case
mjdemedeiros Jun 18, 2024
c120a5c
close nonnegativity proof for Renyi divergence
mjdemedeiros Jun 19, 2024
db56434
Prove Da(P,P)=0
mjdemedeiros Jun 19, 2024
fc17bca
Gaussian gen PMF definition
mjdemedeiros Jun 19, 2024
307568c
discrete gaussian PMF
mjdemedeiros Jun 19, 2024
40869a9
sketch Renyi_Gauss_divergence_bound' (it is fixable)
mjdemedeiros Jun 19, 2024
633953f
discrete_GaussianGenSample_ZeroConcentrated
mjdemedeiros Jun 19, 2024
749ffd9
reduction of privNoisedQuery_zCDPBound to the Real-valued case
mjdemedeiros Jun 19, 2024
99c1745
privNoisedQuery_zCDPBound normalizes
mjdemedeiros Jun 19, 2024
9f8e244
real-valued Jensen converse
mjdemedeiros Jun 20, 2024
6618cf2
Renyi_Jensen_ENNReal_converse_reduct
mjdemedeiros Jun 20, 2024
fc68049
RenyiDivergence_def_eq_0_iff
mjdemedeiros Jun 20, 2024
3c99563
minor cleanup
mjdemedeiros Jun 20, 2024
42be9fb
completed concentrated bound
mjdemedeiros Jun 20, 2024
9562ab9
checkpoint
mjdemedeiros Jun 20, 2024
96e4d1e
zCDP composition, up to absolute continuity assumption
mjdemedeiros Jun 21, 2024
2b8058f
mechanism zCDP
mjdemedeiros Jun 21, 2024
f8c66d5
checkpoint: before changing postprocessing
mjdemedeiros Jun 21, 2024
2825ee0
High-level sketch for postprocessing reduction
mjdemedeiros Jun 21, 2024
fbecc40
more log lemmas
mjdemedeiros Jun 21, 2024
b1bda80
privCompose normalizes
mjdemedeiros Jun 24, 2024
b23d6f1
privPostProcess normalizes
mjdemedeiros Jun 24, 2024
abae0a5
Add absolute continuity side condition
mjdemedeiros Jun 24, 2024
98b15fd
Mechanism absolute continuity
mjdemedeiros Jun 24, 2024
8057170
privCompose absolute continuity
mjdemedeiros Jun 24, 2024
e386b98
RenyiDivergence_aux_zero
mjdemedeiros Jun 24, 2024
c16857e
privPostProccess absolute continuity (removes surjectivity requirement?)
mjdemedeiros Jun 24, 2024
149d62d
(broken build) sketch PostProcess_pre_reduct
mjdemedeiros Jun 24, 2024
db76175
(build fixed) checkpoint progress on PostProcess_pre_reduct
mjdemedeiros Jun 24, 2024
9967bb7
strengthen PostProcess_pre_reduct for the reduction and cleanup
mjdemedeiros Jun 25, 2024
895e0d3
checkpoint reduction: needs neighbours to be symmetric
mjdemedeiros Jun 25, 2024
5db5fd1
All major theorems completed
mjdemedeiros Jun 25, 2024
782b41d
checkpoint conversion lemmas
mjdemedeiros Jun 25, 2024
0517c46
case analysis tactics for remaining log lemmas
mjdemedeiros Jun 26, 2024
76f9bb2
All but one ofEReal lemma
mjdemedeiros Jun 26, 2024
5dbbcc9
checkpoint
mjdemedeiros Jun 26, 2024
211c0de
Strengthen ereal_smul_left_le
mjdemedeiros Jun 26, 2024
cb95d8f
Inline single use misc log lemmas
mjdemedeiros Jun 26, 2024
0996fe7
all proofs closed
mjdemedeiros Jun 26, 2024
0d4cb66
Change return type of mechanism to PMF
mjdemedeiros Jun 27, 2024
72e3736
close composition
mjdemedeiros Jun 27, 2024
49166b6
Close pure mechanism properties
mjdemedeiros Jun 27, 2024
474dec5
nit
mjdemedeiros Jun 27, 2024
aad9994
close postprocessing
mjdemedeiros Jun 27, 2024
562ce39
close bounded mean proof
mjdemedeiros Jun 27, 2024
a7afdc0
laplace gen normalizes
mjdemedeiros Jun 27, 2024
41d8b58
simplify bounded mean proof
mjdemedeiros Jun 27, 2024
75d8d34
Parameterize postprocessing function requirement
mjdemedeiros Jun 27, 2024
048e20f
cleanup DifferentialPrivacy/Abstract
mjdemedeiros Jun 27, 2024
8ab5ad0
cleanup DifferentialPrivacy/Neighbours
mjdemedeiros Jun 27, 2024
19360fd
cleanup DifferentialPrivacy/Pure/Composition
mjdemedeiros Jun 27, 2024
17072f9
cleanup DifferentialPrivacy/Pure/Mechanism/Code
mjdemedeiros Jun 27, 2024
94509f0
cleanup DifferentialPrivacy/Pure/Mechanism
mjdemedeiros Jun 27, 2024
65f9f00
cleanup DifferentialPrivacy/Pure
mjdemedeiros Jun 27, 2024
ed18574
cleanup DifferentialPrivacy/Queries
mjdemedeiros Jun 27, 2024
edc4422
Some cleanup in DifferentialPrivacy/RenyiDivergence
mjdemedeiros Jun 27, 2024
8f2fc72
cleanup DifferentialPrivacy/ZeroConcentrated/Composition
mjdemedeiros Jun 28, 2024
ea00129
cleanup DifferentialPrivacy/ZeroConcentrated
mjdemedeiros Jun 28, 2024
5adaaa4
cleanup Samplers
mjdemedeiros Jun 28, 2024
96560ee
cleanup Util
mjdemedeiros Jun 28, 2024
4660837
Merge branch 'ExtendedAdaptiveComposition' into zcdp_composition
mjdemedeiros Jun 28, 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
219 changes: 102 additions & 117 deletions SampCert/DifferentialPrivacy/Abstract.lean
Original file line number Diff line number Diff line change
Expand Up @@ -10,110 +10,140 @@ import SampCert.Foundations.Basic
/-!
# Differential Privacy

This file defines a notion of a differential private system.
This file defines an abstract system of differentially private operators.
-/

noncomputable section

open Classical Nat Int Real ENNReal

def NonZeroNQ (nq : List T → SLang U) :=
/--
A mechanism is nonzero on its entire domain
-/
def NonZeroNQ (nq : List T → PMF U) :=
∀ l : List T, ∀ n : U, nq l n ≠ 0

def NonTopSum (nq : List T → SLang U) :=
∀ l : List T, ∑' n : U, nq l n ≠ ⊤

namespace SLang

abbrev Query (T U : Type) := List T → U
abbrev Mechanism (T U : Type) := List T → SLang U

abbrev Mechanism (T U : Type) := List T → PMF U

/--
Product of mechanisms.
General (value-dependent) composition of mechanisms
-/
def privComposeAdaptive (nq1 : Mechanism T U) (nq2 : U -> Mechanism T V) (l : List T) : SLang (U × V) := do
let A <- nq1 l
let B <- nq2 A l
return (A, B)


lemma compose_sum_rw_adaptive (nq1 : List T → SLang U) (nq2 : U -> List T → SLang V) (u : U) (v : V) (l : List T) :
(∑' (a : U), nq1 l a * ∑' (a_1 : V), if u = a ∧ v = a_1 then nq2 a l a_1 else 0) = nq1 l u * nq2 u l v := by
have hrw1 : ∀ (a : U), nq1 l a * (∑' (a_1 : V), if u = a ∧ v = a_1 then nq2 a l a_1 else 0) = if (u = a) then (nq1 l a * ∑' (a_1 : V), if u = a ∧ v = a_1 then nq2 a l a_1 else 0) else 0 := by
intro a
split
· simp
· aesop
have hrw2 : ∀ (a : U), (if (u = a) then (nq1 l a * ∑' (a_1 : V), if u = a ∧ v = a_1 then nq2 a l a_1 else 0) else 0) = (nq1 l u * (∑' (a_1 : V), if u = a ∧ v = a_1 then nq2 u l a_1 else 0)) := by
intro a
split
· aesop
· aesop
rw [tsum_congr hrw1]
rw [tsum_congr hrw2]
clear hrw1 hrw2
rw [ENNReal.tsum_mul_left]
congr 1
rw [<- ENNReal.tsum_prod]
have hrw3 : ∀ (p : U × V), (if u = p.1 ∧ v = p.2 then nq2 u l p.2 else 0) = nq2 u l v * (if p = (u, v) then 1 else 0) := by
intro p
split
· aesop
· aesop
rw [tsum_congr hrw3]
rw [ENNReal.tsum_mul_left]
rw [tsum_ite_eq]
exact MulOneClass.mul_one (nq2 u l v)


/--
Chain rule relating the adaptive composition definitions

The joint distribution decomposes into the conditional and marginal (ie, nq1 l) distributions
-/
lemma privComposeChainRule (nq1 : Mechanism T U) (nq2 : U -> Mechanism T V) (l : List T) :
∀ (u : U), ∀ (v : V), privComposeAdaptive nq1 nq2 l (u, v) = nq1 l u * nq2 u l v := by
intros u v
rw [<- compose_sum_rw_adaptive]
simp [privComposeAdaptive]

Note that the second mechanism does not depend on the output of the first; this is in currently
in contrast to the notions of composition found in the DP literature.
/--
Product of mechanisms.
-/
def privCompose (nq1 : Mechanism T U) (nq2 : Mechanism T V) (l : List T) : SLang (U × V) := do
def privCompose (nq1 : Mechanism T U) (nq2 : Mechanism T V) (l : List T) : PMF (U × V) := do
let A ← nq1 l
let B ← nq2 l
return (A,B)

/--
Mechanism obtained by applying a post-processing function to a mechanism.
-/
def privPostProcess (nq : Mechanism T U) (pp : U → V) (l : List T) : SLang V := do
def privPostProcess (nq : Mechanism T U) (pp : U → V) (l : List T) : PMF V := do
let A ← nq l
return pp A


/--
Abstract definition of a differentially private systemm.
-/
class DPSystem (T : Type) where
/--
Notion of differential privacy with a paramater (ε-DP, ε-zCDP, etc)
Differential privacy proposition, with one real paramater (ε-DP, ε-zCDP, etc)
-/
prop : Mechanism T Z → ℝ → Prop
/--
Noise mechanism (eg. Laplace, Discrete Gaussian, etc)
Paramaterized by a query, sensitivity, and the numerator/denominator ofa (rational) security paramater.
A noise mechanism (eg. Laplace, Discrete Gaussian, etc)
Paramaterized by a query, sensitivity, and a (rational) security paramater.
-/
noise : Query T ℤ → ℕ+ℕ+ℕ+ → Mechanism T ℤ
noise : Query T ℤ → (sensitivity : ℕ+)(num : ℕ+)(den : ℕ+) → Mechanism T ℤ
/--
Adding noise to a query makes it differentially private.
Adding noise to a query makes it private.
-/
noise_prop : ∀ q : List T → ℤ, ∀ Δ εn εd : ℕ+, sensitivity q Δ → prop (noise q Δ εn εd) (εn / εd)
/--
Notion of privacy composes by addition.
Privacy composes by addition.
-/
compose_prop : {U V : Type} → [MeasurableSpace U] → [Countable U] → [DiscreteMeasurableSpace U] → [Inhabited U] → [MeasurableSpace V] → [Countable V] → [DiscreteMeasurableSpace V] → [Inhabited V] → ∀ m₁ : Mechanism T U, ∀ m₂ : Mechanism T V, ∀ ε₁ ε₂ ε₃ ε₄ : ℕ+,
prop m₁ (ε₁ / ε₂) → prop m₂ (ε₃ / ε₄) → prop (privCompose m₁ m₂) ((ε₁ / ε₂) + (ε₃ / ε₄))
/-
Uniformity conditions for adaptive composition
-/
-- adaptive_unif_prop {U : Type} : (U -> Mechanism T Z) -> Prop
/-
Notion of privacy composes by addition
-/
-- adaptive_compose_prop : {U V : Type} → [MeasurableSpace U] → [Countable U] → [DiscreteMeasurableSpace U] → [Inhabited U] → [MeasurableSpace V] → [Countable V] → [DiscreteMeasurableSpace V] → [Inhabited V] → ∀ m₁ : Mechanism T U, ∀ m₂ : U -> Mechanism T V, ∀ ε₁ ε₂ ε₃ ε₄ : ℕ+,
-- prop m₁ (ε₁ / ε₂) → (∀ u, prop (m₂ u) (ε₃ / ε₄)) -> adaptive_unif_prop m₂ → prop (privComposeAdaptive m₁ m₂) ((ε₁ / ε₂) + (ε₃ / ε₄))
/--
Requirement for postcomposition to hold.
-/
postprocess_prop_f : {U V : Type} -> (f : U -> V) -> Prop
/--
Notion of privacy is invariant under post-processing.
Privacy is invariant under post-processing.
-/
postprocess_prop : {U : Type} → [MeasurableSpace U] → [Countable U] → [DiscreteMeasurableSpace U] → [Inhabited U] → { pp : U → V } → Function.Surjective pp → ∀ m : Mechanism T U, ∀ ε₁ ε₂ : ℕ+,
postprocess_prop : {U : Type} → [MeasurableSpace U] → [Countable U] → [DiscreteMeasurableSpace U] → [Inhabited U] → { pp : U → V } → postprocess_prop_f pp → ∀ m : Mechanism T U, ∀ ε₁ ε₂ : ℕ+,
prop m (ε₁ / ε₂) → prop (privPostProcess m pp) (ε₁ / ε₂)

@[simp]
lemma bind_bind_indep (p : Mechanism T U) (q : Mechanism T V) (h : U → V → SLang A) :
(fun l => (p l).probBind (fun a : U => (q l).probBind fun b : V => h a b))
=
fun l => (privCompose p q l).probBind (fun z => h z.1 z.2) := by
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)) =
fun l => (privCompose p q l) >>= (fun z => h z.1 z.2) := by
ext l x
simp [privCompose, tsum_prod']
apply tsum_congr
intro b
rw [← ENNReal.tsum_mul_left]
apply tsum_congr
intro c
rw [← mul_assoc]
congr 1
rw [tsum_eq_single b]
. congr 1
rw [tsum_eq_single c]
. simp
. intro b' h1
simp
intro h2
subst h2
contradiction
. intro b' h1
rw [tsum_eq_single c]
. simp
intro h2
subst h2
contradiction
. intro b'' h2
simp
intro h3 h4
subst h3
subst h4
contradiction

lemma compose_sum_rw (nq1 : List T → SLang U) (nq2 : List T → SLang V) (b : U) (c : V) (l : List T) :
(∑' (a : U), nq1 l a * ∑' (a_1 : V), if b = a ∧ c = a_1 then nq2 l a_1 else 0) = nq1 l b * nq2 l c := by
have A : ∀ a : U, ∀ b : U, (∑' (a_1 : V), if b = a ∧ c = a_1 then nq2 l a_1 else 0) = if b = a then (∑' (a_1 : V), if c = a_1 then nq2 l a_1 else 0) else 0 := by
lemma compose_sum_rw (nq1 : U -> ENNReal) (nq2 : V -> ENNReal) (b : U) (c : V) :
(∑' (a : U), nq1 a * ∑' (a_1 : V), if b = a ∧ c = a_1 then nq2 a_1 else 0) = nq1 b * nq2 c := by
have A : ∀ a : U, ∀ b : U, (∑' (a_1 : V), if b = a ∧ c = a_1 then nq2 a_1 else 0) = if b = a then (∑' (a_1 : V), if c = a_1 then nq2 a_1 else 0) else 0 := by
intro x y
split
. rename_i h
Expand All @@ -131,7 +161,7 @@ lemma compose_sum_rw (nq1 : List T → SLang U) (nq2 : List T → SLang V) (b :
rw [A]
rw [ENNReal.tsum_eq_add_tsum_ite b]
simp
have B : ∀ x : U, (if x = b then 0 else if b = x then nq1 l x * ∑' (a_1 : V), if c = a_1 then nq2 l a_1 else 0 else 0) = 0 := by
have B : ∀ x : U, (if x = b then 0 else if b = x then nq1 x * ∑' (a_1 : V), if c = a_1 then nq2 a_1 else 0 else 0) = 0 := by
intro x
split
. simp
Expand All @@ -150,7 +180,7 @@ lemma compose_sum_rw (nq1 : List T → SLang U) (nq2 : List T → SLang V) (b :
congr 1
rw [ENNReal.tsum_eq_add_tsum_ite c]
simp
have C :∀ x : V, (if x = c then 0 else if c = x then nq2 l x else 0) = 0 := by
have C :∀ x : V, (if x = c then 0 else if c = x then nq2 x else 0) = 0 := by
intro x
split
. simp
Expand All @@ -167,47 +197,11 @@ lemma compose_sum_rw (nq1 : List T → SLang U) (nq2 : List T → SLang V) (b :
rw [C]
simp

/--
Composed queries are normalizable.
-/
theorem privCompose_NonTopSum {nq1 : List T → SLang U} {nq2 : List T → SLang V} (nt1 : NonTopSum nq1) (nt2 : NonTopSum nq2) :
NonTopSum (privCompose nq1 nq2) := by
simp [NonTopSum] at *
intro l
replace nt1 := nt1 l
replace nt2 := nt2 l
simp [privCompose]
rw [ENNReal.tsum_prod']
conv =>
right
left
right
intro a
right
intro b
simp
rw [compose_sum_rw]
conv =>
right
left
right
intro a
rw [ENNReal.tsum_mul_left]
rw [ENNReal.tsum_mul_right]
rw [mul_eq_top]
intro H
cases H
. rename_i H
cases H
contradiction
. rename_i H
cases H
contradiction

/--
All outputs of a composed query have nonzero probability.
-/
theorem privCompose_NonZeroNQ {nq1 : List T → SLang U} {nq2 : List T → SLang V} (nn1 : NonZeroNQ nq1) (nn2 : NonZeroNQ nq2) :
theorem privCompose_NonZeroNQ {nq1 : Mechanism T U} {nq2 : Mechanism T V} (nn1 : NonZeroNQ nq1) (nn2 : NonZeroNQ nq2) :
NonZeroNQ (privCompose nq1 nq2) := by
simp [NonZeroNQ] at *
intro l a b
Expand All @@ -216,6 +210,9 @@ theorem privCompose_NonZeroNQ {nq1 : List T → SLang U} {nq2 : List T → SLang
simp [privCompose]
exists a

/--
Partition series into fibers. `g` maps an element to its fiber.
-/
theorem ENNReal.HasSum_fiberwise {f : T → ENNReal} {a : ENNReal} (hf : HasSum f a) (g : T → V) :
HasSum (fun c : V ↦ ∑' b : g ⁻¹' {c}, f b) a := by
let A := (Equiv.sigmaFiberEquiv g)
Expand All @@ -229,6 +226,9 @@ theorem ENNReal.HasSum_fiberwise {f : T → ENNReal} {a : ENNReal} (hf : HasSum
. rfl
. apply ENNReal.summable

/--
Partition series into fibers. `g` maps an element to its fiber.
-/
theorem ENNReal.tsum_fiberwise (p : T → ENNReal) (f : T → V) :
∑' (x : V), ∑' (b : (f ⁻¹' {x})), p b
= ∑' i : T, p i := by
Expand All @@ -237,6 +237,9 @@ theorem ENNReal.tsum_fiberwise (p : T → ENNReal) (f : T → V) :
apply Summable.hasSum
exact ENNReal.summable

/--
Rewrite a series into a sum over fibers. `f` maps an element into its fiber.
-/
theorem fiberwisation (p : T → ENNReal) (f : T → V) :
(∑' i : T, p i)
= ∑' (x : V), if {a : T | x = f a} = {} then 0 else ∑'(i : {a : T | x = f a}), p i := by
Expand Down Expand Up @@ -271,7 +274,11 @@ lemma condition_to_subset (f : U → V) (g : U → ENNReal) (x : V) :
simp
rw [B]

theorem privPostProcess_NonZeroNQ {nq : List T → SLang U} {f : U → V} (nn : NonZeroNQ nq) (sur : Function.Surjective f) :

/--
Postprocessing by a surjection preserves `NonZeroNQ`.
-/
theorem privPostProcess_NonZeroNQ {nq : Mechanism T U} {f : U → V} (nn : NonZeroNQ nq) (sur : Function.Surjective f) :
NonZeroNQ (privPostProcess nq f) := by
simp [NonZeroNQ, Function.Surjective, privPostProcess] at *
intros l n
Expand All @@ -283,26 +290,4 @@ theorem privPostProcess_NonZeroNQ {nq : List T → SLang U} {f : U → V} (nn :
. rw [h]
. apply nn

theorem privPostProcess_NonTopSum {nq : List T → SLang U} (f : U → V) (nt : NonTopSum nq) :
NonTopSum (privPostProcess nq f) := by
simp [NonTopSum, privPostProcess] at *
intros l
have nt := nt l
rw [← ENNReal.tsum_fiberwise _ f] at nt
conv =>
right
left
right
intro n
rw [condition_to_subset]
have A : ∀ x : V, f ⁻¹' {x} = {y | x = f y} := by
aesop
conv =>
right
left
right
intro x
rw [← A]
trivial

end SLang
19 changes: 17 additions & 2 deletions SampCert/DifferentialPrivacy/Neighbours.lean
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,31 @@ Authors: Jean-Baptiste Tristan
/-!
# Neighbours

This file defines the notion of neighbouring lists, in order to define a notion of sensitivity.
This file defines neighbouring lists.
-/


variable {T : Type}

/--
The notion of "difference" between lists for differential privacy.
Lists which differ by the inclusion or modification of an element.

This is SampCert's private property.
-/
inductive Neighbour (l₁ l₂ : List T) : Prop where
| Addition : l₁ = a ++ b → l₂ = a ++ [n] ++ b → Neighbour l₁ l₂
| Deletion : l₁ = a ++ [n] ++ b → l₂ = a ++ b → Neighbour l₁ l₂
| Update : l₁ = a ++ [n] ++ b → l₂ = a ++ [m] ++ b -> Neighbour l₁ l₂


/--
Neighbour relation is symmetric.
-/
def Neighbour_symm (l₁ l₂ : List T) (H : Neighbour l₁ l₂) : Neighbour l₂ l₁ := by
cases H
· rename_i _ _ _ Hl1 Hl2
exact Neighbour.Deletion Hl2 Hl1
· rename_i _ _ _ Hl1 Hl2
exact Neighbour.Addition Hl2 Hl1
· rename_i _ _ _ _ Hl1 Hl2
exact Neighbour.Update Hl2 Hl1
Loading
Loading