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

advanced semantics of programming languages
SMART_READER_LITE
LIVE PREVIEW

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 13 12/11 C LAIRAMBAULT & R IBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 1 / 12 System F The Polymorphic Lambda-Calculus


slide-1
SLIDE 1

Advanced Semantics of Programming Languages

Pierre CLAIRAMBAULT & Colin RIBA

LIP - ENS de Lyon

Course 13 12/11

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 1 / 12

slide-2
SLIDE 2

System F

The Polymorphic Lambda-Calculus

(a.k.a. System F)

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 2 / 12

slide-3
SLIDE 3

System F

Introduction

Example (Map). ◮ Consider a map function mapσ,τ : (σ → τ) × list(σ) − → list(τ)

  • f , [a0; . . . ; an]

→ [f(a0) ; . . . ; f(an)] (σ, τ types)

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 3 / 12

slide-4
SLIDE 4

System F

Introduction

Example (Map). ◮ Consider a map function mapσ,τ : (σ → τ) × list(σ) − → list(τ)

  • f , [a0; . . . ; an]

→ [f(a0) ; . . . ; f(an)] (σ, τ types) ◮ The behavior of mapσ,τ is independent from the types σ, τ.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 3 / 12

slide-5
SLIDE 5

System F

Introduction

Example (Map). ◮ Consider a map function mapσ,τ : (σ → τ) × list(σ) − → list(τ)

  • f , [a0; . . . ; an]

→ [f(a0) ; . . . ; f(an)] (σ, τ types) ◮ The behavior of mapσ,τ is independent from the types σ, τ. ◮ One may want to have just one implementation, independent from σ and τ.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 3 / 12

slide-6
SLIDE 6

System F

Introduction

Example (Map). ◮ Consider a map function mapσ,τ : (σ → τ) × list(σ) − → list(τ)

  • f , [a0; . . . ; an]

→ [f(a0) ; . . . ; f(an)] (σ, τ types) ◮ The behavior of mapσ,τ is independent from the types σ, τ. ◮ One may want to have just one implementation, independent from σ and τ. Example (Identity). ◮ Consider the typed terms idτ := λx : τ.x : τ → τ and idσ := λx : σ.x : σ → σ

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 3 / 12

slide-7
SLIDE 7

System F

Introduction

Example (Map). ◮ Consider a map function mapσ,τ : (σ → τ) × list(σ) − → list(τ)

  • f , [a0; . . . ; an]

→ [f(a0) ; . . . ; f(an)] (σ, τ types) ◮ The behavior of mapσ,τ is independent from the types σ, τ. ◮ One may want to have just one implementation, independent from σ and τ. Example (Identity). ◮ Consider the typed terms idτ := λx : τ.x : τ → τ and idσ := λx : σ.x : σ → σ ◮ These two term behave the same way. ◮ This behaviour is independent from σ, τ.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 3 / 12

slide-8
SLIDE 8

System F

Introduction

Example (Map). ◮ Consider a map function mapσ,τ : (σ → τ) × list(σ) − → list(τ)

  • f , [a0; . . . ; an]

→ [f(a0) ; . . . ; f(an)] (σ, τ types) ◮ The behavior of mapσ,τ is independent from the types σ, τ. ◮ One may want to have just one implementation, independent from σ and τ. Example (Identity). ◮ Consider the typed terms idτ := λx : τ.x : τ → τ and idσ := λx : σ.x : σ → σ ◮ These two term behave the same way. ◮ This behaviour is independent from σ, τ. Main Idea: Polymorphism allows to express such uniformities using explicit universal quantification over types.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 3 / 12

slide-9
SLIDE 9

System F

System F (Girard ’71, Reynolds ’74)

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 4 / 12

slide-10
SLIDE 10

System F

System F (Girard ’71, Reynolds ’74)

Polymorphic Types. ◮ Assume given countably many type variables α, β, . . .

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 4 / 12

slide-11
SLIDE 11

System F

System F (Girard ’71, Reynolds ’74)

Polymorphic Types. ◮ Assume given countably many type variables α, β, . . . ◮ Polymorphic types are given by τ, σ ::= α | σ → τ | ∀α.σ

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 4 / 12

slide-12
SLIDE 12

System F

System F (Girard ’71, Reynolds ’74)

Polymorphic Types. ◮ Assume given countably many type variables α, β, . . . ◮ Polymorphic types are given by τ, σ ::= α | σ → τ | ∀α.σ Terms. t, u ::= x | t u | λx : σ.t

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 4 / 12

slide-13
SLIDE 13

System F

System F (Girard ’71, Reynolds ’74)

Polymorphic Types. ◮ Assume given countably many type variables α, β, . . . ◮ Polymorphic types are given by τ, σ ::= α | σ → τ | ∀α.σ Terms. t, u ::= x | t u | λx : σ.t | Λα.t | t σ

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 4 / 12

slide-14
SLIDE 14

System F

System F (Girard ’71, Reynolds ’74)

Polymorphic Types. ◮ Assume given countably many type variables α, β, . . . ◮ Polymorphic types are given by τ, σ ::= α | σ → τ | ∀α.σ Terms. t, u ::= x | t u | λx : σ.t | Λα.t | t σ Typing Rules. ◮ Extension of the simply-typed systems with Γ ⊢ t : τ Γ ⊢ Λα.t : ∀α.τ (α not free in Γ) Γ ⊢ t : ∀α.τ Γ ⊢ t σ : τ[σ/α]

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 4 / 12

slide-15
SLIDE 15

System F

System F (Girard ’71, Reynolds ’74)

Polymorphic Types. ◮ Assume given countably many type variables α, β, . . . ◮ Polymorphic types are given by τ, σ ::= α | σ → τ | ∀α.σ Terms. t, u ::= x | t u | λx : σ.t | Λα.t | t σ Typing Rules. ◮ Extension of the simply-typed systems with Γ ⊢ t : τ Γ ⊢ Λα.t : ∀α.τ (α not free in Γ) Γ ⊢ t : ∀α.τ Γ ⊢ t σ : τ[σ/α] Reduction. ◮ We consider the full strong reduction ⊲ defined as (λx : τ.t)u ⊲ t[u/x] t ⊲ u t v ⊲ u v t ⊲ u v t ⊲ v u t ⊲ u λx : σ.t ⊲ λx : σ.u (Λα.t)σ ⊲ t[σ/α] t ⊲ u tσ ⊲ uσ t ⊲ u Λα.t ⊲ Λα.u ◮ Let =β be the symmetric-reflexive-transitive closure of ⊲.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 4 / 12

