On Higher-Order Probabilistic Computation: Relational Reasoning, - - PowerPoint PPT Presentation

on higher order probabilistic computation
SMART_READER_LITE
LIVE PREVIEW

On Higher-Order Probabilistic Computation: Relational Reasoning, - - PowerPoint PPT Presentation

On Higher-Order Probabilistic Computation: Relational Reasoning, Termination, and Bayesian Programming Ugo Dal Lago (Based on joint work with Michele Alberti, Raphalle Crubill, Charles Grellois, Davide Sangiorgi,. . . ) IFIP WG 2.2 Annual


slide-1
SLIDE 1

On Higher-Order Probabilistic Computation:

Relational Reasoning, Termination, and Bayesian Programming

Ugo Dal Lago (Based on joint work with Michele Alberti, Raphaëlle Crubillé, Charles Grellois, Davide Sangiorgi,. . . ) IFIP WG 2.2 Annual Meeting, Brno, September 17th

slide-2
SLIDE 2

Probabilistic Models

◮ The environment is supposed not to behave

deterministically, but probabilistically.

slide-3
SLIDE 3

Probabilistic Models

◮ The environment is supposed not to behave

deterministically, but probabilistically.

◮ Crucial when modeling uncertainty.

slide-4
SLIDE 4

Probabilistic Models

◮ The environment is supposed not to behave

deterministically, but probabilistically.

◮ Crucial when modeling uncertainty. ◮ Useful to handle complex domains.

slide-5
SLIDE 5

Probabilistic Models

◮ The environment is supposed not to behave

deterministically, but probabilistically.

◮ Crucial when modeling uncertainty. ◮ Useful to handle complex domains. ◮ Example:

q0 q1 q2 q3

1 4 3 4 1 1 2 1 2 1 3 2 3

slide-6
SLIDE 6

Probabilistic Models

◮ The environment is supposed not to behave

deterministically, but probabilistically.

◮ Crucial when modeling uncertainty. ◮ Useful to handle complex domains. ◮ Example:

q0 q1 q2 q3

1 4 3 4 1 1 2 1 2 1 3 2 3 ◮ Abstractions:

◮ (Labelled) Markov Chains.

slide-7
SLIDE 7

Probabilistic Models

ROBOTICS

slide-8
SLIDE 8

Probabilistic Models

ARTIFICIAL INTELLIGENCE

slide-9
SLIDE 9

Probabilistic Models

NATURAL LANGUAGE PROCESSING

slide-10
SLIDE 10

Randomized Computation

◮ Algorithms and automata are assumed to have the ability

to sample from a distribution [dLMSS1956,R1963].

slide-11
SLIDE 11

Randomized Computation

◮ Algorithms and automata are assumed to have the ability

to sample from a distribution [dLMSS1956,R1963].

◮ This is a powerful tool when solving computational

problems.

slide-12
SLIDE 12

Randomized Computation

◮ Algorithms and automata are assumed to have the ability

to sample from a distribution [dLMSS1956,R1963].

◮ This is a powerful tool when solving computational

problems.

◮ Example:

slide-13
SLIDE 13

Randomized Computation

◮ Algorithms and automata are assumed to have the ability

to sample from a distribution [dLMSS1956,R1963].

◮ This is a powerful tool when solving computational

problems.

◮ Example:

slide-14
SLIDE 14

Randomized Computation

◮ Algorithms and automata are assumed to have the ability

to sample from a distribution [dLMSS1956,R1963].

◮ This is a powerful tool when solving computational

problems.

◮ Example: ◮ Abstractions:

◮ Randomized algorithms; ◮ Probabilistic Turing machines. ◮ Labelled Markov chains.

slide-15
SLIDE 15

Randomized Computation

ALGORITHMICS

slide-16
SLIDE 16

Randomized Computation

CRYPTOGRAPHY

slide-17
SLIDE 17

Randomized Computation

PROGRAM VERIFICATION

slide-18
SLIDE 18

Higher-Order Computation

◮ Mainly useful in programming.

slide-19
SLIDE 19

Higher-Order Computation

◮ Mainly useful in programming. ◮ Functions are first-class citizens:

◮ They can be passed as arguments; ◮ They can be obtained as results.

slide-20
SLIDE 20

Higher-Order Computation

◮ Mainly useful in programming. ◮ Functions are first-class citizens:

◮ They can be passed as arguments; ◮ They can be obtained as results.

◮ Motivations:

◮ Modularity; ◮ Code reuse; ◮ Conciseness.

slide-21
SLIDE 21

Higher-Order Computation

◮ Mainly useful in programming. ◮ Functions are first-class citizens:

◮ They can be passed as arguments; ◮ They can be obtained as results.

◮ Motivations:

◮ Modularity; ◮ Code reuse; ◮ Conciseness.

◮ Example:

slide-22
SLIDE 22

Higher-Order Computation

◮ Mainly useful in programming. ◮ Functions are first-class citizens:

◮ They can be passed as arguments; ◮ They can be obtained as results.

◮ Motivations:

◮ Modularity; ◮ Code reuse; ◮ Conciseness.

◮ Example:

slide-23
SLIDE 23

Higher-Order Computation

◮ Mainly useful in programming. ◮ Functions are first-class citizens:

◮ They can be passed as arguments; ◮ They can be obtained as results.

◮ Motivations:

◮ Modularity; ◮ Code reuse; ◮ Conciseness.

◮ Example: ◮ Models:

◮ λ-calculus

slide-24
SLIDE 24

Higher-Order Computation

FUNCTIONAL PROGRAMMING

slide-25
SLIDE 25

Higher-Order Computation

FUNCTIONAL DATA STRUCTURES

slide-26
SLIDE 26

Higher-Order Computation

λ-CALCULUS

slide-27
SLIDE 27

Higher-Order Probabilistic Computation

Does it Make Sense?

slide-28
SLIDE 28

Higher-Order Probabilistic Computation

Does it Make Sense? What Kind of Metatheory Does it Have?

slide-29
SLIDE 29

Higher-Order Probabilistic Computation

Does it Make Sense? What Kind of Metatheory Does it Have? Applications?

slide-30
SLIDE 30

1980 1990 2000 2010 [Saheb-Djaromi] [JonesPlotkin] [JungTix] [DanosHarmer]

slide-31
SLIDE 31

1980 1990 2000 2010 [Saheb-Djaromi] [JonesPlotkin] [JungTix] [DanosHarmer] . . . too many

slide-32
SLIDE 32

Outline Part I Relational Reasoning Part II Bayesian Functional Programming Part III Termination

slide-33
SLIDE 33

Part I Relational Reasoning

slide-34
SLIDE 34

Syntax and Operational Semantics of Λ⊕

◮ Terms: M ::= x | λx.M | MM | M ⊕ M;

slide-35
SLIDE 35

Syntax and Operational Semantics of Λ⊕

◮ Terms: M ::= x | λx.M | MM | M ⊕ M; ◮ Values: V ::= λx.M;

slide-36
SLIDE 36

Syntax and Operational Semantics of Λ⊕

◮ Terms: M ::= x | λx.M | MM | M ⊕ M; ◮ Values: V ::= λx.M; ◮ Value Distributions:

V

D

− → D(V ) ∈ R[0,1]

  • D =
  • V

D(V ) ≤ 1.

slide-37
SLIDE 37

Syntax and Operational Semantics of Λ⊕

