SLIDE 1 Synthesizing Probabilistic Invariants via Doob’s decomposition
- G. Barthe, T. Espitau, L.M.F Fioriti, J. Hsu
CAV, 2016
SLIDE 2
Introduction
1
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 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 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
Martingale theory 101 (I)
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.
Countably additive mapping P : F → [0, 1] P(Ω) = 1. Probability space
SLIDE 8 Martingale theory 101 (II)
Step 2: Stochastic process
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 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 Martingale theory 101 (III)
Step 3: Expectations & Moments
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 Martingale theory 101 (IV)
Step 4 ( Final! ): Martingales
E [ Xi | Fi-1 ] = Xi-1 Average value of the current step is equal to the value of the previous step
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
Black Magic of martingales
Optional Stopping theorem (Mi) martingale → Expectations are invariants E[Mj] = E[M0]
SLIDE 14
Black Magic of martingales
Optional Stopping theorem E[Mj] = E[M0]
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 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
Let’s play with a program...
SLIDE 18 Geometric distribution
x[0] ← 0; while (z ̸= 0) do z ←$ Bern(p, {1, 0}); x ← x[-1] + z; end
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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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
Automatization
Inputs
SLIDE 43
Automatization
Inputs Extract Poly.
SLIDE 44
Automatization
Inputs Extract Poly. Doob decomp.
SLIDE 45
Automatization
Inputs Extract Poly. Doob decomp. Simplify
SLIDE 46
Automatization
Inputs Extract Poly. Doob decomp. OST Simplify
SLIDE 47
Automatization
Inputs Extract Poly. Doob decomp. OST Simplify Verify Hints.
SLIDE 48
Automatization
Inputs Extract Poly. Doob decomp. OST Simplify Simplify Verify Hints.
SLIDE 49
Gambler’s ruin
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
Automatization
Inputs Extract Poly.
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
Automatization
Inputs Extract Poly. Doob decomp.
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
Automatization
Inputs Extract Poly. Doob decomp. OST Simplify
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
Automatization
Inputs Extract Poly. Doob decomp. OST Simplify Verify Hints.
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
Automatization
Inputs Extract Poly. Doob decomp. OST Simplify Simplify Verify Hints.
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 Gambler’s ruin
x[0] ← a; while (0 < x < b) do z ←$ Bern(1/2, {-1, 1}); x ← x + z; end
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
Automatization
Inputs Extract Poly.
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
Automatization
Inputs Extract Poly. Doob decomp.
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
Automatization
Inputs Extract Poly. Doob decomp. OST Simplify
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
Automatization
Inputs Extract Poly. Doob decomp. OST Simplify Verify Hints.
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
Automatization
Inputs Extract Poly. Doob decomp. OST Simplify Simplify Verify Hints.
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 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 Gambler’s ruin
x[0] ← a; while (0 < x < b) do z ←$ Bern(1/2, {-1, 1}); x ← x + z; end
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 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 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 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 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 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 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 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 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
Questions?