slide-16
SLIDE 16

System F

Expressive Power

◮ The expressive power of System F is huge. We content ourselves with examples.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 5 / 12

slide-17
SLIDE 17

System F

Expressive Power

◮ The expressive power of System F is huge. We content ourselves with examples. Identity. ◮ Let id := Λα.λx : α.x : ∀α(α → α)

  • Id

For each τ we have id τ ⊲ idτ = λx : τ.x : τ → τ In particular id Id : Id → Id

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 5 / 12

slide-18
SLIDE 18

System F

Expressive Power

◮ The expressive power of System F is huge. We content ourselves with examples. Identity. ◮ Let id := Λα.λx : α.x : ∀α(α → α)

  • Id

For each τ we have id τ ⊲ idτ = λx : τ.x : τ → τ In particular id Id : Id → Id Void Type. ◮ Let ⊥ := ∀α.α.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 5 / 12

slide-19
SLIDE 19

System F

Expressive Power

◮ The expressive power of System F is huge. We content ourselves with examples. Identity. ◮ Let id := Λα.λx : α.x : ∀α(α → α)

  • Id

For each τ we have id τ ⊲ idτ = λx : τ.x : τ → τ In particular id Id : Id → Id Void Type. ◮ Let ⊥ := ∀α.α. We have Γ ⊢ t : ⊥ Γ ⊢ t τ : τ ◮ Question. Is there a closed term of type ⊥ ?

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 5 / 12

slide-20
SLIDE 20

System F

Product Types

Let τ × σ := ∀α.

  • (τ → σ → α)

− → α

  • CLAIRAMBAULT & RIBA (LIP - ENS de Lyon)

ASPL (CR04) Course 13 12/11 6 / 12

slide-21
SLIDE 21

System F

Product Types

Let τ × σ := ∀α.

  • (τ → σ → α)

− → α

  • pair t u

:= so that Γ ⊢ t : τ Γ ⊢ u : σ Γ ⊢ pair t u : τ × σ

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 6 / 12

slide-22
SLIDE 22

System F

Product Types

Let τ × σ := ∀α.

  • (τ → σ → α)

− → α

  • pair t u

:= Λα. λp : τ → σ → α. p t u so that Γ ⊢ t : τ Γ ⊢ u : σ Γ ⊢ pair t u : τ × σ

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 6 / 12

slide-23
SLIDE 23

System F

Product Types

Let τ × σ := ∀α.

  • (τ → σ → α)

− → α

  • pair t u

:= Λα. λp : τ → σ → α. p t u π1 t := so that Γ ⊢ t : τ Γ ⊢ u : σ Γ ⊢ pair t u : τ × σ Γ ⊢ t : τ × σ Γ ⊢ π1t : τ

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 6 / 12

slide-24
SLIDE 24

System F

Product Types

Let τ × σ := ∀α.

  • (τ → σ → α)

− → α

  • pair t u

:= Λα. λp : τ → σ → α. p t u π1 t := t τ (λx : τ. λy : σ. x) so that Γ ⊢ t : τ Γ ⊢ u : σ Γ ⊢ pair t u : τ × σ Γ ⊢ t : τ × σ Γ ⊢ π1t : τ

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 6 / 12

slide-25
SLIDE 25

System F

Product Types

Let τ × σ := ∀α.

  • (τ → σ → α)

− → α

  • pair t u

:= Λα. λp : τ → σ → α. p t u π1 t := t τ (λx : τ. λy : σ. x) π2 t := so that Γ ⊢ t : τ Γ ⊢ u : σ Γ ⊢ pair t u : τ × σ Γ ⊢ t : τ × σ Γ ⊢ π1t : τ Γ ⊢ t : τ × σ Γ ⊢ π2t : σ

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 6 / 12

slide-26
SLIDE 26

System F

Product Types

Let τ × σ := ∀α.

  • (τ → σ → α)

− → α

  • pair t u

:= Λα. λp : τ → σ → α. p t u π1 t := t τ (λx : τ. λy : σ. x) π2 t := t σ (λx : τ. λy : σ. y) so that Γ ⊢ t : τ Γ ⊢ u : σ Γ ⊢ pair t u : τ × σ Γ ⊢ t : τ × σ Γ ⊢ π1t : τ Γ ⊢ t : τ × σ Γ ⊢ π2t : σ

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 6 / 12

slide-27
SLIDE 27

System F

Product Types

Let τ × σ := ∀α.

  • (τ → σ → α)

− → α

  • pair t u

:= Λα. λp : τ → σ → α. p t u π1 t := t τ (λx : τ. λy : σ. x) π2 t := t σ (λx : τ. λy : σ. y) so that Γ ⊢ t : τ Γ ⊢ u : σ Γ ⊢ pair t u : τ × σ Γ ⊢ t : τ × σ Γ ⊢ π1t : τ Γ ⊢ t : τ × σ Γ ⊢ π2t : σ Moreover π1(pair t u)

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 6 / 12

slide-28
SLIDE 28

System F

Product Types

Let τ × σ := ∀α.

  • (τ → σ → α)

− → α

  • pair t u

:= Λα. λp : τ → σ → α. p t u π1 t := t τ (λx : τ. λy : σ. x) π2 t := t σ (λx : τ. λy : σ. y) so that Γ ⊢ t : τ Γ ⊢ u : σ Γ ⊢ pair t u : τ × σ Γ ⊢ t : τ × σ Γ ⊢ π1t : τ Γ ⊢ t : τ × σ Γ ⊢ π2t : σ Moreover π1(pair t u) ⊲∗

  • Λα. λp. p t u
  • τ(λxy.x)

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 6 / 12

slide-29
SLIDE 29

System F

Product Types

Let τ × σ := ∀α.

  • (τ → σ → α)

− → α

  • pair t u