◮ Terms: M ::= x | λx.M | MM | M ⊕ M; ◮ Values: V ::= λx.M; ◮ Value Distributions:

V

D

− → D(V ) ∈ R[0,1]

  • D =
  • V

D(V ) ≤ 1.

◮ Semantics: M = supM⇓D D;

slide-38
SLIDE 38

Syntax and Operational Semantics of Λ⊕

◮ Terms: M ::= x | λx.M | MM | M ⊕ M; ◮ Values: V ::= λx.M; ◮ Value Distributions:

V

D

− → D(V ) ∈ R[0,1]

  • D =
  • V

D(V ) ≤ 1.

◮ Semantics: M = supM⇓D D;

M ⇓ ∅ V ⇓ {V 1} M ⇓ D N ⇓ E M ⊕ N ⇓ 1

2D + 1 2E

M ⇓ K {P[N/x] ⇓ E P }λx.P ∈SK MN ⇓

  • λx.P ∈SK

K (λx.P) · EP

slide-39
SLIDE 39

Syntax and Operational Semantics of Λ⊕

◮ Terms: M ::= x | λx.M | MM | M ⊕ M; ◮ Values: V ::= λx.M; ◮ Value Distributions:

V

D

− → D(V ) ∈ R[0,1]

  • D =
  • V

D(V ) ≤ 1.

◮ Semantics: M = supM⇓D D; ◮ Context Equivalence: M ≡ N iff for every context C it

holds that C[M] = C[N].

slide-40
SLIDE 40

Syntax and Operational Semantics of Λ⊕

◮ Terms: M ::= x | λx.M | MM | M ⊕ M; ◮ Values: V ::= λx.M; ◮ Value Distributions:

V

D

− → D(V ) ∈ R[0,1]

  • D =
  • V

D(V ) ≤ 1.

◮ Semantics: M = supM⇓D D; ◮ Context Equivalence: M ≡ N iff for every context C it

holds that C[M] = C[N]. C ::= [·] | λx.C | CM | MC | C ⊕M | M ⊕C

slide-41
SLIDE 41

Syntax and Operational Semantics of Λ⊕

◮ Terms: M ::= x | λx.M | MM | M ⊕ M; ◮ Values: V ::= λx.M; ◮ Value Distributions:

V

D

− → D(V ) ∈ R[0,1]

  • D =
  • V

D(V ) ≤ 1.

◮ Semantics: M = supM⇓D D; ◮ Context Equivalence: M ≡ N iff for every context C it

holds that C[M] = C[N].

◮ Context Distance:

δC(M, N) = supC | C[M] − C[N]|.

slide-42
SLIDE 42

Examples I ⊕ Ω vs. I

slide-43
SLIDE 43

Examples I ⊕ Ω vs. I

λx.x

slide-44
SLIDE 44

Examples I ⊕ Ω vs. I

∆∆ = (λx.xx)(λx.xx)

slide-45
SLIDE 45

Examples I ⊕ Ω vs. I

Not Context Equivalent: C = [·]. Context Distance? Consider Cn = (λx. x . . . x n times )[·].

slide-46
SLIDE 46

Examples I ⊕ Ω vs. I I ⊕ Ω vs. Ω

slide-47
SLIDE 47

Examples I ⊕ Ω vs. I I ⊕ Ω vs. Ω

Not Context Equivalent: C = [·]. Context Distance? Cannot Easily Amplify.

slide-48
SLIDE 48

Examples I ⊕ Ω vs. I I ⊕ Ω vs. Ω (λx.I) ⊕ (λx.Ω) vs. λx.I ⊕ Ω

slide-49
SLIDE 49

Examples I ⊕ Ω vs. I I ⊕ Ω vs. Ω (λx.I) ⊕ (λx.Ω) vs. λx.I ⊕ Ω

Not Context Equivalent in CBV: C = (λx.x(xI))[·] Apparently Context Equivalent in CBN.

slide-50
SLIDE 50

Examples I ⊕ Ω vs. I I ⊕ Ω vs. Ω (λx.I) ⊕ (λx.Ω) vs. λx.I ⊕ Ω Y1 vs. Y2

slide-51
SLIDE 51

Examples I ⊕ Ω vs. I I ⊕ Ω vs. Ω (λx.I) ⊕ (λx.Ω) vs. λx.I ⊕ Ω Y1 vs. Y2

Y1M →∗ M(Y2M) ⊕ M(Y3M) Y2M →∗ M(Y1M) ⊕ M(Y3M) Y3M →∗ M(Y1M) ⊕ M(Y2M)

slide-52
SLIDE 52

A Labelled Markov Chain for Λ⊕

Terms

slide-53
SLIDE 53

A Labelled Markov Chain for Λ⊕

Terms Values

slide-54
SLIDE 54

A Labelled Markov Chain for Λ⊕

Terms Values M

slide-55
SLIDE 55

A Labelled Markov Chain for Λ⊕

Terms Values M V W Z . . . eval, M(V ) eval, M(W) eval, M(Z)

slide-56
SLIDE 56

A Labelled Markov Chain for Λ⊕

Terms Values λx.N

slide-57
SLIDE 57

A Labelled Markov Chain for Λ⊕

Terms Values λx.N N{W/x} W, 1

slide-58
SLIDE 58

Probabilistic Applicative Bisimulation

λx.M R λx.N

slide-59
SLIDE 59

Probabilistic Applicative Bisimulation

λx.M R λx.N M{L/x} L

slide-60
SLIDE 60

Probabilistic Applicative Bisimulation

λx.M R λx.N M{L/x} L N{L/x} L

slide-61
SLIDE 61

Probabilistic Applicative Bisimulation

λx.M R λx.N M{L/x} L N{L/x} L R

slide-62
SLIDE 62

Probabilistic Applicative Bisimulation

λx.M R λx.N M{L/x} L N{L/x} L R M R N

slide-63
SLIDE 63

Probabilistic Applicative Bisimulation

λx.M R λx.N M{L/x} L N{L/x} L R M R N M eval

slide-64
SLIDE 64

Probabilistic Applicative Bisimulation

λx.M R λx.N M{L/x} L N{L/x} L R M R N M eval N eval

slide-65
SLIDE 65

Probabilistic Applicative Bisimulation

λx.M R λx.N M{L/x} L N{L/x} L R M R N M eval N eval M(E)

slide-66
SLIDE 66

Probabilistic Applicative Bisimulation

λx.M R λx.N M{L/x} L N{L/x} L R M R N M eval N eval M(E) N(E)

slide-67
SLIDE 67

Probabilistic Applicative Bisimulation

λx.M R λx.N M{L/x} L N{L/x} L R M R N M eval N eval M(E) N(E) =

slide-68
SLIDE 68

Applicative Bisimilarity vs. Context Equivalence

◮ Bisimilarity: the union ∼ of all bisimulation relations. ◮ Is it that ∼ is included in ≡? How to prove it? ◮ Natural strategy: is ∼ a congruence?

◮ If this is the case:

M ∼ N = ⇒ C[M] ∼ C[N] = ⇒

  • C[M] =
  • C[N]

= ⇒ M ≡ N.

◮ This is a necessary sanity check anyway.

◮ The naïve proof by induction fails, due to application:

from M ∼ N, one cannot directly conclude that LM ∼ LN.

slide-69
SLIDE 69

Howe’s Technique

R RH

slide-70
SLIDE 70

