Advanced Semantics of Programming...

38
Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT & Colin RIBA LIP - ENS de Lyon Course 01 09/11 CLAIRAMBAULT &RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 1 / 10

Transcript of Advanced Semantics of Programming...

Page 1: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Advanced Semantics of Programming Languages

Pierre CLAIRAMBAULT & Colin RIBA

LIP - ENS de Lyon

Course 0109/11

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 1 / 10

Page 2: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Naive Introduction

A Naive Introduction(based on simple examples)

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 2 / 10

Page 3: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Naive Introduction

The First ExampleConsider the programs

foo(f:int->int):return f(5) + f(5) and

bar(f:int->int):a = f(5)return a + a

Are these two programs equivalent ?I They are not equivalent if f can access a global reference.I They are equivalent if f behaves as a function, say

JfK : JintK −→ JintK

where JintK is a set representing the type int.

Objectives of the course.I Mathematical models of programming languages

(denotational semantics, category theory, type systems).

Methodology of the course.I Begin with simple approaches.I Then progressively model more complex behaviours.

Now:I A naive introduction to some basic ideas.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 3 / 10

Page 4: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Naive Introduction

The First ExampleConsider the programs

foo(f:int->int):return f(5) + f(5) and

bar(f:int->int):a = f(5)return a + a

Are these two programs equivalent ?

I They are not equivalent if f can access a global reference.I They are equivalent if f behaves as a function, say

JfK : JintK −→ JintK

where JintK is a set representing the type int.

Objectives of the course.I Mathematical models of programming languages

(denotational semantics, category theory, type systems).

Methodology of the course.I Begin with simple approaches.I Then progressively model more complex behaviours.

Now:I A naive introduction to some basic ideas.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 3 / 10

Page 5: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Naive Introduction

The First ExampleConsider the programs

foo(f:int->int):return f(5) + f(5) and

bar(f:int->int):a = f(5)return a + a

Are these two programs equivalent ?I They are not equivalent if f can access a global reference.

I They are equivalent if f behaves as a function, say

JfK : JintK −→ JintK

where JintK is a set representing the type int.

Objectives of the course.I Mathematical models of programming languages

(denotational semantics, category theory, type systems).

Methodology of the course.I Begin with simple approaches.I Then progressively model more complex behaviours.

Now:I A naive introduction to some basic ideas.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 3 / 10

Page 6: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Naive Introduction

The First ExampleConsider the programs

foo(f:int->int):return f(5) + f(5) and

bar(f:int->int):a = f(5)return a + a

Are these two programs equivalent ?I They are not equivalent if f can access a global reference.I They are equivalent if f behaves as a function, say

JfK : JintK −→ JintK

where JintK is a set representing the type int.

Objectives of the course.I Mathematical models of programming languages

(denotational semantics, category theory, type systems).

Methodology of the course.I Begin with simple approaches.I Then progressively model more complex behaviours.

Now:I A naive introduction to some basic ideas.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 3 / 10

Page 7: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Naive Introduction

The First ExampleConsider the programs

foo(f:int->int):return f(5) + f(5) and

bar(f:int->int):a = f(5)return a + a

Are these two programs equivalent ?I They are not equivalent if f can access a global reference.I They are equivalent if f behaves as a function, say

JfK : JintK −→ JintK

where JintK is a set representing the type int.

Objectives of the course.I Mathematical models of programming languages

(denotational semantics, category theory, type systems).

Methodology of the course.I Begin with simple approaches.I Then progressively model more complex behaviours.

Now:I A naive introduction to some basic ideas.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 3 / 10

Page 8: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Naive Introduction

The First ExampleConsider the programs

foo(f:int->int):return f(5) + f(5) and

bar(f:int->int):a = f(5)return a + a

Are these two programs equivalent ?I They are not equivalent if f can access a global reference.I They are equivalent if f behaves as a function, say

JfK : JintK −→ JintK

where JintK is a set representing the type int.

Objectives of the course.I Mathematical models of programming languages

(denotational semantics, category theory, type systems).

Methodology of the course.I Begin with simple approaches.I Then progressively model more complex behaviours.

Now:I A naive introduction to some basic ideas.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 3 / 10

Page 9: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Naive Introduction

The First ExampleConsider the programs

foo(f:int->int):return f(5) + f(5) and

bar(f:int->int):a = f(5)return a + a

Are these two programs equivalent ?I They are not equivalent if f can access a global reference.I They are equivalent if f behaves as a function, say

JfK : JintK −→ JintK

where JintK is a set representing the type int.

Objectives of the course.I Mathematical models of programming languages

(denotational semantics, category theory, type systems).

Methodology of the course.I Begin with simple approaches.I Then progressively model more complex behaviours.

Now:I A naive introduction to some basic ideas.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 3 / 10

Page 10: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Naive Introduction

Types as SetsI Assume types, say int, bool, are to be interpreted as sets JintK, JboolK.

Question.I Can we assume

JboolK := true,false (1)Answer.I Consider the non-terminating program

loop (b:bool):while true:

skipreturn true

I If JboolK is as in (1), then we can not have

JloopK : JboolK −→ JboolK

I We shall therefore represent divergence and assume

JboolK := ⊥,true,false (⊥ “=” divergence)

We can then have, as expected:

JloopK(a) = ⊥ (for all a ∈ JboolK)

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 4 / 10

Page 11: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Naive Introduction

Types as SetsI Assume types, say int, bool, are to be interpreted as sets JintK, JboolK.

Question.I Can we assume

JboolK := true,false (1)

Answer.I Consider the non-terminating program

loop (b:bool):while true:

skipreturn true

I If JboolK is as in (1), then we can not have

JloopK : JboolK −→ JboolK

I We shall therefore represent divergence and assume

JboolK := ⊥,true,false (⊥ “=” divergence)

We can then have, as expected:

JloopK(a) = ⊥ (for all a ∈ JboolK)

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 4 / 10

Page 12: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Naive Introduction

Types as SetsI Assume types, say int, bool, are to be interpreted as sets JintK, JboolK.

Question.I Can we assume

JboolK := true,false (1)Answer.I Consider the non-terminating program

loop (b:bool):while true:skip

return true

I If JboolK is as in (1), then we can not have

JloopK : JboolK −→ JboolK

I We shall therefore represent divergence and assume

JboolK := ⊥,true,false (⊥ “=” divergence)

We can then have, as expected:

JloopK(a) = ⊥ (for all a ∈ JboolK)

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 4 / 10

Page 13: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Naive Introduction

Types as SetsI Assume types, say int, bool, are to be interpreted as sets JintK, JboolK.

Question.I Can we assume

JboolK := true,false (1)Answer.I Consider the non-terminating program

loop (b:bool):while true:skip

return true

I If JboolK is as in (1), then we can not have

JloopK : JboolK −→ JboolK

I We shall therefore represent divergence and assume

JboolK := ⊥,true,false (⊥ “=” divergence)

We can then have, as expected:

JloopK(a) = ⊥ (for all a ∈ JboolK)

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 4 / 10

Page 14: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Naive Introduction

Types as SetsI Assume types, say int, bool, are to be interpreted as sets JintK, JboolK.

Question.I Can we assume

JboolK := true,false (1)Answer.I Consider the non-terminating program

loop (b:bool):while true:skip

return true

I If JboolK is as in (1), then we can not have

JloopK : JboolK −→ JboolK

I We shall therefore represent divergence and assume

JboolK := ⊥,true,false (⊥ “=” divergence)

We can then have, as expected:

JloopK(a) = ⊥ (for all a ∈ JboolK)

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 4 / 10

Page 15: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Naive Introduction

A Taste of Finitary PCF

Motivation.I A simple language to discuss

JboolK := ⊥,true,false

The Language of Finitary PCF.

τ, σ ::= bool | σ → τ

t , u ::= t u | fun x → t | true | false | if t then u else v | Ω

I Purely functional language with Booleans and divergence (Ω).

We assume call-by-name evaluation:

(fun x → t)u = t [u/x ]if true then t else u = t

if false then t else u = u

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 5 / 10

Page 16: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Naive Introduction

A Taste of Finitary PCF

Motivation.I A simple language to discuss

JboolK := ⊥,true,false

The Language of Finitary PCF.

τ, σ ::= bool | σ → τ

t , u ::= t u | fun x → t | true | false | if t then u else v | Ω

I Purely functional language with Booleans and divergence (Ω).

We assume call-by-name evaluation:

(fun x → t)u = t [u/x ]if true then t else u = t

if false then t else u = u

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 5 / 10

Page 17: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Naive Introduction

A Taste of Finitary PCF

Motivation.I A simple language to discuss

JboolK := ⊥,true,false

The Language of Finitary PCF.

τ, σ ::= bool | σ → τ

