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

Size: px
Start display at page:

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

Transcription

1 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 based on [Pierce] as the underlying textbook. x(1).!x(1) x.set(1) Programming Language Theory The Lambda Calculus Ralf Lämmel [Järvi] Slides by J. Järvi: Programming Languages, CPSC TAMU (2009) [Pierce] B.C. Pierce: Types and Programming Languages, MIT Press, 2002

2 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 based on [Pierce] as the underlying textbook. x(1).!x(1) x.set(1) Programming Language Theory The Untyped Lambda Calculus Ralf Lämmel [Järvi] Slides by J. Järvi: Programming Languages, CPSC TAMU (2009) [Pierce] B.C. Pierce: Types and Programming Languages, MIT Press, 2002

3 What s the lambda calculus? It is the core of functional languages.... x x.x f. g. x.f (g x) The identity function Function composition 3

4 What s the lambda calculus? It is the core of functional languages. It is a mathematical system for studying programming languages. design, specification, implementation, type systems, et al. It comes in variations of typing: implicit/explicit/none. Formal systems built on top of simply typed lambda calculus: System F for studying polymorphism System F<: for studying subtyping... 4

5 Language constructs Abstract syntax: M ::= x M M λx.m M is a lambda term. An infinite set of variables x, y, z,... is assumed. M N is an application. Function M is applied to the argument N. λx.m is an abstraction. The resulting function maps x to M. Lambda functions are anonymous. 5

6 Computability theory Church s thesis: All intuitively computable functions are λ-definable. An established equivalence of notions of computability: Set of Lambda-definable functions = Set of Turing-computable functions 6

7 Syntax and semantics Syntax t ::=x tt x.t Terms A term that cannot be reduced further. v ::= x.t Values (normal forms) Evaluation t 1 0 t 1 t t 0 t 1 t 2 t 0 1 t 2 vt vt 0 ( x.t) v [v/x]t Aka Call by value : Reduce function position, then reduce argument position, then apply. 7

8 Syntactic sugar and conventions M N1...Nk means (...((M N1) N2)... Nk). Function application groups from left to right. λx.x y means (λx.(x y)). Function application has higher precedence. λx1x2... xk. M means λx1.(λx2.(...(λxk.(m))...))). 8

9 Variable binding λ is a binding operator: It binds a variable in the scope of the lambda abstraction. Examples: λx.m λx.x y x is bound (in the lambda abstraction) y is not bound (in the lambda abstraction). If a variable occurs in an expression without being bound, then it is called a free occurrence, or a free variable. Other occurrences of variables are called bound. An open term is one with free variable occurrences. A closed term is one without free variable occurrences. 9 preferred

10 Variable binding precise definition FV(M) defines the set of free variables in the term M FV(x) ={x} FV(MN) =FV(M) FV(N) FV( x.m) =FV(M) \{x} 10

11 Exercise: what are the free and bound variable occurrences in these terms? ( x.y)( y.y) x y xyy x.( y.x y)y 11

12 Inductive definition of substitution [N/x]x = N [N/x]y = y, y any variable di erent from x [N/x](M 1 M 2 )=([N/x]M 1 )([N/x]M 2 ) [N/x]( x.m) = x.m [N/x]( y.m) = y.([n/x]m), y not free in N Examples [z/x]x [z/x]( x.x x) [z/x]( y.y x) [z/x]( z.x z) z If this condition is not met, then a fresh variable is needed. x.x x y.y z a.z a 12

13 α-equivalence and conversion Names of bound variable are insignificant. λx.x defines the same function as λy.y Performing such renaming is also called α-conversion. Suppose two terms differ only on the names of bound variables. Then, they are said to be α-equivalent ( =α ). 13

14 Computation based on the lambda calculus Computation ( ) with the lambda calculus is then a series of Substitutions (so-called β-reductions), and ( Implicit ) α-conversions. Reflexive, transitive closure t 1 0 t 1 t t 0 t 1 t 2 t 0 1 t 2 vt vt 0 ( x.t) v [v/x]t M * N means M reduces to N in zero or more steps. 14

