Meaningless terms in rewriting - Semantic Scholar

Report 7 Downloads 122 Views
Meaningless terms in rewriting Richard Kennaway1, Vincent van Oostrom2, and Fer-Jan de Vries3 ? 1 School of Information Systems, University of East Anglia, Norwich NR4 7TJ, UK 2 NTT BRL, Information Processing Principles Research Group, 3-1 Wakamiya

Morinosato, Atsugi-shi, Kanagawa 243-01, Japan

3 Hitachi Advanced Research Laboratory, Hatoyama, Saitama 350-03, Japan

Abstract. We present an axiomatic approach to meaninglessness in nite

and trans nite term rewriting and lambda calculus. We justify our axioms in two ways. First, they are shown to imply important properties of meaninglessness: genericity of the class of meaningless terms, the consistency of equating all meaningless terms, and the construction of Bohm trees. Second we show that they can be easily veri ed for existing notions of meaninglessness.

1 Introduction Many notions have appeared in the literature of what it means for a term in a rewrite system to be \meaningless". In this paper we present axioms that a set of terms in a rewrite system should satisfy to be considered as a reasonable notion of meaninglessness. The axioms can be easily veri ed for many existing notions of meaninglessness, and are sucient to prove several important properties of such notions, which in the past have been proved separately for each one. We consider term rewrite systems and lambda calculus, in both nitary and trans nite versions. We assume the reader to be familiar with the basic theory of term rewriting systems [DJ90, Klo92] and lambda calculus [Bar84, HS86], and their in nitary counterparts [KKSdV95b, KKSdV96]. We start with some conceptual analysis of meaning in term rewriting systems. In any set of objects one might single out a subset of meaningless objects. Since rewriting is conceived of as a process of obtaining information about a term, no information should be obtainable from a meaningless term. It follows that meaninglessness should be preserved by rewriting. Next, rewriting replaces parts of a term by other terms, according to the rewrite rules. Replacement consists of removing a subterm which is an instance of the lefthand side of some rewrite rule and plugging in the corresponding instance of the right-hand side of that rule. The removed subterm can be in three di erent positions: outside, on the border of, or inside the meaningless subterms which are ?

Email addresses: [email protected], [email protected], and [email protected]. Richard Kennaway was supported by an EPSRC Advanced Fellowship, and by EPSRC Grant no. GR/F 91582. Vincent van Oostrom's work was partially performed at the Vrije Universiteit, Amsterdam and with an HCM grant at the Technische Universitat Munchen. Fer-Jan de Vries's current address is ETL, 1-1-4 Umezono, Tsukuba, Ibaraki 305, Japan.

present in the term. Roughly speaking, one of our axioms shall express that the second (border) situation cannot occur. The motivation for this condition is that a meaningless term is one which cannot convey any information when looked at \from outside". In a term rewrite system one \looks at a term from outside" by matching it against a proper non-variable subterm of a left-hand side (e.g. when one extracts from a term Cons (t; t0 ) the subterm t by applying the Head operator to it and the rule Head (Cons (x; y)) ! x). A meaningless term should not be capable of being inspected in this way. For term rewrite systems, this implies that we should restrict attention to left-linear systems, since non-left-linear systems are capable of performing a test of syntactic identity on any two terms whatever. When considering higher-order rewriting, we will require a further condition, that the set of meaningless terms is closed under substitution. For trans nite rewriting, some of our results require that the set of meaningless terms contains all the hypercollapsing terms | terms which can undergo in nitely many reductions at the root by collapsing rules (de ned below). We shall consider term rewrite systems and lambda calculus, in both nitary and in nitary forms. The latter allow in nitely large terms and rewrite sequences of any ordinal length, the basic theory of which has been set out for both term rewrite systems [KKSdV95b] and lambda calculus [KKSdV96]. We show the usefulness of our axioms in two ways. Firstly, we show that from them we can derive two standard lemmas: the Genericity Lemma and the Consistency Lemma. Genericity states that a meaningless subterm is irrelevant to the computational meaning of the term containing it. Consistency states that adding the rule that all meaningless terms are equal does not give an inconsistent system (one in which all terms are provably equal). Secondly, we show that they can be checked straightforwardly for many existing notions of meaninglessness, both for term rewriting systems (TRSs) and lambda calculi. The results in this paper correct and extend results presented in [AKK+94], which deals with term rewriting systems. Our second axiom here was missing from that paper, as observed by the second author of the present paper. Consequently, the axiom in the earlier paper expressing that all terms not having a root stable form are meaningless can here be restricted to hypercollapsing terms. Our paper [KKSdV96] on in nite lambda calculus bene tted greatly from these insights. In particular, not all variants of Bohm reduction and beta-reduction up to identi cation of 0-active terms are Church-Rosser, as claimed in [KKSdV95a].

