Type assignment for intersections and unions in call-by-value languages
|
|
- Philomena Matthews
- 5 years ago
- Views:
Transcription
1 Type assignment for intersections and unions in call-by-value languages Joshua Dunfield and Frank Pfenning Triple Project Carnegie Mellon University 8 April 2003 FOSSACS 03, Warsaw, Poland Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.1/42
2 Outline Motivation Language Datasort refinements Index refinements Intersections Indefinite types Related work Conclusion & future work Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.2/42
3 Motivation Conventional type systems: ML, Java,... Tractable and easy to use Limited expressive power Refined type systems: Tractable and easy to use Better expressive power Fully dependent type systems: Nuprl,... Undecidable Extremely expressive Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.3/42
4 Push the envelope The goal of the Triple Project: create refined type systems. The present work: Persistent refinements of algebraic datatypes Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.4/42
5 Type Assignment A type assignment system a la Curry Terms do not contain types Undecidable A bidirectional system Terms contain some type annotations Two judgments: inference e A, checking e A. This paper: Type assignment only Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.5/42
6 Property Types Some types build values Example: tuples Others talk about values Example: parametric polymorphism α. α α describing behavior of the identity fn We call the latter property types Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.6/42
7 Property Types In our system: δ(i): Datasort and index refinement : Intersection: v : A B means v has type A and type B : Greatest type (0-ary ) Π: Universal quantifier over indices (infinitary ) : Union: v : A B means v has type A or type B : Empty type (0-ary ) Σ: Existential quantifier over indices (infinitary ) Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.7/42
8 Language Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.8/42
9 Language + Initial Typing A, B, C, D ::= 1 A B e ::= x f () λx. e e 1 (e 2 ) fix f. e B 1 A 1 A 2 B 2 A 1 A 2 B 1 B 2 ( ) 1 1 (1) Γ(x) = A Γ x : A (var) Γ(f) = A Γ f : A (fixvar) Γ e : A A B Γ e : B (sub) Γ e 1 : A B Γ e 2 : A Γ e 1 (e 2 ) : B ( E) Γ, x:a e : B Γ λx. e : A B ( I) Γ, f:a e : A Γ fix f. e : A (fix) Γ () : 1 (1I) Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.9/42
10 cbv Semantics Values v ::= x () λx. e Evaluation contexts E ::= [] E(e) v(e) e R e E[e ] E[e ] (λx. e) v R fix f. e R [v/x] e [fix f. e / f] e Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.10/42
11 Key Properties A practical type system should satisfy Preservation: If e : A and e e then e : A. Progress: If e : A then e is a value or e. e e. Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.11/42
12 Datasort Refinements a.k.a. refinement types (Freeman, Pfenning, Davies) Refine an algebraic datatype by a datasort δ Example: Lists of integers Nil : 1 list Cons : int list list Intersections essential Nil : 1 even Cons : (int odd even) δ : (int even odd) (int list list) list odd 6 even Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.12/42
13 Index Refinements a.k.a. dependent types restricted to a decidable constraint domain (Xi & Pfenning) Refine an algebraic datatype by an index Indices drawn from any decidable constraint domain, here N Example: Lists indexed by their length Nil : 1 list Cons : int list list Nil : 1 list(0) Cons : Πa:N. int list(a) list(a + 1) Example: append : Πa:N. Πb:N. list(a) list(b) list(a+b) Universal quantifier Π essential Existential quantifier Σ also essential Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.13/42
14 Intersection Types Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.14/42
15 Typing Intersections Typing: Γ e : A 1 A 2 Γ e : A 1 ( E 1 ) Γ e : A 1 A 2 Γ e : A 2 ( E 2 ) Γ e : A 1 Γ e : A 2 Γ e : A 1 A 2 ( I) ( I) unsound with mutable references. Γ v : A 1 Γ v : A 2 Γ v : A 1 A 2 ( I) The fix: a value restriction [Davies & Pfenning 00]. Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.15/42
16 Indefinite Types Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.16/42
17 Indefinite Types: Motivation filter : (int bool) list list filter : Πa:N. (int bool) list(a) list( ) filter : Πa:N. (int bool) list(a) (Σb:N. list(b)) Σb:N. B quantifies existentially over b in B [Xi & Pfenning] Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.17/42
18 Indefinite Types: Motivation Definitely need Σ The binary analogue of Σ is the union type Need? Possibly just a convenience Issues similar for both, but easier to talk about Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.18/42
19 Union Types Introduction rules straightforward: Γ e : A Γ e : A B ( I 1) Elimination rule? Γ e : B Γ e : A B ( I 2) Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.19/42
20 Rough Road Recall: for, introduction rule ( I) was tricky Duality suggests ( E) will be interesting too Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.20/42
21 Elimination Want to reason by cases: For x : A B, show for x : A and for x : B. Substitution approach (e.g. [MacQueen et al. 86]), reminiscent of natural deduction: Γ, x:a e : C Γ e : A B Γ, x:b e : C Γ [e /x] e : C Suppose Γ h : (A C) (B C), Γ v : A B Γ v : A B Γ, x:a h x : C Γ, x:b h x : C Γ h v : C Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.21/42
22 Elimination Γ e : A B Γ [e /x] e : C Γ, x:a e : C Γ, x:b e : C Consider a nondeterministic choice e 1 e 2 : e 1 e 2 e 1 e 1 e 2 e 2 Suppose Γ g : (A A C) (B B C), Γ y : A, Γ z : B. Γ y z : A B Γ, x:a g x x : C Γ, x:b g x x : C Γ g (y z) (y z) : C g (y z) (y z) g y (y z) g y z Unsound whenever a term evaluates to more than one value Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.22/42
23 Elimination Γ e : A B Γ [e /x] e : C Γ, x:a e : C Γ, x:b e : C Restrict to exactly one occurrence of e? Can fail if e inside a λ (see paper) Restrict e to a value? [van Bakel 99] Sound but still must guess occurrences of e Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.23/42
24 Elimination: Our Solution Γ e : A B Γ E[e ] : C Γ, x:a E[x] : C Γ, x:b E[x] : C ( E) Exactly one e, in evaluation position So e is the next thing to be evaluated Remainder of computation (E) on the result of e Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.24/42
25 The Empty Type is the empty or void type A ( L) Elimination rule: by analogy with ( E) Γ e : Γ E[e ] : C ( E) Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.25/42
26 A Generalization? Must we restrict the rules to an evaluation context? Or could we also allow cases where e must be evaluated exactly once but might not be in evaluation position? Γ e : e eval d exactly once in e Γ e : C... let ω = (fix f. f). Then ω :. Γ ω : Γ (()())ω : C But ()() is not a value and does not step Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.26/42
27 Type Safety Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.27/42
28 Type Safety Γ e : A B Γ E[e ] : C Γ, x:a E[x] : C Γ, x:b E[x] : C ( E) Preservation and progress hold with δ, i,,, Π,,, Σ Lemma: Values always have definite types. v : If v : A B then v : A or v : B If v : Σa:N. A then v : [i/a] A for some i Above: a special case of the actual lemma (Fully written out for δ, i,, Π in [Dunfield 02]) Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.28/42
29 Closely Related Work Davies 97, 00* δ, ; Dunfield 02 δ, i,, Π; Xi 98, 99*, 00 i, Π, Σ; * & Pfenning This paper* δ, i,, Π,,, Σ, ; : Ongoing work δ, i,, Π,,, Σ, ; Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.29/42
30 Related Work [Coppo et al. 81]: can characterize normal forms (termination); hence undecidable [Reynolds 96]: FORSYTHE with (& type annotations) [Pierce 91]: Language with,, syntactic markers [Barbanera et al. 95]: With unrestricted -elim rule, types not preserved under β-reduction [Wells et al. 02], [Palsberg & Pavlopoulou 01]:, for control flow analysis Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.30/42
31 Conclusion Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.31/42
32 Summary Goal: express more invariants Two especially useful refinements already developed: Datasort refinements Index refinements Refinements motivate,, Π, Σ ( I): Value restriction ( E): Eval. context restriction Type safety The present system: Undecidable, hence impractical Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.32/42
33 Future Work Bidirectional formulation Let-normal form Mutable references Implementation Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.33/42
34 Acknowledgments National Science Foundation: CCR : Type Refinements; : ITR/SY+SI: Language Technology for Trustless Software Dissemination; Graduate Research Fellowship Feedback on the paper: Brigitte Pientka and the anonymous referees Feedback on the talk: Aleksey Kliger, Stephen Magill, Jonathan Moody, Frank Pfenning : Henrik Christian Grove, available at a CTAN mirror near you Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.34/42
35 The End Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.35/42
36 Intersections: Subtyping Subtyping: A B 1 A B 2 A B 1 B 2 A 1 B A 1 A 2 B ( L 1) Distributivity? ( R) A 2 B A 1 A 2 B ( L 2) (A B) (A B ) A (B B ) Again unsound with mutable references. [Davies & Pfenning 00] Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.36/42
37 Unions: Subtyping Subtyping for just the dual of : A 1 B A 2 B A 1 A 2 B ( L) A B 1 A B 1 B 2 ( R 1 ) A B 2 A B 1 B 2 ( R 2 ) Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.37/42
38 Formulating Refinements P ::= i. = j... Γ ::= Γ, x:a Γ, a:γ Γ, P e ::=... c(e) case e of ms v ::=... c(v) E ::=... c(e) case E of ms Atomic subtyping δ 1 δ 2 Γ i =. j Γ δ 1 (i) δ 2 (j) (δ) Γ c : A δ(i) Γ e : A Γ c(e) : δ(i) (δi) Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.38/42
39 Formulating Refinements Atomic subtyping δ 1 δ 2 Γ i =. j Γ δ 1 (i) δ 2 (j) (δ) Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.39/42
40 Evaluation Order Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.40/42
41 Evaluation Order Binary and 0-ary indefinite type elim rules: Γ e : A B Γ E[e ] : C Γ, x:a E[x] : C Γ, x:b E[x] : C A corresponding unary rule? ( E) Γ e : A Γ, x:a E[x] : C Γ E[e ] : C Γ e : Γ E[e ] : C ( E) (direct) Actually a derivable rule: ( E) with A A But not derivable in a bidirectional system Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.41/42
42 Evaluation Order Γ e : A Γ, x:a E[x] : C Γ E[e ] : C (direct) Rule needed so that Π s can be instantiated with existential Σ index variables Problem first recognized by Xi Formulated a translation to let-normal form Added good programs, but removed them too Current work: a sound, complete let-normal translation Type assignment for intersections and unions in call-by-value languages FOSSACS 03 p.42/42
Type Assignment for Intersections and Unions in Call-by-Value Languages
Type Assignment for Intersections and Unions in Call-by-Value Languages Joshua Dunfield and Frank Pfenning Department of Computer Science Carnegie Mellon University Pittsburgh, PA 15213 {joshuad,fp}@cs.cmu.edu
More informationRefined typechecking with Stardust
Refined typechecking with Stardust Joshua Dunfield Carnegie Mellon University (current affiliation: McGill University) PLPV 2007 Freiburg, Germany 5 October 2007 1 Conventional Static Typing ML, Haskell,...
More informationTridirectional Typechecking
Tridirectional Typechecking Joshua Dunfield joshuad@cs.cmu.edu Carnegie Mellon University Pittsburgh, PA Frank Pfenning fp@cs.cmu.edu ABSTRACT In prior work we introduced a pure type assignment system
More informationVerifying Program Invariants with Refinement Types
Verifying Program Invariants with Refinement Types Rowan Davies and Frank Pfenning Carnegie Mellon University Princeton and Yale Colloquium Talks February, 2001 Acknowledgments: Robert Harper 1 Overview
More informationCS152: 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 informationHarvard 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 informationReview. 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 informationProgramming 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 informationIntersections and Unions of Session Types
Intersections and Unions of Session Types Coşku Acay Frank Pfenning Carnegie Mellon University School of Computer Science ITRS 2016 C. Acay & F. Pfenning (CMU) Intersections and Unions of Session Types
More informationλ calculus is inconsistent
Content Rough timeline COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification Gerwin Klein, June Andronick, Toby Murray λ Intro & motivation, getting started [1] Foundations & Principles
More informationHarvard 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 informationProgramming 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 informationUntangling Typechecking of Intersections and Unions
Untangling Typechecking of Intersections and Unions Joshua Dunfield School of Computer Science, McGill University Montréal, Canada joshua@cs.mcgill.ca Intersection and union types denote conjunctions and
More informationGoal. 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` 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 informationGeneric polymorphism on steroids
Generic polymorphism on steroids or How to Solve the Expression Problem with Polymorphic Variants Claudio Sacerdoti Coen Dipartimento di Informatica Scienza e Ingegneria
More informationTYPE 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 informationPolymorphic 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 informationCSE-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 informationCOMP 4161 NICTA Advanced Course. Advanced Topics in Software Verification. Toby Murray, June Andronick, Gerwin Klein
COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification Toby Murray, June Andronick, Gerwin Klein λ 1 Last time... λ calculus syntax free variables, substitution β reduction α and η conversion
More informationPractical Refinement-Type Checking
Practical Refinement-Type Checking Rowan Davies CMU-CS-05-110 May, 2005 School of Computer Science Computer Science Department Carnegie Mellon University Pittsburgh, PA Thesis Committee Frank Pfenning,
More informationA Unified System of Type Refinements
A Unified System of Type Refinements Joshua Dunfield CMU-CS-07-129 School of Computer Science Carnegie Mellon University Pittsburgh, PA 15213 Thesis Committee: Frank Pfenning, chair Jonathan Aldrich Robert
More informationCLF: A logical framework for concurrent systems
CLF: A logical framework for concurrent systems Thesis Proposal Kevin Watkins Carnegie Mellon University Committee: Frank Pfenning, CMU (Chair) Stephen Brookes, CMU Robert Harper, CMU Gordon Plotkin, University
More informationCSE-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 informationLecture Notes on Aggregate Data Structures
Lecture Notes on Aggregate Data Structures 15-312: Foundations of Programming Languages Frank Pfenning Lecture 8 September 23, 2004 In this lecture we discuss various language extensions which make MinML
More informationCS 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 information1 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 informationOrnaments in ML. Thomas Williams, Didier Rémy. April 18, Inria - Gallium
Ornaments in ML Thomas Williams, Didier Rémy Inria - Gallium April 18, 2017 1 Motivation Two very similar functions let rec add m n = match m with Z n S m S (add m n) let rec append ml nl = match ml with
More informationCSCI-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 informationA Practical Optional Type System for Clojure. Ambrose Bonnaire-Sergeant
A Practical Optional Type System for Clojure Ambrose Bonnaire-Sergeant Statically typed vs. Dynamically typed Traditional distinction Dynamically typed Statically typed eg. Java, C, Haskell eg. Javascript,
More informationCSE-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 informationPart 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 informationType Checking and Type Inference
Type Checking and Type Inference Principles of Programming Languages CSE 307 1 Types in Programming Languages 2 Static Type Checking 3 Polymorphic Type Inference Version: 1.8 17:20:56 2014/08/25 Compiled
More informationOn the Logical Foundations of Staged Computation
On the Logical Foundations of Staged Computation Frank Pfenning PEPM 00, Boston, MA January 22, 2000 1. Introduction 2. Judgments and Propositions 3. Intensional Types 4. Run-Time Code Generation 5. The
More informationCombining Programming with Theorem Proving
Combining Programming with Theorem Proving Chiyan Chen and Hongwei Xi Boston University Programming with Theorem Proving p.1/27 Motivation for the Research To support advanced type systems for practical
More informationSubsumption. 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 informationPart 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 informationSubtyping and Objects
Subtyping and Objects Massimo Merro 20 November 2017 Massimo Merro Data and Mutable Store 1 / 22 Polymorphism So far, our type systems are very rigid: there is little support to code reuse. Polymorphism
More informationThis section is primarily based on Principles of Type Refinement, Noam Zeilberger,
1 Refinement Types This section is primarily based on Principles of Type Refinement, Noam Zeilberger, OPLSS 2016 The concept of refinement types is quite general. So general, in fact, that it is not immediately
More informationType Systems. Parametric Polymorphism. 1. Recall Let-Polymorphism. 1. Recall Let-Polymorphism. Lecture 9 Dec. 15th, 2004 Sebastian Maneth
Today Parametric Polymorphism Type Systems Lecture 9 Dec. 15th, 2004 Sebastian Maneth 1. Recall Let-Polymorphism 4. System F-sub 5. Properties of F-sub http://lampwww.epfl.ch/teaching/typesystems/2004
More informationKripke-Style Contextual Modal Type Theory
Kripke-Style Contextual Modal Type Theory YUITO MURASE THE UNIVERSITY OF TOKYO Agenda Background Logic Type System Future Plan/Related Work Background: Syntactical Metaprogramming Extend the syntax of
More informationTyping & Static Analysis of Multi-Staged Programs
Typing & Static Analysis of Multi-Staged Programs School of Computer Science & Engineering Seoul National University 6/7/2011 @ Oxford U (co-work with I. Kim, W. Choi, B. Aktemur, C. Calcagno, M. Tatsuda)
More informationA Substructural Type System for Delimited Continuations
1 A Substructural Type System for Delimited Continuations Oleg Kiselyov (FNMOC) Chung-chieh Shan (Rutgers University) TLCA June 27, 2007 ? 2 Summary Small-step abstract interpretation type systems for
More informationTracing 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 informationThe Logical Basis of Evaluation Order & Pattern-Matching
The Logical Basis of Evaluation Order & Pattern-Matching Noam Zeilberger Thesis Defense April 17, 2009 Frank Pfenning (chair) Peter Lee Robert Harper Paul-André Melliès (Paris VII) A remarkable analogy
More informationSubtyping. 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 informationCS-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 informationLambda 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 informationWhere 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 informationPolymorphism and System-F (OV)
Polymorphism and System-F (OV) Theorie der Programmierung SoSe 2014 FAU the occurrence of something in several different forms Polymorphism? Polymorphic systems Type systems that allow a single piece of
More informationLists. Michael P. Fourman. February 2, 2010
Lists Michael P. Fourman February 2, 2010 1 Introduction The list is a fundamental datatype in most functional languages. ML is no exception; list is a built-in ML type constructor. However, to introduce
More informationA Polymorphic Type System for Multi-Staged Languages
A Polymorphic Modal Type System for Lisp-like Multi-Staged Languages Ik-Soon Kim 1 Kwangkeun Yi 1 Cristiano Calcagno 2 1 Seoul National University 2 Imperial College POPL 06, 1/12/2006 @ Charleston Outline
More informationTypes 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 informationProgramming 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 informationLecture Notes on Data Representation
Lecture Notes on Data Representation 15-814: Types and Programming Languages Frank Pfenning Lecture 9 Tuesday, October 2, 2018 1 Introduction In this lecture we ll see our type system in action. In particular
More informationHiding local state in direct style: a higher-order anti-frame rule
1 / 65 Hiding local state in direct style: a higher-order anti-frame rule François Pottier January 28th, 2008 2 / 65 Contents Introduction Basics of the type system A higher-order anti-frame rule Applications
More informationSoftwaretechnik. Lecture 03: Types and Type Soundness. Peter Thiemann. University of Freiburg, Germany SS 2008
Softwaretechnik Lecture 03: Types and Type Soundness Peter Thiemann University of Freiburg, Germany SS 2008 Peter Thiemann (Univ. Freiburg) Softwaretechnik SWT 1 / 35 Table of Contents Types and Type correctness
More informationAgenda. CS301 Session 11. Common type constructors. Things we could add to Impcore. Discussion: midterm exam - take-home or inclass?
Agenda CS301 Session 11 Discussion: midterm exam - take-home or inclass? Interlude: common type constructors Type soundness 1 2 Things we could add to Impcore Common type constructors Array is a type constructor,
More informationConstrained Types and their Expressiveness
Constrained Types and their Expressiveness JENS PALSBERG Massachusetts Institute of Technology and SCOTT SMITH Johns Hopkins University A constrained type consists of both a standard type and a constraint
More informationCSE 505, Fall 2008, Final Examination 11 December Please do not turn the page until everyone is ready.
CSE 505, Fall 2008, Final Examination 11 December 2008 Please do not turn the page until everyone is ready. Rules: The exam is closed-book, closed-note, except for one side of one 8.5x11in piece of paper.
More informationHOL DEFINING HIGHER ORDER LOGIC LAST TIME ON HOL CONTENT. Slide 3. Slide 1. Slide 4. Slide 2 WHAT IS HIGHER ORDER LOGIC? 2 LAST TIME ON HOL 1
LAST TIME ON HOL Proof rules for propositional and predicate logic Safe and unsafe rules NICTA Advanced Course Forward Proof Slide 1 Theorem Proving Principles, Techniques, Applications Slide 3 The Epsilon
More informationCS4215 Programming Language Implementation. Martin Henz
CS4215 Programming Language Implementation Martin Henz Thursday 26 January, 2012 2 Chapter 4 The Language simpl In this chapter, we are exting the language epl in order to provide a more powerful programming
More informationVariables. Substitution
Variables Elements of Programming Languages Lecture 4: Variables, binding and substitution James Cheney University of Edinburgh October 6, 2015 A variable is a symbol that can stand for another expression.
More informationPierce 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 informationLambda 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 informationType Reconstruction for General Refinement Types
Type Reconstruction for General Refinement Types Kenneth Knowles Cormac Flanagan University of California, Santa Cruz Abstract. General refinement types allow types to be refined by predicates written
More informationSimple 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 informationJava Wildcards Meet Definition-Site Variance
Java Wildcards Meet Definition-Site Variance John Altidor 1 Christoph Reichenbach 2,1 Yannis Smaragdakis 3,1 1 University of Massachusetts 2 Google 3 University of Athens Outline Motivation for Variance.
More informationRecency Types for Dynamically-Typed, Object-Based Languages
Recency Types for Dynamically-Typed, Object-Based Languages Phillip Heidegger, Peter Thiemann Albert-Ludwigs-Universität Freiburg 15.10.2008 Task: Maintenance Finding bugs in JavaScript programs Understanding
More informationCS558 Programming Languages
CS558 Programming Languages Fall 2017 Lecture 7b Andrew Tolmach Portland State University 1994-2017 Type Inference Some statically typed languages, like ML (and to a lesser extent Scala), offer alternative
More informationType Inference with Inequalities
Type Inference with Inequalities Michael I. Schwartzbach mis@daimi.aau.dk Computer Science Department Aarhus University Ny Munkegade DK-8000 Århus C, Denmark Abstract Type inference can be phrased as constraint-solving
More informationProgramming 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 informationThe Typed λ Calculus and Type Inferencing in ML
Notes on Types S. Arun-Kumar Department of Computer Science and Engineering Indian Institute of Technology New Delhi, 110016 email: sak@cse.iitd.ernet.in April 14, 2002 2 Chapter 1 The Typed λ Calculus
More informationSets MAT231. Fall Transition to Higher Mathematics. MAT231 (Transition to Higher Math) Sets Fall / 31
Sets MAT231 Transition to Higher Mathematics Fall 2014 MAT231 (Transition to Higher Math) Sets Fall 2014 1 / 31 Outline 1 Sets Introduction Cartesian Products Subsets Power Sets Union, Intersection, Difference
More informationCS131 Typed Lambda Calculus Worksheet Due Thursday, April 19th
CS131 Typed Lambda Calculus Worksheet Due Thursday, April 19th Name: CAS ID (e.g., abc01234@pomona.edu): I encourage you to collaborate. collaborations below. Please record your Each question is worth
More informationTypes and Programming Languages. Lecture 5. Extensions of simple types
Types and Programming Languages Lecture 5. Extensions of simple types Xiaojuan Cai cxj@sjtu.edu.cn BASICS Lab, Shanghai Jiao Tong University Fall, 2016 Coming soon Simply typed λ-calculus has enough structure
More informationCSE 505, Fall 2008, Final Examination 11 December Please do not turn the page until everyone is ready.
CSE 505, Fall 2008, Final Examination 11 December 2008 Please do not turn the page until everyone is ready. Rules: The exam is closed-book, closed-note, except for one side of one 8.5x11in piece of paper.
More informationCollage of Static Analysis
Course Outline Collage of Static Analysis 0.5hr: Static Analysis Overview 1.5hr: Static Analysis Design Framework 1.0hr: Static Analysis Engineering Framework 1.0hr: Static Analysis of Multi-Staged Programs
More informationCalculus of Inductive Constructions
Calculus of Inductive Constructions Software Formal Verification Maria João Frade Departmento de Informática Universidade do Minho 2008/2009 Maria João Frade (DI-UM) Calculus of Inductive Constructions
More informationCS 6110 S14 Lecture 1 Introduction 24 January 2014
CS 6110 S14 Lecture 1 Introduction 24 January 2014 1 Introduction What is a program? Is it just something that tells the computer what to do? Yes, but there is much more to it than that. The basic expressions
More informationModal Logic: Implications for Design of a Language for Distributed Computation p.1/53
Modal Logic: Implications for Design of a Language for Distributed Computation Jonathan Moody (with Frank Pfenning) Department of Computer Science Carnegie Mellon University Modal Logic: Implications for
More informationl e t print_name r = p r i n t _ e n d l i n e ( Name : ^ r. name)
Chapter 8 Row polymorphism Consider the following code: type name_home = {name : s t r i n g ; home : s t r i n g } type name_mobile = {name : s t r i n g ; mobile : s t r i n g } l e t jane = {name =
More informationCSE-321 Programming Languages 2010 Midterm
Name: Hemos ID: CSE-321 Programming Languages 2010 Midterm Score Prob 1 Prob 2 Prob 3 Prob 4 Total Max 15 30 35 20 100 1 1 SML Programming [15 pts] Question 1. [5 pts] Give a tail recursive implementation
More informationCS-XXX: Graduate Programming Languages. Lecture 17 Recursive Types. Dan Grossman 2012
CS-XXX: Graduate Programming Languages Lecture 17 Recursive Types Dan Grossman 2012 Where are we System F gave us type abstraction code reuse strong abstractions different from real languages (like ML),
More informationSémantique des Langages de Programmation (SemLP) DM : Region Types
Sémantique des Langages de Programmation (SemLP) DM : Region Types I) Submission Submission Date : 21/05/2017 Submission Format : Submit a virtual machine (.ova) 1 with 1. an executable of the interpreter,
More informationLet 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 informationSupplementary Notes on Recursive Types
Supplementary Notes on Recursive Types 15-312: Foundations of Programming Languages Frank Pfenning Lecture 13 October 8, 2002 In the last two lectures we have seen two critical concepts of programming
More informationCSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Sections p.
CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer Science (Arkoudas and Musser) Sections 10.1-10.3 p. 1/106 CSCI.6962/4962 Software Verification Fundamental Proof Methods in Computer
More information3 Type Inference and Optimization
3 Type Inference and Optimization The previous chapter presented a basic compiler from Lua to the CLR and some variations of it, changing the runtime representation of Lua values and the treatment of functions
More informationDependent types and program equivalence. Stephanie Weirich, University of Pennsylvania with Limin Jia, Jianzhou Zhao, and Vilhelm Sjöberg
Dependent types and program equivalence Stephanie Weirich, University of Pennsylvania with Limin Jia, Jianzhou Zhao, and Vilhelm Sjöberg What are dependent types? Types that depend on values of other types
More informationDependent types and program equivalence. Stephanie Weirich, University of Pennsylvania with Limin Jia, Jianzhou Zhao, and Vilhelm Sjöberg
Dependent types and program equivalence Stephanie Weirich, University of Pennsylvania with Limin Jia, Jianzhou Zhao, and Vilhelm Sjöberg Doing dependent types wrong without going wrong Stephanie Weirich,
More informationSubject Reduction vs Intersection / Union Types in λµ µ
Subject Reduction vs Intersection / Union Types in λµ µ Extended abstract Steffen van Bakel Department of Computing, Imperial College London, 180 Queen s Gate, London SW7 2BZ, UK, svb@doc.ic.ac.uk Abstract.
More informationGradual 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 informationATS: a language to make typeful programming real and fun
ATS: a language to make typeful programming real and fun p.1/32 ATS: a language to make typeful programming real and fun Hongwei Xi Boston University Work partly funded by NSF grant CCR-0229480 ATS: a
More informationGADTs 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 informationProgramming Language Concepts: Lecture 19
Programming Language Concepts: Lecture 19 Madhavan Mukund Chennai Mathematical Institute madhavan@cmi.ac.in http://www.cmi.ac.in/~madhavan/courses/pl2009 PLC 2009, Lecture 19, 01 April 2009 Adding types
More informationFlang typechecker Due: February 27, 2015
CMSC 22610 Winter 2015 Implementation of Computer Languages I Flang typechecker Due: February 27, 2015 Project 3 February 9, 2015 1 Introduction The third project is to implement a type checker for Flang,
More informationBeluga: A Framework for Programming and Reasoning with Deductive Systems (System Description)
Beluga: A Framework for Programming and Reasoning with Deductive Systems (System Description) Brigitte Pientka and Joshua Dunfield McGill University, Montréal, Canada {bpientka,joshua}@cs.mcgill.ca Abstract.
More informationConsistent Subtyping for All
Consistent Subtyping for All Ningning Xie Xuan Bi Bruno C. d. S. Oliveira 11 May, 2018 The University of Hong Kong 1 Background There has been ongoing debate about which language paradigm, static typing
More informationCIS 500 Software Foundations Fall December 6
CIS 500 Software Foundations Fall 2006 December 6 Administrivia Administrivia No recitations this week Extra office hours will be posted to the class mailing list Exam: Wednesday, Dec 20, 9 11 Location:
More information