School of Computing and Mathematics, University of Huddersfield CHA2545 Last Lecture LECTURE: LAMBDA CALCULUS SEMANTICS TUTORIAL: Revision.

Slides:



Advertisements
Similar presentations
The Exponential Function
Advertisements

Completeness and Expressiveness
Lecture 24 MAS 714 Hartmut Klauck
How Bad is Selfish Routing? By Tim Roughgarden Eva Tardos Presented by Alex Kogan.
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.
CS5371 Theory of Computation
1 Basic abstract interpretation theory. 2 The general idea §a semantics l any definition style, from a denotational definition to a detailed interpreter.
School of Computing and Mathematics, University of Huddersfield CAS810: WEEK 3 LECTURE: LAMBDA CALCULUS PRACTICAL/TUTORIAL: (i) Do exercises given out.
Language Specfication and Implementation - PART II: Semantics of Procedural Programming Languages Lee McCluskey Department of Computing and Mathematical.
MinML: an idealized programming language CS 510 David Walker.
C. Varela1 Lambda Calculus alpha-renaming, beta reduction, applicative and normal evaluation orders, Church-Rosser theorem, combinators Carlos Varela Rennselaer.
October 1, 2009Theory of Computation Lecture 8: Primitive Recursive Functions IV 1 Primitive Recursive Predicates Theorem 6.1: Let C be a PRC class. If.
Programming Language Semantics Denotational Semantics Chapter 5 Part III Based on a lecture by Martin Abadi.
Chapter 4: A Universal Program 1. Coding programs Example : For our programs P we have variables that are arranged in a certain order: Y 1 X 1 Z 1 X 2.
1 Extended Introduction to Computer Science 2 Administration סגל הקורס: –מרצים: ד"ר דניאל דויטש, איל כהן –מתרגלת:לבנת ג'רבי –בודק: ינון פלד Book: Structure.
Discrete Mathematics Algorithms. Introduction  An algorithm is a finite set of instructions with the following characteristics:  Precision: steps are.
Introduction to Proofs
Analyzing Recursive Algorithms A recursive algorithm can often be described by a recurrence equation that describes the overall runtime on a problem of.
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.
CS3518 Languages and Computability Kees van Deemter Lectures Monday14:00New King’s 14 Tuesday11:00KC T2 Tutorials/Practicals Tuesday13:00-15:00.
1 Programming Languages and Paradigms Functional Programming.
Fixed Point Illustrations. Simple Examples f : int -> int f(n) = 5 n = 5 is a unique fixed point. f(n) = n^2 – 2 n = 2 and n = -1 are both fixed points.
Recursion. L162 Agenda Recursion and Induction Recursive Definitions Sets Strings.
1 Annoucement n Skills you need: (1) (In Thinking) You think and move by Logic Definitions Mathematical properties (Basic algebra etc.) (2) (In Exploration)
CS621 : Artificial Intelligence Pushpak Bhattacharyya CSE Dept., IIT Bombay Lecture 12- Completeness Proof; Self References and Paradoxes 16 th August,
© 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.
1 Formal Semantics. 2 Why formalize? ML is tricky, particularly in corner cases generalizable type variables? polymorphic references? exceptions? Some.
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.
Naïve Set Theory. Basic Definitions Naïve set theory is the non-axiomatic treatment of set theory. In the axiomatic treatment, which we will only allude.
ICS 253: Discrete Structures I Induction and Recursion King Fahd University of Petroleum & Minerals Information & Computer Science Department.
CS 103 Discrete Structures Lecture 13 Induction and Recursion (1)
Based on slides by Patrice Belleville and Steve Wolfman CPSC 121: Models of Computation Unit 11: Sets.
CMSC 330: Organization of Programming Languages Operational Semantics a.k.a. “WTF is Project 4, Part 3?”
School of Computing and Engineering, University of Huddersfield CHA2545: WEEK 14 – SEMANTICS EXAMPLE LECTURE: SIMPLE EXAMPLE OF SEMANTICS DEFINITION TUTORIAL/PRACTICAL:
1/33 Basic Scheme February 8, 2007 Compound expressions Rules of evaluation Creating procedures by capturing common patterns.
CS 312: Algorithm Analysis Lecture #7: Recurrence Relations a.k.a. Difference Equations Slides by: Eric Ringger, with contributions from Mike Jones, Eric.
Based on slides by Patrice Belleville and Steve Wolfman CPSC 121: Models of Computation Unit 11: Sets.
SECTION 9 Orbits, Cycles, and the Alternating Groups Given a set A, a relation in A is defined by : For a, b  A, let a  b if and only if b =  n (a)
CMSC 330: Organization of Programming Languages Operational Semantics.
School of Computing and Mathematics, University of Huddersfield CAS810: WEEK 8 LECTURE: LAMBDA CALCULUS SEMANTICS TUTORIAL: exercises.
Section 1.8. Proof by Cases Example: Let b = max{a, b} = a if a ≥ b, otherwise b = max{a, b} = b. Show that for all real numbers a, b, c
Arvind Computer Science and Artificial Intelligence Laboratory M.I.T. L03-1 September 14, 2006http:// -calculus: A Basis for.
1 Proving Properties of Recursive List Functions CS 270 Math Foundations of CS Jeremy Johnson.
Chapter 2: Lambda Calculus
CS 550 Programming Languages Jeremy Johnson
Unit – 3 :LAMBDA CALCULUS AND FUNCTIONAL PROGRAMMING
Theory of Computation Lecture 10: A Universal Program I
Modeling with Recurrence Relations
Lecture 22 Definite Integrals.
More on Lambda Calculus
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.
Lesson2 Lambda Calculus Basics
Denotational Semantics (Denotational Semantics)
CS 220: Discrete Structures and their Applications
Extended Introduction to Computer Science
CSE322 Regular Expressions and their Identities
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
Language semantics Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section
CSE S. Tanimoto Lambda Calculus
COMPILER CONSTRUCTION
Presentation transcript:

School of Computing and Mathematics, University of Huddersfield CHA2545 Last Lecture LECTURE: LAMBDA CALCULUS SEMANTICS TUTORIAL: Revision

School of Computing and Mathematics, University of Huddersfield LAMBDA CALCULUS it is a notation for describing the behaviour of ALL COMPUTABLE FUNCTIONS. LAMBDA CALCULUS functions are the denotations in our semantic definition. We will study briefly its semantics.

School of Computing and Mathematics, University of Huddersfield The Problem with recursive definitions - Russell’s Paradox for sets: We can define SETS of things which are sets e.g. X = { {1,2}, {2,4} } is a set of sets. We can define sets implicitly via properties e.gX ={x : x is a set containing 3 elements} We can define sets of things that contain themselves: e.g. X = {x : x is a set of sets} X contains itself…! Define Z = { x : x does not contain itself} does Z contain itself!!

School of Computing and Mathematics, University of Huddersfield Russell’s Paradox is related to recursive Lambda calculus functions : At the heart of the paradox is self-reference - recursive functions are self-referential - basic lambda calculus was shown to be inconsistent by a similar argument, which led to “typed” Lambda calculus ie without “type theory” to limit expression we can introduce paradoxes into recursive definitions.

School of Computing and Mathematics, University of Huddersfield Fixed point Semantics A recursive function can be recast as the solution to fixed point equation H f = f One way of finding fixed points is to use a “Fixed Point Combinator”. This is a function which computes fixed points of other functions. Most commonly used is Y = lf ( lx f (x x) ) ( lx f (x x) ) Then for all F, F (YF) = YF. PROOF: YF = lf ( lx f (x x) ) ( lx f (x x) ) F = (lx F (x x) ) ( lx F (x x) ) = F ( (lx F (x x))(lx F (x x)) ) = F ( lg (lx g (x x))(lx g (x x))F ) = F (YF)

School of Computing and Mathematics, University of Huddersfield LAMBDA CALCULUS - Fixed Point Semantics But consider the following function: 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 u. v. (u=v => u+1,  ) are fixed points of H.

School of Computing and Mathematics, University of Huddersfield Fixed point Semantics via Approximations An approximation f’ of a function f is defined as If f’ s is defined then f’ s = f s Eg f’ 0 = 0, f’ 1 = 1, f’ n = undefined for n>1 Is an approximation of f n = n*n

School of Computing and Mathematics, University of Huddersfield Fixed point theorem A static solution of the fixed point equation can be given by approximations: f = H n ( , as n tends to infinity H  H H  H  H H  are improving approximations of f Example: For the factorial function: 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 LAMBDA CALCULUS - Fixed Point Semantics Assume H (f ) = f. Then H n (  as n tends to infinity, gives us the “LEAST DEFINED” fixed point f of H, which is defined as the “non-recursive” meaning of function f

School of Computing and Mathematics, University of Huddersfield  CALCULUS: operational semantics An operational semantics gives us an abstract but precise way to execute functions (programs). A  expression is in NORMAL FORM if it is a  abstraction - i.e. It cannot be reduced. Operational Semantics: Repeatedly apply the conversion rules to an “application” until it is in normal form.

School of Computing and Mathematics, University of Huddersfield  CALCULUS: order of application Two main ones: Left-most innermost (call by value)..basically reduce arguments of a function before reducing the function Left-most outermost (call by name) (also called normal order reduction)..basically reduce the outer-most function without reducing its arguments

School of Computing and Mathematics, University of Huddersfield  CALCULUS: operational semantics Problem: the ORDER of application sometimes makes a difference! E.g. Try ( x. y.y) ( ( v.vv)( z.zz) )

School of Computing and Mathematics, University of Huddersfield  CALCULUS: Church-Rosser Theorem (Paraphrase) If a  Calculus Application can be reduced to a normal form then -- that normal form is UNIQUE up to naming -- the normal form can be reached using normal- order reduction Corollary: We now have a nice operational semantics for  calculus and hence pure functional programming

School of Computing and Mathematics, University of Huddersfield LAMBDA CALCULUS - Fixed Point Semantics = Operational Semantics BIG THEOREM: The least defined fixed point of f  IS OPERATIONALLY THE SAME AS f  NB All above is paraphrased in that I have extracted all the maths/domain theory out to give you the gist.