initial algebra of an endofunctor






An initial algebra for an endofunctor FF on a category CC is an initial object in the category of algebras of FF. These play a role in particular as the categorical semantics for inductive types.


Relation to algebras over a monad

The concept of an algebra of an endofunctor is arguably somewhat odd, a more natural concept being that of an algebra over a monad. However, the former can often be reduced to the latter.


If 𝒞\mathcal{C} is a complete category, then the category of algebras of an endofunctor F:𝒞𝒞F : \mathcal{C} \to \mathcal{C} is equivalent to the category of algebras over a monad of the free monad on FF, if the latter exists.

The proof is fairly straightforward, see for instance (Maciej) or at free monad.

The existence of free monads, on the other hand, can be a tricky question. One general technique is the transfinite construction of free algebras.

Lambek’s theorem


If FF has an initial algebra α:F(X)X\alpha: F(X) \to X, then XX is isomorphic to F(X)F(X) via α\alpha.


In this sense, XX is a fixed point of FF. Being initial, XX is the smallest fixed point of FF in that there is a map from XX to any other fixed point (indeed, any other algebra), and this map is an injection if CC is Set.


The dual concept is terminal coalgebra, which is the largest fixed point of FF.


Given an initial algebra structure α:F(X)X\alpha: F(X) \to X, define an algebra structure on F(X)F(X) to be F(α):F(F(X))F(X)F(\alpha): F(F(X)) \to F(X). By initiality, there exists an FF-algebra map i:XF(X)i: X \to F(X), so that

F(X) F(i) F(F(X)) α F(α) X i F(X)\array{ F(X) & \overset{F(i)}{\to} & F(F(X)) \\ \alpha \downarrow & & \downarrow F(\alpha) \\ X & \underset{i}{\to} & F(X) }

commutes. Now it is trivial, in fact tautological that α\alpha is itself an FF-algebra map F(X)XF(X) \to X. Thus αi=1 X\alpha \circ i = 1_X, since both sides of the equation are FF-algebra maps XXX \to X and XX is initial. As a result, F(α)F(i)=1 F(X)F(\alpha) \circ F(i) = 1_{F(X)}, so that iα=1 F(X)i \circ \alpha = 1_{F(X)} according to the commutative square. Hence α\alpha is an isomorphism, with inverse ii.

Adámek’s theorem

In many cases, initial algebras can be constructed in recursive fashion, using the following special case of a theorem due to Adámek.

Theorem (Adámek)

Let CC be a category with an initial object 00 and transfinite composition of lengh ω\omega, hence colimits of sequences ωC\omega \to C (where ω\omega is the first infinite ordinal), and suppose F:CCF: C \to C preserves colimits of ω\omega-chains. Then the colimit γ\gamma of the chain

0iF(0)F(i)F (n)(0)F (n)(i)F (n+1)(0)0 \overset{i}{\to} F(0) \overset{F(i)}{\to} \ldots \to F^{(n)}(0) \overset{F^{(n)}(i)}{\to} F^{(n+1)}(0) \to \ldots

carries a structure of initial FF-algebra.


The FF-algebra structure FγγF\gamma \to \gamma is inverse to the canonical map γFγ\gamma \to F\gamma out of the colimit (which is invertible by the hypothesis on FF). The proof of initiality may be extracted by dualizing the corresponding proof given at terminal coalgebra.

This approach can be generalized to the transfinite construction of free algebras.

Semantics for inductive types

Initial algebras of endofunctors are the categorical semantics of extensional inductive types. The generalization to weak initial algebras? captures the notion in intensional type theory and homotopy type theory.


Natural numbers

The archetypical example of an initial algebra is the set of natural numbers.


Let 𝒯\mathcal{T} be topos and let F:𝒯𝒯F : \mathcal{T} \to \mathcal{T} the functor given by

F:X*X F : X \mapsto * \coprod X

(hence the functor underlying the “maybe monad”). Then an initial algebra over FF is precisely a natural number object \mathbb{N} in 𝒯\mathcal{T}.


By definition, an FF-algebra is an object XX equipped with a morphism

(0,s):*XX, (0,s) : * \coprod X \to X \,,

