advanced semantics of programming languages
play

Advanced Semantics of Programming Languages Pierre C LAIRAMBAULT - PowerPoint PPT Presentation

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 Gdels System T Gdels System T


  1. 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

  2. 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

  3. 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

  4. 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

  5. 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

  6. 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

  7. 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

  8. 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

  9. 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

  10. 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

  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

  12. 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

  13. 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

  14. 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

  15. 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

  16. 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

  17. PCF The Language PCF C LAIRAMBAULT & R IBA (LIP - ENS de Lyon) ASPL (CR04) Course 03 09/25 5 / 11

  18. 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

  19. 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

  20. 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

  21. 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

  22. 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

  23. 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

  24. 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

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend