The Untyped Lambda Calculus
|
|
- Cody Boyd
- 5 years ago
- Views:
Transcription
1 CS738: Advanced Compiler Optimizations The Untyped Lambda Calculus Amey Karkare Department of CSE, IIT Kanpur
2 Reference Book Types and Programming Languages by Benjamin C. Pierce
3 The Abstract Syntax t := x Variable
4 The Abstract Syntax t := x Variable λx.t Abstraction
5 The Abstract Syntax t := x Variable λx.t Abstraction t t Application
6 The Abstract Syntax t := x Variable λx.t Abstraction t t Application Parenthesis, (... ), can be used for grouping and scoping.
7 Conventions λx.t 1 t 2 t 3 is an abbreviation for λx.(t 1 t 2 t 3 ), i.e., the scope of x is as far to the right as possible until it is
8 Conventions λx.t 1 t 2 t 3 is an abbreviation for λx.(t 1 t 2 t 3 ), i.e., the scope of x is as far to the right as possible until it is terminated by a ) whose matching ( occurs to the left pf λ, OR
9 Conventions λx.t 1 t 2 t 3 is an abbreviation for λx.(t 1 t 2 t 3 ), i.e., the scope of x is as far to the right as possible until it is terminated by a ) whose matching ( occurs to the left pf λ, OR terminated by the end of the term.
10 Conventions λx.t 1 t 2 t 3 is an abbreviation for λx.(t 1 t 2 t 3 ), i.e., the scope of x is as far to the right as possible until it is terminated by a ) whose matching ( occurs to the left pf λ, OR terminated by the end of the term. Applications associate to the left: t 1 t 2 t 3 to be read as (t 1 t 2 )t 3 and not as t 1 (t 2 t 3 )
11 Conventions λx.t 1 t 2 t 3 is an abbreviation for λx.(t 1 t 2 t 3 ), i.e., the scope of x is as far to the right as possible until it is terminated by a ) whose matching ( occurs to the left pf λ, OR terminated by the end of the term. Applications associate to the left: t 1 t 2 t 3 to be read as (t 1 t 2 )t 3 and not as t 1 (t 2 t 3 ) λxyz.t is an abbreviation for λxλyλz.t which in turn is abbreviation for λx.(λy.(λz.t)).
12 α-renaming The name of a bound variable has no meaning except for its use to identify the bounding λ.
13 α-renaming The name of a bound variable has no meaning except for its use to identify the bounding λ. Renaming a λ variable, including all its bound occurrences, does not change the meaning of an expression. For example, λx.x x y is equivalent to λu.u u y
14 α-renaming The name of a bound variable has no meaning except for its use to identify the bounding λ. Renaming a λ variable, including all its bound occurrences, does not change the meaning of an expression. For example, λx.x x y is equivalent to λu.u u y But it is not same as λx.x x w
15 α-renaming The name of a bound variable has no meaning except for its use to identify the bounding λ. Renaming a λ variable, including all its bound occurrences, does not change the meaning of an expression. For example, λx.x x y is equivalent to λu.u u y But it is not same as λx.x x w Can not change free variables!
16 β-reduction (Execution Semantics) if an abstraction λx.t 1 is applied to a term t 2 then the result of the application is
17 β-reduction (Execution Semantics) if an abstraction λx.t 1 is applied to a term t 2 then the result of the application is the body of the abstraction t 1 with all free occurrences of the formal parameter x replaced with t 2.
18 β-reduction (Execution Semantics) if an abstraction λx.t 1 is applied to a term t 2 then the result of the application is the body of the abstraction t 1 with all free occurrences of the formal parameter x replaced with t 2. For example, (λfλx.f (f x)) g β λx.g (g x)
19 Caution During β-reduction, make sure a free variable is not captured inadvertently.
20 Caution During β-reduction, make sure a free variable is not captured inadvertently. The following reduction is WRONG (λxλy.x)(λx.y) β λy.λx.y
21 Caution During β-reduction, make sure a free variable is not captured inadvertently. The following reduction is WRONG (λxλy.x)(λx.y) β λy.λx.y Use α-renaming to avoid variable capture (λxλy.x)(λx.y) α β (λuλv.u)(λx.y) λv.λx.y
22 Exercise Apply β-reduction as far as possible 1. (λx y z. x z (y z)) (λx y. x) (λy.y) 2. (λx. x x)(λx. x x) 3. (λx y z. x z (y z)) (λx y. x) ((λx. x x)(λx. x x))
23 Church-Rosser Theorem Multiple ways to apply β-reduction
24 Church-Rosser Theorem Multiple ways to apply β-reduction Some may not terminate
25 Church-Rosser Theorem Multiple ways to apply β-reduction Some may not terminate However, if two different reduction sequences terminate then they always terminate in the same term
26 Church-Rosser Theorem Multiple ways to apply β-reduction Some may not terminate However, if two different reduction sequences terminate then they always terminate in the same term Also called the Diamond Property
27 Church-Rosser Theorem Multiple ways to apply β-reduction Some may not terminate However, if two different reduction sequences terminate then they always terminate in the same term Also called the Diamond Property Leftmost, outermost reduction will find the normal form if it exists
28 Programming in λ Calculus Where is the other stuff?
29 Programming in λ Calculus Where is the other stuff? Constants?
30 Programming in λ Calculus Where is the other stuff? Constants? Numbers
31 Programming in λ Calculus Where is the other stuff? Constants? Numbers Booleans
32 Programming in λ Calculus Where is the other stuff? Constants? Numbers Booleans Complex Types?
33 Programming in λ Calculus Where is the other stuff? Constants? Numbers Booleans Complex Types? Lists
34 Programming in λ Calculus Where is the other stuff? Constants? Numbers Booleans Complex Types? Lists Arrays
35 Programming in λ Calculus Where is the other stuff? Constants? Numbers Booleans Complex Types? Lists Arrays Don t we need data?
36 Programming in λ Calculus Where is the other stuff? Constants? Numbers Booleans Complex Types? Lists Arrays Don t we need data?
37 Programming in λ Calculus Where is the other stuff? Constants? Numbers Booleans Complex Types? Lists Arrays Don t we need data? Abstractions act as functions as well as data!
38 Numbers: Church Numerals We need a Zero
39 Numbers: Church Numerals We need a Zero Absence of item
40 Numbers: Church Numerals We need a Zero Absence of item And something to count
41 Numbers: Church Numerals We need a Zero Absence of item And something to count Presence of item
42 Numbers: Church Numerals We need a Zero Absence of item And something to count Presence of item Intuition: Whiteboard and Marker
43 Numbers: Church Numerals We need a Zero Absence of item And something to count Presence of item Intuition: Whiteboard and Marker Blank board represents Zero
44 Numbers: Church Numerals We need a Zero Absence of item And something to count Presence of item Intuition: Whiteboard and Marker Blank board represents Zero Each mark by marker represents a count.
45 Numbers: Church Numerals We need a Zero Absence of item And something to count Presence of item Intuition: Whiteboard and Marker Blank board represents Zero Each mark by marker represents a count. However, other pairs of objects will work as well
46 Numbers: Church Numerals We need a Zero Absence of item And something to count Presence of item Intuition: Whiteboard and Marker Blank board represents Zero Each mark by marker represents a count. However, other pairs of objects will work as well Lets translate this intuition into λ-expressions
47 Numbers Zero = λm w. w
48 Numbers Zero = λm w. w No mark on the whiteboard
49 Numbers Zero = λm w. w No mark on the whiteboard One = λm w. m w
50 Numbers Zero = λm w. w No mark on the whiteboard One = λm w. m w One mark on the whiteboard
51 Numbers Zero = λm w. w No mark on the whiteboard One = λm w. m w One mark on the whiteboard Two = λm w. m (m w)
52 Numbers Zero = λm w. w No mark on the whiteboard One = λm w. m w One mark on the whiteboard Two = λm w. m (m w)...
53 Numbers Zero = λm w. w No mark on the whiteboard One = λm w. m w One mark on the whiteboard Two = λm w. m (m w)... What about operations?
54 Numbers Zero = λm w. w No mark on the whiteboard One = λm w. m w One mark on the whiteboard Two = λm w. m (m w)... What about operations? add, multiply, subtract, divide,...?
55 Operations on Numbers succ = λx m w. m (x m w)
56 Operations on Numbers succ = λx m w. m (x m w) Verify: succ N = N + 1
57 Operations on Numbers succ = λx m w. m (x m w) Verify: succ N = N + 1 add = λx y m w. x m (y m w)
58 Operations on Numbers succ = λx m w. m (x m w) Verify: succ N = N + 1 add = λx y m w. x m (y m w) Verify: add M N = M + N
59 Operations on Numbers succ = λx m w. m (x m w) Verify: succ N = N + 1 add = λx y m w. x m (y m w) Verify: add M N = M + N mult = λx y m w. x (y m) w
60 Operations on Numbers succ = λx m w. m (x m w) Verify: succ N = N + 1 add = λx y m w. x m (y m w) Verify: add M N = M + N mult = λx y m w. x (y m) w Verify: mult M N = M * N
61 More Operations pred = λx m w. x (λg h. h (g m))(λu. w)(λu. u)
62 More Operations pred = λx m w. x (λg h. h (g m))(λu. w)(λu. u) Verify: pred N = N - 1
63 More Operations pred = λx m w. x (λg h. h (g m))(λu. w)(λu. u) Verify: pred N = N - 1 nminus = λx y. y pred x
64 More Operations pred = λx m w. x (λg h. h (g m))(λu. w)(λu. u) Verify: pred N = N - 1 nminus = λx y. y pred x Verify: nminus M N = max(0, M - N) natural subtraction
65 Church Booleans True and False
66 Church Booleans True and False Intuition: Selection of one out of two (complementary) choices
67 Church Booleans True and False Intuition: Selection of one out of two (complementary) choices True = λx y. x
68 Church Booleans True and False Intuition: Selection of one out of two (complementary) choices True = λx y. x False = λx y. y
69 Church Booleans True and False Intuition: Selection of one out of two (complementary) choices True = λx y. x False = λx y. y Predicate:
70 Church Booleans True and False Intuition: Selection of one out of two (complementary) choices True = λx y. x False = λx y. y Predicate: iszero = λx. x (λu.false) True
71 Operations on Booleans Logical operations and or not = λp q. p q p = λp q. p p q = λp t f.p f t
72 Operations on Booleans Logical operations and or not = λp q. p q p = λp q. p p q = λp t f.p f t The conditional operator if if = λc e t e f. (c e t e f )
73 Operations on Booleans Logical operations and or not = λp q. p q p = λp q. p p q = λp t f.p f t The conditional operator if if c e t e f reduces to e t if c is True, and to e f if c is False if = λc e t e f. (c e t e f )
74 More... More such types can be found at
75 More... More such types can be found at It is fun to come up with your own definitions for constants and operations over different types
76 More... More such types can be found at It is fun to come up with your own definitions for constants and operations over different types or to develop understanding for existing definitions.
77 We are missing something!! The machinery described so far does not allow us to define Recursive functions Factorial, Fibonacci,... There is no concept of named functions So no way to refer to a function recursively! Fix-point computation comes to rescue
78 Fix-point and Y -combinator A fix-point of a function f is a value p such that f p = p
79 Fix-point and Y -combinator A fix-point of a function f is a value p such that f p = p Assume existence of a magic expression, called Y-combinator, that when applied to a λ-expression, gives its fixed point Y f = f (Y f)
80 Fix-point and Y -combinator A fix-point of a function f is a value p such that f p = p Assume existence of a magic expression, called Y-combinator, that when applied to a λ-expression, gives its fixed point Y f = f (Y f) Y-combinator gives us a way to apply a function recursively
81 Recursion Example: Factorial fact = λn. if (iszero n) One (mult n (fact (pred n))) = (λf n. if (iszero n) One (mult n (f (pred n)))) fact
82 Recursion Example: Factorial fact = λn. if (iszero n) One (mult n (fact (pred n))) = (λf n. if (iszero n) One (mult n (f (pred n)))) fact fact = g fact fact is a fixed point of the function g = (λf n. if (iszero n)one (mult n (f (pred n))))
83 Recursion Example: Factorial fact = λn. if (iszero n) One (mult n (fact (pred n))) = (λf n. if (iszero n) One (mult n (f (pred n)))) fact fact = g fact fact is a fixed point of the function g = (λf n. if (iszero n)one (mult n (f (pred n)))) Using Y-combinator, fact = Y g
84 Factorial: Verify fact 2 = (Y g) 2
85 Factorial: Verify fact 2 = (Y g) 2 = g (Y g) 2 by definition of Y-combinator
86 Factorial: Verify fact 2 = (Y g) 2 = g (Y g) 2 by definition of Y-combinator = (λfn. if (iszero n) 1 (mult n (f (pred n)))) (Y g) 2
87 Factorial: Verify fact 2 = (Y g) 2 = g (Y g) 2 by definition of Y-combinator = (λfn. if (iszero n) 1 (mult n (f (pred n)))) (Y g) 2 = (λn. if (iszero n) 1 (mult n ((Y g) (pred n)))) 2
88 Factorial: Verify fact 2 = (Y g) 2 = g (Y g) 2 by definition of Y-combinator = (λfn. if (iszero n) 1 (mult n (f (pred n)))) (Y g) 2 = (λn. if (iszero n) 1 (mult n ((Y g) (pred n)))) 2 = if (iszero 2) 1 (mult 2 ((Y g)(pred2)))
89 Factorial: Verify fact 2 = (Y g) 2 = g (Y g) 2 by definition of Y-combinator = (λfn. if (iszero n) 1 (mult n (f (pred n)))) (Y g) 2 = (λn. if (iszero n) 1 (mult n ((Y g) (pred n)))) 2 = if (iszero 2) 1 (mult 2 ((Y g)(pred2))) = (mult 2 ((Y g) 1))
90 Factorial: Verify fact 2 = (Y g) 2 = g (Y g) 2 by definition of Y-combinator = (λfn. if (iszero n) 1 (mult n (f (pred n)))) (Y g) 2 = (λn. if (iszero n) 1 (mult n ((Y g) (pred n)))) 2 = if (iszero 2) 1 (mult 2 ((Y g)(pred2))) = (mult 2 ((Y g) 1))... = (mult 2 (mult 1 (if (iszero 0) 1 (...))))
91 Factorial: Verify fact 2 = (Y g) 2 = g (Y g) 2 by definition of Y-combinator = (λfn. if (iszero n) 1 (mult n (f (pred n)))) (Y g) 2 = (λn. if (iszero n) 1 (mult n ((Y g) (pred n)))) 2 = if (iszero 2) 1 (mult 2 ((Y g)(pred2))) = (mult 2 ((Y g) 1))... = (mult 2 (mult 1 (if (iszero 0) 1 (...)))) = (mult 2 (mult 1 1))
92 Factorial: Verify fact 2 = (Y g) 2 = g (Y g) 2 by definition of Y-combinator = (λfn. if (iszero n) 1 (mult n (f (pred n)))) (Y g) 2 = (λn. if (iszero n) 1 (mult n ((Y g) (pred n)))) 2 = if (iszero 2) 1 (mult 2 ((Y g)(pred2))) = (mult 2 ((Y g) 1))... = (mult 2 (mult 1 (if (iszero 0) 1 (...)))) = (mult 2 (mult 1 1)) = 2
93 Recursion and Y -combinator Y-combinator allows to unroll the body of loop once similar to one unfolding of recursive call
94 Recursion and Y -combinator Y-combinator allows to unroll the body of loop once similar to one unfolding of recursive call Sequence of Y-combinator applications allow complete unfolding of recursive calls
95 Recursion and Y -combinator Y-combinator allows to unroll the body of loop once similar to one unfolding of recursive call Sequence of Y-combinator applications allow complete unfolding of recursive calls
96 Recursion and Y -combinator Y-combinator allows to unroll the body of loop once similar to one unfolding of recursive call Sequence of Y-combinator applications allow complete unfolding of recursive calls BUT, what about the existence of Y-combinator?
97 Y -combinators Many candidates exist Y 1 = λf. (λx. f (x x)) (λx. f (x x))
98 Y -combinators Many candidates exist Y 1 = λf. (λx. f (x x)) (λx. f (x x)) Y = λabcdefghijklmnopqstuvwxwzr.r(thisisafixedpointcombinator)
99 Y -combinators Many candidates exist Y 1 = λf. (λx. f (x x)) (λx. f (x x)) Y = λabcdefghijklmnopqstuvwxwzr.r(thisisafixedpointcombinator) Y funny = TTTTT TTTTT TTTTT TTTTT TTTTT T
100 Y -combinators Many candidates exist Y 1 = λf. (λx. f (x x)) (λx. f (x x)) Y = λabcdefghijklmnopqstuvwxwzr.r(thisisafixedpointcombinator) Y funny = TTTTT TTTTT TTTTT TTTTT TTTTT T Verify that (Y f) = f (Y f) for each
101 Summary A cursory look at λ-calculus
102 Summary A cursory look at λ-calculus Functions are data, and Data are functions!
103 Summary A cursory look at λ-calculus Functions are data, and Data are functions! Not covered but important to know: The power of λ calculus is equivalent to that of Turing Machine ( Church Turing Thesis )
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 informationChapter 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λ 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 informationType 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 informationCIS 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 informationThe 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 informationCS 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 informationLambda 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 informationThe 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 informationConcepts of programming languages
Concepts of programming languages Lecture 5 Wouter Swierstra 1 Announcements Submit your project proposal to me by email on Friday; The presentation schedule in now online Exercise session after the lecture.
More informationFormal Semantics. Aspects to formalize. Lambda calculus. Approach
Formal Semantics Aspects to formalize Why formalize? some language features are tricky, e.g. generalizable type variables, nested functions some features have subtle interactions, e.g. polymorphism and
More informationLecture 5: The Untyped λ-calculus
Lecture 5: The Untyped λ-calculus Syntax and basic examples Polyvios Pratikakis Computer Science Department, University of Crete Type Systems and Static Analysis Pratikakis (CSD) Untyped λ-calculus I CS49040,
More informationThe 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 informationCIS 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 informationCS152: 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 informationProgramming Languages. Programming with λ-calculus. Lecture 11: Type Systems. Special Hour to discuss HW? if-then-else int
CSE 230: Winter 2010 Principles of Programming Languages Lecture 11: Type Systems News New HW up soon Special Hour to discuss HW? Ranjit Jhala UC San Diego Programming with λ-calculus Encode: bool if-then-else
More informationCOMP 1130 Lambda Calculus. based on slides by Jeff Foster, U Maryland
COMP 1130 Lambda Calculus based on slides by Jeff Foster, U Maryland Motivation Commonly-used programming languages are large and complex ANSI C99 standard: 538 pages ANSI C++ standard: 714 pages Java
More informationIntroduction 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 informationCIS 500 Software Foundations Midterm I Answer key October 8, 2003
CIS 500 Software Foundations Midterm I Answer key October 8, 2003 Inductive Definitions Review: Recall that the function size, which calculates the total number of nodes in the abstract syntax tree of
More informationWhereweare. 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 informationThe Untyped Lambda Calculus
Resources: The slides of this lecture were derived from x = 1 [Järvi], with permission of the original author, by copy & let x = 1 in... paste or by selection, annotation, or rewording. [Järvi] is in turn
More informationINF 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 informationUntyped 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 informationRecursion. 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 informationThe University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 4 MODULE, SPRING SEMESTER MATHEMATICAL FOUNDATIONS OF PROGRAMMING ANSWERS
The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 4 MODULE, SPRING SEMESTER 2012 2013 MATHEMATICAL FOUNDATIONS OF PROGRAMMING ANSWERS Time allowed TWO hours Candidates may complete the front
More informationFunctional Languages and Higher-Order Functions
Functional Languages and Higher-Order Functions Leonidas Fegaras CSE 5317/4305 L12: Higher-Order Functions 1 First-Class Functions Values of some type are first-class if They can be assigned to local variables
More information9/23/2014. Why study? Lambda calculus. Church Rosser theorem Completeness of Lambda Calculus: Turing Complete
Dr A Sahu Dept of Computer Science & Engineering IIT Guwahati Why study? Lambda calculus Syntax Evaluation Relationship to programming languages Church Rosser theorem Completeness of Lambda Calculus: Turing
More informationUntyped 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 informationCMSC 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 informationResources: The slides of this lecture were derived from [Järvi], with permission of the original author, by copy & x = 1 let x = 1 in...
Resources: The slides of this lecture were derived from [Järvi], with permission of the original author, by copy & x = 1 let x = 1 in... paste or by selection, annotation, or rewording. [Järvi] is in turn
More informationIntroduction to Lambda Calculus. Lecture 7 CS /08/09
Introduction to Lambda Calculus Lecture 7 CS 565 02/08/09 Lambda Calculus So far, we ve explored some simple but non-interesting languages language of arithmetic expressions IMP (arithmetic + while loops)
More informationComputer 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 informationFormal Systems and their Applications
Formal Systems and their Applications Dave Clarke (Dave.Clarke@cs.kuleuven.be) Acknowledgment: these slides are based in part on slides from Benjamin Pierce and Frank Piessens 1 Course Overview Introduction
More informationLecture 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.
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 informationAdvanced Topics in Programming Languages Lecture 3 - Models of Computation
Advanced Topics in Programming Languages Lecture 3 - Models of Computation Andrey Leshenko Maxim Borin 16/11/2017 1 Lambda Calculus At the beginning of the last century, several attempts were made to theoretically
More informationCITS3211 FUNCTIONAL PROGRAMMING
CITS3211 FUNCTIONAL PROGRAMMING 9. The λ calculus Summary: This lecture introduces the λ calculus. The λ calculus is the theoretical model underlying the semantics and implementation of functional programming
More informationCSE 505: Concepts of Programming Languages
CSE 505: Concepts of Programming Languages Dan Grossman Fall 2003 Lecture 6 Lambda Calculus Dan Grossman CSE505 Fall 2003, Lecture 6 1 Where we are Done: Modeling mutation and local control-flow Proving
More informationLambda 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 informationChapter 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 informationProgramming 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 informationCMSC 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 informationFundamentals and lambda calculus
Fundamentals and lambda calculus Again: JavaScript functions JavaScript functions are first-class Syntax is a bit ugly/terse when you want to use functions as values; recall block scoping: (function ()
More informationFall 2013 Midterm Exam 10/22/13. This is a closed-book, closed-notes exam. Problem Points Score. Various definitions are provided in the exam.
Programming Languages Fall 2013 Midterm Exam 10/22/13 Time Limit: 100 Minutes Name (Print): Graduate Center I.D. This is a closed-book, closed-notes exam. Various definitions are provided in the exam.
More informationIntroduction to the Lambda Calculus
Introduction to the Lambda Calculus Overview: What is Computability? Church s Thesis The Lambda Calculus Scope and lexical address The Church-Rosser Property Recursion References: Daniel P. Friedman et
More informationLecture #3: Lambda Calculus. Last modified: Sat Mar 25 04:05: CS198: Extra Lecture #3 1
Lecture #3: Lambda Calculus Last modified: Sat Mar 25 04:05:39 2017 CS198: Extra Lecture #3 1 Simplifying Python Python is full of features. Most are there to make programming concise and clear. Some are
More information5. Introduction to the Lambda Calculus. Oscar Nierstrasz
5. Introduction to the Lambda Calculus Oscar Nierstrasz Roadmap > What is Computability? Church s Thesis > Lambda Calculus operational semantics > The Church-Rosser Property > Modelling basic programming
More informationHarvard 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 informationOne of a number of approaches to a mathematical challenge at the time (1930): Constructibility
λ Calculus Church s λ Calculus: Brief History One of a number of approaches to a mathematical challenge at the time (1930): Constructibility (What does it mean for an object, e.g. a natural number, to
More informationLambda Calculus. Adrian Groza. Department of Computer Science Technical University of Cluj-Napoca
Lambda Calculus Adrian Groza Department of Computer Science Technical University of Cluj-Napoca Outline 1 λ-calculus 2 Operational Semantics Syntax Conversions Normal Form 3 Lambda Calculus as a Functional
More informationProgramming Languages
Programming Languages Lambda Calculus and Scheme CSCI-GA.2110-003 Fall 2011 λ-calculus invented by Alonzo Church in 1932 as a model of computation basis for functional languages (e.g., Lisp, Scheme, ML,
More informationRecursive Definitions, Fixed Points and the Combinator
Recursive Definitions, Fixed Points and the Combinator Dr. Greg Lavender Department of Computer Sciences University of Texas at Austin Recursive Self-Reference Recursive self-reference occurs regularly
More informationdynamically 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 informationMore Lambda Calculus and Intro to Type Systems
More Lambda Calculus and Intro to Type Systems Plan Heavy Class Participation Thus, wake up! Lambda Calculus How is it related to real life? Encodings Fixed points Type Systems Overview Static, Dyamic
More information11/6/17. Outline. FP Foundations, Scheme. Imperative Languages. Functional Programming. Mathematical Foundations. Mathematical Foundations
Outline FP Foundations, Scheme In Text: Chapter 15 Mathematical foundations Functional programming λ-calculus LISP Scheme 2 Imperative Languages We have been discussing imperative languages C/C++, Java,
More informationPure (Untyped) λ-calculus. Andrey Kruglyak, 2010
Pure (Untyped) λ-calculus Andrey Kruglyak, 2010 1 Pure (untyped) λ-calculus An example of a simple formal language Invented by Alonzo Church (1936) Used as a core language (a calculus capturing the essential
More informationIntroductory 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 informationA 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 informationM. 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 informationLambda Calculus. Lambda Calculus
Lambda Calculus Formalism to describe semantics of operations in functional PLs Variables are free or bound Function definition vs function abstraction Substitution rules for evaluating functions Normal
More informationFundamentals 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 informationIntroduction 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 informationLast 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λ-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 informationConstraint-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 informationCostly 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 informationFunctions 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 informationCS 314 Principles of Programming Languages. Lecture 21
CS 314 Principles of Programming Languages Lecture 21 Zheng Zhang Department of Computer Science Rutgers University Wednesday 23 rd November, 2016 Zheng Zhang 1 CS@Rutgers University Class Information
More informationLexicografie computationala Feb., 2012
Lexicografie computationala Feb., 2012 Anca Dinu University of Bucharest Introduction When we construct meaning representations systematically, we integrate information from two different sources: 1. The
More informationMore Lambda Calculus and Intro to Type Systems
#1 More Lambda Calculus and Intro to Type Systems #2 Plan Heavy Class Participation Thus, wake up! (not actually kidding) Lambda Calculus How is it related to real life? Encodings Fixed points Type Systems
More informationlambda calculus History 11/28/13 Jianguo Lu A formal system designed to inves:gate func:on defini:on, func:on applica:on, and recursion.
lambda calculus Jianguo Lu 1 History Lambda calculus A formal system designed to inves:gate func:on defini:on, func:on applica:on, and recursion. Introduced by Alonzo Church in 1930s. The calculus can
More informationLambda Calculus. Variables and Functions. cs3723 1
Lambda Calculus Variables and Functions cs3723 1 Lambda Calculus Mathematical system for functions Computation with functions Captures essence of variable binding Function parameters and substitution Can
More informationVU 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 informationCSC173 Lambda Calculus Lambda Calculus Evaluation (10 min) Evaluate this expression (β-reduce with normal-order evaluation):
CSC173 Lambda Calculus 014 Please write your name on the bluebook. You may use two sides of handwritten notes. There are 90 possible points and 75 is a perfect score. Stay cool and please write neatly.
More informationCMPUT 325 : Lambda Calculus Basics. Lambda Calculus. Dr. B. Price and Dr. R. Greiner. 13th October 2004
CMPUT 325 : Lambda Calculus Basics Dr. B. Price and Dr. R. Greiner 13th October 2004 Dr. B. Price and Dr. R. Greiner CMPUT 325 : Lambda Calculus Basics 1 Lambda Calculus Lambda calculus serves as a formal
More informationElixir, functional programming and the Lambda calculus.
Elixir, functional programming and the Lambda calculus. Programming II - Elixir Version Johan Montelius Spring Term 2018 Introduction In this tutorial you re going to explore lambda calculus and how it
More informationCIS 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 informationCSE-321 Programming Languages 2012 Midterm
Name: Hemos ID: CSE-321 Programming Languages 2012 Midterm Prob 1 Prob 2 Prob 3 Prob 4 Prob 5 Prob 6 Total Score Max 14 15 29 20 7 15 100 There are six problems on 24 pages in this exam. The maximum score
More informationActivity. 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 informationCMSC 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 informationCSE-321 Programming Languages 2010 Midterm
Name: Hemos ID: CSE-321 Programming Languages 2010 Midterm Score Prob 1 Prob 2 Prob 3 Prob 4 Total Max 15 30 35 20 100 1 1 SML Programming [15 pts] Question 1. [5 pts] Give a tail recursive implementation
More informationLambda Calculus and Extensions as Foundation of Functional Programming
Lambda Calculus and Extensions as Foundation of Functional Programming David Sabel and Manfred Schmidt-Schauß 29. September 2015 Lehrerbildungsforum Informatik Last update: 30. September 2015 Overview
More informationλ calculus is inconsistent
Content Rough timeline COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification Gerwin Klein, June Andronick, Toby Murray λ Intro & motivation, getting started [1] Foundations & Principles
More informationCITS3211 FUNCTIONAL PROGRAMMING. 10. Programming in the pure λ calculus
CITS3211 FUNCTIONAL PROGRAMMING 10. Programming in the pure λ calculus Summary: This lecture demonstates the power of the pure λ calculus by showing that there are λ expressions that can be used to emulate
More informationThe Lambda Calculus. notes by Don Blaheta. October 12, A little bondage is always a good thing. sk
The Lambda Calculus notes by Don Blaheta October 2, 2000 A little bondage is always a good thing. sk We ve seen that Scheme is, as languages go, pretty small. There are just a few keywords, and most of
More informationLambda 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 informationLambda 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 informationCMSC 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 informationHarvard School of Engineering and Applied Sciences Computer Science 152
Harvard School of Engineering and Applied Sciences Computer Science 152 Lecture 17 Tuesday, March 30, 2010 1 Polymorph means many forms. Polymorphism is the ability of code to be used on values of different
More informationCMSC 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 informationCMSC 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 informationCMSC 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 information1 Scope, Bound and Free Occurrences, Closed Terms
CS 6110 S18 Lecture 2 The λ-calculus Last time we introduced the λ-calculus, a mathematical system for studying the interaction of functional abstraction and functional application. We discussed the syntax
More informationCMSC 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 informationLambda 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 informationT λx (λy. x) F λx (λ y. y)) if λp (λc (λa. (pc)a)
Class 40: Alternate Computing Models cs20 Fall 2009 University of Virginia David Evans Reminders To qualify for a presentation your team must send me an email containing the URL of your site (with some
More information301AA - Advanced Programming
301AA - Advanced Programming Lecturer: Andrea Corradini andrea@di.unipi.it h;p://pages.di.unipi.it/corradini/ Course pages: h;p://pages.di.unipi.it/corradini/dida@ca/ap-18/ AP-2018-18: Lambda Calculus,
More informationOrganization of Programming Languages CS3200/5200N. Lecture 11
Organization of Programming Languages CS3200/5200N Razvan C. Bunescu School of Electrical Engineering and Computer Science bunescu@ohio.edu Functional vs. Imperative The design of the imperative languages
More informationCMSC330 Fall 2016 Midterm #2 2:00pm/3:30pm
CMSC330 Fall 2016 Midterm #2 2:00pm/3:30pm Gradescope ID: (Gradescope ID is the First letter of your last name and last 5 digits of your UID) (If you write your name on the test, or your gradescope ID
More informationLecture Notes on Data Representation
Lecture Notes on Data Representation 15-814: Types and Programming Languages Frank Pfenning Lecture 9 Tuesday, October 2, 2018 1 Introduction In this lecture we ll see our type system in action. In particular
More information