Advanced Semantics of Programming Languages Pierre C LAIRAMBAULT & Colin R IBA LIP - ENS de Lyon Course 03 09/25 C LAIRAMBAULT & R IBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 1 / 11
Gödel’s System T Gödel’s System T (recap) C LAIRAMBAULT & R IBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 2 / 11
Gödel’s System T Motivation General Idea: ◮ Devise models of programming languages . . . C LAIRAMBAULT & R IBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 3 / 11
Gödel’s System T Motivation General Idea: ◮ Devise models of programming languages . . . starting from simple settings. C LAIRAMBAULT & R IBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 3 / 11
Gödel’s System T Motivation General Idea: ◮ Devise models of programming languages . . . starting from simple settings. So Far C LAIRAMBAULT & R IBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 3 / 11
Gödel’s System T Motivation General Idea: ◮ Devise models of programming languages . . . starting from simple settings. So Far Finitary PCF. ◮ Booleans + Divergence ( Ω ). ◮ Set-theoretic model with � bool � = {⊥ , true , false } C LAIRAMBAULT & R IBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 3 / 11
Gödel’s System T Motivation General Idea: ◮ Devise models of programming languages . . . starting from simple settings. So Far Finitary PCF. ◮ Booleans + Divergence ( Ω ). ◮ Set-theoretic model with � bool � = {⊥ , true , false } PCF. ◮ Natural numbers + General recursion ( Y σ : ( σ → σ ) → σ ). C LAIRAMBAULT & R IBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 3 / 11
Gödel’s System T Motivation General Idea: ◮ Devise models of programming languages . . . starting from simple settings. So Far Finitary PCF. ◮ Booleans + Divergence ( Ω ). ◮ Set-theoretic model with � bool � = {⊥ , true , false } PCF. ◮ Natural numbers + General recursion ( Y σ : ( σ → σ ) → σ ). ◮ There is no canonical choice for � Y σ � : ( � σ � → � σ � ) − → � σ � C LAIRAMBAULT & R IBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 3 / 11
Gödel’s System T Motivation General Idea: ◮ Devise models of programming languages . . . starting from simple settings. So Far Finitary PCF. ◮ Booleans + Divergence ( Ω ). ◮ Set-theoretic model with � bool � = {⊥ , true , false } PCF. ◮ Natural numbers + General recursion ( Y σ : ( σ → σ ) → σ ). ◮ There is no canonical choice for � Y σ � : ( � σ � → � σ � ) − → � σ � Gödel’s System T. ◮ Restrict to recursion over N : Rec ( u , v , 0 ) u ⊲ Rec ( u , v , t +1 ) v t Rec ( u , v , t ) ⊲ C LAIRAMBAULT & R IBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 3 / 11
Gödel’s System T Motivation General Idea: ◮ Devise models of programming languages . . . starting from simple settings. So Far Finitary PCF. ◮ Booleans + Divergence ( Ω ). ◮ Set-theoretic model with � bool � = {⊥ , true , false } PCF. ◮ Natural numbers + General recursion ( Y σ : ( σ → σ ) → σ ). ◮ There is no canonical choice for � Y σ � : ( � σ � → � σ � ) − → � σ � Gödel’s System T. ◮ Restrict to recursion over N : Rec ( u , v , 0 ) u ⊲ Rec ( u , v , t +1 ) v t Rec ( u , v , t ) ⊲ ◮ Allows to see important techniques in a simple setting. C LAIRAMBAULT & R IBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 3 / 11
Gödel’s System T Set-Theoretic Denotational Semantics of System T Normalization. ◮ If ⊢ t : nat then t ⊲ ∗ n for some (unique) n ∈ N . C LAIRAMBAULT & R IBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 4 / 11
Gödel’s System T Set-Theoretic Denotational Semantics of System T Normalization. ◮ If ⊢ t : nat then t ⊲ ∗ n for some (unique) n ∈ N . Consequence. ◮ A term ⊢ t : nat → nat induces a function [ t ] : N → N . C LAIRAMBAULT & R IBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 4 / 11
Gödel’s System T Set-Theoretic Denotational Semantics of System T Normalization. ◮ If ⊢ t : nat then t ⊲ ∗ n for some (unique) n ∈ N . Consequence. ◮ A term ⊢ t : nat → nat induces a function [ t ] : N → N . ◮ But can we say that ⊢ t : ( nat → nat ) → nat induces a function ( N → N ) → N ? (Think of Streams ( nat ) as a subset of ( N → N ) .) C LAIRAMBAULT & R IBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 4 / 11
Gödel’s System T Set-Theoretic Denotational Semantics of System T Normalization. ◮ If ⊢ t : nat then t ⊲ ∗ n for some (unique) n ∈ N . Consequence. ◮ A term ⊢ t : nat → nat induces a function [ t ] : N → N . ◮ But can we say that ⊢ t : ( nat → nat ) → nat induces a function ( N → N ) → N ? (Think of Streams ( nat ) as a subset of ( N → N ) .) Set-Theoretic Model. � nat � := N � τ � � σ � � σ → τ � := � σ � → � τ � = C LAIRAMBAULT & R IBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 4 / 11
Gödel’s System T Set-Theoretic Denotational Semantics of System T Normalization. ◮ If ⊢ t : nat then t ⊲ ∗ n for some (unique) n ∈ N . Consequence. ◮ A term ⊢ t : nat → nat induces a function [ t ] : N → N . ◮ But can we say that ⊢ t : ( nat → nat ) → nat induces a function ( N → N ) → N ? (Think of Streams ( nat ) as a subset of ( N → N ) .) Set-Theoretic Model. � nat � := N � τ � � σ � � σ → τ � := � σ � → � τ � = Natural Numbers. ◮ � 0 � := 0. ◮ � ( − ) +1 � : ( n ∈ N ) �− → ( n + 1 ∈ N ) . C LAIRAMBAULT & R IBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 4 / 11
Gödel’s System T Set-Theoretic Denotational Semantics of System T Normalization. ◮ If ⊢ t : nat then t ⊲ ∗ n for some (unique) n ∈ N . Consequence. ◮ A term ⊢ t : nat → nat induces a function [ t ] : N → N . ◮ But can we say that ⊢ t : ( nat → nat ) → nat induces a function ( N → N ) → N ? (Think of Streams ( nat ) as a subset of ( N → N ) .) Set-Theoretic Model. � nat � := N � τ � � σ � � σ → τ � := � σ � → � τ � = Natural Numbers. ◮ � 0 � := 0. ◮ � ( − ) +1 � : ( n ∈ N ) �− → ( n + 1 ∈ N ) . Recursor. ◮ Given a ∈ � σ � and � σ � � σ � � � nat � � b ∈ � nat → σ → σ � = define � Rec σ � ( a , b , n ) ∈ � σ � by induction on n ∈ N : � Rec σ � ( a , b , 0 ) := a � Rec σ � ( a , b , n + 1 ) := b n � Rec σ � ( a , b , n ) and C LAIRAMBAULT & R IBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 4 / 11
PCF The Language PCF C LAIRAMBAULT & R IBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 5 / 11
PCF The Syntax of PCF Motivation. ◮ A simple functional language with general recursion. C LAIRAMBAULT & R IBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 6 / 11
PCF The Syntax of PCF Motivation. ◮ A simple functional language with general recursion. The Language of PCF. τ, σ ::= | σ → τ nat C LAIRAMBAULT & R IBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 6 / 11
PCF The Syntax of PCF Motivation. ◮ A simple functional language with general recursion. The Language of PCF. τ, σ ::= | σ → τ nat t , u ::= | λ x : σ. t | | | | | x t u Y σ t +1 t -1 n | if t then u else v C LAIRAMBAULT & R IBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 6 / 11
PCF The Syntax of PCF Motivation. ◮ A simple functional language with general recursion. The Language of PCF. τ, σ ::= | σ → τ nat t , u ::= | λ x : σ. t | | | | | x t u Y σ t +1 t -1 n | if t then u else v Notes. ◮ We assume an infinite set of variables x , y , z , . . . ◮ We have one numeral n for each n ∈ N . C LAIRAMBAULT & R IBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 6 / 11
PCF The Syntax of PCF Motivation. ◮ A simple functional language with general recursion. The Language of PCF. τ, σ ::= | σ → τ nat t , u ::= | λ x : σ. t | | | | | x t u Y σ t +1 t -1 n | if t then u else v Notes. ◮ We assume an infinite set of variables x , y , z , . . . ◮ We have one numeral n for each n ∈ N . ◮ Y is the fixpoint combinator. C LAIRAMBAULT & R IBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 6 / 11
PCF The Syntax of PCF Motivation. ◮ A simple functional language with general recursion. The Language of PCF. τ, σ ::= | σ → τ nat t , u ::= | λ x : σ. t | | | | | x t u Y σ t +1 t -1 n | if t then u else v Notes. ◮ We assume an infinite set of variables x , y , z , . . . ◮ We have one numeral n for each n ∈ N . ◮ Y is the fixpoint combinator. Typing Rules. ◮ Adaptation of System T with Γ ⊢ n : nat ( n ∈ N ) Γ ⊢ Y σ : ( σ → σ ) → σ Γ ⊢ t : nat Γ ⊢ u : nat Γ ⊢ v : nat Γ ⊢ t : nat Γ ⊢ if t then u else v : nat Γ ⊢ t -1 : nat C LAIRAMBAULT & R IBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 6 / 11
PCF Operational Semantics Weak Head Reduction. ◮ Usual (weak) call-by-name evaluation. C LAIRAMBAULT & R IBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 7 / 11
Recommend
More recommend