Consistent Subtyping for All

Size: px
Start display at page:

Download "Consistent Subtyping for All"

Transcription

1 Consistent Subtyping for All Ningning Xie Xuan Bi Bruno C. d. S. Oliveira 11 May, 2018 The University of Hong Kong 1

2 Background There has been ongoing debate about which language paradigm, static typing or dynamic typing, is better 2

3 Background 1 Some people are in favor of static typing: Communication Reliability Efficiency Productivity 1 Adapted from POPL2017 tutorial. 3

4 Background 1 Some people are in favor of static typing: Communication Reliability Efficiency Productivity the other prefer dynamic typing: Don t have to write type annotations Expressiveness Cognitive load Learning curve 1 Adapted from POPL2017 tutorial. 3

5 Gradual Typing From a Programmer s View Gradual typing enables the evolution of programs from untyped to typed, and provides fine-grained control over which parts are statically checked. 2 2 Examples courtesy of Garcia s slides at POPL 16 4

6 Gradual Typing From a Programmer s View Gradual typing enables the evolution of programs from untyped to typed, and provides fine-grained control over which parts are statically checked. 2 Program with no type information (dynamic checking) def f(x) = x + 2 def h(g) = g(1) h f 2 Examples courtesy of Garcia s slides at POPL 16 4

7 Gradual Typing From a Programmer s View Gradual typing enables the evolution of programs from untyped to typed, and provides fine-grained control over which parts are statically checked. 2 Program with no type information (dynamic checking) def f(x) = x + 2 def h(g) = g(1) h f Program with full type information (static checking) def f(x : Int) = x + 2 def h(g : Int Int) = g(1) h f 2 Examples courtesy of Garcia s slides at POPL 16 4

8 Gradual Typing From a Programmer s View Gradual typing enables the evolution of programs from untyped to typed, and provides fine-grained control over which parts are statically checked. 2 Program with no type information (dynamic checking) def f(x) = x + 2 def h(g) = g(1) h f Program with full type information (static checking) def f(x : Int) = x + 2 def h(g : Int Int) = g(1) h f Program with some type information (mixed checking) def f(x : Int) = x + 2 def h(g) = g(1) h f 2 Examples courtesy of Garcia s slides at POPL 16 4

9 Gradual Typing 101 A gradual type system enforces static type discipline whenever possible: def f(x : Bool) = x + 2 def h (g) = g(1) h f -- static error 5

10 Gradual Typing 101 A gradual type system enforces static type discipline whenever possible: def f(x : Bool) = x + 2 def h (g) = g(1) h f -- static error Inside every gradual language is a small static language struggling to get out... Anonymous 5

11 Gradual Typing 101 A gradual type system enforces static type discipline whenever possible: def f(x : Bool) = x + 2 def h (g) = g(1) h f -- static error Inside every gradual language is a small static language struggling to get out... Anonymous When the type information is not available, it delegates to dynamic checking at runtime: def f(x : Int) = x + 2 def h(g) = g(true) h f -- runtime error 5

12 Gradual Typing 101 The key external feature of every gradual type system is the unknown type. f (x : Int) = x + 2 h (g : ) = g 1 h f -- static checking -- dynamic checking Central to gradual typing is type consistency, which relaxes type equality: Int, Int Int,... Int = Int Bool = Bool Int Bool extend === Int Int Bool Bool Int Bool Int Int Int... 6

13 Gradual Typing 101 The key external feature of every gradual type system is the unknown type. f (x : Int) = x + 2 h (g : ) = g 1 h f -- static checking -- dynamic checking Central to gradual typing is type consistency, which relaxes type equality: Int, Int Int,... Dynamic semantics is defined by type-directed translation to an internal language with runtime casts: ( g) ( Int 1) 6

14 Many Successes Gradual typing has seen great popularity both in academia and industry. Over the years, there emerge many gradual type disciplines: Subtyping Parametric Polymorphism Type inference Security Typing Effects... 7

15 Many Successes, But... Gradual typing has seen great popularity both in academia and industry. Over the years, there emerge many gradual type disciplines: Subtyping Parametric Polymorphism Type inference Security Typing Effects... R As type systems get more complex, it becomes more difficult to adapt notions of gradual typing. [Garcia et al., 2016] 7

16 Problem Can we design a gradual type system with implicit higher-rank polymorphism? 8

17 Problem Can we design a gradual type system with implicit higher-rank polymorphism? State-of-art techniques are inadequate. 8

18 Why It Is interesting Haskell supports implicit higher-rank polymorphism, but some safe programs are rejected: foo :: ([Int], [Char]) foo = let f x = (x [1, 2], x [ a, b ]) in f reverse -- GHC rejects 9

19 Why It Is interesting Haskell supports implicit higher-rank polymorphism, but some safe programs are rejected: foo :: ([Int], [Char]) foo = let f x = (x [1, 2], x [ a, b ]) in f reverse -- GHC rejects If we had gradual typing... let f (x : ) = (x [1, 2], x [ a, b ]) in f reverse 9

20 Why It Is interesting Haskell supports implicit higher-rank polymorphism, but some safe programs are rejected: foo :: ([Int], [Char]) foo = let f x = (x [1, 2], x [ a, b ]) in f reverse -- GHC rejects If we had gradual typing... let f (x : ) = (x [1, 2], x [ a, b ]) in f reverse Moving to more precised version still type checks, but with more static safety guarantee: let f (x : a. [a] [a]) = (x [1, 2], x [ a, b ]) in f reverse 9

21 Contributions A new specification of consistent subtyping that works for implicit higher-rank polymorphism An easy-to-follow recipe for turning subtyping into consistent subtyping A gradually typed calculus with implicit higher-rank polymorphism Satisfies correctness criteria (formalized in Coq) A sound and complete algorithm 10

22 What Is Consistent Subtyping Consistent subtyping ( ) is the extension of subtyping to gradual types. [Siek and Taha, 2007] 11

23 What Is Consistent Subtyping Consistent subtyping ( ) is the extension of subtyping to gradual types. [Siek and Taha, 2007] A static subtyping relation (<:) over gradual types, with the key insight that is neutral to subtyping ( <: ) 11

24 What Is Consistent Subtyping Consistent subtyping ( ) is the extension of subtyping to gradual types. [Siek and Taha, 2007] A static subtyping relation (<:) over gradual types, with the key insight that is neutral to subtyping ( <: ) Definition (Consistent Subtyping à la Siek and Taha) The following two are equivalent: 1. A B if and only if A C and C <: B for some C. 2. A B if and only if A <: C and C B for some C. 11

25 Design Principle R Gradual typing and subtyping are orthogonal and can be combined in a principled fashion. Siek and Taha 12

26 Challenge Polymorphic types induce a subtyping relation: a. a a <: Int Int Design consistent subtyping that combines 1) consistency 2) subtyping 3) polymorphism. 13