15 Extension / encoding of the untyped Lambda calculus Typical extensions (giving rise to so-called applied lambda calculi) Primitive types (numbers, Booleans,...) Type constructors (tuples, records,...) Recursive functions Effects (cell, exceptions,...)... Many extensions can be encoded in terms of the pure lambda calculus maybe such encoding is somewhat tedious. 15

16 Church Booleans Encodings of literals true = λt.λf.t false = λt.λf.f Conditional expression (if) Expectations ifthenelse b v w * v, if b = true ifthenelse b v w * w, if b = false Encoding ifthenelse = λb.λv.λw.b v w 16

17 Church pairs A Boolean value picks either the 1st or the 2nd value of the pair. Construction and projections pair = λf.λs.λb.b f s first = λp.p true second = λp.p false 17

18 Encodings of numbers c0 = λs.λz.z c1 = λs.λz.s z c2 = λs.λz.s (s z) c3 = λs.λz.s (s (s z)) Church numerals... Encodings of functions on numbers succ = λn.λs.λz.s (n s z) plus = λm.λn.λs.λz.m s (n s z) times = λm.λn.m (plus n) c0... A numeral n is a lambda abstraction that is parameterized by a case for zero, and a case for succ. In the body, the latter is applied n times to the former. This caters for primitive recursion. 18

19 Encoding of recursive functions in the untyped Lambda calculus Let us define the factorial function. Suppose we had recursive function definitions. f λn. if n == 0 then 1 else n*f(n - 1) But we don t have recursive functions! 19

20 Defining factorial as a fixed point Start from a recursive definition. f λn. if n == 0 then 1 else n*f(n - 1) Eliminate self-reference; receive function as argument. g λh.λn.if n == 0 then 1 else n*h(n - 1) g takes a function (h) and returns a function. Define f as a fixed point. f Y g 20

21 Fixed point combinators We call Y a fixed-point combinator if it satisfies the following definitional property: For all f : X X it holds that Y f = f (Y f) 100(M)$ Question: does such a Y exist? 21

22 A lambda term for Y One option: Y = λf.(λx.f (x x))(λx.f (x x)) Verification of the definitional property: Proof: =[unfold Y] =[beta reduce] =[beta reduce] Y g = g (Y g) Y g =[fold Y] g (Y g) (λf.(λx.f (x x))(λx.f (x x))) g (λx.g(x x))(λx.g(x x))) g ((λx.g(x x)) (λx.g(x x))) Not suitable for applicative order. 22

23 Summary: The untyped lambda calculus A concise core of functional programming. A foundation of computability. Textbook support: Types and Programming Languages Chapter 5 Outlook: The simply typed lambda calculus Polymorphism 23

24 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 based on [Pierce] as the underlying textbook. x(1).!x(1) x.set(1) Programming Language Theory The Simply Typed Lambda Calculus Ralf Lämmel [Järvi] Slides by J. Järvi: Programming Languages, CPSC TAMU (2009) [Pierce] B.C. Pierce: Types and Programming Languages, MIT Press, 2002

25 Towards typed lambda calculus Now suppose you want to distinguish values of different types: Booleans Numbers Functions on Booleans Functions on functions on Booleans Products, sums of These types need to be... specified in the program, and checked to be correct. 25

26 The simply typed lambda calculus Define syntax for types including function types. Extend lambda abstractions for explicit types. Define typing rules. Revise reduction semantics. Establish type safety. 26

27 Revised lambda abstraction Lambda abstractions are annotated with types: λx : T.t Grammar of types: T ::= nat bool We only consider these simple types here for simplicity. T T 27

28 Examples What are the types of these terms? λx : bool.x λf : bool bool.f x Note that lambda variables are typed explicitly. Here are the same terms for the untyped calculus: λx.x λf.f x 28