:= Λα. λp : τ → σ → α. p t u π1 t := t τ (λx : τ. λy : σ. x) π2 t := t σ (λx : τ. λy : σ. y) so that Γ ⊢ t : τ Γ ⊢ u : σ Γ ⊢ pair t u : τ × σ Γ ⊢ t : τ × σ Γ ⊢ π1t : τ Γ ⊢ t : τ × σ Γ ⊢ π2t : σ Moreover π1(pair t u) ⊲∗

  • Λα. λp. p t u
  • τ(λxy.x) ⊲∗

(λxy.x)t u

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 6 / 12

slide-30
SLIDE 30

System F

Product Types

Let τ × σ := ∀α.

  • (τ → σ → α)

− → α

  • pair t u

:= Λα. λp : τ → σ → α. p t u π1 t := t τ (λx : τ. λy : σ. x) π2 t := t σ (λx : τ. λy : σ. y) so that Γ ⊢ t : τ Γ ⊢ u : σ Γ ⊢ pair t u : τ × σ Γ ⊢ t : τ × σ Γ ⊢ π1t : τ Γ ⊢ t : τ × σ Γ ⊢ π2t : σ Moreover π1(pair t u) ⊲∗

  • Λα. λp. p t u
  • τ(λxy.x) ⊲∗

(λxy.x)t u ⊲∗ t

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 6 / 12

slide-31
SLIDE 31

System F

Product Types

Let τ × σ := ∀α.

  • (τ → σ → α)

− → α

  • pair t u

:= Λα. λp : τ → σ → α. p t u π1 t := t τ (λx : τ. λy : σ. x) π2 t := t σ (λx : τ. λy : σ. y) so that Γ ⊢ t : τ Γ ⊢ u : σ Γ ⊢ pair t u : τ × σ Γ ⊢ t : τ × σ Γ ⊢ π1t : τ Γ ⊢ t : τ × σ Γ ⊢ π2t : σ Moreover π1(pair t u) ⊲∗

  • Λα. λp. p t u
  • τ(λxy.x) ⊲∗

(λxy.x)t u ⊲∗ t and similarly π2(pair t u) ⊲∗ u

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 6 / 12

slide-32
SLIDE 32

System F

Product Types

Let τ × σ := ∀α.

  • (τ → σ → α)

− → α

  • pair t u

:= Λα. λp : τ → σ → α. p t u π1 t := t τ (λx : τ. λy : σ. x) π2 t := t σ (λx : τ. λy : σ. y) so that Γ ⊢ t : τ Γ ⊢ u : σ Γ ⊢ pair t u : τ × σ Γ ⊢ t : τ × σ Γ ⊢ π1t : τ Γ ⊢ t : τ × σ Γ ⊢ π2t : σ Moreover π1(pair t u) ⊲∗

  • Λα. λp. p t u
  • τ(λxy.x) ⊲∗

(λxy.x)t u ⊲∗ t and similarly π2(pair t u) ⊲∗ u Remark. ◮ We can also have polymorphic pair and πi.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 6 / 12

slide-33
SLIDE 33

System F

Sum Types

Let τ + σ := ∀α.

  • (τ → α)

− → (σ → α) − → α

  • CLAIRAMBAULT & RIBA (LIP - ENS de Lyon)

ASPL (CR04) Course 13 12/11 7 / 12

slide-34
SLIDE 34

System F

Sum Types

Let τ + σ := ∀α.

  • (τ → α)

− → (σ → α) − → α

  • inl t

:= so that Γ ⊢ t : τ Γ ⊢ inl t : τ + σ

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 7 / 12

slide-35
SLIDE 35

System F

Sum Types

Let τ + σ := ∀α.

  • (τ → α)

− → (σ → α) − → α

  • inl t

:= Λα. λℓ : τ → α. λr : σ → α. ℓ t so that Γ ⊢ t : τ Γ ⊢ inl t : τ + σ

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 7 / 12

slide-36
SLIDE 36

System F

Sum Types

Let τ + σ := ∀α.

  • (τ → α)

− → (σ → α) − → α

  • inl t

:= Λα. λℓ : τ → α. λr : σ → α. ℓ t inr u := so that Γ ⊢ t : τ Γ ⊢ inl t : τ + σ Γ ⊢ u : σ Γ ⊢ inr u : τ + σ

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 7 / 12

slide-37
SLIDE 37

System F

Sum Types

Let τ + σ := ∀α.

  • (τ → α)

− → (σ → α) − → α

  • inl t

:= Λα. λℓ : τ → α. λr : σ → α. ℓ t inr u := Λα. λℓ : τ → α. λr : σ → α. r u so that Γ ⊢ t : τ Γ ⊢ inl t : τ + σ Γ ⊢ u : σ Γ ⊢ inr u : τ + σ

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 7 / 12

slide-38
SLIDE 38

System F

Sum Types

Let τ + σ := ∀α.

  • (τ → α)

− → (σ → α) − → α

  • inl t

:= Λα. λℓ : τ → α. λr : σ → α. ℓ t inr u := Λα. λℓ : τ → α. λr : σ → α. r u case t u v := so that Γ ⊢ t : τ Γ ⊢ inl t : τ + σ Γ ⊢ u : σ Γ ⊢ inr u : τ + σ Γ ⊢ t : τ + σ Γ ⊢ u : τ → κ Γ ⊢ v : σ → κ Γ ⊢ case t u v : κ

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 7 / 12

slide-39
SLIDE 39

System F

Sum Types

Let τ + σ := ∀α.

  • (τ → α)

− → (σ → α) − → α

  • inl t

:= Λα. λℓ : τ → α. λr : σ → α. ℓ t inr u := Λα. λℓ : τ → α. λr : σ → α. r u case t u v := t κ u v so that Γ ⊢ t : τ Γ ⊢ inl t : τ + σ Γ ⊢ u : σ Γ ⊢ inr u : τ + σ Γ ⊢ t : τ + σ Γ ⊢ u : τ → κ Γ ⊢ v : σ → κ Γ ⊢ case t u v : κ

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 7 / 12

slide-40
SLIDE 40

System F

Sum Types

Let τ + σ := ∀α.

  • (τ → α)

− → (σ → α) − → α

  • inl t

