Lambda calculus

The Church–Rosser Property

Reading preferences

Optional display controls need JavaScript. All reading content and navigation work without it.

Source file content/lambda-calculus/church-rosser/church-rosser.tex

Source file content/lambda-calculus/church-rosser/definitions-and-properties.tex

Definition and Properties

In this chapter we introduce the concept of Church--Rosser property and some common properties of this property.

Definition of the Church Rosser property

[Church--Rosser property, CR] A relation X\xredonesource on terms is said to satisfy the Church--Rosser property iff, whenever MXPM \xredone Psource and MXQM \xredone Qsource, then there exists some NNsource such that PXNP \xredone Nsource and QXNQ \xredone Nsource.

We can view the lambda calculus as a model of computation in which terms in normal form are “values” and a reducibility relation on terms are the “calculation rules.” The Church--Rosser property states is that when there is more than one way to proceed with a calculation, there is still only a single value of the expression.

To take an example from elementary algebra, there's more than one way to calculate 4×(1+2)+34 \times (1+2) + 3source. It can either be reduced to 4×3+34 \times 3+3source (if we first reduce 1+21+2source to 33source) or to 4×1+4×2+34 \times 1+4 \times 2+3source (if we first reduce 4×(1+2)4 \times (1+2)source using distributivity). Both of these, however, can be further reduced to 12+312+3source.

If we take X\xredonesource to be β\betasource-reduction, we easily see that a consequence of the Church--Rosser property is that if a term has a normal form, then it is unique. For suppose MMsource can be reduced to PPsource and QQsource, both of which are normal forms. By the Church--Rosser property, there exists some NNsource such that both PPsource and QQsource reduce to it. Since by assumption PPsource and QQsource are normal forms, the reduction of PPsource and QQsource to NNsource can only be the trivial reduction, i.e., PPsource, QQsource, and NNsource are identical. This justifies our speaking of the normal form of a term.

In viewing the lambda calculus as a model of computation, then, the normal form of a term can be thought of as the “final result” of the computation starting with that term. The above corollary means there's only one, if any, final result of a computation, just like there is only one result of computing 4×(1+2)+34 \times (1+2)+3source, namely 1515source.

Church Rosser property passes to transitive closure

If a relation X\xredonesource satisfies the Church--Rosser property, and X\xredsource is the smallest transitive relation containing X\xredonesource, then X\xredsource satisfies the Church--Rosser property too.

Proof

Suppose

MXP1XXPm andMXQ1XXQn.M & \xredone P_1 \xredone \dots \xredone P_m \text{ and}\\ M & \xredone Q_1 \xredone \dots \xredone Q_n.source

We will prove the theorem by constructing a grid NNsource of terms of height is m+1m + 1source and width n+1n + 1source. We use Ni,jN_{i,j}source to denote the term in the iisource-th row and jjsource-th column.

We construct NNsource in such a way that Ni,jXNi+1,jN_{i,j} \xredone N_{i+1,j}source and Ni,jXNi,j+1N_{i,j} \xredone N_{i,j+1}source. It is defined as follows:

N0,0=MNi,0=Piif 1imN0,j=Qjif 1jnand otherwise:Ni,j=RN_{0,0} &= M \\ N_{i,0} &= P_i && \text{if } 1 \le i \le m \\ N_{0,j} &= Q_j && \text{if } 1 \le j \le n \\ \intertext{and otherwise:} N_{i,j} &= Rsource

where RRsource is a term such that Ni1,jXRN_{i-1,j} \xredone Rsource and Ni,j1XRN_{i,j-1} \xredone Rsource. By the Church--Rosser property of X\xredonesource, such a term always exists.

Now we have Nm,0XXNm,nN_{m,0} \xredone \dots \xredone N_{m,n}source and N0,nXXNm,nN_{0,n} \xredone \dots \xredone N_{m,n}source. Note Nm,0N_{m,0}source is PPsource and N0,nN_{0,n}source is QQsource. By definition of X\xredsource the theorem follows.

Source file content/lambda-calculus/church-rosser/parallel-beta-reduction.tex

Parallel β\betasource-reduction

We introduce the notion of parallel β\betasource-reduction, and prove the it has the Church--Rosser property.

Four source rules for parallel beta reduction

[parallel β\betasource-reduction, β\bredparsource] Parallel reduction (β\bredparsource) of terms is inductively defined as follows:

  1. xβxx \bredpar xsource.

  2. If NβNN \xrightarrow{\beta} N'source then λx.Nβλx.N\lambd[x][N] \bredpar \lambd[x][N']source.

  3. If PβPP \bredpar P'source and QβQQ \bredpar Q'source then PQβPQPQ \bredpar P'Q'source.

  4. If NβNN \bredpar N'source and QβQQ \bredpar Q'source then (λx.N)QβN[Q/x](\lambd[x][N])Q \bredpar \Subst{N'}{Q'}{x}source.

Parallel β\betasource-reduction allows us to reduce any number of redices in a term in one step. It is different from β\betasource-reduction in the sense that we can only contract redices that occur in the original term, but not redices arising from parallel β\betasource-reduction. For example, the term (λf.fx)(λy.y)(\lambd[f][fx])(\lambd[y][y])source can only be parallel β\betasource-reduced to itself or to (λy.y)x(\lambd[y][y])xsource, but not further to xxsource, although it β\betasource-reduces to xxsource, because this redex arises only after one step of parallel β\betasource-reduction. A second parallel β\betasource-reduction step yields xxsource, though.

Reflexivity of parallel beta reduction

MβMM \bredpar Msource.

Proof

Exercise.

Exercise proving parallel beta reflexivity

Prove the theorem on reflexivity of parallel beta reduction.

Definition of beta complete development

[β\betasource-complete development] The β\betasource-complete development M*β\bcd{M}source of MMsource is defined inductively as follows:

x*β=x(λx.N)*β=λx.N*β(PQ)*β=P*βQ*βif P is not a λ-abstract((λx.N)Q)*β=N*β[Q*β/x]\bcd{x} &= x \ollabel{defn:bcd1} \\ \bcd{(\lambd[x][N])} &= \lambd[x][\bcd{N}] \ollabel{defn:bcd2}\\ \bcd{(PQ)} &= \bcd{P}\bcd{Q} && \text{if $P$ is not a $\lambd$-abstract} \ollabel{defn:bcd3} \\ \bcd{((\lambd[x][N])Q)} &= \Subst{\bcd{N}}{\bcd{Q}}{x} \ollabel{defn:bcd4}source

The β\betasource-complete development of a term, as its name suggests, is a “complete parallel reduction.” While for parallel β\betasource-reduction we still can choose to not contract a redex, for complete development we have no choice but to contract all of them. Thus the complete development of (λf.fx)(λy.y)(\lambd[f][fx])(\lambd[y][y])source is (λy.y)x(\lambd[y][y])xsource, not itself.

Editorial

This definition has the problem that we haven't introduced how to define functions on (λ\lambdsource-)terms recursively. Will fix in future.

Parallel beta reduction and substitution

If MβMM \bredpar M'source and RβRR \bredpar R'source, then M[R/y]βM[R/y]\Subst{M}{R}{y} \bredpar \Subst{M'}{R'}{y}source.

Proof

By induction on the derivation of MβMM \bredpar M'source.

  1. The last step is the variable rule for parallel beta reduction: Exercise.

  2. The last step is the abstraction rule for parallel beta reduction: Then MMsource is λx.N\lambd[x][N]source and MM'source is λx.N\lambd[x][N']source, where NβNN \bredpar N'source. We want to prove that (λx.N)[R/y]β(λx.N)[R/y]\Subst{(\lambd[x][N])}{R}{y} \bredpar \Subst{(\lambd[x][N'])}{R'}{y}source, i.e., λx.N[R/y]βλx.N[R/y]\lambd[x][\Subst{N}{R}{y}] \bredpar \lambd[x][\Subst{N'}{R}{y}]source. This follows immediately by the abstraction rule for parallel beta reduction and the induction hypothesis.

  3. The last step is the application rule for parallel beta reduction: Exercise.

  4. The last step is the contraction rule for parallel beta reduction: MMsource is (λx.N)Q(\lambd[x][N])Qsource and MM'source is N[Q/x]\Subst{N'}{Q'}{x}source. We want to prove that ((λx.N)Q)[R/y]βN[Q/x][R/y]\Subst{((\lambd[x][N])Q)}{R}{y} \bredpar \Subst{\Subst{N'}{Q'}{x}}{R'}{y}source, i.e., (λx.N[R/y])Q[R/y]βN[R/y][Q[R/y]/x](\lambd[x][\Subst{N}{R}{y}])\Subst{Q}{R}{y} \bredpar \Subst{\Subst{N'}{R'}{y}}{\Subst{Q'}{R'}{y}}{x}source. This follows by the contraction rule for parallel beta reduction and the induction hypothesis.

Exercise completing the parallel beta substitution proof

Complete the proof of the substitution compatibility lemma for parallel beta reduction.

