Higher-Order Approximate Relational Refinement Types for Mechanism - - PowerPoint PPT Presentation

higher order approximate relational refinement types for
SMART_READER_LITE
LIVE PREVIEW

Higher-Order Approximate Relational Refinement Types for Mechanism - - PowerPoint PPT Presentation

Higher-Order Approximate Relational Refinement Types for Mechanism Design and Differential Privacy Gilles Barthe, Marco Gaboardi, Emilio Jess Gallego Arias, Justin Hsu, Aaron Roth, Pierre-Yves Strub UPenn-Mines ParisTech, IMDEA Software


slide-1
SLIDE 1

Higher-Order Approximate Relational Refinement Types for Mechanism Design and Differential Privacy

Gilles Barthe, Marco Gaboardi, Emilio Jesús Gallego Arias, Justin Hsu, Aaron Roth, Pierre-Yves Strub

UPenn-Mines ParisTech, IMDEA Software Institute, Dundee

Gallium Seminar, Nov 17th, 2014

Barthe el al. Verifying MD and DP 1

slide-2
SLIDE 2

Motivation

Software Verification

◮ Reason formally about programs and their behavior. ◮ Increase trust in software, help programmers/designers. ◮ Has important practical and economical utility. ◮ Expressiveness? Automation?

Barthe el al. Verifying MD and DP 2

slide-3
SLIDE 3

Motivation

Software Verification

◮ Reason formally about programs and their behavior. ◮ Increase trust in software, help programmers/designers. ◮ Has important practical and economical utility. ◮ Expressiveness? Automation?

Today:

◮ Verification of probabilistic programs. ◮ Mechanisms: inputs controlled by strategic agents. ◮ Truthfulness: An agent gets best utility when telling the truth. ◮ Privacy: An agent’s information leak is bounded.

Barthe el al. Verifying MD and DP 2

slide-4
SLIDE 4

The Main Challenges

Relational Reasoning Properties of interest are relational, that is, defined over two runs

  • f the same program:

◮ Truthfulness: agent telling the truth vs not. ◮ Privacy: run including the agent vs not.

Barthe el al. Verifying MD and DP 3

slide-5
SLIDE 5

The Main Challenges

Relational Reasoning Properties of interest are relational, that is, defined over two runs

  • f the same program:

◮ Truthfulness: agent telling the truth vs not. ◮ Privacy: run including the agent vs not.

Probabilistic Reasoning Interesting algorithms are randomized, properties rely on:

◮ Expected values. ◮ Distance on distributions.

Barthe el al. Verifying MD and DP 3

slide-6
SLIDE 6

Our Approach:

Related/Precursor Work:

◮ Relational logics. ◮ F∗, RF∗. ◮ CertiCrypt/CertiPriv. ◮ Fuzz/DFuzz.

Barthe el al. Verifying MD and DP 4

slide-7
SLIDE 7

Our Approach:

Related/Precursor Work:

◮ Relational logics. ◮ F∗, RF∗. ◮ CertiCrypt/CertiPriv. ◮ Fuzz/DFuzz.

Our Contributions

◮ Extended type system:

◮ Support for Higher-Order refinements. ◮ Embedding of logical relations! DFuzz soundness proof. ◮ Probabilistic approximate types.

◮ New application domain and examples. ◮ Prototype implementation.

Barthe el al. Verifying MD and DP 4

slide-8
SLIDE 8

The System: Relational Refinement Types

Variables Relational variables, x ∈ XR; left/right instances x⊳, x⊲ ∈ XR⋊

⋉.

Expressions em ::= C | x ∈ X m | e e | λx. e | case e with [ǫ ⇒ e | x :: x ⇒ e] |

letrec↑ f x = e | letrec↓ f x = e

| e↑ | let↑ x = e in e | unitM e | bindM x = e in e Regular Types

  • τ,

σ, . . . ∈ CoreTy ::=

  • | B | N | R | R

+ | L[

τ] τ, σ, . . . ∈ Ty ::=

  • τ | M[τ] | C[τ] | τ → σ

Relational Refinement Types T, U ∈ T ::=

  • τ | Mǫ,δ[T] | C[T] | Π(x :: T). T | {x :: T | φ}

φ, ψ ∈ A ::= Q (x : τ). φ | Q (x :: T). φ | C(φ1, . . . , φn) | e⋊

⋉ = e⋊ ⋉ | e⋊ ⋉ ≤ e⋊ ⋉

C = {⊤/

0, ⊥/ 0, ¬/ 1, ∨/ 2, ∧/ 2, ⇒/ 2}

Barthe el al. Verifying MD and DP 5

slide-9
SLIDE 9

Relational Refinement Types: Example

Regular refinement types no enough to capture some properties. k-sensitive function

f

Barthe el al. Verifying MD and DP 6

slide-10
SLIDE 10

Relational Refinement Types: Example

Regular refinement types no enough to capture some properties. k-sensitive function

f

Barthe el al. Verifying MD and DP 6

slide-11
SLIDE 11

Relational Refinement Types: Example

Regular refinement types no enough to capture some properties. k-sensitive function

f

d < k d

Barthe el al. Verifying MD and DP 6

slide-12
SLIDE 12

Relational Refinement Types: Example

Regular refinement types no enough to capture some properties. k-sensitive function

f

d < k d

∀x1, x2.|f(x1) − f(x2)| ≤ k · |x1 − x2|