:= Λα. λℓ : τ → α. λr : σ → α. ℓ t inr u := Λα. λℓ : τ → α. λr : σ → α. r u case t u v := t κ u v so that Γ ⊢ t : τ Γ ⊢ inl t : τ + σ Γ ⊢ u : σ Γ ⊢ inr u : τ + σ Γ ⊢ t : τ + σ Γ ⊢ u : τ → κ Γ ⊢ v : σ → κ Γ ⊢ case t u v : κ Note that case (inl t) u v ⊲∗ u t and case (inr t) u v ⊲∗ v t

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 7 / 12

slide-41
SLIDE 41

System F

Sum Types

Let τ + σ := ∀α.

  • (τ → α)

− → (σ → α) − → α

  • inl t

:= Λα. λℓ : τ → α. λr : σ → α. ℓ t inr u := Λα. λℓ : τ → α. λr : σ → α. r u case t u v := t κ u v so that Γ ⊢ t : τ Γ ⊢ inl t : τ + σ Γ ⊢ u : σ Γ ⊢ inr u : τ + σ Γ ⊢ t : τ + σ Γ ⊢ u : τ → κ Γ ⊢ v : σ → κ Γ ⊢ case t u v : κ Note that case (inl t) u v ⊲∗ u t and case (inr t) u v ⊲∗ v t Remark. ◮ We can also have polymorphic inl, inr, case.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 7 / 12

slide-42
SLIDE 42

System F

Natural Numbers

Let nat := ∀α.

  • α

− → (α → α) − → α

  • CLAIRAMBAULT & RIBA (LIP - ENS de Lyon)

ASPL (CR04) Course 13 12/11 8 / 12

slide-43
SLIDE 43

System F

Natural Numbers

Let

(for n ∈ N)

nat := ∀α.

  • α

− → (α → α) − → α

  • n

:= so that Γ ⊢ n : nat (n ∈ N)

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 8 / 12

slide-44
SLIDE 44

System F

Natural Numbers

Let

(for n ∈ N)

nat := ∀α.

  • α

− → (α → α) − → α

  • n

:= Λα. λz : α. λs : α → α. snz so that Γ ⊢ n : nat (n ∈ N)

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 8 / 12

slide-45
SLIDE 45

System F

Natural Numbers

Let

(for n ∈ N)

nat := ∀α.

  • α

− → (α → α) − → α

  • n

:= Λα. λz : α. λs : α → α. snz S t := so that Γ ⊢ n : nat (n ∈ N) Γ ⊢ t : nat Γ ⊢ S t : nat

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 8 / 12

slide-46
SLIDE 46

System F

Natural Numbers

Let

(for n ∈ N)

nat := ∀α.

  • α

− → (α → α) − → α

  • n

:= Λα. λz : α. λs : α → α. snz S t := Λα. λz : α. λs : α → α. s (t α z s) so that Γ ⊢ n : nat (n ∈ N) Γ ⊢ t : nat Γ ⊢ S t : nat

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 8 / 12

slide-47
SLIDE 47

System F

Natural Numbers

Let

(for n ∈ N)

nat := ∀α.

  • α

− → (α → α) − → α

  • n

:= Λα. λz : α. λs : α → α. snz S t := Λα. λz : α. λs : α → α. s (t α z s) iter t u v := so that Γ ⊢ n : nat (n ∈ N) Γ ⊢ t : nat Γ ⊢ S t : nat Γ ⊢ t : nat Γ ⊢ u : σ Γ ⊢ v : σ → σ Γ ⊢ iter t u v : σ

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 8 / 12

slide-48
SLIDE 48

System F

Natural Numbers

Let

(for n ∈ N)

nat := ∀α.

  • α

− → (α → α) − → α

  • n

:= Λα. λz : α. λs : α → α. snz S t := Λα. λz : α. λs : α → α. s (t α z s) iter t u v := t σ u v so that Γ ⊢ n : nat (n ∈ N) Γ ⊢ t : nat Γ ⊢ S t : nat Γ ⊢ t : nat Γ ⊢ u : σ Γ ⊢ v : σ → σ Γ ⊢ iter t u v : σ

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 8 / 12

slide-49
SLIDE 49

System F

Natural Numbers

Let

(for n ∈ N)

nat := ∀α.

  • α

− → (α → α) − → α

  • n

:= Λα. λz : α. λs : α → α. snz S t := Λα. λz : α. λs : α → α. s (t α z s) iter t u v := t σ u v so that Γ ⊢ n : nat (n ∈ N) Γ ⊢ t : nat Γ ⊢ S t : nat Γ ⊢ t : nat Γ ⊢ u : σ Γ ⊢ v : σ → σ Γ ⊢ iter t u v : σ Moreover S n ⊲∗ n + 1

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 8 / 12

slide-50
SLIDE 50

System F

Natural Numbers

Let

(for n ∈ N)

nat := ∀α.

  • α

− → (α → α) − → α

  • n

:= Λα. λz : α. λs : α → α. snz S t := Λα. λz : α. λs : α → α. s (t α z s) iter t u v := t σ u v so that Γ ⊢ n : nat (n ∈ N) Γ ⊢ t : nat Γ ⊢ S t : nat Γ ⊢ t : nat Γ ⊢ u : σ Γ ⊢ v : σ → σ Γ ⊢ iter t u v : σ Moreover S n ⊲∗ n + 1 iter 0 u v ⊲∗ u

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 8 / 12

slide-51
SLIDE 51

System F

Natural Numbers

Let

(for n ∈ N)

nat := ∀α.

  • α

− → (α → α) − → α

  • n

:= Λα. λz : α. λs : α → α. snz S t := Λα. λz : α. λs : α → α. s (t α z s) iter t u v := t σ u v so that Γ ⊢ n : nat (n ∈ N) Γ ⊢ t : nat Γ ⊢ S t : nat Γ ⊢ t : nat Γ ⊢ u : σ Γ ⊢ v : σ → σ Γ ⊢ iter t u v : σ Moreover S n ⊲∗ n + 1 iter 0 u v ⊲∗ u iter (S t) u v =β v (iter t u v)

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 8 / 12

slide-52
SLIDE 52

System F

Natural Numbers

Let

(for n ∈ N)

nat := ∀α.

  • α

− → (α → α) − → α

  • n

