|
![]() CS 636 / 338: The Structure of Programming Languages Lambda Calculus From classes 5/1/04 and 5/8/04 |
| Email A.Fischer at work | Email A.Fischer at home |
|
An EBNF Grammar for Lambda Expressions.
Notes on this Grammar. In rule 2, we can the part before the dot corresponds to a function header and parameter list. The part between the dot and the vertical bar is the body of the function. An application corresponds to a function call.
Renaming. As in any programming language, you can change the name of a parameter is all references to that parameter are also changed. Thus, there are many equivalent ways to write the number 1, including these: 1 = λx.λy.xy and 1 = λp.λq.pq Binding and scope. Each λ creates one parameter (bound variable). The scope of a binding is from the lambda that declares it to the end of the formula, or to the parenthesis that closes the function by matching the paren just before the lambda. For example, there are three bound variables in this formula: (λn.(λx.λy.nx(xy))) p(pq) The scope of n is (λx.λy.nx(xy)), the scope of x is λy.nx(xy), and the scope of y is nx(xy).
When a binding for the variable x is nested inside an expression that has another binding for x, the familiar scoping rule applies: each reference to x is bound by the most recent open binding. For example, there are two bindings for x in the following expression: Free variables. A variable can occur in an expression without any binding. We call these "free variables". They cannot be renamed, because the renaming rule requires that variable and binding must be renamed simultaneously. A Lambda Application: calculate the successor of 1.
|
| Last updated: 5/2/04 |