2 Axioms and properties of notions of meaninglessness There are ve axioms that we may require a subset U of meaningless terms in a rewriting system to satisfy. In all of the axioms, the reductions they speak of are nitary or in nitary, according as one is considering a nitary or an in nitary rewrite system. The rst two (the rst three, for lambda calculus) will suce to establish the Genericity Lemma for nitary and in nitary rewrite systems. We make extensive use of the notion of a position, also called an occurrence, for identifying subterms of terms. A position is a nite sequence of positive integers.

Given a position u and a term t, the subterm tju, when it exists, is de ned by tj = t ( being the empty sequence), and F (t1 ; : : : ; tn )j(i  u) = ti ju (if i  n). There is a natural pre x ordering on positions, and two positions are said to be disjoint if neither is a pre x of the other. We write s! !t for a reduction of any ordinal length from s to t. In a nitary system, it must be of nite length, and in a trans nite system, it may be nite or in nite. s ! t denotes a reduction of length at most .

Axiom 1. U is closed under rewriting. De nition 1. Let t be a redex, i.e. an instance (l) of the left-hand side l of some rewrite rule. The redex t overlaps the subterm of t at position u if u is a non-empty position of l and l j u is not a variable. Axiom 2. If a redex t overlaps a subterm in U , then t 2 U . Axiom 3. U is closed under substitution. The Consistency Lemma expresses that it is consistent to identify all meaningless terms. In the nitary cases it follows from the same axioms as the Genericity Lemma. In the in nitary setting, we need a fourth axiom for both term rewriting and lambda calculus.

De nition 2. Suppose t is a redex, and reduces to t0 . t is a collapsing redex if t0 is the descendant of a proper subterm of t by that reduction. A term t is hypercollapsing if for every term t0 which t reduces to, t0 reduces to a collapsing redex. H is the set of hypercollapsing terms.

Note that for term rewriting systems a redex is collapsing if it is the redex of a rewrite rule whose right-hand side is a variable, whereas for lambda calculus every redex is collapsing. Axiom 4. H  U . The fth axiom | rather a strong one | is required in order to obtain the uniqueness of Bohm trees. (Existence follows from very weak hypotheses.) It expresses that the meaningfulness of a term does not depend on the identity of its meaningless subterms.

Axiom 5. Let s and t be in U , and let C [ ] be any context. Then C [s] 2 U () C [t] 2 U . 2.1 Related notions Intuitively, meaningless terms should be computationally irrelevant. This is captured formally by the property of genericity.

De nition 3. A term is totally meaningful if it is in normal form, and none of its subterms is in U .

