1. Introduction
1.1 Intuition
Given a set
$X$
, it is possible to form the set
$L(X)$
of finite lists with elements in
$X$
, also called lists on
$X$
. This mapping
$X \mapsto L(X)$
extends to a functor
$L : \textbf {Set} \rightarrow \textbf {Set}$
, where
$f : X \rightarrow Y$
becomes the map
$L(f) : L(X) \rightarrow L(Y)$
given by
$L(f)([x_1, \ldots , x_n]) = [f(x_1), \ldots , f(x_n)]$
.
One way of thinking of the collection
$L(X)$
of lists on
$X$
is to divide lists by length. For any fixed
$n \in \mathbb{N}$
, the set of lists on
$X$
of length
$n$
can just be thought of as
$X^n$
, the product of
$X$
with itself
$n$
times. This gives us a new way to express the set
$L(X)$
:
This expression, a “sum of powers of
$X$
,” is reminiscent of a polynomial, and indeed,
$L$
is an example of a polynomial functor. This means that
$L$
is “represented” by a polynomial, a certain type of diagram (we recall these definitions in Section 2). In our case, the polynomial in question is

where
$E = \{(m,n) \in \mathbb{N} \times \mathbb{N} : m\lt n\}$
, and
$\pi _2^E : E \rightarrow \mathbb{N}$
is the second projection. The goal of this paper is to state and prove that
$L$
is a polynomial functor in a much more general setting.
1.2 Main result
To state the main result of this paper, we must explain how the various concepts involved are adapted to more general categories.
First, the idea of “lists on
$X$
” can be extended to categories more general than
$\textbf {Set}$
by using list objects, introduced by Cockett (Reference Cockett1990). In a category
$\mathcal{C}$
with finite products where every object
$X$
has an associated (parametrized) list object
$L(X)$
, we can form a functor
$L : \mathcal{C} \rightarrow \mathcal{C}$
, which maps
$X$
to
$L(X)$
. We review list objects in more detail in Section 4.5. Moreover, it is often useful to consider list objects in a category
$\mathcal{C}$
, which has finite limits and is extensive (see Section 2); in the terminology of Cockett (Reference Cockett1990), this means
$\mathcal{C}$
is a locos.
Second, we need an analog of the function
$\pi _2^E : E \rightarrow \mathbb{N}$
. We replace
$\mathbb{N}$
with a natural numbers object
$N = L(\unicode {x1D7D9})$
(see Section 4.1), and
$E$
can be constructed using finite limits (see Section 4.4). The arrow
$\pi _2^E : E \rightarrow N$
is sometimes called the generic finite cardinal.
Third, we need a generalization of polynomial functors. Briefly, in a category with finite limits and list objects, if the arrow
$\pi _2^E$
is exponentiable, then the polynomial

induces a polynomial functor
$F_{\pi _2^E}$
, and we say
$L$
is represented by this polynomial if
$L \cong F_{\pi _2^E}$
. We detail these concepts in Section 2.
Our goal, then, is to prove the following theorem.
Theorem 1.1.
Let
$\mathcal{C}$
be an extensive category with finite limits and parametrized list objects. Then, the generic finite cardinal
$\pi _2^E$
is exponentiable, and the list object functor
$L : \mathcal{C} \rightarrow \mathcal{C}$
is represented by the polynomial

