markdown
Basics of the Untyped Lambda Calculusmd b7d6013
lecture/information/programming-languages/lambda-calculus/lambda-calculus-basics.lecture.n.md
Download PDF

Basics of the Untyped Lambda Calculus

informationprogramming-languageslambda-calculuslecture

1Introduction

This lecture explains the syntax and beta-reduction of the untyped lambda calculus. It reviews free variables and alpha-equivalence before beta-reduction because substitution must avoid variable capture. No typing judgment is introduced here.

21. Syntax and association conventions

Let the set of variables be countably infinite. Lambda terms t are defined inductively by

t::=xλx.ttt.

The term λx.t is a lambda abstraction that binds x, and ts is an application. Application associates to the left, and the body of an abstraction extends as far right as possible. Thus tuv=(tu)v and λx.tu=λx.(tu).

32. Free variables and alpha-equivalence

The set FV(t) of free variables is defined by

FV(x)={x},FV(λx.t)=FV(t){x},FV(tu)=FV(t)FV(u).

Terms that differ only by a consistent renaming of bound variables are alpha-equivalent. For example, λx.x=αλz.z. A binder cannot, however, be renamed to z when z occurs free in its body.

43. Capture-avoiding substitution

The term t[x:=s] replaces every free occurrence of x in t with s. If xFV(t), then t[x:=s]=t. Its variable and application cases follow the term structure. The abstraction case is

(\lambda y.t)[x:=s]= \begin{cases} \lambda y.t & y=x,\\ \lambda y.(t[x:=s]) & y\ne x\ \text{and}\ y\notin\mathrm{FV}(s),\\ \lambda z.((t[y:=z])[x:=s]) & y\ne x\ \text{and}\ y\in\mathrm{FV}(s), \end{cases}

where the last case chooses a fresh variable z that differs from x and does not occur anywhere in either t or s. For example, directly producing λy.y from (λy.x)[x:=y] would capture the free y of the substituted term. Alpha-renaming first gives (λy.x)[x:=y]=α(λz.x)[x:=y]=λz.y.

54. Beta-reduction and normal forms

A subterm of the form (λx.t)s is a beta-redex. Capture-avoiding substitution contracts it as follows:

(λx.t)sβt[x:=s].

A beta-redex at any position in a term may be contracted in one step. A term containing no beta-redex is a beta-normal form.

(λx.λy.x)abβ(λy.a)bβa.

In contrast, the only beta-redex of Ω=(λx.xx)(λx.xx) is the whole term, and contracting it returns ΩβΩ. Hence no reduction sequence reaches a beta-normal form. The untyped lambda calculus does not guarantee termination in general.

65. Evaluation strategies

Beta-reduction does not prescribe an order for selecting redexes. Normal order selects the leftmost outermost redex, whereas applicative order selects the leftmost innermost redex; the two strategies can have different termination behavior. Consider

(λx.a)Ω.

Normal order contracts the outer redex first and reaches a. Applicative order repeatedly reduces Ω and does not terminate. This is a difference in strategy termination, not a difference in the beta-reduction rule. If a term has a beta-normal form, normal-order reduction reaches it.

76. Distinguishing eta-conversion

When xFV(f), the eta-conversion λx.fx=ηf expresses extensional identification of functions. It is distinct from beta-reduction, which performs function application.

8Summary

Computation in the untyped lambda calculus is beta-reduction by capture-avoiding substitution, considered modulo alpha-equivalence. The existence of a normal form must be distinguished from termination under a particular evaluation strategy.

data/lecture/information/programming-languages/foundation/substitution-and-alpha-equivalence-basics.lecture.n.md
raw .n.md をコピー
loc をコピー (filepath:line ~ line)
copy share link
copy encoded share link
path をコピー
copy share link
copy encoded share link
copy share link
copy encoded share link
タブを全て閉じる