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 M→XPM \xredone Psource and M→XQM \xredone Qsource, then there exists some NNsource such that P→XNP \xredone Nsource and Q→XNQ \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

M→XP1→X…→XPm andM→XQ1→X…→XQn.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,j→XNi+1,jN_{i,j} \xredone N_{i+1,j}source and Ni,j→XNi,j+1N_{i,j} \xredone N_{i,j+1}source. It is defined as follows:

N0,0=MNi,0=Piif 1≤i≤mN0,j=Qjif 1≤j≤nand 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 Ni−1,j→XRN_{i-1,j} \xredone Rsource and Ni,j−1→XRN_{i,j-1} \xredone Rsource. By the Church--Rosser property of →X\xredonesource, such a term always exists.

Now we have Nm,0→X…→XNm,nN_{m,0} \xredone \dots \xredone N_{m,n}source and N0,n→X…→XNm,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→βN′N \xrightarrow{\beta} N'source then λx.N⇒βλx.N′\lambd[x][N] \bredpar \lambd[x][N']source.

  3. If P⇒βP′P \bredpar P'source and Q⇒βQ′Q \bredpar Q'source then PQ⇒βP′Q′PQ \bredpar P'Q'source.

  4. If N⇒βN′N \bredpar N'source and Q⇒βQ′Q \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⇒βM′M \bredpar M'source and R⇒βR′R \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⇒βM′M \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 M′M'source is λx.N′\lambd[x][N']source, where N⇒βN′N \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 M′M'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⇒βM′M \bredpar M'source then M′⇒βM*βM' \bredpar \bcd{M}source.

Proof

By induction on the derivation of M⇒βM′M \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 M′M'source is λx.N′\lambd[x][N']source with N⇒βN′N \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 M′M'source is P′Q′P'Q'source for some PPsource, QQsource, P′P'source and Q′Q'source, with P⇒βP′P \bredpar P'source and Q⇒βQ′Q \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 P′P'source must be λx.N′\lambd[x][N']source for some N′N'source with N⇒βN′N \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 P′Q′⇒β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 M′M'source is N′[Q′/x]\Subst{N'}{Q'}{x}source for some xxsource, NNsource, QQsource, N′N'source, and Q′Q'source, with N⇒βN′N \bredpar N'source and Q⇒βQ′Q \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→βM′M \bredone M'source, then M⇒βM′M \bredpar M'source.

Proof

If M→βM′M \bredone M'source, then MMsource is (λx.N)Q(\lambd[x][N])Qsource, M′M'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⇒βM′M \bredpar M'source, then M↠βM′M \bred M'source.

Proof

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

  1. The last rule is the variable rule for parallel beta reduction: Then MMsource and M′M'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 M′M'source is λx.N′\lambd[x][N']source for some xxsource, NNsource, N′N'source, where N⇒βN′N \bredpar N'source. By induction hypothesis we have N↠βN′N \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↠βN′N \bred N'source).

  3. The last rule is the application rule for parallel beta reduction: MMsource is PQPQsource and M′M'source is P′Q′P'Q'source for some PPsource, QQsource, P′P'source, Q′Q'source, where P⇒βP′P \bredpar P'source and Q⇒βQ′Q \bredpar Q'source. By induction hypothesis we have P↠βP′P \bred P'source and Q↠βQ′Q \bred Q'source. So PQ↠βP′Q′PQ \bred P'Q'source by the reduction sequence P↠βP′P \bred P'source followed by the reduction Q↠βQ′Q \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 M′M'source is N′[Q′/x]\Subst{N'}{Q'}{x}source for some xxsource, NNsource, M′M'source, QQsource, Q′Q'source, where N⇒βN′N \bredpar N'source and Q⇒βQ′Q \bredpar Q'source. By induction hypothesis we get Q↠βQ′Q \bred Q'source and N↠βN′N \bred N'source. So (λx.N)Q↠βN′[Q′/x](\lambd[x][N])Q \bred \Subst{N'}{Q'}{x}source by N↠βN′N \bred N'source followed by Q↠βQ′Q \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↠βM′M \bred M'source, i.e., M≡M1→β…→βMk≡M′M \ident M_1 \bredone \dots \bredone M_k \ident M'source. By the lemma that one beta contraction is a parallel beta reduction, M≡M1⇒β…⇒βMk≡M′M \ident M_1 \bredpar \dots \bredpar M_k \ident M'source. Since is ↠X\xredsource contains ⇒β\bredparsource and is transitive, M↠XM′M \xred M'source.

↠X⊆↠β\xred \subseteq \bredsource: Suppose M↠XM′M \xred M'source, i.e., M≡M1⇒β…⇒βMk≡M′M \ident M_1 \bredpar \dots \bredpar M_k \ident M'source. By the lemma serializing parallel beta reduction, M≡M1↠β…↠βMk≡M′M \ident M_1 \bred \dots \bred M_k \ident M'source. Since ↠β\bredsource is transitive, M↠βM′M \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→βN′N \xrightarrow{\beta} N'source then λx.N⇒βηλx.N′\lambd[x][N] \beredpar \lambd[x][N']source.

  3. If P⇒βηP′P \beredpar P'source and Q⇒βηQ′Q \beredpar Q'source then PQ⇒βηP′Q′PQ \beredpar P'Q'source.

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

  5. If N⇒βηN′N \beredpar N'source then λx.Nx⇒βηN′\lambd[x][Nx] \beredpar N'source, provided x∉FV(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 x∉FV(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⇒βηM′M \beredpar M'source and R⇒βηR′R \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⇒βηM′M \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, M′M'source is N′N'source for some xxsource and N′N'source where x∉FV(N)x \notin FV(N)source, and N⇒βηN′N \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⇒βηM′M \beredpar M'source then M′⇒βηM*βηM' \beredpar \becd{M}source.

Proof

By induction on the derivation of M⇒βηM′M \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 M′M'source is N′N'source for some xxsource, NNsource, N′N'source where x∉FV(N)x \notin FV(N)source and N⇒βηN′N \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→βηM′M \beredone M'source, then M⇒βηM′M \beredpar M'source.

Proof

By induction on the derivation of M→βηM′M \beredone M'source. If M→βM′M \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⇒βηM′M \beredpar M'source, then M↠βηM′M \bered M'source.

Proof

Induction on the derivation of M⇒βηM′M \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 M′M'source is N′N'source for some xxsource, NNsource, N′N'source where x∉FV(N)x \notin FV(N)source and N⇒βηN′N \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↠βηN′N \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