:= Λα. λz : α. λs : α → α. snz S t := Λα. λz : α. λs : α → α. s (t α z s) iter t u v := t σ u v so that Γ ⊢ n : nat (n ∈ N) Γ ⊢ t : nat Γ ⊢ S t : nat Γ ⊢ t : nat Γ ⊢ u : σ Γ ⊢ v : σ → σ Γ ⊢ iter t u v : σ Moreover S n ⊲∗ n + 1 iter 0 u v ⊲∗ u iter (S t) u v =β v (iter t u v) Remark. ◮ The iterator iter can be polymorphic. ◮ The computational power of System F is huge: the definable functions nat → nat are exactly those provably total in second-order arithmetic !

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 8 / 12

slide-53
SLIDE 53

System F

Lists

Let list(τ) := ∀α.

  • α

− → (τ → α → α) − → α

  • CLAIRAMBAULT & RIBA (LIP - ENS de Lyon)

ASPL (CR04) Course 13 12/11 9 / 12

slide-54
SLIDE 54

System F

Lists

Let list(τ) := ∀α.

  • α

− → (τ → α → α) − → α

  • [t0; . . . ; tn]

:= so that Γ ⊢ t0 : τ . . . Γ ⊢ tn : τ Γ ⊢ [t0; . . . ; tn] : list(τ)

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 9 / 12

slide-55
SLIDE 55

System F

Lists

Let list(τ) := ∀α.

  • α

− → (τ → α → α) − → α

  • [t0; . . . ; tn]

:= Λα. λe : α. λc : τ → α → α. c tn

  • . . . (c t0 e)
  • so that

Γ ⊢ t0 : τ . . . Γ ⊢ tn : τ Γ ⊢ [t0; . . . ; tn] : list(τ)

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 9 / 12

slide-56
SLIDE 56

System F

Lists

Let list(τ) := ∀α.

  • α

− → (τ → α → α) − → α

  • [t0; . . . ; tn]

:= Λα. λe : α. λc : τ → α → α. c tn

  • . . . (c t0 e)
  • nil

:= so that Γ ⊢ t0 : τ . . . Γ ⊢ tn : τ Γ ⊢ [t0; . . . ; tn] : list(τ) Γ ⊢ nil : list(τ)

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 9 / 12

slide-57
SLIDE 57

System F

Lists

Let list(τ) := ∀α.

  • α

− → (τ → α → α) − → α

  • [t0; . . . ; tn]

:= Λα. λe : α. λc : τ → α → α. c tn

  • . . . (c t0 e)
  • nil

:= Λα. λe : α. λc : τ → α → α. e so that Γ ⊢ t0 : τ . . . Γ ⊢ tn : τ Γ ⊢ [t0; . . . ; tn] : list(τ) Γ ⊢ nil : list(τ)

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 9 / 12

slide-58
SLIDE 58

System F

Lists

Let list(τ) := ∀α.

  • α

− → (τ → α → α) − → α

  • [t0; . . . ; tn]

:= Λα. λe : α. λc : τ → α → α. c tn

  • . . . (c t0 e)
  • nil

:= Λα. λe : α. λc : τ → α → α. e cons t ℓ := so that Γ ⊢ t0 : τ . . . Γ ⊢ tn : τ Γ ⊢ [t0; . . . ; tn] : list(τ) Γ ⊢ nil : list(τ) Γ ⊢ t : τ Γ ⊢ ℓ : list(τ) Γ ⊢ cons t ℓ : list(τ)

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 9 / 12

slide-59
SLIDE 59

System F

Lists

Let list(τ) := ∀α.

  • α

− → (τ → α → α) − → α

  • [t0; . . . ; tn]

:= Λα. λe : α. λc : τ → α → α. c tn

  • . . . (c t0 e)
  • nil

:= Λα. λe : α. λc : τ → α → α. e cons t ℓ := Λα. λe : α. λc : τ → α → α. c t (ℓ α e c) so that Γ ⊢ t0 : τ . . . Γ ⊢ tn : τ Γ ⊢ [t0; . . . ; tn] : list(τ) Γ ⊢ nil : list(τ) Γ ⊢ t : τ Γ ⊢ ℓ : list(τ) Γ ⊢ cons t ℓ : list(τ)

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 9 / 12

slide-60
SLIDE 60

System F

Lists

Let list(τ) := ∀α.

  • α

− → (τ → α → α) − → α

  • [t0; . . . ; tn]

:= Λα. λe : α. λc : τ → α → α. c tn

  • . . . (c t0 e)
  • nil

:= Λα. λe : α. λc : τ → α → α. e cons t ℓ := Λα. λe : α. λc : τ → α → α. c t (ℓ α e c) iter ℓ u v := so that Γ ⊢ t0 : τ . . . Γ ⊢ tn : τ Γ ⊢ [t0; . . . ; tn] : list(τ) Γ ⊢ nil : list(τ) Γ ⊢ t : τ Γ ⊢ ℓ : list(τ) Γ ⊢ cons t ℓ : list(τ) Γ ⊢ ℓ : list(τ) Γ ⊢ u : σ Γ ⊢ v : τ → σ → σ Γ ⊢ iter ℓ u v : σ

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 9 / 12

slide-61
SLIDE 61

System F

Lists

Let list(τ) := ∀α.

  • α

− → (τ → α → α) − → α

  • [t0; . . . ; tn]

:= Λα. λe : α. λc : τ → α → α. c tn

  • . . . (c t0 e)
  • nil

:= Λα. λe : α. λc : τ → α → α. e cons t ℓ := Λα. λe : α. λc : τ → α → α. c t (ℓ α e c) iter ℓ u v := ℓ σ u v so that Γ ⊢ t0 : τ . . . Γ ⊢ tn : τ Γ ⊢ [t0; . . . ; tn] : list(τ) Γ ⊢ nil : list(τ) Γ ⊢ t : τ Γ ⊢ ℓ : list(τ) Γ ⊢ cons t ℓ : list(τ) Γ ⊢ ℓ : list(τ) Γ ⊢ u : σ Γ ⊢ v : τ → σ → σ Γ ⊢ iter ℓ u v : σ

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 9 / 12

slide-62
SLIDE 62

System F

Lists

Let list(τ) := ∀α.

  • α

− → (τ → α → α) − → α

  • [t0; . . . ; tn]