De nition 4. Suppose that for every term s in U and every context C [ ] with one hole, if C [s] reduces to a totally meaningful term t, then C [r] reduces to t for every r. Then U is called a generic set. Usually genericity is stated in the form of a conversion to normal form C [r](! ![ ) t instead of a reduction to totally meaningful form C [r]! !t, This is always done

in the context of con uent rewriting systems with each subterm of a normal form being meaningful, so the two notions coincide. Stating it in the `rewrite' form has the advantage of making sense for non-con uent rewriting systems as well, as remarked by Mizuhito Ogawa.

De nition 5. A rewriting system is called consistent if there exist two normal forms which are not convertible with each other by the rules of the system. More formally, there must be two normal forms s and t such that there is no nite sequence s = s0 Rs1 R : : : Rsn?1 Rsn = t, where R relates two terms if there is a reduction of any length, either forwards or backwards, between them. (Note that for trans nite systems, there must still be only nitely many steps in such a proof, although each step R may be an in nitely long reduction.) Given a set of terms U , a rewriting system is strongly consistent (with respect to U ) if there exist two totally meaningful terms which are not provably equal by the rules of the system.

3 Finite term rewriting In this section, only nitary TRSs are considered.

3.1 Genericity The Genericity Lemma formalises our intuition that meaningless terms are comU t0 if A is a set putationally irrelevant. If U is a set of terms, we will write t ! A 0 of pairwise disjoint positions of subterms of t in U , and t can be obtained from t by replacing those subterms by other arbitrary subterms, which are not necessarily members of U .

Lemma6. In a left-linear TRS, suppose that U satis es Axioms 1 and 2. If s !U A t U t0 . and s ! s0 , then there exist t0 and A0 such that t !1 t0 and s0 ! A Proof. Let u be the position of the redex reduced in s ! s0 . We distinguish three 0

cases. 1. u  v for some v 2 A. Take t0 = t and A0 = A. By Axiom 1, s0 has a meaningless term at every position in A0 , and the required relation between s0 and t0 holds. 2. The redex at u overlaps one of the subterms at a position in A. By Axiom 2, the redex itself must be a meaningless subterm of s. Take t0 = t, and A0 to be the set of minimal members of A [ fug w.r.t. the pre x ordering of positions.

3. If neither of the other two cases occurs, the pattern of the redex must be entirely outside all of the subterms of s at A. Since the TRS is left-linear, t must have a redex at u as well. Let t0 result from reducing it. Take A0 to be the set of residuals of A by reduction at u. (By the disjointness property of term rewriting, this is a pairwise disjoint set.) Since every subterm of s0 at A0 is identical to some subterm of s at A, every such subterm is meaningless. ut

Lemma 7 (Genericity). In a left-linear TRS, every set U satisfying Axioms 1 and 2 is generic.

Proof. Suppose we have a context C [ ], a term s 2 U , and a reduction of C [s] to a U C [r], where u totally meaningful term t. With the notation of Lemma 6, C [s] ! fug is the position of the hole in C [ ]. We can therefore apply that lemma to each step of the reduction of C [s] to t, obtaining a reduction of C [r] to a term t0 , such that t0 can be obtained from t by replacing some subterms of t in U . But by hypothesis, t has no such subterms, therefore t0 = t. ut

We remark that the axioms we gave in [AKK+94] do not suce for genericity, as is demonstrated by the example of the rule F (A) ! B and the set U = fAg. This satis es the axioms of that paper, but U is not generic. F (A) reduces to the totally meaningful term B , but F (B ) does not reduce to B . Although the axioms here are sucient but not necessary, they are satis ed by many notions of meaninglessness occurring in the literature. In many cases, an example showing failure of an axiom can be used directly to show failure of the genericity lemma. Example 1. { The TRS fA ! B; B ! B g and the set U = fAg. U is generic, but does not satisfy Axiom 1. { The TRS fG(A) ! B; G(x) ! Bg and the set U = fAg. U is generic, but does not satisfy Axiom 2. The failure of the axiom is due to non-uniformity of usage of information in non-orthogonal TRSs. { The TRS fG(A) ! Bg and the set U = fA; Bg. U is generic, but does not satisfy Axiom 2.

3.2 Consistency A on terms is de ned as follows: De nition 8. Let A be a set of terms. The relation $ A s $ t if t can be obtained from s by replacing some set of pairwise disjoint subterms A we denote of s in A by other terms of A. (The set is allowed to be in nite.) By = A . ! is the quotient of the rewrite relation by the re exive transitive closure of $ A

A =.

A is clearly re exive and symmetric, it need not be transitive. Note that although $

Example 2. Consider terms constructed from nullary A and B , and unary G. Let U U G(B ) $ U A, but not G(A) $ U A. consist of every term except G(A). We have G(A) $

Lemma9. Let U satisfy Axioms 1 and 2. If t $U s ! s0, then for some t0, t !1

t0 =U s0 .

Proof. The argument is very similar to the proof of Lemma 7. The only extra complication is in the second of the three cases, where we consider a redex s ! t at a position u overlapping one of the subterms of s at A. tju need not be a redex, therefore we cannot immediately conclude that it is in U (which the purposes of U s Lemma 7 did not require). In this case, we can take t0 = t. We then have t0 $ U s0 (since by Axiom 2, sju 2 U , so by Axiom 1, s0 ju 2 U ). (by hypothesis) and s $ U Therefore t0 = s0 . ut

Corollary 10. Let U satisfy Axioms 1 and 2. If t =U s!!s0, then for some t0, t!!t0 =U

s0 .

Proof. When s! !s0 is one step long, this follows by applying Lemma 9 to each $U step of a proof that t =U s. The whole corollary then follows by applying this to each step of s! !s0 . ut

De nition 11. Given an equivalence relation  on the terms of a rewrite system, the reduction relation is said to be con uent up to  if ; ! !  !!; ; . The A. reduction relation is said to be con uent up to A if it is con uent up to $ Lemma12 (Consistency). In a left-linear TRS, suppose U satis es Axiom 1 and 2 and the rewrite system is con uent up to U . If two totally meaningful terms are not provably equal by !, then they are not provably equal when the axiom that all members of U are equal is added. U preserves inequality of totally meaningful terms. That is, the quotient by =

Proof. Consider a proof of equality of two totally meaningful terms s0 and sn . It takes the form of a deduction s0 R1 s1 R2    Rn sn , where each relation Ri is either a U reduction sequence (forwards or backwards) or an instance of =. If the proof is empty, then s0 and sn are identical. Otherwise, the total meaningfulness of s0 implies that the rst step must be s0 ! !s1 . Total meaningfulness of sn implies that this cannot be the only step in the proof. s0 ! !s1 !!s2 can be replaced by s0 !!s2 . s0 !!s1 =U s2 can be replaced by s0 =U ! !s2 , by Corollary 10. Total meaningfulness of sn implies that s0 and s2 are identical. s0 ! !s1 s2 can be replaced by s0 !! =U s2 , by the con uence hypothesis. Total meaningfulness of sn implies that s0 s2 . Therefore if the proof is nonempty there exists a proof with fewer steps, and hence a proof with no steps. That is, s0 and sn are identical. ut

Note that since orthogonal TRSs are con uent, they are con uent up to U or any U .

4 Finite lambda calculus Our results for nitary lambda calculus with beta reduction are rather similar to the above, but with the addition of an extra hypothesis on U , Axiom 3. Axiom 2 can be stated for the lambda calculus in more concrete terms: it means that if x:t is in U , then so is (x:t)t0 for any t0 .

Lemma 13 (Genericity). In nitary lambda calculus, every set U satisfying Ax-

ioms 1, 2 and 3 is generic.

Proof. The proof is almost the same as for the Genericity Lemma for nitary TRSs. The same analysis into three cases is made, and for the rst two cases the argument is identical. For the third case, the Disjointness Property does not hold, and A0 must be de ned to be the set of outermost members of the set of residuals of A. Furthermore, the subterms of s0 are no longer exact copies of subterms of s, but in general may be substitution instances of them. This is why Axiom 3 is required: it guarantees that those instances are still meaningless. ut

The lambda calculus versions of Corollary 10 and the Consistency Lemma are proved similarly, both requiring the extra hypothesis on U that it satisfy Axiom 3. In the Consistency Lemma, note that lambda calculus is con uent, and therefore con uent up to U for any U .

5 Trans nite rewriting 5.1 Basic concepts We brie y recall some de nitions and facts from trans nite rewriting as laid out in [KKSdV95b, KKSdV96] for orthogonal term rewriting and lambda calculus respectively. The main result making everything work in both cases, is the Compressing Lemma expressing that for left-linear systems, the theory of trans nite rewriting is the same as that of in nite (rewrites not longer than !) rewriting.

Lemma 14 (Compression). [KKSdV95b, KKSdV96] For left-linear TRSs and for lambda calculus, for any ordinal , if t ! s then t !! s. ut The main di erence with nite rewriting is that in nitary con uence (con uence of ! !) is not implied by orthogonality. The only obstacle to con uence lies with the hypercollapsing terms (both nal terms in the example are hypercollapsing). The following lemma is an essential brick in the construction of positive results for trans nite orthogonal rewriting. Lemma 15. [KKSdV95b, KKSdV96] Trans nite orthogonal TRSs and lambda calculus are con uent up to H. ut

5.2 Genericity and consistency for trans nite term rewriting

To obtain genericity and consistency theorems corresponding to those for nitary term rewriting, we rst prove a lemma generalising Lemma 6. Lemma16. In a left-linear TRS, suppose that U satis es Axioms 1, 2, and 3. If U t and s! s! !s0 , then there exist t0 and A0 such that t!!t0 and s0 !U A t0 . A Proof. If the reduction s! !s0 is nitely long, then this is immediate from Lemma 6. (The presence of in nite terms does not a ect the argument.) Therefore we need only consider the case where it is in nitely long, and by the Compression Lemma, we may assume that it has length !. Write it as s = s0 ! s1 ! : : : s! = s0 . The construction of Lemma 6 can be applied to each step of the reduction s! !s0 ,  1  1 generating a possibly in nite reduction from t: t = t0 ! t1 ! : : :. This is strongly convergent, because each nonempty step is performed at the same position U t. as the corresponding step in the reduction from s. Call its limit t0 , and let si ! A i Because the sequence of depths of reductions tends to in nity, theSsequence of T Asets= A is convergent. (Convergence of this sequence of sets means that j Ti S A ; this set is de ned to be the limit of the sequence.) Let Ai0be jitsi limit. i0 0ji j 0 Then s and t di er only by a substitution of terms at positions in A. Let u be a position in A. For a suciently large i, there is a reduction sequence si ju !1 si+1 ju !1 : : : s0 ju, in which each term before the limit is in U . By Axiom 1, s0 ju must also be in U . Therefore s0 and t0 are in the required relationship. ut Lemma17 (Trans nite Genericity). In a left-linear trans nite TRS, every set U satisfying Axioms 1 and 2 is generic. Proof. Let s be a term of U and C [s]! !t be a reduction to a totally meaningful term t. Let r be any term. By the Compression Property, we may assume this sequence to have length at most !. By Lemma 16, there is a reduction of C [r] to a term t0 U t0 . But t is a normal form, therefore t = t0 . such that t ! ut Lemma18 (Trans nite Consistency). Suppose U satis es Axioms 1 and 2 and the rewrite system is con uent up to U . If two totally meaningful terms are not provably equal by !, then they are not provably equal when the axiom that all members of U are equal is added. U preserves inequality of totally meaningful terms. That is, the quotient by = Proof. The proof proceeds similarly to the nite case. With the notation of U s , where s is totally meaningful. If s s is nitely Lemma 12, we have s0 s1 $ 2 0 0 1 long then the previous argument can be followed exactly. If it is in nitely long, then by the Compression Lemma it may be assumed to be of length !. We apply Lemma 9 U relation along each step of the reduction of s to s , generating a to push the $ 1 0 reduction sequence starting from s2 . Since s0 contains no subterms in U , the depth of the subterms replaced by the =U relation between terms of s1 ! !s0 and of s2 !! : : : must tend to in nity as s0 is approached. This implies that the sequence from s2 U step from the proof of equality strongly converges to s0 . We have thus eliminated a $ of two totally meaningful terms. Repeating the argument eliminates all such steps, yielding the conclusion that the terms are identical. ut 0

i

Corollary 19. If U satis es Axioms 1, 2 and 4, and the rewrite system is orthogoU preserves inequality of totally meaningful terms. nal, then the quotient by =

Proof. From [KKSdV96], orthogonal trans nite rewrite systems are con uent up to H, therefore they are con uent up to U for any U satisfying Axiom 4. ut

5.3 Genericity and consistency for trans nite lambda calculus For trans nite lambda calculus, the Genericity and Consistency lemmas carry over by taking the union of the axioms required for the cases of nite lambda calculus and trans nite term rewriting, viz. Axioms 1{4. Since beta reduction is a collapsing rule, all redexes are collapsing redexes and the class of hypercollapsing terms is the same as the class of root-active terms: those terms t such that if t! !s then s is reducible to a redex. From Lemma 15 we know that trans nite lambda calculus is con uent up to H, so the Consistency Lemma can dispense with that as a hypothesis.

5.4 Bohm trees In lambda calculus we have the notion of a Bohm tree [Bar84]. This is a possibly in nite lambda term which may also contain the constant ?, which represents unde nedness. We can generalise this concept to other rewrite systems, and show that, given suitable constraints on the notion of unde nedness, the Bohm trees w.r.t. that notion form a semantic domain for the rewrite system, and that the computation of the `value' of a term consists of computing its normal form in a trans nite extension of the rewrite system.

De nition 20. In a given rewrite system, the Bohm terms are obtained by adjoining the nullary function symbol ?. An ordering of Bohm terms is de ned by stipulating that ?  s for every term s, and that all the term-forming operations are monotonic. Clearly, when in nite terms are present, the set of Bohm terms forms an algebraic domain in which the order- nite terms are the nite terms. The maximal elements of the domain are the terms not containing ?, i.e. the original terms of the system. A Bohm tree w.r.t. a set U of `unde ned' terms is a Bohm term containing no redexes and no subterms in U . A term of the original system is called Bohm normal if every redex in it is contained in a subterm in U . Given any term t, we may compute a Bohm tree of t by trans nitely reducing t, subject to the constraint that no reduction is ever performed within a subterm in U . If and when a term is reached containing no redex satisfying the constraint | a Bohm normal term | all maximal subterms of t in U are replaced by ?. The resulting Bohm tree is called a Bohm tree of t.

Proposition 21. If U contains every term from which there is a rewrite sequence performing in nitely many root reductions, then every term has at least one Bohm tree.

Proof. The condition on U implies that every reduction which never reduces inside a subterm in U is strongly convergent. Therefore it must trans nitely terminate (and in some countable ordinal number of steps). The nal term is Bohm normal, hence a Bohm tree of the term exists. ut

Note that in lambda calculus and in orthogonal TRSs, the property of having a rewrite sequence performing in nitely many root reductions is equivalent to being root-active. For non-orthogonal TRSs, the latter condition is stronger, and the existence of Bohm trees does not follow from the inclusion in U of all root-active terms.

Proposition 22. If Axiom 5 is satis ed, and trans nite reduction is con uent up to U , then every term has at most one Bohm tree. Proof. Suppose we have two di erent reductions of a term t to Bohm normal terms t0 and t00 . By con uence, these terms di er only by a replacement of subterms in U by subterms in U . From Axiom 5 it follows that this replacement can be chosen to be a replacement of their maximal subterms in U . Therefore the Bohm trees resulting from the two reductions are identical. ut

When the Bohm tree of a term t exists uniquely, we denote it by B(t). We would like to go a step further and introduce the concept of Bohm reduction. This extends the ordinary reduction relation with the Bohm rule: s !? ? if s 2 U : The intention is that computation of Bohm trees should be just trans nite reduction with respect to the extended reduction rules. This is not true for arbitrary U , and as yet, we do not have axioms for U which will ensure this. In [KKSdV96] we proved this for certain special cases for the trans nite lambda calculus, summarised here in section 6.2. However, the proofs are speci c to the particular rewrite systems, and have not suggested to us a set of abstract axioms.

6 Sets of meaningless terms 6.1 Sets of meaningless terms in term rewriting We now check our present axioms for some sets of rst-order terms which seem intuitively good candidates. These include all the examples in [AKK+ 94]. Although our theorems apply to all left-linear TRSs, most of the following notions are only de ned for orthogonal TRSs.

False, True. The empty set and the set of all terms (i.e. the predicates `false' and `true' on terms) satisfy all the axioms, except that the empty set fails Axiom 4 if there are any hypercollapsing terms. Hence they satisfy the Genericity and (with the same exception) the Consistency Lemmas. Note that the Consistency Lemma is vacuous when U is the set of all terms, since there are then no totally meaningful terms.

Has no normal form/has an in nite rewrite. In general, neither the set of terms without normal form nor the set of terms having an in nite rewrite is generic, even for orthogonal systems. The former violates Axiom 2 for the TRS fA ! A; G(H (x)) ! B g. The term H (A) has no normal form, but replacing H (A) by B in G(H (A)) changes the normal form of the latter term from B to G(B ). The set of terms having an in nite rewrite violates Axiom 1, as is shown by the system fA ! A; B (x) ! C g. B (A) has an in nite rewrite, but its reduct C does not.

However, for nitary orthogonal non-erasing TRSs | that is, where every variable occurring on the left of a rule also occurs on the right of that rule (cf. [Klo92, p. 75]) | the two classes coincide and are generic. Since there are no hypercollapsing terms in such systems, Axiom 4 holds trivially. For Axiom 5, we note for future reference that in the terminology introduced in De nition 8, this axiom states that U This is clearly true for this particular U . U is closed under =. In the trans nite case, the two classes no longer coincide, even in non-erasing systems, as demonstrated by the rules fA ! A; G(H (x)) ! J (G(H (x)))g. H (A) does not have a normal form, but G(H (A)) does (activity is pushed into in nity). As a result, neither class is generic. If we strengthen the concept of non-erasingness for trans nite systems, by calling a TRS trans nitely non-erasing if for any reduction t! !t0 , every subterm of t has at least one residual in t0 , then for trans nitely non-erasing TRSs, the property of having an in nite rewrite is once more equivalent to the property of having no normal form. (However, unlike non-erasingness, trans nite non-erasingness is not a decidable property.) For such TRSs, this class of terms satis es Axioms 1, 2 and 4, and so the genericity and consistency lemmas hold.

Opaque. This is a concept which applies to orthogonal rewrite systems. A closed

term is opaque if no term reachable from it is overlapped by any redex4. A general term is opaque if every closed instance is opaque. Axiom 1 holds by de nition. Axiom 2 is trivially true, since a proper subterm overlapping with a redex is not opaque. Axiom 4 is immediate from orthogonality. For the in nitary case we restrict attention to orthogonal systems. Axiom 1 implies the trans nite Axiom 1 by the remark at the end of section 5.1, because left-hand sides of rules are nite. Axiom 2 holds since opaque terms do not interfere in any way with their surrounding context. To prove Axiom 5, suppose that s and t are opaque, and C [s] is not. Then some instance C [s][x := r] = C [x := r][s[x := r]] is reducible to a term q which is overlapped by some redex. From Corollary 10, C [x := r][t[x := r]] is reducible to a term q0 such that q =U q0 . This implies that q0 is overlapped by the same redex as q, and hence that C [t] is not opaque.

!-unde ned. A nite term is !-unde ned if all terms reachable from it can be

decomposed into `redex compatible' parts ([Klo92, Def. 3.3.15]). Precisely, we add a nullary symbol !, and de ne the !-rule t ! ! if t can be transformed into a redex by replacing occurrences of ! by other terms. Every nite term t has a unique 4 In [AKK+ 94] the de nition of opaqueness is stated erroneously, but this is the concept

intended.

normal form !(t) by this rule. For an in nite term t, de ne !(t) to be the least upper bound of !(t0 ) for all nite approximations t0 to t (with respect to the partial ordering determined by 8t:!  t and the monotonicity of all function symbols). A term t is !-unde ned if for every reduct (by the ordinary rules) t0 of every instance of t, !(t0 ) = !. Axiom 2 is immediate. Axiom 1 is immediate in the nitary case, and is simple to prove in the trans nite case. Axiom 4 follows from orthogonality. To prove Axiom 5, suppose that s and t are !-unde ned, and C [s] is not. Then some instance C [s][x := r] = C [x := r][s[x := r]] is reducible to a term q for which !(q) 6= !. From Corollary 10, C [x := r][t[x := r]] is reducible to a term q0 such that q =U q0 . This implies that !(q0 ) 6= !, and hence that C [t] is not !-unde ned.

Root active. A term is root stable if it cannot be rewritten to a redex, and root active if it cannot be rewritten to a root stable term. Taking U to be the set of

root-active terms in an orthogonal TRS, Axiom 1 holds by de nition and Axiom 2 is trivially true, since a proper subterm overlapping with a redex is in root stable form, by orthogonality. Axiom 4 is likewise immediate. Axiom 5 follows by an argument similar to the cases of opaqueness and !-unde nedness. For non-orthogonal systems the genericity lemma fails, as witnessed by fA ! A; G(A) ! B g.

Hypercollapsing. If U is the set of hypercollapsing terms in an orthogonal TRS,

then Axiom 1 holds since by the parallel moves lemma, projecting an in nite rewrite over nitely many steps can erase only nitely many root collapsing steps. Axiom 2 holds by orthogonality. Axiom 4 is true by de nition. Axiom 5 follows by an argument similar to the previous cases. of opaqueness and !-unde nedness. For non-orthogonal systems the genericity lemma fails, as witnessed by fA ! H (A); H (x) ! x; G(A) ! B g.

6.2 Sets of meaningless lambda terms

The axioms are easily checked for many known notions of meaninglessness in lambda calculus ([Bar92, Ong88, Kup94, KKSdV96]). Some other classes known not to be good notions of meaninglessness violate one or more of the axioms.

Has no normal form/Has an in nite rewrite. As for the case of TRSs, neither

the class of terms having no normal form nor the class of terms having an in nite rewrite is generic. When lambda terms are restricted such that each abstracted variable occurs at least once in the body of the lambda term (Church's I -calculus [Chu41]), then the two classes coincide, and are generic, by an argument similar to the one for non-erasing orthogonal TRSs. In the trans nite I -calculus this does not hold, because of the same phenomenon of `pushing to in nity' that we saw for trans nite TRSs. Let =def (x:xx)(x:xx) and Y = f:(x:f (xx))(x:f (xx)). Then the function part of the redex (y:yx )Y does not have a normal form, but the whole redex trans nitely reduces to the in nite normal form x(x(x(: : :))).

Non-simply typable -terms The set of non-simply typable -terms is not generic. For example, the term (x:xx)I reduces to the totally meaningful term I , but if its non-typable subterm x:xx is replaced by K , the whole term is the totally meaningful term KI . All the axioms hold except for Axiom 1, as the nonsimply typable terms are clearly not closed under reduction. Zero terms. A zero term ([Bar92]) is a term which cannot be reduced to an abstraction. The terms, all of whose instances are zero terms, are the opaque terms of lambda calculus. These are easily shown to satisfy Axioms 1, 2, 3 and 4. To prove Axiom 5, the argument is similar to the way this was proved for notions of unde nedness in TRSs. Suppose that every instance of s and t is a zero terms, but some instance of C [s] is not, say, C [s][x := r] = C [x := r][s[x := r]]. Then C [x := r][s[x := r]] reduces to an abstraction y:r. By the lambda-calculus equivalent of Corollary 10, C [x := r][t[x := r]] is reducible to a term q such that y:r =U q. Since abstractions are not zero terms, q must be an abstraction. Therefore C [x := r][t[x := r]] is not a zero term, and C [t] is not in the class of meaningless terms.

Easy terms. t is an easy term if for every closed term s, the  -calculus plus the equation t = s is consistent [JZ85]. It is immediate that Axiom 1 holds. Axiom 3 holds, since t[x := r] = s follows from t = s if s is closed. To prove Axiom 4, suppose that t is hypercollapsing and s is closed, and that adding the axiom t = s allows a proof of K = I (where K = x:y:x and I = x:x). By con uence of beta reduction, such a proof must exist which begins with a series of beta-expansions on K, then uses the axiom t = s to replace some instance of t (or more generally, some reduct of some instance) by s, and then continues with more proof steps ending with I . Consider that use of the axiom and the beta expansion preceding it. We have r b etaC [t0 ] = C [s]. If the beta reduction takes place within t0 , then we can go from r to C [s] by a single application of the axiom. If it takes place outside t0 , then the redex is also present in C [s], and we can get from r to C [s] by rst applying the axiom t = s to each residual of t0 in r, and then beta-expanding to s. The redex cannot overlap t0 , since a reduct of an instance of a hypercollapsing term cannot be an abstraction. Therefore in all cases, the rst application of the axiom in a proof of K = I can be moved closer to the beginning. But the rst step in such a proof cannot be an application of the axiom, since K contains no easy subterms. To check Axiom 2, we must show that if an abstraction x:t is easy, then so is (x:t)s for any s. (x:t)s = r follows from t[x := s] = r. But t[x := s] is easy, therefore so is (x:t)s. We do not know the status of Axiom 5. Unusable. Consider the lambda calculus  with -rules of ([Kup95], [Kup94, Sec.

7.2]). De ne the notion of strict context thus: the empty context [ ] is a strict context, and if C [ ] is a strict context, then so are C [ ]s, x:C [ ] and FC [ ], for any term s, variable x and constant F . Then, a term s is usable if C [s] has a normal form for some strict context C [ ]. Axiom 1 holds by de nition and con uence. Axiom 2 for -redexes holds because this amounts to showing that if s is unusable, then st is unusable, which follows directly from the de nition of strict context. Axiom 3 holds because if s[x := t] is usable, then (x:s)t is, and by the de nition of strict context,

