Church–Rosser theorem
The Church–Rosser theorem states that β-reduction in the λ-calculus is confluent: whenever a term reduces in some number of steps to and also to , there is a term to which both and reduce[1][2]. A term may contain several redexes, and the theorem says that the choice of which to reduce first never leads to results that cannot be reconciled. Two consequences make it fundamental. A term has at most one normal form, so a terminating computation has one result whatever the evaluation order. And two terms are equal in the λ-calculus exactly when they reduce to a common term, which shows that the calculus is consistent: distinct normal forms, such as and , are never equal. Alonzo Church and J. Barkley Rosser proved the theorem in 1936[1]. The name is now used for the same property of any rewriting system.
Statement
Write when results from by contracting one β-redex, for the reflexive and transitive closure of , and for β-conversion, the equivalence relation it generates. The theorem is
Two terms that reduce to a common term are called joinable. Confluence is equivalent to the Church–Rosser property proper, which is the form Church and Rosser stated: two convertible terms are joinable,
The Church–Rosser property implies confluence directly, and confluence implies it by induction on the chain of forward and backward reduction steps that make up a conversion[2][11].
Consequences
If had two normal forms and , confluence would give a common reduct of both, and since normal forms do not reduce, up to renaming of bound variables. So normal forms are unique, and a normal form can be regarded as the value of a term. Terms without a normal form, such as , have no value, but no term has two.
If , the Church–Rosser property would give a common reduct of two distinct normal forms, which is impossible. Hence β-conversion does not equate all terms: the λ-calculus is consistent as an equational theory. Before 1936 this was not known, and the inconsistency of Church's earlier system of logic, of which the λ-calculus was a part, had been shown by Kleene and Rosser in 1935[2].
Confluence says that a normal form, if there is one, can be reached from every reduct of a term\; it does not say that every strategy reaches it. The term has the normal form , but a strategy that keeps reducing never gets there. That leftmost-outermost reduction always finds the normal form is a separate result, the standardization theorem[2].
Why one step is not enough
A tempting proof would show that single steps can be completed to a square: if and , then and for some . Tiling such squares would prove the theorem. But β-reduction does not have this diamond property. Contracting a redex can duplicate another redex, and the copies must then be reduced one at a time.
λ-terms with de Bruijn indices, and the list of all one-step reducts of a term.
(* λ-terms with de Bruijn indices, one-step β-reduction and printing. *)type t = V of int | L of t | A of t * tlet rec shift d c = function| V i -> if i >= c then V (i + d) else V i| L b -> L (shift d (c + 1) b)| A (f, a) -> A (shift d c f, shift d c a)(* subst b a: replace index 0 in b by a, as in (λ. b) a. *)let subst b a =let rec go k = function| V i -> if i = k then shift k 0 a else if i > k then V (i - 1) else V i| L t -> L (go (k + 1) t)| A (f, x) -> A (go k f, go k x)ingo 0 b(* All terms reachable in exactly one β-step. *)let rec reducts = function| V _ -> []| L b -> List.map (fun b' -> L b') (reducts b)| A (f, a) ->(match f with L b -> [ subst b a ] | _ -> [])@ List.map (fun f' -> A (f', a)) (reducts f)@ List.map (fun a' -> A (f, a')) (reducts a)(* Print with binder names chosen by depth; free variables come from ctx. *)let names = [| "x"; "y"; "u"; "v"; "w"; "p"; "q"; "r"; "s" |]let show ?(ctx = [ "z" ]) t =let rec go env = function| V i -> List.nth (env @ ctx) i| L b -> let x = names.(List.length env) in "λ" ^ x ^ ". " ^ go (x :: env) b| A (f, a) ->let sf = match f with L _ -> "(" ^ go env f ^ ")" | _ -> go env f inlet sa = match a with A _ | L _ -> "(" ^ go env a ^ ")" | _ -> go env a insf ^ " " ^ saingo [] t
Computing the complete reduction graph of a term.
open Lam(* The whole reduction graph of a term, breadth first. *)let graph m =let ids = Hashtbl.create 16 and order = ref [] inlet rec visit = function| [] -> ()| t :: rest when Hashtbl.mem ids t -> visit rest| t :: rest ->Hashtbl.add ids t (Hashtbl.length ids); order := t :: !order;visit (rest @ reducts t)invisit [ m ];List.rev_map (fun t -> (Hashtbl.find ids t, t, List.map (Hashtbl.find ids) (reducts t))) !order
Running it on (λx. x x) ((λx. x) z).
t0 = (λx. x x) ((λx. x) z) -> t1, t2t1 = (λx. x) z ((λx. x) z) -> t3, t4t2 = (λx. x x) z -> t5t3 = z ((λx. x) z) -> t5t4 = (λx. x) z z -> t5t5 = z z -> normal form
Reducing the outer redex first copies the inner redex twice, and it then takes two steps to reach , while the other path takes one. A term can also erase a redex, as does. So the one-step forks have no one-step join, and the naive induction fails.
Proof by parallel reduction
The proof now standard, due to Tait and Martin-Löf, replaces single steps by parallel reduction , which contracts any set of redexes present in a term at once, including none[2]. It is defined by the rules
Every single step is a parallel step, and every parallel step is a sequence of single steps, so is also the reflexive and transitive closure of . Takahashi simplified the proof by defining the complete development , which contracts every redex of at once[4]:
The key lemma, proved by induction on the derivation of using a substitution lemma, is the triangle property: every parallel reduct of reduces to in one parallel step,
Therefore has the diamond property: two parallel steps from are joined by one parallel step from each to . The diamond property is preserved by taking the reflexive and transitive closure, by tiling the diamonds, so has it too, and that is confluence[4].
Checking the triangle property on random terms, and the failed one-step diamond from the example.
open Lam(* Every term M' with M ⇛ M': contract any subset of the redexes of M,including redexes created inside the arguments, in parallel. *)let rec parallel = function| V i -> [ V i ]| L b -> List.map (fun b' -> L b') (parallel b)| A (f, a) ->let fs = parallel f and as_ = parallel a inlet apps = List.concat_map (fun f' -> List.map (fun a' -> A (f', a')) as_) fs in(match f with| L b ->apps @ List.concat_map (fun b' -> List.map (fun a' -> subst b' a') as_) (parallel b)| _ -> apps)(* How many ways parallel can choose, without building the terms. *)let rec choices = function| V _ -> 1| L b -> choices b| A (f, a) ->let n = choices f * choices a in(match f with L b -> n + choices b * choices a | _ -> n)(* The complete development M*: contract every redex present in M. *)let rec star = function| V i -> V i| L b -> L (star b)| A (L b, a) -> subst (star b) (star a)| A (f, a) -> A (star f, star a)(* Random terms over the free variables 0 and 1, with plenty of redexes. *)let rec random depth scope =if depth = 0 then V (Random.int (scope + 2))else match Random.int 5 with| 0 -> V (Random.int (scope + 2))| 1 -> L (random (depth - 1) (scope + 1))| 2 -> A (L (random (depth - 1) (scope + 1)), random (depth - 1) scope)| _ -> A (random (depth - 1) scope, random (depth - 1) scope)
Running it.
terms: 4980, pairs M ⇛ N: 29056, pairs where N ⇛ M* fails: 0one-step reducts of (λx. x) z ((λx. x) z) and (λx. x x) z in common: 0M* = z z, reached in one parallel step from both: true
The test enumerates every parallel reduct of each of about 5,000 random terms and confirms that is among the parallel reducts of . It is not a proof, but it would detect a mistake in the definitions: with the rule for changed to leave undeveloped, about 40% of the pairs fail.
Local confluence and Newman's lemma
A weaker property is local confluence: every one-step fork can be joined, by any number of steps. It is much easier to check, since it concerns only single steps, but it does not imply confluence. In the system with , , and , every fork can be joined by going back and forth between and , yet reduces to the two normal forms and .
Checking both properties on that system.
(* Abstract rewriting systems on a finite set of objects. *)let objects = [ "a"; "b"; "c"; "d" ]let step = [ ("b", "a"); ("b", "c"); ("c", "b"); ("c", "d") ]let succ x = List.filter_map (fun (u, v) -> if u = x then Some v else None) steplet rec reach seen = function| [] -> seen| x :: rest when List.mem x seen -> reach seen rest| x :: rest -> reach (x :: seen) (succ x @ rest)let reachable x = reach [] [ x ]let joinable x y = List.exists (fun z -> List.mem z (reachable y)) (reachable x)let pairs f = List.for_all (fun x -> List.for_all (fun y ->List.for_all (fun z -> joinable y z) (f x)) (f x)) objectslet locally_confluent = pairs succlet confluent = pairs reachablelet normal_forms = List.filter (fun x -> succ x = []) objects
Running it.
locally confluent: trueconfluent: falsenormal forms reachable from b: a, d
Newman proved in 1942 that the counterexample depends on the infinite loop: a terminating system that is locally confluent is confluent[3]. Huet gave the short proof by well-founded induction that is now standard[5]. Newman's lemma does not apply to the untyped λ-calculus, which does not terminate, but it gives a quick proof of confluence for strongly normalizing calculi such as the simply typed λ-calculus.
Rewriting systems
Confluence is the central property of term rewriting systems, where it guarantees that rewriting computes a unique result, and a confluent and terminating system decides its equational theory by comparing normal forms[11]. In a terminating system, local confluence can be decided by computing critical pairs, the terms at which two rules overlap, and checking that each pair is joinable\; this is the basis of Knuth and Bendix's completion procedure[6][5]. Orthogonal systems, whose left-hand sides are linear and do not overlap, are confluent whether or not they terminate, a result that generalizes the Church–Rosser theorem and was proved by Rosen and by Klop[7][8]. Combinatory logic is orthogonal, and therefore confluent.
Two confluent relations that commute have a confluent union, the Hindley–Rosen lemma[12][7]\; it gives confluence of βη-reduction from confluence of β and of η. Confluence is fragile under extension. Klop showed that adding surjective pairing to the untyped λ-calculus as rewrite rules makes it non-confluent, even though the resulting equational theory is consistent[8].
History
Church and Rosser proved the theorem in their 1936 paper “Some properties of conversion”[1]. Their proof was long and intricate, and simpler proofs have been sought ever since. Newman's abstract treatment of 1942 separated the combinatorial content from the calculus[3], Hindley's thesis of 1964 studied the property for combinatory logic and unions of relations[12], and the parallel-reduction proof of Tait and Martin-Löf, presented in Barendregt's monograph[2], became the standard textbook argument. Takahashi's complete developments of 1995 shortened it further[4]. The theorem became a benchmark for mechanized mathematics: Shankar checked a proof with the Boyer–Moore theorem prover, published in 1988[9], and Nipkow formalized several proofs in Isabelle/HOL[10].
see also
- β-reductionβ-reduction is the computation rule of the lambda calculus: an application of a function to an argument, (λx. e) a, is replaced by the body e with a substituted for x. Substitution must avoid capturing free variables of the argument. A term with no reducible subterm is in normal form; by the Church–Rosser theorem the normal form, if it exists, is unique, and normal-order reduction, which always contracts the leftmost outermost redex, finds it. Evaluation strategies of programming languages are restrictions of β-reduction.
- SKI combinatorsThree combinators, S x y z = x z (y z), K x y = x and I x = x, from which every closed lambda term can be built by application alone, with no variables. I is redundant, since S K K x = x. The translation from lambda terms is called bracket abstraction.
- De Bruijn indicesA representation of lambda terms without variable names: each variable is the number of binders between it and the lambda that binds it. Alpha-equivalent terms become identical and substitution cannot capture a variable, at the price of shifting indices when a term moves under a binder.
- Y combinatorThe Y combinator is a lambda term Y such that Y f = f (Y f) for every f: it finds a fixed point of any function, and so gives recursion to a language with no named definitions. Under call-by-value it loops before f is ever called; the Z combinator delays the self-application behind a lambda and works in strict languages. No fixed-point combinator has a type in the simply typed lambda calculus.
- Church encodingChurch encoding represents data in the pure lambda calculus, which has only functions, by functions: a natural number n is the function that applies its argument n times, a boolean is a function choosing between two alternatives, and a pair is a function waiting for a selector. In general a value is represented by its own fold. Arithmetic, logic and data structures all become lambda terms, which is how the lambda calculus was shown to express every computable function; in typed form the encoding needs polymorphism, as in System F.
- Dependent typeA dependent type is a type that may mention values, so that a vector's length can appear in its type and a function's result type can be computed from its arguments. Function types generalize to dependent products Π(x : A). B(x), and pairs to dependent sums Σ(x : A). B(x). Because types can express propositions and programs can be proofs, languages with dependent types, such as Agda, Coq (Rocq), Lean and Idris, double as proof assistants. The price is that type checking involves evaluating programs, so these languages require functions to terminate, and type equality is decided up to computation.
further reading
- [1]A. Church, J. B. Rosser, “Some properties of conversion”, Transactions of the American Mathematical Society 39 (1936).
- [2]H. P. Barendregt, The Lambda Calculus: Its Syntax and Semantics, ch. 3 and 11, North-Holland (revised ed., 1984).
- [3]M. H. A. Newman, “On theories with a combinatorial definition of “equivalence””, Annals of Mathematics 43 (1942).
- [4]M. Takahashi, “Parallel reductions in λ-calculus”, Information and Computation 118 (1995).
- [5]G. Huet, “Confluent reductions: abstract properties and applications to term rewriting systems”, Journal of the ACM 27 (1980).
- [6]D. E. Knuth, P. B. Bendix, “Simple word problems in universal algebras”, in Computational Problems in Abstract Algebra, Pergamon (1970).
- [7]B. K. Rosen, “Tree-manipulating systems and Church–Rosser theorems”, Journal of the ACM 20 (1973).
- [8]J. W. Klop, Combinatory Reduction Systems, PhD thesis, Utrecht University, Mathematical Centre Tracts 127 (1980).
- [9]N. Shankar, “A mechanical proof of the Church–Rosser theorem”, Journal of the ACM 35 (1988).
- [10]T. Nipkow, “More Church–Rosser proofs (in Isabelle/HOL)”, Journal of Automated Reasoning 26 (2001).
- [11]F. Baader, T. Nipkow, Term Rewriting and All That, Cambridge University Press (1998).
- [12]J. R. Hindley, The Church–Rosser Property and a Result in Combinatory Logic, PhD thesis, University of Newcastle upon Tyne (1964).
last updated