The proof of this theorem is given at the end of Section 5, relying on results from the rest of the paper. Section 5 explains the structure of the proof; see also Section 1.4 for the structure of this paper.
The functor
$L$
has been shown to be part of a cartesian monad (Jay Reference Jay1993a, Corollary 2.7], so Theorem 1.1 implies that
$L$
is part of a polynomial monad.
This result is notable because we prove that
$\pi _2^E$
is exponentiable while only assuming the existence of list objects. Usually, the list object functor is considered in the context of locally cartesian closed categories, where all arrows are exponentiable by assumption; Theorem 1.1 removes this assumption. In Section 1.3, we explain in more detail how this theorem compares to existing results.
We’ll see in Section 5 that the hypotheses of Theorem 1.1 can be weakened slightly. Indeed, instead of assuming
$\mathcal{C}$
is extensive, it suffices to assume two hypotheses, which we call (H1) and (H2) and which follow from extensivity (see Proposition 5.2). Another way to weaken the hypotheses of Theorem 1.1 would be avoid assuming the existence of all finite limits. We believe that all finite limits we use are pullbacks along injections of coproducts (such as the coproduct
$N = \unicode {x1D7D9} + N$
of fact 4.2), and these exist for free in an extensive category (see Proposition 2.2 of Carboni et al. (Reference Carboni, Lack and Walters1993). However, for ease of exposition, we will not pursue this idea further.
1.3 Comparison to existing results
Polynomial functors have been primarily studied in the context of locally cartesian closed categories; this is assumed in Gambino and Kock (Reference Gambino and Kock2013), our standard reference on the subject. Moreover, the list object functor has been shown to be polynomial (and represented by the diagram of Theorem 1.1) in a variety of settings.
-
• In the category of sets, this result is trivial; it is given as example 1.9 in Gambino and Kock (Reference Gambino and Kock2013).
-
• In a locally cartesian closed, positive coherent category (in particular, a topos) with NNO, list objects are guaranteed to exist and are constructed with the expected polynomial functor, usually written as
$X \mapsto \Sigma _{n \in N} X^n$
(Theorem 2.5.17 of Johnstone (Reference Johnstone2002)). -
• Another route to this result is through the following well-known fact (it is, e.g., used implicitly in a paper of Bénabou (Reference Bénabou1991)). If
$\mathcal{C}$
is a topos with NNO, then the polynomial functor
$X \mapsto \Sigma _{n \in N} X^n$
produces free monoids; that is, it is left adjoint to the forgetful functor
$\operatorname {Mon}(\mathcal{C}) \rightarrow \mathcal{C}$
, where
$\operatorname {Mon}(\mathcal{C})$
is the category of monoids in
$\mathcal{C}$
. This result has been attributed both to Mikkelsen (p. 190 of Johnstone (Reference Johnstone1977)) and to Lawvere (author’s note in Mikkelsen (Reference Mikkelsen2022)); it is also established in the proof of Theorem 6.41 in Johnstone (Reference Johnstone1977). It’s easy to show that
$L(X)$
is the free monoid on
$X$
(the unit is the singleton list and the operation is concatenation), so the desired result follows. -
• Another approach is to remark that the list object functor is a parametrized initial algebra. As discussed in Abbott et al. (Reference Abbott, Altenkirch, Ghani and Gordon2003) and Abbott et al. (Reference Abbott, Altenkirch and Ghani2005) (and using the notation of these papers), we have
$L(X) \cong \mu Y.(\unicode {x1D7D9} + X \times Y)$
. The functor
$(X,Y) \mapsto \unicode {x1D7D9} + X \times Y$
is (trivially) polynomial, and polynomial functors are closed under taking parametrized initial algebras (see section 6 of Abbott et al. (Reference Abbott, Altenkirch, Ghani and Gordon2003) or Theorem 6.3.10 of Basold (Reference Basold2018)), so
$L$
is polynomial. However, some assumptions are needed on the ambient category for this to hold; in particular, the category must be locally cartesian closed.
Each of these results assumes that the ambient category
$\mathcal{C}$
is (at least) locally cartesian closed. This is central to all the above arguments: the polynomial
$\Sigma _{n \in N} X^n$
exists by assumption, and it is shown to have certain properties. The significance of Theorem 1.1 is that we impose minimal assumptions on
$\mathcal{C}$
; in particular, we do not assume it is locally cartesian closed. Instead, we show directly that
$\pi _2^E$
is exponentiable and moreover that the resulting polynomial functor is isomorphic to
$L$
.
1.4 Structure of this paper
The first few sections of this paper are preliminaries: Section 2 reviews standard categorical concepts, Section 3 presents the internal language that is used throughout the paper, and Section 4 covers natural numbers objects and list objects (using the internal language), including some important constructions used in the paper. Throughout Section 4, we only assume we are working in a category with finite products (and usually a parametrized NNO or parametrized list objects) in order to keep the discussion as general as possible.
Then, in Section 5, we explain how to prove Theorem 1.1. We show how to reduce this theorem to a more tangible result, Theorem 5.3, whose proof takes up the rest of the paper (the proof of Theorem 1.1 is in Section 5, contingent on Theorem 5.3). We also note (with Proposition 5.2) that the assumption of extensivity for
$\mathcal{C}$
can be replaced by two weaker hypotheses, (H1) and (H2).
Finally, Sections 6 through 9 contain the main elements for the proof of Theorem 5.3; Section 5 explains how these parts fit together. Throughout Sections 6 to 9, we always assume we are working in a category with finite products (and usually a parametrized NNO or parametrized list objects). Many results will require the existence of finite limits, but we always state this assumption when it is needed; we also do not generally assume we are working in an extensive category.
2. Standard Categorical Notions
In this section, we’ll review standard concepts from category theory to establish notation and to recall useful results from the literature.
2.1 Products and pullbacks
For a binary product
$A \times B$
, we denote the projection maps
$\pi _1^{A,B}$
and
$\pi _2^{A,B}$
, omitting superscripts when they can be inferred from the context. The pairing of
$f : X \rightarrow A$
and
$g : X \rightarrow B$
is denoted
$\langle f, g \rangle$
, and given
$\alpha : X \rightarrow A$
and
$\beta : Y \rightarrow B$
, we write
$\alpha \times \beta$
for
$\langle \alpha \circ \pi _1, \beta \circ \pi _2\rangle : X \times Y \rightarrow A \times B$
. This notation extends to the
$n$
-fold product
$A_1 \times \ldots \times A_n$
, which has projections
$\pi _1, \ldots , \pi _n$
and pairing
$\langle f_i \rangle _{i=1}^n$
. In particular, for the terminal object
$\unicode {x1D7D9}$
, the unique arrow
$X \rightarrow \unicode {x1D7D9}$
is denoted
$\langle \rangle _X$
.
For pullbacks, the notation is similar. The pullback of
$f : A \rightarrow C$
and
$g : B \rightarrow C$
is denoted
$A \times _C B$
, and the projections are denoted
$\pi _1^{A,B}$
and
$\pi _2^{A,B}$
. We will also use the notation
$\langle p, q \rangle : X \rightarrow A \times _C B$
and
$\alpha \times _C \beta : X \times _C Y \rightarrow A \times _C B$
whenever these constructions are well-defined.
2.2 Slice categories and exponentiable arrows
Given an arrow
$f : A \rightarrow B$
in a category
$\mathcal{C}$
, we write
$\Sigma _f$
for the composition functor
$\mathcal{C}/A \rightarrow \mathcal{C}/B$
. Its right adjoint is the pullback functor
$\Delta _f : \mathcal{C}/B \rightarrow \mathcal{C}/A$
(sometimes denoted
$f^*$
), assuming it exists. In the special case
$B = \unicode {x1D7D9}$
, these functors become
$\Sigma _A : \mathcal{C}/A \rightarrow \mathcal{C}$
(the forgetful functor) and
$\Delta _A : \mathcal{C} \rightarrow \mathcal{C}/A$
.
If
$\Delta _f$
has a further right adjoint, we call it the dependent product functor along
$f$
and denote it
$\Pi _f : \mathcal{C}/A \rightarrow \mathcal{C}/B$
. We say
$f$
is exponentiable if the right adjoint
$\Pi _f$
exists; this is equivalent to saying that
$f$
is exponentiable as an object of
$\mathcal{C}/B$
(per Corollary 1.2 of Niefield (Reference Niefield1982)).
2.3 Polynomials
Polynomials and polynomial functors are often discussed in the context of a locally cartesian closed category, as is done in Gambino and Kock (Reference Gambino and Kock2013). However, it is possible to work in a much more general setting, as is done in Uemura (Reference Uemura2022) and Weber (Reference Weber2015), at the cost of not all polynomial functors existing. This is what we do as well.
Let
$\mathcal{C}$
be a category with finite limits. A polynomial over a category
$\mathcal{C}$
is a diagram
$P$
of the following form.

If
$f$
is exponentiable, then the functor
$F_P : \mathcal{C}/I \rightarrow \mathcal{C}/J$
given by

is called the polynomial functor associated to
$P$
. A functor
$F : \mathcal{C}/I \rightarrow \mathcal{C}/J$
is called a polynomial functor if there exists a polynomial
$P$
such that
$F_P$
exists and
$F \cong F_P$
. In this case, we say
$P$
represents
$F$
. If
$F : \mathcal{C} \rightarrow \mathcal{C}$
, then we say it is a polynomial functor if this is the case when using the usual identification between
$\mathcal{C}$
and
$\mathcal{C}/\unicode {x1D7D9}$
.
2.4 Extensivity
A category is extensive if it has finite coproducts, which are well-behaved; we refer to Carboni et al. (Reference Carboni, Lack and Walters1993) for the precise definition. Since we often assume our categories have finite limits, we use the following characterization, drawn from Proposition 2.2 of Carboni et al. (Reference Carboni, Lack and Walters1993).
Fact 2.1.
Let
$\mathcal{C}$
be a category with finite limits and finite coproducts. Then,
$\mathcal{C}$
is extensive if and only if for every coproduct
$X_1 \longrightarrow X_1 + X_2 \longleftarrow X_2$
and any commutative diagram as below,

the squares are pullbacks if and only if the top row is a coproduct.
In particular, in an extensive category, every binary coproduct is universal, which means that its pullback along any arrow is still a coproduct.
3. Reasoning with Variables
In any category with finite products, there is a way to express equalities between arrows in a “variable form”, so that an equality
$f=g$
is instead written as
$f(x) =_x g(x)$
. This improves readability: to define some
$h : X \times Y \times Z \rightarrow A$
, it is much clearer to write
We will use this notation throughout this paper, starting with Section 4.
The way to make this precise is to develop an internal language for our ambient category
$\mathcal{C}$
. The general technique is covered sections D1.1–D1.3 of Johnstone (Reference Johnstone2002), particularly on p. 837, but the version used in this paper is weaker than what is done there. We will therefore briefly describe our language, which is inspired by Román (Reference Román1989). We start in Section 3.1 with a system that works for any category with finite products, and then add some tools in Section 3.2 for categories with all finite limits.
We should note that, in addition to what is presented in this section, we introduce internal language notation for arithmetic and list-arithmetic operations in Sections 4.2, 4.3, and 4.5, and we use infix notation when appropriate.
3.1 The language for categories with finite products
In this section, we describe the internal language we’ll use for categories with finite products. First, the internal language has a collection of types, which are the objects of
$\mathcal{C}$
. It has function symbols of the form
$f : A_1 \times \ldots \times A_n \rightarrow B$
, which come from the arrows of
$\mathcal{C}$
. Arrows with domain
$\unicode {x1D7D9}$
are treated as constant symbols. We inductively build typed terms using variables and these function symbols in the usual way.
Next, a context is a list of variables and their types, such as
$C=(x:X, y:Y, z:Z)$
, and we write
$[C]$
for
$X \times Y \times Z$
. (We omit the types of the variables if they are clear from context.) A context is valid for a term
$t$
if all the variables in
$t$
occur in
$C$
, and the interpretation of a term
$t:B$
in a valid context
$C$
is an arrow
$[t]_C : [C] \rightarrow B$
. This interpretation is defined inductively: for a variable
$x_i$
in a context
$C=(x_1:X_1, \ldots , x_n:X_n)$
,
$[x_i]_C$
is the projection map
$\pi _i : [C] \rightarrow X_i$
, and for a term
$f(t_1, \ldots , t_n)$
, its interpretation is
$f \circ \langle [t_1], \ldots , [t_n] \rangle$
.
Finally, if
$t_1, t_2$
are terms in a context
$C$
, we write
$t_1 =_C t_2$
to mean that
$[t_1]_C = [t_2]_C$
(as arrows in
$\mathcal{C}$
). Since this is enough to make sense of the example above with
$h(x,y,z)$
, this completes the formal setup of the language. Notably, we don’t use relations, since the usual treatment requires the existence of pullbacks.
Below, we state some basic facts about this language (the only non-trivial rule is the second one, which requires Lemma D1.2.4 in Johnstone (Reference Johnstone2002)).
-
• The equality
$=_C$
is an equivalence relation. -
• The equality
$=_C$
is preserved by substitution: if
$a =_C b$
, then
$a[\vec {t}/\vec {y}] =_C b[\vec {t}/\vec {y}]$
, and if
$t_i =_C s_i$
for each
$i$
, then
$a[\vec {t}/\vec {y}] = a[\vec {s}/\vec {y}]$
. -
• Given arrows
$f,g : X_1 \times \ldots \times X_n \rightarrow Y$
and the context
$\vec {x} = (x_1 : X_1, \ldots , x_n : X_n)$
, we have
$f=g$
if and only if
$f(x_1, \ldots , x_n) =_{\vec {x}} g(x_1, \ldots , x_n)$
. -
• For any appropriate arrows
$f, (g_i)_{i=1}^m, (h_j)_{j=1}^n$
, terms
$(t_i)_{i=1}^m$
, and context
$C$
, we haveand
\begin{equation*} f(g_1(t_1, \ldots , t_n), \ldots , g_m(t_1, \ldots , t_n)) =_C (f \circ \langle g_1, \ldots , g_m \rangle )(t_1, \ldots , t_n) \end{equation*}
In particular,
\begin{equation*} f(h_1(t_1), \ldots , h_n(t_n)) =_C (f \circ (h_1 \times \ldots \times h_n))(t_1, \ldots , t_n). \end{equation*}
$f(g(t)) =_C (f \circ g)(t)$
.
Finally, given two terms
$a:A$
,
$b:B$
in a context
$C$
, we can let
$(a,b)$
be shorthand for the term
${\operatorname {Id}}_{A \times B}(a,b)$
(and similarly for products of any length). Since
$(a,b) : A \times B$
, this notation lets us mimic products of types without having to build them into the language. Remark that
$[(a,b)]_C = \langle [a]_C, [b]_C \rangle$
, as we’d expect. In particular, if we have an arrow
$g : A \times B \rightarrow X$
, then
$g((a,b)) =_C g(a,b)$
, and so we will not bother to distinguish between these terms.
3.2 Additional notation for categories with finite limits
In this section, we augment our internal language with some notation that makes it easier to work in categories with finite limits.
3.2.1. Contexts for equalizers
Suppose we have a context
$D = (y_1 : Y_1, \ldots , y_n : Y_n)$
and terms
$s,t : Z$
in the context
$D$
. Then, we can form the following equalizer diagram.

We will write
$\{y_1 : Y_1, \ldots , y_n : Y_n \mid s=t\}$
as notation for the object
$E$
, and we will write
$(y_1 : Y_1, \ldots , y_n : Y_n \mid s=t)$
or
$(D \mid s=t)$
as notation for the context
$D' = (e:E)$
. This makes it easier to refer to equalizers without using new variable names; for example, the context for a pullback of
$f : U \rightarrow W$
,
$g : V \rightarrow W$
is
$(u:U, \, v:V \mid f(u) = g(v))$
.
A key point here is that
$y_1, \ldots , y_n$
, as well as
$s$
and
$t$
, can be considered terms in the context
$D' = (y_1, \ldots , y_n \mid s = t)$
. Indeed, any terms in the context
$D$
can be also considered to be terms in
$D'$
, simply by “pulling back” along the inclusion map
$i : [D'] \rightarrow [D]$
. Explicitly, if
$i = \langle i_1, \ldots , i_n \rangle$
, then the variable
$y_k$
is considered shorthand for
$i_k(e)$
. Note that, if we view
$s,t$
as terms in
$D'$
, then we have
$s =_{D'} t$
.
3.2.2. Obtaining terms in the equalizer
Since the equalizer
$E$
is thought of as a subset of
$[D]$
, we want to be talk about “terms of type
$E$
” and “terms of type
$[D]$
which equalize
$s$
and
$t$
” interchangeably. This will require us to abuse notation in the following ways. First, if we have a term
$e : E$
, then we can also think of it as the term
$i(e) : [D]$
. So, we may write
$e : [D]$
to refer to this term.
Second, if we have terms
$u_1 : Y_1, \ldots , u_n : Y_n$
in a context
$C = (\vec {x} : \vec {X})$
, then the term
$(u_1, \ldots , u_n)$
is formally of type
$[D]$
. However, if
$s[\vec {u}/\vec {y}] =_C t[\vec {u}/\vec {y}]$
, then the universal property of the equalizer tells us there is a unique term
$u : E$
such that
$i(u) = (u_1, \ldots , u_n)$
. Thus, we write
$(u_1, \ldots , u_n) : E$
as shorthand for
$u : E$
.
It is important to note that these two ways of abusing notation are compatible with each other. On one hand, if
$(u_1, \ldots , u_n) : [D]$
equalizes
$s$
and
$t$
, then
$i(u_1, \ldots , u_n) =_C (u_1, \ldots , u_n)$
as terms of type
$[D]$
; on the other hand, if
$e : E$
, then
$i(e) =_C e$
as terms of type
$E$
(these are easy to check).
Finally, we remark that the latter notation behaves well with respect to substitution. That is, with the above setup, if we let
$w_1 : X_1, \ldots , w_m : X_m$
be terms in another context
$B$
, then
The proof is straightforward, though it does require Lemma D1.2.4 from Johnstone (Reference Johnstone2002).
3.2.3. Substitution for equalizers
As noted previously, if we have terms
$s,t$
in a context
$D = (y_1, \ldots , y_n)$
, then we can form the context
$D' = (y_1, \ldots , y_n \mid s = t)$
, and we can still view
$y_1, \ldots , y_n$
as terms in this context. However, these
$y_k$
are no longer variables in the context
$D'$
, since formally,
$D' = (e : E)$
, where
$E$
is the equalizer.
Now, consider a term like
$g(y_1, \ldots , y_n)$
in the context
$D$
. If we consider this term in the context
$D'$
, can we still substitute terms for the variables
$y_k$
? The
$y_k$
are no longer variables in the context
$D'$
, so this requires special consideration.
Formally, let
$r : R$
be a term in the context
$D' = (e : E) = (y_1, \ldots , y_n \mid s = t)$
, and let
$u_1 : Y_1, \ldots , u_n : Y_n$
be terms in a context
$C$
. If we assume that
$s[\vec {u}/\vec {y}] =_C t[\vec {u}/\vec {y}]$
, then we can say that
where on the right side,
$\vec {u} = (u_1, \ldots , u_n)$
is considered to be of type
$E$
by our previous abuse of notation. This definition ensures that our substitution notation enjoys many of the same properties of regular substitution, and it behaves the way: we have
$y_k[\vec {u}/\vec {y}] =_C u_k$
(the proof is straightforward).
4. Basic Constructions with Natural Numbers Objects and List Objects
In this section, we review the standard concepts of (parametrized) natural numbers objects and (parametrized) list objects, along with a few related constructions. We state the definitions, explain our notation, and establish (or recall) a few basic facts. Throughout this section, we only assume our ambient category
$\mathcal{C}$
to have finite products, except when stated otherwise, to keep our discussion as general as possible.
When possible, we give references in the literature for definitions and facts. However, in some cases, these are either not stated in quite the way we need or they are not in the same context (a category with only finite products); in this case, we describe the relevant comparisons and provide some brief proofs for completeness.
4.1 Natural numbers objects and arithmetic
We start this section by recalling the standard definition of natural numbers objects, which can be found in Román (Reference Román1989), for one.
Definition 4.1.
Let
$\mathcal{C}$
be a category with finite products. A
$\text{(parametrized) natural numbers object}$
(NNO) is a triple
$(N,0,s)$
consisting of an object
$N$
and arrows
$0 : \unicode {x1D7D9} \rightarrow N$
,
$s : N \rightarrow N$
, which satisfy the following property. For any objects
$A,B$
and arrows
$g : A \rightarrow B$
,
$h : A \times N \times B \rightarrow B$
, there exists a unique arrow
$f : A \times N \rightarrow B$
such that
$f(a,0) =_a g(a)$
and
$f(a,sn) =_{a,n} h(a,n,f(a,n))$
.
This definition uses our internal language (see Section 3); the definition is given diagrammatically in Román (Reference Román1989). Following the convention of Román (Reference Román1989), the term “natural numbers object” will always refer to parametrized natural numbers objects; we will not discuss unparametrized NNOs (where we omit the parameter
$A$
in the definition).
It’s helpful to have the following formulation of the universal property that uses the internal language even more (we omit the easy proof). It avoids the need to think of the terms
$f, f_1, f_2, g, h$
as coming from arrows and is more true to how calculations are performed in Román (Reference Román1989).
Remark. Let
$N$
be a natural numbers object. Let
$A,B$
be objects, let
$g$
be a term in the context
$(a:A)$
, and let
$h$
be a term in the context
$(a:A,n:N,b:B)$
. Then, there exists a term
$f$
in the context
$(a:A,n:N)$
such that
$f[0/n] =_a g$
and
$f[s(n)/n] =_{a,n} h[f/b]$
. Moreover, if
$f_1, f_2$
are two such terms, then
$f_1 =_{a,n} f_2$
.
The NNO property lets us define the operations of addition
$+ : N \times N \rightarrow N$
, multiplication
$\bullet : N \times N \rightarrow N$
, predecessor
$P : N \rightarrow N$
, and (truncated) subtraction
$\mathrel {\substack {\cdot \\[-1ex]-}} : N \times N \rightarrow N$
in the usual inductive way (see A2.5.4 of Johnstone (Reference Johnstone2002) for the full definitions). The operations
$+$
and
$\bullet$
, along with
$0$
and
$1 = s0$
, make
$N$
into an (internal) commutative semiring. More properties of these operations can be found in Román (Reference Román1989) (themselves inspired by Goodstein (Reference Goodstein1957)), and we prove some additional facts in Appendix A. We also record the following fact (see, e.g., Johnstone (Reference Johnstone2002), Lemma A2.5.5]).
Fact 4.2.
In a category with finite products and a (parametrized) NNO, the diagram
$\unicode {x1D7D9} \overset {0}{\longrightarrow } N \overset {s}{\longleftarrow } N$
is a coproduct.
4.2 Order in NNOs
Relations, such as inequality for natural numbers, are usually represented as subobjects and integrated into the internal language of a category. For natural numbers objects, the inequality relation (
$\leq$
) is given by the subobject
$N \times N \hookrightarrow N \times N : (m,n) \mapsto (m,m+n)$
, and strict inequality (
$\lt$
) is given by the subobject
$N \times N \hookrightarrow N \times N : (m,n) \mapsto (m,sm+n)$
(see Román (Reference Román1989), Section 3]).
However, relations in the internal language require pullbacks to be interpreted (Johnstone Reference Johnstone2002, Definition D1.2.6), which we are avoiding for this section. Instead, for this paper, we will use the following notation to express inequalities. Given two terms
$x,y : N$
in a context
$C$
, we write
$x \leq _C y$
to mean that
$x \mathrel {\substack {\cdot \\[-1ex]-}} y =_C 0$
, and we write
$x \lt _C y$
to mean
$s(x) \mathrel {\substack {\cdot \\[-1ex]-}} y =_C 0$
. This lets us write things like
$a \lt _a a+1$
.
The justification for this approach is that the subobject that defines inequality (given by
$(m,n) \mapsto (m,m+n)$
) is precisely the equalizer of the maps
$(x,y) \mapsto x \mathrel {\substack {\cdot \\[-1ex]-}} y$
and
$(x,y) \mapsto 0$
. In particular,
$x \leq _C y$
implies both that
$x \mathrel {\substack {\cdot \\[-1ex]-}} y =_C 0$
and that there is a term
$k$
such that
$x+k = y$
. (The analogous fact is true for strict inequality.) However, while this fact seems implicit in the proof of Proposition 3.2 in Román (Reference Román1989), we could not find it stated explicitly. In Appendix A, we show this result (Corollary A.3) and other useful facts about our version of inequality.
We also use inequalities when defining equalizers in our internal language; for instance, we will write
$\{m:N, n:N \mid m \lt n\}$
instead of
$\{m:N, n:N \mid (sm \mathrel {\substack {\cdot \\[-1ex]-}} n) = 0\}$
. Finally, we record the following proposition; it follows directly from Appendix A, but we single it out since we will use it several times.
Proposition 4.3.
Let
$\mathcal{C}$
be a category with finite products and an NNO, and let
$n : N$
be a term in a context
$C$
. If
$n \gt _C 0$
, then
$n =_C s(P(n))$
.
4.3 Definition by cases in NNOs
In this section, we’ll establish some notation for defining functions by cases. For instance, if we have a term
$n : N$
in a context
$C$
, we may like to define an arrow
$[C] \rightarrow X$
that splits into cases
$n=0$
and
$n\gt 0$
. In an extensive category with finite limits, this can be done by writing
$[C]$
as a coproduct (as is done in Section 6.1), but this is not possible in a general category with finite products. Fortunately, we can use an alternative, which we describe below.
Given an object
$X$
, define the function
$ITE_X : X \times X \times N \rightarrow X$
(short for “if-then-else”) by induction as follows:
We will use the following special notation for this function.
\begin{align*} ITE_X(x,y,n) =_{x,y,n} \left \{\begin{matrix} x\;\;\;\;\; & \text{if } n=0 \\ y\;\;\;\;\; & \text{else} \end{matrix}\right . \end{align*}
If we substitute the variables
$x,y,n$
by general terms in a context
$C$
, we obtain a function
$[C] \rightarrow X$
, as desired.
We make this notation a bit more flexible in two ways. First, when considering more than one case at a time, we’ll write
\begin{align*} \left \{\begin{matrix} x\;\;\;\;\; & \text{if } m=0 \\ y\;\;\;\;\; & \text{else if } n=0 \\ z\;\;\;\;\; & \text{else} \end{matrix}\right \} =_{x,y,z,m,n} \left \{\begin{matrix} x\;\;\;\;\; & \text{if } m=0 \\ \left \{\begin{matrix} y\;\;\;\;\; & \text{if } n=0 \\ z\;\;\;\;\; & \text{else} \end{matrix}\right \} & \text{else} \end{matrix}\right \}\!. \end{align*}
Second, if we want our condition to look like
$m \leq n$
instead of
$n = 0$
, we use the following shorthand (and similarly for
$m\lt n$
).
\begin{align*} \left \{\begin{matrix} x\;\;\;\;\; & \text{if } m \leq n \\ y\;\;\;\;\; & \text{else} \end{matrix}\right \} =_{x,y,m,n} \left \{\begin{matrix} x\;\;\;\;\; & \text{if } (m \mathrel {\substack {\cdot \\[-1ex]-}} n)=0 \\ y\;\;\;\;\; & \text{else} \end{matrix}\right \} \end{align*}
4.4 The generic finite cardinal
A key part of Theorem 1.1 is the arrow
$\pi _2^E : E \rightarrow N$
. In the category of sets, we said that
$E = \{(m,n) \in \mathbb{N} \times \mathbb{N} : m \lt n\}$
, and this carries over nicely to a category with finite limits and a natural numbers object
$N$
, where we set
(Here, we use notation from Sections 3.2 and 4.2; explicitly,
$E$
is the equalizer of the arrows
$N \times N \rightarrow N$
given by
$(m,n) \mapsto s(m) \mathrel {\substack {\cdot \\[-1ex]-}} n$
and
$(m,n) \mapsto 0$
.) Now, if we write
$D$
for the context
$(m : N, \, n : N \mid m\lt n)$
(remark that
$[D] = E$
), then we can define the map
$\pi _2^E : E \rightarrow N$
by
$\pi _2^E(m,n) =_D n$
. This arrow is sometimes called the generic finite cardinal (e.g., section A2.5 of [John 02]). Going forward, we’ll write
$E$
,
$\pi _2^E$
to refer to this object without mentioning it explicitly.
Remark. Corollary A.3 shows that
$E$
is just the subobject
$N \times N \rightarrow N \times N : (m,n) \mapsto sm + n$
, and so we don’t need to assume finite limits to define this object. However, we will only discuss this object in the context of a category with finite limits, so we don’t bother to use this characterization.
4.5 List objects
In this section, we introduce list objects and give some basic properties. List objects in the context of category theory originated with Cockett in 1990 and have since received considerable attention. They have notably been used to develop the theory of shapely functors (Jay Reference Jay1993a, Reference Jay1995; Jay et al. Reference Jay and Cockett1994; Moggi et al. Reference Moggi, Bellè and Jay1999) and are usually studied when the ambient category is a locos: an extensive category with finite limits and list objects. List objects have been used to study finiteness in a locos (Jay Reference Jay1997) and are used in Maietti (Reference Maietti2010) to define arithmetic universes. Owing to their roots in computer science, list objects are also studied from the perspective of datatypes in, for example, Abbott et al. (Reference Abbott, Altenkirch, Ghani and Gordon2003) and Abbott et al. (Reference Abbott, Altenkirch and Ghani2005), where they are examples of initial algebras and strictly positive types. List objects have even been generalized to monoidal categories (see Jay (Reference Jay1993b) and Fiore and Saville (Reference Fiore, Saville and Miller2017)); the free monoid functor, closely related to lists, can be constructed in certain cases when the category has countable coproducts (Lack Reference Lack2010).
List objects are defined as follows. As with natural numbers objects, “list object” will always mean the parametrized version.
Definition 4.4.
Let
$\mathcal{C}$
be a category with finite products, and let
$X \in \mathcal{C}$
be an object. A
$\text{(parametrized) list object}$
on
$X$
is a triple
$(L(X), r_0^X, r_1^X)$
consisting of an object
$L(X)$
and arrows
$r_0^X : \unicode {x1D7D9} \rightarrow L(X)$
,
$r_1^X : X \times L(X) \rightarrow L(X)$
, which satisfy the following property.
For any objects
$A,B$
and arrows
$g : A \rightarrow B$
,
$h : X \times B \rightarrow B$
, there exists a unique arrow
$f : A \times L(X) \rightarrow B$
, which makes the following diagrams commute. (Here,
$\sigma$
is the obvious isomorphism
$A \times (X \times L(X)) \rightarrow X \times (A \times L(X))$
.)

It is much easier to write these diagrams equationally. By writing
$\varnothing$
for
$r_0^X$
and
$x :: \ell$
for
$r_1^X(x,\ell )$
, the diagrams become the equations
$f(a,\varnothing ) =_a g(a)$
and
$f(a, x :: \ell ) =_{a,x,\ell } h(x,f(a,\ell ))$
; we’ll also use the notation
$[x]$
to denote the list
$x :: \varnothing$
. A version of the universal property with terms can also be formulated, like for natural numbers objects (see Section
4.1
).
The list object property can actually be generalized slightly to the following proposition. We have not found this result stated in the literature, but it seems to be used implicitly in Jay (Reference Jay1997), for instance. We use it to define the truncation arrow in Section 4.6.
Proposition 4.5.
Let
$\mathcal{C}$
be a category with finite products and all list objects, and let
$X \in \mathcal{C}$
. For any objects
$A,B$
and arrows
$g : A \rightarrow B$
,
$h : A \times X \times L(X) \times B \rightarrow B$
, there exists a unique arrow
$f : A \times L(X) \rightarrow B$
such that
$f(a, \varnothing ) =_a g(a)$
and
$f(a, x :: \ell ) =_{a,x,\ell } h(a,x,\ell ,f(a,\ell ))$
.
Proof. In the definition of list objects, replace
$B$
with
$A \times L(X) \times B$
. With some small straightforward adjustments, we get the desired property.
From this proposition, it becomes clear that
$L(\unicode {x1D7D9})$
is a (parametrized) natural numbers object, so it is redundant to assume that a category has list objects and a natural numbers object. Moreover, similarly to natural numbers objects, list objects can be expressed as a coproduct. (This is noted in section 2 of Jay et al. (Reference Jay and Cockett1994); it follows directly from the universal property.)
Fact 4.6.
In a category with finite products and list objects,
$\unicode {x1D7D9} \overset {r_0^X}{\longrightarrow } L(X) \overset {r_1^X}{\longleftarrow } X \times L(X)$
is a coproduct diagram.
Finally, if a category
$\mathcal{C}$
with finite products has all list objects, then we can form a functor
$L : \mathcal{C} \rightarrow \mathcal{C}$
, which maps
$X$
to the list object
$L(X)$
. Its action on arrows is defined as follows: given
$f : X \rightarrow Y$
, we define
$L(f) : L(X) \rightarrow L(Y)$
inductively by
The arrow
$L(f)$
is also denoted
$\texttt {map}(f)$
in Jay (1994).
4.6 Important list arrows
In this section, we define some important arrows related to list objects and prove some properties about them. Throughout, we assume we are working in a category
$\mathcal{C}$
with finite products and parametrized list objects (and therefore a parametrized NNO).
Most of these definitions and results are not original: many of them appear in the existing literature on list objects (briefly surveyed in Section 4.5). Some of the notation comes from functional programming (in Jay et al. (Reference Jay and Cockett1994), the authors note that some of their notation is from Bird and Wadler (Reference Bird and Wadler1988)), while some of the results are inspired by the Rocq standard library for lists (Rocq 2025). However, in many cases, the definitions and results are either used implicitly or proved under different assumptions. Therefore, we restate the parts we’ll need and compare to the literature when possible.
We start with the definitions. These operators are all indexed by an object
$X$
, but we remove this index if it is clear from context.
-
• The length arrow,
${\operatorname {len}}_X : L(X) \rightarrow N$
, is defined inductively by the equations
${\operatorname {len}}_X(\varnothing ) = 0$
and
${\operatorname {len}}_X(x :: \ell ) =_{x,\ell } s({\operatorname {len}}_X(\ell ))$
. -
• The list concatenation arrow,
$\mathbin {+\mkern -2mu+}_X : L(X) \times L(X) \rightarrow L(X)$
, is defined inductively by
$\varnothing \mathbin {+\mkern -2mu+}_X \ell _2 =_{\ell _2} \ell _2$
and
$(x :: \ell _1) \mathbin {+\mkern -2mu+}_X \ell _2 =_{x,\ell _1,\ell _2} x :: (\ell _1 \mathbin {+\mkern -2mu+}_X \ell _2)$
. -
• The truncate arrow,
${\operatorname {tr}}_X : L(X) \rightarrow L(X)$
, is the arrow that removes the leading element from a list. It is defined inductively by
${\operatorname {tr}}_X(\varnothing ) = \varnothing$
and
${\operatorname {tr}}_X(x :: \ell ) =_{x,\ell } \ell$
. -
• The tail arrow,
${\operatorname {tail}}_X : N \times L(X) \rightarrow L(X)$
, is an arrow, which iterates truncation:
${\operatorname {tail}}_X(n,\ell )$
returns the list
$\ell$
with the
$n$
leading elements removed. It is defined inductively by
${\operatorname {tail}}_X(0,\ell ) =_\ell \ell$
and
${\operatorname {tail}}_X(s(n), \ell ) =_{n,\ell } {\operatorname {tr}}_X({\operatorname {tail}}_X(n,\ell ))$
. -
• The zeroth-or-default arrow,
${\operatorname {zerothDef}}_X : X \times L(X) \rightarrow X$
, is an arrow that takes a pair
$(x,\ell )$
as input. If
$\ell$
is a nonempty list, it returns its leading element; however, if
$\ell$
is empty, it returns
$x$
, the “default” element. This arrow is defined inductively by
${\operatorname {zerothDef}}_X(x,\varnothing ) =_x x$
and
${\operatorname {zerothDef}}_X(x, y :: \ell ) =_{x,y,\ell } y$
. -
• The nth-or-default arrow,
${\operatorname {nthDef}}_X : X \times N \times L(X) \rightarrow X$
, is an arrow that takes a triple
$(x,n,\ell )$
as input. It returns the
$n^{th}$
element of
$\ell$
if
$n \lt {\operatorname {len}}(\ell )$
, and otherwise it returns a default. It is defined by
${\operatorname {nthDef}}_X(x,n,\ell ) =_{x,n,\ell } {\operatorname {zerothDef}}_X( x, \; {\operatorname {tail}}_X(n, \ell ))$
.
The length and concatenation arrows appear (for instance) in Jay et al. (Reference Jay and Cockett1994), where they are denoted
$\#$
and
$@$
; the truncate and tail arrows appear in Jay (Reference Jay1997), with the names tail and take; the
$\operatorname {zerothDef}$
and
$\operatorname {nthDef}$
maps appears in Rocq (2025) as hd and nth. Note that we say “the zeroth element” for the leading element for consistency with “the
$n^{th}$
element”.
Next, we establish some propositions about these maps. First, we have a naturality result; versions of these results are found in Rocq (2025).
Proposition 4.7.
Let
$f : X \rightarrow Y$
be an arrow. Then,
-
1.
${\operatorname {len}}_Y (L(f)(\ell ) ) =_\ell {\operatorname {len}}_X(\ell )$
; -
2.
${\operatorname {tr}}_Y (L(f)(\ell ) ) =_\ell L(f) ({\operatorname {tr}}_X(\ell ) )$
; -
3.
${\operatorname {tail}}_Y (m, \, L(f)(\ell ) ) =_{m,\ell } L(f) ({\operatorname {tail}}_X(m, \, \ell ) )$
; -
4.
${\operatorname {zerothDef}}_Y (f(x), \, L(f)(\ell ) ) =_{x,\ell } f ({\operatorname {zerothDef}}_X(x, \, \ell ) )$
; -
5.
${\operatorname {nthDef}}_Y (f(x), m, L(f)(\ell ) ) =_{x,m,\ell } f ({\operatorname {nthDef}}_X(x,m,\ell ) )$
.
Proof. Statements 1, 2, and 4 are by induction on
$\ell$
; statement 3 is by induction on
$m$
; and statement 5 follows directly from statements 3 and 4.
Next, we have some results about how the concatenation and tail relate to the length arrow. We have not found them stated explicitly in the literature, but they are not new either: the first equality is used implicitly in a diagram in section 4 of Jay et al. (Reference Jay and Cockett1994), and a version of the second equality appears in Proposition5.2 of Cockett (Reference Cockett1990). They also appear in Rocq (2025).
Proposition 4.8. The following equalities hold:
-
1.
${\operatorname {len}}(\ell _1 \mathbin {+\mkern -2mu+} \ell _2) =_{\ell _1, \ell _2} {\operatorname {len}}(\ell _1) + {\operatorname {len}}(\ell _2)$
, -
2.
${\operatorname {len}}({\operatorname {tail}}(n,\ell )) =_{n,\ell } {\operatorname {len}}(\ell ) \mathrel {\substack {\cdot \\[-1ex]-}} n$
.
Proof. The first equality is easy by induction on
$\ell _1$
. For the second, first remark that
${\operatorname {len}}({\operatorname {tr}}(\ell )) =_\ell P({\operatorname {len}}(\ell ))$
(by induction on
$\ell$
); we can then use this result to prove the desired equality by induction on
$n$
.
The next proposition shows how to decompose list objects based on their length. We draw particular attention to the second case: we would like to decompose a list
$t : L(X)$
of positive length into
$t = x :: t'$
, but we cannot extract a term of type
$X$
from the context
$(\ell : L(X) \mid {\operatorname {len}}(\ell ) \gt 0)$
without additional assumptions (see Propositions 6.1 and 7.1). So, in order to perform the decomposition, we need to be given an arbitrary term
${\operatorname {def}} : X$
. Hence, these results are standard for locoi, but we have not seen a proof in the literature for categories with only finite products and list objects.
Proposition 4.9.
Let
$t : L(X)$
be a term in a context
$C$
.
-
1. If
${\operatorname {len}}(t) =_C 0$
, then
$t =_C \varnothing$
. -
2. If
${\operatorname {len}}(t) \gt _C 0$
, then for any term
${\operatorname {def}} : X$
in the context
$C$
, we have
\begin{align*} t =_C {\operatorname {zerothDef}}({\operatorname {def}}, t) :: {\operatorname {tr}}(t). \end{align*}
-
3. If
${\operatorname {len}}(t) \gt _C 0$
, then for any terms
$x, x' : X$
in the context
$C$
, we have
\begin{align*} {\operatorname {zerothDef}}(x,t) =_C {\operatorname {zerothDef}}(x',t). \end{align*}
Proof. For the first point, consider the map
$Z : N \times L(X) \rightarrow L(X)$
defined inductively by
$Z(0,\ell ) =_{\ell } \varnothing$
,
$Z(sn,\ell ) =_{n,\ell } \ell$
. By induction on
$\ell$
, it is easy to show that
$Z({\operatorname {len}}(\ell ), \ell ) =_\ell \ell$
. We conclude by using the hypothesis
${\operatorname {len}}(t) =_C 0$
to compute
as desired.
For the second point, we similarly consider an arrow
$Z : X \times N \times L(X) \rightarrow L(X)$
defined by
$Z(x,0,\ell ) =_{x,\ell } \varnothing$
and
$Z(x,sn,\ell ) =_{x,n,\ell } {\operatorname {zerothDef}}(x,\ell ) :: {\operatorname {tr}}(\ell )$
. As before, we can easily show by induction that
$Z(x, {\operatorname {len}}(\ell ), \ell ) =_{x,\ell } \ell$
. Now, if
${\operatorname {len}}(t) \gt _C 0$
, then
${\operatorname {len}}(t) =_C s(n)$
for some
$n : N$
(by Proposition 4.3). If, moreover, we have some
${\operatorname {def}} : X$
, then
as desired.
For the third point, consider the term
${\operatorname {zerothDef}}(x,t)$
. If we substitute the equality
$t =_C {\operatorname {zerothDef}}(x',t) :: {\operatorname {tr}}(t)$
(which holds by the second point) and simplify, we get the desired result.
Finally, we have some results about the behavior of
$\operatorname {nthDef}$
. They tell us that if
$n \geq {\operatorname {len}}(\ell )$
, then
$\operatorname {nthDef}$
returns the default, and if
$n \lt {\operatorname {len}}(\ell )$
, then the default is irrelevant. Again, these do not seem to appear explicitly in the literature (except Rocq (2025)), and there is perhaps some novelty in establishing these results when only working in a category with finite products and list objects.
Proposition 4.10.
Let
$x : X$
,
$n : N$
,
$\ell : L(X)$
be terms in a context
$C$
.
-
1. If
$n \geq _C {\operatorname {len}}(\ell )$
, then
${\operatorname {nthDef}}(x,n,\ell ) =_C x$
. -
2. If
$n \lt _C {\operatorname {len}}(\ell )$
, then for any other term
$x' : X$
in the context
$C$
, we have that
${\operatorname {nthDef}}(x,n,\ell ) =_C {\operatorname {nthDef}}(x',n,\ell )$
.
Proof. For the first point, we have
${\operatorname {len}}({\operatorname {tail}}(n,\ell )) =_C {\operatorname {len}}(\ell ) \mathrel {\substack {\cdot \\[-1ex]-}} n =_C 0$
by Proposition 4.8 and the assumption
$n \geq _C {\operatorname {len}}(\ell )$
; thus,
${\operatorname {tail}}(n,\ell ) =_C \varnothing$
by Proposition 4.9. So, by definition of
$\operatorname {nthDef}$
, we have
This is what we wanted.
For the second point, by Proposition A.5 from the appendix,
$n\lt _C {\operatorname {len}}(\ell )$
implies that
${\operatorname {len}}(\ell ) \mathrel {\substack {\cdot \\[-1ex]-}} n \gt _C 0$
, so
by Proposition 4.8. Then, by Proposition 4.9, we have
as desired.
5. Proof Setup and Outline
Recall that the goal of this paper is to prove Theorem 1.1, which states that if
$\mathcal{C}$
is an extensive category with finite limits and list objects, then the list object functor
$L$
is polynomial.
We start by proving the following proposition, which makes this goal more attainable. We make use of the functor
$L_N : \mathcal{C} \rightarrow \mathcal{C}/N$
, which maps an object
$X$
to the arrow
${\operatorname {len}}_X : L(X) \rightarrow N$
. In particular, we note that
$L = \Sigma _N \circ L_N$
; this is the canonical factorization of
$L$
as a functor
$\mathcal{C} \rightarrow \mathcal{C}/L(\unicode {x1D7D9}) \rightarrow \mathcal{C}$
.
Proposition 5.1.
Let
$\mathcal{C}$
be a category with finite limits and parametrized list objects. To show that the arrow
$\pi _2^E$
is exponentiable and that the polynomial
$\unicode {x1D7D9} \leftarrow E \overset {\pi _2^E}{\longrightarrow } N \rightarrow \unicode {x1D7D9}$
represents
$L$
, it suffices to show that
$L_N$
is a right adjoint to
$\Sigma _E \circ \Delta _{\pi _2^E} : \mathcal{C}/N \rightarrow \mathcal{C}$
.
Proof. Suppose
$L_N$
is right adjoint to
$\Sigma _E \circ \Delta _{\pi _2^E}$
. By Corollary 1.2 of Niefield (Reference Niefield1982), this right adjoint existing implies that
$\Pi _{\pi _2^E}$
, the right adjoint of
$\Delta _{\pi _2^E}$
, also exists, and so
$\pi _2^E$
is exponentiable. Thus, the polynomial functor associated to
$\unicode {x1D7D9} \leftarrow E \overset {\pi _2^E}{\longrightarrow } N \rightarrow \unicode {x1D7D9}$
exists, and it remains to show that
Since
$L = \Sigma _N \circ L_N$
, we just need to show that
$\Pi _{\pi _2^E} \circ \Delta _E \cong L_N$
. For this, we note that
$\Pi _{\pi _2^E}$
and
$\Delta _E$
are the right adjoints of
$\Delta _{\pi _2^E}$
and
$\Sigma _E$
, respectively, and so
$\Pi _{\pi _2^E} \circ \Delta _E$
is right adjoint to
$\Sigma _E \circ \Delta _{\pi _2^E}$
(see Borceux (Reference Borceux1994), prop. 3.2.1]). However,
$L_N$
is already a right adjoint of
$\Sigma _E \circ \Delta _{\pi _2^E}$
by assumption, so by uniqueness of adjoints, we get
$\Pi _{\pi _2^E} \circ \Delta _E \cong L_N$
, as desired.
Thus, our proof strategy will involve showing that
$L_N$
is a right adjoint to
$\Sigma _E \circ \Delta _{\pi _2^E}$
. Note that the above proposition does not require
$\mathcal{C}$
to be extensive; in fact, we can weaken the assumption of extensivity and instead use the following two hypotheses. (In Section 6, we rephrase these hypotheses using the internal language to make them easier to use.)
-
(H1) For any object
$X$
, in the following commutative diagram, the squares are pullbacks.
-
(H2) The coproduct
is universal (its pullback along any arrow is still a coproduct).
Proposition 5.2.
Let
$\mathcal{C}$
be a category with finite limits and parametrized list objects. If
$\mathcal{C}$
is extensive, then hypotheses (H1) and (H2) hold.
Proof. This is a direct consequence of the characterization of extensivity mentioned in Section 2 (i.e. Fact 2.1). For (H1), the squares are pullbacks because the top and bottom rows are coproducts (Facts 4.2 and 4.6) and the diagram commutes (by definition of
$\operatorname {len}$
).
Note that hypothesis (H2) is not trivial: the coproduct
$\unicode {x1D7D9} \overset {0}{\longrightarrow } N \overset {s}{\longleftarrow } N$
is not necessarily universal in categories with finite limits. A counter-example can be found on the MathOverflow website (Henry Reference Henry2022). On the other hand, in hypothesis (H1), the left square can be easily shown to be a pullback without extra assumptions, so assuming it is redundant. We only need to assume that the right square is a pullback; though we have not constructed a counter-example, we suspect this assumption is necessary.
With this setup, the rest of the paper will be devoted to proving the following theorem.
Theorem 5.3.
Let
$\mathcal{C}$
be a category with finite limits and parametrized list objects. If we assume (H1) and (H2), then
$L_N$
is a right adjoint to
$\Sigma _E \circ \Delta _{\pi _2^E}$
.
Our strategy for this theorem is to use the universal property characterization and construct a natural transformation
${\operatorname {nth}} : \Sigma _E \circ \Delta _{\pi _2^E} \circ L_N \Rightarrow {\operatorname {Id}}_{\mathcal{C}}$
such that
$(L_N(X), {\operatorname {nth}}_X)$
is a universal morphism from
$\Sigma _E \circ \Delta _{\pi _2^E}$
to
$X$
for each
$X$
. Unraveling the definitions, this means that we must prove the following universal property for each
$X$
:
So, we can think of the proof as being broken down into three steps.
-
1. First, we must define the arrows
${\operatorname {nth}}_X : E \times _N L(X) \rightarrow X$
and check that they form a natural transformation. -
2. Second, we must construct
$h$
based on the given
$l_A$
and
$g$
, and check that it satisfies the required equations. -
3. Third, we must show that any two arrows satisfying the equations must be equal.
These steps are accomplished mostly independently: constructing
${\operatorname {nth}}_X$
is done in Section 7; constructing the map
$h$
is done in Section 8; and showing uniqueness is done in Section 9. Section 6 provides some important technical tools for these steps. Putting it all together gives us the following proof.
Proof of theorem
5.3. Proposition 7.2 tells us that
${\operatorname {nth}} : \Sigma _E \circ \Delta _{\pi _2^E} \circ L_N \Rightarrow {\operatorname {Id}}$
is a natural transformation. Moreover, Theorem 8.6 and Corollary 9.7 together tell us that for each
$X$
,
$(L_N(X), {\operatorname {nth}}_X)$
is a universal morphism from
$\Sigma _E \circ \Delta _{\pi _2^E}$
to
$X$
. Thus,
$L_N$
is right adjoint to
$\Sigma _E \circ \Delta _{\pi _2^E}$
(see, e.g., Borceux Reference Borceux1994, dfn. 3.1.4).
Of course, this now implies Theorem 1.1.
Proof of theorem
1.1. By assumption, we’re working in an extensive category, so (H1) and (H2) hold by Proposition 5.2. We can thus apply Theorem 5.3 to conclude that
$L_N$
is a right adjoint to
$\Sigma _E \circ \Delta _{\pi _2^E}$
, and Proposition 5.1 tells us that this implies the desired conclusion.
6. Technical Calculations
In this section, we prove some technical results that will be used at various points in the rest of the paper. Throughout, we assume that we are working in a category
$\mathcal{C}$
with finite products and a parametrized natural numbers object, and we specify additional assumptions as needed.
6.1 Rephrasing the hypotheses
Hypotheses (H1) and (H2) are not easy to apply directly when doing proofs with the internal language. In this section, we obtain consequences of these hypotheses that can be applied to the internal language. We start with (H1), which is fairly easy to adapt.
Proposition 6.1.
Let
$\mathcal{C}$
be a category with finite limits and parametrized list objects and assume (H1). If
$\ell : L(X)$
is a term in a context
$C$
such that
${\operatorname {len}}(\ell ) \gt _C 0$
, then there exist terms
$x : X$
,
$\ell ' : L(X)$
in the context
$C$
such that
$\ell =_C x :: \ell '$
.
Proof. Since
${\operatorname {len}}(\ell ) \gt _C 0$
, we have
${\operatorname {len}}(\ell ) =_C s(P({\operatorname {len}}(\ell )))$
by Proposition 4.3, which means the following diagram commutes.

Since (H1) asserts that this square is a pullback, there exists an arrow
$\gamma : [C] \rightarrow X \times L(X)$
, which makes the whole diagram commute. So, if we write
$C = (y_1 : Y_1, \ldots , y_n : Y_n)$
and we let
$x =_C \pi _1(\gamma (y_1, \ldots , y_n))$
and
$\ell ' =_C \pi _2(\gamma (y_1, \ldots , y_n))$
, then the equality
$[\ell ]_C = r_1^X \circ \gamma$
implies
$\ell =_C x :: \ell '$
, as desired.
Next, we move on to (H2). This hypothesis is used when we need to perform a construction or calculation “by cases,” depending on whether a certain parameter is zero or nonzero (e.g., the proof of Theorem 8.6); the following proposition makes this easier to do.
Proposition 6.2.
Let
$\mathcal{C}$
be a category with finite limits and a parametrized NNO. Let
$t : N$
be a term in a context
$C$
, and let
$C_0 = (C \mid t=0)$
,
$C_{\gt 0} = (C \mid t \gt 0)$
.
If we assume hypothesis (H2), then
is a coproduct.
Proof. Write
$i_0, i_{\gt 0}$
for the inclusion maps of
$[C_0], [C_{\gt 0}]$
into
$[C]$
, respectively, and consider the following diagram.

We claim that this diagram commutes and that the squares are pullbacks. If this is true, then hypothesis (H2) tells us that the top row is a coproduct, as desired.
First, we check that the squares commute. The left square states that, in the context
$C_0$
,
$t =_{C_0} 0$
, which is true by definition. The right square states that, in the context
$C_{\gt 0}$
,
$t =_{C_{\gt 0}} s(P(t))$
. We know
$t \gt 0$
in this context, so the equality follows by Proposition 4.3.
Second, we claim that the left square is a pullback because of how
$[C_0]$
is defined as an equalizer, and the right square is a pullback because of how
$[C_{\gt 0}]$
is defined as an equalizer. This is mostly a routine check, so we omit the details. We just note that for the latter case, if
$f : B \rightarrow [C]$
and
$g : B \rightarrow N$
are such that
$[t]_C \circ f = s \circ g$
, then
$[t]_C \circ f \gt 0$
(by Proposition 4.3) and
$g = P \circ [t]_C \circ f$
.
The conclusion of this proposition can be reformulated using the internal language so that it is easier to use.
Remark. Let
$t, C, C_0, C_{\gt 0}$
be as in Proposition 6.2 and assume (H2). Let
$a_0 : Y$
be a term in the context
$C_0$
, and let
$a_{\gt 0}$
be a term in the context
$C_{\gt 0}$
. Then, there exists a unique arrow
$h : [C] \rightarrow Y$
such that
$h(x_1, \ldots , x_n) =_{C_0} a_0$
and
$h(x_1, \ldots , x_n) =_{C_{\gt 0}} a_{\gt 0}$
. Moreover, for any terms
$p, q : Y$
in the context
$C$
, if
$p =_{C_0} q$
and
$p =_{C_{\gt 0}} q$
, then
$p =_C q$
.
We will generalize the above result slightly. Instead of splitting into the case
$t=0$
and
$t\gt 0$
, we will split into the case
$u\lt w$
and
$u \geq w$
. Note that the conclusion of this generalization can also be phrased using terms as in the above remark; we won’t rewrite it in full.
Corollary 6.3.
Let
$\mathcal{C}$
be a category with finite limits and a parametrized NNO. Let
$u,w : N$
be terms in a context
$C = (x_1 : X_1, \ldots , x_n : X_n)$
, and let
$C_1$
,
$C_2$
be the contexts
$C_1 = (C \mid u\lt w)$
and
$C_2 = (C \mid u \geq w)$
.
If we assume hypothesis (H2), then
is a coproduct.
Proof. Remark that
$C_2 = (C \mid w \mathrel {\substack {\cdot \\[-1ex]-}} u = 0)$
. So, if we let
$C_{\gt 0} = (C \mid w \mathrel {\substack {\cdot \\[-1ex]-}} u \gt 0)$
, then by Proposition 6.2, the following diagram is a coproduct.

So, to show the result we want, we need to show that there is an isomorphism
$[C_1] \cong [C_{\gt 0}]$
that respects the inclusion into
$[C]$
.
The only choice for an isomorphism between the objects
$[C_1] = \{C \mid u \lt w\}$
and
$[C_{\gt 0}] = \{C \mid w \mathrel {\substack {\cdot \\[-1ex]-}} u \gt 0\}$
which respects the inclusion into
$[C]$
is the “identity map”
$(x_1, \ldots , x_n) \mapsto (x_1, \ldots , x_n)$
. Therefore, we just need to show that this map is well-defined in both directions. This just involves showing that
$w \mathrel {\substack {\cdot \\[-1ex]-}} u \gt _{C_1} 0$
(knowing that
$u \lt _{C_1} w$
) and that
$u \lt _{C_{\gt 0}} w$
(knowing that
$w \mathrel {\substack {\cdot \\[-1ex]-}} u \gt _{C_{\gt 0}} 0$
). This is true by Proposition A.5 of the appendix.
6.2 Pullbacks along E
As we saw in Proposition 5.1, a central part of our proof strategy is the functor
$\Sigma _E \circ \Delta _{\pi _2^E} : \mathcal{C}/N \rightarrow \mathcal{C}$
, which maps an arrow
$l_A : A \rightarrow N$
to the object
$E \times _N A$
defined by the following pullback.

Using the internal language, we have
$E \times _N A = \{e : E, \, a : A \mid \pi _2^E(e) = l_A(a) \}$
. Since
$E$
is the object
$\{m : N, n : N \mid m \lt n\}$
, we could also write this as
$\{(m,n) : E, \, a : A \mid n = l_A(a)\}$
. However, this shows us that the “
$n$
” parameter is redundant, and that we can just think of this object as
$\{m : N, \, a : A \mid m \lt l_A(a)\}$
. Specifically, we’d like to use the context
$(m:N, a:A \mid m \lt l_A(a))$
when referencing the object
$E \times _N A$
. The following proposition assures us that this is valid.
Proposition 6.4.
Let
$\mathcal{C}$
be a category with finite limits and a parametrized NNO, and let
$l_A : A \rightarrow N$
. Then, the following maps are well-defined and provide an isomorphism
$E \times _N A \cong \{m : N, \, a : A \mid m \lt l_A(a)\}$
.

Proof. Straightforward check.
Note that we do need to be careful when writing
$\{m : N, a : A \mid m \lt l_A(a)\}$
for
$E \times _N A$
, because applying the projection maps does not behave the way we expect. For instance, we have the map
$\pi _1^{E,A} : E \times _N A \rightarrow E$
, and if we consider
$(m,a) : E \times _N A$
with
$m : N, a : A$
, then
$\pi _1^{E,A}(m,a)$
is not equal to
$m$
, as we might think if we’re not being careful.
Fortunately, this issue does not come up very often. We’ll only need the following fact to assure us that we aren’t making mistakes (the proof is a straightforward check, so we omit it).
Fact 6.5.
Let
$\mathcal{C}$
be a category with finite limits and a parametrized NNO, and suppose we have arrows
$l_A : A \rightarrow N$
,
$l_B : B \rightarrow N$
and
$f : A \rightarrow B$
. Assume
$l_B \circ f = l_A$
, so that we can consider the following arrow.

Then, in the context
$C = (m : N, a : A \mid m \lt l_A(a))$
, we have
6.3 Converting a finite sequence to an infinite sequence
In the proof outline of Section 5, we saw that we need to use an arrow
$g : E \times _N A \rightarrow X$
to produce an arrow
$A \rightarrow L(X)$
. As we’ll see in Section 8.3, a key technical step in this process will be obtaining an intermediate arrow
$g' : N \times [A_{\gt 0}] \rightarrow X$
, where
$A_{\gt 0} = (a : A \mid l_A(a)\gt 0)$
. The important property of
$g'$
is that it should produce the same output as
$g$
, as long as it is acting on inputs
$m:N$
,
$a:A$
such that
$m \lt l_A(a)$
.
In order to obtain the arrow
$g'$
we want, we need to introduce an arrow
${\operatorname {IdUntil}} : N \times N \rightarrow N$
, defined by
Here,
$P$
is the predecessor function, and
$\min$
is defined as in Román (Reference Román1989, Prop. 1.3). What’s important about
$\operatorname {IdUntil}$
is that it has the following properties.
Proposition 6.6.
Let
$m,n : N$
be terms in a context
$C$
. Then:
-
• If
$0 \lt _C n$
, then
${\operatorname {IdUntil}}(m,n) \lt _C n$
. -
• If
$m \lt _C n$
, then
${\operatorname {IdUntil}}(m,n) =_C m$
.
Proof. For the first part, we first note that
$n \gt _C 0$
implies
$n =_C s(P(n))$
(see Proposition 4.3). Using this and Román (Reference Román1989, Prop. 1.3), we compute
It is easy to check that
$\min (x,y) \mathrel {\substack {\cdot \\[-1ex]-}} y =_{x,y} 0$
(using Román Reference Román1989, Prop. 1.3), so this gives us
${\operatorname {IdUntil}}(m,n) \lt _C n$
, as desired.
For the second part, we note that
$n \gt _C 0$
, and so once again
$n = s(P(n))$
. The inequality
$m \lt _C n$
therefore implies that
$m \leq P(n)$
(since
$sx \mathrel {\substack {\cdot \\[-1ex]-}} sy =_{x,y} x \mathrel {\substack {\cdot \\[-1ex]-}} y$
). This fact and Román (Reference Román1989, Prop. 1.3)] let us compute
This is all we needed to show.
We can now use the arrow
$\operatorname {IdUntil}$
to obtain
$g'$
from
$g$
. Essentially,
$g'(m,a)$
is equal to
$g(m,a)$
for
$m \lt l_A(a)$
, and for
$m \geq l_A(a)$
, it is just equal to
$g(l_A(a) \mathrel {\substack {\cdot \\[-1ex]-}} 1, \, a)$
(which is a valid term because
$l_A(a)\gt 0$
, by assumption).
Corollary 6.7.
Let
$\mathcal{C}$
be a category with finite limits and a parametrized NNO. Let
$l_A : A \rightarrow N$
be an arrow, let
$C = (m:N, \, a:A \mid m \lt l_A(a))$
, and let
$A_{\gt 0} = (a : A \mid l_A(a) \gt 0)$
. Then, for any
$g : [C] \rightarrow X$
, the arrow
$g' : N \times [A_{\gt 0}] \rightarrow X$
given by
is well-defined. Moreover, in the context
$C$
, the term
$g'(m,a)$
is well-defined, and
Proof. We start with the first part of the statement. Let
$n = {\operatorname {IdUntil}}(m, l_A(a))$
; we must check that
$g(n, a)$
is well-defined (remark that
$a : [A_{\gt 0}]$
, but we also write
$a$
for its image via the inclusion
$[A_{\gt 0}] \hookrightarrow A$
). Specifically, we need to check that
$(n, a)$
is a valid term of type
$[C]$
by checking that
$n \lt _{m,a} l_A(a)$
. By definition of
$A_{\gt 0}$
, we have
$l_A(a) \gt _{m,a} 0$
, so we can apply Proposition 6.6 to find that
as desired.
For the second part, we must check that
$g'(m,a)$
is well-defined. In particular, we need to check that the term
$a : A$
in the context
$C$
can be considered as a term of type
$[A_{\gt 0}]$
. This is simple: we have
$l_A(a) \gt m \geq 0$
, which is all we need.
Finally, we must check that
$g'(m,a) =_C g(m,a)$
. Since
$m \lt l_A(a)$
in
$C$
, we can apply Proposition 6.6 to get
${\operatorname {IdUntil}}(m, l_A(a)) =_C m$
, and so
$g'(m,a) =_C g(m,a)$
, as desired.
7. Extracting Elements from Lists
Throughout this section, we assume we’re working in a category
$\mathcal{C}$
with finite limits and parametrized list objects (and therefore a parametrized natural numbers object).
As noted in Section 5, the goal of this section is to construct arrows
${\operatorname {nth}}_X : E \times _N L(X) \rightarrow X$
and check that they form a natural transformation. To do so, we must first understand what we expect the arrow
${\operatorname {nth}}_X$
should be. Proposition 6.4 shows that we can write
or in other words,
$C = (m : N, \, \ell : L(X) \mid m \lt {\operatorname {len}}(\ell ))$
is a context for the domain of
${\operatorname {nth}}_X$
. So,
${\operatorname {nth}}_X$
should take a list
$\ell$
and an integer
$m$
with
$m \lt {\operatorname {len}}(\ell )$
and return an element of
$X$
. As the name suggests, this map should output the
$m^{th}$
element of
$\ell$
, so we would like to use the arrow
${\operatorname {nthDef}}_X$
defined in Section 4.6.
However,
${\operatorname {nthDef}}_X$
always requires a default element, so to define
${\operatorname {nth}}_X$
, we need a term
${\operatorname {def}}_X : X$
in the context
$C$
to serve as the default element. Then, we can set
How can we obtain this
${\operatorname {def}}_X$
? This will in fact require hypothesis (H1).
Proposition 7.1.
Let
$\mathcal{C}$
be a category with finite limits and parametrized list objects and assume (H1). In the context
$C = (m : N, \; \ell : L(X) \mid m \lt {\operatorname {len}}(\ell ))$
, there exists a term
${\operatorname {def}}_X$
of type
$X$
.
Proof. In the context
$C$
, remark that
${\operatorname {len}}(\ell ) \gt _C m \geq _C 0$
. By the term version of (H1) (Proposition 6.1), this implies that there exist terms
$x : X$
,
$\ell ' : L(X)$
in
$C$
such that
$\ell =_C x :: \ell '$
. So, we can just take
${\operatorname {def}}_X$
to be this term
$x$
.
With this default term, our definition of
${\operatorname {nth}}_X$
is now complete. However, it’s important to be aware that any further discussion of the arrow
${\operatorname {nth}}_X$
implicitly assumes the hypothesis (H1) (and the existence of finite limits). We should also note that this arrow is used under the name entry in section 5 of Cockett (Reference Cockett1990), albeit in a somewhat different context.
Proposition 7.2.
Let
$\mathcal{C}$
be a category with finite limits and parametrized list objects and assume (H1). The collection of arrows
$({\operatorname {nth}}_X)_X$
is a natural transformation
$\Sigma _E \circ \Delta _{\pi _2^E} \circ L_N \Rightarrow {\operatorname {Id}}_{\mathcal{C}}$
.
Proof. Let
$f : X \rightarrow Y$
be an arrow of
$\mathcal{C}$
. We must show that the following square commutes.

Let
$C$
be the context
$(m : N, \; \ell : L(X) \mid m \lt {\operatorname {len}}(\ell ))$
. We compute:
\begin{align*} {\operatorname {nth}}_Y (m, L(f)(\ell )) &=_C {\operatorname {nthDef}}_Y \big ( {\operatorname {def}}_Y', \; m, \; L(f)(\ell ) \big ) \\ &=_C {\operatorname {nthDef}}_Y \big ( f({\operatorname {def}}_X), \; m, \; L(f)(\ell ) \big ) \\ &=_C f({\operatorname {nthDef}}_X({\operatorname {def}}_X, m, \ell )) \\ &=_C f({\operatorname {nth}}_X(m, \ell )). \end{align*}
Here,
${\operatorname {def}}_Y'$
is the term
${\operatorname {def}}_Y[L(f)(\ell )/\ell ]$
. For the second equality, we noted that
$m \lt {\operatorname {len}}(\ell ) = {\operatorname {len}}(L(f)(\ell ))$
(using Proposition 4.7) and applied Proposition 4.10. Finally, the third equality uses Proposition 4.7.
8. Constructing Lists and Computing Their Elements
Throughout this section, we assume we’re working in a category
$\mathcal{C}$
with finite products and parametrized list objects (and therefore a parametrized natural numbers object). We specify additional assumptions as needed.
As noted in Section 5, the goal of this section is to show the existence part of the statement that
$(L_N(X), {\operatorname {nth}}_X)$
is a universal morphism. That is, given arrows
$l_A : A \rightarrow N$
and
$g : E \times _N A \rightarrow X$
, we must construct an arrow
$h : A \rightarrow L(X)$
such that
$l_A = {\operatorname {len}}_X \circ h$
and
$g = {\operatorname {nth}}_X \circ ({\operatorname {Id}} \times _N h)$
.
It is particularly difficult to construct maps into a list object because its universal property only provides inductive constructions of maps out of it. Therefore, we start this section by developing a general technique for constructing such maps. Then, we establish some properties of this technique, before finally applying it to this particular case.
8.1 Constructing maps into a list object
The key idea for constructing maps into
$L(X)$
is that we should use the inductive property of NNOs. Indeed, suppose we have a map
$f : N \times A \rightarrow X$
, which we think of as a collection of infinite sequences
$(x_{n,a})_n$
indexed by
$a \in A$
. We can use this map to construct the map
${\operatorname {Seq}}[f] : N \times N \times A \rightarrow L(X)$
, where
${\operatorname {Seq}}[f](m,n,a)$
represents
$[x_{m,a}, \ldots , x_{m+n-1,a}]$
. This is done by induction on
$n$
, the length of this list, as follows.
If we are also given a map
$p : A \rightarrow N$
that represents the length of a list associated to
$a$
, then we can define
${\operatorname {List}}[f,p] : A \rightarrow L(X)$
by setting
Intuitively, we have
${\operatorname {List}}[f,p](a) = [x_{0,a}, \ldots , x_{p(a)-1,a}]$
. The drawback of this technique is that it requires an infinite sequence
$(x_{n,a})_n$
to specify this finite list; we address this issue in Section 8.3.
We end this section with some very basic facts about this construction.
Proposition 8.1.
${\operatorname {len}} \circ {\operatorname {List}}[f,p] = p$
Proof. To obtain this equality, it suffices to show that that
${\operatorname {len}}({\operatorname {Seq}}[f](m,n,a)) =_{m,n,a} n$
. This is done by induction on
$n$
: using Proposition 4.8 and noting that
${\operatorname {len}}([x]) =_x 1$
, it is easy to show that these terms both satisfy the introductory equations
$h(m,0,a) =_{m,a} 0$
and
$h(m,sn,a) =_{m,n,a} h(m,n,a)+1$
.
Proposition 8.2.
${\operatorname {Seq}}[f](m,sn,a) =_{m,n,a} f(m,a) :: {\operatorname {Seq}}[f](sm,n,a)$
.
Proof. This is proved by induction on
$n$
: it is straightforward to check that both terms satisfy
$h(m,0,a) =_{m,a} [f(m,a)]$
and
$h(m,sn,a) =_{m,n,a} h(m,n,a) \mathbin {+\mkern -2mu+} [f(s(m+n),a)]$
.
8.2 The nth elements of constructed lists
In this section, we prove an important result about the interaction between
$\operatorname {nth}$
and
${\operatorname {List}}[f,p]$
: specifically, we show with Theorem 8.5 that the
$m^{th}$
element of
${\operatorname {List}}[f,p](a)$
is
$f(m,a)$
, as long as
$m\lt p(a)$
.
We start with some intermediate results. The first thing we need to do is investigate the interaction between truncation and
${\operatorname {Seq}}[f]$
because
$\operatorname {nthDef}$
is built using
$\operatorname {tr}$
, and
$\operatorname {List}$
is built using
$\operatorname {Seq}$
. Recall that
$P$
represents the predecessor function.
Proposition 8.3.
Let
$f : N \times A \rightarrow X$
. Then,
${\operatorname {tr}}({\operatorname {Seq}}[f](m,n,a)) =_{m,n,a} {\operatorname {Seq}}[f](sm,Pn,a)$
.
Proof. By induction on
$n$
, it suffices to show that the arrows agree on
$0$
and
$s$
. For the base case, it’s clear that both terms reduce to
$\varnothing$
; for the inductive case, we use Proposition 8.2:
This is all we need to show.
From this fact, we expect that iterating the truncation map just turns into iterating the successor
$s$
and predecessor
$P$
. However, iterating the successor just becomes addition, and iterating the predecessor just becomes subtraction. This observation gives us the following important lemma.
Lemma 8.4.
Let
$f : N \times A \rightarrow X$
. Then,
In particular, given
$p : A \rightarrow N$
, we have
Proof. We start with the first equality, which we prove by induction on
$k$
. To this end, we show that both arrows satisfy the equalities
$h(0,m,n,a) =_{m,n,a} {\operatorname {Seq}}[f](m,n,a)$
and
$h(sk,m,n,a) =_{k,m,n,a} {\operatorname {tr}}(h(k,m,n,a))$
. The first equality is trivial, since
${\operatorname {tail}}(0,\ell ) =_\ell \ell$
,
$m+0 =_m m$
, and
$n \mathrel {\substack {\cdot \\[-1ex]-}} 0 =_n n$
. The second equality is immediate for the left-hand side function (it’s the definition of
$\operatorname {tail}$
); for the right-hand side function, we use Proposition 8.3.
This is all we needed to show for the first part. For the second part, we simply replace
$m$
by
$0$
and
$n$
by
$p(a)$
, then use the definition of
${\operatorname {List}}[f,p]$
.
Finally, we arrive at the desired result. Note that we need to assume hypothesis (H1) and the existence of finite limits in order to talk about the
$\operatorname {nth}$
arrow.
Theorem 8.5.
Let
$\mathcal{C}$
be a category with finite limits and parametrized list objects and assume (H1). Let
$f : N \times A \rightarrow X$
and
$p : A \rightarrow N$
and let
$m:N$
,
$a:A$
be terms in a context
$C$
. If
$m \lt _C p(a)$
, then
Proof. First, we note that the term on the left is well-defined because
${\operatorname {len}}({\operatorname {List}}[f,p](a)) =_C p(a)$
(by Proposition 8.1) and
$m \lt _C p(a)$
be assumption. Then, by the definition of
$\operatorname {nth}$
and Lemma 8.4,
\begin{align*} {\operatorname {nth}}(m, {\operatorname {List}}[f,p](a)) &=_C {\operatorname {nthDef}}({\operatorname {def}}_X', m, {\operatorname {List}}[f,p](a)) \\ &=_C {\operatorname {zerothDef}} ({\operatorname {def}}_X', \; {\operatorname {tail}} (m, \; {\operatorname {List}}[f,p](a) ) ) \\ &=_C {\operatorname {zerothDef}} ({\operatorname {def}}_X', \; {\operatorname {Seq}}[f] (m, p(a) \mathrel {\substack {\cdot \\[-1ex]-}} m, a ) ). \end{align*}
(Here,
${\operatorname {def}}_X'$
is
${\operatorname {def}}_X$
with the appropriate substitution.) Since
$m \lt _C p(a)$
by assumption, we have
$p(a) \mathrel {\substack {\cdot \\[-1ex]-}} m \gt _C 0$
by Proposition A.5 of the appendix. Therefore, by Proposition 4.3,
$p(a) \mathrel {\substack {\cdot \\[-1ex]-}} m =_C s(k)$
for some term
$k$
. We substitute this into the above equality, apply Proposition 8.2, and use the definition of
$\operatorname {zerothDef}$
. We get:
This is what we wanted to show.
8.3 The universal property arrow
The construction
${\operatorname {List}}[f,p]$
allows us to construct an arrow
$A \rightarrow L(X)$
based on two arrows
$f : N \times A \rightarrow X$
and
$p : A \rightarrow N$
. However, the goal stated at the beginning of this chapter is to construct
$h : A \rightarrow L(X)$
from
$g : E \times _N A \rightarrow X$
and
$l_A : A \rightarrow N$
, so we need to adjust this technique. (In this section, we assume our category has finite limits.)
Recall from Proposition 6.4 that
$E \times _N A = \{m : N, \, a : A \mid m \lt l_A(a)\}$
. This means that the arrow
$g : E \times _N A \rightarrow X$
only gives us finite sequences
$(x_{0,a}, \ldots , x_{l_A(a)-1,a})$
instead of the infinite sequences used in
${\operatorname {List}}[f,p]$
. We account for this discrepancy by using two tricks.
-
• First, if
$l_A(a)\gt 0$
, then we can extend the finite sequence to an infinite one simply by repeating the last element; we will use Corollary 6.7 to do this formally. -
• Second, we note that the first trick doesn’t work if
$l_A(a)=0$
, because then
$g$
doesn’t give us any elements of
$X$
. However,
$l_A(a)=0$
just means that we should set
$h(a)=\varnothing$
. So, we have to use hypothesis (H2) to split into two cases:
$l_A(a)=0$
and
$l_A(a)\gt 0$
.
We employ these techniques in the following proof. Note that hypothesis (H1) is required to talk about
${\operatorname {nth}}_X$
.
Theorem 8.6.
Let
$\mathcal{C}$
be a category with finite limits and parametrized list objects and assume (H1) and (H2). Given objects
$X$
,
$A$
and arrows
$l_A : A \rightarrow N$
and
$g : E \times _N A \rightarrow X$
, there exists an arrow
$h : A \rightarrow L(X)$
such that
$l_A = {\operatorname {len}}_X \circ h$
and
$g = {\operatorname {nth}}_X \circ ({\operatorname {Id}}_E \times _N h)$
.
Proof. Hypothesis (H2) tells us (via Proposition 6.2) that we have the coproduct
$A = [A_0] + [A_{\gt 0}]$
, where
$A_0 = (a : A \mid l_A(a)=0)$
and
$A_{\gt 0} = (a : A \mid l_A(a) \gt 0)$
. This lets us define
$h : A \rightarrow L(X)$
by cases on each part of this coproduct.
In the case
$l_A(a)=0$
, we simply set
$h(a) =_{A_0} \varnothing$
. For the case
$l_A(a) \gt 0$
, note that the domain of
$g$
is
$[C]$
, where
$C = (m : N, \, a : A \mid m \lt l_A(a))$
. Then, Corollary 6.7 tells us that there is an arrow
$g' : N \times [A_{\gt 0}] \rightarrow X$
such that
$g'(m,a) =_C g(m,a)$
, and we can define
$h$
in the
$A_{\gt 0}$
case to be
where
$l_A' : [A_{\gt 0}] \rightarrow N$
is just given by
$l_A'(a) =_{A_{\gt 0}} l_A(a)$
. This completes the definition of
$h$
; we must now check that it satisfies the required equalities.
First, we check that
${\operatorname {len}}(h(a)) =_a l_A(a)$
. This can be done by checking equality on both parts of the coproduct. In the
$A_0$
case, we have
${\operatorname {len}}(h(a)) =_{A_0} {\operatorname {len}}(\varnothing ) =_{A_0} 0 =_{A_0} l_A(a)$
, and in the
$A_{\gt 0}$
case, we have
by using Proposition 8.1.
Second, we check that
${\operatorname {nth}}_X(m, h(a)) =_C g(m,a)$
. We could check on both parts of the coproduct, but this would be redundant: the condition
$m\lt l_A(a)$
in
$C$
implies that we are already in the
$A_{\gt 0}$
case. Formally, performing the substitution
$a \mapsto a$
in the equation
$h(a) =_{A_{\gt 0}} {\operatorname {List}}[g',l_A'](a)$
gives us the equality
$h(a) =_C {\operatorname {List}}[g', l_A'](a)$
, and this substitution is valid because
$l_A(a) \gt 0$
in
$C$
. Using this equality and Theorem 8.5, we compute
which is what we wanted.
9. Equality of Lists
Throughout this section, we assume we’re working in a category
$\mathcal{C}$
with finite products and parametrized list objects (and therefore a parametrized natural numbers object). We specify additional assumptions as needed.
As noted in Section 5, the goal of this section is to show the uniqueness part of the statement that
$(L_N(X), {\operatorname {nth}}_X)$
is a universal morphism. That is, if we have two arrows
$h_1, h_2 : A \rightarrow L(X)$
such that
$l_A = {\operatorname {len}}_X \circ h_i$
and
$g = {\operatorname {nth}}_X \circ ({\operatorname {Id}} \times _N h_i)$
for
$i=1,2$
, then
$h_1 = h_2$
(here,
$l_A : A \rightarrow N$
and
$g : E \times _N A \rightarrow X$
). Intuitively, what we need to show is that if two lists have the same length and the same elements, then they are equal.
To simplify this problem, we can start by using the arrow
$\operatorname {nthDef}$
instead of
$\operatorname {nth}$
. So, given two arrows
$h_1, h_2 : A \rightarrow L(X)$
, we’d like to show the following statement:
It turns out that hypotheses (H1) and (H2) are necessary to prove this statement. Without them, the best we can do is show that
$h_1(a) =_{x,a} h_2(a)$
, where
$x:X$
; this is the content of Theorem 9.4.
This section will therefore be divided into two subsections. In the first, we prove Theorem 9.4, which doesn’t require (H1) or (H2), or even the existence of all finite limits. In the second, we use these hypotheses to improve this result: first, we change the conclusion to be
$h_1 = h_2$
, and then we adjust our hypotheses so they involve
$\operatorname {nth}$
instead of
$\operatorname {nthDef}$
.
9.1 Equality without extra hypotheses
Our goal for this section is to prove Theorem 9.4 below. Essentially, we want to prove that two lists
$h_1, h_2 : A \rightarrow L(X)$
are equal if they have the same length and the same elements. The idea of the proof is to go by induction on their length and show that they are “built up in the same way”.
More specifically, the strategy is as follows. Given arrows
$h_1, h_2 : A \rightarrow L(X)$
, we form arrows
$H_1, H_2 : N \times A \rightarrow L(X)$
where
$H_i(k,a)$
is the list
$h_i(a)$
with all but the last
$k$
elements removed. We then want to show that
$H_1 = H_2$
; if this is true, then by setting
$k = {\operatorname {len}}(h_i(a))$
, we get
$h_1(a) = h_2(a)$
, as desired. To show that
$H_1 = H_2$
, we go by induction on
$k$
: the base case is clear since
$H_1(0,a) = H_2(0,a) = \varnothing$
, but the inductive step is more tricky.
For the inductive step, we must analyze the transition from having the last
$k$
elements of
$h_i$
to having the last
$k+1$
elements of
$h_i$
. What we’re doing is “adding back” an element to
$h_i$
; specifically, the one in position
${\operatorname {len}}(h_i) \mathrel {\substack {\cdot \\[-1ex]-}} k$
. So, we’d expect to have
If we’re assuming that
$\operatorname {nthDef}$
and
$\operatorname {len}$
agree for
$h_1$
and
$h_2$
, then this gives us a recurrence relation that both
$H_1$
and
$H_2$
satisfy, and we’re done. However, there’s a problem:
$\operatorname {nthDef}$
must include a default parameter. For this reason,
$H_i$
must also include a default parameter, making it of the form
$H_i(x,k,a)$
. This is why we can only conclude
$h_1(a) =_{x,a} h_2(a)$
.
Formalizing this proof idea requires several steps, and we will make heavy use of the if-then-else notation from Section 4.3. First, we must have a better understanding of the arrows
$H_i$
. These arrows will involve the mapping
$(x,k,\ell ) \mapsto {\operatorname {tail}}({\operatorname {len}}(\ell ) \mathrel {\substack {\cdot \\[-1ex]-}} k, \ell )$
, which we want to show interacts nicely with appending an
$n^{th}$
element of
$\ell$
. These first two propositions give us more information about this idea.
Proposition 9.1. We have
\begin{align*} {\operatorname {tail}}(m,\ell ) =_{x,m,\ell } \left \{\begin{matrix} \varnothing & \text{if } {\operatorname {len}}(\ell ) \leq m \\ {\operatorname {nthDef}}(x,m,\ell ) :: {\operatorname {tail}}(sm,\ell ) & \text{else} \end{matrix}\right .\!. \end{align*}
Proof. We first prove by induction on
$\ell$
that
\begin{align*} \ell =_{x,\ell } \left \{\begin{matrix} \varnothing & \text{if } {\operatorname {len}}(\ell ) = 0 \\ {\operatorname {zerothDef}}(x, \ell ) :: {\operatorname {tr}}(\ell ) & \text{else} \end{matrix}\right .\!. \end{align*}
If
$\ell = \varnothing$
, then
${\operatorname {len}}(\ell ) = 0$
, so the right side reduces to
$\varnothing$
. If
$\ell = y :: \ell '$
, then
${\operatorname {len}}(\ell ) = s({\operatorname {len}}(\ell '))$
, and the right side reduces to
${\operatorname {zerothDef}}(x, y :: \ell ') :: {\operatorname {tr}}(y :: \ell ') = y :: \ell ' = \ell$
.
Now, in the above equality, we replace
$\ell$
by
${\operatorname {tail}}(m,\ell )$
. The else case simplifies (using the definition of
$\operatorname {nthDef}$
) to
The term
${\operatorname {len}}({\operatorname {tail}}(m,\ell ))$
in the “if” condition simplifies (by Proposition 4.8) to
${\operatorname {len}}(\ell ) \mathrel {\substack {\cdot \\[-1ex]-}} m$
, so the condition is equivalent to
${\operatorname {len}}(\ell ) \leq m$
. Thus, we get the desired equality.
Proposition 9.2. We have
\begin{align*} {\operatorname {tail}}(Pm,\ell ) =_{x,m,\ell } \left \{\begin{matrix} {\operatorname {tail}}(m,\ell ) & \text{if } m=0 \\ \varnothing & \text{else if } {\operatorname {len}}(\ell ) \lt m \\ {\operatorname {nthDef}}(x,Pm,\ell ) :: {\operatorname {tail}}(m,\ell ) & \text{else} \end{matrix}\right .\!. \end{align*}
Proof. We prove this by induction on
$m$
. If
$m=0$
, then the left side is just
${\operatorname {tail}}(0,\ell )$
. On the right side, the condition
$m=0$
is true, so it reduces to
${\operatorname {tail}}(0,\ell )$
, as desired.
On the other hand, suppose
$m=sn$
. On the right-hand side, the outer condition becomes
$sn=0$
, which is false, so it reduces to the else-if. So, the equality we want to prove becomes
\begin{align*} {\operatorname {tail}}(Psn,\ell ) =_{x,n,\ell } \left \{\begin{matrix} \varnothing & \text{if } {\operatorname {len}}(\ell ) \lt sn \\ {\operatorname {nthDef}}(x,Psn,\ell ) :: {\operatorname {tail}}(sn,\ell ) & \text{else} \end{matrix}\right .\!. \end{align*}
Clearly,
$Psn=n$
, and the condition
${\operatorname {len}}(\ell ) \lt sn$
is by definition equivalent to
$s({\operatorname {len}}(\ell )) \mathrel {\substack {\cdot \\[-1ex]-}} sn = 0$
. But
$sa \mathrel {\substack {\cdot \\[-1ex]-}} sb =_{a,b} a \mathrel {\substack {\cdot \\[-1ex]-}} b$
, so this condition is just
${\operatorname {len}}(\ell ) \mathrel {\substack {\cdot \\[-1ex]-}} n = 0$
, i.e.,
${\operatorname {len}}(\ell ) \leq n$
. Thus, the equality we want to prove is precisely what we have proved in the previous proposition.
In the next lemma, we show that an arrow
$H$
(which will act like the arrows
$H_1, H_2$
we mentioned) satisfies a recurrence relation like the one we described in the proof outline.
Lemma 9.3.
Consider the arrow
$A : X \times N \times L(X) \times L(X) \rightarrow L(X)$
given by
\begin{align*} A(x,k,\ell ,L) =_{x,k,\ell ,L} \left \{ \begin{matrix} L & \text{if } {\operatorname {len}}(\ell ) \leq k \\ {\operatorname {nthDef}}(x, P({\operatorname {len}}(\ell )\mathrel {\substack {\cdot \\[-1ex]-}} k), \ell ) :: L & \text{else} \end{matrix} \right .\!. \end{align*}
Next, consider
$H : X \times N \times L(X) \rightarrow L(X)$
given by
Intuitively,
$H$
takes
$\ell$
and removes all but the last
$k$
elements. Then,
Proof. Using the previous proposition, we compute
\begin{align*} & H(x,sk,\ell ) \\ &\quad =_{x,k,\ell } {\operatorname {tail}}({\operatorname {len}}(\ell ) \mathrel {\substack {\cdot \\[-1ex]-}} sk, \ell ) \\ &\quad =_{x,k,\ell } {\operatorname {tail}}(P({\operatorname {len}}(\ell ) \mathrel {\substack {\cdot \\[-1ex]-}} k), \ell ) \\ &\quad =_{x,k,\ell } \left \{\begin{matrix} {\operatorname {tail}}({\operatorname {len}}(\ell ) \mathrel {\substack {\cdot \\[-1ex]-}} k,\ell ) & \text{if } {\operatorname {len}}(\ell ) \mathrel {\substack {\cdot \\[-1ex]-}} k=0 \\ \varnothing & \text{else if } {\operatorname {len}}(\ell ) \lt {\operatorname {len}}(\ell ) \mathrel {\substack {\cdot \\[-1ex]-}} k \\ {\operatorname {nthDef}}(x,P({\operatorname {len}}(\ell ) \mathrel {\substack {\cdot \\[-1ex]-}} k),\ell ) :: {\operatorname {tail}}({\operatorname {len}}(\ell ) \mathrel {\substack {\cdot \\[-1ex]-}} k,\ell ) & \text{else} \end{matrix}\right .\!. \end{align*}
Note that the top condition,
${\operatorname {len}}(\ell ) \mathrel {\substack {\cdot \\[-1ex]-}} k = 0$
, is the same as
${\operatorname {len}}(\ell ) \leq k$
. Moreover, the else-if condition is just false, so the else-if-else reduces to just the else case. (To justify this formally, we need to show
$s({\operatorname {len}}(\ell )) \mathrel {\substack {\cdot \\[-1ex]-}} ({\operatorname {len}}(\ell ) \mathrel {\substack {\cdot \\[-1ex]-}} k) \gt _{k,\ell } 0$
. But by Proposition A.5, this is equivalent to saying
${\operatorname {len}}(\ell ) \mathrel {\substack {\cdot \\[-1ex]-}} k \leq _{k,\ell } s({\operatorname {len}}(\ell ))$
, which is easy to show.) Finally, we can just replace the term
${\operatorname {tail}}({\operatorname {len}}(\ell ) \mathrel {\substack {\cdot \\[-1ex]-}} k, \ell )$
by
$H(x,k,\ell )$
. With all this consideration, the above expression reduces to
\begin{align*} H(x,sk,\ell ) = \left \{\begin{matrix} H(x,k,\ell ) & \text{if } {\operatorname {len}}(\ell ) \leq k \\ {\operatorname {nthDef}}(x, P({\operatorname {len}}(\ell ) \mathrel {\substack {\cdot \\[-1ex]-}} k), \ell ) :: H(x,k,\ell ) & \text{else} \end{matrix}\right .\!, \end{align*}
which is just
$A(x,k,\ell , H(x,k,\ell ))$
, as desired.
Finally, we reach the desired result. As noted previously, this theorem does not allow us to conclude
$h_1(a) =_a h_2(a)$
, that is,
$h_1 = h_2$
. It says that
$h_1 \circ \pi _A = h_2 \circ \pi _A$
as maps
$X \times A \rightarrow L(X)$
; we can’t yet get rid of the parameter
$X$
.
Theorem 9.4.
Let
$h_1, h_2 : A \rightarrow L(X)$
. Suppose that
Then,
$h_1(a) =_{x,a} h_2(a)$
, where
$x$
is a variable of type
$X$
.
Proof. For
$i=1,2$
, we define the map
$A_i : X \times N \times A \times L(X) \rightarrow L(X)$
by setting
$A_i(x,k,a,L) =_{x,k,a,L} A(x,k,h_i(a),L)$
, where
$A$
is as in the previous lemma. For
$i=1,2$
, define
$H_i : X \times N \times A \rightarrow L(X)$
by
$H_i(x,k,a) =_{x,k,a} H(x,k,h_i(a))$
, where
$H$
is as in the previous lemma. By the previous lemma, we know that
$H_i(x,sk,a) =_{x,k,a} A_i(x,k,a,H_i(x,k,a))$
.
We claim that
$H_1 = H_2$
; we’ll prove this by induction on
$k$
. In the base case, we have
$H_1(x,0,a) =_{x,a} \varnothing =_{x,a} H_2(x,0,a)$
; indeed, for
$i=1,2$
, we compute
The last equality follows from combining Propositions 4.8 and 4.9. (The length of this list is
${\operatorname {len}}(h_i(a)) \mathrel {\substack {\cdot \\[-1ex]-}} {\operatorname {len}}(h_i(a)) =_{x,a} 0$
, so the list is empty.)
For the inductive step, we note that
$A_1 = A_2$
. Indeed, we have
\begin{align*} A_i(x,k,a,L) =_{x,k,a,L} \left \{\begin{matrix} L & \text{if } {\operatorname {len}}(h_i(a)) \leq k \\ {\operatorname {nthDef}}(x, P({\operatorname {len}}(h_i(a)) \mathrel {\substack {\cdot \\[-1ex]-}} k), h_i(a)) :: L & \text{else} \end{matrix}\right .\!, \end{align*}
so the equalities assumed for this theorem give us
$A_1 = A_2$
. Writing
$A_\times$
for
$A_1 = A_2$
, we therefore have
$H_i(x,sk,a) = A_\times (x,k,a,H_i(x,a,k))$
for
$i=1,2$
.
So,
$H_1, H_2$
satisfy the same defining equations, and we conclude by induction that
$H_1 = H_2$
. Now, note that
so
$H_1 = H_2$
and
${\operatorname {len}}(h_1(a)) =_a {\operatorname {len}}(h_2(a))$
let us conclude
$h_1(a) =_{x,a} h_2(a)$
, as desired.
9.2 Equality with extensivity hypotheses
In this section, we use finite limits and hypotheses (H1) and (H2) to supplement Theorem 9.4. First, we show that the conclusion can be changed from
$h_1(a) =_{x,a} h_2(a)$
to
$h_1 = h_2$
.
Lemma 9.5.
Let
$\mathcal{C}$
be a category with finite limits and parametrized list objects and assume (H1) and (H2). If
$h_1, h_2 : A \rightarrow L(X)$
are arrows that satisfy the equations
${\operatorname {len}}(h_1(a)) =_a {\operatorname {len}}(h_2(a))$
and
$h_1(a) =_{x,a} h_2(a)$
(
$x$
is a variable of type
$X$
), then
$h_1 = h_2$
.
Proof. Let
$l_A = {\operatorname {len}}_X \circ h_1 = {\operatorname {len}}_X \circ h_2$
. Let
$D_0$
be the context
$(a:A \mid l_A(a)=0)$
and let
$D_{\gt 0}$
be the context
$(a:A \mid l_A(a) \gt 0)$
. By Proposition 6.2 (which uses (H2)), we have
$A = [D_0] + [D_{\gt 0}]$
. Therefore, to show
$h_1 = h_2$
, it suffices to show that
For the first equality, we claim that both terms equal
$\varnothing$
. Indeed, in the context
$D_0$
, we have
${\operatorname {len}}(h_1(a)) =_{D_0} l_A(a) =_{D_0} 0$
, and this implies that
$h_1(a) =_{D_0} \varnothing$
by Proposition 4.9. The same goes for
$h_2$
.
For the second equality, we need the existence of a term
${\operatorname {def}}' : X$
in the context
$D_{\gt 0}$
. Indeed, if such a term exists, then by substituting
$x \mapsto {\operatorname {def}}'$
,
$a \mapsto a$
in the equation
$h_1(a) =_{x,a} h_2(a)$
, we get the desired equality
To obtain
${\operatorname {def}}'$
, we use Proposition 7.1 (which requires (H1)) to get a term
${\operatorname {def}} : X$
in the context
$(m:N, \, \ell : L(X) \mid m \lt {\operatorname {len}}(\ell ))$
. Then, since
$0 \lt _{D_{\gt 0}} l_A(a) =_{D_{\gt 0}} {\operatorname {len}}(h_1(a))$
, we can perform a substitution
$m \mapsto 0$
,
$\ell \mapsto h_1(a)$
to get the term
${\operatorname {def}}' = {\operatorname {def}}[0/m, \, h_1(a)/\ell ]$
of type
$X$
in the context
$D_{\gt 0}$
, as desired.
Next, we show that the hypotheses of Theorem 9.4 can be changed so that we use
$\operatorname {nth}$
instead of
$\operatorname {nthDef}$
(recall that assumption (H1) is necessary to talk about
${\operatorname {nth}}_X$
).
Lemma 9.6.
Let
$\mathcal{C}$
be a category with finite limits and parametrized list objects and assume (H1) and (H2). Let
$h_1, h_2 : A \rightarrow L(X)$
. Suppose that
and denote this arrow
$l_A$
. Then, in the context
$C = (m : N, \; a : A \mid m \lt l_A(a))$
, suppose that
Then,
${\operatorname {nthDef}}(x, m, h_1(a)) =_{x,m,a} {\operatorname {nthDef}}(x, m, h_2(a))$
.
Proof. Let
$D = (x:X, m:N, a:A)$
, and let
$D_0 = (D \mid m \lt l_A(a))$
,
$D_1 = (D \mid m \geq l_A(a))$
. Since we’re assuming (H2), we can use Corollary 6.3 to conclude that
$[D] = [D_0] + [D_1]$
. Therefore, to show that
${\operatorname {nthDef}}(x, m, h_1(a)) =_D {\operatorname {nthDef}}(x, m, h_2(a))$
, it suffices to show the following.
We start with the second equality, since it is the easiest. Indeed, since we have
$m \geq _{D_1} l_A(a) =_{D_1} {\operatorname {len}}(h_1(a))$
, Proposition 4.10 tells us that
The same is true if we replace
$h_1$
by
$h_2$
, so the equality follows.
For the first equality, we note that
${\operatorname {nth}}(m, h_1(a)) =_{D_0} {\operatorname {nth}}(m, h_2(a))$
by assumption (we can “add
$x:X$
to the context” by performing a substitution). To establish the desired equality, then, it suffices to show that
and the same for
$h_2$
(which is done the same way). We finish the proof by establishing this equality.
There are two things to note here. First, the second equality is by Proposition 4.10, using the hypothesis
$m \lt l_A(a) = {\operatorname {len}}(h_1(a))$
from the context
$D_0$
. Second,
${\operatorname {def}}'$
is the term
$\operatorname {def}$
used to define
$\operatorname {nth}$
, but with the substitution
$\ell \mapsto h_1(a)$
(it is originally in the context
$(m:N, \ell :L(X) \mid m \lt {\operatorname {len}}(\ell ))$
).
Putting this all together, we get the following result, which is the uniqueness part of showing that
$(L_N(X), {\operatorname {nth}}_X)$
is a universal morphism.
Corollary 9.7.
Let
$\mathcal{C}$
be a category with finite limits and parametrized list objects and assume (H1) and (H2). If
$h_1, h_2 : A \rightarrow L(X)$
are such that
${\operatorname {len}}_X \circ h_1 = {\operatorname {len}}_X \circ h_2$
and
${\operatorname {nth}}_X \circ ({\operatorname {Id}}_E \times _N h_1) = {\operatorname {nth}}_X \circ ({\operatorname {Id}}_E \times _N h_2)$
, then
$h_1 = h_2$
.
Proof. Apply Lemma 9.6, then Theorem 9.4, then Lemma 9.5. Remark that, if we set
$l_A = {\operatorname {len}}_X \circ h_1 = {\operatorname {len}}_X \circ h_2$
, then in the context
$C = (m : N, a : A \mid m \lt l_A(a))$
, we have
$\big ( {\operatorname {nth}}_X \circ ({\operatorname {Id}}_E \times _N h) \big )(m, \ell ) =_C {\operatorname {nth}}_X(n, h(a))$
by Fact 6.5.
Acknowledgements
This research was conducted as part the author’s PhD thesis, under the supervision of Simon Henry and Philip J. Scott. The author wishes to express his gratitude for their insights and support. This research was partially supported by the Natural Sciences and Engineering Research Council of Canada (NSERC) and by the Ontario Graduate Scholarship (OGS) Program.
Competing interests
The author completed this paper as part of his PhD program under the supervision of Professor Simon Henry, who is a guest editor for the MSCS journal. The author is also acquainted professionally with Richard Blute, another guest editor of the journal.
Appendix A. Inequality for natural numbers objects
In this appendix, we develop various facts about the inequality relations on a natural numbers object. Throughout, we work in a category with finite products and an NNO. As far as we can tell, these results do not exist in the literature in the form that we present, though they are closely related to standard facts about inequalities for NNOs (such as those presented in section 3 of Román (Reference Román1989) or section A2.5 of Johnstone (Reference Johnstone2002)).
In addition to the definitions and notation from Sections 4.1 and 4.2, we will borrow the function
$|x,y| =_{x,y} (x \mathrel {\substack {\cdot \\[-1ex]-}} y) + (y \mathrel {\substack {\cdot \\[-1ex]-}} x)$
from Román’s paper on natural numbers objects (Román Reference Román1989) (originally from Goodstein (Reference Goodstein1957)). This map has the property that for
$f,g : X \rightarrow N$
,
$f=g$
if and only if
$|f,g| = 0_X$
(Corollary 1.4 in his paper). Equivalently, given any two terms
$x,y : N$
in a context
$C$
, we have
$x =_C y$
if and only if
$|x,y| =_C 0$
. We will also use Román’s
$\min$
and
$\max$
functions, defined as
$\min (x,y) =_{x,y} x \mathrel {\substack {\cdot \\[-1ex]-}} (x \mathrel {\substack {\cdot \\[-1ex]-}} y) =_{x,y} y \mathrel {\substack {\cdot \\[-1ex]-}} (y \mathrel {\substack {\cdot \\[-1ex]-}} x)$
and
$\max (x,y) =_{x,y} x + (y \mathrel {\substack {\cdot \\[-1ex]-}} x) =_{x,y} y + (x \mathrel {\substack {\cdot \\[-1ex]-}} y)$
(see his Proposition 1.3).
We start with a few preliminary facts which we’ll use in the rest of the appendix.
Lemma A.1. We have the following equalities.
-
1.
$a \mathrel {\substack {\cdot \\[-1ex]-}} (b+c) =_{a,b,c} (a \mathrel {\substack {\cdot \\[-1ex]-}} b) \mathrel {\substack {\cdot \\[-1ex]-}} c$
-
2.
$|\max (a,b), b| =_{a,b} a \mathrel {\substack {\cdot \\[-1ex]-}} b$
-
3.
$(a \mathrel {\substack {\cdot \\[-1ex]-}} b) \bullet (b \mathrel {\substack {\cdot \\[-1ex]-}} a) =_{a,b} 0$
Proof. For part 1, we go by induction on
$c$
. The base case is trivial, and for the induction step, both sides clearly satisfy the recurrence
$f(a,b,sc) =_{a,b,c} P(f(a,b,c))$
.
For part 2, since
$|\max (a,b),b| =_{a,b} (\max (a,b) \mathrel {\substack {\cdot \\[-1ex]-}} b) + (b \mathrel {\substack {\cdot \\[-1ex]-}} \max (a,b))$
, it suffices to show
$\max (a,b) \mathrel {\substack {\cdot \\[-1ex]-}} b =_{a,b} a \mathrel {\substack {\cdot \\[-1ex]-}} b$
and
$b \mathrel {\substack {\cdot \\[-1ex]-}} \max (a,b) =_{a,b} 0$
. The latter equality is an easy computation with part 1:
For the former equality, we use Corollary 2.2(e) from Román’s paper (Román Reference Román1989):
For part 3, we will use the induction principle provided by Proposition 3.1(c) in Román’s paper (Román Reference Román1989). This principle states that, given
$f : N^2 \rightarrow N$
, if
$f(a+sb,b) =_{a,b} 0$
, then
$(a \mathrel {\substack {\cdot \\[-1ex]-}} b) \bullet f(a,b) =_{a,b} 0$
. This conclusion is what we want with
$f(a,b) =_{a,b} b \mathrel {\substack {\cdot \\[-1ex]-}} a$
, so we compute
This is all we needed to show.
We now start establishing results about the inequality relation. First, we show some equivalent characterizations of
$a \leq _C b$
.
Proposition A.2.
Let
$a,b : N$
be terms in a context
$C$
. The following are equivalent:
-
1.
$a \leq _C b$
; -
2.
$\max (a,b) =_C b$
; -
3.
$\min (a,b) =_C a$
; -
4. There exists a term
$x : N$
in the context
$C$
such that
$a+x =_C b$
; -
5. There exists a term
$x : N$
in the context
$C$
such that
$a =_C b \mathrel {\substack {\cdot \\[-1ex]-}} x$
.
Proof. For this proof, we show that
$1 \Rightarrow 2 \Rightarrow 4 \Rightarrow 1$
and
$1 \Rightarrow 3 \Rightarrow 5 \Rightarrow 1$
. All the equalities here will take place in the context
$C$
, so we will omit the subscripts.
(
$1 \Rightarrow 2$
). If
$a \leq b$
, then
$a \mathrel {\substack {\cdot \\[-1ex]-}} b = 0$
. Using Lemma A.1(2), we find that
$|\max (a,b),b| = a \mathrel {\substack {\cdot \\[-1ex]-}} b = 0$
, which implies
$\max (a,b) = b$
, as desired.
(
$2 \Rightarrow 4$
). Suppose
$\max (a,b) = b$
, and set
$x = b \mathrel {\substack {\cdot \\[-1ex]-}} a$
. Then
$a+x = \max (a,b) = b$
.
(
$4 \Rightarrow 1$
). Assume
$a+x=b$
. Then, using A.1(1),
$a \mathrel {\substack {\cdot \\[-1ex]-}} b = a \mathrel {\substack {\cdot \\[-1ex]-}} (a+x) = (a \mathrel {\substack {\cdot \\[-1ex]-}} a) \mathrel {\substack {\cdot \\[-1ex]-}} x = 0 \mathrel {\substack {\cdot \\[-1ex]-}} x = 0$
, which is equivalent to
$a \leq b$
.
(
$1 \Rightarrow 3$
). Suppose
$a \leq b$
, that is
$a \mathrel {\substack {\cdot \\[-1ex]-}} b = 0$
. By definition,
$\min (a,b) = a \mathrel {\substack {\cdot \\[-1ex]-}} (a \mathrel {\substack {\cdot \\[-1ex]-}} b) = a \mathrel {\substack {\cdot \\[-1ex]-}} 0 = a$
.
(
$3 \Rightarrow 5$
). If
$\min (a,b)=a$
, set
$x = b \mathrel {\substack {\cdot \\[-1ex]-}} a$
. Then
$b \mathrel {\substack {\cdot \\[-1ex]-}} x = \min (b,a) = \min (a,b) = a$
.
(
$5 \Rightarrow 1$
). Assume
$a = b \mathrel {\substack {\cdot \\[-1ex]-}} x$
. By Román’s Proposition 1.3(f),
$a \mathrel {\substack {\cdot \\[-1ex]-}} b = (b \mathrel {\substack {\cdot \\[-1ex]-}} x) \mathrel {\substack {\cdot \\[-1ex]-}} b = (b \mathrel {\substack {\cdot \\[-1ex]-}} b) \mathrel {\substack {\cdot \\[-1ex]-}} x = 0 \mathrel {\substack {\cdot \\[-1ex]-}} x = 0$
, which is equivalent to
$a \leq b$
.
With the above proposition, we can now connect our definition of inequality to the usual definition via subobjects. Specifically, we show that the usual subobjects for
$\leq$
and
$\lt$
(see section 3 of Román (Reference Román1989)) are given by equalizers, as promised in Section 4.2.
Corollary A.3.
Let
$\mathcal{C}$
be a category with finite products and a parametrized NNO. Then the following diagrams are equalizers.

Proof. We start with the first diagram, and argue in the internal language. Let
$a,b : N$
be terms in a context
$C$
such that
$a \mathrel {\substack {\cdot \\[-1ex]-}} b =_C 0$
, that is
$a \leq _C b$
. By Proposition A.2, there exists some
$x$
such that
$a+x =_C b$
, that is
$(a,a+x) =_C (a,b)$
. We have uniqueness because
$x =_C (a+x) \mathrel {\substack {\cdot \\[-1ex]-}} a =_C b \mathrel {\substack {\cdot \\[-1ex]-}} a$
(Proposition 1.3(c) of Román (Reference Román1989)).
For the second diagram, suppose that
$sa \mathrel {\substack {\cdot \\[-1ex]-}} b =_C 0$
; equivalently
$sa \leq _C b$
. Then
$b =_C sa + x$
for some
$x$
, and so
$(a,s(a+x)) =_C (a,b)$
. Again, we have uniqueness because
$x =_C b \mathrel {\substack {\cdot \\[-1ex]-}} sa$
.
Next, we note that
$\leq _C$
is a partial order, and that it is preserved by arithmetic operations. It is well known that inequality is a partial order (this is shown in section 3 of Román (Reference Román1989)), but the result is slightly different in our notation. We could appeal to Román’s result for the proof thanks to Corollary A.3, but we prefer a short direct proof. As for the arithmetic operations preserving inequality, we could not find a reference that was only for categories with finite products and an NNO.
Proposition A.4.
For any context
$C$
, the relation
$\leq _C$
is a partial order on terms of type
$N$
in the context
$C$
. That is:
-
1.
$x \leq _C x$
; -
2. If
$x \leq _C y$
and
$y \leq _C x$
, then
$x =_C y$
; -
3. If
$x \leq _C y$
and
$y \leq _C z$
, then
$x \leq _C z$
.
Moreover, if
$x \leq _C y$
, then
$x+z \leq _C y+z$
,
$x \bullet z \leq _C y \bullet z$
, and
$x \mathrel {\substack {\cdot \\[-1ex]-}} z \leq _C y \mathrel {\substack {\cdot \\[-1ex]-}} z$
.
Proof. We will omit the
$C$
subscript for clarity. For 1, see Román’s Proposition 1.3(b). For 2, note that
$x \leq y$
and
$y \leq x$
imply
$|x,y| = (x \mathrel {\substack {\cdot \\[-1ex]-}} y) + (y \mathrel {\substack {\cdot \\[-1ex]-}} x) = 0 + 0 = 0$
; by Román’s Corollary 1.4, we get
$x=y$
. For 3, we use Proposition A.2 to conclude that there exist
$a,b : N$
such that
$x+a = y$
and
$y+b = z$
. Then,
$x+(a+b) = (x+a)+b = y+b = z$
, so
$x \leq z$
, as desired.
For the last part, assume that
$x \leq y$
, so
$y = x+k$
for some
$k$
(by Proposition A.2). For the addition inequality,
$y+z = (x+k)+z = (x+z)+k$
, so
$x+z \leq y+z$
. For the multiplication,
$y \bullet z = (x+k) \bullet z = x \bullet z + k \bullet z$
, so
$x \bullet z \leq y \bullet z$
. For the subtraction, we apply Román’s Corollary 2.2(e) to find
so
$x \mathrel {\substack {\cdot \\[-1ex]-}} z \leq y \mathrel {\substack {\cdot \\[-1ex]-}} z$
.
Finally, we show another way to characterize the relation
$a \lt _C b$
.
Proposition A.5.
Let
$a,b : N$
be terms in a context
$C$
. Then,
$a \lt _C b$
if and only if
$b \mathrel {\substack {\cdot \\[-1ex]-}} a \gt _C 0$
.
Proof. We omit the
$C$
subscript for brevity and show that
$b \geq a+1$
if and only if
$b \mathrel {\substack {\cdot \\[-1ex]-}} a \geq 1$
. First, suppose
$b \geq a+1$
; then
$b \mathrel {\substack {\cdot \\[-1ex]-}} a \geq (a+1) \mathrel {\substack {\cdot \\[-1ex]-}} a = 1$
by Proposition A.4 and Román’s Proposition 1.3(c).
On the other hand, suppose
$b \mathrel {\substack {\cdot \\[-1ex]-}} a \geq 1$
. Then, using Lemma A.1(3) and Proposition A.4,
so
$a \mathrel {\substack {\cdot \\[-1ex]-}} b = 0$
. Thus,
(The second equality is the definition of
$\max$
; see Román’s Proposition 1.3(e).)
The above proposition lends itself to a nice categorical expression.
Corollary A.6.
Let
$\mathcal{C}$
be a category with finite products and a parametrized NNO. Then the following diagram commutes, its top row is a coproduct, and the squares are pullbacks.

Proof. Commutativity of the diagram amounts to showing the easy equalities
$a \mathrel {\substack {\cdot \\[-1ex]-}} (a+b) =_{a,b} 0$
and
$s(a+b) \mathrel {\substack {\cdot \\[-1ex]-}} b =_{a,b} sa$
. For the top row, we note that it consists of the subobjects
$(\!\leq\!)$
and
$(\!\gt\!)$
; Proposition 3.2(b) of Román (Reference Román1989) shows their coproduct is
$N \times N$
, as desired. The left square is a pullback because it is just another way of writing the equalizer diagram of Corollary A.3.
Finally, to show the right square is a pullback, let
$a,b,c:N$
be terms in a context
$C$
such that
$a \mathrel {\substack {\cdot \\[-1ex]-}} b =_C sc$
. Thus,
$a \mathrel {\substack {\cdot \\[-1ex]-}} b \gt _C 0$
, so by Proposition A.5,
$b \lt _C a$
. By Corollary A.3, there is a unique
$k$
such that
$(s(b+k), k) =_C (a,b)$
, and we find that
$a \mathrel {\substack {\cdot \\[-1ex]-}} b =_C s(b+k) \mathrel {\substack {\cdot \\[-1ex]-}} b =_C sk$
, so
$k =_C c$
.
We used a result from Román (Reference Román1989) to establish that the top row in the diagram is a coproduct. If we were working in an extensive category, this would be enough to directly conclude that the squares are pullbacks (see Fact 2.1). However, we showed that this holds even without this additional hypothesis.







is universal (its pullback along any arrow is still a coproduct).