Type-checking Linear Dependent Types
Arthur Azevedo de Amorim 1 2 Marco Gaboardi 3 Emilio Jesús Gallego Arias 1 Justin Hsu 1
1University of Pennsylvania 2INRIA Paris-Rocquencourt 3University of Dundee 1
Type-checking Linear Dependent Types Arthur Azevedo de Amorim 1 2 - - PowerPoint PPT Presentation
Type-checking Linear Dependent Types Arthur Azevedo de Amorim 1 2 Marco Gaboardi 3 Emilio Jess Gallego Arias 1 Justin Hsu 1 1 University of Pennsylvania 2 INRIA Paris-Rocquencourt 3 University of Dundee 1 2 2 2 Anonymization Movie Ratings
Arthur Azevedo de Amorim 1 2 Marco Gaboardi 3 Emilio Jesús Gallego Arias 1 Justin Hsu 1
1University of Pennsylvania 2INRIA Paris-Rocquencourt 3University of Dundee 1
2
2
2
Movie Ratings Internet Anonymization
2
2
2
3
by much
learning, ...
4
Deterministic Query
Random Noise Differentially Private Probabilistic Query
5
k-sensitive Deterministic Query
Random Noise ∝ k Differentially Private Probabilistic Query
5
k-sensitive Deterministic Query
Random Noise ∝ k Differentially Private Probabilistic Query Bound on result variation
5
k-sensitive Deterministic Query
Random Noise ∝ k Differentially Private Probabilistic Query Bound on result variation Requires tedious proofs
5
function sensitivity (hence, differential privacy)
6
The DFuzz type system combines interesting features:
Their interplay makes it difficult to reuse existing techniques directly
7
combining linear and dependent types in the presence of subtyping
those domains can be adapted to a type system built around a special-purpose index language
8
9
10
Bound output variation based on input variation f is k-sensitive: d(f(x), f(y)) ≤ k · d(x, y)
11
Bound output variation based on input variation f is k-sensitive: d(f(x), f(y)) ≤ k · d(x, y) Distance functions
11
x y D f(x) f(y) f f ≤ k · D
11
12
Multivariate polynomial
12
size)
12
size)
12
Consider the standard map function function map f l { case l of { | [] => [] | x :: l’ => f x :: map f l’ } } How to bound “distance” between results of two calls?
13
d(map(f, x), map(g, y))
14
d(map(f, x), map(g, y)) k-sensitive
14
d(map(f, x), map(g, y)) length n
14
d(map(f, x), map(g, y)) =
n
d(f(xi), g(yi)) Distance for lists
14
d(map(f, x), map(g, y)) =
n
d(f(xi), g(yi)) ≤
n
[d(f(xi), g(xi)) + d(g(xi), g(yi))] Triangle inequality
14
d(map(f, x), map(g, y)) =
n
d(f(xi), g(yi)) ≤
n
[d(f(xi), g(xi)) + d(g(xi), g(yi))] ≤
n
[d(f, g) + k · d(xi, yi)] Max difference between f and g
14
d(map(f, x), map(g, y)) =
n
d(f(xi), g(yi)) ≤
n
[d(f(xi), g(xi)) + d(g(xi), g(yi))] ≤
n
[d(f, g) + k · d(xi, yi)] Definition of sensitivity
14
d(map(f, x), map(g, y)) =
n
d(f(xi), g(yi)) ≤
n
[d(f(xi), g(xi)) + d(g(xi), g(yi))] ≤
n
[d(f, g) + k · d(xi, yi)] = n · d(f, g) + k · d( x, y)
14
map : !n(!kσ ⊸ τ) ⊸ !klistn σ ⊸ listn τ
15
map : !n(!kσ ⊸ τ) ⊸ !klistn σ ⊸ listn τ Argument sensitivities
15
Γ, x :k σ ⊢ e : τ Γ ⊢ λx :k σ.e : !kσ ⊸ τ (⊸ I)
16
Γ, x :k σ ⊢ e : τ Γ ⊢ λx :k σ.e : !kσ ⊸ τ (⊸ I) Keep track of sensitivity
16
Γ, x :k σ ⊢ e : τ Γ ⊢ λx :k σ.e : !kσ ⊸ τ (⊸ I) Propagate sensitivity to type
16
Γ ⊢ e1 :!kσ ⊸ τ ∆ ⊢ e2 : σ Γ + k · ∆ ⊢ e1 e2 : τ (⊸ E) Context split, combine sensitivities
16
Γ ⊢ e1 :!kσ ⊸ τ ∆ ⊢ e2 : σ Γ + k · ∆ ⊢ e1 e2 : τ (⊸ E) Composition: multiply sensitivities
16
∆ ⊢ e : listn σ Γ ⊢ enil : τ Γ, h :k σ, t :k listi σ ⊢ econs : τ Γ + k · ∆ ⊢ case e of [] → enil | h :: t → econs : τ (list E)
16
∆ ⊢ e : listn σ Γ ⊢ enil : τ Γ, h :k σ, t :k listi σ ⊢ econs : τ Γ + k · ∆ ⊢ case e of [] → enil | h :: t → econs : τ (list E) Assuming n = 0
16
∆ ⊢ e : listn σ Γ ⊢ enil : τ Γ, h :k σ, t :k listi σ ⊢ econs : τ Γ + k · ∆ ⊢ case e of [] → enil | h :: t → econs : τ (list E) Assuming n = i + 1
16
∆ ⊢ e : listn σ Γ ⊢ enil : τ Γ, h :k σ, t :k listi σ ⊢ econs : τ Γ + k · ∆ ⊢ case e of [] → enil | h :: t → econs : τ (list E) Track sensitivity on list
16
17
DFuzz Program
18
DFuzz Program Inference
18
DFuzz Program Inference σ Constraints
18
DFuzz Program Inference σ Constraints Polynomial inequalities from subtyping
18
DFuzz Program Inference σ Constraints Solver
18
DFuzz Program Inference σ Constraints Solver Yes
18
DFuzz Program Inference σ Constraints Solver ⊑ τ?
18
DFuzz Program Inference σ Constraints Solver ⊑ τ? Provided by annotation
18
DFuzz Program Inference σ Constraints Solver Yes ⊑ τ?
18
leaves, combine sensitivities progressively
19
leaves, combine sensitivities progressively . . . e1 . . . e2 . . .
19
leaves, combine sensitivities progressively . . . e1 . . . e2 . . . e1 : σ1 e2 : σ2
19
leaves, combine sensitivities progressively . . . e1 . . . e2 . . . : τ e1 : σ1 e2 : σ2
19
leaves, combine sensitivities progressively
19
leaves, combine sensitivities progressively
19
leaves, combine sensitivities progressively
E.g !_(!kα ⊸ α) ⊸ α
19
polynomial
20
polynomial
20
polynomial
problem)
20
Equivalent to previous ones, but directly translatable to algorithm Input Term, argument type annotations Output Minimal sensitivities, minimal type
21
Γ ⊢ e1 :!kσ ⊸ τ ∆ ⊢ e2 : σ′ σ′ ⊑ σ Γ + k · ∆ ⊢ e1 e2 : τ (⊸ E)
21
Γ ⊢ e1 :!kσ ⊸ τ ∆ ⊢ e2 : σ′ σ′ ⊑ σ Γ + k · ∆ ⊢ e1 e2 : τ (⊸ E) Not necessarily equal
21
Γ ⊢ e1 :!kσ ⊸ τ ∆ ⊢ e2 : σ′ σ′ ⊑ σ Γ + k · ∆ ⊢ e1 e2 : τ (⊸ E) Subtype check
21
∆ ⊢ e : listn σ Γ ⊢ enil : τnil Γ, h :k σ, t :k listi σ ⊢ econs : τcons τ = case(n, τnil, i, τcons) Γ + k · ∆ ⊢ case e of [] → enil | h :: t → econs : τ (list E)
21
∆ ⊢ e : listn σ Γ ⊢ enil : τnil Γ, h :k σ, t :k listi σ ⊢ econs : τcons τ = case(n, τnil, i, τcons) Γ + k · ∆ ⊢ case e of [] → enil | h :: t → econs : τ (list E) Sensitivity-level case lifted to types
21
understand them
22
k ≥ case(n, k0, i, ks) (n = 0 ⇒ k ≥ k0) ∧ (∀i, n = i + 1 ⇒ k ≥ ks)
22
23
index structure
[DalLago&Petit13])
24
Available at http://cis.upenn.edu/~emilioga/dFuzz.tar.gz Capable of checking most of the original DFuzz examples
25
annotations)
26
27
dR(x, y) = |x − y| dσ→τ(f, g) = sup
x∈σ dτ(f(x), g(x))
dlist σ(l1, l2) =
if length(l1) = length(l2)
dset σ(s1, s2) = |s1 \ s2 ∪ s2 \ s1| dP(σ)(µ, ν) =
log dµ dν
28
Γ, x :1 σ ⊢ x : σ (Var)
29
Γ, x :∞ σ ⊢ e : σ ∞ · Γ ⊢ fix x : σ.e : σ (Fix)
29
∆ ⊑ Γ Γ ⊢ e : σ σ ⊑ τ ∆ ⊢ e : τ (⊑)
29
Suppose ⊢ e :!kσ ⊸ τ ⊢ v1 : σ ⊢ v2 : σ e v1 →∗ v′
1
There exists v′
2 such that e v2 →∗ v′ 2 and
dτ(v′
1, v′ 2) ≤ k · dσ(v1, v2)
30