1 Introduction

Terminal coalgebras yield a fully abstract domain of behavior for a given type of state-based systems whose transition type is described by an endofunctor F. Often one is mainly interested in the study of the semantics of finite coalgebras; for instance, regular languages are the behaviors of finite deterministic automata, while the terminal coalgebra of the corresponding functor is formed by all formal languages. For endofunctors on sets, the rational fixed point introduced by Adámek et al. [2] yields a fully abstract domain of behavior for finite coalgebras. However, in recent years there has been a lot of interest in studying coalgebras over more general categories than sets. In particular, categories of algebras for a (finitary) monad T on sets are a paradigmatic setting; they are used, for instance, in the generalized determinization framework of Silva et al. [30] and yield coalgebraic language equivalence [9] as a semantic equivalence of systems with a side effect provided by the monad T. In the category \(\mathscr {C}\) of T-algebras, several notions of ’finite’ object are natural to consider, and each of those yields an ensuing notion of ‘finite’ coalgebra: free objects on finitely many generators (ffg objects) yield precisely the coalgebras that are the target of generalized determinization; finitely presentable (fp) objects are the ones that can be presented by finitely many generators and relations and yield the rational fixed point; and finitely generated (fg) objects, i.e. those presented by finitely many generators (but possibly infinitely many relations). Taking the colimits of all coalgebras with ffg, fp, and fg carriers, respectively, yields three coalgebras \(\varphi F\), \(\varrho F\) and \(\vartheta F\) which, under suitable assumptions on F, are all fixed points of F [2, 24, 34]. Our present paper is devoted to studying the fixed point \(\varphi F\), which we call the locally ffg fixed point of F. For a finitary endofunctor F preserving surjective and non-empty injective morphisms in \(\mathscr {C}\), the three fixed points are related (to the terminal coalgebra \(\nu F\)) as shown in the picture below:

$$\begin{aligned} \varphi F \twoheadrightarrow \varrho F \twoheadrightarrow \vartheta F \rightarrowtail \nu F, \end{aligned}$$
(1.1)

where \(\twoheadrightarrow \) denotes a quotient coalgebra and \(\rightarrowtail \) a subcoalgebra. The three right-hand fixed points are characterized by a universal property both as a coalgebra and (inverting their coalgebra structure) as an algebra [2, 19, 24]; see [34] for one uniform proof. We recall this in more detail in Sect. 2.4.

The main contribution of this paper is a new characterization of the locally ffg fixed point \(\varphi F\) by a universal property as an algebra. As already observed by Urbat [34], as a coalgebra, \(\varphi F\) does not satisfy the expected finality property. A simple initiality property of \(\varphi F\) as an algebra was recently established by Milius [21]. Here we go a step further and introduce the notion of an ffg-Elgot algebra (Sect. 4), which is an algebra for F equipped with an operation that allows to take solutions of effectful iterative equations (see Remark 4.5) subject to two natural axioms. These axioms are inspired by and closely related to the axioms of (ordinary) Elgot algebras [1], which we recall in Sect. 3. We then prove that \(\varphi F\) is the initial ffg-Elgot algebra (Theorem 4.11).

In addition, we study the construction of free ffg-Elgot algebras. In the case of ordinary Elgot algebras, it was shown in [1] that the parametrized rational fixed point \(\varrho (F(-)+Y)\) is a free Elgot algebra on Y. In addition, the category of Elgot algebras is the Eilenberg-Moore category for the corresponding monad on \(\mathscr {C}\). In the present paper, we first prove that free ffg-Elgot algebras exist on every object Y of \(\mathscr {C}\). But is it true that the free ffg-Elgot algebra on Y is \(\varphi (F(-)+Y)\)? We do not know the answer for arbitrary objects Y, but if Y is a free T-algebra (on a possibly infinite set of generators), the answer is affirmative (Theorem 4.15).

Finally, we prove that the category of ffg-Elgot algebras is monadic over \(\mathscr {C}\), i.e. ffg-Elgot algebras are precisely the Eilenberg-Moore algebras for the monad that assigns to a given object Y of \(\mathscr {C}\) its free ffg-Elgot algebra (Theorem 4.16). Full proofs of all results presented here can be found in [18].

2 Preliminaries

2.1 Varieties and ‘Finite’ Algebras

Throughout the paper we will work with a (finitary, many-sorted) variety \(\mathscr {C}\) of algebras. Equivalently, \(\mathscr {C}\) is the category of Eilenberg-Moore algebras for a finitary monad T on the category \({\mathsf {Set}}^S\) of S-sorted sets [6]. We will speak about objects of \(\mathscr {C}\) (rather than algebras for T) and reserve the word ‘algebra’ for algebras for an endofunctor on \(\mathscr {C}\). All the usual categories of algebraic structures and their homomorphisms are varieties: monoids, (semi-)groups, rings, vector spaces over a fixed field, modules for a (semi-)ring, positive convex algebras, join-semilattices, Boolean algebras, distributive lattices, and many others. In each case, the corresponding monad T assigns to a set the free object on it, e.g. \(TX = X^*\) for monoids, the finite power-set monad \(T= \mathcal {P}_\mathsf {f}\) for join-semilattices, and the subdistribution monad \(\mathscr {D}\) for positive convex algebras, etc.

As mentioned in the introduction, every variety \(\mathscr {C}\) of algebras comes with three natural notions of ’finite’ objects, each of which admits a neat category-theoretic characterization (see [6]):

Finitely presentable objects (fp objects, for short) can be presented by finitely many generators and relations. An object X is fp iff the covariant hom-functor \(\mathscr {C}(X,-){:}\,\mathscr {C}\rightarrow Set\) is finitary, i.e. it preserves filtered colimits.Footnote 1 We denote by \(\mathscr {C}_\mathsf {fp}\) the full subcategory of \(\mathscr {C}\) given by all fp objects. In our proofs we will use the well-known fact that every object X is the filtered colimit of the canonical diagram \(\mathscr {C}_\mathsf {fp}/X \rightarrow \mathscr {C}\), i.e. objects in the diagram scheme are morphisms \(P \rightarrow X\) in \(\mathscr {C}\) with P fp.

Finitely generated objects (fg objects, for short) are presented by finitely many generators but, possibly, infinitely many relations. An object X is fg iff \(\mathscr {C}(X,-)\) preserves filtered colimits with monic connecting morphisms. Hence, every fp object is fg but not conversely. In fact, the fg objects are precisely the (regular) quotients of the fp objects [6, Proposition 5.22].

Free finitely generated objects (ffg objects, for short) are the objects \((TX_0, \mu _{X_0})\) where \(X_0\) is a finite S-sorted set (i.e. the coproduct of all components \(X_s\), \(s \in S\) is finite). An object X is a split quotient of an ffg object iff \(\mathscr {C}(X,-)\) preserves sifted colimits [6, Corollary 5.14]. Recall from [6] that sifted colimits are more general than filtered colimits: a sifted colimit is a colimit of a diagram \(D{:}\,\mathscr {D}\rightarrow \mathscr {C}\) whose diagram scheme \(\mathscr {D}\) is a sifted category, which means that finite products commute with colimits over \(\mathscr {D}\) in \({\mathsf {Set}}\). For instance, every filtered category and every category with finite coproducts is sifted, see [6, Example 2.16].

The category \(\mathscr {C}\) is cocomplete and the forgetful functor \(\mathscr {C}\rightarrow {\mathsf {Set}}^S\) preserves and reflects sifted colimits, that is, sifted colimits in \(\mathscr {C}\) are formed on the level of underlying sets [6, Proposition 2.5].

A finitely cocomplete category has sifted colimits if and only if it has filtered colimits and reflexive coequalizers, and, moreover a functor preserves sifted colimits if and only if it preserves filtered colimits and reflexive coequalizers [5].

We denote by \(\mathscr {C}_\mathsf {ffg}\) the full subcategory of ffg objects of \(\mathscr {C}\). Analogously to the corresponding result for fp objects, every object X is a sifted colimit of the canonical diagram \(\mathscr {C}_\mathsf {ffg}/X \rightarrow \mathscr {C}\); this follows from [6, Proposition 5.17].

2.2 Relation Between the Object Classes

We already mentioned that every fp object is fg (but not conversely, in general). Clearly, every ffg object is fg, but not conversely in general. So, in general, we have full embeddings

$$\begin{aligned} \mathscr {C}_\mathsf {ffg}\overset{\ne }{\hookrightarrow } \mathscr {C}_\mathsf {fp}\overset{\ne }{\hookrightarrow } \mathscr {C}_\mathsf {fg}. \end{aligned}$$

In rare cases, all three object classes coincide; e.g. in \({\mathsf {Set}}\) (considered as a variety) and the category of vector spaces over a field.

In addition to those examples, the equation \(\mathscr {C}_\mathsf {fg}= \mathscr {C}_\mathsf {fp}\) holds true, for example, for all locally finite varieties (i.e. where ffg objects are carried by finite sets), for positive convex algebras [31], commutative monoids [14, 29], abelian groups, and more generally, in any category of (semi-)modules for a semiring \(\mathbb {S}\) that is Noetherian in the sense of Ésik and Maletti [12], i.e. every subsemimodule of an fg semimodule is fg itself. For example, the following semirings are Noetherian: every finite semiring, every field, every principal ideal domain such as the ring of integers and therefore every finitely generated commutative ring by Hilbert’s Basis Theorem. The tropical semiring \((\mathbb {N}\cup \{\infty \}, \min , +, \infty , 0)\) is not Noetherian [11]. The usual semiring of natural numbers is also not Noetherian, but for the category of \(\mathbb {N}\)-semimodules (\(=\) commutative monoids), \(\mathscr {C}_\mathsf {fp}= \mathscr {C}_\mathsf {fg}\) still holds.

2.3 Functors and Liftings

We will consider coalgebras for functors F on the variety \(\mathscr {C}\). In many cases F is a lifting of a set functor, i.e. we have functor \(F_0{:}\,{\mathsf {Set}}^S \rightarrow {\mathsf {Set}}^S\) such that \(F_0 \cdot U = U \cdot F\), where \(U{:}\,\mathscr {C}\rightarrow {\mathsf {Set}}^S\) is the forgetful functor. It is well-known [7, 15] that liftings of a given functor \(F_0\) on \({\mathsf {Set}}^S\) to \(\mathscr {C}\), the variety given by the monad T, are in bijective correspondence with distributive laws of the monad T over the functor \(F_0\). It was observed by Turi and Plotkin [28] that a final coalgebra for \(F_0\) lifts to a final coalgebra for the lifting F, and this is then the final bialgebra for the corresponding distributive law.

Coalgebras for lifted functors are significant for us because the targets of finite coalgebras X under generalized determinization [30] are precisely those coalgebras for the lifting F carried by ffg objects TX. In more detail, generalized determinization is the process of turning a given coalgebra \(c{:}\,X \rightarrow F_0TX\) in \({\mathsf {Set}}^S\) into a coalgebra for the lifting F: one uses the freeness of TX and the fact that FTX is a T-algebra to extend c to a T-algebra homomorphism \(c^*{:}\,TX \rightarrow FTX\). The coalgebraic language semantics [9] of (Xc) is then the final semantics of \(c^*\) in \(\mathscr {C}\). The classical instance of this is the language semantics of non-deterministic automata considered as coalgebras \(X \rightarrow \{0,1\} \times (\mathcal {P}_\mathsf {f}X)^\varSigma \); here the generalized determinization with \(T = \mathcal {P}_\mathsf {f}\) and \(F = \{0,1\} \times X^\varSigma \) on \({\mathsf {Set}}\) is the well-known subset construction from automata theory.

2.4 Four Fixed Points

Let us now consider a finitary endofunctor \(F{:}\,\mathscr {C}\rightarrow \mathscr {C}\) on our variety. Then we know that F has a terminal coalgebra [4], which we denote by \(\nu F\). Its coalgebra structure \(\nu F \rightarrow F(\nu F)\) is an isomorphism by Lambek’s lemma [17], and so \(\nu F\) is a fixed point of F.

There are three more fixed points of F obtained from ‘finite’ coalgebras, where ‘finite’ can mean each of the three notions discussed in the previous subsection. More precisely, we consider the full subcategories of the category \(\mathop {\mathsf {Coalg}}F\) given by those coalgebras with fp, fg, and ffg carriers, respectively and denote them as shown below:

$$\begin{aligned} \mathop {\mathsf {Coalg}_{\mathsf {ffg}}}F \hookrightarrow \mathop {\mathsf {Coalg}_{\mathsf {fg}}}F \hookrightarrow \mathop {\mathsf {Coalg}_{\mathsf {fp}}}F \hookrightarrow \mathop {\mathsf {Coalg}}F. \end{aligned}$$

Since all three categories \(\mathop {\mathsf {Coalg}}\nolimits _x F\) (for \(x = \mathsf {fp}, \mathsf {fg}\) or \(\mathsf {ffg}\)) are essentially small, we can form coalgebras as the colimits of the above inclusions as follows:

$$\begin{aligned} \varphi F&= \mathop {\mathrm {colim}}(\mathop {\mathsf {Coalg}_{\mathsf {ffg}}}F \hookrightarrow \mathop {\mathsf {Coalg}}F),\\ \vartheta F&= \mathop {\mathrm {colim}}(\mathop {\mathsf {Coalg}_{\mathsf {fg}}}F \hookrightarrow \mathop {\mathsf {Coalg}}F), \\ \varrho F&= \mathop {\mathrm {colim}}(\mathop {\mathsf {Coalg}_{\mathsf {fp}}}F \hookrightarrow \mathop {\mathsf {Coalg}}F). \end{aligned}$$

Note that the latter two colimits are filtered; in fact, \(\mathop {\mathsf {Coalg}_{\mathsf {fg}}}F\) and \(\mathop {\mathsf {Coalg}_{\mathsf {fp}}}F\) are clearly closed under finite colimits in \(\mathop {\mathsf {Coalg}}F\), whence they are filtered categories. The first colimit is a sifted colimit since its diagram scheme \(\mathop {\mathsf {Coalg}_{\mathsf {ffg}}}F\) is closed under finite coproducts [22, Lemma 3.7]. In what follows, the objects of \(\mathop {\mathsf {Coalg}_{\mathsf {ffg}}}F\) are called ffg-coalgebras.

We now discuss the three above coalgebras in more detail.

The rational fixed point is the coalgebra \(\varrho F\); that this is a fixed point was proved by Adámek et al. [2]. In addition, \(\varrho F\) is characterized by a universal property both as a coalgebra and as an algebra: (a) as a coalgebra, \(\varrho F\) is the terminal locally finitely presentable (lfp) coalgebra, where a coalgebra is called lfp if it is a filtered colimit of a diagram formed by coalgebras from \(\mathop {\mathsf {Coalg}_{\mathsf {fp}}}F\) [20]; and (b) as an algebra, \(\varrho F\) is the initial iterative algebra for F. An iterative algebra is an F-algebra \(a{:}\,FA \rightarrow A\) such that every fp-equation, i.e. a morphism \(e{:}\,X \rightarrow FX + A\) with X fp, has a unique solution in A. The latter means that there exists a unique morphism \({e}^\dagger \) such that the following square commutes:

(2.1)

(Note that in a diagram we usually denote identity morphisms simply by the (co)domain object.) This notion is a categorical generalization of iterative \(\varSigma \)-algebras for a single-sorted signature \(\varSigma \) originally introduced by Nelson [27]; see also Tiuryn [33] for a closely related concept.

The locally finite fixed point is the coalgebra \(\vartheta F\); this coalgebra was recently introduced and studied by Milius et al. [24] for a finitary and mono-preserving functor F. It was proved to be a fixed point of F and characterized by two universal properties analogous to the rational fixed point: (a) as a coalgebra, \(\vartheta F\) is the terminal locally finitely generated (lfg) coalgebra, where a coalgebra is called lfg if it is a colimit of a directed diagram of coalgebras in \(\mathop {\mathsf {Coalg}_{\mathsf {fg}}}F\); and (b) as an algebra, \(\vartheta F\) is the initial fg-iterative algebra for F, where fg-iterative is simply the variation of iterative where the domain object of \(e{:}\,X \rightarrow FX + A\) is required to be fg in lieu of fp. Moreover, \(\vartheta F\) always is a subcoalgebra of \(\nu F\) [24, Theorem 3.10] and thus fully abstract w.r.t. behavioral equivalence.

The locally ffg fixed point is the coalgebra \(\varphi F\). Recently, Urbat [34] has proved that \(\varphi F\) is indeed a fixed point of F, provided that F preserves sifted colimits. Actually, he defined \(\varphi F\) as the colimit of all F-coalgebras whose carrier is a split quotient of an ffg object. However, this is the same colimit as the one we use above . Moreover, loc. cit. provides a general framework that allows to prove that all four coalgebras \(\varrho F\), \(\varrho F\), \(\vartheta F\) and \(\nu F\) are fixed points by one uniform proof. Also, a uniform proof of the universal properties of \(\varrho F\), \(\vartheta F\) and \(\nu F\) is given.

Somewhat surprisingly, the coalgebra \(\varphi F\) fails to have the finality property w.r.t. to coalgebras in \(\mathop {\mathsf {Coalg}_{\mathsf {ffg}}}F\): Urbat [34, Example 4.12] gives an example of a coalgebra for the identity functor on the category \(\mathscr {C}\) of algebras with one unary operation (and no equations) that admits two coalgebra homomorphisms into \(\varphi F\); see Example 2.2 below. This also shows that \(\varphi F\) cannot have a universal property as some kind of iterative algebra (i.e. where solutions are unique).

Relations between the Fixed Points. Recall that a quotient of a coalgebra is represented by a coalgebra homomorphism carried by a regular epimorphism (\(=\) surjective algebra morphism) in \(\mathscr {C}\). Suppose we have a finitary functor F on \(\mathscr {C}\) preserving surjective and non-empty injective morphisms.Footnote 2 Then the subcoalgebra \(\vartheta F\) of \(\nu F\) is a quotient of \(\varrho F\), which in turn is a quotient of \(\varphi F\) [22, 23]; see (1.1). Whenever, \(\mathscr {C}_\mathsf {fp}= \mathscr {C}_\mathsf {fg}\), we clearly have \(\mathop {\mathsf {Coalg}_{\mathsf {fp}}}F = \mathop {\mathsf {Coalg}_{\mathsf {fg}}}F\) and hence \(\varrho F \cong \vartheta F\) (i.e. \(\varrho F\) is fully abstract w.r.t. behavioral equivalence), and if \(\mathscr {C}_\mathsf {fp}= \mathscr {C}_\mathsf {fg}= \mathscr {C}_\mathsf {ffg}\) then those two coincide with \(\varphi F\) as well. Moreover, Milius [22] introduced the notion of a proper functor (generalizing the notion of a proper semiring of Ésik and Maletti [11]) and proved that a functor F is proper if and only if the three fixed points coincide, i.e. the picture  (1.1) collapses to \(\varphi F \cong \varrho F \cong \vartheta F \hookrightarrow \nu F\). Loc. cit. also shows that on a variety \(\mathscr {C}\) where fg objects are closed under taking kernel pairs, every endofunctor mapping kernel pairs to weak pullbacks in \({\mathsf {Set}}\) is proper [22, Proposition 3.18].Footnote 3

Instances of the three fixed points have mostly been considered for proper functors (where the three are the same, e.g. for functors on \({\mathsf {Set}}\)), or else on algebraic categories where \(\mathscr {C}_\mathsf {fp}= \mathscr {C}_\mathsf {fg}\) (where the rational and locally finite fixed points coincide). For example, regular languages for the automaton functor \(2 \times (-)^\varSigma \) on \({\mathsf {Set}}\); rational formal power series for the functor \(\mathbb {S}\times (-)^\varSigma \) on \(\mathbb {S}\)-semimodules (whenever \(\mathbb {S}\) is a proper semiring the three fixed points coincide); rational (a.k.a. regular) \(\varSigma \)-trees for the polynomial functor on \({\mathsf {Set}}\) associated to the signature \(\varSigma \); eventually periodic and rational streams for the functor \(k \times (-)\) on \({\mathsf {Set}}\) and vector spaces over the field k, respectively; the behaviors of probabilistic automata modelled as coalgebras for \([0,1] \times (-)^\varSigma \) on the category of positive convex algebras (that this functor is proper was recently proved by Sokolova and Woracek [32]); finally, (deterministic) context-free languages and constructively \(\mathbb {S}\)-algebraic formal power-series (the weighted counterpart of context-free languages) [24]. Note that the last two examples are instances of the locally finite fixed point \(\vartheta F\), but a description of \(\varphi F\) and \(\varrho F\) is unknown.

Remark 2.1

The rational and locally finite fixed points are defined and studied more generally than in the present setting, namely for finitary functors F on a locally finitely presentable category \(\mathscr {C}\) (see Adámek and Rosický [4] for an introduction to locally presentable categories). The following are instances of \(\varrho F\) and \(\vartheta F\) for F on a locally finitely presentable category \(\mathscr {C}\): (a) Courcelle’s algebraic trees [10] as proved in [24]; (b) rational \(\lambda \)-trees (modulo \(\alpha \)-equivalence) for a functor on the category of presheaves over finite sets [3] or for a related functor on the category of nominal sets [26]; more generally, (c) rational trees over an arbitrary binding signature (see Fiore et al. [13]) as proved in [25]. Again, (a) is an instance of the locally finite fixed point \(\vartheta F\) but a description of the rational fixed point is unknown. In the setting of general locally finitely presentable categories, there is no analogy to \(\varphi F\), of course.

We now present a new example where only \(\varphi F\) is interesting but the other three fixed points are trivial.

Example 2.2

We consider the monad T on \({\mathsf {Set}}\) whose algebras are the algebras with one unary operation u (with no equation):

$$\begin{aligned} TX = \mathbb {N}\times X \quad \text {with}\quad u(n,x)=(n+1,x). \end{aligned}$$

The functor F is the identity functor \(\mathsf {Id}\) on the category \(\mathscr {C}= {\mathsf {Set}}^T\). The final coalgebra for \(\mathsf {Id}\) is (lifted from \({\mathsf {Set}}\) and therefore is) the trivial algebra on 1 with \(\mathsf {id}_1\) as coalgebra structure. Since 1 is clearly finitely presented by one generator x and the relation \(u(x) = x\), both of the diagrams \(\mathop {\mathsf {Coalg}_{\mathsf {fp}}}\mathsf {Id}\) and \(\mathop {\mathsf {Coalg}_{\mathsf {fg}}}\mathsf {Id}\) have a terminal object which is then their colimit, whence \(\varrho \mathsf {Id}\cong \vartheta \mathsf {Id}\cong 1\).

However, \(\varphi \mathsf {Id}\) is non-trivial and interesting: an ffg-coalgebra \(TX\xrightarrow {\gamma } TX\) may be viewed (by restricting it to its generators in X) as obtained by generalized determinization of an FT-coalgebra with \(F = \mathsf {Id}\) on \({\mathsf {Set}}\), i.e. a map \(X\xrightarrow {\langle o,\delta \rangle } \mathbb {N}\times X\) that we call stream coalgebra. Given a state \(x\in X\), we call the sequence of natural numbers

$$\begin{aligned} (\,o(x), o(\delta (x)), o(\delta ^2(x)),\ldots \,) \end{aligned}$$

the stream generated by x. Since X is finite, this stream is eventually periodic, i.e. of the form \(s=s_0s_1^\omega \) for finite lists \(s_0\) and \(s_1\) of natural numbers. (Here \((\mathord {-})^\omega \) means infinite iteration.) Two eventually periodic streams \(s=s_0s_1^\omega \) and \(t=t_0t_1^\omega \) with \(s_1=(s_{1,0},\ldots , s_{1,p-1})\) and \(t_1 = (t_{1,0},\ldots ,t_{1,q-1})\) are called equivalent if one has

$$\begin{aligned} q\cdot \sum _{i<p} s_{1,i} = p\cdot \sum _{j<q} t_{1,j}, \end{aligned}$$
(2.2)

i.e. the entries of the two lists \(s_1^q\) and \(t_1^p\) of length \(p \cdot q\) have the same sum. For instance, the streams

$$\begin{aligned} s=(1,2,7,4)(1,3,2)^\omega = (1,2,7,4,1,3,2,1,3,2,1,3,2,\ldots ) \end{aligned}$$

and

$$\begin{aligned} t=(5,6)(0,4)^\omega = (5,6,0,4,0,4,0,4,0,4,\ldots ) \end{aligned}$$

are equivalent. Note that the above notion of equivalence is well-defined, i.e. not depending on the choice of the finite lists \(s_0,s_1\) and \(t_0,t_1\) in the representation of s and t. In fact, given alternative representations \(s=\overline{s}_0 \overline{s}_1^\omega \) and \(t=\overline{t}_0 \overline{t}_1^\omega \) with \(\overline{s}_1 = (\overline{s}_{1,0},\ldots ,\overline{s}_{\overline{p}-1})\) and \(\overline{t}_1=(\overline{t}_{1,0},\ldots ,\overline{t}_{1,\overline{q}-1})\), the lists \(s_1^{\overline{p}}\) and \(\overline{s}_1^p\) are equal up to cyclic shift, as are the lists \(t_1^{\overline{q}}\) and \(\overline{t}_1^{q}\). Therefore from (2.2) it follows that

$$\begin{aligned} \overline{q}\cdot q\cdot p \cdot \sum _{i<\overline{p}} \overline{s}_{1,i} = \overline{q}\cdot q \cdot \overline{p}\cdot \sum _{i<p} s_{1,i} = \overline{q} \cdot \overline{p} \cdot p\cdot \sum _{j<q}t_{1,j} = \overline{p} \cdot p\cdot q\cdot \sum _{j<\overline{q}} \overline{t}_{1,j}. \end{aligned}$$

Dividing by \(p\cdot q\) yields

$$\begin{aligned} \overline{q}\cdot \sum _{i<\overline{p}} \overline{s}_{1,i} = \overline{p}\cdot \sum _{j<\overline{q}} \overline{t}_{1,j}, \end{aligned}$$

as required.

Lemma 2.3

