Synthesizing Probabilistic Invariants via Doobs decomposition G. - - PowerPoint PPT Presentation

synthesizing probabilistic invariants via doob s
SMART_READER_LITE
LIVE PREVIEW

Synthesizing Probabilistic Invariants via Doobs decomposition G. - - PowerPoint PPT Presentation

Synthesizing Probabilistic Invariants via Doobs decomposition G. Barthe, T. Espitau , L.M.F Fioriti, J. Hsu CAV, 2016 Introduction 1 Introduction Probabilistic 1 2 Computations Ubiquitous in many fields (ML, Crypto, Privacy,)


slide-1
SLIDE 1

Synthesizing Probabilistic Invariants via Doob’s decomposition

  • G. Barthe, T. Espitau, L.M.F Fioriti, J. Hsu

CAV, 2016

slide-2
SLIDE 2

Introduction

1

slide-3
SLIDE 3

Introduction

1 Probabilistic Computations 2

Ubiquitous in many fields (ML, Crypto, Privacy,…) But… Difficult to prove Termination ? (Certainly, almost sure, non terminating)

slide-4
SLIDE 4

Introduction

1 Probabilistic Computations 2 Martingales? 3 Doob’s Decomposition

Ubiquitous in many fields (ML, Crypto, Privacy,…) But… Difficult to prove Termination ? (Certainly, almost sure, non terminating) Difficulty to transfer local to end of program Reason on average values Martingales have the required transfer property

slide-5
SLIDE 5

Introduction

1 Probabilistic Computations 2 Martingales? 3 Doob’s Decomposition

Ubiquitous in many fields (ML, Crypto, Privacy,…) But… Difficult to prove Termination ? (Certainly, almost sure, non terminating) Difficulty to transfer local to end of program Reason on average values Martingales have the required transfer property But (again)… Difficult to find good ones Automated generation? Doob’s decomposition Formal method to generate martingales from a seed.

slide-6
SLIDE 6

Martingale theory 101 (I)

slide-7
SLIDE 7

Martingale theory 101 (I)

Step 1: Some probabilities

  • Ω set of outcomes.
  • Sigma algebra:

Set F of subsets of Ω Closed under complements, countable unions, countable intersections.

  • Probability measure:

Countably additive mapping P : F → [0, 1] P(Ω) = 1. Probability space

slide-8
SLIDE 8

Martingale theory 101 (II)

Step 2: Stochastic process

  • Random variable:

X : Ω → R measurable ( X-1 ( (a,b] ) ∈F )

  • Filtration: ( Fi ) ⊂ F s.t:

Fi-1 ⊂ Fi

  • Process wrt filtration Fi:

Sequence (Xi) s.t: Xi is Fi measurable

slide-9
SLIDE 9

Martingale theory 101 (II)

Interlude: PL setting Ω: Element = Possible outcome of samples Fi: Events sampled at iteration i or before Process (Xi) is adapted to the filtration iff: Xi is defined in term of elements sampled at step i or before

i = 0 While b do z[i] ←$ Samplings... x[i] ← f(x[i-1], ... , f[0], z[i], … ,z[0]) i++ end

slide-10
SLIDE 10

Martingale theory 101 (III)

Step 3: Expectations & Moments

  • Expectation:

E[X] = ∑u∈Ω X(u) P(u)

  • Conditional expectation wrt G ⊂ F: E[X|G]

Y G-mesurable st E[X.1A ] = E[Y.1A] for A∈G

slide-11
SLIDE 11

Martingale theory 101 (IV)

Step 4 ( Final! ): Martingales

  • Martingale:

E [ Xi | Fi-1 ] = Xi-1 Average value of the current step is equal to the value of the previous step

slide-12
SLIDE 12

Playing with martingales

Doob’s decomposition (Xi) stochastic process → (Mi) martingale M0 = X0 Mi = X0 + ∑i

j=1 Xj - E [Xj | Fj-1]

slide-13
SLIDE 13

Black Magic of martingales

Optional Stopping theorem (Mi) martingale → Expectations are invariants E[Mj] = E[M0]

slide-14
SLIDE 14

Black Magic of martingales

Optional Stopping theorem E[Mj] = E[M0]

slide-15
SLIDE 15

Black Magic of martingales

