dynamically typed dynamically scoped
|
|
- Junior Stephens
- 6 years ago
- Views:
Transcription
1 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 Harper, Cambridge University Press, 2016, pages Note: Harper doesn t much care for dynamically typed languages and his criticisms are dead on, but these languages do have some advantages. Lambda calculus definition, from Wikipedia. Royer Dynamically Typed Programming Languages 1 / 19 Royer Dynamically Typed Programming Languages 2 / 19 Important!!! dynamically typed dynamically scoped Dynamically typed roughly means we may not find out the type of a value until runtime. The λ-calculus Dynamically scoped roughly means we may not find out a variable s binding until runtime. Dynamically Typed Programming Languages include: Lisp, Scheme, Racket, Python, Dylan,... The premier example is the (untyped) λ-calculus. Royer Dynamically Typed Programming Languages 3 / 19 Royer Dynamically Typed Programming Languages 4 / 19
2 The λ-calculus: Beginnings The λ-calculus: Beginnings The λ-calculus: Beginnings The λ-calculus: Beginnings The formalism was cut back to the part that was about defining functions, λ-calculus. Amazingly... The formalism was cut back to the part that was about defining functions, λ-calculus. Amazingly... The λ-calculus turns out to be Turing-complete. Why amazingly?
3 The λ-calculus: Beginnings Definitions, 1 The formalism was cut back to the part that was about defining functions, λ-calculus. Amazingly... The λ-calculus turns out to be Turing-complete. Why amazingly? Because on the surface there is not very much to the λ-calculus. Concrete Syntax Note: E ::= X (variable occurrence) (E E) (function application) λx. E (function abstraction) X ::= identifiers We sometimes add extra parens around lambda-expressions. E.g., we can write ((λx.(y x)) z) for (λx.(y x) z). Also, by convention application associates to the left. E.g., we can write w x y z for (((w x) y) z) as in Haskell. Harper uses a LISPy concrete syntax for λx.e. E.g.: λ(x)e Royer Dynamically Typed Programming Languages 6 / 19 Free and bound variables Abstract Syntax (in Haskell) E ::= X (E E) λx.e type Name = String data Exp = Id Name App Exp Exp Lam Name Exp ((λ I x.( B x F z)) F x) I = binding occurrence B = bound occurence F = free occurence Id x Lam x App App Id z Id x Computations Definition An expression of the form: ((λx.e 0 ) e 1 ) is called a β-redex. ((λx.e 0 ) e 1 ) β-reduces to e 0 [e 1 /x]. e β-reduces to e when e is the result of replacing some subexpression of e of the form ((λx.e 0 ) e 1 ) with e 0 [e 1 /x]. e is in β-normal form when it contains no β-redexes. Examples ((λx.(plus x z)) y) β (plus y z) ((λw.(plus w z)) (times x y)) β (plus (times x y) z) ((λx.(λz.(plus x z))) y) β (λz.(plus y z)) ((λx.(λy.(plus x y))) y) β (λy.(plus y y)) variable capture!! ((λx.(λy.(plus x y))) y) β (λz.(plus y z)) (x (λy.y)) β anything as it is in normal form Ω = def ((λx.(x x)) (λx.(x x))) β ((λx.(x x)) (λx.(x x))) = Ω Royer Dynamically Typed Programming Languages 7 / 19 Royer Dynamically Typed Programming Languages 8 / 19
4 β-reduction s less glamorous siblings Normal Order Evaluation (think preorder) α-conversion (Bound vars don t mater for meaning) λx.e α λy.(e[y/x]) where x = y. (I.e., Renaming bound vars doesn t change meaning.) η-conversion (Extensionality) ((λx.e) x) η e when x / freevars(e). (I.e., λ-terms producing the same result on all args are equivalent.) The Normal Order Evaluation Strategy Always do the leftmost possible beta-reduction. Repeat until (if ever) you reach a normal form. Normal Order Evaluation Strategy is equivalent to: function nor(m) if M = ((λx.n) P) then nor(n[p/x]) else if M = (N P) & N n.o. N then nor( (N P) ) else if M = (N P) & P n.o. P then nor( (N P ) ) else if M = λx.n & N n.o. N then nor(λx.n ) ( ) else (* M is in β-n.f. *) return M [Draw the parse tree!] Theorem If e has a normal form, normal order evaluation will eventually reach it. ( ) Drop this line to get to call-by-name. Royer Dynamically Typed Programming Languages 9 / 19 Royer Dynamically Typed Programming Languages 10 / 19 Applicative Order Evaluation (think postorder) The Applicative Order Evaluation Strategy Always do the innermost (to the left) possible beta-reduction. Repeat until (if ever) you run out of beta-redexes. [Draw the parse tree!] Normal Order Evaluation Strategy is equivalent to: function nor(m) if M = (N P) & N n.o. N then nor( (N P) ) else if M = (N P) & P n.o. P then nor( (N P ) ) else if M = ((λx.n) P) then nor(n[p/x]) else if M = λx.n & N n.o. N then nor(λx.n ) ( ) else (* M is in β-n.f. *) return M Dynamically Typed Programming Languages Applicative Order Evaluation (think postorder) Are there other evaluation strategies? More than you want to know. For starts, see: Applicative Order Evaluation (think postorder) 11 / 19[width=8cm] The Applicative Order Evaluation Strategy Always do the innermost (to the left) possible beta-reduction. Repeat until (if ever) you run out of beta-redexes. [Draw the parse tree!] Normal Order Evaluation Strategy is equivalent to: function nor(m) if M = (N P) & N n.o. N then nor( (N P) ) else M = (N P) & P n.o. P then nor( (N P ) ) if else if M = ((λx.n) P) then nor(n[p/x]) then nor(λx.n ) else if M = λx.n & N n.o. N ( ) else (* M is in β-n.f. *) return M Fact If e has a normal form, applicative order evaluation may not find it. ( ) Drop this line to get to call-by-value. Fact If e has a normal form, applicative order evaluation may not find it. ( ) Drop this line to get to call-by-value. Royer Dynamically Typed Programming Languages 11 / 19
5 The λ-calculus as a RISC assembly language, 1 The λ-calculus as a RISC assembly language, 2 Church Booleans true = def λt.λf.t false = def λt.λf.f test = def λb.λm.λn.((l m) n) and = def λb.λc.((b c) false) Examples test true u v β u test false u v β v and true true β true and false true β false. Church Pairs pair = def λf.λs.λb.((b f ) s) fst = def λp.(p true) snd = def λp.(p false) Examples fst (pair u v) β u snd (pair u v) β u Church Numerals c 0 = def λs.λz.z c 1 = def λs.λz.(s z) c 2 = def λs.λz.(s (s z)) c 3 = def λs.λz.(s (s (s z))). successor = def λn.λs.λz.(s (n s z)) plus = def λm.λn.λs.λz.m s (n s z) times = def λm.λn.(m (plus n) c 0 ). Y = def λf.(λx.f (x x))(λx.f (x x)) Object oriented integers specify what successor (s) is specify what zero (z) is c n = apply s n-times to z predecessor is difficult (pred c 0 β c 0 & pred c n+1 β c n ) Royer Dynamically Typed Programming Languages 12 / 19 Royer Dynamically Typed Programming Languages 13 / 19 From Barendregt s Impact of the Lambda calculus Kleene did find a way to lambda define the predecessor function in the untyped lambda calculus, by using an appropriate data type (pairs of integers) as auxiliary device. In [69], he described how he found the solution while being anesthetized by laughing gas (N 2 O) for the removal of four wisdom teeth. Back to Harper Royer Dynamically Typed Programming Languages 14 / 19 Royer Dynamically Typed Programming Languages 15 / 19
6 Term formation à la Harper Term equivalence à la Harper There is just one type: ok. Γ, x : ok x : ok Γ, x : ok e : ok Γ λx.e : ok Γ u u asserts that u and u (with free variables in Γ), think u and u are behaviorally equivalent. Γ, u : ok u u Γ u u Γ u u Γ u u Γ u u Γ u u Γ u 1 u 1 Γ u 2 u 2 Γ (u 1 u 2 ) (u 1 u 2 ) Γ, x : ok u u Γ λx.u λx.u Γ e 1 : ok Γ e 2 : ok Γ (e 1 e 2 ) : ok Γ, x : ok u 2 : ok Γ e 1 : ok Γ ((λx.e 2 ) e 1 ) e 2 [e 1 /x] Scott s Theorem u u is undecidable. So, if there was any doubt, we are firmly in Turing s tar-pit. Royer Dynamically Typed Programming Languages 16 / 19 Royer Dynamically Typed Programming Languages 17 / Dynamically Typed Programming Languages Term equivalence à la Harper The first three rules say that is an equiv. rel. Term equivalence à la Harper 17 / 19[width=8cm] Γ u u asserts that u and u (with free variables in Γ), think u and u are behaviorally equivalent. Γ, u : ok u u Scott s Theorem Γ u u Γ u u Γ u u Γ u u Γ u u Γ u1 u 1 Γ u2 u 2 Γ, x : ok u u Γ (u1 u2) (u 1 u 2 ) Γ λx.u λx.u u u is undecidable. Γ, x : ok u2 : ok Γ e1 : ok Γ ((λx.e2) e1) e2[e1/x] The fourth rule states that applying things, yields results. So, if there was any doubt, we are firmly in Turing s tar-pit. The fifth rule states that abstracting on things, yields results. The last rule says that u β u implies u u. I.e., an evaluation step (β-reduction) preserves meaning. Observation: The λ-calculus is seriously strange The λ-calculus has but one feature, the higher-order function. Everything is a function, and hence every expression may be applied to an argument, which must itself be a function, with the result also being a function. To borrow a turn of phrase, in the λ-calculs it s functions all the way down. Harper, page 127 In terms of the type ok, we have: ok = (ok ok) By Cantor s Theorem, the above makes no sense in standard set theory. Royer Dynamically Typed Programming Languages 18 / 19
7 Observation: The λ-calculus is seriously strange The λ-calculus has but one feature, the higher-order function. Everything is a function, and hence every expression may be applied to an argument, which must itself be a function, with the result also being a function. To borrow a turn of phrase, in the λ-calculs it s functions all the way down. Harper, page Dynamically Typed Programming Languages Observation: The λ-calculus is seriously strange By Cantor, if card(a) > 1, then where card(a) < card(a A ) A A = the set of (total) functions from A to A. Observation: The λ-calculus is seriously strange 18 / 19[width=8cm] The λ-calculus has but one feature, the higher-order function. Everything is a function, and hence every expression may be applied to an argument, which must itself be a function, with the result also being a function. To borrow a turn of phrase, in the λ-calculs it s functions all the way down. Harper, page 127 In terms of the type ok, we have: ok = (ok ok) By Cantor s Theorem, the above makes no sense in standard set theory. However, it turns out to make sense in a computability context. In terms of the type ok, we have: ok = (ok ok) By Cantor s Theorem, the above makes no sense in standard set theory. However, it turns out to make sense in a computability context. Royer Dynamically Typed Programming Languages 18 / 19 How to make computational sense of ok = (ok ok) Briefly, as a recursive type. E.g., in Haskell data Ok = F (Ok -> Ok) We are skipping Harper s treatment of recursive types, but: It isn t too hard to represent the λ-calculus using a type like Ok. But it also is a pain. (See Harper.)... and it breaks as soon as you add any other data type to the lambda calculus, which is exactly what we want to do. So there is another approach. (Next time!) Royer Dynamically Typed Programming Languages 19 / 19
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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 informationFrom the λ-calculus to Functional Programming Drew McDermott Posted
From the λ-calculus to Functional Programming Drew McDermott drew.mcdermott@yale.edu 2015-09-28 Posted 2015-10-24 The λ-calculus was intended from its inception as a model of computation. It was used by
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 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 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 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 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 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
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 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 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 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 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 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 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 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 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 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 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 informationLambda calculus. Wouter Swierstra and Alejandro Serrano. Advanced functional programming - Lecture 6
Lambda calculus Advanced functional programming - Lecture 6 Wouter Swierstra and Alejandro Serrano 1 Today Lambda calculus the foundation of functional programming What makes lambda calculus such a universal
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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 336: Type Systems for Programming Languages Lecture 4: Programming in the Lambda Calculus Acar & Ahmed 22 January 2008.
CMSC 336: Type Systems for Programming Languages Lecture 4: Programming in the Lambda Calculus Acar & Ahmed 22 January 2008 Contents 1 Announcements 1 2 Solution to the Eercise 1 3 Introduction 1 4 Multiple
More informationGraphical Untyped Lambda Calculus Interactive Interpreter
Graphical Untyped Lambda Calculus Interactive Interpreter (GULCII) Claude Heiland-Allen https://mathr.co.uk mailto:claude@mathr.co.uk Edinburgh, 2017 Outline Lambda calculus encodings How to perform lambda
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 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 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 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 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 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. 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 informationProgramming Languages Lecture 14: Sum, Product, Recursive Types
CSE 230: Winter 200 Principles of Programming Languages Lecture 4: Sum, Product, Recursive Types The end is nigh HW 3 No HW 4 (= Final) Project (Meeting + Talk) Ranjit Jhala UC San Diego Recap Goal: Relate
More 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 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 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 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 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 informationCSE-321 Programming Languages 2010 Final
Name: Hemos ID: CSE-321 Programming Languages 2010 Final Prob 1 Prob 2 Prob 3 Prob 4 Prob 5 Prob 6 Total Score Max 18 28 16 12 36 40 150 There are six problems on 16 pages, including two work sheets, in
More informationLambda Calculus. 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 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 informationMore Lambda Calculus and Intro to Type Systems
More Lambda Calculus and Intro to Type Systems #1 One Slide Summary The lambda calculus is a model of computation or a programming language that is as expressive as a Turing machine. The lambda calculus
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 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 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 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 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 informationGetting Started with Haskell (10 points)
Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science 6.827 Multithreaded Parallelism: Languages and Compilers Problem Set 1 Out: September 19, 2006 Due: October
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 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 information> module Lambda where > import Data.List -- I need some standard list functions
Lecture 9 Lambda Calculus We now look at lambda calculus, the theoretical stuff that underlies functional programming. It was introduced by Alonzo Church to formalise two key concepts when dealing with
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 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 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 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 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 information