t , u ::= t u | fun x → t | true | false | if t then u else v | Ω

I Purely functional language with Booleans and divergence (Ω).

We assume call-by-name evaluation:

(fun x → t)u = t [u/x ]if true then t else u = t

if false then t else u = u

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 5 / 10

Page 18: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Naive Introduction

A Taste of Finitary PCF

Motivation.I A simple language to discuss

JboolK := ⊥,true,false

The Language of Finitary PCF.

τ, σ ::= bool | σ → τ

t , u ::= t u | fun x → t | true | false | if t then u else v | Ω

I Purely functional language with Booleans and divergence (Ω).

We assume call-by-name evaluation:

(fun x → t)u = t [u/x ]if true then t else u = t

if false then t else u = u

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 5 / 10

Page 19: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Naive Introduction

Example.Consider the two following or programs:

or_l := fun a, b ->if a then a else b vs

or_r := fun a, b ->if b then b else a

Questions.I What are the functions Jor_lK, Jor_rK ?I Are the programs or_l and or_r equivalent ?

Example.Consider, for b ∈ true,false, the program

taste_b := fun f ->if f(true, Ω) and

f(Ω, true) andnot(f(false, false))

then belse true

Questions.I Do we have Jtaste_trueK = Jtaste_falseK ?I Are taste_true and taste_false equivalent ?

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 6 / 10

Page 20: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Naive Introduction

Example.Consider the two following or programs:

or_l := fun a, b ->if a then a else b vs

or_r := fun a, b ->if b then b else a

Questions.I What are the functions Jor_lK, Jor_rK ?I Are the programs or_l and or_r equivalent ?

Example.Consider, for b ∈ true,false, the program

taste_b := fun f ->if f(true, Ω) and

f(Ω, true) andnot(f(false, false))

then belse true

Questions.I Do we have Jtaste_trueK = Jtaste_falseK ?I Are taste_true and taste_false equivalent ?

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 6 / 10

Page 21: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Naive Introduction

Example.Consider the two following or programs:

or_l := fun a, b ->if a then a else b vs

or_r := fun a, b ->if b then b else a

Questions.I What are the functions Jor_lK, Jor_rK ?I Are the programs or_l and or_r equivalent ?

Example.Consider, for b ∈ true,false, the program

taste_b := fun f ->if f(true, Ω) and

f(Ω, true) andnot(f(false, false))

then belse true

Questions.I Do we have Jtaste_trueK = Jtaste_falseK ?I Are taste_true and taste_false equivalent ?

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 6 / 10

Page 22: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Naive Introduction

Example.Consider the two following or programs:

or_l := fun a, b ->if a then a else b vs

or_r := fun a, b ->if b then b else a

Questions.I What are the functions Jor_lK, Jor_rK ?I Are the programs or_l and or_r equivalent ?

Example.Consider, for b ∈ true,false, the program

taste_b := fun f ->if f(true, Ω) and

f(Ω, true) andnot(f(false, false))

then belse true

Questions.I Do we have Jtaste_trueK = Jtaste_falseK ?I Are taste_true and taste_false equivalent ?

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 6 / 10

Page 23: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Naive Introduction

A Taste of PCFMotivation.I Extend Finitary PCF with general recursion.I Mathematically cleaner if an infinite type is assumed (say the natural numbers).

The Language of PCF.

τ, σ ::= . . . | nat

t , u ::= . . . | t+1 | t-1 | z? | Y | n (for each n ∈ N)I Y is a fixpoint combinator:

Y t = t (Y t)Examples.I We could have defined

Ω := Y (fun x → x)

I Additionadd 0 u = uadd t+1 u = (add t u)+1

can be defined asadd := Y add_rec

whereadd_rec := fun f, x, y ->

if (z? x) then y else (f x-1 y)+1

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 7 / 10

Page 24: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Naive Introduction

A Taste of PCFMotivation.I Extend Finitary PCF with general recursion.I Mathematically cleaner if an infinite type is assumed (say the natural numbers).

The Language of PCF.

τ, σ ::= . . . | nat

t , u ::= . . . | t+1 | t-1 | z? | Y | n (for each n ∈ N)I Y is a fixpoint combinator:

Y t = t (Y t)

Examples.I We could have defined

Ω := Y (fun x → x)

I Additionadd 0 u = uadd t+1 u = (add t u)+1

can be defined asadd := Y add_rec

whereadd_rec := fun f, x, y ->

if (z? x) then y else (f x-1 y)+1

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 7 / 10

Page 25: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Naive Introduction

A Taste of PCFMotivation.I Extend Finitary PCF with general recursion.I Mathematically cleaner if an infinite type is assumed (say the natural numbers).

The Language of PCF.

τ, σ ::= . . . | nat

t , u ::= . . . | t+1 | t-1 | z? | Y | n (for each n ∈ N)I Y is a fixpoint combinator:

Y t = t (Y t)Examples.I We could have defined

Ω := Y (fun x → x)

I Additionadd 0 u = uadd t+1 u = (add t u)+1

can be defined asadd := Y add_rec

whereadd_rec := fun f, x, y ->

if (z? x) then y else (f x-1 y)+1

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 7 / 10

Page 26: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Naive Introduction

A Taste of PCFMotivation.I Extend Finitary PCF with general recursion.I Mathematically cleaner if an infinite type is assumed (say the natural numbers).

The Language of PCF.

τ, σ ::= . . . | nat

t , u ::= . . . | t+1 | t-1 | z? | Y | n (for each n ∈ N)I Y is a fixpoint combinator:

Y t = t (Y t)Examples.I We could have defined

Ω := Y (fun x → x)

I Additionadd 0 u = uadd t+1 u = (add t u)+1

can be defined asadd := Y add_rec

whereadd_rec := fun f, x, y ->

if (z? x) then y else (f x-1 y)+1

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 7 / 10

Page 27: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Naive Introduction

A Taste of PCFMotivation.I Extend Finitary PCF with general recursion.I Mathematically cleaner if an infinite type is assumed (say the natural numbers).

The Language of PCF.

τ, σ ::= . . . | nat

t , u ::= . . . | t+1 | t-1 | z? | Y | n (for each n ∈ N)I Y is a fixpoint combinator:

Y t = t (Y t)Examples.I We could have defined

Ω := Y (fun x → x)

I Additionadd 0 u = uadd t+1 u = (add t u)+1

can be defined asadd := Y add_rec

whereadd_rec := fun f, x, y ->

if (z? x) then y else (f x-1 y)+1

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 7 / 10

Page 28: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Naive Introduction

A Denotational Semantics for PCF ?

We Would LikeI each type τ to be interpreted as a set JτK,I a program t of type say σ → τ to be interpreted as a function

JtK : JσK −→ JτK

Difficulty.I Equation

Y t = t (Y t)

imposesJY K : (S → S) −→ S

Traditional Solution.I Restrict S → S to the continuous functions for a suitable topology

(cpos, Scott domains, etc).Gödel’s System T.I Restrict Y to recursion over N:

rec u v 0 = urec u v t+1 = v t (rec u v t)

I Allows to see important basic techniques in a simple setting.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 8 / 10

Page 29: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Naive Introduction

A Denotational Semantics for PCF ?We Would LikeI each type τ to be interpreted as a set JτK,

I a program t of type say σ → τ to be interpreted as a function

JtK : JσK −→ JτK

Difficulty.I Equation

Y t = t (Y t)

imposesJY K : (S → S) −→ S

Traditional Solution.I Restrict S → S to the continuous functions for a suitable topology

(cpos, Scott domains, etc).Gödel’s System T.I Restrict Y to recursion over N:

rec u v 0 = urec u v t+1 = v t (rec u v t)

I Allows to see important basic techniques in a simple setting.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 8 / 10

Page 30: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Naive Introduction

A Denotational Semantics for PCF ?We Would LikeI each type τ to be interpreted as a set JτK,I a program t of type say σ → τ to be interpreted as a function

JtK : JσK −→ JτK

Difficulty.I Equation

Y t = t (Y t)

imposesJY K : (S → S) −→ S

Traditional Solution.I Restrict S → S to the continuous functions for a suitable topology

(cpos, Scott domains, etc).Gödel’s System T.I Restrict Y to recursion over N:

rec u v 0 = urec u v t+1 = v t (rec u v t)

I Allows to see important basic techniques in a simple setting.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 8 / 10

Page 31: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Naive Introduction

A Denotational Semantics for PCF ?We Would LikeI each type τ to be interpreted as a set JτK,I a program t of type say σ → τ to be interpreted as a function

JtK : JσK −→ JτK

Difficulty.I Equation

Y t = t (Y t)

imposesJY K : (S → S) −→ S

Traditional Solution.I Restrict S → S to the continuous functions for a suitable topology

(cpos, Scott domains, etc).Gödel’s System T.I Restrict Y to recursion over N:

rec u v 0 = urec u v t+1 = v t (rec u v t)

I Allows to see important basic techniques in a simple setting.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 8 / 10

Page 32: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Naive Introduction

A Denotational Semantics for PCF ?We Would LikeI each type τ to be interpreted as a set JτK,I a program t of type say σ → τ to be interpreted as a function

JtK : JσK −→ JτK

Difficulty.I Equation

Y t = t (Y t)

imposesJY K : (S → S) −→ S

Traditional Solution.I Restrict S → S to the continuous functions for a suitable topology

(cpos, Scott domains, etc).

Gödel’s System T.I Restrict Y to recursion over N:

rec u v 0 = urec u v t+1 = v t (rec u v t)

I Allows to see important basic techniques in a simple setting.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 8 / 10

Page 33: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Naive Introduction

A Denotational Semantics for PCF ?We Would LikeI each type τ to be interpreted as a set JτK,I a program t of type say σ → τ to be interpreted as a function

JtK : JσK −→ JτK

Difficulty.I Equation

Y t = t (Y t)

imposesJY K : (S → S) −→ S

Traditional Solution.I Restrict S → S to the continuous functions for a suitable topology

(cpos, Scott domains, etc).Gödel’s System T.I Restrict Y to recursion over N:

rec u v 0 = urec u v t+1 = v t (rec u v t)

I Allows to see important basic techniques in a simple setting.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 8 / 10

Page 34: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Naive Introduction

A Denotational Semantics for PCF ?We Would LikeI each type τ to be interpreted as a set JτK,I a program t of type say σ → τ to be interpreted as a function

JtK : JσK −→ JτK

Difficulty.I Equation

Y t = t (Y t)

imposesJY K : (S → S) −→ S

Traditional Solution.I Restrict S → S to the continuous functions for a suitable topology

(cpos, Scott domains, etc).Gödel’s System T.I Restrict Y to recursion over N:

rec u v 0 = urec u v t+1 = v t (rec u v t)

I Allows to see important basic techniques in a simple setting.CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 8 / 10

Page 35: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Outline

Rough Outline

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 9 / 10

Page 36: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Outline

Indicative Outline

Courses 1–6: (C. RIBA)I Set-theoretic semantics of System T.I Denotational semantics of PCF (cpos, logical relations).I Further topics among:

I Polymorphism (Girard-Reynolds System F).I Recursive types.I Intersection types.I Scott domains and PCF definability.I Results on the set-theoretic semantics of the simply-typed λ-calculus.

Courses 7–12: (P. CLAIRAMBAULT)I Categories, functors and natural transformations.I Cartesian closed categories and the λ-calculus.I Monads.I Further topics among:

I Categorical models of linear logic.I Game semantics.

Courses 13–: Survey of Some Active Research Topics.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 10 / 10

Page 37: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Outline

Indicative Outline

Courses 1–6: (C. RIBA)I Set-theoretic semantics of System T.I Denotational semantics of PCF (cpos, logical relations).I Further topics among:

I Polymorphism (Girard-Reynolds System F).I Recursive types.I Intersection types.I Scott domains and PCF definability.I Results on the set-theoretic semantics of the simply-typed λ-calculus.

Courses 7–12: (P. CLAIRAMBAULT)I Categories, functors and natural transformations.I Cartesian closed categories and the λ-calculus.I Monads.I Further topics among:

I Categorical models of linear logic.I Game semantics.

Courses 13–: Survey of Some Active Research Topics.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 10 / 10

Page 38: Advanced Semantics of Programming Languagesperso.ens-lyon.fr/colin.riba/teaching/as/slides/course01.pdf · 2019-09-11 · Advanced Semantics of Programming Languages Pierre CLAIRAMBAULT

Outline

Indicative Outline

Courses 1–6: (C. RIBA)I Set-theoretic semantics of System T.I Denotational semantics of PCF (cpos, logical relations).I Further topics among:

I Polymorphism (Girard-Reynolds System F).I Recursive types.I Intersection types.I Scott domains and PCF definability.I Results on the set-theoretic semantics of the simply-typed λ-calculus.

Courses 7–12: (P. CLAIRAMBAULT)I Categories, functors and natural transformations.I Cartesian closed categories and the λ-calculus.I Monads.I Further topics among:

I Categorical models of linear logic.I Game semantics.

Courses 13–: Survey of Some Active Research Topics.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 01 09/11 10 / 10