Optional Stopping theorem E[MT] = E[M0] For T a stopping time : T : Ω → R { w ∈ Ω | T(w) ≤ i } ⊂ Fi

slide-16
SLIDE 16

Black Magic of martingales

Optional Stopping theorem E[MT] = E[M0] For T a stopping time : T : Ω → R { w ∈ Ω | T(w) ≤ i } ⊂ Fi

and...

|Mi - Mi-1 | ≤ C E[T] < ∞

slide-17
SLIDE 17

Let’s play with a program...

slide-18
SLIDE 18

Geometric distribution

x[0] ← 0; while (z ̸= 0) do z ←$ Bern(p, {1, 0}); x ← x[-1] + z; end

slide-19
SLIDE 19

Geometric distribution

x[0] ← 0; while (z ̸= 0) do z ←$ Bern(p, {1, 0}); x ← x[-1] + z; end

Stopping time? (on average)

slide-20
SLIDE 20

Geometric distribution

x[0] ← 0; while (z ̸= 0) do z ←$ Bern(p, {1, 0}); x ← x[-1] + z; end

Stopping time? (on average) 1/(1-p)

slide-21
SLIDE 21

Geometric distribution

x[0] ← 0; while (z ̸= 0) do z ←$ Bern(p, {1, 0}); x ← x[-1] + z; end

Equation for x? Xi = Xi-1 + Zi

slide-22
SLIDE 22

Geometric distribution

x[0] ← 0; while (z ̸= 0) do z ←$ Bern(p, {1, 0}); x ← x[-1] + z; end

Equation for x? Xi = Xi-1 + Zi Polynomial extraction

slide-23
SLIDE 23

Geometric distribution

x[0] ← 0; while (z ̸= 0) do z ←$ Bern(p, {1, 0}); x ← x[-1] + z; end

Xi = Xi-1 + Zi M0 = X0 Mi = X0 + ∑i

j=1 Xj - E[Xj | Fj-1]

Doob

slide-24
SLIDE 24

Geometric distribution

x[0] ← 0; while (z ̸= 0) do z ←$ Bern(p, {1, 0}); x ← x[-1] + z; end

Xi = Xi-1 + Zi M0 = 0 Mi = X0 + ∑i

j=1 Xj - E[Xj | Fj-1]

slide-25
SLIDE 25

Geometric distribution

x[0] ← 0; while (z ̸= 0) do z ←$ Bern(p, {1, 0}); x ← x[-1] + z; end

Xi = Xi-1 + Zi M0 = 0 Mi = ∑i

j=1 Xj - E[Xj | Fj-1]

slide-26
SLIDE 26

Geometric distribution

x[0] ← 0; while (z ̸= 0) do z ←$ Bern(p, {1, 0}); x ← x[-1] + z; end

Xi = Xi-1 + Zi M0 = 0 Mi = ∑i

j=1 Xj - E[Xj-1 + Zi | Fj-1]

slide-27
SLIDE 27

Geometric distribution

x[0] ← 0; while (z ̸= 0) do z ←$ Bern(p, {1, 0}); x ← x[-1] + z; end

Xi = Xi-1 + Zi M0 = 0 Mi = ∑i

j=1 Xj - E[Xj-1 | Fj-1] + E[Zi | Fj-1]

slide-28
SLIDE 28

Geometric distribution

x[0] ← 0; while (z ̸= 0) do z ←$ Bern(p, {1, 0}); x ← x[-1] + z; end

Xi = Xi-1 + Zi M0 = 0 Mi = ∑i

j=1 Xj - E[Xj-1 | Fj-1] + E[Zi ]

slide-29
SLIDE 29

Geometric distribution

x[0] ← 0; while (z ̸= 0) do z ←$ Bern(p, {1, 0}); x ← x[-1] + z; end

Xi = Xi-1 + Zi M0 = 0 Mi = ∑i

j=1 Xj - E[Xj-1 | Fj-1] + p

slide-30
SLIDE 30

Geometric distribution

x[0] ← 0; while (z ̸= 0) do z ←$ Bern(p, {1, 0}); x ← x[-1] + z; end

Xi = Xi-1 + Zi M0 = 0 Mi = ∑i

j=1 Xj - Xj-1 + p

slide-31
SLIDE 31

Geometric distribution

