Semantics of Higher-Order Recursion Schemes

Higher-order recursion schemes are recursive equations defining new operations from given ones called"terminals". Every such recursion scheme is proved to have a least interpreted semantics in every Scott's model of \lambda-calculus in which the terminals are interpreted as continuous operations. For the uninterpreted semantics based on infinite \lambda-terms we follow the idea of Fiore, Plotkin and Turi and work in the category of sets in context, which are presheaves on the category of finite sets. Fiore et al showed how to capture the type of variable binding in \lambda-calculus by an endofunctor H\lambda and they explained simultaneous substitution of \lambda-terms by proving that the presheaf of \lambda-terms is an initial H\lambda-monoid. Here we work with the presheaf of rational infinite \lambda-terms and prove that this is an initial iterative H\lambda-monoid. We conclude that every guarded higher-order recursion scheme has a unique uninterpreted solution in this monoid.


Introduction
The present paper is a contribution to the study of the semantics of recursive definitions using category-theoretic tools and methods. Our goal is to present a category-theoretic semantics of higher-order recursion schemes in the sense of W. Damm [8]. To reach this goal we apply the theory of rational monads on a category K , developed in our previous work [2] in order to formalize iteration in algebra, to the category K = Set F (F = finite sets and functions) of sets in context. We use the approach to λ-calculus based on H-monoids in the category of sets in context due to M. Fiore, G. Plotkin and D. Turi [10]. Our main result is a description of the initial iterative H-monoid as the monoid of rational λ-terms, and the fact that in this monoid every higher-order recursion scheme has a unique uninterpreted solution. We now explain the motivation of our paper in more detail. In the higher-order semantics we assume a given collection Σ of existing programs of given types (that is, a manysorted signature of "terminals"). One recursively defines new typed programs p 1 , . . . , p n (forming a many-sorted signature of "nonterminals") using symbols from Σ and {p 1 , . . . , p n }. If the recursion only concerns application, we can formalize this as a collection of equations p i = f i (i = 1, . . . , n) (1.1) whose right-hand sides f i are terms in the signature of all terminals and all non-terminals. Such collections are called (first-order) recursion schemes and were studied in 1970's by various authors, e.g. B. Courcelle, M. Nivat and I. Guessarian (see the monograph [12] and references there) or S. J. Garland and D. C. Luckham [11]. Recently, a categorical approach to semantics of first-order recursion schemes was presented by S. Milius and L. Moss [18].
In the present paper we take a first step in an analogous approach to the semantics of higher-order recursion schemes in which λ-abstraction is also used as one of the operations. That is, a higher-order recursion scheme, as introduced by W. Damm [8] (see also the recent contributions [7] and [19]) is a collection of equations p i = f i where f i are terms using application and λ-abstraction on symbols from Σ and {p 1 , . . . , p n }. As in [18], we first study the uninterpreted semantics, where the given system is regarded as a purely syntactic construct. At this stage the operation symbols in Σ as well as λ-abstraction and application have no interpretation on actual data. So the semantics is provided by formal (infinite) terms. These terms can be represented by rational trees, i. e., infinite trees having finitely many subtrees. Thus the uninterpreted solution assigns to each of the recursive variables p i in (1.1) a rational tree p † i such that the formal equations become identities if we substitute p † i for p i (i = 1, . . . , n). We assume α-conversion (renaming of bound variables) but no other rules in the uninterpreted semantics. We next turn to an interpreted semantics. Here a recursion scheme is given together with an interpretation of all symbols from Σ as well as λ-abstraction and application. Following D. Scott, we interpret the λ-calculus on a CPO, say D. The symbols of Σ are interpreted as continuous operations on D, and formal λ-abstraction and application are the actual λ-abstraction and application in the model D. An interpreted solution in D then assigns to each p i in the context Γ of all free variables in (1.1) an element of CPO(D Γ , D) (continuously giving to each assignment of free variables in D Γ an element of D) such that the formal equations in the recursion scheme become identities in D when the right-hand sides are interpreted in D.
Example 1.1. The fixed-point operator Y is specified by and the uninterpreted semantics is the rational tree (The symbol @ makes application explicit.) The interpreted solution in D is the least fixed point operator (considered as an element of D).
The above example is untyped, and indeed we are only treating the untyped case in the present paper since its uninterpreted semantics is technically simpler than the typed case; however, the basic ideas of uninterpreted semantics are similar. In contrast, the interpreted semantics (based on a specified model of λ-calculus with "terminal" symbols interpreted as operations) is more subtle in the untyped case.
Our main result is that every guarded higher-order recursion scheme has a unique uninterpreted solution, and a least interpreted one. This demonstrates that the methods for iteration in locally finitely presentable categories developed in [2] can serve not only for first-order iteration, when applied to endofunctors of Set, but also for higher-order iteration: it is possible to apply these methods to other categories, here the category of sets in context. Related Work. This is an extended and revised version of the conference paper [4]. In addition to the material in that extended abstract we include here the theory of iterative monoids in a monoidal category, see Section 4 below, and we provide detailed proofs.
(1) Throughout the paper a given countably infinite set Var of variables is assumed. Finite subsets Γ ⊆ Var are called contexts and form a full subcategory F of Set. We also assume that a (possibly empty) finitary signature Σ is given. When speaking about formulas in context Γ we mean those that have all free variables in Γ. For example, λx.yx is a formula in context Γ = {y, y ′ }.
(2) The category Set F of "covariant presheaves" on F is well known to be equivalent to the category of finitary endofunctors of Set. Indeed, every endofunctor X yields the presheaf X ↾ F , and conversely, every presheaf X in Set F has a left Kan extension to a finitary endofunctor of Set: for every set M we have where the union ranges over embeddings i Γ : Γ ֒→ M of contexts Γ into M , and Xi Γ [X(Γ)] denotes the image of Xi Γ . (3) From now on we speak about presheaves when objects of Set F are meant. The word endofunctor is reserved for endofunctors on Set F throughout our paper.