29 Meaningless terms Some terms diverge.... unless we end up showing strong normalization. Some applications are ill-typed, e.g.: (λf : bool bool.f x) true Goal: a type system to reject ill-typed terms. 29

30 Typing relation with context t : T read as: Term t has type T in the typing context A typing context is a sequence of bindings. Each binding is a variable-type pair, e.g.: x : T. Contexts are composed as in Γ, x : T. All variable names are distinct for a given Γ. Γ can be omitted if it is empty. Γ can be empty for closed terms. 30

31 Typing rules for simply-typed lambda calculus x, y, z, f, g range over variables s, t, u range over terms S, T, U range over types T-Variable x : T x : T T-Abstraction, x : T u : U x : T.u : T U T-Application t : U T u : U tu: T 31

32 Rules for bool T-True true : bool T-False false : bool These typing rules illustrate one option to add specific types and their operations to a basic lambda calculus. Basically, we need to add one rule per operation. 32

33 Evaluation rules Syntax (terms, values, types) t ::=x v tt v ::= x :T.t true false T ::=bool T T Evaluation rules t 1 t 1 t t t 1 t 2 t 1 t 2 vt vt ( x :T.t) v [v/x]t Evaluation rules do not bother with types. 33

34 Typing derivations Construct derivations as proofs of terms having a certain type. f : bool bool 2 f : bool bool f : bool bool ` f : bool bool f : bool bool ` false : bool g : bool 2 g : bool f : bool bool ` f false : bool g : bool ` g : bool ` ( f : bool bool.f false) :(bool bool) bool ` g : bool.g : bool bool ` ( f : bool bool.f false) g : bool.g : bool T-Variable x : T x : T T-Abstraction, x : T u : U x : T.u : T U T-Application t : U T u : U tu: T 34

35 Type safety = progress + preservation Progress: If t is a closed, well-typed term, then either t is a value, or there exists some u, such that t u. Preservation: If t : T and t u, then u : T Requires several trivial lemmas (properties) that are omitted here. 35

36 A few extensions of the simply typed Lambda calculus Recursion (fixed point combinator) Type annotation (for documentation, abstraction) Pairs (as a simple form of type construction) Lists (another example of type construction) Records (as a first step towards objects) Mutable variables (not discussed here)... 36

37 Recursion A fixed point combinator is definable in the untyped calculus. It is not definable in the simply typed version. A special combinator fix is added to the formal system. Alternatively, a more powerful type system is needed. See this and other extension on the slides with extra material towards the end of the slide deck! 37

38 Summary: The typed lambda calculus Typing relation carries argument for context. Recursion requires built-in Y combinator. Textbook support: Types and Programming Languages Chapters 7 and 11 Outlook: Lambda calculi with polymorphism Object calculi Process calculi 38

39 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 based on [Pierce] as the underlying textbook. x(1).!x(1) x.set(1) Programming Language Theory The Polymorphic Lambda Calculus (System F) Ralf Lämmel [Järvi] Slides by J. Järvi: Programming Languages, CPSC TAMU (2009) [Pierce] B.C. Pierce: Types and Programming Languages, MIT Press, 2002

40 Polymorphism -- Why? What s the identity function? In the simply typed lambda calculus, we need many! Examples λx:bool. x λx:nat. x λx:bool bool. x λx:bool nat. x... In need of polymorphic functions, i.e., functions that accept many types of arguments. 40

41 Kinds of polymorphism Parametric polymorphism ( all types ) Bounded polymorphism ( subtypes / OO) Ad-hoc polymorphism ( some types ) We focus on parametric polymorphism. Existential types ( exists as opposed to for all ) 41

42 System F -- Syntax tax Type variable t ::=x v tt t[t ] v ::= x :T.t X.t T ::=X T T X.T System F [Girard72,Reynolds74] = (simply-typed) lambda calculus + type abstraction & application Type application Type abstraction Polymorphic type Example: id : X.X X id =ΛX.λx :X.x 42

43 Examples Term id =ΛX.λx :X.x id[bool] id[bool] true id true Type : X.X X : bool bool : bool type error In actual programming languages, type application may be implicit. 43

44 System F -- Typing rules Type variables are held the context. T-Variable x : T x : T T-Abstraction, x : T u : U x : T.u : T U T-Application t : U T u : U tu: T Type variables are subject to alpha conversion. T-TypeAbstraction, X t : T X.t : X.T T-TypeApplication t : X.T t[t 1 ]:[T 1 /X ]T 44 Example: id : X.X X id =ΛX.λx :X.x

45 System F -- Evaluation rules E-AppFun t 1 t 1 t 1 t 2 t 1 t 2 E-TypeApp E-AppArg t t vt E-AppAbs ( x :T.t) v [v/x]t vt Example: id : X.X X id =ΛX.λx :X.x E-TypeApp t 1 t 1 t 1 [T ] t 1 [T ] E-TypeAppAbs ( X.t)[T ] [T /X ]t 45

46 The doubling function double: X.(X X) X X Instantiated with nat double=λx.λf :X X.λx :X.f (f x) double_nat = double [nat] : (nat nat) nat nat Instantiated with nat nat double_nat_arrow_nat = double [nat nat] : ((nat nat) nat nat) (nat nat) nat nat Invoking double double [nat] (λx : nat.succ (succ x)) 5 * 9 46

47 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 based on [Pierce] as the underlying textbook. x(1).!x(1) x.set(1) Programming Language Theory Extra material on the Lambda calculus Ralf Lämmel [Järvi] Slides by J. Järvi: Programming Languages, CPSC TAMU (2009) [Pierce] B.C. Pierce: Types and Programming Languages, MIT Press, 2002

48 Properties of reduction 48

49 Properties of reduction How do we select redexes for reduction steps? The given semantics first reduces function, then argument. The order could be inverted. The argument may not need to be reduced at all. Does the result depend on such a choice? Does reduction ultimately terminate with a normal form? 49

50 Illustration of different reductions (We assume natural numbers with +.) Option 1 (λf.λx.f (f x)) (λy.y + 1) 2 (λx.(λy.y +1) ((λy.y +1) x)) 2 (λx.(λy.y +1) (x +1)) 2 (λx.(x+1+1)) 2 (2+1+1) 4 Option 2 (λf.λx.f (f x)) (λy.y + 1) 2 (λx.(λy.y +1) ((λy.y +1) x)) 2 (λy.y +1) ((λy.y +1) 2)

51 Confluence Confluence: evaluation strategy is not significant for final value. That is: there is (at most) one normal form of a given expression. [ Rosser_theorem] 51

52 Confluence M * N means M reduces to N in zero or more steps. Confluence If M * N and M * N, then there exists some P such that N * P and N * P. 52

53 Strong normalization property of a calculus with reduction Definition: For every term M there is a normal form N such that M * N. Strong normalization properties for lambda calculi: Untyped lambda calculus: no ( x.x x)( x.x x) Simply-typed lambda calculus: yes 53

54 Evaluation/reduction strategies Full beta reduction Choice of strategy may impact termination behavior Reduce anywhere. Applicative order ( reduce the leftmost innermost redex ) Reduce argument before applying function. Normal order ( reduce the leftmost outermost redex ) Apply function before reducing argument. eager (strict) lazy (non-strict) 54

55 A few extensions of the simply typed Lambda calculus 55

56 A few extensions of the simply typed Lambda calculus Recursion (fixed point combinator) Type annotation (for documentation, abstraction) Pairs (as a simple form of type construction) Lists (another example of type construction) Records (as a first step towards objects) Mutable variables (not discussed here)... 56

57 Recursion A fixed point combinator is definable in the untyped calculus. It is not definable in the simply typed version. A special combinator fix is added to the formal system. Alternatively, a more powerful type system is needed. 57

58 Why is Y not typeable? Consider again the fixed-point combinator: Y = λf.(λx.f (x x))(λx.f (x x)) Let us simplify. Y contains self-application: λx. x x How could self-application be typeable? λx :?. x x The type of x would need to be obviously a function type and the argument type of the same type. 58

59 Illustration of fix iseven : nat bool iseven = fix iseven iseven is a generator for the iseven function. Given a function f that equates with iseven for numbers up to n, iseven f equates with iseven an approximation up to n + 2. fix iseven extends this to all n. iseven : (nat bool) nat bool iseven = λ f:nat bool. λ x:nat. if iszero x then true else if iszero (pred x) then false else f (pred (pred x)) 59

60 Intuition We think of unfolding the recursive definition. fix iseven 0 true fix iseven 1 false fix iseven 2 true fix iseven 3 false fix iseven 4 true iseven? 0 true iseven? 1 false iseven? 2? iseven (iseven?) 2 true iseven (iseven?) 3 false iseven (iseven?) 4? 60

61 Recursion in the presence of types Add a primitive fix. t ::=... fix t Typing rule t : T T fix t : T Evaluation rules fix ( x : T.t) t fix t t fix t [(fix ( x : T.t))/x] t 61

62 Type annotation (ascription) Syntax: t ::=... t as T Typing rule: t : T t as T : T Evaluation rules: t t as T v as T u u as T v 62

63 Typing of pairs: Pairs New syntax: t ::=... {t, t} t.1 t.2 New types: T ::=... T x T { } t : T u : U {t, u} : T U t : T t.1 : T U t : T t.2 : U U Evaluation rules: {v 1, v 2 }.1 v 1 {v 1, v 2 }.2 v 2 t t {t, u} {t, u} u u {v, u} {v, u } t t t.1 t.1 t t t.2 t.2 63

64 Lists New type:... List T New syntax:... nil[t] cons[t] t t isnil[t] t head[t] t tail[t] t New congruence rules, e.g.: New computation rules, e.g.: t 1 t 1 cons[t ] t 1 t 2 cons[t ] t 1 t 2 head[s] (cons[t ] v 1 v 2 ) v 1 New typing rules, e.g.: t : List T head[t ] t : T 64

65 Records Pairs generalize to tuples. Tuples further generalize to records. Records generalize to extensible records. Extensible records generalize to objects. We use the syntax: {age=44, name="smith"} {age=44, name="smith"}.name and write the types as: // record value // field access {age=44, name="smith"} : {age:int, name:string} 65

66 Records New syntax: t ::=... {l i = t i i21...n } t.l New values: v ::=... {l i = v i i21...n } New types: T ::=... {l i : T i i21...n } Typing of records: for each i, t i : T i {l i = t i i21...n } : {l i : T i i21...n } t : {l i : T i i21...n } t.l j : T j Evaluation rules: {l i = v i i21...n }.l j v j t t 0 t j t j 0 t.l t 0.l {l i = v i i21...j 1, l j = t j, l k = t k k2j+1...n } {l i = v i i21...j 1, l j = t j 0, l k = t k k2j+1...n } 66

67 More details on parametric polymorphism 67

68 Functions on polymorphic functions Consider the polymorphic identity function: id : X. X X id = ΛX.λx : X.x Use id to construct a pair of Boolean and String: pairid : (Bool, String) pairid = (id true, id true ) Abstract over id: pairapply : ( X. X X) (Bool, String) pairapply = λf : X. X X. (f true, f true ) Type application left implicit. Argument must be polymorphic! 68

69 Self application Not typeable in the simply-typed lambda calculus λx :?. x x Typeable in System F selfapp : ( X.X X) ( X.X X) selfapp = λx : X.X X.x [ X.X X] x 69

70 The fix operator (Y) Not typeable in the simply-typed lambda calculus Extension required Typeable in System F. t : T T fix t : T fix : X.(X X) X Encodeable in System F with recursive types. fix =? See [TAPL] 70

71 Meaning of all types In the type X...., we quantify over all types. Predicative polymorphism X ranges over simple types. Polymorphic types are type schemes. Type inference is decidable. Impredicative polymorphism X also ranges over polymorphic types. Type inference is undecidable. type:type polymorphism X ranges over all types, including itself. Computations on types are expressible. Type checking is undecidable. Not covered by this lecture Generality is used for selfapp. 71

72 End of Lambda slides 72

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

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

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

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

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

Formal Semantics. Aspects to formalize. Lambda calculus. Approach

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

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

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

Lambda Calculus. Variables and Functions. cs3723 1

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

Introduction to Lambda Calculus. Lecture 5 CS 565 1/24/08

Introduction to Lambda Calculus. Lecture 5 CS 565 1/24/08 Introduction to Lambda Calculus Lecture 5 CS 565 1/24/08 Lambda Calculus So far, we ve explored some simple but non-interesting languages language of arithmetic expressions IMP (arithmetic + while loops)

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

Introduction to Lambda Calculus. Lecture 7 CS /08/09

Introduction to Lambda Calculus. Lecture 7 CS /08/09 Introduction to Lambda Calculus Lecture 7 CS 565 02/08/09 Lambda Calculus So far, we ve explored some simple but non-interesting languages language of arithmetic expressions IMP (arithmetic + while loops)

More information

Constraint-based Analysis. Harry Xu CS 253/INF 212 Spring 2013

Constraint-based Analysis. Harry Xu CS 253/INF 212 Spring 2013 Constraint-based Analysis Harry Xu CS 253/INF 212 Spring 2013 Acknowledgements Many slides in this file were taken from Prof. Crista Lope s slides on functional programming as well as slides provided by

More information

Concepts of programming languages

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

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

Type Systems. Parametric Polymorphism. 1. Recall Let-Polymorphism. 1. Recall Let-Polymorphism. Lecture 9 Dec. 15th, 2004 Sebastian Maneth

Type Systems. Parametric Polymorphism. 1. Recall Let-Polymorphism. 1. Recall Let-Polymorphism. Lecture 9 Dec. 15th, 2004 Sebastian Maneth Today Parametric Polymorphism Type Systems Lecture 9 Dec. 15th, 2004 Sebastian Maneth 1. Recall Let-Polymorphism 4. System F-sub 5. Properties of F-sub http://lampwww.epfl.ch/teaching/typesystems/2004

More 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

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

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

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

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

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

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

More information

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

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

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

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

dynamically typed dynamically scoped

dynamically typed dynamically scoped Reference Dynamically Typed Programming Languages Part 1: The Untyped λ-calculus Jim Royer CIS 352 April 19, 2018 Practical Foundations for Programming Languages, 2/e, Part VI: Dynamic Types, by Robert

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

Costly software bugs that could have been averted with type checking

Costly software bugs that could have been averted with type checking Type Checking Class Notes from Lectures 6 and 7 Lahav Yeffet and Ori Folger The material in these lectures is based on the textbook Types and Programming Languages by Benjamin Pierce. Here is a list of

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. Deian Stefan (adopted from my & Edward Yang s CSE242 slides)

Fundamentals and lambda calculus. Deian Stefan (adopted from my & Edward Yang s CSE242 slides) Fundamentals and lambda calculus Deian Stefan (adopted from my & Edward Yang s CSE242 slides) Logistics Assignments: Programming assignment 1 is out Homework 1 will be released tomorrow night Podcasting:

More information

Last class. CS Principles of Programming Languages. Introduction. Outline

Last class. CS Principles of Programming Languages. Introduction. Outline Last class CS6848 - Principles of Programming Languages Principles of Programming Languages V. Krishna Nandivada IIT Madras Interpreters A Environment B Cells C Closures D Recursive environments E Interpreting

More information

CMSC 330: Organization of Programming Languages. Lambda Calculus Encodings

CMSC 330: Organization of Programming Languages. Lambda Calculus Encodings CMSC 330: Organization of Programming Languages Lambda Calculus Encodings CMSC330 Spring 2018 1 The Power of Lambdas Despite its simplicity, the lambda calculus is quite expressive: it is Turing complete!

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

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

CIS 500 Software Foundations Fall December 6

CIS 500 Software Foundations Fall December 6 CIS 500 Software Foundations Fall 2006 December 6 Administrivia Administrivia No recitations this week Extra office hours will be posted to the class mailing list Exam: Wednesday, Dec 20, 9 11 Location:

More information

Administrivia. Existential Types. CIS 500 Software Foundations Fall December 6. Administrivia. Motivation. Motivation

Administrivia. Existential Types. CIS 500 Software Foundations Fall December 6. Administrivia. Motivation. Motivation CIS 500 Software Foundations Fall 2006 Administrivia December 6 Administrivia No recitations this week Extra office hours will be posted to the class mailing list Exam: Wednesday, Dec 20, 9 11 Location:

More information

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

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Lambda Calculus Encodings CMSC 330 Spring 2017 1 Review A lambda calculus expression is defined as e ::= x variable λx.e abstraction (fun def) e e application

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Lambda Calculus Encodings CMSC 330 Summer 2017 1 The Power of Lambdas Despite its simplicity, the lambda calculus is quite expressive: it is Turing complete!

More information

Activity. CSCI 334: Principles of Programming Languages. Lecture 4: Fundamentals II. What is computable? What is computable?

Activity. CSCI 334: Principles of Programming Languages. Lecture 4: Fundamentals II. What is computable? What is computable? Activity CSCI 334: Principles of Programming Languages Lecture 4: Fundamentals II Write a function firsts that, when given a list of cons cells, returns a list of the left element of each cons. ( (a. b)

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

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

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

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

λ 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

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

CITS3211 FUNCTIONAL PROGRAMMING

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

VU Semantik von Programmiersprachen

VU Semantik von Programmiersprachen VU Semantik von Programmiersprachen Agata Ciabattoni Institute für Computersprachen, Theory and Logic group (agata@logic.at) (A gentle) Introduction to λ calculus p. 1 Why shoud I studyλcalculus? p. 2

More information

One of a number of approaches to a mathematical challenge at the time (1930): Constructibility

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

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

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

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

CIS 500 Software Foundations Fall October 2

CIS 500 Software Foundations Fall October 2 CIS 500 Software Foundations Fall 2006 October 2 Preliminaries Homework Results of my email survey: There was one badly misdesigned (PhD) problem and a couple of others that were less well thought through

More information

Lambda Calculus and Type Inference

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

Harvard School of Engineering and Applied Sciences Computer Science 152

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

More information

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

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

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

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

(Refer Slide Time: 4:00)

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

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

Lambda Calculus and Type Inference

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

The lambda calculus (An introduction)

The lambda calculus (An introduction) The lambda calculus (An introduction) Ralf Lämmel Software Language Engineering Team University of Koblenz-Landau http://www.softlang.org/ Dependencies: Tree-based abstract syntax Operational semantics

More information

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

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

More information

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

Polymorphism. Lecture 19 CS 565 4/17/08

Polymorphism. Lecture 19 CS 565 4/17/08 Polymorphism Lecture 19 CS 565 4/17/08 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 need to write

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

Functional Programming and λ Calculus. Amey Karkare Dept of CSE, IIT Kanpur

Functional Programming and λ Calculus. Amey Karkare Dept of CSE, IIT Kanpur Functional Programming and λ Calculus Amey Karkare Dept of CSE, IIT Kanpur 0 Software Development Challenges Growing size and complexity of modern computer programs Complicated architectures Massively

More information

3.1 λ-calculus: Syntax

3.1 λ-calculus: Syntax 3 The Lambda Calculus The Lambda calculus, or λ-calculus, is a model of computation based on the idea that algorithms can be seen as mathematical functions mapping inputs to outputs. It was introduced

More information

1 Introduction. 3 Syntax

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

More information

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

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

More information

Computer Science 203 Programming Languages Fall Lecture 10. Bindings, Procedures, Functions, Functional Programming, and the Lambda Calculus

Computer Science 203 Programming Languages Fall Lecture 10. Bindings, Procedures, Functions, Functional Programming, and the Lambda Calculus 1 Computer Science 203 Programming Languages Fall 2004 Lecture 10 Bindings, Procedures, Functions, Functional Programming, and the Lambda Calculus Plan Informal discussion of procedures and bindings Introduction

More information

Functional Languages and Higher-Order Functions

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

Fall 2013 Midterm Exam 10/22/13. This is a closed-book, closed-notes exam. Problem Points Score. Various definitions are provided in the exam.

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

A Quick Overview. CAS 701 Class Presentation 18 November Department of Computing & Software McMaster University. Church s Lambda Calculus

A Quick Overview. CAS 701 Class Presentation 18 November Department of Computing & Software McMaster University. Church s Lambda Calculus A Quick Overview CAS 701 Class Presentation 18 November 2008 Lambda Department of Computing & Software McMaster University 1.1 Outline 1 2 3 Lambda 4 5 6 7 Type Problem Lambda 1.2 Lambda calculus is a

More information

Lambda Calculus. CS 550 Programming Languages Jeremy Johnson

Lambda Calculus. CS 550 Programming Languages Jeremy Johnson Lambda Calculus CS 550 Programming Languages Jeremy Johnson 1 Lambda Calculus The semantics of a pure functional programming language can be mathematically described by a substitution process that mimics

More information

Programming Languages

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

More information

Lambda Calculus alpha-renaming, beta reduction, applicative and normal evaluation orders, Church-Rosser theorem, combinators

Lambda Calculus alpha-renaming, beta reduction, applicative and normal evaluation orders, Church-Rosser theorem, combinators Lambda Calculus alpha-renaming, beta reduction, applicative and normal evaluation orders, Church-Rosser theorem, combinators Carlos Varela Rennselaer Polytechnic Institute February 11, 2010 C. Varela 1

More information

CMSC 330: Organization of Programming Languages. Lambda Calculus

CMSC 330: Organization of Programming Languages. Lambda Calculus CMSC 330: Organization of Programming Languages Lambda Calculus 1 Turing Completeness Turing machines are the most powerful description of computation possible They define the Turing-computable functions

More information

CMSC330. Objects, Functional Programming, and lambda calculus

CMSC330. Objects, Functional Programming, and lambda calculus CMSC330 Objects, Functional Programming, and lambda calculus 1 OOP vs. FP Object-oriented programming (OOP) Computation as interactions between objects Objects encapsulate mutable data (state) Accessed

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

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

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Lambda Calculus CMSC 330 Summer 2017 1 100 years ago Albert Einstein proposed special theory of relativity in 1905 In the paper On the Electrodynamics of

More information

CSE-321 Programming Languages 2012 Midterm

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

More information

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

9/23/2014. Why study? Lambda calculus. Church Rosser theorem Completeness of Lambda Calculus: Turing Complete

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

CMSC 330: Organization of Programming Languages. Lambda Calculus

CMSC 330: Organization of Programming Languages. Lambda Calculus CMSC 330: Organization of Programming Languages Lambda Calculus 1 100 years ago Albert Einstein proposed special theory of relativity in 1905 In the paper On the Electrodynamics of Moving Bodies 2 Prioritätsstreit,

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