CONFLUENCE OF AN EXTENSION OF COMBINATORY LOGIC BY BOOLEAN CONSTANTS ŁUKASZ CZAJKA Abstract. We show confluence of a conditional term rewriting system CLC, which is an extension of Combinatory Logic by Boolean constants. This solves problem 15 from the RTA list of open problems.
arXiv:1306.2069v2 [cs.LO] 1 Aug 2015
1. Introduction Combinatory Logic is a small term rewriting system capable of representing any computable function. It may be considered an abstraction of a functional programming language. Combinatory Logic is defined by just two rules: Kxy Sxyz
→ x → xz(yz)
Using only S and K, it is possible to encode natural numbers via Church numerals and all computable functions operating on them. However, a conditional C encoded in this way will not have a desirable property that Ct1 t2 t2 = t2 if t1 encodes neither true nor false. It is therefore interesting to investigate extensions of Combinatory Logic incorporating a conditional directly. Perhaps the most natural such extension is CLC0 : CT xy
→ x
CF xy
→ y
Czxx → x Kxy → x Sxyz
→ xz(yz)
Unfortunately, the system CLC0 is well-known not to be confluent [4]. One may thus try other ways of adding a conditional and Boolean constants to Combinatory Logic. We show confluence of a conditional term rewriting system CLC defined by the following rules: CT xy CF xy
→ x → y
Czxy Kxy
→ x → x
Sxyz
→ xz(yz)
⇐
x=y
Confluence of this system appears as problem 15 on the RTA list of open problems [3]. The equality in the third rule refers to equality in the system CLC, thus the definition is circular. This circularity is an essential property of CLC which distinguishes it from CLC0 . A system related to CLC is CLC+ , which consists of all the rules of CLC plus the rule: Czxy → y
⇐ x=y
+
It is known that CLC is confluent [2]. However, the confluence proof in [2] essentially depends on a semantic argument to first establish T 6=CLC+ F . We provide a syntactic proof of confluence of both CLC and CLC+ . The systems CLC and CLC+ are conditional linearizations of CLC0 . The notion of conditional linearization was introduced in the hope of providing a simpler proof of Chew’s theorem [5] which states that all compatible term rewriting systems have the unique normal form property. Compatibility imposes certain restrictions on the term rewriting system, but it does not require termination or left-linearity. In particular, Chew’s theorem is applicable to many term rewriting systems which are not confluent. Partially supported by Narodowe Centrum Nauki grant 2012/07/N/ST6/03398. 1
For instance, CLC0 satisfies the conditions of Chew’s theorem, but it is not confluent. As shown in [2], to prove the unique normal form property of a term rewriting system, it suffices to prove confluence of one of its conditional linearizations. The proof of Chew’s theorem in [5] is quite complicated and uses a related but different approach, relying on left-right separated conditional linearizations instead of the more straightforward ones from [2]. It may be expected that developing a syntactic confluence proof for the concrete example of the systems CLC and CLC+ might lead a way to a new, and hopefully simpler, proof of Chew’s theorem or some variant thereof. 2. Proof overview In this section we present an informal overview of the proof, trying to convey the underlying intuitions. Section 3 presents formal definitions of the notions informally motivated here, and Section 4 provides details of the proof itself. The most difficult part of our confluence proof is to show that for any term q the following condition holds: ∗
(⋆) q =CLC F implies q →CLC F Having established (⋆), the confluence of CLC (and of CLC+ ) is obtained by a relatively simple argument similar to the one used in [2] to derive the confluence of CLC+ from the condition T 6=CLC+ F . A naive approach to prove (⋆) could be to proceed by induction on the number of contractions ∗ (reduction steps) and expansions in a sequence q ↔CLC F . In the inductive step we would need to prove: ∗
∗
(1) if q →CLC F and q →CLC q ′ then q ′ →CLC F , ∗ ∗ (2) if q →CLC F and q CLC← q ′ then q ′ →CLC F . The second part is obvious, but the first one is hard. The difficulty stems from the existence of a non-trivial overlap between the second and the third rule. If t1 =CLC t2 then CF t1 t2 →CLC t1 by the third rule and CF t1 t2 →CLC t2 by the second. We do not know enough about t1 and t2 to infer that they have a common reduct. One may try to strengthen the inductive hypothesis in the hope of making the first part easier to prove. A naive attempt would be to claim that all reductions starting from q end in F , instead of claiming that some reduction ends in F . This would make the first part trivial, but the second one would not go through as this is false in general. ∗ The idea is to consider, for a given sequence q ↔CLC F of contractions and expansions, a certain set ∗ ∗ S(q ↔CLC F ) of reductions, all starting from q. The set S(q ↔CLC F ) depends on the exact form of ∗ q ↔CLC F . Then our two parts of the proof for the inductive step become: ∗
(1) if S(q ↔CLC F ) is nonempty and all reductions in it end in F , and q →CLC q ′ , then S(q ′
CLC←
∗
q ↔CLC F )
is nonempty and all reductions in it end in F , ∗ (2) if S(q ↔CLC F ) is nonempty and all reductions in it end in F , and q
CLC←
q ′ , then
∗
S(q ′ →CLC q ↔CLC F ) is nonempty and all reductions in it end in F . ∗
The hope is that if we define S(q ↔CLC F ) appropriately, then showing both parts will become feasible. ∗ Essentially, the set S(q ↔CLC F ) will be encoded in the labelling of certain constants in q. The labels determine which contractions (one-step reductions) are permitted when a given constant appears as the leftmost constant in a redex1. Terms with the leftmost constant labelled will be called “significant”, or s-terms, whereas others will be “insignificant”, or i-terms. Contractions occurring in i-terms will be “insignificant”, or i-contractions. A “significant” contraction, or s-contraction, will be a contraction of a term with the leftmost constant labelled, in a way permitted by the label of the leftmost constant. Contraction of a redex in which the leftmost constant is not labelled is not permitted in s-contractions. A “significant” reduction, or s-reduction, will be a reduction in which all contractions are “significant”. The intuition is that we do not need to care about the expansions and contractions occurring in “insignificant” subterms of a given term, since they cannot influence the s-reductions starting from this term and ending in F . 1E.g. in the redex CT t t the constant C is the leftmost constant. 1 2 2
∗
Now the set S(q ↔CLC F ) will be encoded in a labelled variant2 t of q, and it will consist of all s-reductions starting from t and ending in a normal form (with respect to s-contraction). Formally speaking, we have just silently shifted from considering contractions in “plain” terms of the system CLC to contractions in their labelled variants, in a different rewriting system which we have not yet defined. In particular, we will actually be interested in s-reductions ending in a labelled variant F1 of F . However, it will be later shown that s-reductions defined on labelled terms may be “erased” to appropriate reductions in the system CLC. In the next section we define the system CLCs over labelled terms which will give precise rules of s-contraction. In this section we will only give informal motivations. ∗ We write t − → t′ for contraction in CLCs , i.e. for s-contraction of t to t′ , and t − → t′ for s-reduction. s s We use the abbreviation s-NF for CLCs -normal form. We write t ❀ F1 when the following conditions hold: ∗ • if t − → t′ with t′ in s-NF, then t′ ≡ F1 , s • t is strongly normalizing with respect to s-reductions. Formal definitions of these notations will be given in Section 3. ∗ With the set S(q ↔CLC F ) coded by labels, the two parts of the inductive step become: (1) if t is a labelled variant of q such that t ❀ F1 , and q →CLC q ′ , then there exists a labelled variant t′ of q ′ such that t′ ❀ F1 , (2) if t is a labelled variant of q such that t ❀ F1 , and q CLC ← q ′ , then there exists a labelled variant t′ of q ′ such that t′ ❀ F1 . Now we provide some explanations on how the terms will be labelled. For this purpose we analyze ∗ why the second part fails when we take S(q ↔CLC F ) to be the set of all reductions starting from q. We indicate how to introduce the labelled variants so as to make the second part go through while still retaining the feasibility of showing the first part. This analysis is informal and a bit vague. It is intended to convey the motivations behind the definition of the system CLCs in the next section. Suppose q CLC ← q ′ and we have already decided on the labelled variant of q. We need to label q ′ , and assign appropriate meaning to the labels, in such a way that the second part goes through. For simplicity assume the expansion occurs at the root. Because there are no non-root overlaps between the rules of CLC, this assumption will turn out to be inessential. We have the following possibilities. • If q ′ ≡ CT qq0 →CLC q then q0 is a new subterm which may not be SN. Thus allowing s-reductions inside q0 might introduce some infinite reductions, which we want to avoid. By inspecting the rules of CLC, we may conclude that the subterm q0 is “insignificant” in the sense that it cannot in any way “contribute” to the CLCs -normal form of q ′ . On the other hand, the subterm T is “significant”, because changing it could destroy the redex. In this case we thus label C to C1 and T to T1 in order to indicate that q ′ and T are “significant”. So if t is the labelled variant of q, then the labelled variant of q ′ is C1 T1 tq0 . To accomodate the next related case, the labelling C1 of C will be interpreted as not permitting contraction by the third rule, i.e. in CLCs we will only have the rules C1 T1 xy → x and C1 F1 xy → y. • The case when q ′ ≡ CF q0 q →CLC q is analogous, except that q0 may not be considered “insignificant” if q0 =CLC q, because then the third rule is also applicable. However, if we label C to C1 , which does not permit contraction by the third rule of CLC, then q0 is “insignificant”, because then again it cannot “contribute” in any way to the CLCs -normal form of q. Thus, if t is the labelled variant of q, then C1 F1 q0 t is the labelled variant of q ′ . • If q ′ ≡ Cq0 qq1 →CLC q by the third rule, then q0 or q1 may not be SN. However, if we label C to C2 and interpret this labelling as permitting contraction only by the third rule, then q0 and q1 are “insignificant”. Thus, if t is the labelled variant of q, then C2 q0 tq1 is the labelled variant of q ′ . The only rule for C2 in CLCs will be C2 zxy → x ⇐ |x| =CLC |y| where |x| =CLC |y| means that the “erasures” of the labelled terms substituted for x and y must be equal in CLC for the rule to be applicable. • If q ′ ≡ Kqq0 →CLC q then q0 may not be SN, but it is an “insignificant” subterm, because changing it cannot impact in any essential way the reductions starting from q ′ and ending in a normal form. We label K to K1 in order to indicate that q ′ is “significant”. Thus, if t is the labelled variant of q, then K1 tq0 is the labelled variant of q ′ . The rule for K1 in CLCs will be K1 xy → x. 2By a “labelled variant” of a term q we mean a term with certain constants labelled which is identical with q when the labels are “erased”. 3
• If q ′ ≡ Sq1 q2 q3 →CLC q1 q3 (q2 q3 ) ≡ q then we run into a problem with our labelling approach, because the labelled variants of the distinct occurences of q3 may be distinct. Suppose t1 is the labelled variant of q1 , the term t2 of q2 , the term t3 of the first q3 , and t′3 of the second q3 . We cannot just arbitrarily choose e.g. t3 and say that S1 t1 t2 t3 is the labelled variant of q ′ , because contracting S1 t1 t2 t3 yields t1 t3 (t2 t3 ), not t1 t3 (t2 t′3 ), and now the second occurence of q3 has the wrong labelling which may not guarantee that all significant reductions ending in a normal form actually end in F1 , or at least it is hard to show that they do end in F1 . A solution is to remember both labelled variants of q3 . So the labelled variant of q ′ would be e.g. S1 t1 t2 ht3 , t′3 i. The rule of significant contraction for S1 would be S1 x1 x2 hx3 , x′3 i → x1 x3 (x2 x′3 ). However, once we introduce such pairs, terms of the form S1 t1 t2 ht3 , t′3 i may appear in the terms being expanded. This is not a problem for any of the rules of CLC except the rule for S, because the right sides of all other rules are variables. Consider for instance q ≡ q0 q3 (Sq1 q2 q3 ) CLC ← Sq0 (Sq1 q2 )q3 ≡ q ′ . Suppose the labelling of q is t0 t3 (S1 t1 t2 ht3 , t′3 i). Now the term q3 has three possibly distinct labelled variants, and we need to remember all of them. We will thus introduce a new labelling of S for every possible labelling of the right side xz(yz) of the rule for S in the system CLC. The above gives an overview of how the terms will be labelled, but this is not the whole story. We need to ensure that we can also handle the first part of the inductive step when q →CLC q ′ . Suppose t is the labelled variant of q. We need to find a labelled variant for q ′ . For simplicity assume that there is only one position in t which corresponds to the position of the contraction in q. If the contraction occurs inside an i-term in t, then it does not matter and we may label q ′ in the same way as q. If an s-term is contracted in a way permitted for significant contraction, then it is also obvious how to label q ′ – just take the labelled variant of q ′ to be the reduct of the labelled variant of q. But what if neither of the two holds? For instance, what if t ≡ C1 t0 t1 t2 but q ≡ Cq0 q ′ q2 →CLC q ′ by the third rule? The idea is to proceed by induction on the number of contractions and expansions in a sequence ∗ ∗ q ↔CLC0 F , instead of a sequence q ↔CLC F . Recall that CLC0 is the non-conditional version of the system CLC, defined as CLC with the third rule replaced by Cxyy → y. A simple but crucial observation is that the condition q =CLC q ′ is in fact equivalent to q =CLC0 q ′ . This will be shown in the next section. Let us return to the case when t ≡ C1 t0 t1 t2 is the labelling of q ≡ Cq0 q ′ q2 . If the contraction is in ∗ → F1 , CLC0 , i.e. Cq0 q ′ q2 →CLC0 q ′ , then q ′ ≡ q2 and this possibility is not problematic, provided that t0 − s which will be the case because t0 was “obtained” from F1 by a sequence of expansions and contractions with the intermediate terms labelled appropriately. We may thus take t2 to be the labelling of q ′ . We then ∗ → C1 F1 t1 t2 and the contraction C1 F1 t1 t2 → t2 is permitted for “significant” contractions. have C1 t0 t1 t2 − s
The last problematic case is when t ≡ C2 F t1 q ′ is the labelling of q ≡ CF q1 q ′ , and q →CLC0 q ′ by the second rule. According to what we have said above, “significant” contraction by (a rule corresponding to) the second rule of CLC is not permitted in CLCs . However, now that we consider only CLC0 -expansions, we may reconsider the case when q CLC0 ← Cq0 qq. The term q0 is then “insignificant”, because changing it cannot destroy the redex. Reducing and/or expanding q0 may create a redex by the second rule if q0 =CLC F , so strictly speaking we may not completely ignore the reductions/expansions in q0 , but nevertheless they may be considered “insignificant” for our purposes. Suppose t is the labelling of q. Thus we may take C2 q0 tt as the labelling of Cq0 qq. This means that after all for C2 we do not have to disallow contraction by the second rule. 3. Definitions This section is devoted to fixing notation and introducing definitions of various technical concepts. Familiarity with basic term-rewriting is assumed. Notations are compatible with those in [1], unless stated otherwise. We use ≡ to denote identity of terms, to avoid confusion with equality = of terms in a rewriting system. First, we clarify the formal definition of conditional term rewriting systems. For more background on conditional rewriting see e.g. [6]. Definition 3.1. A conditional rewrite rule is a rule of the form l → r ⇐ ϕ, where l is not a variable, F V (r) ⊆ F V (l), and ϕ is a logical formula such that F V (ϕ) ⊆ F V (l). A term t is a redex (contractum) by this rule if there exists a substitution σ such that t ≡ σl (t ≡ σr) and σϕ holds. We will not give completely precise definitions of the syntax or semantics of the formulas used, as this is intuitively obvious 4
and would only add excessive formalism. The function and relation symbols in σϕ are interpreted by the previously defined functions and relations with the same name, and terms are interpreted by themselves. The formula ϕ may also refer to a previously undefined equality symbol =, whose interpretation only makes sense in the context of the conditional term rewriting system to which the rule belongs. A conditional term rewriting system R is a set of conditional rewrite rules of the form: l1 → r1
⇐ ϕ1 ∧ s1 = s′1
l2 → r2
⇐ ϕ2 ∧ s2 = s′2 .. .
lm → rm
⇐ ϕm ∧ si = s′i
where li , ri , si , s′i are terms for i = 1, . . . , m. We assume that = does not occur in ϕi . The equality = in the conditions refers to the equality relation associated with R. Thus, the definition is circular. Formally, an R-contraction q →R q ′ is defined in the following way. Define R0 to be the system R but using the empty relation in place of =, and Rn+1 to be the system R with the equality relation = defined by means of →Rn . We then define q →R q ′ to hold if there exists n ∈ N such that q →Rn q ′ . The least such n is ∗ called the level of the contraction. The notion of a level generalizes to a sequence q1 ↔R q2 by taking the largest of the levels of the individual steps. When we say that we perform induction on the definition of a conditional term rewriting system, we mean induction on the level of a sequence of contraction and expansion steps involved. Let ∼ be a binary relation on terms. If for any substitution σ such that σϕ holds, and any σ ′ such that σ(x) ∼ σ ′ (x) for all variables x, the condition σ ′ ϕ also holds, then the condition ϕ is stable under ∼. The following is a simple but crucial observation, which implies that it indeed suffices to consider sequences of contractions and expansions in CLC0 . Lemma 3.2. The following are equivalent: (1) q =CLC0 q ′ , (2) q =CLC q ′ , (3) q =CLC+ q ′ . Proof. It is obvious that (1) implies (2) and that (2) implies (3). The implication from (3) to (1) is ∗ shown by induction on the level of a sequence q ↔CLC+ q ′ . Definition 3.3. We define insignificant terms, or i-terms, inductively: • any variable x is an i-term, • the constants C, T, F, K, S are i-terms, • if t1 , t2 are i-terms, then (t1 · t2 ) is an i-term. The set of labelled terms, or l-terms, is defined inductively. • Any i-term is an l-term. • The labelled constants C1 , C2 , T1 , F1 , K1 and S n0 ,...,nk for k ≥ 1, n1 , . . . , nk ∈ N+ , are l-terms. • If t1 , t2 are l-terms then (t1 · t2 ) is an l-term. • If t1 , . . . , tn are l-terms for n ≥ 2, then ht1 , . . . , tn i is an l-term. We assume that · associates to the left and usually omit it together with spurious brackets. We adopt the convention hti ≡ t. If t ≡ ht1 , . . . , tn i with n > 1, then we say that t is a tuple of size n. Note that hti ≡ t is just a notational convention. We say that ht1 , . . . , tn i is a tuple only when n > 1. An erasure of an l-term is defined as follows: • an i-term is an erasure of itself, • C is an erasure of C1 and C2 , • T is an erasure of T1 , • F is an erasure of F1 , • K is an erasure of K1 , • S is an erasure of S n1 ,...,nk , • if q1 , q2 are erasures of t1 , t2 , respectively, then q1 q2 is an erasure of t1 t2 , • if qi is an erasure of ti , for some 1 ≤ i ≤ n, then qi is an erasure of ht1 , . . . , tn i. The leftmost erasure, denoted | − |, is the erasure in which we always choose i = 1 in the last point above. We write t ≻ q if every erasure of t is identical with q. We define significant terms, or s-terms, inductively. 5
• Any labelled constant is an s-term. • If t1 is an s-term and t2 is an l-term, then t1 t2 is an s-term. In other words, an s-term is an l-term whose leftmost constant is labelled. In what follows t, t1 , t2 , r, r1 , r2 , s, s1 , etc. stand for l-terms; and q, q1 , q2 , etc. stand for i-terms; unless otherwise qualified. Also, whenever we speak about terms without further qualification, we implicitly assume them to be l-terms. Definition 3.4. The system CLCs is defined by the following significant reduction rules: C1 T1 xy C1 F1 xy
→ x → y
C2 zxy C2 T xy
→ x → x
C2 F xy C2 T1 xy
→ y → x
C2 F1 xy K1 xy
→ y → x
S ~n xhy1 , . . . , yk ih~z0 , . . . , ~zk i
→
⇐
|x| =CLC |y|
xh~z0 ihy1 h~z1 i, . . . , yk h~zk ii
⇐
ϕ
where |zi,j | =CLC |zi′ ,j ′ | for i, i′ = 0, . . . , k, j = 1, . . . , ni , j ′ = 1, . . . , ni′ , and
ϕ ≡
|yi | =CLC |yj | for i, j = 1, . . . , k, and ~n stands for n0 , . . . , nk , and ~zi stands for zi,1 , . . . , zi,ni , for i = 0, . . . , k. When dealing with terms whose lefmost constant is S n0 ,...,nk , we will often use this kind of vector notation. Recall the convention hti ≡ t. Hence, if e.g. n0 = 1, then h~z0 i ≡ hz0,1 i ≡ z0,1 in the above rule. Note that the equality =CLC in the conditions refers to the system CLC, not CLCs , so there is no circularity here. Note also that all rules of CLCs are linear. Contraction by a rule in CLCs is called significant contraction, or s-contraction, and denoted by − →. s
∗
Analogously, we use the terminology and notation of s-reduction (− →), s-expansion, s-redex, s-normal s
form (s-NF), s-strongly normalizing (s-SN), etc. Note that every s-redex is an s-term. Formally, the relation of s-contraction is defined inductively, in the expected way. We will sometimes perform induction on the definition of the relation of s-contraction. An i-redex is a CLC-redex which is also an i-term. An l-term t1 is said to i-contract to t2 , denoted t1 − → i
t2 , if t1 →CLC t2 and the redex contracted in t1 is an i-term. An l-term t1 is said to i-expand to t2 ∗ if t2 − → t1 . The relation of i-reduction (− →) is defined as the transitive-reflexive closure of i-contraction i
i
≡
(− →). We write t1 −→ t2 if t1 − → t2 or t1 − → t2 . We use − → for the reflexive closure of a relation →, and ↔ i
i,s
i
s
for the symmetric closure of →. In more complex expressions involving reduction relations we often write · in place of an unspecifed term, e.g. t − →·←·− → t′ means that there exist terms t1 and t2 such that t − → t1 ← t2 − → t′ . s
s
i
i
We use the standard notions of subterms and subterm occurences, which could be formally defined by introducing the notion of positions. For the sake of brevity, we will not give precise definitions, as they are well-known and understood. If t is a redex, i.e. t ≡ σl for some term l and substitution σ, then we say that a subterm s occurs below a variable position of the redex t if s occurs in a subterm of t occurring at the position of a variable in l. We say that a contraction t1 → t2 occurs at the root if t1 is the redex contracted in this contraction. Lemma 3.5. The system CLCs has the strong normalization property. Proof. The number of labelled constants decreases with each s-contraction.
Lemma 3.6. If t1 − → t2 then |t1 | =CLC |t2 |. s
The above simple lemma implies that the conditions in significant reduction rules are stable (see the end of Definition 3.1) under s-contraction and s-expansion. It is obvious that they are also stable under i-contraction and i-expansion. 6
In the next definition we introduce the relation ❀ and the notion of standard l-terms. Intuitively, an l-term t is standard if the labellings in t have the meaning we intend to ascribe them, i.e. if t is a term obtained by the process informally described in the previous section. Definition 3.7. We say that an l-term t is standard, denoted t ↓, when for every subterm t′ of t the following conditions hold: (1) t′ is either an i-term, an s-term or a tuple, (2) if t′ ≡ C1 t0 t1 t2 and t0 is in s-NF, then t0 ≡ T1 or t0 ≡ F1 , Pk (3) if t′ ≡ S n0 ,...,nk t0 t1 t2 then t2 is a tuple of size i=0 nk and if k > 1 then t1 is a tuple of size k, ∗ (4) if t′ is an s-term and t′ − → t′′ , then t′′ is also an s-term, s
(5) if t′ ≡ ht1 , . . . , tn i with n > 1, then none of t1 , . . . , tn is a tuple. ∗
We say that an l-term t is strongly standard if t − → t′ implies t′ ↓. We write t ❀ F1 if t is strongly s ∗
standard and has no s-NFs other than F1 , i.e. if t − → t′ with t′ in s-NF then t′ ≡ F1 . s
We conclude this section with a few simple lemmas establishing some basic properties of standard and strongly standard terms. Lemma 3.8. (1) Any i-term is standard. (2) Any labelled constant is standard. (3) Every subterm of a standard term is also standard. (4) Every subterm of a term to which some strongly standard term reduces, is strongly standard. Lemma 3.9. If t ↓ and t ≡ t1 t2 then t1 is not a tuple. Proof. A term of the form t1 t2 with t1 a tuple is not a tuple, an s-term, or an i-term, which contradicts 1 in Definition 3.7. Lemma 3.10. If t ↓ and t is not a tuple, then it does not s-reduce to a tuple. Proof. Follows directly from 1 and 4 in Definition 3.7.
∗
∗
s
s
→ F1 . → T1 or t0 − Lemma 3.11. If t is strongly standard and C1 t0 t1 t2 is a subterm of t, then t0 − Proof. Follows directly from Lemma 3.5 and condition 2 in Definition 3.7.
Lemma 3.12. Suppose t is a standard s-term and t ≻ q. • If q ≡ Cq0 q1 q2 then t ≡ C ′ t0 t1 t2 where C ′ ∈ {C1 , C2 } and ti ≻ qi for i = 1, 2, 3. • If q ≡ Kq0 q1 then t ≡ K1 t0 t1 where ti ≻ qi for i = 0, 1. • If q ≡ Sq0 q1 q2 then t ≡ S n0 ,...,nk t0 t1 t2 where ti ≻ qi for i = 0, 1, 2, the term t2 is a tuple of P size ki=0 ni , and if k > 1 then t1 is a tuple of size k. Proof. Note that t cannot have the form e.g. h. . .it0 by Lemma 3.9. Additionally, if t ≡ S n0 ,...,nk t0 t1 t2 Pk then t2 is a tuple of size i=0 ni , and if k > 2 then t1 is a tuple of size k, by 3 in Definition 3.7. Thus, since t is an s-term, it is easy to see that it has the required form. 4. Confluence proof In this section we give technical details of the confluence proof for the systems CLC and CLC+ . As outlined in Section 2, we intend to simulate CLC0 -contractions (expansions) in unlabelled terms by i-reductions and s-reductions (i-expansions and s-expansions) in their labelled variants. Once we show this is possible, it remains to prove that i-contractions, i-expansions, s-contractions and s-expansions ∗ all preserve ❀, i.e. if t ❀ F1 and t ←→ t′ , then t′ ❀ F1 . A sequence q ↔ F can then be translated i,s
∗
∗
i,s
i,s
into a sequence t ←→ F1 with t ≻ q. Since F1 ❀ F1 and we prove that ←→ preserves ❀, we may ∗
conclude that t ❀ F1 . Then by the definition of ❀ we obtain a significant reduction t − → F1 which may s
∗
be translated into a CLC-reduction by erasing the labellings. Hence finally q →CLC F . We first show that a CLC0 -contraction may be simulated by i-reductions and s-reductions. Lemma 4.1. If t is strongly standard, t ≻ q and q →CLC0 q ′ , then there exists a term t′ such that ∗ t −→ t′ and t′ ≻ q ′ . i,s
7
Proof. Induction on the size of ht, qi. The base case is when t is not a tuple and q is the CLC0 -redex contracted in q →CLC0 q ′ . If t ≡ q then t ≡ q − → q ′ and we may take t′ ≡ q ′ . If t ≡ 6 q then t is not an i-term because t ≻ q. Hence by 1 in i
Definition 3.7 we conclude that t is an s-term. By Lemma 3.12 we have the following possibilities. • If q ≡ CT q1 q2 →CLC0 q1 ≡ q ′ then the leftmost constant in t is either C1 or C2 . – If t ≡ C1 T1 t1 t2 then t − → t1 and t1 ≻ q1 , so we may take t′ ≡ t1 . s – The case t ≡ C1 T t1 t2 is impossible by 2 in Definition 3.7. – If t ≡ C2 t0 t1 t2 then t1 ≻ q1 and t0 ≡ T or t0 ≡ T1 . In any case t − → t1 and we may take s
t′ ≡ t1 . • If q ≡ CF q1 q2 →CLC0 q2 then the argument is analogous. • If q ≡ Cq0 q1 q1 →CLC0 q1 then t ≡ C ′ t0 t1 t2 with C ′ ∈ {C1 , C2 }, t0 ≻ q0 , t1 ≻ q1 and t2 ≻ q1 . ∗ ∗ ∗ ∗ → F1 by Lemma 3.11. Hence t − → t1 or t − → t2 . In the first → T1 or t0 − – If C ′ ≡ C1 then t0 − s
s
s
s
case we may take t′ ≡ t1 , and in the second we take t′ ≡ t2 . – If C ′ ≡ C2 then t − → t1 because |t1 | ≡ |t2 | ≡ q1 . Thus we take t′ ≡ t1 . s
• If q ≡ Kq1 q2 →CLC0 q1 then t ≡ K1 t1 t2 − → t1 with t1 ≻ q1 . We take t′ ≡ t1 . s
• If q ≡ Sq0 q1 q2 →CLC0 q0 q2 (q1 q2 ) then t ≡ S ~n sht1 , . . . , tk ih~r0 , . . . , ~rk i where the conventions regarding the vector notation are as in Defintions 3.4, and s ≻ q0 , and ti ≻ q1 for i = 1, . . . , k, and ri,j ≻ q2 for i = 0, . . . , k, j = 1, . . . , i. Thus t− → sh~r0 iht1 h~r1 i, . . . , tk h~rk ii ≻ q0 q2 (q1 q2 ) s
′
and we may take t ≡ sh~r0 iht1 h~r1 i, . . . , tk h~rk ii. Now suppose that t ≡ ht1 , . . . , tn i with n > 1. Then ti ≻ q for i = 1, . . . , n, and we may appeal to the inductive hypothesis. Finally, suppose q is not the contracted CLC0 -redex. Since t ≻ q and q contains a CLC0 -redex, t cannot be a variable or a constant. Hence, t ≡ t1 t2 and we obtain the claim immediately from the inductive hypothesis. The following technical lemma shows that ←→ may be postponed after − →. s
i
≡
Lemma 4.2. If t ←→ · − → t′ then t − → · ←→ t′ . s
i
s
i
Proof. Suppose t1 ←→ t2 − → t3 . We proceed by induction on the definition of t2 − → t3 . s
i
s
If t2 is the contracted s-redex then, because an i-redex (i-contractum) is an i-term, it is easy to see by inspecting Definition 3.4 that the i-redex (i-contractum) in t2 must occur below a variable position of the s-redex. Since significant reduction rules are linear and their conditions are stable under i-contractions ≡ (i-expansions), the claim holds. Note that we need ←→ instead of ←→ in the conclusion, because the i
i
i-redex (i-contractum) may be erased by the s-contraction. If t2 is not the s-redex, then t2 ≡ s1 s2 or t2 ≡ hs1 , . . . , sn i with n > 1. Suppose t2 ≡ s1 s2 , the other case being analogous. Since s-redexes are s-terms, and i-redexes (i-contracta) do not contain any s-terms, t2 cannot be an i-redex (i-contractum). Therefore, t3 ≡ s′1 s′2 , t1 ≡ s′′1 s′′2 , and we have the following possibilities: • s′′1 ≡ s1 − → s′1 and s′2 ≡ s2 ←→ s′′2 , s
i
• s′′2 ≡ s2 − → s′2 and s′1 ≡ s1 ←→ s′′1 , s
i
• s1 − → s′1 , s1 ←→ s′′1 and s2 ≡ s′2 ≡ s′′2 , s
i
• s2 − → s′2 , s2 ←→ s′′2 and s1 ≡ s′1 ≡ s′′1 . s
i
In the first two cases the claim is easily established by taking s′1 s′′2 and s′′1 s′2 , respectively. In the last two cases we appeal to the inductive hypothesis. The simple lemma below will be often used implicitly in the proofs that follow. Lemma 4.3. If t is an i-term/s-term/tuple and t ←→ t′ , then so is t′ . i
Proof. The only non-obvious case is when t is an s-term, which is however easily handled by induction on the structure of t. 8
The next several lemmas show that i-contractions, i-expansions and s-contractions all preserve ❀. Lemma 4.4. If t ↓ and t ←→ t′ then t′ ↓. i
Proof. We check that the conditions in Definition 3.7 hold for every subterm s′ of t′ . Note that because ≡ i-redexes and i-contracta are i-terms, s′ is an i-term or there exists a subterm s of t such that s ←→ s′ . i
≡
(1) If s′ is not an i-term, then there exists a subterm s of t such that s ←→ s′ . If s is an i-term or i
a tuple then so is s′ . Otherwise, s is an s-term by 1 in the definition of t ↓. Then s′ is also an s-term by Lemma 4.3. (2) Suppose s′ ≡ C1 t′0 t′1 t′2 with t′0 in s-NF. Since s′ is not an i-term, there exists a subterm s of t ≡ such that s ≡ C1 t0 t1 t2 and ti ←→ t′i for i = 0, 1, 2. Since t′0 is in s-NF and t0 ←→ t′0 , the term t0 i
i
is also in s-NF. Thus t0 ≡ T1 or t0 ≡ F1 by 2 in the definition of t ↓. Hence t′0 ≡ T1 or t′0 ≡ F1 . (3) Suppose s′ ≡ S n0 ,...,nk t′0 t′1 t′2 . Since s′ is not an i-term, there exists a subterm s of t such that ≡ s ≡ S n0 ,...,nk t0 t1 t2 and ti ←→ t′i for i = 0, 1, 2. By 3 in the definition of t ↓ we conclude that t2 P i is a tuple of size n = ki=0 ni , and if k > 1 then t1 is a tuple of size k. The same holds for t′2 and t′1 , because a tuple cannot be an i-redex or an i-contractum. ≡ (4) Suppose s′ is an s-term. There exists a subterm s of t such that s ←→ s′ . Since s′ is an s-term, i
∗
∗
≡
s
s
i
so is s. Suppose s′ − → r′ . By Lemma 4.2 there exists r such that s − → r ←→ r′ . By 4 in the definition of t ↓, the term r is an s-term. Hence, r′ is also an s-term. (5) Suppose s′ ht′1 , . . . , t′n i with n > 1. Since s′ is not an i-term, there exists a subterm s of t such ≡ that s ≡ ht1 , . . . , tn i and ti ←→ t′i for i = 1, . . . , n. By 5 in the definition of t ↓ none of t1 , . . . , tn i
is a tuple. Hence, none of t′1 , . . . , t′n is a tuple either, by Lemma 4.3. Lemma 4.5. If t ❀ F1 and t ←→ t′ then t′ ❀ F1 . i
Proof. Suppose
∗ → t′ − s
t′0 .
∗
By Lemma 4.2 there exists t0 such that t − → t0 and t0 ←→ t′0 . Because t is s
i
strongly standard we have t0 ↓. Hence t′0 ↓ by Lemma 4.4. Therefore t′ is strongly standard. ≡ ∗ ∗ → t′0 with t′0 in s-NF. By Lemma 4.2 there exists t0 such that t − → t0 ←→ t′0 . Since t′0 is Suppose t′ − s
s
i
in s-NF, so is t0 , because an i-contraction or an i-expansion cannot create an s-redex. Since t ❀ F1 we obtain t0 ≡ F1 . Thus t′0 ≡ t0 ≡ F1 . Lemma 4.6. If t ❀ F1 and t − → t′ then t′ ❀ F1 . s
Proof. Obvious.
Corollary 4.7. If t ❀ F1 , t ≻ q and q →CLC0 q ′ , then there exists t′ such that t′ ≻ q ′ and t′ ❀ F1 . Proof. Follows directly from Lemma 4.1, Lemma 4.5 and Lemma 4.6.
With the above corollary we have finished the first half of the proof. Now we need to show an analogous corollary for CLC0 -expansions. First, we want to prove that CLC0 -expansions in unlabelled terms may be simulated by i-expansions and s-expansions in their strongly standard labelled variants. We have already shown in Lemma 4.5 that i-expansions preserve ❀. Thus it then remains to show that s-expansions preserve ❀. Like in the proof of Lemma 4.5 we show that if t′ − → t then any reduction s
∗
∗
≡
s
s
s
t′ − → s′ may be simulated by a reduction t − → s with s′ − → s. The most interesting case is when t′ ≡ E ′ [C2 t0 t1 t1 ] − → E[t1 ] ≡ t (where E, E ′ are contexts), which is s obtained from a CLC0 -expansion by the rule Cxyy → y. We now informally describe the idea for the ∗ proof in this case. Thus suppose t′ − → s′ . If a contracted s-redex does not overlap with a descendant3 s of C2 t0 t1 t1 , then the s-contraction is simulated by the same s-contraction. If a descendant of C2 t0 t1 t1 occurs inside a contracted s-redex, but it is different from this redex, then the descendant must occur below a variable position of the s-redex, because there are no non-root overlaps between the rules of significant reduction. Thus we may simulate this s-contraction by the same s-contraction. If a contracted 3Note that because the rules of significant reduction are linear there may be at most one descendant. 9
s-redex occurs inside a descendant C2 t′0 t′1 t′2 of C2 t0 t1 t1 , but it is different from this descendant, then it must occur in t′0 , t′1 or t′2 . In this case we ignore the s-contraction while at all times maintaining the ∗ ∗ → t′2 , and the descendant of t1 in → t′1 and t1 − invariant: if C2 t′0 t′1 t′2 is a descendant of C2 t0 t1 t1 then t1 − s
s
the simulated reduction is always identical with t1 , i.e. t1 (the s-contractum of C2 t0 t1 t1 ) is not changed by the simulated s-reduction. Finally, if a descendant C2 t′0 t′1 t′2 of C2 t0 t1 t1 is s-contracted, then either → t′2 . In any case we can s-reduce t1 to t′1 or t′2 . In other words, we defer the → t′1 or C2 t′0 t′1 t′2 − C2 t′0 t′1 t′2 − s s choice of the simulated reduction path till the descendant of the s-redex is actually contracted. Instead of speaking of descendants we will use a stronger auxiliary relation − → in place of − →. This a
s
will also help us with other parts of the proof of t′ ↓. Definition 4.8. An l-term t′ is an a-redex and t its a-contractum, if t is an s-term and one of the following holds: • t′ ≡ C1 T1 tq and q is an i-term, • t′ ≡ C1 F1 qt and q is an i-term, ∗ ∗ • t′ ≡ C2 qt1 t2 , t − → t1 , t − → t2 and q is an i-term, s
s
• t′ ≡ K1 tq and q is an i-term, • t′ ≡ S ~n t0 hs1 , . . . , sk ih~r0 , . . . , ~rk i where the conventions regarding vector notation are as in Definition 3.4, |si | =CLC |sj | for i, j = 1, . . . , k, |ri,j | =CLC |ri′ ,j ′ | for i, i′ = 0, . . . , k, j = 1, . . . , ni , j ′ = 1, . . . , ni′ , none of the si or ri,j is a tuple, and t ≡ t0 h~r0 ihs1 h~r1 i, . . . , sk h~rk ii. Because of the third condition, an a-contractum of an a-redex is not unique. The relation of a-contraction ∗ is defined inductively in the expected way. The notations − →, − →, −−→, etc. are used accordingly. Note a
a
i,a
that any a-redex is an s-redex. ∗
Lemma 4.9. If t′ − → t then t′ − →·← − t, and hence |t′ | =CLC |t|. a
s
s
The above simple lemma implies that the conditions in significant reduction rules are stable under a-contraction and a-expansion. Note that if t′ − → t then not necessarily t′ − → t because of the third a s condition in Definition 4.8. Lemma 4.10. If t is standard, t ≻ q and q
CLC0 ←
∗
q ′ , then there exists t′ such that t′ −−→ t and t′ ≻ q ′ . i,a
Proof. Induction on the size of ht, qi. The base case is when t is not a tuple and q is the CLC0 -contractum expanded in q CLC0 ← q ′ . If t is an i-term, then t ≡ q ← − q ′ and we may take t′ ≡ q ′ . If t is not an i-term, then it is an s-term by 1 i
in the definition of t ↓. We have the following possibilities, depending on the rule of CLC0 used in the expansion. • If q ′ ≡ CT q1 q2 →CLC0 q1 ≡ q then we may take t′ ≡ C1 T1 tq2 and we have t′ − → t and t′ ≻ q ′ . a
• • • •
If q ′ ≡ CF q1 q2 →CLC0 q2 ≡ q then we may take t′ ≡ C1 F1 q1 t. If q ′ ≡ Cq0 q1 q1 →CLC0 q1 then we may take t′ ≡ C2 q0 tt. If q ′ ≡ Kq0 q1 →CLC0 q0 then we may take t′ ≡ K1 tq1 . If q ′ ≡ Sq0 q1 q2 →CLC0 q0 q2 (q1 q2 ) then t ≻ q0 q2 (q1 q2 ) and t is an s-term. Hence t ≡ ta tb tc with ta ≻ q0 , tb ≻ q2 and tc ≻ q1 q2 . Recalling the convention hsi ≡ s for any term s, we may assume (⋆) tb ≡ hs1 , . . . , sm i, tc ≡ ht1 , . . . , tk i, for k, m ∈ N+ , if k = 1 then t1 is not a tuple, and if m = 1 then s1 is not a tuple. In other words, if e.g. tb is a tuple, then tb ≡ hs1 , . . . , sm i for some s1 , . . . , sm . If tb is not a tuple then we take s1 ≡ tb and consider tb ≡ htb i ≡ hs1 i. This is chiefly to reduce the number of cases to consider. Let 1 ≤ i ≤ k. Because tb ≻ q2 , we have si ≻ q2 for i = 1, . . . , m. By condition 5 in the definition of t ↓, or by (⋆) if m = 1, none of s1 , . . . , sm is a tuple. Since tc ≻ q1 q2 , we have ti ≻ q1 q2 . By condition 5 in the definition of t ↓, or by (⋆) if k = 1, we conclude that ti cannot be a tuple. Thus ti ≡ ui h~ri i where ~ri stands for ri,1 , . . . , ri,ni , and ui ≻ q1 and ri,j ≻ q2 for j = 1, . . . , ni , where none of the ri,j is a tuple, by definition (if ni = 1) or by condition 5 in the definition of t ↓. By Lemma 3.9 also none of u1 , . . . , uk is a tuple. 10
We may thus take t′ ≡ S m,n1 ,...,nk ta hu1 , . . . , uk ihr~0 , ~r1 , . . . , ~rk i where ~r0 stands for s1 , . . . , sm . We have t′ − → t and t′ ≻ q ′ . a
Now suppose that t ≡ ht1 , . . . , tn i with n > 1. Then ti ≻ q for i = 1, . . . , n, and we may appeal to the inductive hypothesis. Finally, if t is not a tuple and q is not the CLC0 -contractum, then t ≡ t1 t2 , q ≡ q1 q2 , t1 ≻ q1 , t2 ≻ q2 and we may apply the inductive hypothesis. The next lemma is illustrated by the following diagram.
/t↓ ✤ ✤ s s ∗ ✤ ≡ t′1 ❴ ❴a ❴/ t1 t′
a
≡
∗
a
s
Lemma 4.11. If t′ − → t′1 , t′ − → t and t ↓ then there exists t1 such that t′1 − → t1 and t − → t1 . s
Proof. Suppose t
′
a
− → t′1 , t′ − → s a
t and t ↓. We proceed by induction on the definition of t′ − → t′1 . The base s
case is when the s-contraction t′ − → t′1 occurs at the root. s
If the s-contraction occurs at the root, but the a-contraction t′ − → t does not occur at the root, a
then it is easy to see by inspecting the definitions that the a-redex in t′1 must occur below a variable position of the s-redex. Since significant reduction rules are linear and their conditions are stable under a-contraction, the claim holds in this case. Assume that both the s-contraction and the a-contraction occur at the root. Then there are the following possibilities. • If t′ ≡ C1 T1 sq − → s then the s-contraction must be by the first rule of CLCs , so t′1 ≡ t and we a
may take t1 ≡ t′1 ≡ t. ∗ ∗ • If t′ ≡ C2 qs1 s2 − → s then s − → s1 , s − → s2 and the s-contraction of t′ yields either s1 or s2 . We a
s
s
∗
may thus take either t1 ≡ s1 or t1 ≡ s2 , and we have t − → t1 ≡ t′1 . s • All other cases are analogous to the first one. If neither the s-contraction nor the a-contraction occurs at the root, then the claim is easily established, possibly appealing to the inductive hypothesis. Finally, assume that the a-contraction occurs at the root, but the s-contraction does not occur at the root. We have the following possibilities. • If t′ ≡ C1 T1 tq − → t then the s-contraction must occur inside t. So t − → t1 for some term t1 . Note a s that t is an s-term by definition of a-contraction. Therefore t1 is also an s-term, by 4 in the definition of t ↓. Thus t1 satisfies the required conditions. ∗ ∗ • If t′ ≡ C2 qs1 s2 − → t then t − → s1 , t − → s2 and the s-contraction must occur inside s1 or s2 . We a
s
s
may take t1 ≡ t and we still have t′1 − → t1 . a
• The cases t′ ≡ C1 F1 qt − → t and t′ ≡ K1 tq − → t are analogous to the first case. a
a
• If t′ ≡ S ~n t0 hs1 , . . . , sk ih~r0 , . . . , ~rk i then |si | =CLC |sj |, |ri,j | =CLC |ri′ ,j ′ | for i, j, i′ , j ′ as in Definition 4.8, none of the si or ri,j is a tuple, and t ≡ t0 h~r0 ihs1 h~r1 i, . . . , sk h~rk ii. The s-contraction must occur inside one of the si or the ri,j , or in t0 . For instance, assume s1 − → s′1 . Since s1 is a subterm of t and it is not a tuple, it cannot s-reduce to a tuple by s
Lemma 3.10. Hence s′1 is not a tuple. Take t1 ≡ t0 h~r0 ihs′1 h~r1 i, s2 h~r2 i, . . . , sk h~rk ii. Note that t − → t1 . Thus t1 is an s-term, because t is an s-term and it s-reduces only to s-terms, s by 4 in the definition of t ↓. 11
Lemma 4.12. If r is a strongly standard a-contractum of an a-redex r′ , and s′ is a proper subterm of r′ , then s′ ↓. Proof. It suffices to show that s′ is a subterm of some standard term. We have the following possibilities. • Suppose r′ ≡ C1 T1 rq − → r with q an i-term. All of T1 , r and q are standard and s′ is a subterm a of one of them, so the claim holds. • Suppose r′ ≡ C2 qr1 r2 − → r with q an i-term. If s′ occurs in q then the claim holds. Otherwise, s′ a
∗
occurs in e.g. r1 . Because r − → r1 and r is strongly standard, the claim holds. s
• The cases r′ ≡ C1 F1 qr and r′ ≡ K1 rq are analogous to the first one. • Suppose r′ ≡ S ~n t0 hs1 , . . . , sk ih~r0 , . . . , ~rk i − → t0 h~r0 ihs1 h~r1 i, . . . , sk h~rk ii. If s′ occurs in t0 or one a
of the si or ri,j (with i, j as in Definition 4.8), then the claim holds, because each of them is a standard term. Suppose e.g. s′ ≡ hs1 , . . . , sk i and k > 1. For i = 1, . . . , k, since si h~ri i is standard, si is not a tuple by Lemma 3.9. Since each si is also standard, by inspecting Definition 3.7 we may conclude that s′ is standard. Lemma 4.13. If s is an s-term and s′ − → s then s′ is also an s-term. a
Proof. Induction on the structure of s. If s is the a-contractum then s′ is the a-redex and the claim follows directly from Definition 4.8. If s ≡ s1 s2 then s1 is an s-term, s′ ≡ s′1 s′2 , and either s′1 ≡ s1 , hence s′ is an s-term, or s′1 − → s1 and s′2 ≡ s2 , hence we may apply the inductive hypothesis. a
Lemma 4.14. If t is strongly standard and t′ − → t then t′ ↓. a
Proof. We check that the conditions in Definition 3.7 hold for every subterm s′ of t′ . Of course, we may assume that s′ does not occur in t, as otherwise the claim follows from t ↓. Therefore, s′ occurs in the a-redex contracted in t′ − → t, or the a-redex occurs inside s′ . If s′ is a proper subterm of the a-redex, a
then our claim holds by Lemma 4.12. Therefore, it suffices to check the conditions in Definition 3.7 for s′ under the assumption that the a-redex r′ is a subterm of s′ . (1) Suppose r is the a-contractum of r′ and s′ − → s. By Definition 4.8, the term r is an s-term. a
Thus s cannot be an i-term. If s is a tuple, then so is s′ . Otherwise, s is an s-term, by 1 in the definition of t ↓. Hence s′ is also an s-term by Lemma 4.13. (2) Suppose s′ ≡ C1 t′0 t′1 t′2 and t′0 is in s-NF. If s′ ≡ r′ then s′ ≡ C1 T1 t′1 t′2 or s′ ≡ C1 F1 t′1 t′2 , hence t′0 ≡ T1 or t′0 ≡ F1 . If r′ is a proper subterm of s′ , then r′ must be a subterm of t′1 or t′2 , because a-redexes are not in s-NF. Thus, s′ − → s ≡ C1 t′0 t1 t2 for some terms t1 , t2 , where s is a subterm a
of t. Hence, t′0 ≡ T1 or t′0 ≡ F1 by 2 in the definition of t ↓. (3) Suppose s′ ≡ S n0 ,...,nk t′0 t′1 t′2 . If s′ ≡ r′ , then s′ ≡ S n0 ,...,nk t′0 hs1 , . . . , sk ih~r0 , . . . , ~rk i, as in → Definition 4.8, so the claim holds. If r′ is a proper subterm of s′ , then s′ ≡ S n0 ,...,nk t′0 t′1 t′2 − a
≡
→ ti for i = 0, 1, 2, and s is a subterm of t. By 3 in the definition s ≡ S n0 ,...,nk t0 t1 t2 where t′i − a P of t ↓, the term t2 is a tuple of size ki=0 ni , and if k > 1 then t1 is a tuple of size k. Since an a-contractum is an s-term, and hence not a tuple, t2 is not an a-contractum, and if k > 1 then t1 P is not an a-contractum. Thus we may conclude that t′2 is a tuple of size ki=0 ni , and if k > 1 then t1 is a tuple of size k. ∗ (4) Suppose s′ is an s-term and s′ − → s′1 . If r′ is a subterm of s′ then s′ − → s with s a subterm of t, s
a
≡
∗
a
s
→ s1 and s − → s1 . By Definition 4.8, hence s ↓. By Lemma 4.11 there exists s1 such that s′1 − the term s is an s-term, so s1 is also an s-term by 4 in the definition of s ↓. By Lemma 4.13 we conclude that s′1 is an s-term. (5) Suppose s′ ≡ ht′1 , . . . , t′n i with n > 1. If r′ is a subterm of s′ , then s′ − → s ≡ ht1 , . . . , tn i where s a
≡
→ ti for i = 1, . . . , n. By 5 in the definition of s ↓, none is a subterm of t (hence s ↓), and t′i − a
of t1 , . . . , tn is a tuple. Thus it is easy to see by inspecting Definition 4.8 that none of t′1 , . . . , t′n can be a tuple. Lemma 4.15. If t ❀ F1 and t′ − → t then t′ ❀ F1 . a
12
∗
∗
≡
s
s
a
→ t0 . Since t is strongly Proof. Suppose t′ − → t′0 . By Lemma 4.11 these exists t0 such that t − → t0 and t′0 − standard, so is t0 . Therefore, t′0 is standard by Lemma 4.14. ∗ ∗ ≡ Suppose t′ − → t′0 with t′0 in s-NF. By Lemma 4.11 these exists t0 such that t − → t0 and t′0 − → t0 . Since s
s
a
an a-redex is an s-redex and t′0 is in s-NF, we conclude that t′0 ≡ t0 . But then t′0 ≡ t0 ≡ F1 , because t ❀ F1 . Corollary 4.16. If t ❀ F1 , t ≻ q and q
CLC0 ←
q ′ , then there exists t′ such that t′ ❀ F1 and t′ ≻ q ′ .
Proof. Follows directly from Lemma 4.10, Lemma 4.5 and Lemma 4.15.
∗
Lemma 4.17. If t ❀ F1 then there exists an s-reduction t − → F1 in which no contraction occurs inside s a tuple. Proof. Since s-reduction is strongly normalising, by reducting s-redexes outside any tuples we will ul∗ timately obtain a term t′ with all s-redexes inside tuples, and such that t − → t′ . If t′ is in s-NF then s
t′ ≡ F1 . Otherwise, any s-NF of t′ must contain a tuple, because s-reduction inside a tuple cannot erase this tuple or create an s-redex outside of it. But since any s-NF of t′ is an s-NF of t, this contradicts the fact that t has no s-NFs other than F1 . We now have everything we need to show the central lemma of the confluence proof. ∗
Lemma 4.18. If q =CLC F then q →CLC F . Proof. If q =CLC F then by Lemma 3.2 we have q =CLC0 F . Note that F1 ❀ F1 and |F1 | ≡ F . Thus, using Corollary 4.7 and Corollary 4.16 it is easy to show by induction on the number of contractions and expansions in q =CLC0 F that there exists t such that t ≻ q and t ❀ F1 . By Lemma 4.17 there exists an ∗ s-reduction t − → F1 in which no contraction occurs inside a tuple. But then because t ≻ q it is easy to s
∗
∗
show by induction on the number of contractions in t − → F1 that q ≡ |t| →CLC |F1 | ≡ F . s
It remains to derive the confluence of CLC and CLC+ from Lemma 4.18. We use a trick with an auxiliary term rewriting system R, in a way similar to how the confluence of CLC+ is derived from the condition T 6=CLC+ F in [2]. Definition 4.19. The term rewriting system R is defined by the following rules: CT xy
→ x
Czxy Czxy
→ y → x
Kxy Sxyz
→ x → xz(yz)
⇐ ⇐
z =CLC F z 6=CLC F ∧ x =CLC y
Note that the equality in the conditions refers to the system CLC, so there is no circularity here. ∗
Lemma 4.20. If q →R q ′ then q →CLC q ′ . Proof. Without loss of generality assume the contraction occurs at the root of q. The only non-obvious case is when the contraction is by the second rule of R. Then q ≡ Cq0 q1 q ′ →R q ′ and q0 =CLC F . By ∗ ∗ Lemma 4.18 we obtain q0 →CLC F . So q ≡ Cq0 q1 q ′ →CLC CF q1 q ′ →CLC q ′ . Lemma 4.21. If q →CLC0 q ′ then q →R q ′ . Proof. The only non-obvious case is when the third rule of CLC0 is used and we have q ≡ Cq0 q ′ q ′ →CLC0 q ′ and q0 =CLC F . But then the second rule of R is applicable, so q →R q ′ . Lemma 4.22. The system R is confluent. Proof. Because T 6=CLC F by Lemma 4.18, the system R is weakly orthogonal (i.e. it is left-linear and all its critical pairs are trivial). By Lemma 4.20 the conditions are stable under reduction. Weakly orthogonal conditional term rewriting systems whose conditions are stable under reduction are confluent [6, Chapter 4]. Theorem 4.23. The systems CLC and CLC+ are confluent. 13
Proof. Since q1 →CLC q2 implies q1 →CLC+ q2 , it suffices to show that q1 =CLC+ q2 implies the existence ∗ ∗ of q such that q1 →CLC q and q2 →CLC q. So suppose q1 =CLC+ q2 . Then by Lemma 3.2 we have ∗ q1 =CLC0 q2 . By Lemma 4.21 we obtain q1 =R q2 . By Lemma 4.22 there exists q such that q1 →R q and ∗ ∗ ∗ q2 →R q. By Lemma 4.20 we conclude that q1 →CLC q and q2 →CLC q. 5. Conclusion Up to now, the only known syntactic proof of the unique normal form (UN) property for the system CLC0 was by appealing to Chew’s theorem. It is shown in [2] that the UN property of CLC0 may be derived from the confluence of CLC+ , or more generally that the UN property of any term rewriting system may be derived from the confluence of any of its conditional linearizations. As already mentioned, confluence of CLC+ is established in [2] by a simple proof, albeit involving a sematic argument. We repeat here the argument from [2] showing how to derive the UN property of CLC0 from the confluence of CLC. Theorem 5.1. The system CLC0 has the unique normal form property, i.e. if t1 and t2 are in CLC0 normal form and t1 =CLC0 t2 , then t1 ≡ t2 . Proof. First, we show by induction on the size of a term t the claim: if t contains a CLC-redex, then it contains a CLC0 -redex. The only non-obvious case is when the CLC-redex in t has the form Ct0 t1 t2 with t1 =CLC t2 . If t1 or t2 contains a CLC-redex, then t contains a CLC0 -redex by the inductive hypothesis. Otherwise, t1 and t2 are in CLC-normal form. Since t1 =CLC t2 , by confluence of CLC we obtain t1 ≡ t2 . Therefore, Ct0 t1 t2 ≡ Ct0 t1 t1 is a CLC0 -redex in t. This establishes the claim. Now, suppose t1 =CLC0 t2 with t1 , t2 in CLC0 -normal form. By the claim just shown t1 and t2 are in CLC-normal form. By Lemma 3.2 we obtain t1 =CLC t2 . Hence t1 ≡ t2 by confluence of CLC. We conjecture that our methods may be generalized to show confluence of conditional linearizations of any compatible term rewriting system, thereby yielding a new proof of Chew’s theorem. However, this generalization is far from straightforward. Our confluence proof makes essential use of the special form of the system CLC. References [1] Franz Baader and Tobias Nipkow. Term Rewriting and All That. Cambridge University Press, 1999. [2] R.C. de Vrijer. Conditional linearization. Indagationes Mathematicae, 10(1):145–159, 1999. [3] Nachum Dershowitz, Jean-Pierre Jouannaud, and Jan Willem Klop. Open problems in rewriting. In Ronald V. Book, editor, RTA, volume 488 of Lecture Notes in Computer Science, pages 445–456. Springer, 1991. [4] Jan Willem Klop. Combinatory reduction systems, volume 127 of Mathematical Centre Tracts. Centre for Mathematics and Computer Science, Amsterdam, 1980. [5] K. Mano and M. Ogawa. Unique normal form property of compatible term rewriting systems: a new proof of Chew’s theorem. Theoretical Computer Science, 258(1):169–208, 2001. [6] Terese. Term Rewriting Systems, volume 55 of Cambridge Tracts in Theoretical Computer Science. Cambridge University Press, 2003. Institute of Informatics, University of Warsaw, Banacha 2, 02-097 Warszawa, Poland E-mail address:
[email protected] 14