Symmetry in Type Theory
|
|
- Cameron Briggs
- 5 years ago
- Views:
Transcription
1 Google May 29th, 2012
2 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. Simpler syntax. Fewer inference rules. Power. Can express some programs more directly. More programs are typeable.
3 Outline Pure Type Systems Symmetry between objects, types, and kinds. Symmetry between typing and kinding. Higher-order subtyping Generalize subtyping. Personal research: Pure Subtype Systems Symmetry between values and proper types. Symmetry between typing and subtyping. Subtyping: metatheory and proof techniques Symmetry between preservation and transitivity elimination.
4 Part I Pure Type Systems
5 The story so far: λ System λ (a.k.a. simply-typed λ-calculus) TAPS, Chapter 9. Provides ordinary functions, from object to object. Objects have types. description maps syntax proper type ordinary functions object object λx : T. u T U (Note: Pierce distinguishes between terms and types. I use the word object instead of term; this will be important later on.)
6 The story so far: System F System F (a.k.a. polymorphic λ-calculus) TAPS, Chapter 23. Adds type variables X. Adds functions from types to objects. E.g. map : A. B. (A B) [A] [B] description maps syntax proper type ordinary functions: object object λx : T. u T U polymorphism: type object λx. t X. T
7 The story so far: System F ω System F ω (a.k.a. type operators or higher-order types) TAPS, Chapter 30. Adds functions from types to types. E.g. List is a function; List<Int>, List<String>, are types. Types have kinds. Kinding is a copy of typing, one level up. description maps syntax type/kind ordinary functions: object object λx : T. u T U polymorphism: type object λx :: K. t X :: K. T type operators: type type λx :: K 1. T K 1 K 2
8 Looking ahead: the Calculus of Constructions The Calculus of Constructions (a.k.a. dependent types) Coquand and Huet, 1986 Adds functions from objects to types. E.g. Array<int, 128> The array type is parameterized by its size, which is an integer. X. T syntax extended to ordinary function types; function return type may depend on arguments. description maps syntax type/kind ordinary functions: object object λx : T. u x : T. U polymorphism: type object λx :: K. t X :: K. T type operators: type type λx :: K 1. T X :: K 1. K 2 dependent types: object type λx : T. U x : T. K
9 Getting ugly What a mess! Three sorts of term, which are syntactically distinct. objects, types, and kinds. E.g. x for object variables, X for type variables. Two relations: typing (:) and kinding (::). Four sorts of functions: object object, type object, type type, object type
10 Some obvious symmetries Typing and kinding rules are exactly the same. Γ, x : T u : U Γ λx : T. u : T U Γ, X :: K 1 T :: K 2 Γ λx :: K 1. T :: K 1 K 2 No need to distinguish between typing and kinding. No need to distinguish syntactically between objects, types, and kinds
11 Pure Type Systems Pure Type Systems (Barendregt, 1992) Terms t, u range over objects, types, and kinds. Typing (t : T ) and kinding (T :: K) are unified. Only one relation: typing. The typing relation is defined over all terms. description maps syntax type/kind functions: any any λx : t. u Πx : t. s The Πx : t. s syntax unifies the different function types: and Π are the same thing. T U is sugar for Πx : T. U, where x U. K 1 K 2 is sugar for ΠX : K 1. K 2, where X K 2.
12 Core PTS definitions S ::= sorts s, t, u ::= terms S sort x variable λx : t. u function Πx : t. u function type t(u) function application Γ : x : t Γ Γ x : t Γ t : Πx : u. s, u : u Γ t(u) : [x u]s Γ Πx : t. s : S Γ, x : t u : s Γ λx : t. u : Πx : t. s Γ t : S Γ, x : t u : S Γ Πx : t. u : S (S, S) R
13 Some Subtleties It is still possible to distinguish between objects, types, and kinds. The syntax has been unified......but the typing judgement tells you which is which. t : u : means that t is an object, u is a type t : u : means that t is a type, u is a kind
14 The λ-cube Relation R controls which dependencies are allowed. Eight λ-calculi in one! x axis: dependent types y axis: polymorphism z axis: type operators F ω CC F λ λp
15 Part II Higher Order Subtyping
16 What is subtyping? A proper type denotes a set of objects. Typing denotes the is a member of relation. (e.g. 3 : Nat) Subtyping denotes the subset relation. (e.g. Nat <: Top) Object Plant Animal Cat Dog Rock Top Nat 3 5 List(Nat) [2,3] [] Fluffy
17 Two uses of subtyping Subtype polymorphism (loosen constraint on objects) A function can accept arguments of many different types. Alternative to parametric polymorphism (i.e. System F) Widely used in object-oriented languages. void writetofile(serializable obj); Bounded quantification (tighten constraint on types) Used to constrain type arguments. Alternative to kinding (X <: T vs. X :: K) class SerializableArray<T extends Serializable> Γ t : U, U <: T Γ t : T Γ, X <:T u : U Γ λx <: T. u : X <: T. U
18 Higher-order subtyping Subtyping is lifted pointwise to type operators. F <: G if and only if F (X) <: G(X) for any X. Example: a List is a Container. List<T > <: Container<T > for any type T. List<Integer> <: Container<Integer> List<String> <: Container<String> Subtyping means more than just subset! // Java example : c l a s s Container <X> {... } c l a s s L i s t <X> e x t e n d s Container <X> {... }
19 Higher order subtyping: key rules Subtyping over functions: Γ, X <: T U <: S Γ λx <: T. U <: λx <: T. S Subtyping over function application: Γ T <: U Γ T (S) <: U(S)
20 System F ω <: TAPS, Chapter 31. Adds subtyping and bounded quantification to System F ω. Two versions: type operators with kinding (TAPS Chapter 31) type operators with bounded quantification description maps syntax type/kind ordinary functions: object object λx : T. u T U polymorphism: type object λx <: T. u X <: T. U type operators: type type λx :: K 1. U K 1 K 2
21 Getting even more ugly An even bigger mess! Three sorts of term: objects, types, and kinds. Three relations: typing (:), subtyping (<:), and kinding (::) Three sorts of functions: object object, type object, type type,
22 Part III Pure Subtype Systems
23 Typing, subtyping, and kinding description maps syntax type/kind ordinary functions: object object λx : T. u T U polymorphism: type object λx <: T. u X <: T. U type operators: type type λx :: K 1. U K 1 K 2
24 Pure Subtype Systems PSS simplify System F ω <:, much like PTS simplify System F ω. Terms s, t, u range over both objects and types (like PTS). Only one syntax for functions (like PTS). Key idea: unify typing, subtyping, and kinding. One relation: subtyping. Subtyping is defined over all terms. Objects are subtypes of types. e.g. 3 <: Nat <: Top (instead of 3 : Nat <: Top) Subtyping a substitute for typing. No distinction between values and proper types. Exploit a new symmetry not part of PTS.
25 Typing, subtyping, and kinding We already know that typing and kinding can be unified. Same as in PTS. Subtyping is strictly stronger than kinding. (Pierce) Introduce a universal supertype Top. Every kind K is associated with a bounding type T. X :: becomes X <: Top X :: becomes X <: (λy <: Top.Top) etc. Still need to unify subtyping and typing...
26 Typing vs. subtyping Γ, x <: t u : s Γ λx <: t. u : Πx <: t. s Γ, x <: t u <: s Γ λx <: t. u <: λx <: t. s Γ, x <: t u <: s Γ Πx <: t. u <: Πx <: t. s Typing Subtyping Typing compares λ and Π. Subtyping compares λ and λ, or Π and Π. λ is a value, whereas Π is a proper type. Can we unify λ and Π?
27 The symmetry of values Proper types describe the shape of values. Every distinct kind of value has a corresponding type. description value type unit unit Unit functions λx : T. u Πx : T.U records {l i = t i 1..n i } {l i : T i 1..n pairs (t, u) (T, U) i }
28 The symmetry of values, ctd. Traditional type theory: Values can be eliminated by reduction. E.g. {l i = ti i 1..n }.l i t i Proper types cannot be eliminated. E.g. {l i : Ti i 1..n }.l i is not a valid type. Pure Subtype Systems: Use a single syntax for values and proper types. Elimination rules apply to both values and proper types. e.g. {foo : 3, bar : 5}.foo 3 e.g. {foo : Int, bar : Int}.foo Int
29 Example: natural numbers Review: Church encodings of natural numbers in System F: 3 = λx. λf : X X. λa : X. f(f(f(a))) Nat = X. (X X) X X Church encodings using subtyping, in System F ω <:: 3 = λx <: Top. λf <: X X. λa <: X. F (F (F (A))) Nat = λx <: Top. λf <: X X. λa <: X. X We don t really need a new theory; we re just exploiting symmetry in an existing theory.
30 Double Vision 3 = λx <: Top. λf <: x x. λa <: x. f(f(f(a))) Nat = λx <: Top. λf <: x x. λa <: x. x 3 <: Nat The number 3 can be used as a type or an object. As an object, it can be used in addition, etc. It is also a singleton type: the type of all numbers equal to 3. Set theory: 3 N versus {3} N The type Nat can be used as a type or an object. As a type, it is the type of natural numbers. It can also be used in addition, etc. Nat + 3 = Nat. Operations on types are a bit like abstract interpretation. A type represents a set of possible values. Operations on types produce a set of possible results.
31 Desconstructing Typing The typing judgement provides three pieces of information: 1 Types describe the shape of value that will be produced when a term is evaluated; e.g. t : (Πx : U. S) means t will evaluate to a function. 2 A term which has a type is well-typed. Well-typed terms can t go wrong i.e. certain errors cannot occur during the evaluation of a well-typed term. 3 Typing determines the level (object, type, or kind) of a term.
32 Reconstructing Typing Pure Subtype Systems use three separate judgements: 1 Subtyping (t <: u) compares the shape of terms. e.g. t <: (λx <: u. s) means that t will evaluate to a function. 2 Well-formedness (t wf) identifies the well-typed terms. Well-formed terms can t go wrong. 3 A universe judgement (t U(K)) distinguishes between types and objects. (For simplicity, we use only a single universe.)
33 System λ : Syntax and well-formed terms s, t, u ::= Terms x variable Top universal supertype λx <: t. u function t(u) application Top wf x <: t Γ Γ x wf Γ t wf Γ, x <: t u wf Γ λx <: t. u wf Γ t wf, u wf Γ t <: (λx <: s. s ), Γ t(u) wf u <: s
34 Subtyping and equivalence: Core Rules Γ s <: t, t <: u, t wf Γ s <: u Γ x <: t Γ Γ x <: t Γ t <: Top Γ, x <: t u <: s Γ λx <: t. u <: λx <: t. s Γ t <: u Γ t(s) <: u(s) Γ (λx <: t. u)(s) [x s]u
35 Part IV Metatheory of Subtyping
36 Review: Type Soundness Standard proof technique is by progress and preservation. Progress: if t : T, then either t is a value, or t t. Preservation: if t : T and t t, then t : T. Preservation: Example: T T Int Int : : : : t t (λx : Int. x)(3) 3
37 Review: Inversion of typing Consider the following reduction: (λx : T.u)(s) [x s]u Typing derivations are unique. Thus, we can invert the typing relation. (λx : T.u)(s) : U only if x : T u : U, and s : T. Preservation follows by the substitution lemma.
38 The problem with transitivity Subtyping has no inversion lemma, because of transitivity: s <: t t <: u s <: u The term t is present in the premise, but not the conclusion. Transitivity is not algorithmic. An algorithm trying to prove s <: u, would need to guess t. The term t could be anything. Any subtyping derivation can end in transitivity. Subtyping derivations are not unique. Cannot invert the subtype relation. With no inversion lemma, cannot prove type soundness. We need to show that: (λx <: t. u) <: (λx <: t. u ) only if t t.
39 Metatheory: transitivity elimination Standard approach: transitivity elimination. Formulate algorithmic subtyping without a transitivity rule. Show that transitivity is admissible in the algorithmic system. i.e. transitivity can be derived from other rules. If s <: t and t <: u are transitivity-free derivations, then there exists a transitivity-free derivation of s <: u. Standard formulation: (Pierce & Steffen, Compagnoni & Goguen) Reduce all expressions to normal form. Subtyping between normal forms are transitive. Only works for strongly-normalizing theories!
40 Strong normalization Strongly normalizing Not strongly normalizing
41 Strong normalization, the real definition A normal form is a term that cannot be further reduced. The number 3 is a normal form; is not. λx : T. x(x) is a normal form; (λx : T. x)(y) is not. A type theory is strongly normalizing if all terms can be reduced to normal form. i.e. the evaluation of all terms must terminate. no loops or general recursion. Example: the simply-typed λ-calculus. In most real-world languages: Type expressions are strongly normalizing. Object expressions are not strongly normalizing. Pure Subtype Systems eliminate the distinction between types and objects. Oops.
42 An alternative approach to transitivity elimination Type equivalence is also transitive: s t t u s u How do we handle equivalence? Standard approach: Formulate equivalence as a reduction system. Two types are equivalent if they have a common reduct: t u iff t u Transitivity follows from confluence of reduction. No need for strong normalization!
43 Confluence Confluence states that the order in which expressions are evaluated does not matter. It is a fundamental property of the λ-calculus. More formally: t 0 t 1 Example: t 2 t 3 (1 2) + (3 4) 2 + (3 4) (1 2)
44 Subtype reduction Formulate algorithmic subtyping as a reduction system. t u reduces t to an equivalent term u. u simplifies t to a supertype u. t <: u iff t <: u. t <: Γ s <: t Γ (λx <: t. u)(s) [x s]u x <: t Γ Γ x <: t Γ t <: Top
45 Preservation of subtyping. <: Subtyping is sound if and commute. Commutativity is confluence with two kinds of reduction. This property looks a lot like preservation. Except that we allow reductions on the top edge. Commutativity: Example: u u (λx <: Int. Int)(3) Int <: <: <: <: t t (λx <: Int. x)(3) 3
46 Proof: transitivity elimination If s <: t <: u then s <: u. u <: <: t <: s
47 Confluence: proofs and related properties There are 3 properties related to confluence. It is almost impossible to prove confluence directly. The diamond property is strictly stronger than confluence. Local confluence is strictly weaker. (Need an additional induction principle to get confluence.) Confluence t 0 t 1 t 2 t 3 Diamond Property t 0 t 1 t 2 t 3 Local Confluence t 0 t 1 t 2 t 3
48 The bad news Subtype reduction commutes locally. It is very hard to prove that it commutes globally. (λx <: a. a)(c) a <: <: (λx <: a. x)(c) c
49 Bring back the types! Problem: too much symmetry. Solution: restore distinction between types and objects. Define a subset of terms that are strongly normalizing. Call them types. Functions must be written λx <: T. u, where T is a type. Can now prove that <: and commute. But... weren t we trying to avoid strong normalization? We don t need normalization for all terms. We only need normalization for terms that are used as types. Makes sense: what would inhabit a non-terminating type? (Translation: what objects have such a type?)
50 Cheap tricks How to define the strongly normalizing subset? Option 1: Use more than one universe. Beautiful. Elegant. Can you tell me how? Strong normalization proofs are really, really hard. Option 2: Require that types be well-kinded. Sad that we can t eliminate kinding altogether, though... Option 3: Require that types be in normal form to start with. Normal forms are not stable under substitution. e.g. x(y) is a normal form......but substituting a function for x yields a redex. Cheap trick: change the way that substitution is done. Use administrative normal form. (Cormac et. al., 1993) Substitution only replaces variables with variables. Hoorah! Closely resembles the nominal subtyping found in Java.
51 Metatheory of subtyping: summary Transitivity is evil. Must prove transitivity elimination for any theory of subtyping. Transitivity elimination is essentially a preservation theorem; it shows that subtyping is sound. Also: the more symmetric and powerful your theory, the harder the meta-theory becomes.
52 Part V Applications
53 Modules module A { type Expr <: Object ; e v a l ( e : Expr ) : I n t ; } ; module B e x t e n d s A { type Expr =... ; e v a l ( e : Expr ) : I n t =... ; } ; Is module A an object, or a type? Hard to say... A.eval is an object. A.expr is a type. Need subtyping to handle inheritance. Need dependent types for type members. Pure subtype sytems make this much simpler.
54 Questions?
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 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 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 informationLecture 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 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 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 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 informationLecture slides & distribution files:
Type Theory Lecture slides & distribution files: http://www.cs.rhul.ac.uk/home/zhaohui/ttlectures.html Zhaohui Luo Department of Computer Science Royal Holloway, University of London April 2011 2 Type
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 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 informationTradeoffs. 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 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 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 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 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 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 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 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 informationFormal 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 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 informationSecond-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 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 informationFormal Semantics. Aspects to formalize. Lambda calculus. Approach
Formal Semantics Aspects to formalize Why formalize? some language features are tricky, e.g. generalizable type variables, nested functions some features have subtle interactions, e.g. polymorphism and
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 informationOfficial 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 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 informationLambda Calculus and Type Inference
Lambda Calculus and Type Inference Björn Lisper Dept. of Computer Science and Engineering Mälardalen University bjorn.lisper@mdh.se http://www.idt.mdh.se/ blr/ August 17, 2007 Lambda Calculus and Type
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 informationBasic Foundations of Isabelle/HOL
Basic Foundations of Isabelle/HOL Peter Wullinger May 16th 2007 1 / 29 1 Introduction into Isabelle s HOL Why Type Theory Basic Type Syntax 2 More HOL Typed λ Calculus HOL Rules 3 Example proof 2 / 29
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 informationResources: The slides of this lecture were derived from [Järvi], with permission of the original author, by copy & x = 1 let x = 1 in...
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λ 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 informationThe University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 4 MODULE, SPRING SEMESTER MATHEMATICAL FOUNDATIONS OF PROGRAMMING ANSWERS
The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 4 MODULE, SPRING SEMESTER 2012 2013 MATHEMATICAL FOUNDATIONS OF PROGRAMMING ANSWERS Time allowed TWO hours Candidates may complete the front
More informationLambda Calculus and Type Inference
Lambda Calculus and Type Inference Björn Lisper Dept. of Computer Science and Engineering Mälardalen University bjorn.lisper@mdh.se http://www.idt.mdh.se/ blr/ October 13, 2004 Lambda Calculus and Type
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 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 information3.4 Deduction and Evaluation: Tools Conditional-Equational Logic
3.4 Deduction and Evaluation: Tools 3.4.1 Conditional-Equational Logic The general definition of a formal specification from above was based on the existence of a precisely defined semantics for the syntax
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 informationThis is already grossly inconvenient in present formalisms. Why do we want to make this convenient? GENERAL GOALS
1 THE FORMALIZATION OF MATHEMATICS by Harvey M. Friedman Ohio State University Department of Mathematics friedman@math.ohio-state.edu www.math.ohio-state.edu/~friedman/ May 21, 1997 Can mathematics be
More informationThe Untyped Lambda Calculus
Resources: The slides of this lecture were derived from x = 1 [Järvi], with permission of the original author, by copy & let x = 1 in... paste or by selection, annotation, or rewording. [Järvi] is in turn
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 informationλ calculus Function application Untyped λ-calculus - Basic Idea Terms, Variables, Syntax β reduction Advanced Formal Methods
Course 2D1453, 2006-07 Advanced Formal Methods Lecture 2: Lambda calculus Mads Dam KTH/CSC Some material from B. Pierce: TAPL + some from G. Klein, NICTA Alonzo Church, 1903-1995 Church-Turing thesis First
More informationA Canonical 1 Locally Named Representation of Binding. α -equivalence is identity. Randy Pollack. Masahiko Sato. LFCS, University of Edinburgh
A Canonical 1 Locally Named Representation of Binding Randy Pollack LFCS, University of Edinburgh Masahiko Sato Graduate School of Informatics, Kyoto University Version of December 7, 2009 1 α -equivalence
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 informationaxiomatic semantics involving logical rules for deriving relations between preconditions and postconditions.
CS 6110 S18 Lecture 18 Denotational Semantics 1 What is Denotational Semantics? So far we have looked at operational semantics involving rules for state transitions, definitional semantics involving translations
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 informationType 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 informationLet 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 informationFundamentals and lambda calculus
Fundamentals and lambda calculus Again: JavaScript functions JavaScript functions are first-class Syntax is a bit ugly/terse when you want to use functions as values; recall block scoping: (function ()
More informationT ::=Nat T T. zero : Nat. This rule can be instantiated for any type T, so it is actually a family of rules, one for each type.
V Capretta 46 G54FOP 2018 Chapter 6 System T We have seen that the simple types of λ allow us to define only a limited class of operations. We can program addition and multiplication but not exponentiation.
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 informationIntroduction to the Lambda Calculus
Introduction to the Lambda Calculus Overview: What is Computability? Church s Thesis The Lambda Calculus Scope and lexical address The Church-Rosser Property Recursion References: Daniel P. Friedman et
More informationThree Applications of Strictness in the Efficient Implementaton of Higher-Order Terms
Three Applications of Strictness in the Efficient Implementaton of Higher-Order Terms Frank Pfenning Workshop on Implementation of Logic Réunion Island, France November 11, 2000 Joint work with Carsten
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 informationFunctional Languages and Higher-Order Functions
Functional Languages and Higher-Order Functions Leonidas Fegaras CSE 5317/4305 L12: Higher-Order Functions 1 First-Class Functions Values of some type are first-class if They can be assigned to local variables
More informationCITS3211 FUNCTIONAL PROGRAMMING
CITS3211 FUNCTIONAL PROGRAMMING 9. The λ calculus Summary: This lecture introduces the λ calculus. The λ calculus is the theoretical model underlying the semantics and implementation of functional programming
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 informationSemantics via Syntax. f (4) = if define f (x) =2 x + 55.
1 Semantics via Syntax The specification of a programming language starts with its syntax. As every programmer knows, the syntax of a language comes in the shape of a variant of a BNF (Backus-Naur Form)
More informationCategorical models of type theory
1 / 59 Categorical models of type theory Michael Shulman February 28, 2012 2 / 59 Outline 1 Type theory and category theory 2 Categorical type constructors 3 Dependent types and display maps 4 Fibrations
More informationCSE 505: Concepts of Programming Languages
CSE 505: Concepts of Programming Languages Dan Grossman Fall 2003 Lecture 6 Lambda Calculus Dan Grossman CSE505 Fall 2003, Lecture 6 1 Where we are Done: Modeling mutation and local control-flow Proving
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 informationLecture 5: The Untyped λ-calculus
Lecture 5: The Untyped λ-calculus Syntax and basic examples Polyvios Pratikakis Computer Science Department, University of Crete Type Systems and Static Analysis Pratikakis (CSD) Untyped λ-calculus I CS49040,
More informationProgramming 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 informationNote that in this definition, n + m denotes the syntactic expression with three symbols n, +, and m, not to the number that is the sum of n and m.
CS 6110 S18 Lecture 8 Structural Operational Semantics and IMP Today we introduce a very simple imperative language, IMP, along with two systems of rules for evaluation called small-step and big-step semantics.
More informationFeatherweight Java (FJ)
x = 1 let x = 1 in... x(1).!x(1) x.set(1) Programming Language Theory Featherweight Java (FJ) Ralf Lämmel This lecture is based on David Walker s lecture: Computer Science 441, Programming Languages, Princeton
More informationOne of a number of approaches to a mathematical challenge at the time (1930): Constructibility
λ Calculus Church s λ Calculus: Brief History One of a number of approaches to a mathematical challenge at the time (1930): Constructibility (What does it mean for an object, e.g. a natural number, to
More information1 Scope, Bound and Free Occurrences, Closed Terms
CS 6110 S18 Lecture 2 The λ-calculus Last time we introduced the λ-calculus, a mathematical system for studying the interaction of functional abstraction and functional application. We discussed the syntax
More informationCOMP 1130 Lambda Calculus. based on slides by Jeff Foster, U Maryland
COMP 1130 Lambda Calculus based on slides by Jeff Foster, U Maryland Motivation Commonly-used programming languages are large and complex ANSI C99 standard: 538 pages ANSI C++ standard: 714 pages Java
More informationPure (Untyped) λ-calculus. Andrey Kruglyak, 2010
Pure (Untyped) λ-calculus Andrey Kruglyak, 2010 1 Pure (untyped) λ-calculus An example of a simple formal language Invented by Alonzo Church (1936) Used as a core language (a calculus capturing the essential
More information11/6/17. Outline. FP Foundations, Scheme. Imperative Languages. Functional Programming. Mathematical Foundations. Mathematical Foundations
Outline FP Foundations, Scheme In Text: Chapter 15 Mathematical foundations Functional programming λ-calculus LISP Scheme 2 Imperative Languages We have been discussing imperative languages C/C++, Java,
More informationInductive Definitions, continued
1 / 27 Inductive Definitions, continued Assia Mahboubi Jan 7th, 2016 2 / 27 Last lecture Introduction to Coq s inductive types: Introduction, elimination and computation rules; Twofold implementation :
More informationFundamental Concepts. Chapter 1
Chapter 1 Fundamental Concepts This book is about the mathematical foundations of programming, with a special attention on computing with infinite objects. How can mathematics help in programming? There
More informationDenotational Semantics. Domain Theory
Denotational Semantics and Domain Theory 1 / 51 Outline Denotational Semantics Basic Domain Theory Introduction and history Primitive and lifted domains Sum and product domains Function domains Meaning
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 informationCOS 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 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 informationThe Substitution Model
The Substitution Model Prof. Clarkson Fall 2017 Today s music: Substitute by The Who Review Previously in 3110: simple interpreter for expression language abstract syntax tree (AST) evaluation based on
More informationTypes and Programming Languages. Lecture 8. Recursive type
Types and Programming Languages Lecture 8. Recursive type Xiaojuan Cai cxj@sjtu.edu.cn BASICS Lab, Shanghai Jiao Tong University Fall, 2016 List[T] List[T] is a type constructor whose elements are lists
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 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 informationEmbedding logics in Dedukti
1 INRIA, 2 Ecole Polytechnique, 3 ENSIIE/Cedric Embedding logics in Dedukti Ali Assaf 12, Guillaume Burel 3 April 12, 2013 Ali Assaf, Guillaume Burel: Embedding logics in Dedukti, 1 Outline Introduction
More informationLambda Calculus. Type Systems, Lectures 3. Jevgeni Kabanov Tartu,
Lambda Calculus Type Systems, Lectures 3 Jevgeni Kabanov Tartu, 13.02.2006 PREVIOUSLY ON TYPE SYSTEMS Arithmetical expressions and Booleans Evaluation semantics Normal forms & Values Getting stuck Safety
More informationType checking in the presence of meta-variables
Type checking in the presence of meta-variables Ulf Norell and Catarina Coquand Department of Computer Science and Engineering Chalmers University of Technology {ulfn,catarina}@cs.chalmers.se Abstract.
More informationFall 2013 Midterm Exam 10/22/13. This is a closed-book, closed-notes exam. Problem Points Score. Various definitions are provided in the exam.
Programming Languages Fall 2013 Midterm Exam 10/22/13 Time Limit: 100 Minutes Name (Print): Graduate Center I.D. This is a closed-book, closed-notes exam. Various definitions are provided in the exam.
More informationLecture 9: Typed Lambda Calculus
Advanced Topics in Programming Languages Spring Semester, 2012 Lecture 9: Typed Lambda Calculus May 8, 2012 Lecturer: Mooly Sagiv Scribe: Guy Golan Gueta and Shachar Itzhaky 1 Defining a Type System for
More informationSemantic Analysis Type Checking
Semantic Analysis Type Checking Maryam Siahbani CMPT 379 * Slides are modified version of Schwarz s compiler course at Stanford 4/8/2016 1 Type Checking Type errors arise when operations are performed
More informationLecture 3: Recursion; Structural Induction
15-150 Lecture 3: Recursion; Structural Induction Lecture by Dan Licata January 24, 2012 Today, we are going to talk about one of the most important ideas in functional programming, structural recursion
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 informationCSCI B522 Lecture 11 Naming and Scope 8 Oct, 2009
CSCI B522 Lecture 11 Naming and Scope 8 Oct, 2009 Lecture notes for CS 6110 (Spring 09) taught by Andrew Myers at Cornell; edited by Amal Ahmed, Fall 09. 1 Static vs. dynamic scoping The scope of a variable
More informationINF 212/CS 253 Type Systems. Instructors: Harry Xu Crista Lopes
INF 212/CS 253 Type Systems Instructors: Harry Xu Crista Lopes What is a Data Type? A type is a collection of computational entities that share some common property Programming languages are designed to
More informationOn Meaning Preservation of a Calculus of Records
On Meaning Preservation of a Calculus of Records Emily Christiansen and Elena Machkasova Computer Science Discipline University of Minnesota, Morris Morris, MN 56267 chri1101, elenam@morris.umn.edu Abstract
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 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 information9/23/2014. Why study? Lambda calculus. Church Rosser theorem Completeness of Lambda Calculus: Turing Complete
Dr A Sahu Dept of Computer Science & Engineering IIT Guwahati Why study? Lambda calculus Syntax Evaluation Relationship to programming languages Church Rosser theorem Completeness of Lambda Calculus: Turing
More informationDependent Object Types - A foundation for Scala s type system
Dependent Object Types - A foundation for Scala s type system Draft of September 9, 2012 Do Not Distrubute Martin Odersky, Geoffrey Alan Washburn EPFL Abstract. 1 Introduction This paper presents a proposal
More informationA 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(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 information5. Introduction to the Lambda Calculus. Oscar Nierstrasz
5. Introduction to the Lambda Calculus Oscar Nierstrasz Roadmap > What is Computability? Church s Thesis > Lambda Calculus operational semantics > The Church-Rosser Property > Modelling basic programming
More informationFrom 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 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 information