:= Λα. λe : α. λc : τ → α → α. c tn

  • . . . (c t0 e)
  • nil

:= Λα. λe : α. λc : τ → α → α. e cons t ℓ := Λα. λe : α. λc : τ → α → α. c t (ℓ α e c) iter ℓ u v := ℓ σ u v so that Γ ⊢ t0 : τ . . . Γ ⊢ tn : τ Γ ⊢ [t0; . . . ; tn] : list(τ) Γ ⊢ nil : list(τ) Γ ⊢ t : τ Γ ⊢ ℓ : list(τ) Γ ⊢ cons t ℓ : list(τ) Γ ⊢ ℓ : list(τ) Γ ⊢ u : σ Γ ⊢ v : τ → σ → σ Γ ⊢ iter ℓ u v : σ Moreover cons t nil ⊲∗ [t]

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 9 / 12

slide-63
SLIDE 63

System F

Lists

Let list(τ) := ∀α.

  • α

− → (τ → α → α) − → α

  • [t0; . . . ; tn]

:= Λα. λe : α. λc : τ → α → α. c tn

  • . . . (c t0 e)
  • nil

:= Λα. λe : α. λc : τ → α → α. e cons t ℓ := Λα. λe : α. λc : τ → α → α. c t (ℓ α e c) iter ℓ u v := ℓ σ u v so that Γ ⊢ t0 : τ . . . Γ ⊢ tn : τ Γ ⊢ [t0; . . . ; tn] : list(τ) Γ ⊢ nil : list(τ) Γ ⊢ t : τ Γ ⊢ ℓ : list(τ) Γ ⊢ cons t ℓ : list(τ) Γ ⊢ ℓ : list(τ) Γ ⊢ u : σ Γ ⊢ v : τ → σ → σ Γ ⊢ iter ℓ u v : σ Moreover cons t nil ⊲∗ [t] cons t [t0; . . . ; tn] ⊲∗ [t0; . . . ; tn; t]

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 9 / 12

slide-64
SLIDE 64

System F

Lists

Let list(τ) := ∀α.

  • α

− → (τ → α → α) − → α

  • [t0; . . . ; tn]

:= Λα. λe : α. λc : τ → α → α. c tn

  • . . . (c t0 e)
  • nil

:= Λα. λe : α. λc : τ → α → α. e cons t ℓ := Λα. λe : α. λc : τ → α → α. c t (ℓ α e c) iter ℓ u v := ℓ σ u v so that Γ ⊢ t0 : τ . . . Γ ⊢ tn : τ Γ ⊢ [t0; . . . ; tn] : list(τ) Γ ⊢ nil : list(τ) Γ ⊢ t : τ Γ ⊢ ℓ : list(τ) Γ ⊢ cons t ℓ : list(τ) Γ ⊢ ℓ : list(τ) Γ ⊢ u : σ Γ ⊢ v : τ → σ → σ Γ ⊢ iter ℓ u v : σ Moreover cons t nil ⊲∗ [t] cons t [t0; . . . ; tn] ⊲∗ [t0; . . . ; tn; t] iter nil u v ⊲∗ u

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 9 / 12

slide-65
SLIDE 65

System F

Lists

Let list(τ) := ∀α.

  • α

− → (τ → α → α) − → α

  • [t0; . . . ; tn]

:= Λα. λe : α. λc : τ → α → α. c tn

  • . . . (c t0 e)
  • nil

:= Λα. λe : α. λc : τ → α → α. e cons t ℓ := Λα. λe : α. λc : τ → α → α. c t (ℓ α e c) iter ℓ u v := ℓ σ u v so that Γ ⊢ t0 : τ . . . Γ ⊢ tn : τ Γ ⊢ [t0; . . . ; tn] : list(τ) Γ ⊢ nil : list(τ) Γ ⊢ t : τ Γ ⊢ ℓ : list(τ) Γ ⊢ cons t ℓ : list(τ) Γ ⊢ ℓ : list(τ) Γ ⊢ u : σ Γ ⊢ v : τ → σ → σ Γ ⊢ iter ℓ u v : σ Moreover cons t nil ⊲∗ [t] cons t [t0; . . . ; tn] ⊲∗ [t0; . . . ; tn; t] iter nil u v ⊲∗ u iter (cons t ℓ) u v =β v t (iter ℓ u v)

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 9 / 12

slide-66
SLIDE 66

System F

Lists

Let list(τ) := ∀α.

  • α

− → (τ → α → α) − → α

  • [t0; . . . ; tn]

:= Λα. λe : α. λc : τ → α → α. c tn

  • . . . (c t0 e)
  • nil

:= Λα. λe : α. λc : τ → α → α. e cons t ℓ := Λα. λe : α. λc : τ → α → α. c t (ℓ α e c) iter ℓ u v := ℓ σ u v so that Γ ⊢ t0 : τ . . . Γ ⊢ tn : τ Γ ⊢ [t0; . . . ; tn] : list(τ) Γ ⊢ nil : list(τ) Γ ⊢ t : τ Γ ⊢ ℓ : list(τ) Γ ⊢ cons t ℓ : list(τ) Γ ⊢ ℓ : list(τ) Γ ⊢ u : σ Γ ⊢ v : τ → σ → σ Γ ⊢ iter ℓ u v : σ Moreover cons t nil ⊲∗ [t] cons t [t0; . . . ; tn] ⊲∗ [t0; . . . ; tn; t] iter nil u v ⊲∗ u iter (cons t ℓ) u v =β v t (iter ℓ u v) Remark. ◮ For polymorphic lists, just take list := ∀α. list(α). It is then easy to define a polymorphic map function.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 9 / 12

slide-67
SLIDE 67

System F

Lists

Let list(τ) := ∀α.

  • α

− → (τ → α → α) − → α

  • [t0; . . . ; tn]

:= Λα. λe : α. λc : τ → α → α. c tn

  • . . . (c t0 e)
  • nil