27 Challenge Polymorphic types induce a subtyping relation: a. a a <: Int Int Design consistent subtyping that combines 1) consistency 2) subtyping 3) polymorphism. R Gradual typing and polymorphism are orthogonal and can be combined in a principled fashion. 3 3 Note that here we are mostly concerned with static semantics. 13

28 Problem with Existing Definition

29 Odersky-Läufer Type System The underlying static language is the well-established type system for higher-rank types. [Odersky and Läufer, 1996] Types A, B ::= Int a A B a. A Monotypes τ, σ ::= Int a τ σ Terms e ::= x n λx : A. e λx. e e 1 e 2 Contexts Ψ ::= Ψ, x : A Ψ, a 14

30 Subtyping Ψ A <: B (Subtyping) a Ψ Ψ a <: a Ψ τ Ψ Int <: Int Ψ A[a τ] <: B Ψ a. A <: B Ψ B 1 <: A 1 Ψ A 2 <: B 2 Ψ A 1 A 2 <: B 1 B 2 Ψ, a A <: B Ψ A <: a. B 15

31 Subtyping with Unknown Types Ψ A <: B (Subtyping) a Ψ Ψ a <: a Ψ τ Ψ Int <: Int Ψ A[a τ] <: B Ψ a. A <: B Ψ B 1 <: A 1 Ψ A 2 <: B 2 Ψ A 1 A 2 <: B 1 B 2 Ψ, a A <: B Ψ A <: a. B Ψ <: 15

32 Type Consistency A B (Type Consistency) A A A A A 1 B 1 A 2 B 2 A 1 A 2 B 1 B 2 16

33 Type Consistency with Polymorphic Types A B (Type Consistency) A A A A A 1 B 1 A 2 B 2 A 1 A 2 B 1 B 2 A B a. A a. B 16

34 Type Consistency with Polymorphic Types A B (Type Consistency) A A A A A 1 B 1 A 2 B 2 A 1 A 2 B 1 B 2 A B a. A a. B R The simplicity comes from the orthogonality between consistency and subtyping! 16

35 Bad News Definition (Consistent Subtyping à la Siek and Taha) The following two are equivalent: 1. A B if and only if A C and C <: B for some C. 2. A B if and only if A <: C and C B for some C. R Equivalence is broken in the polymorphic setting! 17

36 Bad News Definition (Consistent Subtyping à la Siek and Taha) The following two are equivalent: 1. A B if and only if A C and C <: B for some C. 2. A B if and only if A <: C and C B for some C. R Equivalence is broken in the polymorphic setting! ( Int) Int <: <: ( a.a Int) Int ( a. Int) Int 17

37 Bad News Definition (Consistent Subtyping à la Siek and Taha) The following two are equivalent: 1. A B if and only if A C and C <: B for some C. 2. A B if and only if A <: C and C B for some C. R Equivalence is broken in the polymorphic setting! Int Int Int <: <: a.a 17

38 Bad News Definition (Consistent Subtyping à la Siek and Taha) The following two are equivalent: 1. A B if and only if A C and C <: B for some C. 2. A B if and only if A <: C and C B for some C. R Equivalence is broken in the polymorphic setting! ( (( Int) Int) Bool) (Int ) <: <: ( (( a.a Int) Int) Bool) ( a.a) 17

39 Revisiting Consistent Subtyping

40 Consistent Subtyping vs. Subtyping Subtyping validates the subsumption principle Ψ e : A Ψ e : B A <: B 18

41 Consistent Subtyping vs. Subtyping Subtyping validates the subsumption principle, so should consistent subtyping Ψ e : A Ψ e : B A B 18

42 Consistent Subtyping vs. Subtyping Subtyping validates the subsumption principle, so should consistent subtyping Ψ e : A Ψ e : B A B Subtyping is transitive, but consistent subtyping is not 18

43 Observations Observation (I) If A <: B and B C, then A C. <: T 1 <: C <: B T 2 A 19

44 Observations Observation (I) If A <: B and B C, then A C. <: T 1 <: C <: B T 2 A 19

45 Observations Observation (I) If A <: B and B C, then A C. <: T 1 <: C B T 2 <: A 19

46 Observations Observation (I) If A <: B and B C, then A C. Observation (II) If C B and B <: A, then C A. <: T 1 C <: B T 2 <: A <: T 1 B <: <: A C T 2 19

47 Observations Observation (I) If A <: B and B C, then A C. Observation (II) If C B and B <: A, then C A. <: T 1 C <: B T 2 <: A <: T 1 B <: <: A C T 2 19

48 Consistent Subtyping, the Specification Definition (Generalized Consistent Subtyping) Ψ A B def = Ψ A <: A, A B and Ψ B <: B for some A and B. <: B A B <: A 20

49 Consistent Subtyping, the Specification Definition (Generalized Consistent Subtyping) Ψ A B def = Ψ A <: A, A B and Ψ B <: B for some A and B. ((( Int) Int) Bool) (Int ) A <: B <: ((( a.a Int) Int) Bool) ( a.a) A = (( a.a Int) Int) Bool) (Int Int) B = (( a. Int) Int) Bool) (Int ) 20

50 Non-Determinism Definition (Generalized Consistent Subtyping) Ψ A B def = Ψ A <: A, A B and Ψ B <: B for some A and B. Two sources of non-determinism: 1. Two intermediate types A and B 21

51 Non-Determinism Definition (Generalized Consistent Subtyping) Ψ A B def = Ψ A <: A, A B and Ψ B <: B for some A and B. Two sources of non-determinism: 1. Two intermediate types A and B 2. Guessing monotypes Ψ τ Ψ A[a τ] <: B Ψ a. A <: B 21

52 Non-Determinism Definition (Generalized Consistent Subtyping) Ψ A B def = Ψ A <: A, A B and Ψ B <: B for some A and B. Two sources of non-determinism: 1. Two intermediate types A and B R We can derive a syntax-directed inductive definition without resorting to subtyping or consistency at all! 21

53 Consistent Subtyping Without Existentials Notice Ψ A always holds ( <: A <: A), and vise versa (Ψ A ) 22

54 Consistent Subtyping Without Existentials: First Step 1. Replace <: with Ψ A <: B a Ψ Ψ a <: a Ψ τ Ψ Int <: Int Ψ A[a τ] <: B Ψ a. A <: B (Subtyping) Ψ B 1 <: A 1 Ψ A 2 <: B 2 Ψ A 1 A 2 <: B 1 B 2 Ψ, a A <: B Ψ A <: a. B Ψ <: 22

55 Consistent Subtyping Without Existentials: First Step 1. Replace <: with Ψ A B a Ψ Ψ a a Ψ τ Ψ Int Int Ψ A[a τ] B Ψ a. A B (Consistent Subtyping, not yet) Ψ B 1 A 1 Ψ A 2 B 2 Ψ A 1 A 2 B 1 B 2 Ψ, a A B Ψ A a. B Ψ 22

56 Consistent Subtyping Without Existentials: Second Step 1. Replace <: with 2. Replace Ψ with Ψ A and Ψ A Ψ A B (Consistent Subtyping, not yet) a Ψ Ψ a a Ψ Int Int Ψ B 1 A 1 Ψ A 2 B 2 Ψ A 1 A 2 B 1 B 2 Ψ τ Ψ A[a τ] B Ψ a. A B Ψ, a A B Ψ A a. B Ψ 22

57 Consistent Subtyping Without Existentials: Second Step 1. Replace <: with 2. Replace Ψ with Ψ A and Ψ A Ψ A B (Consistent Subtyping) a Ψ Ψ a a Ψ Int Int Ψ B 1 A 1 Ψ A 2 B 2 Ψ A 1 A 2 B 1 B 2 Ψ τ Ψ A[a τ] B Ψ a. A B Ψ, a A B Ψ A a. B Ψ A Ψ A 22

58 Definition Meets Specification Theorem Ψ A B iff Ψ A <: A, A B and Ψ B <: B for some A and B. 23

59 Declarative Type System

60 Type System Ψ e : A Ψ, a e : A Ψ e : a. A u-gen (Typing, selected rules) Ψ, x : A e : B Ψ λx : A. e : A B u-lamann Ψ, x : τ e : B Ψ λx. e : τ B u-lam Ψ e 1 : A Ψ A A 1 A 2 Ψ e 2 : A 3 Ψ A 3 A 1 Ψ e 1 e 2 : A 2 u-app 24

61 Type System Ψ e 1 : A Ψ A A 1 A 2 Ψ e 2 : A 3 Ψ A 3 A 1 Ψ e 1 e 2 : A 2 u-app Ψ A A 1 A 2 (Matching) Ψ τ Ψ A[a τ] A 1 A 2 Ψ a. A A 1 A 2 m-forall Ψ A 1 A 2 A 1 A 2 m-arr Ψ m-unknown 24

62 Dynamic Semantics Type-directed translation into an intermediate language with runtime casts (Ψ e : A s) We translate to the Polymorphic Blame Calculus (PBC) [Ahmed et al., 2011] PBC terms 4 s ::= x n λx : A. s Λa. s s 1 s 2 A B s 4 Only a subst of PBC terms are used 25

63 Correctness Criteria Conservative extension: for all static Ψ, e, and A, if Ψ OL e : A, then there exists B, such that Ψ e : B, and Ψ B <: A. if Ψ e : A, then Ψ OL e : A Monotonicity w.r.t. precision: for all Ψ, e, e, A, if Ψ e : A, and e e, then Ψ e : B, and B A for some B. Type Preservation of cast insertion: for all Ψ, e, A, if Ψ e : A, then Ψ e : A s, and Ψ B s : A for some s. Monotonicity of cast insertion: for all Ψ, e 1, e 2, s 1, s 2, A, if Ψ e 1 : A s 1, and Ψ e 2 : A s 2, and e 1 e 2, then Ψ Ψ s 1 B s 2. 26

64 Correctness Criteria Conservative extension: for all static Ψ, e, and A, if Ψ OL e : A, then there exists B, such that Ψ e : B, and Ψ B <: A. if Ψ e : A, then Ψ OL e : A Monotonicity w.r.t. precision: for all Ψ, e, e, A, if Ψ e : A, and e e, then Ψ e : B, and B A for some B. Type Preservation of cast insertion: for all Ψ, e, A, if Ψ e : A, then Ψ e : A s, and Ψ B s : A for some s. Monotonicity of cast insertion: for all Ψ, e 1, e 2, s 1, s 2, A, if Ψ e 1 : A s 1, and Ψ e 2 : A s 2, and e 1 e 2, then Ψ Ψ s 1 B s 2. R Proved in Coq! 26

65 Recap Gradual Language with Implict Higher-Rank Polymorphism <translate> Cast Language PBC <Gradualize> Static Language Criteria 27

66 More in the Paper A bidirectional account of the algorithmic type system (inspired by [Dunfield and Krishnaswami, 2013]) Extension to top types Discussion and comparison with other approaches (AGT [Garcia et al., 2016], Directed Consistency [Jafery and Dunfield, 2017]) Discussion of dynamic guarantee 28

67 Future Work Fix the issue with dynamic guarantee (partially) More features: fancy types, etc. 29

68 References A. Ahmed, R. B. Findler, J. G. Siek, and P. Wadler. Blame for all. In POPL, J. Dunfield and N. R. Krishnaswami. Complete and easy bidirectional typechecking for higher-rank polymorphism. In ICFP, R. Garcia, A. M. Clark, and É. Tanter. Abstracting gradual typing. In POPL, K. A. Jafery and J. Dunfield. Sums of uncertainty: Refinements go gradual. In POPL, M. Odersky and K. Läufer. Putting type annotations to work. In POPL, J. G. Siek and W. Taha. Gradual typing for objects. In ECOOP,

69 Consistent Subtyping for All Ningning Xie Xuan Bi Bruno C. d. S. Oliveira 11 May, 2018 The University of Hong Kong 31

70 Backup Slides

71 Dynamic Guarantee Changes to the annotations of a gradually typed program should not change the dynamic behaviour of the program. The declarative system breaks it... (λf : a. a Int. λx : Int. f x) (λx. 1) 3 3 (λf : a. a Int. λx :. f x) (λx. 1) 3? A common problem in gradual type inference, see [Garcia and Cimini 2015]. Static and gradual type parameters may help. A more sophisticated term precision is needed in PBC. [Igarashi et al. 2017]

Consistent Subtyping for All

Consistent Subtyping for All Consistent Subtyping for All Ningning Xie, Xuan Bi, and Bruno C. d. S. Oliveira The University of Hong Kong {nnxie,xbi,bruno}@cs.hku.hk Abstract. Consistent subtyping is employed in some gradual type systems

More information

Let Arguments Go First

Let Arguments Go First Let Arguments Go First Ningning Xie and Bruno C. d. S. Oliveira The University of Hong Kong {nnxie,bruno}@cs.hku.hk Abstract. Bi-directional type checking has proved to be an extremely useful and versatile

More information

Let Arguments Go First

Let Arguments Go First Let Arguments Go First Ningning Xie (B) and Bruno C. d. S. Oliveira The University of Hong Kong, Pokfulam, Hong Kong {nnxie,bruno}@cs.hku.hk Abstract. Bi-directional type checking has proved to be an extremely

More information

The Polymorphic Blame Calculus and Parametricity