Example 2.2.
(i) The presheaf of variables, V , is our name for the embedding F ֒→ Set: V (Γ) = Γ. As we will see in Section 3, V is the unit of the monoidal operation of substitution. (ii) Free presheaf on one generator of context Γ is our name for the representable presheaf Indeed, the Yoneda lemma states that this presheaf is freely generated by the element id Γ of context Γ: for every presheaf X and every x ∈ X(Γ) there exists a unique morphism f : F (Γ, −) → X with f Γ (id Γ ) = x. Observe that F (Γ, −) is naturally isomorphic to the functor X → X n , where n = card Γ is the power of Γ. Consequently a free presheaf on k generators in contexts Γ 1 , . . . , Γ k has the form This is the "polynomial presheaf" X Σ of a signature Σ of k operation symbols of the given arities n i . (iii) The presheaf F λ of (finite) λ-terms is defined via a quotient since we want to treat λ-terms always modulo α-conversion. We first consider the set of all λ-trees τ given by the grammar τ ::= x | τ @ τ | λy.τ (x, y ∈ Var).
(2.1) In the graphic form: The notions of a free and bound variable of a λ-tree τ are defined as usual. As explained in [10], the following approach is equivalent to defining λ-terms up to α-equivalence by de Bruijn levels: We first denote by F ′ λ (Γ) the set of all finite λ-trees with free variables in the context Γ = {x 1 , . . . , x n }. We then define the presheaf F λ in context Γ by F λ (Γ) = F ′ λ (Γ)/∼ α where ∼ α represents the α-conversion: this is the least congruence with λy.τ ∼ α λz.τ z y , where z is not a free variable of τ . And we define F λ on morphisms γ : Γ → Γ ′ by choosing a term t ∈ F λ (Γ), relabelling all bound variables so that they do not lie in Γ ′ , and denoting by F λ γ(t) the term obtained by relabelling every free variable x ∈ Γ to γ(x) ∈ Γ ′ .
We call the congruence classes of finite λ-trees modulo α-conversion finite λ-terms. (Finite λ-trees do not form a presheaf, due to possible clashes of bound and free variables. For example consider the λ-tree λx @ x y / / / / in F ′ λ { y } and the function j : { y } → Γ with x ∈ Γ and j(y) = x. Then to define the action of F ′ λ on j we must rename the bound variable x to some z ∈ Γ. But in fact, any other renaming to z ′ ∈ Γ is fine, too. So trying to define the action of F ′ λ on functions naturally forces us to consider equivalence classes modulo α-conversion.) (iv) The presheaf F λ,Σ of finite λ-Σ-terms is defined analogously: in (2.1) we just add the term σ(τ 1 , . . . , τ n ) for every n-ary operation symbol σ ∈ Σ, and in (2.2) the corresponding tree.