:= Λα. λe : α. λc : τ → α → α. e cons t ℓ := Λα. λe : α. λc : τ → α → α. c t (ℓ α e c) iter ℓ u v := ℓ σ u v so that Γ ⊢ t0 : τ . . . Γ ⊢ tn : τ Γ ⊢ [t0; . . . ; tn] : list(τ) Γ ⊢ nil : list(τ) Γ ⊢ t : τ Γ ⊢ ℓ : list(τ) Γ ⊢ cons t ℓ : list(τ) Γ ⊢ ℓ : list(τ) Γ ⊢ u : σ Γ ⊢ v : τ → σ → σ Γ ⊢ iter ℓ u v : σ Moreover cons t nil ⊲∗ [t] cons t [t0; . . . ; tn] ⊲∗ [t0; . . . ; tn; t] iter nil u v ⊲∗ u iter (cons t ℓ) u v =β v t (iter ℓ u v) Remark. ◮ For polymorphic lists, just take list := ∀α. list(α). It is then easy to define a polymorphic map function. ◮ Any first-order structure over a finite signature is representable (with its iterator).

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 9 / 12

slide-68
SLIDE 68

System F

Main Properties

Subject Reduction. ◮ If t ⊲ u and Γ ⊢ t : σ then Γ ⊢ u : σ.

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

slide-69
SLIDE 69

System F

Main Properties

Subject Reduction. ◮ If t ⊲ u and Γ ⊢ t : σ then Γ ⊢ u : σ. Church Rosser. ◮ If t ⊲∗ u and t ⊲∗ v, then there is a term w such that u ⊲∗ w and v ⊲∗ w.

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

slide-70
SLIDE 70

System F

Main Properties

Subject Reduction. ◮ If t ⊲ u and Γ ⊢ t : σ then Γ ⊢ u : σ. Church Rosser. ◮ If t ⊲∗ u and t ⊲∗ v, then there is a term w such that u ⊲∗ w and v ⊲∗ w. Strong Normalization.

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

slide-71
SLIDE 71

System F

Main Properties

Subject Reduction. ◮ If t ⊲ u and Γ ⊢ t : σ then Γ ⊢ u : σ. Church Rosser. ◮ If t ⊲∗ u and t ⊲∗ v, then there is a term w such that u ⊲∗ w and v ⊲∗ w. Strong Normalization. ◮ Let SN be the smallest set of terms t such that ∀u

  • t ⊲ u ⇒ u ∈ SN
  • =

⇒ t ∈ SN

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

slide-72
SLIDE 72

System F

Main Properties

Subject Reduction. ◮ If t ⊲ u and Γ ⊢ t : σ then Γ ⊢ u : σ. Church Rosser. ◮ If t ⊲∗ u and t ⊲∗ v, then there is a term w such that u ⊲∗ w and v ⊲∗ w. Strong Normalization. ◮ Let SN be the smallest set of terms t such that ∀u

  • t ⊲ u ⇒ u ∈ SN
  • =

⇒ t ∈ SN ◮ Note that t ∈ SN iff there is no infinite reduction sequence t = t0 ⊲ t1 ⊲ · · · ⊲ tn ⊲ . . . .

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

slide-73
SLIDE 73

System F

Main Properties

Subject Reduction. ◮ If t ⊲ u and Γ ⊢ t : σ then Γ ⊢ u : σ. Church Rosser. ◮ If t ⊲∗ u and t ⊲∗ v, then there is a term w such that u ⊲∗ w and v ⊲∗ w. Strong Normalization. ◮ Let SN be the smallest set of terms t such that ∀u

  • t ⊲ u ⇒ u ∈ SN
  • =

⇒ t ∈ SN ◮ Note that t ∈ SN iff there is no infinite reduction sequence t = t0 ⊲ t1 ⊲ · · · ⊲ tn ⊲ . . . .

Theorem (Girard ’71)

If t is typable then t ∈ SN.

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

slide-74
SLIDE 74

System F

Main Properties

Subject Reduction. ◮ If t ⊲ u and Γ ⊢ t : σ then Γ ⊢ u : σ. Church Rosser. ◮ If t ⊲∗ u and t ⊲∗ v, then there is a term w such that u ⊲∗ w and v ⊲∗ w. Strong Normalization. ◮ Let SN be the smallest set of terms t such that ∀u

  • t ⊲ u ⇒ u ∈ SN
  • =

⇒ t ∈ SN ◮ Note that t ∈ SN iff there is no infinite reduction sequence t = t0 ⊲ t1 ⊲ · · · ⊲ tn ⊲ . . . .

Theorem (Girard ’71)

If t is typable then t ∈ SN. Remark. ◮ There is no (natural) set-theoretic model of System F.

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

slide-75
SLIDE 75

System F

Curry Style System F

Motivation.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 11 / 12

slide-76
SLIDE 76

System F

Curry Style System F

Motivation. ◮ Variant of System F with lighter syntax.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 11 / 12

slide-77
SLIDE 77

System F

Curry Style System F

Motivation. ◮ Variant of System F with lighter syntax. ◮ More suited to normalization proofs.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 11 / 12

slide-78
SLIDE 78

System F

Curry Style System F

Motivation. ◮ Variant of System F with lighter syntax. ◮ More suited to normalization proofs. ◮ The previous (original) version is called Church style.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 11 / 12

slide-79
SLIDE 79

System F

Curry Style System F

Motivation. ◮ Variant of System F with lighter syntax. ◮ More suited to normalization proofs. ◮ The previous (original) version is called Church style. Terms. t, u ::= x | t u | λx.t

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 11 / 12

slide-80
SLIDE 80

System F

Curry Style System F

Motivation. ◮ Variant of System F with lighter syntax. ◮ More suited to normalization proofs. ◮ The previous (original) version is called Church style. Terms. t, u ::= x | t u | λx.t Typing. Γ, x : τ ⊢ x : τ Γ ⊢ t : σ → τ Γ ⊢ u : σ Γ ⊢ t u : τ Γ, x : σ ⊢ t : τ Γ ⊢ λx.t : σ → τ Γ ⊢ t : τ Γ ⊢ t : ∀α.τ (α not free in Γ) Γ ⊢ t : ∀α.τ Γ ⊢ t : τ[σ/α]

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 11 / 12

slide-81
SLIDE 81

System F

Curry Style System F