so is s. Axiom 4 holds since the unusable terms include the unsolvables, and rootactive terms are unsolvable. Axiom 5 is proved as before.

abc-active.(cf. [KKSdV96]) Given a string of three binary digits abc, there is a measure Dabc (s; ) of length of a position  of a term s: Dabc (s; ) =def 0 abc D (x:s; 0) =def a + Dabc (s; ) Dabc (st; 0) =def b + Dabc (s; ) Dabc (st; 1) =def c + Dabc (t; ) A term is (abc-)stable if it cannot be reduced to a term having a redex at abc-depth 0. It is (abc-)active if it cannot be reduced to a abc-stable term. Three particular

instances of these abstract concepts are well-known: 111-active is just another formulation of root-active, the 001-stable terms are exactly the terms having a head normal form, and the 101-stable terms are exactly the terms having a weak head normal form. For all depth measures, Axioms 1 and 4 are immediate from the de nitions. For depth measures 001, 101, and 111, the other axioms all hold. For all the other measures, at least one of them fails. Detailed proofs for each axiom and depth measure are given in [KvOdV96] From this we conclude that Genericity, Consistency, and the existence and uniqueness of Bohm trees hold for the measures 001, 101, and 111, for both nite and trans nite lambda calculus. This con rms the conclusion of [KKSdV96] that these are the only measures which yield well-behaved versions of in nitary lambda calculus.

Unsolvable/!-unde ned/001-active. A lambda term s is solvable ([Bar84]) if !I . Taking the there exist tuples x of variables and t of terms such that (x:s)t!

same de nition of !-unde nedness as for TRSs, it is not dicult to check that the unsolvable terms coincide with the !-unde ned ones. It is well-known that the unsolvable terms are exactly the terms without head normal form. This implies that unsolvability is equivalent to 001-active, treated above. Hence all axioms hold.

Strongly unsolvable/101-active. A term is strongly unsolvable ([Ong88, Sec.

2.1.1{2]) if it is a zero term and it is not convertible to a term of the form xs. That is, it has no weak head normal form, or equivalently it is a 101-active form, treated above. Hence all axioms hold.

Mute/hypercollapsing/root-active. A term is mute if it is a zero term which cannot be reduced to a variable or to an application of a zero term to any term [Ber]. This de nition is equivalent to the property of hypercollapsing or root-activeness, which in turn is equivalent to 111-activeness. All axioms hold.

7 Acknowledgements We thank Jan Kuper, Mizuhito Ogawa, and Femke van Raamsdonk for useful discussions, Zena Ariola, Jan Willem Klop, and Ronan Sleep for their earlier collaboration, and Stefan Kahrs and two anonymous referees for their detailed comments.

References [AGM92]

S. Abramsky, D. M. Gabbay, and T. S. E. Maibaum, editors. Handbook of Logic in Computer Science, volume 2, Background: Computational Structures. Oxford University Press, New York, 1992. [AKK+94] Z. M. Ariola, J. R. Kennaway, J. W. Klop, M. R. Sleep, and F. J. de Vries. Syntactic de nitions of unde ned: On de ning the unde ned. In Int. Symp. on Theoretical Aspects of Computer Software, Sendai, pages 543{554, 1994. Lecture Notes in Computer Science, vol. 789. [Bar84] H. P. Barendregt. The Lambda Calculus, Its Syntax and Semantics, volume 103 of Studies in Logic and the Foundations of Mathematics. Elsevier Science Publishers B.V., Amsterdam, revised edition, 1984. [Bar92] H. P. Barendregt. Representing `unde ned' in lambda calculus. Journal of Functional Programming, 2(3):367{374, July 1992. [Ber] A. Berarducci. In nite -calculus and non-sensible models. Presented to the conference in honour of Roberto Magari, Siena 1994. [Chu41] A. Church. The Calculi of Lambda Conversion. Princeton University Press, 1941. [DJ90] N. Dershowitz and J.-P. Jouannaud. Rewrite systems. In [Lee90, Ch. 6 pp. 243{320], 1990. [HS86] J. R. Hindley and J. P. Seldin. Introduction to Combinators and -Calculus, volume 1 of London Mathematical Society Students Texts. Cambridge University Press, 1986. [JZ85] J. G. Jacopini and M. Venturini Zilli. Easy terms in the lambda calculus. Fundamenta Informaticae, VIII, 1985. [KKSdV95a] J. R. Kennaway, J. W. Klop, M. R. Sleep, and F. J. de Vries. In nitary lambda calculus and Bohm models. In Proc. Conference on Rewriting Techniques and Applications, pages 257{270, 1995. Lecture Notes in Computer Science, vol. 914. [KKSdV95b] J. R. Kennaway, J. W. Klop, M. R. Sleep, and F. J. de Vries. Trans nite reductions in orthogonal term rewriting systems. Information and Computation, 119:18{38, 1995. [KKSdV96] J. R. Kennaway, J. W. Klop, M. R. Sleep, and F. J. de Vries. In nitary lambda calculus. Th. Comp. Sci., 1996. to appear. [Klo92] J. W. Klop. Term rewriting systems. In [AGM92, pp. 1{116], 1992. [Kup94] J. Kuper. Partiality in Logic and Computation, Aspects of Unde nedness. PhD thesis, Universiteit Twente, February 1994. [Kup95] J. Kuper. Proving the Genericity Lemma by leftmost reduction is simple. In Proc. Conference on Rewriting Techniques and Applications, pages 271{278, 1995. Lecture Notes in Computer Science, vol. 914. [KvOdV96] J. R. Kennaway, V. van Oostrom, and F. J. de Vries. abc-active terms in trans nite lambda calculus. Available by ftp from ftp://ftp.sys.uea.ac.uk/ pub/kennaway/publications/abcactive.dvi, 1996. [Lee90] J. van Leeuwen, editor. Handbook of Theoretical Computer Science, volume B: Formal Models and Semantics. Elsevier Science Publishers B.V., Amsterdam, 1990. [Ong88] C.-H. L. Ong. The Lazy Lambda Calculus: An Investigation into the Foundations of Functional Programming. PhD thesis, Imperial College of Science and Technology, University of London, May 1988. This article was processed using the LATEX macro package with LLNCS style