The Polymorphic Blame Calculus and Parametricity 1 / 31 The Polymorphic Blame Calculus and Parametricity Jeremy G. Siek Indiana University, Bloomington University of Strathclyde August 2015 2 / 31 Integrating static and dynamic typing Static Dynamic

More information

Gradual Parametricity, Revisited

Gradual Parametricity, Revisited aaachicbvddssmwge39nfov6qu30sf4y2lfuerk6i3etbbys0jtdmtle1lkgqj7nrh8am81sfwtrwvh8d3mo12ozshkpyc7zvkywlsrqwy7s9jbn5hcwm5sljdvvf2ds3tlsyyqqmtzywrlgbkorrtpqkkkbcvbaub4y0g8f1uw8/ecfpwu/vmcv+jhqcrhqjpawuuedfiucmqdecljy61nvfofruusouxdk1a7zll4czxjmqgpig0tw/vtdbwuy4wgxj2hsvpk5eopirkzvl5mkriaeqsjkucxk5efmued7qsqj2tnqguv3tyfes5taodgemvf9o1wrxv1onu9gzn1oezopwph4oyhhucsxygsevbcs21arhqfwseperqfjp9kpeacxdelfoi+tksofitkcws1rhlmnbzt1jr41sagcdse+oaqooav1camaoakweatp4aw8gk/gm/fufixb54yjzwf8gfh5a4h9n/m=

More information

The gradual typing approach to mixing static and dynamic typing

The gradual typing approach to mixing static and dynamic typing 1 / 38 The gradual typing approach to mixing static and dynamic typing Jeremy G. Siek University of Colorado = Indiana University TFP 2013 at Provo, Utah, May 2013 The Goals of Gradual Typing Enjoy the

More information

Gradual Typing with Union and Intersection Types

Gradual Typing with Union and Intersection Types Gradual Typing with Union and Intersection Types Giuseppe Castagna, Victor Lanvin ICFP 17 September 6, 2017 1 / 14 Outline 1 Motivating Example 2 Types and Subtyping 3 Function Types and Operators 4 Conclusion

More information

Arbitrary-rank polymorphism in (GHC) Haskell

Arbitrary-rank polymorphism in (GHC) Haskell Arbitrary-rank polymorphism in (GHC) Haskell CAS 743 Stephen Forrest 20 March 2006 Damas-Milner Type System A Damas-Milner type system (also called Hindley-Milner) is a traditional type system for functional

More information

` e : T. Gradual Typing. ` e X. Ronald Garcia University of British Columbia

` e : T. Gradual Typing. ` e X. Ronald Garcia University of British Columbia aaab/hicbvbns8naen34wetxtecvi0xwvbirfe9fd3qs0c9oqplsnu3s3stsbgqh1l/ixymixv0h3vw3btsctpxbwoo9gwbmbslnsjvot7w2vrg5tv3ake/u7r8c2kfhbzvkktawsxgiuweoyllmw5pptruppcactjvb6g7md8zukpbetz2n1bcwifnecggj9e2kdw9capbgiaghpvggn/t21ak5c+bv4hakigo0+vaxfyykeztwhinspddjtt8bqrnhdfr2mkvticmy0j6hmqiq/mn8+ck+m0qio0saijweq78njicuykvgogxoovr2zuj/xi/t0bu/yxgaarqtxaio41gnejyedpmkrppceccsmvsxgyieok1ezrocu/zykmlf1fyn5j5evuu3rrwldijo0tly0rwqowfuqc1eui6e0st6s56sf+vd+li0rlnftax9gfx5a8zmk40=

More information

Tradeoffs. CSE 505: Programming Languages. Lecture 15 Subtyping. Where shall we add useful completeness? Where shall we add completeness?

Tradeoffs. CSE 505: Programming Languages. Lecture 15 Subtyping. Where shall we add useful completeness? Where shall we add completeness? Tradeoffs CSE 505: Programming Languages Lecture 15 Subtyping Zach Tatlock Autumn 2017 Desirable type system properties (desiderata): soundness - exclude all programs that get stuck completeness - include

More information

COS 320. Compiling Techniques

COS 320. Compiling Techniques Topic 5: Types COS 320 Compiling Techniques Princeton University Spring 2016 Lennart Beringer 1 Types: potential benefits (I) 2 For programmers: help to eliminate common programming mistakes, particularly

More information

Lambda Calculi With Polymorphism

Lambda Calculi With Polymorphism Resources: The slides of this lecture were derived from [Järvi], with permission of the original author, by copy & x = 1 let x = 1 in... paste or by selection, annotation, or rewording. [Järvi] is in turn

More information

Programming Languages

Programming Languages CSE 230: Winter 2008 Principles of Programming Languages Ocaml/HW #3 Q-A Session Push deadline = Mar 10 Session Mon 3pm? Lecture 15: Type Systems Ranjit Jhala UC San Diego Why Typed Languages? Development

More information

Lecture 13: Subtyping

Lecture 13: Subtyping Lecture 13: Subtyping Polyvios Pratikakis Computer Science Department, University of Crete Type Systems and Programming Languages Pratikakis (CSD) Subtyping CS546, 2018-2019 1 / 15 Subtyping Usually found

More information

Gradual Typing with Inference

Gradual Typing with Inference Gradual Typing with Inference Jeremy Siek University of Colorado at Boulder joint work with Manish Vachharajani Overview Motivation Background Gradual Typing Unification-based inference Exploring the Solution

More information

Gradual Typing for Functional Languages. Jeremy Siek and Walid Taha (presented by Lindsey Kuper)

Gradual Typing for Functional Languages. Jeremy Siek and Walid Taha (presented by Lindsey Kuper) Gradual Typing for Functional Languages Jeremy Siek and Walid Taha (presented by Lindsey Kuper) 1 Introduction 2 What we want Static and dynamic typing: both are useful! (If you re here, I assume you agree.)

More information

Static and User-Extensible Proof Checking. Antonis Stampoulis Zhong Shao Yale University POPL 2012

Static and User-Extensible Proof Checking. Antonis Stampoulis Zhong Shao Yale University POPL 2012 Static and User-Extensible Proof Checking Antonis Stampoulis Zhong Shao Yale University POPL 2012 Proof assistants are becoming popular in our community CompCert [Leroy et al.] sel4 [Klein et al.] Four-color

More information

On Polymorphic Gradual Typing

On Polymorphic Gradual Typing On Polymorphic Gradual Typing YUU IGARASHI, Kyoto University TARO SEKIYAMA, IBM Research - Tokyo ATSUSHI IGARASHI, Kyoto University We study an extension of gradual typing a method to integrate dynamic

More information

Simple Unification-based Type Inference for GADTs

Simple Unification-based Type Inference for GADTs Simple Unification-based Type Inference for GADTs Stephanie Weirich University of Pennsylvania joint work with Dimitrios Vytiniotis, Simon Peyton Jones and Geoffrey Washburn Overview Goal: Add GADTs to

More information

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011 CS152: Programming Languages Lecture 11 STLC Extensions and Related Topics Dan Grossman Spring 2011 Review e ::= λx. e x e e c v ::= λx. e c τ ::= int τ τ Γ ::= Γ, x : τ (λx. e) v e[v/x] e 1 e 1 e 1 e

More information

Goal. CS152: Programming Languages. Lecture 15 Parametric Polymorphism. What the Library Likes. What The Client Likes. Start simpler.

Goal. CS152: Programming Languages. Lecture 15 Parametric Polymorphism. What the Library Likes. What The Client Likes. Start simpler. Goal Understand what this interface means and why it matters: CS152: Programming Languages Lecture 15 Parametric Polymorphism Dan Grossman Spring 2011 type a mylist; val mt_list : a mylist val cons : a

More information

Subsumption. Principle of safe substitution

Subsumption. Principle of safe substitution Recap on Subtyping Subsumption Some types are better than others, in the sense that a value of one can always safely be used where a value of the other is expected. Which can be formalized as by introducing:

More information

Harvard School of Engineering and Applied Sciences Computer Science 152

Harvard School of Engineering and Applied Sciences Computer Science 152 Harvard School of Engineering and Applied Sciences Computer Science 152 Lecture 17 Tuesday, March 30, 2010 1 Polymorph means many forms. Polymorphism is the ability of code to be used on values of different

More information

Type Systems. Pierce Ch. 3, 8, 11, 15 CSE

Type Systems. Pierce Ch. 3, 8, 11, 15 CSE Type Systems Pierce Ch. 3, 8, 11, 15 CSE 6341 1 A Simple Language ::= true false if then else 0 succ pred iszero Simple untyped expressions Natural numbers encoded as succ succ

More information

Simply-Typed Lambda Calculus

Simply-Typed Lambda Calculus #1 Simply-Typed Lambda Calculus #2 Back to School What is operational semantics? When would you use contextual (small-step) semantics? What is denotational semantics? What is axiomatic semantics? What

More information

Programming Languages Lecture 15: Recursive Types & Subtyping

Programming Languages Lecture 15: Recursive Types & Subtyping CSE 230: Winter 2008 Principles of Programming Languages Lecture 15: Recursive Types & Subtyping Ranjit Jhala UC San Diego News? Formalize first-order type systems Simple types (integers and booleans)

More information

Tracing Ambiguity in GADT Type Inference

Tracing Ambiguity in GADT Type Inference Tracing Ambiguity in GADT Type Inference ML Workshop 2012, Copenhagen Jacques Garrigue & Didier Rémy Nagoya University / INRIA Garrigue & Rémy Tracing ambiguity 1 Generalized Algebraic Datatypes Algebraic

More information

CS-XXX: Graduate Programming Languages. Lecture 9 Simply Typed Lambda Calculus. Dan Grossman 2012

CS-XXX: Graduate Programming Languages. Lecture 9 Simply Typed Lambda Calculus. Dan Grossman 2012 CS-XXX: Graduate Programming Languages Lecture 9 Simply Typed Lambda Calculus Dan Grossman 2012 Types Major new topic worthy of several lectures: Type systems Continue to use (CBV) Lambda Caluclus as our

More information

Exploring the Design Space of Higher-Order Casts ; CU-CS

Exploring the Design Space of Higher-Order Casts ; CU-CS University of Colorado, Boulder CU Scholar Computer Science Technical Reports Computer Science Fall 10-1-2008 Exploring the Design Space of Higher-Order Casts ; CU-CS-1047-08 Jeremy Siek University of

More information

Mutable References. Chapter 1

Mutable References. Chapter 1 Chapter 1 Mutable References In the (typed or untyped) λ-calculus, or in pure functional languages, a variable is immutable in that once bound to a value as the result of a substitution, its contents never

More information

Subtyping. Lecture 13 CS 565 3/27/06

Subtyping. Lecture 13 CS 565 3/27/06 Subtyping Lecture 13 CS 565 3/27/06 Polymorphism Different varieties of polymorphism: Parametric (ML) type variables are abstract, and used to encode the fact that the same term can be used in many different

More information

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Lecture 14 Tuesday, March 24, 2015 1 Parametric polymorphism Polymorph means many forms. Polymorphism is the ability of

More information

CS 565: Programming Languages. Spring 2008 Tu, Th: 16:30-17:45 Room LWSN 1106

CS 565: Programming Languages. Spring 2008 Tu, Th: 16:30-17:45 Room LWSN 1106 CS 565: Programming Languages Spring 2008 Tu, Th: 16:30-17:45 Room LWSN 1106 Administrivia Who am I? Course web page http://www.cs.purdue.edu/homes/peugster/cs565spring08/ Office hours By appointment Main

More information

An update on XML types

An update on XML types An update on XML types Alain Frisch INRIA Rocquencourt (Cristal project) Links Meeting - Apr. 2005 Plan XML types 1 XML types 2 3 2/24 Plan XML types 1 XML types 2 3 3/24 Claim It is worth studying new

More information

The Trouble with Types

The Trouble with Types The Trouble with Types Martin Odersky EPFL and Typesafe Types Everyone has an opinion on them Industry: Used to be the norm (C/C++, Java). Today split about evenly with dynamic. Academia: Static types

More information

Lambda Calculi With Polymorphism

Lambda Calculi With Polymorphism Resources: The slides of this lecture were derived from [Järvi], with permission of the original author, by copy & x = 1 let x = 1 in... paste or by selection, annotation, or rewording. [Järvi] is in turn

More information

Topics Covered Thus Far CMSC 330: Organization of Programming Languages

Topics Covered Thus Far CMSC 330: Organization of Programming Languages Topics Covered Thus Far CMSC 330: Organization of Programming Languages Names & Binding, Type Systems Programming languages Ruby Ocaml Lambda calculus Syntax specification Regular expressions Context free

More information

Adding GADTs to OCaml the direct approach

Adding GADTs to OCaml the direct approach Adding GADTs to OCaml the direct approach Jacques Garrigue & Jacques Le Normand Nagoya University / LexiFi (Paris) https://sites.google.com/site/ocamlgadt/ Garrigue & Le Normand Adding GADTs to OCaml 1

More information

Concepts of programming languages

Concepts of programming languages Concepts of programming languages Lecture 2 Wouter Swierstra 1 Last time: programming languages In the first lecture I tried to motivate why we might consider programming languages themselves as interesting

More information

Linking Types: Secure compilation of multi-language programs

Linking Types: Secure compilation of multi-language programs Linking Types: Secure compilation of multi-language programs Daniel Patterson and Amal Ahmed January 15, 2017 Northeastern University Fully abstract compilers Source program fully abstract compiler Compiled

More information

Types and Type Inference

