Derivation for the Necessity of Recursive Types and its Basic Usage

Size: px
Start display at page:

Download "Derivation for the Necessity of Recursive Types and its Basic Usage"

Transcription

1 Derivation for the Necessity of Recursive Types and its Basic Usage Philipp Koster Supervised by Prof. Dr. Farhad D. Mehta Seminar AT Abstract This paper derives the need for recursive types by simulating recursion in the untyped lambda calculus extending it with types of the simply typed lambda calculus showing the flaws of this typed recursion Further recursive types will be introduced by the derivation of the µ-operator defining equality of recursive types defining a well-typed fixpoint-combinator After introducing the recursive types the concept will be clarified with more usage examples. The key challenge of this paper will be to derive and explain the need of recursive types in a simple, nonetheless compact form. 1

2 2 Introduction Most programming languages do have built-in recursion. For example in Java a factorial function, which references itself, can be defined like this: public static long factorial ( long n) { if (n == 1) return 1; else return n * factorial ( n - 1); } The same can be done in the untyped and simply typed lambda calculus. Concerning the typing of the recursion, there exists some flaws, where recursive types will be an elegant solution for. In this paper will first these flaws be shown. Afterwards, will the recursive types be introduced to correct them. In the end, some more examples for the use of recursive types will be shown. 3 Derivation for Recursive Types In this section, the need for recursive types will be derived. Therefore, the factorial function will be implemented in the untyped lambda calculus. Later, the implementation will be enriched with types from the simply typed lambda calculus. In the end, the flaws of this solution will be shown. 3.1 Recursion in the Untyped Lambda Calculus In this section, the possibility to simulate recursion in the untyped lambda calculus, which has no built-in recursion, will be derived and explained. The approach to explain this as easy as possible is inspired by the following article [9]. This paper does not explain the whole untyped lambda calculus to the reader. This means that an understanding of its elements and use is required. Only some selected elements will be recapitulated shortly. If the basic knowledge is not provided, the following papers will help [2], [7]. Additionally, is it important to mention that some terms will be used without defining them beforehand (e.g. if, else, *, =). Furthermore, a slightly invalid form can be used to simplify terms. This, because it will lead to much more compact expressions. 2

3 The untyped lambda calculus is defined as follows: Syntax t ::= x λx.t t t terms: variable abstraction application Figure 1: Syntax of the untyped lambda calculus As known is it not possible to assign a term to a variable and reference this term in the assignment. Therefore, the following definition of the factorial function is not possible: factorial = λn.if n = 0 then 1 else n factorial(n 1) This term would only be possible if the language would have a built-in recursion. But as already said, is it possible to simulate recursion in a language without recursion. Therefore, the factorial function must be abstracted first: abstracted-factorial = λfactorial.λn.if n = 0 then 1 else n factorial(n 1) Simply said, is the new abstracted-factorial function a function, which takes an existing factorial function as argument and returns a working factorial function. Therefore, the following definition of a factorial function would work: factorial = abstracted-factorial existing-factorial But since the existing-factorial function does not exist yet, this finding seems to be useless. But indeed, it points in the right direction. Because even tough 3

4 the existing-factorial function does not exist yet, it is possible to define a function factorial0, which works correctly for the argument 0. To do that, the identity function can be passed as first argument to the abstracted-factorial function 1. factorial0 = abstracted-factorial identity Which leads to following implementation: factorial0 = λn.if n = 0 then 1 else n identity(n 1) It is clear that the factorial0 function works for the argument 0 but not for any higher values. But with this definition it is possible to define a factorial1 function like this: factorial1 = abstracted-factorial factorial0 Which is the same as: factorial1 = abstracted-factorial abstracted-factorial factorial0 And leads to the following implementation: factorial1 = λn.if n = 0 then 1 else n factorial0(n 1) 1 Actually, every function could have been used here. The reason why we chose the identity function is simply because it is the simplest known function. 4

5 As it is clear, the factorial1-function works for the arguments 1 and 0. This process can now be repeated infinitely, which would end in a definition like this: factorial =abstracted-factorial abstracted-factorial abstracted-factorial abstracted-factorial abstracted-factorial abstracted-factorial abstracted-factorial... factorial0 (1) Or written in a more compact, although invalid form: factorial = abstracted-factorial factorial (2) This is a function, which always adds one more call of the abstract-factorial function, if the right hand side is substituted. But again, it is not possible to use the defined function in the definition itself, since it would require recursion built into the language. To define a working factorial function, the fixpoint of the abstractedfactorial function is needed. A fixpoint is a value of a function, when applied to the function, results in the same value again. Or in other words, x is the fixpoint of the function f if: x = f(x) Figure 2: Definition of the fixpoint x for the function f In the lambda calculus the fixpoint is a function which, applied to another function, results in the same function. With that in mind, it becomes clear that the factorial function defined in (2) is a fixpoint of the abstracted-factorial function. 5