hence equivalently with a point 0:*X0 : * \to X and an endomorphism s:XXs : X \to X. This being inital means that for (0 Y,s Y):*YY(0_Y, s_Y) : * \coprod Y \to Y any other morphism, there is a unique morphism f:XYf : X \to Y such that the diagram

* 0 X s X f f * 0 Y s Y \array{ * &\stackrel{0}{\to}& X &\stackrel{s}{\to}& X \\ \downarrow && \downarrow^{\mathrlap{f}} && \downarrow^{\mathrlap{f}} \\ * &\stackrel{0}{\to}& Y &\stackrel{s}{\to}& Y }

commutes. This is the very definition of natural number object X=X = \mathbb{N}.

More examples

Theorem 2 applies in particular to any functor F:SetSetF: Set \to Set which is a colimit of finitely representable functors hom(n,):XX nhom(n, -): X \mapsto X^n, as in the following examples.

  • Let AA be a set, and let F:SetSetF: Set \to Set be the functor F(X)=1+A×XF(X) = 1 + A \times X. Then the initial FF-algebra is A *A^*, the free monoid on AA. The FF-algebra structure is

    (e,m):1+A×A *A *(e, m| ): 1 + A \times A^* \to A^*

    where e:1A *e: 1 \to A^* is the identity and m:A×A *A *m|: A \times A^* \to A^* is the restriction of the monoid multiplication along the evident inclusion i×1:A×A *A *×A *i \times 1: A \times A^* \to A^* \times A^*.

    This “fixed point” of FF can be thought of as the result of the (slightly nonsensical) calculation

    1+A×X=XX=11A=1+A+A 2+=A *1 + A \times X = X \Rightarrow X = \frac1{1 - A} = 1 + A + A^2 + \ldots = A^*

    which can be made rigorous by interpreting the initial equality as defining the solution XX by recursion, and applying the theorem above.

  • Let F:SetSetF: Set \to Set be the functor F(X)=1+X 2F(X) = 1 + X^2. Then the initial FF-algebra is the set TT of isomorphism classes of finite (planar, rooted) binary trees. The FF-algebra structure is

    (r,j):1+T 2T(r, j): 1 + T^2 \to T

    where r:1Tr: 1 \to T names the tree consisting of just a root vertex, and j:T 2Tj: T^2 \to T creates a tree ttt \vee t' from two trees tt, tt' by joining their roots to a new root, so that the root of tt becomes the left child and the root of tt' the right child of the new root.

    The recursive equation

    T=1+T 2T = 1 + T^2

    would seem to imply that the structure TT behaves something like a structural “sixth root of unity”, and indeed the structural isomorphism TF(T)T \cong F(T) allows one to exhibit an isomorphism

    T=T 7T = T^7

    constructively, as famously explored in the paper by Andreas Blass, Seven Trees in One.

  • Let F:SetSetF: Set \to Set be the functor F(X)=X *F(X) = X^* (the free monoid from an earlier example). Then the initial FF-algebra is the set of isomorphism classes of finite planar rooted trees (not necessarily binary as in the previous example).

  • Let CC be the coslice category Ab\mathbb{Z} \downarrow Ab, and let F:CCF: C \to C be the functor which pushes out along the multiplication-by-pp map p:p \cdot -: \mathbb{Z} \to \mathbb{Z}. Then the initial FF-algebra is the Pruefer group [p 1]/\mathbb{Z}[p^{-1}]/\mathbb{Z}. See the discussion at the n-Category Café, starting here.

  • Let BanBan be the category of complex Banach spaces and maps of norm bounded above by 11, and let F:BanBanF: \mathbb{C} \downarrow Ban \to \mathbb{C} \downarrow Ban be the squaring functor XX×XX \mapsto X \times X. Then the initial FF-algebra is L 1([0,1])L^1([0, 1]) (with respect to the usual Lebesgue measure). This result is due to Tom Leinster; see this MathOverflow discussion.


A textbook account of the basic theory is in chapter 10 of

A brief review of some basics with an eye towards inductive types is in section 2 of

The relation to free monads is discussed in

Revised on February 12, 2014 05:41:21 by Urs Schreiber (