Meyer and Wand property for Damas and Milners polymorphic type - - PowerPoint PPT Presentation

meyer and wand property for damas and milner s
SMART_READER_LITE
LIVE PREVIEW

Meyer and Wand property for Damas and Milners polymorphic type - - PowerPoint PPT Presentation

Meyer and Wand property for Damas and Milners polymorphic type assignment system Presentation Type Theory and Coq Jelte J. Zwetsloot Radboud University Nijmegen May 15th, 2018 Jelte J. Zwetsloot (Radboud University) Meyer and Wand property


slide-1
SLIDE 1

Meyer and Wand property for Damas and Milner’s polymorphic type assignment system

Presentation Type Theory and Coq Jelte J. Zwetsloot

Radboud University Nijmegen

May 15th, 2018

Jelte J. Zwetsloot (Radboud University) Meyer and Wand property for DM May 15th, 2018 1 / 17

slide-2
SLIDE 2

Contents

1

Damas and Milner’s polymorphic type assignment system (DM) Types and contexts Typing rules DM+cont

2

Call-by-Name Type Transform for DM

3

Meyer-Wand typing property for DM

Jelte J. Zwetsloot (Radboud University) Meyer and Wand property for DM May 15th, 2018 2 / 17

slide-3
SLIDE 3

Terms and values for call-by-name

untyped terms e ::= x | λx.e | e1e2 | let x be e1 in e2 callcc | throw untyped values n ::= λx.e | callcc | throw

Jelte J. Zwetsloot (Radboud University) Meyer and Wand property for DM May 15th, 2018 3 / 17

slide-4
SLIDE 4

Call-by-Name CPS Transform

|n|cbn = λk.k||n||cbn |x|cbn = x |e1e2|cbn = λk.|e1|cbn(λk′.k′|e2|cbnk) |let x be e1 in e2|cbn = λk.let x be |e1|cbn in (|e2|cbnk) ||λx.e||cbn = λx.|e|cbn ||callcc||cbn = λf .λk.f (λf ′.f ′(λl.lk)k) ||throw||cbn = λc.λk.k(λx.λl.c(λc′.x(λx′.c′x′)))

Jelte J. Zwetsloot (Radboud University) Meyer and Wand property for DM May 15th, 2018 4 / 17

slide-5
SLIDE 5

Damas and Milner’s polymorphic type assignment system (DM) Types and contexts

DM types and contexts

mono-types τ ::= t | b | τ1 → τ2 poly-types σ ::= τ | ∀t.σ contexts Γ ::= • | Γ, x : σ

Jelte J. Zwetsloot (Radboud University) Meyer and Wand property for DM May 15th, 2018 5 / 17

slide-6
SLIDE 6

Damas and Milner’s polymorphic type assignment system (DM) Typing rules

λ→ typing rules

Γ ⊢ x : Γ(x) (VAR) Γ, x : τ1 ⊢ e : τ2 (ABS) Γ ⊢ λx.e : τ1 → τ2 Γ ⊢ e1 : τ1 → τ2 Γ ⊢ e2 : τ1 (APP) Γ ⊢ e1e2 : τ2 Γ ⊢ e1 : τ1 Γ, x : τ1 ⊢ e2 : τ2 (MONO-LET) Γ ⊢ let x be e1 in e2 : τ2

Jelte J. Zwetsloot (Radboud University) Meyer and Wand property for DM May 15th, 2018 6 / 17

slide-7
SLIDE 7

Damas and Milner’s polymorphic type assignment system (DM) Typing rules

Additional DM typing rules

Γ ⊢ e : σ (t/ ∈ FTV (Γ)), (GEN) Γ ⊢ e : ∀t.σ Γ ⊢ e : ∀t.σ (INST) Γ ⊢ e : [τ/t]σ Γ ⊢ e1 : σ Γ, x : σ ⊢ e2 : τ (x/ ∈ dom(Γ)), (POLY − LET) Γ ⊢ let x be e1 in e2 : τ

Jelte J. Zwetsloot (Radboud University) Meyer and Wand property for DM May 15th, 2018 7 / 17

