% !TeX spellcheck = en_US
\documentclass[10pt,a4paper]{article}

\input{./header.tex}

% po4a: environment remark
% po4a: environment tikzpicture
% po4a: environment property

\title{Categorical semantics of the reduction of GATs to two-sorted GATs.
	\\[1ex] \large Notes on my 4.5-month internship at the Laboratoire d'Informatique de l'École Polytechnique (Palaiseau, France)}
\hypersetup{pdftitle={Categorical semantics of the reduction of GATs to two-sorted GATs}}
\author{Samy Avrillon, supervised by
	\\[1ex] Ambroise Lafont (LIX, Palaiseau, France)}

\begin{document}
	\doparttoc
	\maketitle
	
	\hsep
	
	\tableofcontents
	
	\newpage

	\section{Introduction}
	
	A Generalized Algebraic Theory (or GAT), first introduced by Cartmell \cite{CartmellGATs}, is a syntactic specification of an algebraic structure. From a GAT, one can define a category of models describing the models of the algebraic structure.
	A GAT typically starts with a sort specification i.e. a list of sort declarations, which may be followed by a list of constructors.
	In this document, we will not ask ourselves about the specific syntax of GATs. A \enquote{vague} definition is enough to understand the rest of the document.
	
	\paragraph{Sort specification}
	
	A sort specification is a list of \emph{sort declarations}, composed of \emph{parameters} and $\Set$ as their codomain.
	
	We give an example of a sort specification for Type Theory. On the right column we give the interpretation of the sort declarations as components of the models of the GAT.
	
	\vspace{1em}
	\renewcommand\arraystretch{1.5}
	\begin{tabular}{l|p{.5\textwidth}}
	$\Con : \Set$ & A set of contexts $X_\Con$\\
	$\Ty : (\Gamma : \Con) \to \Set$ & For each context $\Gamma \in X_\Con$, a set $X_\Ty(\Gamma)$ of types in this context\\
	$\Tm : (\Delta : \Con) \to (A : \Ty\;\Delta) \to \Set$ & For each context $\Gamma \in X_\Con$ and each type $A \in X_\Ty(\Gamma)$ in this context, a set $X_\Tm(\Gamma,A)$ of terms of this type.
	\end{tabular}
	\vspace{1em}
	
	A sort specification therefore specifies the differents families of sets contained in a model, and how they relate to each other in terms of indexing.
	
	\paragraph{Term specification}
	Once we have a sort specification, we can add constructors to it in order to make a complete GAT. Constructors are composed of parameters (the same kind as for sort declarations) and of a codomain which is a sort defined by a previous sort declaration. Those constructors specify elements of the sets contained in the model.
	For example, to the previous sort specification, one can add the following constructors:
	
	\vspace{1em}
	\renewcommand\arraystretch{1.5}
	\begin{tabular}{p{.37\textwidth}|p{.6\textwidth}}
		$\operatorname{unit} : (\Gamma : \Con) \to \Ty\;\Gamma$ & In any context $\Gamma \in X_\Con$, a type $\operatorname{unit}(\Gamma) \in X_\Ty(\Gamma)$.\\
		
		$\operatorname{tt}: (\Gamma : \Con) \to \Tm\;\Gamma\;(\operatorname{unit}(\Gamma))$ & In any context $\Gamma \in X_\Con$, an element $\operatorname{tt}(\Gamma) \in X_\Tm(\Gamma,\operatorname{unit}(\Gamma))$.
	\end{tabular}
	\vspace{1em}
	
	\paragraph{Two-sortification}
	
	It was observed \cite{AmbrusSzumiXie2sort} that one can transform any GAT into a GAT with only two sorts. Let us present this transformation.
	
	The sort specification of the transformed GAT is always the same, and contains these two sort declarations:
	
	\vspace{1em}
	\begin{tabular}{p{0.37\textwidth}|p{0.5\textwidth}}
		$\UU : \Set$ & The set of sorts \\
		$\El : \mathcal{O} \to \Set$ & For every sort object $o$ in the set of sorts, a set called $\El(o)$ of objects corresponding to the sort object $o$.
	\end{tabular}
	\vspace{1em}
	
	
	
	Then, we replace all occurrences of $\Set$ to $\mathcal{O}$, and we apply $\El$ to every parameter. We write $\underline{o}$ rather than $\El(o)$ in order to ease reading. For example, the GAT of Type Theory presented above becomes that which follows:
	
	\begin{tabular}{p{0.4\textwidth}|p{0.5\textwidth}}
		$\Con : \mathcal{O}$ & One sort object is called \enquote{$\Con$} \\
		$\Ty : (\Gamma : \underline{\Con}) \to \mathcal{O}$ &
		For each object $\Gamma$ corresponding to the sort object $\Con$, another sort object called \enquote{$\Ty\;\Gamma$} \\
		$\Tm : (\Gamma : \underline{\Con}) \to (A : \underline{\Ty\;\Delta}) \to \mathcal{O}$ &
		For each object $\Gamma$ corresponding to the sort object $\Con$,
		and for every object $A$ corresponding to the sort object $\Ty\;\Gamma$, another sort object called \enquote{$\Tm\;\Gamma\;A$}\\
		$\operatorname{unit} : (\Gamma : \underline{\Con}) \to \underline{\Ty\;\Gamma}$ &
		For each object $\Gamma$ corresponding to the sort object $\Con$, an object called "$\operatorname{unit} \Gamma$" corresponding to the sort object $\Ty\;\Gamma$\\
		$\operatorname{tt}: (\Gamma : \underline{\Con}) \to \underline{\Tm\;(\operatorname{unit}\;\Gamma)}$ &
		$\dots$
	\end{tabular}
	
	This process is useful when studying GATs, as it allows to restrict a study to GATs with only two sorts without loss of generality. Filippo Sestini noticed that in his thesis \cite{SestiniPhD}:
	
	\begin{quote}
		Many instances of multi-sorted IITs [IITs are a variant of GATs] can be reduced to equivalent two-sorted IITs, via a systematic reduction method originally observed by Zongpu (Szumi) Xie. We are not aware of a formal proof of this construction for arbitrary IITs, but we conjecture that it does apply to all instances of induction-induction and	consequently that it shows two-sorted IITs are enough to represent any specifiable IIT.
	\end{quote}
	
	\paragraph{Goal}
	
	The goal of my internship was to study and understand the relationship between the categories of models of an original GAT and the category of models of the transformed \enquote{two-sortified} GAT, in order to legitimate this transformation. In this document, we will only study sort specifications (i.e. lists of sort declaration, with no constructors).
	
	We constructed a coreflection between those two categories, whose formal definition is given in \autoref{sec:proofSection}. It consists of an adjunction $F \vdash G$ between the category $\CC$ of the models of the GAT and the category $\BB$ of the models of the two-sortified GAT, where G is full and faithful.
	This coreflection justifies the transformation as the initial object of $\CC$ can be computed as the image by $F$ of the initial object of $\BB$.
	
	The category $\BB$ is equipped with a forgetful functor $R$ to $\BB_0$, the category of models of the two-sort sort specification $(\mathcal{O},\El)$.
	
	\begin{center}
		% YADE DIAGRAM GlobalConstructionSimple.json
		% GENERATED LATEX
		\input{graphs/GlobalConstructionSimple.tex}
		% END OF GENERATED LATEX
	\end{center}
	
	\section{Examples}
	\label{sec:Examples}
	
	Before making the formal proof, we will study our construction on three examples, in order to ease understanding of the formal proof.
	
	\paragraph{Structure of the proof}
	The formal proof will be an induction on the number of sorts taken into account. At each step, we will add a new sort declaration, represented by a functor $H_i$ described later (\autoref{sec:constructingCategory}).
	
	At the $i$-th recursion step, we will build the following objects :
	\begin{itemize}
		\setlength\itemsep{-1ex}
		\item The category of models of the GAT $\CC_i$
		\item The category of models of the transformed GAT $\BB_i$
		\item A functor $F_i : \BB_i \to \CC_i$
		\item A functor $G_i : \CC_i \to \BB_i$
		\item An adjunction between them $F_i \vdash G_i$
		\item A proof that $F_iG_i \cong \Id_{\CC_i}$ (i.e. $F_i \vdash G_i$ make up a coreflection)
	\end{itemize}
	
	We will now present those objects on three specific examples in order to help getting an understanding of the logic behind the formal proof.
	
	\subsection{The empty sort specification}
	
		\label{sec:EmptySortSpec}
	
		Our first example is the empty sort specification. As our proof will we an induction on the number of sorts, its first step will always be creating the objects for this empty sort specification.
		
		\paragraph{Category of models of the empty sort specification}
		
			The category of models of the empty sort specification will simply be $\one$, the category with only one object $\star$ and one trivial morphism (i.e. the terminal category of $\Cat$). This is because the empty sort specification only has one model. We will denote this category as $\CC_0$.
			
		\paragraph{Category of models of the transformed GAT}
			
			The transformed GAT for the empty sort specification is the sort specification $(\mathcal{O},\El)$ (no constructors as there are no sort in the initial sort specification):
			\vspace{.5ex}
			\begin{center}
				\renewcommand\arraystretch{1}
				\begin{tabular}{|l|}
					\hline
					$\UU : \Set$ \\
					$\El : \mathcal{O} \to \Set$ \\
					\hline
				\end{tabular}
			\end{center}
			\vspace{.5ex}
			
			The usual way of defining the category of models of this sort specification is by taking the category of families of sets $\FamSet$, whose objects are pairs of a set $X$ and a family of sets indexed by $X$ : $(Y_x)_{x\in X}$. However, we will rather use another category : $\TSet$, the category of presheaves over the category $\TT$, the category with two objects and one non-trivial arrow between them. The objects and morphism of $\TT$ are described below:
			
			\begin{center}
				% YADE DIAGRAM CategoryTT.json
				% GENERATED LATEX
				\input{graphs/CategoryTT.tex}
				% END OF GENERATED LATEX
			\end{center}
			
			This category is equivalent to the catgegory $\FamSet$ with an equivalence we will see later (\autoref{SetXSetXEquivalence})
			
			With this formalisation, a model of this sort specification is a functor $X : \TT \to \Set$, such that
			\begin{itemize}
				\item $X_\UU$ is the set of the \enquote{sort objects}
				\item For each sort object $A \in X_\UU$, the set of objects corresponding to the sort object is $X_p^{-1}(\{A\}) \subset X_\El$
			\end{itemize}
			
			We will denote this category of models of the empty sort specification as $\BB_0$.
			
		\paragraph{Functors}
			
			We want to show that there is a coreflection between those two categories $\BB_0$ and $\CC_0$ as follows:
			
			\begin{center}
				% YADE DIAGRAM AdjunctionLevel0.json
				% GENERATED LATEX
				\input{graphs/AdjunctionLevel0.tex}
				% END OF GENERATED LATEX
			\end{center}
			
			$F_0 : \TSet \to \one$ is simply the terminal functor of $\Cat$, i.e. the functor sending all objects to $\star$, the only object of $\one$, and all morphisms to $\id_\star$.
			
			$G_0 : \one \to \TSet$ is the functor that sends the only object of $\one$ to the initial object of $\TSet$: $0_\TSet$ (i.e. such that $G_0$ preserves colimits)
			
			We can check that those two functors create an adjunction, as 
			\[
				\Hom(G_0 \star,X) = \Hom(0_\TSet,X) \cong \one \cong \Hom(\star,F_0 X)
			\]
			
			We also have that they create a coreflection, as $F_0G_0$ goes from $\one$ to $\one$, and so $F_0G_0 = \Id_\one$ as $\one$ is terminal in $\Cat$. So $F_0G_0$ is an isofunctor.
			
	\subsection{Type theory example}
		
		We will take as a first example the sort specification of type theory presented in the introduction. The sort specification and its transformation are as follows:
		
		\vspace{1ex}
		\begin{center}
		\renewcommand\arraystretch{1}
		\begin{tabular}{|l|l|}
			\hline
			& $\UU : \Set$ \\
			& $\El : \mathcal{O} \to \Set$ \\
			$\Con : \Set$ & $\Con : \mathcal{O}$\\
			$\Ty : (\Gamma : \Con) \to \Set$ & $\Ty : (\Gamma : \underline{\Con}) \to \mathcal{O}$\\
			$\Tm : (\Delta : \Con) \to (A : \Ty\;\Delta) \to \Set$ & $\Tm : (\Delta : \underline{\Con}) \to (A : \underline{\Ty\;\Delta}) \to \mathcal{O}$ \\
			\hline
		\end{tabular}
		\end{center}
		\vspace{1ex}
		
		We will build the following objects, step by step, adding one sort at a time:
		
		\begin{center}
			% YADE DIAGRAM TypeTheoryConstruction.json
			% GENERATED LATEX
			\input{graphs/TypeTheoryConstruction.tex}
			% END OF GENERATED LATEX
		\end{center}
		
		Where the categories $\CC_i$ are the categories of models of the sort specification limited to the $i$ first sort declarations, and $\BB_i$ are the categories of models of the transformed GAT limited to the $i$ first sort declarations. For example, $\CC_2$ is the category of models of the two first sorts of the sort specification ($\Con$,$\Ty$). $\BB_0$,$\CC_0$,$F_0$, and $G_0$ have been defined in the last subsection.
		
		The $R^i_{i-1}$ functors between the categories are forgetful functors that forgets about the added sorts.
		
		I will only give here the explanation of functors $F_3$ and $G_3$, omitting the intermediate functors $F_1$,$G_1$,$F_2$,$G_2$. Their construction is given in the complete proof.
		
		\paragraph{Category of models}
		
			We have seen in the introduction a description of a model of the type theory sort specification. We will rebuild the category of those models inductively, adding one sort at a time.
			
			In order to construct those categories in a generic way, we will define functors $H_X : \CC_{X-1} \to \Set$ that will describe the \enquote{parameters} of the sort declaration.
			
			\[
			\boxed{\Con : \Set}
			\]
			We begin with the following functor, corresponding to the sort declaration above
			\[
				H_\Con(\star) = 1 \in \Set
			\]
			
			This functor means that $\Con$ takes no parameter i.e. there is only \emph{one} way of constructing a $\Con$.
			
			We build $\CC_1$ to be a pair of 
			\begin{itemize}
				\item An object $X_0$ of $\CC_0$
				\item A family of sets $X_\Con$ indexed by $H_\Con(x) = 1$
			\end{itemize}
			
			As there is only one object in $\CC_0$ and that a family of sets indexed by $1$ is simply a set, we have that this category $\CC_1$ is isomorphic to $\Set$ (i.e. the category of sets).
			This is as expected: a model $X$ consists of a set $X_\Con$.
			
			\[
			\boxed{\Ty : (\Gamma : \Con) \to \Set}
			\]
			
			Then, we take the functor $H_2(X) = X_\Con$, corresponding to the sort declaration above. This functor means that $\Ty$ takes one parameter of type $\Con$ i.e. There is exactly one $\Ty$ sort for every $\Con$ there is in the model.
			
			Again, we build $\CC_\Ty$ to be a pair of
			\begin{itemize}
				\item A model $X_\Con$ from $\CC_1$
				\item A family of sets $X_\Ty$ indexed by $H_\Ty(X_\Con) = X_\Con$
			\end{itemize}
			
			This category is, as expected, the category $\FamSet$ of families of sets i.e. objects are pairs of a set $X_\Con$ and of a family indexed by $X_\Con$: $(X_\Ty(\Gamma))_{\Gamma\in X_\Con}$.
			
			\[
				\boxed{\Tm : (\Delta : \Con) \to (A : \Ty\;\Delta) \to \Set}
			\]
			
			The functor $\CC_2 \to \Set$ we will use here is defined as follows:
			\[
				H_\Tm(X_\Con,X_\Ty) = \coprod_{\Delta \in \Con}X_\Ty(\Delta) \in \Set
			\]
			
			$\coprod$ denotes the coproduct or disjoint union in $\Set$. This functor means that $\Tm$ takes one parameter $\Delta$ of sort $\Con$ and one parameter of sort $\Ty\;\Delta$, i.e. there is exactly one $\Tm$ for every pair of a $\Con$ called $\Delta$ in the model, and of a $\Ty$ associated to $\Delta$ in the model.
			
			We build $\CC_3$ to be a pair of
			\begin{itemize}
				\item A model $(X_\Con,X_\Ty)$ from $\CC_2$
				\item A family of sets $X_\Tm$ indexed by $H_\Tm(\Con)$
			\end{itemize}
			
			This category is isomorphic to the category composed of triples of
			\begin{itemize}
				\item A set $X_\Con$
				\item A family of sets indexed by $X_\Con$ : $\left(X_\Ty(\Gamma)\right)_{\Gamma \in X_\Con}$
				\item A family of sets indexed by $(\Delta : X_\Con)$ and $X_\Ty(\Delta)$ :
				$\left(\left(X_\Tm(\Delta,A)\right)_{A \in X_\Ty(\Delta)}\right)_{\Delta \in X_\Con}$
			\end{itemize}
			
		\paragraph{Category of models of the transformed GAT}
		
			We have also seen in the introduction how was constructed the category of models of the transformed GAT. We will reconstruct it sort by sort.
			
			\[
				\boxed{\begin{array}{c}
					\mathcal{O} : \Set \\
					\El : \mathcal{O} \to \Set
				\end{array}}
			\]
			
			We have seen in previous subsection that the category of models of this GAT is $\BB_0 = \TSet$. We will only add new \emph{constructors} to these models, and no new sorts.
			
			\[
				\boxed{\Con : \mathcal{O}}
			\]
			
			We are adding a constructor to the model. This constructor takes no parameters, which means we want to select one sort out of our model to be the $\Con$ sort. And we recall that the sorts of a model $X : \TSet$ are the elements of $X_\UU$.
			
			Therefore a model of the above GAT with only one constructor is a model $X : \TSet$ along with an object $\Cstr^X_\Con \in X_\UU$. An object of $\BB_1$ is a pair of
			\begin{itemize}
				\item A functor $X : \TT \to \Set$
				\item An element $\Cstr^X_\Con \in X_\UU$
			\end{itemize}
			
			A morphism $f$ from $(X,\Cstr^X_\Con)$ to $(X',\Cstr^{X'}_\Con)$ is simply a morphism of $\TSet$ from $X$ to $X'$ that respects the constructor, i.e. that is such that
			\[
				f_\UU(\Cstr^X_\Con) = \Cstr^{X'}_\Con
			\]
			
			\[
				\boxed{\Ty : \underline{\Con} \to \mathcal{O}}
			\]
			
			Now the constructor we are adding takes one parameter. It means that for every element of $\El$ associated with $\Con$, there is an object in $\mathcal{O}$.
			
			This constructor translates into an object
			\[
				\Cstr^X_\Ty : X_p^{-1}(\Cstr^X_\Con) \to X_\UU
			\]
			
			The codomain of this constructor means \enquote{Every object of $X_\El$ that are associated to the $\Con$ object of $X_\UU$ i.e. the object $\Cstr^X_\Con$}
			This codomain is quite verbose, but we have another way of expressing it. In the final proof, we will have already constructed the functor $F_1 : \BB_1 \to \CC_1$, and we had a functor $H_\Ty : \CC_1 \to \Set$ that described the parameters of the sort declaration of $\Ty$ for the category $\CC_1$. It turns out that $H_\Ty \circ F_1 : \BB_1 \to \Set$ describes exactly the codomain expressed above.
			\[
				(H_\Ty \circ F_1) (X,\Cstr^X_\Con) = X_p^{-1}\left(\Cstr^X_\Con\right)
			\]
			
			The fact that $H_X \circ F_{X-1}$ describes exactly the codomain of the constructor we want to add will hold for every sort declaration we can add.
			
			Therefore, the category $\BB_2$ consists of a pair of
			\begin{itemize}
				\item A model $(X,\Cstr^X_\Con)$ from $\BB_1$
				\item A constructor $\Cstr^X_\Ty : H_iF_{i-1}(X,\Cstr^X_\Con) \to X_\UU$
			\end{itemize}
			
			One again, a morphism $f$ from $(X,\Cstr^X_\Con,\Cstr^X_\Ty)$ to $(X',\Cstr^{X'}_\Con,\Cstr^{X'}_\Ty)$ is simply a morphism of $\BB_1$ from $(X,\Cstr^X_\Con)$ to $(X',\Cstr^{X'}_\Con)$ that does respect the $\Cstr_\Ty$ constructor, i.e. that verifies, for every $\Gamma$ in $H_iF_{i-1}(X,\Cstr^X_\Con)$ that
			\[
				f_\UU(\Cstr^X_\Ty(\Gamma)) = \Cstr^{X'}_\Ty(f_\El(\Gamma))
			\]
			
			\[
				\boxed{\Tm : (\Delta : \underline{\Con}) \to (A : \underline{\Ty\;\Delta}) \to \mathcal{O}}
			\]
			
			This one is made like the others, a model of $\BB_3$ is a pair of
			\begin{itemize}
				\item A model $(X,\Cstr^X_\Con,\Cstr^X_\Ty)$ of $\BB_2$
				\item A constructor $\Cstr^X_\Tm$ that goes from $H_\Tm F_2 X$ to $X_\UU$
			\end{itemize}
			
			And morphism are restricted with the $\Tm$ constructor rule that states that for every $(\Delta,A)$ in $H_iF_{i-1}(X,\Cstr^X_\Con,\Cstr^X_\Ty)$
			\[
				f_\UU(\Cstr^X_\Tm(\Delta,A)) = \Cstr^{X'}_\Tm(f_\El(\Delta),f_\El(A))
			\]
			
		\paragraph{Constructing $G_3$}
		
			We want to make functors connecting those two categories
			\[
				\begin{array}{l|l}
					Y : \mathbf{\CC_3} & X : \mathbf{\BB_3} \\\hline
					& X : \TSet\\
					Y_\Con : \Set & \Cstr^X_\Con : X_\UU \\
					\left(Y_\Ty(\Gamma)\right)_{\Gamma \in Y_\Con} &
					\Cstr^X_\Ty : H_\Ty F_{1} (X,\Cstr^X_\Con) \to X_\UU \\
					\left(\left(Y_\Tm(\Delta,A)\right)_{A \in Y_\Ty(\Delta)}\right)_{\Delta \in Y_\Con} &
					\Cstr^X_\Tm : H_\Tm F_{2} (X,\Cstr^X_\Con,\Cstr^X_\Ty) \to X_\UU \\
				\end{array}
			\]
			
			Let's first look at the first component of the «result» $X = G_3(Y)$. It will be a functor of $\TSet$. We recall how $\TSet$ corresponds to the sort specification $(\mathcal{O},\El)$:
			\begin{itemize}
				\item $X_\UU$ is the set of all sorts
				\item $X_\El$ is the set of all objects of those sorts
				\item $X_p$ sends an object of a sort to the sort it corresponds to
			\end{itemize}
			
			Therefore, we will construct $X_\UU$ to be the disjoint union of all the indices of the sets inside $Y$, $X_\El$ will be the disjoint union of all the sets inside $Y$, and $X_p$ will keep track of what is the index of a set.
			
			\[\begin{array}{ccccccc}
				
				X_\El & = &
				Y_\Con & \oplus &
				\displaystyle\coprod_{\Gamma \in Y_\Con}Y_\Ty(\Gamma) & \oplus &
				\displaystyle\coprod_{\Delta \in Y_\Con}\coprod_{A \in Y_\Ty(\Delta)}Y_\Ty(\Delta,A) \\
				\labeledupdownarrow{p}&&\labeledupdownarrow{}&&\labeledupdownarrow{\operatorname{proj}_1}&&\labeledupdownarrow{\operatorname{proj}_{2,1}}\\
				X_\UU & = &
				1 & \oplus &
				Y_\Con & \oplus&
				\displaystyle\coprod_{\Delta \in Y_\Con}Y_\Ty(\Delta)
			\end{array}\]
			where $\operatorname{proj}_1 : \coprod_{a\in A}B(a) \to A$ is the first projector of the coproduct, and $\operatorname{proj}_{2,1}$ get the index $ \coprod_{a \in A}B(a)$ of a double coproduct $\coprod_{a \in A}\coprod_{b\in B(a)} C(a,b)$
			\vspace{.2ex}
			
			Now, the constructors only have to give the right sort according to their arguments. So
			\[\begin{array}{lcl}
				\Cstr^X_\Con &=& \inj_1(\star)\\
				\Cstr^X_\Ty(\Gamma) &=& \inj_2(\Gamma) \\
				\Cstr^X_\Tm(\Delta,A) &=& \inj_3(\Delta,A)
			\end{array}\]
			
			where $\inj_i$ is the $i$-th injector of the direct sum $\oplus$.
			
			\begin{remark}
				With this functor, every element of $X_\UU$ is reached by some constructor. And therefore, every object of $X_\El$ points to a sort that is reached by some constructor.
			\end{remark}
			
			\todo{Parler des morphismes ? Est-ce nécessaire ?}
			
		\paragraph{Constructing $F_i$}
			
			We will now create an object $Y = F_i X$ of $\CC_3$ from an object $X$ of $\BB_3$.
			
			\begin{itemize}
				\item $Y_\Con$ should be the set of all objects of sort $\Con$. In the transformed GAT, it means all objects of $\El$ which have been created with the sort $\Cstr^X_\Con$. Therefore we have
				\[
					Y_\Con = X_p^{-1}(\left\{\Cstr^X_\Con\right\}) \subseteq X_\El
				\]
				\item $Y_\Ty(\Gamma)$ should be the set of all objects of sort $\Ty\;\Gamma$, which means all objects of $\El$ which have been created with the sort $\Cstr^X_\Ty(\Gamma)$. Therefore we have, for every $\Gamma$ in $Y_\Con$
				\[
					Y_\Ty(\Gamma) = X_p^{-1}(\{\Cstr^X_\Ty(\Gamma)\})
				\]
				This is well-defined, as
				\[
					\Gamma : Y_\Con = X(p)^{-1}(\{\Cstr^X_\Con\}) = H_\Ty(X(p)^{-1}(\{\Cstr^X_\Con\})) = H_\Ty F_1(X,\Cstr^X_\Con)
				\]
				\item In the same way, we define
				\[
					Y_\Tm(\Delta,A) = X_p^{-1}(\Cstr^X_\Tm(\Delta,A))
				\]
				which is also well-defined
			\end{itemize}
			
			\begin{remark}
				We can see that the $F_3$ functor does not take into account elements of $X_\UU$ that are not \enquote{created} by one of the constructors, nor does it take into account the elements of $X_\El$ that are associated with those elements of $X_\UU$.
				
				This will later justify that when one adds elements to the base object $X$ of a model of $\BB_i$, then the image model by $F_i$ is unchanged, i.e. $F_i \inj_\tl^i$ is an isomorphism.
			\end{remark}
			
		\paragraph{An adjunction}
			
			I will not do the proof that $F_3 \vdash G_3$, but i will give moral reasons of why the adjunction holds.
			
			An adjunction would be described by the following isomorphism:
			\[
				\Hom_{\BB_3}\left(G_3Y,X\right) \simeq \Hom_{\CC_3}\left(Y,F_3X\right)
			\]
			
			Recall that sorts of $G_3Y$ are all in the domain of some constructor, so therefore, a morphism of $\Hom_{\BB_3}(G_3Y,X)$ only acts on constructible sorts.
			Also, the only sorts that remain in $F_3X$ are the one that were reached by some constructor of $X$, therefore a morphism of $\Hom_{\CC_3}(Y,F_3X)$ only acts on constructible sorts.
			
			Therefore, both morphism are only descriptions of actions on constructible sorts into constructible sorts. That's how we create the isomorphism.
		
		\paragraph{A coreflection}
		
			If we look at $F_3G_3 Y$ for a model $Y$ of $\CC_3$, we remark that
			\[\begin{array}{lcl}
				F_3G_3(Y)_\Con &=& G_3(Y)_p^{-1}(\{\Cstr^{G_3(Y)}_\Con\})\\
				&=& G_3(Y)_p^{-1}(\{\inj_1 \star\}) \\
				&=& Y_\Con
			\end{array}\]
			and
			\[\begin{array}{lcl}
				F_3G_3(Y)_\Ty(\Gamma) &=& G_3(Y)_p^{-1}(\{\Cstr^{G_3(Y)}_\Ty(\Gamma)\})\\
				&=& G_3(Y)_p^{-1}(\{\inj_2 \Gamma\}) \\
				&=& \operatorname{proj}_1^{-1}(\Gamma) \\
				&=& \left\{(\Gamma',A) \in \coprod_{\Gamma' \in Y_\Con}Y_\Ty(\Gamma') \middle| \Gamma' = \Gamma\right\}\\
				&\simeq& Y_\Ty(\Gamma)
			\end{array}\]
			and finally, with the same method, we get that
			\[
				F_3G_3(Y)_\Tm(\Delta,A) \simeq Y_\Tm(\Delta,A)
			\]
			
			And therefore $F_3G_3 \cong \Id_{\CC_3}$.
			
	\subsection{Another sort specification}
	\todo{L'exemple, ou sinon remplacer toutes les occurences de «trois» par «deux»}
		
	\section{Constructing the coreflection}
		\label{sec:proofSection}
		The proof will take form of an induction on the number of sorts taken into account. At each induction step, we will build the following objects:
		
		\begin{itemize}
			\setlength\itemsep{-1ex}
			\item The category of models of the GAT $\CC_i$
			\item The category of models of the transformed GAT $\BB_i$
			\item A forgetful functor $R_{i-1}^i : \BB_i \to \BB_{i-1}$. 
			
			Those functors compose themselves into a functor $R_0^i : \BB_i \to \BB_0$:
			\[
			R_0^i := R^1_0 \circ \dots \circ R_{i-1}^i
			\]
			\item An operator $\tl^i : \BB_i \times \BB_0 \to \BB_i$ along with a morphism $\inj_\tl^i : X \to X \tl^i Y$ for every $X,Y$ in $\BB_i \times \BB_0$, such that the canonical morphism $\en_{i-1}^i : (R_{i-1}^i X) \tl^{i-1} Y \to R_{i-1}^i (X \tl^i Y)$ is an isomorphism. This operation follows a specific universal property: For every morphisms $g : X \to Z$ and $h : Y \to R_0^iZ$, there is an unique morphism $\{g;h\}$ such that the two following diagrams commute:
			\label{sec:tlUniversalProperty}
			
			\begin{center}
				% YADE DIAGRAM TlUniversal.json
				% GENERATED LATEX
				\input{graphs/TlUniversal.tex}
				% END OF GENERATED LATEX
			\end{center}
			
			where $\en_0^i$ is the following composition:
			
			\[\en_0^i := R_0^{i-1} \en_{i-1}^i \circ  \dots \circ R_0^1\en_1^2 \circ \en_0^1 :  (R_0^i X) \oplus Y = (R_0^i X) \tl^0 Y \to R_0^i (X \tl^i Y)\]
			
			And where $\inj_2$ is the second injector of $\oplus$, the coproduct of the category $\BB_0 = \TSet$. We will define $\tl^0$ to be $\oplus$, so the equality above holds.
			
			The operator is also defined on morphisms, such that for any morphism $g : X \to X'$ in $\BB_i$ and $h : Y \to Y'$ in $\BB_0$, there is a morphism $g \tl^i h : X \tl^i Y \to X' \tl^i Y'$ in $\BB_i$.
			
			\item A functor $F_i : \BB_i \to \CC_i$
			\item A functor $G_i : \CC_i \to \BB_i$
			\item An adjunction between them $F_i \vdash G_i$
			\item A proof that $F_iG_i \cong \Id_{\CC_i}$ (i.e. $F_i \vdash G_i$ make up a coreflection)
			\item A proof that $F_i\inj_\tl^i$ is an isomorphism. The inverse isomorphism will be denoted as $(F_i\inj_\tl^i)^{-1}$
		\end{itemize}
		
		Here is a figure that describes the recursive construction of some of the above objects
		\begin{center}
			% YADE DIAGRAM GlobalRecursiveConstruction.json
			% GENERATED LATEX
			\input{graphs/GlobalRecursiveConstruction.tex}
			% END OF GENERATED LATEX
		\end{center}
	
		\subsection{Preliminaries}
		
			\paragraph{Grothendieck construction} 
		For a category $\mathcal{C}$ and a functor $F : \mathcal{C} \to \Cat$, the Grothendieck construction of $F$ is a category whose objects are pairs of
		\begin{itemize}
			\item $X$ an object of $\mathcal{C}$
			\item an object of $F(X)$
		\end{itemize}
		
		A morphism $(X,Y) \to (X',Y')$ is a pair of a morphism $f : X \to X'$ in $\mathcal{C}$ and a morphism $g : F(f)(Y) \to Y'$ in $H(X')$.
		
		We will denote this category $(X : \mathcal{C}) \times F(X)$ as its objects are pairs.
		
		\paragraph{Slice category}
		For a category $\mathcal{C}$ and $X$ an object in that category, the slice category (or over category) $\mathcal{C}/X$ is a category whose objects are pairs of
		\begin{itemize}
			\item $Y$ an object of $\mathcal{C}$
			\item an arrow $Y \to X$ of $\mathcal{C}$
		\end{itemize}
		
		A morphism $(Y,f) \to (Y',f')$ is a morphism $g : Y \to Y'$ such that $f' \circ g = f$.
		
		We can define a functor $\left(\mathcal{C}/\dash\right) : \mathcal{C} \to \Cat$ from this construction.
		
		We will often concatenate the two method above to create from a category $\mathcal{C}$ and a functor $H : \mathcal{C} \to \Set$ a new category $(X : \mathcal{C}) \times \left(\Set\middle/H(X)\right)$.
		
		\paragraph{Slice category over a set}
		\label{SetXSetXEquivalence}
		
		When the category $\mathcal{C}$ is $\Set$, we have the equivalence 
		\[\Set/X \cong \Set^X\]
		
		This equivalence is described by the following correspondence of objects.
		An object $(Y,f)$ of $\Set/X$ is transformed into the family of sets $A : X \to \Set$ defined by
		\[
			A(x) := f^{-1}(\{x\}) = \text{the preimage by f of the singleton $\{x\}$}
		\]
		
		Conversly, a familiy of sets $A : X \to \Set$ is transformed into the following object of $\Set/X$
		\begin{center}
			% YADE DIAGRAM EquivSetXSetX.json
			% GENERATED LATEX
			\input{graphs/EquivSetXSetX.tex}
			% END OF GENERATED LATEX
		\end{center}
		
		where $\coprod$ is the coproduct of $\Set$ and $\pi_1$ is the first projection of the coproduct.
		
		Morphisms are translated using the same logic.
		
		This equivalence justifies that we used $\TSet$, the category of presheaves over $\TT$ instead of $\FamSet$ to describe the category of models of the sort specification $(\mathcal{O},\El)$ in \autoref{sec:EmptySortSpec}.
		
		We recall that the category $\TT$ is as follows
		\begin{center}
			% YADE DIAGRAM CategoryTT.json
			% GENERATED LATEX
			\input{graphs/CategoryTT.tex}
			% END OF GENERATED LATEX
		\end{center}
		
		This category is equivalent to the category $\FamSet$, as $(X : \Set) \times \Set^X$ is equivalent to $(X : \Set) \times (\Set/X)$ (as seen above), which is isomorphic to $\TSet$ (both categories consists of two sets and one arrow between them).
		
		The categories of models of the transformed GATs will be built atop of this category $\BB_0 = \TSet$.
		
		\paragraph{$K$ functor}
		
		We define a helper functor $K_A : (X:C) \times (\Set/A(X)) \to \TSet$ defined as follows
		\[
		K_A(X,(Y,f)) = \TSetObject{Y}{f}{A(X)}
		\]
		The morphisms are translated as-is.
		
		\begin{remark}
			This functor can be constructed using the formal construction of the Grothendieck construction of $\TSet \simeq (X: \Set) \times (\Set/X)$ as a pullback in the category of categories $\Cat$
		\end{remark}
	
	\subsection{Initialization}
		In this subsection, we will recall objects built in \autoref{sec:EmptySortSpec}, and build some other objects corresponding to the empty sort specification i.e. the first step of our induction.
		
		\begin{itemize}
			\setlength\itemsep{-1ex}
			\item $\CC_0$ is $\one$, the category with only one object $\star$ and one trivial morphism (i.e. the terminal category of $\Cat$)
			\item $\BB_0$ is $\TSet$, the category of models of the $(\mathcal{O},\El)$ sort specification.
			\item The universal property of $\tl^0$ is that of the coproduct. Therefore, we will define $\tl^0 : \BB_0 \times \BB_0 \to \BB_0$ to be the coproduct $\oplus$ of $\TSet$, with $\inj_\tl^0 : X \to X \oplus Y$ being the first injector of the coproduct. The second injector of the coproduct $\oplus$ will be refered as $\inj_2$.
			\item $F_0 : \TSet \to \one$ is the terminal functor of $\Cat$
			\item $G_0 : \one \to \TSet$ is the functor that sends the only object of $\one$ to the initial object of $\TSet$: $0_\TSet$
			\item For $X$ an object of $\TSet$, we have 
			\[\Hom(G_0 \star,X) = \Hom(0_\TSet,X) \cong \one \cong \Hom(\star,F_0 X)\]
			(reminder: $\star$ is the only object of $\one$)
			Therefore, we have that $F_0 \vdash G_0$.
			\item $F_0G_0 : \one \to \one$ so $F_0G_0 = \Id_\one$ as $\one$ is terminal in $\Cat$
			\item $F_i\inj_1 = \id_\star$ which is an isomorphism
		\end{itemize}
		
		
	\subsection{Inductive Step: Constructing the categories}
	
		\label{sec:constructingCategory}
		In this part, i will show how we construct recursively both categories $\CC_i$ and $\BB_i$, along with the functor $R_{i-1}^i : \BB_i \to \BB_{i-1}$. We will use the loop invariants that we expressed in the introduction of this section.
		
		In order to construct the categories, we need some object describing the sorts we are adding to the categories. This object is a given functor $H_i : \CC_{i-1} \to \Set$. Those functors are the same that Altenkirsh and al. \cite{Altenkirch2018} used in their paper to describe a specification of sorts. They are such that, for $X : \CC_{i-1}$ a model, they describe the set $H_iX$ of parameter range for the added sort. We gave an example of those functors in section \nameref{sec:Examples} if you want to understand how they work. There is also a way of obtaining them directly from the syntax, described in section \nameref{sec:HiFromSyntax}.
		We suppose that those $H_i$ functors are given.
		
		\subsubsection{Constructing $\CC_i$}
		
		We construct the category $\CC_i$ as the following Grothendieck pair:
		\[
			\CC_i := (X : \CC_{i-1}) \times \left(\Set\middle/H_i(X)\right)
		\]
		and where $H_i$ is the specific functor described above.
		
		This way of constructing the category has formerly been described by Altenkirsch and al. \cite{Altenkirch2018}, with the only difference of the equivalence $\Set/H_i(X) \simeq \Set^{H_i(X)}$.
		
		\subsubsection{Constructing $\BB_i$}
		
		We construct the category $\BB_i$ as follows.
		
		An object of $\BB_i$ is a pair of:
		\begin{itemize}
			\item an object $X$ of $\BB_{i-1}$
			\item a \enquote{sort constructor} $\Cstr^X$ as a function $H_iF_{i-1}X \to (R_0^{i-1}X)_\UU$
			\newline
			where $H_i$ is the functor $\CC_{i-1} \to \Set$ described above and $F_{i-1}$ is the right part of the adjunction $\BB_{i-1} \to \CC_{i-1}$ that we have defined at the previous induction step.
		\end{itemize}
		
		If we have an object $X$ of $\BB_i$, the first component is denoted as $R_{i-1}^iX$, which is an object of $\BB_{i-1}$, and the second component is denoted as $\Cstr^X : R_{i-1}^i X \to (R_0^iX)_\UU$. 
		
		A morphism $X \to X'$ of $\BB_i$ is a morphism $f : R_{i-1}^iX \to R_{i-1}^iX'$ in $\BB_{i-1}$ such that the following diagram commutes.
		
		\begin{center}
			% YADE DIAGRAM BiMorphismDiagram.json
			% GENERATED LATEX
			\input{graphs/BiMorphismDiagram.tex}
			% END OF GENERATED LATEX
		\end{center}
		
		For a morphism $f : X \to X'$ of $\BB_i$, we denote as $R_{i-1}^if$ the underlying morphism $R_{i-1}^i X \to R_{i-1}^i X'$.
		
		Identities and compositions are that of the category $\BB_{i-1}$, and categorical equalities are trivially derived from the diagram above.
		
		$R_{i-1}^i$ acts on objects and morphisms, and induces a functor $\BB_i \to \BB_{i-1}$. The induced functor is monadic, and therefore preserves limits.
		
	\subsection{Inductive step: Constructing the functors $F_i$ and $G_i$}
	
		The adjunction $F_i \vdash G_i$ is built using the two functors from the adjunction $F_{i-1} \vdash G_{i-1}$ defined in the previous induction step. We use them to define the first part of the adjunction, and we compose them with two adjoint functors $W$ and $E$ that we will define in this section. The overall construction for this induction step is as follows:
		
		\begin{center}
			% YADE DIAGRAM InductionStepDiagram.json
			% GENERATED LATEX
			\input{graphs/InductionStepDiagram.tex}
			% END OF GENERATED LATEX
		\end{center}
		
		Where
		\[
			(F_{i-1} \times \id)(X,\underset{y : Y \to F_{i-1}(X)}{(Y,y)}) = (F_{i-1}X,\underset{y : Y \to F_{i-1}X}{(Y,y)})
		\]
		\[
			(F_{i-1} \times \id)(f,g) = (F_{i-1}f,g)
		\]
		and
		\[
			(G_{i-1} \times (H_i\eta_{i-1} \circ \dash))(X,\underset{y : Y \to H_iX}{(Y,y)}) = (G_{i-1}X,\underset{Y : Y \to H_i X \to H_iF_{i-1}(G_{i-1}X)}{(Y,H_i\eta_{i-1} \circ y)})
		\]
		\[
			(G_{i-1} \times (H_i\eta_{i-1} \circ \dash))(f,g) = (G_{i-1}f,g)
		\]
		with $\eta_{i-1} : X \to F_{i-1}G_{i-1}X$ being the unit of the adjunction $F_{i-1} \vdash G_{i-1}$.
		
		These equations define two functors, that create the following adjunction:
		\[F_{i-1} \times \id \vdash G_{i-1} \times (H_i\eta_{i-1} \circ \dash)\]
		
		The unit of this adjunction is $\eta_{i-1} \times (H_i\eta_{i-1}\circ \dash)$ and its counit is $\varepsilon_{i-1} \times \id$, where $\varepsilon_{i-1}$ is the counit of the adjunction $F_{i-1} \vdash G_{i-1}$
		
	\subsubsection{W definition}
	
		We define a functor $W : \left(\left(X : \BB_{i-1}\right) \times \Set/H_iF_{i-1}X\right) \to \BB_{i}$
		
		The action on objects is as follows:
		\[
		W(X,Y) := \left(X \tl^{i-1} K_{H_iF_{i-1}}(X,Y), \widetilde{\inj_2} \right)
		\]
		
		With $\widetilde{\inj_2}$ being defined by the composition
		\begin{center}
			% YADE DIAGRAM Wdef.json
			% GENERATED LATEX
			\input{graphs/Wdef.tex}
			% END OF GENERATED LATEX
		\end{center}
		
		The action on a morphism $(g,h)$ from $(X,Y)$ to $(X',Y')$ is the following:
		\[
			W(g,h) := \left(g \tl^{i-1} K_{H_iF_{i-1}}(g,h)\right)
		\]
		
		It is indeed a morphism of $\BB_{i}$ as it makes the following diagram commute.
		
		\begin{center}
			% YADE DIAGRAM WghMorphismOfBi.json
			% GENERATED LATEX
			\input{graphs/WghMorphismOfBi.tex}
			% END OF GENERATED LATEX
		\end{center}
	
	\subsubsection{E definition}
	
		We define $E : \BB_{i} \to \left(X : \BB_{i-1}\right) \times (\Set/H_iF_{i-1}X)$
		
		The action on objects is 
		\[
			E(X) = (R_{i-1}^i X, (A,h))
		\]
		Where $(A,h)$ is defined as the following pullback:
		
		\begin{center}
			% YADE DIAGRAM EDefinitionPullback.json
			% GENERATED LATEX
			\input{graphs/EDefinitionPullback.tex}
			% END OF GENERATED LATEX
		\end{center}
		
		The action on a morphism $f$ from $X$ to $X'$ is defined as $E(f) = (R_{i-1}^i f, !)$, with $!$ being the only morphism making the following diagram commute (thanks to the pullback property):
		
		\begin{center}
			% YADE DIAGRAM EDefinitionMorphism.json
			% GENERATED LATEX
			\input{graphs/EDefinitionMorphism.tex}
			% END OF GENERATED LATEX
		\end{center}
		 
	\subsection{Inductive Step: Proof of the coreflection}
		 
		 In this subsection, we prove that $(W,E)$ make up a coreflection i.e. an adjunction where the left adjoint is full and faithful.
		 
		 \paragraph{Adjunction} We will prove the adjunction by showing that there is a natural isomorphism between $\Hom$ sets in both categories.
		 
		 We want to construct for each $(X,Y)$ in $(X : \BB_{i-1}) \times (\Set/H_iF_{i-1}X)$ and $Z$ in $\BB_i$, a natural isomorphism $\phi_{XYZ}$.
		 
		 \[
			 \phi_{XYZ} : \Hom(W(X,Y),Z) \to \Hom((X,Y),E(Z))
		 \]
		 
		 You can find the proof of the adjunction in \autoref{apx:adjunction}, made of the following parts:
		 \begin{itemize}
		 	\item The construction of $\phi_{XYZ}$
		 	\item The construction of $\phi_{XYZ}^{-1}$
		 	\item A proof that $\phi_{XYZ}^{-1} \circ \phi_{XYZ} (f) = f$
		 	\item A proof that $\phi_{XYZ} \circ \phi_{XYZ}^{-1} (g,h) = (g,h)$
		 	\item A proof that $\phi_{XYZ}$ is natural.
		 \end{itemize}
		 
		All these steps give us that $F_i$ and $G_i$ are in an adjunction $F_i \vdash G_i$.
		
		\paragraph{Coreflection}
		Next, we have proven that this newly created adjunction $F_i \vdash G_i$ create a coreflection. It means that $F_iG_i \cong \Id_{\CC_i}$, or equivalently that $G_i$ is full and faithful.
		
		The proof of that second statement is given in \autoref{apx:FG-refl}.
			
	\subsection{Inductive step: Constructing $\tl^i$}
	
		\label{sec:coproductConstr}
		
		\paragraph{Constructing the objects}
		We will define the $\tl^i$ operator of two objects $X$ from $\BB_i$ and $Y$ from $\BB_0$ as follows:
		\[
			X \tl_i Y := \left((R_{i-1}^i X) \tl^{i-1} Y, (R_0^{i-1} \inj_\tl^{i-1})_\UU \circ \Cstr_i^X \circ (H_iF_{i-1}\inj_\tl^{i-1})^{-1}\right)
		\]
			
		The constructor goes as follows:
		
		\begin{center}
			% YADE DIAGRAM TlConstructor.json
			% GENERATED LATEX
			\input{graphs/TlConstructor.tex}
			% END OF GENERATED LATEX
		\end{center}
		
		The injector $\inj_\tl^i : X \to X \tl^i Y$ is defined as follows:
		\[
			\inj_\tl^i := \inj_\tl^{i-1} : R_{i-1}^i X \to R_{i-1}^i (X \tl^i Y) = R_{i-1}^i X \tl^{i-1} Y
		\]
		
		It is a morphism of $\BB_i$ as it makes the following diagram commute:
		\begin{center}
			% YADE DIAGRAM TlInj1MorphismOfBi.json
			% GENERATED LATEX
			\input{graphs/TlInj1MorphismOfBi.tex}
			% END OF GENERATED LATEX
		\end{center}
		
		\paragraph{Universal Property}
		We will now show that that the universal property stated in \autoref{sec:tlUniversalProperty} holds.
		To that end, we take two objects $X$ and $Z$ in $\BB_i$, $Y$ in $\BB_0$, a morphism $g : X \to Z$ in $\BB_i$ and a morphism $h : Y \to R_0^iZ$ in $\BB_0$. We want to build a morphism $\{g,h\}$ of $\BB_i$ such that the following two diagrams commute.
		
		\begin{center}
			% YADE DIAGRAM TlUniversal.json
			% GENERATED LATEX
			\input{graphs/TlUniversal.tex}
			% END OF GENERATED LATEX
		\end{center}
		
		We define $\{g ; h\}_i = \{R_{i-1}^i g ; h\}_{i-1}$. This is a morphism of $\BB_i$ as it makes the following diagram commute:
		
		\begin{center}
			% YADE DIAGRAM TlUniversalMorphismIsOfBi.json
			% GENERATED LATEX
			\input{graphs/TlUniversalMorphismIsOfBi.tex}
			% END OF GENERATED LATEX
		\end{center}
		
		With this definition, the isomorphism $\en_{i-1}^i : (R_{i-1}^i X) \tl^{i-1} Y \to R_{i-1}^i(X \tl^i Y)$ is simply the identity morphism.
		
		\paragraph{Building morphisms}
		
		For any two morphisms $g : X \to X'$ of $\BB_i$ and $h : Y \to Y'$ of $\BB_0$, we will create a morphism $X \tl^i Y \to X' \tl^i Y'$ as follows:
		\[
			g\tl^ih := R_{i-1}^ig \tl^{i-1} h
		\]
		\todo{Même question d'homogénéité}
		
		This is indeed a morphism of $\BB_i$ as it makes the following diagram commute:
		
		\begin{center}
			% YADE DIAGRAM TlDefOnMorphisms.json
			% GENERATED LATEX
			\input{graphs/TlDefOnMorphisms.tex}
			% END OF GENERATED LATEX
		\end{center}
		
		\paragraph{Composition with $F_i$}
		We finally need to prove, for any objects $X$ in $\BB_i$ and $Y$ in $\TSet$, that the morphism
		$F_i(\inj_\tl^i) : F_iX \to F_i(X \tl^i Y)$ is an isomorphism.
		
		Morphisms $\BB_{i}$ are morphisms of $\BB_{i-1}$ that follows some equations, and composition is the same. Moreover, we know from the definition above that $R_{i-1^i} \inj_\tl^i := \inj_\tl^{i-1}$.
		
		So, we just need to know that $R_{i-1}^i(F_{i-1}\inj_\tl^i)$ is an isomorphism.
		
		\[
			R_{i-1}^iF_i\inj_\tl^i = \left[(F_{i-1} \times \id) (E(\inj_\tl^i))\right]_1 = \left[(F_{i-1} \times \id) (R_{i-1}^i \inj_\tl^i,!)\right]_1 = F_{i-1} \inj_\tl^{-1}
		\]

		And we know from the previous induction step that $F_{i-1}\inj_\tl^{i-1}$ is an isomorphism. Therefore, $F_i\inj_\tl^i$ is an isomorphism.
	
	\section{Other Properties}
	
	\subsection{Fibration of the category $\CC_i$}
	
	In the formal proof, we defined $\CC_i$ as an inductive Grothendieck construction as in Altenkirsch and al. papers \cite{Altenkirch2018}.
	
	But there is an other way \cite{Fiore2008} of building the category $\CC_i$ which is equivalent to the one presented above.
	
	With this other method, a sort specification is described by a countable simple direct category $S$ (i.e. a countable category where all the arrows follow an unique direction, and $\Hom$-sets are finite). The models of the sort specification are therefore the presheaves over the category $S$ called $\left[S,\Set\right]$.
	
	\paragraph{Constructing $S$ as a sequence}
	In order to fall back on the definition we gave in the formal proof, we will build the final countable simple direct category $S$ as a sequence $\emptyset = S_0,S_1,\dots,S_i$ where $S_i$ is the category describing the sort specification limited to the $i$ first sort declarations.
	
	The input data describing the GAT will be a sequence of finite functors $\Gamma_i : S_{i-1} \to \Set$.
	
	We will then construct the category $S_i$ by adding a single object $\alpha_i$ to the category $S_{i-1}$, along with morphisms $f : \alpha_j \to \alpha_{i+1}$ for $f \in \Gamma_{i+1}(\alpha_j)$ and $j \leq i$. The morphisms follow the composition condition, describing that every pair of morphisms $f : \alpha_j \to \alpha_{i+1}$ and $g : \alpha_k \to \alpha_{i+1}$ (i.e. $f\in\Gamma_{i+1}(\alpha_k)$ and $g\in\Gamma_{i+1}(\alpha_j)$) and for every morphism of $S_{i}$ $h : \alpha_j \to \alpha_k$, we have $\Gamma_{i+1}(h)(f) \circ f = g$.
	
	Avec le formalisme de la construction de Grothendieck, on peut formaliser la construction de la nouvelle catégorie comme cela:
	\[
		S_i = S_{i-1} \times 
	\]
	
	The final category is simply $S = \bigcup S_i$.
	
	In our type theory example, the category $S$ is constructed as follows:
	
	\begin{center}
	\begin{tabular}{c|c|c}
		$\boxed{\Con : \Set}$ &
		$\boxed{\Ty : (\Gamma : \Con) \to \Set}$ &
		$\boxed{\Tm : (\Delta : \Con) \to (A : \Ty\;\Delta) \to \Set}$ \\
		$S_1 = \qquad \Con$	&
		$S_2 = \qquad \Con \leftarrow \Ty$ &
		$S_3 = \qquad \Con \leftarrow \Ty \leftarrow \Tm$ \\
		$\left[S_1,\Set\right] \simeq \CC_1$ &
		$\left[S_2,\Set\right] \simeq \CC_2$ &
		$\left[S_3,\Set\right] \simeq \CC_3$
	\end{tabular}
	\end{center}
	
	\begin{remark}
		This definition is reversable (up to the order of the sorts), and therefore, one can define a sequence of $\Gamma_i$ functors from any countable simple direct category.
	\end{remark}
	
	\paragraph{Falling back on the formal proof}
	
		In the formal proof, we used categories $\CC_i$ and functors $H_i : \CC_i \to \Set$. We now undertand that the categories $\CC_i$ are defined on top of the categories $S_i$ with $\CC_i := \left[S_i,\Set\right]$.
		
		In the same way, the functors $H_i : \CC_{i-1} \to \Set$ are defined on top of the functors $\Gamma_i$ with the following relation:
		\[
			H_i(X) := \Hom_{\left[S_{i-1},\Set\right]}\left(\Gamma_i,X\right)
		\]
	
	\subsection{Creating semantics object from the syntax}
		\label{sec:HiFromSyntax}
		
		In this part, we will see how the functors $\Gamma_i$ given above can be constructed from the syntax of a sort specification. The previous subsection gives us a way of constructing the $H_i$ functors from the $\Gamma_i$ functors, and thus one can make the complete proof with the definition below.
		
		\paragraph{Verbose sort specification}
		We will take a verbose version of a sort specification, where when \enquote{implementing} a sort, we gave the name of the parameter and the name of the term. For example, our type theory example becomes the following verbose version:
		
		\begin{center}
		\renewcommand\arraystretch{1.5}
		\begin{tabular}{l}
			$\Con : \Set$\\
			$\Ty : (\Gamma : \Con) \to \Set$ \\
			$\Tm : (\Delta : \Con) \to (A : \Ty \left[\Gamma \mapsto \Delta\right]) \to \Set$
		\end{tabular}
		\end{center}
		\vspace{1em}
		The only sort declaration that changes is that of $\Tm$ as it is the only one for which one of its parameter is a sort with parameters.
		
		With that verbose definition, a generic sort specification is a list of sort declarations indexed by $\mathbb{T}$, the fully ordered set of all sorts. The sort declarations are as follow, for a sort $T \in \mathbb{T}$
		
		\[
			T : \left[x_a^T : U_T(a) \left[x^{U_T(a)}_{b} \mapsto x^T_{v_T(a,b)}\right]_{b\leq I_{U_T(a)}}\right]_{a \leq I_T} \to \Set
		\]
		
		Where
		\begin{itemize}
			\setlength\itemsep{-.2em}
			\item $I_T$ is the number of parameters of the sort $T$
			\item $x^T_a$ is the $a$-th parameter of the sort $T$
			\item $U_T(a)$ is the sort of the $a$-th parameter of the sort $T$ (we have $U_T(a) < T$)
			\item $I_{U_T(a)}$ is the number of parameters of the sort $U_T(a)$ i.e. the number of arguments we have to give to make an object of sort $U_T(a)$
			\item $x^{U_T(a)}_b$ is the $b$-th parameter of the sort $U_T(a)$
			\item $v_T(a,b)$ is the index of the parameter of the sort $T$ given as the $b$-th parameter of the $a$-th parameter of the sort $T$ (we have $v_T(a,b) < a$)
			\item The types of parameters have to be respected, therefore we must have the equality
			\[
				U_T(v_T(a,b)) = U_{U_T(a)}(b)
			\]
		\end{itemize}
		
		For example, for the above sort declaration, we would have
		\begin{itemize}
			\setlength\itemsep{-.2em}
			\item $\mathbb{T} = \left\{\Con < \Ty < \Tm\right\}$
			\item $I_\Con = 0$, $I_\Ty = 1$, $I_\Tm = 2$
			\item $x^\Ty_1 = "\Gamma"$, $x^\Tm_1 = "\Delta"$, $x^\Tm_2 = "A"$
			\item $U_\Ty(1) = \Con$, $U_\Tm(1) = \Con$, $U_\Tm(2) = \Ty$
			\item $v_\Tm(2,1) = 1$ such that $x^\Tm_{v_\Tm(2,1)} = "\Delta"$ (associated to $x^\Ty_{b=1} = "\Gamma"$)
		\end{itemize}
		
		\paragraph{Describing the category $S$}
			
			We will then describe what is the category $S$ corresponding to a given sort specification $(\mathbb{T},I,U,v)$
			
			Its objects are simply the sorts, i.e. the elements of $\mathbb{T}$.
			
			Morphisms from a sort $T_x$ to a different sort $T_y$ are described by $U$ and correspond to the parameters of the sort $T_x$ that are of sort $T_y$. In other words:
			
			\[
				\Hom_{S}(T_x,T_y) = \left\{x^{T_x}_a\middle| a \leq I_{T_x} \text{ and } U_{T_x}(a) = T_y\right\}
			\]
			
			We can see that the category is direct, because of the rule $U_T(a) < T$ i.e. if $T_x < T_y$ then $\Hom_S(T_x,T_y) = \emptyset$.
			For every sort $T$, we define $\Hom_S(T,T)$ to contain only the identity morphism $\id_T$, for which composition rules are already defined.
			
			Composition is described by $v$, corresponding to\enquote{parameters of parameters}.
			Let's take two morphisms $x^{T_x}_b : T_x \to T_y$ and $x^{T_y}_a : T_y \to T_z$. Their composition is defined by
			\[
				x^{T_y}_a \circ x^{T_x}_b = x^{T_x}_{v_{T_x}(a,b)}
			\]
			
			This composition is well-defined as 
			\[
				U_{T_x}(v_{T_x}(a,b)) = U_{U_{T_x}(a)}(b) = U_{T_y}(b) = T_z
			\]
			
			For our type theory example, the category $S$ is as follows
			
			\begin{center}
				% YADE DIAGRAM TyThExampleSCat.json
				% GENERATED LATEX
				\input{graphs/TyThExampleSCat.tex}
				% END OF GENERATED LATEX
			\end{center}
		
		\paragraph{Creating the functor $\Gamma_i$}
		
			We know we can create the functors $\Gamma_i$ directly from a complete category $S$, but we will look more in detail what those functors mean related to the syntax.
			
			If we are given the category $S_{i-1}$ with objects corresponding to the $i-1$ sorts already defined.
			
			We want to build a finite functor $\Gamma_i : S_{i-1} \to \Set$ corresponding to the following sort declaration of a new sort $T_i$
		
			We will build $\Gamma_i$ as follows:
			
			\[
				\Gamma_i(T_x) = \left\{x^{T_i}_a\middle| a \leq I_{T_i} \text{ and } U_{T_i}(a) = T_x\right\}
			\]
			
			\[
				\Gamma_i(x_b^{T_x} : T_x \to T_y)(x^{T_i}_a \in \Gamma_i(T_x)) = x^{T_i}_{v_{T_i}(a,b)}
			\]
			
			This definition is redundant with that of the last paragraph, but it has the advantage of directly creating the functor $\Gamma_i$ that are used to create the functors $H_i$ and all the rest of the proof.
	
	\subsection{Non-recursive definitions}
	
	\subsubsection{Redefinition of $\BB_i$}
	\subsubsection{Redefinition of $G_i$ and $F_i$}
	\subsubsection{Non-direct base category}
	
	\subsection{Infinite construction of $\BB_i$}
	\[
	\BB_i := \left(X : \TSet, \Cstr : (a : S_{i-1}) \to \Hom_{\BB_{a-1}}(G_{a-1}\Gamma_a,R_{a-1}^i(\this)) \to X(\UU)\right)
	\]
	A morphism from $(X,\Cstr)$ to $(X', \Cstr')$ is a morphism from $X$ to $X'$ in $\TSet$ (i.e. a natural transformation $X \implies X'$) which makes the following diagram commute, for all $a$ in $S_{i-1}$.
	
	\begin{center}
		% YADE DIAGRAM BiMorphismDiagram.json
		% GENERATED LATEX
		\input{graphs/BiMorphismDiagram.tex}
		% END OF GENERATED LATEX
	\end{center}
	
	Identities and compositions are that of the base category $\TSet$, and categorical equalities are trivially derived from the diagram above.
	
	The diagram expresses as
	\[
	\forall \gamma \in \Hom_{G_{a-1}\Gamma_a,X}, \quad \Cstr'_a(f \circ \gamma) = f_\UU(\Cstr_a \gamma)
	\]
	
	\todo{Define properly the use of \this}
	
	\subsection{$G$ and $F$ infinite constructions}
	
	\[
	G_i(Y) = \left(\sum_{a\in S_i}H_{Y(a)}\left(\lim_{(a/S_i)*}\overline{Y_a}\right), \lambda a.\lambda \eta.(a,u (\inj_2 \star))\right)
	\]
	
	where $u : \left(Y(a) \oplus 1, \inj_1\right) \to (\lim_{(a/S_i)*} \overline{Y_a})$
	
	so that $\varphi_{b,f} u (\star) = \eta_\El^b(f)$
	
	\[
	F_i(X,\Cstr)(a) = X(p)^{-1}\left(\Cstr_a\left(\Hom_{\BB_{a-1}}(G_{a-1}\Gamma_a,X)\right)\right)
	\]
	\[
	F_i(X,\Cstr)(f : a \to b)(X(p)(x); x \in \Cstr_a(\eta)) = \eta_\El^b(f)
	\]
	
	\todo{Show that those are the same functors as those defined recursively. Prove the adjunction/reflection infinitely ?}
	
	\section{Summary}
		
		\lipsum[2-3]
	
	
	
	\section{Bibliography}
	\begingroup
	\renewcommand{\section}[2]{}%
	\printbibliography
	\endgroup
	
	\newpage
	\addappheadtotoc
	\appendix
	\addtocontents{toc}{\protect\setcounter{tocdepth}{-1}}
	\appendixpage
	
	\section{$W \dashv E$ adjunction}
	\label{apx:adjunction}
	
	\subsubsection{Constructing $\phi_{XYZ}$}
	
	Let $f$ be in $\Hom(W(X,Y),Z)$.
	We want to construct $\phi_{XYZ}(f) : (X,Y) \to E(Z)$.
	
	The first component of $\phi_{XYZ}(f)$ is defined as the following composition:
	
	\begin{center}
		% YADE DIAGRAM PhiXYZFirstComponent.json
		% GENERATED LATEX
		\input{graphs/PhiXYZFirstComponent.tex}
		% END OF GENERATED LATEX
	\end{center}
	
	The second component is defined through the universal property of the pullback defined by $E(Z)$ according to the following diagram:
	
	\begin{center}
		% YADE DIAGRAM PhiXYZSndComponentPullback.json
		% GENERATED LATEX
		\input{graphs/PhiXYZSndComponentPullback.tex}
		% END OF GENERATED LATEX
		
	\end{center}
	
	\subsubsection{Constructing $\phi^{-1}_{XYZ}$}
	
	Now, we take $(g,h)$ a morphism from $(X,Y)$ to $E(Z)$.
	
	The morphism $\phi^{-1}_{XYZ}(g,h)$ of $\BB_i$ from $W(X,Y)$ to $Z$ is a morphism of $\BB_{i-1}$ from $X \tl^{i-1} K_{H_iF_{i-1}} (X,Y)$ to $R_{i-1}^i(Z)$ that make a specific diagram commute. We build this morphism using the universal property of $\tl^{i-1}$, stated in the introduction of this section.
	
	\[
	\phi^{-1}_{XYZ}(g,h) := \left\{g ; \square \right\}
	\]
	
	\todo{Est-ce qu'il faut que j'écrive $R_{i-1}^i\phi^{-1}_{XYZ}(g,h) := ...$ pour être plus «homogène» ?}
	
	Where $\square$ is a morphism $K_{H_iF_{i-1}} (X,Y) \to R_0^i Z$ in $\TSet$ defined by the following diagram:
	
	\begin{center}
		% YADE DIAGRAM PhiXYZ-1Square.json
		% GENERATED LATEX
		\input{graphs/PhiXYZ-1Square.tex}
		% END OF GENERATED LATEX
		
	\end{center}
	
	Finally, we check that $\phi^{-1}_{XYZ}(g,h)$ is a morphism of $\BB_i$ from $W(X,Y)$ to $Z$, i.e. that it makes the following diagram commute:
	
	\begin{center}
		% YADE DIAGRAM PhiXYZ-1MorphismOfBi.json
		% GENERATED LATEX
		\input{graphs/PhiXYZ-1MorphismOfBi.tex}
		% END OF GENERATED LATEX
		
	\end{center}
	
	\subsection{Composition $\phi_{XYZ} \circ \phi_{XYZ}^{-1}$}
	
	The first component of $\phi_{XYZ} (\phi_{XYZ}^{-1}(g,h))$ is
	\[
	R_{i-1}^i(\phi_{XYZ}^{-1}(g,h)) \circ \inj_\tl^{i-1} = \left\{g ; \square \right\} \circ \inj_\tl^{i-1} = g
	\]
	
	The second component of $\phi_{XYZ} (\phi_{XYZ}^{-1}(g,h))$ follows the following diagram
	
	\begin{center}
		% YADE DIAGRAM CompositionSecondComponent.json
		% GENERATED LATEX
		\input{graphs/CompositionSecondComponent.tex}
		% END OF GENERATED LATEX
	
\end{center}
	
	
	\todo{Justifier que la partie du haut commute, i.e. que \[
		(R_0^{i-1}\{g,\square\})_\El \circ (\en_0^i)_\El \circ (\inj_2)_\El = \square_\El
		\]}
		
	The diagram commutes, and so we can deduce that the second component of $\phi_{XYZ}(f)$ is $h$, by proprty of the pullback $E(Z)$
	
	\subsection{Composition $\phi_{XYZ}^{-1} \circ \phi_{XYZ}$}
	
	Now, the converse composition is
	
	\[
	\phi_{XYZ}^{-1} (\phi_{XYZ}(f)) = \left\{R_{i-1}^i f \circ \inj_\tl^{i-1} ; \square \right\}
	\]
	where $\square$ follows the following diagram
	
	\begin{center}
		% YADE DIAGRAM CompositionSquareConstruction.json
		% GENERATED LATEX
		\input{graphs/CompositionSquareConstruction.tex}
		% END OF GENERATED LATEX
	\end{center}
	
	We want to show that $\phi_{XYZ}^{-1} (\phi_{XYZ}(f)) = f$. By definition of $\{;\}$ in $\BB_i$, it suffices to show that $\square = R_0^i f \circ \en_0^{i-1} \circ \inj_2$.
	
	The two required equalities are proved by the diagram above:
	
	\begin{align*}
		\square_\El = \left(R_0^i f \circ \en_0^{i-1} \circ \inj_2\right)_\El \\
		\square_\UU = \left(R_0^i f \circ \en_0^{i-1} \circ \inj_2\right)_\UU
	\end{align*}
	
	\subsection{Naturality}
	
	We want to show that the following diagram commutes, for any objects $X$,$Y$,$Z$,$X'$,$Y'$,$Z'$ and morphisms $f$,$g$,$h$.
	
	\begin{center}
		% YADE DIAGRAM NaturalityDiagram.json
		% GENERATED LATEX
		\input{graphs/NaturalityDiagram.tex}
		% END OF GENERATED LATEX
	\end{center}
	
	We take a morphism $\ii$ in $\Hom\left(W(X,Y),Z\right)$. We want to show that it is sent by the above diagram to the same morphism of $\Hom\left((X',Y'),E(Z')\right)$.
	
	We first look at the first component of the result morphism.
	
	\[\begin{array}{rcl}
		\phi_{X'Y'Z'}(f \circ \ii \circ W(g,h))_1
		&=& R_{i-1}^i\left(f \circ \ii \circ (g \tl^{i-1} K_\bullet(g,h))^+\right) \circ \inj_\tl^{i-1} \\
		&=& R_{i-1}^i f \circ R_{i-1}^i \ii \circ (g \tl^{i-1} K_\bullet(g,h)) \circ \inj_\tl^{i-1} \\
		&=& R_{i-1}^i f \circ R_{i-1}^i \ii \circ \inj_\tl^{i-1} \circ g \\
		&=& \left[E(f) \circ \phi_{XYZ}(\ii) \circ (g,h)\right]_1
	\end{array}\]
	
	The second components are defined as described by the following diagram
	
	\begin{center}
		% YADE DIAGRAM NaturalityDoublePullbackDefinition.json
		% GENERATED LATEX
		\input{graphs/NaturalityDoublePullbackDefinition.tex}
		% END OF GENERATED LATEX
	\end{center}
	
	The second projection of $\phi_{XYZ}(f \circ \ii \circ W(g,h))$ is defined by the pullback of $E(Z')$ commuting with the two path highlighted by the inner blue line. And that of $\phi_{X'Y'Z'}(\ii)$ is defined by the red outer line.
	The outer squares commute, and therefore, by the pullback property, we get that
	\[
		\phi_{X'Y'Z'}(f\circ\ii\circ W(g,h))_2 = \left[E(f) \circ \phi_{XYZ}(\ii) \circ (g,h)\right]_2
 	\]
	
	And thus we have naturality.
	
	
	\section{$F_i \vdash G_i$ reflection}
	\label{apx:FG-refl}
	
	We want to find, for each object $(X,(B,g))$ of $\CC_i = (X : \CC_{i-1}) \times (\Set/H_i(X))$, an isomorphism $(X,(B,g)) \to F_iG_i(X,(B,g))$. $g$ is a morphism from $B$ to $H_i(X)$
	
	\[\begin{array}{rcl}
		F_iG_i(X,(B,g)) 
		&=& F_iW_i(G_{i-1}X,(B,H_i\eta_{i-1}\circ g))\\
		&=& F_i\left(G_{i-1}X \tl^{i-1}K_\bullet(G_{i-1}X,(B,H_i\eta_{i-1}\circ g)),\widetilde{\inj_2}\right)\\
		&=&(F_{i-1} \times \id)\left(G_{i-1}X \tl^{i-1}K_\bullet(G_{i-1}X,(B,H_i\eta_{i-1}\circ g)),(A,h)\right)\\
		&=&\left(F_{i-1}(G_{i-1}X \tl^{i-1}K_\bullet(G_{i-1}X,(B,H_i\eta_{i-1}\circ g))),(A,h)\right)
	\end{array}\]
	
	Where $(A,h)$ is the pullback defined as
	\begin{center}
		% YADE DIAGRAM ReflectionFGPullback.json
		% GENERATED LATEX
		\input{graphs/ReflectionFGPullback.tex}
		% END OF GENERATED LATEX
	\end{center}
	
	We can extend this pullback with the two isomorphisms $\en_0^i$ and $H_iF_{i-1}(\inj_\tl^{i-1})$ in another pullback. This new pullback is over the injection morphism $\inj_2$ of the coproduct of $\TSet$, so the new pullback object is the second component of the $\bullet \oplus B$ i.e. $B$.
	
	\begin{center}
		% YADE DIAGRAM ReflectionFGExtendedPullback.json
		% GENERATED LATEX
		\input{graphs/ReflectionFGExtendedPullback.tex}
		% END OF GENERATED LATEX
	\end{center}
	
	The first component of the isomorphism is the following isomorphism, where $\eta_{i-1}^{FG}$ if the counit of the adjunction $F_{i-1} \vdash G_{i-1}$, that we know to be an isomorphism from the induction hypothesis.
	
	\begin{center}
		% YADE DIAGRAM ReflectionFGIsomorphismFirst.json
		% GENERATED LATEX
		\input{graphs/ReflectionFGIsomorphismFirst.tex}
		% END OF GENERATED LATEX
	\end{center}
	
	And the second component is made using the isomorphism constructed by the pullback, that makes the diagram commute.
	\begin{center}
		% YADE DIAGRAM ReflectionFGIsomorphismSecond.json
		% GENERATED LATEX
		\input{graphs/ReflectionFGIsomorphismSecond.tex}
		% END OF GENERATED LATEX
	\end{center}
	
	
\end{document} 






















































































































