Barthe el al. Verifying MD and DP 6

slide-13
SLIDE 13

Relational Refinement Types: Example

Regular refinement types no enough to capture some properties. k-sensitive function

f

d < k d

∀x1, x2.|f(x1) − f(x2)| ≤ k · |x1 − x2| What should the type for f be?

Barthe el al. Verifying MD and DP 6

slide-14
SLIDE 14

Relational Refinement Types: Example

For the property: ∀x1, x2.|f(x1) − f(x2)| ≤ k · |x1 − x2|

Barthe el al. Verifying MD and DP 7

slide-15
SLIDE 15

Relational Refinement Types: Example

For the property: ∀x1, x2.|f(x1) − f(x2)| ≤ k · |x1 − x2| we can do a refinement at a higher type: {f : R → R | ∀x :: R.|f(x⊳) − f(x⊲)| ≤ k · |x⊳ − x⊲|}

Barthe el al. Verifying MD and DP 7

slide-16
SLIDE 16

Relational Refinement Types: Example

For the property: ∀x1, x2.|f(x1) − f(x2)| ≤ k · |x1 − x2| we can do a refinement at a higher type: {f : R → R | ∀x :: R.|f(x⊳) − f(x⊲)| ≤ k · |x⊳ − x⊲|}

  • r we can refer to two copies of the input:

f : Π(x :: R). {r :: R | k · |r⊳ − r⊲| ≤ |x⊳ − x⊲|} Both types are equivalent in our system, but the pre/post style more convenient for reasoning.

Barthe el al. Verifying MD and DP 7

slide-17
SLIDE 17

The System: Semantics

Semantic subytping for non-relational types: ⊢ e : T Γ | = φ[x/e] ⊢ e : {x : T | φ}

Barthe el al. Verifying MD and DP 8

slide-18
SLIDE 18

The System: Semantics

Semantic subytping for non-relational types: ⊢ e : T Γ | = φ[x/e] ⊢ e : {x : T | φ} ⊢ e : T ⇒ e ∈ T

Barthe el al. Verifying MD and DP 8

slide-19
SLIDE 19

The System: Semantics

Semantic subytping for non-relational types: ⊢ e : T Γ | = φ[x/e] ⊢ e : {x : T | φ} ⊢ e : T ⇒ e ∈ T v ∈ T | = φ(v) v ∈ {x : T | φ(x)}

Barthe el al. Verifying MD and DP 8

slide-20
SLIDE 20

The System: Semantics

Semantic subytping for non-relational types: ⊢ e : T Γ | = φ[x/e] ⊢ e : {x : T | φ} ⊢ e : T ⇒ e ∈ T v ∈ T | = φ(v) v ∈ {x : T | φ(x)} Semantic subtyping for HO relational types: Tθ ⊆ |T| × |T| (d1, d2) ∈ τ × τ (d1, d2) ∈ τθ (d1, d2) ∈ Tθ φθ

x⊳ → d1 x⊲ → d2

  • (d1, d2) ∈ {x :: T | φ}θ

(f1, f2) ∈ |T| → |U| ∀(d1, d2) ∈ Tθ. (f1(d1), f2(d2)) ∈ Uθ

x⊳ → d1 x⊲ → d2

  • (f1, f2) ∈ Π(x :: T). Uθ

Barthe el al. Verifying MD and DP 8

slide-21
SLIDE 21

SubTyping

SUB-REFL

G ⊢ T G ⊢ T T

SUB-TRANS G ⊢ T U

G ⊢ U V G ⊢ T V

SUB-LEFT

G ⊢ {x :: T | φ} G ⊢ {x :: T | φ} T

SUB-RIGHT

G ⊢ T U G, x :: U ⊢ φ ∀θ. θ ⊢ G, x :: T ⇒ φθ G ⊢ T {x :: U | φ}

SUB-PROD G ⊢ T2 T1

G, x :: T2 ⊢ U1 U2 G ⊢ Π(x :: T1). U1 Π(x :: T2). U2

Barthe el al. Verifying MD and DP 9

slide-22
SLIDE 22

The System: Typing

The typing judgment relates two programs to a type: G ⊢ e1 ∼ e2 :: T

Barthe el al. Verifying MD and DP 10

slide-23
SLIDE 23

The System: Typing

The typing judgment relates two programs to a type: G ⊢ e1 ∼ e2 :: T Soundness G ⊢ e1 ∼ e2 :: T ⇒ ∀G ⊢ θ, (e1θ, e2θ) ∈ Tθ

Barthe el al. Verifying MD and DP 10

slide-24
SLIDE 24

The System: Typing

The typing judgment relates two programs to a type: G ⊢ e1 ∼ e2 :: T Soundness G ⊢ e1 ∼ e2 :: T ⇒ ∀G ⊢ θ, (e1θ, e2θ) ∈ Tθ Synchronicity In most cases programs are synchronous, so we use: G ⊢ e :: T ≡ G ⊢ e⊳ ∼ e⊲ :: T with e⊳, e⊲ projecting the variables in e.

Barthe el al. Verifying MD and DP 10

slide-25
SLIDE 25

Base Typing Rules

VAR x :: T ∈ dom(G)

G ⊢ x :: T

ABS

G, x :: T ⊢ e :: U G ⊢ λx. e :: Π(x :: T). U

