CSE-321 Programming Languages -Calculus (II) POSTECH March 26, 2007 박성우.

Slides:



Advertisements
Similar presentations
Substitution & Evaluation Order cos 441 David Walker.
Advertisements

Computational Models The exam. Models of computation. –The Turing machine. –The Von Neumann machine. –The calculus. –The predicate calculus. Turing.
The lambda calculus David Walker CS 441. the lambda calculus Originally, the lambda calculus was developed as a logic by Alonzo Church in 1932 –Church.
Elements of Lambda Calculus Functional Programming Academic Year Alessandro Cimatti
INF 212 ANALYSIS OF PROG. LANGS LAMBDA CALCULUS Instructors: Crista Lopes Copyright © Instructors.
Catriel Beeri Pls/Winter 2004/5 functional-language 1 Substitution Semantics of FL – a simple functional language FL is EL + (non-recursive) function creation.
Advanced Formal Methods Lecture 2: Lambda calculus Mads Dam KTH/CSC Course 2D1453, Some material from B. Pierce: TAPL + some from G. Klein, NICTA.
Foundations of Programming Languages: Introduction to Lambda Calculus
6. Introduction to the Lambda Calculus. © O. Nierstrasz PS — Introduction to the Lambda Calculus 6.2 Roadmap  What is Computability? — Church’s Thesis.
School of Computing and Mathematics, University of Huddersfield CAS810: WEEK 3 LECTURE: LAMBDA CALCULUS PRACTICAL/TUTORIAL: (i) Do exercises given out.
Chair of Software Engineering 1 Concurrent Object-Oriented Programming Arnaud Bailly, Bertrand Meyer and Volkan Arslan.
CS5205: Foundation in Programming Languages Lecture 1 : Overview
C. Varela1 Lambda Calculus alpha-renaming, beta reduction, applicative and normal evaluation orders, Church-Rosser theorem, combinators Carlos Varela Rennselaer.
1 Relational Algebra and Calculus Yanlei Diao UMass Amherst Feb 1, 2007 Slides Courtesy of R. Ramakrishnan and J. Gehrke.
PPL Syntax & Formal Semantics Lecture Notes: Chapter 2.
PPL Syntax & Formal Semantics Lecture Notes: Chapter 2.
1 Relational Algebra and Calculus Chapter 4. 2 Relational Query Languages  Query languages: Allow manipulation and retrieval of data from a database.
Lecture 20: λ Calculus λ Calculus & Computability Yan Huang Dept. of Comp. Sci. University of Virginia.
1 SML fn x => e e 1 e 2 0, 1, 2,..., +, -,... true, false, if e then e else e patterns datatypes exceptions structures functors fun f x = e variables.
10/12/20151 GC16/3C11 Functional Programming Lecture 3 The Lambda Calculus A (slightly) deeper look.
CSE S. Tanimoto Lambda Calculus 1 Lambda Calculus What is the simplest functional language that is still Turing complete? Where do functional languages.
Lambda Calculus History and Syntax. History The lambda calculus is a formal system designed to investigate function definition, function application and.
A Theory of Hygienic Macros David Herman, Mitchell Wand Northeastern University.
1 ML fun x -> e e 1 e 2 0, 1, 2,..., +, -,... true, false, if e then e else e patterns datatypes exceptions structures functors let f x = e variables These.
1 Relational Algebra and Calculas Chapter 4, Part A.
© Kenneth C. Louden, Chapter 11 - Functional Programming, Part III: Theory Programming Languages: Principles and Practice, 2nd Ed. Kenneth C. Louden.
CSE 230 The -Calculus. Background Developed in 1930’s by Alonzo Church Studied in logic and computer science Test bed for procedural and functional PLs.
Types and Programming Languages Lecture 6 Simon Gay Department of Computing Science University of Glasgow 2006/07.
1 Formal Semantics. 2 Why formalize? ML is tricky, particularly in corner cases generalizable type variables? polymorphic references? exceptions? Some.
Principles of programming languages 9: Lambda calculus Isao Sasano Department of Information Science and Engineering.
CSE-321 Programming Languages -Calculus (II) POSTECH March 27, 2006 박성우.
Lesson2 Lambda Calculus Basics 1/10/02 Chapter 5.1, 5.2.
-Calculus Kangwon National University 임현승 Programming Languages These slides are based on the slides by Prof. Sungwoo Park at POSTECH.
Lambda Calculus CSE 340 – Principles of Programming Languages Fall 2015 Adam Doupé Arizona State University
Basic Scheme February 8, 2007 Compound expressions Rules of evaluation Creating procedures by capturing common patterns.
1/33 Basic Scheme February 8, 2007 Compound expressions Rules of evaluation Creating procedures by capturing common patterns.
Lesson 3 Formalizing and Implementing Pure Lambda Calculus 1/15/02 Chapters 5.3, 6, 7.
Arvind Computer Science and Artificial Intelligence Laboratory M.I.T. L04Ext-1 September 21, 2006http:// Some more thoughts.
CSE-321 Programming Languages Abstract Machine E POSTECH May 1, 2006 박성우.
CS321 Functional Programming 2 © JAS The λ Calculus This is a formal system to capture the ideas of function abstraction and application introduced.
Types and Programming Languages Lecture 16 Simon Gay Department of Computing Science University of Glasgow 2006/07.
PPL Syntax & Formal Semantics Lecture Notes: Chapter 2.
6/21/20161 Programming Languages and Compilers (CS 421) Reza Zamani Based in part on slides by Mattox Beckman,
Arvind Computer Science and Artificial Intelligence Laboratory M.I.T. L03-1 September 14, 2006http:// -calculus: A Basis for.
Aim: How do we evaluate algebraic expressions? Do Now: Evaluate. 1. (-4) 2 ÷ [(6+2) ] (6 × ) 3. ( * 5) ÷ 12 √100.
Chapter 2: Lambda Calculus
CS 550 Programming Languages Jeremy Johnson
Basic Scheme February 8, 2007 Compound expressions Rules of evaluation
Lambda Calculus CSE 340 – Principles of Programming Languages
CSE-321 Programming Languages Simply Typed -Calculus
Carlos Varela Rennselaer Polytechnic Institute September 5, 2017
CS 611: Lecture 9 More Lambda Calculus: Recursion, Scope, and Substitution September 17, 1999 Cornell University Computer Science Department Andrew Myers.
September 4, 1997 Programming Languages (CS 550) Lecture 6 Summary Operational Semantics of Scheme using Substitution Jeremy R. Johnson TexPoint fonts.
Carlos Varela Rennselaer Polytechnic Institute September 6, 2016
Lesson2 Lambda Calculus Basics
Carlos Varela Rennselaer Polytechnic Institute September 4, 2015
Programming Languages and Compilers (CS 421)
What would be our focus ? Geometry deals with Declarative or “What is” knowledge. Computer Science deals with Imperative or “How to” knowledge 12/25/2018.
Announcements Quiz 6 HW7 due Tuesday, October 30
Carlos Varela Rennselaer Polytechnic Institute September 8, 2017
What would be our focus ? Geometry deals with Declarative or “What is” knowledge. Computer Science deals with Imperative or “How to” knowledge 2/23/2019.
Announcements Exam 2 on Friday, November 2nd Topics
L Calculus.
Programming Languages and Compilers (CS 421)
Programming Languages and Compilers (CS 421)
CSE S. Tanimoto Lambda Calculus
Introduction to the Lab
Carlos Varela Rennselaer Polytechnic Institute September 8, 2015
Carlos Varela Rennselaer Polytechnic Institute September 6, 2019
Carlos Varela Rennselaer Polytechnic Institute September 10, 2019
Presentation transcript:

CSE-321 Programming Languages -Calculus (II) POSTECH March 26, 2007 박성우

2 Values and Reductions redex = reducible expression :  -reduction

3 Call-by-name Call-by-value

4 Outline Abstract syntax of the -calculus V Operational semantics of the -calculus V Substitutions Programming in the -calculus

5 [e' / x] e Informally "substitute e' for every occurrence of x in e." Examples

6 Easy Cases First

7 Two Remaining Cases

8 First (stupid) attempt Second attempt But wait:

9 Names of bound variables do not matter. Hence –for a fresh variable y, Bound Variables

10 One Remaining Case

11 A Naive Attempt An anomaly: something for y

12 Free Variables Variables that are bound nowhere FV(e) = set of free variables in e

13 Free Variables Remain Free From the point of view of an outside observer, a free variable remains free until it is explicitly replaced. outside observer ? variable capture

14 Capture-Avoiding Substitution What happens if –the free variable y is captured and becomes a bound variable. –To an outside observer, it suddenly disappears!

15 Substitution Completed

16 We have to rename bound variables as necessary. Capture-Avoiding Substitution in Action

17  Conversion Renaming bound variables when necessary Okay because the names of bound variables do not matter. Examples

18 Formalization of  -Conversion See the course notes! –It's more interesting than you might think.

19 Outline Abstract syntax of the -calculus V Operational semantics of the -calculus V Substitutions V Programming in the -calculus

20 A boolean value –"Give me two options and I will choose one for you!" Syntactic sugar Booleans

21 Examples Under the call-by-name strategy,

22 Logical Operators

23 Natural Numbers A natural number n –has the capability to repeat a given process n times. –"Give me a function f and I will return f n = f o f... f o f "

24 Church Numerals

25 Addition Key observation:

26 Multiplication Key observation: Alternatively

27 Recursive Functions in -Calculus Plan of attack 1.Assume a recursive function construct fun f x. e 2.Rewrite it as an expression in the -calculus i.e., show that it is syntactic sugar.

28 Plan of attack 1.Assume a recursive function construct 2.Rewrite it as an expression in the -calculus i.e., show that it is syntactic sugar. Example: Factorial

29 fac to FAC

30 FAC produces a new function from f

31 Now we only need to find a fixed point of:

32 Fixed Point Fixed point of function f V such that V = f (V) Ex. f (x) = 2 - x fixed point of f = 1 1 = f (1)

33 Magic Revealed Fixed point combinator / Y combinator (call-by-value) fix F returns a fixed point of F.

34 Now we only need to find a fixed point of: Now we only need to compute:

35 Answer