nLab
terminal coalgebra of an endofunctor

Context

Algebra

Induction

Terminal coalgebras

Introduction

A terminal coalgebra, also called final coalgebra, for an endofunctor F on a category C is a terminal object in the category of coalgebras of F.

If F has a terminal coalgebra α:XF(X), then X is isomorphic to F(X) (see below); in this sense, X is a fixed point of F. Being terminal, X is the largest fixed point of F in that there is a map to X to any other fixed point (indeed, any other coalgebra), and this map is an injection if C is Set.

The dual concept is initial algebra. Just as initial algebras allow for induction and recursion, so terminal coalgebras allow for coinduction and corecursion.

Details

Given two coalgebras (x,η:xFx), (y,θ:yFy), a coalgebra map is a morphism f:xy which respects the coalgebra structures:

θf=F(f)η\theta \circ f = F(f) \circ \eta

A terminal coalgebra (usually called a final coalgebra in the literature) is of course a terminal object in the category of coalgebras. Many data structures can be expressed as terminal coalgebras of suitable endofunctors; a simple but useful theorem says that terminal coalgebras x are “fixed points” of their endofunctors, in that Fxx. This is the dual form of a theorem discovered long ago by Lambek:

Theorem

If (x,θ:xFx) is a terminal object in the category of F-coalgebras, then θ is an isomorphism.

Proof

Define a coalgebra structure on Fx by Fθ:FxFFx. By terminality of x, there is a unique coalgebra map f:Fxx. We claim this is inverse to θ. Indeed, by how we defined the coalgebra structure on Fx, it is tautological that θ is a coalgebra map. By terminality of x again, this gives an equation of coalgebra maps:

fθ=1 x.f \circ \theta = 1_x.

On the other hand,

θf=F(f)F(θ)=F(fθ)=F(1 x)=1 Fx\theta \circ f = F(f) \circ F(\theta) = F(f \circ \theta) = F(1_x) = 1_{F x}

where the first equation holds because f is a coalgebra map. This completes the proof.

To construct terminal coalgebras, the following result is useful and practical. See Adámek's theorem on terminal coalgebras? for an extension of this result.

Theorem (Adámek)

If C has a terminal object 1 and the limit L of the diagram

F 31F 2!F 21F!F1!1(1)\ldots F^3 1 \stackrel{F^2 !}{\to} F^2 1 \stackrel{F !}{\to} F 1 \stackrel{!}{\to} 1 \qquad (1)

exists in C and F preserves this limit, then the limit carries a structure of terminal coalgebra.

Proof

Let π n:LF n1 be the n th projection of the limiting cone. Then we have a cone from FL to the diagram (1) whose components are

FLFπ nF n+11F n!F n1F L \stackrel{F\pi_n}{\to} F^{n+1} 1 \stackrel{F^n !}{\to} F^n 1

and the induced map FLL to the limit is invertible by hypothesis; let θ:LFL be the inverse. We claim the coalgebra (L,θ) is terminal.

Indeed, suppose (x,η:xFx) is any coalgebra. We recursively define maps f n:xF n1: let f 0:x1 be the unique map, and

f n+1=F(f n)ηf_{n+1} = F(f_n) \circ \eta

It is easily checked by induction that we have a commutative diagram

F n+11 F n! F n1 Ff n f n+1 f n Fx η x\array{ F^{n+1}1 & \stackrel{F^n !}{\to} & F^n 1 \\ ^\mathllap{F f_n} \uparrow & \nwarrow ^\mathrlap{f_{n+1}} & \uparrow ^\mathrlap{f_n} \\ F x & \underset{\eta}{\leftarrow} & x }

defining a cone from x to the diagram (1), and inducing a map f:xL such that the following diagram commutes:

FL θ 1 L Ff f Fx η x\array{ F L & \stackrel{\theta^{-1}}{\to} & L \\ ^\mathllap{F f} \uparrow & & \uparrow ^\mathrlap{f} \\ F x & \underset{\eta}{\leftarrow} & x }

This diagram gives the fact that f is a coalgebra map. Moreover, any coalgebra map f:xL leads to a sequence f n=π nf that satisfies f n+1=F(f n)η, by gluing the second diagram to the commutative diagram

F n+11 F n! F n1 Fπ n π n+1 π n FL θ 1 L\array{ F^{n+1}1 & \stackrel{F^n!}{\to} & F^n 1 \\ ^\mathllap{F \pi_n} \uparrow & \nwarrow ^\mathrlap{\pi_{n+1}} & \uparrow ^\mathrlap{\pi_n} \\ F L & \underset{\theta^{-1}}{\to} & L }

so that we were forced to define the f n by recursion as we did, and the coalgebra map f:xL is therefore uniquely determined.

Examples

Unit interval in the real line

As first observed by Peter Freyd, the unit interval [0,1] inside the real line can be characterized as a suitable terminal coalgebra. There are various ways of realizing this; we give one (but see remarks below).

Consider the category of intervals Int, i.e., linearly ordered sets with separate top and bottom elements 1 and 0, and let

F:IntIntF\colon Int \to Int

be the endofunctor which takes an interval X to XX, the linear order obtained by taking two copies of X and gluing the top element of the first copy to the bottom element of the second. The real interval [0,1] becomes a coalgebra if we identify [0,1][0,1] with [0,2] and consider the multiplication-by-2 map [0,1][0,2] as giving a coalgebra structure.

Theorem

The interval [0,1] is terminal in the category of coalgebras.

Proof (sketch)

Given any coalgebra structure f:XXX, any value f(x) lands either in the “lower” half (the first X in XX), the “upper” half (the second X in XX), or at the precise spot between them, where the top element in the first copy is glued to the bottom element of the second. Intuitively, one could think of a coalgebra structure θ:XXX as giving an automaton where on input x 0 there is output of the form (x 1,h 1), where h 1 is either “upper”, “lower”, or “between”. By iteration, this generates a behavior stream (x n,h n). Interpreting upper as 1 and lower as 0, the h n form a binary expansion to give a number between 0 and 1, and therefore we have an interval map X[0,1] which sends x 0 to that number. Of course, should we ever hit (x n,between), we have a choice to resolve it as either (bottom X,upper) or (top X,lower) and continue the stream, but these streams are identified, and this corresponds to the identification of binary expansions

.h 1...h n1100000...=.h 1...h n1011111....h_1... h_{n-1} 100000... = .h_1... h_{n-1}011111...

as real numbers. In this way, we produce a unique well-defined interval map X[0,1], so that [0,1] is the terminal coalgebra.

Remarks

(More material can be found at coalgebra of the real interval.)

  1. The same proof shows that we could have considered instead the category of posets with separate top and bottom, or even the category of sets with separate top and bottom, with an analogous endofunctor. The reason we chose the category of intervals is (besides the availability of the succinct term ‘interval’) to indicate that choice of interval [0,1], as the model which classifies the geometric realization functor, can be justified on the grounds of a universal property, as shown by this theorem.

  2. Freyd, in his original post on this result, was inspired by a similar theorem due to Pavlovic and Pratt, that the half-open interval [0,) can be described as the terminal coalgebra for the endofunctor that sends a linearly ordered set X to ω×X with the dictionary order.

  3. The theorem holds in an arbitrary topos (with [0,1] being the interval of Dedekind reals), provided that the word “separate” is interpreted correctly:

    p:P(¬(0=p)¬(1=p))\forall p\colon P\; (\neg(0 = p) \vee \neg(1 = p))

    and provided that the process of gluing endpoints is given correctly. See Johnstone’s Elephant, section D.4.7, for an extended discussion.

Categorified example: Trees

The notion of terminal coalgebra may be categorified. For example, given a 2-category C and a (pseudo) functor F:CC, one may speak of a 2-terminal (pseudo) coalgebra.

A theoretically important example is the category of trees, seen as a 2-terminal coalgebra for the endofunctor on Cat which takes a locally small category C to its small-coproduct cocompletion. Further discussion of this point is given at pure set.

The small-coproduct cocompletion of C is given by a comma category construction: objects are pairs (X,F:X dC) where X is a set and F is a functor whose domain is the discrete category on X, denoted X d. A morphism from (X,F) to (Y,G) is a pair (f,Φ) where f:XY is a function and Φ:FGf d is a natural transformation. This category is denoted SetC; it is called a “categorical wreath product” (see also the discussion at club).

Adámek’s theorem may be adapted to this 2-categorical situation. The iterated wreath product (Set) n1 may be identified with the category of n-stage trees:

(Set) n1=Set [n] op(Set \wr)^n 1 = Set^{[n]^{op}}

where [n] is the linear order 12n. Or, what is the same, the category of presheaves T:[n+1] opSet with the condition that T(0)=1 is terminal; the element of T(0) is considered to be the root of the tree.

Indeed, we realize an explicit equivalence

Σ:SetSet [n] opSet [n+1] op\Sigma: Set \wr Set^{[n]^{op}} \simeq Set^{[n+1]^{op}}

by defining Σ(X,F:XSet [n] op) to be the functor T:[n+1] opSet that on the object level takes 1 to X, and i+1 to

xXF(x)(i).\sum_{x \in X} F(x)(i).

On the morphism level, T(i+1i) is the coproduct of morphisms

xXF(x)(ii1)\sum_{x \in X} F(x)(i \to i-1)

(and this makes sense for all 1in under the convention F(x)(0)=1).

The morphism

(Set) n!:(Set) nSet(Set) n1(Set \wr)^n !: (Set \wr)^n Set \to (Set \wr)^n 1

used in Adámek’s theorem is identified with the restriction functor

Set [n+1] opSet [n] opSet^{[n+1]^{op}} \to Set^{[n]^{op}}

which restricts presheaves along the inclusion [n][n+1].

The 2-limit of the diagram in Adámek’s theorem is then

Set ω op,Set^{\omega^{op}},

aka the category of trees, where ω is the colimit of the finite ordinals [n]. The statement that the category of trees is equivalent to its small-coproduct cocompletion says that the category of trees is equivalent to the category of forests.

Terminal coalgebras are the categorical semantics of coinductive types, for instance M-types.

References

  • Peter Freyd, Real coalgebra Mailing to the categories list, Dec. 22, 1999. (link)

Cross-relations between algebraic and coalgebraic aspects of real numbers may be found in this article:

  • Peter Freyd, Algebraic Real Analysis, Theor. Appl. Cat., vol. 20, no. 10 (2008), 215-308. (link)

Revised on October 4, 2012 23:54:54 by Urs Schreiber (82.169.65.155)