APP G ⊢ ef :: Π(x :: T). U

G ⊢ ea :: T G ⊢ ef ea :: U{x → ea}

Barthe el al. Verifying MD and DP 11

slide-26
SLIDE 26

Base Typing Rules

VAR x :: T ∈ dom(G)

G ⊢ x :: T

ABS

G, x :: T ⊢ e :: U G ⊢ λx. e :: Π(x :: T). U

APP G ⊢ ef :: Π(x :: T). U

G ⊢ ea :: T G ⊢ ef ea :: U{x → ea}

CASE

G ⊢ e :: L[ τ] ∀θ. θ ⊢ G ⇒ skeleton(e⊳, e⊲) G, {e⊳ = e⊲ = ǫ} ⊢ e1 :: T G, x :: τ, y :: L[ τ], {e⊳ = x⊳ :: y⊳ ∧ e⊲ = x⊲ :: y⊲} ⊢ e2 :: T G ⊢ case e with [ǫ ⇒ e1 | x :: y ⇒ e2] :: T

Barthe el al. Verifying MD and DP 11

slide-27
SLIDE 27

Typing Rules for Recursion

To ensure consistency at higher-types, we must embed non-terminating computations in the partiality monad:

LETRECSN

G, f :: Π(x :: T). U ⊢ λx. e :: Π(x :: T). U G ⊢ Π(x :: T). U SN-guard G ⊢ letrec↓ f x = e :: Π(x :: T). U

Barthe el al. Verifying MD and DP 12

slide-28
SLIDE 28

Typing Rules for Recursion

To ensure consistency at higher-types, we must embed non-terminating computations in the partiality monad:

LETRECSN

G, f :: Π(x :: T). U ⊢ λx. e :: Π(x :: T). U G ⊢ Π(x :: T). U SN-guard G ⊢ letrec↓ f x = e :: Π(x :: T). U

LETREC

G ⊢ Π(x :: T). C[U] G, f :: Π(x :: T). C[U] ⊢ λx. e :: Π(x :: T). C[U] G ⊢ letrec f x = e :: Π(x :: T). C[U]

Barthe el al. Verifying MD and DP 12

slide-29
SLIDE 29

Typing Rules for Recursion

To ensure consistency at higher-types, we must embed non-terminating computations in the partiality monad:

LETRECSN

G, f :: Π(x :: T). U ⊢ λx. e :: Π(x :: T). U G ⊢ Π(x :: T). U SN-guard G ⊢ letrec↓ f x = e :: Π(x :: T). U

LETREC

G ⊢ Π(x :: T). C[U] G, f :: Π(x :: T). C[U] ⊢ λx. e :: Π(x :: T). C[U] G ⊢ letrec f x = e :: Π(x :: T). C[U]

UNITC

G ⊢ e :: T G ⊢ e↑ :: C[T]

BINDC

G ⊢ e1 :: C[T1] G ⊢ C[T2] G, x :: T1 ⊢ e2 :: C[T2] G ⊢ let↑ x = e1 in e2 :: C[T2]

Barthe el al. Verifying MD and DP 12

slide-30
SLIDE 30

Asynchronous Rules

ASYM

G ⊢ e1 ∼ e2 :: T G↔ ⊢ e2

↔ ∼ e1 ↔ :: T ↔

AREDLEFT e1 → e′

1

G ⊢ e1 ∼ e2 :: T G ⊢ e′

1 ∼ e2 :: T

Barthe el al. Verifying MD and DP 13

slide-31
SLIDE 31

Asynchronous Rules

ASYM

G ⊢ e1 ∼ e2 :: T G↔ ⊢ e2

↔ ∼ e1 ↔ :: T ↔

AREDLEFT e1 → e′

1

G ⊢ e1 ∼ e2 :: T G ⊢ e′

1 ∼ e2 :: T

ACASE

|G| ⊢ e : L[ τ] |G| ⊢ e′ : |T| G, {e⊳ = ǫ} ⊢ e1 ∼ e′ :: T G, x :: τ, y :: L[ τ], {e⊳ = x⊳ :: y⊳} ⊢ e2 ∼ e′ :: T G ⊢ case e with [ǫ ⇒ e1 | x :: y ⇒ e2] ∼ e′ :: T

Barthe el al. Verifying MD and DP 13

slide-32
SLIDE 32

More on Mechanism Design

Mechanism design is the study of algorithm design where the inputs to the algorithm are controlled by strategic agents, who must be incentivized to faithfully report them.

Barthe el al. Verifying MD and DP 14

slide-33
SLIDE 33

More on Mechanism Design

Mechanism design is the study of algorithm design where the inputs to the algorithm are controlled by strategic agents, who must be incentivized to faithfully report them. Formally

◮ n agents, with type for actions Ai, i ∈ {1, . . . , n}. ◮ A mechanism M : An → O. ◮ A payoff for every agent Pi : O → R+. ◮ Probabilistic algorithms are common!

Payoff becomes expected payoff.

Barthe el al. Verifying MD and DP 14

slide-34
SLIDE 34

More on Mechanism Design

Mechanism design is the study of algorithm design where the inputs to the algorithm are controlled by strategic agents, who must be incentivized to faithfully report them. Formally

◮ n agents, with type for actions Ai, i ∈ {1, . . . , n}. ◮ A mechanism M : An → O. ◮ A payoff for every agent Pi : O → R+. ◮ Probabilistic algorithms are common!