Every parallel beta reduct reaches the complete development

If MβMM \bredpar M'source then MβM*βM' \bredpar \bcd{M}source.

Proof

By induction on the derivation of MβMM \bredpar M'source.

  1. The last rule is the variable rule for parallel beta reduction: Exercise.

  2. The last rule is the abstraction rule for parallel beta reduction: MMsource is λx.N\lambd[x][N]source and MM'source is λx.N\lambd[x][N']source with NβNN \bredpar N'source. We want to show that λx.Nβ(λx.N)*β\lambd[x][N'] \bredpar \bcd{(\lambd[x][N])}source, i.e., λx.Nβλx.N*β\lambd[x][N'] \bredpar \lambd[x][\bcd{N}]source by the abstraction equation for beta complete development. It follows by the abstraction rule for parallel beta reduction and the induction hypothesis.

  3. The last rule is the application rule for parallel beta reduction:MMsource is PQPQsource and MM'source is PQP'Q'source for some PPsource, QQsource, PP'source and QQ'source, with PβPP \bredpar P'source and QβQQ \bredpar Q'source. By induction hypothesis, we have PβP*βP' \bredpar \bcd{P}source and QβQ*βQ' \bredpar \bcd{Q}source.

    1. If PPsource is λx.N\lambd[x][N]source for some xxsource and NNsource, then PP'source must be λx.N\lambd[x][N']source for some NN'source with NβNN \bredpar N'source. By induction hypothesis we have NβN*βN' \bredpar \bcd{N}source and QβQ*βQ' \bredpar \bcd{Q}source. Then (λx.N)QβN*β[Q*β/x](\lambd[x][N'])Q' \bredpar \Subst{\bcd{N}}{\bcd{Q}}{x}source by the contraction rule for parallel beta reduction.

    2. If PPsource is not a λ\lambdsource-abstract, then PQβP*βQ*βP'Q' \bredpar \bcd{P}\bcd{Q}source by the application rule for parallel beta reduction, and the right-hand side is PQ*β\bcd{PQ}source by the non-redex application equation for beta complete development.

  4. The last rule is the contraction rule for parallel beta reduction: MMsource is (λx.N)Q(\lambd[x][N])Qsource and MM'source is N[Q/x]\Subst{N'}{Q'}{x}source for some xxsource, NNsource, QQsource, NN'source, and QQ'source, with NβNN \bredpar N'source and QβQQ \bredpar Q'source. By induction hypothesis we know NβN*βN' \bredpar \bcd{N}source and QβQ*βQ' \bredpar \bcd{Q}source. By the substitution compatibility lemma for parallel beta reduction we have N[Q/x]βN*β[Q*β/x]\Subst{N'}{Q'}{x} \bredpar \Subst{\bcd{N}}{\bcd{Q}}{x}source, the right-hand side of which is exactly ((λx.N)Q)*β\bcd{((\lambd[x][N])Q)}source.

Exercise completing the beta complete development lemma

Complete the proof of the lemma that every parallel beta reduct reaches the complete development.

Church Rosser property for parallel beta reduction

β\bredparsource has the Church--Rosser property.

Proof

Immediate from the lemma that every parallel beta reduct reaches the complete development.

Source file content/lambda-calculus/church-rosser/beta-reduction.tex

β\betasource-reduction

One beta contraction is a parallel beta reduction

If MβMM \bredone M'source, then MβMM \bredpar M'source.

Proof

If MβMM \bredone M'source, then MMsource is (λx.N)Q(\lambd[x][N])Qsource, MM'source is N[Q/x]\Subst{N}{Q}{x}source, for some xxsource, NNsource, and QQsource. Since NβNN \bredpar Nsource and QβQQ \bredpar Qsource by the theorem on reflexivity of parallel beta reduction, we immediately have (λx.N)QβN[Q/x](\lambd[x][N])Q \bredpar \Subst{N}{Q}{x}source by the definition of parallel beta reductionthe contraction rule for parallel beta reduction.

A parallel beta step can be serialized

If MβMM \bredpar M'source, then MβMM \bred M'source.

Proof

By induction on the derivation of MβMM \bredpar M'source.

  1. The last rule is the variable rule for parallel beta reduction: Then MMsource and MM'source are just xxsource, and xβxx \bred xsource.

  2. The last rule is the abstraction rule for parallel beta reduction: MMsource is λx.N\lambd[x][N]source and MM'source is λx.N\lambd[x][N']source for some xxsource, NNsource, NN'source, where NβNN \bredpar N'source. By induction hypothesis we have NβNN \bred N'source. Then λx.Nβλx.N\lambd[x][N] \bred \lambd[x][N']source (by the same series of β\bredonesource contractions as NβNN \bred N'source).

  3. The last rule is the application rule for parallel beta reduction: MMsource is PQPQsource and MM'source is PQP'Q'source for some PPsource, QQsource, PP'source, QQ'source, where PβPP \bredpar P'source and QβQQ \bredpar Q'source. By induction hypothesis we have PβPP \bred P'source and QβQQ \bred Q'source. So PQβPQPQ \bred P'Q'source by the reduction sequence PβPP \bred P'source followed by the reduction QβQQ \bred Q'source.

  4. The last rule is the contraction rule for parallel beta reduction: MMsource is (λx.N)Q(\lambd[x][N])Qsource and MM'source is N[Q/x]\Subst{N'}{Q'}{x}source for some xxsource, NNsource, MM'source, QQsource, QQ'source, where NβNN \bredpar N'source and QβQQ \bredpar Q'source. By induction hypothesis we get QβQQ \bred Q'source and NβNN \bred N'source. So (λx.N)QβN[Q/x](\lambd[x][N])Q \bred \Subst{N'}{Q'}{x}source by NβNN \bred N'source followed by QβQQ \bred Q'source and finally contraction of (λx.N)Q(\lambd[x][N'])Q'source to N[Q/x]\Subst{N'}{Q'}{x}source.

Beta reduction is the transitive closure of parallel beta reduction

β\bredsource is the smallest transitive relation containing β\bredparsource.

Proof

Let X\xredsource be the smallest transitive relation containing β\bredparsource.

βX\bred \subseteq \xredsource: Suppose MβMM \bred M'source, i.e., MM1ββMkMM \ident M_1 \bredone \dots \bredone M_k \ident M'source. By the lemma that one beta contraction is a parallel beta reduction, MM1ββMkMM \ident M_1 \bredpar \dots \bredpar M_k \ident M'source. Since is X\xredsource contains β\bredparsource and is transitive, MXMM \xred M'source.

Xβ\xred \subseteq \bredsource: Suppose MXMM \xred M'source, i.e., MM1ββMkMM \ident M_1 \bredpar \dots \bredpar M_k \ident M'source. By the lemma serializing parallel beta reduction, MM1ββMkMM \ident M_1 \bred \dots \bred M_k \ident M'source. Since β\bredsource is transitive, MβMM \bred M'source.

Church Rosser property for beta reduction

β\bredsource satisfies the Church--Rosser property.

Proof

Immediate from the theorem that transitive closure preserves the Church Rosser property, the Church Rosser theorem for parallel beta reduction, and the lemma identifying beta reduction as the transitive closure of parallel beta reduction.

Source file content/lambda-calculus/church-rosser/parallel-beta-eta-reduction.tex

Parallel βη\beta\etasource-reduction

In this section we prove the Church-Rosser property for parallel βη\beta\etasource-reduction, the parallel reduction notion corresponding to βη\beta\etasource-reduction.

Five source rules for parallel beta eta reduction

[Parallel βη\beta\etasource-reduction, βη\beredparsource] Parallel βη\beta\etasource-reduction (βη\beredparsource) on terms is inductively defined as follows:

  1. xβηxx \beredpar xsource.

  2. If NβNN \xrightarrow{\beta} N'source then λx.Nβηλx.N\lambd[x][N] \beredpar \lambd[x][N']source.

  3. If PβηPP \beredpar P'source and QβηQQ \beredpar Q'source then PQβηPQPQ \beredpar P'Q'source.

  4. If NβηNN \beredpar N'source and QβηQQ \beredpar Q'source then (λx.N)QβηN[Q/x](\lambd[x][N])Q \beredpar \Subst{N'}{Q'}{x}source.

  5. If NβηNN \beredpar N'source then λx.NxβηN\lambd[x][Nx] \beredpar N'source, provided xFV(N)x \notin FV(N)source.

