Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

CSC-421/621 Homework 3: The lambda calculus

Problem 1:

A variable in a lambda calculus expression can be bound to one of the λ terms, or is free if it isn't bound to
any. (Refer to Section 1.1 of the lambda calculus tutorial written by R. Rojas for additional explanation.)

For each of the following expressions, identify which variables are bound and which are free:

(a): (λx.x)

(b): (λx.x) y

(c): (λxy.xz) y

(d): (λx.x) (λy.yx)

Hint: There may be more than one distinct variable named 'x', 'y', or 'z' in a given expression! When there
is, clarify which variable you're referring to, e.g. "the x inside the first lambda is bound".

Problem 2:

For each of the expressions in Problem 1, show what it reduces to. (If an expression doesn't reduce any
further, just write the expression as-is as your answer.)

Problem 3:

The only thing we can do in the lambda calculus is define functions. Therefore, data types such as
booleans, integers, or anything else are encoded into particular choices of functions. Any choice of
encoding is possible, but for the data types to work, we need to be able to define operations that do the
things we would normally expect to be able to do with that data type.

The following is how boolean values are typically encoded in the lambda calculus:

T = (λxy.x)

F = (λxy.y)

Here is a definition of the boolean function NOT:

(λx.x(λuv.v)(λab.a))

(a): Write the lambda expression for NOT F. (Write the expression that would compute NOT F, not the
result of the computation.)

(b): Show step-by-step how the term for NOT F that you gave in (a) reduces.

Hint: It should reduce to a lambda expression equivalent to T!


(c): Why does this definition of NOT work?

Hint: It may be useful to notice that NOT = (λx.x(λuv.v)(λab.a)) = (λx.xFT).

Extra credit:

Write a lambda expression that calculates NAND, the boolean function which returns true when at least
one of its arguments is false. You can either devise it from scratch, or build it out of the logical operators
that the R. Rojas tutorial already defined. Include a brief explanation of which approach you took, and why
your construction of NAND works.

You might also like