5
(v) The presheaf T λ of all (finite and infinite) λ-terms is defined analogously to F λ . We first denote by T ′ λ (Γ) the set of all trees (2.2) dropping the assumption of finiteness. Then we use α-conversion: for infinite trees t and t ′ we write t ∼ α t ′ if their (finite) cuttings at level k (with label ⊥ for all leaves at level k) are α-equivalent in the above sense for all k ∈ N. (We can formalize this by using Σ ⊥ = Σ ∪ { ⊥ } with ⊥ a constant symbol outside of Σ ∪ Var). The presheaf T λ is defined on objects Γ by T λ (Γ) = T ′ λ (Γ)/∼ α and on morphisms γ : Γ → Γ ′ by relabellings of variables as in (iii). Observe that since Var \Γ is infinite, the relabelling of bound variables needed here causes no problem. (vi) The presheaf R λ of rational λ-terms is also defined analogously. Recall that a tree is called rational if it has up to isomorphism only finitely many subtrees. We denote by R ′ λ (Γ) the set of all rational trees in T ′ λ (Γ) and define a presheaf R λ by R λ (Γ) = R ′ λ (Γ)/∼ α on objects, and by relabellings of variables (as in (iii)) on morphisms. Observe that, by definition, every rational λ-term t is represented by a rational λtree. However, t can also be represented by non-rational λ-trees-for example, if it contains infinitely many λ's, the α-conversion can introduce an infinite number of bound variables. (vii) The presheaves T λ,Σ (of all λ-Σ-terms) and R λ,Σ (of rational λ-Σ-terms) are obvious modifications of (iv) and (v): one adds to (2.1) and (2.2) the case σ(τ 1 , . . . , τ n ) for all n-ary symbols σ ∈ Σ and all (rational) λ-Σ-trees τ 1 , . . . , τ n . Notation 2.3. We denote by δ : Set F → Set F the endofunctor defined by δX(Γ) = X(Γ + 1).
Observe that δ preserves limits and colimits. Note that an algebra for δ is a presheaf Y together with an operation Y (Γ + 1) → Y (Γ) for all contexts Γ-this is precisely the form of λ-abstraction, where to a formula f in Y (Γ + {y}) we assign λy.f in Y (Γ). The other λ-operation, application, is simply a presheaf morphism X × X → X, that is, a binary operation on X. We put these two together: Notation 2.4. Let H λ denote the endofunctor of Set F given by Thus, an algebra for H λ is a presheaf X together with operations of application X(Γ) × X(Γ) → X(Γ) and abstraction X(Γ + 1) → X(Γ) for all contexts Γ; these operations are compatible with the renaming of free variables.
Example 2.5. The presheaves F λ , T λ and R λ are algebras for H λ in the obvious sense.
(i) The slice category V / Set F of presheaves X together with a morphism i : V → X is called the category of pointed presheaves. For example F λ is a pointed presheaf in a canonical sense: i F : V → F λ takes a variable x to the term x. Analogously i T : V → T λ and i R : V → R λ are pointed presheaves, and so are F λ,Σ , R λ,Σ and T λ,Σ . (ii) Recall that the category Alg H λ of algebras for H λ has as morphisms the usual H λhomomorphisms, i.e., a morphism from a : Then Alg H λ is a concrete category over Set F with the forgetful functor (H λ X → X) → X.
Theorem 2.7 (see [10]). The presheaf F λ of finite λ-terms is the free H λ -algebra on V .
Definition 2.8 (see [2]). Given an endofunctor H, an algebra a : HA → A is called (1) completely iterative (cia for short) if for every object X (of variables) and every (flat equation) morphism e : X → HX + A there exists a unique solution which means a unique morphism e † : X → A such that the square below commutes (2) iterative if every equation morphism e : X → HX + A with X finitely presentable has a unique solution e † : X → A.
We are going to characterize finitely presentable presheaves in Theorem 2. 16. In practice, we are interested only in equations using free presheaves (on polynomial endofunctors of Set) as X, but including the more general concept does not "disturb" anything as we explain in Remark 5.2. Example 2.9. As proved in [17], Corollary 6.3, the free completely iterative algebra for an arbitrary finitary endofunctor H on an object X is precisely the terminal coalgebra for H(−) + X. More detailed, suppose T X is the terminal coalgebra for H(−) + X, then its structure morphism is an isomorphism by Lambek's Lemma and the inverse of this morphism has the components τ X : HT X → T X and η T X : X → T X making T X a free cia on X.
Conversely, let τ X : HT X → T X be a cia which is free on X w.r.t. the universal arrow η T X . Then [τ X , η T X ] : HT X + X → T X is an isomorphism, and its inverse is the structure of the terminal coalgebra for H(−) + X.
Theorem 2.10. The presheaf T λ of infinite λ-terms is the free completely iterative H λalgebra on V .
Proof. As explained in Example 2.9 above, the free completely iterative algebra for H λ on V is precisely the terminal coalgebra for H λ (−)+V . The latter functor clearly preserves limits of ω op -chains. Consequently, its terminal coalgebra is a limit of the chain W with W 0 = 1 (the terminal presheaf) and W n+1 = H λ W n + V , where the connecting maps are the unique w 0 : W 1 → W 0 and w n+1 = H λ w n + id V .
Observe first that the limit of W is computed objectwise. So for every context Γ we can identify W 0 (Γ) with the set {⊥} where ⊥ / ∈ Var, and we have An easy induction proof now shows that W n (Γ) can be identified with the set of all λterms in context Γ of depth at most n having all leaves of depth n labelled by ⊥. And w n+1 : W n+1 → W n cuts away the level n + 1 in the trees of W n+1 (Γ), relabelling level-n leaves by ⊥. With this identification we obtain T λ as a limit of W n where the limit maps T λ → W n cut the trees in T λ (Γ) at level n and relabel level-n leaves by ⊥.
Example 2.11. The complete iterativity of the algebra T λ means that we are able to solve systems of recursive equations such as Indeed, the solution in T λ ({y}) is formed by the λ-terms represented by the following treeŝ t 1 andt 2 : How is this related to the above concept of Definition 2.8? Firstly, every system of recursive equations can be flattened: a flat system has in context Γ the right-hand sides of only three types: p i @ p j or λx.p i or a term in T λ (Γ). For example, we flatten the system (2.4) to Let Γ = {y} be the context of all free variables and let X be the free presheaf on generators p 1 , . . . , p 4 of context Γ, see Example 2.2. Notice that even though the recursion variables p 1 , . . . , p 4 appear as constants in the system (2.5), the associated presheaf X is not a constant presheaf. Using the Yoneda lemma, the above system (2.5) defines an obvious morphism e : X → H λ X + T λ viz, the unique one such that e Γ (p i ) is the right-hand side of the equation above. The solution e † : X → T λ is the unique morphism such that e † Γ takes p i to the solution in T λ ; for example e † Γ (p 1 ) = [t 1 ] for the above treet 1 . We will see in Theorem 5.7 below that equations such as (2.5) have a unique solution yielding rational trees.
. Due to the commutativity of (2.3) for H λ X = X × X + δX we have three possible cases for every p: Remark 2.13. We are going to characterize the presheaf R λ as a free iterative algebra for H λ . That is, in equations we admit only presheaves X of variables that are finitely presentable. Recall that an object X of a category W is finitely presentable provided that its hom-functor W (X, −) preserves filtered colimits. We are first going to characterize the finitely presentable presheaves by using the following concept: Definition 2.14 (see [4]). A presheaf X is called super-finitary provided that each X(Γ) is finite and there exists a nonempty context Γ 0 generating X in the sense that for every nonempty context Γ we have . This is a super-finitary presheaf iff Σ is a finite signature. Other super-finitary presheaves are precisely the quotients of X Σ with Σ finite.
Theorem 2.16. A presheaf in Set F is finitely presentable iff it is super-finitary.

SEMANTICS OF HIGHER-ORDER RECURSION SCHEMES 9
Proof.
(1) Let X be a super-finitary presheaf and let Γ 0 be a context of n variables generating X. We prove that X is a finite colimit of representables. Since representables are (due to Yoneda lemma) clearly finitely presentable, this proves finite presentability of X.
Form the finite diagram of all presheaves where Γ ⊆ Γ 0 + Γ 0 is a context of at most 2n variables 1 and a ∈ X(Γ). The connecting morphisms are the Yoneda transformations clearly form a compatible cocone of this finite diagram. We prove that this is a colimit cocone. In other words, for every contextΓ we must prove that the cocone of allΓcomponents zΓ a (sending elements f : For that we only need to verify that in every contextΓ (i) the cocone zΓ a is collectively epimorphic, and (ii) whenever two elements f : Γ →Γ of Z a and f ′ : then there exists a zig-zag connecting f and f ′ in theΓ-component of our diagram. The proof of (i) is trivial: given an element a ∈ X(Γ), eitherΓ = ∅ or by Equation (2.6) there exists f : Γ 0 →Γ and an element b ∈ X(Γ 0 ) with a = Xf (b), in other words, In caseΓ = ∅ we have a = zΓ a (id ∅ ).
To prove (ii), observe that the given equation states In caseΓ has at most 2n variables, we can assumeΓ ⊆ Γ 0 + Γ 0 and the desired zig-zag is where b = Xf (a). Thus, we can assume thatΓ has more than 2n elements.
Here f = f ′ and we have Xf (a) = Xf (a ′ ). Choose a monomorphism m : Γ 0 →Γ and observe that f = m·g for the unique g : ∅ → Γ 0 . Thus Xm(Xg(a)) = Xm(Xg(a ′ )) and since m is a split monomorphism, we conclude Factorize f ′ as an epimorphism e followed by a split monomorphism m: Then, since for the unique h : ∅ → Γ 1 we have f = m·h, we obtain Xm Xe(a ′ ) = Xm Xh(a) .
Case 3: Γ as an epimorphism followed by a split monomorphism; so we obtain a commutative diagram Since m is a split monomorphism, conclude that (2) Let X be a finitely presentable object of Set F . The empty maps are denoted by t Γ : ∅ → Γ. For every nonempty context Γ 0 let X Γ 0 be the subfunctor of X generated by the elements of X(Γ 0 ) ∪ X(∅): it assigns to every Γ the subset of X(Γ) given by We obviously have a union X = factorizes through one of the colimit injections X Γ 0 ֒→ X. In other words It remains to prove that the sets X(Γ 0 ) and X(∅) are finite, then every X(Γ) is finite. For every finite set M ⊆ X(∅) we have the subfunctor X M of X equal to X on nonempty objects and maps, and assigning M to ∅. We obviously get X as a directed union of these subfunctors X M , thus, as above, there exists M with X = X M . Then X(∅) = M is finite.
For every finite set M ⊆ X(Γ 0 ) we have the subfunctor M X of X = X Γ 0 generated by the elements of M ∪ X(∅): Again X is a directed union of these subfunctors M X, thus, there exists M with X = M X, proving that X(Γ 0 ) is finite.
Proof. (I) R λ is an iterative algebra for H λ . Indeed, given an equation morphism where Equation (2.6) holds for Γ 0 , we know that its extension has a unique solution e † : X → T λ , and we are going to prove that the trees e † Γ 0 (p) and e † ∅ (p) are all rational. It then follows that all the trees e † Γ (p) are rational for all contexts Γ, and this gives us the desired solution 3) we also obtain in cases (i) and (ii) From Equation (2.6) we see that in case (ii) there exists f : . Thus we get equations telling us that for every i either t i = t j @ t k or t i = λx.T λ f (t j ) or t i is a rational tree. Using these equations it is now easy, for every i = 1, . . . , n, to prove by induction on the depth k of subtrees of t i that each subtree of t i is either of the form s = T λ f (e † Γ 0 (r)) for some r ∈ X(Γ 0 ) and some f : Γ 0 → Γ 0 + {x}, or s is a subtree of some rational tree e † Γ 0 (r) = e Γ 0 (r) in case (iii). Since X(Γ 0 ) is a finite set, it follows that every tree t i has only finitely many subtrees, whence . We already know that the trees in case (ii) are rational. Thus, each subtree of e † ∅ (p i ) is either e † ∅ (r) or it is a subtree of some rational tree in cases (ii) or (iii).
The solution of e in R λ is unique because every solution in R λ yields a solution of the extended morphismē in T λ .
(II) Let D be the category of all equation morphisms e : X → H λ X + V, X finitely presentable, whose morphisms are the coalgebra homomorphisms for H λ (−) + V . The diagram D : D → Set F , D(e) = X, is filtered and its colimit is the free iterative H λ -algebra on V , see [2]. We will prove that R λ is a colimit of D. Recall that R λ is a pointed presheaf (see Remark 2.6).
For every e as above the equation morphism It is easy to verify that these morphisms form a cocone for the diagram D. Since D is a filtered diagram in Set F and since colimits in Set F are constructed objectwise in Set, in order to prove that all we need to prove is that for every context Γ (a) the coconeẽ † Γ is collectively epimorphic: there exists a connecting morphism in D merging x and x ′ too.
To prove (a), let t ∈ R λ (Γ) be a rational tree and let Γ 0 be the context of variables x s indexed by the finitely many subtrees s of t (up to isomorphism). Let X be the free presheaf on the set Γ 0 of generators of contextΓ = Γ ∪ Γ 0 , see Example 2.2(ii). Define e : X → H λ X + V by assigning to every variable x s , for a subtree s of t, the following value: This object e of D yields two equation morphisms:ẽ : X → H λ X + R λ above, and analogouslyê = (id +i T )·e : X → H λ X + T λ . The solution of the latter is the unique morphism 3) is easily seen to commute forê andê † . In (I) above we saw that the solutionẽ † : X → R λ is a codomain restriction ofê † . In particular: To prove (b) let τ : H λ T λ → T λ denote the algebra structure of T λ . By Theorem 2.10 and Example 2.9 we have that Let us factorizeê † as a strong epimorphism k : X → Y followed by a monomorphism m : Y → T λ . Then the last equation makes it possible to apply the diagonal fill in: Indeed, H λ = (−) 2 + δ preserves connected limits (because each summand does), thus, monomorphisms; consequently, H λ m+id V is a monomorphism. Since Y is a strong quotient of X, it follows from Theorem 2.16 that Y is finitely presentable. Thus, is an object of D, and clearly k is a connecting morphism from e to f . From (I) we know thatẽ † is the domain restriction ofê † , thus we see thatẽ † as requested.
Remark 2.18. As mentioned in the Introduction we want to combine application and abstraction with other operations. Suppose Σ = (Σ n ) n∈N is a signature (of "terminals"). Then we can form the endofunctor H λ,Σ of Set F on objects by where Σ n • X n is the coproduct (that is: disjoint union in every context) of Σ n copies of the n-th Cartesian power of X. For this endofunctor an algebra is an H λ -algebra A together with an n-ary operation on A(Γ) for every σ ∈ Σ n and every context Γ.
In the following result we use notation of Example 2.2(vii).
Indeed, (i) was proved in [10], and the proofs of (ii) and (iii) are completely analogous to the proofs of Theorems 2.17 and 2.10.

Presheaves as Monoids
So far we have not treated one of the basic features of λ-calculus: substitution of subterms. For the presheaf F λ,Σ of finite λ-Σ-terms this was elegantly performed by Fiore et al [10] based on the monoidal structure of the category Set F . As mentioned in Notation 2.1(3), we can work with the equivalent category Fin(Set, Set) of all finitary endofunctors of Set. Composition of functors makes this a (strict, non-symmetric) monoidal category with unit Id Set . This monoidal structure, as shown in [10], corresponds to simultaneous substitution. Indeed, let X and Y be objects of Fin(Set, Set). Then the "formulas of the composite presheaf X·Y " in context Γ are the elements of where u :Γ ֒→ Y (Γ) ranges over finite subobjects of Y (Γ). Indeed, X preserves the filtered colimit Y (Γ) = colimΓ. Consequently, in order to specify an X·Y -formula t in context Γ we need (a) an Xformula s in some new contextΓ and (b) for every variable x ∈Γ a Y -formula of context Γ, say, r x . We can then think of t as the formula s(r x /x) obtained from s by simultaneous substitution.
Example 3.1. We consider the presheaves F λ,Σ and F λ,Σ ′ , where Σ is the signature with a binary operation symbol * and Σ ′ a signature with a unary operation symbol o. Then for every context Γ, the elements of F λ,Σ ·F λ,Σ ′ (Γ) are λ-Σ-terms in some context Γ with free variables replaced by λ-Σ ′ -terms in context Γ. For a concrete example, let Γ = { y, z } and Γ = { z ′ } and consider the λ-Σ-term Then the element of F λ,Σ ·F λ,Σ ′ (Γ) corresponding to t and u is the term

Remark 3.2.
(i) The monoidal structure on Set F corresponding to composition in Fin(Set, Set) will be denoted by ⊗. Its unit (corresponding to Id) is V , see Notation 2.2(i). Observe that every endofunctor −⊗X preserves colimits, e.g., (A + B) ⊗ X ∼ = (A ⊗ X) + (B ⊗ X). (ii) Explicitly, the monoidal structure can be described by the coend (iii) Recall that monoids in the monoidal category Fin(Set, Set) are precisely the finitary monads on Set. (iv) The presheaf F λ,Σ is endowed with the usual simultaneous substitution of λ-terms which defines a morphism m F : F λ,Σ ⊗ F λ,Σ → F λ,Σ . Together with the canonical pointing i F : V → F λ,Σ , see Remark 2.6, this constitutes a monoid as proved in [10].
Analogously the simultaneous substitution of infinite λ-terms defines a monoid It is easy to see that given a rational term, every simultaneous substitution of rational terms for variables yields again a rational term. Thus, we have a submonoid (R λ,Σ , m R , i R ).
(v) The monoidal operation of F λ,Σ is well connected to its structure of an H λ,Σ -algebra. This was expressed in [10] by the concept of an H λ,Σ -monoid.
In order to recall this concept, we need the notion of point-strength introduced in [9] under the name (I/W )-strength; this is a weakening of the classical strength (necessary since H λ,Σ is unfortunately not strong). Recall that given an object I of a category W , then objects of the slice category I/W are morphisms x : I → X for X ∈ obj W . Definition 3.3 (see [9]). Let (W , ⊗, I) be a strict monoidal category and H an endofunctor on W . A point-strength of H is a collection of morphisms natural in (X, x) and (Y, y) ranging through I/W such that (i) s (X,x)(I,id) = id HX , and (ii) the following triangles commute: Example 3.4.
(i) The endofunctor X → X ⊗ X (which usually fails to be strong) has the point-strength (ii) The endofunctor X → X n of Set F is clearly (point-)strong for every n ∈ N.
(iii) The functor δ in Notation 2.3 is point-strong, as observed in [10]. The easiest way to describe its point-strength is by working in Fin(Set, Set). Given pointed endofunctors x : Id → X and y : Id → Y , then the point-strength s (X,x)(Y,y) : (δX)·Y → δ(X·Y ) has components where can : Y (Γ) + Y (1) → Y (Γ + 1) denotes the canonical morphism. (iv) A coproduct of point-strong functors is point-strong.  (1) Homomorphisms of H-monoids are those monoid homomorphisms which are also Halgebra homomorphisms. (2) An H-monoid is called (completely) iterative if its underlying H-algebra has this property.
(1) F λ is an H λ -monoid. Indeed, we know that substitution yields the monoid structure (Remark 2.6) and tree tupling yields the algebra structure (Example 2.5). Let us consider the square for a given context Γ 0 together with a substitution f : Γ 0 → F λ (Γ). In case of the summand F λ (Γ 0 ) × F λ (Γ 0 ) the lower passage m F Γ (ϕ Γ ⊗ id) assigns to t = (t 1 , t 2 ) the term t 1 @ t 2 with variables substituted according to f . And the upper passage first substitutes to t 1 and t 2 according to f separately, and then forms @; the result is the same. In case of the summand F λ (Γ 0 + {x}) the lower passage assigns to t the term λx.t with variables substituted according to f ; the upper one first substitutes in t and then forms λx.− yielding the same result again.
Although in [16], Example 13, just T λ is used, the methods of that paper apply to T λ,Σ immediately. The following theorem proves a stronger property of T λ,Σ , corresponding to Theorem 3.9 above.
An elementary proof of this theorem was presented in [4]. Here we will prove a more general result in Theorem 4.18 below.

