Skip to content
The Lumenary

Each worksheet prints cleanly on A4 or Letter. Answer keys are on a separate page.

The Lumenary · Advanced undergraduate

The λ-calculus

Name: ______________________

Date: ______________________

You will learn to

  • Reduce λ-terms using capture-avoiding substitution, and encode booleans, pairs and natural numbers (Church numerals)
  • Use a fixed-point combinator to define recursive functions, and explain why untyped terms need not terminate
  • Prove the Church–Rosser theorem by parallel reduction and deduce that a term has at most one normal form
  • Prove that every simply typed λ-term has a normal form, and say what this costs in expressive power
  • State the equivalence of λ-definability with computability and the undecidability of β-equality
  1. 1.

    List the free variables of the term λx. x y (λy. y z)\lambda x.\, x\, y\, (\lambda y.\, y\, z). Enter each variable name once.

  2. 2.

    What does (λx. λy. x) y(\lambda x.\, \lambda y.\, x)\, y reduce to in one β-step (with yy free)?

    • A.λz. y\lambda z.\, y
    • B.λy. y\lambda y.\, y
    • C.yy
    • D.λy. x\lambda y.\, x
  3. 3.

    With Church numerals nˉ=λf x. fn x\bar n = \lambda f\, x.\, f^n\, x, the term 3ˉ 2ˉ\bar 3\, \bar 2 (the numeral 33 applied to the numeral 22) β-reduces to a Church numeral kˉ\bar k. What is kk?

  4. 4.

    Which of these terms have no normal form? Here Ω=(λx. x x)(λx. x x)\Omega = (\lambda x.\, x\, x)(\lambda x.\, x\, x), K=λx y. xK = \lambda x\, y.\, x, I=λx. xI = \lambda x.\, x. Choose all that apply.

    • A.Ω\Omega
    • B.λz. Ω\lambda z.\, \Omega
    • C.K I ΩK\, I\, \Omega
    • D.(λx. x x)(λy. y)(\lambda x.\, x\, x)(\lambda y.\, y)
  5. 5.

    Why does the proof of the Church–Rosser theorem go through parallel reduction ⇒\Rightarrow instead of showing directly that one-step reduction →\to has the diamond property?

    • A.Because →\to does not have the diamond property: contracting a redex can duplicate another redex, so joining may need several steps on one side.
    • B.Because →\to is not terminating.
    • C.Because ⇒\Rightarrow is terminating while →\to is not.
    • D.Because the diamond property for →\to is true but too hard to prove.
  6. 6.

    In Turing's proof of weak normalisation we contract a redex R=(λx:A. P) QR = (\lambda x{:}A.\, P)\, Q of maximal degree dd chosen so that QQ contains no redex of degree dd. Which part of the argument needs this choice?

    • A.Redexes inside QQ may be copied many times by the substitution P[Q/x]P[Q/x]; the choice ensures all the copies have degree less than dd.
    • B.It ensures that no new redexes are created.
    • C.It ensures that the redexes inside PP survive.
    • D.It ensures the term is typable after the step.
  7. 7.

    Which of these terms has a type in the simply typed λ-calculus (for suitable types on the bound variables)?

    • A.λf x. f (f x)\lambda f\, x.\, f\,(f\, x)
    • B.λx. x x\lambda x.\, x\, x
    • C.Y=λf. (λx. f (x x)) (λx. f (x x))Y = \lambda f.\, (\lambda x.\, f\,(x\, x))\,(\lambda x.\, f\,(x\, x))
    • D.Ω\Omega
  8. 8.

    In the lesson's Lean file, Step t u is one β-step and ReflTransGen Step t u is t↠ut \twoheadrightarrow u. Which statement is the Church–Rosser theorem, as proved there?

    • A.∀ {t u v}, ReflTransGen Step t u → ReflTransGen Step t v → ∃ w, ReflTransGen Step u w ∧ ReflTransGen Step v w
    • B.Diamond Step
    • C.∀ t, ∃ u, ReflTransGen Step t u ∧ Normal u
    • D.∀ {t u v}, Step t u → Step t v → u = v
  9. 9.

    Python's lambda can run Church numerals directly. With church(n) and to_int below, define times(m, n) and exp(m, n) returning the Church numerals for m⋅nm \cdot n and mnm^n, using only application and lambda (no conversion to int inside them).

    Computational — Practice

Code: Apache-2.0 · Content: CC BY-SA 4.0