School of Computing and Mathematics, University of Huddersfield CAS810: WEEK 3 LECTURE: LAMBDA CALCULUS PRACTICAL/TUTORIAL: (i) Do exercises given out.

Slides:



Advertisements
Similar presentations
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.
Advertisements

Elements of Lambda Calculus Functional Programming Academic Year Alessandro Cimatti
David Evans CS150: Computer Science University of Virginia Computer Science Lecture 39: Lambda Calculus.
ISBN Chapter 3 Describing Syntax and Semantics.
School of Computing and Engineering, University of Huddersfield CHA2545: WEEK 14 LECTURE: ABSTRACT SYNTAX SIMPLE EXAMPLE OF SEMANTICS DEFINITION TUTORIAL/PRACTICAL:
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.
Language Specfication and Implementation - PART II: Semantics of Procedural Programming Languages Lee McCluskey Department of Computing and Mathematical.
Computing Fundamentals 1 Lecture 1 Lecturer: Patrick Browne Room K308 Based on Chapter 1. A Logical approach to Discrete.
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.
מבוא מורחב - שיעור 2 1 Lecture 2 - Substitution Model (continued) - Recursion - Block structure and scope (if time permits)
School of Computing and Mathematics, University of Huddersfield CHA2545 Last Lecture LECTURE: LAMBDA CALCULUS SEMANTICS TUTORIAL: Revision.
Type Systems and Object- Oriented Programming John C. Mitchell Stanford University.
Continuous Random Variables and Probability Distributions
Describing Syntax and Semantics
1 Relational Algebra and Calculus Yanlei Diao UMass Amherst Feb 1, 2007 Slides Courtesy of R. Ramakrishnan and J. Gehrke.
Chapter 5 Objectives 1. Find ordered pairs associated with two equations 2. Solve a system by graphing 3. Solve a system by the addition method 4. Solve.
Example 1. Find the exact value of FP2 Calculus 1 Inverse Trig functions.
PPL Syntax & Formal Semantics Lecture Notes: Chapter 2.
Objective - To graph linear equations using x-y charts. One Variable Equations Two Variable Equations 2x - 3 = x = 14 x = 7 One Solution.
Thinking Mathematically Algebra: Graphs, Functions and Linear Systems 7.3 Systems of Linear Equations In Two Variables.
Lecture 20: λ Calculus λ Calculus & Computability Yan Huang Dept. of Comp. Sci. University of Virginia.
The importance of sequences and infinite series in calculus stems from Newton’s idea of representing functions as sums of infinite series.  For instance,
Functional Languages. Why? Referential Transparency Functions as first class objects Higher level of abstraction Potential for parallel execution.
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.
© Kenneth C. Louden, Chapter 11 - Functional Programming, Part III: Theory Programming Languages: Principles and Practice, 2nd Ed. Kenneth C. Louden.
Lexicografie computationala Feb., 2012 Anca Dinu University of Bucharest.
© Kenneth C. Louden, Chapter 11 - Functional Programming, Part III: Theory Programming Languages: Principles and Practice, 2nd Ed. Kenneth C. Louden.
Albert Gatt LIN3021 Formal Semantics Lecture 4. In this lecture Compositionality in Natural Langauge revisited: The role of types The typed lambda calculus.
Formal Semantics of Programming Languages 虞慧群 Topic 1: Introduction.
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.
School of Computing and Mathematics, University of Huddersfield CHA2545: WEEK 4 LECTURE: DENOTIONAL SEMANTICS OF A SIMPLE LANGUAGE TUTORIAL: Do exercises.
Lambda Calculus Prepared by Manuel E. Bermúdez, Ph.D. Associate Professor University of Florida Programming Language Principles Lecture 11.
Lambda Calculus CSE 340 – Principles of Programming Languages Fall 2015 Adam Doupé Arizona State University
School of Computing and Engineering, University of Huddersfield CHA2545: WEEK 14 – SEMANTICS EXAMPLE LECTURE: SIMPLE EXAMPLE OF SEMANTICS DEFINITION TUTORIAL/PRACTICAL:
10-1 An Introduction to Systems A _______ is a set of sentences joined by the word ____ or by a ________________. Together these sentences describe a ______.
Systems of Linear Equations in Two Variables. 1. Determine whether the given ordered pair is a solution of the system.
Lesson 3 Formalizing and Implementing Pure Lambda Calculus 1/15/02 Chapters 5.3, 6, 7.
CSC3315 (Spring 2009)1 CSC 3315 Languages & Compilers Hamid Harroud School of Science and Engineering, Akhawayn University
School of Computing and Mathematics, University of Huddersfield CAS810: WEEK 8 LECTURE: LAMBDA CALCULUS SEMANTICS TUTORIAL: exercises.
CS321 Functional Programming 2 © JAS The λ Calculus This is a formal system to capture the ideas of function abstraction and application introduced.
C H A P T E R E I G H T Functional Programming Programming Languages – Principles and Paradigms by Allen Tucker, Robert Noonan.
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.
Chapter 2: Lambda Calculus
CS 550 Programming Languages Jeremy Johnson
Unit – 3 :LAMBDA CALCULUS AND FUNCTIONAL PROGRAMMING
Lecture 6: Lambda Calculus
Lambda Calculus CSE 340 – Principles of Programming Languages
Denotational Semantics
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
Systems of Linear Equations in Two Variables
Announcements Quiz 6 HW7 due Tuesday, October 30
Carlos Varela Rennselaer Polytechnic Institute September 8, 2017
MA/CSSE 474 More Math Review Theory of Computation
Class 33: Making Recursion M.C. Escher, Ascending and Descending
Announcements Exam 2 on Friday, November 2nd Topics
L Calculus.
Recursion and Fixed-Point Theory
CSE S. Tanimoto Lambda Calculus
Carlos Varela Rennselaer Polytechnic Institute September 8, 2015
Carlos Varela Rennselaer Polytechnic Institute September 10, 2019
Presentation transcript:

School of Computing and Mathematics, University of Huddersfield CAS810: WEEK 3 LECTURE: LAMBDA CALCULUS PRACTICAL/TUTORIAL: (i) Do exercises given out (ii) Go through ARJ’s supporting WEB notes (from main web page).

School of Computing and Mathematics, University of Huddersfield LAMBDA CALCULUS n A Formal System is a formal language together with a well-defined way of “reasoning” with expressions in the language. EG predicate calculus n Lambda Calculus is a formal system designed by Alonzo Church in 1940, developed by Scott and Strachey c.1970.

School of Computing and Mathematics, University of Huddersfield LAMBDA CALCULUS -- USE n it is a notation for describing the behaviour of functions - it can be used to represent ALL COMPUTABLE FUNCTIONS. n It is used (as other formal systems) to theorise about computation. These theories direct and support work in compiler design, language design, interface design etc.. n LAMBDA CALCULUS expressions are the denotations in our semantic definitions (next week)

School of Computing and Mathematics, University of Huddersfield LAMBDA CALCULUS -- SYNTAX ::= | ( ) | % abstraction % application NB: n If there are no brackets, expressions are LEFT ASSOCIATIVE - abc = ((a)b)c n We ENRICH syntax with numbers and the function (b->x,y) meaning if b then x else y n Scope rules..

School of Computing and Mathematics, University of Huddersfield LAMBDA CALCULUS -- WHY? n It has simple, clear structure / syntax providing a simple model of function definition and application n used extensively as a MEANING domain for programming languages n allows us to treat functions as values, and to define functions without giving them a name! EG: x.x - lambda abstraction - identity function x.x+1 - lambda abstraction - successor function  x.x+1)y - application  x.x+1)  y.y+1) - application

School of Computing and Mathematics, University of Huddersfield LAMBDA CALCULUS - substitution The calculus “evaluates” using substitution and use of CONVERSION RULES: An occurrence of variable x is BOUND in a lambda expression M if x.N is a sub-expression of M and x occurs within N. Otherwise, the occurrence of x is FREE. n [M/x]N means substitute expression M for all free occurrences of x in N.