Reflexivity of parallel beta eta reduction

MβηMM \beredpar Msource.

Proof

Exercise.

Exercise proving parallel beta eta reflexivity

Prove the theorem on reflexivity of parallel beta eta reduction.

Source definition of beta eta complete development

[βη\beta\etasource-complete development] The βη\beta\etasource-complete development M*βη\becd{M}source of MMsource is defined as follows:

x*βη=x(λx.N)*βη=λx.N*βη(PQ)*βη=P*βηQ*βηif P is not a λ-abstract((λx.N)Q)*βη=N*βη[Q*βη/x](λx.Nx)*βη=N*βηif xFV(N)\becd{x} &= x \ollabel{defn:becd1} \\ \becd{(\lambd[x][N])} &= \lambd[x][\becd{N}] \ollabel{defn:becd2}\\ \becd{(PQ)} &= \becd{P}\becd{Q} && \text{if $P$ is not a $\lambd$-abstract} \ollabel{defn:becd3} \\ \becd{((\lambd[x][N])Q)} &= \Subst{\becd{N}}{\becd{Q}}{x} \ollabel{defn:becd4} \\ \becd{(\lambd[x][Nx])} &= \becd{N} \ollabel{defn:becd5} & \text{if $x \notin FV(N)$}source

Parallel beta eta reduction and substitution