6 To retrieve a valid fixpoint of the abstracted-factorial, a fixpoint-combinator can be used. The normally used fixpoint-combinator in the untyped lambda calculus is the Curry s paradoxical combinator Y [3]. Its definition is 2 : fix = λf.(λx. f(λy. x x y))(λx. f(λy. x x y)) Figure 3: Definition of the fixpoint-combinator The definition of the fixpoint-combinator is not very intuitive and hard to understand. But applying it to the function f, leads to following reductions: fix f =f(fix f) f(f(fix f)) f(f(f(fix f))) f(f(f(f(fix f))))... Which is exactly equivalent to applying the abstracted-factorial an infinite time to itself, as done in (2). Therefore, the fixpoint-combinator can be applied to the abstract-factorial function to get the expression from (2): factorial = fix abstracted-factorial 2 There is a slightly simpler fixpoint-combinator for the call-by-name setting, which is useless in the call-by-value setting. 6

7 Finally, the factorial function can be defined in the untyped lambda calculus: abstracted-factorial = λfactorial.λn.if n = 0 then 1 factorial = fix abstracted-factorial else n factorial(n 1) Figure 4: Definition of the factorial function with the fixpoint-combinator Of course can the fixpoint-combinator not only been used for the factorial function, but for all recursive functions. It is even part of functional programming languages like Haskell (see [10]). The next challenge will be to type a recursive function. This will be done in the next section. 3.2 Extending Recursion with Simply Types In section 3.1 have been shown that recursion is possible in the untyped lambda calculus. In this section it will be shown how to extend this recursion with types from the simply typed lambda calculus. As in section 3.1 for the untyped lambda calculus, in this section a basic knowledge for the simply typed lambda calculus is required by the reader. If not provided, the following papers can help [8], [4]. The obvious first approach to get recursion in the simply typed lambda calculus is to simply add types to a recursive function, as the factorial function: abstracted-factorial = λfactorial:nat Nat. (1) λn:nat. if n = 0 then 1 else n factorial(n 1) factorial = fix abstracted-factorial (2) But how could the fixpoint-combinator be typed? This is actually not possible only using simply types. The reason for this is the fact that the simply typed 7

8 lambda calculus is strongly normalizing. This means for every well-typed term a normal form can be found. The normal form is the form of a term which can not be diverged any further. In other words, every well-typed term is guaranteed to halt in a finite number of steps [5]. But since the fixpoint-combinator does not have a normal form, because it never terminates, it is not possible to type it. To get around these circumstances, the simply typed lambda calculus must be extended by adding fix as a new primitive with the corresponding evaluation rules 3. The new primitive and the corresponding typing rule looks like this 4 : New syntactic forms t ::=... fix t terms: variable New typing rules Γ t 1 : T 1 T 1 Γ fix t 1 : T 1 (T-Fix) Figure 5: Adding fix as new primitive with corresponding typing rule With the new primitive the defined factorial function (1) from the beginning of this section is typed correctly. Regarding T-Fix, has the abstractfactorial function t 1 the type Nat Nat. This leads to the resulting type for the factorial function (2), namely N at. From this it follows, that the factorial function is typed Nat Nat. The recursive factorial function have now been typed in the simply typed lambda calculus, by adding a new primitive. But would it be possible to type the fixpoint-combinator itself and getting rid of the manually added fix 3 This extended simply typed lambda calculus is also known as PCF, which was introduced by [6]. 4 The new evaluation rules are not shown, since they are not important for the understanding of the concept. Furthermore, is the letrec construct, which would lead to a simpler syntax, not covered by this paper. 8

9 primitives? This is possible with the recursive types, which will be introduced in the next section. 4 Introducing Recursive Types In this section, the recursive types will be introduced. Recursive types can be used to define a well-typed fixpoint-combinator. In section 3.2, a new primitive was added to get around the fact that it is not possible to assign a type to the fixpoint-combinator with the simply typed lambda calculus. But what type system would be necessary to type following fixpoint-combinator 5? fix = λf.(λx. f(x x))(λx. f(x x)) When applying fix to the abstracted-factorial, the following expression results: fix abstracted-factorial = (λx. abstracted-factorial(x x))(λx. abstracted-factorial(x x)) Since the abstracted-factorial function takes an argument with the type N at, the x function should return this. This leads to the type for x: Nat Nat. But since x is also applied to itself, it has to take Nat Nat as argument too. In other words, the x function has to be able to take arguments with the following types: Nat Nat Nat But since Nat Nat Nat, such a type for x cannot be expressed. Recursive types, or more precisely the µ operator is required for this. 4.1 µ operator The µ operator is an abstraction operator for types, as λ is an abstraction operator for functions. It allows recursive type definitions, which can be used 5 To simplify the expression, the simpler call-by-name fixed point combinator is used. 9