Payoff becomes expected payoff. Verification Incentives are not enough, the agents need to believe them. Verification is an attractive way to convince them.

Barthe el al. Verifying MD and DP 14

slide-35
SLIDE 35

Mechanism Examples

Auctions

◮ Buyers (agents), bids (actions), seller (mechanism). ◮ Outcome: price, goods assignation. ◮ An auction is truthful if the buyer gets maximal payoff when

she reports her true valuation.

Barthe el al. Verifying MD and DP 15

slide-36
SLIDE 36

Mechanism Examples

Auctions

◮ Buyers (agents), bids (actions), seller (mechanism). ◮ Outcome: price, goods assignation. ◮ An auction is truthful if the buyer gets maximal payoff when

she reports her true valuation. Nash Equilibrium Computation

◮ n players, action type A. ◮ Payoff for i, Pi : An → R+, depends on others actions. ◮ The mechanism suggests an action profile (a1, . . . , an). ◮ If all the other players follow the suggestion, player i gets

the best payoff by following too.

Barthe el al. Verifying MD and DP 15

slide-37
SLIDE 37

Digital Goods Auctions

◮ Price a good with infinite supply. (i.e: Digital goods)

Barthe el al. Verifying MD and DP 16

slide-38
SLIDE 38

Digital Goods Auctions

◮ Price a good with infinite supply. (i.e: Digital goods) ◮ Bidders and seller.

Barthe el al. Verifying MD and DP 16

slide-39
SLIDE 39

Digital Goods Auctions

◮ Price a good with infinite supply. (i.e: Digital goods) ◮ Bidders and seller. ◮ Bidders have a secret true value for the item vi, and make a

public bid bi before the price is known.

Barthe el al. Verifying MD and DP 16

slide-40
SLIDE 40

Digital Goods Auctions

◮ Price a good with infinite supply. (i.e: Digital goods) ◮ Bidders and seller. ◮ Bidders have a secret true value for the item vi, and make a

public bid bi before the price is known.

◮ The seller knows the bids, but not the real values. Sets the

price p after the bids.

Barthe el al. Verifying MD and DP 16

slide-41
SLIDE 41

Digital Goods Auctions

◮ Price a good with infinite supply. (i.e: Digital goods) ◮ Bidders and seller. ◮ Bidders have a secret true value for the item vi, and make a

public bid bi before the price is known.

◮ The seller knows the bids, but not the real values. Sets the

price p after the bids.

◮ If bi ≥ p, the bidder i gets the item, with utility vi − p.

Otherwise she doesn’t get it, and utility is 0.

Barthe el al. Verifying MD and DP 16

slide-42
SLIDE 42

Digital Goods Auctions

◮ Price a good with infinite supply. (i.e: Digital goods) ◮ Bidders and seller. ◮ Bidders have a secret true value for the item vi, and make a

public bid bi before the price is known.

◮ The seller knows the bids, but not the real values. Sets the

price p after the bids.

◮ If bi ≥ p, the bidder i gets the item, with utility vi − p.

Otherwise she doesn’t get it, and utility is 0. The auction is truthful if buyers have optimal utility when they reports the true value vi as their bids bi. In general, an auction cannot be truthful if it depends on the bidder’s price!

Barthe el al. Verifying MD and DP 16

slide-43
SLIDE 43

The Fixed Price Auction

Fixed Price Auctions The simplest truthful auction is the fixed price auction. The seller will set p independently of the bid b for a seller with true value v. If b ≥ p, then utility v − p, else 0. Note the bad revenue properties.

Barthe el al. Verifying MD and DP 17

slide-44
SLIDE 44

The Fixed Price Auction

Fixed Price Auctions The simplest truthful auction is the fixed price auction. The seller will set p independently of the bid b for a seller with true value v. If b ≥ p, then utility v − p, else 0. Note the bad revenue properties. Informal proof of truthfulness The price p is fixed, we compare b⊳ = v vs b⊲ = v. The interesting cases are when the bidder gets the item in one run and doesn’t in the other:

◮ If b⊲ got the item, utility is negative, thus less than 0 for the

b⊳ case (remember b⊳ didn’t get the item).

◮ If b⊳ got the item, utility will be greater or equal than 0, thus

better or equal than b⊲’s utility (0).

Barthe el al. Verifying MD and DP 17

slide-45
SLIDE 45

The Fixed Price Auction

We model the utility as a program:

let fp_utility (v : R) {b :: R | b⊳ = v} (p : R) : { u :: R | u⊳ >= u⊲ } = if b >= p then v - p else 0.0

Barthe el al. Verifying MD and DP 18

slide-46
SLIDE 46

The Fixed Price Auction

We model the utility as a program:

let fp_utility (v : R) {b :: R | b⊳ = v} (p : R) : { u :: R | u⊳ >= u⊲ } = if b >= p then v - p else 0.0

Barthe el al. Verifying MD and DP 18

slide-47
SLIDE 47

The Fixed Price Auction

We model the utility as a program:

let fp_utility (v : R) {b :: R | b⊳ = v} (p : R) : { u :: R | u⊳ >= u⊲ } = if b >= p then v - p else 0.0

We use asynchronous reasoning. The interesting case is: {b⊳ = v, b⊳ ≥ p, b⊲ < p} ⊢ v − p ∼ 0.0 :: {u :: R | u⊳ ≥ u⊲} substituting [v − p/u⊳, 0.0/u⊲] we get the proof obligation:

Barthe el al. Verifying MD and DP 18

slide-48
SLIDE 48

The Fixed Price Auction

We model the utility as a program:

let fp_utility (v : R) {b :: R | b⊳ = v} (p : R) : { u :: R | u⊳ >= u⊲ } = if b >= p then v - p else 0.0

We use asynchronous reasoning. The interesting case is: {b⊳ = v, b⊳ ≥ p, b⊲ < p} ⊢ v − p ∼ 0.0 :: {u :: R | u⊳ ≥ u⊲} substituting [v − p/u⊳, 0.0/u⊲] we get the proof obligation: v ≥ p ⇒ v − p ≥ 0.0

Barthe el al. Verifying MD and DP 18

slide-49
SLIDE 49

The Distribution Type

We didn’t specify the semantics of relational distribution types. A first approach to lifting (µ1, µ2) ∈ M[|T|] × M[|T|] (µ1, µ2) ∈ M[T]θ

Barthe el al. Verifying MD and DP 19

slide-50
SLIDE 50

The Distribution Type

We didn’t specify the semantics of relational distribution types. A first approach to lifting (d1, d2) ∈ Tθ (µ1, µ2) ∈ M[|T|] × M[|T|] (µ1, µ2) ∈ M[T]θ

Barthe el al. Verifying MD and DP 19

slide-51
SLIDE 51

The Distribution Type

We didn’t specify the semantics of relational distribution types. A first approach to lifting ?? (d1, d2) ∈ Tθ (µ1, µ2) ∈ M[|T|] × M[|T|] (µ1, µ2) ∈ M[T]θ

Barthe el al. Verifying MD and DP 19

slide-52
SLIDE 52

The Distribution Type

We didn’t specify the semantics of relational distribution types. A first approach to lifting ?? (d1, d2) ∈ Tθ (µ1, µ2) ∈ M[|T|] × M[|T|] (µ1, µ2) ∈ M[T]θ We need to relate (d1, d2) to (µ1, µ2)!

Barthe el al. Verifying MD and DP 19

slide-53
SLIDE 53

The Distribution Type

We didn’t specify the semantics of relational distribution types. A first approach to lifting ?? (d1, d2) ∈ Tθ (µ1, µ2) ∈ M[|T|] × M[|T|] (µ1, µ2) ∈ M[T]θ We need to relate (d1, d2) to (µ1, µ2)! Solution: define a lifting of the relation Tθ through a witness distribution µ = M[|T| × |T|], such that: Pr

x←µ1 x ∈ T =

  • y∈T

Pr

(x,y)←µ(x, y) ∈ Tθ

Barthe el al. Verifying MD and DP 19

slide-54
SLIDE 54

Lifting

More formally, for a relation Φ : T1 × T2, the predicate L(Φ) µ1 µ2 holds iff there exists a distribution µ ∈ M[T1 × T2] such that for every H ⊆ T1, we have Pr

x←µ1[H(x)] =

  • y∈T2

Pr

(x,y)←µ[H(x) ∧ Φ(x, y)]

and symmetrically for T2. “Probability of events in µ1 µ2 must respect the relation”.

Barthe el al. Verifying MD and DP 20

slide-55
SLIDE 55

Examples of Lifting

As an example, for Φ ≡ {(F, F), (F, T), (T, T)} we have liftings: µ1(F) = 2/3 µ(F, F) = 1/3 µ1(T) = 1/3 µ(F, T) = 1/3 µ2(F) = 1/3 µ(T, F) = 0 µ2(T) = 2/3 µ(T, T) = 1/3 µ1(F) = 1 µ(F, F) = 1 µ1(T) = 0 µ(F, T) = 0 µ2(F) = 1 µ(T, F) = 0 µ2(T) = 0 µ(T, T) = 0

Barthe el al. Verifying MD and DP 21

slide-56
SLIDE 56

Semantics of the Distribution Type

We can now interpret the relational distribution type as all the distributions satisfying the lifting: µ1, µ2 ∈ M[|T|] L(Tθ) µ1 µ2 (µ1, µ2) ∈ M[T]θ In particular, the type M[{x :: T | x⊳ = x⊲}] forces equal distributions.

Barthe el al. Verifying MD and DP 22

slide-57
SLIDE 57

Higher-Order Refinements and Probability

Expectation Expectation of a function f over µ is: E µ f :=

  • x∈D

(f x) · (µ x)

Barthe el al. Verifying MD and DP 23

slide-58
SLIDE 58

Higher-Order Refinements and Probability

Expectation Expectation of a function f over µ is: E µ f :=

  • x∈D

(f x) · (µ x) We capture monotonicity of expectation as: I := [0, 1] IBF := {f :: D → I | ∀d : D. f⊳ d ≥ f⊲ d} E : Π(µ :: M[{x :: D | x⊳ = x⊲}]). Π(f :: IBF). {e :: I | e⊳ ≥ e⊲} Sound as a primitive; other types are possible.

Barthe el al. Verifying MD and DP 23

slide-59
SLIDE 59

Randomized Auctions

◮ Using the probabilistic primitives, we can now define and

verify randomized auctions, which have much better revenue properties than the fixed price one.

◮ The price a bidder gets won’t still depend on her bid,