x[0] ← 0; while (z ̸= 0) do z ←$ Bern(p, {1, 0}); x ← x[-1] + z; end

Xi = Xi-1 + Zi M0 = 0 Mi = Xi - X0 + i p

slide-32
SLIDE 32

Geometric distribution

x[0] ← 0; while (z ̸= 0) do z ←$ Bern(p, {1, 0}); x ← x[-1] + z; end

Xi = Xi-1 + Zi M0 = 0 Mi = Xi + i p Simplify...

slide-33
SLIDE 33

Geometric distribution

x[0] ← 0; while (z ̸= 0) do z ←$ Bern(p, {1, 0}); x ← x[-1] + z; end

M0 = 0 Mi = Xi + i p Xi = Xi-1 + Zi

slide-34
SLIDE 34

Geometric distribution

x[0] ← 0; while (z ̸= 0) do z ←$ Bern(p, {1, 0}); x ← x[-1] + z; end

M0 = 0 Mi = Xi + i p Xi = Xi-1 + Zi E[ M0 ] = E[ MT] Optional Stopping

slide-35
SLIDE 35

Geometric distribution

x[0] ← 0; while (z ̸= 0) do z ←$ Bern(p, {1, 0}); x ← x[-1] + z; end

M0 = 0 Mi = Xi + i p Xi = Xi-1 + Zi 0 = E[ MT]

slide-36
SLIDE 36

Geometric distribution

x[0] ← 0; while (z ̸= 0) do z ←$ Bern(p, {1, 0}); x ← x[-1] + z; end

M0 = 0 Mi = Xi + i p Xi = Xi-1 + Zi 0 = E[ XT- Tp]

slide-37
SLIDE 37

Geometric distribution

x[0] ← 0; while (z ̸= 0) do z ←$ Bern(p, {1, 0}); x ← x[-1] + z; end

M0 = 0 Mi = Xi + i p Xi = Xi-1 + Zi 0 = E[ XT] - E[ Tp]

slide-38
SLIDE 38

Geometric distribution

x[0] ← 0; while (z ̸= 0) do z ←$ Bern(p, {1, 0}); x ← x[-1] + z; end

M0 = 0 Mi = Xi + i p Xi = Xi-1 + Zi 0 = E[ XT] - p E[T] Simplify...

slide-39
SLIDE 39

Geometric distribution

x[0] ← 0; while (z ̸= 0) do z ←$ Bern(p, {1, 0}); x ← x[-1] + z; end

M0 = 0 Mi = Xi + i p Xi = Xi-1 + Zi 0 = E[T-1] - p E[T] Hint XT = T-1

slide-40
SLIDE 40

Geometric distribution

x[0] ← 0; while (z ̸= 0) do z ←$ Bern(p, {1, 0}); x ← x[-1] + z; end

M0 = 0 Mi = Xi + i p Xi = Xi-1 + Zi 0 = E[T] - 1 - p E[T]

slide-41
SLIDE 41

Geometric distribution

x[0] ← 0; while (z ̸= 0) do z ←$ Bern(p, {1, 0}); x ← x[-1] + z; end

M0 = 0 Mi = Xi + i p Xi = Xi-1 + Zi E[T] = 1 /(1-p) Simplify...

slide-42
SLIDE 42

Automatization

Inputs

slide-43
SLIDE 43

Automatization

Inputs Extract Poly.

slide-44
SLIDE 44

Automatization

Inputs Extract Poly. Doob decomp.

slide-45
SLIDE 45

Automatization

Inputs Extract Poly. Doob decomp. Simplify

slide-46
SLIDE 46

Automatization

Inputs Extract Poly. Doob decomp. OST Simplify

slide-47
SLIDE 47

Automatization

Inputs Extract Poly. Doob decomp. OST Simplify Verify Hints.

slide-48
SLIDE 48

Automatization

Inputs Extract Poly. Doob decomp. OST Simplify Simplify Verify Hints.

slide-49
SLIDE 49

Gambler’s ruin

slide-50
SLIDE 50

Gambler’s ruin

x[0] ← a; while (0 < x < b) do z ←$ Bern(1/2, {-1, 1}); x ← x + z; end

X

slide-51
SLIDE 51

Automatization

Inputs Extract Poly.

slide-52
SLIDE 52

Gambler’s ruin

