CS 641 Lecture -*- Outline -*- * Implicit type systems ** \2-Curry (generalization of ML to allow non-shallow types) T ::= V | C | T -> T | all V . T \bot = all a . a *** rules see page 13 *** properties CR, SR, SN, not UT e.g., \x.x has types a -> a and all a. a -> a. type checking properties open! ** \\mu-Curry allows recursion in types, hence fixpoint operators T ::= V | C | T -> T | \mu V . T *** equivalence of types use infinite trees (see page 15) s ~~ t iff Tree(s) = Tree(t) e.g., \mu a . a -> a ~~ (\mu a . a -> a) -> (\mu a . a -> a) \mu a . b -> a ~~ \mu a. b -> b -> a *** rules see page 16 *** properties not SN, since Y can be typed. not UT *** pragmatics recurisve types typically limited to occur in combination with variants or records ** \-intersection (conjunctive types) T ::= V | C | T -> T | T intersect T if f: (bool -> bool) intersect (int -> int) then can apply f to both booleans and integers (page 19) if M:s and M:t, then M:(s intersect t) *** induced preorder, subtyping (3.3.2 on page 17) (s intersect t) <= s (s intersect t) <= t if s <= t and s <= r, then s <= (t intersect r) (s->t)intersect(s->r) <= (s -> (t intersect r)) usual rule for function subtyping <= is reflexive and transitive top element is omega: s <= omega omega <= omega -> omega equivalence relation: s ~ t iff s <= t and t <= s *** rules see page 18, esp top, intersection rules, and subsumption examples: (i) \x.xx : (s intersect (s -> t)) -> t *** properties not SN, not UT, H |- M:s is undecideable! *** pragmatics handling aliasing? see Reynolds 89 **** models of OOP labeled types, l:T, like one-field records (with operation get_l: (l:T ->T) can form general records (l1:T1, l2:T2) = l1:T1 intersect l2:T2 get record subtyping from rules for <=