Types and Type Inference Types and Type Inference Mooly Sagiv Slides by Kathleen Fisher and John Mitchell Reading: Concepts in Programming Languages, Revised Chapter 6 - handout on the course homepage Outline General discussion

More information

Official Survey. Cunning Plan: Focus On Objects. The Need for a Calculus. Object Calculi Summary. Why Not Use λ-calculus for OO?

Official Survey. Cunning Plan: Focus On Objects. The Need for a Calculus. Object Calculi Summary. Why Not Use λ-calculus for OO? Modeling and Understanding Object-Oriented Oriented Programming Official Survey Please fill out the Toolkit course survey 40142 CS 655-1 Apr-21-2006 Midnight May-04-2006 9am Why not do it this evening?

More information

Review. CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Let bindings (CBV) Adding Stuff. Booleans and Conditionals

Review. CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Let bindings (CBV) Adding Stuff. Booleans and Conditionals Review CS152: Programming Languages Lecture 11 STLC Extensions and Related Topics e ::= λx. e x ee c v ::= λx. e c (λx. e) v e[v/x] e 1 e 2 e 1 e 2 τ ::= int τ τ Γ ::= Γ,x : τ e 2 e 2 ve 2 ve 2 e[e /x]:

More information

CSCI-GA Scripting Languages

CSCI-GA Scripting Languages CSCI-GA.3033.003 Scripting Languages 12/02/2013 OCaml 1 Acknowledgement The material on these slides is based on notes provided by Dexter Kozen. 2 About OCaml A functional programming language All computation

More information

Once Upon a Polymorphic Type

Once Upon a Polymorphic Type Once Upon a Polymorphic Type Keith Wansbrough Computer Laboratory University of Cambridge kw217@cl.cam.ac.uk http://www.cl.cam.ac.uk/users/kw217/ Simon Peyton Jones Microsoft Research Cambridge 20 January,

More information

Sound Gradual Typing is Nominally Alive and Well

Sound Gradual Typing is Nominally Alive and Well Sound Gradual Typing is Nominally Alive and Well FABIAN MUEHLBOECK, Cornell University, USA ROSS TATE, Cornell University, USA Recent research has identified significant performance hurdles that sound

More information

Lambda Calculus: Implementation Techniques and a Proof. COS 441 Slides 15

Lambda Calculus: Implementation Techniques and a Proof. COS 441 Slides 15 Lambda Calculus: Implementation Techniques and a Proof COS 441 Slides 15 Last Time: The Lambda Calculus A language of pure functions: values e ::= x \x.e e e v ::= \x.e With a call-by-value operational

More information

Exercise 1 ( = 24 points)

Exercise 1 ( = 24 points) 1 Exercise 1 (4 + 5 + 4 + 6 + 5 = 24 points) The following data structure represents polymorphic binary trees that contain values only in special Value nodes that have a single successor: data Tree a =

More information

Pierce Ch. 3, 8, 11, 15. Type Systems

Pierce Ch. 3, 8, 11, 15. Type Systems Pierce Ch. 3, 8, 11, 15 Type Systems Goals Define the simple language of expressions A small subset of Lisp, with minor modifications Define the type system of this language Mathematical definition using

More information

Space-Efficient Blame Tracking for Gradual Types

Space-Efficient Blame Tracking for Gradual Types Space-Efficient Blame Tracking for Gradual Types Jeremy G. Siek University of Colorado at Boulder jeremy.siek@colorado.edu Abstract Static and dynamic type systems have well-known strengths and weaknesses.

More information

Exercise 1 ( = 22 points)

Exercise 1 ( = 22 points) 1 Exercise 1 (4 + 3 + 4 + 5 + 6 = 22 points) The following data structure represents polymorphic lists that can contain values of two types in arbitrary order: data DuoList a b = C a (DuoList a b) D b

More information

Eta-equivalence in Core Dependent Haskell

Eta-equivalence in Core Dependent Haskell Eta-equivalence in Core Dependent Haskell You should machine-check your proofs Stephanie Weirich University of Pennsylvania Core Dependent Haskell A Specification for Dependent Types in Haskell Stephanie

More information

Uniqueness Typing Redefined

Uniqueness Typing Redefined Uniqueness Typing Redefined Edsko de Vries 1, Rinus Plasmeijer 2, and David Abrahamson 1 1 Trinity College Dublin, Ireland, {devriese,david}@cs.tcd.ie 2 Radboud Universiteit Nijmegen, Netherlands, rinus@cs.ru.nl

More information

The DOT Calculus. (Dependent Object Types) Nada Amin. June 18, Scala Days

The DOT Calculus. (Dependent Object Types) Nada Amin. June 18, Scala Days The DOT Calculus (Dependent Object Types) Nada Amin Scala Days June 18, 2014 1 DOT: Dependent Object Types DOT is a core calculus for path-dependent types. Goals simplify Scala s type system by desugaring

More information

From IMP to Java. Andreas Lochbihler. parts based on work by Gerwin Klein and Tobias Nipkow ETH Zurich

From IMP to Java. Andreas Lochbihler. parts based on work by Gerwin Klein and Tobias Nipkow ETH Zurich From IMP to Java Andreas Lochbihler ETH Zurich parts based on work by Gerwin Klein and Tobias Nipkow 2015-07-14 1 Subtyping 2 Objects and Inheritance 3 Multithreading 1 Subtyping 2 Objects and Inheritance

More information

Foo A Minimal Modern OO Calculus

Foo A Minimal Modern OO Calculus Foo A Minimal Modern OO Calculus Prodromos Gerakios George Fourtounis Yannis Smaragdakis Department of Informatics University of Athens {pgerakios,gfour,smaragd}@di.uoa.gr 1 / 24 What A core OO calculus

More information

A Type System for Functional Traversal-Based Aspects

A Type System for Functional Traversal-Based Aspects A Type System for Functional Traversal-Based Aspects Bryan Chadwick College of Computer & Information Science Northeastern University, 360 Huntington Avenue Boston, Massachusetts 02115 USA chadwick@ccs.neu.edu

More information

Exercise 1 ( = 18 points)

Exercise 1 ( = 18 points) 1 Exercise 1 (4 + 5 + 4 + 5 = 18 points) The following data structure represents polymorphic binary trees that contain values only in special Value nodes that have a single successor: data Tree a = Leaf

More information

M. Snyder, George Mason University LAMBDA CALCULUS. (untyped)

M. Snyder, George Mason University LAMBDA CALCULUS. (untyped) 1 LAMBDA CALCULUS (untyped) 2 The Untyped Lambda Calculus (λ) Designed by Alonzo Church (1930s) Turing Complete (Turing was his doctoral student!) Models functions, always as 1-input Definition: terms,

More information

2 Blending static and dynamic typing

2 Blending static and dynamic typing 2 Blending static and dynamic typing We begin this chapter presenting a little bit of the history behind combining static and dynamic typing in the same language. Then, we introduce optional type systems

More information

Formal Systems and their Applications

Formal Systems and their Applications Formal Systems and their Applications Dave Clarke (Dave.Clarke@cs.kuleuven.be) Acknowledgment: these slides are based in part on slides from Benjamin Pierce and Frank Piessens 1 Course Overview Introduction

More information

Symmetry in Type Theory

Symmetry in Type Theory Google May 29th, 2012 What is Symmetry? Definition Symmetry: Two or more things that initially look distinct, may actually be instances of a more general underlying principle. Why do we care? Simplicity.

More information

CSE-321 Programming Languages 2011 Final

CSE-321 Programming Languages 2011 Final Name: Hemos ID: CSE-321 Programming Languages 2011 Final Prob 1 Prob 2 Prob 3 Prob 4 Prob 5 Prob 6 Total Score Max 15 15 10 17 18 25 100 There are six problems on 18 pages in this exam, including one extracredit

More information

Recursive Types and Subtyping

Recursive Types and Subtyping Recursive Types and Subtyping #1 One-Slide Summary Recursive types (e.g., list) make the typed lambda calculus as powerful as the untyped lambda calculus. If is a subtype of then any expression of type

More information

Part III. Chapter 15: Subtyping

Part III. Chapter 15: Subtyping Part III Chapter 15: Subtyping Subsumption Subtype relation Properties of subtyping and typing Subtyping and other features Intersection and union types Subtyping Motivation With the usual typing rule

More information

Practical Affine Types and Typestate-Oriented Programming

Practical Affine Types and Typestate-Oriented Programming Practical Affine Types and Typestate-Oriented Programming Philipp Haller KTH Royal Institute of Technology Stockholm, Sweden Dagstuhl Seminar 17051 Theory and Applications of Behavioural Types Schloss

More information

Recursive Types and Subtyping

Recursive Types and Subtyping Recursive Types and Subtyping #1 One-Slide Summary Recall: Recursive types (e.g., τ list) make the typed lambda calculus as powerful as the untyped lambda calculus. If τ is a subtype of σ then any expression

More information

Programming Languages Assignment #7

Programming Languages Assignment #7 Programming Languages Assignment #7 December 2, 2007 1 Introduction This assignment has 20 points total. In this assignment, you will write a type-checker for the PolyMinML language (a language that is

More information

1 Introduction. 3 Syntax

1 Introduction. 3 Syntax CS 6110 S18 Lecture 19 Typed λ-calculus 1 Introduction Type checking is a lightweight technique for proving simple properties of programs. Unlike theorem-proving techniques based on axiomatic semantics,

More information

Static Use Based Object Confinement. Christian Skalka and Scott Smith The Johns Hopkins University

Static Use Based Object Confinement. Christian Skalka and Scott Smith The Johns Hopkins University Static Use Based Object Confinement Christian Skalka and Scott Smith The Johns Hopkins University Object confinement: what is it? Object confinement is concerned with the encapsulation, or protection,

More information

CSE-321 Programming Languages 2010 Final

CSE-321 Programming Languages 2010 Final Name: Hemos ID: CSE-321 Programming Languages 2010 Final Prob 1 Prob 2 Prob 3 Prob 4 Prob 5 Prob 6 Total Score Max 18 28 16 12 36 40 150 There are six problems on 16 pages, including two work sheets, in

More information

Higher-Order Intensional Type Analysis. Stephanie Weirich Cornell University

Higher-Order Intensional Type Analysis. Stephanie Weirich Cornell University Higher-Order Intensional Type Analysis Stephanie Weirich Cornell University Reflection A style of programming that supports the run-time discovery of program information. What does this code do? How is

More information

TYPE INFERENCE. François Pottier. The Programming Languages Mentoring ICFP August 30, 2015

TYPE INFERENCE. François Pottier. The Programming Languages Mentoring ICFP August 30, 2015 TYPE INFERENCE François Pottier The Programming Languages Mentoring Workshop @ ICFP August 30, 2015 What is type inference? What is the type of this OCaml function? let f verbose msg = if verbose then

More information

Typed Lambda Calculus. Chapter 9 Benjamin Pierce Types and Programming Languages

Typed Lambda Calculus. Chapter 9 Benjamin Pierce Types and Programming Languages Typed Lambda Calculus Chapter 9 Benjamin Pierce Types and Programming Languages t ::= x x. t t t Call-by-value small step perational Semantics terms variable v ::= values abstraction x. t abstraction values

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Type Systems, Names and Binding CMSC 330 - Spring 2013 1 Topics Covered Thus Far! Programming languages Ruby OCaml! Syntax specification Regular expressions

More information

Programming Languages Fall 2014

Programming Languages Fall 2014 Programming Languages Fall 2014 Lecture 7: Simple Types and Simply-Typed Lambda Calculus Prof. Liang Huang huang@qc.cs.cuny.edu 1 Types stuck terms? how to fix it? 2 Plan First I For today, we ll go back

More information

Adam Chlipala University of California, Berkeley ICFP 2006

Adam Chlipala University of California, Berkeley ICFP 2006 Modular Development of Certified Program Verifiers with a Proof Assistant Adam Chlipala University of California, Berkeley ICFP 2006 1 Who Watches the Watcher? Program Verifier Might want to ensure: Memory

More information

Second-Order Type Systems

Second-Order Type Systems #1 Second-Order Type Systems Homework 5 Summary Student : 37.9704 Student : 44.4466 ORIGINAL : 50.2442 Student : 50.8275 Student : 50.8633 Student : 50.9181 Student : 52.1347 Student : 52.1633 Student

More information

GADTs meet Subtyping

GADTs meet Subtyping GADTs meet Subtyping Gabriel Scherer, Didier Rémy Gallium INRIA 2014 Gabriel Scherer, Didier Rémy (Gallium INRIA) GADTs meet Subtyping 2014 1 / 21 A reminder on GADTs GADTs are algebraic data types that

More information

Programming Languages Lecture 14: Sum, Product, Recursive Types

Programming Languages Lecture 14: Sum, Product, Recursive Types CSE 230: Winter 200 Principles of Programming Languages Lecture 4: Sum, Product, Recursive Types The end is nigh HW 3 No HW 4 (= Final) Project (Meeting + Talk) Ranjit Jhala UC San Diego Recap Goal: Relate

More information

CMSC 631 Program Analysis and Understanding. Dynamic Typing, Contracts, and Gradual Typing

CMSC 631 Program Analysis and Understanding. Dynamic Typing, Contracts, and Gradual Typing CMSC 631 Program Analysis and Understanding Dynamic Typing, Contracts, and Gradual Typing Static vs. Dynamic Typing Languages with Static Typing Examples: Ocaml, Java, C#, Scala, Haskell Typechecker proves

More information

CSE-321 Programming Languages 2012 Midterm

CSE-321 Programming Languages 2012 Midterm Name: Hemos ID: CSE-321 Programming Languages 2012 Midterm Prob 1 Prob 2 Prob 3 Prob 4 Prob 5 Prob 6 Total Score Max 14 15 29 20 7 15 100 There are six problems on 24 pages in this exam. The maximum score

More information

CMSC 336: Type Systems for Programming Languages Lecture 5: Simply Typed Lambda Calculus Acar & Ahmed January 24, 2008

CMSC 336: Type Systems for Programming Languages Lecture 5: Simply Typed Lambda Calculus Acar & Ahmed January 24, 2008 CMSC 336: Type Systems for Programming Languages Lecture 5: Simply Typed Lambda Calculus Acar & Ahmed January 24, 2008 Contents 1 Solution to the Exercise 1 1.1 Semantics for lambda calculus.......................

More information

Interlanguage Migration

Interlanguage Migration Interlanguage Migration From Scripts to Programs Sam Tobin-Hochstadt and Matthias Felleisen Northeastern University DLS 2006 1 A Story 2 About a programmer 3 Who needed to manage his budget 4 And so, he

More information

CSE-321 Programming Languages 2014 Final

CSE-321 Programming Languages 2014 Final Name: Hemos ID: CSE-321 Programming Languages 2014 Final Problem 1 Problem 2 Problem 3 Problem 4 Problem 5 Problem 6 Total Score Max 15 12 14 14 30 15 100 There are six problems on 12 pages in this exam.

More information

Simon Peyton Jones Microsoft Research August 2012

Simon Peyton Jones Microsoft Research August 2012 Simon Peyton Jones Microsoft Research August 2012 A functional language Purely functional Lazy Statically typed Designed 1988-1990 By a committee For research, teaching, and practical use Geeks Practitioners

More information

Where is ML type inference headed?

Where is ML type inference headed? 1 Constraint solving meets local shape inference September 2005 2 Types are good A type is a concise description of the behavior of a program fragment. Typechecking provides safety or security guarantees.

More information

Part III Chapter 15: Subtyping

Part III Chapter 15: Subtyping Part III Chapter 15: Subtyping Subsumption Subtype relation Properties of subtyping and typing Subtyping and other features Intersection and union types Subtyping Motivation With the usual typing rule

More information

CS 6110 S11 Lecture 25 Typed λ-calculus 6 April 2011

CS 6110 S11 Lecture 25 Typed λ-calculus 6 April 2011 CS 6110 S11 Lecture 25 Typed λ-calculus 6 April 2011 1 Introduction Type checking is a lightweight technique for proving simple properties of programs. Unlike theorem-proving techniques based on axiomatic

More information

Why Types Matter. Zheng Gao CREST, UCL

Why Types Matter. Zheng Gao CREST, UCL Why Types Matter Zheng Gao CREST, UCL Russell s Paradox Let R be the set of all sets that are not members of themselves. Is R a member of itself? If so, this contradicts with R s definition If not, by

More information

Provably Correct Software

Provably Correct Software Provably Correct Software Max Schäfer Institute of Information Science/Academia Sinica September 17, 2007 1 / 48 The Need for Provably Correct Software BUT bugs are annoying, embarrassing, and cost gazillions

More information

A New Foundation for Generic Programming

A New Foundation for Generic Programming Ord List A ) in The Implicit Calculus nt ) [[2, 5], [1, 3]] A New Foundation for Generic Programming 1 (presenter), Tom 2, Bruno C. d.{?(ord S.?(Ord Oliveira Schrijvers List Int with List Int )} List Int

More information

Topics Covered Thus Far. CMSC 330: Organization of Programming Languages. Language Features Covered Thus Far. Programming Languages Revisited

Topics Covered Thus Far. CMSC 330: Organization of Programming Languages. Language Features Covered Thus Far. Programming Languages Revisited CMSC 330: Organization of Programming Languages Type Systems, Names & Binding Topics Covered Thus Far Programming languages Syntax specification Regular expressions Context free grammars Implementation

More information

Polymorphic lambda calculus Princ. of Progr. Languages (and Extended ) The University of Birmingham. c Uday Reddy

Polymorphic lambda calculus Princ. of Progr. Languages (and Extended ) The University of Birmingham. c Uday Reddy 06-02552 Princ. of Progr. Languages (and Extended ) The University of Birmingham Spring Semester 2016-17 School of Computer Science c Uday Reddy2016-17 Handout 6: Polymorphic Type Systems 1. Polymorphic

More information

The DOT Calculus. (Dependent Object Types) Nada Amin. May 12, flatmap(oslo)

The DOT Calculus. (Dependent Object Types) Nada Amin. May 12, flatmap(oslo) The DOT Calculus (Dependent Object Types) Nada Amin flatmap(oslo) May 12, 2014 1 Types in Scala and DOT 2 Types in Scala modular named type scala.collection.bitset compound type Channel with Logged refined

More information

Well-typed programs can t be blamed

Well-typed programs can t be blamed Well-typed programs can t be blamed Philip Wadler University of Edinburgh Robert Bruce Findler University of Chicago Abstract We show how contracts with blame fit naturally with recent work on hybrid types

More information

Faith, Evolution, and Programming Languages. Philip Wadler University of Edinburgh

Faith, Evolution, and Programming Languages. Philip Wadler University of Edinburgh Faith, Evolution, and Programming Languages Philip Wadler University of Edinburgh Evolution Multiculturalism Part I Church: The origins of faith Gerhard Gentzen (1909 1945) Gerhard Gentzen (1935) Natural

More information

An Approach to Behavioral Subtyping Based on Static Analysis

An Approach to Behavioral Subtyping Based on Static Analysis TACoS 04 Preliminary Version An Approach to Behavioral Subtyping Based on Static Analysis Francesco Logozzo 1 STIX - École Polytechnique F-91128 Palaiseau, France Abstract In mainstream object oriented

More information

Types. Type checking. Why Do We Need Type Systems? Types and Operations. What is a type? Consensus

Types. Type checking. Why Do We Need Type Systems? Types and Operations. What is a type? Consensus Types Type checking What is a type? The notion varies from language to language Consensus A set of values A set of operations on those values Classes are one instantiation of the modern notion of type

More information

Types for References, Exceptions and Continuations. Review of Subtyping. Γ e:τ τ <:σ Γ e:σ. Annoucements. How s the midterm going?

Types for References, Exceptions and Continuations. Review of Subtyping. Γ e:τ τ <:σ Γ e:σ. Annoucements. How s the midterm going? Types for References, Exceptions and Continuations Annoucements How s the midterm going? Meeting 21, CSCI 5535, Spring 2009 2 One-Slide Summary Review of Subtyping If τ is a subtype of σ then any expression

More information