1 / 14

CHA2545 Last Lecture

CHA2545 Last Lecture. LECTURE: LAMBDA CALCULUS SEMANTICS TUTORIAL: Revision. 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.

elroy
Download Presentation

CHA2545 Last Lecture

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CHA2545 Last Lecture • LECTURE: • LAMBDA CALCULUS SEMANTICS • TUTORIAL: • Revision

  2. 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.

  3. 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.g X ={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!!

  4. 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.

  5. 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)

  6. 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.

  7. 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

  8. Fixed point theorem • A static solution of the fixed point equation can be given by approximations: • f = Hn(, 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, )…

  9. LAMBDA CALCULUS - Fixed Point Semantics • Assume H (f ) = f. • Then Hn(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

  10. 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.

  11. 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

  12. CALCULUS: operational semantics • Problem: • the ORDER of application sometimes makes a difference! • E.g. Try • (x. y.y) ( (v.vv)(z.zz) )

  13. 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

  14. 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.

More Related