10 to represent an infinite number of types. The µ operator can for example be used to type following NatList 6 : NatList = < nil : Unit, cons : {Nat, NatList} >; This NatList makes use of labeled variants, where nil and cons are field labels. The type of nil is Unit and the type of cons is a 2-tuple {Nat, NastList}. It is clear, that NatList diverges to a infinite tree, since the type of cons recursively references the N atlist. In Java, this type could look like this: public class NatList { public int value ; public NatList list ; } With the µ operator, it is possible to write this type like this: NatList = µx. < nil : Unit, cons : {Nat, X} >; This definition can be read as: NatList is the infinite type satisfying the equation X =< nil : Unit, cons : {Nat, X} >. The exact meaning of this and more usage examples will be shown in the section 4.4. But first, the equality for recursive types has to be defined, by formalizing it. The two different approaches are shown in the next section. 4.2 Equality for recursive types As seen in the previous section, diverges recursive type definitions. Going one step deeper into the type tree is called unfolding. Regarding the definition of the µ-operator µx.t, it means replacing all occurrences of X in the body T with the whole recursive type. For example, does the definition of NatList from the previous section, unfolds to following type: unfold µx. < nil : Unit, cons : {Nat, X} >= µx. < nil : Unit, cons : {Nat, µx. < nil : Unit, cons : {Nat, X} >} > 6 This example of a NatList is taken from [5]. 10

11 But are the old and the new type equal? There are two different approaches to define the equality. The equi-recursive approach defines two types to be equal if they stand for the same infinite tree. In other words, two types are equal, regardless of how many times one of them has been unfolded 7. The consequence of this definition is that it will be complex for a typechecker to decide if two types are equal 8. The second approach is the iso-recursive approach. Two types, one unfolded once, are considered to be different but isomorphic. With the isorecursive approach, the unfold and fold functions must be defined, where fold is the inverse function of unfold. A typechecker can use these methods to decide if two types are isomorphic. The equi-recursive approach is generally more intuitive, but it also requires a more complex typechecker. Additionally, the combination with more advanced typing features can lead to theoretical difficulties and even undecidable typechecking problems [5]. The iso-recursive approach on the other hand, does include more complexity for programs, since the fold and unfold operations must be defined 9. But despite the complexity, most functional programming languages are using the iso-recursive approach. After introducing the µ-operator and defining the equality of recursive types, the initial goal of defining a well-typed fixpoint-combinator can be tackled. This will be done in the next section. 4.3 Well-Typed Fixpoint-Combinator After introducing the µ-operator it is possible to define a well-typed fixpointcombinator. In the introduction of the section 4 it was pointed out, that it is not possible to type following expression: fix abstracted-factorial = (λx. abstracted-factorial(x x))(λx. abstracted-factorial(x x)) It was not possible to type it, since x would need the type Nat and the type Nat Nat. Exactly this is now possible with the infinite type µa.a Nat. 7 The unfold operator does actually not exist in the equi-recursive approach, since the term is unfolded implicitly. 8 There are algorithms to check this equivalence, which are proven to be correct [1]. 9 Even tough these definitions can be hidden. 11

12 This because the infinite type contains both types: Nat = µa.a Nat Nat Nat = unfold µa.a Nat = µa.a Nat Nat Recursive types can be used to define a type for the fixpoint-combinator likes this: fix T = λf : T T.(λx : (µa.a T ).f(x x))(λx : (µa.a. T ).f(x x)) The function f has the type T T. The two occurrences of x have the recursive type µa.a. T. This well-typed fixpoint-combinator fix T can now be used to define well-typed terms. For example, the factorial function can be defined as follows: abstracted-factorial = λfactorial.λn.if n = 0 then 1 factorial = fix T abstracted-factorial else n factorial(n 1) Finally, it is possible to define a well-typed fixpoint-combinator with recursive types. It is not necessary anymore to add fix as a primitive, as done in section 3.2. But recursive types can be used for other things as well. In the next section more examples for the use of recursive types will be shown. 4.4 Examples for Recursive Types In this section, two more examples for the use of recursive types will be shown Hungry Function A simple example for the use of recursive types is the definition of a function, which accepts an infinitely amount of arguments. The function is always 10 The examples are taken from [5]. 12