however:

◮ we randomly split the bidders in two groups, ga, gb, we

compute the revenue-maximizing price for each group, pa, pb, and sell to ga using pb and conversely.

◮ This auction is truthful on the expected utility.

Universal truthfulness: A bidder will be never able to gain from lying, even knowing the random coins of the mechanism.

Barthe el al. Verifying MD and DP 24

slide-60
SLIDE 60

The Competitive Auction

let utility (v : real) (bid :: { b :: R | b⊳ = v }) (otherbids : L[R]) (g, groups) : (B * L[B]) : { u :: real | u⊳ >= u⊲ } = match split g bid others otherbids with | (g1, g2) → if g then fixedprice v bid (prices g2) else fixedprice v bid (prices g1) let auction (n : N) (v : R) (bid :: { b :: R | b⊳ = v }) (otherbids : L[R]) : { u :: real | u⊳ >= u⊲ } = let grouping :: M{ r :: (B * B list) | r⊳ = r⊲} = mlet mycoin = flip in mlet coins = flipN n in munit (mycoin, coins) in E grouping (utility v bid otherbids)

Barthe el al. Verifying MD and DP 25

slide-61
SLIDE 61

The Competitive Auction

let E (mu : M[ r : α | r⊳ = r⊲ ]) (f : α →real | ∀ x : α, f⊳ x >= f⊲ x) : { r :: real | r⊳ >= r⊲ } = .... let utility (v : real) (bid :: { b :: R | b⊳ = v }) (otherbids : L[R]) (g, groups) : (B * L[B]) : { u :: real | u⊳ >= u⊲ } = ... let auction (n : N) (v : R) (bid :: { b :: R | b⊳ = v }) (otherbids : L[R]) : { u :: real | u⊳ >= u⊲ } = let grouping :: M{ r :: (B * B list) | r⊳ = r⊲} = ... in E grouping (utility v bid otherbids)

Barthe el al. Verifying MD and DP 26

slide-62
SLIDE 62

Differential Privacy

Contribution of a single individual to the output of a mechanism cannot be effectively distinguished by an attacker under worst-case assumptions.

Barthe el al. Verifying MD and DP 27

slide-63
SLIDE 63

Differential Privacy

Formal Definition A probabilistic function F : T → S is (ǫ, δ)-Differentially Private if for all pairs of adjacent t1, t2 ∈ T and for every E ⊆ S: Pr

x←F t1

[x ∈ E] ≤ exp(ǫ) Pr

x←F t2

[x ∈ E] + δ

Barthe el al. Verifying MD and DP 28

slide-64
SLIDE 64

Differential Privacy

Formal Definition A probabilistic function F : T → S is (ǫ, δ)-Differentially Private if for all pairs of adjacent t1, t2 ∈ T and for every E ⊆ S: Pr

x←F t1

[x ∈ E] ≤ exp(ǫ) Pr

x←F t2

[x ∈ E] + δ Example: The Laplace Mechanism:

◮ Compute the sensitivity k of f. ◮ For input t, release f(t) + random noise, scaled by k.

Barthe el al. Verifying MD and DP 28

slide-65
SLIDE 65

Differential Privacy

Formal Definition A probabilistic function F : T → S is (ǫ, δ)-Differentially Private if for all pairs of adjacent t1, t2 ∈ T and for every E ⊆ S: Pr

x←F t1

[x ∈ E] ≤ exp(ǫ) Pr

x←F t2

[x ∈ E] + δ Example: The Laplace Mechanism:

◮ Compute the sensitivity k of f. ◮ For input t, release f(t) + random noise, scaled by k.

Many algorithms are DP: private database release, counters, analytics, strong connection to Mechanism Design!

Barthe el al. Verifying MD and DP 28

slide-66
SLIDE 66

Approximately Reasoning over Distributions

We can capture DP with a refinement over the type of probability distributions using the definition of ∆-distance: ∆ǫ(µ1, µ2) = max

E⊆U

  • Pr

x←µ2[x ∈ E] − exp(ǫ) Pr x←µ1[x ∈ E]

  • Barthe el al.

Verifying MD and DP 29

slide-67
SLIDE 67

Approximately Reasoning over Distributions

We can capture DP with a refinement over the type of probability distributions using the definition of ∆-distance: ∆ǫ(µ1, µ2) = max

E⊆U

  • Pr

x←µ2[x ∈ E] − exp(ǫ) Pr x←µ1[x ∈ E]

  • Then, f is (ǫ, δ) differentially private if it has type:

{d :: T | Adj(d⊳, d⊲)} → {r :: M[R] | ∆ǫ(r⊳, r⊲) ≤ δ} However, verification conditions involving ∆ are quite hard.

Barthe el al. Verifying MD and DP 29

slide-68
SLIDE 68

The Relational Distribution Type

Our solution: Internalize distribution distance in the types: µ1, µ2 ∈ M[|T|] Lǫ,δ(Tθ) µ1 µ2 (µ1, µ2) ∈ Mǫ,δ[T]θ Lifting is extended from p = p1 to p ≤ p1 ≤ exp(p) + δ.

Barthe el al. Verifying MD and DP 30

slide-69
SLIDE 69

The Relational Distribution Type

