Type-checking Linear Dependent Types Arthur Azevedo de Amorim 1 2 - - PowerPoint PPT Presentation

type checking linear dependent types
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

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

slide-2
SLIDE 2

2

slide-3
SLIDE 3

2

slide-4
SLIDE 4

2

slide-5
SLIDE 5

Movie Ratings Internet Anonymization

2

slide-6
SLIDE 6

2

slide-7
SLIDE 7

2

slide-8
SLIDE 8

How to allow database queries and retain privacy guarantees?

3

slide-9
SLIDE 9

Differential Privacy

  • Rigorous bound on “privacy loss” [Dwork, 2006]
  • Informally: adding one’s data doesn’t change query results

by much

  • Many available algorithms
  • Statistical analyses, combinatorial optimizations, machine

learning, ...

4

slide-10
SLIDE 10

Ensuring Differential Privacy

Deterministic Query

+

Random Noise Differentially Private Probabilistic Query

5

slide-11
SLIDE 11

Ensuring Differential Privacy

k-sensitive Deterministic Query

+

Random Noise ∝ k Differentially Private Probabilistic Query

5

slide-12
SLIDE 12

Ensuring Differential Privacy

k-sensitive Deterministic Query

+

Random Noise ∝ k Differentially Private Probabilistic Query Bound on result variation

5

slide-13
SLIDE 13

Ensuring Differential Privacy

k-sensitive Deterministic Query

+

Random Noise ∝ k Differentially Private Probabilistic Query Bound on result variation Requires tedious proofs

5

slide-14
SLIDE 14

Types to the Rescue

  • DFuzz [Reed&Pierce10,Gaboardi13] is a type system for

function sensitivity (hence, differential privacy)

  • Capable of expressing many differentially private algorithms
  • Metatheory ensures differential privacy
  • Type-checking algorithm: proof automation

6

slide-15
SLIDE 15

Challenge: Checking and Inference

The DFuzz type system combines interesting features:

  • Linear indexed types
  • Dependent types
  • Subtyping

Their interplay makes it difficult to reuse existing techniques directly

7

slide-16
SLIDE 16

Our Contributions

  • A type-checking and type-inference algorithm for a system

combining linear and dependent types in the presence of subtyping

  • Showing how ideas from the type-checking literature for

those domains can be adapted to a type system built around a special-purpose index language

8

slide-17
SLIDE 17

Outline

  • DFuzz and function sensitivity
  • Type checking and inference for DFuzz

9

slide-18
SLIDE 18

DFuzz and Function Sensitivity

10

slide-19
SLIDE 19

Function Sensitivity

Bound output variation based on input variation f is k-sensitive: d(f(x), f(y)) ≤ k · d(x, y)

11

slide-20
SLIDE 20

Function Sensitivity

Bound output variation based on input variation f is k-sensitive: d(f(x), f(y)) ≤ k · d(x, y) Distance functions

11

slide-21
SLIDE 21

Function Sensitivity

x y D f(x) f(y) f f ≤ k · D

11

slide-22
SLIDE 22

DFuzz in a Nutshell

  • !kσ ⊸ τ: k-sensitive function (= linear)

12

slide-23
SLIDE 23

DFuzz in a Nutshell

  • !kσ ⊸ τ: k-sensitive function (= linear)

Multivariate polynomial

12

slide-24
SLIDE 24

DFuzz in a Nutshell

  • !kσ ⊸ τ: k-sensitive function (= linear)
  • listn σ: list of length n (mechanisms that depend on input

size)

12

slide-25
SLIDE 25

DFuzz in a Nutshell

  • !kσ ⊸ τ: k-sensitive function (= linear)
  • listn σ: list of length n (mechanisms that depend on input

size)

  • σ ⊑ τ: sensitivity weakening (e.g. (!1σ ⊸ τ) ⊑ (!2σ ⊸ τ))

12

slide-26
SLIDE 26

A Basic Example

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

slide-27
SLIDE 27

Analyzing Example

d(map(f, x), map(g, y))

14

slide-28
SLIDE 28

Analyzing Example

d(map(f, x), map(g, y)) k-sensitive

14

slide-29
SLIDE 29

Analyzing Example

d(map(f, x), map(g, y)) length n

14

slide-30
SLIDE 30

Analyzing Example

d(map(f, x), map(g, y)) =

n

  • i=1

d(f(xi), g(yi)) Distance for lists

14

slide-31
SLIDE 31

Analyzing Example

d(map(f, x), map(g, y)) =

n

  • i=1

d(f(xi), g(yi)) ≤

n

  • i=1

[d(f(xi), g(xi)) + d(g(xi), g(yi))] Triangle inequality

14

slide-32
SLIDE 32

Analyzing Example

d(map(f, x), map(g, y)) =

n

  • i=1

d(f(xi), g(yi)) ≤

n

  • i=1

[d(f(xi), g(xi)) + d(g(xi), g(yi))] ≤

n

  • i=1

[d(f, g) + k · d(xi, yi)] Max difference between f and g

14

slide-33
SLIDE 33

Analyzing Example

d(map(f, x), map(g, y)) =

n

  • i=1

d(f(xi), g(yi)) ≤

n

  • i=1

[d(f(xi), g(xi)) + d(g(xi), g(yi))] ≤

n

  • i=1

[d(f, g) + k · d(xi, yi)] Definition of sensitivity

14

slide-34
SLIDE 34

Analyzing Example

d(map(f, x), map(g, y)) =

n

  • i=1

d(f(xi), g(yi)) ≤

n

  • i=1

[d(f(xi), g(xi)) + d(g(xi), g(yi))] ≤

n

  • i=1

[d(f, g) + k · d(xi, yi)] = n · d(f, g) + k · d( x, y)

14

slide-35
SLIDE 35

Typing Example in DFuzz

map : !n(!kσ ⊸ τ) ⊸ !klistn σ ⊸ listn τ

15

slide-36
SLIDE 36

Typing Example in DFuzz

map : !n(!kσ ⊸ τ) ⊸ !klistn σ ⊸ listn τ Argument sensitivities

15

slide-37
SLIDE 37

Some Rules

Γ, x :k σ ⊢ e : τ Γ ⊢ λx :k σ.e : !kσ ⊸ τ (⊸ I)

16

slide-38
SLIDE 38

Some Rules

Γ, x :k σ ⊢ e : τ Γ ⊢ λx :k σ.e : !kσ ⊸ τ (⊸ I) Keep track of sensitivity

16

slide-39
SLIDE 39

Some Rules

Γ, x :k σ ⊢ e : τ Γ ⊢ λx :k σ.e : !kσ ⊸ τ (⊸ I) Propagate sensitivity to type

16

slide-40
SLIDE 40

Some Rules

Γ ⊢ e1 :!kσ ⊸ τ ∆ ⊢ e2 : σ Γ + k · ∆ ⊢ e1 e2 : τ (⊸ E) Context split, combine sensitivities

16

slide-41
SLIDE 41

Some Rules

Γ ⊢ e1 :!kσ ⊸ τ ∆ ⊢ e2 : σ Γ + k · ∆ ⊢ e1 e2 : τ (⊸ E) Composition: multiply sensitivities

16

slide-42
SLIDE 42

Some Rules

∆ ⊢ e : listn σ Γ ⊢ enil : τ Γ, h :k σ, t :k listi σ ⊢ econs : τ Γ + k · ∆ ⊢ case e of [] → enil | h :: t → econs : τ (list E)

16

slide-43
SLIDE 43

Some Rules

∆ ⊢ e : listn σ Γ ⊢ enil : τ Γ, h :k σ, t :k listi σ ⊢ econs : τ Γ + k · ∆ ⊢ case e of [] → enil | h :: t → econs : τ (list E) Assuming n = 0

16

slide-44
SLIDE 44

Some Rules

∆ ⊢ e : listn σ Γ ⊢ enil : τ Γ, h :k σ, t :k listi σ ⊢ econs : τ Γ + k · ∆ ⊢ case e of [] → enil | h :: t → econs : τ (list E) Assuming n = i + 1

16

slide-45
SLIDE 45

Some Rules

∆ ⊢ e : listn σ Γ ⊢ enil : τ Γ, h :k σ, t :k listi σ ⊢ econs : τ Γ + k · ∆ ⊢ case e of [] → enil | h :: t → econs : τ (list E) Track sensitivity on list

16

slide-46
SLIDE 46

Type Checking and Inference

17

slide-47
SLIDE 47

Plan

DFuzz Program

18

slide-48
SLIDE 48

Plan

DFuzz Program Inference

18

slide-49
SLIDE 49

Plan

DFuzz Program Inference σ Constraints

18

slide-50
SLIDE 50

Plan

DFuzz Program Inference σ Constraints Polynomial inequalities from subtyping

18

slide-51
SLIDE 51

Plan

DFuzz Program Inference σ Constraints Solver

18

slide-52
SLIDE 52

Plan

DFuzz Program Inference σ Constraints Solver Yes

18

slide-53
SLIDE 53

Plan

DFuzz Program Inference σ Constraints Solver ⊑ τ?

18

slide-54
SLIDE 54

Plan

DFuzz Program Inference σ Constraints Solver ⊑ τ? Provided by annotation

18

slide-55
SLIDE 55

Plan

DFuzz Program Inference σ Constraints Solver Yes ⊑ τ?

18

slide-56
SLIDE 56

Important Points

  • Context splitting imposes a bottom-up strategy: start with

leaves, combine sensitivities progressively

19

slide-57
SLIDE 57

Important Points

  • Context splitting imposes a bottom-up strategy: start with

leaves, combine sensitivities progressively . . . e1 . . . e2 . . .

19

slide-58
SLIDE 58

Important Points

  • Context splitting imposes a bottom-up strategy: start with

leaves, combine sensitivities progressively . . . e1 . . . e2 . . . e1 : σ1 e2 : σ2

19

slide-59
SLIDE 59

Important Points

  • Context splitting imposes a bottom-up strategy: start with