Howe’s Technique

R RH ⊆

slide-71
SLIDE 71

Howe’s Technique

R RH ⊆ RH is a Congruence whenever R is an equivalence

slide-72
SLIDE 72

Howe’s Technique

⊆ ∼H is a Congruence ∼ ∼H

slide-73
SLIDE 73

Howe’s Technique

⊆ ∼H is a Congruence ∼ ∼H ⊇ Key Lemma

slide-74
SLIDE 74

Our Neighborhood

◮ Λ, where we observe convergence

∼ ⊆ ≡ ≡ ⊆ ∼ CBN

  • CBV
  • [Abramsky1990, Howe1993]

◮ Λ⊕ with nondeterministic semantics, where we observe

convergence, in its may or must flavors.

∼ ⊆ ≡ ≡ ⊆ ∼ CBN

  • ×

CBV

  • ×

[Ong1993, Lassen1998]

slide-75
SLIDE 75

The Probabilistic Case

◮ Λ⊕ with probabilistic semantics.

∼ ⊆ ≡ ≡ ⊆ ∼ CBN

  • ×

CBV

slide-76
SLIDE 76

The Probabilistic Case

◮ Λ⊕ with probabilistic semantics.

∼ ⊆ ≡ ≡ ⊆ ∼ CBN

  • ×

CBV

  • ◮ Counterexample for CBN: (λx.I) ⊕ (λx.Ω) ∼ λx.I ⊕ Ω

◮ Where these discrepancies come from?

slide-77
SLIDE 77

The Probabilistic Case

◮ Λ⊕ with probabilistic semantics.

∼ ⊆ ≡ ≡ ⊆ ∼ CBN

  • ×

CBV

  • ◮ Counterexample for CBN: (λx.I) ⊕ (λx.Ω) ∼ λx.I ⊕ Ω

◮ Where these discrepancies come from? ◮ From testing!

slide-78
SLIDE 78

The Probabilistic Case

◮ Λ⊕ with probabilistic semantics.

∼ ⊆ ≡ ≡ ⊆ ∼ CBN

  • ×

CBV

  • ◮ Counterexample for CBN: (λx.I) ⊕ (λx.Ω) ∼ λx.I ⊕ Ω

◮ Where these discrepancies come from? ◮ From testing! ◮ Bisimulation can be characterized by testing equivalence as

follows: Calculus Testing Λ T ::= ω | a · T PΛ⊕ T ::= ω | a · T | T, T NΛ⊕ T ::= ω | a · T | ∧i∈I Ti | . . .

slide-79
SLIDE 79

The Probabilistic Case

◮ Λ⊕ with probabilistic semantics.

⊆ ≤ ≤ ⊆ CBN

  • ×

CBV

  • ×
slide-80
SLIDE 80

The Probabilistic Case

◮ Λ⊕ with probabilistic semantics.

⊆ ≤ ≤ ⊆ CBN

  • ×

CBV

  • ×

◮ Probabilistic simulation can be characterized by testing as

follows: T ::= ω | a · T | T, T | T ∨ T

slide-81
SLIDE 81

The Probabilistic Case

◮ Λ⊕ with probabilistic semantics.

⊆ ≤ ≤ ⊆ CBN

  • ×

CBV

  • ×

◮ Probabilistic simulation can be characterized by testing as

follows: T ::= ω | a · T | T, T | T ∨ T

◮ Full abstraction can be recovered if endowing Λ⊕ with

parallel disjunction [CDLSV2015].

⊆ ≤ ≤ ⊆ CBN

  • ×

CBV

slide-82
SLIDE 82

Context Distance: the Affine Case [CDL2015]

◮ Let us consider a simple fragment of Λ⊕, first.

slide-83
SLIDE 83

Context Distance: the Affine Case [CDL2015]

◮ Let us consider a simple fragment of Λ⊕, first. ◮ Preterms: M, N ::= x | λx.M | MM | M ⊕ M | Ω;

slide-84
SLIDE 84

Context Distance: the Affine Case [CDL2015]

◮ Let us consider a simple fragment of Λ⊕, first. ◮ Preterms: M, N ::= x | λx.M | MM | M ⊕ M | Ω; ◮ Terms: any preterm M such that Γ ⊢ M.

slide-85
SLIDE 85

Context Distance: the Affine Case [CDL2015]

◮ Let us consider a simple fragment of Λ⊕, first. ◮ Preterms: M, N ::= x | λx.M | MM | M ⊕ M | Ω; ◮ Terms: any preterm M such that Γ ⊢ M.

Γ, x ⊢ x x, Γ ⊢ M Γ ⊢ λx.M Γ ⊢ M ∆ ⊢ N Γ, ∆ ⊢ MN Γ ⊢ M Γ ⊢ N Γ ⊢ M ⊕ N

slide-86
SLIDE 86

Context Distance: the Affine Case [CDL2015]

◮ Let us consider a simple fragment of Λ⊕, first. ◮ Preterms: M, N ::= x | λx.M | MM | M ⊕ M | Ω; ◮ Terms: any preterm M such that Γ ⊢ M. ◮ Behavioural Distance δb.

◮ The metric analogue to bisimilarity.

slide-87
SLIDE 87

Context Distance: the Affine Case [CDL2015]

◮ Let us consider a simple fragment of Λ⊕, first. ◮ Preterms: M, N ::= x | λx.M | MM | M ⊕ M | Ω; ◮ Terms: any preterm M such that Γ ⊢ M. ◮ Behavioural Distance δb.

◮ The metric analogue to bisimilarity.

◮ Trace Distance δt.

◮ The maximum distance induced by traces, i.e., sequences of

actions: δt(M, N) = supT |Pr(M, T) − Pr(N, T)|.

slide-88
SLIDE 88

Context Distance: the Affine Case [CDL2015]

◮ Let us consider a simple fragment of Λ⊕, first. ◮ Preterms: M, N ::= x | λx.M | MM | M ⊕ M | Ω; ◮ Terms: any preterm M such that Γ ⊢ M. ◮ Behavioural Distance δb.

◮ The metric analogue to bisimilarity.

◮ Trace Distance δt.

◮ The maximum distance induced by traces, i.e., sequences of

actions: δt(M, N) = supT |Pr(M, T) − Pr(N, T)|.

◮ Soundness and Completeness Results:

δb ≤ δc δc ≤ δb δt ≤ δc δc ≤ δt

  • ×
slide-89
SLIDE 89

Context Distance: the Affine Case [CDL2015]

◮ Let us consider a simple fragment of Λ⊕, first. ◮ Preterms: M, N ::= x | λx.M | MM | M ⊕ M | Ω; ◮ Terms: any preterm M such that Γ ⊢ M. ◮ Behavioural Distance δb.

◮ The metric analogue to bisimilarity.

◮ Trace Distance δt.

◮ The maximum distance induced by traces, i.e., sequences of

actions: δt(M, N) = supT |Pr(M, T) − Pr(N, T)|.

◮ Soundness and Completeness Results:

δb ≤ δc δc ≤ δb δt ≤ δc δc ≤ δt

  • ×
  • ◮ Example: δt(I, I ⊕ Ω) = δt(I ⊕ Ω, Ω) = 1

2.

slide-90
SLIDE 90

Context Distance: the General Case [CDL2016]

◮ The LMC we have have worked so far with induces

unsound metrics for Λ⊕. . .