School of Computing and Mathematics, University of Huddersfield LAMBDA CALCULUS - Conversion Rules (i)If y does not occur free in N then x.N cnv  y[y/x]N (ii) Reduction -  x.M)N cnv  [N/x]M (iii) Reduction - if x is NOT FREE in M  x.M)N cnv  M

School of Computing and Mathematics, University of Huddersfield LAMBDA CALCULUS -- EXAMPLES x.x - lambda abstraction - identity function x.x+1 - lambda abstraction - successor function  x.x+1)y - application  x.xx)  y.y) - application recursive functions in enriched syntax.. f = n.(n=0 -> 1, n*f(n-1))

School of Computing and Mathematics, University of Huddersfield Introduction to the Semantics of -calculus Well, you can evaluate them to normal form using the conversion rules… But recursive functions - what do they MEAN?????

School of Computing and Mathematics, University of Huddersfield Recursive Functions - The Fixed Point Equation E.g. Factorial Function f = n.(n=0 -> 1, n*f(n-1)) Consider: H = g. n.(n=0 -> 1, n*g(n-1)) H f = ( g. n.(n=0 -> 1, n*g(n-1))) f = n.(n=0 -> 1, n*f(n-1)) = f by the definition above. Hf = f... is the fixed point equation

School of Computing and Mathematics, University of Huddersfield The Fixed Point Equation n Every recursive function f has a corresponding the fixed point equation H f = f where H is constructed as shown in the slide above. So - a non-recursive function which satisfies H f = f can be thought of as the “meaning” f

School of Computing and Mathematics, University of Huddersfield Problem... But consider f = x. y.( x=y -> y+1, f x (f (x-1) (y-1)) ) In this case H has many fixed points !! E.g.  u. v. u+1 is a fixed point of H. There are many others.

School of Computing and Mathematics, University of Huddersfield Solving the Fixed Point Equation - “Graphs” of Functions n The Graph of a function f is a list of pairs (n, f n) where n is an input value to f. E.G. Part of the graph for factorial is g = {(0,1), (1,1), (2,2), (3,6), (4,24), (5,120), (6,720) } We can also DEFINE functions using graphs, and approximate recursive functions with them. NB g is an FINITE APPROXIMATION of factorial.

School of Computing and Mathematics, University of Huddersfield A static solution to the FPE The static solution of the FP equation turns out to be (lots of maths later…): f = H n (  as n tends to infinity. eg For the factorial: H = g. n.(n=0 -> 1, n*g(n-1)) H  n.(n=0 -> 1,  Graph(H  = (0,1), (1,  ), (2,  ), (3,  ), (4,  )… H H  g. n.(n=0 -> 1, n*g(n-1)) ( n.(n=0 -> 1,  Graph(H H  (0,1), (1, 1), (2,  ), (3,  ), (4,  )…

School of Computing and Mathematics, University of Huddersfield Example - Conclusion H  H H  H  H H  are improving approximations of any recursive function f, where H appears in f’s fixed point equation. SO, the meaning of recursive functions can be given via a “fixed point semantics”. The MYSTERY of recursive functions having infinite fixed points is cleared up - H n (  = the least defined fixed point.

School of Computing and Mathematics, University of Huddersfield Exercises (1) Consider the following Lambda applications:  x.xx)  y.y) 1.2 ( y. z.z -> x,y)( x. y.xy) 1.3 ( g. n.(n=0 -> 1, n*g(n-1)) ( y.y+1)) 3 - For each instance of each variable in , say whether the instance of the variable occurs free or bound. - Use the conversion rules to find the normal forms for (2) If f is the factorial function, and H f = f, derive H 3 (  ) and H 4 (  ). Hence derive graph(H 3 (  ) ), graph(H 4 (  ) ) and verify that they are improving approximations to f. (3) If H is the general function in the Cmeans of the while loop, derive H 1 (  ) and H 2 (  ) and their graphs. Are they approximations of the while-loop?