Polymorphism Dynamic Typing Favonia | Nick Benton | Bob Harper 1 - - PowerPoint PPT Presentation
Polymorphism Dynamic Typing Favonia | Nick Benton | Bob Harper 1 - - PowerPoint PPT Presentation
Polymorphism Dynamic Typing Favonia | Nick Benton | Bob Harper 1 Polymorphism T C E R R O C Dynamic Typing Favonia | Nick Benton | Bob Harper 1 Is this the shortest PLunch? Bob and I wanted to make homework 2 Is this the shortest
1
Polymorphism
Favonia | Nick Benton | Bob Harper
Dynamic Typing
C O R R E C T
2
Is this the shortest PLunch?
Bob and I wanted to make homework
2
Is this the shortest PLunch?
Bob and I wanted to make homework and so we had a JFP Theoretical Pearl.
3
source TARGET type var. “top” type
System F to PCF
3
source TARGET type var. “top” type
System F to PCF
3
source TARGET type var. “top” type But keep other types!
System F to PCF
4
System F source
System F to PCF
4
System F PCF with dyn
source TARGET
System F to PCF
4
System F PCF with dyn
source TARGET
System F to PCF
5
System F to PCF
Keep everything except variables
5
System F to PCF
Keep everything except variables
6
Type Application
type app
6
Type Application
type app
6
Type Application
type app ?
6
Type Application
type app ?
7
Type Application
type app ?
7
Type Application
type app ?
8
Embed and Project
9
Type Application
type app
9
Type Application
type app Idea: lift the projection to handle arbitrary type operators.
9
Type Application
type app Idea: lift the projection to handle arbitrary type operators.
9
Type Application
type app Idea: lift the projection to handle arbitrary type operators. *Mayer-Wand style
10
Embed and Project 2.0
Find all the t!
11
Embed and Project 2.0
12
Problem Statement
12
Problem Statement
(Intended) homework assignment: no run-time errors
12
Problem Statement
(Intended) homework assignment: no run-time errors Igarashi, Pierce and Wadler [2001] showed correctness in a minimal core calculus for Java with generics, relying on the class table.
12
Problem Statement
(Intended) homework assignment: no run-time errors Igarashi, Pierce and Wadler [2001] showed correctness in a minimal core calculus for Java with generics, relying on the class table.
Our difficulty: composition of types
13
System F types System F terms PCF terms relations for type variables that respect obs. equiv.
13
System F types System F terms PCF terms relations for type variables that respect obs. equiv. no J here!
14
Logical Relation Recipe
weakening and exchange STEP 1 the relation itself respects obs. equiv. (and the properties you care) STEP 2 composition of types/relations STEP 3 fundamental lemma! STEP 4
14
Logical Relation Recipe
weakening and exchange STEP 1 the relation itself respects obs. equiv. (and the properties you care) STEP 2 composition of types/relations STEP 3 fundamental lemma! STEP 4
?
15
Compositionality
15
Compositionality
15
Compositionality
not so clear if it's “iff.”
16
Compositionality
FAILED ATTEMPT
implies(?)
16
Compositionality
Assume We want
FAILED ATTEMPT
implies(?)
16
Compositionality
Assume We have We want
FAILED ATTEMPT
implies(?)
16
Compositionality
Assume We have We want
FAILED ATTEMPT
implies(?)
16
Compositionality
Assume We have We want
FAILED ATTEMPT
implies(?)
17
Logical Relation Recipe
weakening and exchange STEP 1 the relation itself respects obs. equiv. (and the properties you care) STEP 2 quasi-composition of types/relations STEP 3 fundamental lemma! STEP 4
Thus, compiled programs give the same numbers!
(no run-time errors)
18
Concluding Notes
18
Concluding Notes
A nice trick to deal with embedding/projection!
18
Concluding Notes
We used refinements to make but rejected by POPL. :-( A nice trick to deal with embedding/projection!
18
Concluding Notes
We used refinements to make but rejected by POPL. :-( A nice trick to deal with embedding/projection! We have 3 different proofs with different setups.
18
Concluding Notes
We used refinements to make but rejected by POPL. :-( Thunks to preserve values: A nice trick to deal with embedding/projection! We have 3 different proofs with different setups.
18
Concluding Notes
We used refinements to make but rejected by POPL. :-( Thunks to preserve values: You can find open problems by TAing! A nice trick to deal with embedding/projection! We have 3 different proofs with different setups.