If MβηMM \beredpar M'source and RβηRR \beredpar R'source, then M[R/y]βηM[R/y]\Subst{M}{R}{y} \beredpar \Subst{M'}{R'}{y}source.

Proof

By induction on the derivation of MβηMM \beredpar M'source.

The first four cases are exactly like those in the substitution compatibility lemma for parallel beta reduction. If the last rule is the eta rule for parallel beta eta reduction, then MMsource is λx.Nx\lambd[x][Nx]source, MM'source is NN'source for some xxsource and NN'source where xFV(N)x \notin FV(N)source, and NβηNN \beredpar N'source. We want to show that (λx.Nx)[R/y]βηN[R/y]\Subst{(\lambd[x][Nx])}{R}{y} \beredpar \Subst{N'}{R'}{y}source, i.e., λx.N[R/y]xβηN[R/y]\lambd[x][\Subst{N}{R}{y} x] \beredpar \Subst{N'}{R'}{y}source. It follows by the definition of parallel beta eta reductionthe eta rule for parallel beta eta reduction and the induction hypothesis.

Source beta eta complete development lemma

If MβηMM \beredpar M'source then MβηM*βηM' \beredpar \becd{M}source.

Proof

By induction on the derivation of MβηMM \beredpar M'source.

The first four cases are like those in the lemma that every parallel beta reduct reaches the complete development. If the last rule is the eta rule for parallel beta eta reduction, then MMsource is λx.Nx\lambd[x][Nx]source and MM'source is NN'source for some xxsource, NNsource, NN'source where xFV(N)x \notin FV(N)source and NβηNN \beredpar N'source. We want to show that Nβη(λx.Nx)*βηN' \beredpar \becd{(\lambd[x][Nx])}source, i.e., NβηN*βηN' \beredpar \becd{N}source, which is immediate by induction hypothesis.

Source Church Rosser theorem for parallel beta eta reduction

βη\beredparsource has the Church-Rosser property.

Proof

Immediate from the source lemma that every parallel beta eta reduct reaches the complete development.

Source file content/lambda-calculus/church-rosser/beta-eta-reduction.tex

βη\beta\etasource-reduction

The Church--Rosser property holds for βη\beta\etasource-reduction (βη\beredsource).

One beta eta contraction is a parallel beta eta reduction

If MβηMM \beredone M'source, then MβηMM \beredpar M'source.

Proof

By induction on the derivation of MβηMM \beredone M'source. If MβMM \bredone M'source by η\etasource-conversion (i.e., the earlier definition of eta contraction), we use the theorem on reflexivity of parallel beta eta reduction. The other cases are as in the lemma that one beta contraction is a parallel beta reduction.

A parallel beta eta step can be serialized

If MβηMM \beredpar M'source, then MβηMM \bered M'source.

Proof

Induction on the derivation of MβηMM \beredpar M'source.

If the last rule is the eta rule for parallel beta eta reduction, then MMsource is λx.Nx\lambd[x][Nx]source and MM'source is NN'source for some xxsource, NNsource, NN'source where xFV(N)x \notin FV(N)source and NβηNN \beredpar N'source. Thus we can first reduce λx.Nx\lambd[x][Nx]source to NNsource by η\etasource-conversion, followed by the series of βη\beredonesource steps that show that NβηNN \bered N'source, which holds by induction hypothesis.

Beta eta reduction is the transitive closure of parallel beta eta reduction

βη\beredsource is the smallest transitive relation containing βη\beredparsource.

Proof

As in the lemma identifying beta reduction as the transitive closure of parallel beta reduction

Church Rosser property for beta eta reduction

βη\beredsource satisfies Church--Rosser property.

Proof

By the theorem that transitive closure preserves the Church Rosser property, the Church Rosser theorem for parallel beta eta reduction and the lemma identifying beta eta reduction as the transitive closure of parallel beta eta reduction.

Source disclosures