A Substructural Type System for Delimited Continuations
|
|
- Shanon Rich
- 5 years ago
- Views:
Transcription
1 1 A Substructural Type System for Delimited Continuations Oleg Kiselyov (FNMOC) Chung-chieh Shan (Rutgers University) TLCA June 27, 2007
2 ? 2
3 Summary Small-step abstract interpretation type systems for ((delimited) control) effects formalize as a substructural logic Slogan Types are abstract expressions (Cousot) The colon is a turnstile (Lambek) 3
4 Outline Delimited continuations Answer types Types as abstract interpretation Substructural logic The λξ 0 -calculus with small-step typing 4
5 Reset # is the identity continuation (reset [ ]). $ plugs in a term. # $ Goldilocks said: (# $ This porridge is too hot. ) # $ Goldilocks said: (# $ This porridge is too hot. ) # $ Goldilocks said: (# $ This porridge is too hot. ) # $ Goldilocks said: This porridge is too hot. # $ Goldilocks said: This porridge is too hot. Goldilocks said: This porridge is too hot. 5
6 Shift 0 ξ 0 k. removes and binds k to a continuation. # $ Goldilocks said: (# $ This porridge is (ξ 0 k.(k $ too hot ) (k $ too cold ) (k $ just right )). ) # $ Goldilocks said: ((# $ This porridge is too hot. ) (# $ This porridge is too cold. ) (# $ This porridge is just right. )) Goldilocks said: This porridge is too hot. This porridge is too cold. This porridge is just right. 6
7 Applications Try/catch/reset; throw/abort. # $ Goldilocks said: (# $ Porridge (ξ 0 k. Ouch! ) is my favorite food. ) # $ Goldilocks said: Ouch! 7
8 Applications Try/catch/reset; throw/abort. # $ Goldilocks said: (# $ Porridge (ξ 0 k. Ouch! ) is my favorite food. ) # $ Goldilocks said: Ouch! Delimited continuations are useful for: backtracking search representing monads CPS transformation partial evaluation Web interactions mobile code linguistics We need multiple answer types, not just string. 7
9 8 Outline Delimited continuations Answer types Types as abstract interpretation Substructural logic The λξ 0 -calculus with small-step typing
10 Answer types in the CPS transformation 1 < 2 { (bool T) T }} { λk. (int T) T {}}{ (λk. k1) (λx. (int T) T {}}{ (λk. k2) (λy. k(x < y) }{{} )) } {{ T } } {{ T } T 9
11 Answer types in the CPS transformation 1 < 2 { (bool T) T }} { λk. (int T) T {}}{ (λk. k1) (λx. (int T) T {}}{ (λk. k2) (λy. k(x < y) }{{} )) } {{ T } } {{ T } T 9
12 Answer types in the CPS transformation 1 < 2 { (bool T) T }} { λk. (int T) T {}}{ (λk. k1) (λx. (int T) T {}}{ (λk. k2) (λy. k(x < y) }{{} )) } {{ T } } {{ T } T 9
13 Answer types in the CPS transformation 1 < 2 (ξ 0 k. Ouch! ) < 2 { (bool T) string }} { λk. (int T) string {}}{ (λk. Ouch! ) (λx. (int T) T {}}{ (λk. k2) (λy. k(x < y) }{{} )) } {{ T } } {{ T } string 9
14 Answer types in the CPS transformation 1 < 2 (ξ 0 k. Ouch! ) < 2 1 < (ξ 0 k. c ) { (bool T) char }} { (int char) char {}}{ (int T) char {}}{ λk. (λk. k1) (λx. (λk. c ) (λy. k(x < y) }{{} )) } {{ T } } {{ char } char 9
15 Answer types in the CPS transformation 1 < 2 (ξ 0 k. Ouch! ) < 2 1 < (ξ 0 k. c ) (ξ 0 k. Ouch! ) < (ξ 0 k. c ) { (bool T) string }} { (int char) string {}}{ (int T) char {}}{ λk. (λk. Ouch! ) (λx. (λk. c ) (λy. k(x < y) }{{} )) } {{ T } } {{ char } string Evaluation order chains together initial and final answer types. 9
16 10 Desideratum 1: Changing the answer type Need to change the answer type to: create functions find list prefixes represent parameterized monads analyze questions and polarity in natural language Ghani & Johann, generalized continuations yesterday newtype Ran g h a = Ran ( b. (a g b) h b)
17 Desideratum 1: Changing the answer type Need to change the answer type to: create functions find list prefixes represent parameterized monads analyze questions and polarity in natural language Ghani & Johann, generalized continuations yesterday newtype Ran g h a = Ran ( b. (a g b) h b) For example (Danvy & Filinski): [x σ]ρ, α E : τ, β ρ, δ λx. E : (σ/α τ/β), δ. The 4-ary type constructor / / fits exactly two answer types. 10
18 Desideratum 1: Changing the answer type Need to change the answer type to: create functions find list prefixes represent parameterized monads analyze questions and polarity in natural language Ghani & Johann, generalized continuations yesterday newtype Ran g h a = Ran ( b. (a g b) h b) For example (Danvy & Filinski): (τ α) β {}}{ [x σ]ρ, α E : τ, β ρ, δ λx. E : (σ/α τ/β), δ. }{{} σ (τ α) β The 4-ary type constructor / / fits exactly two answer types. 10
19 11 Desideratum 2: Reaching beyond the nearest delimiter Need to reach beyond the nearest delimiter to: combine multiple monadic effects normalize λ-terms with sums simulate exceptions and mutable references simulate dynamic binding encode process calculi?
20 12 Lacuna Unfortunately No existing type system subsumes all others. Answer types (effect annotations) on judgments and arrows obscure logical interpretation.
21 Lacuna Unfortunately No existing type system subsumes all others. Answer types (effect annotations) on judgments and arrows obscure logical interpretation. Our new system allows an arbitrary number of changing answer types, using small-step abstract interpretation and only binary connectives. 12
22 Lacuna ξ 0 k. Ouch! : (int T) string Our new system allows an arbitrary number of changing answer types, using small-step abstract interpretation and only binary connectives. 12
23 Lacuna ξ 0 k. Ouch! : (int T) string Our new system allows an arbitrary number of changing answer types, using small-step abstract interpretation and only binary connectives. 12
24 Lacuna ξ 0 k. Ouch! : (int T) string 1 < 2 : bool 1 < 2 : (bool T) T (ξ 0 k. Ouch! ) < 2 : (bool T) string (ξ 0 k. Ouch! ) < (ξ 0 k. c ) : (bool T) string Our new system allows an arbitrary number of changing answer types, using small-step abstract interpretation and only binary connectives. 12
25 13 Outline Delimited continuations Answer types Types as abstract interpretation Substructural logic The λξ 0 -calculus with small-step typing
26 Big step Operational semantics < true Abstract interpretation 1 : int 2 : int 3 : int 4 : int : int : int < : bool For control effects, need small steps. 14
27 Small step Operational semantics true true 3 < 7 true 3 < true < true time Abstract interpretation [x : int] 1 [y : int] 2 [z : bool] 3 3 x < y : bool 2 x < : bool < : bool bool : bool int < int : bool int < : bool < : bool An abstract value is a linear hypothesis. The colon is a turnstile. 14
28 15 Abstract expressions and abstract evaluation contexts Plugging works in both directions. (U T) $ U : T S $ (S T) : T Also need hypothetical reasoning.
29 16 Abstract expressions and abstract evaluation contexts Ouch! : string ξ 0 k. Ouch! : (int ) string c : char ξ 0 k. c : (int T) char (bool T) $ bool : T (bool T) $ ( < ) : T (bool T) $ int < (ξ 0 k. c ) : char (bool T) $ (ξ 0 k. Ouch! ) < : string 1 < 2 : bool
30 16 Abstract expressions and abstract evaluation contexts [k : bool T] 1 [z : bool] 2 k $ z : T 2 k $ (1 < 2) : T 1 1 < 2 : (bool T) T Ouch! : string ξ 0 k. Ouch! : (int ) string c : char ξ 0 k. c : (int T) char (bool T) $ bool : T (bool T) $ ( 1 < 2 ) : T (bool T) $ int < (ξ 0 k. c ) : char (bool T) $ (ξ 0 k. Ouch! ) < : string 1 < 2 : (bool T) T Duality between and ; bool is a subtype of (bool T) T.
31 16 Abstract expressions and abstract evaluation contexts Ouch! : string ξ 0 k. Ouch! : (int T ) string c : char ξ 0 k. c : (int T) char (bool T) $ bool : T (bool T) $ (int < 2 ) : T (bool T) $ int < (ξ 0 k. c ) : char (bool T) $ (ξ 0 k. Ouch! ) < 2 : string (ξ 0 k. Ouch! ) < 2 : (bool T) string Typing derivation is CPS transformation; ξ 0 is abstraction like λ.
32 Abstract expressions and abstract evaluation contexts Ouch! : string ξ 0 k. Ouch! : (int char) string c : char ξ 0 k. c : (int T) char (bool T) $ bool : T (bool T) $ (int < int) : T (bool T) $ int < (ξ 0 k. c ) : char (bool T) $ (ξ 0 k. Ouch! ) < (ξ 0 k. c ) : string (ξ 0 k. Ouch! ) < (ξ 0 k. c ) : (bool T) string time The rest is details: to abstractly decompose an expression into a redex and an evaluation context, use substructural logic. 16
33 Outline Delimited continuations Answer types Types as abstract interpretation Substructural logic The λξ 0 -calculus with small-step typing 17
34 18 Directionality controls combination An expression is a structure. Juxtaposition is tensor, but neither commutative nor associative. Natural deduction: T, T are types, E, F are structures of types. T : T AF : T E : T F : T\T \I F : T\T \E EF : T FA : T /I F : T /T F : T /T E : T /E FE : T saw : (person\bool)/person Bob : person /E Alice : person saw Bob : person\bool \E Alice (saw Bob) : bool T T is T /T.
35 Modes construct syntax The type of woman cannot be person\bool or bool/person. AnF : T E : T F : T\ n T \ n I F : T\ n T \ n E EnF : T FnA : T / n I F : T / n T F : T / n T E : T /n E FnE : T The new binary mode n is internal (unspeakable). Alice : person woman : person\ n bool \n E Alice n woman : bool Modes interact through stipulated structural rules. 19
36 Modes construct syntax A binary mode without products AnF : T E : T F : T\ n T \ n I F : T\ n T \ n E EnF : T A unary mode with products FnA : T / n I F : T / n T F : T / n T E : T /n E FnE : T E : T I E : T E : T E E : T E : T I E : T E : T Γ[ T ] : T E Γ[E] : T For delimited continuations, reify evaluation contexts as coterms. We add two binary modes for coterms:, ; a nullary mode for coterms: # a binary mode for plugging: $ a unary mode for values: (implicit) 19
37 Modes construct syntax A binary mode without products AnF : T E : T F : T\ n T \ n I F : T\ n T \ n E EnF : T A unary mode with products FnA : T / n I F : T / n T F : T / n T E : T /n E FnE : T E : T I E : T E : T E E : T E : T I E : T E : T Γ[ T ] : T E Γ[E] : T For delimited continuations, reify evaluation contexts as coterms. We add two binary modes for coterms: E, C C [ ]E C; V C V[ ] a nullary mode for coterms: # reset [ ] a binary mode for plugging: C $ E C[E] a unary mode for values: V 19
38 Structural rules express evaluation order C $ FE = E, C $ F C $ VE = C; V $ E V = # $ V Γ[C $ FE] : T ========== Γ[E, C $ F] : T Γ[C $ VE] : T ========== Γ[C; V $ E] : T Γ[V] : T ========= Γ[# $ V] : T # $ V 1 (V 2 V 3 ) V 4 = (V 4, #) $ V 1 (V 2 V 3 ) = V 2 V 3, (V 4, #) $ V 1 = (V 4, #); V 1 $ V2 V 3 Our coterm type T T is T / $ T. Our impure term type T T is T\ $ T. 20
39 21 Outline Delimited continuations Answer types Types as abstract interpretation Substructural logic The λξ 0 -calculus with small-step typing
40 Terms E, F ::= V FE C $ E ξ 0 k. E Values V ::= x λx. E Coterms C ::= k # E, C C; V Types T ::= U S T Pure types U ::= U T string int Cotypes S ::= U T Transitions C 1 $ $ C n $ (λx. E)V C 1 $ $ C n $ E{x V} C 1 $ $ C n $ C $ (ξ 0 k. E) C 1 $ $ C n $ E{k C} 22
41 Reset: dynamic semantics Alternate between refocusing and reducing. # $ Goldilocks said: (# $ This porridge is too hot. ) = #; ( Goldilocks said: ) $ (#; ( This porridge is ) $ too hot. ) #; ( Goldilocks said: ) $ (#; ( This porridge is ) $ too hot. ) = #; ( Goldilocks said: ) $ (# $ This porridge is too hot. ) #; ( Goldilocks said: ) $ (# $ This porridge is too hot. ) = # $ Goldilocks said: This porridge is too hot. # $ Goldilocks said: This porridge is too hot. = Goldilocks said: This porridge is too hot. 23
42 Shift 0 : dynamic semantics # $ Goldilocks said: (# $ This porridge is (ξ 0 k.(k $ too hot ) (k $ too cold ) (k $ just right )). ) = #; ( Goldilocks said: ) $ (., (#; ( This porridge is ))); $ ξ0 k.(k $ too hot ) (k $ too cold ) (k $ just right ) #; ( Goldilocks said: ) $ (((., (#; ( This porridge is ))); ) $ too hot ) (((., (#; ( This porridge is ))); ) $ too cold ) (((., (#; ( This porridge is ))); ) $ just right ) = #; ( Goldilocks said: ) $ (# $ This porridge is too hot. ) (# $ This porridge is too cold. ) (# $ This porridge is just right. ) 24
43 Terms E, F ::= V FE C $ E ξ 0 k. E Values V ::= x λx. E Coterms C ::= k # E, C C; V Types T ::= U S T Pure types U ::= U T string int Cotypes S ::= U T [x : U] E : T λ λx. E : U T F : U T FE : T [x : U] Vx : T I V : U T E : U E [k : S] E : T ξ 0 k. E : S T ξ 0 [k : S] k $ E : T I E : S T C : S E : S T E C $ E : T [x : U] F : U E[x] : T E[U] E[F] : T [x : U] C $ x : T I C : U T C : U T E : U E C $ E : T 25
44 26 Reset: static semantics Compute cotype by hypothetical reasoning. [x : string] # $ Tpi x. : string = (., (#; ( Tpi ))); $ x : string I (., (#; ( Tpi ))); : string string too hot : string (., (#; ( Tpi ))); $ too hot : string = E # $ Tpi too hot. : string
45 26 Shift 0 : static semantics Compute cotype by hypothetical reasoning. [x : string] # $ Tpi x. : string = (., (#; ( Tpi ))); $ x : string I (., (#; ( Tpi ))); : string string ξ 0 k. (k $ too hot ) : (string string) string E (., (#; ( Tpi ))); $ too hot : string = # $ Tpi too hot. : string
46 Type checking algorithm Implemented in Twelf. [k : string bool] 1 x : char 1 (ξ 0 k : string bool. x ) (string bool) char [x : string] 2 [n : int] 3 length x int int bool n : bool 3 int bool length x : bool int bool ; length x : bool 2 ; length (ξ 0 k : string bool. x ) (int bool) char length(ξ 0 k : string bool. x ) (int bool) char Say that length is a string int function. 27
47 Type checking algorithm Implemented in Twelf. [k : string bool] 1 x : char 1 (ξ 0 k : string bool. x ) (string bool) char [x : string] 2 [n : int] 3 length x int int bool n : bool 3 int bool length x : bool int bool ; length x : bool 2 ; length (ξ 0 k : string bool. x ) (int bool) char length(ξ 0 k : string bool. x ) (int bool) char Tridirectional type-checking? 27
48 Summary Small-step abstract interpretation type systems for ((delimited) control) effects formalize as a substructural logic Slogan Types are abstract expressions (Cousot) The colon is a turnstile (Lambek) Discoveries Binding and evaluation contexts are related, but the latter is linear. The typing derivation of a direct-style program desugars it into continuation-passing style. Code online small-step-typechecking.tar.gz 28
Call-by-name linguistic side effects
Call-by-name linguistic side effects Oleg Kiselyov FNMOC oleg@pobox.com Abstract We propose a typed call-by-name λ-calculus with shift, reset and strict functions and describe its linguistic applications,
More informationA static simulation of dynamic delimited control
Higher-Order and Symbolic Computation manuscript No. (will be inserted by the editor) A static simulation of dynamic delimited control Chung-chieh Shan the date of receipt and acceptance should be inserted
More informationIntroduction to Programming with Shift and Reset
Introduction to Programming with Shift and Reset Kenichi Asai Oleg Kiselyov September 23, 2011 Abstract The concept of continuations arises naturally in programming: a conditional branch selects a continuation
More informationPolymorphic Delimited Continuations
Polymorphic Delimited Continuations Kenichi Asai Ochanomizu University Yukiyoshi Kameyama University of Tsukuba November 30, 2007 Outline of the talk 1. The language: λ-calculus + let + shift/reset 2.
More informationType 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 Triple Project Carnegie Mellon University 8 April 2003 FOSSACS 03, Warsaw, Poland Type assignment
More informationCPS Translations and Applications: The Cube and Beyond
CPS Translations and Applications: The Cube and Beyond Section 2: The domain-free λ-cube Haye Böhm June 12, 2018 What we ve seen so far 1 CBV/CBN reduction strategies 2 Simulating CBN in a CBV language
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 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 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 informationPolymorphic Delimited Continuations
Polymorphic Delimited Continuations Kenichi Asai 1 and Yukiyoshi Kameyama 2 1 Department of Information Science, Ochanomizu University asai@is.ocha.ac.jp 2 Department of Computer Science, University of
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 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 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 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 information1 Delimited continuations in Haskell
1 Delimited continuations in Haskell This section describes programming with delimited control in Haskell. Delimited control, like its instance, exceptions, is an effect. Therefore, we have to use monads.
More informationWe defined congruence rules that determine the order of evaluation, using the following evaluation
CS 4110 Programming Languages and Logics Lectures #21: Advanced Types 1 Overview In this lecture we will extend the simply-typed λ-calculus with several features we saw earlier in the course, including
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 informationTyped Lambda Calculus
Department of Linguistics Ohio State University Sept. 8, 2016 The Two Sides of A typed lambda calculus (TLC) can be viewed in two complementary ways: model-theoretically, as a system of notation for functions
More informationMikiβ : A General GUI Library for Visualizing Proof Trees
Mikiβ : A General GUI Library for Visualizing Proof Trees System Description and Demonstration Kanako Sakurai and Kenichi Asai Ochanomizu University, Japan {sakurai.kanako,asai}@is.ocha.ac.jp Abstract.
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 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 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 informationComputational Linguistics: Syntax-Semantics Interface
Computational Linguistics: Syntax-Semantics Interface Raffaella Bernardi KRDB, Free University of Bozen-Bolzano P.zza Domenicani, Room: 2.28, e-mail: bernardi@inf.unibz.it Contents 1 Lambda terms and DCG...................................
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 informationPart VI. Imperative Functional Programming
Part VI Imperative Functional Programming Chapter 14 Mutable Storage MinML is said to be a pure language because the execution model consists entirely of evaluating an expression for its value. ML is
More informationTyped Lambda Calculus for Syntacticians
Department of Linguistics Ohio State University January 12, 2012 The Two Sides of Typed Lambda Calculus A typed lambda calculus (TLC) can be viewed in two complementary ways: model-theoretically, as a
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 informationSyntax-semantics interface and the non-trivial computation of meaning
1 Syntax-semantics interface and the non-trivial computation of meaning APA/ASL Group Meeting GVI-2: Lambda Calculi, Type Systems, and Applications to Natural Language APA Eastern Division 108th Annual
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 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 informationHandout 10: Imperative programs and the Lambda Calculus
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 10: Imperative programs and the Lambda Calculus
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 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 informationLING 130: Quantified Noun Phrases
LING 130: Quantified Noun Phrases James Pustejovsky March 15, 2010 1 Syntax for Typed λ-calculus We will now present a language which uses specific types of entities, where the entities are combined with
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 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 informationFunctional unjunparsing. Kenichi Asai (Ochanomizu) Oleg Kiselyov (FNMOC) Chung-chieh Shan (Rutgers)
Functional unjunparsing Kenichi Asai (Ochanomizu) Oleg Kiselyov (FNMOC) Chung-chieh Shan (Rutgers) The problem printf("%d-th character after %c is %c", 5, a, f ); 5-th character after a is f scanf("%d-th
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 informationMonolingual probabilistic programming using generalized coroutines
Monolingual probabilistic programming using generalized coroutines Oleg Kiselyov FNMOC oleg@pobox.com Chung-chieh Shan Rutgers University ccshan@cs.rutgers.edu 19 June 2009 This session... programming
More informationIf a program is well-typed, then a type can be inferred. For example, consider the program
CS 6110 S18 Lecture 24 Type Inference and Unification 1 Type Inference Type inference refers to the process of determining the appropriate types for expressions based on how they are used. For example,
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 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 informationLecture Notes on Program Equivalence
Lecture Notes on Program Equivalence 15-312: Foundations of Programming Languages Frank Pfenning Lecture 24 November 30, 2004 When are two programs equal? Without much reflection one might say that two
More informationPolymorphic Delimited Continuations
Polymorphic Delimited Continuations Kenichi Asai 1 and Yukiyoshi Kameyama 2 1 Department of Information Science, Ochanomizu University asai@is.ocha.ac.jp 2 Department of Computer Science, University of
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 informationCSE 505, Fall 2006, Final Examination 11 December Please do not turn the page until everyone is ready.
CSE 505, Fall 2006, Final Examination 11 December 2006 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 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 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 informationCSE505, Fall 2012, Midterm Examination October 30, 2012
CSE505, Fall 2012, Midterm Examination October 30, 2012 Rules: The exam is closed-book, closed-notes, except for one side of one 8.5x11in piece of paper. Please stop promptly at Noon. You can rip apart
More informationarxiv:cs/ v1 [cs.lo] 8 Aug 2005
Logical Methods in Computer Science Volume 00, Number 0, Pages 000 000 S 0000-0000(XX)0000-0 arxiv:cs/0508048v1 [cs.lo] 8 Aug 2005 AN OPERATIONAL FOUNDATION FOR DELIMITED CONTINUATIONS IN THE CPS HIERARCHY
More informationLambda Calculus. Variables and Functions. cs3723 1
Lambda Calculus Variables and Functions cs3723 1 Lambda Calculus Mathematical system for functions Computation with functions Captures essence of variable binding Function parameters and substitution Can
More informationAbstract register machines Lecture 23 Tuesday, April 19, 2016
Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Lecture 23 Tuesday, April 19, 2016 1 Why abstract machines? So far in the class, we have seen a variety of language features.
More informationA Type-Theoretic Foundation of Continuations and Prompts
A Type-Theoretic Foundation of Continuations and Prompts Zena M. Ariola University of Oregon ariola@cs.uoregon.edu Hugo Herbelin INRIA-Futurs Hugo.Herbelin@inria.fr Amr Sabry Indiana University sabry@indiana.edu
More informationHigher-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 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 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 information(Refer Slide Time: 4:00)
Principles of Programming Languages Dr. S. Arun Kumar Department of Computer Science & Engineering Indian Institute of Technology, Delhi Lecture - 38 Meanings Let us look at abstracts namely functional
More informationCS 4110 Programming Languages & Logics. Lecture 28 Recursive Types
CS 4110 Programming Languages & Logics Lecture 28 Recursive Types 7 November 2014 Announcements 2 Foster office hours 11-12pm Guest lecture by Fran on Monday Recursive Types 3 Many languages support recursive
More informationAssistant for Language Theory. SASyLF: An Educational Proof. Corporation. Microsoft. Key Shin. Workshop on Mechanizing Metatheory
SASyLF: An Educational Proof Assistant for Language Theory Jonathan Aldrich Robert J. Simmons Key Shin School of Computer Science Carnegie Mellon University Microsoft Corporation Workshop on Mechanizing
More informationIntroduction to System F. Lecture 18 CS 565 4/20/09
Introduction to System F Lecture 18 CS 565 4/20/09 The Limitations of F 1 (simply-typed λ- calculus) In F 1 each function works exactly for one type Example: the identity function id = λx:τ. x : τ τ We
More informationMutable 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 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 informationLambda Calculus and Extensions as Foundation of Functional Programming
Lambda Calculus and Extensions as Foundation of Functional Programming David Sabel and Manfred Schmidt-Schauß 29. September 2015 Lehrerbildungsforum Informatik Last update: 30. September 2015 Overview
More informationERC 4th Workshop KAIST. Sukyoung Ryu KAIST. August 26, 2010
ERC 4th Workshop Sukyoung Ryu August 26, 2010 : Members Coq Mechanization of Basic Core Fortress for Type Soundness Adding Pattern Matching to Existing Object- Oriented Languages FortressCheck: Automatic
More informationAdvanced Programming Handout 7. Monads and Friends (SOE Chapter 18)
Advanced Programming Handout 7 Monads and Friends (SOE Chapter 18) The Type of a Type In previous chapters we discussed: Monomorphic types such as Int, Bool, etc. Polymorphic types such as [a], Tree a,
More informationInverse scope as metalinguistic quotation in operational semantics
Inverse scope as metalinguistic quotation in operational semantics Chung-chieh Shan Rutgers University ccshan@rutgers.edu Abstract. We model semantic interpretation operationally: constituents interact
More informationPure Lambda Calculus. Lecture 17
Pure Lambda Calculus Lecture 17 Lambda Calculus Lambda Calculus (λ-calculus) is a functional notation introduced by Alonzo Church in the early 1930s to formalize the notion of computability. Pure λ-calculus
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-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 informationConcepts of programming languages
Concepts of programming languages Lecture 5 Wouter Swierstra 1 Announcements Submit your project proposal to me by email on Friday; The presentation schedule in now online Exercise session after the lecture.
More informationCMSC 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 informationIntroduction to lambda calculus Part 3
Introduction to lambda calculus Part 3 Antti-Juhani Kaijanaho 2017-01-27... 1 Untyped lambda calculus... 2 Typed lambda calculi In an untyped lambda calculus extended with integers, it is required that
More informationCSE 505, Fall 2007, Final Examination 10 December Please do not turn the page until everyone is ready.
CSE 505, Fall 2007, Final Examination 10 December 2007 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 informationMPRI course 2-4 Functional programming languages Exercises
MPRI course 2-4 Functional programming languages Exercises Xavier Leroy October 13, 2016 Part I: Interpreters and operational semantics Exercise I.1 (**) Prove theorem 2 (the unique decomposition theorem).
More informationIntroduction to Lambda Calculus. Lecture 7 CS /08/09
Introduction to Lambda Calculus Lecture 7 CS 565 02/08/09 Lambda Calculus So far, we ve explored some simple but non-interesting languages language of arithmetic expressions IMP (arithmetic + while loops)
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 informationA robust implementation of delimited control
A robust implementation of delimited control Zena M. Ariola University of Oregon ariola@cs.uoregon.edu Hugo Herbelin INRIA-Futurs Hugo.Herbelin@inria.fr Daniel Keith University of Oregon dkeith@cs.uoregon.edu
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 informationFunctional Semantics of Parsing Actions, and Left Recursion Elimination as Continuation Passing
Functional Semantics of Parsing Actions, and Left Recursion Elimination as Continuation Passing Hayo Thielecke University of Birmingham, UK H.Thielecke@cs.bham.ac.uk Abstract Parsers, whether constructed
More informationArbitrary-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 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 informationCMSC 330: Organization of Programming Languages. Operational Semantics
CMSC 330: Organization of Programming Languages Operational Semantics Notes about Project 4, Parts 1 & 2 Still due today (7/2) Will not be graded until 7/11 (along with Part 3) You are strongly encouraged
More informationSemantics of programming languages
Semantics of programming languages Informatics 2A: Lecture 28 Mary Cryan School of Informatics University of Edinburgh mcryan@inf.ed.ac.uk 21 November 2018 1 / 18 Two parallel pipelines A large proportion
More informationSemantics of programming languages
Semantics of programming languages Informatics 2A: Lecture 27 Alex Simpson School of Informatics University of Edinburgh als@inf.ed.ac.uk 18 November, 2014 1 / 18 Two parallel pipelines A large proportion
More informationLess naive type theory
Institute of Informatics Warsaw University 26 May 2007 Plan 1 Syntax of lambda calculus Why typed lambda calculi? 2 3 Syntax of lambda calculus Why typed lambda calculi? origins in 1930s (Church, Curry)
More informationShifting the Stage. Staging with Delimited Control. Oleg Kiselyov. Chung-chieh Shan. Yukiyoshi Kameyama. Abstract. 1. Introduction
Yukiyoshi Kameyama University of Tsukuba kameyama@acm.org Shifting the Stage Staging with Delimited Control Oleg Kiselyov FNMOC oleg@pobox.com Chung-chieh Shan Rutgers University ccshan@cs.rutgers.edu
More informationML F Raising ML to the Power of System F
ML F Raising ML to the Power of System F Didier Le Botlan and Didier Rémy INRIA-Rocquencourt 78153 Le Chesnay Cedex, France {Didier.Le_Botlan,Didier.Remy}@inria.fr Abstract We propose a type system ML
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 informationCS 4110 Programming Languages & Logics. Lecture 27 Recursive Types
CS 4110 Programming Languages & Logics Lecture 27 Recursive Types 4 November 2016 Announcements 2 My office hours are at the normal time today but canceled on Monday Guest lecture by Seung Hee Han on Monday
More informationValue Recursion in Monadic Computations
Value Recursion in Monadic Computations Levent Erkök OGI School of Science and Engineering, OHSU Advisor: John Launchbury June 24th, 2002 Outline Recursion and effects Motivating examples Value recursion
More informationChapter 13: Reference. Why reference Typing Evaluation Store Typings Safety Notes
Chapter 13: Reference Why reference Typing Evaluation Store Typings Safety Notes References Computational Effects Also known as side effects. A function or expression is said to have a side effect if,
More informationOutcome-Oriented Programming (5/12/2004)
1 Outcome-Oriented Programming (5/12/2004) Daniel P. Friedman, William E. Byrd, David W. Mack Computer Science Department, Indiana University Bloomington, IN 47405, USA Oleg Kiselyov Fleet Numerical Meteorology
More informationCoherent Coercion Abstraction with a step-indexed strong-reduction semantics
preprint version Coherent Coercion Abstraction with a step-indexed strong-reduction semantics Julien Cretin Didier Rémy INRIA {julien.cretin,didier.remy}@inria.fr Abstract The usual notion of type coercions
More informationFunctional programming languages
Functional programming languages Part V: functional intermediate representations Xavier Leroy INRIA Paris-Rocquencourt MPRI 2-4, 2015 2017 X. Leroy (INRIA) Functional programming languages MPRI 2-4, 2015
More informationLogic-Flow Analysis of Higher-Order Programs
Logic-Flow Analysis of Higher-Order Programs Matt Might http://matt.might.net/ POPL 2007 Why? Tim Sweeney, POPL 2006 Static array-bounds checking. Example... a[i]... Will 0 i < a.length always hold? 3
More informationFirst-Class Type Classes
First-Class Type Classes Matthieu Sozeau Joint work with Nicolas Oury LRI, Univ. Paris-Sud - Démons Team & INRIA Saclay - ProVal Project Gallium Seminar November 3rd 2008 INRIA Rocquencourt Solutions for
More informationCOMP3151/9151 Foundations of Concurrency Lecture 8
1 COMP3151/9151 Foundations of Concurrency Lecture 8 Liam O Connor CSE, UNSW (and data61) 8 Sept 2017 2 Shared Data Consider the Readers and Writers problem from Lecture 6: Problem We have a large data
More informationA Logical View of Effects
A Logical View of Effects Sungwoo Park and Robert Harper Computer Science Department Carnegie Mellon University {gla,rwh}@cs.cmu.edu Abstract Despite their invaluable contribution to the programming language
More informationModal Logic Revisited
Modal Logic Revisited Frank Pfenning The Scottfest In honor of Dana Scott on his 70th Birthday Pittsburgh, Pennsylvania October 12, 2002 1 Source [1] Dana Scott, Advice on Modal Logic. In: Philosophical
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 information