higher-order probabilistic programming
TRANSCRIPT
Higher-Order Probabilistic ProgrammingA Tutorial at POPL 2019
Part I
Ugo Dal Lago(Based on joint work with Flavien Breuvart, Raphaëlle Crubillé, Charles
Grellois, Davide Sangiorgi,. . . )
POPL 2019, Lisbon, January 14th
Probabilistic Models
I The environment is supposed not to behave deterministically, butprobabilistically.
I Crucial when modeling uncertainty.I Useful to handle complex domains.I Example:
q0 q1
q2 q3
14
34 1
12
12
13
23
I Abstractions:I (Labelled) Markov Chains.
Probabilistic Models
I The environment is supposed not to behave deterministically, butprobabilistically.
I Crucial when modeling uncertainty.
I Useful to handle complex domains.I Example:
q0 q1
q2 q3
14
34 1
12
12
13
23
I Abstractions:I (Labelled) Markov Chains.
Probabilistic Models
I The environment is supposed not to behave deterministically, butprobabilistically.
I Crucial when modeling uncertainty.I Useful to handle complex domains.
I Example:
q0 q1
q2 q3
14
34 1
12
12
13
23
I Abstractions:I (Labelled) Markov Chains.
Probabilistic Models
I The environment is supposed not to behave deterministically, butprobabilistically.
I Crucial when modeling uncertainty.I Useful to handle complex domains.I Example:
q0 q1
q2 q3
14
34 1
12
12
13
23
I Abstractions:I (Labelled) Markov Chains.
Probabilistic Models
I The environment is supposed not to behave deterministically, butprobabilistically.
I Crucial when modeling uncertainty.I Useful to handle complex domains.I Example:
q0 q1
q2 q3
14
34 1
12
12
13
23
I Abstractions:I (Labelled) Markov Chains.
Probabilistic Models
RO
BO
TIC
S
Probabilistic Models
ART
IFIC
IAL
INT
ELL
IGE
NC
E
Probabilistic Models
NAT
UR
AL
LAN
GU
AG
EP
RO
CE
SSIN
G
Randomized Computation
I Algorithms and automata are assumed to have the ability to sample from adistribution [dLMSS1956,R1963].
I This is a powerful tool when solving computational problems.I Example:
I Abstractions:I Randomized algorithms;I Probabilistic Turing machines.I Labelled Markov chains.
Randomized Computation
I Algorithms and automata are assumed to have the ability to sample from adistribution [dLMSS1956,R1963].
I This is a powerful tool when solving computational problems.
I Example:
I Abstractions:I Randomized algorithms;I Probabilistic Turing machines.I Labelled Markov chains.
Randomized Computation
I Algorithms and automata are assumed to have the ability to sample from adistribution [dLMSS1956,R1963].
I This is a powerful tool when solving computational problems.I Example:
I Abstractions:I Randomized algorithms;I Probabilistic Turing machines.I Labelled Markov chains.
Randomized Computation
I Algorithms and automata are assumed to have the ability to sample from adistribution [dLMSS1956,R1963].
I This is a powerful tool when solving computational problems.I Example:
I Abstractions:I Randomized algorithms;I Probabilistic Turing machines.I Labelled Markov chains.
Randomized Computation
I Algorithms and automata are assumed to have the ability to sample from adistribution [dLMSS1956,R1963].
I This is a powerful tool when solving computational problems.I Example:
I Abstractions:I Randomized algorithms;I Probabilistic Turing machines.I Labelled Markov chains.
Randomized Computation
01 1 1 0
s
· · · · · · δ(s, 0) = {(q, 1,←)12 , (r, 0,→)
23 }
01 1 1 0
r
· · · · · ·
11 1 1 0
q
· · · · · ·
12
12
Randomized Computation
01 1 1 0
s
· · · · · · δ(s, 0) = {(q, 1,←)12 , (r, 0,→)
23 }
01 1 1 0
r
· · · · · ·
11 1 1 0
q
· · · · · ·
12
12
Randomized Computation
01 1 1 0
s
· · · · · · δ(s, 0) = {(q, 1,←)12 , (r, 0,→)
23 }
01 1 1 0
r
· · · · · ·
11 1 1 0
q
· · · · · ·
23
13
Randomized Computation
ALG
OR
ITH
MIC
S
Randomized Computation
CRY
PT
OG
RA
PH
Y
Randomized Computation
PR
OG
RA
MV
ER
IFIC
ATIO
N
What Algorithms Compute
I Deterministic ComputationI For every input x, there is at most one output y any algorithm A produces when
fed with x.
I As a consequence:
A ; JAK : N⇀ N.
I Randomized ComputationI For every input x, any algorithm A outputs y with a probability 0 ≤ p ≤ 1.
I As a consequence:
A ; JAK : N→ D(N).I The distribution JAK(n) sums to anything between 0 and 1, thus accounting for
the probability of divergence.
What Algorithms Compute
I Deterministic ComputationI For every input x, there is at most one output y any algorithm A produces when
fed with x.
I As a consequence:
A ; JAK : N⇀ N.I Randomized Computation
I For every input x, any algorithm A outputs y with a probability 0 ≤ p ≤ 1.
I As a consequence:
A ; JAK : N→ D(N).I The distribution JAK(n) sums to anything between 0 and 1, thus accounting for
the probability of divergence.
Higher-Order Computation
I Mainly useful in programming.
I Functions are first-class citizens:I They can be passed as arguments;I They can be obtained as results.
I Motivations:I Modularity;I Code reuse;I Conciseness.
I Example:
I Models:I λ-calculus
Higher-Order Computation
I Mainly useful in programming.I Functions are first-class citizens:
I They can be passed as arguments;I They can be obtained as results.
I Motivations:I Modularity;I Code reuse;I Conciseness.
I Example:
I Models:I λ-calculus
Higher-Order Computation
I Mainly useful in programming.I Functions are first-class citizens:
I They can be passed as arguments;I They can be obtained as results.
I Motivations:I Modularity;I Code reuse;I Conciseness.
I Example:
I Models:I λ-calculus
Higher-Order Computation
I Mainly useful in programming.I Functions are first-class citizens:
I They can be passed as arguments;I They can be obtained as results.
I Motivations:I Modularity;I Code reuse;I Conciseness.
I Example:
I Models:I λ-calculus
Higher-Order Computation
I Mainly useful in programming.I Functions are first-class citizens:
I They can be passed as arguments;I They can be obtained as results.
I Motivations:I Modularity;I Code reuse;I Conciseness.
I Example:
I Models:I λ-calculus
Higher-Order Computation
I Mainly useful in programming.I Functions are first-class citizens:
I They can be passed as arguments;I They can be obtained as results.
I Motivations:I Modularity;I Code reuse;I Conciseness.
I Example:
I Models:I λ-calculus
Higher-Order Computation
FUN
CT
ION
AL
PR
OG
RA
MM
ING
Higher-Order Computation
FUN
CT
ION
AL
DAT
AST
RU
CT
UR
ES
Higher-Order Computation
λ-C
ALC
ULU
S
Higher-Order Probabilistic Computation?
Does it Make Sense?
What Kind of MetatheoryDoes it Have?
Interesting Research Problems?
Higher-Order Probabilistic Computation?
Does it Make Sense?
What Kind of MetatheoryDoes it Have?
Interesting Research Problems?
Higher-Order Probabilistic Computation?
Does it Make Sense?
What Kind of MetatheoryDoes it Have?
Interesting Research Problems?
This Tutorial
1. Motivating Examples.2. A λ-Calculus Foundation.3. Operational and Denotational Semantics.4. Termination and Resource Analysis.
A webpage: http://www.cs.unibo.it/~dallago/HOPP/
This Tutorial
1. Motivating Examples.2. A λ-Calculus Foundation.3. Operational and Denotational Semantics.4. Termination and Resource Analysis.
A webpage: http://www.cs.unibo.it/~dallago/HOPP/
MergeSort (1)
MergeSort (2)
The Structure of MergeSort
merge sort
merge sort
merge sort
MergeSort, HO
QuickSort
The Structure of MergeSort
quick sort
quick sort
quick sort
QuickSort, HO
Randomized QuickSort (1)
Randomized QuickSort (2)
Random Walk
0 1 2 n· · ·
p 1 − p
Two Kinds of Random Walks
The Coupon Collector
I A brand distributes a large quantity of coupons, each labelled withi ∈ {1, . . . , n}.
I Every day, you collect one coupon at a local store. Any label i has probability1n to occur.
I You win a prize when you collect a set of n coupons, each with a distinct label.I Example: if n = 5, you could get the following coupons:
3, 1, 5, 2, 3, 1, 5, 2, 3, 1, 5, 2, . . .
I Are you guaranteed to win the prize with probability 1? After how many days,on the average?
The Coupon Collector
I A brand distributes a large quantity of coupons, each labelled withi ∈ {1, . . . , n}.
I Every day, you collect one coupon at a local store. Any label i has probability1n to occur.
I You win a prize when you collect a set of n coupons, each with a distinct label.I Example: if n = 5, you could get the following coupons:
3, 1, 5, 2, 3, 1, 5, 2, 3, 1, 5, 2, . . .
I Are you guaranteed to win the prize with probability 1? After how many days,on the average?
The Coupon Collector
I A brand distributes a large quantity of coupons, each labelled withi ∈ {1, . . . , n}.
I Every day, you collect one coupon at a local store. Any label i has probability1n to occur.
I You win a prize when you collect a set of n coupons, each with a distinct label.
I Example: if n = 5, you could get the following coupons:
3, 1, 5, 2, 3, 1, 5, 2, 3, 1, 5, 2, . . .
I Are you guaranteed to win the prize with probability 1? After how many days,on the average?
The Coupon Collector
I A brand distributes a large quantity of coupons, each labelled withi ∈ {1, . . . , n}.
I Every day, you collect one coupon at a local store. Any label i has probability1n to occur.
I You win a prize when you collect a set of n coupons, each with a distinct label.I Example: if n = 5, you could get the following coupons:
3, 1, 5, 2, 3, 1, 5, 2, 3, 1, 5, 2, . . .
I Are you guaranteed to win the prize with probability 1? After how many days,on the average?
The Coupon Collector
I A brand distributes a large quantity of coupons, each labelled withi ∈ {1, . . . , n}.
I Every day, you collect one coupon at a local store. Any label i has probability1n to occur.
I You win a prize when you collect a set of n coupons, each with a distinct label.I Example: if n = 5, you could get the following coupons:
3, 1, 5, 2, 3, 1, 5, 2, 3, 1, 5, 2, . . .
I Are you guaranteed to win the prize with probability 1? After how many days,on the average?
The Coupon Collector
Beyond Randomized Algorithms: The Grass Problem
I You get up in the morning, and notice that the grass in your garden is wet.
I You know that there is 30% probability that it rains during the night.I The sprinkler is activated once every two days.I You further know that:
I If it rains, there is 90% probability that the grass is wet the following morning.I If the sprinkler is activated, there is 80% probability that the grass is wet the
following morning.I In any other case, there is anyway a 10% probability that the grass is wet.
I In other words, you are in a situation like the following:rain
sprinkler
grass is wet
I Now: how likely it is that it rained?
Beyond Randomized Algorithms: The Grass Problem
I You get up in the morning, and notice that the grass in your garden is wet.I You know that there is 30% probability that it rains during the night.
I The sprinkler is activated once every two days.I You further know that:
I If it rains, there is 90% probability that the grass is wet the following morning.I If the sprinkler is activated, there is 80% probability that the grass is wet the
following morning.I In any other case, there is anyway a 10% probability that the grass is wet.
I In other words, you are in a situation like the following:rain
sprinkler
grass is wet
I Now: how likely it is that it rained?
Beyond Randomized Algorithms: The Grass Problem
I You get up in the morning, and notice that the grass in your garden is wet.I You know that there is 30% probability that it rains during the night.I The sprinkler is activated once every two days.
I You further know that:I If it rains, there is 90% probability that the grass is wet the following morning.I If the sprinkler is activated, there is 80% probability that the grass is wet the
following morning.I In any other case, there is anyway a 10% probability that the grass is wet.
I In other words, you are in a situation like the following:rain
sprinkler
grass is wet
I Now: how likely it is that it rained?
Beyond Randomized Algorithms: The Grass Problem
I You get up in the morning, and notice that the grass in your garden is wet.I You know that there is 30% probability that it rains during the night.I The sprinkler is activated once every two days.I You further know that:
I If it rains, there is 90% probability that the grass is wet the following morning.I If the sprinkler is activated, there is 80% probability that the grass is wet the
following morning.I In any other case, there is anyway a 10% probability that the grass is wet.
I In other words, you are in a situation like the following:rain
sprinkler
grass is wet
I Now: how likely it is that it rained?
Beyond Randomized Algorithms: The Grass Problem
I You get up in the morning, and notice that the grass in your garden is wet.I You know that there is 30% probability that it rains during the night.I The sprinkler is activated once every two days.I You further know that:
I If it rains, there is 90% probability that the grass is wet the following morning.I If the sprinkler is activated, there is 80% probability that the grass is wet the
following morning.I In any other case, there is anyway a 10% probability that the grass is wet.
I In other words, you are in a situation like the following:rain
sprinkler
grass is wet
I Now: how likely it is that it rained?
The Grass Model
Thank You!
Questions?