Motivation. ◮ Variant of System F with lighter syntax. ◮ More suited to normalization proofs. ◮ The previous (original) version is called Church style. Terms. t, u ::= x | t u | λx.t Typing. Γ, x : τ ⊢ x : τ Γ ⊢ t : σ → τ Γ ⊢ u : σ Γ ⊢ t u : τ Γ, x : σ ⊢ t : τ Γ ⊢ λx.t : σ → τ Γ ⊢ t : τ Γ ⊢ t : ∀α.τ (α not free in Γ) Γ ⊢ t : ∀α.τ Γ ⊢ t : τ[σ/α] Reduction. (λx.t)u ⊲ t[u/x] t ⊲ u t v ⊲ u v t ⊲ u v t ⊲ v u t ⊲ u λx.t ⊲ λx.u

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 11 / 12

slide-82
SLIDE 82

System F

Curry Style System F

Motivation. ◮ Variant of System F with lighter syntax. ◮ More suited to normalization proofs. ◮ The previous (original) version is called Church style. Terms. t, u ::= x | t u | λx.t Typing. Γ, x : τ ⊢ x : τ Γ ⊢ t : σ → τ Γ ⊢ u : σ Γ ⊢ t u : τ Γ, x : σ ⊢ t : τ Γ ⊢ λx.t : σ → τ Γ ⊢ t : τ Γ ⊢ t : ∀α.τ (α not free in Γ) Γ ⊢ t : ∀α.τ Γ ⊢ t : τ[σ/α] Reduction. (λx.t)u ⊲ t[u/x] t ⊲ u t v ⊲ u v t ⊲ u v t ⊲ v u t ⊲ u λx.t ⊲ λx.u Subject Reduction. ◮ If Γ ⊢ t : τ and t ⊲ u then Γ ⊢ u : τ.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 11 / 12

slide-83
SLIDE 83

System F

Curry Style System F

Motivation. ◮ Variant of System F with lighter syntax. ◮ More suited to normalization proofs. ◮ The previous (original) version is called Church style. Terms. t, u ::= x | t u | λx.t Typing. Γ, x : τ ⊢ x : τ Γ ⊢ t : σ → τ Γ ⊢ u : σ Γ ⊢ t u : τ Γ, x : σ ⊢ t : τ Γ ⊢ λx.t : σ → τ Γ ⊢ t : τ Γ ⊢ t : ∀α.τ (α not free in Γ) Γ ⊢ t : ∀α.τ Γ ⊢ t : τ[σ/α] Reduction. (λx.t)u ⊲ t[u/x] t ⊲ u t v ⊲ u v t ⊲ u v t ⊲ v u t ⊲ u λx.t ⊲ λx.u Subject Reduction. ◮ If Γ ⊢ t : τ and t ⊲ u then Γ ⊢ u : τ. Undecidability of Typing. ◮ It is undecidable whether a term is typable (and whether it has a given type).

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 11 / 12

slide-84
SLIDE 84

System F

The Erasure Map

The erasure map | − | from Church to Curry terms is defined by induction as follows: |x| := x |t u| := |t| |u| |λx : σ.t| := λx.|t| |t σ| := |t| |Λα.t| := |t|

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 12 / 12

slide-85
SLIDE 85

System F

The Erasure Map

The erasure map | − | from Church to Curry terms is defined by induction as follows: |x| := x |t u| := |t| |u| |λx : σ.t| := λx.|t| |t σ| := |t| |Λα.t| := |t| Basic Properties. ◮ If Γ ⊢ t : τ in the Church system, then Γ ⊢ |t| : τ in the Curry system.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 12 / 12

slide-86
SLIDE 86

System F

The Erasure Map

The erasure map | − | from Church to Curry terms is defined by induction as follows: |x| := x |t u| := |t| |u| |λx : σ.t| := λx.|t| |t σ| := |t| |Λα.t| := |t| Basic Properties. ◮ If Γ ⊢ t : τ in the Church system, then Γ ⊢ |t| : τ in the Curry system. ◮ If Γ ⊢ t : τ in the Curry system, then there is a Church term u such that |u| = t and Γ ⊢ u : τ.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 12 / 12

slide-87
SLIDE 87

System F

The Erasure Map

The erasure map | − | from Church to Curry terms is defined by induction as follows: |x| := x |t u| := |t| |u| |λx : σ.t| := λx.|t| |t σ| := |t| |Λα.t| := |t| Basic Properties. ◮ If Γ ⊢ t : τ in the Church system, then Γ ⊢ |t| : τ in the Curry system. ◮ If Γ ⊢ t : τ in the Curry system, then there is a Church term u such that |u| = t and Γ ⊢ u : τ. ◮ If t ⊲ u then either |t| ⊲ |u| or |u| = |t|.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 12 / 12

slide-88
SLIDE 88

System F

The Erasure Map

The erasure map | − | from Church to Curry terms is defined by induction as follows: |x| := x |t u| := |t| |u| |λx : σ.t| := λx.|t| |t σ| := |t| |Λα.t| := |t| Basic Properties. ◮ If Γ ⊢ t : τ in the Church system, then Γ ⊢ |t| : τ in the Curry system. ◮ If Γ ⊢ t : τ in the Curry system, then there is a Church term u such that |u| = t and Γ ⊢ u : τ. ◮ If t ⊲ u then either |t| ⊲ |u| or |u| = |t|.

Lemma

Consider a (possibly untyped) Church term t. If |t| is S.N., then t is S.N.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 12 / 12

slide-89
SLIDE 89

System F

The Erasure Map

The erasure map | − | from Church to Curry terms is defined by induction as follows: |x| := x |t u| := |t| |u| |λx : σ.t| := λx.|t| |t σ| := |t| |Λα.t| := |t| Basic Properties. ◮ If Γ ⊢ t : τ in the Church system, then Γ ⊢ |t| : τ in the Curry system. ◮ If Γ ⊢ t : τ in the Curry system, then there is a Church term u such that |u| = t and Γ ⊢ u : τ. ◮ If t ⊲ u then either |t| ⊲ |u| or |u| = |t|.

Lemma

Consider a (possibly untyped) Church term t. If |t| is S.N., then t is S.N.

Corollary

If Curry’s style System F is S.N., then Church’s style System F is S.N.

CLAIRAMBAULT & RIBA (LIP - ENS de Lyon) ASPL (CR04) Course 13 12/11 12 / 12