1 Introduction

A category \({\mathbb {C}}\) can host internal algebraic structures such as monoids, groups, rings, etc. Among these internal algebraic structures there are categories, too. An internal category is defined as an internal graph having a composition arrow and an identity arrow making some diagrams (representing associativity of composition and properties of identities) commute (see e.g. [3]).

An internal category cannot directly be compared with the category in which it lives. However, it can be “externalized” by means of global elements. It is hence natural to compare this externalization with \({\mathbb {C}}\).

In this paper we deal with the question whether there exist categories \({\mathbb {C}}\) having an internal copy, that is an internal category in \({\mathbb {C}}\) of which the externalization is isomorphic to \({\mathbb {C}}\) itself. We will show that one can produce examples of a weakening of this notion by considering some categories of definable classes of first-order theories. A metaproperty called numerical existence property will play a crucial role in this case. Finally, we will produce an example of a category with an internal copy in the strong sense.

Notational conventions In this paper we adopt the following convention: whenever we say that \({\mathbb {C}}\) is a finitely complete category, we mean that \({\mathbb {C}}\) is endowed with a distinct terminal object 1 and with an explicit choice of pullbacks \(({\mathsf {Pb}}(f,g),\pi _0^{f,g},\pi _1^{f,g})\) for every pair of arrows f and g having the same codomain. In this case, if \(k_0\) and \(k_1\) are arrows in \({\mathbb {C}}\) such that \(f\circ k_0=g\circ k_1\), then we denote by \(\langle k_0,k_1\rangle _{f,g}\) the only arrow from \(\partial _0(k_0)=\partial _0(k_1)\) to \({\mathsf {Pb}}(f,g)\) such that \(\pi _i^{f,g}\circ \langle k_0,k_1\rangle _{f,g}=k_i\) for \(i=0,1\). If \(!_A:A\rightarrow 1\) and \(!_B:B\rightarrow 1\) are the unique arrows from A and B, respectively, to the terminal object 1, then we denote with \(A\times B\) the object \({\mathsf {Pb}}(!_A,!_B)\), with \(\pi _{i}^{A,B}\) the arrow \(\pi _i^{!_A,!_B}\) for \(i=0,1\) and with \(\langle f,g\rangle _{A,B}\) the arrow \(\langle f,g\rangle _{!_A,!_B}\). As usual, we define \(\Delta _A\) as \(\langle {\mathsf {id}}_{A},{\mathsf {id}}_A\rangle _{A,A}\) and \({\mathsf {tw}}_A\) as \(\langle \pi _{1}^{A,A},\pi _0^{A,A}\rangle _{A,A}\). We will omit the subscripts and superscripts when they will be clear from the context.

2 Internal Copies and Extensions of a Category

Definition 2.1

An internal category\(\Gamma \) in a finitely complete category \({\mathbb {C}}\) is a

6-uple \(({\Gamma _{0}},{\Gamma _{1}},{\delta _{0}},{\delta _{1}},\mathsf {ID},\Box )\) where \({\Gamma _{0}}\), \({\Gamma _{1}}\) are objects of \({\mathbb {C}}\) and \({\delta _{0}},{\delta _{1}}:{\Gamma _{1}}\rightarrow {\Gamma _{0}}\), \(\mathsf {ID}:{\Gamma _{0}}\rightarrow {\Gamma _{1}}\) and \(\Box :{\mathsf {Pb}}({\delta _{1}},{\delta _{0}})\rightarrow {\Gamma _{1}}\) are arrows of \({\mathbb {C}}\) such that

  1. 1.

    \(\delta _i\circ \mathsf {ID}={\mathsf {id}}_{{\Gamma _{0}}}\) for \(i=0,1\);

  2. 2.

    \(\delta _i\circ \Box =\delta _i\circ \pi _{i}\) for \(i=0,1\);

  3. 3.

    \(\Box \circ \langle \mathsf {ID}\circ {\delta _{0}}, {\mathsf {id}}_{{\Gamma _{1}}}\rangle =\Box \circ \langle {\mathsf {id}}_{{\Gamma _{1}}},\mathsf {ID}\circ {\delta _{1}}\rangle ={\mathsf {id}}_{{\Gamma _{1}}}\);

  4. 4.

    \(\Box \circ \langle \pi _0,\Box \circ \pi _1\rangle =\Box \circ \langle \Box \circ \pi _0,\pi _1\rangle \circ \langle \langle \pi _0, \pi _0\circ \pi _1\rangle , \pi _1\circ \pi _1\rangle \).

Definition 2.2

If \(\Gamma \) is an internal category of a finitely complete category \({\mathbb {C}}\), then its externalization is the category \({\mathsf {Ext}}_{{\mathbb {C}}}(\Gamma )\) defined as follows:

  1. 1.

    \({\mathsf {Obj}}({{\mathsf {Ext}}}_{{\mathbb {C}}}(\Gamma )):={\mathsf {Hom}}_{{\mathbb {C}}}(1,{\Gamma _{0}})\);

  2. 2.

    \({\mathsf {Arr}}({{\mathsf {Ext}}}_{{\mathbb {C}}}(\Gamma )):={\mathsf {Hom}}_{{\mathbb {C}}}(1,{\Gamma _{1}})\);

  3. 3.

    \({\partial _{i}}(f):=\delta _i\circ f\) for \(i=0,1\) for morphisms f from 1 to \({\Gamma _{1}}\);

  4. 4.

    \({\mathsf {id}}_A:={\mathsf {ID}}\circ A\) for morphisms A from 1 to \({\Gamma _{0}}\);

  5. 5.

    \(g\circ f:=\Box \circ \langle f,g\rangle \) for morphisms f, g from 1 to \(\Gamma _{1}\) such that \(\partial _{1} (f) = \partial _{0} (g)\).

Definition 2.3

Let \({\mathbb {C}}\) be a finitely complete category. An internal copy of \({\mathbb {C}}\) is a pair \((\Gamma ,{\mathbf {I}})\) consisting of an internal category \(\Gamma \) and an isomorphism \({\mathbf {I}}:{\mathsf {Ext}}_{{\mathbb {C}}}(\Gamma )\rightarrow {\mathbb {C}}\).

Let us first consider some trivial cases. Let \({\mathbb {C}}\) be a finitely complete category having an internal copy with \(\mathsf {Arr}({\mathbb {C}})\) finite; then \({\mathbb {C}}\) is the trivial category. Indeed, if \(\mathsf {Arr}({\mathbb {C}})\) is finite, then from \(|{\mathsf {Hom}}_{\mathbb {C}}(1,{\Gamma _{1}})|=|\mathsf {Arr}({\mathbb {C}})|\), it follows that \({\mathsf {Hom}}_{{\mathbb {C}}}(1,{\Gamma _{1}})= \mathsf {Arr}({\mathbb {C}})\). Since \({\mathsf {id}}_{{\Gamma _{1}}}\in \mathsf {Arr}({\mathbb {C}})\), we conclude that \(1={\Gamma _{1}}\) and thus \({\mathbb {C}}\) has only one object and this object is terminal. Hence \({\mathbb {C}}\) is the trivial category. Moreover, no non-trivial preorder has an internal copy: if \({\mathbb {C}}\) is a preorder with an internal copy \(\Gamma \), then, since \({\mathsf {Hom}}_{{\mathbb {C}}}(1, {\Gamma _{1}})\) has at most one element, \({\mathbb {C}}\) has at most one arrow. But, having an internal category, \({\mathbb {C}}\) has at least one arrow. Thus \({\mathbb {C}}\) is the trivial category.

Obviously, also every locally small category which is not small (e.g. \(\mathbf {Set}\), \(\mathbf {Grp}\)...) cannot have an internal copy.

We can weaken the notion of internal copy by relativazing it to a doctrine over \({\mathbb {C}}\). If \(\mathbf {p}:{\mathbb {C}}^{op}\rightarrow \mathbf {InfSL}\) is a (primary) doctrine, that is a contravariant functor from \({\mathbb {C}}\) to the category of inf-semilattices, we can consider the internal categories in the base category \(\mathcal {Q}_\mathbf {p}\) of its elementary quotient completion (see [5]). The objects of this category are pairs \((I,\rho )\) where I is an object of \({\mathbb {C}}\) and \(\rho \in \mathbf {p}(I\times I)\) is a \(\mathbf {p}\)-equivalence relation on it, that is

  1. 1.

    \(\mathbf {p}(\Delta _I)(\rho )=\top \) in \(\mathbf {p}(I)\);

  2. 2.

    \(\mathbf {p}({\mathsf {tw}}_I)(\rho )=\rho \) in \(\mathbf {p}(I\times I)\);

  3. 3.

    \(\mathbf {p}(\langle \pi _1,\pi _2\rangle )(\rho )\wedge \mathbf {p}\langle \pi _2,\pi _3\rangle )(\rho )\le \mathbf {p}(\langle \pi _1,\pi _3\rangle )(\rho )\) in \(\mathbf {p}(I\times I\times I)\).

An arrow from \((I,\rho )\) to \((J,\eta )\) is an equivalence class [f] of arrows \(f:I\rightarrow J\) of \({\mathbb {C}}\) such that \(\rho \le \mathbf {p}(f\times f)(\eta )\) with respect to the equivalence relation for which f and g are equivalent if and only if \(\rho \le \mathbf {p}(f\times g)(\eta )\).

If \({\mathbb {C}}\) is finitely complete, then \(\mathcal {Q}_\mathbf {p}\) has all finite products. In particular, a terminal object in \(\mathcal {Q}_\mathbf {p}\) is given by the pair \((1,\top )\).

Thus for every \((I,\rho )\) in \(\mathcal {Q}_\mathbf {p}\),

$$\begin{aligned} {\mathsf {Hom}}_{\mathcal {Q}_\mathbf {p}}((1,\top ),(I,\rho ))={\mathsf {Hom}}_{{\mathbb {C}}}(1,I)/\sim _\rho \end{aligned}$$

where \(f\sim _\rho g\) if and only if \(\top \le \mathbf {p}(\langle f,g\rangle )(\rho )\).

Among the doctrines over \({\mathbb {C}}\) there is in particular the subobject doctrine. We can hence give the following definition:

Definition 2.4

Let \({\mathbb {C}}\) be a finitely complete category with a primary doctrine \(\mathbf {p}\) over it such that \(\mathcal {Q}_\mathbf {p}\) is finitely complete. A \(\mathbf {p}\)-internal copy of \({\mathbb {C}}\) is a pair \((\Gamma ,{\mathbf {I}})\) consisting of an internal category \(\Gamma \) of \(\mathcal {Q}_\mathbf {p}\) and an isomorphism \({\mathbf {I}}:{\mathsf {Ext}}_{\mathcal {Q}_\mathbf {p}}(\Gamma )\rightarrow {\mathbb {C}}\). A weak internal copy of a finitely complete category \({\mathbb {C}}\) is a \(\mathbf {Sub}_{{\mathbb {C}}}\)-internal copy of \({\mathbb {C}}\).Footnote 1