13 hungry for more. The type and the function can be defined like this: Hungry = µa. Nat A; hungry-function = fix(λf : Nat Hungry.λn : Nat. f); Applying the hungry-function to a number, a new hungry-function will be returned, which accepts again a number. This function does not make a any sense, but it shows the possibility to type it with recursive types Function Objects A good example for the use of recursive types, is the type for a functional object. A functional object can be defined by using records 11. Whereas each field of the record is a function of the object. When calling these functions, not the internal state of the object is mutated, but a new object with the new state is created and returned. The recursive types are used to type the functions accordingly. Counter = µc. {get : Nat, inc : Unit C, dec : Unit C} This type can now be used when creating a new object: c = let create = fix(λf :{x : Nat} Counter.λs : {x : Nat}. {get = s.x, {inc = λ : Unit.f{x = succ(s.x)}, {dec = λ : Unit.f{x = pred(s.x)}} in create {x = 0} Figure 6: Defining a purely functional counter object with recursive types For creating the object c, let bindings are used. The expression let create = fix(...)in create {x = 0} evaluates the fix(...) function and assigns its value 11 A record can be thought of as labeled tuple. 13

14 to create. Afterwards, create is applied to {x = 0}, to create the object c. The created object c can now be used like this: c1 = c.inc unit; c2 = c1.inc unit; Whereas the value for c2 is now 2. As already said, are c1 and c2 different objects. But with recursive types, they have the same type. 5 Conclusion This paper has shown in section 3.1 how recursion can be implemented in the untyped lambda calculus. This was done by using the fixpoint-combinator. In section 3.2 the recursion was extended with types of the simply typed lambda calculus. But it was not possible to type the fixpoint-combinator. This has been solved by adding fix as a new primitive. In section 4 recursive types were introduced. With the µ operator, it is possible to define infinite types. It has been shown that there exists to approaches to define the equality for types with the µ-operator: iso-recursive and equi-recursive. With recursive types, it was finally possible to type the fixpoint-combinator, without adding a new primitive. Besides the possibility to type a fixpointcombinator, more examples of recursive types were shown in section 4.4. References [1] Roberto M. Amadio and Luca Cardelli. Subtyping recursive types. In: ACM Transactions on Programming Languages and Systems (1993), pp doi: / url: lucacardelli.name/papers/srt.pdf. [2] Jonas Biedermann. The untyped lambda calculus - examination of theory and practice [3] Giuseppe Castagna. Object-oriented programming a unified foundation. Birkhauser, [4] Daniel Marty. Simply Typed Lambda Calculus

15 [5] Benjamin C. Pierce. Types and Programming Languages. 1 st. The MIT Press, isbn: , [6] G.D. Plotkin. LCF considered as a programming language. In: Theoretical Computer Science 5.3 (1977), pp issn: doi: url: [7] Daniel Schmid. Untyped lambda calculus [8] Marco Syfrig. Typed Lambda Calculus [9] Mike Vanier. The Y Combinator (Slight Return). Aug url: [10] Wikibooks. Haskell/Fix and recursion Wikibooks, The Free Textbook Project. [Online; accessed 11-December-2016] url: https: //en.wikibooks.org/w/index.php?title=haskell/fix_and_ recursion&oldid=

Derivation for the Necessity of Recursive Types and its Basic Usage

Derivation for the Necessity of Recursive Types and its Basic Usage Derivation for the Necessity of Recursive Types and its Basic Usage Philipp Koster Supervised by Prof. Dr. Farhad D. Mehta Seminar AT 2016 1 Abstract With this paper I ll derive the need for recursive

More information

ADT. Typing. Recursive Types. Java. Preliminary: syntax, operational semantics. Untyped lambda calculus. Simply typed lambda calculus

ADT. Typing. Recursive Types. Java. Preliminary: syntax, operational semantics. Untyped lambda calculus. Simply typed lambda calculus Review Preliminary: syntax, operational semantics Untyped lambda calculus Simply typed lambda calculus Simple extension: tuples, sums, lists Subtyping Typing ADT Universal type: system F Java Recursive

More information

Lecture 14: Recursive Types

Lecture 14: Recursive Types Lecture 14: Recursive Types Polyvios Pratikakis Computer Science Department, University of Crete Type Systems and Programming Languages Pratikakis (CSD) Recursive Types CS546, 2018-2019 1 / 11 Motivation

More information

Types and Programming Languages. Lecture 8. Recursive type

Types 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 information

Chapter 21: Metatheory of Recursive Types. Induction and Coinduction Finite and Infinite Types/Subtyping Membership Checking

Chapter 21: Metatheory of Recursive Types. Induction and Coinduction Finite and Infinite Types/Subtyping Membership Checking Chapter 21: Metatheory of Recursive Types Induction and Coinduction Finite and Infinite Types/Subtyping Membership Checking Review of Chapter 20 Recursive Types Lists NatList =

More information

CS 4110 Programming Languages & Logics. Lecture 28 Recursive Types

CS 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 information

Design Principles of Programming Languages. Recursive Types. Zhenjiang Hu, Haiyan Zhao, Yingfei Xiong Peking University, Spring Term

Design Principles of Programming Languages. Recursive Types. Zhenjiang Hu, Haiyan Zhao, Yingfei Xiong Peking University, Spring Term Design Principles of Programming Languages Recursive Types Zhenjiang Hu, Haiyan Zhao, Yingfei Xiong Peking University, Spring Term Review: what have we learned so far? λ-calculus: function and data can

More information

Design Principles of Programming Languages. Recursive Types. Zhenjiang Hu, Haiyan Zhao, Yingfei Xiong Peking University, Spring Term, 2014

Design Principles of Programming Languages. Recursive Types. Zhenjiang Hu, Haiyan Zhao, Yingfei Xiong Peking University, Spring Term, 2014 Design Principles of Programming Languages Recursive Types Zhenjiang Hu, Haiyan Zhao, Yingfei Xiong Peking University, Spring Term, 2014 Review: Why learn type theories? Art vs. Knowledge Art cannot be

More information

Lecture 9: More Lambda Calculus / Types

Lecture 9: More Lambda Calculus / Types Lecture 9: More Lambda Calculus / Types CSC 131 Spring, 2019 Kim Bruce Pure Lambda Calculus Terms of pure lambda calculus - M ::= v (M M) λv. M - Impure versions add constants, but not necessary! - Turing-complete

More information

- M ::= v (M M) λv. M - Impure versions add constants, but not necessary! - Turing-complete. - true = λ u. λ v. u. - false = λ u. λ v.

- M ::= v (M M) λv. M - Impure versions add constants, but not necessary! - Turing-complete. - true = λ u. λ v. u. - false = λ u. λ v. Pure Lambda Calculus Lecture 9: More Lambda Calculus / Types CSC 131 Spring, 2019 Kim Bruce Terms of pure lambda calculus - M ::= v (M M) λv. M - Impure versions add constants, but not necessary! - Turing-complete

More information

CS 4110 Programming Languages & Logics. Lecture 17 Programming in the λ-calculus

CS 4110 Programming Languages & Logics. Lecture 17 Programming in the λ-calculus CS 4110 Programming Languages & Logics Lecture 17 Programming in the λ-calculus 10 October 2014 Announcements 2 Foster Office Hours 11-12 Enjoy fall break! Review: Church Booleans 3 We can encode TRUE,

More information

CIS 500 Software Foundations Fall September 25

CIS 500 Software Foundations Fall September 25 CIS 500 Software Foundations Fall 2006 September 25 The Lambda Calculus The lambda-calculus If our previous language of arithmetic expressions was the simplest nontrivial programming language, then the

More information

Introduction to the Lambda Calculus

Introduction 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 information

Types and Programming Languages. Lecture 5. Extensions of simple types

Types 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 information

11/6/17. Outline. FP Foundations, Scheme. Imperative Languages. Functional Programming. Mathematical Foundations. Mathematical Foundations

11/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 information

Type Systems Winter Semester 2006

Type Systems Winter Semester 2006 Type Systems Winter Semester 2006 Week 4 November 8 November 15, 2006 - version 1.1 The Lambda Calculus The lambda-calculus If our previous language of arithmetic expressions was the simplest nontrivial

More information

Lambda Calculus. Lecture 4 CS /26/10

Lambda Calculus. Lecture 4 CS /26/10 Lambda Calculus Lecture 4 CS 565 10/26/10 Pure (Untyped) Lambda Calculus The only value is a function Variables denote functions Functions always take functions as arguments Functions always return functions

More information

CS 4110 Programming Languages & Logics. Lecture 27 Recursive Types

CS 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 information

Lambda Calculus. Type Systems, Lectures 3. Jevgeni Kabanov Tartu,

Lambda 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 information

λ calculus Function application Untyped λ-calculus - Basic Idea Terms, Variables, Syntax β reduction Advanced Formal Methods

λ 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 information

The Untyped Lambda Calculus

The Untyped Lambda Calculus 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

The Lambda Calculus. 27 September. Fall Software Foundations CIS 500. The lambda-calculus. Announcements

The Lambda Calculus. 27 September. Fall Software Foundations CIS 500. The lambda-calculus. Announcements CIS 500 Software Foundations Fall 2004 27 September IS 500, 27 September 1 The Lambda Calculus IS 500, 27 September 3 Announcements Homework 1 is graded. Pick it up from Cheryl Hickey (Levine 502). We

More information

CS611 Lecture 33 Equirecursive types & Recursive domain equations November 19, 2001

CS611 Lecture 33 Equirecursive types & Recursive domain equations November 19, 2001 CS611 Lecture 33 Equirecursive types & Recursive domain equations November 19, 001 Scribe: Hongzhou Liu and Junhwan Kim Lecturer: Andrew Myers 1 Semantics of recursive types, part There are two basic approaches

More information

Lecture Notes on Data Representation

Lecture 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 information

Untyped Lambda Calculus

Untyped Lambda Calculus Advanced Topics in Programming Languages Untyped Lambda Calculus Oded Padon & Mooly Sagiv (original slides by Kathleen Fisher, John Mitchell, Shachar Itzhaky, S. Tanimoto ) Reference: Types and Programming

More information

Pure (Untyped) λ-calculus. Andrey Kruglyak, 2010

Pure (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 information

CSE-321 Programming Languages 2011 Final

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

More information

Programming Languages Lecture 15: Recursive Types & Subtyping

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

More information

1.3. Conditional expressions To express case distinctions like

1.3. Conditional expressions To express case distinctions like Introduction Much of the theory developed in the underlying course Logic II can be implemented in a proof assistant. In the present setting this is interesting, since we can then machine extract from a

More information

Untyped Lambda Calculus

Untyped Lambda Calculus Concepts in Programming Languages Recitation 5: Untyped Lambda Calculus Oded Padon & Mooly Sagiv (original slides by Kathleen Fisher, John Mitchell, Shachar Itzhaky, S. Tanimoto ) Reference: Types and

More information

Introduction to the λ-calculus

Introduction to the λ-calculus Announcements Prelim #2 issues: o Problem 5 grading guide out shortly o Problem 3 (hashing) issues Will be on final! Friday RDZ office hours are 11-12 not 1:30-2:30 1 Introduction to the λ-calculus Today

More information

5. Introduction to the Lambda Calculus. Oscar Nierstrasz

5. 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 information

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

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages. Lambda calculus Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Tuesday, February 19, 2013 The lambda calculus (or λ-calculus) was introduced by Alonzo Church and Stephen Cole Kleene in

More information

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

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

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Lambda Calculus CMSC 330 1 Programming Language Features Many features exist simply for convenience Multi-argument functions foo ( a, b, c ) Use currying

More information

Introduction to lambda calculus Part 3

Introduction 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 information

CSE 505: Concepts of Programming Languages

CSE 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 information

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

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

More information

COMP 1130 Lambda Calculus. based on slides by Jeff Foster, U Maryland

COMP 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 information

The Untyped Lambda Calculus

The 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 information

Introduction to System F. Lecture 18 CS 565 4/20/09

Introduction 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 information

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

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

More information

CS152: Programming Languages. Lecture 7 Lambda Calculus. Dan Grossman Spring 2011

CS152: Programming Languages. Lecture 7 Lambda Calculus. Dan Grossman Spring 2011 CS152: Programming Languages Lecture 7 Lambda Calculus Dan Grossman Spring 2011 Where we are Done: Syntax, semantics, and equivalence For a language with little more than loops and global variables Now:

More information

Formal Systems and their Applications

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

More information

Whereweare. CS-XXX: Graduate Programming Languages. Lecture 7 Lambda Calculus. Adding data structures. Data + Code. What about functions

Whereweare. CS-XXX: Graduate Programming Languages. Lecture 7 Lambda Calculus. Adding data structures. Data + Code. What about functions Whereweare CS-XXX: Graduate Programming Languages Lecture 7 Lambda Calculus Done: Syntax, semantics, and equivalence For a language with little more than loops and global variables Now: Didn t IMP leave

More information

The Untyped Lambda Calculus

The Untyped Lambda Calculus 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

1 Scope, Bound and Free Occurrences, Closed Terms

1 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 information

Lecture 5: The Halting Problem. Michael Beeson

Lecture 5: The Halting Problem. Michael Beeson Lecture 5: The Halting Problem Michael Beeson Historical situation in 1930 The diagonal method appears to offer a way to extend just about any definition of computable. It appeared in the 1920s that it

More information

To What Extend Is Type Inference for Parameteric Polymorphism Possible in the Presence of Ad-Hoc and Subtype Polymorphism

To What Extend Is Type Inference for Parameteric Polymorphism Possible in the Presence of Ad-Hoc and Subtype Polymorphism To What Extend Is Type Inference for Parameteric Polymorphism Possible in the Presence of Ad-Hoc and Subtype Polymorphism Daniel Marty University of Applied Sciences Rapperswil Supervised by Prof. Dr.

More information

Quick announcement. Midterm date is Wednesday Oct 24, 11-12pm.

Quick announcement. Midterm date is Wednesday Oct 24, 11-12pm. Quick announcement Midterm date is Wednesday Oct 24, 11-12pm. The lambda calculus = ID (λ ID. ) ( ) The lambda calculus (Racket) = ID (lambda (ID) ) ( )

More information

More Untyped Lambda Calculus & Simply Typed Lambda Calculus

More Untyped Lambda Calculus & Simply Typed Lambda Calculus Concepts in Programming Languages Recitation 6: More Untyped Lambda Calculus & Simply Typed Lambda Calculus Oded Padon & Mooly Sagiv (original slides by Kathleen Fisher, John Mitchell, Shachar Itzhaky,

More information

Lambda Calculi With Polymorphism

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

More information

Lecture 5: The Untyped λ-calculus

Lecture 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 information

CS 6110 S14 Lecture 1 Introduction 24 January 2014

CS 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 information

Chapter 5: The Untyped Lambda Calculus

Chapter 5: The Untyped Lambda Calculus Chapter 5: The Untyped Lambda Calculus What is lambda calculus for? Basics: syntax and operational semantics Programming in the Lambda Calculus Formalities (formal definitions) What is Lambda calculus

More information

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...

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... Resources: The slides of this lecture were derived from [Järvi], with permission of the original author, by copy & x = 1 let x = 1 in... paste or by selection, annotation, or rewording. [Järvi] is in turn

More information

Programming Languages Lecture 14: Sum, Product, Recursive Types

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

More information

Exercise 1 ( = 22 points)

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

More information

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

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

More information

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

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

More information

Functions as data. Massimo Merro. 9 November Massimo Merro The Lambda language 1 / 21

Functions as data. Massimo Merro. 9 November Massimo Merro The Lambda language 1 / 21 Functions as data Massimo Merro 9 November 2011 Massimo Merro The Lambda language 1 / 21 The core of sequential programming languages In the mid 1960s, Peter Landin observed that a complex programming

More information

Fundamentals and lambda calculus

Fundamentals 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 information

Lambda Calculus. Concepts in Programming Languages Recitation 6:

Lambda Calculus. Concepts in Programming Languages Recitation 6: Concepts in Programming Languages Recitation 6: Lambda Calculus Oded Padon & Mooly Sagiv (original slides by Kathleen Fisher, John Mitchell, Shachar Itzhaky, S. Tanimoto ) Reference: Types and Programming

More information

Chapter 13: Reference. Why reference Typing Evaluation Store Typings Safety Notes

Chapter 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 information

Exercise 1 ( = 24 points)

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

More information

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

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

More information

Exercise 1 (2+2+2 points)

Exercise 1 (2+2+2 points) 1 Exercise 1 (2+2+2 points) The following data structure represents binary trees only containing values in the inner nodes: data Tree a = Leaf Node (Tree a) a (Tree a) 1 Consider the tree t of integers

More information

INF 212 ANALYSIS OF PROG. LANGS LAMBDA CALCULUS. Instructors: Crista Lopes Copyright Instructors.

INF 212 ANALYSIS OF PROG. LANGS LAMBDA CALCULUS. Instructors: Crista Lopes Copyright Instructors. INF 212 ANALYSIS OF PROG. LANGS LAMBDA CALCULUS Instructors: Crista Lopes Copyright Instructors. History Formal mathematical system Simplest programming language Intended for studying functions, recursion

More information

Inductive Definitions, continued

Inductive 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 information

Programming Language Concepts: Lecture 19

Programming 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 information

Semantic Subtyping. Alain Frisch (ENS Paris) Giuseppe Castagna (ENS Paris) Véronique Benzaken (LRI U Paris Sud)

Semantic Subtyping.  Alain Frisch (ENS Paris) Giuseppe Castagna (ENS Paris) Véronique Benzaken (LRI U Paris Sud) Semantic Subtyping Alain Frisch (ENS Paris) Giuseppe Castagna (ENS Paris) Véronique Benzaken (LRI U Paris Sud) http://www.cduce.org/ Semantic Subtyping - Groupe de travail BD LRI p.1/28 CDuce A functional

More information

λ-calculus Lecture 1 Venanzio Capretta MGS Nottingham

λ-calculus Lecture 1 Venanzio Capretta MGS Nottingham λ-calculus Lecture 1 Venanzio Capretta MGS 2018 - Nottingham Table of contents 1. History of λ-calculus 2. Definition of λ-calculus 3. Data Structures 1 History of λ-calculus Hilbert s Program David Hilbert

More information

λ calculus is inconsistent

λ 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 information

Chapter 2 The Language PCF

Chapter 2 The Language PCF Chapter 2 The Language PCF We will illustrate the various styles of semantics of programming languages with an example: the language PCF Programming language for computable functions, also called Mini-ML.

More information

Lambda Calculus.

Lambda Calculus. Lambda Calculus Oded Padon & Mooly Sagiv (original slides by Kathleen Fisher, John Mitchell, Shachar Itzhaky, S. Tanimoto, Stephen A. Edwards) Benjamin Pierce Types and Programming Languages http://www.cs.cornell.edu/courses/cs3110/2008fa/recitations/rec26.html

More information

CSE-505: Programming Languages. Lecture 20.5 Recursive Types. Zach Tatlock 2016

CSE-505: Programming Languages. Lecture 20.5 Recursive Types. Zach Tatlock 2016 CSE-505: Programming Languages Lecture 20.5 Recursive Types Zach Tatlock 2016 Where are we System F gave us type abstraction code reuse strong abstractions different from real languages (like ML), but

More information

Denotational Semantics. Domain Theory

Denotational 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 information

Programming Language Features. CMSC 330: Organization of Programming Languages. Turing Completeness. Turing Machine.

Programming Language Features. CMSC 330: Organization of Programming Languages. Turing Completeness. Turing Machine. CMSC 330: Organization of Programming Languages Lambda Calculus Programming Language Features Many features exist simply for convenience Multi-argument functions foo ( a, b, c ) Ø Use currying or tuples

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Lambda Calculus CMSC 330 1 Programming Language Features Many features exist simply for convenience Multi-argument functions foo ( a, b, c ) Ø Use currying

More information

Introductory Example

Introductory Example CSc 520 Principles of Programming Languages 21: Lambda Calculus Introduction Christian Collberg Department of Computer Science University of Arizona collberg@cs.arizona.edu Copyright c 2005 Christian Collberg

More information

The University of Nottingham

The University of Nottingham The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER 2013-2014 G54FOP FOUNDATIONS OF PROGRAMMING Time allowed 2 hours Candidates may complete the front cover of their

More information

Handout 10: Imperative programs and the Lambda Calculus

Handout 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 information

CIS 500 Software Foundations Midterm I

CIS 500 Software Foundations Midterm I CIS 500 Software Foundations Midterm I October 11, 2006 Name: Student ID: Email: Status: Section: registered for the course not registered: sitting in to improve a previous grade not registered: just taking

More information

Lecture 9: Typed Lambda Calculus

Lecture 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 information

CS-XXX: Graduate Programming Languages. Lecture 17 Recursive Types. Dan Grossman 2012

CS-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 information

Pure Lambda Calculus. Lecture 17

Pure 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 information

Recursion. Lecture 6: More Lambda Calculus Programming. Fixed Points. Recursion

Recursion. Lecture 6: More Lambda Calculus Programming. Fixed Points. Recursion Recursion Lecture 6: More Lambda Calculus Programming CSC 131! Fall, 2014!! Kim Bruce Recursive definitions are handy! - fact = λn. cond (iszero n) 1 (Mult n (fact (Pred n)))! - Not a legal definition

More information

Recitation 8: Dynamic and Unityped Languages : Foundations of Programming Languages

Recitation 8: Dynamic and Unityped Languages : Foundations of Programming Languages Recitation 8: Dynamic and Unityped Languages 15-312: Foundations of Programming Languages Jeanne Luning Prak, Charles Yuan March 7, 2018 1 Untyped Languages In this recitation, we explore two languages:

More information

Lambda Calculus and Extensions as Foundation of Functional Programming

Lambda 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 information

We defined congruence rules that determine the order of evaluation, using the following evaluation

We 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 information

The 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 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 information

Symmetry in Type Theory

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

More information

Foundations. Yu Zhang. Acknowledgement: modified from Stanford CS242

Foundations. Yu Zhang. Acknowledgement: modified from Stanford CS242 Spring 2013 Foundations Yu Zhang Acknowledgement: modified from Stanford CS242 https://courseware.stanford.edu/pg/courses/317431/ Course web site: http://staff.ustc.edu.cn/~yuzhang/fpl Reading Concepts

More information

Presented By : Abhinav Aggarwal CSI-IDD, V th yr Indian Institute of Technology Roorkee. Joint work with: Prof. Padam Kumar

Presented By : Abhinav Aggarwal CSI-IDD, V th yr Indian Institute of Technology Roorkee. Joint work with: Prof. Padam Kumar Presented By : Abhinav Aggarwal CSI-IDD, V th yr Indian Institute of Technology Roorkee Joint work with: Prof. Padam Kumar A Seminar Presentation on Recursiveness, Computability and The Halting Problem

More information

CSE-321 Programming Languages 2010 Final

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

More information

Subsumption. Principle of safe substitution

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

More information

The Untyped Lambda Calculus

The Untyped Lambda Calculus CS738: Advanced Compiler Optimizations The Untyped Lambda Calculus Amey Karkare karkare@cse.iitk.ac.in http://www.cse.iitk.ac.in/~karkare/cs738 Department of CSE, IIT Kanpur Reference Book Types and Programming

More information

Overview. A normal-order language. Strictness. Recursion. Infinite data structures. Direct denotational semantics. Transition semantics

Overview. A normal-order language. Strictness. Recursion. Infinite data structures. Direct denotational semantics. Transition semantics Overview A normal-order language Strictness Recursion Infinite data structures Direct denotational semantics Transition semantics Lazy (call-by-need) evaluation and its semantics A Normal-Order Language

More information

COMP80 Lambda Calculus Programming Languages Slides Courtesy of Prof. Sam Guyer Tufts University Computer Science History Big ideas Examples:

COMP80 Lambda Calculus Programming Languages Slides Courtesy of Prof. Sam Guyer Tufts University Computer Science History Big ideas Examples: COMP80 Programming Languages Slides Courtesy of Prof. Sam Guyer Lambda Calculus Formal system with three parts Notation for functions Proof system for equations Calculation rules called reduction Idea:

More information

Polymorphism and System-F (OV)

Polymorphism 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