The Initial Iterative H-Monoid
The aim of this section is to prove that the presheaf R λ,Σ of rational λ-Σ-terms is the initial iterative H λ,Σ -monoid in Set F . We have (in contrast to the characterization of T λ in the preceding section) no elementary proof. Rather, we need to work with the monad R λ,Σ of free iterative H λ,Σ -algebras on Set F (for which R λ,Σ is R λ,Σ (V )) and prove that it is point-strong and use this strength further. We will actually work in a more general setting (which can be applied later for the case of typed λ-calculus).
Assumption 4.1. Throughout this section we assume that H is a finitary endofunctor of W where (1) W is a locally finitely presentable category, i.e., a cocomplete category with a set of finitely presentable objects W fp whose closure under filtered colimits is all of W . (2) W is also a strict monoidal category with the unit I finitely presentable and the tensor product preserving finite presentability: if A, B are finitely presentable, then so is A⊗B. (3) W is right distributive, that is, for every object W the endofunctor −⊗W preserves finite coproducts. (4) The tensor product is a finitary functor, i.e., its preserves filtered colimits (in both variables). We call categories satisfying (1)-(4) monoidally locally finitely presentable.
Example 4.2. Set is, as a cartesian closed category, monoidally locally finitely presentable. For every monoidally locally finitely presentable category W all functor categories W A , A small, have the property too; for example, Set F with the cartesian product as tensor. However, in our paper we only use the fact that Set F is a monoidally locally finitely presentable w.r.t. ⊗ in Remark 3.2(i). This follows from the fact that this is equivalent to Fin(Set, Set) with the tensor product given by composition. Observe that ⊗ is right distributive (since precomposition with a given functor preserves colimits) but not left distributive. where µ X : RRY → RY is the unique homomorphism extending η Y : R is called the rational monad of the endofunctor H. Then RY together with η Y and ̺ Y is the free iterative H-algebra on Y . We also have Furthermore, e # is the unique coalgebra homomorphism from e to i Y . (iv) For every e : W → HW + Y the morphism e # : W → RY is the unique solution (in the iterative algebra RY ) of for every equation morphism e : X → HX + A.
Example 4.5. The rational monad of H λ is the monad R λ of rational λ-terms with constants: to every presheaf Y it assigns the presheaf R λ (Y ) defined precisely as R λ in Example 2.2(v) except that in every context Γ we can also use elements of Y (Γ) to label the leaves.
More detailed: we first define the set R ′ λ (Y )(Γ) of rational trees in context Γ with constants from Y . It consists of all rational trees of the form (2.2) such that a node labelled by an element of Y (Γ) is a leaf.
By using the α-conversion precisely as in Example 2.2(iii), we obtain the desired presheaf It is again pointed; the pointing i R λ (Y ) : V → R λ (Y ) assigns to every variable the corresponding singleton tree. And R λ (Y ) is canonically an H λ -algebra. We define to assign to every element of Y (Γ) the corresponding singleton tree. This is the free iterative H λ -algebra on Y , the proof is completely analogous to that of Theorem 2.17.
and the multiplication: Example 4.7. By our assumption that H be finitary we know that all terminal coalgebras for H(−) + X exist, this follows from [15], see also [5]. Equivalently, all free completely iterative algebras for H exist (cf. Example 2.9), and they yield the object map of a monad T = (T, η T , µ T ). This monad is the free completely iterative monad on the endofunctor H, see [17]. The monad multiplication µ T X : T T X → T X is the unique algebra homomorphism extending id T X , i.e., such that Theorem 4.8. The free completely iterative monad T of a point-strong endofunctor H is point-strong.
Remark. The strength of T will be proved to be the unique natural transformation s T for which the diagram commutes. Indeed, the algebra T Z is completely iterative. Due to (HT X + Y ) ⊗ Y = HT X ⊗ Y + X ⊗ Y , see Assumption 4.1(3), we obtain an equation morphism in T Z as follows: Its unique solution is denoted by f ♭ . It is characterized by the commutative diagram It is easy to verify that this diagram commutes iff (4.11) does.
In other words, we define the components of s T via (4.11) uniquely. (b1) s T is natural: the squares s T commute for all morphisms g and h of I/W since both passages form f ♭ for . Indeed, for the upper passage, f ♭ = T (g ⊗ h)·s T , use the following diagram: The two left-hand parts form Diagram (4.11), the remaining two commute by naturality of τ and η.
The lower passage f ♭ = s T ·(T g ⊗ h) follows from the following diagram: The right-hand parts form Diagram (4.12), the left-hand ones commute by naturality of τ and η T . (b2) s T is a point-strength of the endofunctor T . Indeed, the axiom follows from the fact that if (Y, y) = (V, id), then Diagram (4.10) commutes with id T (X) in lieu of s T . To verify the Axiom (3.3), apply (a) to f = η T X⊗Y ⊗Z : we prove that the lower passage of (3.3) serves as f ♭ . In detail, the diagram commutes. Indeed, all inner parts commute by two applications of (4.10).
(b3) It remains to verify the axioms of Definition 4.6. For (4.7) use the lower triangle of Diagram (4.10). For (4.8) apply (a) to We prove that both passages of (4.8) serve as f ♭ . For the lower passage, (s T ) ♭ = s T ·µ T ⊗ Y , use the following diagram The upper left-hand part is Equation (4.9), the lower one commutes by the monad axiom µ T ·η T T = id, the upper triangle is the naturality of s H , and the right-hand part follows from (4.10).
For the upper passage, (s T ) ♭ = µ T ·T s T ·s T , use the following diagram The three upper squares commute due to (4.10), the naturality of τ and (4.9). The lower triangles commute due to (4.10), the naturality of s T and µ T ·η T T = id.  Remark. The strength of R will be proved to be the unique natural transformation s R for which the diagram commutes.
Proof. (a) Given pointed objects (X, x) and (Y, y), we prove that for every morphism f : X ⊗ Y → RZ there exists a unique morphism f ♭ : RX ⊗Y → RZ such that the following diagram commutes: (a1) Assume that Y is finitely presentable. Recall RY = colim Eq Y from Remark 4.4. For every object e : W → HW + X in EQ X define, using the distributivity (HW + Y ) ⊗ Y = HW ⊗ Y + X ⊗ Y (see Assumption 4.1(3)), the equation morphism Since W ⊗ Y is finitely presentable by Assumption 4.1(2), we obtain the unique solution e † : W ⊗ Y → RZ, and those solutions form a cocone of the diagram Eq X ⊗ Y . Indeed, given a connecting morphism Hh+X then h ⊗ Y is a coalgebra homomorphism fromê toê ′ : Consequently, we can define f ♭ : RX ⊗ Y → RZ by the commutativity of the triangles for all e ∈ EQ X . (4.16) Indeed, since −⊗Y is a finitary functor by Assumption 4.1(4), we see that RX ⊗ Y is a colimit of Eq Y ⊗ Y with the colimit cocone e # ⊗ Y . We now verify that the Diagram (4.14) commutes. Consider the diagram below: Notice first that the left-hand edge isê. The upper left-hand part commutes by (4.4), and the lower one does by naturality of s H . The outside of the diagram commutes since f ♭ ·(e # ⊗ Y ) is the unique solution ofê in the iterative algebra RZ. Thus, the right-hand part commutes when precomposed by any e # ⊗Y . So since the latter morphisms are collectively epimorphic (being the injections of colim Eq X ⊗ Y ), we see that the right-hand part commutes. Now we use that i X is an isomorphism with the inverse [̺ X , η X ], see Equation (4.5), which implies Finally observe that the two coproduct components of the right-hand part of (4.17) yield precisely the upper and lower parts of (4.14)-this proves that (4.14) commutes. It only remains to prove the uniqueness of f ♭ . So suppose we have some f ♭ such that Diagram (4.14) commutes. Equivalently, the right-hand part of (4.17) commutes, and this implies that f ♭ ·(e # ⊗ Y ) is, for every e in EQ X , a solution ofê. This determines f ♭ uniquely.
(a2) Let Y be arbitrary. Then since W is locally finitely presentable we can express Y as a filtered colimit of finitely presentable objects Y q . By Assumption 4.1(2) the unit object I is finitely presentable, thus the given pointing of Y : factorizes through some y q . The diagram above being filtered, we can assume that this factorization takes place for every q ∈ Q, in other words, that we have a filtered diagram of pointed objects Y q with colimit Y (and with all the connecting morphisms Y q → Y q ′ preserving the pointing). Given f : X ⊗ Y → RZ, for every q ∈ Q we know from the previous part (a1) that there exists a unique f ♭ q : RX ⊗ Y q → RZ such that Diagram (4.14) commutes when f ♭ is replaced by f ♭ q and f by This defines a unique f ♭ : Now Diagram (4.14) commutes because HRX ⊗Y = colim q∈Q HRX ⊗Y q as well as X ⊗Y = colim q∈Q X ⊗ Y q . And f ♭ is uniquely determined by this commutativity; indeed, for any f ♭ such that (4.14) commutes one easily verifies that (4.18) holds using the uniqueness of f ♭ q from part (a1). (b) Analogously to the proof of Theorem 4.8 put The verification that s R is the desired strength is analogous to the above proof: just replace T by R (and τ by ̺).
Remark 4.11. The proofs of Theorems 4.8 and 4.10 have the same structure, and also the proof that the monad F λ,Σ is point-strong can proceed analogously: Let H be a point-strong endofunctor of W and let (M ,μ,η) be a monad. Suppose that a natural transformation α : HM →M has the property that for every morphism The morphisms ̺ X : HRX → RX and η X : X → RX of (4.13) are coproduct injections of RX = HRX + X as proved in [2]. From diagram (4.13) we conclude that the strength of R, whose domain is HRX ⊗ Y + X ⊗ Y by 4.1 (2) and codomain is HR(X ⊗ Y ) + X ⊗ Y , has the form s R = Hs R ·s H + X ⊗ Y. Proof. Indeed, the unit laws are obvious:   Proof. Notice that e is precisely of the form e f from Remark 4.4(vi) for f = e * W . Also recall from Remark 4.4(iv) that e # = (η • e ) † and similarly (e * W ) # = (η • (e * W )) † . We shall also use that the H-algebra homomorphism e # preserves solutions (cf. Remark 4.4(vii)). Thus, we compute   (3) Proof of the upper passage of (4.23): We are now in the position to demonstrate (4.25): Since the right-hand triangle is Equation (4.20) and the lower square commutes by the naturality of s R , we see thatē † is a solution of e in the sense of Definition 5.3 iffē † is a solution ofē in the sense of [2]. This proves that e has a unique solution.
Remark 5.8. Analogously we could define a solution of a higher-order recursion scheme of the form e : X → T λ,Σ ⊗ (X + V ) in the initial completely iterative monoid T λ,Σ , see Theorem 3.11. (Here we, moreover, do not need to assume that X is finitely presentable.) And guardedness means here that e factorizes through the summand H λ,Σ T λ,Σ ⊗(X +V )+V of T λ,Σ ⊗ (X + V ) (cf. Remarks 4.9 and 3.2(i)). Every such guarded scheme has a unique solution in T λ,Σ . The proof is completely analogous to the previous one for R λ,Σ but using Corollary 3.8 in [1] in lieu of Theorem 4.5 from [2].
Remark 5.9. Notice that the definitions and results in this section generalize to the setting as considered in Section 4 (see Assumption 4.1). Simply replace H λ,Σ by the finitary functor H, the monoid F λ,Σ by the initial H-monoid F ; this exists and is given by the free H-algebra on V , see [10]. Further replace the monoid R λ,Σ by the initial iterative H-monoid RI (cf. Theorem 4.17), and T λ,Σ by the initial completely iterative H-monoid (cf. Theorem 4.18).

Interpreted Solutions
In the present section we prove that every Scott model of λ-calculus as a CPO, D, with fold and unfold operations can be used as a model of higher-order recursion. Following M. Fiore et al [10] we work with the presheaf D, D which to a context Γ assigns the set of all continuous functions from D Γ to D. We prove that every higher-order recursion scheme has a least solution in D, D . We denote by CPO the cartesian closed category of posets with directed joins and continuous functions. Thus least elements are not assumed; if they exist we use ⊥ for them. Assumption 6.1. We assume that a Scott model D of λ-calculus is given, i.e., a CPO with ⊥ and with an embedding-projection pair fold : CPO(D, D) ⊳ D : unfold . (6.1) Moreover, for the given signature Σ of terminals we also assume that continuous operations σ D : D n → D for every n-ary σ in Σ are given.   [14] we see that the monoidal category (Set F , ⊗, V ) has the following monoidal action * on CPO: given X in Set F and C in CPO, we put X * C = Γ X(Γ) • C Γ . Moreover, extending the above notation to pairs C, C ′ of CPO's and defining C, C ′ Γ = CPO(C Γ , C ′ ) we obtain a presheaf with a natural isomorphism Set F (X, C, C ′ ) ∼ = CPO(X * C, C ′ ).
As observed by George Janelidze and Max Kelly [13] this yields an enriched category whose hom-objects are C, C ′ . In particular, D, D receives a monoid structure. It is tedious but not difficult to prove that this monoid structure is given by (6.2) above and it forms an H λ,Σ -monoid (cf. Definition 3.6). with the following property: Given an X-term x in context Γ, then e Γ assigns to it an element e Γ (x) of (F λ,Σ ⊗ (X + V ))(Γ), that is, a finite term t ∈ F λ,Σ (Γ) for some Γ ⊆ X(Γ) + Γ. We request that the solution assigns to x the same value e † Γ (x) : D Γ → D that we obtain from the interpretation [[t]] 1 of the given term by substituting the Γ-variables using [e † , ι] : X + V → D, D . This substitution is given by composing [[−]] ⊗ [e † , ι] with the monoid structure of D, D . This leads to the following Definition 6.7. Given a higher-order recursion scheme e : X → F λ,Σ ⊗ (X + V ) by an interpreted solution is meant a presheaf morphism e † : X → D, D such that the square below commutes:  (6.2), this yields the components of (m·(id ⊗z)) Γ as follows: for every contextΓ the component composed with the coproduct injection in u of u is the map g → g· z Γ ·u for g ∈ D, D Γ .
iterative H λ,Σ -monoid. And its subpresheaf R λ,Σ of all rational λ-Σ-terms is the initial iterative H λ,Σ -monoid. We used that last presheaf in our uninterpreted semantics of recursion schemes.
Our approach was based on untyped λ-calculus. The ideas in the typed version are quite analogous. If S is the set of all types, then we form the full subcategory F of Set S of finite S-sorted sets and consider presheaves in (Set S ) F -the latter category is equivalent to that of finitary endofunctors of the category Set S . The definition of H λ,Σ is then completely analogous to the untyped case, and one can form the presheaves F λ,Σ (free algebra on V ), T λ,Σ (free completely iterative algebra) and R λ,Σ (free iterative algebra). Each of them is a monoid, in fact, an H λ,Σ -monoid in the sense of [10]. Moreover, every guarded higher-order recursion scheme has a unique solution in R λ,Σ . The interpreted semantics can be built up on a CPO-enriched cartesian closed category (as our model of typed λ-calculus) with additional continuous morphisms for all terminals. The details of the typed version are more involved, and we leave them for future work.
Related results on higher-order substitution can be found e.g. in [16] and [20]. In future work we will, analogously as in [18], investigate the relation of uninterpreted and interpreted solutions.