x[0] ← a; while (0 < x < b) do z ←$ Bern(1/2, {-1, 1}); x ← x + z; end

Xi = Xi-1 + Zi

slide-53
SLIDE 53

Automatization

Inputs Extract Poly. Doob decomp.

slide-54
SLIDE 54

Gambler’s ruin

x[0] ← a; while (0 < x < b) do z ←$ Bern(1/2, {-1, 1}); x ← x + z; end

Xi = Xi-1 + Zi M0 = X0 Mi = Xi

slide-55
SLIDE 55

Automatization

Inputs Extract Poly. Doob decomp. OST Simplify

slide-56
SLIDE 56

Gambler’s ruin

x[0] ← a; while (0 < x < b) do z ←$ Bern(1/2, {-1, 1}); x ← x + z; end

Xi = Xi-1 + Zi M0 = X0 Mi = Xi a = E[X0] = E[XT]

slide-57
SLIDE 57

Automatization

Inputs Extract Poly. Doob decomp. OST Simplify Verify Hints.

slide-58
SLIDE 58

Gambler’s ruin

x[0] ← a; while (0 < x < b) do z ←$ Bern(1/2, {-1, 1}); x ← x + z; end

Xi = Xi-1 + Zi M0 = X0 Mi = Xi a = E[X0] = E[XT] x=0 or x=b

slide-59
SLIDE 59

Automatization

Inputs Extract Poly. Doob decomp. OST Simplify Simplify Verify Hints.

slide-60
SLIDE 60

Gambler’s ruin

x[0] ← a; while (0 < x < b) do z ←$ Bern(1/2, {-1, 1}); x ← x + z; end

Xi = Xi-1 + Zi M0 = X0 Mi = Xi a = E[X0] = E[XT] x=0 or x=b a = b P[x=b]

slide-61
SLIDE 61

Gambler’s ruin

x[0] ← a; while (0 < x < b) do z ←$ Bern(1/2, {-1, 1}); x ← x + z; end

slide-62
SLIDE 62

Gambler’s ruin

x[0] ← a; while (0 < x < b) do z ←$ Bern(1/2, {-1, 1}); x ← x + z; end

X2

slide-63
SLIDE 63

Automatization

Inputs Extract Poly.

slide-64
SLIDE 64

Gambler’s ruin

x[0] ← a; while (0 < x < b) do z ←$ Bern(1/2, {-1, 1}); x ← x + z; end

X2 Xi

2 = (Xi-1 + Zi)2

slide-65
SLIDE 65

Automatization

Inputs Extract Poly. Doob decomp.

slide-66
SLIDE 66

Gambler’s ruin

x[0] ← a; while (0 < x < b) do z ←$ Bern(1/2, {-1, 1}); x ← x + z; end

M0 = X0

2 Mi = Xi 2-i

Xi

2 = (Xi-1 + Zi)2

slide-67
SLIDE 67

Automatization

Inputs Extract Poly. Doob decomp. OST Simplify

slide-68
SLIDE 68

Gambler’s ruin

x[0] ← a; while (0 < x < b) do z ←$ Bern(1/2, {-1, 1}); x ← x + z; end

M0 = X0 Mi = Xi a2 = E[X0

2] = E[XT 2 - T]

Xi

2 = (Xi-1 + Zi)2

M0 = X0

2 Mi = Xi 2-i

slide-69
SLIDE 69

Automatization

Inputs Extract Poly. Doob decomp. OST Simplify Verify Hints.

slide-70
SLIDE 70

Gambler’s ruin

x[0] ← a; while (0 < x < b) do z ←$ Bern(1/2, {-1, 1}); x ← x + z; end

M0 = X0 Mi = Xi a = E[X0] = E[XT] x=0 or x=b Xi

2 = (Xi-1 + Zi)2

M0 = X0

2 Mi = Xi 2-i

M0 = X0 Mi = Xi a2 = E[X0

2] = E[XT 2 - T]

M0 = X0

2 Mi = Xi 2-i

slide-71
SLIDE 71

Automatization

Inputs Extract Poly. Doob decomp. OST Simplify Simplify Verify Hints.

slide-72
SLIDE 72

Gambler’s ruin

x[0] ← a; while (0 < x < b) do z ←$ Bern(1/2, {-1, 1}); x ← x + z; end