Our solution: Internalize distribution distance in the types: µ1, µ2 ∈ M[|T|] Lǫ,δ(Tθ) µ1 µ2 (µ1, µ2) ∈ Mǫ,δ[T]θ Lifting is extended from p = p1 to p ≤ p1 ≤ exp(p) + δ. Capturing DP The interpretation of Mǫ,δ[{r :: R | r⊳ = r⊲}] is the set of pairs of probability distributions that are (ǫ, δ)-apart, capturing DP.

Barthe el al. Verifying MD and DP 30

slide-70
SLIDE 70

The Relational Distribution Type

Our solution: Internalize distribution distance in the types: µ1, µ2 ∈ M[|T|] Lǫ,δ(Tθ) µ1 µ2 (µ1, µ2) ∈ Mǫ,δ[T]θ Lifting is extended from p = p1 to p ≤ p1 ≤ exp(p) + δ. Capturing DP The interpretation of Mǫ,δ[{r :: R | r⊳ = r⊲}] is the set of pairs of probability distributions that are (ǫ, δ)-apart, capturing DP. DP algorithms are typed as: f : {d :: T | Adj(d⊳, d⊲)} → Mǫ,δ[{r :: R | r⊳ = r⊲}]

Barthe el al. Verifying MD and DP 30

slide-71
SLIDE 71

The Probability Polymonad

Reasoning about distance is compositional:

SUB-M G ⊢ T U

∀θ. θ ⊢ G, x :: T ⇒ ǫ1 ≤ ǫ2 ∧ δ1 ≤ δ2θ G ⊢ Mǫ1,δ1[T] Mǫ2,δ2[U]

UNITM

G ⊢ e :: T G ⊢ unitM e :: Mǫ,δ[T]

BINDM G ⊢ e1 :: Mǫ1,δ1[T1]

G, x :: T1 ⊢ e2 :: Mǫ2,δ2[T2] G ⊢ bindM x = e1 in e2 :: Mǫ1+ǫ2,δ1+δ2[T2] Bind is distance-adjusting sampling.

Barthe el al. Verifying MD and DP 31

slide-72
SLIDE 72

Type for the Laplace Mechanism

Recall the Laplace Mechanism: For a k-sensitive f, f plus k/ǫ-scaled Laplacian noise is DP . This is captured by the type:

Barthe el al. Verifying MD and DP 32

slide-73
SLIDE 73

Type for the Laplace Mechanism

Recall the Laplace Mechanism: For a k-sensitive f, f plus k/ǫ-scaled Laplacian noise is DP . This is captured by the type: lap : Π(ǫ :: R). Π(x :: R). Mǫ∗|x⊳−x⊲|,0[{r :: R | r⊳ = r⊲}] Note that the actual distance ǫ ∗ |x⊳ − x⊲| depends on the distance of the inputs. This is a better alternative than using a precondition on x.

Barthe el al. Verifying MD and DP 32

slide-74
SLIDE 74

Type for the Laplace Mechanism

Recall the Laplace Mechanism: For a k-sensitive f, f plus k/ǫ-scaled Laplacian noise is DP . This is captured by the type: lap : Π(ǫ :: R). Π(x :: R). Mǫ∗|x⊳−x⊲|,0[{r :: R | r⊳ = r⊲}] Note that the actual distance ǫ ∗ |x⊳ − x⊲| depends on the distance of the inputs. This is a better alternative than using a precondition on x. Using the bind rule, we can sample from laplace and assume the sampled value equal in both runs.

Barthe el al. Verifying MD and DP 32

slide-75
SLIDE 75

Example: Private Histogram

We add noise to an histogram to make it private.

let rec histogram {l :: L(R) | Adj x⊳ x⊲) } : M[e * d(l⊳,l⊲)] { r :: L(R) | r⊳ = r⊲ } = match l with | []

→ unit []

| x :: xs → mlet y = lap eps x in mlet ys = histogram xs in munit (y :: ys)

Barthe el al. Verifying MD and DP 33

slide-76
SLIDE 76

Example: Private Histogram

We add noise to an histogram to make it private.

let rec histogram {l :: L(R) | Adj x⊳ x⊲) } : M[e * d(l⊳,l⊲)] { r :: L(R) | r⊳ = r⊲ } = match l with | []

→ unit []

| x :: xs → mlet y = lap eps x in mlet ys = histogram xs in munit (y :: ys)

The main proof obligation is: e ∗ d(x⊳ :: xs⊳, x⊲ :: xs⊲) ≥ e ∗ (d(x⊳, x⊲) + d(xs⊳, xs⊲)) which is implied by the adjacency precondition.

Barthe el al. Verifying MD and DP 33

slide-77
SLIDE 77

Combining MD and DP: Aggregative Games

◮ We verify the computation of an approximate

Nash-equilibrium.

◮ n agents can choose over a space of actions ai ∈ A.

Barthe el al. Verifying MD and DP 34

slide-78
SLIDE 78

Combining MD and DP: Aggregative Games

◮ We verify the computation of an approximate

Nash-equilibrium.

◮ n agents can choose over a space of actions ai ∈ A. ◮ (a1, . . . , an) is an α-approximate Nash-equilibrium if no

single agent i can gain more than α payoff by unilateral deviation: For all agents i and actions a′

i:

E[Pi(a1, . . . , ai, . . . aN)] ≥ E[Pi(a1, . . . , a′

i, . . . aN)] − α.

Barthe el al. Verifying MD and DP 34

slide-79
SLIDE 79

