Nominal Coalgebraic Data Types with Applications to Lambda Calculus
Alexander Kurz, Daniela Luan Petrişan, Paula Severi, Fer-Jan de Vries
NOMINAL COALGEBRAIC DATA TYPES WITH APPLICATIONS TOLAMBDA CALCULUS
ALEXANDER KURZ, DANIELA PETRIS¸AN, PAULA SEVERI, AND FER-JAN DE VRIESDepartment of Computer Science, University of Leicester, Leicester, UK e-mail address : { ak155, ps65, fdv1 } @mcs.le.ac.uk, [email protected] Abstract.
We investigate final coalgebras in nominal sets. This allows us to definetypes of infinite data with binding for which all constructions automatically respect alphaequivalence. We give applications to the infinitary lambda calculus.
Contents
1. Introduction 22. Preliminaries on Algebra and Coalgebra 63. Preliminaries on Infinitary Lambda Calculus 73.1. Infinitary Terms as a Final Coalgebra 73.2. Computing the Infinite Normal Forms using Corecursion 84. Preliminaries on Nominal Sets 115. Alpha Corecursion Principle for Nominal Coalgebraic Data Types 155.1. Final Coalgebras of
Nom
Functors 155.2. Nominal Algebraic Data Types for Binding Signatures 185.3. An abstract account of α -equivalence. 215.4. Problems with Alpha Equivalence in the Infinitary Case 225.5. Nominal Coalgebraic Data Types for Binding Signatures 245.6. Presenting Limits in Nominal Sets 296. Applications 406.1. Substitution on an Arbitrary Coalgebraic Data Type 406.2. Substitution on α -Equivalence Classes of Infinitary λ -Terms 426.3. Computing the Infinite Normal Form of α -Equivalence Classes of λ -Terms 446.4. Nominal Sets of Infinite Normal Forms and Bisimulations 456.5. Infinitely Many Free Variables 487. Related and Future Work 49Acknowledgements 50References 50 [ Theory of computation ]: Semantics and reasoning—Program semantics—Algebraicsemantics.
Key words and phrases: coinduction, corecursion, nominal sets, infinitary lambda calculus.
LOGICAL METHODS l IN COMPUTER SCIENCE DOI:10.2168/LMCS-9(4:20)2013 c (cid:13)
A. Kurz, D. Petri¸san, P. Severi, and F.-J.!de Vries CC (cid:13) Creative Commons
A. KURZ, D. PETRIS¸AN, P. SEVERI, AND F.-J.!DE VRIES Introduction
We investigate types of infinite data with binding. A leading example is the infinitary λ -calculus. To construct explicitly a domain of infinitary λ -terms, one usually starts from finite λ -terms and then applies two constructions: Metric completion to obtain infinite terms andquotienting up to α -equivalence. Although each of these constructions appear to be routine,we show that their combination is more subtle than one might think at first. For example,one either needs to assume uncountably many variables or find a solution to the problemthat, in the case of countably many variables, metric completion does not commute withquotienting by α -equivalence. On the other hand, general principles suggest to constructinfinitary λ -terms more abstractly as final coalgebras in the category of nominal sets. Itallows us to treat infinitary data types with binding in general and provides a principle ofdefinition and proof by coinduction. We also show that the syntactic approach of completingand quotienting agrees with the semantic approach of final coalgebras in nominal sets.To summarise, the paper contributes to coalgebra, to nominal sets, and to the infinitary λ -calculus. To coalgebra, by showing that as for coalgebras over sets also over nominal setswe obtain from finality a definition and proof principle of coinduction. To nominal sets,by investigating limits and introducing notions of safe maps and bound variables. To theinfinitary λ -calculus, by clarifying the fundamental constructions in the case of countablymany variables and by showing that the informal reasoning with α -equivalence classes ofinfinitary λ -terms is indeed mathematically precise.In the remainder of the introduction we outline the contents of the paper. Nominal sets were introduced in [GP99], but see also [Hof99, FPT99] for related proposals.Roughly speaking, a nominal set is a set X equipped with an action of a set of permutationson some countably infinite set V of ‘names’ or ‘variables’. One can then define the support of some x ∈ X as the smallestset of variables on which x depends (we review the precise definitions in Section 4), thusgiving an abstract account of the ‘free variables’ in x . It is characteristic of nominal setsthat all elements have finite support. In other words, modelling syntax in nominal setsrequires us to only consider terms with finitely many free variables. But, and this is one ofthe themes of this paper, it is possible to have terms with infinitely many bound variables.(The question what may constitute an abstract account of bound variables in nominal setswill be discussed in Section 5.6.) Variable binding in nominal sets can be described by a type constructor X [ V ] X whichcan be understood as a quotient V × X → [ V ] X identifying elements ( v, x ) up to α -equivalence, that is, up to renaming of the ‘bound’variable v . For example, whereas λ -terms are given by the initial algebra of the functor L X = V + V × X + X × X (1.1)it was shown in [GP99] that λ -terms up to α -equivalence are given by the initial algebra ofthe functor L α X = V + [ V ] X + X × X (1.2) OMINAL COALGEBRAIC DATA TYPES WITH APPLICATIONS TO LAMBDA CALCULUS 3
Alpha-structural recursion [Pit05, Pit06, Pit11] is the induction principle that ensuesfrom syntax as an initial algebra in the category
Nom of nominal sets. For example, theclassic definition of substitution in the λ -calculus [Bar84] y [ x := N ] = N if y = x,y otherwise , ( P Q )[ x := N ] = ( P [ x := N ] Q [ x := N ]) , ( λy.P )[ x := N ] = λy. ( P [ x := N ]) if y fv ( N ) ∪ { x } . (1.3)is not an inductive definition in the usual sense. Because of the side condition, substitutionis only a partial function on raw terms. But, as explained in detail in [Pit05], (1.3) is aninductive definition according to (1.2). Moreover, [Pit05] establishes a general inductionprinciple for inductively defined data types with variable binding, explaining when partiallydefined functions in Set give rise to totally defined functions in
Nom . Alpha-structural corecursion introduced in this paper is the analogue of α -structuralrecursion for coinductive datatypes. For example, in the study of the infinitary λ -calculus[KKSdV95, KKSdV97, KdV03], which we review in Section 3, one is interested in thefinal coalgebra of L α . We describe the corecursion principle ensuing from final coalgebrasin nominal sets and show that (1.3) is indeed a coinductive definition of substitution forinfinitary λ -terms. Infinitely many free variables in a term (Section 5.4), which do appear if we takethe final coalgebra of L in sets, pose a problem. To see this, note that (1.3) becomes aninductive definition by choosing a suitable representative λy.P such that y fv ( N ) ∪ { x } .This approach is not immediately viable for the infinitary λ -calculus, because we may haveterms that exhaust all the available variables, so that we cannot find a fresh y . For example,consider the infinite λ -term allfv = x ( x ( x ( . . . ))) which contains all variables from V . Inthe following β -step ( λx x .x x ) allfv → β ( λx .x x )[ x := allfv ] (1.4)we have that x ∈ fv ( allfv ) and, therefore, the x in λx .x x should be replaced by somefresh variable, which is impossible because allfv contains all of them [Sal01]. Restricting to finitely many free variables , as opposed to allowing V to be uncountable,is the solution adopted in this paper (but we will come back to infinitely many free variablein Section 6.5). That is, in our example, we will consider the setΛ ∞ ffv = { M ∈ Λ ∞ | fv ( M ) is finite } (1.5)of λ -terms with finitely many free variables , avoiding terms such as allfv . On the one hand,finitely many free variables are sufficient in order to capture the infinite normal forms ofterms representing programs, since the limit of an infinite β -reduction sequence starting froma finite term has always a finite number of free variables. On the other hand, restricting tofinitely many free variables has the advantage of allowing us to work with nominal sets. Infinitely many bound variables must be allowed, since additional fresh variables maybe needed at each β -reduction step to avoid capture. For example, consider the finite term A. KURZ, D. PETRIS¸AN, P. SEVERI, AND F.-J.!DE VRIES
Pinfbv ≡ fix ( λf xy.xy ( f ( xy ))) which has the following reduction sequence: Pinfbv →→ β λxy.xy ( Pinfbv ( xy ))= α λx x .x x ( Pinfbv ( x x )) →→ β λx x .x x ( λy.x x y ( Pinfbv ( x x y )))= α λx x .x x ( λx .x x x ( Pinfbv ( x x x ))) →→ β λx x .x x ( λx .x x x ( λy.x x x y ( Pinfbv ( x x x y ))))= α λx x .x x ( λx .x x x ( λx .x x x x ( Pinfbv ( x x x x ))))...The limit of the above sequence is the infinite term: infbv ≡ λx .λx .x x ( λx .x x x ( λx .x x x x ( . . . ))) . The term infbv has an infinite number of bound variables. All the terms in its α -equivalenceclass have an infinite number of bound variables. The different classes of λ -terms arising from the discussion above are summarisedin the following picture, which is one of the contributions of our work. Previous work oninfinitary λ -calculus either assumed uncountably many variables or did not make the carefuldistinctions discussed below.Λ / / / / (cid:15) (cid:15) (cid:15) (cid:15) Λ ∞ (cid:15) (cid:15) (cid:15) (cid:15) Λ ∞ ffv (cid:15) (cid:15) (cid:15) (cid:15) ? _ o o Λ ∞ / = α (cid:15) (cid:15) (cid:15) (cid:15) Λ ∞ ffv / = α ∼ = (cid:15) (cid:15) ( ∗ )Λ / = α / / / / (Λ / = α ) ∞ (Λ / = α ) ∞ fs ? _ o o (1.6)In the diagram, Λ denotes the set of finite λ -terms. Vertical arrows / / / / denote quoti-enting by α -equivalence. Infinitary λ -terms are constructed by metric completions / / / / .The rightmost column arises from maps ? _ o o that restrict to terms with finitely manyfree variables. Going first right and then down in the diagram means to first complete toinfinitary terms and then to quotient by α -equivalence, whereas going first down and thenright, means to first quotient and then to complete. If both ways of constructing infini-tary terms up-to α -equivalence coincide, then we say that metric completion commutes withquotienting by α -equivalence. The two main results here are the following. • The vertical map in the middle column Λ ∞ → (Λ / = α ) ∞ is not onto (Example 5.20),hence metric completion and quotienting by α -equivalence do not commute for terms withcountably many free variables (as opposed to the case of uncountably many variables, seeTheorem 5.19). • The vertical map Λ ∞ ffv → (Λ / = α ) ∞ fs in the right-hand column is onto [KPSdV12, The-orem 22], in other words, restricted to terms with finitely many free variables, the twooperations of metric completion and quotienting by α -equivalence do commute. OMINAL COALGEBRAIC DATA TYPES WITH APPLICATIONS TO LAMBDA CALCULUS 5
Nominal coalgebraic datatypes for a binding signature (Section 5.5) generalise (1.6)to the diagram below (where we omitted the middle row obtained from epi-mono factorisa-tions). T Σ / / / / (cid:15) (cid:15) (cid:15) (cid:15) T ∞ Σ (cid:15) (cid:15) ( T ∞ Σ ) ffv (cid:15) (cid:15) (cid:15) (cid:15) ? _ o o ( ∗ ) T Σ / = α / / / / ( T Σ / = α ) ∞ ( T Σ / = α ) ∞ fs ? _ o o (1.7)Σ is a so-called binding signature [FPT99] and T Σ and T Σ / = α are initial algebras. Themiddle column of metric completions arises via unique arrows / / / / from an ω -colimitinto an ω op -limit as in [Bar99, Proposition 3.1]. In the right-hand column, ( T Σ / = α ) ∞ fs isthe final coalgebra in Nom and ( T ∞ Σ ) ffv can be defined as making the right-hand squareinto a pullback. The theorem that metric completion commutes with quotienting by α -equivalence then follows from one of our main technical contributions, namely thatpulling back the (not necessarily surjective) middle vertical arrow T ∞ Σ → ( T Σ / = α ) ∞ along( T Σ / = α ) ∞ ( T Σ / = α ) ∞ fs ? _ o o yields a surjection ( T ∞ Σ ) ffv → ( T Σ / = α ) ∞ fs . Representing limits in nominal sets (Section 5.6) provides the setting which enablesus to give a semantic proof of the result discussed in the previous paragraph. To see theconnection, denote by U : Nom → Set the forgetful functor and use the (well-known) resultthat the middle column of (1.7) arises as limits of ω op -chains as depicted in U X o o (cid:15) (cid:15) (cid:15) (cid:15) U X o o (cid:15) (cid:15) (cid:15) (cid:15) U X o o (cid:15) (cid:15) (cid:15) (cid:15) · · · o o lim U X n (cid:15) (cid:15) o o ? _ P ( ∗ ) (cid:15) (cid:15) (cid:15) (cid:15) U Y o o U Y o o U Y o o · · · o o lim U Y n o o ? _ U lim Y n (1.8)Similarly, the bottom right-hand corner of (1.7) is given by the limit in Nom of the lowersequence. The question whether metric completion commutes with α -equivalence now be-comes an instance of a more general question. Given an ω op -sequence of surjections X n → Y n in Nom , can the limit lim Y n in Nom be represented by a surjection P → U lim Y n , where P is defined to be the pullback ( ∗ )? A careful analysis of this situation is carried out inSection 5.6. In particular, the notions of safe squares, safe maps and of the bound variablesrelative to a map are introduced and it is shown that P → U lim Y n is onto if all verticalmaps and squares in the chain are safe. We also explore the relationship between safe mapsand maps with orbit-finite fibres. As applications , we give a general definition of substitution on the final coalgebra comingfrom a binding signature. We also give corecursive definitions of various notions of infinitenormal form (B¨ohm, L´evy-Longo and Berarducci trees) on α -equivalence classes of terms.We also show a solution, suggested to us by Pitts, of how to treat infinitely many freevariables in nominal sets. Related Work.
This paper generalises [KPSdV12, Theorem 22] from the particular func-tor describing λ -calculus to arbitrary binding signatures. Along with this generalisationwe replaced the syntactic proof (depending on a concrete presentation of the functor) of[KPSdV12, Theorem 22] with a semantic argument for the generalised Theorem 5.34 of thispaper. In particular, the new material in Section 5.6 allows us to show that all elements of A. KURZ, D. PETRIS¸AN, P. SEVERI, AND F.-J.!DE VRIES the final coalgebra are presented by infinite terms with finitely many free variables, usingonly semantic (that is, category theoretic) properties of the
Nom -endofunctors of (5.4).2.
Preliminaries on Algebra and Coalgebra
Finite data types, or algebraic data types , can be studied as initial algebras for functorson different categories. Consider an endofunctor F on a category C and an object X of C .An F -algebra ( X, α ) with carrier X is a C -morphism α : F X → X . Given two F -algebras( X, α ) and (
Y, β ) an F -algebra morphism is an arrow f : X → Y such that f ◦ α = β ◦ F f .The F -algebras thus form a category. One can prove the existence of an initial object inthis category under certain assumptions on the cocompleteness of C and on the “size” ofthe functor F . Assume that C has colimits. Then we can consider the following sequence,starting from the initial C -object 0.0 ! / / F F ! / / F F ! / / . . . / / F ω / / · · · (2.1)Above ! : 0 → F F
0. When we reach a limitordinal α we define F α β<α F β
0. The colimit of this sequence, when it exists, isthe carrier of the initial F -coalgebra. Notice that for each ordinal ι we have a canonicalmap from F ι F preserves colimits of ω -chains,then the initial F -algebra is F ω ω -chains are an example of a well studied class of colimits, namely filteredcolimits [AR94]. Recall that a filtered colimit is a colimit of a diagram J : D → C where D is a category such that any finite diagram in D has a cocone. Functors that preserve filteredcolimits are called finitary . Finitary functors have an initial algebra and the computationof the colimit of the initial chain stops after ω steps. Infinitary data types, or coalgebraic data types , are understood as final coalgebras forsuitable functors. An F -coalgebra ( X, ξ ) is defined as an arrow ξ : X → F X . A coalgebramorphism between (
X, ξ ) and (
Y, ζ ) is a C -morphism f : X → Y such that F f ◦ ξ = ζ ◦ f .Similarly to the initial algebra situation, we can consider the final sequence1 F o o F F ! o o . . . o o F ω o o · · · o o (2.2)where 1 is the final C -object and ! is the unique arrow from F C haslimits. For limit ordinals we compute the limit of the diagram constructed previously. Thelimit of the final sequence, if it exists, is the carrier of the final coalgebra. Therefore, functorsthat preserve limits of ω op -chains, sometimes called continuous , have a final coalgebra whosecarrier is F ω
1. We also have canonical maps from the final coalgebra to each F ι ι . The metric completion of F ω F ω
1, see Barr [Bar99, Proposition 3.1]. Inmore detail, if F is an endofunctor on Set and F F ω F ω
0. The metric on F ω p n : F ω → F n
1. Explicitly, for t, t ′ ∈ F ω d ( t, t ′ ) = 2 − max { n | p n t = p n t ′ } . OMINAL COALGEBRAIC DATA TYPES WITH APPLICATIONS TO LAMBDA CALCULUS 7 Preliminaries on Infinitary Lambda Calculus
Infinitary Terms as a Final Coalgebra.
We assume familiarity with basic notionsand notations of the finite λ -calculus [Bar84]. The set Λ of finite λ -terms is defined byinduction from the grammar: M ::= x | ( λx.M ) | ( M M ) (3.1)where x ranges over a given set V of variables.First we explain how the set Λ ∞ of finite and infinite λ -terms can be constructed as themetric completion of the set Λ of finite λ -terms. Then we will briefly recall some notionsand facts of infinitary λ -calculus [KKSdV97, KdV03]. The notion of α -equivalence will begiven in Definitions 5.11 and 5.17.The idea of putting a metric on a set of terms goes at least back to Arnold and Ni-vat [AN80]. To do so we define truncations. Definition 3.1 (Truncation) . The truncation of a term M ∈ Λ at depth n ∈ N is definedby induction on n : M = ∗ ,M n +1 = x if M = x ∈ V ,λx.N n if M = λx.N ,N n P n if M = N P . (3.2)where ∗ is any constant not appearing in the syntax of the λ -calculus, for example ∅ . Definition 3.2 (Metric) . We define a metric d : Λ × Λ → [0 ,
1] by d ( M, N ) = 2 − m , (3.3)where m = sup { n ∈ N | M n = N n } and we use the convention 2 −∞ = 0.In fact, (Λ , d ) is an ultrametric space, since for all M, N, P ∈ Λ we have d ( M, N ) ≤ max { d ( M, P ) , d ( P, N ) } , as one can easily check.The set Λ ∞ of finite and infinite λ -terms is now defined as the metric completion ofthe set Λ of finite terms with respect to the metric d . Alternatively, Λ ∞ can be defined byinterpreting (3.1) as a coinductive definition. The fact that both definitions coincide is aconsequence of Barr’s theorem on final coalgebras for bicontinuous Set endofunctors.Indeed, interpreting (3.1) coinductively amounts to taking as λ -terms the elements ofthe final coalgebra for the Set -endofunctor
L X = V + V × X + X × X. (3.4)Notice that the set Λ of finite λ -terms constitutes the initial algebra for L . A closer lookat the proof of Barr [Bar99, Theorem 3.2 and Proposition 3.1] shows now that the metric d on Λ of Definition 3.2 coincides with the metric induced by the final coalgebra. Hence,by [Bar99, Proposition 3.1], the completion of the initial L -algebra Λ in the metric d is thefinal L -coalgebra.To summarise, the final L -coalgebra (Λ ∞ , unfold : Λ ∞ → L (Λ ∞ )) is the Cauchy com-pletion of Λ and we have a dense inclusion map ι : Λ → Λ ∞ . It is well-known that the A. KURZ, D. PETRIS¸AN, P. SEVERI, AND F.-J.!DE VRIES structure map of the final coalgebra unfold : Λ ∞ → L (Λ ∞ ) is an isomorphism, hence theset L (Λ ∞ ) can be equipped with a complete metric. The map unfold : Λ ∞ → L (Λ ∞ ) is theunique uniformly continuous map from Λ ∞ to L (Λ ∞ ) making diagram (3.5) commutative:Λ ι (cid:15) (cid:15) ≃ / / L (Λ) L ( ι ) (cid:15) (cid:15) Λ ∞ unfold / / L (Λ ∞ ) (3.5)Having defined the set Λ ∞ of finite and infinite λ -terms we now extend the usualsyntactic conventions for finite λ -calculus to infinitary λ -calculus. Terms and variables willrespectively be written with (super- and subscripted) letters M, N and x, y, z . Terms of theform ( M M ) and ( λx.M ) will respectively be called applications and abstractions.The truncation of an infinite term M ∈ Λ ∞ at depth n is defined just as in Definition 3.1by induction on n . Observe that ( M n ) n ∈ N is a Cauchy sequence in (Λ ∞ , d ) that convergesto M .The set of free and bound variables of a finite term M is defined as usual and denotedby fv ( M ) and bv ( M ) respectively. We extend fv ( M ) , bv ( M ) to infinitary terms M ∈ Λ ∞ using truncations by fv ( M ) = S n ∈ N fv ( M n ) bv ( M ) = S n ∈ N bv ( M n ) . Also, var ( M ) = fv ( M ) ∪ bv ( M ).We define β -reduction on Λ ∞ and denote it as → β in the usual way: the smallestrelation that contains ( λx.P ) Q → β P [ x := Q ] and is closed under contexts. The reflexiveand transitive closure of → β is denoted by →→ β . For the definition of →→→ β that assumes asequence of reduction steps of any ordinal length, see for instance [KKSdV95]. Terms ofthe form ( λx.P ) Q are called redexes. Normal forms are terms without redexes and hencecannot be changed by further computation.The definition of infinitary λ -calculus is completed by enriching the syntax (3.1) witha fresh constant ⊥ and then adding ⊥ -reduction, denoted by → ⊥ , defined as the smallestrelation closed under contexts and containing M → ⊥ ⊥ for M belonging to some fixed set U of meaningless terms . If and only if the set U satisfies certain properties, the resultinginfinitary calculus is confluent and normalising, in which case each term has a unique normalform [KKSdV97, KdV03, SdV11].3.2. Computing the Infinite Normal Forms using Corecursion.
The normal formof a λ -term can be thought to represent its meaning, the maximal amount of informationembodied in the term, stable in the sense that it cannot be changed by further computation.Note that this concept of meaning depends on the chosen set U of meaningless terms forwhich there is ample, uncountable choice [SdV11].For concrete sets of meaningless terms an alternative, “informal” corecursive definitionof the normal form of a term in the corresponding infinitary λ -calculus can sometimes begiven. Three of them are well known and they are recalled in (3.6), (3.7) and (3.8).In his book [Bar84], Barendregt argued that the terms without head normal formsshould be considered as meaningless terms. Any finite λ -term is either a head normalform (hnf), that is, a term of the form λx . . . λx n .xN . . . N m , or it is a term of the form λx . . . λx n . (( λy.P ) Q ) N . . . N m where the redex ( λy.P ) Q is called the head redex. Startingwith a term M that is not in hnf one can repeatedly contract the head redex. Either this will OMINAL COALGEBRAIC DATA TYPES WITH APPLICATIONS TO LAMBDA CALCULUS 9 go on forever or terminate with a hnf, which represents part of the information embodiedin a term. In the latter case one can repeat this process on the subterms N i to try tocompute more information. This idea led Barendregt to his elegant “informal” definition ofthe B¨ohm tree BT ( M ) of a term M , that we now recognise as a corecursive definition. BT ( M ) = λx . . . λx n .yBT ( M ) . . . BT ( M m ) , if M →→ β λx . . . λx n .yM . . . M m , ⊥ otherwise . (3.6)The image of BT is denoted as BT and can be explicitly defined as follows. Definition 3.3 (Set of B¨ohm trees) . The set BT of B¨ohm trees is defined as the maximalset such that for all M ∈ BT , either M = ⊥ or M = λx . . . λx n .yM . . . M m where M , . . . , M m ∈ BT for some m, n ≥ BT is an infinitary lambda term over the syntax (3.1) enrichedwith ⊥ .Taking for U the set of terms without hnf, one can show using the confluence prop-erty that the normal forms of the corresponding infinitary λ -calculus satisfy the equationsin (3.6). That is, the B¨ohm tree of a term M is the normal form of M in the infinitary λ -calculus that equates all terms without head normal form with ⊥ [Bar84, KKSdV97].Alternatively, as Abramsky has forcefully argued in [Abr90], one can take the set ofterms without weak head normal form (whnf) as set of meaningless terms. Any finite λ -termis either a weak head normal form, that is, a term of either of the two forms xM . . . M m ,or λx.N , or it is a term of the form (( λy.P ) Q ) M . . . M m where the redex ( λy.P ) Q is calledthe weak head redex. In perfect analogy with before, starting with a term M that is notin whnf one can repeatedly contract the weak head redex. Either this will go on forever orterminate with a whnf. In the latter case one can repeat this process on the subterms M i ofthe tail of the whnf or on the subterm N of its body to try to compute more information.This describes a lazy computation strategy, that postpones reduction under abstractions asmuch as possible.The normal forms of the corresponding infinitary λ -calculus that equates all termswithout weak head normal form with ⊥ satisfy the equations (3.7) that define the L´evy-Longo tree LLT ( M ) of a term M corecursively [Lon83, L´ev76, AO93, KKSdV97]. LLT ( M ) = yLLT ( M ) . . . LLT ( M m ) if M →→ β yM . . . M m ,λx.LLT ( N ) if M →→ β λx.N, ⊥ otherwise . (3.7)The image of LLT is denoted as
LLT and can be explicitly defined as follows.
Definition 3.4 (Set of L´evy-Longo trees) . The set
LLT of L´evy-Longo trees can be definedas the maximal set that satisfies that whenever M ∈ LLT then M has one of the followingshapes:(1) either M = ⊥ , or(2) M = λx.N for some N ∈ LLT , or(3) M = yM . . . M n for some M , . . . , M n ∈ LLT . Term B¨ohm tree L´evy-Longo tree Berarducci tree
M BT ( M ) LLT ( M ) BeT ( M ) fix x x ( x ( x ( . . . ))) x ( x ( x ( . . . ))) x ( x ( x ( . . . ))) fix ( λyx.xy ) λx .x ( λx .x ( . . . )) λx .x ( λx .x ( . . . )) λx .x ( λx .x ( . . . )) λx. Ω ⊥ λx. ⊥ λx. ⊥ fix ( λxy.x ) ⊥ λx λx λx . . . λx λx λx . . . ΩΩ ⊥ ⊥ ⊥⊥ fix ( λy.yx ) ⊥ ⊥ ((( . . . ) x ) x ) x )Figure 1: Examples of B¨ohm, L´evy-Longo and Berarducci treesThe least set of meaningless terms that gives rise to a confluent and normalising infini-tary λ -calculus is the set of terms without a top normal form. Here a term M is a top normalform (tnf) if it is either a variable, an abstraction or an application of the form M M inwhich M is a zero term , i.e. a term that cannot reduce to an abstraction. The well-knownterm Ω = ( λx.xx )( λx.xx ) has no tnf. The normal forms of this calculus can alternativelybe characterised by the corecursive definition of the Berarducci tree [Ber96, KKSdV97] BeT ( M ) of a term M : BeT ( M ) = x if M →→ β x,λx.BeT ( N ) if M →→ β λx.N,BeT ( N ) BeT ( P ) if M →→ β N P and N is a zero term , ⊥ otherwise , (3.8)The image of BeT is denoted as B e T and can be explicitly defined as follows. Definition 3.5 (Set of Berarducci trees) . The set B e T of Berarducci trees can be definedas the maximal set that satisfies that whenever M ∈ B e T then M has one of the followingshapes:(1) M = λx.N for some N ∈ B e T , or(2) M = yM . . . M n for some M , . . . , M n ∈ B e T , or(3) M = ⊥ M . . . M n for some M , . . . , M n ∈ B e T , or(4) M = (( . . . ) M ) M for some ( M i ) i ≥ such that M i ∈ B e T for all i ≥ L -coalgebra, pro-vided we give concrete reduction strategies to compute the various forms used in the defini-tions. However, in order to take into account α -equivalence, we will prove an α -corecursionprinciple based on nominal sets. OMINAL COALGEBRAIC DATA TYPES WITH APPLICATIONS TO LAMBDA CALCULUS 11 Preliminaries on Nominal Sets
We recall basic facts on nominal sets [GP01, Pit13].Consider a countably infinite set V of ‘variables’ (or ‘atoms’ or ‘names’) and the group S ( V ) of permutations on V generated by transpositions, which are permutations of the form( x y ) that swap x and y . Consider a set X equipped with an action of the group S ( V ),denoted by · : S ( V ) × X → X . We say that u ∈ X is supported by a set S ⊆ V when for all π ∈ S ( V ) such that π ( x ) = x for all x ∈ S we have π · u = u . We say that u ∈ X is finitelysupported if there exists a finite S ⊆ V which supports u . Definition 4.1 (Nominal set) . A nominal set ( X, · ) is set X equipped with a S ( V )-actionsuch that all elements of X are finitely supported. Given nominal sets ( X, · ) and ( Y, · ), amap f : X → Y is called equivariant when f ( π · u ) = π · f ( u ) for all π ∈ S ( V ) and u ∈ X .The category of nominal sets and equivariant maps is denoted by Nom .A crucial property of nominal sets is that each element of a nominal set has a least finitesupport, see [GP01]. Indeed, if two finite sets S and S support u , then their intersectionalso supports u . Notation 4.2 (Support and freshness) . The smallest finite support of u is denoted by supp ( u ). If x ∈ V \ supp ( u ) we say that x is fresh for u , and write x u . More generally, giventwo nominal sets ( X, · ) and ( Y, · ), u ∈ X and v ∈ Y , we write u v for supp ( u ) ∩ supp ( v ) = ∅ .Given S, T ⊆ V , we write S u for supp ( u ) ∩ S = ∅ . We also write S T for S ∩ T = ∅ . Remark 4.3.
An important property of supp is that for every equivariant f : X → Y and u ∈ X , we have supp ( f ( u )) ⊆ supp ( u ). Example 4.4.
The set of names V equipped with the evaluation action given by π · x = π ( x )is a nominal set. Example 4.5.
The finite subsets of atoms P fin ( V ) form a nominal set with the pointwiseaction π · X = { π ( u ) | u ∈ X } for all X ∈ P fin ( V ). Remark 4.6.
Notice that taking the support of elements of a nominal set X gives anequivariant map supp : X → P fin ( V ). Indeed, one can show that for any u ∈ X and π ∈ S ( V ) we have supp ( π · u ) = π · supp ( u ). As a consequence, supp ( π · u ) and supp ( u ) havethe same cardinality for any permutation π . Example 4.7.
The set Λ of finite λ -terms with the action · : S ( V ) × Λ → Λ inductivelydefined by π · x = π ( x ) π · ( λx.M ) = λπ ( x ) . ( π · M ) π · ( M N ) = (( π · M )( π · N )) (4.1)is a nominal set. In this example we do not take into account α -equivalence, so the supportof a λ -term M is the set of all variables occurring either bound or free in M .Given a S ( V )-action · on a set X , let X fs denote the set X fs = { u ∈ X | u is finitely supported } . (4.2)Then · restricts to a S ( V )-action on X fs and ( X fs , · ) is a nominal set. Example 4.8.
The set Λ ∞ of finite and infinite λ -terms can be equipped with the action · : S ( V ) × Λ ∞ → Λ ∞ defined coinductively by (4.1). Alternatively, π · ( − ) can be definedusing the universal property of the metric completion, as the unique map that extendsΛ π · ( − ) −→ Λ ι −→ Λ ∞ . Observe that ( π · M ) n = π · M n for all M ∈ Λ ∞ and n ∈ N . Notice that(Λ ∞ , · ) is not a nominal set since the set of variables in a term, and hence its support, canbe infinite. But ((Λ ∞ ) fs , · ) is a nominal set and supp ( M ) = var ( M ) for all M ∈ (Λ ∞ ) fs . Definition 4.9 (Abstraction) . Let ( X, · ) be a nominal set. One defines ∼ α on V × X by( x , u ) ∼ α ( x , u ) ⇔ ( ∃ z { x , u , x , u } )( x z ) · u = ( x z ) · u (4.3)The ∼ α -equivalence class of ( x, u ) is denoted by h x i u . The abstraction [ V ] X of the nominalset X is the quotient ( V × X ) / ∼ α . The S ( V )-action on [ V ] X is defined by π · h x i u = h π · x i π · u. (4.4)Given equivariant f : ( X, · ) → ( Y, · ), we define [ V ] f : [ V ] X → [ V ] Y by h x i u
7→ h x i f ( u ) . (4.5) Definition 4.10. [Concretion] Let ( X, · ) be a nominal set. Concretion is the partial function@ : [ V ] X × V → X with h y i u @ z , the ‘concretion of h y i u at z ’, defined as h y i u @ z = ( z y ) · u if z ∈ V \ supp ( h y i u ).Notice that y h y i u and ( h y i u )@ y = u . Moreover, observe that [ V ] X × V is a nominalset with the coordinatewise action of S ( V ). One can show that concretion is equivariant.Indeed, if z h y i u then π · z h π · y i π · u and π · ( h y i u @ z ) = ( h π · y i π · u )@ π · z . Definition 4.11. [Internal hom] Given two nominal sets ( X, · ) and ( Y, · ), we define theinternal hom [ X, Y ] as the nominal set of all functions f : X → Y that are finitely supportedwith respect to the action ( π · f )( u ) = π · f ( π − · u ) . Remark 4.12.
A function f : X → Y is finitely supported if and only if there exists afinite set S of names, such that for all permutations π ∈ S ( V ) that fix the names in S andfor all x ∈ X we have π · f ( x ) = f ( π · x ). Limits and colimits in
Nom . Further, we recall some general results form [Pit03] that willbe necessary in the rest of the paper. The category
Nom is complete and cocomplete. Theforgetful functor to
Set creates finite products and all colimits. For example, the productof two nominal sets ( X, · ) and ( Y, · ) is ( X × Y, · ) where π · ( u, v ) = ( π · u, π · v ) . Arbitrary products in
Nom are computed differently than in
Set . Given a family of nominalsets ( X i , · i ) i ∈ I , we can equip the set of all tuples { ( u i ) i ∈ I | u i ∈ X i } with the pointwiseaction given by π · ( u i ) i ∈ I = ( π · i u i ) i ∈ I . (4.6)This is a S ( V )-action, but some tuples may not be finitely supported. The product of( X i , · i ) i ∈ I in Nom is the nominal set ( Q i ∈ I ( X i , · i )) fs of tuples of the form ( u i ) i ∈ I that arefinitely supported with respect to the action of (4.6).The limit in Nom of an ω op -chain X X f o o . . .f o o OMINAL COALGEBRAIC DATA TYPES WITH APPLICATIONS TO LAMBDA CALCULUS 13 is the nominal set of finitely supported tuples ( u , u , . . . ) such that for all i ∈ ω we have u i ∈ X i and f i +1 ( u i +1 ) = u i .The initial object of Nom is the empty nominal set with the trivial action. In
Nom , allmonomorphisms are strong and are precisely the injective equivariant maps.
Categorical properties of
Nom . The category
Nom is locally finitely presentable , see[AR94]. An object X in a category C is called finitely presentable when the hom functor C ( X, − ) preserves filtered colimits. For example the finitely presentable sets are the finiteones. A locally small category C is called locally finitely presentable when it is cocompleteand it has a small set A of finitely presentable objects, such that any object in C is a filteredcolimit of objects in A .We describe next the finitely presentable objects in Nom . First we need to define thenotion of orbit . Definition 4.13 (Orbit) . Consider a nominal set ( X, · ) and x, y ∈ X . We say that x and y are orbit equivalent when there exists π ∈ S ( V ) such that π · x = y . An orbit O ⊆ X isan equivalence class with respect to this equivalence relation. Remark 4.14.
Let O denote an orbit in a nominal set and consider x ∈ O . Then O = { π · x | π ∈ S ( V ) } .A proof of the following proposition is in [Pet12, Proposition 2.3.7]. Proposition 4.15.
A nominal set ( X, · ) is finitely presentable in Nom if and only if it hasfinitely many orbits.
Observe that a nominal set is the disjoint union of its orbits, and hence the directedunion of all its nominal subsets with finitely many orbits.
Properties of the abstraction functor.
The abstraction functor [ V ]( − ) : Nom → Nom preserves all limits and colimits, see [Pit13]. The remainder of this section is only neededin the proof of Lemma 5.56.By [Pit13, Theorem 4.13] we know that [ V ]( − ) has a right adjoint R : Nom → Nom defined by RX = { g ∈ [ V , X ] | ( ∀ x ∈ V ) x g ( x ) } . Above, [ V , X ] is the nominal set of finitely supported maps from V to X , as in Defini-tion 4.11. The argument below [Pit13, (4.27)] also implies that R does not preserve colimits,the counterexample being the coproduct of two nominal sets. However we can show that R preserves filtered colimits. But first let us give a simpler description of the nominal set RX . Lemma 4.16.
Consider a nominal set X and a Set -function g : V → X . We have that g ∈ RX if and only if the following conditions are satisfied: (1) For all x ∈ V we have x g ( x ) . (2) There exists a finite set of names S such that for all x ∈ V we have supp ( g ( x )) ⊆ S and g is constant on V \ S .Proof. For the direct implication, notice that (1) is clearly satisfied. For (2), let S denotethe support of g . Observe that, by Remark 4.12 we have that supp ( g ( x )) ⊆ S ∪ { x } . Since x g ( x ) we have that supp ( g ( x )) ⊆ S for all x ∈ V . Now consider x, x ′ S . Then, byRemark 4.12, we have ( x x ′ ) · g ( x ) = g ( x ′ ). On the other hand, ( x x ′ ) · g ( x ) = g ( x ) holdssince x, x ′ g ( x ). Hence g ( x ) = g ( x ′ ), thus g is constant outside S . Conversely, we only have to show that g is finitely supported. Let π ∈ S ( V ) be apermutation that fixes the set S . By Remark 4.12, it is enough to show that π · g ( x ) = g ( π · x )for all x ∈ V . Since supp ( g ( x )) ⊆ S we have that π · g ( x ) = g ( x ). We can also provethat g ( π · x ) = g ( x ). This is clear for x ∈ S . For the case when x S , observe that π · x = π ( x ) S , thus we can use the fact that g is constant outside S . Proposition 4.17.
The functor [ V ]( − ) : Nom → Nom has a finitary right adjoint.Proof.
Consider a filtered diagram D and a functor J : D → Nom . In order to provethat R colim d ∈ D J d ≃ colim d ∈ D RJ ( d ) it is enough to show that each finitely supported map g : V → colim d ∈ D J d such that for all x ∈ V we have x g ( x ) factors through a J d for some d ∈ D V g d (cid:15) (cid:15) ✤✤✤ g % % ❏❏❏❏❏❏❏❏❏❏❏ J d ι / / colim d ∈ D J d (4.7)and the map g d is finitely supported and for all x ∈ V we have x g d ( x ). Let S denote thefinite support of g and let x S . There exists d ∈ D such that g ( x ) = [ y ] for some y ∈ J d . We used square brackets here to denote the equivalence classes needed in thecomputation of filtered colimits. By Lemma 4.16 we have that supp ([ y ]) ⊆ S and for all x S we have that g ( x ) = [ y ]. Notice that S = { x , . . . , x n } is a finite set and for each x i there exists d i ∈ D such that g ( x i ) = [ y i ] for some y i ∈ J d i . We can assume without loss ofgenerality that for all 0 ≤ i ≤ n we have supp ( y i ) = supp ([ y i ]), see [Pet12, Proposition 2.3.7].By Lemma 4.16 for all 0 ≤ i ≤ n we have x i g ( x i ) = [ y i ] and supp ( g ( x i )) = supp ([ y i ]) ⊆ S . Hence, for all 0 ≤ i ≤ n we have x i y i and supp ( y i ) ⊆ S . Since D is filtered, there exists d ∈ D and arrows u i : d i → d in D for all 0 ≤ i ≤ n . We define g d : V →
J d by g d ( x ) = J u ( y ) if x S,J u i ( y i ) if x = x i for some 1 ≤ i ≤ n. (4.8)Notice that g d satisfies the properties (1) and (2) of Lemma 4.16. Indeed, we have that x g d ( x ) and supp ( g d ( x )) ⊆ S for all x ∈ V (because the maps J u i are equivariant andthus can only shrink the support of the elements, recall Remark 4.3). Thus g d is in R ( J d )by Lemma 4.16 and it makes diagram (4.7) commutative. Therefore R preserves filteredcolimits. Lemma 4.18.
The functor [ V ]( − ) : Nom → Nom preserves finitely presentable objects.Proof.
This is immediate by the previous lemma. Let X be a finitely presentable nominalset and let colim Y i be a filtered colimit. Then Nom ([ V ] X, colim Y i ) ≃ Nom ( X, R (colim Y i )) ≃ Nom ( X, colim R ( Y i )) ≃ colim Nom ( X, R ( Y i )) ≃ colim Nom ([ V ] X, Y i ) . (4.9)This shows that [ V ] X is finitely presentable. OMINAL COALGEBRAIC DATA TYPES WITH APPLICATIONS TO LAMBDA CALCULUS 15 Alpha Corecursion Principle for Nominal Coalgebraic Data Types
In this section we introduce nominal coalgebraic data types as a means of studying infinitarydata up to α -equivalence. In Section 5.1 we describe final coalgebras of certain Nom -endofunctors. We apply this result for functors arising from signatures with binding. Weprove that the set of equivalence classes of infinitary terms with finitely many free variablesis the final coalgebra of a
Nom -functor. Our running example is the infinitary λ -calculus,and indeed the results of [KPSdV12] are particular instances of the main theorems in thissection.5.1. Final Coalgebras of
Nom
Functors.
In this section we describe the final coalgebrasfor certain endofunctors on
Nom . It is well known that an endofunctor that preserveslimits of ω op -chains has a final coalgebra which is computed as the limit of the final chain.Similarly, endofunctors that preserve colimits of ω -chains have an initial algebra obtainedas the colimit of the initial sequence. We will generalise Barr’s theorem [Bar99] relatingfinal coalgebras and initial algebras to functors on nominal sets. To this end we need tointroduce nominal (complete) metric spaces. Definition 5.1 (Nominal metric space) . A nominal metric space is a tuple ( X, · , d ) suchthat ( X, · ) is a nominal set and d : X × X → [0 ,
1] is an equivariant metric when the interval[0 ,
1] is equipped with the trivial action. That is, d ( x, y ) = d ( π · x, π · y ) for all x, y ∈ X and π ∈ S ( V ). Definition 5.2 (Finitely supported Cauchy sequence) . A finitely supported Cauchy se-quence in a nominal metric space is a Cauchy sequence ( x n ) n ≥ such that there exists afinite set of variables S ⊆ V that supports all elements x n . A nominal metric space is complete when every finitely supported Cauchy sequence converges. Remark 5.3 (Nominal Completion) . Given a nominal metric space ( X, · , d ) one can con-struct its nominal completion ( X, · , d ) by adding the limits of all the finitely supportedCauchy sequences. This construction has the following universal property. For any com-plete metric space ( Y, · , e ) and any equivariant uniformly continuous function f : X → Y there exists a unique equivariant uniformly continuous map f : X → Y extending f . Theproofs are straightforward.In what follows, Theorem 5.4 and Theorem 5.5 show that the final coalgebra of certain Nom -functors can be regarded as a nominal metric space and is the nominal completionof the initial algebra. Theorem 5.4 is an instance of Ad´amek’s generalisation of Barr’stheorem from [Ad´a03]. The fact that T is the nominal Cauchy completion of I is equivalentto hom( B, T ) being the Cauchy completion of hom( B, I ) for any finitely presentable objects B ∈ Nom . Nevertheless, we opted to sketch a direct proof below, not only for the sake ofcompleteness, but also because we can work directly with metrics on the initial algebra andfinal coalgebra, paying attention to some extra conditions regarding equivariance and finitesupport. Moreover, a careful inspection of the proof allows us to prove a small variationof this result, see Theorem 5.5. One crucial hypothesis in [Ad´a03] is that the functor atissue, say F , has the property that F s : 1 → F F = 0 is not equivalent to the existence of a Nom -morphism s : 1 → F
0. As an example consider the functor L α of 5.15, where we canapply Theorem 5.5, but not Theorem 5.4.We first formulate Theorem 5.4 following [Ad´a03] in assuming that a morphism s : 1 → F F preserves limits of ω op -chains and monomorphisms. Note that we do notassume that F preserves colimits of ω -chains. The existence of the final coalgebra gives asize constraint on the functor F that ensures also the existence of the initial algebra.However, in Theorem 5.5 we will see that a variation of Theorem 5.4 in which we onlyassume that F = 0 holds provided that F can be extended to finitely-supported maps. Theorem 5.4.
Let F : Nom → Nom be a functor that preserves limits of ω op -chains andmonomorphisms and such that a morphism s : 1 → F exists. Then F has a final coalgebra T and an initial algebra I , both of which be equipped with equivariant metrics. Moreover thefinal coalgebra is the nominal completion of the initial algebra.Proof. We split the proof in four parts.(1)
Existence of final F -coalgebra and initial F -algebra. Since it preserves limits of ω op -chains, the functor F has a final coalgebra which can be computed as the limit of the ω op -chain 1 o o ! F o o F ! F o o F ! · · · o o T (5.1)Since Nom is locally finitely presentable and F preserves monomorphisms we havethat the initial F -algebra exists and is a subobject of T . For full details and the generalproof see [Ad´a03, Proposition 3.4]. The idea is to prove by transfinite induction that forevery ordinal ι we have a monomorphism u ι : F ι → F ι
1. For example for finite ordinalswe put u i = F i ( u ) where u : 0 → ι ≥ ω we have that F ι F ι ∼ = F ω
1. Using the fact that
Nom iswell powered, we know that F ω F -algebra, denoted by I . Moreover since for all ι ≥ ω we have F ι ∼ = F ω ∼ = T there exists a monomorphism v : I → T .0 / / u (cid:15) (cid:15) F / / (cid:127) _ u (cid:15) (cid:15) F / / (cid:127) _ u (cid:15) (cid:15) · · · / / F ω (cid:127) _ u ω (cid:15) (cid:15) / / · · · / / F ι (cid:127) _ u ι (cid:15) (cid:15) ∼ = I (cid:127) _ v (cid:15) (cid:15) ✤✤✤ o o F o o F o o · · · o o F ω o o ∼ = · · · F ι o o ∼ = T (5.2)(2) Equivariant metrics on T and I . First we define a metric on T . Let p n : T → F n d ( x, y ) = 2 − max { n | p n x = p n y } (5.3)with the convention that 2 − ω = 0. Considering the interval [0 ,
1] as a nominal set withthe trivial action the map d : T × T → [0 ,
1] becomes equivariant. This follows easilysince each p n is equivariant.(3) T is a nominal complete metric space. Next we show that ( T , d ) is a nominal completemetric space. Consider a finitely supported Cauchy sequence ( x n ) n ⊆ T . This impliesthat there exists a finite set S ⊆ V that supports all x n . Without loss of generalitywe may assume that for every n we have d ( x n , x n +1 ) ≤ − n . Therefore, we have that p n x n = p n x n +1 for all n , or equivalently, p n x n = F n !( p n +1 x n +1 ). Since for all n wehave supp ( x n ) ⊆ S and p n is equivariant, it follows that supp ( p n x n ) ⊆ S for all n . The OMINAL COALGEBRAIC DATA TYPES WITH APPLICATIONS TO LAMBDA CALCULUS 17 existence of such a common support is essential, recall how limits of ω op -chains arecomputed in Nom . It follows that there exists an element x ∈ T corresponding to thetuple ( p n x n ) n . We thus have that p n x = p n x n for all n and this proves that x is a limitof ( x n ) n with respect to the metric d .(4) T is the nominal completion of I . Since I contains F ω
0, see (5.2), it is enough to provethat any element x ∈ T can be written as the limit of a Cauchy sequence of elementsin F ω s : 1 → F
0. Notice that there exists aunique (finitely supported) map into 1, therefore we have that ! u s = id . We define x n ∈ F ω F n +1 → F ω F n s ( p n x ). Notice that thesupport of x n is included in the support of x for all natural numbers n . It is easy tocheck that p n u ω x n = p n x , thus d ( u ω x n , x ) ≤ − n . Therefore the sequence ( x n ) n is afinitely supported Cauchy sequence whose limit is x .In order to relax the assumption that the map s : 1 → F F to be Nom -enriched. This means that for any two nominal sets X and Y we have an equivariant map F X,Y : [
X, Y ] → [ F X, F Y ] which behaves well with respect tocomposition [Kel82], where [ X, Y ] denotes the internal hom in the cartesian closed category
Nom , and consists of the finitely supported maps from X to Y , see Definition 4.11. Theorem 5.5.
Let F : Nom → Nom be a functor that preserves limits of ω op -chains andmonomorphisms and such that F = 0 . Assume further that the functor F is Nom -enriched.Then F has a final coalgebra T and an initial algebra I , both of which can be equipped withequivariant metrics. Moreover the final coalgebra is the nominal completion of the initialalgebra.Proof. Notice that in
Nom the fact that F = 0 is equivalent to the existence of a finitelysupported map s : 1 → F
0. Thus, if F can be extended to finitely supported maps, theproof follows the same lines as Theorem 5.4 with a small difference. The maps F n s arefinitely-supported rather than equivariant. Since F is Nom -enriched the support of F n s isincluded in the support of s for any finitely supported map s . This follows by Remark 4.3since the maps F X,Y : [
X, Y ] → [ F X, F Y ] are equivariant. Therefore the support of theCauchy sequence ( x n ) n is included in the support of x union the support of the map s .As a side observation, notice that F being an enriched Nom -functor with respect to thecartesian symmetric monoidal structure of
Nom is equivalent to the existence of a strength,a notion that we will also use in Section 6.1.One can easily show that functors obtained from the grammar (5.4) below have theproperties required in Theorems 5.4 and 5.5.
Proposition 5.6.
Endofunctors on
Nom obtained from the grammar F ::= V | K | Id | a F | F × F | [ V ] F (5.4) preserve monomorphisms, epimorphims and limits of ω op -chains and are Nom -enriched.Above K denotes a constant functor, ` F denotes at most countable coproducts, while [ V ] F denotes precomposition with the abstraction functor introduced in Definition 4.9.Proof. It is immediate that the constant functors V and K , the identity functor Id preserveall limits and colimits. Countable coproducts commute in Nom with limits of ω op -chains andpreserve monomorphisms and epimorphisms. Binary products commute in Nom with all limits and preserve epimorphisms. Finally, the abstraction functor [ V ]( − ) : Nom → Nom isboth a right adjoint, see [Pit13, Theorem 4.12], and a left adjoint, see [Pit13, Theorem 4.13].Therefore [ V ]( − ) preserves all limits and colimits, in particular limits of ω op -chains, monosand epis. The fact that [ V ]( − ) is Nom -enriched follows from [Pit11, Lemma 4.10]. Thefunctors obtained from products and coproducts can be easily proved to be
Nom -enriched,see [Kel82].As a corollary, we can apply Theorem 5.4 to any endofunctor of the form (5.4) withthe additional property that a
Nom -morphism s : 1 → F F = 0.As an aside, note that the class of functors with the property that F = 0 is not closedunder countable products: Example 5.7.
Consider the functors F n : Nom → Nom defined by F n ( X ) = P n ( V ) + X where P n ( V ) is the nominal set of subsets of variables of cardinality n with the pointwiseaction. Observe that for every n we have F n = 0 , but Q n<ω F n Nominal Algebraic Data Types for Binding Signatures.
In this section wewill introduce binding signatures [FPT99] and we will see how the set of finite raw terms,respectively the set of α -equivalence classes of terms for a binding signature can be obtainedas initial algebras for Nom -functors. The results in this section are based on [GP01, Pit06,Pit11].
Definition 5.8 (Terms coming from a binding signature) . A binding signature is a pair(Σ , ar ) where Σ is a set of operations and ar : Σ → N ∗ specifies the binding arity of theoperations. The set of finite raw terms T Σ for a binding signature (Σ , ar ) is defined by theinductive rules( x ∈ V ) x ∈ T Σ t ∈ T Σ , . . . , t k ∈ T Σ ( ar ( op ) = n , . . . , n k ) op ( h x i .t , . . . , h x k i .t k ) ∈ T Σ (5.5)where in the second rule of (5.5) x i denotes a list x i , . . . , x n i i of of names of length n i where n i ≥ ≤ i ≤ k . If k = 0, we write op () for representing constants. Note that (5.5)defines raw terms, not quotiented by α -equivalence, but the intention here is to say that op binds the names in the list x i in the scope given by the term t i . Example 5.9 ( λ -terms) . The binding signature for λ -calculus consists of two operations Abs (abstraction) and
App (application) with respective arities ar ( Abs ) = , ar ( App ) = , . (5.6)The raw terms in this signature are the finite λ -terms not quotiented by α -equivalence. Forexample, λx.x is written as Abs ( h x i x ) and ( x y ) as App ( hi x , hi y ). Recall from Example 4.7that the set of λ -terms can be equipped with an action of the group S ( V ) and thus turnedinto a nominal set. OMINAL COALGEBRAIC DATA TYPES WITH APPLICATIONS TO LAMBDA CALCULUS 19
We can define inductively a S ( V )-action on raw terms for an arbitrary binding signature π · x = π ( x ) if x ∈ V ,π · op ( h x i .t , . . . , h x k i .t k ) = op ( h π · x i .t , . . . , h π · x k i .t k ) , (5.7)where π acts pointwise on the lists x i , that is, if x i = x i , . . . , x n i i then π · x i is the list π · x i , . . . , π · x n i i . Then we have that ( T Σ , · ) is a nominal set. Notice that the support of aterm t ∈ T Σ is then the set of all variables occurring in t . Definition 5.10 (Free and bound variables) . We can inductively define the set of freevariables in a term t ∈ T Σ : fv ( x ) = x if x ∈ V , fv ( op ( h x i .t , . . . , h x k i .t k )) = S ki =1 fv ( t i ) \ S ki =1 x i . (5.8)The set of bound variables is defined similarly: bv ( x ) = ∅ if x ∈ V , bv ( op ( h x i .t , . . . , h x k i .t k )) = S ki =1 bv ( t i ) ∪ S ki =1 x i . (5.9)For the binding signature in Example 5.9 we obtain the usual definition of free andbound variable in a λ -term.We will now proceed to define α -equivalence on finite raw terms for a binding signature.We will use the fact that T Σ is a nominal set. First let us recall the case of λ -calculus.On finite λ -terms, α -equivalence can be defined inductively using the permutation action · : S ( V ) × Λ → Λ of Example 4.7, see [GP01].
Definition 5.11 (Alpha equivalence on λ -terms) . Let
M, N, M ′ , N ′ ∈ Λ. The relation = α is the least equivalence relation closed under the rules:( var ) x = α x M = α N M ′ = α N ′ ( app ) M M ′ = α N N ′ ( x z ) · M = α ( y z ) · N z x, y, M, N ) ( abs ) λx.M = α λy.N The relation = α is equivariant, that is, M = α N implies π · M = α π · N for all π ∈ S ( V ).Thus we obtain a nominal set (Λ / = α , · ) where supp ( M ) = fv ( M ). Definition 5.12 (Alpha equivalence on terms coming from a binding signature) . For anarbitrary binding signature (Σ , ar ), we can define α -equivalence on finite terms inductively:( var ) x = α x ( x i z i ) · t i = α ( y i z i ) · s i ≤ i ≤ k for fresh z i ( op ) op ( h x i .t , . . . , h x k i .t k ) = α op ( h y i .s , . . . , h y k i .s k )where each z i is a list of distinct elements of length n i which are fresh for all the termsinvolved. Also, by ( y i z i ) we mean the composition of transposition ( x i z i ) . . . ( x n i i z n i i ). The relation = α is equivariant, that is, t = α s implies π · t = α π · s for all π ∈ S ( V ).Thus we obtain a nominal set ( T Σ / = α , · ). The equivalence class of a term t ∈ T Σ is denotedby [ t ] α and we have that supp ([ t ] α ) = fv ( t ).We can express the α -equivalence classes of terms in a binding signature as an initialalgebra for a Nom -functor. The next result allowed Gabbay and Pitts to formulate α -structural induction and recursion principles, see [Pit11, GP01, Pit06]. Theorem 5.13 (Nominal algebraic data types) . The nominal set ( T Σ / = α , · ) of finite α -equivalence classes of terms is the initial algebra for the functor F α : Nom → Nom givenby: F α X = V + a op ∈ Σ ar ( op )= n ,...,n k [ V ] n X × . . . × [ V ] n k X. (5.10)On the other hand, the nominal set ( T Σ , · ) of finite raw terms is the initial algebra for thefunctor F : Nom → Nom given by: F X = V + a op ∈ Σ ar ( op )= n ,...,n k ( V n × X ) × . . . × ( V n k × X ) . (5.11)We can also obtain T Σ as the initial algebra for a Set -functor. Indeed, we define a functor F : Set → Set (5.12)by the same formula as (5.11). The initial F -algebra is the set T Σ . Notice that F is a liftingof F to nominal sets in the sense that the next diagram commutes. Nom F / / U (cid:15) (cid:15) Nom U (cid:15) (cid:15) Set F / / Set (5.13)
Remark 5.14.
Notice that both functors F α and F are obtained from grammar (5.4). Example 5.15.
Consider the binding signature for λ -calculus of Example 5.9. Then thenominal set (Λ / = α , · ) is the initial algebra of the functor L α : Nom → Nom already men-tioned in the introduction (1.2): L α X = V + [ V ] X + X × X while the raw λ -terms for a nominal set which is the initial L -algebra for L : Nom → Nom given by L X = V + V × X + X × X. OMINAL COALGEBRAIC DATA TYPES WITH APPLICATIONS TO LAMBDA CALCULUS 21
An abstract account of α -equivalence. In the above example α -equivalence is thekernel of the map Λ ։ Λ / = α . Using Definition 4.9 we see that this map is induced at thelevel of Nom -endofunctors by the natural transformation θ X : V × X ։ [ V ] X (5.14)defined by ( x, u )
7→ h x i u .Consider an arbitrary F α : Nom → Nom obtained from grammar (5.4) or, equivalently,from a binding signature Σ. To F α we can associate a functor F : Nom → Nom in whichall occurrences of the abstraction functor [ V ]( − ) are replaced by V × − . Therefore F is apolynomial functor and the natural transformation (5.14) induces a natural transformation q : F → F α given by the following inductive rules: F α = IdF = Id q = id F α = V F = V q = id F α = KF = K q = id F α = [ V ] F ′ α q ′ : F ′ → F ′ α F = V × F ′ q = θ ◦ ( V × q ′ ) F α = F ′ α × F ′′ α q ′ : F ′ → F ′ α q ′′ : F ′′ → F ′′ α F = F ′ × F ′′ q = q ′ × q ′′ F α = ` ( F i ) α q i : F i → ( F i ) α F = ` F i q = ` q i (5.15)Using the initial chain, this in turn gives a surjective map from the initial F -algebra I =( T Σ , · ) to the initial F α -algebra I α = ( T Σ / = α , · ). Indeed, we have the following diagram0 / / [ − ] (0) α (cid:15) (cid:15) F / / [ − ] (1) α (cid:15) (cid:15) (cid:15) (cid:15) F / / [ − ] (2) α (cid:15) (cid:15) (cid:15) (cid:15) · · · / / I [ − ] α (cid:15) (cid:15) (cid:15) (cid:15) ✤✤✤ / / F α / / F α / / · · · / / I α (5.16)where [ − ] (0) α = id and [ − ] ( n +1) α = q F nα ◦ F [ − ] ( n ) α . The horizontal arrows are defined asin (2.1).Since the functors F obtained from grammar (5.4) preserve surjections, we have thatall the maps [ − ] ( n ) α are surjective. The compositions F n ։ F nα → I α form a cocone, thususing the universal property of the colimit I we obtain a unique map [ − ] α : I → I α such thatdiagram (5.16) commutes. To show that [ − ] α is surjective assume v, w : I α → B are twoequivariant maps such that v [ − ] α = w [ − ] α . It follows that v and w equalise F n ։ F nα → I α for all n . Using the universal property of I α , it follows that v = w . Hence [ − ] α is surjective. Remark 5.16.
We had to explain why the maps [ − ] ( n ) α are surjections. In Set this followseasily, since all
Set -functors preserve surjections (we just have to consider a right inverse).In
Nom we have equivariant surjective maps that do not have right inverses. E.g. theunique map from V to the final nominal set {∗} has no equivariant right inverse, becausethe support of ∗ is empty whereas all elements of V have non-empty support.Given a binding signature (Σ , ar ) we described α -equivalence on finite terms in twoequivalent ways: • syntactically , as in Definition 5.12; • semantically , via initial algebras, as in (5.16).While the latter presentation of α -equivalence may seem rather pedantic, the abstractperspective sheds some light on the problems one has with defining α -equivalence and findingrepresentatives for α -equivalence classes in the infinitary case.5.4. Problems with Alpha Equivalence in the Infinitary Case.
As an illustration,let us first look at possible definitions of α -equivalence for the infinitary λ -calculus. Wesee that there are two possible ways of defining α -equivalence classes and, contrary to allexpectations, they are not equivalent in case of a countable set of variables V .Recall that the set of raw infinitary λ -terms Λ ∞ is the final coalgebra of the Set -functorin (3.4). We define α -equivalence on the set Λ ∞ using truncations. This definition is slightlydifferent from, though equivalent, to those used in [KKSdV95, KKSdV97, KdV03]. Definition 5.17 (Alpha equivalence on infinitary λ -terms) . We extend the notion of α -conversion to the set Λ ∞ via M = α N iff M n = α N n for all n ∈ N .We thus obtain the quotient Λ ∞ / = α . The notion of truncation can be extended to Λ ∞ / = α via [ M ] nα = [ M n ] α .A second approach to define the set of α -equivalence classes of infinitary terms is toconsider the metric completion of the quotient Λ / = α . Definition 5.18 (Metric on α -equivalence classes) . We define d α : Λ × Λ → [0 ,
1] via d α ( M, N ) = inf { − n | M n = α N n , n ∈ N } . (5.17)We have that d α is a pseudometric on Λ and d α ( M, N ) = 0 if and only if M = α N .Thus d α gives rise to a metric on Λ / = α denoted by abuse of notation also by d α .We consider the metric completion of Λ / = α with respect to d α , denoted by(Λ / = α ) ∞ . Observe that d α extends to a pseudometric d ∞ α : Λ ∞ × Λ ∞ → [0 ,
1] given by the same formulaas in (5.17). Then M = α N in the sense of Definition 5.17 if and only if d ∞ α ( M, N ) = 0.Hence we obtain a metric on Λ ∞ / = α , also denoted by d ∞ α . Theorem 5.19.
Let V be uncountable. Then we have that (Λ ∞ / = α , d ∞ α ) is isomorphic to (Λ / = α ) ∞ . We do not include the proof of this theorem, since in this paper we are only interestedin the case where V is countable. The idea of the proof is to show that (Λ ∞ / = α , d ∞ α ) is acomplete metric space and then to use the universality property of the metric completion.This argument fails when the set of variables is at most countable. Indeed, we can showthat for countable V the space (Λ ∞ / = α , d ∞ α ) is not complete. Example 5.20.
Assume that V is countable, say V = { x , x , . . . } and consider the sequence([ λx n .x n ( x ( x ( . . . x n − )))] α ) n ≥ in Λ ∞ / = α . This is a Cauchy sequence with respect to d ∞ α ,but has no limit in Λ ∞ / = α . Indeed, assume towards a contradiction that the limit ℓ exists.On one hand we can prove that fv ( ℓ ) = V , on the other hand ℓ should be of the form[ λu.u ( x ( x . . . ))] α for some variable u . But this contradicts the fact that u is free in ℓ . OMINAL COALGEBRAIC DATA TYPES WITH APPLICATIONS TO LAMBDA CALCULUS 23
The example shows that with a countable V the two possible definitions of infinitary λ -terms up to α -equivalence do not coincide. In other words, metric completion and quoti-enting by α do not commute. We find the following formulation of this phenomenon usefulas well. Remark 5.21.
The canonical map[ − ] α : Λ ∞ → (Λ / = α ) ∞ taking the α -equivalence class of an infinitary λ -term is not surjective.These problems of α -equivalence in the presence of countably many variables disappearif we consider the set Λ ∞ ffv of infinitary terms with finitely many free variables. Notation 5.22 (Restriction to finitely many free variables) . Let Λ ∞ ffv denote the set { M ∈ Λ ∞ | fv ( M ) is finite } . Remark 5.23.
Note that Λ ∞ ffv is different from the set (Λ ∞ ) fs = Λ ∞ fs , defined in (4.2), of λ -terms with finitely many variables, bound or free. We do have that Λ ∞ fs ⊆ Λ ∞ ffv , but theinclusion is strict. Indeed, the following two terms belong to Λ ∞ ffv but not to Λ ∞ fs : • ogre ≡ λx .λx .λx . . . • infbv ≡ λx .λx .x x ( λx .x x x ( λx .x x x x ( . . . ))).For ogre we can find N ∈ Λ ∞ fs such that N = α ogre , e.g. N ≡ λx .λx .λx . . . . For infbv this is not possible. Remark 5.24.
The equivalence relation = α of Definition 5.17 restricts to Λ ∞ ffv , but not toΛ ∞ fs , as shown by ogre = α λx .λx .λx . . . where only the latter term is in Λ ∞ fs .For all M, N ∈ Λ ∞ ffv we have that M = α N implies π · M = α π · N . Hence we canequip Λ ∞ ffv / = α with a S ( V )-action given by π · [ M ] α = [ π · M ] α and we can easily check that(Λ ∞ ffv / = α , · ) is a nominal set. Indeed, [ M ] α ∈ Λ ∞ ffv / = α is supported by the finite set fv ( M ).The permutation action on Λ / = α can be extended to (Λ / = α ) ∞ as follows. For each π ∈ S ( V ) we have that π · ( − ) : Λ / = α → Λ / = α is a uniformly continuous function withrespect to d α . Using the universal property of the metric completion, this function can beextended to a uniformly continuous map on (Λ / = α ) ∞ :Λ / = α π · ( − ) & & ▼▼▼▼▼▼▼ / / (Λ / = α ) ∞ π · ( − ) (cid:15) (cid:15) Λ / = α ' ' ❖❖❖❖❖❖❖❖ (Λ / = α ) ∞ Thus we have a nominal set ((Λ / = α ) ∞ fs , · ). In [KPSdV12] we showed that this nominal setis isomorphic to (Λ ∞ ffv / = α , · ) and to the carrier of the final coalgebra of the Nom -functor L α . Hence, for each α -equivalence class of infinitary terms with finitely many variables wecan find a representative. This means that we have a surjective map[ − ] α : Λ ∞ ffv → (Λ / = α ) ∞ fs (5.18)whose kernel is the α -equivalence relation on Λ ∞ ffv . Remark 5.25.
On the other hand, the restriction Λ ∞ fs → (Λ / = α ) ∞ fs to Λ ∞ fs of (5.18) is notsurjective. For example the equivalence class of infbv ∈ Λ ∞ ffv is obtained as the limit of afinitely supported (actually emptily supported) sequence:[ λx . ∗ ] α [ λx x . ∗ ] α [ λx x .x ∗ ] α . . . and thus belongs to (Λ / = α ) ∞ fs . However, for the term infbv there is no N ∈ Λ ∞ fs such that N = α infbv .To summarise, we have seen the following classes of λ -termsΛ / / / / (cid:15) (cid:15) (cid:15) (cid:15) Λ ∞ (cid:15) (cid:15) (cid:15) (cid:15) Λ ∞ ffv (cid:15) (cid:15) (cid:15) (cid:15) ? _ o o Λ ∞ fs ? _ o o (cid:2) (cid:2) ☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎☎ Λ ∞ / = α (cid:15) (cid:15) (cid:15) (cid:15) Λ ∞ ffv / = α (cid:15) (cid:15) ∼ = (cid:15) (cid:15) (cid:15) (cid:15) Λ / = α / / / / (Λ / = α ) ∞ (Λ / = α ) ∞ fs ? _ o o (5.19)with inclusions, injections and surjections as indicated by the arrows. Λ and Λ / = α areinitial algebras for L and L α , respectively. Similarly Λ ∞ fs and (Λ / = α ) ∞ fs are final coalgebrasfor the same functors. But the coinductive situation is complicated by the fact that thecanonical map Λ ∞ fs → (Λ / = α ) ∞ fs is not onto, that is, infinitary λ -terms upto α -equivalencedo not arise by quotienting, in Nom , the raw infinitary λ -terms (which do allow only finitelymany bound variables). Instead of Λ ∞ fs we need to work with Λ ∞ ffv , which is not a finalcoalgebra. That Λ ∞ ffv can be given a semantic characterisation is one of the topics of thenext subsection.5.5. Nominal Coalgebraic Data Types for Binding Signatures.
The aim of thissection is to introduce nominal coalgebraic data types in their generality. We will generalisethe previous subsection to arbitrary binding signatures and give semantic characterisationsof all the vertices of (5.19).In particular, at the end of the section, we will have explained the following diagram,which generalises (5.19) (eliding the middle row of (5.19) obtained by epi-mono factorisa-tions). T Σ / / / / (cid:15) (cid:15) (cid:15) (cid:15) T ∞ Σ (cid:15) (cid:15) ( T ∞ Σ ) ffv (cid:15) (cid:15) (cid:15) (cid:15) ? _ o o ( T ∞ Σ ) fs ? _ o o x x ♣♣♣♣♣♣♣♣♣♣♣ T Σ / = α / / / / ( T Σ / = α ) ∞ ( T Σ / = α ) ∞ fs ? _ o o (5.20)Recall from Section 5.2 the definition of T Σ and T Σ / = α . Also recall that T Σ and T Σ / = α areinitial algebras of the Nom -endofunctors F and F α , (see respectively (5.11) and (5.10)). The OMINAL COALGEBRAIC DATA TYPES WITH APPLICATIONS TO LAMBDA CALCULUS 25 transformation T Σ / / / / T Σ / = α induced by a natural transformation F → F α is quotientingby α -equivalence. Next, we define T ∞ Σ . Definition 5.26 (Infinitary terms coming from a binding signature) . Consider a bindingsignature (Σ , ar ).(1) The set of infinitary raw terms T ∞ Σ is defined coinductively by( x ∈ V ) x ∈ T ∞ Σ t ∈ T ∞ Σ , . . . , t k ∈ T ∞ Σ ( ar ( op ) = n , . . . , n k ) op ( h x i .t , . . . , h x k i .t k ) ∈ T ∞ Σ (5.21)(2) Truncation of raw terms at depth n is defined by induction on n : t = ∗ t n +1 = x if t = x ∈ V op ( h x i .t n , . . . , h x k i .t nk ) if t = op ( h x i .t , . . . , h x k i .t k ) (5.22)where {∗} is a terminal object in Nom .(3) To define α -equivalence, let t and s be two infinitary raw terms in T ∞ Σ . We say that t = α s when the truncations at all depths are α -equivalent in the sense of Definition 5.12,that is, for all n we have t n = α s n .(4) The sets fv ( t ) and bv ( t ) of free and bound variables of an infinitary raw term t ∈ T ∞ Σ are defined as follows. fv ( t ) = S n ∈ N fv ( t n ) bv ( t ) = S n ∈ N bv ( t n ) . Remark 5.27. T ∞ Σ is the final coalgebra for the Set -functor defined in (5.12).
Definition 5.28.
We denote by ( T Σ / = α ) ∞ the metric completion of T Σ / = α with respectto the metric d α given by d α ([ t ] α , [ s ] α ) = inf { − n | t n = α s n , n ∈ N } . Notice that ( T Σ / = α ) ∞ is equipped with a canonical permutation action, but it is not anominal set, since not all elements are finitely supported (namely those terms with infinitelymany free variables). Remark 5.29.
Going back to Section 2, and in the notation of (5.16), we have that U I ∼ = U F ω ∼ = T Σ and U I α ∼ = U F ωα ∼ = T Σ / = α . The completions T ∞ Σ and ( T Σ / = α ) ∞ then canbe obtained as limits of ω op -sequences:1 o o (cid:15) (cid:15) (cid:15) (cid:15) (cid:15) (cid:15) U F o o U [ − ] (1) α (cid:15) (cid:15) (cid:15) (cid:15) U F o o U [ − ] (2) α (cid:15) (cid:15) (cid:15) (cid:15) · · · o o lim U F n ∼ = T ∞ Σ [ − ] α (cid:15) (cid:15) o o U F α o o U F α o o · · · o o lim U F nα ∼ = ( T Σ / = α ) ∞ (5.23)Moreover, the horizontal arrows in the diagram are precisely the truncations (with 1 = {∗} )and the kernels of the vertical arrows capture the α -equivalence of Definition 5.26. Sinceall maps [ − ] ( n ) α : F n → F nα F nα α -equivalence class of a raw term t ∈ F n
1. If [ t ] α ∈ F nα supp ([ t ] α ) = fv ( t ). The set lim U F nα ∼ = ( T Σ / = α ) ∞ appears to be a natural domain for infinitary terms upto α -equivalence and it will reappear in Section 6.5. But it fails to have desirable properties.Indeed, it is not a final coalgebra of a Set -functor in any obvious way, nor is it a nominalset. Moreover the map [ − ] α : T ∞ Σ → ( T Σ / = α ) ∞ is not surjective in general, as shown byExample 5.20. In the case of the infinitary λ -calculus we solved this issue by restrictingour attention to terms with finitely many free variables [KPSdV12]. We do the same in thecase of a general binding signature.Recalling from (4.2) the notation ( − ) fs , we now obtain from the rightmost edge of (5.23)( T ∞ Σ ) fs and ( T Σ / = α ) ∞ fs . (5.24)In the first case we restrict to finitely many variables and in the second case to finitely manyfree variables. More precisely, ( T Σ / = α ) ∞ fs consists of limits of Cauchy sequences ([ t n ] α ) n of α -equivalence classes of finite terms which altogether have only finitely many free variables,that is, S n fv ( t n ) is finite. Similarly ( T ∞ Σ ) fs consists of limits of Cauchy sequences ( t n ) n offinite terms which altogether have only finitely many variables. Remark 5.30.
According to Theorem 5.5, we have that ( T ∞ Σ ) fs , respectively ( T Σ / = α ) ∞ fs ,can be taken to be the final F -coalgebra T , respectively the final F α -coalgebra T α .Just as in the case of the initial chains (see (5.16)), the natural transformation q : F → F α defined by (5.15) induces a unique map T → T α from the final F -coalgebra to the final F α -coalgebra. However, unlike in the initial algebra situation (5.16), the induced map [ − ] α is not surjective in general, see Remark 5.25. The aim of the remainder of this section isto prove that, nevertheless, T α is the quotient by α -equivalence of the infinitary terms withfinitely many free variables for which we introduce the following notation. Definition 5.31.
Denote by ( T ∞ Σ ) ffv (5.25)the set of elements of T ∞ Σ having only finitely many free variables.Notice that ( T ∞ Σ ) ffv consists of limits of Cauchy sequences ( t n ) n of finite terms whichaltogether have only finitely many free variables. The definition above relies on the syntacticnotion of free variable. Proposition 5.33 shows that a semantic definition is possible. Tothis end, we first give a semantic definition of the inclusion ( T Σ / = α ) ∞ fs (cid:31) (cid:127) / / ( T Σ / = α ) ∞ asthe map ι α arising in (5.26). Remark 5.32.
As a final F -coalgebra, T induces a cone over the sequence ( F n n<ω , dual-ising (5.16).This induces a unique map ι : U T → lim U F n
1. In the same way, by finality of T α , oneobtains ι α : U T α → lim U F nα o o (cid:15) (cid:15) U F o o (cid:15) (cid:15) (cid:15) (cid:15) U F o o (cid:15) (cid:15) (cid:15) (cid:15) · · · o o lim U F n o o ι [ − ] α (cid:15) (cid:15) U T U [ − ] α (cid:15) (cid:15) ( ∗ )1 o o U F α o o U F α o o · · · o o lim U F nα o o ι α U T α (5.26) OMINAL COALGEBRAIC DATA TYPES WITH APPLICATIONS TO LAMBDA CALCULUS 27
Proposition 5.33.
The set ( T ∞ Σ ) ffv of infinitary raw terms with finitely many free variablesis the pullback of the maps ι α : U T α → lim U F nα and [ − ] α : lim U F n → lim U F nα . lim U F n − ] α (cid:15) (cid:15) ( T ∞ Σ ) ffv [ − ] α (cid:15) (cid:15) ? _ o o ✤❴ lim U F nα U T α ι α o o (5.27) Proof.
First we have to define the map [ − ] α : ( T ∞ Σ ) ffv → U T α . Given t ∈ ( T ∞ Σ ) ffv , noticethat we can construct a finitely supported sequence in the sets F nα − ] ( n ) α to the truncations at depth n of t . Indeed, each [ t n ] ( n ) α is supported by the finite setof free variables in t . We define [ t ] α ∈ T α to be the unique element whose projection in F nα t n ] ( n ) α for all n . We can easily check that the square (5.27) commutes.Consider a pair ( t, s ) with t ∈ lim U F n ≃ T ∞ Σ and s ∈ U T α such that ι α ( s ) = [ t ] α .This implies that [ t n ] ( n ) α is equal to the projection of s into F nα
1, and thus the free variablesof each truncation t n are contained in the finite set that supports s . Therefore t has finitelymany free variables, that is, t ∈ ( T ∞ Σ ) ffv and s = [ t ] α . So ( T ∞ Σ ) ffv is indeed a pullback.To summarise, we are now ready to give a semantic version of diagram (5.20) – whichwe set about to prove at the beginning of the section: I / / / / (cid:15) (cid:15) (cid:15) (cid:15) lim U F n (cid:15) (cid:15) P (cid:15) (cid:15) (cid:15) (cid:15) ? _ o o ✤❴ T ? _ o o | | ②②②②②②②②② I α / / / / lim U F nα T α ? _ o o (5.28)with I and I α the initial algebras as well as T and T α the final (or terminal) coalgebras of F and F α , and P being a pullback in Set . To improve readability we omitted writing theforgetful functor U : Nom → Set in (5.28).The map T (cid:31) (cid:127) / / P above is obtained using the universal property of P and the com-mutativity of the square ( ∗ ) in (5.26) and corresponds to the inclusion ( T ∞ Σ ) fs (cid:31) (cid:127) / / ( T ∞ Σ ) ffv ,(see Proposition 5.33). Theorem 5.34.
Completing T Σ by Cauchy sequences ( t n ) n such that S n fv ( t n ) is finite andquotienting by α -equivalence commute. This means that • the two equivalent diagrams below commute U I [ − ] α (cid:15) (cid:15) (cid:15) (cid:15) / / P [ − ] α (cid:15) (cid:15) (cid:15) (cid:15) U I α / / U T α T Σ [ − ] α (cid:15) (cid:15) (cid:15) (cid:15) / / ( T ∞ Σ ) ffv [ − ] α (cid:15) (cid:15) (cid:15) (cid:15) T Σ / = α / / ( T Σ / = α ) ∞ fs semantic version syntactic version; (5.29) • the map [ − ] α : P → U T α is surjective, or equivalently each element in ( T Σ / = α ) ∞ fs canbe represented as an equivalence class of an infinitary raw term with finitely many freevariables. Proof.
The first bullet is easier to prove. We show that the semantic version of (5.29)commutes, using the commutativity of I [ − ] α (cid:15) (cid:15) (cid:15) (cid:15) / / T [ − ] α (cid:15) (cid:15) I α / / T α (5.30)The argument uses the finality of T α and the fact that all the four arrows in (5.30) are F α -coalgebra morphisms.By pasting the right-hand triangle of (5.28), we obtain the commutativity of the desireddiagram: U I [ − ] α (cid:15) (cid:15) (cid:15) (cid:15) / / U T [ − ] α (cid:15) (cid:15) (cid:31) (cid:127) / / P } } ⑤⑤⑤⑤⑤⑤⑤⑤ U I α / / U T α (5.31)The second part of the theorem, stating that the map P → U T α in1 o o (cid:15) (cid:15) U F o o (cid:15) (cid:15) (cid:15) (cid:15) U F o o (cid:15) (cid:15) (cid:15) (cid:15) · · · o o lim U F n o o (cid:15) (cid:15) P (cid:15) (cid:15) o o U F α o o U F α o o · · · o o lim U F nα o o ι α U T α (5.32)is surjective can be proved by going back to the syntax as in [KPSdV12], just that thistime, due to generalising from λ -calculus to binding signatures, the notation becomes evenheavier and quite unpleasant. Therefore, we will give a semantic proof in the next section,so that surjectivity becomes a consequence of Theorem 5.72. This, in turn, is a consequenceof a more general result Theorem 5.46 about limits of sequences in nominal sets and will beproved in the next section.We state explicitly the most important consequence of the theorem as a corollary. Corollary 5.35 (Nominal coalgebraic data types) . The nominal set (( T ∞ Σ ) ffv / = α , · ) of α -equivalence classes of infinitary terms with finitely many free variables is the final coalgebrafor the functor F α : Nom → Nom corresponding to a binding signature (Σ , ar ) : F α X = V + a op ∈ Σ ar ( op )= n ,...,n k [ V ] n X × . . . × [ V ] n k X. (5.33) Remark 5.36.
Let us point out that Diagram (5.28) does not actually depend on the func-tors F , F α arising from a binding signature and makes sense for any pair of Nom -endofunctors F , F α and any component-wise surjective natural transformation F → F α subject to somenatural conditions (which are satisfied by functors that do arise from binding signatures),namely that F preserves surjections and that both F , F α have initial algebras and final coal-gebras. Finally, we want the surjectivity of P → T α and we give a semantic analysis of itin the next subsection. OMINAL COALGEBRAIC DATA TYPES WITH APPLICATIONS TO LAMBDA CALCULUS 29
Presenting Limits in Nominal Sets.
The motivation of this section is to give asemantic proof of the fact that the final T α -coalgebra is the quotient by α -equivalence of( T ∞ Σ ) ffv , the infinitary terms with finitely many free variables. We move this proof intoa separate subsection because the semantic analysis depends on certain facts on limits innominal sets and leads to a novel notion of ‘bound variable relative to a map’ which maybe of independent interest.5.6.1. Bound variables, safe maps, and safe squares.
In nominal sets, the syntax dependent notion of free variable is replaced by the seman-tic concept of minimal finite support. What about bound variables? Consider [ − ] α :Λ → Λ / = α and x ( λy.y ) ∈ Λ. Then the bound variables of xλy.y can be computed as supp ( xλy.y ) \ supp ([ xλy.y ] α ) = { x, y } \ { x } = { y } . Of course, this calculation depends onbeing able to assume that the bound variables and free variables of xλy.y do not overlap, or,in the terminology of [KPSdV12], that xλy.y is α -safe. The next definition gives a semanticformulation of an element being safe with respect to a map, which now does not need to bea quotient by α -equivalence. Definition 5.37 (Safe element) . Let f : X → Y be an equivariant function. We call u ∈ Xf -safe when | supp ( u ) | = max { | supp ( v ) | | v ∈ f − ( f ( u )) } . (5.34)The maximum in the right-hand side of 5.34 does not always exist, see Example 5.44. Example 5.38 ([ − ] α -Safe Terms) . We consider the equivariant map [ − ] α : Λ → Λ / = α .Then M is an [ − ] α -safe term if it has a maximal number of variables among all the repre-sentatives of its α -equivalence class. The terms x ( λy.y ) and λx.x ( λy.y ) are [ − ] α -safe but x ( λx.x ) and λx.x ( λx.x ) are not. Remark 5.39 ( α -safe Term) . A term M ∈ Λ is α -safe in the sense of [KPSdV12, Defini-tion 19] if and only if M is [ − ] α -safe in the sense of Definition 5.37. Intuitively, a λ -term M is α -safe when bv ( M ) ∩ fv ( M ) = ∅ and M does not have two different λ ’s with the samebinding variable, i.e. if λx and λy occur in two different positions of M then x = y .If a λ -term M is [ − ] α -safe then the set bv ( M ) of bound variables of M is equal to var ( M ) \ fv ( M ) = supp ( M ) \ supp ([ M ] α ). This motivates the following notation. Notation 5.40. If f : X → Y is an equivariant map then we define bv f ( u ) = supp ( u ) \ supp ( f ( u )) . When no confusion may arise, we omit the subscript and write bv ( u ) instead of bv f ( u ). Remark 5.41.
Let f : X → Y be equivariant and u ∈ X . Then supp ( f ( u )) ⊆ supp ( u ) and | bv f ( u ) | = | supp ( u ) | − | supp ( f ( u )) | . Lemma 5.42.
Let f : X → Y be an equivariant map. Then u is f -safe if and only if | bv f ( u ) | = max { | bv f ( v ) | | v ∈ f − ( f ( u )) } . (5.35) Proof.
Assume u is f -safe and consider v ∈ Y such that f ( v ) = f ( u ). Then | bv f ( u ) | = | supp ( u ) | − | supp ( f ( u )) | ≥ | supp ( v ) | − | supp ( f ( v )) | = | bv f ( v ) | . The converse is similar.
Definition 5.43 (Safe map) . Let f : X → Y be an equivariant map in Nom . We call f safe when for all v ∈ Y there exists an f -safe u ∈ X such that f ( u ) = v . Example 5.44.
The map [ − ] α : Λ → Λ / = α is safe [KPSdV12, Lemma 20]. But the map! : P fin ( V ) → {∗} is not.A diagram such as (5.36) is a weak pullback if for all identified u and v , there is a z witnessing this fact, that is, if f ( u ) = q ( v ) then there exists z ∈ Z such that u = p ( z ) and v = g ( z ). In the following we will need a similar but weaker condition, which, intuitively,requires the existence of a witness only up to the renaming of bound variables. Definition 5.45 (Safe square) . A square X o o pf (cid:15) (cid:15) Zg (cid:15) (cid:15) W o o q Y (5.36)is a safe square when for all f -safe u ∈ X and for all v ∈ Y such that f ( u ) = q ( v ) and bv f ( u ) v there exists a g -safe z ∈ Z such that p ( z ) = u and g ( z ) = v .5.6.2. Representing limits in nominal sets.
Consider two ω op -chains in Nom and let lim X n , respectively lim Y n denote their limits in Nom . X o o p f (cid:15) (cid:15) (cid:15) (cid:15) X o o p f (cid:15) (cid:15) (cid:15) (cid:15) X o o f (cid:15) (cid:15) (cid:15) (cid:15) · · · o o lim X n f (cid:15) (cid:15) ✤✤✤ Y o o q Y o o q Y o o · · · o o lim Y n (5.37)By the universal property of the limits we obtain a map f : lim X n → lim Y n . In thecategory of sets, we have the theorem that if all the squares are weak pullbacks and all the f n are surjective, then f is surjective. But in our main example where the f n quotient by α -equivalence, the squares are not weak pullbacks.Recalling that U : Nom → Set denotes the forgetful functor, consider the limits of thetwo chains in
Set
U X o o f (cid:15) (cid:15) (cid:15) (cid:15) U X o o f (cid:15) (cid:15) (cid:15) (cid:15) U X o o f (cid:15) (cid:15) (cid:15) (cid:15) · · · o o lim U X n g (cid:15) (cid:15) ✤✤✤ o o a ❴❴❴ U lim X n U f (cid:15) (cid:15) ( ∗ ) U Y o o U Y o o U Y o o · · · o o lim U Y n o o b ❴❴❴ U lim Y n (5.38)By the universal property of limits, there exist unique maps a : U lim X n → lim U X n and b : U lim Y n → lim U Y n making the square ( ∗ ) commutative. Again, the map g : lim U X n → lim U Y n induced in the limit may not be surjective in general, see Example 5.20.However we can prove the following general result: OMINAL COALGEBRAIC DATA TYPES WITH APPLICATIONS TO LAMBDA CALCULUS 31
Theorem 5.46.
Assume that diagram (5.37) is such that for all n the square X n o o p n f n (cid:15) (cid:15) (cid:15) (cid:15) X n +1 f n +1 (cid:15) (cid:15) (cid:15) (cid:15) Y n o o q n Y n +1 (5.39) is safe and f n is a safe map. Let P denote the pullback lim U X n g (cid:15) (cid:15) o o r Ph (cid:15) (cid:15) ✤❴ lim U Y n o o b U lim Y n (5.40) Then h : P → U lim Y n is a surjection.Proof. We start with v ∈ lim Y n . Consider the projections v n ∈ Y n of v obtained via theprojections of the limiting cone. Since q n ( v n +1 ) = v n and q n are equivariant maps we havethe following inclusions of finite sets supp ( v ) ⊆ supp ( v ) ⊆ . . . ⊆ supp ( v ) . Thus the sequence stabilises eventually, that is, there exists n such that supp ( v n ) = supp ( v n + k )for all natural numbers k . Moreover since v = ( v , v , . . . ) we have that for all k ≥ supp ( v n + k ) = supp ( v ) . We will now construct u = ( u , u , . . . ) in lim U X n such that g ( u ) = b ( v ). First let u n ∈ X n be an f n -safe element such that f n ( u n ) = v n . For each k ≥
1, we define an f n + k -safe u n + k ∈ X n + k such that p n + k ( u n + k ) = u n + k − and f n + k ( u n + k ) = v n + k .The proof is by induction on k . Since supp ( v n +1 ) = supp ( v n ), we have that ( supp ( u n ) \ supp ( v n )) ∩ supp ( v n +1 ) = ∅ . Since all the squares (5.39) are safe squares, there exists an f n +1 -safe element u n +1 ∈ X n +1 in the preimage of v n +1 such that p n +1 ( u n +1 ) = u n . Thisshows that the claim is true for k = 1.For the inductive step k → k +1, notice that ( supp ( u n + k ) \ supp ( v n + k )) ∩ supp ( v n + k +1 ) = ∅ and that u n + k is f n + k -safe. Using the safe square property, there exists f n + k +1 -safe u n + k +1 ∈ X n + k +1 with the desired properties.For m < n define u m = p m p m +1 . . . p n ( u n ). Now observe that ( u , u , . . . ) is an elementof lim U X n whose image in lim U Y n is ( v , v , . . . ). This means that g (( u , u , . . . )) = b ( v ) . Since P is the pullback of g and b , there exists w ∈ P such that r ( w ) = ( u , u , . . . ) and h ( w ) = v . Thus h : P → U lim Y n is surjective.Going back to Theorem 5.34 and looking at (5.32), we find that so far we establishedthe following corollary of Theorem 5.34. Corollary 5.47.
Let F , F α be endofunctors on Nom having final coalgebras, and let F → F α be a component-wise surjective natural transformation, and P be a pullback as in (5.20) .Moreover assume that F preserves surjections. If • the induced maps [ − ] ( n ) α : F n → F nα are safe • and the squares F n o o [ − ] ( n ) α (cid:15) (cid:15) (cid:15) (cid:15) F n +1 − ] ( n +1) α (cid:15) (cid:15) (cid:15) (cid:15) F nα o o F n +1 α are safe squares,then P → U T α is onto. In the following we will prove the second part of Theorem 5.34 using Corollary 5.47,that is, by establishing the two bullet points above. Let us briefly outline the structure ofthat argument. Recall that the maps [ − ] ( n ) α are defined inductively as follows: [ − ] (0) α = id and [ − ] ( n +1) α = q F nα ◦ F ([ − ] ( n ) α ). Also recall that the natural transformation q : F → F α isdefined inductively depending on the structure of F and F α using the rules (5.15). Therefore,the argument will proceed by induction on n and on the structure of F . For this, we needsome structural closure properties for safe maps. To this end, we also study a special caseof safe maps, namely maps with orbit-finite fibres. This will help us to prove the first bulletpoint of Corollary 5.47. For the second bullet we need a detailed study of safe squares. Thisis eventually done in Section 5.6.5.5.6.3. Some properties of safe elements and safe maps.
Lemma 5.48. If u ∈ X is f -safe and π is an arbitrary finite permutation then π · u is f -safe.Proof. Suppose u ∈ X is f -safe. Consider v ∈ X such that v ∈ f − ( f ( π · u )). Then π − · v ∈ f − ( f ( u )) because f is equivariant. Using Remark 4.6 we conclude | supp ( π · u ) | = | supp ( u ) | ≥ | supp ( π − · v ) | = | supp ( v ) | . Lemma 5.49.
Assume f : X → Y is safe. Consider v ∈ Y and let S be an arbitrary finiteset of names. Then there exists an f -safe u ∈ f − ( v ) such that bv ( u ) ∩ S = ∅ .Proof. Since f is safe, there exists an f -safe u ∈ f − ( v ). Let T = S ∩ bv ( u ). If T is empty weare done. If not, let T ′ be a finite set of names fresh for u, v, S which has the same numberof elements as T . Let π denote a finite permutation that swaps the elements of T and T ′ and fixes the remaining names in V . Then π · x = x for all x ∈ supp ( v ), thus π · u ∈ f − ( v ).By Lemma 5.48, π · u is f -safe. Moreover, by Remark 4.6 we have supp ( π · u ) = π · supp ( u )and thus bv ( π · u ) ∩ S = ∅ . Lemma 5.50.
Assume f : X → Y and f : X → Y are safe maps. Then ( u , u ) is ( f × f ) -safe if and only if the following hold u i is f i -safe for i = 1 , bv ( u ) u bv ( u ) u . (5.42) OMINAL COALGEBRAIC DATA TYPES WITH APPLICATIONS TO LAMBDA CALCULUS 33
Proof.
Assume ( u , u ) satisfy (5.42) and let v i denote f i ( u i ) for i = 1 ,
2. We will show that( u , u ) ∈ ( f × f ) − ( v , v ) is ( f × f )-safe. First observe that bv ( u , u ) = ( supp ( u ) ∪ supp ( u )) \ ( supp ( v ) ∪ supp ( v ))= ( supp ( u ) \ supp ( v )) \ supp ( v ) ∪∪ ( supp ( u ) \ supp ( v )) \ supp ( v )= bv ( u ) ⊎ bv ( u ) . (5.43)The last equality holds by (5.42). Therefore | bv ( u , u ) | = | bv ( u ) | + | bv ( u ) | . (5.44)In order to show that ( u , u ) is indeed ( f × f )-safe consider ( u ′ , u ′ ) ∈ ( f × f ) − ( v , v ).We have the inequalities | supp ( u ′ , u ′ ) \ supp ( v , v ) | = | ( supp ( u ′ ) ∪ supp ( u ′ )) \ ( supp ( v ) ∪ supp ( v )) |≤ | ( supp ( u ′ ) \ ( supp ( v ) ∪ supp ( v ))) | ++ | ( supp ( u ′ ) \ ( supp ( v ) ∪ supp ( v ))) |≤ | ( supp ( u ′ ) \ supp ( v ) | + | ( supp ( u ′ ) \ supp ( v ) |≤ | bv ( u ) | + | bv ( u ) | . (5.45)The last inequality holds because u and u are f -safe, respectively, f -safe. Thus, us-ing (5.44), we can conclude that | supp ( u ′ , u ′ ) \ supp ( v , v ) | ≤ | bv ( u , u ) | . Conversely, assume that ( u ′ , u ′ ) ∈ ( f × f ) − ( v , v ) is ( f × f )-safe. By Lemma 5.49,there exists u ∈ f − ( v ) an f -safe element such that bv ( u ) ∩ supp ( u ) = ∅ . (5.46)Similarly, there exists u ∈ f − ( v ) an f -safe element such that bv ( u ) ∩ supp ( u ) = ∅ . (5.47)From (5.46) and (5.47) we can derive (5.42). By the first part of the proof we know that( u , u ) is ( f × f )-safe and that the inequalities of (5.45) hold. Since ( u ′ , u ′ ) is also ( f × f )-safe we know that all the inequalities of (5.45) are equalities. For the last inequality of (5.45),this implies that each u ′ i is f i -safe. For the second inequality of (5.45), this implies that bv ( u ′ ) f ( u ) and bv ( u ) f ( u ). Hence, by the fact that also the first inequality of (5.45)is actually an equality we have that bv ( u ′ ) bv ( u ′ ). Since supp ( u ′ ) = bv ( u ′ ) ∪ supp ( f ( u ′ ))we conclude that bv ( u ′ ) u ′ . Similarly bv ( u ′ ) u ′ . Lemma 5.51.
Let f : X → Y and g : Y → W be equivariant maps. If u is gf -safe, then u is f -safe.Proof. Consider v ∈ f − ( f ( u )). Then gf ( v ) = gf ( u ). Since u is gf -safe, we have that | supp ( v ) | ≤ | supp ( u ) | . Unfortunately, safe maps are not closed under composition as the next example shows.
Example 5.52.
Consider the set N of natural numbers as a nominal set equipped withthe trivial action and let P fin ( V ) denote the nominal set of all finite subsets of V . Let f : P fin ( V ) → N denote the map which sends any finite set of names to its cardinal and let g : N → {∗} denote the unique map from N into the final nominal set {∗} . Both f and g are equivariant and safe, but their composition g ◦ f is not safe.Therefore we need a stronger notion of maps that still accommodates our examples butwith better closure properties. This is the purpose of the next section.5.6.4. Maps with orbit-finite fibers.
In this section, we introduce the notion of maps with orbit-finite fibers and use it to provethat the maps [ − ] ( n ) α : F n → F nα Definition 5.53 (Orbite-finite fibers) . We say that a
Nom -morphism f : X → Y has orbit-finite fibers when for all v ∈ Y we have that f − ( v ) is included in the union of finitely manyorbits of X . Lemma 5.54.
The following are equivalent: (1) f has orbit-finite fibers. (2) For all v ∈ Y there exists a finitely presentable nominal subset X v ⊆ X such that f − ( v ) ⊆ X v . (3) For all finitely presentable nominal subset Y ′ ⊆ Y the nominal subset f − ( Y ′ ) of X isfinitely presentable.Proof. (1) ⇐⇒ (2) is immediate.(2) = ⇒ (3): Consider Y ′ ⊆ Y a finitely presentable nominal subset. Then Y ′ is a finiteunion of orbits O v ∪ . . . ∪ O v n . We have picked generators v , . . . , v n for these orbits. Foreach i there exists a finitely presentable nominal subset X i ⊆ X with f − ( v i ) ⊆ X i . Thenfor all π we have that f − ( π · v i ) ⊆ π · X i = X i . Therefore f − ( O v i ) ⊆ X i . Therefore, f − ( Y ′ ) ⊆ X ∪ . . . ∪ X n . Since a finite union of finitely presentable nominal sets is afinitely presentable nominal set, we conclude that f − ( Y ′ ) is a nominal subset of a finitelypresentable nominal set, thus it is itself a finitely presentable nominal set. (3) ⇐ = (2):Consider v ∈ Y . Put Y ′ to be the one-orbit nominal set generated by v . By (3) wehave that f − ( Y ′ ) is a finitely presentable nominal subset of X . We obviously have that f − ( v ) ⊆ f − ( Y ′ ). Lemma 5.55. If f : X → Y is surjective and has orbit-finite fibers, then f is safe.Proof. If two elements of X are in the same orbit of f − ( v ) their supports have the samenumber of variables. Indeed, if u, u ′ ∈ f − ( v ) and u ′ = π · u for some permutation π , we havethat supp ( u ′ ) = π · supp ( u ), thus supp ( u ) and supp ( u ′ ) have the same number of elements.By hypothesis f − ( v ) is included in the union O ∪ . . . ∪ O n of finitely many orbits of X .By the above observation, the set {| supp ( u ) | | u ∈ O i ∩ f − ( v ) } is a singleton for each 1 ≤ i ≤ n . Since we have only finitely many orbits, it follows that {| supp ( u ) | | u ∈ f − ( v ) } has at most n elements, and therefore has a maximum. Thus f is safe. OMINAL COALGEBRAIC DATA TYPES WITH APPLICATIONS TO LAMBDA CALCULUS 35
Lemma 5.56.
Functions with orbit-finite fibers are closed under (1) finite products, (2)coproducts, (3) abstraction, and (4) composition.Proof. (1) Consider f i : X i → Y i for i = 1 , v , v ) ∈ Y × Y .There exists finitely presentable nominal subsets X ′ i ⊆ X i such that f − i ( v i ) ⊆ X ′ i . Then( f × f ) − ( v , v ) = f − ( v ) × f − ( v ) ⊆ X ′ × X ′ . But, since orbit-finite nominal setsare closed under finite products, see for example [BBKL12, Lemma 2], we have that X ′ × X ′ is orbit-finite, so we are done.(2) That’s easy, component-wise.(3) Consider f : X → Y with orbit-finite fibers. We want to prove that [ V ] f also hasorbit-finite fibers. Notice that([ V ] f ) − ( h x i v ) = {h x i u | u ∈ f − ( v ) } . There exist a finitely presentable nominal subset X ′ ⊆ X such that f − ( v ) ⊆ X ′ .Therefore ([ V ] f ) − ( h x i v ) ⊆ [ V ] X ′ . By Lemma 4.18 we know that [ V ] X ′ is finitelypresentable.(4) Assume f : X → Y and g : Y → W have orbit-finite fibers. We show that g ◦ f alsohas orbit-finite fibers. Let w ∈ W . Then g − ( w ) ⊆ Y ′ for some finitely presentablenominal subset Y ′ of Y . By Lemma 5.54 we have that f − ( Y ′ ) is finitely presentable.Since ( g ◦ f ) − ( w ) = f − ( g − ( w )) ⊆ f − ( Y ′ ) we are done. Example 5.57.
The function θ X : V × X → [ V ] X has orbit-finite fibers. Indeed, notice that θ − ( h x i v ) ⊆ V × O v where O v is the orbit spanned by v . But V × O v is finitely presentable,so we are done. Lemma 5.58.
The maps q X : F X → F α X have orbit-finite fibers.Proof. This is proved by induction on the structure of F , since the map q X is obtained fromthe identity map and θ X , via products, coproducts and composition. We can thereforeapply Lemma 5.56. Proposition 5.59.
The maps [ − ] ( n ) α : F n → F nα have orbit-finite fibers and are safe.Proof. We use induction on n . The base case is clear since [ − ] (0) α = id . For the inductivestep, notice that [ − ] ( n +1) α = q F nα ◦ F ([ − ] ( n ) α ). By items (1) and (2) of Lemma 5.56 wehave that F ([ − ] ( n ) α ) has orbit-finite fibers. Then we can apply item (4) of Lemma 5.56and Lemma 5.58 to derive that [ − ] ( n +1) α also has orbit-finite fibers. Since the [ − ] ( n ) α aresurjective, it follows from Lemma 5.55 that they are safe.The maps with orbit-finite fibers have nice closure properties, but safe elements do notbehave well with respect to composition, as shown in the next example. Example 5.60.
Let P ( V ) be the nominal set of two-element sets of names and let f : V + P ( V ) → V + 1 denote the map id V +! where ! denotes the unique map into the finalnominal set. Let g denote the unique map from V + 1 to 1. Notice that f , g (and thereforetheir composition) have orbit-finite fibers and are safe. Nevertheless • u ∈ V is f -safe and f ( u ) = u is g safe, but u is not ( g ◦ f )-safe. • { u, v } is ( g ◦ f )-safe, but f ( { u, v } ) is not g -safe.Therefore, in the next section we need to study the properties of safe squares. Properties of safe squares.
In the first part of this section we will show that safe squares are closed under products andcoproducts. Then we will show that also the ‘vertical’ composition of safe squares is safeprovided that some additional properties are satisfied by the maps at issue. This allowsus to prove the second bullet point of Corollary 5.47 and conclude our main result on thesurjectivity of P → U T α in Theorem 5.72. Lemma 5.61.
Consider a safe square X o o pf (cid:15) (cid:15) Zg (cid:15) (cid:15) W o o q Y (5.48) If u ∈ X is f -safe, v ∈ Y and S is a finite subset of V such that f ( u ) = q ( v ) , bv f ( u ) v and bv f ( u ) S there exists a g -safe z ∈ Z such that p ( z ) = u , g ( z ) = v and bv g ( z ) S .Proof. By the definition of safe squares there exists a g -safe z such that g ( z ) = v and p ( z ) = u . Let T denote the intersection S ∩ bv g ( z ). If T is empty we are done. Otherwiseconsider a set T ′ of names fresh for u, v, z, S having the same cardinality as T and let π denote a finite permutation that swaps the elements of T with the elements of T ′ and fixesall the other elements of V . We will show that π · z has all the required properties. ByLemma 5.48, π · z is g -safe. In order to prove that g ( π · z ) = v it is enough to check that π · x = x for all x ∈ supp ( v ). This is true because T ⊆ bv g ( z ) and bv g ( z ) ∩ supp ( v ) = ∅ ,hence T ∩ supp ( v ) = ∅ . In order to check that p ( π · z ) = u , it is enough to show that π · x = x for all x ∈ supp ( u ). But supp ( u ) = bv f ( u ) ∪ supp ( f ( u )) ⊆ bv f ( u ) ∪ supp ( v ). Wehave established that T ∩ supp ( v ) = ∅ . On the other hand, T ⊆ S and S bv f ( u ) imply that T ∩ bv f ( u ) = ∅ . Hence T u . Since T ′ u we obtain that π fixes all the names in supp ( u ). Lemma 5.62.
Safe squares are closed under finite products and coproducts.Proof.
The case of coproducts is easy. We show the closure of safe squares under finiteproducts. Assume X i f i (cid:15) (cid:15) o o p i Z i q i (cid:15) (cid:15) W i o o g i Y i (5.49)for i ∈ { , } are safe squares. We will show that X × X f × f (cid:15) (cid:15) o o p × p Z × Z q × q (cid:15) (cid:15) W × W o o g × g Y × Y (5.50)is a safe square. Consider f × f -safe ( u , u ) and ( v , v ) ∈ Y × Y such that bv ( u , u ) v , v )and f i ( u i ) = g i ( v i ). By Lemma 5.50 we know that u i is f i -safe and that bv ( u ) bv ( u ). OMINAL COALGEBRAIC DATA TYPES WITH APPLICATIONS TO LAMBDA CALCULUS 37
Moreover we can compute that bv ( u , u ) = bv ( u ) ⊎ bv ( u ) . Since bv ( u ) v and bv ( u ) bv ( u ), by Lemma 5.61 (applied for S = bv ( u )) we can find z ∈ Z such that • bv ( z ) v and bv ( z ) bv ( u ) • z is q -safe. • q ( z ) = v and p ( z ) = u .Since bv ( u ) v and bv ( u ) bv ( z ), by Lemma 5.61 (applied for S = bv ( z )) we can find z ∈ Z such that • bv ( z ) v and bv ( z ) bv ( z ). • z is q -safe. • q ( z ) = v and p ( z ) = u .By construction we have that bv ( z ) v , bv ( z ) v and bv ( z ) bv ( z ). It follows that bv ( z ) z and bv ( z ) z . By Lemma 5.50 we know that ( z , z ) is ( q × q )-safe.Next we will show that under some mild conditions safe squares are closed under verticalcomposition. Safe squares resemble weak pullbacks. It is straightforward to show thatvertical composition of weak pullbacks gives a weak pullback. However, in the case ofsafe squares, some additional constraints are imposed on the elements, such as f -safety.Therefore, safe elements should behave well with respect to the vertical composition of themaps. We will find the following definitions handy. Definition 5.63 (Forward-safe) . Let f : X → Y and g : Y → W be safe maps. We saythat the pair ( f, g ) is forward-safe if, for all u ∈ X such that u is ( g ◦ f )-safe, we have that f ( u ) is g -safe. Definition 5.64 (Backward-safe) . Let f : X → Y and g : Y → W be safe maps. We saythat the pair ( f, g ) is backward-safe if, for all u ∈ X such that u is f -safe and f ( u ) is g -safe,we have that u is ( g ◦ f )-safe. Lemma 5.65.
Consider the following diagram X o o pf (cid:15) (cid:15) X h (cid:15) (cid:15) (1) Y o o qg (cid:15) (cid:15) Y k (cid:15) (cid:15) (2) W o o s W . (5.51) such that (1) and (2) are safe squares, the pair ( f, g ) is forward-safe and the pair ( h, k ) isbackward-safe. Then the outer square in (5.51) is a safe square.Proof. Consider u ∈ X and w ∈ W such that u is ( g ◦ f )-safe, bv gf ( u ) w and gf ( u ) = s ( w ). Since ( f, g ) is forward-safe we have that f ( u ) is g -safe. We also have that bv g ( f ( u )) w , because bv g ( f ( u )) ⊆ bv gf ( u ). Since (2) is a safe square there exists a k -safe v ∈ Y such that k ( v ) = w and q ( v ) = f ( u ). Moreover by Lemma 5.61 we can assume that bv k ( v ) bv f ( u ) . (5.52)We can apply Lemma 5.61 in this case because bv f ( u ) bv g ( f ( u )).By Lemma 5.51 u is f -safe. We also have that bv f ( u ) v . This holds because supp ( v ) = bv k ( v ) ⊎ supp ( w ) and both bv k ( v ) and supp ( w ) are fresh for bv f ( u ). Theformer is by (5.52) while the latter holds because bv f ( u ) ⊆ bv gf ( u ) and bv gf ( u ) w .Since q ( v ) = f ( u ), we use that (1) is a safe square to derive the existence of an h -safe u ∈ X that satisfies p ( u ) = u and h ( u ) = v . Since ( h, k ) is a backward-safe pair ofmaps, u is h -safe and h ( u ) = v is k -safe, we conclude that u is also ( k ◦ h )-safe and thussatisfies all the requirements. Lemma 5.66. If u is f -safe and x bv f ( u ) then ( x, u ) is ( θ ◦ ( V × f )) -safe.Proof. By Lemma 5.50, ( x, u ) is (
V × f )-safe. Consider ( y, v ) such that h x i f ( u ) = h y i f ( v ).We will show that | supp ( y, v ) | ≤ | supp ( x, u ) | . We have that f ( u ) = ( y x ) · f ( v ). Then f ( u ) = f (( y x ) · v ) because f is equivariant. Since ( x, u ) is ( V × f )-safe, | supp ( x, ( y x ) · v ) | ≤| supp ( x, u ) | . We also have that | supp ( y, v ) | = | ( y x ) · supp ( y, v ) | = | supp ( x, ( y x ) · v ) | ≤| supp ( x, u ) | Lemma 5.67.
Back- and forward-safe pairs have the following closure properties: (1) If ( f , g ) and ( f , g ) are forward-safe (backward-safe) pairs of maps then ( f × f , g × g ) is forward-safe (backward-safe). (2) If ( f i , g i ) are forward-safe (backward-safe) then ( ` f i , ` g i ) is forward-safe (backward-safe). (3) If ( f, g ) is a forward-safe (backward-safe) pair of maps then ( V × f, θ ◦ ( V × g )) isforward-safe (backward-safe).Proof. (1) Let us show first that ( f × f , g × g ) is forward-safe. Assume ( u , u ) is ( g × g ) ◦ ( f × f )-safe. By Lemma 5.50 we know that each u i is g i ◦ f i -safe, bv g f ( u ) u and bv g f ( u ) u . Since each ( f i , g i ) is forward-safe we have that f i ( u i ) is g i -safe.Moreover since bv g i ( f i ( u i )) ⊆ bv g i f i ( u i ) and supp ( f i ( u i )) ⊆ supp ( u i ) we conclude that bv g ( f ( u )) f ( u ) and bv g ( f ( u )) f ( u ). Therefore we can apply again Lemma 5.50to conclude that ( f ( u ) , f ( u )) is g × g -safe.Next we show that ( f × f , g × g ) is backward-safe when each ( f i , g i ) is. To thisend assume ( u , u ) is f × f -safe and ( f ( u ) , f ( u )) is g × g -safe. We want to showthat ( u , u ) is ( g × g ) ◦ ( f × f )-safe. By Lemma 5.50 we have that • u i is f i -safe and f i ( u i ) is g i -safe, • bv f ( u ) u and bv f ( u ) u , • bv g ( f ( u )) f ( u ) and bv g ( f ( u )) f ( u ).Since ( f i , g i ) are backward-safe the first item above implies that each u i is g i ◦ f i -safe. The next two items imply together that bv g f ( u ) u and bv g f ( u ) u . ByLemma 5.50 we conclude that ( u , u ) is ( g × g ) ◦ ( f × f )-safe.(2) As usual the case of coproducts seems trivial.(3) We first prove the lemma for forward-safe maps. Assume ( x, u ) is ( θ Y ◦ ( V × g ) ◦ ( V × f ))-safe. We will show that ( x, f ( u )) is ( θ Y ◦ ( V × g ))-safe. By Lemma 5.51 we have that( x, u ) is (( V × g ) ◦ ( V × f ))-safe. By Lemma 5.50 we have that u is ( g ◦ f )-safe and x bv gf ( u ). Since ( f, g ) is forward-safe we have that f ( u ) is g -safe. Moreover since OMINAL COALGEBRAIC DATA TYPES WITH APPLICATIONS TO LAMBDA CALCULUS 39 bv g ( f ( u )) ⊆ bv gf ( u ) we have that x bv g ( f ( u )). Therefore, by Lemma 5.50 we havethat ( x, f ( u )) is ( V × g )-safe. By Lemma 5.66 we know that ( x, f ( u )) is ( θ Y ◦ ( V × g ))-safe.Now let us prove this closure property for backward-safe maps. Assume ( x, u ) is( V × f )-safe and ( x, f ( u )) is ( θ ◦ ( V × g ))-safe. We want to show that ( x, u ) is ( θ ◦ ( V × g ) ◦ ( V × f ))-safe. By Lemma 5.50 we know that u is f -safe and x bv f ( u ). ByLemma 5.51 we know that ( x, f ( u )) is ( V × g )-safe, thus by Lemma 5.50 we know that f ( u ) is g -safe and x bv g ( f ( u )). Since ( f, g ) is backward-safe we have that u is ( g ◦ f )-safe. We can also check that x bv gf ( u ). Thus ( x, u ) is ( V × ( g ◦ f ))-safe. ApplyingLemma 5.66 we get that ( x, u ) is ( θ ◦ ( V × ( g ◦ f )))-safe. Lemma 5.68.
For every safe map f : X → Y the pair of maps ( F ( f ) , q Y ) is both backward-safe and forward-safe.Proof. The proof is by induction on the grammar of F α and Lemma 5.67. Lemma 5.69. If Xf (cid:15) (cid:15) o o p Zq (cid:15) (cid:15) W o o g Y (5.53) is a safe square then V × Xθ ◦ ( V × f ) (cid:15) (cid:15) o o V × p V × Zθ ◦ ( V × q ) (cid:15) (cid:15) [ V ] W o o [ V ] g [ V ] Y (5.54) is a safe square.Proof. We apply Lemma 5.65. Note that the pairs of maps (
V × f, θ ) and (
V × q, θ ) areforward and backward-safe by Lemma 5.67 (3).
Lemma 5.70.
For all equivariant f : X → Y the square F Y o o q Y (cid:15) (cid:15) (cid:15) (cid:15) F Xq X (cid:15) (cid:15) (cid:15) (cid:15) F α Y o o F α X (5.55) is a safe square.Proof. This is proved by induction on F α using Lemmas 5.62 and 5.69. Proposition 5.71.
For all n the squares F n o o [ − ] ( n ) α (cid:15) (cid:15) (cid:15) (cid:15) F n +1 − ] ( n +1) α (cid:15) (cid:15) (cid:15) (cid:15) F nα o o F n +1 α are safe squares. Proof.
We use induction on n . For the inductive step observe that the ( n + 1) th square isthe composition FF n o o F [ − ] ( n ) α (cid:15) (cid:15) (cid:15) (cid:15) FF n +1 F [ − ] ( n +1) α (cid:15) (cid:15) (cid:15) (cid:15) FF nα o o q F nα (cid:15) (cid:15) FF n +1 α q F n +1 α (cid:15) (cid:15) F α F nα o o F α F n +1 α F [ − ] ( n ) α , q F nα )is forward-safe and ( F [ − ] ( n +1) α , q F n +1 α ) is backward-safe. Thus, we can apply Lemma 5.65to conclude that the outer square in (5.57) is a safe square.We established the two bullet points of Corollary 5.47 in Propositions 5.59 and 5.71: Theorem 5.72.
Let F , F α be endofunctors on Nom obtained from a binding signature and q : F → F α be the natural transformation defined in 5.12. Let P be a pullback as in (5.20) .Then P → U T α is onto. Applications
In this section, we first give a general definition of substitution on the final coalgebra T α ofa functor F α coming from a binding signature. We, then, apply the general results given inthe previous sections to the infinitary λ -calculus by defining substitution and the notionsof B¨ohm, L´evy-Longo and Berarducci trees on α -equivalence classes of λ -terms.6.1. Substitution on an Arbitrary Coalgebraic Data Type.
The following lemma[Mos01, Lemma 2.1] allows parameters in coinductive definitions. It dualises the way inwhich primitive recursion strengthens induction. In order to express substitution, the set X will be used for the term N in M [ x := N ] which is not subject to recursion and the set Y will be used for the recursion. Lemma 6.1.
Let δ : D → F ( D ) be a final coalgebra and g : X → F ( X ) an arbitrary F -coalgebra. Then, there is a unique map f : Y → D such that for any h : Y → F ( X + Y ) ,the following diagram commutes: Yh (cid:15) (cid:15) f / / Dδ (cid:15) (cid:15) F ( X + Y ) F ([ g ∗ , f ]) / / F ( D ) where g ∗ : X → D is the unique homomorphism between ( X, g ) and ( D, δ ) . We apply Lemma 6.1 to define substitution on the final coalgebra T α of a functor F α coming from a binding signature. OMINAL COALGEBRAIC DATA TYPES WITH APPLICATIONS TO LAMBDA CALCULUS 41
Definition 6.2 (Substitution on α -equivalence classes of infinitary terms coming from abinding signature) . Substitution on T α is defined as the unique map such that the diagrambelow commutes: T α × V × T α h subs α (cid:15) (cid:15) subs α / / ❴❴❴❴❴❴❴❴❴❴❴❴❴❴❴ T α unfold (cid:15) (cid:15) F α ( T α + T α × V × T α ) F α ([ id , subs α ]) / / F α ( T α )where h subs α is defined in (6.1), (6.2) and (6.3).Intuitively subs α ([ t ] α , x, [ s ] α ) is given by [ t [ x := s ]] α . However, as explained in theintroduction, substitution cannot be formally defined as a total function on raw terms:additional freshness side conditions are required. See also the explanation following (6.7).In order to define the equivariant map h subs α we can use the properties of the functor F α .As observed in Proposition 5.6 such functors are Nom -enriched, or equivalently (see [Koc72]) strong . That is, there exists a natural transformation τ X,Y : F α X × Y → F α ( X × Y ) . Each functor obtained from the grammar in (5.4) can be equipped with a strength. Mostconstructions are standard and if two functors are strong so is their composition, productor coproduct. The only interesting case is that of the abstraction functor. We define astrength using the concretion of Definition 4.10. Explicitly τ X,Y : [ V ] X × Y → [ V ]( X × Y )is defined by ( h x i u, v )
7→ h y i ( h x i u @ y, v )where y is some/any fresh variable for x, u, v . By construction, τ is a well-defined andnatural in both X and Y .The map h subs α is defined as follows. • For tuples of the form ( x, x, N ) we define h subs α ( x, x, N ) as the composite T α × V × T α π / / T α unfold / / F α ( T α ) F α ( inl ) / / F α ( T α + T α × V × T α ) (6.1) • For tuples of the form ( y, x, N ) with x = y or for tuples of the form ( k, x, N ) where k isa constant, we define h subs α ( y, x, N ) as the composite T α × V × T α π / / T α unfold / / F α ( T α ) F α ( inl ) / / F α ( T α + T α × V × T α ) (6.2) • For tuples (
M, x, N ) such that M is not a variable we define h subs α ( M, x, N ) as thecomposite: T α × V × T α unfold × V × T α (cid:15) (cid:15) h subs α / / ❴❴❴❴❴❴ F α ( T α + T α × V × T α ) F α ( T α ) × V × T α τ T α , V× T α / / F α ( T α × V × T α ) F α ( inr ) O O (6.3) Since { ( x, x, N ) | x ∈ V} , { ( y, x, N ) | x = y ∈ V} , { ( k, x, N ) | k constant } and { ( M, x, N ) | M
6∈ V} are nominal sets that form a partition of T α × V × T α the map h subs α is well-defined and equivariant, thus we can apply Lemma 6.1 to prove the existenceof a unique substitution map subs α .6.2. Substitution on α -Equivalence Classes of Infinitary λ -Terms. As an examplewe spell out the concrete calculations for substitution on the nominal set Λ ∞⊥ of finite andinfinite λ -terms with ⊥ . The set Λ ∞⊥ is defined as the final coalgebra of the functor Lb defined by: Lb X = V + {⊥} + V × X + X × X. (6.4)Adding the extra constant ⊥ is needed in order to write corecursive functions that computethe B¨ohm, L´evy-Longo and Berarducci trees. We also consider the functor Lb α X = V + {⊥} + [ V ] X + X × X. (6.5) Notation 6.3.
We write Λ ∞ α for the final coalgebra of Lb α , omitting the ⊥ in the notationto improve readability. We continue to denote terms in Λ ∞⊥ ffv by M, N , but will denoteterms in Λ ∞ α by M , N . By Corollary 5.35 we have that Λ ∞ α is isomorphic to Λ ∞⊥ ffv / = α .The injections for the coproduct X + Y are denoted as inl X,Y : X → X + Y and inr X,Y : Y → X + Y . But for the case of L α ( X ), we denote them as inbot X : {⊥} → Lb α ( X ) invar X : V → Lb α ( X ) inabs X : [ V ] X → Lb α ( X ) inapp X : X × X → Lb α ( X ) . We drop the superscripts when they are clear from the context.Since unfold is an isomorphism that partitions its domain Λ ∞ α into four disjoint compo-nents, see (1.2), we write typical elements of Λ ∞ α as x , ⊥ , M M , λ y . M where x = unfold − ( invar x ) ⊥ = unfold − ( inbot ⊥ ) λ y . M = unfold − ( inabs h y i M ) M M = unfold − ( inapp ( M , M )) . (6.6)We use x to denote both an element in V and also its copy in Λ ∞ α . Example 6.4 (Substitution on α -equivalence classes of infinitary λ -terms with ⊥ ) . Byinstantiating the definition of the map h subs α given in (6.1), (6.2) and (6.3) for the functor OMINAL COALGEBRAIC DATA TYPES WITH APPLICATIONS TO LAMBDA CALCULUS 43 Lb α we obtain h subs α : Λ ∞ α × V × Λ ∞ α → Lb α ( Λ ∞ α + Λ ∞ α × V × Λ ∞ α ) given by h subs α ( x , x , N ) = unfold ( N ) h subs α ( y , x , N ) = invar y if y = xh subs α ( ⊥ , x , N ) = inbot ⊥ h subs α ( M M , x , N ) = inapp (( M , x , N ) , ( M , x , N )) h subs α ( λ y . M , x , N ) = inabs h z i (( h y i M )@ z , x , N ) if z λ y . M , x , N ) . To improve readability we omitted Lb α inr or Lb α inl in the definition of h subs α . We obtainthe substitution function subs α : Λ ∞ α × V × Λ ∞ α → Λ ∞ α given by subs α ( x , x , N ) = Nsubs α ( x , y , N ) = x if y = xsubs α ( ⊥ , y , N ) = ⊥ subs α ( M M , x , N ) = subs α ( M , x , N ) subs α ( M , x , N ) subs α ( λ y . M , x , N ) = λ y . subs α ( M , x , N ) if y x , N ) . (6.7)It should be pointed out that subs α defined in (6.7) is the ‘semantic’ version of the substi-tution map since it is defined on the (or any) final Lb α -coalgebra. It is Corollary 5.35 thatallows us to identify the element λ y . M ∈ Λ ∞ α with the α -equivalence class of an infinitaryterm [ λy.M ] α having finitely many free variables. Thus we obtain a ‘syntactic’ version ofthe substitution map which looks indeed just like a notational variant of the Set -based (1.3),but is now fully justified as a coinductive definition on α -equivalence classes of λ -terms.We can now define β -reduction using subs α . Definition 6.5 ( β -reduction on α -equivalence classes) . We define β α -reduction as the small-est relation on Λ ∞ α × Λ ∞ α that satisfies ( β α )( λ x . P ) Q → β α subs α ( P , x , Q ) P → β α P ′ ( abs ) λ x . P → β α λ x . P ′ P → β α P ′ ( app L ) PQ → β α P ′ Q Q → β α Q ′ ( app R ) PQ → β α PQ ′ We define the notion of β -head reduction which contracts only the redex at the headposition and corresponds to the normalising leftmost strategy. This reduction is used todefine B¨ohm trees. Definition 6.6 (Head β -reduction on α -equivalence classes) . We define β -reduction as thesmallest relation on Λ ∞ α × Λ ∞ α closed under ( β )( λ x . P ) Q → β subs α ( P , x , Q ) P → β P ′ ( abs ) λ x . P → β λ x . P ′ P → β P ′ P is not an abstraction ( app L ) PQ → β P ′ Q A term M is in head normal form (hnf) if it is of the form λ x . . . x n . yN . . . N m .We restrict the β -head reduction by not contracting β -redexes in the body of an ab-straction and obtain the weak head β -reduction which is needed to define the notion ofL´evy-Longo tree. Definition 6.7 (Weak head β -reduction on α -equivalence classes) . We define β -reductionas the smallest relation on Λ ∞ α × Λ ∞ α closed under( β )( λ x . P ) Q → β subs α ( P , x , Q ) P → β P ′ ( app L ) PQ → β P ′ Q A term M is in weak head normal form (whnf) if it is either a head normal form or anabstraction.We now define the notion of top β -reduction which only contracts β -weak head redexesat depth 0 and it will be used to define Berarducci trees. Definition 6.8 (Top β -reduction on α -equivalence classes) . We define β -reduction as thesmallest relation on Λ ∞ α × Λ ∞ α closed under M →→ β ( λ x . P ) ( β ) MQ → β subs α ( P , x , Q )A term M is a top normal form (tnf) if it is either a weak head normal form or an applicationof the form NP where N cannot reduce to an abstraction.The reflexive, transitive closures of → β , → β and → β are denoted by →→ β , →→ β and →→ β , respectively. The corresponding normal forms, head normal form (hnf), weak headnormal form (whnf) and top normal form (tnf), should they exist are unique.6.3. Computing the Infinite Normal Form of α -Equivalence Classes of λ -Terms. We now define the notions of B¨ohm tree, L´evy-Longo tree, and Berarducci tree using thefinality of unfold : Λ ∞ α → Lb α ( Λ ∞ α ). Definition 6.9 (B¨ohm tree on α -equivalence classes) . We define the B¨ohm tree of M as BT α ( M ) where BT α is the unique map such that Λ ∞ α g BT α (cid:15) (cid:15) BT α / / Λ ∞ α unfold (cid:15) (cid:15) Lb α ( Λ ∞ α ) Lb α ( BT α ) / / Lb α ( Λ ∞ α ) OMINAL COALGEBRAIC DATA TYPES WITH APPLICATIONS TO LAMBDA CALCULUS 45 commutes, with g BT α : Λ ∞ α → Lb α ( Λ ∞ α ) being defined as g BT α ( M ) = unfold ( N ) if M →→ β N and N is in hnf , inbot ⊥ otherwise . Definition 6.10 (L´evy-Longo tree on α -equivalence classes) . We define the L´evy-Longotree of M as LLT α ( M ) where LLT α is the unique map such that Λ ∞ α g LLT α (cid:15) (cid:15) LLT α / / Λ ∞ α unfold (cid:15) (cid:15) Lb α ( Λ ∞ α ) Lb α ( LLT α ) / / Lb α ( Λ ∞ α )commutes, with g LLT α : Λ ∞ α → Lb α ( Λ ∞ α ) being defined as g LLT α ( M ) = unfold ( N ) if M →→ β N and N is in whnf , inbot ⊥ otherwise . Definition 6.11 (Berarducci tree on α -equivalence classes) . We define the Berarducci treeof M as BeT α ( M ) where BeT α is the unique map such that Λ ∞ α g BeT α (cid:15) (cid:15) BeT α / / Λ ∞ α unfold (cid:15) (cid:15) Lb α ( Λ ∞ α ) Lb α ( BeT α ) / / Lb α ( Λ ∞ α )commutes, with g BeT α : Λ ∞ α → Lb α ( Λ ∞ α ) being defined as follows. g BeT α ( M ) = unfold ( N ) if M →→ β N and N is in tnf , inbot ⊥ otherwise . Similar to the remark on the substitution map mentioned at the end of Example 6.4, themaps BT α , LLT α and BeT α are the ‘semantic’ counterparts of the maps that compute theB¨ohm, L´evy-Longo and Berarducci trees. Corollary 5.35 allows us to obtain a ‘syntactic’version of these maps which look like a notational variant of the Set -based (3.6), (3.7)and (3.8), but are now fully justified as coinductive definitions on α -equivalence classes of λ -terms.6.4. Nominal Sets of Infinite Normal Forms and Bisimulations.
Recall the infor-mal corecursive definitions for the sets of B¨ohm, L´evy-Longo and Berarducci Trees givenin Definitions 3.3, 3.4 and 3.5. In this section, we formally define the first two ones on α -equivalence classes as an application of Corollary 5.35. In order to define the set ofBerarducci trees, one needs to extend the notion of binding signature to include infiniteproducts, which is beyond the scope of our paper. Example 6.12 (B¨ohm trees up to α -equivalence) . We define the functor S BT by S BT ( X ) = {⊥} + V + ` k [ V ] k ( V ×
List ( X )) . The final coalgebra of S BT , denoted by BT α , exists and it is isomorphic to the set ( BT ) ffv / = α of α -equivalence classes of B¨ohm trees with finitely many free variables by Corollary 5.35(see also (3.6)).The nominal set Λ ∞ α can be equipped with a S BT -coalgebra structure. Explicitly, con-sider ξ BT : Λ ∞ α → S BT ( Λ ∞ α ) defined by ξ BT ( M ) = x if M →→ β x , h x i . . . h x n i ( x , M , . . . , M n ) if M →→ β λ x . . . λ x n . xM . . . M m , ⊥ otherwise . Since BT α is the final S BT -coalgebra, we have a unique morphism BT α : Λ ∞ α → BT α suchthat the diagram below commutes. Notice that this morphism is obtained by restrictingthe codomain of the map BT α from Definition 6.9. Λ ∞ α BT α / / ξ BT (cid:15) (cid:15) BT α ≃ (cid:15) (cid:15) S BT ( Λ ∞ α ) S BT ( BT α ) / / S BT ( BT α )We can now define the head bisimulation ∼ hnf on Λ ∞ α as the kernel pair of the map BT α ,that is, M ∼ hnf N if and only if M and N have the same B¨ohm tree. Explicitly, ∼ hnf isdefined as the pullback ∼ hnf π / / π (cid:15) (cid:15) ❴✤ Λ ∞ α BT α (cid:15) (cid:15) Λ ∞ α BT α / / BT α Since [ V ]( − ) preserves pullbacks and pullbacks commute with coproducts and limits in Nom ,we have that S BT preserves pullbacks, thus the outer square of the diagram S BT ( ∼ hnf ) S BT ( π ) / / S BT ( π ) (cid:15) (cid:15) S BT ( Λ ∞ α ) S BT ( BT α ) (cid:15) (cid:15) ∼ hnf π / / π (cid:15) (cid:15) g g ❖ ❖ ❖ ❖ ❖ ❖ ❴✤ Λ ∞ α ξ BT ♣♣♣♣♣♣♣♣♣♣♣♣♣ BT α (cid:15) (cid:15) Λ ∞ α ξ BT w w ♦♦♦♦♦♦♦♦♦♦♦♦♦ BT α / / BT α ' ' ❖❖❖❖❖❖❖❖❖❖❖❖ S BT ( Λ ∞ α ) S BT ( BT α ) / / S BT ( BT α ) OMINAL COALGEBRAIC DATA TYPES WITH APPLICATIONS TO LAMBDA CALCULUS 47 is also a pullback. Therefore we obtain an S BT -coalgebra structure on ∼ hnf such that thediagram Λ ∞ α ξ BT (cid:15) (cid:15) ∼ hnf (cid:15) (cid:15) π o o π / / Λ ∞ α ξ BT (cid:15) (cid:15) S BT ( Λ ∞ α ) S BT ( ∼ hnf ) S BT ( π ) o o S BT ( π ) / / S BT ( Λ ∞ α ) (6.8)commutes. This shows that ∼ hnf is a bisimulation in the sense of [AM89]. The com-mutativity of (6.8) means that ∼ hnf is a binary relation on Λ ∞ α such that for all M and N , if M ∼ hnf N and M →→ β λ x . . . λ x n . xM . . . M m , then there are N , . . . , N m such that N →→ β λ x . . . λ x n . xN . . . N m and M i ∼ hnf N i for all 1 ≤ i ≤ m . Example 6.13 (L´evy-Longo trees up to α -equivalence) . We define the functor S LLT by S LLT ( X ) = {⊥} + [ V ] X + V ×
List ( X ) . The final coalgebra of S LLT , denoted by
LLT α , exists and is isomorphic to the set ( LLT ) ffv / = α by Corollary 5.35 (see also (3.7)).The nominal set Λ ∞ α can be equipped with an S LLT -coalgebra structure ξ LLT : Λ ∞ α → S LLT ( Λ ∞ α ) as follows: ξ LLT ( M ) = h x i N if M →→ β λ x . N , ( x , M , . . . , M n ) if M →→ β xM . . . M m , ⊥ otherwise . The unique map from ξ LLT into the final S LLT -coalgebra is given by the restriction ofthe map
LLT α from Definition 6.10 and maps the equivalence class of an infinitary λ -termto its L´evy-Longo tree.The weak head bisimulation can be defined as the kernel pair of the map LLT α : Λ ∞ α → LLT α . Similarly to the case of head simulation, we can show that ∼ whnf is a bisimulation in thesense of [AM89], namely we have an S LLT -coalgebra structure on ∼ whnf such that Λ ∞ α ξ LLT (cid:15) (cid:15) ∼ whnf (cid:15) (cid:15) π o o π / / Λ ∞ α ξ LLT (cid:15) (cid:15) S LLT ( Λ ∞ α ) S LLT ( ∼ whnf ) S LLT ( π ) o o S LLT ( π ) / / S LLT ( Λ ∞ α ) (6.9)The commutativity of the above diagram means that the weak head bisimulation ∼ whnf isa binary relation on Λ ∞ α such that for all M and N , if M ∼ whnf N , the following hold:(1) M →→ β λ x . M then N →→ β λ x . N and M ∼ whnf N .(2) M →→ β xM . . . M m then N →→ β xN . . . N m and M i ∼ whnf N i for all 1 ≤ i ≤ m . Example 6.14 (Berarducci trees up to α -equivalence) . By Theorem 5.4, the final coalgebraof S BerT exists where S BerT ( X ) = [ V ] X + {⊥} × List ( X ) + V ×
List ( X ) + Stream ( X ) However, we cannot apply Corollary 5.35 in this case because our current definition ofbinding signatures does not include infinite products, e.g.
Stream .6.5.
Infinitely Many Free Variables.
In this section we follow a suggestion from Pittsto treat the case of terms with infinitely many free variables. In Theorem 5.19 we provedthat (Λ ∞ / = α , d ∞ α ) is isomorphic to (Λ / = α ) ∞ provided that V is uncountable. However,the isomorphism does not hold if V is countable (Example 5.20). Moreover, even if V iscountable and the set (Λ / = α ) ∞ can be equipped with a permutation action, (Λ / = α ) ∞ is nota nominal set, since the terms with infinitely many free variables are not finitely supported.One way to deal with terms with infinitely many free variables, without leaving the worldof nominal sets, is to extend the calculus with constants and to regard the free variables asconstants.Let C be a countable set of names. The sets Λ( C ) and Λ( C ) ∞ are the sets Λ and Λ ∞ extended with a set of constants C . We can equip the set C with the trivial permutationaction and consider the functor L α + C : Nom → Nom . The following proposition followsfrom [Pit11, Theorem 5.12], or [Pit06, Theorem 5.1, Remark 5.3].
Proposition 6.15.
The initial algebra of L α + C is the nominal set Λ( C ) / = α of λ -termsextended with C -constants up to α -equivalence. The following proposition follows from Corollary 5.35 since L α + C is a functor obtainedfrom a binding signature (see Definition 5.8 and Proposition 5.6). Proposition 6.16.
The final coalgebra of L α + C is isomorphic to the nominal sets (Λ( C ) / = α ) ∞ fs and Λ( C ) ∞ ffv / = α . Proposition 6.17.
Let ρ : V → C be a bijection. We have an isomorphism Tr between Λ / = α and the set of closed terms in (Λ( C ) / = α ) .Proof. The map Tr : Λ → Λ( C ) is defined inductively as follows: Tr ( x ) = ρ ( x ) Tr ( M N ) = Tr ( M ) Tr ( N ) Tr ( λx.M ) = λx. Tr ( M )[ x/ρ ( x )]where Tr ( M )[ x/ρ ( x )] is the result of replacing ρ ( x ) by x in Tr ( M ).It is easy to check that if M = α N then Tr ( M ) = α Tr ( N ). Hence, Tr can be definedon equivalence classes and we have Tr : Λ / = α → (Λ( C ) / = α ) . Note that the map Tr is notfinitely supported. For example, Tr (( xy ) · x ) = ( xy ) · Tr ( x ) if ρ ( x ) = ρ ( y ). Hence, we cannotapply Pitts’ alpha structural induction principle.The inverse of Tr is defined as follows. Given an α -equivalence class [ M ] α ∈ (Λ( C ) / = α ) ,we can find a representative M ∈ Λ( C ) such that the set of bound variables of M is disjointfrom the image under ρ − of the constants occurring in M . We put Tr − ( M ) to be theequivalence class of the term obtained by replacing each constant b occurring in M by ρ − ( b ). OMINAL COALGEBRAIC DATA TYPES WITH APPLICATIONS TO LAMBDA CALCULUS 49
Proposition 6.18.
The set (Λ / = α ) ∞ is isomorphic to (Λ( C ) ∞ ffv / = α ) .Proof. By the universal property of the Cauchy completion, Tr is extended to an isomor-phism between (Λ / = α ) ∞ and the completion of (Λ( C ) / = α ) . The proof is complete by ob-serving that the isomorphism between (Λ( C ) / = α ) ∞ fs and Λ( C ) ∞ ffv / = α (see Proposition 6.16)cuts down to an isomorphism between the completion of (Λ( C ) / = α ) and (Λ( C ) ∞ ffv / = α ) .Explicitly, given a Cauchy sequence in Λ / = α , the image under Tr is a finitely supported Cauchy sequence in (Λ( C ) / = α ) , and thus also in Λ( C ) / = α . Thus it converges to a uniqueelement of (Λ( C ) ∞ ffv / = α ) . Conversely, given M ∈ (Λ( C ) ∞ ffv / = α ) , we consider the trunca-tions M n . Their translations Tr − ( M n ) in Λ / = α form a Cauchy sequence and we map M to its limit.Substitution is defined on Λ( C ) ∞ ffv / = α by instantiating Definition 6.2. Now, β -reductionrestricts to (Λ( C ) ∞ ffv / = α ) and can be defined on (Λ / = α ) ∞ via the translation Tr . Weillustrate how this works with an example. Example 6.19.
Consider the term ( λx x .x x ) allfv , where allfv = x ( x ( x ( . . . ))) givenin (1.4). Suppose C = { c , c , . . . } and ρ ( x i ) = c i for all i .Then, Tr (( λx x .x x ) allfv ) = ( λx x .x x ) allconst where allconst = c ( c ( c ( . . . ))). The translated term does not contain free variables, butbound variables and constants only. It is important to stress the fact that the constantsrepresent the free variables of the original term. We can now safely perform the β -step( λx x .x x ) allconst → β ( λx .x x )[ x := allconst ] = λx . allconst x . (6.10)This β -step is possible because substitution is defined on the set (Λ( C ) ∞ ffv / = α ). Accordingto Proposition 6.18, the equivalence class [ λx . allconst x ] α translates back to an element in(Λ / = α ) ∞ which is the limit of the Cauchy sequence ([ λx n .x ( x . . . ( x n − ∗ )) x n ] α ) n . Similarto Example 5.20, it does not have any preimage under [ − ] α : Λ ∞ → (Λ / = α ) ∞ .7. Related and Future Work
The problem of having insufficiently many fresh variables does not arise if we use de Bruijnindices [dB72, Dup00]. However, it is unclear whether using de Bruijn indices could lead toa coalgebraic treatment of the corecursion principle.It would also be interesting to investigate nominal coalgebraic data types with infinitelymany free variables based on either Section 6.5 or on variations of nominal sets allowingcountable supports, see e.g. [Che06, DG12]. This could have applications to the semanticsof processes which are able to generate infinitely many fresh names.Using the ‘same’ endofunctor as [GP99], but on a different category, namely the category
Set F of presheaves on finite sets, [FPT99] also exhibits finite λ -terms as an initial algebra.Roughly speaking, the difference between Nom and
Set F is that the latter already comesequipped with a notion of substitution, see [Sta07, Section 7.3] for details. [MU04] furtherdevelop substitution for algebraic and coalgebraic datatypes over presheaf-categories anddescribe the set of infinitary λ -terms as a final coalgebra. [AMV11] furthermore studythe so-called rational fixed point, again over Set F , as a semantic universe for solutions ofhigher-order recursion schemes. In [HvO03], the authors define a calculus with an operator called adbmal to deal with α -conversion. This operator removes the scope of a variable. It will be interesting to extendthis calculus for infinite terms. Using this operator, it would give an alternative approachto dealing with the problem of having insufficient fresh variables.Nominal Isabelle provides infrastructure for declaring nominal data types and definingrecursive functions over them [Urb08]. Proposals for codata types in Isabelle are presentedin [TPB12]. It will be nice to include nominal codata types in Isabelle in order to formalisethe proofs of some theorems on λ -calculus concerning B¨ohm trees and infinitary λ -calculus.Nominal extensions of typed λ -calculus have been proposed in [Pit10, Che09] for systemT, in [Che12] for LF and in [WSA09] for the Calculus of Inductive Constructions. Furtherresearch could include a study of typing that combines nominal syntax with coinductivedata types.The corecursion principle presented in this paper cannot handle infinitary meta-terms asdefined for Infinitary Combinatory Reduction Systems (iCRS) [KS11]. It will be interestingto prove an α -coinduction principle that includes meta-variables and meta-terms. However,it is not straightforward to define α -equivalence on them [FG07].One could also study how to extend the notion of binding signature and Corollary 5.35to include infinite products for representing the set of Berarducci trees up to α (see Example6.14). Another possible solution, suggested by a referee, would be to use a version of Bekiˇclemma [LS81, BBvGvdW95, Fre92] and to replace a nested final coalgebra by a non-nestedmany-sorted one.It will also be worthwhile to study α -corecursion principles for sets of infinitary termsobtained from alternative metrics such as the 001- and 101-metrics [KKSdV97] or the metricthat captures the infinite normal forms of reactive programs [SdV12]. Also, meta-terms forInfinitary Combinatory Reduction Systems that satisfy the finite property chain can bedefined using an alternative metric ([KS11, page 20]). Acknowledgements
We are grateful to Andy Pitts for suggesting us to treat the infinitely many free variables ofa term as constants. We would also like to thank Christian Urban for helpful discussions.Finally, we acknowledge insightful improvements suggested by the referees.
References [Abr90] S. Abramsky. The lazy lambda calculus. In
Research Topics in Functional Programming ,pages 65–116. Addison-Wesley, 1990.[Ad´a03] J. Ad´amek. On final coalgebras of continuous functors.
Theoretical Computer Science ,294(1/2):3–29, 2003.[AM89] P. Aczel and N. P. Mendler. A final coalgebra theorem. In
CTCS , pages 357–365, 1989.[AMV11] J. Ad´amek, S. Milius, and J. Velebil. Semantics of higher-order recursion schemes.
LogicalMethods in Computer Science , 7(1), 2011.[AN80] A. Arnold and M. Nivat. The metric space of infinite trees. algebraic and topological prop-erties.
Fundamenta Informaticae , 4:445–476, 1980.[AO93] S. Abramsky and C.-H. Luke Ong. Full abstraction in the lazy lambda calculus.
Informationand Computation , 105(2):159–267, 1993.[AR94] J. Ad´amek and J. Rosicky.
Locally Presentable and Accessible Categories . Cambridge Uni-versity Press, 1994.
OMINAL COALGEBRAIC DATA TYPES WITH APPLICATIONS TO LAMBDA CALCULUS 51 [Bar84] H. P. Barendregt.
The Lambda Calculus: Its Syntax and Semantics . North-Holland, Ams-terdam, Revised edition, 1984.[Bar99] M. Barr. Terminal coalgebras for endofunctors on sets.
Theoretical Computer Science ,114(2):299–315, 1999.[BBKL12] M. Bojanczyk, L. Braud, B. Klin, and S. Lasota. Towards nominal computation. In
POPL ,pages 401–412, 2012.[BBvGvdW95] R. C. Backhouse, M. Bijsterveld, R. van Geldrop, and J. van der Woude. Categorical fixedpoint calculus. In
Category Theory and Computer Science , pages 159–179, 1995.[Ber96] A. Berarducci. Infinite λ -calculus and non-sensible models. In Logic and algebra (Pontignano,1994) , pages 339–377. Dekker, New York, 1996.[Che06] J. Cheney. Completeness and Herbrand theorems for nominal logic.
Journal of SymbolicLogic , 71(1):299–320, 2006.[Che09] J. Cheney. A simple nominal type theory.
Electronic Notes on Theoretical Computer Science ,228:37–52, 2009.[Che12] J. Cheney. A dependent nominal type theory.
Logical Methods in Computer Science , 8(1),2012.[dB72] N. G. de Bruijn. Lambda Calculus Notation with Nameless Dummies, a Tool for AutomaticFormula Manipulation, with applications to the Church-Rosser Theorem.
Indagationes Math-ematicae , 34:381–392, 1972.[DG12] G. Dowek and M. J. Gabbay. Permissive-nominal logic: First-order logic over nomi-nal terms and sets.
ACM Transactions on Computational Logic
Information and Computation ,205(6):917–965, 2007.[FPT99] M. Fiore, G. D. Plotkin, and D. Turi. Abstract syntax and variable binders. In
LICS , pages193–202, 1999.[Fre92] P. Freyd. Remarks on algebraically compact categories. In
Applications of Categories inComputer Science , volume 77 of
London Math. Soc. Lecture Notes Series , pages 95 – 106.Cambridge University Press, 1992.[GP99] M. J. Gabbay and A. M. Pitts. A new approach to abstract syntax involving binders. In
LICS , pages 214–224, 1999.[GP01] M. J. Gabbay and A. M. Pitts. A new approach to abstract syntax with variable binding.
Formal Aspects of Computing , 13(3–5):341–363, 2001.[Hof99] M. Hofmann. Semantical analysis of higher-order abstract syntax. In
LICS , pages 204–213,1999.[HvO03] D. Hendriks and V. van Oostrom. Adbmal. In
CADE , pages 136–150, 2003.[Jec73] T. Jech.
The axiom of choice . North-Holland, 1973.[KdV03] J. R. Kennaway and F. J. de Vries. Infinitary rewriting. In Terese, editor,
Term RewritingSystems , volume 55 of
Cambridge Tracts in Theoretical Computer Science , pages 668–711.Cambridge University Press, 2003.[Kel82] M. Kelly.
Basic Concepts of Enriched Category Theory . Number 64 in London MathematicalSociety Lecture Notes. Cambridge University Press, 1982.[KKSdV95] J. R. Kennaway, J. W. Klop, M. R. Sleep, and F. J. de Vries. Infinite lambda calculus andB¨ohm models. In
RTA , pages 257–270, 1995.[KKSdV97] J. R. Kennaway, J. W. Klop, M. R. Sleep, and F. J. de Vries. Infinitary lambda calculus.
Theoretical Computer Science , 175(1):93–125, 1997.[Koc72] A. Kock. Strong functors and monoidal monads.
Archiv der Mathematik , 23(1):113–120,1972.[KPSdV12] A. Kurz, D. Petri¸san, P. G. Severi, and F. J. de Vries. An alpha-corecursion principle for theinfinitary lambda calculus. In
CMCS , pages 130–149, 2012.[KS11] J. Ketema and J. Grue Simonsen. Infinitary combinatory reduction systems.
Informationand Computation , 209(6):893–926, 2011. [L´ev76] J.-J. L´evy. An algebraic interpretation of the λβK -calculus, and an application of a labelled λ -calculus. Theoretical Computer Science , 2(1):97–114, 1976.[Lon83] G. Longo. Set-theoretical models of λ -calculus: theories, expansions, isomorphisms. Annalsof Pure and Applied Logic , 24(2):153–188, 1983.[LS81] D. J. Lehmann and M. B. Smyth. Algebraic specification of data types: A synthetic approach.
Mathematical Systems Theory , 14:97–139, 1981.[Mos01] L. S. Moss. Parametric corecursion.
Theoretical Computer Science , 260:139–163, 2001.[MU04] R. Matthes and T. Uustalu. Substitution in non-wellfounded syntax with variable binding.
Theoretical Computer Science , 327:155–174, 2004.[Pet12] D. Petri¸san.
Investigations into Algebra and Topology over Nominal Sets . PhD thesis, Uni-versity of Leicester, 2012.[Pit03] A. M. Pitts. Nominal logic, a first order theory of names and binding.
Information andComputation , 186:165–193, 2003.[Pit05] A. M. Pitts. Alpha-structural recursion and induction. In
TPHOLs , pages 17–34, 2005.[Pit06] A. M. Pitts. Alpha-structural recursion and induction.
Journal of the ACM , 53:459–506,2006.[Pit10] A. M. Pitts. Nominal system T. In
POPL , pages 159–170, 2010.[Pit11] A. M. Pitts. Nominal sets. Notes for Midlands Graduate School, 2011.[Pit13] A. M. Pitts.
Nominal Sets . Cambridge University Press, 2013.[Sal01] A. Salibra. Nonmodularity results for lambda calculus.
Fundamenta Informaticae , 45:379–392, 2001.[SdV11] P. G. Severi and F. J. de Vries. Weakening the axiom of overlap in the infinitary lambdacalculus. In
RTA , pages 313–328, 2011.[SdV12] P. G. Severi and F. J. de Vries. Pure type systems with corecursion on streams: from finiteto infinitary normalisation. In
ICFP , pages 141–152, 2012.[Sta07] S. Staton. Name-passing process calculi: operational models and structural operational se-mantics. Technical Report UCAM-CL-TR-688, University of Cambridge, Computer Labo-ratory, June 2007.[TPB12] D. Traytel, A. Popescu, and J. C. Blanchette. Foundational, compositional (co)datatypesfor higher-order logic: Category theory applied to theorem proving. In
LICS , pages 596–605,2012.[Urb08] C. Urban. Nominal techniques in Isabelle/HOL.
Journal of Automated Reasoning , 40(4):327–356, 2008.[WSA09] E. M. Westbrook, A. Stump, and E. Austin. The calculus of nominal inductive constructions:an intensional approach to encoding name-bindings. In
LFMTP , pages 74–83, 2009.
This work is licensed under the Creative Commons Attribution-NoDerivs License. To viewa copy of this license, visit http://creativecommons.org/licenses/by-nd/2.0/http://creativecommons.org/licenses/by-nd/2.0/