If the doctrine \(\mathbf {p}\) is elementary (see [5]), then one can define a functor \(\nabla \) from \({\mathbb {C}}\) to \(\mathcal {Q}_\mathbf {p}\) sending each object I to \((I,\exists _{\Delta _I}(\top ))\) (where \(\exists _{\Delta _I}\) is left adjoint to \(\mathbf {p}(\Delta _I)\)) and sending an arrow f to [f]. If \(\mathbf {p}\) has comprehensive weak equalizers, then \(\nabla \) is full and faithful. In this case, as a consequence, if \({\mathbb {C}}\) has an internal copy, then it has also a \(\mathbf {p}\)-internal copy. If \({\mathbb {C}}\) is regular, the subobject functor is an elementary doctrine having comprehensive weak equalizers (see [5]); hence every internal copy of \({\mathbb {C}}\) is also a weak internal copy.

From the very definition of \(\mathbf {p}\)-internal copies, it follows that no non-trivial finite category or preorder has a \(\mathbf {p}\)-internal copy; moreover, obviously, no locally small non-small category has a \(\mathbf {p}\)-internal copy.

3 Categories of Definable Classes

Let \({\mathsf {T}}\) be a first-order (intuitionistic or classical) theory with equalityFootnote 2. Let xyz be fixed distinct variables of the language of \({\mathsf {T}}\). The category of its definable classes \({\mathbb {DC}}[{\mathsf {T}}]\) is defined as follows:

  1. 1.

    Its objects are formal expressions \(\{x|\,\varphi \}\) where \(\varphi \) is a formula of \({\mathsf {T}}\) having at most x as free variable; such objects are called definable classes and we write \(t\,\varepsilon \,\{x|\,\varphi \}\) as a shorthand for \(\varphi [t/x].\)Footnote 3

  2. 2.

    We will identify objects \(\{x|\,\varphi \}\) and \(\{x|\,\psi \}\) for which \(\varphi \vdash _{{\mathsf {T}}}\psi \) and \(\psi \vdash _{{\mathsf {T}}}\varphi \);

  3. 3.

    An arrow from \(\{x|\,\varphi \}\) to \(\{x|\,\psi \}\) in \({\mathbb {DC}}[{\mathsf {T}}]\) is a formula F having at most x and y as free variables, such that

    1. (a)

      \(F\vdash _{{\mathsf {T}}}\varphi \wedge \psi [y/x]\);

    2. (b)

      \(F\wedge F[z/y]\vdash _{{\mathsf {T}}}y=z\);

    3. (c)

      \(\varphi \vdash _{{\mathsf {T}}}\exists y \, F\);

  4. 4.

    We will identify arrows F and G from \(\{x|\,\varphi \}\) to \(\{x|\,\psi \}\) in \({\mathbb {DC}}[{\mathsf {T}}]\) such that \(F\vdash _{{\mathsf {T}}}G\) and \(G\vdash _{{\mathsf {T}}}F\);

  5. 5.

    The composition of \(F:\{x|\,\varphi \}\rightarrow \{x|\,\psi \}\) and \(G:\{x|\,\psi \}\rightarrow \{x|\,\rho \}\) is defined as \(\exists z(F[z/y]\wedge G[z/x]):\{x|\,\varphi \}\rightarrow \{x|\,\rho \}\);

  6. 6.

    The identity arrow for \(\{x|\,\varphi \}\) is the arrow \(\varphi \wedge x=y\).

The following proposition shows some sufficient conditions which guarantee the category of definable classes of a first-order theory with equality to be finitely complete. The proof is omitted since it consists simply of a verification.

Proposition 3.1

