% !TeX spellcheck = en_US
\documentclass[11pt,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)}
\date{}


\fancyhead[L]{M2 internship report}
\fancyhead[R]{Categorical semantics of the 2-sortification of GATs}
\fancyfoot[L]{Samy Avrillon}

\begin{document}
	\doparttoc
	\setlength\droptitle{-1.5cm}
	\maketitle
	 \vspace{-1cm}
	\hsep
	
	\subsection*{General Context}
	
	Generalized Algebraic Theories a.k.a. GATs are syntactic objects introduced in 1986 by Cartmell \cite{CartmellGATs}. We can see them as a generalization of Type Theory's inductive types as they enable us to describe algebraic structures. For example, we can describe the models of first order logic using a GAT.
	
	A GAT is made of a list of \enquote{sorts} called a \enquote{sort specification} that describes sets, usually followed by a list of \enquote{constructors}.
	
	\subsection*{Problem Studied}
	
	There is a process that transforms any GAT into another GAT with only two sorts. This transformation has been used by Filippo Sestini in their PhD, to restrict their study to GATs with only two sorts. However, this systematic transformation has not yet been formally justified. 
	
	\subsection*{Proposed Contribution}
	
	During this internship, my goal was to formalize this transformation semantically. I focused directly on the categories of models without looking at the syntactic aspects of GATs. I only focused on \enquote{sort specification}, i.e. GATs that are just a list of sort declarations with no constructors. I started with applying the transformation on simple examples to identify properties that would prove the transformation to be correct, working in a categorical framework. Then, I formally stated those properties and proved them as generically as possible.
	
	\subsection*{Arguments Supporting Their Validity}
	
	The overall proof was made semantically and at each step, we tried to generalize objects as much as possible. The ways of constructing the objects are based on published papers \cite{Altenkirch2018} \cite{Fiore2008}.
	
	My contribution is also a first step towards solving the conjecture stated in Sestini's PhD.
	
	\subsection*{Summary and Future Work}
	
	We formalized semantically this transformation, enabling us to be more general and avoid the syntactical aspects of GATs.
	This transformation has been proven so that studying only GATs with two sorts can be done without losing generality.
	
	The next step could be to add term constructors to our formalization. We could describe their transformation and adapt the properties we stated for sort specification to them.
	
	We could also try to further generalize GATs using this transformation. We could for example try to describe sorts that are mutually included one into the other. More work needs to be done studying them and looking at how the transformation affects them to discover new properties.
	
	We could also aim to encode this transformation and the associated proofs in a proof assistant like Agda or Coq.
	
	\newpage
	
	\setcounter{tocdepth}{2}
	\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. In 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 different 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 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)$ 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 : (\Delta : \underline{\Con}) \to (A : \underline{\Ty\;\Delta}) \to \mathcal{O}$ &
		For each object $\Delta$ corresponding to the sort object $\Con$,
		and for every object $A$ corresponding to the sort object $\Ty\;\Delta$, another sort object called \enquote{$\Tm\;\Delta\;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 enables one to restrict the scope of their 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, to legitimate this transformation. In this document, we will only study sort specifications (i.e. lists of sort declarations, 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 two 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 two specific examples to help get 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 be 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 (identity) morphism (i.e. the terminal category of $\Cat$). This is because the empty sort specification has only 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 is 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}
			
			So an object of $\TSet$ is composed of two sets $X_\UU$ and $X_\El$ and an arrow $X_p : X_\El \to X_\UU$. Morphisms are natural transformations $f : X \to X'$ i.e. two functions $f_\UU : X_\UU \to X'_\UU$ and $f_\El : X_\El \to X'_\El$ that commutes with $X_p$ and $X'_p$.
			
			This category is equivalent to the category $\FamSet$ with an equivalence we will see later (\autoref{SetXSetXEquivalence})
			
			With this formalization, 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 1_\Set \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}
		
		Our next example is the sort specification of type theory presented in the introduction. We recall that 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 forget 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.
			
			To construct those categories generically, we will define functors $H_i : \CC_{i-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 (or one parameter of type \texttt{unit}) 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 as 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 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 the 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 means that a model $X$ comes with a function as follows:
			\[
				\Cstr^X_\Ty : X_p^{-1}\left(\{\Cstr^X_\Con\}\right) \to X_\UU
			\]
			
			The codomain of this constructor means \enquote{Every object of $X_\El$ that is 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}
			
			Once 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 morphisms 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 (denoted $\oplus$) 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 disjoint union $\oplus$.
			
			\begin{remark}
				With this functor, every element of $X_\UU$ is reached by some constructor. Therefore, every object of $X_\El$ points to a sort that is reached by some constructor.
			\end{remark}
			
		\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, which we will later express by \enquote{$F_i \inj_\tl^i$ is an isomorphism} in \hyperref[sec:proofSection]{the global proof}.
			\end{remark}
			
		\paragraph{An adjunction}
			
			I will not do the proof that $F_3 \vdash G_3$ in this specific case, as it will be proven in the general case in the global proof, but I will give intuitions 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 ones 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 morphisms 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 the 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 two morphisms $\inj_1^i : X \to X \tl^i Y$ and $\inj_2^i : Y \to R_0^i(X \tl^i Y)$ for every $X,Y$ in $\BB_i \times \BB_0$. This operation follows a specific universal property: For every morphism $g : X \to Z$ and $h : Y \to R_0^iZ$, there is a unique morphism $\{g;h\}$ such that the following two diagrams respectively in $\BB_i$ and $\BB_0$ commute:
			\label{sec:tlUniversalProperty}
			
			\begin{center}
				% YADE DIAGRAM TlUniversal.json
				% GENERATED LATEX
				\input{graphs/TlUniversal.tex}
				% END OF GENERATED LATEX
			\end{center}
			
			The operator can be extended to act on morphisms by exploiting the universal property, so 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_1^i$ is an isomorphism. The inverse isomorphism will be denoted as $(F_i\inj_1^i)^{-1}$
			\item A proof 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.
			
			We will denote the composition of those $\en$ morphisms as such:
			\[\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) \tl^0 Y \to R_0^i (X \tl^i Y)\]
		\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 methods 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 \simeq \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\}$}
		\]
		
		Conversely, a family 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 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 the example of \nameref{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_1^0 : X \to X \tl^0 Y$ being the first injector of the coproduct and $\inj_2^0 : Y \to X \tl^0 Y$ being the second injector.
			\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 1_\Set \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^0_1 = \id_\star$ which is an isomorphism
		\end{itemize}
		
		
	\subsection{Inductive Step: Constructing the categories}
	
		\label{sec:constructingCategory}
		In this part, we 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.
		
		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 Altenkirch 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 Altenkirch 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 defined such that:
		\[
			R_{i-1}^i W(g,h) := \left(g \tl^{i-1} K_{H_iF_{i-1}}(g,h)\right)
		\]
		
		We verify in Appendix \ref{apx:wdefsound} that this morphism verifies the property of morphisms of $\BB_i$ so that it is indeed a morphism of $\BB_{i}$.
	
	\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$ creates 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_1^{i-1})_\UU \circ \Cstr_i^X \circ (H_iF_{i-1}\inj_1^{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 first injector $\inj_1^i : X \to X \tl^i Y$ is defined such that:
		\[
			R_{i-1}^i \inj_1^i := \inj_1^{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
		\]
		
		We check that $\inj_1^i$ is a morphism of $\BB_i$ in Appendix \ref{apx:inj1morphism}.
		
		The second injector is defined as
		\[
			\inj_2^i := \inj_2^{i-1} : Y \to R_0^{i-1} (R_{i-1}^iX \tl^{i-1} Y) = R_0^i (X \tl^i Y)
		\]
		
		\paragraph{Universal Property}
		We will now show that the universal property stated in the introduction of this section 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 diagrams of $\BB_i$ and $\BB_0$ commute.
		
		\begin{center}
			% YADE DIAGRAM TlUniversal.json
			% GENERATED LATEX
			\input{graphs/TlUniversal.tex}
			% END OF GENERATED LATEX
		\end{center}
		
		We check that $\{R_{i-1}^i g ; h\}_{i-1}$ verifies the property of morphisms of $\BB_i$ in Appendix \ref{apx:universalpropertymorphismIsMorphism}. Therefore, we can define $\{g ; h\}_i$ such that $R_{i-1}^i\{g ; h\}_i = \{R_{i-1}^i g ; h\}_{i-1}$. 
		
		This morphism $\{g;h\}_i$ is such that the universal property for it is the same as the one of $\{R_{i-1}^i g, h\}$.
		
		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 check that the morphism $R_{i-1}^ig \tl^{i-1} h$ verifies the morphism property of $\BB_i$ in Appendix \ref{apx:tlMorphismOfBi}, so that we can define a morphism $g\tl^ih : X \tl^i Y \to X' \tl^i Y'$ such that
		\[
			R_{i-1}^i\left(g\tl^ih\right) = \left(R_{i-1}^ig\right) \tl^{i-1} h
		\]
		
		\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_1^i) : F_iX \to F_i(X \tl^i Y)$ is an isomorphism.
		
		Morphisms $\BB_{i}$ are morphisms of $\BB_{i-1}$ that follow some equations, and composition is the same. Moreover, we know from the definition above that $R_{i-1}^i \inj_1^i = \inj_1^{i-1}$.
		
		So, we just need to prove that $R_{i-1}^i(F_{i-1}\inj_1^i)$ is an isomorphism.
		
		\[
			R_{i-1}^iF_i\inj_1^i = \left[(F_{i-1} \times \id) (E(\inj_1^i))\right]_1 = \left[(F_{i-1} \times \id) (R_{i-1}^i \inj_1^i,!)\right]_1 = F_{i-1} \inj_1^{i-1}
		\]

		And we know from the previous induction step that $F_{i-1}\inj_1^{i-1}$ is an isomorphism. Therefore, $F_i\inj_1^i$ is an isomorphism.
	
	\section{Other Properties}
	
	\subsection{Sort specifications as simple direct categories}
	
	In the formal proof, we defined $\CC_i$ as an inductive Grothendieck construction as in Altenkirch and al. paper \cite{Altenkirch2018}.
	
	But there is another 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 finite simple direct category $S$ (i.e. a finite category where all the arrows follow a 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}
	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 $h : \alpha_j \to \alpha_k$ of $S_{i}$, we have $\Gamma_{i+1}(h)(f) \circ f = g$.
	
	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 reversible (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{Link with the formal proof}
	
		In the formal proof, we used categories $\CC_i$ and functors $H_i : \CC_i \to \Set$. We now understand 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 give 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 parameters 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 follows, 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 at 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 functors $\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}
	
	\section{Summary}
		
		The initial goal of this internship was to study the transformation of GATs to GATs with only two sorts. We have only studied the transformation of sort specifications. We managed to give a formal construction of the semantics of any sort specification and its transformation.
		
		We have described a relation between both categories, which is a coreflection, i.e. an adjunction where the left adjoint is full and faithful. This adjunction allows us to build the initial model of the initial GAT from the initial model of the transformed GAT, so one can study the properties of GATs with only two sorts and transpose them to any GATs.
		
		There is still work to be done to make the contents of this document apply to any GAT instead of only sort specifications. There are also ways of generalizing our formal construction to description more general than GATs like GATs with sorts mutually included one into the other.
	
	
	
	\section{Bibliography}
	\begingroup
	\renewcommand{\section}[2]{}%
	\printbibliography
	\endgroup
	\label{LastReportPage}
	
	\newpage
	\addappheadtotoc
	\appendix
	\addtocontents{toc}{\protect\setcounter{tocdepth}{-1}}
	\appendixpage
	
	\section{Soundness of definitions}
	
	\subsection{$W(g,h)$ morphism of $\BB_i$}
		\label{apx:wdefsound}
		
		The morphism $R_{i-1}^iW(g,h) = g \tl_{i-1} K_{H_iF_{i-1}}(g,h)$ is 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}
	
	\subsection{$\inj_1^i$ morphism of $\BB_i$}
		\label{apx:inj1morphism}
		
		The morphism $R_{i-1}^i \inj_1^i = \inj_1^{i-1}$ 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}
	
	\subsection{$\{g,h\}_i$ morphism of $\BB_i$}
		\label{apx:universalpropertymorphismIsMorphism}
		
		$R_{i-1}^i\{g,h\}_i := \{R_{i-1}^ig,h\}_{i-1}$ 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}
		
	\subsection{$g \tl_i h$ morphism of $\BB_i$}
	
		\label{apx:tlMorphismOfBi}
		
		$(R_{i-1}^ig)\tl_{i-1}h$ is a morphism of $\BB_i$ as it makes the following diagram commute:
		\begin{center}
			\begin{scaletikzpicturetowidth}{.9\textwidth}
				% YADE DIAGRAM TlDefOnMorphisms.json
				% GENERATED LATEX
				\input{graphs/TlDefOnMorphisms.tex}
				% END OF GENERATED LATEX
			\end{scaletikzpicturetowidth}
		\end{center}
		
	\section{$W \dashv E$ adjunction}
	\label{apx:adjunction}
	
	\subsection{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}
	
	\subsection{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 on the morphisms $g$ and $\square$, 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}
	
	We check that the morphism $\{g;\square\}$ verifies the property of morphisms of $\BB_i$ i.e. 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}
	
	Therefore, we can define $\phi^{-1}_{XYZ}(g,h)$ such that
	\[
		R_{i-1}^i\phi^{-1}_{XYZ}(g,h) := \left\{g ; \square \right\}_{i-1}
	\]
	
	
	\subsection{Composition $\phi_{XYZ} \circ \phi_{XYZ}^{-1}$}
	
	The first component of $\phi_{XYZ} (\phi_{XYZ}^{-1}(g,h))$ is
	\[
	R_{i-1}^i\left(\phi_{XYZ}^{-1}(g,h)\right) \circ \inj_1^{i-1} = \left\{g ; \square \right\} \circ \inj_1^{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}
		
	The diagram commutes, and so we can deduce that the second component of $\phi_{XYZ}(f)$ is $h$, by property 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_1^{i-1} ; \square \right\}_{i-1}
	\]
	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 \inj^{i-1}_2$.
	
	The two required equalities are proved by the diagram above:
	
	\begin{align*}
		\square_\El = \left(R_0^i f \circ \inj^{i-1}_2\right)_\El \\
		\square_\UU = \left(R_0^i f \circ \inj^{i-1}_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_1^{i-1} \\
		&=& R_{i-1}^i f \circ R_{i-1}^i \ii \circ (g \tl^{i-1} K_\bullet(g,h)) \circ \inj_1^{i-1} \\
		&=& R_{i-1}^i f \circ R_{i-1}^i \ii \circ \inj_1^{i-1} \circ g \\
		&=& \left[E(f) \circ \phi_{XYZ}(\ii) \circ (g,h)\right]_1
	\end{array}\]
	
	The notation $k^+$ denotes the morphism of $\BB_i$ such that $R_{i-1}^i(k^+) = k$ when the morphism property has already been proven.
	
	The second components are defined by the pullback properties of $E(Z)$ and $E(Z')$. The two sides that define each morphism are given separately in the two following diagrams.
	
	\begin{center}
		% YADE DIAGRAM NaturalityDoublePullbackDefinition1.json
		% GENERATED LATEX
		\input{graphs/NaturalityDoublePullbackDefinition1.tex}
		% END OF GENERATED LATEX
	\end{center}
	
	\begin{center}
		% YADE DIAGRAM NaturalityDoublePullbackDefinition2.json
		% GENERATED LATEX
		\input{graphs/NaturalityDoublePullbackDefinition2.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 blue bottom path. And that of $\phi_{X'Y'Z'}(\ii)$ is defined by the red top path.
	Both diagrams 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 isomorphisms $H_iF_{i-1}(\inj_\tl^{i-1})$ into 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$, by property of the coproduct.
	
	\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}$ if the counit of the adjunction $F_{i-1} \vdash G_{i-1}$, which 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}
	
	The second component is made using the isomorphism constructed by the pullback, which makes the diagram commute.
	\begin{center}
		% YADE DIAGRAM ReflectionFGIsomorphismSecond.json
		% GENERATED LATEX
		\input{graphs/ReflectionFGIsomorphismSecond.tex}
		% END OF GENERATED LATEX
	\end{center}
	
%	\section{Misc}
%	\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
%		% 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 ?}
	
\end{document} 










