Functions as data. Massimo Merro. 9 November Massimo Merro The Lambda language 1 / 21
|
|
- Ethan Rice
- 5 years ago
- Views:
Transcription
1 Functions as data Massimo Merro 9 November 2011 Massimo Merro The Lambda language 1 / 21
2 The core of sequential programming languages In the mid 1960s, Peter Landin observed that a complex programming language can be understood by focussing on a tiny core calculus capturing the language s essential mechanisms together with a collection of convenient derived constructs whose behaviour is understood by translating them into the core calculus. The core language used by Landin was the λ-calculus, a formal system invented by Alonzo Church in the 1930 s as a universal language of computable functions. In 1960, John McCarthy published the design of the programming language Lisp based on the λ-calculus. Since then, the λ-calculus has seen a widespread use in the specification of programming language features in language design and implementation in the study of type systems. Massimo Merro The Lambda language 2 / 21
3 Expressiveness of the λ-calculus The λ-calculus can be viewed as a very simple programming language in which computations can be described as mathematical objects. It is a formal language in which every term denotes a function any term (function) can be applied to any other term, so functions are inherently higher-order Despite its simplicitiy, it is a Turing-complete language: it can express computations on natural number as does any other known programming language. Church s Thesis: any conceivable notion of computable function on natural numbers is equivalent to the λ-calculus. The force of Church s Thesis is that it postulates that all future notions of computation will be equivalent in expressive power to the λ-calculus. Massimo Merro The Lambda language 3 / 21
4 Encoding language features in λ-calculus The λ-calculus can be enriched in a variety of ways. It is often convenient to add special constructs for features like numbers, booleans, tuples, records, etc. However, all these features can be encoded in the λ-calculus, so they represent only syntactic sugar. Such extensions lead eventually to programming languages such as Lisp (McCarthy, 1960), ML (Milner et al., 1990), Haskell (Hudak et al., 1992), or Scheme (Sussman and Steele, 1975). In the next slide, we propose the Lambda language a simple extension of the λ-calculus with built-in operators for manipulating natural numbers and Booleans. Massimo Merro The Lambda language 4 / 21
5 The language Lambda M Lambda ::= n true false x (M 1 + M 1 ) (M 1 M 2 ) x Vars... M 1 and M 2 M 1 or M 2 M 1 = M 2 if M 1 then M 2 else M 3 λx.m M 1 M 2 The constructs in red constitute Churchs λ-calculus M 1 M 2 : apply function M 1 to argument M 2 λx.m: called λ-abstraction, define anonymous function which when applied to data N executes M{ N / x }. Massimo Merro The Lambda language 5 / 21
6 Examples of anonymous functions λx.x from numerals to numerals λf.(f (2)) - from functions to numerals λx.if x = 0 then λy.y else λy.x - from numerals to functions λf.λx.if x = 0 then 1 else (let y = f (x 1)x y in ) - from functions to functions λf.λg.λx.f (g(x)) - from pairs of functions to functions. Massimo Merro The Lambda language 6 / 21
7 Conventions We recall the grammar given before describes the abstract syntax of the language; when we come to write terms down concretely we will often use brackets, as above, to clarify the structure of terms. So, to keep brackets to a minimum in this part, we will use some conventions for writing λ-terms: applications associates left: MNP means the same as (MN)P the scope of λ extends as far to the right as possible: λx.mn means λx.(mn), not (λx.m)n we sometimes write λxy.m for λx.λy.m. Massimo Merro The Lambda language 7 / 21
8 Free variables The construct λx.m for function definition is the only binding operator. In λx.m the variable x is bound in M which represents the scope of x. Let us provide a formal definition of free variables by structural induction: fv(x) = {x} fv(n) = fv(true) = fv(false) = fv(m 1 op M 2 ) = fv(m 1 ) fv(m 2 ) fv(m 1 M 2 ) = fv(m 1 ) fv(m 2 ) fv(λx.m) = fv(m) \ {x} Closed terms M is closed if fv(m) = Closed terms corresponds to programs. Massimo Merro The Lambda language 8 / 21
9 Small-step semantics Judgements: M N where M and N are programs Intuition: M performs one function application or one built-in operation and N remains to be evaluated. Massimo Merro The Lambda language 9 / 21
10 Semantic rules Standard rules: (S-Left) M 1 M 1 M 1 + M 2 M 1 + M 2 (S-Right) M 2 M 2 n 1 + M 2 n 1 + M 2 (S-Add) Similar rules for, and, if then else,... n 1 + n 2 n 3 n 3 = add(n 1, n 2 ) Massimo Merro The Lambda language 10 / 21
11 Function application To evaluate M 1 M 2 : First evaluate M 1 to a function λx.m Then it depends on the evaluation strategy. If Call-by-value: evaluate M 2 to a value v v Val ::= n true false λx.n evaluate M{ v / x }. If Call-by-name: evaluate M{ M 2 / x } Massimo Merro The Lambda language 11 / 21
12 Function application rules (L-App) M 1 M 1 M 1 M 2 M 1 M 2 Call-by-value: M 2 M (L-CBV.A) 2 (λx.m)m 2 (λx.m)m 2 where v Val ::= n true false (L-CBV) λx.n (λx.m)v M{ v / x } Call-by-name (L-CBN) (λx.m)m 2 M{ M 2 / x } where M 2 is a closed term (i.e. a program). Massimo Merro The Lambda language 12 / 21
13 Substitution of closed terms N closed: x{ N / x } = N y{ N / x } = y if y x (λx.m){ N / x } = λx.m (λy.m){ N / x } = λy.m{ N / x } if y x (M 1 M 2 ){ N / x } = (M 1 { N / x })(M 2 { N / x }) (M 1 op M 2 ){ N / x } = (M 1 { N / x }) op (M 2 { N / x }) N open: requires α-conversion, i.e. renaming of bound variables. Massimo Merro The Lambda language 13 / 21
14 Self-application Is it possible to express non-terminating programs in Lambda? Yes, of course! For example, the divergent combinator Ω def = (λx.xx)(λx.xx) contains just one redex, and reducing this redex yields exactly Ω again! Ω Ω Ω Ω Non-termination is built-in in Lambda! Massimo Merro The Lambda language 14 / 21
15 Call-by-name vs. call-by-value Note that unlike the Fpl language, having function definitions among the constructs may lead to different results. They give different results: (λx.0)(ω) cbn 0 (λx.0)(ω) cbv (λx.0)(ω) cbv... cbv... Even more surprisingly: (λx.λy.x)(id 0) cbn λy.(id 0) (λx.λy.x)(id 0) cbv λy.0 For different evaluation strategies see Benjamin C. Pierce s Types and Programming Languages at pp. 56. Massimo Merro The Lambda language 15 / 21
16 Fixpoints In Mathematics, a fixpoint p (also known as an invariant point) of a function f is a point that is mapped to itself, i.e. f (p) = p. Fixpoints represent the core of what is known as recursion theory. Kleene s recursion theorems are a pair of fundamental results about the application of computable functions to their own descriptions. The two recursion theorems can be applied to construct fixed points of certain operations on computable functions, to generate quines 1, and to construct functions defined via recursive definitions. Kleene s recursion theorems is used to prove a fundamental result in computability theory: the Rice s Theorem! Rice s Theorem: For any non-trivial property of partial functions, there is no general and effective method to decide whether an algorithm computes a partial function with that property. 1 A quine is a computer program which produces a copy of its own source code as its only output. Massimo Merro The Lambda language 16 / 21
17 Fixpoints (via Turing s combinator) So, it is very important to prove that Lambda can express fixpoints. Let us define the two following terms in Lambda: A fix def = λx.λy.y(xxy) def = AA fix is a recursive function that given a term M returns a fixpoint of M, denoted with fix M. In fact, for any term M, using a call-by-name evaluation, we have: fix M (λy.y(aay))m M(fix M). Very often this operator is denoted using the greek letter Θ. Massimo Merro The Lambda language 17 / 21
18 Example: the factorial function F Fac def = λf.λx.if x = 0 then 1 else x f (x 1) def = ΘF ΘF λx.if x = 0 then 1 else x ΘF (x 1) ΘF 3 (λx.if x = 0 then 1 else x ΘF (x 1)) 3 3 ΘF 2 3 (λx.if x = 0 then 1 else x ΘF (x 1)) ΘF ΘF Massimo Merro The Lambda language 18 / 21
19 Fixpoints (via Curry s combinator) Notice that there are infinitely many forms of fixpoint combinators. Probably, the best known is the one by Curry and most commonly called Y : Y def = λf.(λx.f (xx))(λx.f (xx)) We can easily check that is has the required property: Y M def = ( λf. ( λx.f (xx))(λx.f (xx) )) M ( ) λx.m(xx))(λx.m(xx) M ( (λx.m(xx))(λx.m(xx)) ) = M(Y M) M ( (λx.m(xx))(λx.m(xx)) ) Massimo Merro The Lambda language 19 / 21
20 Applicative order fixpoint combinator The Curry Y -combinator does not work in languages like Lisp, because of the applicative order (call-by-value) reduction strategy: Y M will keep evaluating forever. A different fixpoint combinator does work, though: the applicative order fixpoint combinator which is λf.(λg.gg)(λx.f (λa.xxa)) or alternatively λf.(λx.f (λa.xxa))(λx.f (λa.xxa)) Exercise Check that this is a fixpoint combinator. Notice that it only differs from Curry s Y by replacing terms of the form xx with λa.xxa. Inserting this λ stops Lisp s evaluation mechanism from getting into an infinite loop. Massimo Merro The Lambda language 20 / 21
21 Some fun: Klop s fixpoint combinator Jan Klop came up with this ridiculous one: if we define where then L def = λabcdefghijklmnopqstuvwxyzr.r(thisisafixedpointcombinator) λabcdef... means λa.λb.λc.λd.λe.λf.... thisisafixe... means ((((((((((th)i)s)i)s)a)f )i)x)e)... LLLLLLLLLLLLLLLLLLLLLLLLLL is indeed a fixpoint combinator. (26 times) Exercise Check that Klop s combinator works. Hint: the phrase this is a fixed point combinator contains 27 letters. Massimo Merro The Lambda language 21 / 21
Functions. Massimo Merro. 24 October Massimo Merro Functional language 1 / 1
Functions Massimo Merro 24 October 2017 Massimo Merro Functional language 1 / 1 Most programming languages have some notion of function, method, or procedure... to abstract a piece of code on formal parameters
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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 information3.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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 informationLambda Calculus. Type Systems, Lectures 3. Jevgeni Kabanov Tartu,
Lambda Calculus Type Systems, Lectures 3 Jevgeni Kabanov Tartu, 13.02.2006 PREVIOUSLY ON TYPE SYSTEMS Arithmetical expressions and Booleans Evaluation semantics Normal forms & Values Getting stuck Safety
More 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 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 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 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 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 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 informationPure Lambda Calculus. Lecture 17
Pure Lambda Calculus Lecture 17 Lambda Calculus Lambda Calculus (λ-calculus) is a functional notation introduced by Alonzo Church in the early 1930s to formalize the notion of computability. Pure λ-calculus
More informationConcepts of programming languages
Concepts of programming languages Lecture 5 Wouter Swierstra 1 Announcements Submit your project proposal to me by email on Friday; The presentation schedule in now online Exercise session after the lecture.
More informationLambda 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 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 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 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 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 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 informationCMSC330. 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 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 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 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 informationMore 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 informationCS 6110 S14 Lecture 1 Introduction 24 January 2014
CS 6110 S14 Lecture 1 Introduction 24 January 2014 1 Introduction What is a program? Is it just something that tells the computer what to do? Yes, but there is much more to it than that. The basic expressions
More 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 informationImplementing functional languages with abstract machines
Implementing functional languages with abstract machines Hayo Thielecke University of Birmingham http://www.cs.bham.ac.uk/~hxt December 9, 2015 Contents Introduction Lambda calculus and programming languages
More informationIntroduction to the Lambda Calculus. Chris Lomont
Introduction to the Lambda Calculus Chris Lomont 2010 2011 2012 www.lomont.org Leibniz (1646-1716) Create a universal language in which all possible problems can be stated Find a decision method to solve
More informationLambda Calculus. Gunnar Gotshalks LC-1
Lambda Calculus LC-1 l- Calculus History Developed by Alonzo Church during 1930 s-40 s One fundamental goal was to describe what can be computed. Full definition of l-calculus is equivalent in power to
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 informationWeek 4: Functional Programming
CS320 Principles of Programming Languages Week 4: Functional Programming Jingke Li Portland State University Fall 2017 PSU CS320 Fall 17 Week 4: Functional Programming 1/ 66 Topic List for this Unit Functional
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 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 informationCSCI.4430/6969 Programming Languages Lecture Notes
CSCI.4430/6969 Programming Languages Lecture Notes August 28, 2006 1 Brief History of Programming Languages Ada Augusta, the Countess of Lovelace, the daughter of the poet Lord Byron, is attributed as
More informationIntroduction. chapter Functions
chapter 1 Introduction In this chapter we set the stage for the rest of the book. We start by reviewing the notion of a function, then introduce the concept of functional programming, summarise the main
More informationFunctional Programming
Functional Programming COMS W4115 Prof. Stephen A. Edwards Spring 2003 Columbia University Department of Computer Science Original version by Prof. Simon Parsons Functional vs. Imperative Imperative programming
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 informationAn Introduction to the Lambda Calculus
Department of Computer Science Australian National University COMP3610 Principles of Programming Languages An Introduction to the Lambda Calculus Clem Baker-Finch August 13, 2013 Contents 1 Motivation
More informationLambda Calculus LC-1
Lambda Calculus LC-1 λ- Calculus History-1 Developed by Alonzo Church during 1930 s-40 s One fundamental goal was to describe what can be computed. Full definition of λ-calculus is equivalent in power
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 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 informationThe 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 informationProgramming Language Concepts: Lecture 19
Programming Language Concepts: Lecture 19 Madhavan Mukund Chennai Mathematical Institute madhavan@cmi.ac.in http://www.cmi.ac.in/~madhavan/courses/pl2009 PLC 2009, Lecture 19, 01 April 2009 Adding types
More informationPart I. Historical Origins
Introduction to the λ-calculus Part I CS 209 - Functional Programming Dr. Greg Lavender Department of Computer Science Stanford University Historical Origins Foundations of Mathematics (1879-1936) Paradoxes
More informationLambda Calculus and Type Inference
Lambda Calculus and Type Inference Björn Lisper Dept. of Computer Science and Engineering Mälardalen University bjorn.lisper@mdh.se http://www.idt.mdh.se/ blr/ August 17, 2007 Lambda Calculus and Type
More 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 informationFunctional 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 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 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 informationn λxy.x n y, [inc] [add] [mul] [exp] λn.λxy.x(nxy) λmn.m[inc]0 λmn.m([add]n)0 λmn.n([mul]m)1
LAMBDA CALCULUS 1. Background λ-calculus is a formal system with a variety of applications in mathematics, logic, and computer science. It examines the concept of functions as processes, rather than the
More informationProgramming Languages Third Edition
Programming Languages Third Edition Chapter 12 Formal Semantics Objectives Become familiar with a sample small language for the purpose of semantic specification Understand operational semantics Understand
More informationCS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011
CS152: Programming Languages Lecture 11 STLC Extensions and Related Topics Dan Grossman Spring 2011 Review e ::= λx. e x e e c v ::= λx. e c τ ::= int τ τ Γ ::= Γ, x : τ (λx. e) v e[v/x] e 1 e 1 e 1 e
More informationProgramming Languages. 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 informationDenotational Semantics. Domain Theory
Denotational Semantics and Domain Theory 1 / 51 Outline Denotational Semantics Basic Domain Theory Introduction and history Primitive and lifted domains Sum and product domains Function domains Meaning
More 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 informationCS522 - Programming Language Semantics
1 CS522 - Programming Language Semantics Lambda Calculus and Combinatory Logic Grigore Roşu Department of Computer Science University of Illinois at Urbana-Champaign 2 In this part of the course we discuss
More informationPolymorphic lambda calculus Princ. of Progr. Languages (and Extended ) The University of Birmingham. c Uday Reddy
06-02552 Princ. of Progr. Languages (and Extended ) The University of Birmingham Spring Semester 2016-17 School of Computer Science c Uday Reddy2016-17 Handout 6: Polymorphic Type Systems 1. Polymorphic
More informationFunctional Languages. Hwansoo Han
Functional Languages Hwansoo Han Historical Origins Imperative and functional models Alan Turing, Alonzo Church, Stephen Kleene, Emil Post, etc. ~1930s Different formalizations of the notion of an algorithm
More information1 Introduction. 3 Syntax
CS 6110 S18 Lecture 19 Typed λ-calculus 1 Introduction Type checking is a lightweight technique for proving simple properties of programs. Unlike theorem-proving techniques based on axiomatic semantics,
More informationFunctional Programming
Functional Programming CS331 Chapter 14 Functional Programming Original functional language is LISP LISt Processing The list is the fundamental data structure Developed by John McCarthy in the 60 s Used
More informationShell CSCE 314 TAMU. Haskell Functions
1 CSCE 314: Programming Languages Dr. Dylan Shell Haskell Functions 2 Outline Defining Functions List Comprehensions Recursion 3 Conditional Expressions As in most programming languages, functions can
More informationFundamentals of Artificial Intelligence COMP221: Functional Programming in Scheme (and LISP)
Fundamentals of Artificial Intelligence COMP221: Functional Programming in Scheme (and LISP) Prof. Dekai Wu Department of Computer Science and Engineering The Hong Kong University of Science and Technology
More information