slide-8
SLIDE 8

Damas and Milner’s polymorphic type assignment system (DM) DM+cont

DM+cont typing rules

DM is extended to DM + cont by adding the type expression τ cont, and by adding the following typing rules: Γ ⊢ callcc : σcallcc (CALLCC’) Γ ⊢ throw : σthrow (THROW’) where σcallcc = ∀t.(t cont → t) → t and σthrow = ∀s.∀t.s cont → s → t.

Jelte J. Zwetsloot (Radboud University) Meyer and Wand property for DM May 15th, 2018 8 / 17

slide-9
SLIDE 9

Call-by-Name Type Transform for DM

Call-by-Name Type Transform for DM

|τ|cbn = (||τ||cbn → α) → α |∀t.σ|cbn = ∀t.|σ|cbn ||t||cbn = t ||b||cbn = b ||τ1 → τ2||cbn = |τ1|cbn → |τ2|cbn ||∀t.σ||cbn = ∀t.||σ||cbn

Jelte J. Zwetsloot (Radboud University) Meyer and Wand property for DM May 15th, 2018 9 / 17

slide-10
SLIDE 10

Call-by-Name Type Transform for DM

Call-by-Name Type Transform for contexts

|Γ|cbn(x) = |Γ(x)|cbn for each x ∈ dom(Γ)

Jelte J. Zwetsloot (Radboud University) Meyer and Wand property for DM May 15th, 2018 10 / 17

slide-11
SLIDE 11

Call-by-Name Type Transform for DM

Clarity

| − |cbn = | − | || − ||cbn = || − ||

Jelte J. Zwetsloot (Radboud University) Meyer and Wand property for DM May 15th, 2018 11 / 17

slide-12
SLIDE 12

Call-by-Name Type Transform for DM

Substitution rules

Lemma: || [τ/t] σ || = [ ||τ||/t ] ||σ|| | [τ/t] σ | = [ ||τ||/t ] |σ|

Jelte J. Zwetsloot (Radboud University) Meyer and Wand property for DM May 15th, 2018 12 / 17

slide-13
SLIDE 13

Call-by-Name Type Transform for DM

Substitution rules: proof

Lemma: || [τ/t] σ || = [ ||τ||/t ] ||σ|| | [τ/t] σ | = [ ||τ||/t ] |σ| Proof: by induction on structure of σ.

Jelte J. Zwetsloot (Radboud University) Meyer and Wand property for DM May 15th, 2018 13 / 17

slide-14
SLIDE 14

Meyer-Wand typing property for DM

Meyer-Wand property for DM

Theorem:

  • 1. If Γ ⊢ n : σ holds in DM, then |Γ| ⊢ ||n|| : ||σ|| holds in DM
  • 2. If Γ ⊢ e : σ holds in DM, then |Γ| ⊢ |e| : |σ| holds in DM

Jelte J. Zwetsloot (Radboud University) Meyer and Wand property for DM May 15th, 2018 14 / 17

slide-15
SLIDE 15

Meyer-Wand typing property for DM

Meyer-Wand property for DM: proof

Theorem:

  • 1. If Γ ⊢ n : σ holds in DM, then |Γ| ⊢ ||n|| : ||σ|| holds in DM
  • 2. If Γ ⊢ e : σ holds in DM, then |Γ| ⊢ |e| : |σ| holds in DM

Proof by induction on the structure of typing derivations

Jelte J. Zwetsloot (Radboud University) Meyer and Wand property for DM May 15th, 2018 15 / 17

slide-16
SLIDE 16

Meyer-Wand typing property for DM

Extension to DM+cont

Extend DM to DM + cont by defining ||τ cont|| = ||τ|| → α Then verify ||callcc|| : ||σcallcc|| ||throw|| : ||σthrow||

Jelte J. Zwetsloot (Radboud University) Meyer and Wand property for DM May 15th, 2018 16 / 17

slide-17
SLIDE 17

Meyer-Wand typing property for DM

Thank you for your attention

Jelte J. Zwetsloot (Radboud University) Meyer and Wand property for DM May 15th, 2018 17 / 17