slide-91
SLIDE 91

Context Distance: the General Case [CDL2016]

◮ The LMC we have have worked so far with induces

unsound metrics for Λ⊕. . .

◮ . . . because it does not adequately model copying.

slide-92
SLIDE 92

Context Distance: the General Case [CDL2016]

◮ The LMC we have have worked so far with induces

unsound metrics for Λ⊕. . .

◮ . . . because it does not adequately model copying. ◮ A Tuple LMC.

◮ Preterms:

M ::= x | λx.M | λ!x.M | MM | M ⊕ M | !M

◮ Terms: any preterm M such that Γ ⊢ M. ◮ States: sequences of terms, rather than terms. ◮ Actions not only model parameter passing, but also

copying of terms.

slide-93
SLIDE 93

Context Distance: the General Case [CDL2016]

◮ The LMC we have have worked so far with induces

unsound metrics for Λ⊕. . .

◮ . . . because it does not adequately model copying. ◮ A Tuple LMC.

◮ Preterms:

M ::= x | λx.M | λ!x.M | MM | M ⊕ M | !M

◮ Terms: any preterm M such that Γ ⊢ M.

!Γ, x ⊢ x !Γ, !x ⊢ x x, Γ ⊢ M Γ ⊢ λx.M !x, Γ ⊢ M Γ ⊢ λ!x.M !Γ ⊢ M !Γ ⊢!M Γ, !Θ ⊢ M ∆, !Θ ⊢ N Γ, ∆, Θ ⊢ MN Γ ⊢ M Γ ⊢ N Γ ⊢ M ⊕ N

◮ States: sequences of terms, rather than terms. ◮ Actions not only model parameter passing, but also

copying of terms.

slide-94
SLIDE 94

Context Distance: the General Case [CDL2016]

◮ The LMC we have have worked so far with induces

unsound metrics for Λ⊕. . .

◮ . . . because it does not adequately model copying. ◮ A Tuple LMC.

◮ Preterms:

M ::= x | λx.M | λ!x.M | MM | M ⊕ M | !M

◮ Terms: any preterm M such that Γ ⊢ M. ◮ States: sequences of terms, rather than terms. ◮ Actions not only model parameter passing, but also

copying of terms.

◮ Soundness and Completeness Results:

δt ≤ δc δc ≤ δt

slide-95
SLIDE 95

Context Distance: the General Case [CDL2016]

◮ The LMC we have have worked so far with induces

unsound metrics for Λ⊕. . .

◮ . . . because it does not adequately model copying. ◮ A Tuple LMC.

◮ Preterms:

M ::= x | λx.M | λ!x.M | MM | M ⊕ M | !M

◮ Terms: any preterm M such that Γ ⊢ M. ◮ States: sequences of terms, rather than terms. ◮ Actions not only model parameter passing, but also

copying of terms.

◮ Soundness and Completeness Results:

δt ≤ δc δc ≤ δt

  • ◮ Examples: δt(!(I ⊕ Ω), !Ω) = 1

2

δt(!(I ⊕ Ω), !I) = 1.

slide-96
SLIDE 96

Context Distance: the General Case [CDL2016]

◮ The LMC we have have worked so far with induces

unsound metrics for Λ⊕. . .

◮ . . . because it does not adequately model copying. ◮ A Tuple LMC.

◮ Preterms:

M ::= x | λx.M | λ!x.M | MM | M ⊕ M | !M

◮ Terms: any preterm M such that Γ ⊢ M. ◮ States: sequences of terms, rather than terms. ◮ Actions not only model parameter passing, but also

copying of terms.

◮ Soundness and Completeness Results:

δt ≤ δc δc ≤ δt

  • ◮ Examples: δt(!(I ⊕ Ω), !Ω) = 1

2

δt(!(I ⊕ Ω), !I) = 1.

◮ Trivialisation: the context distance collapses to an

equivalence in strongly normalising fragments or in presence

  • f parellel disjuction.
slide-97
SLIDE 97

Context Distance: the General Case [CDL2016]

◮ The LMC we have have worked so far with induces

unsound metrics for Λ⊕. . .

◮ . . . because it does not adequately model copying. ◮ A Tuple LMC.

◮ Preterms:

M ::= x | λx.M | λ!x.M | MM | M ⊕ M | !M

◮ Terms: any preterm M such that Γ ⊢ M. ◮ States: sequences of terms, rather than terms. ◮ Actions not only model parameter passing, but also

copying of terms.

◮ Soundness and Completeness Results:

δt ≤ δc δc ≤ δt

  • ◮ Examples: δt(!(I ⊕ Ω), !Ω) = 1

2

δt(!(I ⊕ Ω), !I) = 1.

◮ Trivialisation: the context distance collapses to an

equivalence in strongly normalising fragments or in presence

  • f parellel disjuction.

What would a sensible notion of distance look like?

slide-98
SLIDE 98

Part II Bayesian Functional Programming

slide-99
SLIDE 99
slide-100
SLIDE 100
slide-101
SLIDE 101
slide-102
SLIDE 102

1. normalize( 2. let x = sample(bern 5 7

  • ) in

3. let r = if x then 10 else 3 in 4.

  • bserve 4 from poisson(r);

5. return(x)) x = true x = false

5 7 2 7

r = 10 r = 3 x = true x = false

slide-103
SLIDE 103

1. normalize( 2. let x = sample(bern 5 7

  • ) in

3. let r = if x then 10 else 3 in 4.

  • bserve 4 from poisson(r);

5. return(x)) x = true x = false

5 7 2 7

r = 10 r = 3 x = true x = false

slide-104
SLIDE 104

1. normalize( 2. let x = sample(bern 5 7

  • ) in

3. let r = if x then 10 else 3 in 4.

  • bserve 4 from poisson(r);

5. return(x)) x = true x = false

5 7 2 7

r = 10 r = 3 x = true x = false

slide-105
SLIDE 105

1. normalize( 2. let x = sample(bern 5 7

  • ) in

3. let r = if x then 10 else 3 in 4.

  • bserve 4 from poisson(r);

5. return(x)) x = true x = false

5 7 2 7

r = 10 r = 3 x = true x = false

slide-106
SLIDE 106

1. normalize( 2. let x = sample(bern 5 7

  • ) in

3. let r = if x then 10 else 3 in 4.

  • bserve 4 from poisson(r);

5. return(x)) x = true x = false

5 7 2 7

r = 10 r = 3 x = true x = false poisson(10)(4) ∼ 0.016 poisson(3)(4) ∼ 0.168

slide-107
SLIDE 107

1. normalize( 2. let x = sample(bern 5 7

  • ) in

3. let r = if x then 10 else 3 in 4.

  • bserve 4 from poisson(r);

5. return(x)) x = true x = false

5 7 2 7

r = 10 r = 3 x = true x = false 0.22 0.78

slide-108
SLIDE 108

Bayesian Functional Programming

ANGLICAN

slide-109
SLIDE 109

Bayesian Functional Programming

HAKARU

slide-110
SLIDE 110

1. normalize( 2. let x = sample(gauss (0, 1)) in 4.

  • bserve d from exp(1/f(x));

5. return(x))

slide-111
SLIDE 111

1. normalize( 2. let x = sample(gauss (0, 1)) in 4.

  • bserve d from exp(1/f(x));

5. return(x))

slide-112
SLIDE 112

Bayesian Programming: Semantics

◮ Giving semantics to programming languages like Anglican

  • r Hakaru is nontrivial:

◮ Real numbers; ◮ Sampling from continuous distributions; ◮ Conditioning.

slide-113
SLIDE 113

Bayesian Programming: Semantics

◮ Giving semantics to programming languages like Anglican

  • r Hakaru is nontrivial:

◮ Real numbers; ◮ Sampling from continuous distributions; ◮ Conditioning.

◮ Key ingredients:

◮ In M ⇓ D, we need D to be a measure, because the set of

term is not countable anymore.

slide-114
SLIDE 114

Bayesian Programming: Semantics

◮ Giving semantics to programming languages like Anglican

  • r Hakaru is nontrivial:

◮ Real numbers; ◮ Sampling from continuous distributions; ◮ Conditioning.

◮ Key ingredients:

◮ In M ⇓ D, we need D to be a measure, because the set of

term is not countable anymore.

◮ Terms must thus be equipped with the structure of a

measurable space.

slide-115
SLIDE 115

Bayesian Programming: Semantics

◮ Giving semantics to programming languages like Anglican

  • r Hakaru is nontrivial:

◮ Real numbers; ◮ Sampling from continuous distributions; ◮ Conditioning.

◮ Key ingredients:

◮ In M ⇓ D, we need D to be a measure, because the set of

term is not countable anymore.

◮ Terms must thus be equipped with the structure of a

measurable space.

◮ From

M ⇓ K {P[N/x] ⇓ E P }λx.P ∈SK MN ⇓

  • λx.P ∈SK

K (λx.P) · EP we go to M ⇓ K {P[N/x] ⇓ E P }λx.P ∈SK MN ⇓

  • EP · dK (λx.P)
slide-116
SLIDE 116

Bayesian Programming: Semantics

◮ Giving semantics to programming languages like Anglican

  • r Hakaru is nontrivial:

◮ Real numbers; ◮ Sampling from continuous distributions; ◮ Conditioning.

◮ Key ingredients:

◮ In M ⇓ D, we need D to be a measure, because the set of

term is not countable anymore.

◮ Terms must thus be equipped with the structure of a

measurable space.

◮ From

M ⇓ K {P[N/x] ⇓ E P }λx.P ∈SK MN ⇓

  • λx.P ∈SK

K (λx.P) · EP we go to M ⇓ K {P[N/x] ⇓ E P }λx.P ∈SK MN ⇓

  • EP · dK (λx.P)

◮ This Lebesgue integral

does not necessarily exist.

◮ We must ensure that ⇓

gives rise to a stochastic kernel.

◮ In presence of conditioning,

we need even more.

slide-117
SLIDE 117

Part III Termination

slide-118
SLIDE 118

The Landscape: Type Theory

Simple Types Polymorphic Types Intersection Types Sized Types

τ ::= ι | τ → τ τ ::= · · · | α | ∀α.τ τ ::= · · · | τ ∧ τ τ ::= · · · | ι[ξ]

slide-119
SLIDE 119

The Landscape: Type Theory

Simple Types Polymorphic Types Intersection Types Sized Types

τ ::= ι | τ → τ τ ::= · · · | α | ∀α.τ τ ::= · · · | τ ∧ τ τ ::= · · · | ι[ξ]

◮ Sound for termination, in absence

  • f recursion.

◮ Poor expressive power. ◮ Intuitionistic Logic.

slide-120
SLIDE 120

The Landscape: Type Theory

Simple Types Polymorphic Types Intersection Types Sized Types

τ ::= ι | τ → τ τ ::= · · · | α | ∀α.τ τ ::= · · · | τ ∧ τ τ ::= · · · | ι[ξ]

slide-121
SLIDE 121

The Landscape: Type Theory

Simple Types Polymorphic Types Intersection Types Sized Types

τ ::= ι | τ → τ τ ::= · · · | α | ∀α.τ τ ::= · · · | τ ∧ τ τ ::= · · · | ι[ξ]

◮ Second-order Logic. ◮ Very expressive, extensionally. ◮ Still poor, intensionally.

slide-122
SLIDE 122

The Landscape: Type Theory

Simple Types Polymorphic Types Intersection Types Sized Types

τ ::= ι | τ → τ τ ::= · · · | α | ∀α.τ τ ::= · · · | τ ∧ τ τ ::= · · · | ι[ξ]

slide-123
SLIDE 123

The Landscape: Type Theory

Simple Types Polymorphic Types Intersection Types Sized Types

τ ::= ι | τ → τ τ ::= · · · | α | ∀α.τ τ ::= · · · | τ ∧ τ τ ::= · · · | ι[ξ]

◮ Motivated by Semantics. ◮ Complete for termination. ◮ Type inference is undecidable.

slide-124
SLIDE 124

The Landscape: Type Theory

Simple Types Polymorphic Types Intersection Types Sized Types

τ ::= ι | τ → τ τ ::= · · · | α | ∀α.τ τ ::= · · · | τ ∧ τ τ ::= · · · | ι[ξ]

slide-125
SLIDE 125

The Landscape: Type Theory

Simple Types Polymorphic Types Intersection Types Sized Types

τ ::= ι | τ → τ τ ::= · · · | α | ∀α.τ τ ::= · · · | τ ∧ τ τ ::= · · · | ι[ξ]

◮ Reasonably expressive,

intensionally.

◮ Type inference remains decidable

slide-126
SLIDE 126

The Landscape: Recursion Theory

Determinism Ms →∗ Ns

slide-127
SLIDE 127

The Landscape: Recursion Theory

Determinism Probabilism Ms →∗ Ns Ms = Ds

slide-128
SLIDE 128

The Landscape: Recursion Theory

Determinism Probabilism Ms →∗ Ns Ms = Ds

Ds can be smaller than 1.

slide-129
SLIDE 129

The Landscape: Recursion Theory

Determinism Probabilism Ms →∗ Ns Ms = Ds Termination ∃Ns ∈ NF

slide-130
SLIDE 130

The Landscape: Recursion Theory

Determinism Probabilism Ms →∗ Ns Ms = Ds Termination ∃Ns ∈ NF

Undecidable; Σ0

1-complete.

slide-131
SLIDE 131

The Landscape: Recursion Theory

Determinism Probabilism Ms →∗ Ns Ms = Ds Termination ∃Ns ∈ NF Ds = 1

slide-132
SLIDE 132

The Landscape: Recursion Theory

Determinism Probabilism Ms →∗ Ns Ms = Ds Termination ∃Ns ∈ NF Ds = 1

Almost-Sure Termination Π0

2-complete.

slide-133
SLIDE 133

The Landscape: Recursion Theory

Determinism Probabilism Ms →∗ Ns Ms = Ds Termination ∃Ns ∈ NF Ds = 1 Uniform Termination ∀s.∃Ns ∈ NF

slide-134
SLIDE 134

The Landscape: Recursion Theory

Determinism Probabilism Ms →∗ Ns Ms = Ds Termination ∃Ns ∈ NF Ds = 1 Uniform Termination ∀s.∃Ns ∈ NF

Π0

2-complete.

slide-135
SLIDE 135

The Landscape: Recursion Theory

Determinism Probabilism Ms →∗ Ns Ms = Ds Termination ∃Ns ∈ NF Ds = 1 Uniform Termination ∀s.∃Ns ∈ NF ∀s. Ds = 1

