On Higher-Order Probabilistic Subrecursion
Flavien BREUVART, Ugo Dal Lago
Focus, Inria team, Bologna
LC&A: 2016 September 6
When are the Probabilities Computationally Necessary?
Are all distributions deterministically representable?
Finite Representation prob
³
M→k´= fg(k)(k) ∈Q Functional Representation prob
³
M→k´=Pnf(n2n,k) ∈R
Parametrization ForM:N→N
When is (infinite) randomization useful?
Monte Carlo
f(n)reached with prob>12+² Las Vegas
f(n)reached and ascertained with prob>²
Dynamic/Strict bounds Make²dynamic/null
Different classes
Complexity Primitive Rec. HO Prim. Rec. Recursive
BPP
ZPP
NP,PP Exponential
Blow Up
future work Depending on
Prob. Operators
When are the Probabilities Computationally Necessary?
Are all distributions deterministically representable?
Finite Representation prob
³
M→k´= fg(k)(k) ∈Q Functional Representation prob
³
M→k´=Pnf(n2n,k) ∈R
Parametrization ForM:N→N
When is (infinite) randomization useful?
Monte Carlo
f(n)reached with prob>12+² Las Vegas
f(n)reached and ascertained with prob>²
Dynamic/Strict bounds Make²dynamic/null
Different classes
Complexity Primitive Rec. HO Prim. Rec. Recursive
BPP
ZPP
NP,PP Exponential
Blow Up
future work Depending on
Prob. Operators
When are the Probabilities Computationally Necessary?
Are all distributions deterministically representable?
Finite Representation prob
³
M→k´= fg(k)(k) ∈Q Functional Representation prob
³
M→k´=Pnf(n2n,k) ∈R
Parametrization ForM:N→N
When is (infinite) randomization useful?
Monte Carlo
f(n)reached with prob>12+² Las Vegas
f(n)reached and ascertained with prob>²
Dynamic/Strict bounds Make²dynamic/null
Different classes
Complexity Primitive Rec. HO Prim. Rec. Recursive BPP
ZPP
NP,PP Exponential
Blow Up
future work Depending on
Prob. Operators
When are the Probabilities Computationally Necessary?
Are all distributions deterministically representable?
Finite Representation prob
³
M→k´= fg(k)(k) ∈Q Functional Representation prob
³
M→k´=Pnf(n2n,k) ∈R
Parametrization ForM:N→N
When is (infinite) randomization useful?
Monte Carlo
f(n)reached with prob>12+² Las Vegas
f(n)reached and ascertained with prob>²
Dynamic/Strict bounds Make²dynamic/null
Different classes
Complexity Primitive Rec. HO Prim. Rec. Recursive
BPP
ZPP
NP,PP Exponential
Blow Up
future work Depending on
Prob. Operators
When are the Probabilities Computationally Necessary?
Are all distributions deterministically representable?
Finite Representation prob
³
M→k´= fg(k)(k) ∈Q Functional Representation prob
³
M→k´=Pnf(n2n,k) ∈R
Parametrization ForM:N→N
When is (infinite) randomization useful?
Monte Carlo
f(n)reached with prob>12+² Las Vegas
f(n)reached and ascertained with prob>²
Dynamic/Strict bounds Make²dynamic/null
Different classes
Complexity Primitive Rec. HO Prim. Rec. Recursive
BPP
ZPP
NP,PP Exponential
Blow Up
future work Depending on
Prob. Operators
Gödel’s System T :
A Language for HO Primitive Recursion
Gödel’s System
T(Call-by-Value)
M,N,L ::= x | λx.M | M N | rec | 0 | S
recM N 0 → M recM N (Sn)→N n (recM N n)
Γ,x:A`x:A
Γ,x:A`M:B Γ`λx.M:A→B
Γ`M:A→B Γ`N:A Γ`M N:B
Γ`0:N Γ`S:N→N Γ`rec:A→(N→A→A)→N→A
A Powerful System
•
Corresponds to provably recursive functions in Peano arithmetic•
Encodes any monad (states, exceptions, continuations...)Probabilistic Systems T
Different Probabilistic Extensions for System
T M,N,L ::= x | λx.M | M N | rec | 0 | S | M⊕N | X | R(3⊕4)⊕2
3⊕4 2
3 4
1
2 1
2
1
2 1
2
Finite
tree X S 0
0 S(X S 0) 1 SS(X S 0)
2 . ..
1 2
1 2
1 2
1 2
1
2 1
2
Finitely branching
Finite paths
R
0 1 2 3 4
1
2 1
4 1
8 1
24
TL ⊂ TR = TX
Almost Sure Convergence
TL,R,X
is Almost Surely Converging
∀M∈TL,R,X, Prob(M⇓)=1
Idea of Reducibility
1)By induction onA, we define RedA⊆{M| `M:A}, 2)By induction on→:
M→N∈RedA ⇒ M∈RedA, 20)RedA is inhabited (ind. onA)
3)By induction onA:
RedA⊆ASC, 4)By induction onM:
`M:A ⇒ M∈RedA,
Specificities for Probabilities
Item 3)becomes:
3)RedA are exactly the ASC terms that are evaluated into
[[M]]⊆RedA.
We also need a technical lemma 0)The application is continuous:
[[M N]] = hh[[M]] [[N]]ii.
Finite Representation of T
L’s Distributions
∀M∈TL(N),∃N∈T(N→Q), Prob(M→k) :=NF(N k)
Using a Finite Random Tape Using a Single Memory Cell s :
N(N1⊕N2)†:=if(even!s) (s:=!s/2;N1) (s:=!s/2;N2)
State Passing Transformation
M† λs.M‡
Counting Occurrences
P(M→k) :=
#ns≤2m|M‡→ko 2m
formsufficiently large.
T-Computable (simple recursion on s)
Exists since the execution of M∈TL is bounded
Parametrization: How do we calculate the bound 2
m?
Feasible but more technical: we use a more complex monad.
When are the Probabilities Computationally Necessary?
Are all distributions deterministically representable?
Finite Representation prob
³
M→k´= fg(k)(k) ∈Q Functional Representation prob
³
M→k´=Pnf(n2n,k) ∈R
Parametrization ForM:N→N
When is (infinite) randomization useful?
Monte Carlo
f(n)reached with prob>12+² Las Vegas
f(n)reached and ascertained with prob>²
Dynamic/Strict bounds Make²dynamic/null
Different classes
Complexity Primitive Rec. HO Prim. Rec. Recursive
BPP
ZPP
NP,PP Exponential
Blow Up
future work Depending on
Prob. Operators
Functional Representation of Probabilistic recursive functions
What is a functional representation?
LetM a probabilistic program that output an integer with probability 1.
We look for a recursive functionf:N→R
N→N
such that:
prob(M→k)=f(k)
X n
f(k)(n) 2n
let f M k n :=
let tab : Rational[] in let rec simul M p:=
eval M with
"return k" -> tab[k] += 1/(2^p);
"if coin then L else N" -> { newThread{simul L (p+1)}; newThread{simul N (p+1)}; };
in newthread{simul M 0}; newThread{
while ( sum tab < 1-1/n ) do skip; return tab[k];
}
tab: dynamical approximation Updating tabon terminating
branches
Run probabilistic choicesin parallel Waitingfor a reasonable
approximation
Functional Representation of Probabilistic recursive functions
What is a functional representation?
LetM a probabilistic program that output an integer with probability 1.
We look for a recursive functionf:N→N→N such that:
prob(M→k)=X
n
f(k)(n) 2n
let f M k n :=
let tab : Rational[] in let rec simul M p:=
eval M with
"return k" -> tab[k] += 1/(2^p);
"if coin then L else N" -> { newThread{simul L (p+1)}; newThread{simul N (p+1)}; };
in newthread{simul M 0}; newThread{
while ( sum tab < 1-1/n ) do skip; return tab[k];
}
tab: dynamical approximation Updating tabon terminating
branches
Run probabilistic choicesin parallel Waitingfor a reasonable
approximation
Functional Representation of Probabilistic recursive functions
What is a functional representation?
LetM a probabilistic program that output an integer with probability 1.
We look for a recursive functionf:N→N→Q such that:
prob(M→k)=lim
n f(k)(n) ³1−X
k
f(k)(n)´≤1 n
let f M k n :=
let tab : Rational[] in let rec simul M p:=
eval M with
"return k" -> tab[k] += 1/(2^p);
"if coin then L else N" -> { newThread{simul L (p+1)};
newThread{simul N (p+1)};
};
in newthread{simul M 0};
newThread{
while ( sum tab < 1-1/n ) do skip;
return tab[k];
}
tab: dynamical approximation Updating tabon terminating
branches
Run probabilistic choicesin parallel Waitingfor a reasonable
approximation
When are the Probabilities Computationally Necessary?
Are all distributions deterministically representable?
Finite Representation prob
³
M→k´= fg(k)(k) ∈Q Functional Representation prob
³
M→k´=Pnf(n2n,k) ∈R
Parametrization ForM:N→N
When is (infinite) randomization useful?
Monte Carlo
f(n)reached with prob>12+² Las Vegas
f(n)reached and ascertained with prob>²
Dynamic/Strict bounds Make²dynamic/null
Different classes
Complexity Primitive Rec. HO Prim. Rec. Recursive
BPP
ZPP
NP,PP Exponential
Blow Up
future work Depending on
Prob. Operators
Functional representation of T
XRemark: Finite representation does not hold
Prob[X(rec 0(λxy.0⊕SSx))1 → 0] is not rational
Objective: Functional representation of
TXin
TL ForM∈TX(N), findM∗∈TL(N→N),[[M∗ n]]'12n [[M]]
Naive idea: Counter
StopM afterf(n)steps
〈M, f(n)〉M−→ 〈→M0 M0,f(n)−1〉
· · ·
→ 〈M00,0〉
→0
f(1)
...
f(2)...
f(3)...
f has to beT-definable! May not be possible...
Functional representation of T
XRemark: Finite representation does not hold
Prob[X(rec 0(λxy.0⊕SSx))1 → 0] is not rational
Objective: Functional representation of
TXin
TL ForM∈TX(N), findM∗∈TL(N→N),[[M∗ n]]'12n [[M]]
Naive idea: Counter
StopM afterf(n)steps
〈M, f(n)〉M−→ 〈→M0 M0,f(n)−1〉
· · ·
→ 〈M00,0〉
→0
f(1)
...
f(2)...
f(3)...
f has to beT-definable!
May not be possible...
Functional representation of T
RBetter Idea:
Truncating R
Limiting
themth
each apparition of the operatorRto[0, ...,n
∗m
]
R:=
0 7→ 12
· · · n 7→ 2n1+1
− 7→ Err
Bounded Probability of error
Prob(M[R/R]→Err) ≤ 1−Y
n≥0
(1− 1
2m∗n) ≤ 1 n
Functional representation of T
RThe Real Idea:
Increasing Truncature
Limitingthemthapparition of the operatorRto[0, ...,n∗m]
R:=(m:=m+1);
0 7→ 12
· · · n∗m 7→ 2n∗1m+1
− 7→ Err
Bounded Probability of error
Prob(M[R/R]→Err) ≤ 1−Y
n≥0
(1− 1
2m∗n) ≤ 1 n
When are the Probabilities Computationally Necessary?
Are all distributions deterministically representable?
Finite Representation prob
³
M→k´= fg(k)(k) ∈Q Functional Representation prob
³
M→k´=Pnf(n2n,k) ∈R
Parametrization ForM:N→N
When is (infinite) randomization useful?
Monte Carlo
f(n)reached with prob>12+² Las Vegas
f(n)reached and ascertained with prob>²
Dynamic/Strict bounds Make²dynamic/null
Different classes
Complexity Primitive Rec. HO Prim. Rec. Recursive
BPP
ZPP
NP,PP Exponential
Blow Up
future work Depending on
Prob. Operators