leaves, combine sensitivities progressively . . . e1 . . . e2 . . . : τ e1 : σ1 e2 : σ2

19

slide-60
SLIDE 60

Important Points

  • Context splitting imposes a bottom-up strategy: start with

leaves, combine sensitivities progressively

  • Restrict subtyping to essential places (e.g. application)

19

slide-61
SLIDE 61

Important Points

  • Context splitting imposes a bottom-up strategy: start with

leaves, combine sensitivities progressively

  • Restrict subtyping to essential places (e.g. application)
  • Assume sensitivities on higher-order types are given

19

slide-62
SLIDE 62

Important Points

  • Context splitting imposes a bottom-up strategy: start with

leaves, combine sensitivities progressively

  • Restrict subtyping to essential places (e.g. application)
  • Assume sensitivities on higher-order types are given

E.g !_(!kα ⊸ α) ⊸ α

19

slide-63
SLIDE 63

Problems

  • Language not rich enough to express minimal sensitivities
  • E.g. point-wise maximum of two polynomials is not a

polynomial

  • Solution: enrich sensitivity language with new operators

20

slide-64
SLIDE 64

Problems

  • Language not rich enough to express minimal sensitivities
  • E.g. point-wise maximum of two polynomials is not a

polynomial

  • Solution: enrich sensitivity language with new operators
  • cf. literature on subtyping

20

slide-65
SLIDE 65

Problems

  • Language not rich enough to express minimal sensitivities
  • E.g. point-wise maximum of two polynomials is not a

polynomial

  • Solution: enrich sensitivity language with new operators
  • Type checking is undecidable
  • Can encode equality of integer polynomials (Hilbert’s tenth

problem)

  • Completeness relative to a decider of sensitivity inequalities

20

slide-66
SLIDE 66

Syntax-Directed Rules

Equivalent to previous ones, but directly translatable to algorithm Input Term, argument type annotations Output Minimal sensitivities, minimal type

21

slide-67
SLIDE 67

Syntax-Directed Rules

Γ ⊢ e1 :!kσ ⊸ τ ∆ ⊢ e2 : σ′ σ′ ⊑ σ Γ + k · ∆ ⊢ e1 e2 : τ (⊸ E)

21

slide-68
SLIDE 68

Syntax-Directed Rules

Γ ⊢ e1 :!kσ ⊸ τ ∆ ⊢ e2 : σ′ σ′ ⊑ σ Γ + k · ∆ ⊢ e1 e2 : τ (⊸ E) Not necessarily equal

21

slide-69
SLIDE 69

Syntax-Directed Rules

Γ ⊢ e1 :!kσ ⊸ τ ∆ ⊢ e2 : σ′ σ′ ⊑ σ Γ + k · ∆ ⊢ e1 e2 : τ (⊸ E) Subtype check

21

slide-70
SLIDE 70

Syntax-Directed Rules

∆ ⊢ 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

slide-71
SLIDE 71

Syntax-Directed Rules

∆ ⊢ 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

slide-72
SLIDE 72

Solver Integration

  • Need to convert constraints so that standard solvers

understand them

  • Avoid alternating quantifiers

22

slide-73
SLIDE 73

Solver Integration

k ≥ case(n, k0, i, ks) (n = 0 ⇒ k ≥ k0) ∧ (∀i, n = i + 1 ⇒ k ≥ ks)

22

slide-74
SLIDE 74

Wrapping Up

23

slide-75
SLIDE 75

Conclusion

  • Type-checking system with linear and dependent types
  • Standard ideas adapted to exploit application domain and

index structure

  • Recover minimal sensitivities by extending index language
  • As simple as possible, no need for much expressive power (cf

[DalLago&Petit13])

24

slide-76
SLIDE 76

Implementation

Available at http://cis.upenn.edu/~emilioga/dFuzz.tar.gz Capable of checking most of the original DFuzz examples

25

slide-77
SLIDE 77

Future Directions

  • Let-generalization for sensitivities (remove higher-order

annotations)

  • Identify decidable fragment of DFuzz

26

slide-78
SLIDE 78

Questions?

27

slide-79
SLIDE 79

Some Metric Spaces

dR(x, y) = |x − y| dσ→τ(f, g) = sup

x∈σ dτ(f(x), g(x))

dlist σ(l1, l2) =

if length(l1) = length(l2)

  • i dσ(l1[i], l2[i])
  • therwise

dset σ(s1, s2) = |s1 \ s2 ∪ s2 \ s1| dP(σ)(µ, ν) =

  • σ

log dµ dν

28

slide-80
SLIDE 80

More Typing Rules

Γ, x :1 σ ⊢ x : σ (Var)

29

slide-81
SLIDE 81

More Typing Rules

Γ, x :∞ σ ⊢ e : σ ∞ · Γ ⊢ fix x : σ.e : σ (Fix)

29

slide-82
SLIDE 82

More Typing Rules

∆ ⊑ Γ Γ ⊢ e : σ σ ⊑ τ ∆ ⊢ e : τ (⊑)

29

slide-83
SLIDE 83

Metric Preservation

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