Let \({\mathsf {T}}\) be a first-order theory with equality.

  1. 1.

    If \(\tau \) is a formula with at most x as free variable such that \({\mathsf {T}}\vdash \exists ! x\,\tau \), then \(\{x|\,\tau \}\) is a terminal object in \({\mathbb {DC}}[{\mathsf {T}}]\). In particular, if the language of \({\mathsf {T}}\) has a constant k, then \({\mathbb {DC}}[{\mathsf {T}}]\) has a terminal object.

  2. 2.

    If \(\pi \) is a formula with at most x, y and z as free variables such that

    1. (a)

      \(\pi \wedge \pi [y'/y,z'/z]\vdash _{{\mathsf {T}}}y=y'\wedge z=z'\)

    2. (b)

      \(\pi \wedge \pi [x'/x]\vdash _{{\mathsf {T}}}x=x'\)

    3. (c)

      \({\mathsf {T}}\vdash \exists x\,\pi \)

    then, for every pair of definable classes \(\{x|\,\varphi \}\) and \(\{x|\,\psi \}\), the following is a product diagram in \({\mathbb {DC}}[{\mathsf {T}}]\):

    where

    1. (a)

      \(\pi _1=^{def}\exists z(\pi \wedge \varphi [y/x]\wedge \psi [z/x])\)

    2. (b)

      \(\pi _2=^{def}\exists z(\pi [z/y,y/z]\wedge \varphi [z/x]\wedge \psi [y/x])\)

  3. 3.

    Every pair of parallel arrows \(F,G:\{x|\,\varphi \}\rightarrow \{x|\,\psi \}\) in \({\mathbb {DC}}[{\mathsf {T}}]\) has an equalizer \(\exists y(F\wedge G)\wedge x=y:\{x|\,\exists y(F\wedge G)\}\rightarrow \{x|\,\varphi \}\).

As a consequence of the proposition above, the categories of definable classes of Peano arithmetics \(\mathsf {PA}\) and of Heyting arithmetics \(\mathsf {HA}\) are finitely complete. The same holds for the categories of definable classes of set theories like \(\mathsf {ZFC}\), \(\mathsf {ZF}\), \(\mathsf {IZF}\) and \(\mathsf {CZF}\).

In \({\mathbb {DC}}[\mathsf {PA}]\) and in \({\mathbb {DC}}[\mathsf {HA}]\) a terminal object is given by \(\{x|\,x=0\}\), while in set theories the definable class \(\{x|\,\lnot \exists y(y\in x)\}\) is terminal.

For binary products, in \(\mathsf {HA}\) and in \(\mathsf {PA}\) one can take \(\pi \) to be (a formula representing) \(x=2^y(2z+1)\); in set theories, one can take \(\pi \) to be

$$\begin{aligned}\forall u(u\in x\leftrightarrow (\forall v(v\in u\leftrightarrow (v=y\vee v=z))\vee \forall v(v\in u\leftrightarrow v=y) ))\end{aligned}$$

Definition 3.2

We will call a first-order theory with equality \({\mathsf {T}}\) having formulas \(\tau \) and \(\pi \) satisfying the properties in items 1. and 2. of proposition 3.1 a cartesian first-order theory with equality. Whenever \({\mathsf {T}}\) is a cartesian first-order theory with equality, we assume that the structure of finitely complete category of \({\mathbb {DC}}[\mathcal {T}]\) is the one determined by the constructions in proposition 3.1.Footnote 4

4 First-Order Theories with Natural Numbers

Definition 4.1

Let \({\mathbb {C}}\) be a cartesian category. A parametric natural numbers object is a triple \((\mathsf {N},\mathsf {z},\mathsf {s})\) where \(\mathsf {N}\) is an object, and \(\mathsf {z}:1\rightarrow \mathsf {N}\) and \(\mathsf {s}:\mathsf {N}\rightarrow \mathsf {N}\) are arrows, such that for every pair of objects PQ and every pair of arrows \(f:P\rightarrow Q\) and \(g:Q\rightarrow Q\) there exists a unique arrow \(h:P\times \mathsf {N}\rightarrow Q\) making the following diagram commute:

Remark 4.2

In a cartesian category with a parametric natural numbers object, every primitive recursive function between natural numbers can be represented. Indeed, as a consequence of the definition, for every \(f:\mathsf {N}^{k}\rightarrow \mathsf {N}\) and \(g:\mathsf {N}^{k+2}\rightarrow \mathsf {N}\) there exists a unique arrow \(\mathsf {rec}[f,g]:\mathsf {N}^{k+1}\rightarrow \mathsf {N}\) making the following diagram commute.

Definition 4.3

A first-order theory with equality \({\mathsf {T}}\)has natural numbers if its category of definable classes \({\mathbb {DC}}(\mathcal {T})\) is cartesian and has a parameterized natural numbers object \((\{x|{\mathsf {Nat}}(x)\},Z,S)\) for which S is a mono, and Z and S are disjoint.Footnote 5 In this case, for every natural (meta)number n and every formula \(\varphi \) we define the formula \(\varphi [\underline{n}/x]\) as follows:

  1. 1.

    \(\varphi [\underline{0}/x]\equiv ^{def} \exists y\exists x(Z\wedge \varphi [y/x])\)

  2. 2.

    \(\varphi [\underline{n+1}/x]\equiv ^{def} \exists y(S[\underline{n}/x]\wedge \varphi [y/x])\)

Set theories \(\mathsf {ZFC}, \mathsf {ZF}, \mathsf {IZF}\) and \(\mathsf {CZF}\) have natural numbers: if we consider the terminal object \(\{x|\lnot \exists z(z\in x)\}\), we take

  1. 1.

    \({\mathsf {Nat}}(x)\equiv ^{def}\exists w(\mathsf {Trans}(w)\wedge x\in w\wedge \)

    $$\begin{aligned} \forall y(y\in w\rightarrow (\lnot \exists z(z\in y)\vee \exists z(z\in w\wedge \mathsf {Succ}(z,y)))) \end{aligned}$$

    where

    1. (a)

      \(\mathsf {Trans}(w)\equiv ^{def}\forall y\forall z(y\in z\wedge z\in w\rightarrow y\in w)\)

    2. (b)

      \(\mathsf {Succ}(z,y)\equiv ^{def}\forall u(u\in y\leftrightarrow (u=z\vee u\in z)) \)

  2. 2.

    \(Z\equiv ^{def}\lnot \exists z(z\in x)\wedge x=y\).

  3. 3.

    \(S\equiv ^{def}{\mathsf {Nat}}(x)\wedge \mathsf {Succ}(x,y)\).

The theories of arithmetics \(\mathsf {PA}\) and \(\mathsf {HA}\) have natural numbers: \({\mathsf {Nat}}(x)\equiv ^{{def}}x=x, Z\equiv ^{{def}}x=y\wedge x=0\) and \(S\equiv ^{{def}}y=succ(x)\).

5 Numerical Existence Properties

Definition 5.1

A first-order theory with equality \({\mathsf {T}}\) having natural numbers has the numerical existence property (\(\mathbf {nEP}\)) if, for every formula \(\varphi \) having at most x as free variable such that \({\mathsf {T}}\vdash \exists x\,({\mathsf {Nat}}(x)\wedge \varphi )\), there exists a natural (meta)number n such that \({\mathsf {T}}\vdash \varphi [\underline{n}/x]\).

Numerical existence property \(\mathbf {nEP}\) essentially means that if a natural number satisfying a property is proven to exist in \({\mathsf {T}}\), then a natural (meta)number can be proven to satisfy that property in \({\mathsf {T}}\).

Peano arithmetic \(\mathsf {PA}\), Zermelo–Fraenkel set theory \(\mathsf {ZF}\) and, in general, classical first-order theories with equality of numbers or sets (if consistent) do not have the numerical existence property. Indeed one can consider an independent sentence I (which exists by Gödel’s first incompleteness theorem): clearly \({\mathsf {T}}\vdash \exists x((x=\underline{0}\wedge \lnot I)\vee (x=\underline{1}\wedge I))\) as a consequence of the law of excluded middle; however there cannot be a numeral \(\underline{n}\) such that \({\mathsf {T}}\vdash (\underline{n}=\underline{0}\wedge \lnot I)\vee (\underline{n}=\underline{1}\wedge I)\), since in that case \(\underline{n}\) would be \(\underline{0}\) or \(\underline{1}\) and we could hence prove \(\lnot I\) or I in \({\mathsf {T}}\).

Heyting arithmetic \(\mathsf {HA}\) has the numerical existence property: this was proven by means of realizability by Kleene (see [4]). \(\mathsf {CZF}\) and \(\mathsf {IZF}\) also have the numerical existence property, as it was proven by Rathjen in [6] and Beeson in [1], respectively.

6 Internalizing Definable Classes

Every cartesian first-order theory with equality \({\mathsf {T}}\) having natural numbers enjoys a primitive recursive Gödelian internal encoding of its syntax by means of natural numbers. We fix such an encoding. We also use, with abuse of notation, symbols for primitive recursive functions between natural numbers (including a primitive recursive bijective encoding of natural numbers \(\mathsf {p}\) with primitive recursive projections \(\mathsf {p}_{1}\) and \(\mathsf {p}_{2}\)), since they can be adequately represented in \({\mathsf {T}}\). In particular,

  1. 1.

    Every variable \(\xi \) in the syntax of \({\mathsf {T}}\) is encoded by a numeral \(\underline{\xi }\);

  2. 2.

    We use the notation \(\widehat{\cdot }\) for the encodings of connectives, quantifiers and equality as primitive recursive functions;

  3. 3.

    We use \(\mathsf {sub}(x,y,z)\) to denote the code of the formula encoded by x in which the variable encoded by z is substituted by the variable encoded by y;

  4. 4.

    There is a predicate \(\mathsf {form}(x)\) expressing the fact that x is the code of a formula of \({\mathsf {T}}\);

  5. 5.

    There is a predicate \(\mathsf {free}(y,x)\) expressing the fact that y is the code of a variable which is free in the formula encoded by x;

  6. 6.

    There is a predicate \(\mathsf {pf}(u,x,y)\) expressing the fact that u is the code of a proof in \({\mathsf {T}}\) of the formula encoded by y from the assumption encoded by x;

  7. 7.

    There is a predicate \(\mathsf {notocc}(x,y)\) expressing the fact that the variable encoded by x does not occur in the formula encoded by y.

  8. 8.

    We write \(\mathsf {der}(x,y)\) as an abbreviation for \(\exists u(\mathsf {pf}(u,x,y))\).

One can hence define some formulas which will be helpful in the following sections:

  1. 1.

    We define the formula \(\mathsf {dc}(x)\) as

    $$\begin{aligned}\mathsf {form}(x)\wedge \forall y(\mathsf {free}(y,x)\rightarrow y=\underline{x})\wedge \mathsf {notoccur}(\underline{y},x)\wedge \mathsf {notoccur}(\underline{z},x)\end{aligned}$$

    which expresses the fact that x is the code of a formula of \({\mathsf {T}}\) having at most x as free variable. Here and in what follows we will use the formula \(\mathsf {notoccur}\) to avoid problems with substitutions.

  2. 2.

    We define \(\Delta \Gamma _{0}[{\mathsf {T}}]:=\{x|\,\mathsf {dc}(x)\}\), which is an object of \({\mathbb {DC}}[{\mathsf {T}}]\).

  3. 3.

    We define the formula \(x\equiv _{0}y\) as \(\mathsf {dc}(x)\wedge \mathsf {dc}(y)\wedge \mathsf {der}(x,y)\wedge \mathsf {der}(y,x)\).

  4. 4.

    We define the formula \(\mathsf {fr}(x)\) as follows

    $$\begin{aligned}\mathsf {form}(x)\wedge \forall z(\mathsf {free}(z,x)\rightarrow z=\underline{x}\vee z=\underline{y})\wedge \\ \mathsf {notoccur}(\underline{z},x) \wedge \mathsf {der}(x\widehat{\wedge }\mathsf {sub}(x,\underline{z},\underline{y}),\underline{y}\widehat{=}\underline{z} ) \end{aligned}$$

    expressing the fact that x is the code of a definable functional relation.

  5. 5.

    In order to encode the collection of arrows of \({\mathbb {DC}}[{\mathsf {T}}]\), we need to take track of their codomains (which cannot be reconstructed otherwise). We hence consider the collection

    $$\begin{aligned}\Delta \Gamma _{1}[{\mathsf {T}}]:=\{x|\,\exists y\exists z(x=\mathsf {p}(y,z)\wedge \mathsf {fr}(y)\wedge \mathsf {dc}(z)\wedge \mathsf {der}(y,\mathsf {sub}(z,\underline{y},\underline{x})))\}\end{aligned}$$
  6. 6.

    The formula \(x\equiv _1 y\), defined as follows, expresses the equivalence relation of elements \(x\,\varepsilon \,\Delta {\Gamma _{1}}[{\mathsf {T}}]\):

    $$\begin{aligned}x\,\varepsilon \,\Delta {\Gamma _{1}}[{\mathsf {T}}]\wedge y\,\varepsilon \,\Delta {\Gamma _{1}}[{\mathsf {T}}]\wedge \mathsf {p}_1(x)\equiv _0\mathsf {p}_1(y)\wedge \mathsf {p}_2(x)\equiv _0\mathsf {p}_2(y)\end{aligned}$$
  7. 7.

    We define a domain relation \({\delta _{0}}(x,y)\) as \(x\,\varepsilon \,\Delta \Gamma _{1}[{\mathsf {T}}]\wedge y=\widehat{\exists } \underline{y}(\mathsf {p}_{1}(x))\);

  8. 8.

    We define a codomain relation \({\delta _{1}}(x,y)\) as \(x\,\varepsilon \,\Delta \Gamma _{1}[{\mathsf {T}}]\wedge y=\mathsf {p}_2(x)\);

  9. 9.

    We define an identity relation \(\mathsf {ID}(x,y)\) as \(x\,\varepsilon \,\Delta \Gamma _{0}[{\mathsf {T}}]\wedge y=x\widehat{\wedge }(\underline{x}\widehat{=}\underline{y})\);

  10. 10.

    We define a composition relation \(\Box (x,y)\) as follows:

    $$\begin{aligned}&\displaystyle \mathsf {p}_1(x)\,\varepsilon \,\Delta {\Gamma _{1}}[{\mathsf {T}}]\wedge \mathsf {p}_2(x)\,\varepsilon \,\Delta {\Gamma _{1}}[{\mathsf {T}}] \nonumber \\&\displaystyle \Lambda \exists z \exists u (\delta _1 (p_1(x), z) \Lambda \delta _0 (p_2(x),u) \Lambda z\equiv _0 u )\nonumber \\&\displaystyle \wedge \,\mathsf {p}_1(y)=\widehat{\exists }\underline{z}(\mathsf {sub}(\mathsf {p}_1(\mathsf {p}_1(x)),\underline{z},\underline{y})\widehat{\wedge }\mathsf {sub}(\mathsf {p}_1(\mathsf {p}_2(x)),\underline{z},\underline{x}))\wedge \mathsf {p}_2(y)=\mathsf {p}_2(\mathsf {p}_2(x))\nonumber \\ \end{aligned}$$

7 An Example of Category with a Weak Internal Copy

Exploiting the fact that in a category of definable classes \({\mathbb {DC}}[{\mathsf {T}}]\) of a first-order theory with equality, every mono \(I\rightarrow \{x|\,\varphi \}\) is isomorphic to one of the form \(\psi \wedge x=y:\{x|\psi \}\rightarrow \{x|\,\varphi \}\), one can prove the following proposition.

Proposition 7.1

Let \({\mathsf {T}}\) be a first-order theory with equality. The doctrine of subobjects of \({\mathbb {DC}}[{\mathsf {T}}]\) is naturally isomorphic to the first-order hyperdoctrine \(\mathbf {LT}_{{\mathsf {T}}}\) on \({\mathbb {DC}}[{\mathsf {T}}]\) defined as follows:

  1. 1.

    For every object \(\{x|\,\varphi \}\) of \({\mathbb {DC}}[{\mathsf {T}}]\), \(\mathbf {LT}_{{\mathsf {T}}}(\{x|\,\varphi \})\) contains all the formulas \(\psi \) of \({\mathsf {T}}\) having at most x as free variable such that \(\psi \vdash _{{\mathsf {T}}}\varphi \); these formulas are identified when they are provable to be equivalent in \({\mathsf {T}}\) and they are ordered by \(\vdash _{{\mathsf {T}}}\);

  2. 2.

    For every arrow \(F:\{x|\,\varphi \}\rightarrow \{x|\,\psi \}\) of \({\mathbb {DC}}[{\mathsf {T}}]\) and every \(\rho \) in \(\mathbf {LT}_{{\mathsf {T}}}(\{x|\,\psi \})\), \(\mathbf {LT}_{{\mathsf {T}}}(F)(\rho )\equiv ^{def} \exists y(F\wedge \rho [y/x])\).

Proof

Each subobject \([J:\{x|\,\psi \}\rightarrow \{x|\,\varphi \}]\) of \(\{x|\,\varphi \}\) is sent to \(\exists y\,J[y/x,x/y]\) in \(\mathbf {LT}_{{\mathsf {T}}}(\{x|\,\varphi \})\), while, conversely, each \(\rho \) in \(\mathbf {LT}_{{\mathsf {T}}}(\{x|\,\varphi \})\) is sent to the subobject determined by the mono \(\rho \wedge x=y:\{x|\,\rho \}\rightarrow \{x|\,\varphi \}\). These functions are well-defined and determine a natural isomorphism between \(\mathbf {Sub}_{{\mathbb {DC}}[{\mathsf {T}}]}\) and \(\mathbf {LT}_{{\mathsf {T}}}\). \(\square \)

Corollary 7.2

Let \({\mathsf {T}}\) be a cartesian first-order theory with equality. The category \(\mathcal {Q}_{\mathbf {Sub}_{{\mathbb {DC}}[{\mathsf {T}}]}}\) is isomorphic to the category \({\mathbb {DC}}_q[{\mathsf {T}}]\) of which the objects are pairs \((\{x|\varphi \}, R)\) in which \(\{x|\varphi \}\) is an object of \({\mathbb {DC}}_q[{\mathsf {T}}]\) and R is a formula of \({\mathsf {T}}\) having at most xy as free variables which is a definable equivalence relationFootnote 6 on the class \(\{x|\varphi \}\) (we identify objects of which the equivalence relations can be proven to be equivalent in \({\mathsf {T}}\)); and of which an arrow from \((\{x|\varphi \}, R)\) to \((\{x|\psi \}, S)\) is an equivalence class of arrows F from \(\{x|\varphi \}\) to \(\{x|\psi \}\) in \({\mathbb {DC}}[{\mathsf {T}}]\) such that \(F\wedge F[x'/x,y'/y]\wedge R[x'/y]\vdash _{\mathsf {T}}S[y/x,y'/y]\) with respect to the equivalence relation for which two such arrows are equivalent if and only if \(F\wedge G[x'/x,y'/y]\wedge R[x'/y]\vdash _{\mathsf {T}}S[y/x,y'/y]\).

Proof

From proposition 7.1, it follows that \(\mathcal {Q}_{\mathbf {Sub}_{{\mathbb {DC}}[{\mathsf {T}}]}}\) is isomorphic to \(\mathcal {Q}_{\mathbf {LT}_{{\mathsf {T}}}}\). Moreover, since \({\mathsf {T}}\) is cartesian, one can define an isomorphism from \(\mathcal {Q}_{\mathbf {LT}_{{\mathsf {T}}}}\) to \({\mathbb {DC}}_q[{\mathsf {T}}]\) by sending each of its objects \((\{x|\, \varphi \},\rho )\) to

$$\begin{aligned}(\{x|\, \varphi \},\exists z(\pi [z/x,x/y,y/z]\wedge \rho [z/x]))\end{aligned}$$

and each arrow F to itself. \(\square \)

The category \({\mathbb {DC}}_q\)[T] is finitely complete and from the very definition of the abbreviations in the previous section, the following proposition holds.

Proposition 7.3

Let \({\mathsf {T}}\) be a cartesian first-order theory with equality and natural numbers. The sestuple

$$\begin{aligned}((\Delta {\Gamma _{0}}[{\mathsf {T}}],x\equiv _0 y),(\Delta {\Gamma _{1}}[{\mathsf {T}}],x \equiv _1 y),[{\delta _{0}}(x,y)],[{\delta _{1}}(x,y)],[\mathsf {ID}(x,y)],[\Box (x,y)])\end{aligned}$$

is an internal category in \({\mathbb {DC}}_q[{\mathsf {T}}]\) which we will denote with \(\Delta \Gamma [{\mathsf {T}}]\), provided that we take as pullback of \([\delta _1(x,y)]\) and \([\delta _0(x,y)]\) the definable class defined by the formula consisting of the first two lines in item 10. in the previous section together with the equivalence relation induced by \(\equiv _1\) on first and on second components, with the projections determined by \({\mathsf {p}}_1\) and \({\mathsf {p}}_2\).

Theorem 7.4

Every category of definable classes of a cartesian first-order theory \({\mathsf {T}}\) with equality and natural numbers having the numerical existence property has a weak internal copy.

Proof

We can assume \({\mathsf {T}}\) to be consistent, since otherwise the thesis trivially holds.

As a consequence of the corollary above, it is sufficient to prove that \({\mathsf {Ext}}_{{\mathbb {DC}}_q[{\mathsf {T}}]}(\Delta \Gamma [{\mathsf {T}}])\) is isomorphic to \({\mathbb {DC}}[{\mathsf {T}}]\). If we denote with \(\widehat{\varphi }\) the natural (meta)number encoding the formula \(\varphi \) in the Gödelian encoding we considered, we obtain a functor \(\mathbf {J}\) from \({\mathbb {DC}}[{\mathsf {T}}]\) to \({\mathsf {Ext}}_{{\mathbb {DC}}_q[{\mathsf {T}}]}(\Delta \Gamma [{\mathsf {T}}])\) by sending

  1. 1.

    Each object \(\{x|\varphi \}\) to \([\tau \wedge y=\underline{\widehat{\varphi }}]\in {\mathsf {Hom}}_{{\mathbb {DC}}_q[{\mathsf {T}}]}(1,(\Delta {\Gamma _{0}}[{\mathsf {T}}],x\equiv _{0}y))\)

  2. 2.

    Each arrow F from \(\{x|\varphi \}\) to \(\{x|\psi \}\) to

    $$\begin{aligned} \left[ \tau \wedge y=\mathsf {p}(\underline{\widehat{F}},\underline{\widehat{\psi }})\right] \in {\mathsf {Hom}}_{{\mathbb {DC}}_q[{\mathsf {T}}]}(1,(\Delta {\Gamma _{1}}[{\mathsf {T}}],x\equiv _{1}y) \end{aligned}$$

Conversely, we define a functor from \({\mathsf {Ext}}_{{\mathbb {DC}}_q[{\mathsf {T}}]}(\Delta \Gamma [{\mathsf {T}}])\) to \({\mathbb {DC}}[{\mathsf {T}}]\) as follows.

  1. 1.

    If \([F]\in {\mathsf {Hom}}_{{\mathbb {DC}}_q[{\mathsf {T}}]}(1,(\Delta {\Gamma _{0}}[{\mathsf {T}}],\equiv _{0}))\), then \({\mathsf {T}}\vdash \exists ! y \exists x F\) and \(F\vdash _{ {\mathsf {T}}}{\mathsf {Nat}}(y)\). Thus, by \(\mathbf {nEP}\) there exists a natural (meta)number n such that \({\mathsf {T}}\vdash \exists x F[\underline{n}/y]\). Decoding n one can construct a formula \(\varphi _n\) such that \(\widehat{\varphi _n}\) is n. The definable class \(\{x|\,\varphi _n\}\) is the object to which [F] is sent. This application is well-defined, since if F and G represent the same arrow from 1 to \((\Delta {\Gamma _{0}}[{\mathsf {T}}],\equiv _{0})\) in \({\mathbb {DC}}_q[{\mathsf {T}}]\), and n and m are natural (meta)numbers such that \({\mathsf {T}}\vdash \exists x F[\underline{n}/y]\) and \({\mathsf {T}}\vdash \exists x G[\underline{m}/y]\), then \({\mathsf {T}}\vdash \exists u\,\mathsf {pf}(u,\underline{n},\underline{m})\) and \({\mathsf {T}}\vdash \exists u\,\mathsf {pf}(u,\underline{m},\underline{n})\); hence using \(\mathbf {nEP}\) we can find natural (meta)numbers k and h such that \({\mathsf {T}}\vdash \mathsf {pf}(\underline{k},\underline{n},\underline{m})\) and \({\mathsf {T}}\vdash \mathsf {pf}(\underline{h},\underline{m},\underline{n})\). Decoding k and h we obtain actual proofs of \(\varphi _n\vdash _{{\mathsf {T}}}\varphi _m\) and of \(\varphi _m\vdash _{{\mathsf {T}}}\varphi _n\).

  2. 2.

    We use an analogous procedure to define the functor on arrows, exploiting \(\mathbf {nEP}\).

These two functors determine an isomorphism of categories. \(\square \)

8 The Classical Case

In case of cartesian classical first-order theories with equality and natural numbers one can define some quotients in \({\mathbb {DC}}[{\mathsf {T}}]\) using the minimum principle which holds for natural numbers:

Proposition 8.1

If \({\mathsf {T}}\) is a classical first-order theory with equality and natural numbers, then the full subcategory \({\mathbb {DC}}^{Nat}[{\mathsf {T}}]\) of \({\mathbb {DC}}[{\mathsf {T}}]\) of which the objects are those of the form \(\{x|\,\varphi \}\) with \(\varphi \vdash _{\mathsf {T}}{\mathsf {Nat}}(x)\) is equivalent to the full subcategory \({\mathbb {DC}}_q^{Nat}[{\mathsf {T}}]\) of \({\mathbb {DC}}_q[{\mathsf {T}}]\) of which the objects are those of the form \(\left( \{x|\,\varphi \},R\right) \) with \(\varphi \vdash _{\mathsf {T}}{\mathsf {Nat}}(x)\).

Proof

One just have to exploit the fact that in \({\mathsf {T}}\) the minimum principle for natural numbers holds. We define a functor \(\mathbf {Q}: {\mathbb {DC}}_q^{Nat}[{\mathsf {T}}]\rightarrow {\mathbb {DC}}[{\mathsf {T}}]\) as follows:

  1. 1.

    Every object \((\{x|\,\varphi \},R)\) in \({\mathbb {DC}}_q^{Nat}[{\mathsf {T}}]\) is sent toFootnote 7

    $$\begin{aligned}\mathbf {Q}(\{x|\,\varphi \},R):=\{x|\,\varphi (x)\wedge \forall y(R\rightarrow x\le y)\} \end{aligned}$$
  2. 2.

    Every arrow \([F]:(\{x|\,\varphi \},R)\rightarrow (\{x|\,\psi \},S)\) is sent to the arrow

    $$\begin{aligned}x\,\varepsilon \,\mathbf {Q}(\{x|\,\varphi \},R)\wedge y\,\varepsilon \,\mathbf {Q}(\{x|\,\psi \},S)\wedge \forall y'(F[y'/y]\rightarrow S[y/x,y'/y]).\end{aligned}$$

Conversely, we can define a functor \(\mathbf {Q}':{\mathbb {DC}}^{Nat}[{\mathsf {T}}]\rightarrow {\mathbb {DC}}_q[{\mathsf {T}}]\) as follows: every object \(\{x|\,\varphi \}\) in \({\mathbb {DC}}^{Nat}[{\mathsf {T}}]\) is sent to \((\{x|\,\varphi \},\varphi \wedge x=y)\) and every arrow F is sent to [F].

This pair of functors gives rise to an equivalence of categories. \(\square \)

In this case a functor \(\mathbf {J}\) can still be defined from \({\mathbb {DC}}[{\mathsf {T}}]\) to \({\mathsf {Ext}}_{{\mathbb {DC}}_q[{\mathsf {T}}]}(\Delta \Gamma [{\mathsf {T}}])\) exactly as it is done in the first part of the proof of theorem 7.4.

Moreover, since \(\Delta \Gamma [{\mathsf {T}}]\) is defined using only formulas regarding natural numbers, it can be seen as an internal category in \({\mathbb {DC}}_q^{Nat}[{\mathsf {T}}]\).Footnote 8 By proposition 8.1, the category \({\mathbb {DC}}_q^{Nat}[{\mathsf {T}}]\) is equivalent to the full subcategory \({\mathbb {DC}}^{Nat}[{\mathsf {T}}]\) of \({\mathbb {DC}}[{\mathsf {T}}]\). Thus \(\Delta \Gamma [{\mathsf {T}}]\) can be turned into an internal category of \({\mathbb {DC}}[{\mathsf {T}}]\) of which the externalization is isomorphic to \({\mathsf {Ext}}_{{\mathbb {DC}}_q[{\mathsf {T}}]}(\Delta \Gamma [{\mathsf {T}}])\).

This would make this internal category a possible candidate to be an internal copy of \({\mathbb {DC}}[{\mathsf {T}}]\). However, if \({\mathsf {T}}\) is consistent, the lack of the numerical existence property is an obstacle to prove that \(\mathbf {J}\) is an isomorphism. Indeed, we cannot turn a global element of \(\Delta {\Gamma _{0}}\), which gives us a “definable” code for a formula, in a natural (meta)number from which we can construct an actual formula of \({\mathsf {T}}\). Faithfulness of \(\mathbf {J}\) and its injectivity on objects are also obstacled by the lack of the numerical existence property: \({\mathsf {T}}\) could in principle prove the existence of (a code of) a proof of equivalence between two (codes of) formulas \(\varphi \) and \(\psi \), also in cases in which we cannot (meta)prove there is an actual proof for such an equivalence.

9 An Example of Category with an Internal Copy

Theorem 9.1

Let \({\mathsf {T}}\) be a cartesian first-order theory with equality having natural numbers and having the numerical existence property. Then \({\mathbb {DC}}_{q}[{\mathsf {T}}]\) has an internal copy.

Proof

One can modify \(\Delta \Gamma [{\mathsf {T}}]\) and obtain an internal category \(\Delta \Gamma ^q[{\mathsf {T}}]\) by adding the encoding of equivalence relations in the formulas defining the class of (codes for) objects and the conditions about their preservations in the class of (codes for) arrows (together with a track of both domain and codomain), and by adequately modifying the internal equivalence relations on them. Numerical existence property will allow to establish the isomorphism between \({\mathbb {DC}}_{q}[{\mathsf {T}}]\) and \({\mathsf {Ext}}(\Delta \Gamma ^q[{\mathsf {T}}])\)\(\square \)