M0 = X0 Mi = Xi a = E[X0] = E[XT] x=0 or x=b a2 = b2 P[x=b]-E[T] Xi

2 = (Xi-1 + Zi)2

M0 = X0

2 Mi = Xi 2-i

M0 = X0 Mi = Xi a2 = E[X0

2] = E[XT 2 - T]

M0 = X0

2 Mi = Xi 2-i

slide-73
SLIDE 73

Gambler’s ruin

x[0] ← a; while (0 < x < b) do z ←$ Bern(1/2, {-1, 1}); x ← x + z; end

a2 = b2 P[x=b]-E[T] a = b P[x=b] E[T] = a(b-a)

slide-74
SLIDE 74

Gambler’s ruin

x[0] ← a; while (0 < x < b) do z ←$ Bern(1/2, {-1, 1}); x ← x + z; end

slide-75
SLIDE 75

Abracadabra

match0[0] ←1; match1[0] ←0; ... match11[0] ← 0; while (match11 == 0) do s ←$ UnifMatches; match11 ← match10[-1] * π11(s); match10 ← match9[-1] * π10(s); ... match1 ← match0[-1] * π1(s); end

slide-76
SLIDE 76

Abracadabra

match0[0] ←1; match1[0] ←0; ... match11[0] ← 0; while (match11 == 0) do s ←$ UnifMatches; match11 ← match10[-1] * π11(s); match10 ← match9[-1] * π10(s); ... match1 ← match0[-1] * π1(s); end

slide-77
SLIDE 77

Abracadabra

match0[0] ←1; match1[0] ←0; ... match11[0] ← 0; while (match11 == 0) do s ←$ UnifMatches; match11 ← match10[-1] * π11(s); match10 ← match9[-1] * π10(s); ... match1 ← match0[-1] * π1(s); end

1+ L· match1 +···+L11 ·match11

slide-78
SLIDE 78

Abracadabra

match0[0] ←1; match1[0] ←0; ... match11[0] ← 0; while (match11 == 0) do s ←$ UnifMatches; match11 ← match10[-1] * π11(s); match10 ← match9[-1] * π10(s); ... match1 ← match0[-1] * π1(s); end

1+ L· match1 +···+L11 ·match11

1+L+...+L11 - [ 1+ L· match1 +···+L11 ·match11 ] decreases with Pr 1/L

slide-79
SLIDE 79

Abracadabra

match0[0] ←1; match1[0] ←0; ... match11[0] ← 0; while (match11 == 0) do s ←$ UnifMatches; match11 ← match10[-1] * π11(s); match10 ← match9[-1] * π10(s); ... match1 ← match0[-1] * π1(s); end

1+ L· match1 +···+L11 ·match11 E[T] = L+L4+L11

slide-80
SLIDE 80

Abracadabra

match0[0] ←1; match1[0] ←0; ... match11[0] ← 0; while (match11 == 0) do s ←$ UnifMatches; match11 ← match10[-1] * π11(s); match10 ← match9[-1] * π10(s); ... match1 ← match0[-1] * π1(s); end

1+ L· match1 +···+L11 ·match11 E[T] = 26+264+2611

slide-81
SLIDE 81

Abracadabra

match0[0] ←1; match1[0] ←0; ... match11[0] ← 0; while (match11 == 0) do s ←$ UnifMatches; match11 ← match10[-1] * π11(s); match10 ← match9[-1] * π10(s); ... match1 ← match0[-1] * π1(s); end

1+ L· match1 +···+L11 ·match11 E[T] =

3670344487444778

slide-82
SLIDE 82

Abracadabra

match0[0] ←1; match1[0] ←0; ... match11[0] ← 0; while (match11 == 0) do s ←$ UnifMatches; match11 ← match10[-1] * π11(s); match10 ← match9[-1] * π10(s); ... match1 ← match0[-1] * π1(s); end

1+ L· match1 +···+L11 ·match11 E[T] =

3670344487444778

116 385 860 years...

slide-83
SLIDE 83

In a nutshell

  • Program + Seed → Martingale
  • Martingale + OST → Expectation at the stopping time
  • f loop
  • Works symbolically , only requires AS-termination
  • POC written in Python+SymPy, runs in less than a

second for simplest example to 6s for Abracadabra.

slide-84
SLIDE 84

Questions?