 # Constructing Initial Algebras Using Inflationary Iteration

An old theorem of Adámek constructs initial algebras for sufficiently cocontinuous endofunctors via transfinite iteration over ordinals in classical set theory. We prove a new version that works in constructive logic, using "inflationary" iteration over a notion of size that abstracts from limit ordinals just their transitive, directed and well-founded properties. Borrowing from Taylor's constructive treatment of ordinals, we show that sizes exist with upper bounds for any given signature of indexes. From this it follows that there is a rich class of endofunctors to which the new theorem applies, provided one admits a weak form of choice (WISC) due to Streicher, Moerdijk, van den Berg and Palmgren, and which is known to hold in the internal constructive logic of many kinds of elementary topos.

## Authors

##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1 Introduction

Initial algebras for endofunctors are a simple category-theoretic concept that has proved very useful in logic and computer science. Recall that an initial algebra for an endofunctor on a category , is a morphism in with the property that for any morphism , there is a unique that is an -algebra morphism, that is, satisfies . In functional programming, is sometimes called the catamorphism associated with the algebra  . By varying the choice of and , such initial algebras give semantics for various kinds of inductive (or dually, coinductive) structures and, via their catamorphisms, associated (co)recursion schemes. We refer the reader to the draft book by Adámek, Milius, and Moss  for an account of this within classical logic.

Here we make a contribution to the existence of initial algebras within constructive logics. Our motivation for doing so is not philosophical, nor motivated by the computational insights that a constructive approach can bring, important though both those thing are. Rather, we are interested in the semantics of dependent type theories with inductive constructions, such as types that are inductive , inductive-recursive , inductive-inductive , quotient (inductive-)inductive [10, 20] and more generally higher-inductive . Toposes are often used when constructing models of such type theories and sometimes the easiest way of doing so is to use their “internal logic” [19, Part D] to express the constructions; see [28, 22], for example. Although there are different candidates for what is the internal logic of toposes, in general they are not classical. So we are led to ask for what categories and functors that are describable in such an internal logic is it the case that an initial -algebra can be constructed?

We pursue this question by developing a constructive version of Adámek’s classical theorem about existence of initial algebras via transfinite iteration over ordinals  (we discuss a different constructive approach  in section 5). Recall, or see Adámek et al. [7, section 6.1] for example, that if is an endofunctor on a category with all small colimits (colimits of small chains is enough), then we get a large chain in , indexed by the totally ordered class of ordinals , defined by recursion over the ordinals:

 Fα0=⎧⎪⎨⎪⎩0(initial object in \C)if α=0, the ordinal zeroF(Fβ0)if α=β+ is a successor ordinal\colim_β<λFβ0if α=λ is a limit % ordinal (1)

The links in the chain are -morphisms also defined by ordinal recursion:

 i_α=⎧⎨⎩unique morphism given by initiality of 0if α=0, the ordinal zeroF(i_β)if α=β+ is a successor ordinalinduced by the universal property of colimitsif α=λ% is a limit ordinal (2)

[ (Adámek )] If is an isomorphism for some , then is an initial algebra for . So in particular, if preserves colimits of shape for some limit ordinal , then (by definition of “preserves colimits”) is an isomorphism and is an initial

-algebra. This theorem is labelled because its proof uses classical logic: the properties of ordinal numbers that it relies upon require the Law of Excluded Middle (

). In section 3 we show that by replacing the use of ordinals with a weaker notion of “size” and modifying the way is iterated, one can obtain a constructive version of Adámek’s theorem (see section 3).

Not only the proof, but also the application of Adámek’s theorem can require classical logic: the Axiom of Choice is often invoked to find a suitably large limit ordinal for which a particular functor of interest preserves -colimits. Such uses of are not always necessary. In particular, existence of initial algebras for polynominal functors (where and ) can be proved constructively; see [25, Proposition 3.6]. These initial algebras are the categorical analogue of W-types [2, 17] and we will make use of the fact that they exist in toposes with natural number object in what follows. However, for non-polynomial functors, especially ones whose specification involves both exponentiation by infinite sets and taking quotients by equivalence relations (such as section 4 below), it is not immediately clear that can be avoided. In fact, we show in section 4 that a much weaker choice principle than , the “Weakly Initial Sets of Covers” axiom [33, 25, 39] is enough to ensure that our constructive version of Adámek’s theorem applies to a rich class of endofunctors. has been called “constructively acceptable” because it is valid in a wide range of elementary toposes . In particular it holds in presheaf and realizability toposes that have been used to construct models of dependent type theory that mix quotients and inductive constructions, which, as we mentioned above, motivates our desire for a constructive treatment of initial algebras.

## 2 Constructive meta-theory

The results in this paper are presented in the usual informal language of mathematics, but only making use of intuitionistically valid logical principles (and, to obtain the results of section 4, extended by the WISC axiom). In particular we avoid use of the Law of Excluded Middle, or more generally the Axiom of Choice.

More specifically, our results can be soundly interpreted in any elementary topos with natural number object and universes  (satisfying , for the last part of the paper). Thus when we refer to the category

of small sets and functions, we mean the generalised elements of some such universe, which we always assume contains the subobject classifier. In fact, in order to interpret quantification over such small sets in a straightforward way, we tacitly assume there is a countable nested sequence of such universes,

. A suitable version of Martin-Löf’s Extensional Type Theory  extended with an impredicative universe of propositions can be used as the internal language of such toposes.

In fact the use of impredicative quantification is not necessary: we have developed a formalisation of the results of this paper using the Agda 

proof assistant, which can provide a dependent type theory with a predicative universe of (proof irrelevant) propositions and convenient mechanisms (such as pattern-matching) for using inductively defined types. We then have to postulate as axioms some things which are derivable in the logic of toposes, namely axioms for propositional extensionality, quotient sets and unique choice (and , when we need it). Our Agda development is available at

.

## 3 Size-indexed inflationary iteration

Throughout this section we fix a large, locally small category111The collection of objects is in and the collection of morphisms between any pair of objects is in . and an endofunctor . We will consider sequences of objects in built up by iterating while taking certain colimits. For simplicity we assume that is cocomplete, that is, has colimits of all small diagrams.222This means that we are given a function assigning a choice of colimit for each small diagram, since we work in a constructive setting and in particular have to avoid use of the Axiom of Choice.

From a constructive point of view, the problem with the sequence (1) is that it makes use of ordinals, which rely on the Law of Excluded Middle for their good properties; in particular, the definition in (1) is by cases according to whether an ordinal is zero, or a successor, or not. In the case that is a complete partially ordered set (with joins denoted by ), Abel and Pientka [4, section 4.5] point out that one can avoid this case distinction, while still achieving within constructive logic the same result in the (co)limit, by instead taking the approach of Sprenger and Dam  and using what they term an inflationary iteration:

 μ_iF=⋁_j

We only need to range over the elements of a set equipped with a binary relation that is well-founded for this definition to make sense. Here we generalise from complete posets to cocomplete categories, replacing joins by colimits. section 3 sums up what we need of the indexes and the relation between them in order to ensure that the inflationary sequence can be defined and yields an initial algebra for if it becomes stationary up to isomorphism.

Recall that a semi-category is like a category, but lacks identity morphisms. A semi-category is thin if there is at most one morphism between any pair of objects. Thus a small thin semi-category is the same thing as a set (the set of objects) equipped with a transitive relation (the existence-of-a-morphism relation). Given such a , a diagram in a category is by definition a semi-functor from to : thus maps each to a -object , each pair with to a -morphism , and these morphisms satisfy for all in .

A size is a small thin semi-category that is

• directed: every finite subset of has an upper bound with respect to ; specifically, we assume we are given a distinguished element and a binary operation satisfying

