Computer Science 591i
Church-Rosser - Call-by-Value and Call-by-Name

Now let's try to tidy up the Church-Rosser Theorem for the -calculus.

We don't need to worry about the case illustrated in the second figure, because it is converted into the case handled by Proposition LC2 by -conversion. The only case left to us to consider is that in which the inner redux occurs in the argument of the outer redux.

Recall the diagram of this case. If we perform the outer reduction before the inner one (the "call-by-name" case), we get a copy of the inner redux for every occurrence of the variable of the outer -bound variable in the body of the outer -abstraction.

If, on the other hand (the "call-by-value" case), we perform the inner reduction before the outer one, we get exactly one contractum of the inner redex, leaving us with a new version of the outer redex with that contractum in place of the inner redex.

Obviously, to achieve local confluence, we have to reduce those redexes (under discussion) which remain unreduced in each case. In the call-by-value case, the outer redex will be reduced, resulting in the substitution of the inner contractum for all occurrences of the variable of the lambda-abstraction of the outer redex in the body of that abstraction.

However, in the call-by-name case, the inner-redex has been copied zero or more times in the body of the lambda-abstraction of the outer redex. In order to bring this "call-by-name" reduction into line with the "call-by-value" case, we will have to reduce every one of the copies of the inner-redex. This means that we will need to show that the final substitution which occurs in the call-by-value case gives an identical result to multiple-constructive-updates along paths which are the effect of multiple applications of our function.

The practical result of this is that, since (in the call-by-value case) we have to separately reduce each copy of the inner-redux, we will use a distinct path to address each redux. We can characterise multiple -reductions by a sequence of paths, each of which addresses one redux-copy.

How are we to create this path-sequence? Well, let's observe that each copy of the inner-redux occurs in place of an ocurrence of the outer lambda-bound variable in the original outer-redux. Thus, if we can make a list of all paths to occurrences of a specified variable in an expression, we will be well placed to being able to use such a list (or finite sequence) as a way of specifying the -reductions required to bring the call-by-name form in line with the call-by-value one. This is achieved by the paths function, defined below.

However we have to show identity (up to -conversion) of substitution with multiple conversions along paths. This is achieved primarily by Lemma PT4 which shows that the substitution E[v:=F] can be accomplished by a series of updates of paths leading to v in E

However, before we can begin work upon this key lemma, we need to refresh our memory about various general functions defined on finite sequences which are familiar to users of functional languages, to whit map and reduce.

The reduce function (not to be confused with the term reduction as we have been using it) takes a binary operation as argument, and in essence uses that binary operation to combine elements of a finite sequence together. A second argument is supplied to provide a base for the combination. It helps us (or at least it helped me) to visualise what's going on if we write the binary operation infixed as o. Thus, if P is a sequence, then

In this, o associates to the right, to make this clear let's actually write:

It is essential to remember the right-associativity when we come to use reduce for real later.

An elementary example of the use of reduce is.


Definition of reduce

Let o: X >< Y->Y be a binary function, written infixed. Let s be a finite sequence of members of X .
Let y Y Then the reduce function is defined as follows:

Note

The reduce function as defined above is missing the first argument that the reduce function has in the 287 course.


We will also require the function map which transforms one finite sequence into another, making a systematic modification of every element. While this can be regarded as a special case of reduce, it's more convenient to define it separately.

Definition

Let f be a function. Let s be a finite sequence.
We will also need the concept of concatenating two finite sequences. Let's define this thus

Definition

The concatenation function, written infix as "<>", is defined by:
We also need the concept of the extension of a path by one step. This is simply related to the sequence-constructor operation "::".

Definition


Definition

Let E be a term of the -calculus. Let v be a variable. Then the paths leading to v in E, written paths(E,v) are the sequence of paths defined as follows.

Now the above definition of paths makes use of the concatenation operator "<>", as well as the map function. Our general strategy will be to use the reduce function to combine the effects of multiple -reductions. Thus inevitably reduce is going to interact with "<>" and with map. Let's prove a couple of lemmas that address that interaction.

The following lemma is fairly obvious if we think about reduce in the right way. Suppose, for example, we have two path-sequences P and P'. Then

We can, by emphasising the bracketing, easily see that the RHS can be seen as so, it's not surprising that we can treat such a beast as a nested application of reduce.

Lemma Red1

Let l1 l2 be two finite sequences. Let o be a binary function, written as an infix. Then

Proof

By induction on length(l1)

Base Case

If length(l1) = 0 then l1 = ().

On the one hand, from the definition of "<>".

On the other hand, since l1=(), by the definition of reduce we have:

Hence the result holds in the base case.

Inductive Step.

Suppose for all sequences l for which length(l) = n that

we have to show that the result holds for a sequence s::l where length(l) = n. Applying first the definition of "<>" and then the definition of reduce we obtain

by the inductive hypothesis. On the other hand, using the definition of reduce we obtain

Hence the result holds for any sequence s::l of length n+1. Hence the result holds for all finite sequences.


Note

It's worth noting that the proof of the above lemma is independent of any algebraic properties (such as associativity) of the o operation.

Next we come to the interaction of reduce and the use of map in the definition of paths. In this case, we prove lemmas specific to the actual use of map in the definition of paths. These lemmas are motivated by the requirements of Lemma PT4, which shows how substitution can be performed using path-updates - so those seeking motivation of the immediate lemmas should perhaps look first at PT4.


Lemma Red2

Let F, G, H be terms of the lambda-calculus. Let P be a sequence of paths. Let us define the infix operation o to be, for any path p and any term E Then

Proof

By induction on length(P)

Base Case On the other hand

Inductive Step

Suppose that for all path-sequences of length n that Consider a path-sequence p::P of length n+1. by the definition of map, ext by the definition of reduce by the inductive hypothesis. Now, using the definition of o and of path-update, we obtain Hence the result holds for any path-sequence of length n+1. Hence, by the principle of induction, the result holds for all finite sequences of paths.

Lemma Red3

Let F, G, H be terms of the lambda-calculus. Let P be a sequence of paths. Let us define the infix operation o to be, for any path p and any term E Then

Proof

Similar to Lemma Red2

Lemma Red4

Let F, G be terms of the lambda-calculus. Let P be a sequence of paths. Let us define the infix operation o to be, for any path p and any term E Then

Proof

Similar to Lemma Red2

Building a connection between path-updates and substitution.

This case of the Church Rosser Theorem requires us to show that a substitution (of the reduced argument in the body of the lambda-abstraction of the outer redux) is equivalent to multiple reductions along a variety of paths. Now it is intuitively obvious that a substitution can be accomplished by multiple tree-updates along paths. The following lemma formalises this.

Lemma PT4

Let E,F be a expressions of the lambda-calculus, and let v be a variable. Suppose no variable free in F is bound in E. Let us write the infixed o operation to mean then

Proof

By induction of the height of E.

Inductive Step

Suppose for all E for which height(E) n we have that We have to show that the result holds for E for which height(E)=n+1
Unfortunately we've defined the -function to have its arguments the wrong way round for the smoothest statement of the next result. But here goes: