introduction
play

Introduction 1 Static semantics 2 Syntax Instantiation Typing - PowerPoint PPT Presentation

Elaboration of e MLF into x MLF Introduction Static semantics Dynamic semantics Introduction 1 Static semantics 2 Syntax Instantiation Typing Examples Dynamic semantics 3 Reduction Examples Properties Elaboration of e MLF into x MLF


  1. Elaboration of e MLF into x MLF Introduction Static semantics Dynamic semantics Introduction 1 Static semantics 2 Syntax Instantiation Typing Examples Dynamic semantics 3 Reduction Examples Properties Elaboration of e MLF into x MLF 4 Didier R´ emy (INRIA Paris - Rocquencourt) Explicit type-level retyping functions June 2008 1 / 22

  2. Elaboration of e MLF into x MLF Introduction Static semantics Dynamic semantics System F with explicit type-level retyping functions Didier R´ emy INRIA Paris - Rocquencourt IFIP WG 2.8 Based on joint work with Boris Yakobowski Didier R´ emy (INRIA Paris - Rocquencourt) Explicit type-level retyping functions June 2008 2 / 22

  3. An internal language for MLF

  4. This is not half-baked work but half of baked work thus, I shall be short, and I will not show you any graphs.

  5. Elaboration of e MLF into x MLF Introduction Static semantics Dynamic semantics Prelude About MLF MLF smoothly combines System-F first-class polymorphism with ML-style type inference and requires very few type annotations—only on parameters of functions that are used polymorphically. MLF type inference crucially relies on type generalization for polymorphism explicit introduction, which is applied at every subexpression and not only at let-bindings. Therefore... Didier R´ emy (INRIA Paris - Rocquencourt) Explicit type-level retyping functions June 2008 � 1 � 5 / 22

  6. Elaboration of e MLF into x MLF Introduction Static semantics Dynamic semantics Prelude About MLF MLF smoothly combines System-F first-class polymorphism with ML-style type inference and requires very few type annotations—only on parameters of functions that are used polymorphically. MLF type inference crucially relies on type generalization for polymorphism explicit introduction, which is applied at every subexpression and not only at let-bindings. Therefore... MLF ♥ ML ML ♥ MLF ∧ Didier R´ emy (INRIA Paris - Rocquencourt) Explicit type-level retyping functions June 2008 � 2 � 5 / 22

  7. Elaboration of e MLF into x MLF Introduction Static semantics Dynamic semantics Motivation A fair question by Simon P.J. . . . in Island: What would be an internal language for MLF ? Type soundness for MLF proved for the original version, but a bit tricky, using some intermediate more implicitly-typed version (no inference) it showed preservation of typability during reduction, but failed to preserve the typing derivation. it assumed that no reduction occurred under λ ’s. type soundness has never been proved for the most general version. Also. . . Better understand instance bounded quantification , without having to bother about type inference. Didier R´ emy (INRIA Paris - Rocquencourt) Explicit type-level retyping functions June 2008 6 / 22

  8. Elaboration of e MLF into x MLF Introduction Static semantics Dynamic semantics The example of choice choice : ∀ ( β ) β → β → β � Λ( β ) λ ( x : β ) λ ( y : β ) if true then x else y id : ∀ ( α ) α → α � Λ( α ) λ ( x : α ) x choice id : ( ∀ ( α ) α → α ) → ( ∀ ( α ) α → α ) : ∀ ( α ) ( α → α ) → ( α → α ) ? : Didier R´ emy (INRIA Paris - Rocquencourt) Explicit type-level retyping functions June 2008 � 1 � 7 / 22

  9. Elaboration of e MLF into x MLF Introduction Static semantics Dynamic semantics The example of choice choice : ∀ ( β ) β → β → β � Λ( β ) λ ( x : β ) λ ( y : β ) if true then x else y id : ∀ ( α ) α → α � Λ( α ) λ ( x : α ) x choice id : ( ∀ ( α ) α → α ) → ( ∀ ( α ) α → α ) : ∀ ( α ) ( α → α ) → ( α → α ) ∀ ( α � ∀ ( α ) α → α ) β → β : Didier R´ emy (INRIA Paris - Rocquencourt) Explicit type-level retyping functions June 2008 � 2 � 7 / 22

  10. Elaboration of e MLF into x MLF Introduction Static semantics Dynamic semantics The example of choice choice : ∀ ( β ) β → β → β � Λ( β ) λ ( x : β ) λ ( y : β ) if true then x else y id : ∀ ( α ) α → α � Λ( α ) λ ( x : α ) x choice id : ( ∀ ( α ) α → α ) → ( ∀ ( α ) α → α ) : ∀ ( α ) ( α → α ) → ( α → α ) ∀ ( α � ∀ ( α ) α → α ) β → β : � ? Didier R´ emy (INRIA Paris - Rocquencourt) Explicit type-level retyping functions June 2008 � 3 � 7 / 22

  11. Elaboration of e MLF into x MLF Introduction Static semantics Dynamic semantics The example of choice choice : ∀ ( β ) β → β → β � Λ( β ) λ ( x : β ) λ ( y : β ) if true then x else y id : ∀ ( α ) α → α � Λ( α ) λ ( x : α ) x choice id : ( ∀ ( α ) α → α ) → ( ∀ ( α ) α → α ) : ∀ ( α ) ( α → α ) → ( α → α ) ∀ ( α � ∀ ( α ) α → α ) β → β : � � Λ( β � ∀ ( α ) α → α ) choice � id Didier R´ emy (INRIA Paris - Rocquencourt) Explicit type-level retyping functions June 2008 � 4 � 7 / 22

  12. Elaboration of e MLF into x MLF Introduction Static semantics Dynamic semantics The example of choice choice : ∀ ( β ) β → β → β � Λ( β ) λ ( x : β ) λ ( y : β ) if true then x else y id : ∀ ( α ) α → α � Λ( α ) λ ( x : α ) x choice id : ( ∀ ( α ) α → α ) → ( ∀ ( α ) α → α ) : ∀ ( α ) ( α → α ) → ( α → α ) ∀ ( α � ∀ ( α ) α → α ) β → β : � � Λ( β � ∀ ( α ) α → α ) choice � β � � id (! β ) Didier R´ emy (INRIA Paris - Rocquencourt) Explicit type-level retyping functions June 2008 � 5 � 7 / 22

  13. Elaboration of e MLF into x MLF Introduction Static semantics Dynamic semantics The example of choice choice : ∀ ( β ) β → β → β � Λ( β ) λ ( x : β ) λ ( y : β ) if true then x else y id : ∀ ( α ) α → α � Λ( α ) λ ( x : α ) x choice id : ( ∀ ( α ) α → α ) → ( ∀ ( α ) α → α ) : ∀ ( α ) ( α → α ) → ( α → α ) ∀ ( α � ∀ ( α ) α → α ) β → β : � � Λ( β � ∀ ( α ) α → α ) choice ( ∀ ( � β ); � ) � id (! β ) Didier R´ emy (INRIA Paris - Rocquencourt) Explicit type-level retyping functions June 2008 � 6 � 7 / 22

  14. Elaboration of e MLF into x MLF Introduction Static semantics Dynamic semantics The example of choice choice : ∀ ( β ) β → β → β � Λ( β ) λ ( x : β ) λ ( y : β ) if true then x else y id : ∀ ( α ) α → α � Λ( α ) λ ( x : α ) x choice id : ( ∀ ( α ) α → α ) → ( ∀ ( α ) α → α ) : ∀ ( α ) ( α → α ) → ( α → α ) ∀ ( α � ∀ ( α ) α → α ) β → β : � � Λ( β � ∀ ( α ) α → α ) choice ( ∀ ( � β ); � ) � id (! β ) � �� � � �� � β → β → β β Didier R´ emy (INRIA Paris - Rocquencourt) Explicit type-level retyping functions June 2008 � 7 � 7 / 22

  15. Elaboration of e MLF into x MLF Introduction Static semantics Dynamic semantics Syntax System F Types Terms τ ::= ::= a | α | x | τ → τ | λ ( x : τ ) a | ∀ ( α ) τ | a a | Λ( α ) a | a φ φ ::= τ | let x = a in a Didier R´ emy (INRIA Paris - Rocquencourt) Explicit type-level retyping functions June 2008 � 1 � 8 / 22

  16. Elaboration of e MLF into x MLF Introduction Static semantics Dynamic semantics MLF Syntax Types Terms τ ::= ::= a | α | x | τ → τ | λ ( x : τ ) a ∀ ( α � τ ) τ | | a a Λ( α � τ ) a | | ⊥ | a φ φ ::= τ | let x = a in a Didier R´ emy (INRIA Paris - Rocquencourt) Explicit type-level retyping functions June 2008 � 2 � 8 / 22

  17. Elaboration of e MLF into x MLF Introduction Static semantics Dynamic semantics Syntax Instantiations Types Terms τ ::= ::= a | α | x | τ → τ | λ ( x : τ ) a ∀ ( α � τ ) τ | | a a Λ( α � τ ) a | | ⊥ 1 | a φ φ ::= τ | let x = a in a | ! α ∀ ( � φ ) | ∀ ( α � ) φ | | � | � | φ ; φ | Didier R´ emy (INRIA Paris - Rocquencourt) Explicit type-level retyping functions June 2008 � 3 � 8 / 22

  18. Elaboration of e MLF into x MLF Introduction Static semantics Dynamic semantics Instantiation as a relation Under Bot Γ , α � τ ⊢ φ : τ 1 ≤ τ 2 1 : τ ≤ τ Γ ⊢ ∀ ( α � ) φ : ∀ ( α � τ ) τ 1 ≤ ∀ ( α � τ ) τ 2 Γ ⊢ τ : ⊥ ≤ τ Inside Abstr α � τ ∈ Γ Γ ⊢ φ : τ 1 ≤ τ 2 Γ ⊢ ∀ ( � φ ) : ∀ ( α � τ 1 ) τ ≤ ∀ ( α � τ 2 ) τ Γ ⊢ ! α : τ ≤ α Elim Id Γ ⊢ � : ∀ ( α � τ ) τ ′ ≤ τ ′ { α ← τ } Γ ⊢ Comp Γ ⊢ φ 1 : τ 1 ≤ τ 2 Intro Γ ⊢ φ 2 : τ 2 ≤ τ 3 α / ∈ ftv( τ ) Γ ⊢ � : τ ≤ ∀ ( α � ⊥ ) τ Γ ⊢ φ 1 ; φ 2 : τ 1 ≤ τ 3 Didier R´ emy (INRIA Paris - Rocquencourt) Explicit type-level retyping functions June 2008 9 / 22

  19. Elaboration of e MLF into x MLF Introduction Static semantics Dynamic semantics 1 ) Instantiation as a function If Γ ⊢ φ : τ ≤ τ ′ then τ φ = τ ′ τ (! α ) = α ⊥ ( τ ) = τ τ ( = τ = ∀ ( α � ⊥ ) τ τ ( � ) α / ∈ ftv( τ ) τ ( φ 1 ; φ 2 ) = ( τ ( φ 1 ) ) ( φ 2 ) ( ∀ ( α � τ ) τ ′ ) ( � ) = τ ′ { α ← τ } ( ∀ ( α � τ ) τ ′ ) ( ∀ ( � φ )) = ∀ ( α � τ ( φ ) ) τ ′ = ∀ ( α � τ ) ( τ ′ ( φ ) ) ( ∀ ( α � τ ) τ ′ ) ( ∀ ( α � ) φ ) Didier R´ emy (INRIA Paris - Rocquencourt) Explicit type-level retyping functions June 2008 � 1 � 10 / 22

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