Combining MD and DP: Aggregative Games

◮ We verify the computation of an approximate

Nash-equilibrium.

◮ n agents can choose over a space of actions ai ∈ A. ◮ (a1, . . . , an) is an α-approximate Nash-equilibrium if no

single agent i can gain more than α payoff by unilateral deviation: For all agents i and actions a′

i:

E[Pi(a1, . . . , ai, . . . aN)] ≥ E[Pi(a1, . . . , a′

i, . . . aN)] − α. ◮ Assumption: Payoff for i depends only on ai plus a signal, a

positive (bounded) real number depending on the aggregated actions of all players.

Barthe el al. Verifying MD and DP 34

slide-80
SLIDE 80

Combining MD and DP: Aggregative Games

◮ The key: use differential privacy to compute the equilibria. ◮ Mediator: The mechanism suggests the equilibria action ai. ◮ We prove that the player gets optimal utility if she does ai. ◮ We reason over a deviation function devi for player i.

Barthe el al. Verifying MD and DP 35

slide-81
SLIDE 81

Combining MD and DP: Aggregative Games

◮ The key: use differential privacy to compute the equilibria. ◮ Mediator: The mechanism suggests the equilibria action ai. ◮ We prove that the player gets optimal utility if she does ai. ◮ We reason over a deviation function devi for player i.

In types:

let aggregative_utility ( ... ) { dev :: act → act | ∀ a : act. dev⊳ a = a) } : { u :: real | u⊳ >= u⊲ - alpha }

Barthe el al. Verifying MD and DP 35

slide-82
SLIDE 82

Combining MD and DP: Aggregative Games

◮ The key: use differential privacy to compute the equilibria. ◮ Mediator: The mechanism suggests the equilibria action ai. ◮ We prove that the player gets optimal utility if she does ai. ◮ We reason over a deviation function devi for player i.

In types:

let aggregative_utility ( ... ) { dev :: act → act | ∀ a : act. dev⊳ a = a) } : { u :: real | u⊳ >= u⊲ - alpha }

Relate expectation to distance on the distributions: E : Π(µ :: Mǫ,δ[{x :: I | x⊳ ≤ x⊲ + c}]). {e :: I | e⊳ ≤ e⊲ + ǫ + c + δe−ǫ}

Barthe el al. Verifying MD and DP 35

slide-83
SLIDE 83

The Implementation

◮ Hybrid SMT/Bidirectional type checking. ◮ Why3 as the SMT backend, multiple solvers required. ◮ Verification using top-level annotations (+2 cuts). ◮ Top-level types act as the specification. ◮ Support for debug of type-checking failures important.

Barthe el al. Verifying MD and DP 36

slide-84
SLIDE 84

Benchmarks

Example # Lines

  • Verif. time

histogram

25 2.66 s.

dummysum

31 11.95 s.

noisysum

55 3.64 s.

two-level-a

38 2.55 s.

two-level-b

56 3.94 s.

binary

95 18.56 s.

idc

73 27.60 s.

dualquery

128 27.71 s.

competitive-b

81 2.80 s.

competitive

75 4.19 s.

fixedprice

10 0.90 s.

summarization

471 238.42 s.

Table : Benchmarks

Barthe el al. Verifying MD and DP 37

slide-85
SLIDE 85

Future work and Conclusions:

Future Work:

◮ More examples from the algorithms community. ◮ More examples from the security/cryptography domain. ◮ More properties: accuracy, fancier distributions. ◮ Extensions to the language.

Barthe el al. Verifying MD and DP 38

slide-86
SLIDE 86

Future work and Conclusions:

Future Work:

◮ More examples from the algorithms community. ◮ More examples from the security/cryptography domain. ◮ More properties: accuracy, fancier distributions. ◮ Extensions to the language.

Conclusions

◮ Higher-Order Approximate Probabilistic Relational

Refinement Types: HOARe2

◮ Built-in support for approximate reasoning. ◮ Logic seems to capture many examples. ◮ Automatic verification worked reasonably well. ◮ SMT interaction is still a challenge.

Barthe el al. Verifying MD and DP 38

slide-87
SLIDE 87

Thank you

Questions?

Barthe el al. Verifying MD and DP 39

slide-88
SLIDE 88

More on the Aggregative Example:

Expected Payoff for the deviating agent

let expay br* dev* br dev =

E (mlet

sums = mkSums k br* br in let

s•

= search k br* br sums in let a* = dev* (br* s•) in let a = dev (br

s•)

in let p* = pay* a* (sign a* a) in munit p*) (λx. x)

s• is close to the true signal on the strategy profile.

Barthe el al. Verifying MD and DP 1

slide-89
SLIDE 89

More on the Aggregative Example:

Type for expay {br* :: R → A | ∀s, a. pay* (br*⊳ s) s ≥ pay* a s} → {dev* :: A → A | ∀x. dev*⊳ x = x} → {br :: R → A | br⊳ = br⊲} → {dev :: A → A | ∀a. dev⊳ a = dev⊲ a = a} → {u :: R

+

| u⊳ ≥ u⊲ − α}. Extended type for Laplace

lap with a refinement type capturing accuracy:

Π(x :: R). Mǫ|x⊳−x⊲|,β[{u :: R | u⊳ = u⊲ ∧ |x⊳ − u⊳| < T}]

Barthe el al. Verifying MD and DP 2