(a) The coalgebra \(\varphi \mathsf {Id}\) is carried by the set of equivalence classes of eventually periodic streams. The unary operation and the coalgebra structure are both given by \(\mathsf {id}{:}\,\varphi \mathsf {Id}\rightarrow \varphi \mathsf {Id}\). (b) For any \(\mathsf {Id}\)-coalgebra \((TX,\gamma _X)\) with X finite, the colimit injection \(\gamma _X^\#{:}\,TX\rightarrow \varphi \mathsf {Id}\) maps \((m,x)\in TX\) to the equivalence class of the stream generated by x.

Proof

(1) We first show that the morphisms \((\mathord {-})^\#\) form a cocone. Given an ffg-coalgebra \((TX,\gamma _X)\) and elements \((m,x),(n,y)\in TX\) with \(\gamma _X(m,x)=(n,y)\), the stream generated by y is the tail of the stream generated by x, and thus the two streams are equivalent. This shows that \(\gamma _X^\#\) is a coalgebra homomorphism.

To show that the morphisms \((\mathord {-})^\#\) form a compatible family, suppose that \(h{:}\,(TX,\gamma _X)\rightarrow (TY,\gamma _Y)\) is a homomorphism of ffg-coalgebras, and let \((m,x)\in TX\) and \((n,y)\in TY\) with \(h(m,x)=(n,y)\) be given. We need to show that the streams generated by x and y are equivalent. Denote by

$$\begin{aligned} (m_j,x_j) := \gamma _X^j(m,x)\quad \text {and}\quad (n_j,y_j):= \gamma _Y^j(n,y)\qquad (j=0,1,2,\ldots ) \end{aligned}$$
(2.3)

the states reached from (mx) and (ny) after j steps. Since h is a coalgebra homomorphism, one has \(h(m_j,x_j)=(n_j,y_j)\) for all j. Since X is finite, there exist natural numbers \(k\ge 0\) and \(p>0\) with \(x_k=x_{k+p}\). Then the eventually periodic stream generated by x is given by

$$\begin{aligned} (m_1-m_0,m_2-m_1,\ldots , m_k-m_{k-1})(m_{k+1}-m_k,\ldots , m_{k+p}-m_{k+p-1})^\omega \end{aligned}$$

Since \(h(m_k,x_k)=(n_k,y_k)\) and \(h(m_{k+p},x_{k+p}) = (n_{k+p},y_{k+p})\), one has \(y_k=y_{k+p}\), which implies that y generates the stream

$$\begin{aligned} (n_1-n_0,n_2-n_1,\ldots , n_k-n_{k-1})(n_{k+1}-n_k,\ldots , n_{k+p}-n_{k+p-1})^\omega \end{aligned}$$

To show that the streams generated by x and y are equivalent, it suffices to verify that \(m_{k+p}-m_k=n_{k+p}-n_k\), as this entails that

$$\begin{aligned}&p\cdot \sum _{i<p} m_{k+i+1}-m_{k+i} = p\cdot (m_{k+p}-m_k) = p\cdot (n_{k+p}-n_k) \\&\quad = p\cdot \sum _{i<p} n_{k+i+1}-n_{k+i}. \end{aligned}$$

To prove the desired equation, we compute

$$\begin{aligned} (n_{k+p},y_{k+p})&= h(m_{k+p},x_{k+p}) \\&= h(m_{k+p},x_k) \\&= h(m_{k+p}-m_k+m_k, x_k) \\&= (m_{k+p}-m_k+n_k,y_k) \end{aligned}$$

where the last equality uses that \(h(m_k,x_k)=(n_k,y_k)\) and that h is a morphism in \(\mathscr {C}\). This implies \(n_{k+p}=m_{k+p}-m_k+n_k\).

(2) We prove that the cocone \((\mathord {-})^\#\) is a colimit cocone. Since sifted colimits in \(\mathop {\mathsf {Coalg}}\mathsf {Id}\) are formed as in \(\mathscr {C}\) and thus as in \({\mathsf {Set}}\), it suffices to show that (i) the morphisms \(\gamma _X^\#\) are jointly surjective and (ii) given ffg-coalgebras \((TX,\gamma _X)\) and \((TY,\gamma _Y)\) and two states \((m,x)\in TX\) and \((n,y)\in TY\) merged by \(\gamma _X^\#\) and \(\gamma _Y^\#\), there exists a zig-zag in \(\mathop {\mathsf {Coalg}_{\mathsf {ffg}}}\mathsf {Id}\) connecting the two states. Statement (i) is clear because finite stream coalgebras generate precisely the eventually periodic streams. For (ii), we adapt the argument of the first part of our proof and continue to use the notation (2.3). Since X and Y are finite, there exist natural numbers \(k\ge 0\) and \(p>0\) with \(x_k=x_{k+p}\) and \(y_k=y_{k+p}\). As the streams generated by x and y are equivalent, one has \(m_{k+p}-m_k = n_{k+p}-n_k\). Consider the ffg-coalgebra \((TZ,\gamma _Z)\) with \(Z=\{z_0,z_1,\ldots ,z_{k+p-1}\}\), and \(\gamma _Z\) defined by

$$\begin{aligned} \gamma _Z(z_j) = (0,z_{j+1}) \;\;(j<k+p-1) \quad \text {and}\quad \gamma _Z(z_{k+p-1}) = (m_{k+p}-m_k,z_k). \end{aligned}$$

Form the morphisms \(g{:}\,TZ\rightarrow TX\) and \(h{:}\,TZ\rightarrow TX\) given by

$$\begin{aligned} g(z_{j}) = (m_j,x_j) \quad \text {and}\quad h(z_j) = (n_j,y_j)\qquad (j<k+p). \end{aligned}$$

Then g and h are coalgebra homomorphisms. Indeed, for \(j<k+p-1\) we have

$$\begin{aligned} g(\gamma _Z(z_j))&= g(0,z_{j+1})&(\text {def.}~ \gamma _Z)\\&= (m_{j+1},x_{j+1})&(\text {def.}~ g)\\&= \gamma _X(m_j,x_j)&(\text {def.}~ m_{j+1},\, x_{j+1})\\&= \gamma _X(g(z_{j}))&(\text {def.}~ g) \end{aligned}$$

and moreover

$$\begin{aligned} g(\gamma _Z(z_{k+p-1}))&= g(m_{k+p}-m_k,z_k)&(\text {def.}~ \gamma _Z)\\&= (m_{k+p}-m_k+m_k,x_k)&(\text {def.}~ g)\\&= (m_{k+p},x_{k+p})\\&= \gamma _X(m_{k+p-1},x_{k+p-1})&(\text {def.}~ m_{k+p},\,x_{k+1})\\&= \gamma _X(g(z_{k+p-1}))&(\text {def.}~ g) \end{aligned}$$

and analogously for h. Thus we have constructed a zig-zag

in \(\mathop {\mathsf {Coalg}_{\mathsf {ffg}}}\mathsf {Id}\) connecting (mx) and (ny), as required. \(\square \)

Observe that every non-empty ffg-coalgebra \((TX,\gamma _X)\) admits infinitely many coalgebra homomorphisms into \(\varphi \mathsf {Id}\), for instance, any constant map into \(\varphi \mathsf {Id}\) is one. This shows that, in general, the coalgebra \(\varphi F\) is not final w.r.t. the coalgebras in \(\mathop {\mathsf {Coalg}_{\mathsf {ffg}}}F\).

3 Recap: Elgot Algebras

In this section we briefly recall the notion of an Elgot algebra [1] and some key results to contrast this with our subsequent development of ffg-Elgot algebras in Sect. 4. Throughout this section we assume the endofunctor \(F{:}\,\mathscr {C}\rightarrow \mathscr {C}\) to be finitary.

Definition 3.1

An fp-equation is a morphism

$$\begin{aligned} e{:}\,X \rightarrow FX + A, \end{aligned}$$

where X is an fp object (of variables) and A an arbitrary object of parameters.

Suppose that A carries the structure of an F-algebra \(a{:}\,FA \rightarrow A\). Then a solution of e in A is a morphism \({e}^\dagger {:}\,X \rightarrow A\) such that the square (2.1) commutes.

Notation 3.2

We use the following notation for fp-equations:

  1. (1)

    Given an fp-equation \(e{:}\,X \rightarrow FX + A\) and a morphism \(h{:}\,A \rightarrow B\) we have an fp-equation

    $$\begin{aligned} h \bullet e = \left( \,X \xrightarrow {e} FX + A \xrightarrow {FX + h} FX + B\,\right) . \end{aligned}$$
  2. (2)

    Given a pair of fp-equations \(e{:}\,X \rightarrow FX + Y\) and \(f{:}\,Y \rightarrow FY + Z\) we combine them into the following fp-equation

    where \(\mathsf {can}= [F\mathsf {inl},F\mathsf {inr}]{:}\,FX + FY \rightarrow F(X+Y)\) denotes the canonical morphism.

Definition 3.3

An Elgot algebra is a triple \((A,a,\dagger )\) where (Aa) is an F-algebra and \(\dagger \) is an operation

$$\begin{aligned} \frac{e{:}\,X \rightarrow FX + A}{{e}^\dagger {:}\,X \rightarrow A} \end{aligned}$$

assigning to every fp-equation in A a solution subject to the following two conditions:

  1. (1)

    Weak Functoriality. Given a pair of equations \(e{:}\,X \rightarrow FX + Z\), \(f{:}\,Y \rightarrow FY + Z\), where Z is an fp object, and a coalgebra homomorphism \(m{:}\,X \rightarrow Y\) for \(F(-) + Z\), then for every morphism \(h{:}\,Z \rightarrow A\) we have \({(h \bullet f)}^\dagger \cdot m = {(h \bullet e)}^\dagger \):

  2. (2)

    Compositionality. For every pair of fp-equations \(e{:}\,X \rightarrow FX + Y\) and \(f{:}\,Y \rightarrow FY + A\) we have

Remark 3.4

Later we will need the following properties of \(\bullet \) and :

  1. (1)

    \(t \bullet (s \bullet e) = (t \cdot s) \bullet e\) for every \(e{:}\,X \rightarrow FX + A\), \(s{:}\,A \rightarrow B\) and \(t{:}\,B \rightarrow C\);

  2. (2)

    for every \(e{:}\,X \rightarrow FX + Y\), \(f{:}\,Y\rightarrow FY + A\) and \(s{:}\,A \rightarrow B\);

  3. (3)

    for every \(e{:}\,X \rightarrow FX + Y\), \(f{:}\,Y \rightarrow FY + Z\) and \(g{:}\,Z \rightarrow FZ + V\).

For the proof of the first two see [1, Remark 4.6]. The remaining one is easy to prove by considering the three coproduct components of \(X+Y+Z\) separately, we leave this as an easy exercise for the reader.

Note that, in lieu of weak functoriality, \(\dagger \) previously [1] was required to satisfy (full) functoriality, i.e. given fp-equations \(e{:}\,X \rightarrow FX + A\), \(f{:}\,Y \rightarrow FY + A\) and a coalgebra homomorphism \(m{:}\,(X,e) \rightarrow (Y,f)\) we have \({f}^\dagger \cdot m = {e}^\dagger {:}\,X \rightarrow A\). However, this makes no difference:

Lemma 3.5

Functoriality and weak functoriality are equivalent properties of  \(\dagger \).

Proof

Functoriality clearly implies Weak Functoriality. In order to prove the converse, let \(e{:}\,X \rightarrow FX + A\), \(f{:}\,Y \rightarrow FY + A\) be fp-equations, and let \(m{:}\,(X,e) \rightarrow (Y,f)\) be a coalgebra morphism. Write A is the filtered colimit of its canonical diagram \(\mathscr {C}_\mathsf {fp}/A\) (cf. Sect. 2.1). The functor \(FX + (-)\) preserves filtered colimits, and so \(FX + A\) is the filtered colimit of the diagram formed by all morphisms \(FX + h{:}\,FX + Z \rightarrow FX + A\). Since X is fp, the morphism \(e{:}\,X \rightarrow FX + A\) factors through one of these morphisms, i.e. there exists a morphism \(h{:}\,Z \rightarrow A\) with Z fp and \(e'{:}\,X \rightarrow FX + Z\) such that \(e = h \bullet e'\):

Similarly, we have a factorization of \(f{:}\,Y \rightarrow FY + A\), and by filteredness of the diagram \(\mathscr {C}_\mathsf {fp}/A \rightarrow \mathscr {C}\) we can assume the same \(h{:}\,Z \rightarrow A\) is used. Thus a morphsm \(f'{:}\,Y \rightarrow FY + Z\) is given such that \(h \bullet f' = (FY + h) \cdot f' = f\). We do not claim that m is a coalgebra homomorphism from \((X,e')\) to \((Y,f')\). However, the corresponding equation holds when postcomposed by the colimit injection \(FY + h\):

$$\begin{aligned} (FX + h)\cdot (Fm + Z) \cdot e'&= (Fm + A) \cdot (FX + h) \cdot e' \\&= (Fm + A) \cdot e \\&= f \cdot m \\&= (FY + h) \cdot f' \cdot m. \end{aligned}$$

Therefore there exists a morphism \(h{:}\,Z' \rightarrow A\) with \(Z'\) fp and a connecting morphism \(z{:}\,Z \rightarrow Z'\) in \(\mathscr {C}_\mathsf {fp}/A\), i.e. z satisfies \(h' \cdot z = h\), such that \(FY + z\) merges \((Fm + Z) \cdot e'\) and \(f' \cdot m\). It follows that m is a coalgebra homomorphism from \(z \bullet e'\) to \(z \bullet f'\):

Indeed, the left-hand square commutes when postcomposed with \(FY + z\); thus, since the upper and lower parts as well as the right-hand square commute, so does the outside, as desired. By weak functoriality, we thus conclude

figure a

Example 3.6

Let us recall a few examples of Elgot algebras [1].

  1. (1)

    Iterative F-algebras (cf. Sect. 2.4): the operation \(\dagger \) assigning to every equation its unique solution satisfies Compositionality and (Weak) Functoriality, see [1, 2.15–1.19]. It follows that \(\varrho F\), \(\vartheta F\) and \(\nu F\) are Elgot algebras.

  2. (2)

    Cpo enrichable algebras. Recall that a complete partial order (cpo, for short) is a partially ordered set having joins of \(\omega \)-chains. Cpos form a category \({\mathsf {CPO}}\) together with the continuous functions, i.e. functions preserving joins of \(\omega \)-chains. Let \(F_0{:}\,{\mathsf {Set}}\rightarrow {\mathsf {Set}}\) be a functor having a locally continuous lifting \(F{:}\,{\mathsf {CPO}}\rightarrow {\mathsf {CPO}}\), i.e. a lifting such that the hom mappings \({\mathsf {CPO}}(X,Y) \rightarrow {\mathsf {CPO}}(FX,FY)\) are continuous. For example, every polynomial functor \(F_\varSigma \) associated to the signature \(\varSigma \) has a lifting to \({\mathsf {CPO}}\).

    Suppose further that \(a{:}\,FA \rightarrow A\) is an algebra where A is a CPO with a least element \(\bot \) and a is continuous. Then A is an Elgot algebra w.r.t. the operation \(\dagger \) assigning the least solution. More precisely, given an fp-equation \(e{:}\,X \rightarrow FX + A\) (in \({\mathsf {Set}}\)) consider X as a cpo with discrete order and let \(e^\dagger {:}\, X \rightarrow A\) be the least fixed point of the continuous function

    $$\begin{aligned} h \mapsto [a,A] \cdot (Fh + A) \cdot e \end{aligned}$$

    on the cpo of continuous functions from X to A. For details see [1, 3.5–3.8].

  3. (3)

    CMS enrichable algebras. A related example is based on complete metric spaces, i.e. metric spaces in which every Cauchy sequence has a limit. Here one considers the category \({\mathsf {CMS}}\) of complete metric spaces with distances in [0, 1] and non-expanding maps, i.e. maps \(f{:}\, X \rightarrow Y\) such that for every \(x,x' \in X\) one has \(d_Y(fx,fx') \le d_X(x,x')\). Let \(F_0{:}\, {\mathsf {Set}}\rightarrow {\mathsf {Set}}\) have a locally contracting lifting to \({\mathsf {CMS}}\), i.e. a lifting \(F{:}\, {\mathsf {CMS}}\rightarrow {\mathsf {CMS}}\) such that there exists some \(\varepsilon < 1\) such that for all \(f, g{:}\, X \rightarrow Y\) in \({\mathsf {CMS}}\) one has

    $$\begin{aligned} d_{X,Y} (f,g) \le \varepsilon d_{FX,FY}(Ff,Fg), \end{aligned}$$

    where \(d_{X,Y}\) denotes the \(\sup \)-metric on \({\mathsf {CMS}}(X,Y)\). Again, polynomial set functors have locally contracting liftings to \({\mathsf {CMS}}\).

    Now suppose that \(a{:}\, FA \rightarrow A\) is a non-empty algebra such that A carries a complete metric space and a is a non-expanding map. Then A is iterative, whence an Elgot algebra. In fact, for every equation \(e{:}\, X \rightarrow FX + A\) consider X as a discrete metric space (i.e. all distances are 1) and consider the \(\varepsilon \)-contracting function

    $$\begin{aligned} h \mapsto [a,A] \cdot (Fh + A) \cdot e \end{aligned}$$

    on \({\mathsf {CMS}}(X,A)\). Then, by Banach’s fixed point theorem, this function has a unique fixed point, viz. a unique solution of e. For details see [1, 2.8–2.11].

  4. (4)

    As a concrete instance of the previous point one can obtain fractals as solutions of equations. For example, let A be the set of closed subsets of the unit interval [0, 1] equipped with the following binary operation:

    $$\begin{aligned} (C,C') \mapsto \frac{1}{3}C \cup \left( \frac{1}{3}{C'} + \frac{2}{3}\right) , \end{aligned}$$

    where \(\frac{1}{3}C = \{\frac{1}{3} c \mid c \in C\}\) etc. Then A is an algebra for \(F_0X = X \times X\) on \({\mathsf {Set}}\), and this \(F_0\) has the locally contracting lifting \(F(X,d) = (X \times X, \frac{1}{3}d_{\max })\), where \(d_{\max }\) denotes the usual maximum metric on the cartesian product. One sees that A is an algebra for F when equipped with the so-called Hausdorff metric. Hence, it is an Elgot algebra. For example, let \(X = \{x\}\) and let \(e{:}\, X \rightarrow FX + A\) be given by \(e(x) = (x,x)\). Then \({e}^\dagger (x)\) is the well-known Cantor set.

The rational fixed point \(\varrho F\) is, besides being the initial iterative F-algebra, also an initial Elgot algebra. Moreover, for every object Y, the rational fixed point \(\varrho (F(-) + Y)\) is a free iterative algebra on Y. Thus, the object assignment \(R{:}\, Y \mapsto \varrho (F(-) + Y)\) yields a monad on \(\mathscr {C}\), and one obtains the following

Theorem 3.7

([1]). The category of Eilenberg-Moore algebras for R is isomorphic to the category of Elgot algebras for F.

Thus, in particular, \(\varrho (F(-) + Y)\) is not only a free iterative algebra but also a free Elgot algebra on Y.

4 FFG-Elgot Algebras

The rest of our paper is devoted to studying the fixed point \(\varphi F\), the colimit of all ffg-coalgebras for F, in its own right and establish a universal property of it as an algebra.

Assumption 4.1

Throughout the rest of the paper we assume that \(\mathscr {C}\) is a variety of algebras and that \(F{:}\,\mathscr {C}\rightarrow \mathscr {C}\) is an endofunctor preserving sifted colimits.

Example 4.2

  1. (1)

    For the monad T representing \(\mathscr {C}\), all functors that are liftings of finitary set functor \(F_0\) (i.e., with a distributive law of T over \(F_0\)) preserve sifted colimits. Indeed, finitary set functors \(F_0\) preserve all sifted colimits [6, Proposition 6.30]. Since \(\mathscr {C}\) is cocomplete and the forgetful functor \(U{:}\,\mathscr {C}\rightarrow {\mathsf {Set}}\) preserves and reflects sifted colimits, it follows that every lifting of \(F_0\) preserves sifted colimits, too. The following examples are not liftings of set functors.

  2. (2)

    The functor \(FX = X + X\), where \(+\) denotes the coproduct of \(\mathscr {C}\) preserves sifted colimits. More generally, every coproduct of sifted colimit preserving functors preserves them too. Similarly, for finite products of sifted colimit preserving functors. Thus, all polynomial functors on \(\mathscr {C}\) preserve sifted colimits.

  3. (3)

    Let \(\mathscr {C}\) is an entropic variety, i.e. such that the usual tensor product makes it symmetric monoidal closed. (Examples include sets, vector spaces, join-semilattices, or abelian groups.) Then the functor \(FX = X \otimes X\) preserves sifted colimits. To see this, it suffices to show that (a) F is finitary and (b) it preserves reflexive coequalizers (see [5]). First note that since \(\mathscr {C}\) is symmetric monoidal closed, we know that each functor \(X \otimes -\) and \(- \otimes X\) is a left adjoint and therefore preserves all colimits.

    Ad (a). Suppose that \(D: \mathscr {D}\rightarrow C\) is a filtered diagram with colimit injections \(a_d: Dd \rightarrow A\) for \(d \in \mathscr {D}\). We need to prove that all \(a_d \otimes a_d: Dd \otimes Dd \rightarrow A \otimes A\) form a colimit cocone. That is, for every morphism \(f: X \rightarrow A \otimes A\) with X fp, (i) there exists some \(d \in \mathscr {D}\) and \(g: X \rightarrow Dd \otimes Dd\) with \((a_d \otimes a_d) \cdot g = f\) and (ii) given \(g, h: X \rightarrow Dd \otimes Dd\) that yield f in this way, there exists a morphism \(m: d \rightarrow d'\) in \(\mathscr {D}\) such that \(Dm \otimes Dm\) merges g and h.

    To prove (i), we use that \(- \otimes A\) is finitary to obtain some \(d \in \mathscr {D}\) and \(f': X \rightarrow A \otimes Dd\) with \((A \otimes a_d) \cdot f' = f\). Now use that \(Dd \otimes -\) is finitary to obtain \(d' \in \mathscr {D}\) and \(f'': X \rightarrow Dd \otimes Dd'\) with \((Dd \otimes a_{d'}) \cdot f'' = f'\). Since \(\mathscr {D}\) is filtered, we can choose morphisms \(m: d \rightarrow \bar{d}\) and \(n: d' \rightarrow \bar{d}\) in \(\mathscr {D}\). Let \(g = (Dm \otimes Dn)\cdot f''\). Then we have

    $$\begin{aligned} (a_{{\bar{d}}} \otimes a_{{\bar{d}}}) \cdot g&= (a_{{\bar{d}}} \otimes a_{{\bar{d}}}) \cdot (Dm \otimes Dn)\cdot f'' = (a_{d} \otimes a_{d'}) \cdot f''\\&= (a_d \otimes A) \cdot (Dd \otimes a_{d'}) \cdot f'' = (a_d \otimes A) \cdot f' = f \end{aligned}$$

    as desired.

    For (ii), use first that \({-}\otimes A\) is finitary and choose some morphism \(o: d \rightarrow d'\) such that

    $$\begin{aligned} (Do\otimes A) \cdot \left( (Dd \otimes a_d) \cdot g\right) = (Do\otimes A) \cdot \left( (Dd \otimes a_d) \cdot h\right) . \end{aligned}$$

    It follows that \((Dd' \otimes a_d)\) merges \((Do \otimes Dd) \cdot g\) and \((Do \otimes Dd) \cdot h\). Now use that \(Dd' \otimes -\) is finitary and choose a morphism \(p:d \rightarrow d''\) in \(\mathscr {D}\) such that \((Dd' \otimes Dp)\) also merges those two morphisms. Finally, use that \(\mathscr {D}\) is filtered to choose two morphisms \(q: d' \rightarrow {\bar{d}}\) and \(r: d'' \rightarrow {\bar{d}}\) such that \(q \cdot o = r \cdot p\), and let us call this last morphism \(m: d \rightarrow {\bar{d}}\). It is then easy to see that \(Dm \otimes Dm\) merges g and h:

    $$\begin{aligned} (Dm \otimes Dm) \cdot g&= (D(q \cdot o) \otimes D(r \cdot p))\cdot g = (Dq \otimes Dr) \cdot (Do \otimes Dp) \cdot g \\&= (Dq \otimes Dr) \cdot (Dd' \otimes Dp) \cdot (Do \otimes Dd) \cdot g \\&= (Dq \otimes Dr) \cdot (Dd' \otimes Dp) \cdot (Do \otimes Dd) \cdot h \\&= (Dm \otimes Dm) \cdot h. \end{aligned}$$

    Ad (b). Let \(f, g: A \rightarrow B\) be any (not necessarily reflexive) parallel pair of morphisms, and let \(c: B \rightarrow C\) be their coequalizer. Use that all functors \({-}\otimes X\) and \(X \otimes -\) preserve coequalizers to see that in the following diagram, whose parts commute in the obvious way, all rows and columns are coequalizers:

    By the ‘3-by-3 lemma’ [16, Lemma 0.17], it follows that the diagonal yields a coequalizer too, i.e., \(c \otimes c\) is a coequalizer of the pair \(f \otimes f, g \otimes g\) as desired.

  4. (4)

    Combining the previous argument with induction, we see that sifted colimit preserving functors on an entropic variety \(\mathscr {C}\) are stable under finite tensor products. Thus, all tensor-polynomial functors on \(\mathscr {C}\) preserve sifted colimits.

Under our assumptions we know that \(\varphi F\) is a fixed point of F and we will henceforth denote the inverse of its coalgebra structure by \( t{:}\,F(\varphi F) \rightarrow \varphi F. \)

Definition 4.3

By an ffg-equation is meant a morphism \(e{:}\,X \rightarrow FX + A\) where X is an ffg object. An ffg-Elgot algebra is a triple \((A,a,\dagger )\) where (Aa) is an F-algebra and \(\dagger \) is an operation

$$\begin{aligned} \frac{e{:}\,X \rightarrow FX + A}{{e}^\dagger {:}\,X \rightarrow A} \end{aligned}$$

assigning to every ffg-equation in A a solution and satisfying Weak Functoriality 3.3(1) and Compositionality 3.3(2) with XY and Z restricted to ffg objects.

Remark 4.4

Note that in categories where fp objects are ffg, e.g. in the category of sets or vector spaces, (ordinary) Elgot algebras and ffg-Elgot algebras are the same concept. However, in the present setting this may not be the case. Moreover, we do not know whether, for ffg-Elgot algebras, weak functoriality implies functoriality. The proofs of our main results (in particular Proposition 4.8 and Theorem 4.12) do not work when weak functoriality is replaced by functoriality.

Remark 4.5

In the case where \(F{:}\,{\mathsf {Set}}^T \rightarrow {\mathsf {Set}}^T\) is a lifting of a functor \(F_0{:}\,{\mathsf {Set}}\rightarrow {\mathsf {Set}}\) (via a distributive law \(\lambda \)), then an F-algebra is given by a set A equipped with both a T-algebra structure \(\alpha {:}\,TA \rightarrow A\) and an \(F_0\)-algebra structure \(a{:}\,F_0 A \rightarrow A\) such that a is a T-algebra homomorphism, i.e. one has \(\alpha \cdot Ta = a \cdot F\alpha \cdot \lambda _A\). Morphisms of F-algebras are those maps that are both T-algebra and \(F_0\)-algebra homomorphisms. Now one may think of ffg-equations and their solutions as modelling effectful iteration. Indeed, let \(X_0\) be a finite set of variables and consider any map

$$\begin{aligned} e_0{:}\,X_0 \rightarrow T(F_0 X_0 + A). \end{aligned}$$

Then this may be regarded as a system of recursive equations with variables \(X_0\) and parameters in A, where for any recursive call a side effect in T might happen. If \((A, \alpha , a)\) is an F-algebra, a solution to such a recursive system should assign to each variable in \(X_0\) an element of A, i.e. we have a map \({e}^\dagger _0{:}\,X_0 \rightarrow A\), such that the square below commutes (here we write \(+\) for disjoint union and \(\oplus \) for the coproduct in \(\mathscr {C}\), which may be different):

Indeed, from \(e_0\) we may form the map

$$\begin{aligned} \overline{e} = \left( X_0 \xrightarrow {e_0} T(F_0 X_0 + A) \xrightarrow {\cong } TF_0 X_0 \oplus TA \xrightarrow {\lambda _X \oplus \alpha } F TX_0 \oplus A\right) . \end{aligned}$$

Then its unique extension \(TX_0 \rightarrow FTX_0 \oplus A\) to a T-algebra morphism is an ffg-equation, and a solution \(TX_0 \rightarrow A\) of this in the sense of Definition 4.3 is precisely the same as an extension of a solution for \(e_0\) in the above sense.

Construction 4.6

We aim at proving that \(\varphi F\) is an initial ffg-Elgot algebra. For that we first construct a solution \({e}^\dagger {:}\,X \rightarrow \varphi F\) for every given ffg-equation \(e{:}\,X\rightarrow FX+\varphi F\). The colimit cocone of \(\varphi F\) is denoted by \({c}^\sharp : C \rightarrow \varphi F\) for (Cc) in \(\mathop {\mathsf {Coalg}_{\mathsf {ffg}}}F\).

Since X is an ffg-object, \(\mathscr {C}(X,-)\) preserves the sifted colimit

$$\begin{aligned} FX + \varphi F = \mathop {\mathrm {colim}}(FX + C), \qquad (C,c)~ \text {in}~ \mathop {\mathsf {Coalg}_{\mathsf {ffg}}}F. \end{aligned}$$

Every ffg-equation \(e{:}\,X \rightarrow FX + \varphi F\) thus factorizes through one of the colimit injections \(FX + {c}^\sharp \), i.e. for some \(c{:}\,C \rightarrow FC\) in \(\mathop {\mathsf {Coalg}_{\mathsf {ffg}}}F\) and \(w{:}\,X \rightarrow FX + C\) we have the commutative triangle below:

(4.1)

We see that w is an ffg-equation. We combine it with the ffg-equation c (having the initial object 0 as parameter) to , which is an object of \(\mathop {\mathsf {Coalg}_{\mathsf {ffg}}}F\). Finally, we put

(4.2)

The proofs of the following results can be found in [18].

Lemma 4.7

The definition of \({e}^\dagger \) in (4.2) is independent of the choice of the factorization (4.1), and \({e}^\dagger \) is a solution of e in \(\varphi F\).

Proposition 4.8

The algebra \(t{:}\,F(\varphi F) \rightarrow \varphi F\) together with the solution operator \(\dagger \) from Construction 4.6 is an ffg-Elgot algebra.

Definition 4.9

A morphism of ffg-Elgot algebras from \((A,a,\dagger )\) to \((B,b,\ddagger )\) is a morphism \(h{:}\,A \rightarrow B\) in \(\mathscr {C}\) preserving solutions, i.e. for every ffg-equation \(e{:}\,X \rightarrow FX + A\) we have

$$\begin{aligned} (h \bullet e)^\ddagger = h\cdot e^\dag . \end{aligned}$$

Identity morphisms are clearly ffg-Elgot algebra morphisms, and ffg-Elgot algebra morphisms compose. Therefore ffg-Elgot algebras form a category, which we denote by

$$\begin{aligned} \mathop {\mathsf {ffg\textsf {-}Elgot}}F. \end{aligned}$$

The next lemma shows that the above category is a subcategory of the category \(\mathbf {Alg}\,F\) of algebras for F.

Lemma 4.10

Morphisms of ffg-Elgot algebras are F-algebra homomorphisms.

Note that the converse fails in general. In fact, [1, Example 4.4] exhibits an (ffg-)Elgot algebra for the identity functor on \({\mathsf {Set}}\) and an algebra morphism on it which is not solution-preserving.

Theorem 4.11

The triple \((\varphi F, t, \dagger )\) is the initial ffg-Elgot algebra for F.

Proof

(Sketch). Let \((A,a,\ddagger )\) be an ffg-Elgot algebra. We obtain a cocone over the diagram

$$\begin{aligned} \mathop {\mathsf {Coalg}_{\mathsf {ffg}}}F \rightarrowtail \mathop {\mathsf {Coalg}}F\xrightarrow {U} \mathscr {C}\end{aligned}$$

(where U is the forgetful functor) as follows: to every ffg-coalgebra \(c{:}\,C\rightarrow FC\) assign the solution

$$\begin{aligned} (i_A\bullet c)^\ddagger {:}\,C\rightarrow A \end{aligned}$$

of \(i_A\bullet c{:}\,C\rightarrow FC+A\), where \(i_A{:}\,0\rightarrow A\) is the unique morphism. Thus there exists a unique morphism \(h{:}\,\varphi F\rightarrow A\) in \(\mathscr {C}\) such that the triangle below commute for every ffg-coalgebra \(c{:}\,C\rightarrow FC\):

One then shows that the morphism h is solution-preserving and is the unique such morphism. \(\square \)

The following result is the key to constructing free ffg-Elgot algebras. In the case where \(\mathscr {C}_\mathsf {ffg}= \mathscr {C}_\mathsf {fp}\), this yields a new result about ordinary Elgot algebras.

Theorem 4.12

Let \(a{:}\,FA\rightarrow A\) be an F-algebra and let Y be a free object of \(\mathscr {C}\). For any morphism \(h{:}\,Y\rightarrow A\), there is a bijective correspondence between

  1. (i)

    solution operators \(\dag \) such that \((A,a,\dag )\) is an ffg-Elgot algebra for F, and

  2. (ii)

    solution operators \(\ddagger \) such that \((A,[a,h],\ddagger )\) is an ffg-Elgot algebra for \(F(-)+Y\).

Proof

(Sketch). (1) Given an ffg-Elgot algebra \((A,a,\dag )\) for F, we define a solution operator \(\ddagger \) w.r.t. \(F(-)+Y\) as follows. For any ffg-equation \(e{:}\,X\rightarrow FX+Y+A\), let

$$\begin{aligned} e_h \;\equiv \; X\xrightarrow {e} FX+Y+A \xrightarrow {FX+[h,A]} FX+A \end{aligned}$$

and put

$$\begin{aligned} e^\ddagger \;:=\; e_h^\dag . \end{aligned}$$

Then one can prove that \((A,[a,h],\ddagger )\) is an ffg-Elgot algebra for \(F(-) +Y\). (In order to verify weak functoriality, the assumption that Y is free is critical.)

(2) Conversely, given an ffg-Elgot algebra \((A,[a,h],\ddagger )\) for \(F(-)+Y\), we define a solution operator \(\dag \) w.r.t. F as follows. For any ffg-equation \(e{:}\,X\rightarrow FX+A\), let

$$\begin{aligned} \overline{e} \;\equiv \; X\xrightarrow {e} FX+A \xrightarrow {\mathsf {inl}+A} FX+Y+A \end{aligned}$$

and put

$$\begin{aligned} e^\dag \;:=\; \overline{e}^\ddagger . \end{aligned}$$

Then one can prove that \((A,a,\dag )\) is an ffg-Elgot algebra.

(3) Finally, one shows that the two passages \(\dag \mapsto \ddagger \) and \(\ddagger \mapsto \dag \) are mutually inverse. \(\square \)

For the forgetful functor of ffg-Elgot algebras

$$\begin{aligned} U_F{:}\,\mathop {\mathsf {ffg\textsf {-}Elgot}}F\rightarrow \mathscr {C}\end{aligned}$$

recall that the slice category \(Y\mathord {/} U_F\) has as objects all morphisms \(y{:}\,Y\rightarrow U_F(A,a,\dag )\), and morphisms into \(y'{:}\, Y\rightarrow U_F(B,b,\ddagger )\) are the solution-preserving morphisms \(p{:}\, (A,a, \dag )\rightarrow (B,b,\ddagger )\) with \(p\cdot y = p'\). Denote by \(\uppi {:}\, Y/U_F \rightarrow \mathscr {C}\) the projection functor.

Corollary 4.13

For every free object Y of \(\mathscr {C}\), there is an isomorphism I of categories such that

It is given by \((A,[a,h],\ddagger ) \;\mapsto \; (h{:}\,Y\rightarrow U_F(A,a,\dag ))\).

Construction 4.14

For any object Y of \(\mathscr {C}\) denote by \(\varPhi Y\) the colimit of all ffg-coalgebras for \(F(-)+Y\), that is, \(\varPhi Y = \varphi (F(-)+Y)\). Its coalgebra structure is invertible, and we denote by \(t_Y{:}\,F\varPhi Y \rightarrow \varPhi Y\) and \(\eta _Y{:}\,Y\rightarrow \varPhi Y\) the components of its inverse.

The F-algebra \((\varPhi Y, t_Y)\) is endowed with a canonical solution operation \(\dag \): given an ffg-equation \(e{:}\,X\rightarrow FX+\varPhi Y\), put \(\overline{e} \;\equiv \; X\xrightarrow {e} FX+\varPhi Y \xrightarrow {FX+\mathsf {inl}} FX+Y+\varPhi Y\). This ffg-equation for \(F(-)+Y\) has a solution \(\overline{e}^\ddagger {:}\, X\rightarrow \varPhi Y\) in the ffg-Elgot algebra \(\varPhi Y = \varphi (F(-)+Y)\), and we put \( e^{\dag } \;:=\; \overline{e}^\ddagger . \)

The next result shows that all ffg-Elgot algebras form an algebraic category over the given variety \(\mathscr {C}\).

Theorem 4.15

For every free object Y of \(\mathscr {C}\), the algebra \((\varPhi Y, t_Y)\) with the solution operation \(\dagger \) is a free ffg-Elgot algebra for F on Y with \(\eta _Y\) as the universal morphism.

Proof

(Sketch). \(\varPhi Y\) is an ffg-Elgot algebra since it, together with \(\eta _Y\), corresponds to the initial ffg-Elgot algebra \(\varphi (F(-)+Y)\) under the isomorphism of Corollary 4.13. To verify its universal property, let \((A,a,\dag )\) be an ffg-Elgot algebra for F and \(h{:}\,Y\rightarrow A\) a morphism. Corollary 4.13 gives an ffg-Elgot algebra \((A,[a,h],\oplus )\) for \(F(-)+Y\) with \(e^\dag = \overline{e}^\oplus \) for all ffg-equations \(e{:}\,X\rightarrow FX+A\). Furthermore, Corollary 4.13 states that a morphism \(p{:}\,\varPhi Y\rightarrow A\) in \(\mathscr {C}\) is solution-preserving w.r.t. \(F(-)+Y\) if and only if it is solution-preserving w.r.t. F and satisfies \(p\cdot \eta _Y = h\). Therefore the universal property of \(\varPhi Y\) w.r.t. F follows from the initiality of \(\varPhi Y\) w.r.t. \(F(-)+Y\) (see Theorem 4.11). \(\square \)

Theorem 4.16

The forgetful functor \(U_F{:}\,\mathop {\mathsf {ffg\textsf {-}Elgot}}F \rightarrow \mathscr {C}\) is monadic.

Proof

(Sketch). (1) First, one readily proves that \(U_F\) creates sifted colimits. Moreover, \(U_F\) has a left adjoint. Indeed, for every ffg object Y there exists a free ffg-Elgot algebra on Y by Theorem 4.15, which defines the corresponding functor \(\varPhi {:}\,\mathscr {C}_\mathsf {ffg}\rightarrow \mathop {\mathsf {ffg\textsf {-}Elgot}}F.\) We can extend it to a left adjoint of \(U_F\) as follows. Given an object Y of \(\mathscr {C}\) expressed as a sifted colimit \(y_i{:}\,Y_i\rightarrow Y\) (\(i\in I\)) of ffg objects, then the image of that sifted diagram under \(\varPhi \) has a colimit \({\mathop {\mathrm {colim}}}_{i\in I} \varPhi Y_i\) which, since \(U_F\) creates sifted colimits, is an ffg-Elgot algebra. It follows easily that this colimit is a free ffg-Elgot algebra on Y.

(2) By Beck’s theorem it remains to prove that \(U_F\) creates coequalizers of \(U_F\)-split pairs of morphisms. Thus let \(f,g{:}\, (A,a,\dag )\rightarrow (B,b,\ddagger )\) be solution-preserving morphisms of ffg-Elgot algebras and suppose that morphisms \(c{:}\,B\rightarrow C\), \(s{:}\,C\rightarrow B\) and \(t{:}\,B\rightarrow A\) in \(\mathscr {C}\) are given with \(c\cdot f = c\cdot g\), \(c\cdot s = \mathsf {id}_C\), \(g\cdot t = \mathsf {id}_B\) and \(s\cdot c = f\cdot t\).

Since the category \(\mathbf {Alg}\,{F}\) of F-algebras and their morphisms is monadic over \(\mathscr {C}\) [8] we know that there is a unique F-algebra structure \(\gamma {:}\,FC\rightarrow C\) such that C is an F-algebra homomorphisms from (Bb) to \((C,\gamma )\) and c is, moreover, a coequalizer of f and g in \(\mathbf {Alg}\,{F}\). Define a solution operator \(*\) for \((C,\gamma )\) as follows. Given an ffg-equation \(e{:}\,X\rightarrow FX+C\), put \(e^* = c\cdot (s\bullet e)^\ddagger \). One then proves that \(*\) is the unique solution operator making \((C,\gamma ,*)\) an ffg-Elgot algebra and c a solution-preserving morphism from \((B,b,\ddagger )\) to \((C,\gamma ,*)\). Moreover, c is a coequalizer of f and g in \(\mathop {\mathsf {ffg\textsf {-}Elgot}}F\). \(\square \)

5 Conclusions and Further Work

For a functor F on a variety preserving sifted colimits, the concept of an Elgot algebra [1] has a natural weakening obtained by working with iterative equations having ffg objects of variables. We call such algebras ffg-Elgot algebras. We have proved that the locally ffg fixed point \(\varphi F\) of an endofunctor, constructed by taking the colimit of all F-coalgebras with an ffg carrier, is the initial ffg-Elgot algebra for F. Furthermore, we have proved that all free ffg-Elgot algebras exist, and we have shown that the colimit of all ffg-carried coalgebras for \(F(-) + Y\) yield a free ffg-Elgot algebra on Y whenever Y is a free object of \(\mathscr {C}\) on some (possibly infinite) set. Finally, we have proved that the forgetful functor \(\mathop {\mathsf {ffg\textsf {-}Elgot}}H \rightarrow \mathscr {C}\) is monadic.

We leave the task of giving a coalgebraic construction of arbitrary free ffg-Elgot algebras for further work. In addition, the study of the properties of the ensuing free ffg-Elgot algebra monad is also left for the future. The monad of ordinary free Elgot algebras (cf. Sect. 3) yields the free Elgot monad on the given endofunctor F; it should be interesting to see whether the above monad of free ffg-Elgot algebras is characterized by a similar universal property.

Finally, in the current setting we have the following picture of categories and forgetful functors: \(\mathop {\mathsf {ffg\textsf {-}Elgot}}F \hookrightarrow \mathop {\mathsf {Alg}}F \rightarrow \mathscr {C}\rightarrow {\mathsf {Set}}.\) Each of those functors has a left-adjoint and is in fact monadic, and we have shown that the composite of the first two is monadic, too. We leave the question whether the composite of all three of the functors is monadic for further work.