{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

fu-lambda-tutorial

# fu-lambda-tutorial - A Tutorial Introduction to the Lambda...

This preview shows pages 1–3. Sign up to view the full content.

A Tutorial Introduction to the Lambda Calculus Ra´ul Rojas * FU Berlin, WS-97/98 Abstract This paper is a short and painless introduction to the λ calculus. Originally developed in order to study some mathematical properties of effectively com- putable functions, this formalism has provided a strong theoretical foundation for the family of functional programming languages. We show how to perform some arithmetical computations using the λ calculus and how to define recur- sive functions, even though functions in λ calculus are not given names and thus cannot refer explicitly to themselves. 1 Definition The λ calculus can be called the smallest universal programming language of the world . The λ calculus consists of a single transformation rule (variable substitution) and a single function definition scheme. It was introduced in the 1930s by Alonzo Church as a way of formalizing the concept of effective computability. The λ calculus is universal in the sense that any computable function can be expressed and evaluated using this formalism. It is thus equivalent to Turing machines. However, the λ calculus emphasizes the use of transformation rules and does not care about the actual machine implementing them. It is an approach more related to software than to hardware. The central concept in λ calculus is the “expression”. A “name”, also called a “variable”, is an identifier which, for our purposes, can be any of the letters a, b, c, . . . An expression is defined recursively as follows: < expression > := < name > | < function > | < application > < function > := λ < name > . < expression > < application > := < expression >< expression > An expression can be surrounded with parenthesis for clarity, that is, if E is an expression, ( E ) is the same expression. The only keywords used in the language are λ and the dot. In order to avoid cluttering expressions with parenthesis, we adopt the convention that function application associates from the left, that is, the expression E 1 E 2 E 3 . . . E n * Send corrections or suggestions to [email protected] 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
is evaluated applying the expressions as follows: ( . . . (( E 1 E 2 ) E 3 ) . . . E n ) As can be seen from the definition of λ expressions given above, a single identifier is a λ expression. An example of a function is the following: λx.x This expression defines the identity function. The name after the λ is the identifier of the argument of this function. The expression after the point (in this case a single x ) is called the “body” of the definition. Functions can be applied to expressions. An example of an application is ( λx.x ) y This is the identity function applied to y . Parenthesis are used for clarity in order to avoid ambiguity. Function applications are evaluated by substituting the value of the argument x (in this case y ) in the body of the function definition, i.e.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern