The problem of determining when two programs are equivalent is central in computer science. For instance, it is necessary to verify that the optimizations performed by a compiler actually preserve the meaning of the program. For -calculi, it has become standard to consider two -terms and as equivalent when they are contextually equivalent with respect to some fixed set of observables . This means that it is possible to plug either or into any context without noticing any difference in the global behaviour: produces a result belonging to exactly when does. The problem of working with this definition is that the quantification over all possible contexts is difficult to handle. Therefore, many researchers undertook a quest for characterizing observational equivalences both semantically, by defining fully abstract denotational models, and syntactically, by comparing possibly infinite trees representing possible program executions.
The most famous observational equivalence for the untyped -calculus is obtained by considering as observables the head normal forms, which are -terms representing stable amounts of information coming out of the computation. Introduced by Hyland  and Wadsworth , it has been ubiquitously studied in the literature [3, 17, 15, 36, 29, 6], since it enjoys many interesting properties. By definition, it corresponds to the extensional -theory which is the greatest consistent sensible -theory [3, Thm. 16.2.6]. Semantically, it arises as the -theory of Scott’s pioneering model , a result which first appeared in  and , independently. More recently, Breuvart provided in  a characterization of all -models that are fully abstract for . As shown in [3, Thm. 16.2.7], two -terms are equivalent in exactly when their Böhm trees are equal up to countably many possibly infinite -expansions.
However, the head normal forms are not the only reasonable choice of observables. For instance, the original extensional contextual equivalence defined by Morris in  arises by considering as observables the -normal forms, which represent completely defined results. We denote by the -theory corresponding to Morris’s observational equivalence111The notation has been introduced in , while the same theory is denoted in  and in .. The -theory is sensible and distinct from , so we have . Despite the fact that the equality in has been the subject of fewer investigations, it has been characterized both semantically and syntactically. In , Coppo et al. proved that corresponds to the -theory induced by a suitable filter model. More recently, Manzonetto and Ruoppolo introduced a simpler model of living in the relational semantics  and Breuvart et al. provided necessary and sufficient conditions for a relational model to be fully abstract for . From a syntactic perspective, Hyland proved in  that two -terms are equivalent in exactly when their Böhm trees are equal up to countably many -expansions of finite depth (see also [36, §11.2] and ).
We have seen that both observational equivalences correspond to some extensional equalities between Böhm trees. A natural question is whether can be generated just by adding -conversion to the -theory equating all -terms having the same Böhm tree. The -theory
so defined has been little studied in the literature, probably because it does not arise as an observational equivalence nor is induced by some known denotational model. In[3, Lemma 16.4.3], Barendregt shows that one -expansion in a -term can generate infinitely many finite -expansions on its Böhm tree . In [3, Lemma 16.4.4], he exhibits two -terms that are equal in but distinct in , thus proving that .
However, the -calculus also possesses another notion of extensionality, known as the -rule, which is strictly stronger than -conversion. Such a rule has been studied by many researchers in connection with several -theories [23, 1, 34, 4, 22]. Formally, the -rule states that for all -terms and , whenever holds for all closed -terms . A -theory satisfies the -rule whenever it is closed under such a rule. Since this is such an impredicative rule, we can meaningfully wonder how the -theory , obtained as the closure of under the -rule, compares with the other -theories. As shown by Barendregt in [3, Lemma 16.4.4], does not satisfy the -rule, while does [3, Thm. 17.2.8(i)].
Therefore, the three possible scenarios are the following:
In the seventies, Sallé was working with Coppo and Dezani on type systems for studying termination properties of -terms [37, 12]. In 1979, at the conference on -calculus that took place in Swansea, he conjectured that a strict inclusion holds. Such a conjecture was reported in the proof of [3, Thm. 17.4.16], but for almost fourty years no progress has been made in that direction. In this paper we demonstrate that the -theories and actually coincide, thus disproving Sallé’s conjecture. We now give an outline of the proof, discuss the results we need, the techniques we develop and the underlying ideas.
. The fact that the -theory is included in follows immediately if one can prove that satisfies the -rule. We notice that, on closed -terms, observational equivalences are equivalently defined by applicative contexts of shape , where the ’s are closed as well. Moreover, if satisfies the -rule, two closed are equated if they have the same observable behaviour in every non-empty applicative context. Whence, the key point in proving that is closed under the -rule is being able to complete any applicative context distinguishing from , to ensure that it is non-empty. For , this follows from Wadsworth’s characterization of -terms having a head normal form in terms of solvability: it is possible to find such that, say, is equal to the identity , while is unsolvable and can be chosen of any length by adding copies of at the end.
To prove that satisfies the -rule, we need to show something similar, namely that when has a -normal form while does not, we can find a non-empty context preserving this property. Interestingly, it is sufficient to prove this for -terms that are equated in the -theory ; in other words we need to perform a detailed analysis of the equations in . We show that when two closed -terms are equal in , but different in , their Böhm trees are similar but there exists a (possibly virtual) position where they differ because of an infinite -expansion of a variable , and such an -expansion follows the structure of some computable infinite tree . Thanks to a refined Böhm-out technique, we prove that it is always possible to extract such a difference by defining a suitable applicative context that sends into the identity and into some infinite -expansion of the identity (Theorem 5). This provides a separability theorem in the spirit of [18, 11, 14] but the notion of separability that we consider is weaker since it arises from Morris’s observability. We then prove that applying an infinite -expansion of the identity to itself, one still gets a (possibly different) infinite -expansion of . From this closure property we obtain that also in this case the length of the discriminating context can be chosen arbitrarily by adding copies of at the end. Once this property has been established, the fact that satisfies the -rule follows (Theorem 4.3).
. To prove this result we need to show that, whenever two -terms and are equal in , they are also equal in . From , we know that in this case there is a Böhm tree such that , where means that the Böhm tree can be obtained from by performing countably many finite -expansions. Thus, the Böhm trees of are compatible and have a common “-supremum” .
Our proof can be divided into several steps:
We show that the aforementioned -supremum is -definable: there exists a -term such that (Proposition 6).
We define a -term (Definition 5.3) taking as arguments (the codes of) two -terms and a stream (infinite sequence) of -terms. Assuming the Böhm tree of is more -expanded than the one of , i.e. , we show that:
Summing up, if are equal in , then by (1) there is a -term such that . By (2), has the same Böhm tree as when the stream is , and as when is . Symmetrically, has the same Böhm tree as , while has the same Böhm tree as . Since and are equal in by (3), we conclude (Theorem 6).
The intuition behind is that, working on their codes, the -term computes the Böhm trees of and , compares them, and at every position applies to the “smaller” (the less -expanded one) an element extracted from the stream in the attempt of matching the structure of the “larger” (the more -expanded one). If the stream contains all possible -expansions then each attempt succeeds, so computes the -supremum of and . If only contains infinitely many copies of the identity, each non-trivial attempt fails, and computes their -infimum.
A characterization of
The technique that we develop for -expanding Böhm trees in a controlled way is powerful enough to open the way for a characterization of as well. More precisely, we prove that two -terms and are equal in exactly when their Böhm trees are equal up to countably many -expansions of bounded size (Theorem 7.3). Indeed, in this case and admit an -supremum obtained from their Böhm trees by performing at every position at most -expansions, each having size bounded by . (In this context, the size of an -expansion is not the actual size of its tree but rather the maximum between its height and its maximal number of branchings.) It turns out that, when exploiting our -term to compute the -supremum, it only relies on a finite portion of the input stream . Since in any finite sequence is equal to the sequence and actually computes the -infimum, we obtain once again that the -supremum and the -infimum collapse. We can therefore proceed as in the proof sketched above for and conclude that and are equal in .
We build on the characterizations of and given by Hylandand Wadsworth [18, 19, 41] and subsequently improved by Lévy . In Section 2 we give a uniform presentation of these preliminary results using the formulation given in [3, §19.2] for , that exploits the notion of Böhm-like trees, namely labelled trees that “look like” Böhm trees but might not be -definable. Böhm-like trees were introduced in  since at the time researchers were less familiar with the notion of coinduction, but they actually correspond to infinitary terms coinductively generated by the grammar of -normal forms possibly containing the constant . It is worth mentioning that such characterizations of and have been recently rewritten by Severi and de Vries using the modern approach of infinitary rewriting [39, 40], and that we could have used their formulation instead.
A key ingredient in our proof of is the fact that -terms can be encoded as natural numbers, and therefore as Church numerals, in an effective way. This is related to the theory of self-interpreters in -calculi, which is an ongoing subject of study [31, 16, 35, 9], and we believe that the present paper provides a nice illustration of the usefulness of such interpreters. As a presentation choice, we decided to use the encoding described in Barendregt’s book [3, Def. 6.5.6], even if it works for closed -terms only, because it is the most standard. However, our construction could be recast using any (effective) encoding, like the one proposed by Mogensen in  that works more generally for open terms.
The present paper is a long version of the extended abstract  published in the Proceedings of the Second International Conference on Formal Structures for Computation and Deduction (FSCD) 2017. The primary goal of this article is to describe the mathematical context where Sallé’s conjecture has arisen, and provide a self-contained treatment of its refutation. Besides giving more detailed proofs and examples, we provide some original results only announced in , like the characterization of in terms of an extensional equality between Böhm trees up to bounded -expansions.
Notice that a proof-sketch of the fact that satisfies the -rule previously appeared in a conference paper written by the second and third authors in collaboration with Breuvart and Ruoppolo . Since the topic of that paper is mainly semantical we decided — in agreement with them — to exploit the present article to provide the missing details concerning Morris’s separability theorem. The semantic results contained in  are the subject of a different article  presenting more broadly the class of relational graph models and their properties.
The structure of the present paper is the following. Section 1 contains the preliminaries, mainly concerning the untyped -calculus — we present its syntax and recall several well-established properties. In Section 2, we review the main notions of extensional equalities on Böhm trees and provide a few paradigmatic examples. The key results concerning the -rule in connection with several -theories are presented in Section 3; we conclude the section by stating Sallé’s conjecture. Section 4 is devoted to studying the structural properties of the set of -expansions of the identity, introduce our version of the Böhm-out technique and present the weak separability theorem for Morris’s observability. As a consequence, we get that satisfies the -rule. In Section 5 we show how to build Böhm trees, and their -supremum and -infimum, starting from the codes of -terms and streams of -expansions of the identity. Section 6 is devoted to the actual proof of the refutation of Sallé’s conjecture. In Section 7 we provide a characterization of in terms of a notion of equality on Böhm trees up to bounded -expansions.
We review some basic notions and introduce some notations that will be used in the rest of the paper.
Throughout this paper, we often consider possibly infinite trees as coinductive objects and perform coinductive reasoning. Here we recall some basic facts and introduce some terminology, but we mainly assume that the reader is familiar with these concepts. If that is not the case, we suggest the following tutorials on the subject [24, 25].
A coinductive structure, also known as coinductive datatype, is the greatest fixed point over a grammar, or equivalently the final coalgebra over the corresponding signature. We also consider coinductive relations, that are the greatest relations over such coinductive structures that respect the structural constraints. A coinductive proof that two elements of the structures stand in relation to one another is given by an infinite derivation tree, which is a coinductive structure itself.
Since structural coinduction has been around for decades and many efforts have been made within the community to explain why it should be used as innocently as structural induction, in our proofs we will not reassert the coinduction principle every time it is used. Borrowing the terminology from , we say that we apply the “coinductive hypothesis” whenever the coinduction principle is applied. The idea is that one can appeal to the coinductive hypothesis as long as there has been progress in producing the nodes of a tree and there is no further analysis of the subtrees. We believe that this style of mathematical writing greatly improves the readability of our proofs without compromising their correctness; the suspicious reader can study  where it is explained how this informal terminology actually corresponds to a formal application of the coinduction principle.
1.2. Sequences, Trees and Encodings
We let be the set of all natural numbers and be the set of all finite sequences over . Given a sequence and we write for the sequence . Given two sequences we write for their concatenation. We will denote the empty sequence by .
We consider fixed an effective (bijective) encoding of all finite sequences of natural numbers . In particular, we assume that for all and the code is computable from and .
An (unlabelled) tree is a partial function such that is closed under prefixes and, for all we have . The subtree of at is the tree defined by setting for all .
The elements of are called positions. Notice that, in our definition of a tree , provides the number of children of the node at position ; therefore we have whenever the position corresponds to a leaf. A tree is called: recursive if the function is partial recursive (after coding using ); finite if is finite; infinite if it is not finite. We denote by (resp. ) the set of all (infinite) recursive trees.
1.3. The Lambda Calculus
We generally use the notation of Barendregt’s first book  for the untyped -calculus. Let us fix a denumerable set of variables.
The set of -terms (over ) is defined inductively by the following grammar:
We suppose that application associates to the left and has higher precedence than -abstraction. For instance, we write for the -term . We write as an abbreviation for , for , for and finally for ( times).
The set of free variables of and -conversion are defined as in [3, Ch. 1§2]. Given and we denote by the capture-free substitution of for all free occurrences of in . From now on, -terms are considered up to -conversion.
We say that a -term is closed whenever . In this case, is also called a combinator. We denote by the set of all combinators.
The -calculus is a higher order term rewriting system and several notions of reduction can be considered. Let us consider an arbitrary notion of reduction . The multistep -reduction is obtained by taking its reflexive and transitive closure. The -conversion is defined as the reflexive, transitive and symmetric closure of . We denote by the -normal form of , if it exists, and by the set of all -terms in -normal form.
In this paper we are mainly concerned with the study of - and - reductions.
The -reduction is the contextual closure of the rule:
The -reduction is the contextual closure of the rule:
We denote by the notion of reduction obtained from the union , and by (resp. ) the corresponding multistep reduction (resp. conversion). A -term in -normal form has the shape where each is in -normal form.
Concerning specific combinators, we use the following notations (for ):
where denotes syntactic equality (up to -conversion). The -term represents the identity, is a -expansion of the identity, is the composition combinator , and are the first and second projections, is the paradigmatic looping -term, is Curry’s fixed point combinator and is the combinator defined by Wadsworth in .
We denote by the -th Church numeral [3, Def. 6.4.4], by and the successor and predecessor, and by the -term -convertible to if and -convertible to otherwise. For , we denote by the numeral .
We encode the -tuple in -calculus by setting with . Thus, represents the pair [3, Def. 6.2.4]. An enumeration of closed -terms is called effective (or uniform in [3, §8.2]) if there exists such that . Given an effective enumeration as above, it is possible222One needs to use the fixed point combinator , as shown in [3, Def. 8.2.3]. to define the stream as a single -term satisfying . We often use the notation:
The -th projection associated with a stream is since .
The -terms are classified into solvable and unsolvable, depending on their capability of interaction with the environment.
A closed -term is solvable if for some . A -term is solvable if its closure is solvable. Otherwise is called unsolvable.
It was first noticed by Wadsworth in  that solvable terms can be characterised in terms of “head normalizability”. The head reduction is the notion of reduction obtained by contracting the head redex in a -term having shape . A -term is in head normal form (hnf, for short) if it has the form . The principal hnf of is the hnf (if it exists) obtained from by head reduction, i.e. ; it is unique since is deterministic. A -term has a head normal form if and only if exists. We denote by the set of all head normal forms.
A -term is solvable if and only if has a head normal form.
The typical example of an unsolvable is . The following result appears as Lemma 17.4.4 in  and shows that any can be turned into an unsolvable by applying enough ’s.
For all there exists such that is unsolvable.
1.5. Böhm(-like) trees
The Böhm trees were introduced by Barendregt , who named them after Böhm since their structure arises from the proof of the homonymous theorem .They are coinductively defined labelled trees representing the execution of a -term .
The Böhm tree of a -term is the coinductive structure defined by:
if is has a hnf and then:
otherwise is unsolvable and .
In Figure 1, we provide some examples of Böhm trees of notable -terms. Comparing the Böhm trees of and we note that both look like -expansions of the identity, but the former actually is, while the latter gives rise to infinite computations. Terms like are called “infinite -expansions” of the identity. A simple inspection of the Böhm tree of should convince the reader that the following lemma holds.
[cf. [3, 10.1.5(v)]] Let and be two effective enumerations.
The set of Böhm-like trees is coinductively generated by:
In [3, Def. 10.1.12], Böhm-like trees are labelled trees defined as partial functions mapping positions to pairs where is the number of children of the node labelled at . In a personal communication, Barendregt told us that the reason is twofold: firstly coinduction was not as well understood at the time he wrote that book as it is now; secondly speaking of functions makes it easier to define “partial computable” trees. Indeed, not all Böhm-like trees arise as a Böhm tree of a -term : by [3, Thm. 10.1.23], this is the case precisely when is partial computable and is finite.
Given we denote by its underlying naked tree, namely the (unlabelled) tree having the same structure as .
1.6. The Lattice of Lambda Theories
Inequational theories and -theories become the main object of study when one considers the computational equivalence between -terms as being more important than the process of computation itself.
A relation between -terms is compatible if it is compatible with lambda abstraction and application. We say that is a congruence if it is a compatible equivalence relation.
An inequational theory is any compatible preorder on containing the -conversion. A -theory is any congruence on containing the -conversion. Given an inequational theory , we write or when is smaller than or equal to in . For a -theory , and stand for .
The set of all -theories, ordered by set-theoretical inclusion, forms a complete lattice having a quite rich mathematical structure, as shown by Lusin and Salibra in .
A -theory (resp. inequational theory) is called:
consistent if it does not equate all -terms, inconsistent otherwise;
extensional if it contains -conversion;
sensible if it equates all unsolvable -terms.
We denote by
the least -theory,
the least extensional -theory,
the least sensible -theory,
the -theory equating all -terms having the same Böhm tree.
The -theory is sensible, but not extensional.
We let be the least extensional -theory containing the -theory .
It is well known that two -theories that coincide on closed terms must be equal. Hence we often focus on equalities between closed -terms.
Several interesting -theories are obtained through observational preorders that are defined with respect to some set of observables.
A context is a -term containing some occurrences of a “hole”, namely an algebraic variable denoted by . A context is called a head context if it has the shape for some and . A head context is called applicative if it has the shape and closed if all the ’s are closed.
Given a context and a -term , we write for the -term obtained from by replacing without renaming for the hole, possibly with capture of free variables in .
We write if there exists such that .
The -observational preorder is defined as follows:
The -observational equivalence is defined by setting if and only if both and hold.
It is easy to check that if and only if .
In the present paper we focus on the following observational preorders and equivalences.
Morris’s observational preorder and equivalence are generated by taking as the set of -normal forms .
These observational preorders and equivalences are easily proved to be inequational and -theories, respectively. (For the general case, one needs some hypotheses on the set of observables, as discussed in .) The -theory can be characterized as the (unique) maximal consistent sensible -theory [3, Thm. 16.2.6]. The proof extends easily to which is maximal consistent among sensible inequational theories [8, Lemma 2.3]. It follows that is extensional and . As -reduction is strongly normalizing, a -term has a -normal form if and only if it has a -normal form, therefore is extensional as well.
[Context Lemma] For or , the following are equivalent:
there exists a closed head context such that , while .
In particular, if and are closed then can be chosen closed and applicative.
The quantification over all possible (applicative) contexts makes these definitions difficult to handle in practice. That is the reason why researchers have looked for characterizations of and in terms of extensional equalities between Böhm trees.
2. Böhm Trees and Extensionality
We review three different notions of extensional equality between Böhm trees corresponding to the equality in and .
The following streams will be used as running examples in the rest of the section:
2.1. : Countably Many -Expansions of Bounded Size
Recall that is the least extensional -theory including . Except for some lemmas in [3, §16.4], the -theory has been mostly neglected in the literature, probably because it does not arise as the theory of any known denotational model. Perhaps, one might be led to think that entails that the Böhm trees of and differ because of finitely many -expansions. In reality, one -expansion of can generate countably many -expansions in its Böhm tree.
A typical example of this situation is the following:
thus and are equated in despite the fact that their Böhm trees differ by infinitely many -expansions. More precisely, entails that can be obtained from by performing at most one -expansion at every position. [[3, Lemma 16.4.3]] If , then is obtained from by replacing in the latter some
possibly infinitely often (but simultaneously, thus without -expanding the new variable ).
In particular, no finite amount of -expansions in can turn its Böhm tree into , which has infinitely many -expansions of increasing size.
, while .
2.2. : Countably Many Finite -Expansions
By definition, is the -theory corresponding to Morris’s original observational equivalence where the observables are the -normal forms . The -theory and its inequational version have been studied both from a syntactic and from a semantic point of view. We refer to [18, 27, 13] for some standard literature and to [30, 7] for more recent work. The properties that we present here can be found in [36, §11.2]. Two -terms having the same Böhm tree cannot be distinguished by any context , so we have . Since is an extensional -theory, we get .
The question naturally arising is whether there are -terms different in that become equal in . It turns out that holds exactly when and are equal up to countably many -expansions of finite size. A typical example of this situation is given by the streams and since the Böhm tree of the latter can be obtained from the Böhm tree of the former by performing infinitely many finite -expansions.
Given two Böhm-like trees and , we define coinductively the relation expressing the fact that is a finitary -expansion of . We let be the greatest relation between Böhm-like trees such that entails that
or, for some :
where , for all and for all .
It is easy to check that holds.
For , we write if and only if .
Note that and entail , therefore the equivalence corresponding to and capturing needs to be defined in a more subtle way.
This means that in general, when , one may need to perform countably many -expansions of finite size both in and in to find the common “-supremum”.
, while .
2.3. : Countably Many Infinite -Expansions
The -theory and its inequational version are, by far, the most well studied theories of the untyped -calculus [3, 17, 15, 36, 29, 6]. Recall that corresponds to the observational equivalence where the observables are the head normal forms. Two -terms are equated in if their Böhm trees are equal up to countably many -expansions of possibly infinite depth. The typical example is .
Given two Böhm-like trees and , we define coinductively the relation expressing the fact that is a possibly infinite -expansion of . We let be the greatest relation between Böhm-like trees such that entails that
or (for some ):
where , for all and for all .
For instance, we have . For , we write if and only if . Given two Böhm-like trees and we write whenever results from by replacing some subtrees by (possibly infinitely many).
if and only if there exist two Böhm-like trees such that .
if and only if there exists a Böhm-like tree such that .
Exercise 10.6.7 in Barendregt’s book  consists in showing that the -supremum in item 2 above can always be chosen to be the Böhm tree of some -term. As we will prove in Section 6, this property also holds for the Böhm-like tree of Theorem 2.2.
are all equal in . However, and , so we have .
3. The Omega Rule and Sallé’s Conjecture
The -calculus possesses a strong form of extensionality which is known as the -rule [3, Def. 4.1.10]. The -rule has been extensively investigated in the literature by many authors [23, 1, 34, 4, 22]. Intuitively the -rule mimics the definition of functional equality, namely it states that two -terms and are equal whenever they coincide on every closed argument .
The -rule is given by:
We write for the -rule restricted to .
We say that a -theory