slide-136
SLIDE 136

The Landscape: Recursion Theory

Determinism Probabilism Ms →∗ Ns Ms = Ds Termination ∃Ns ∈ NF Ds = 1 Uniform Termination ∀s.∃Ns ∈ NF ∀s. Ds = 1

Π0

2-complete.

slide-137
SLIDE 137

Deterministic Sized Types

◮ Pure λ-calculus with simple types is terminating.

◮ This can be proved in many ways, including by

reducibility.

◮ But useless as a programming language.

slide-138
SLIDE 138

Deterministic Sized Types

◮ Pure λ-calculus with simple types is terminating.

◮ This can be proved in many ways, including by

reducibility.

◮ But useless as a programming language.

◮ For every type τ, define a set of

reducible terms Redτ.

◮ Prove that all reducible terms are

  • normalizing. . .

◮ . . . and that all typable terms are

reducible.

slide-139
SLIDE 139

Deterministic Sized Types

◮ Pure λ-calculus with simple types is terminating.

◮ This can be proved in many ways, including by

reducibility.

◮ But useless as a programming language.

◮ What if we endow it with full recursion as a fix binder?

slide-140
SLIDE 140

Deterministic Sized Types

◮ Pure λ-calculus with simple types is terminating.

◮ This can be proved in many ways, including by

reducibility.

◮ But useless as a programming language.

◮ What if we endow it with full recursion as a fix binder?

(fix x.M)V → M{fix x.M/x}V

slide-141
SLIDE 141

Deterministic Sized Types

◮ Pure λ-calculus with simple types is terminating.

◮ This can be proved in many ways, including by

reducibility.

◮ But useless as a programming language.

◮ What if we endow it with full recursion as a fix binder? ◮ All the termination properties are lost, for very good

reasons.

slide-142
SLIDE 142

Deterministic Sized Types

◮ Pure λ-calculus with simple types is terminating.

◮ This can be proved in many ways, including by

reducibility.

◮ But useless as a programming language.

◮ What if we endow it with full recursion as a fix binder? ◮ All the termination properties are lost, for very good

reasons.

◮ Is everything lost?

slide-143
SLIDE 143

Deterministic Sized Types

◮ Pure λ-calculus with simple types is terminating.

◮ This can be proved in many ways, including by

reducibility.

◮ But useless as a programming language.

◮ What if we endow it with full recursion as a fix binder? ◮ All the termination properties are lost, for very good

reasons.

◮ Is everything lost? ◮ NO!

slide-144
SLIDE 144

Deterministic Sized Types

◮ Pure λ-calculus with simple types is terminating.

◮ This can be proved in many ways, including by

reducibility.

◮ But useless as a programming language.

◮ What if we endow it with full recursion as a fix binder? ◮ All the termination properties are lost, for very good

reasons.

◮ Is everything lost? ◮ NO!

fix f λx : ι

f(x − 1) f(x) f(x) f(x + 1)

M fix f λx : ι

f(x − 1) f(x − 2) f(x − 3)

M

BAD! GOOD!

slide-145
SLIDE 145

Deterministic Sized Types

◮ Pure λ-calculus with simple types is terminating.

◮ This can be proved in many ways, including by

reducibility.

◮ But useless as a programming language.

◮ What if we endow it with full recursion as a fix binder? ◮ All the termination properties are lost, for very good

reasons.

◮ Is everything lost? ◮ NO!

fix f λx : ι

f(x − 1) f(x) f(x) f(x + 1)

M fix f λx : ι

f(x − 1) f(x − 2) f(x − 3)

M

BAD! GOOD!

fix f λx : ι

f(x − 1) f(x − 2) f(x − 3)

M

GOOD!

slide-146
SLIDE 146

Deterministic Sized Types, Technically

◮ Types.

ξ ::= a | ω | ξ + 1; τ ::= ι[ξ] | τ → τ.

slide-147
SLIDE 147

Deterministic Sized Types, Technically

◮ Types.

ξ ::= a | ω | ξ + 1; τ ::= ι[ξ] | τ → τ. Index Terms

slide-148
SLIDE 148

Deterministic Sized Types, Technically

◮ Types.

ξ ::= a | ω | ξ + 1; τ ::= ι[ξ] | τ → τ.

◮ Typing Fixpoints.

Γ, x : ι[a] → τ ⊢ M : ι[a + 1] → τ Γ ⊢ fix x.M : ι[ξ] → τ

slide-149
SLIDE 149

Deterministic Sized Types, Technically

◮ Types.

ξ ::= a | ω | ξ + 1; τ ::= ι[ξ] | τ → τ.

◮ Typing Fixpoints.

Γ, x : ι[a] → τ ⊢ M : ι[a + 1] → τ Γ ⊢ fix x.M : ι[ξ] → τ

◮ Quite Powerful.

◮ Can type many forms of structural recursion.

slide-150
SLIDE 150

Deterministic Sized Types, Technically

◮ Types.

ξ ::= a | ω | ξ + 1; τ ::= ι[ξ] | τ → τ.

◮ Typing Fixpoints.

Γ, x : ι[a] → τ ⊢ M : ι[a + 1] → τ Γ ⊢ fix x.M : ι[ξ] → τ

◮ Quite Powerful.

◮ Can type many forms of structural recursion.

◮ Termination.

◮ Proved by Reducibility. ◮ . . . but of an indexed form.

slide-151
SLIDE 151

Deterministic Sized Types, Technically

◮ Types.

ξ ::= a | ω | ξ + 1; τ ::= ι[ξ] | τ → τ.

◮ Typing Fixpoints.

Γ, x : ι[a] → τ ⊢ M : ι[a + 1] → τ Γ ⊢ fix x.M : ι[ξ] → τ

◮ Quite Powerful.

◮ Can type many forms of structural recursion.

◮ Termination.

◮ Proved by Reducibility. ◮ . . . but of an indexed form.

◮ Reducibility sets are of the form Redθ τ. ◮ θ is an environment for index variables. ◮ Proof of reducibility for fix x.M is

rather delicate.

slide-152
SLIDE 152

Deterministic Sized Types, Technically

◮ Types.

ξ ::= a | ω | ξ + 1; τ ::= ι[ξ] | τ → τ.

◮ Typing Fixpoints.

Γ, x : ι[a] → τ ⊢ M : ι[a + 1] → τ Γ ⊢ fix x.M : ι[ξ] → τ

◮ Quite Powerful.

◮ Can type many forms of structural recursion.

◮ Termination.

◮ Proved by Reducibility. ◮ . . . but of an indexed form.

◮ Type Inference.

◮ It is indeed decidable. ◮ But nontrivial.

slide-153
SLIDE 153

Probabilistic Termination

◮ Examples:

fix f.λx.if x > 0 then if FairCoin then f(x − 1) else f(x + 1); fix f.λx.if x > 0 then if BiasedCoin then f(x − 1) else f(x + 1); fix f.λx.if BiasedCoin then f(x + 1) else x.

slide-154
SLIDE 154

Probabilistic Termination

◮ Examples:

fix f.λx.if x > 0 then if FairCoin then f(x − 1) else f(x + 1); fix f.λx.if x > 0 then if BiasedCoin then f(x − 1) else f(x + 1); fix f.λx.if BiasedCoin then f(x + 1) else x.

Unbiased Random Walk

slide-155
SLIDE 155

Probabilistic Termination

◮ Examples:

fix f.λx.if x > 0 then if FairCoin then f(x − 1) else f(x + 1); fix f.λx.if x > 0 then if BiasedCoin then f(x − 1) else f(x + 1); fix f.λx.if BiasedCoin then f(x + 1) else x.

Unbiased Random Walk Biased Randomn Walk

slide-156
SLIDE 156

Probabilistic Termination

◮ Examples:

fix f.λx.if x > 0 then if FairCoin then f(x − 1) else f(x + 1); fix f.λx.if x > 0 then if BiasedCoin then f(x − 1) else f(x + 1); fix f.λx.if BiasedCoin then f(x + 1) else x.

◮ Non-Examples:

fix f.λx.if FairCoin then f(x − 1) else (f(x + 1); f(x + 1)); fix f.λx.if BiasedCoin then f(x + 1) else f(x − 1);

slide-157
SLIDE 157

Probabilistic Termination

◮ Examples:

fix f.λx.if x > 0 then if FairCoin then f(x − 1) else f(x + 1); fix f.λx.if x > 0 then if BiasedCoin then f(x − 1) else f(x + 1); fix f.λx.if BiasedCoin then f(x + 1) else x.

◮ Non-Examples:

fix f.λx.if FairCoin then f(x − 1) else (f(x + 1); f(x + 1)); fix f.λx.if BiasedCoin then f(x + 1) else f(x − 1);

Unbiased Random Walk, with two upward calls.

slide-158
SLIDE 158

Probabilistic Termination

◮ Examples:

fix f.λx.if x > 0 then if FairCoin then f(x − 1) else f(x + 1); fix f.λx.if x > 0 then if BiasedCoin then f(x − 1) else f(x + 1); fix f.λx.if BiasedCoin then f(x + 1) else x.

◮ Non-Examples:

fix f.λx.if FairCoin then f(x − 1) else (f(x + 1); f(x + 1)); fix f.λx.if BiasedCoin then f(x + 1) else f(x − 1);

Unbiased Random Walk, with two upward calls. Biased Random Walk, the “wrong” way.

slide-159
SLIDE 159

Probabilistic Termination

◮ Examples:

fix f.λx.if x > 0 then if FairCoin then f(x − 1) else f(x + 1); fix f.λx.if x > 0 then if BiasedCoin then f(x − 1) else f(x + 1); fix f.λx.if BiasedCoin then f(x + 1) else x.

◮ Non-Examples:

fix f.λx.if FairCoin then f(x − 1) else (f(x + 1); f(x + 1)); fix f.λx.if BiasedCoin then f(x + 1) else f(x − 1);

◮ Probabilistic termination is thus:

◮ Sensitive to the actual distribution from which we sample. ◮ Sensitive to how many recursive calls we perform.

slide-160
SLIDE 160

One-Counter Blind Markov Chains

◮ They are automata of the form (Q, δ) where

◮ Q is a finite set of states. ◮ δ : Q → Dist(Q × {−1, 0, 1}).

◮ They are a very special form of One-Counter Markov

Decision Processeses [BBEK2011].

◮ The model is fully probabilistic, there is no nondeterminism. ◮ The counter value is ignored.

slide-161
SLIDE 161

One-Counter Blind Markov Chains

◮ They are automata of the form (Q, δ) where

◮ Q is a finite set of states. ◮ δ : Q → Dist(Q × {−1, 0, 1}).

◮ They are a very special form of One-Counter Markov

Decision Processeses [BBEK2011].

◮ The model is fully probabilistic, there is no nondeterminism. ◮ The counter value is ignored.

◮ The probability of reaching a configuration where the

counter is 0 can be approximated arbitrarily well in polynomial time.

slide-162
SLIDE 162

Probabilistic Sized Types [DLGrellois2017]

◮ Basic Idea: craft a sized-type system in such a way as to

mimick the recursive structure by a OCBMC.

slide-163
SLIDE 163

Probabilistic Sized Types [DLGrellois2017]

◮ Basic Idea: craft a sized-type system in such a way as to

mimick the recursive structure by a OCBMC.

◮ Judgments.

Γ | ∆ ⊢ M : µ

slide-164
SLIDE 164

Probabilistic Sized Types [DLGrellois2017]

◮ Basic Idea: craft a sized-type system in such a way as to

mimick the recursive structure by a OCBMC.

◮ Judgments.

Γ | ∆ ⊢ M : µ Every higher-order variable occurs at most once.

slide-165
SLIDE 165

Probabilistic Sized Types [DLGrellois2017]

◮ Basic Idea: craft a sized-type system in such a way as to

mimick the recursive structure by a OCBMC.

◮ Judgments.

Γ | ∆ ⊢ M : µ

◮ Typing Fixpoints.

Γ | x : σ ⊢ V : ι[a + 1] → τ OCBMC(σ) terminates. Γ | x : σ ⊢ V : ι[ξ] → τ

slide-166
SLIDE 166

Probabilistic Sized Types [DLGrellois2017]

◮ Basic Idea: craft a sized-type system in such a way as to

mimick the recursive structure by a OCBMC.

◮ Judgments.

Γ | ∆ ⊢ M : µ

◮ Typing Fixpoints.

Γ | x : σ ⊢ V : ι[a + 1] → τ OCBMC(σ) terminates. Γ | x : σ ⊢ V : ι[ξ] → τ

This is sufficient for typing:

◮ Unbiased random walks; ◮ Biased random walks.

slide-167
SLIDE 167

Probabilistic Sized Types [DLGrellois2017]

◮ Basic Idea: craft a sized-type system in such a way as to

mimick the recursive structure by a OCBMC.

◮ Judgments.

Γ | ∆ ⊢ M : µ

◮ Typing Fixpoints.

Γ | x : σ ⊢ V : ι[a + 1] → τ OCBMC(σ) terminates. Γ | x : σ ⊢ V : ι[ξ] → τ

◮ Typing Probabilistic Choice

Γ | ∆ ⊢ M : τ Γ | Ω ⊢ N : ρ Γ | 1

2∆ + 1 2Ω ⊢ M ⊕ N : 1 2τ + 1 2ρ

slide-168
SLIDE 168

Probabilistic Sized Types [DLGrellois2017]

◮ Basic Idea: craft a sized-type system in such a way as to

mimick the recursive structure by a OCBMC.

◮ Judgments.

Γ | ∆ ⊢ M : µ

◮ Typing Fixpoints.

Γ | x : σ ⊢ V : ι[a + 1] → τ OCBMC(σ) terminates. Γ | x : σ ⊢ V : ι[ξ] → τ

◮ Typing Probabilistic Choice

Γ | ∆ ⊢ M : τ Γ | Ω ⊢ N : ρ Γ | 1

2∆ + 1 2Ω ⊢ M ⊕ N : 1 2τ + 1 2ρ

◮ Termination.

◮ By a quantitative nontrivial refinement of reducibility.

slide-169
SLIDE 169

Probabilistic Sized Types [DLGrellois2017]

◮ Basic Idea: craft a sized-type system in such a way as to

mimick the recursive structure by a OCBMC.

◮ Judgments.

Γ | ∆ ⊢ M : µ

◮ Typing Fixpoints.

Γ | x : σ ⊢ V : ι[a + 1] → τ OCBMC(σ) terminates. Γ | x : σ ⊢ V : ι[ξ] → τ

◮ Typing Probabilistic Choice

Γ | ∆ ⊢ M : τ Γ | Ω ⊢ N : ρ Γ | 1

2∆ + 1 2Ω ⊢ M ⊕ N : 1 2τ + 1 2ρ

◮ Termination.

◮ By a quantitative nontrivial refinement of reducibility.

◮ Reducibility sets are now on the form Redθ,p τ ◮ p stands for the probability of being reducible. ◮ Reducibility sets are continuous:

Redθ,p

τ

=

  • q<p

Redθ,q

τ

slide-170
SLIDE 170

Deterministic Intersection Types

◮ Question: what are simple types missing as a way to

precisely capture termination?

slide-171
SLIDE 171

Deterministic Intersection Types

◮ Question: what are simple types missing as a way to

precisely capture termination?

◮ Very simple examples of normalizing terms which canoot be

typed: ∆ = λx.xx ∆(λx.x).

slide-172
SLIDE 172

Deterministic Intersection Types

◮ Question: what are simple types missing as a way to

precisely capture termination?

◮ Very simple examples of normalizing terms which canoot be

typed: ∆ = λx.xx ∆(λx.x).

◮ Types

τ ::= ⋆ | A → B A ::= {τ1, . . . , τn}

slide-173
SLIDE 173

Deterministic Intersection Types

◮ Question: what are simple types missing as a way to

precisely capture termination?

◮ Very simple examples of normalizing terms which canoot be

typed: ∆ = λx.xx ∆(λx.x).

◮ Types

τ ::= ⋆ | A → B A ::= {τ1, . . . , τn}

◮ Typing Rules: Examples

{Γ ⊢ M : τi}1≤i≤n Γ ⊢ M : {τ1, . . . , τn} Γ ⊢ M : {A → B} Γ ⊢ N : A Γ ⊢ MN : B

slide-174
SLIDE 174

Deterministic Intersection Types

◮ Question: what are simple types missing as a way to

precisely capture termination?

◮ Very simple examples of normalizing terms which canoot be

typed: ∆ = λx.xx ∆(λx.x).

◮ Types

τ ::= ⋆ | A → B A ::= {τ1, . . . , τn}

◮ Typing Rules: Examples

{Γ ⊢ M : τi}1≤i≤n Γ ⊢ M : {τ1, . . . , τn} Γ ⊢ M : {A → B} Γ ⊢ N : A Γ ⊢ MN : B

◮ Termination

◮ Again by reducibility.

slide-175
SLIDE 175

Deterministic Intersection Types

◮ Question: what are simple types missing as a way to

precisely capture termination?

◮ Very simple examples of normalizing terms which canoot be

typed: ∆ = λx.xx ∆(λx.x).

◮ Types

τ ::= ⋆ | A → B A ::= {τ1, . . . , τn}

◮ Typing Rules: Examples

{Γ ⊢ M : τi}1≤i≤n Γ ⊢ M : {τ1, . . . , τn} Γ ⊢ M : {A → B} Γ ⊢ N : A Γ ⊢ MN : B

◮ Termination

◮ Again by reducibility.

◮ Completeness

◮ By subject expansion, the dual of subject reduction.

slide-176
SLIDE 176

Oracle Intersection Types [BreuvartDL2017]

◮ Probabilistic choice can be seen as a form of read operation:

M ⊕ N = if BitInput then M else N

slide-177
SLIDE 177

Oracle Intersection Types [BreuvartDL2017]

◮ Probabilistic choice can be seen as a form of read operation:

M ⊕ N = if BitInput then M else N

◮ Types

τ ::= ⋆ | A → s · B A ::= {τ1, . . . , τn} s ∈ {0, 1}∗

slide-178
SLIDE 178

Oracle Intersection Types [BreuvartDL2017]

◮ Probabilistic choice can be seen as a form of read operation:

M ⊕ N = if BitInput then M else N

◮ Types

τ ::= ⋆ | A → s · B A ::= {τ1, . . . , τn} s ∈ {0, 1}∗

◮ Typing Rules: Examples

Γ ⊢ M : s · A Γ ⊢ M ⊕ N : 0s · A Γ ⊢ M : r · {A → s · B} Γ ⊢ N : q · A Γ ⊢ MN : (rqs) · B

slide-179
SLIDE 179

Oracle Intersection Types [BreuvartDL2017]

◮ Probabilistic choice can be seen as a form of read operation:

M ⊕ N = if BitInput then M else N

◮ Types

τ ::= ⋆ | A → s · B A ::= {τ1, . . . , τn} s ∈ {0, 1}∗

◮ Typing Rules: Examples

Γ ⊢ M : s · A Γ ⊢ M ⊕ N : 0s · A Γ ⊢ M : r · {A → s · B} Γ ⊢ N : q · A Γ ⊢ MN : (rqs) · B

◮ Termination and Completeness

◮ Formulated in a rather unusual way. ◮ Proved as usual, but relative to a single probabilistic branch

slide-180
SLIDE 180

Oracle Intersection Types [BreuvartDL2017]

◮ Probabilistic choice can be seen as a form of read operation:

M ⊕ N = if BitInput then M else N

◮ Types

τ ::= ⋆ | A → s · B A ::= {τ1, . . . , τn} s ∈ {0, 1}∗

◮ Typing Rules: Examples

Γ ⊢ M : s · A Γ ⊢ M ⊕ N : 0s · A Γ ⊢ M : r · {A → s · B} Γ ⊢ N : q · A Γ ⊢ MN : (rqs) · B

◮ Termination and Completeness

◮ Formulated in a rather unusual way. ◮ Proved as usual, but relative to a single probabilistic branch

P(M ↓) =

  • ⊢M:s·⋆

2|s|

slide-181
SLIDE 181

Oracle Intersection Types [BreuvartDL2017]

◮ Probabilistic choice can be seen as a form of read operation:

M ⊕ N = if BitInput then M else N

◮ Types

τ ::= ⋆ | A → s · B A ::= {τ1, . . . , τn} s ∈ {0, 1}∗

◮ Typing Rules: Examples

Γ ⊢ M : s · A Γ ⊢ M ⊕ N : 0s · A Γ ⊢ M : r · {A → s · B} Γ ⊢ N : q · A Γ ⊢ MN : (rqs) · B

◮ Termination and Completeness

◮ Formulated in a rather unusual way. ◮ Proved as usual, but relative to a single probabilistic branch

P(M ↓) =

  • ⊢M:s·⋆

2|s| This is unavoidable, due to recursion theory.

slide-182
SLIDE 182

Intersection Types and Computations

M V

slide-183
SLIDE 183

Intersection Types and Computations

M V

Intersection Types

slide-184
SLIDE 184

Intersection Types and Computations

M V M W V . . . . . .

slide-185
SLIDE 185

Intersection Types and Computations

M V M W V . . . . . .

Oracle Intersection Types

slide-186
SLIDE 186

Intersection Types and Computations

M V M W V . . . . . . M W V . . . . . .

slide-187
SLIDE 187

Intersection Types and Computations

M V M W V . . . . . . M W V . . . . . .

Monadic Intersection Types [BDL2017]

◮ They are a combination of oracle and

sized types.

◮ Intersections are needed for preciseness. ◮ Distributions of types allow to analyse

more than one probabilistic branch in the same type derivation.

slide-188
SLIDE 188

These Slides, and More...

slide-189
SLIDE 189

These Slides, and More...

Questions?