• well-founded: for all , if , then .

Note that the directedness property in particular gives a successor operation on the elements of a size, defined by and satisfying . (We do not need a successor that also preserves , although the sizes constructed in the next section have one that does so.)

In the next section we will define a rich class of sizes derived from algebraic signatures (see section 4). For now, we note that the natural numbers with their usual strict order is a size.333

will be the smallest size once one has developed a comparison relation between sizes. To do that one probably has to restrict to sizes that are

extensional, that is, satisfy . However, we have no need of that property for the results in this paper. In classical logic, an ordinal is a size iff its usual strict total order is directed, which happens iff it is a limit ordinal.

Since we are working constructively, the well-foundedness property of a size is stated in a suitably positive form; classically, it is equivalent to the non-existence of infinite descending chains for . Well-foundedness of allows one to define size-indexed families by well-founded recursion [37, section 6.3]: given a size and a -indexed family of sets , from each family of functions we get a family of elements , uniquely defined by the requirement . Given a size , for each element we get a small thin semi-category444Well-foundedness is preserved, but directedness is not, so is not necessarily a size. whose vertices are the elements with and whose morphisms are the instances of the relation. Thus a diagram maps each to a -object and each pair with to a -morphism , satisfying for all . We write

 (\incD_j:D_j\fun\colim_j

for the colimit of this diagram (recall that we are assuming is cocomplete). Thus for all it is the case that ; and given any cocone in

 (f_j:D_j\funX)_j

there is a unique -morphism satisfying .

Since is transitive, if in , then is a sub-semi-category of and each diagram restricts to a diagram . We write

 (5)

for the unique -morphism satisfying .

Let be a size. Given an endofunctor on a cocomplete category , a diagram is an inflationary iteration of over if for all

Given an endofunctor on a cocomplete category , for each size the inflationary iteration of over exists (and is unique).

###### Proof.

Given , say that a diagram is an inflationary iteration of up to if for all , and . Note that given such a diagram, for any we have that is an inflationary iteration of up to . Using well-founded induction for , one can prove that

 ∀i∈κ,any two inflationary iterations of F up to i are equal (6)

Then one can use well-founded recursion for (section 3) to define for each an inflationary iteration of up to , . If , then and are both inflationary iterations of up to and so are equal by (6). From this it follows that

defines an inflationary iteration of . (Furthermore, since any such restricts to an up-to- inflationary iteration, uniqueness follows from (6).) ∎

We record some simple properties of inflationary iteration that we need in the proof of the theorem below. Let be the inflationary iteration of over . Note that for all in , the components of the colimit cocone are morphisms satisfying

 ∀k

The first equation follows from the fact that and the second from the definition of as a component of a cocone. Since that cocone is colimiting, one also has for all and all -morphisms that

 (∀j

The proof of section 3 only used the transitive and well-founded properties of the relation on a size , whereas the following theorem needs its directedness property as well.

[(Initial algebras via inflationary iteration)] Suppose is a cocomplete category, is an endofunctor and there is a size such that preserves colimits of diagrams . Then has an initial algebra whose underlying -object is the colimit of the inflationary iteration (section 3) of over .

###### Proof.

By section 3 there is an inflationary iteration of over ; call it and define . For each , as in section 3 we have with and hence a -morphism

 ι_i\defeq(F(D_i)ι_i,\sizesucci−−−−−−−−→D_\sizesucci\incD_\sizesucci−−−−−−−−−−→\colim_i∈κD_i=μF)

By (7), is a cocone under the diagram and so induces . Then since preserves the colimit of , we get a morphism

 ι\defeq(F(μF)=F(\colim_i∈κD_i)\iso\colim_i∈κF(D_i)^ι→μF) (9)

Therefore has the structure of an -algebra. To see that it is initial, suppose we are given . We have to show that there is a unique -algebra morphism .

If is such an algebra morphism, that is , then by definition of in (9) it follows that the associated cocone satisfies . From this, using the directedness property of sizes, we get

 ∀i∈κ.∀j

So if and are both -algebra morphisms , one can prove by well-founded induction for , using (8) and (10), that and hence that .

So it just remains to prove that there is such an . It suffices to construct a cocone satisfying (10) and then take to be the morphism given by the universal property of the colimit; for then we have and hence , as required.

For each , say that a morphism is an up-to- algebra morphism if (cf. (10)). Given such a morphism, then for any , is an up-to- algebra morphism. From this it follows by well-founded induction for that any two up-to- algebra morphisms are equal. A well-founded recursion for allows one to construct an up-to- algebra morphism for each ; and the uniqueness of up-to algebra morphisms implies that when . Thus is the required cocone satisfying (10). ∎

With the same assumptions on , and as in section 3, then free -algebras exist, that is, the forgetful functor from the category of -algebras to has a left adjoint.

###### Proof.

The free -algebra on an object is the same thing as an initial algebra for the endofunctor . So by the theorem, it suffices to check that preserves colimits of diagrams . It does so because does by assumption and because is directed (cf. section 4(4) below). ∎

## 4 Initial algebras for sized endofunctors

In classical set theory with the Axiom of Choice, given a set of operation symbols with associated arities , the associated polynomial endofunctor on preserves -colimits when the ordinal is large enough; specifically it does so if for all , has upper bounds (with respect to the strict total order given by membership) for all -indexed families of ordinals less than . We will see that this notion of “large enough” is also the right one for sizes in our constructive setting.

A signature (also known as a container [2, 17]) is specified by a set and an -indexed family of sets . We write for the large set of all such signatures. Given , we say that a size is -filtered if for all and every function , there exists with . We can deduce the existence of -filtered sizes by abstracting from the constructive analysis of Conway’s surreal numbers by Shulman , which in turn is inspired by Taylor’s constructive notion of “plump” ordinal . For each , let be the initial algebra for the associated polynominal endofunctor , . Thus is an example of a W-type [27, Chapter 15]. The function exists in our constructive setting, because W-types can be constructed in elementary toposes with natural number objects [25, Proposition 3.6]; one can take the elements of to be well-founded trees representing the algebraic terms inductively generated by the signature . Each such term is uniquely of the form where is the -arity operation symbol named by and, inductively, is a -tuple of well-founded algebraic terms over . The plump ordering on is given by the least relations and satisfying for all , and

 (∀x∈B(a).f(x)

As noted in [15, Example 5.4], is transitive and well-founded, and is a preorder (reflexive and transitive). In particular, since is reflexive, from (11) we deduce that , in other words for each arity set in the signature, any function is bounded above in the relation by . This allows us to construct -filtered sizes:

There is a -filtered size for every signature .

###### Proof.

Given a signature , we extend it to a signature by adding fresh nullary and binary operation symbols. Thus and satisfies for , and . Let set be the W-type and let be the plump order given by (11). As noted above, is transitive and well-founded and has upper bounds for any arity-indexed family and hence in particular it is -filtered. It just remains to see that it is directed (section 3). Since contains the nullary operation symbol , contains ; and given , letting map to and to , then is an upper bound for and with respect to . ∎

Given a signature , a functor between cocomplete categories is -sized if it preserves colimits of all diagrams for any -filtered size . A functor is sized it there exists a signature for which it is -sized.

[(Sized endofunctors have initial algebras)] Assuming is a cocomplete category, if is sized, then there exists an initial algebra for . More precisely, there is a function assigning to each signature and each -sized endofunctor an initial algebra for .

###### Proof.

If is -sized for some , then preserves colimits of diagrams for the -filtered size constructed in the proof of section 4. Hence by section 3, it has an initial algebra, given by taking the colimit of its inflationary iteration. ∎

To apply this theorem one needs a rich collection of sized functors. The rest of the section is devoted to exploring closure properties of sized functors. To do so we use the following operation on signatures:

Suppose is a family of signatures indexed by the elements of some set . Then the signature sum is the signature where and maps each to the set . As a special case when , we have the binary sum . There is also an empty signature which acts as a unit for up to isomorphism (for a suitable notion of signature morphism).

Note that if a size is -filtered, it is also -filtered for each . Conversely, given a single signature , if a size is -filtered, it is also -filtered.

Suppose that , and are cocomplete categories.

1. Any cocontinuous functor is sized.

2. Identity functors are sized. If and are sized, so is their composition .

3. The terminal functor and the projection functors and are sized; if and are sized, then so is .

4. For any the constant functor with value is sized.

###### Proof.

For part 1, if is cocontinuous, then it is -sized for any and in particular for the empty signature.

The first sentence of part 2 follows from part 1. If is -sized and is -sized, then and both preserve colimits over any -filtered size, because such a size is also - and -filtered. The composition preserves such a colimit because and do. Therefore is -sized.

For part 3 we use the fact that colimits in a product category are computed componentwise. Thus the terminal and projection functors are sized by part 1; and if is -sized and is -sized, then is -sized.

For part 4, note that each size is directed and hence in particular is a connected semi-category; therefore is canonically isomorphic to . So the constant functor with value is -sized for any and in particular for the empty signature. ∎

We can deduce further preservation properties involving infinitary operations on sized functors by assuming a weak form of choice, which following https://ncatlab.org/nlab/show/WISC we call the axiom. It was introduced in type theory by Streicher  under the name (“Type Theoretic Collection Axiom”) and independently in constructive set theory by Moerdijk and van den Berg  under the name “Axiom of Multiple Choice”; see also Levy [21, Section 5.1]: [] A (possibly large) cover of a set is a surjective function with . An indexed family555We will refer to elements of as families rather than signatures when we are not thinking of them as collections of operation symbols of set-valued arity. is a wisc for if for any cover , there exist and such that is surjective. The axiom666For simplicity and following , we have given the axiom just for a pair of universes, ; more generally one can ask for the property to hold for any pair . states that for every there exists a family that is a wisc for it. “Wisc” stands for “weakly initial set of covers” and the terminology is justified by the fact that if in the family is a wisc for , then the family of covers of whose domains are of the form for some is weakly initial among all the (possibly large) covers of : for every and , there is some cover in the family that factors as for some .

Classically, is implied by the Axiom of Choice , since the latter implies that every surjection has a right inverse and hence the family whose single member is is a is a wisc for . From the results of van den Berg and Moerdijk  (and as noted by Streicher ), if any elementary topos satisfies , then so do toposes of (pre)sheaves and realizability toposes built from ; it is in this sense that the axiom is constructively acceptable. In particular, starting from the category of sets in classical set theory with , holds in the kinds of topos that have been used to model type theory with various kinds of higher inductive types, whose semantics motivates the work presented here. (However, it does not hold in all toposes .)

[] Suppose holds and that and are cocomplete categories. If is a family of sized functors indexed by a set , then there exists a signature such that is -sized for all .

###### Proof.

Consider the large set in . By assumption on , the first projection is a large777This proof, as well as that for section 4, illustrate the need for a wisc property that quantifies over large covers of small sets. cover of . By there is some surjection in and a function so that for all , the functor is -sized; and since is surjective this implies that each is -sized for some . Consider the signature from section 4. By section 4, each is -sized. ∎

[ (Colimits of sized functors)] Suppose that holds, and are cocomplete categories, is a small category and that is a functor. If for some signature the functor is -sized for each , then is also -sized. More generally, if each is sized, then so is .

###### Proof.

If is -sized for all and is a -filtered size, then each preserves colimits of all diagrams . Thus given such a diagram , we have a canonical isomorphism , natural in . Taking the colimit over and writing , we have . Since colimits commute with each other, it follows that the canonical morphism is an isomorphism. Therefore is -sized. The last sentence of the theorem follows by section 4. ∎

[] Suppose holds and that and are cocomplete categories. If is sized, then there is a function assigning to each an initial algebra for the functor . The induced functor is sized.

###### Proof.

Suppose is -sized. It follows from section 4 and section 4 that for each , the functor is -sized. Therefore by sections 4 and 3, the function is the required function mapping each to an initial algebra for . Since each is , it follows by well-founded induction on that each is -sized, using section 4 (taking to be the category generated by the thin semi-category ). Then by section 4 again (taking to be the category generated by ) we have that is -sized. ∎

Although sections 4, 4 and 4 show that there is quite a rich collection of sized functors, what is lacking so far is any closure under taking limits, assuming the target category has them; in other words the dual of section 4. We consider this for the case , leaving consideration of more general complete and cocomplete categories for future work. First note that if are sized functors, the equalizer of any parallel pair of natural transformations is also a sized functor (it is -sized if is -sized and is -sized). This is because each size is directed and so taking -colimits in commutes with finite limits and hence in particular with equalizers. So to get closure of sized functors under all small limits it suffices to consider small products. For this we need to use a “double cover” signature of a set (the wiscs and in the proof of section 4 below), inspired by the use that Swan  makes of the indexed form of the WISC Axiom; see also . So we will need wiscs for indexed families of sets; but their existence follows from : [] Assuming holds, then for every family of sets there exists a family that is a wisc for each set .

###### Proof.

Consider . By , the first projection is a large cover of . Since there is a wisc for , it follows that there is some surjection in and a function so that for all , is a wisc for . Consider the signature sum as in section 4. Thus writing for and for each , we have and is the function mapping each to . Then we claim that is a wisc for each set . For, given any cover , since is a surjection, there exists with ; then since is a wisc for , there exists and such that is surjective. So there exists and with is surjective. Therefore does indeed have the wisc property for . ∎

[ (Products of set-valued sized functors are sized)] Suppose that is a cocomplete category. Assuming holds, if is a family of sized functors indexed by some set , then the functor given by taking products in is also sized.

###### Proof.

By section 4, there exists a signature so that each functor is -sized. However, we need a bigger signature than in order to prove that is sized. Using , let be a wisc for . Then using section 4, let be a wisc for the sets in the family , where

 kerp\defeq{(d_1,d_2)∈E_c×E_c∣p(d_1)=p(d_2)} (12)

We claim that the functor is -sized when (using the signature sum from section 4).

If is a diagram on a -filtered size , then by section 4, each is -sized and so we have a canonical isomorphism . Taking the product over , we get . So it just remains to show that the canonical function

 \can_F,D:\colim_i∈κ((∏_x∈XF_x)D_i)=\colim_i∈κ∏_x∈XF_x(D_i)\fun∏_x∈X\colim_i∈κF_x(D_i) (13)

is an isomorphism, that is, both an injection and a surjection. The summand in ensures that has upper bounds for -indexed families for any ; and the summand ensures the same for -indexed families, for any . The first kind of upper bound, together with the wisc property of comes into play in proving that is injective; and both kinds of upper bound and the wisc properties of and come into play in proving that is surjective.

To prove that is injective and surjective we use the fact that the colimit in of a directed diagram can be described explicitly as the quotient where the equivalence relation identifies if there is some with , and . We will write for the -equivalence class of . Then the function in equation 13 satisfies for all and

 \can_F,D[i,f]_≈=λx∈X.[i,f(x)]_≈

To see that is injective, suppose we also have and satisfying ; we wish to prove that . By definition of , from the assumption about we have . Since is a wisc for , there exists , a surjection and a function so that

 ∀z∈E_c.i

Since is a summand in and is a -filtered size, there is an -upper bound for ; and since is directed, we can assume and . So from (14) and surjectiviy of we deduce that , which implies . Therefore the function