

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Class: Advanced Topics in Computer Graphics; Subject: Computer Science; University: University of California-Santa Cruz; Term: Unknown 2005;
Typology: Study notes
1 / 2
This page cannot be seen from the preview
Don't miss anything!


Types and Programming Languages, Spring 2005, SoE UCSC
We recalled the differences in programming styles when using objects versus ADTs, in particular the expressiveness problem with objects under pure existential types when defining (strong) binary operations. Such questions came up in Kim Bruce’s talk on May 17 as well. We agreed that more information on the type variable in existential types is useful in order to write interesting programs; bounded existentials provide the means to pass such information.
The syntax of the pure lambda calculus with bounded quantified types has the following syntax. Terms t ::= x (variable) | λx : T.t (abstraction) | t t (application) | ΛX <: T.t (type abstraction) | t [T ] (type application) | {⋆T, t} as T (packing) | let {X, x} = t in t (unpacking)
Types T ::= X (type variable) | Top (maximum type) | T → T (function type) | ∀X <: T. T (universal type) | {∃X <: T, T } (existential type)
Environments Γ ::= ∅ (empty) | Γ, x : T (variable type declaration) | Γ, X <: T (type bound declaration)
For a moment, the syntax looked funny because the bounding symbol <: occured in three places (type abstraction, universal and existential type) instead of four (packing?). However it was observed that in the term {⋆T 1 , t} as T 2 , T 2 would be of the form {∃X <: T 3 , T 4 }, hence satisfying our intuitive alarm. Before going further, we tried our hands at subtyping pure (unbounded) quantified types.
Γ, X ⊢ T <: S (<: ∃) Γ ⊢ ∃X.T <: ∃X.S
It was agreed that there was no need for rules with different bound variables, since these could be renamed without affecting the meaning of the quantified type. We then moved to writing some of the interesting type rules.
(Ax <:) X <:^ T^ ∈^ Γ Γ ⊢ X <: T
Γ, X <: T ⊢ S 1 <: S 2 (∃ <:◦) Γ ⊢ {∃X <: T, S 1 } <: {∃X <: T, S 2 }
Γ, X <: T ⊢ t 2 : T 2 (∀E) Γ ⊢ ΛX <: T. t 2 : ∀X <: T. T 2
(∀I) Γ^ ⊢^ t^ :^ ∀X <:^ T^ ′. T^ ′′^ Γ^ ⊢^ T <:^ T^ ′ Γ ⊢ t [T ] : [X 7 → T ]T ′′
The first rule is straightforward. The second and third rules assume that the quantified type variables have the same bounds. The fourth and fifth rules are generalizations of these, where the bounds may be different. In such rules, the usual notions of covariance and contravariance apply. The sixth and seventh rules introduce and eliminate type abstractions. Similar rules can be written to introduce and eliminate packages.
Exercise Try encoding existentials with bounded universal types alone (i.e., find encodings for exis- tential types, packing and unpacking in terms of the rest of the calculus).