Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
b178344
fix adaptive composition
markusdemedeiros Oct 28, 2024
d0b4650
fix definition
markusdemedeiros Oct 28, 2024
7c1eac8
update base proof for gaussian mechanism property
markusdemedeiros Oct 28, 2024
0b0370b
fix mono
markusdemedeiros Oct 28, 2024
5f6ef79
fix base proof for approxDP
markusdemedeiros Oct 28, 2024
95be45c
new zCDP proofs wrapped
markusdemedeiros Oct 28, 2024
569d44e
stub changes to system
markusdemedeiros Oct 28, 2024
28efc75
stub changes to noise
markusdemedeiros Oct 28, 2024
40ac9cc
instance for pure DP laplace noise
markusdemedeiros Oct 28, 2024
456514a
pure DP system complete
markusdemedeiros Oct 28, 2024
dfc4b3f
count query complete
markusdemedeiros Oct 28, 2024
dc7ee36
tweak definitions of abstract DP for better inference
markusdemedeiros Oct 28, 2024
00e2ef6
cleanup bounded sum abstract proof
markusdemedeiros Oct 28, 2024
be8cfd4
update bounded mean
markusdemedeiros Oct 28, 2024
b064656
Histogram update
markusdemedeiros Oct 28, 2024
edec416
historgram mean update
markusdemedeiros Oct 28, 2024
592cdea
instances for zCDP (except approx DP)
markusdemedeiros Oct 28, 2024
e746f46
checkpoint
markusdemedeiros Oct 28, 2024
4ea177b
zCDP degrade
markusdemedeiros Oct 29, 2024
de517ba
simplify abstract DP presentation further with typeclass synonym
markusdemedeiros Oct 30, 2024
2241651
shorten histogram proofs
markusdemedeiros Nov 2, 2024
dc787ef
histogram: move epsilons to variable
markusdemedeiros Nov 2, 2024
1b8cf40
define SPMF
markusdemedeiros Nov 5, 2024
e4a2f46
SPMF: generic
markusdemedeiros Nov 5, 2024
e023a0f
postprocessing
markusdemedeiros Nov 5, 2024
1b86165
update queries to be computable
markusdemedeiros Nov 5, 2024
b806c8b
move SPMF to SLang
markusdemedeiros Nov 5, 2024
f75fe5a
query tests
markusdemedeiros Nov 5, 2024
0884bac
rename adp -> app_dp
markusdemedeiros Nov 12, 2024
6372ea0
Countable -> DiscProbSpace
markusdemedeiros Nov 12, 2024
7d9ba57
prelim
markusdemedeiros Sep 25, 2024
cabf7a2
checkpoint
markusdemedeiros Sep 26, 2024
0f89042
checkpoint sv2
markusdemedeiros Sep 26, 2024
c5e7ee0
checkpoint sv2->sv3
markusdemedeiros Sep 26, 2024
4d58b9d
checkpoint
markusdemedeiros Sep 26, 2024
845ba9f
constancy inside the cone of possibility
markusdemedeiros Sep 30, 2024
4edd572
cone_below_zero
markusdemedeiros Sep 30, 2024
d9c5505
external_to_cone_zero
markusdemedeiros Sep 30, 2024
120b2d7
reduce sv2_eq_sv3 to cone_left_edge_constancy
markusdemedeiros Sep 30, 2024
3b30b10
close cone_constancy
markusdemedeiros Oct 1, 2024
f030596
checkpoint
markusdemedeiros Oct 1, 2024
f38b2ae
checkpoint
markusdemedeiros Oct 6, 2024
7a30a61
so close yet so far
markusdemedeiros Oct 7, 2024
b94fd5b
closer (not really)
markusdemedeiros Oct 7, 2024
7e33b89
explicit presampling is promising
markusdemedeiros Oct 7, 2024
8612d16
checkpoint
markusdemedeiros Oct 7, 2024
6a89720
sv6 experiment
markusdemedeiros Oct 8, 2024
cde6978
checkpoint
markusdemedeiros Oct 28, 2024
ff23721
checkpoint
markusdemedeiros Nov 3, 2024
b32b153
sv5 sv6 base case
markusdemedeiros Nov 3, 2024
0a12c1f
checkpoint explorations into sv6
markusdemedeiros Nov 3, 2024
82bebcc
work on sv3 admits
markusdemedeiros Nov 3, 2024
93ec8f8
so close
markusdemedeiros Nov 4, 2024
267c61f
sv5 sv6 victory
markusdemedeiros Nov 4, 2024
6e17ff4
sketch sv7
markusdemedeiros Nov 4, 2024
5f3e10e
sv8 (definition of G from the paper)
markusdemedeiros Nov 4, 2024
b86c6e0
cleanup
markusdemedeiros Nov 4, 2024
b1f7b98
skeleton of privacy argument
markusdemedeiros Nov 4, 2024
44c9e7d
sparse vector main proof
markusdemedeiros Nov 4, 2024
1f7254a
extra sensitivity lemmas
markusdemedeiros Nov 4, 2024
7c1d1ae
checkpoint
markusdemedeiros Nov 4, 2024
85b9a4b
base case
markusdemedeiros Nov 5, 2024
b41d701
checkpoint
markusdemedeiros Nov 5, 2024
1489ded
Fix build
markusdemedeiros Nov 5, 2024
60c7b74
move executable code to a new file
markusdemedeiros Nov 5, 2024
22f3fd2
add sparse vector test
markusdemedeiros Nov 5, 2024
d08f848
tweak numbers
markusdemedeiros Nov 5, 2024
5408fe0
checkpoint
markusdemedeiros Nov 5, 2024
6f8c612
vector_sum_singleton
markusdemedeiros Nov 6, 2024
45a55c7
minor
markusdemedeiros Nov 6, 2024
c64d2d9
sv4_presample_split progress
markusdemedeiros Nov 6, 2024
f94da17
progress on presample_norm_lemma
markusdemedeiros Nov 6, 2024
1a9496a
DS0
markusdemedeiros Nov 6, 2024
155300c
nit
markusdemedeiros Nov 6, 2024
f9a7882
move remaining sensitivity bounds out of privacy proof
markusdemedeiros Nov 6, 2024
61f0672
close vk sensitivity
markusdemedeiros Nov 6, 2024
e125c1a
generalize DS0->DSN
markusdemedeiros Nov 6, 2024
d4444a4
nit
markusdemedeiros Nov 6, 2024
91a8f03
privacy is sorry-free
markusdemedeiros Nov 6, 2024
414ca7b
minor cleanup
markusdemedeiros Nov 6, 2024
a7ff04f
list get last lemma
markusdemedeiros Nov 7, 2024
9377021
sv8_eq_sv9
markusdemedeiros Nov 7, 2024
572aa68
close presample_norm_lemma
markusdemedeiros Nov 7, 2024
2906f3e
close sv6 sv7 eq
markusdemedeiros Nov 7, 2024
4a5e2c7
exactDiffSum eventually constant
markusdemedeiros Nov 7, 2024
9cf0cbb
checkpoint
markusdemedeiros Nov 7, 2024
b845bee
checkpoint before deleting sv4_presample_perm
markusdemedeiros Nov 7, 2024
0a533de
sv4_presample_eval
markusdemedeiros Nov 7, 2024
8173cd7
close sv4_presample_split
markusdemedeiros Nov 7, 2024
35ab39e
tweak spmf
markusdemedeiros Nov 8, 2024
031af6f
sv1_ub
markusdemedeiros Nov 8, 2024
324ab62
close iSup tsum lemma
markusdemedeiros Nov 8, 2024
f08a18a
sv1_lb reduction to sv1_cdf_lb
markusdemedeiros Nov 8, 2024
b8c3ea6
new attempt
markusdemedeiros Nov 8, 2024
b8d910f
checkpoint
markusdemedeiros Nov 9, 2024
9f35e54
checkpoint
markusdemedeiros Nov 9, 2024
2e092b3
skeleton
markusdemedeiros Nov 9, 2024
1c1a02d
checkpoint
markusdemedeiros Nov 9, 2024
24e345a
checkpoint
markusdemedeiros Nov 9, 2024
4948e24
victory
markusdemedeiros Nov 9, 2024
bd4b29a
Parallel composition + instance for pure DP
markusdemedeiros Mar 8, 2025
dce5320
checkpoint par histogram
markusdemedeiros Mar 8, 2025
e37a321
remove Update case of neighbour
markusdemedeiros Mar 10, 2025
ec81463
complete privacy proof
markusdemedeiros Mar 10, 2025
68a3682
add code from submodule
markusdemedeiros Mar 12, 2025
03973b5
checkpoint
markusdemedeiros Mar 12, 2025
8bf9e28
update benchmarks to use different line styles
markusdemedeiros Mar 12, 2025
2ba9c7a
docker
markusdemedeiros Mar 12, 2025
fd38ad9
REPRODUCING.md
markusdemedeiros Mar 17, 2025
724b228
REPRODUCING
markusdemedeiros Mar 17, 2025
3b97a1f
Dockerfile
markusdemedeiros Mar 17, 2025
1e33f2b
nit
markusdemedeiros Mar 17, 2025
1466b38
platform
markusdemedeiros Mar 17, 2025
3cc5e0e
more tweaks
markusdemedeiros Mar 17, 2025
ab91305
check
markusdemedeiros Mar 17, 2025
884e82b
ok
markusdemedeiros Mar 17, 2025
55ed21b
nit
markusdemedeiros Mar 17, 2025
bdb9c71
remove IBM
markusdemedeiros Mar 17, 2025
dc8e61d
cleanup
markusdemedeiros Mar 17, 2025
ebc3400
paper mapping
markusdemedeiros Mar 17, 2025
7e92144
[broken] sv1, sv2
markusdemedeiros Mar 24, 2025
1566132
wow
markusdemedeiros Mar 24, 2025
a279d04
privacy general
markusdemedeiros Mar 25, 2025
eab5348
move and fix executability
markusdemedeiros Mar 25, 2025
5e44ed2
exactdiffsum sensitivity
markusdemedeiros Mar 25, 2025
6c38f4a
generic sv done
markusdemedeiros Mar 25, 2025
ed29f9e
generalize T
markusdemedeiros Mar 25, 2025
231abb9
checkpoint
markusdemedeiros Mar 25, 2025
7b8008a
generalize database type
markusdemedeiros Mar 25, 2025
7786904
Algorithm 2
markusdemedeiros Mar 25, 2025
519cad9
some changes from the artifact
markusdemedeiros Apr 9, 2025
12c90c2
update paepr_mapping
markusdemedeiros Apr 9, 2025
f133a7a
changes for artifact
markusdemedeiros Apr 9, 2025
28ef732
no pbuild
markusdemedeiros Apr 9, 2025
501fdcd
add load
markusdemedeiros Apr 9, 2025
3f474d4
nits for artifact upload
markusdemedeiros Apr 18, 2025
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
40 changes: 40 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
FROM xtrm0/dafny

USER root

RUN apt-get update && apt-get install curl git g++ vim python3-pip -y && apt-get clean

RUN pip install matplotlib scipy tqdm diffprivlib

# create a non-root user
RUN useradd -m lean

USER lean

WORKDIR /home/lean

SHELL ["/bin/bash", "-c"]

ENV PATH="/home/lean/.elan/bin:/home/lean/.local/bin:$PATH"

RUN mkdir SampCert

COPY --chown=lean . ./SampCert/

RUN curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | sh -s -- -y --default-toolchain none && \
. ~/.profile && \
elan toolchain install $(curl https://raw.githubusercontent.com/leanprover-community/mathlib/master/leanpkg.toml | grep lean_version | awk -F'"' '{print $2}') && \
elan default stable

RUN cd SampCert/ && \
lake exe cache get

RUN cd SampCert/ && \
lake build

RUN cd SampCert/ && \
lake build FastExtract && \
dafny build --target:py Tests/SampCert.dfy Tests/Random.py Tests/testing-kolmogorov-discretegaussian.py Tests/testing-kolmogorov-discretelaplace.py Tests/IBM/discretegauss.py Tests/benchmarks.py -o Tests/SampCert.dfy

RUN cd SampCert && \
lake build test
91 changes: 91 additions & 0 deletions REPRODUCING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# SampCert Artifact

Our artifact consists of
- The Lean 4 source code for SampCert, including all proofs mentioned in the paper, and a code extractor used to translate the samplers into Python.
- A script to benchmark the extracted SampCert samplers against other DP implementations.
- A script to profile the number of bytes consumed by the discrete Gaussian sampler.
- A script to run statistical tests on the extracted SampCert samplers.
- A Lean 4 program to run statistical tests on the SampCert samplers and example DP queries, using the Lean FFI.

## Building

To build and enter the artifact, run the following commands (**from the root directory of the artifact**).
```
docker build --platform linux/amd64 -t sampcert .
docker run -it --platform linux/amd64 --name sampcert sampcert /bin/bash
```
This will compile our Lean code, and extract the implementation of our samplers used by our Large Cloud Provider.
We have tested that this image builds and runs on a 2023 M2 Macbook Pro, Ubuntu Linux, and within WSL.
If running this docker image on a ARM system, please ensure that Rosetta2 virtualization is enabled.

Alternatively, you can load our prebuilt docker image using
```
docker image load -i sampcert-image.tar
docker run -it --platform linux/amd64 --name sampcert sampcert /bin/bash
```


## The Lean code

The file `SampCert.lean` is the top-level file in the project.
To check that `definition-name` code is sorry-free, one can add the line
```
#print axioms definition-name
```
to any file and recompile with `lake build` (**from inside the SampCert directory**).
For example, uncommenting `-- #print axioms combineMeanHistogram` at the bottom of `SampCert.lean` will print
```
[2165/2166] Built SampCert
info: ././././SampCert.lean:75:0: 'combineMeanHistogram' depends on axioms: [propext, Classical.choice, Quot.sound]
```
which does not include the axiom `sorryAx`, indicating that the definition and proof is closed.

The file ``paper_mapping.md`` includes a table that lists all of the definitions from our paper.

## Benchmarks

To reproduce our benchmarks (figure 4), run the following command from (**the home directory, inside the artifact**):
```
sh SampCert/Tests/run_benchmark.sh
```
This command will save a reproduction of figure 4 to the home directory. It can be accessed by running the following command (**from outside of the container**).
```
docker cp sampcert:/home/lean/GaussianBenchmarks.pdf .
```

To profile the number of bytes of entropy consumed, we have a version of the code instrumented with logging on a separate branch (``git diff main..PLDI25-profiling`` will show you the differences).
To produce a figure that counts the number of bytes of entropy consumed, run the following (**from the SampCert directory**):
```
git checkout PLDI25-profiling
lake build profile
LD_LIBRARY_PATH=.lake/build/lib/ python3 profile.py
```
To view the profile, it can be copied out of the container by executing the following (**from outside of the container**):
```
docker cp sampcert:/home/lean/SampCert/GaussianProfile.pdf .
```


## Statistical Tests: Extracted samplers

To check that our extracted samplers execute and sample from the correct distribution, we have included a K-S test.
To run the tests on the extracted versions, run the following (**from the home directory, on the main branch**):
```
python3 SampCert/Tests/SampCert-py/testing-kolmogorov-discretegaussian.py
python3 SampCert/Tests/SampCert-py/testing-kolmogorov-discretelaplace.py
```
The script reports `Test passed!` when the kolmogorov distance between the computed and ideal CDF is within `0.02`.


## Tests: FFI samplers

To demonstrate our claim that our code can be executed within Lean using the C FFI we have rewritten the K-S test, as well as several example queries, inside the file `Test.lean`.
To run that file, execute the command (**from the SampCert directory, on the main branch**)
```
lake exe test
```

This will do the following:
- Execute our implementation of the sparse vector technique on randomly generated sample data
- Execute our noised histogram query, and histogram mean queries, on randomly generated sample data,
- Preform statistical tests on our implementation of the discrete Gaussian, and report the Kolmogorov distance as above.
14 changes: 10 additions & 4 deletions SampCert.lean
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ import SampCert.DifferentialPrivacy.Queries.Histogram.Basic
import SampCert.DifferentialPrivacy.ZeroConcentrated.System
import SampCert.DifferentialPrivacy.Pure.System
import SampCert.DifferentialPrivacy.Queries.HistogramMean.Properties
import SampCert.DifferentialPrivacy.Queries.UnboundedMax.Basic
import SampCert.DifferentialPrivacy.Queries.ParHistogram.Basic
import SampCert.DifferentialPrivacy.Queries.Sparse.Basic
import SampCert.DifferentialPrivacy.Queries.AboveThresh.Basic
import SampCert.DifferentialPrivacy.Approximate.DP
import SampCert.Samplers.Gaussian.Properties
import Init.Data.UInt.Lemmas

open SLang PMF

def combineConcentrated := @privNoisedBoundedMean_DP gaussian_zCDPSystem
def combineConcentrated := @privNoisedBoundedMean_DP zCDPSystem
def combinePure := @privNoisedBoundedMean_DP PureDPSystem

/-
Expand All @@ -27,7 +31,7 @@ def numBins : ℕ+ := 64
/-
Bin the infinite type ℕ with clipping
-/
def bin (n : ℕ) : Fin numBins :=
def example_bin (n : ℕ) : Fin numBins :=
{ val := min (Nat.log 2 n) (PNat.natPred numBins),
isLt := by
apply min_lt_iff.mpr
Expand All @@ -40,8 +44,8 @@ Return an upper bound on the bin value, clipped to 2^(1 + numBins)
-/
def unbin (n : Fin numBins) : ℕ+ := 2 ^ (1 + n.val)

noncomputable def combineMeanHistogram : Mechanism ℕ (Option ℚ) :=
privMeanHistogram PureDPSystem numBins { bin } unbin 1 20 2 1 20
def combineMeanHistogram : Mechanism ℕ (Option ℚ) :=
privMeanHistogram PureDPSystem laplace_pureDPSystem numBins { bin := example_bin } unbin 1 20 2 1 20

end histogramMeanExample

Expand Down Expand Up @@ -69,3 +73,5 @@ def DiscreteGaussianSampleGet (num den : UInt32) (mix: UInt32) : UInt32 := Id.ru
else
let z : IO ℤ ← run <| DiscreteGaussianPMF ⟨ num.toNat , UInt32.toNa_of_non_zero h₁ ⟩ ⟨ den.toNat , UInt32.toNa_of_non_zero h₂ ⟩ mix.toNat
return DirtyIOGet z

-- #print axioms combineMeanHistogram
101 changes: 72 additions & 29 deletions SampCert/DifferentialPrivacy/Abstract.lean
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,31 @@ import SampCert.DifferentialPrivacy.Approximate.DP
This file defines an abstract system of differentially private operators.
-/

noncomputable section

open Classical Nat Int Real ENNReal

namespace SLang

/--
Typeclass synonym for the classes we use for probaility
-/
class DiscProbSpace (T : Type) where
instMeasurableSpace : MeasurableSpace T
instCountable : Countable T
instDiscreteMeasurableSpace : DiscreteMeasurableSpace T
instInhabited : Inhabited T

-- Typeclass inference to- and from- the synonym
instance [idps : DiscProbSpace T] : MeasurableSpace T := idps.instMeasurableSpace
instance [idps : DiscProbSpace T] : Countable T := idps.instCountable
instance [idps : DiscProbSpace T] : DiscreteMeasurableSpace T := idps.instDiscreteMeasurableSpace
instance [idps : DiscProbSpace T] : Inhabited T := idps.instInhabited

instance [im : MeasurableSpace T] [ic : Countable T] [idm : DiscreteMeasurableSpace T] [ii : Inhabited T] : DiscProbSpace T where
instMeasurableSpace := im
instCountable := ic
instDiscreteMeasurableSpace := idm
instInhabited := ii

/--
Abstract definition of a differentially private systemm.
-/
Expand All @@ -31,54 +50,52 @@ class DPSystem (T : Type) where
prop : Mechanism T Z → NNReal → Prop

/--
For any δ, prop implies ``ApproximateDP δ ε`` up to a sufficient degradation
of the privacy parameter.
Definition of DP is well-formed: Privacy parameter required to obtain (ε', δ)-approximate DP
-/
prop_adp [Countable Z] {m : Mechanism T Z} :
∃ (degrade : (δ : NNReal) -> (ε' : NNReal) -> NNReal), ∀ (δ : NNReal) (_ : 0 < δ) (ε' : NNReal),
(prop m (degrade δ ε') -> ApproximateDP m ε' δ)
of_app_dp : (δ : NNReal) -> (ε' : NNReal) -> NNReal
/--
DP is monotonic
For any ε', this definition of DP implies (ε', δ)-approximate-DP for all δ
-/
prop_mono {m : Mechanism T Z} {ε₁ ε₂: NNReal} (Hε : ε₁ ≤ ε₂) (H : prop m ε₁) : prop m ε₂
prop_adp [DiscProbSpace Z] {m : Mechanism T Z} : ∀ (δ : NNReal) (_ : 0 < δ) (ε' : NNReal),
(prop m (of_app_dp δ ε') -> ApproximateDP m ε' δ)
/--
A noise mechanism (eg. Laplace, Discrete Gaussian, etc)
Paramaterized by a query, sensitivity, and a (rational) security paramater.
-/
noise : Query T ℤ → (sensitivity : ℕ+) → (num : ℕ+) → (den : ℕ+) → Mechanism T ℤ
/--
Adding noise to a query makes it private.
DP is monotonic
-/
noise_prop : ∀ q : List T → ℤ, ∀ Δ εn εd : ℕ+, sensitivity q Δ → prop (noise q Δ εn εd) (εn / εd)
prop_mono {m : Mechanism T Z} {ε₁ ε₂: NNReal} :
ε₁ ≤ ε₂ -> prop m ε₁ -> prop m ε₂
/--
Privacy adaptively 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,
∀ ε₁ ε₂ : NNReal,
prop m₁ ε₁ → (∀ u, prop (m₂ u) ε₂) -> prop (privComposeAdaptive m₁ m₂) (ε₁ + ε₂)
adaptive_compose_prop {U V : Type} [DiscProbSpace U] [DiscProbSpace V]
{m₁ : Mechanism T U} {m₂ : U -> Mechanism T V} {ε₁ ε₂ ε : NNReal} :
prop m₁ ε₁ → (∀ u, prop (m₂ u) ε₂) ->
ε₁ + ε₂ = ε ->
prop (privComposeAdaptive m₁ m₂) ε
/--
Privacy is invariant under post-processing.
-/
postprocess_prop : {U : Type} → [MeasurableSpace U] → [Countable U] → [DiscreteMeasurableSpace U] → [Inhabited U] → { pp : U → V } →
m : Mechanism T U, ∀ ε : NNReal,
prop m ε → prop (privPostProcess m pp) ε
postprocess_prop {U : Type} [DiscProbSpace U]
{ pp : U → V } {m : Mechanism T U} {ε : NNReal} :
prop m ε → prop (privPostProcess m pp) ε
/--
Constant query is 0-DP
-/
const_prop : {U : Type} → [MeasurableSpace U] → [Countable U] → [DiscreteMeasurableSpace U] -> (u : U) -> prop (privConst u) (0 : NNReal)

const_prop {U : Type} [DiscProbSpace U] {u : U} {ε : NNReal} :
ε = (0 : NNReal) -> prop (privConst u) ε

namespace DPSystem

/-
Non-adaptive privacy composes by addition.
-/
lemma compose_prop {U V : Type} [dps : DPSystem T] [MeasurableSpace U] [Countable U] [DiscreteMeasurableSpace U] [Inhabited U] [MeasurableSpace V] [Countable V] [DiscreteMeasurableSpace V] [Inhabited V] :
∀ m₁ : Mechanism T U, ∀ m₂ : Mechanism T V, ∀ ε₁ ε₂ : NNReal,
dps.prop m₁ ε₁ → dps.prop m₂ ε₂ → dps.prop (privCompose m₁ m₂) (ε₁ + ε₂) := by
intros m₁ m₂ ε₁ ε₂ p1 p2
lemma compose_prop {U V : Type} [dps : DPSystem T] [DiscProbSpace U] [DiscProbSpace V] :
{m₁ : Mechanism T U} -> {m₂ : Mechanism T V} -> {ε₁ ε₂ ε : NNReal} ->
(ε₁ + ε₂ = ε) ->
dps.prop m₁ ε₁ → dps.prop m₂ ε₂ → dps.prop (privCompose m₁ m₂) ε := by
intros _ _ _ _ _ _ p1 p2
unfold privCompose
exact adaptive_compose_prop m₁ (fun _ => m₂) ε₁ ε₂ p1 fun _ => p2
apply adaptive_compose_prop p1 (fun _ => p2)
trivial

end DPSystem

Expand All @@ -96,4 +113,30 @@ lemma bind_bind_indep (p : Mechanism T U) (q : Mechanism T V) (h : U → V → P
ext l x
simp [privCompose, privComposeAdaptive, tsum_prod']

/--
A noise function for a differential privacy system
-/
class DPNoise (dps : DPSystem T) where
/--
A noise mechanism (eg. Laplace, Discrete Gaussian, etc)
Paramaterized by a query, sensitivity, and a (rational) security paramater.
-/
noise : Query T ℤ → (sensitivity : ℕ+) → (num : ℕ+) → (den : ℕ+) → Mechanism T ℤ
/--
Relationship between arguments to noise and resulting privacy amount
-/
noise_priv : (num : ℕ+) → (den : ℕ+) → (priv : NNReal) -> Prop
/--
Adding noise to a query makes it private
-/
noise_prop {q : List T → ℤ} {Δ εn εd : ℕ+} {ε : NNReal} :
noise_priv εn εd ε ->
sensitivity q Δ →
dps.prop (noise q Δ εn εd) ε


class DPPar (T : Type) extends (DPSystem T) where
prop_par {m1 : Mechanism T U} {m2 : Mechanism T V} {ε₁ ε₂ ε : NNReal} :
ε = max ε₁ ε₂ -> ∀f, prop m1 ε₁ -> prop m2 ε₂ -> prop (privParCompose m1 m2 f) ε

end SLang
3 changes: 0 additions & 3 deletions SampCert/DifferentialPrivacy/Approximate/DP.lean
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ Authors: Jean-Baptiste Tristan
import SampCert.SLang
import SampCert.DifferentialPrivacy.Generic
import SampCert.DifferentialPrivacy.Neighbours
-- import SampCert.DifferentialPrivacy.Pure.DP
-- import SampCert.DifferentialPrivacy.ZeroConcentrated.DP
-- import SampCert.Util.Log

noncomputable section

Expand Down
Loading