%\documentclass[sigplan]{acmart}
\documentclass{article}
\usepackage[utf8x]{inputenc}
\usepackage{t1enc}

\usepackage{hyperref}
%\usepackage{proof}
\usepackage{fullpage}
\usepackage{amssymb}
\usepackage{stmaryrd}
%\usepackage{txfonts}
\usepackage{url}
\usepackage{color}
%\usepackage{textcomp}
\usepackage{amsmath}
\usepackage{yfonts}
\usepackage[all]{xy}
\xyoption{2cell}
\UseAllTwocells

\makeatletter
\newcommand{\Overrightarrow}[2]{\raisebox{#1}{$\ext@arrow 0359\Rightarrowfill@{\mbox{${#2}$}}{}$}}
\newcommand{\Overleftarrow}[2]{\raisebox{#1}{$\ext@arrow 0359\Leftarrowfill@{\mbox{${#2}$}}{}$}}
%\newcommand{\Overrightarrow}[1]{\raisebox{1.4ex}{$\ext@arrow 0359\Rightarrowfill@{\mbox{${#1}$}}{}$}}
\makeatother

\newcommand{\highlight}[1]{{\em #1}}

\include{macros}
\newcommand{\Type}{\mathsf{Type}}
\newcommand{\Set}{\mathsf{Set}}
\newcommand{\Prop}{\mathsf{Prop}}
\newcommand{\refl}[1]{\mathsf{refl}\,{#1}}
\newcommand{\mkmlidtype}[3]{{#1} =^{\mathrm{id}}_{#2} {#3}}
\newcommand{\mkmleqdep}[3]{{#1} =^{\mathrm{dep}}_{#2} {#3}}
\newcommand{\hrefl}[1]{\mathsf{refl^{\mathrm{dep}}}\,{#1}}
\newcommand{\mluniv}{\mathsf{U}}
\newcommand{\Jdep}[2]{\mathsf{J}\;{#1}\;{#2}}

\newcommand{\nth}[1]{{#1}^{\mbox{\scriptsize th}}}
\newcommand{\binomial}[2]{\left(\begin{array}{c}#1\\#2\end{array}\right)}

\newcommand{\wfctx}[1]{{#1}~\mathsf{ok}}

\newcommand{\mkover}[1]{\widetilde{#1}}
\newcommand{\mkoverdim}[2]{\widetilde{#2}^{#1}}
%\newcommand{\mkover}[1]{\dot{#1}}
\newcommand{\mkprod}[3]{\Pi {#1}\!:\!{#2}.\,{#3}}
\newcommand{\mkprodovereq}[3]{\mkover{\Pi} {#1}\!:\!{#2}.\,{#3}}
\newcommand{\mkprodovereqopp}[3]{\opp{\mkover{\Pi}} {#1}\!:\!{#2}.\,{#3}}
\newcommand{\mkboundedprod}[4]{\Pi {#3}\!:\!{#1}\leq{#2}.\,{#4}}
\newcommand{\mklam}[3]{\lambda {#1}\!:\!{#2}.\,{#3}}
\newcommand{\mkboundedlam}[4]{\lambda {#3}\!:\!{#1}\leq{#2}.\,{#4}}
\newcommand{\mkapp}[2]{{#1}\,{#2}}
\newcommand{\prodsort}[2]{\Pi ({#1},{#2})}

% selecting kind of treatment of sorts
\newcommand{\typeorsort}[2]{{#2}}

\newcommand{\mksigma}[3]{\Sigma {#1}\!:\!{#2}.\,{#3}}
\newcommand{\mksigmaovereq}[3]{\mkover{\Sigma} {#1}\!:\!{#2}.\,{#3}}
\newcommand{\mksigmaovereqopp}[3]{\opp{\mkover{\Sigma}} {#1}\!:\!{#2}.\,{#3}}
\newcommand{\mkpair}[2]{\langle{#1},{#2}\rangle}
\newcommand{\mkfst}[1]{{#1}.1}
\newcommand{\mksnd}[1]{{#1}.2}
\newcommand{\sigsort}[2]{\Sigma ({#1},{#2})}

\newcommand{\sortsort}[1]{{\mathcal S}_{#1}}

\newcommand{\Sone}{\mathbb{S}^1}
\newcommand{\casesone}[5]
  {\mathsf{case}\;{#1}\;\mathsf{of}\;{#2}\;\Rightarrow\;{#3}\;|\;{#4}\;\Rightarrow\;{#5}\;\mathsf{end}}
\newcommand{\base}{\mathsf{base}}
\newcommand{\loopsone}{\mathsf{loop}}
\newcommand{\Sonesort}{l_{\mathbb{S}^1}}

\newcommand{\emptyctx}{\boxbox}

\newcommand{\sort}[1]{\mathsf{U}_{#1}}
\newcommand{\univ}{\boxempty}
%\newcommand{\istype}{~:~S}
\newcommand{\typeannot}{\mathsf{type}}
\newcommand{\istype}{~\typeannot}

\newcommand{\mkeq}[3]{{#1} =_{#2} {#3}}
\newcommand{\mkhomeq}[3]{{#1} =_{#2} {#3}}
\newcommand{\mkeqovereq}[3]{{#1} \,\mkover{=}_{#2}\, {#3}}
\newcommand{\mkeqovereqdim}[4]{{#2} \,\mkoverdim{#1}{=}_{#3}\, {#4}}
%\newcommand{\mkeqtype}[3]{{#1} =_{#2} {#3}} % case where we can write either s or refl{s}
\newcommand{\mkeqtype}[3]{{#1} =_{\typeannot} {#3}}
\newcommand{\mkeqtypeovereq}[3]{{#1} \,\mkover{=}_{#2}\, {#3}} % case where we can write either s or refl{s}
\newcommand{\mkeqarray}[3]{\begin{array}{c}{#1}\\ =_{#2}\\ {#3}\end{array}}
\newcommand{\mkfaces}[3]{\mkeq{#1}{#2}{#3}}
\newcommand{\mkfacesarray}[3]{\mkeqarray{#1}{#2}{#3}}
\newcommand{\mkfacesover}[3]{\mkeqovereq{#1}{#2}{#3}}
\newcommand{\lameq}[2]{\lambda {#1}.{#2}}
%\newcommand{\reflterm}[1]{\textsf{refl}{#1}}
\newcommand{\reflterm}[1]{\widehat{#1}}
\newcommand{\overreflterm}[1]{{\mkover{\reflterm{#1}}}}
\newcommand{\refltermdim}[2]{{\widehat{#2}}^{#1}}
%\newcommand{\reflterm}[1]{\lambda{#1}}
%\newcommand{\refltype}[1]{\lambda{#1}}
\newcommand{\refltype}[1]{\reflterm{#1}}
\newcommand{\purerewlr}[1]{\overrightarrow{#1}}
\newcommand{\purerewrl}[1]{\overleftarrow{#1}}
%\newcommand{\rewlr}[2]{\mathsf{rew}^\rightarrow\;{#1}\;\mathsf{in}\;{#2}}
%\newcommand{\rewrl}[2]{\mathsf{rew}^\leftarrow\;{#1}\;\mathsf{in}\;{#2}}
\newcommand{\rewlr}[2]{\overrightarrow{#1}(#2)}
\newcommand{\rewrl}[2]{\overleftarrow{#1}(#2)}
\newcommand{\deprewlr}[1]{\raisebox{0em}{$\ulcorner$}\!#1}
\newcommand{\deprewrl}[1]{{#1}\raisebox{-0.2em}{$\!\lrcorner$}}
\newcommand{\rewlrspec}[2]{{#1}^{\rightarrow}(#2)}
\newcommand{\rewrlspec}[2]{{#1}^{\leftarrow}(#2)}
\newcommand{\rewlrrevspec}[2]{{#1}_-^{\rightarrow}(#2)}
\newcommand{\rewrlrevspec}[2]{{#1}_-^{\leftarrow}(#2)}
\newcommand{\rewlrrevspecin}[2]{{#1}_+^{\rightarrow}(#2)}
\newcommand{\rewrlrevspecin}[2]{{#1}_+^{\leftarrow}(#2)}
\newcommand{\doublerewlr}[2]{\Overrightarrow{1.4ex}{#1}({#2})}
\newcommand{\doublerewrl}[2]{\Overleftarrow{1.4ex}{#1}({#2})}
%\newcommand{\mktuple}[6]{\{#1\mapsto #3(#1); #2\mapsto #4(#2); #1\mapsto #5(#1); #2\mapsto #6(#2)\}}
\newcommand{\mktuple}[6]{\{#3; #4; #5; #6\}_{#1,#2}}
\newcommand{\mktupleshort}[6]{\{#3; #4; #5; #6\}}
\newcommand{\opp}[1]{{#1}^{-1}}
\newcommand{\oppi}[2]{\appi{#1}{(\opp{#2}/{#2})}}

\newcommand{\weakensquarelr}[2]{{#1}_L(#2)}
\newcommand{\weakensquarerl}[2]{{#1}_R(#2)}

\newcommand{\rewlrmkeq}[4]{\mkeq{\rewlr{#1}{#2}}{#3}{#4}}

% Version basse
%% \newcommand{\appi}[2]{{#1}_{#2}}
%% \newcommand{\appidep}[2]{{#1}_{({#2})}}
%% \newcommand{\bp}[1]{{#1}_0}
%% \newcommand{\ep}[1]{{#1}_1}
%% \newcommand{\bpdep}[1]{{#1}_{(0)}}
%% \newcommand{\epdep}[1]{{#1}_{(1}}}
% Version haute
% \newcommand{\metaappi}[2]{{#1}_{[{#2}]}}
\newcommand{\appi}[2]{{#1}\;\!{#2}}
\newcommand{\appidep}[2]{{#1}_{#2}}
\newcommand{\bp}[1]{{#1}{\scriptstyle 0}}
\newcommand{\ep}[1]{{#1}{\scriptstyle 1}}
\newcommand{\bpoverdim}[2]{{#2}{\scriptstyle \mkoverdim{#1}{0}}}
\newcommand{\epoverdim}[2]{{#2}{\scriptstyle \mkoverdim{#1}{1}}}
\newcommand{\bpdep}[1]{{#1}_0}
\newcommand{\epdep}[1]{{#1}_1}

\newcommand{\bpsubstexpl}[2]{{#2}_{\{0/{#1}\}}}
\newcommand{\epsubstexpl}[2]{{#2}_{\{1/{#1}\}}}
\newcommand{\eqsubstexpl}[2]{{#2}_{\{\star/{#1}\}}}
\newcommand{\bpsubstexplcons}[2]{{#2}\}\{0/{#1}}
\newcommand{\epsubstexplcons}[2]{{#2}\}\{1/{#1}}
\newcommand{\eqsubstexplcons}[2]{{#2}\}\{\star/{#1}}
\newcommand{\bpsubst}[2]{{#2}{[0/{#1}]}}
\newcommand{\epsubst}[2]{{#2}{[1/{#1}]}}
\newcommand{\bpsubstctx}[3]{{#3}{[0/{#2}]}^{#1}}
\newcommand{\epsubstctx}[3]{{#3}{[1/{#2}]}^{#1}}
\newcommand{\takebpface}[2]{\partial^{#1}_0{#2}}
\newcommand{\takeepface}[2]{\partial^{#1}_1{#2}}

\newcommand{\dimvalid}[2]{{#1} \in {#2}}
\newcommand{\dimdeclare}[1]{{#1}}
\newcommand{\dimlength}[1]{|#1|_{\mathit{dim}}}
\newcommand{\dimindex}[2]{\#_{#1}{#2}}

\newcommand{\substminus}[2]{{#1}-{#2}}
\newcommand{\substminusbernardymoulin}[2]{{#1}/{#2}}

\newcommand{\N}{\mathbb{N}}
\newcommand{\expand}[2]{\mathsf{expand}(#1,#2)}

\newcommand{\defeq}{\triangleq}
%\newcommand{\metaequiv}{=\!\!\!=}
\newcommand{\metaequiv}{\cong}
\newcommand{\metaletin}[3]{\mathit{let}\;{#1}\;\defeq\;{#2}\;\mathit{in}\;{#3}}
\newcommand{\map}[2]{\mathsf{ap}\,{#1}\,{#2}}
\newcommand{\depmap}[2]{\mathsf{apd}\,{#1}\,{#2}}
\newcommand{\transport}[3]{\mathsf{transport}\,{#1}\,{#2}\,{#3}}
\newcommand{\deptransport}[3]{\mathsf{transportd}\,{#1}\,{#2}\,{#3}}
%\newcommand{\swap}[1]{\mathsf{swap}(#1)}
%\newcommand{\swapbracket}[1]{\mathsf{swap}(#1)}
%\newcommand{\swaptype}[1]{\mathsf{swap}(#1)}
\newcommand{\swap}[1]{{#1}^{\circ}}
\newcommand{\swapbracket}[1]{({#1})^{\circ}}
\newcommand{\swaptype}[1]{{#1}^{\circ}}
\newcommand{\swapoverdim}[2]{{#2}^{\mkoverdim{#1}{\circ}}}
\newcommand{\homsquare}[1]{\mathsf{homsquare}(#1)}
\newcommand{\permute}[2]{\mathsf{permute}_{#1}(#2)}
\newcommand{\swapprodeq}[2]{\mathsf{swap}_{\Pi=}^{#1}(#2)}
\newcommand{\swapeqprod}[2]{\mathsf{swap}_{=\Pi}^{#1}(#2)}
\newcommand{\swapeqprodlr}[2]{\mathsf{swap}_{=\Pi}^{\rightarrow}({#1})(#2)}
\newcommand{\swapeqprodrl}[2]{\mathsf{swap}_{=\Pi}^{\leftarrow}({#1})(#2)}
\newcommand{\swapsigmaeq}[1]{\mathsf{swap}_{\Sigma=}(#1)}
\newcommand{\swapeqsigma}[1]{\mathsf{swap}_{=\Sigma}(#1)}

\newcommand{\bool}{\mathsf{bool}}
\newcommand{\booldeux}{\bool^2}
\newcommand{\boolexp}{\bool^{\bool}}

\newcommand{\reduce}{\;\triangleright\;}

\newcommand{\emptysubst}{\emptyctx}

\newcommand{\sortrule}{\sort{}}
\newcommand{\axrule}{\mathsf{Ax}}
\newcommand{\ctxemptyrule}{\mathsf{Ctx}_{\emptyctx}}
\newcommand{\ctxconsrule}{\mathsf{Ctx}_{\mathsf{cons}}}
\newcommand{\convrule}{\mathsf{Conv}}
\newcommand{\convconvrule}{\mathsf{Conv}-\mathsf{Conv}}
\newcommand{\univrule}{\mathsf{\univ}}
\newcommand{\convruleredright}{\reduce_R}
\newcommand{\convruleredleft}{\reduce_L}
\newcommand{\convrulerefl}{\equiv_{\mathsf{refl}}}
\newcommand{\convruletrans}{\equiv_{\mathsf{trans}}}
\newcommand{\convruleredtyperight}{\reduce_R^{\typeannot}}
\newcommand{\convruleredtypeleft}{\reduce_L^{\typeannot}}
\newcommand{\convruletyperefl}{\equiv_{\mathsf{refl}}^{\typeannot}}
\newcommand{\convruletypetrans}{\equiv_{\mathsf{trans}}^{\typeannot}}

\newcommand{\circovereq}{\;\mkover{\circ}\;}
\newcommand{\circsigma}{\circ_{\Sigma}}

\newcommand{\comprule}{R_{\mathsf{\circ}}}
\newcommand{\opprule}{R_{\mathsf{\opp}}}

\newcommand{\idleftredrule}{\mathsf{Id_L}}
\newcommand{\idrightredrule}{\mathsf{Id_R}}
\newcommand{\idoppredrule}{\mathsf{\opp{Id}}}
\newcommand{\oppoppredrule}{\mathsf{\opp{(\opp{\_})}}}
\newcommand{\assoccompredrule}{\mathsf{Assoc}}
\newcommand{\distriboppcompredrule}{\mathsf{\opp{\circ}}}
\newcommand{\squaredownredrule}{\circ_{=_{\mkover{=}}}}
\newcommand{\exchangerule}{\mathsf{Exch}}
\newcommand{\compeqovereqredrule}{\circ_{\mkover{=}}}
\newcommand{\squareprodredrule}{\circ_{=_{\mkover{\Pi}}}}

\newcommand{\depmapdef}{\mathsf{ApD}}
\newcommand{\funextpuredef}{\mathsf{LiftDim}}
\newcommand{\funextdeppuredef}{\mathsf{LiftDepDim}}
\newcommand{\funextdepdeppuredef}{\mathsf{LiftDepDim}}
\newcommand{\funextdef}{\mathsf{FunExt}}
\newcommand{\funextdepdef}{\mathsf{FunDepExt}}
\newcommand{\funext}[1]{\mathsf{funext}(#1)}
\newcommand{\funextdep}[1]{\mathsf{fundepext}(#1)}
\newcommand{\funextpure}[1]{\mathsf{liftdim}(#1)}
\newcommand{\funextdeppure}[1]{\mathsf{liftdepdim}(#1)}

\newcommand{\OMEGATT}{\omega\mathsf{TT}}

\begin{document}

\title{Iterated syntactic parametricity translation}

\maketitle

\newcommand{\emptysigma}{\bullet}
\newcommand{\itsemterm}[4]{\llbracket #4 \rrbracket^{#2;#3}_{#1}}
\newcommand{\itsemtype}[4]{\llbracket #4 \rrbracket^{#2;#3}_{#1}}
\newcommand{\semterm}[3]{\llbracket #3 \rrbracket^{#1;#2}}
\newcommand{\semtype}[3]{\llbracket #3 \rrbracket^{#1;#2}}
\newcommand{\incrstep}[3]{\mathsf{split}_{#1}{#3}(#2)}
\newcommand{\distrstep}[3]{\mathsf{distr}_{#1}{#3}(#2)}
\newcommand{\applytype}[4]{\mathsf{apptype}_{#1}^{#2}(#3,#4)}
\newcommand{\shrink}[3]{\mathsf{shrink}_{#1}\,{#2}\,#3}
\newcommand{\under}[3]{\mathsf{under}_{#1}\,{#2}\,#3}
\newcommand{\undertau}[3]{\mathsf{under}_{#1}^{#2}\,#3}
\newcommand{\proj}[3]{\pi_{#1}^{#2}\,#3}
\newcommand{\elt}[2]{\mathsf{El}_{#1}\,#2}
\newcommand{\semtypenew}[2]{| #2 |_{#1}}
\newcommand{\semnew}[2]{\llbracket #2 \rrbracket_{#1}}
\newcommand{\semctx}[2]{\llbracket #2 \rrbracket_{#1}}
\newcommand{\semlam}[5]{\mathsf{lam}_{#1}^{#2}\,#4\,(#3)\,#5}
\newcommand{\semlambis}[5]{\mathsf{lam'}_{#1}^{#2}\,#4\,(#3)\,#5}
\newcommand{\semapp}[3]{\mathsf{app}_{#1}#2\,#3}
\newcommand{\semprod}[5]{\mathsf{prod}_{#1}^{#2}\,#4\,(#3)\,#5}
\newcommand{\access}[2]{\mathsf{get}_{#1}(#2)}
\newcommand{\accesstyped}[3]{\mathsf{get}_{#1}^{#2}(#3)}
\newcommand{\lift}[1]{\mathsf{lift}\, {#1}}
\newcommand{\liftlr}[1]{\mathsf{lift}^\rightarrow\, {#1}}
\newcommand{\liftrl}[1]{\mathsf{lift}^\leftarrow\, {#1}}
\newcommand{\diag}[2]{\mathsf{diag}_{#1}(#2)}
\newcommand{\semsort}[1]{\mathsf{sort}_{#1}}
\newcommand{\reflsort}[1]{\mathsf{refl}^{\sort{}}_{#1}}
\newcommand{\mktuplenew}[6]{\{#4\,|\begin{array}{l} #5 \\ #6 \end{array}\}_{#1,#2,#3}}
\newcommand{\mktuplein}[4]{{#1}; {#2}; {#3}; {#4}}
\newcommand{\nwconn}[2]{\deprewlr{#2}_{#1}}
\newcommand{\seconn}[2]{\deprewrl{#2}_{#1}}
\newcommand{\refltermn}[3]{\mathsf{reflterm}_{#1}(#3)}
\newcommand{\refltypen}[2]{\mathsf{refltype}_{#1}(#2)}

\newcommand{\restrict}{\mathsf{restrict}}
\newcommand{\MofL}{\mathsf{underlying}}
\newcommand{\defequiv}{\mathsf{\simeq}}
\newcommand{\isequivalence}{\mathsf{isequiv}}
\newcommand{\gpdlevel}{\mathsf{gpdlevel}}
\newcommand{\regrefl}{\mathsf{regrefl}}
\newcommand{\mybox}[1]{\mathsf{r\mbox{-}box}_{#1}}
\newcommand{\mylayer}[1]{\mathsf{r\mbox{-}layer}_{#1}}
\newcommand{\mycube}[1]{\mathsf{r\mbox{-}cube}_{#1}}
\newcommand{\myheterobox}[1]{\mathsf{box}_{#1}}
\newcommand{\myheterolayer}[1]{\mathsf{layer}_{#1}}
\newcommand{\myheterocube}[1]{\mathsf{cube}_{#1}}
\newcommand{\myheteroboxtype}[1]{\mathsf{Box}_{#1}}
\newcommand{\myheterolayertype}[1]{\mathsf{Layer}_{#1}}
\newcommand{\myheterocubetype}[1]{\mathsf{Cube}_{#1}}
\newcommand{\myheterodepbox}[1]{\mathsf{d\mbox{-}box}_{#1}}
\newcommand{\myheterodeplayer}[1]{\mathsf{d\mbox{-}layer}_{#1}}
\newcommand{\myheterodepcube}[1]{\mathsf{d\mbox{-}cube}_{#1}}
\newcommand{\myheterodepboxtype}[1]{\mathsf{d\mbox{-}Box}_{#1}}
\newcommand{\myheterodeplayertype}[1]{\mathsf{d\mbox{-}Layer}_{#1}}
\newcommand{\myheterodepcubetype}[1]{\mathsf{d\mbox{-}Cube}_{#1}}
\newcommand{\downbox}[2]{\mathsf{r\mbox{-}subbox}_{#1,#2}}
\newcommand{\downlayer}[2]{\mathsf{r\mbox{-}sublayer}_{#1,#2}}
\newcommand{\downcube}[2]{\mathsf{r\mbox{-}subcube}_{#1,#2}}
%\newcommand{\downboxleft}{\mathsf{subbox}^L}
%\newcommand{\downboxright}{\mathsf{subbox}^R}
%\newcommand{\downlayerleft}{\mathsf{sublayer}^L}
%\newcommand{\downlayerright}{\mathsf{sublayer}^R}
%\newcommand{\downcubeleft}{\mathsf{subcube}^L}
%\newcommand{\downcuberight}{\mathsf{subcube}^R}
%% \newcommand{\downboxleft}{\downarrow^{\mathsf{box},L}}
%% \newcommand{\downboxright}{\downarrow^{\mathsf{box},R}}
%% \newcommand{\downlayerleft}{\downarrow^{\mathsf{layer},L}}
%% \newcommand{\downlayerright}{\downarrow^{\mathsf{layer},R}}
%% \newcommand{\downcubeleft}{\downarrow^{\mathsf{cube},L}}
%% \newcommand{\downcuberight}{\downarrow^{\mathsf{cube},R}}
\newcommand{\heterodownbox}[2]{\mathsf{subbox}_{#1,#2}}
\newcommand{\heterodownlayer}[2]{\mathsf{sublayer}_{#1,#2}}
\newcommand{\heterodowncube}[2]{\mathsf{subcube}_{#1,#2}}
\newcommand{\heterodepdownbox}[1]{\mathsf{d\mbox{-}subbox}_{#1}}
\newcommand{\heterodepdownlayer}[1]{\mathsf{d\mbox{-}sublayer}_{#1}}
\newcommand{\heterodepdowncube}[1]{\mathsf{d\mbox{-}subcube}_{#1}}
\newcommand{\heterodepdownboxtype}[1]{\mathsf{d\mbox{-}Subbox}_{#1}}
\newcommand{\heterodepdownlayertype}[1]{\mathsf{d\mbox{-}Sublayer}_{#1}}
\newcommand{\heterodepdowncubetype}[1]{\mathsf{d\mbox{-}Subcube}_{#1}}
\newcommand{\downboxtype}[2]{\mathsf{Subbox}_{#1,#2}}
\newcommand{\downlayertype}[2]{\mathsf{Sublayer}_{#1,#2}}
\newcommand{\downcubetype}[2]{\mathsf{Subcube}_{#1,#2}}
\newcommand{\cohbox}[2]{\mathsf{r\mbox{-}cohbox}_{#1,#2}}
\newcommand{\cohlayer}[2]{\mathsf{r\mbox{-}cohlayer}_{#1,#2}}
\newcommand{\cohcube}[2]{\mathsf{r\mbox{-}cohcube}_{#1,#2}}
\newcommand{\cohreflbox}[1]{\mathsf{r\mbox{-}cohreflbox}_{#1}}
\newcommand{\cohrefllayer}[1]{\mathsf{r\mbox{-}cohrefllayer}_{#1}}
\newcommand{\cohreflcube}[1]{\mathsf{r\mbox{-}cohreflcube}_{#1}}
\newcommand{\cohrefleqbox}[1]{\mathsf{cohrefleqbox}_{#1}}
\newcommand{\cohrefleqlayer}[1]{\mathsf{cohrefleqlayer}_{#1}}
\newcommand{\cohrefleqcube}[1]{\mathsf{cohrefleqcube}_{#1}}
\newcommand{\cohboxtype}[2]{\mathsf{Cohbox}_{#1,#2}}
\newcommand{\cohlayertype}[2]{\mathsf{Cohlayer}_{#1,#2}}
\newcommand{\cohcubetype}[2]{\mathsf{Cohcube}_{#1,#2}}
\newcommand{\heterocohbox}[2]{\mathsf{cohbox}_{#1,#2}}
\newcommand{\heterocohlayer}[2]{\mathsf{cohlayer}_{#1,#2}}
\newcommand{\heterocohcube}[2]{\mathsf{cohcube}_{#1,#2}}
\newcommand{\myappdepbox}[1]{\mathsf{appbox}_{#1}}
\newcommand{\myappdeplayer}[1]{\mathsf{applayer}_{#1}}
\newcommand{\myappdepcube}[1]{\mathsf{appcube}_{#1}}
\newcommand{\myappdepboxtype}[1]{\mathsf{Appbox}_{#1}}
\newcommand{\myappdeplayertype}[1]{\mathsf{Applayer}_{#1}}
\newcommand{\myappdepcubetype}[1]{\mathsf{Appcube}_{#1}}
\newcommand{\unitpoint}{\star}
\newcommand{\unittype}{\mathsf{unit}}
\newcommand{\eqett}{\equiv_{\mathit{ETT}}}
\newcommand{\reflett}{\mathsf{refl}_{\mathit{ETT}}}
\newcommand{\mygpd}{\mathsf{gpd}}
\newcommand{\mycubset}{\mathsf{cubset}}
\newcommand{\partialcubset}[1]{\mathsf{cubsetprefix}_{#1}}
\newcommand{\typecubset}{\mathsf{typecubset}}
\newcommand{\mysymcubset}{\mathsf{symcubset}}
\newcommand{\issymcubset}{\mathsf{issymcubset}}
\newcommand{\partialsymcubset}{\mathsf{symcubset}}
\newcommand{\mypermute}{\mathsf{permute}}
\newcommand{\partialhascomp}{\mathsf{partialhascomp}}
\newcommand{\hascomp}{\mathsf{hascomp}}
\newcommand{\tube}[1]{\mathsf{r\mbox{-}tube}_{#1}}
\newcommand{\propercube}[1]{\mathsf{r\mbox{-}propercube}_{#1}}
\newcommand{\border}[1]{\mathsf{r\mbox{-}border}_{#1}}
\newcommand{\myheteroborder}[1]{\mathsf{border}_{#1}}
\newcommand{\reflexive}{\mathsf{refl}}
\newcommand{\permutation}{\mathsf{permutation}}
\newcommand{\diagonal}{\mathsf{diagonal}}
\newcommand{\connection}{\mathsf{connection}}
\newcommand{\diagprop}{\mathsf{diag}}
\newcommand{\reglr}{\rightarrow-\mathsf{reg}}
\newcommand{\regrl}{\leftarrow-\mathsf{reg}}
\newcommand{\coercivelr}{\rightarrow-\mathsf{def}}
\newcommand{\coerciverl}{\leftarrow-\mathsf{def}}
\newcommand{\regularitylr}{\rightarrow-\mathsf{regularity}}
\newcommand{\regularityrl}{\leftarrow-\mathsf{regularity}}
\newcommand{\Reglr}{\Rightarrow-\mathsf{reg}}
\newcommand{\Regrl}{\Leftarrow-\mathsf{reg}}
\newcommand{\Coercivelr}{\Rightarrow-\mathsf{def}}
\newcommand{\Coerciverl}{\Leftarrow-\mathsf{def}}
\newcommand{\Regularitylr}{\Rightarrow-\mathsf{regularity}}
\newcommand{\Regularityrl}{\Leftarrow-\mathsf{regularity}}
\newcommand{\coebacklr}{\overrightarrow{\mathsf{coe}}}
\newcommand{\coebackrl}{\overleftarrow{\mathsf{coe}}}
\newcommand{\backcoercivelr}{\overrightarrow{\mathsf{coe}}-\mathsf{def}}
\newcommand{\backcoerciverl}{\overleftarrow{\mathsf{coe}}-\mathsf{def}}
\newcommand{\regbacklr}{\overrightarrow{\mathsf{coe}}-\mathsf{reg}}
\newcommand{\regbackrl}{\overleftarrow{\mathsf{coe}}-\mathsf{reg}}
\newcommand{\regularitybacklr}{\overrightarrow{\mathsf{coe}}-\mathsf{regularity}}
\newcommand{\regularitybackrl}{\overleftarrow{\mathsf{coe}}-\mathsf{regularity}}
\newcommand{\Coebacklr}{\Overrightarrow{1ex}{\mathsf{coe}}}
\newcommand{\Coebackrl}{\Overleftarrow{1ex}{\mathsf{coe}}}
\newcommand{\Coercivebacklr}{\Overrightarrow{1ex}{\mathsf{coe}}-\mathsf{def}}
\newcommand{\Coercivebackrl}{\Overleftarrow{1ex}{\mathsf{coe}}-\mathsf{def}}
\newcommand{\Regbacklr}{\Overrightarrow{1ex}{\mathsf{coe}}-\mathsf{reg}}
\newcommand{\Regbackrl}{\Overleftarrow{1ex}{\mathsf{coe}}-\mathsf{reg}}
\newcommand{\Regularitybacklr}{\Overrightarrow{1ex}{\mathsf{coe}}-\mathsf{regularity}}
\newcommand{\Regularitybackrl}{\Overleftarrow{1ex}{\mathsf{coe}}-\mathsf{regularity}}

\newcommand{\reflbox}{\mathsf{reflbox}}
\newcommand{\refllayer}{\mathsf{refllayer}}
\newcommand{\reflcube}{\mathsf{reflcube}}
\newcommand{\permutebox}{\mathsf{permutebox}}
\newcommand{\diagbox}{\mathsf{diagbox}}
\newcommand{\connbox}{\mathsf{connbox}}
%% \newcommand{\cohbox}{\mathsf{coh}^{\mathsf{box}}}
%% \newcommand{\cohlayer}{\mathsf{coh}^{\mathsf{layer}}}
\newcommand{\hd}{\mathsf{hd}}
\newcommand{\tl}{\mathsf{tl}}
\newcommand{\first}{\mathsf{first}}
\newcommand{\groupoid}{\mathsf{groupoid}}
\newcommand{\groupoidn}{\mathsf{groupoidn}}
\newcommand{\letinsplit}[3]{\!\!\begin{array}{l}\mathbf{let}~{#1}=#2\;\mathbf{in}~\\#3\end{array}}

\tableofcontents

\section{Introduction}

This note aims at interpreting the cubical type theory described in
Moeneclaey's master thesis (called the ``source'') through a delimited iterated
``univalent'' parametricity translation into Extensional Type Theory
(called the ``target'').

We call our parametricity translation univalent in that it interprets
type not only as relations (as in usual parametricity) but as
relations equipped with a transport structure in such a way that types
are related under parametricity when they are equivalent. We call our
parametricity iterated in that it iterates the usual parametricity
translation $n$ times for a sequent of dimension with $n$ declarations
of an axis. We call it delimited in that the declaration of a
dimension in the source delimits a new iteration of the translation.

This translation can be seen as a delimited variant in unbounded
dimensions of previous (non-delimited) syntactic translations by:
\begin{itemize}
\item Gandy~\cite{Gandy56} and Takeuti~\cite{Takeuti57}: setoid
  translation, capturing function extensionality and propositional
  extensionality\footnote{The corresponding translation applies to Church's
  simple type theory, which, as a type system, can be seen as System
  $F_{\omega}$ with an impredicative ``universe'' $\mathsf{Prop}$ and
  a ``universe'' $\mathsf{Type}$ of simple types based on
  $\mathsf{Prop}$. Equality in $\mathsf{Prop}$ is over elements typed
  in types of $\mathsf{Type}$. The proof level is not dependent, so
  there is no equality of proofs to consider. The translation thus
  applies only to the simply-typed $\lambda$-calculus built from the
  arrow type and the impredicative sort $\mathsf{Prop}$. (actually, as
  a consequence of satisfying propositional extensional types in
  $\mathsf{Prop}$ are provably-irrelevant. Technically, the
  translation only requires to show that the existence of maps back
  and forth a proposition extends from propositional atoms to
  implication and universal quantification over types of the
  $\mathsf{Type}$ level.}
\item Section 5 of Barras, Coquand and
  Huber~\cite{BarrasCoquandHuber15} modifies the setoid translation so
  that it supports dependent types and a proof-relevant
  (non-impredicative) universe up to isomorphism (i.e. equality
  between types is the existence of an isomorphism). The translation
  is formulated as a translation to semi-simplicial sets truncated half
  way between dimension~1 and~2.
  The
  translation is to intentional type theory (ITT) and it does not
  validate the reduction rules for $J$ nor validate substitution under a
  $\lambda$-abstraction.

  In comparison, our translation uses cubes rather than simplices (see
  Shulman and Riehl~\cite{} for an interpretation of simplices on top
  of cubes using declaration of variables in the interval of the form
  $j \leq i$ where $i$ is the name of the previous variable declared,
  and 1 if $j$ is the first variable declared) but mutatis mutandis,
  both use Kan composition rather than ordinary composition and
  inverses. The main differences are that: 1) our translation is
  incremental and iterated, locally extending the dimension when a new
  interval variable is declared 2) our composition is required to be
  regular (in the sense of~\cite[Section 10]{CohCoqHubMor16}) so that
  the reduction rules for Martin-Löf's eliminator $J$ are validated.

  TODO: why Barras, Coquand and Huber's translation does not validate
  substitution under a $\lambda$-abstraction?

\item Sozeau and Tabareau~\cite{SozeauTabareau14}: this also extends
  Gandy and Takeuti translations but using a definition of 1-groupoid
  with composition and inverses rather than a semi-simplicial sets
  with a Kan composition.

\item Altenkirch, Boulier, Kaposi and
  Tabareau~\cite{AltenkirchBoulierKaposiTabareau19} gives a
  machine-checked setoid translation in ITT extended with a
  definitionally proof-irrelevant universe of proposition. The
  translation derives from previous work of the first author in the
  context of Observational Type Theory~\cite{}. This is similar to
  Gandy et Takeuti's translation but for a different source language
  (ITT rather than Church's simple theory of types). In particular, it
  supports dependent product.
\end{itemize}

Our translation can alternatively be seen as a (delimited, arbitrarily
highly $n$-truncated) syntactic formulation of (undelimited,
untruncated) presheaves semantics in set theory (or in any other
metalanguage featuring a notion of sets, e.g. type theory with
h-sets):
\begin{itemize}
\item Sections 7 and 8 of Barras, Coquand and
  Huber~\cite{BarrasCoquandHuber15} presents an interpretation of ITT
  with univalence within Kan semi-simplicial set in all dimensions.
\item Cohen, Coquand, Huber and M\"ortberg~\cite{CohCoqHubMor16}
  presents an interpretation of a variant of ITT with cubical equality
  within Kan cubical sets in all dimensions. The source language being
  interpreted differs in the following:
  \begin{itemize}
  \item Composition in our approach is only for ``tubes'' while it
    supports arbitrary systems of faces in \cite{CohCoqHubMor16}.
  \item Univalence, which connects equivalence of types and equality
    of types is obtained via a ``Glue'' operator while it is by
    definition in our case.
  \end{itemize}
 Regarding the interpretation, besides the fact that
 \cite{CohCoqHubMor16} gives an interpretation within the metalanguage
 while our interpretation is in another object language, we see the
 following differences:
 \begin{itemize}
 \item We interpret a judgement with $n$ axis variables in the typing
   context by a cubical set truncated to dimension $n$ while
   \cite{CohCoqHubMor16} interprets all judgements by a non-truncated
   cubical set independently of the number of axis variables in the
   context.
 \item The authors of \cite{CohCoqHubMor16} reason at a level of
   abstraction which circumscribes the combinatoric and equational
   structure of cubical sets in the definition of the site category of
   the presheaf. In our case, the equational structure of cubical sets
   is enforced using type dependencies rather than equations. As a
   consequence, the combinatorics of cubical sets become intertwined
   with the definition of cubical sets.

   For instance, as a comparison, a cube in a semi-cubical
   set\footnote{meaning here a cubical set with only face maps}
   presented as a presheaf is an object $a$ together with, for each
   iteration of faces $\tau$ considered modulo the equational theory
   on faces, another object $a_{\tau}$ which itself comes equipped for
   each face map $\tau'$ of a subobject $(a_{\tau})_{\tau'}$ such that
   $(a_{\tau})_{\tau'} = a_{(\tau\tau')}$ holds. In our definition of
   cubical sets, the later equality holds by construction using type
   dependencies. Otherwise said, while the presheaf construction
   represents a cube $a$ by a flat collection of all objects of the
   form $(...(a_{\tau_1})...)_{\tau_n}$ together with all equations
   asserting all necessary equations between these objects, our
   construction adds objects incrementally using instead type
   dependencies to enforce that the necessary equations hold.

   Also, while \cite{CohCoqHubMor16} treats faces, degeneracies,
   symmetries, diagonals, reversal and connections at the level of the
   site of the presheaf, we start from a semi-cubical basis (i.e. with
   only faces) and introduce reflexivity/degeneracies, symmetries and
   diagonals as axtra structure (we do not have reversal - TODO:
   connections?).

   We believe that, in any case, the combinatorics of cubical sets
   cannot be avoided and the level of details we present is anyway
   necessary for a full syntactic translation. Alternative syntactic
   translations closer to the structure of presheaves (i.e. building
   objects coming together with their collection of cubical maps and
   their associated equations) are certainly possible and they would
   eventually require to also characterize the combinatorical and
   equational structure of cubical sets. Whatever way the
   information is structured, there are irreductible bits of
   information to consider.
 \end{itemize}
\end{itemize}

It relies on an adaptation of the dependent construction of
semi-simplicial sets in type theory~\cite{Herbelin14} to a semi-strict
(regular) cubical form of $\omega$-groupoids.

\section{Delimited iterated parametricity translation}

One step of parametricity can be seen as interpreting a point by a
line. Iterating parametricity shall lead to map terms typed in a
context with $n$ declarations of an axis as $n$-cubes. We shall
interpret a
typing derivation with $n$ axis declarations as an $n$-cube of typing
derivations in the target. For instance, a typing derivation with
exactly one declaration of an axis will be interpreted by 3 typing
derivations in the target, two of them typing points and the third one
typing a proof, seen as a line, together with the fact that these two points are related (as
in ordinary parametricity), while a typing derivation with $n$
declarations of an axis shall be interpreted as a $3^n$ derivations,
split into $2^n$ derivations of points,
$2^{n-1}\times\left(\begin{array}{c}1\\n\end{array}\right)$ derivations of lines
between those points, $2^{n-2}\times\left(\begin{array}{c}2\\n\end{array}\right)$
derivations of squares between those lines, etc. until having a single
(i.e. $2^{n-n}\times \left(\begin{array}{c}n\\n\end{array}\right)$)
$n$-cube connecting the whole. Note that the points are not typed in
the same context as the lines which connect them: a variable of some
type in the source context is interpreted as a variable of the same
type in the derivation of a point but as a variable of line over
points in this type for the derivation of the line. This difference of
typing context in each component of the so-obtained $n$-cube
gives to parametricity a semantic flavor. In the presence of transport, we
suspect that a more purely syntactic form of parametricity where all components of
the $n$-cube are typed in the same context is possible. Then, an
$n$-cube of derivations in the same context is isomorphic to the
single derivation of the tupling of all components of the $n$-cubes as
an inhabitant of a $\Sigma$-type iterated $n$ times.

Each operation of the source language relative to a connective shall
be interpreted as an operation applied in parallel on each derivation
of the $n$-cube of derivations. Abstraction over a variable of axis
shall be interpreted as turning an $n$-cube of derivation over some
type $A$ into an $(n-1)$-cube of derivations over lines over $A$.
Application of a variable of axis to a proof of an equality shall be
interpreted as taking a diagonal of the square defined by this axis
and by the line which this equality denotes.

Abstraction over an ordinary variable shall require some
care. Interpreting abstraction of an $n$-cube as an $n$-cube of
abstractions such that a face of dimension $p$ of the $n$-cube takes a
$p$-cube as arguments shall drop too much information for the
diagonals to be definable in dependent products. Thus, abstraction
shall instead be interpreted as the abstraction together with a
precomputation of the diagonals in all the axes of the $n$-cube. On
the other side, dependent pairing of $n$-cubes will compositionally be
defined as $n$-cubes of dependent pairs.

Types shall be interpreted as $n$-cubes of equivalent types. More
concretely, a $0$-cube shall be a type, a $1$-cube shall be two types
$A$ and $B$, both equipped with a proper homogeneous relation,
together with a form of Galois connection structure over the two
types made of an ``oblique'' heterogeneous relation over $A$ and $B$
and of coercions back and forth between $A$ and $B$ that agree on the
oblique relation. Additionally, this Galois connection is supposed to
be regular, meaning here that if the two types are identical, the
coercions are the identity. A $2$-cube shall be four types forming a
square, four proofs that nearby pairs are equivalences and a proof
that the four equivalences are consistent, i.e., in fine, that the square
commutes. The later itself shall consist of a relation over the four
types and four equivalences and 2-dimensional coherent coercions back
and forth between the four equivalences. Note in particular that such
a relation is defined over the border of a square, i.e. the $3^2 - 1$
objects made from the four types and four equivalences between those
types. In the general case, an $n$-cube of types will be characterized
by an $n$-dimensional heterogeneous relation over $n$-boxes, i.e. of
the border of an $n$-cube, i.e. an $n$-cube without a filler inside,
plus $n$-dimensional coercions back and forth.

Each $n$-cube of derivations (i.e. again, $3^n$ components) can thus
be decomposed into an $n$-dimensional filler (one component) of its
border which is an $n$-box made from the faces (and iterated faces) of
the $n$-cube.

A typing judgement $t:A$ shall be interpreted as follows: if one sees
each $p$-dimensional face $t'$ of the interpretation of $t$ as an
$n$-cube as the pair of a filler and of a $p$-box, then, $t'$ shall be
an inhabitant of the relation underlying the corresponding face of $A$
applied to the aforementioned $p$-box.

The interpretation of the universe shall be a delicate
part. Since a type $A$ has type $\sort{l}$ for some universe level $l$
in the source, the interpretation of $\sort{l}$ as an $n$-cube has to
characterize what it means for a type to be interpreted as an $n$-cube.

In the following, we are interpreting cubical type theory in ETT and
thus use a ``type-theoretic'' terminology, such as $t$ is a term of
type $A$. The reader used to set theory can in petto reformulate such
a statement as $t$ is a element of the set $A$.

\subsection{Structure of cubes}

The notion of {\em cube} goes together with the notions of {\em box} and of {\em tube}.
A $n$-cube {\em fills} an $n$-box and, conversely, the border of an $n$-cube
is an $n$-box. A $(n+1)$-box whose two opposite faces are missing is
called an $n$-tube. The data of an $n$-cube together with the $n$-box
that it inhabits shall be called a full $n$-cube. A
$0$-cube is called a {\em point}. A $1$-cube connects two points and is
called a {\em line} with the two points forming the bordering $1$-box of the
line. A $2$-cube is a filled {\em square}. The unfilled square is a $2$-box
which can be seen as a $1$-tube made of two parallel lines together
with two extra lines closing the tube.  A $3$-cube is a filled
3-dimensional cube. The unfilled cube is a $3$-box which can be seen
as a $2$-tube made of an unfilled square stretched in one direction so
that it looks like a squared hollow cylinder together with two extra squares
closing the tube.

Cubes, boxes and tubes are relative to a type of points and to a
{\em relational structure} in all dimensions telling when a cube inhabits
(or fills) a box. There are {\em homogeneous} and {\em heterogeneous} cubes and
boxes. By a homogeneous cube or box, we mean a (full) cube or box in
which all points are in the same type and all relations in all
dimensions are homogeneous. In an heterogeneous cube or box, each
point might be in a different type and the higher-dimensional
relational structure over these types is itself
heterogeneous. However, in the latter case, even though the types and
higher-dimensional relations is heterogeneous, they can in turn be
themselves organized as a full cube or box, which, this time, is
homogeneous (i.e. a higher-dimensional relational structure can be
seen as a cube over another higher-dimensional relational structure in
a upper level, the same way as a type is itself a term in some
universe, and this universe itself a term in some upper universe, and
so on).

In the syntax of cubical type theory, the cubical structure can be
seen in two forms. A judgement in a context with $n$ axis variables
denotes an $n$-cube and this is the ``metalevel'' use of $n$-cubes. In
particular, in a judgement $\Gamma \vdash t:A$ with $n$ axis variables
declared in $\Gamma$, the type $A$ denotes an $n$-cube of relations up to dimension
$n$ (with types as points) and $t$ is a full heterogeneous $n$-cube
over the homogeneous $n$-cube of relations denoted by~$A$.

In the syntax of cubical type theory, there is also an internalizing
of the metalevel language in the object language by means of the
equality symbol. The equality over some type denotes a relation and,
when iterated, it denotes a higher-dimensional relation. Such equality
in dimension $n$ expects an $n$-box as argument, and, altogether, they
express the type of fillers of the $n$-box. For instance, in a
judgement of the form $\Gamma \vdash \alpha:p =_{\lambda i.(r i =_A s
  i)} q$ can be seen as a (non full) $2$-cube $\alpha$ inhabiting the
$2$-box built from $p$, $q$, $r$ and~$s$. More generally, if the
context $\Gamma$ itself declares $m$ variables of axis, a judgement
about an equality nested $n$ times denotes a full heterogeneous $m$-cube whose
points are themselves (non full) heterogeneous $n$-cubes.

As for an $n$-tube, it can be seen as the chain of the $2n$ $n$-cubes
forming the tube.

\iffalse
Types of the source language are eventually interpreted as
$\omega$-groupoids. We use a non-standard cubical definition of
(semi-strict) $\omega$-groupoid suitable for our needs. Relating it to
other definitions of $\omega$-groupoid is an open question.

An $\omega$-groupoid is given by a cubical type structure and a
transport structure. The cubical type structure is given by a type $A$
and a collection of higher-dimensional equalities over this type. The
inhabitants of $A$ are written $t$, $u$, $v$, $w$, ... and called
points or $0$-cubes. The equality over points, written $t =_A u$, have
lines written $p$, $q$, $r$, $s$, ... and also called $1$-cubes as
inhabitants. The equality over lines, written $p =_{r \hat{=}_A s} q$
or $[p,r] =^2_A [q,s]$, have squares, written $\alpha$, $\beta$,
$\gamma$, ... and also called $2$-cubes as inhabitants.  The equality
over squares $\alpha =_{\gamma \hat{=}_{\eta \widehat{\hat{=}}_A
    \theta} \delta} \beta$, also shortened $[\alpha,\gamma,\eta] =^3_A
[\beta,\delta,\theta]$ have proper cubes, also called $3$-cubes as
inhabitants, etc.

The transport structure is obtained by saying that any $n$-tube gives
rise to an equivalence of the $n$-boxes characterizing the missing
opposite faces of the $n$-tube, i.e. that any $n$-tube gives rise to a
mean to ``transport'' a face filling one of the hole of the $n$-tube
into a face filling the opposite hole of the $n$-tube, together with a
filler of this ``open box'' completion.
\fi

The characterization of homogeneous $n$-boxes and full $n$-cubes can
be obtained by a recursive definition reminiscent from parametricity:
a full $(n+1)$-cube is obtained by taking two full $n$-cubes plus a
third full $n$-cube connecting the two full $n$-cubes. Since it
connects full $n$-cubes, the third full $n$-cube is actually a full
$n$-cube over lines, so it is shifted by one relatively to the
underlying relational structure. Let us write $\mycube{}^{n,p}$ for a
full $(n-p)$-cube over points which are full $p$-cubes. Working
informally, we thus have the equation:
$$
\mycube{}^{n+1,0} \defeq (\mycube{}^{n,0} \times \mycube{}^{n,0}) \times \mycube{}^{n+1,1}
$$
and, iterating and generalizing the process, we have actually:
$$
\mycube{}^{n+1,p} \defeq (\mycube{}^{n,p} \times \mycube{}^{n,p}) \times \mycube{}^{n+1,p+1}
$$
Now, the third cube (of dimension $((n+1)-(p+1))$, i.e. $n-p$) connects the first two
$(n-p)$-cubes, so it has to depend on them. So, the equation is rather
something of the form:
$$
\mycube{}^{n+1,p} \defeq \Sigma a:(\mycube{}^{n,p} \times \mycube{}^{n,p}).\, \mycube{}^{n+1,p+1}(a)
$$
Then, by iterating, we obtain:
$$
\mycube{}^{n+1,p} \defeq \Sigma a:(\mycube{}^{n,p} \times \mycube{}^{n,p}).\,
 \Sigma b:(\mycube{}^{n,p+1}(a) \times \mycube{}^{n,p+1}(a)). \, \mycube{}^{n+1,p+2}(a,b)
$$
and so on. Thus, we need first to make the definition of
$\mycube{}^{n,p}$ dependent over the part of the full cube built up to
this point and secondly to accumulate this information. At the end of
the accumulation of the process, i.e. at the time of building
$\mycube{}^{n+1,n}$, a complete $n$-box will have been built. So, let us
call $\mybox{}^{n,p}$ the partial $n$-box built up to the stage $p$
of the construction. Thus, we refine our definition into something like:
$$
\begin{array}{lll}
\mybox{}^{n,0} &\defeq& \unittype\\
\mybox{}^{n,p+1} &\defeq& \Sigma d:\mybox{}^{n,p}.\,(\mycube{}^{n,p}(d) \times \mycube{}^{n,p}(d))\\
\\
\mycube{}^{n+1,p}(d:\mybox{}^{n,p}) &\defeq& \Sigma a:(\mycube{}^{n,p}(d) \times \mycube{}^{n,p}(d)).\,\mycube{}^{n+1,p+1}(d,a)
\end{array}
$$
where $\unittype$ is a canonical singleton type used to initiate the
construction of a list of pairs of $n$-cubes.

Now, the two cubes $\mycube{}^{n,p}(d)$ and $\mycube{}^{n,p}(d)$ cannot be
any cubes. They have to represent two opposite cubes and we need a way
to express this. The answer is simple. The partial box has two faces
and these two cubes have to respectively fill the left face and the
right face of the partial box. We thus have to rely on operations
$\downbox{l}{L}$ and $\downbox{l}{R}$ which extract the sides of a box,
leading to the refined definition:
$$
\begin{array}{lll}
\mycube{}^{n+1,p}(d:\mybox{}^{n,p}) &\defeq& \Sigma a:(\mycube{}^{n,p}(\downbox{l}{L}(d)) \times \mycube{}^{n,p}(\downbox{l}{R}(d))).\,\mycube{}^{n+1,p+1}(d,a)
\end{array}
$$

The full explicit definition shall be given in the next sections but,
to give an idea, let us show the structure of an $n$-cube for the
first three dimensions.

A full $0$-cube is made of just one point:
$$
\begin{array}{lll}
\mbox{\textit{points}}\\
\end{array}
\begin{array}{lll}
  \framebox{$a$}\\
\end{array}
$$

A full $1$-cube is made of two points connected by a line:
$$
\begin{array}{lll}
\mbox{\textit{lines}}\\
[1mm]\mbox{\textit{points}}\\
\end{array}
\begin{array}{lll}
\framebox{$
\begin{array}{ll}
  & \framebox{$a_{\star}$}\\
\framebox{$a_0$}~\framebox{$a_1$}\\
\end{array}
$}
\end{array}
$$

A full $2$-cube is made of two full $1$-cubes connected by a lifted
$1$-cube made of two lines connecting the former points and a square
connecting the former lines:
$$
\begin{array}{lll}
\mbox{\textit{squares}}\\
[1mm]\mbox{\textit{lines}}\\
[1mm]\mbox{\textit{points}}\\
[1mm]\end{array}
\framebox{$\begin{array}{lll}
\framebox{$
\begin{array}{ll}
  & \framebox{$a_{0\star}$}\\
\framebox{$a_{00}$}~\framebox{$a_{01}$}\\
\end{array}
$}~
\framebox{$
\begin{array}{ll}
 & \framebox{$a_{1\star}$}\\
\framebox{$a_{10}$}~\framebox{$a_{11}$}\\
\end{array}
$}~
\raisebox{4.8mm}{$\framebox{$
\begin{array}{ll}
 & \framebox{$a_{\star\star}$}\\
\framebox{$a_{\star 0}$}~\framebox{$a_{\star 1}$}\\
\end{array}
$}$}
\end{array}$}
$$

In the next sections, we define homogeneous cubes, what allows to
define a structure of cubical set and, later, of cubical
$\omega$-groupoid. From that, we can define heterogeneous cubes over
$\omega$-groupoid at leaves. This heterogeneous cubes will be the
basis for interpreting judgements of cubical type theory.

%This is what leads to the definition on
%Figures~\ref{fig:barecubicalset}, \ref{fig:barecubicalsetstructure},
%\ref{fig:barecubicalsetfaces} and \ref{fig:barecubicalsetcoherences}.

\subsection{Homogeneous cubes}

In this section, we formally define in
Figures~\ref{fig:barecubicalsetstructure},
\ref{fig:barecubicalsetfaces} and \ref{fig:barecubicalsetcoherences}
the structure of the underlying higher-dimensional relations on which
cubes and boxes are built, together with the definition of homogeneous
$n$-boxes, homogeneous $n$-cubes, together with face operations on
boxes and cubes, together with commutation properties of the face
operations. All are mutually defined as types of the target language
ETT. Such relational structure, cubes and boxes are relative to a
universe, so let us fix $\sort{l}$ to be a given universe and
$\sort{l+1}$ to be its type. Let also $\unittype$ be the canonical
type with a single distinguished inhabitant $\unitpoint$. This type
lives in the first universe and, by cumulativity, also in all other
universes. We write $\hd(l)$ for the first component of a
$\Sigma$-type. We write $\times$ for the non-dependent case of a
$\Sigma$-type and may sometimes also use the notation $p_0$ and $p_1$
for the two projections from a non-dependent $\Sigma$-types. We write
$\overrightarrow{p}$ for the rewriting operator along an equality
proof $p$ of the target language. Regarding equality in the
metalanguage, we will implicitly consider equality of a dependent pair
as equivalent to a dependent pair of component-wise equalities.

\begin{figure*}
\centerline{ \framebox{$
\begin{array}{llcl}
\partialcubset{l}^n && : & \sort{l+1}\\
\partialcubset{l}^0 && \defeq & \unittype\\
\partialcubset{l}^{n'+1} && \defeq & \Sigma D:\partialcubset{l}^{n'}.\,(\mybox{l}^{n',n'}(D) \imp \sort{l})\\
\\
\mybox{l}^{n,p,[p \leq n]} & (D:\partialcubset{l}^n) & : & \sort{l}\\
\mybox{l}^{n,0} & D & \defeq & \unittype\\
\mybox{l}^{n,p'+1} & D & \defeq & \Sigma d:\mybox{l}^{n,p'}(D).\,\mylayer{l}^{n,p'}(D)(d)\\
\\
\mylayer{l}^{n,p,[p < n]} & \!\!\!\begin{array}{l}(D:\partialcubset{l}^{n})\\(d:\mybox{l}^{n,p}(D))\end{array}& : & \sort{l}\\
\mylayer{l}^{n,p} & D~d & \defeq & \!\!\begin{array}{l}\mycube{l}^{n-1,p}(\hd(D))(\tl(D))(\downbox{l}{L}^{n,p,p}(D)(d)) \\\times\; \mycube{l}^{n-1,p}(\hd(D))(\tl(D))(\downbox{l}{R}^{n,p,p}(D)(d))\end{array}\\
\\
\mycube{l}^{n,p,[p \leq n]} & \!\!\!\begin{array}{l}(D:\partialcubset{l}^{n})\\(E:\mybox{l}^{n,n}(D) \imp \sort{l})\\(d:\mybox{l}^{n,p}(D))\end{array} & : & \sort{l}\\
\mycube{l}^{n,p,[p = n]} & D~E~d & \defeq & E(d)\\
\mycube{l}^{n,p,[p < n]} & D~E~d & \defeq & \Sigma b:\mylayer{l}^{n,p}(D)(d).\,\mycube{l}^{n,p+1}(D)(E)(d,b)\\
\\
\end{array}
$
}}
\caption{Definition of a bare truncated cubical set (higher-dimensional relation structure and homogeneous cubes)}
\label{fig:barecubicalsetstructure}
\end{figure*}

\begin{figure*}
\centerline{ \framebox{$
\begin{small}
\begin{array}{llcl}
\downbox{l}{\epsilon}^{n,q,p,[p \leq q < n]} & \!\!\!\begin{array}{l}(D:\partialcubset{l}^{n})\\(d:\mybox{l}^{n,p}(D))\end{array}& : & \mybox{l}^{n-1,p}(\hd(D))\\
\downbox{l}{\epsilon}^{n,q,0} & D~\unitpoint & \defeq & \unitpoint\\
\downbox{l}{\epsilon}^{n,q,p'+1} & D~(d,b) & \defeq & (\downbox{l}{\epsilon}^{n,q,p'}(D)(d),\downlayer{l}{\epsilon}^{n,q,p'}(D)(d)(b))\\
\\
\downlayer{l}{\epsilon}^{n,q,p,[p < q < n]} & \!\!\!\begin{array}{l}(D:\partialcubset{l}^{n})\\(d:\mybox{l}^{n,p}(D))\\(b:\mylayer{l}^{n,p}(D)(d))\end{array}& : & \mylayer{l}^{n-1,p}(\hd(D))(\downbox{l}{\epsilon}^{n,q,p}(D)(d))\\
\downlayer{l}{\epsilon}^{n,q,p} & D~d~c & \defeq & \!\!\begin{array}{l}(\overrightarrow{\cohbox{l}{\epsilon,L}^{n,p,q,p}(D)(d)}(\downcube{l}{\epsilon}^{n-1,q-1,p}(\hd(D))(\tl(D))(\downbox{l}{L}^{n,p,p}(D)(d))(c_L)),\\\;\overrightarrow{\cohbox{l}{\epsilon,R}^{n,p,q,p}(D)(d)}(\downcube{l}{\epsilon}^{n-1,q-1,p}(\hd(D))(\tl(D))(\downbox{l}{bR}^{n,p,p}(D)(d))(c_R)))\end{array}\\
\\
\downcube{l}{\epsilon}^{n,q,p,[p \leq q < n]} & \!\!\!\begin{array}{l}(D:\partialcubset{l}^{n})\\(E:\mybox{l}^{n,n}(D) \imp \sort{l})\\(d:\mybox{l}^{n,p}(D))\\(b:\mycube{l}^{n,p}(D)(E)(d))\end{array}& : & \mycube{l}^{n-1,p}(\hd(D))(\tl(D))(\downbox{l}{\epsilon}^{n,q,p}(D)(d))\\
\downcube{l}{\epsilon}^{n,q,p,[p=q]} & D~E~d~(b,\_) & \defeq & b_{\epsilon}\\
\downcube{l}{\epsilon}^{n,q,p,[p<q]} & D~E~d~(b,c) & \defeq & \letinsplit{b'}{\downlayer{l}{\epsilon}^{n,q,p}(D)(d)(b)}{(b',\downcube{l}{\epsilon}^{n,q,p+1}(D)(E)(d,b')(c))}\\
\\
\end{array}
\end{small}
$
}}
\caption{Definition of a homogeneous bare cubical set ($q$-th projection)}
\label{fig:barecubicalsetfaces}
\end{figure*}

\begin{figure*}
\centerline{ \framebox{$
\begin{small}
\begin{array}{llcl}
\cohbox{l}{\epsilon,\epsilon'}^{\!\!\!\tiny\begin{array}{l}n,q,r,p\\\mbox{}[p \leq r < q < n]\end{array}} & \!\!\!\begin{array}{l}(D:\partialcubset{l}^{n})\\(d:\mybox{l}^{n,p}(D))\end{array}& : & \!\!\!\begin{array}{ll}\downbox{l}{\epsilon}^{n-1,q,p}(\hd(D))(\downbox{l}{\epsilon'}^{n,r,p}(D)(d)) \\ \eqett \downbox{l}{\epsilon'}^{n-1,r,p}(\hd(D))(\downbox{l}{\epsilon}^{n,q,p}(D)(d))\end{array}\\
\cohbox{l}{\epsilon,\epsilon'}^{n,q,r,0} & D~\unitpoint & \defeq & \reflett(\unitpoint)\\
\cohbox{l}{\epsilon,\epsilon'}^{n,q,r,p'+1} & D~(d,b) & \defeq & (\cohbox{l}{\epsilon,\epsilon'}^{n,q,r,p'}(D)(d),\cohlayer{l}{\epsilon,\epsilon'}^{n,q,r,p'}(D)(d)(b))\\
\\
\cohlayer{l}{\epsilon,\epsilon'}^{\!\!\!\tiny\begin{array}{l}n,q,r,p\\\mbox{}[p < r < q < n]\end{array}} & \!\!\!\begin{array}{l}(D:\partialcubset{l}^{n})\\(d:\mybox{l}^{n,p}(D))\\(b:\mylayer{l}^{n,p}(D)(d))\end{array}& : & \!\!\!\begin{array}{ll}\downlayer{l}{\epsilon}^{n-1,q,p}(\hd(D))(\downbox{l}{\epsilon'}^{n,r,p}(D)(d))(\downlayer{l}{\epsilon'}^{n,r,p}(D)(d)(b)) \\ \eqett \downlayer{l}{\epsilon'}^{n-1,r,p}(\hd(D))(\downbox{l}{\epsilon}^{n,q,p}(D)(d))(\downlayer{l}{\epsilon}^{n,q,p}(D)(d)(b))\end{array}\\
\cohlayer{l}{\epsilon,\epsilon'}^{n,q,r,p} & D~d~c & \defeq & \!\!\begin{array}{l}(\cohcube{l}{\epsilon,\epsilon'}^{n-1,q-1,r-1,p}(\hd(D))(\tl(D))(\downbox{l}{L}^{n,p,p}(D)(d))(c_L),\\\;\cohcube{l}{\epsilon,\epsilon'}^{n-1,q-1,r-1,p}(\hd(D))(\tl(E))(\downbox{l}{R}^{n,p,p}(D)(d))(c_R))\end{array}\\
\\
\cohcube{l}{\epsilon,\epsilon'}^{\!\!\!\tiny\begin{array}{l}n,q,r,p\\\mbox{}[p \leq r < q < n]\end{array}} & \!\!\!\begin{array}{l}(D:\partialcubset{l}^{n})\\(E:\mybox{l}^{n,n}(D) \imp \sort{l})\\(d:\mybox{l}^{n,p}(D))\\(b:\mycube{l}^{n,p}(D)(E)(d))\end{array}& : & \!\!\!\begin{array}{ll}\downcube{l}{\epsilon}^{n-1,q-1,p}(\hd(D))(\tl(D))(\downbox{l}{\epsilon'}^{n,r,p}(D)(d))(\downcube{l}{\epsilon'}^{n,r,p}(D)(E)(d)(b)) \\ \eqett \downcube{l}{\epsilon'}^{n-1,r-1,p}(\hd(D))(\tl(D))(\downbox{l}{\epsilon}^{n,q,p}(D)(d))(\downcube{l}{\epsilon}^{n,q,p}(D)(E)(d)(b))\end{array}\\
\cohcube{l}{\epsilon,\epsilon'}^{n,q,r,p,[p=r]} & D~E~d~(b,\_) & \defeq & \reflett(\downcube{l}{\epsilon}^{n-1,q-1,p}(\hd(D))(\tl(E))(\downbox{l}{\epsilon'}^{n,p,p}(D)(d))(b_{\epsilon}))\\
\cohcube{l}{\epsilon,\epsilon'}^{n,q,r,p,[p<r]} & D~E~d~(b,c) & \defeq & \!\!\begin{array}{l}(\cohlayer{l}{\epsilon,\epsilon'}^{n,q,r,p}(D)(d)(b),\\\;\cohcube{l}{\epsilon,\epsilon'}^{n,q,r,p+1}(D)(E)(d,\downlayer{l}{\epsilon}^{n,q,p}(D)(d)(b))(c))\end{array}\\
\end{array}
\end{small}
$
}}
\caption{Definition of a homogeneous bare cubical set (commutation of $q$-th projection and $r$-th projection)}
\label{fig:barecubicalsetcoherences}
\end{figure*}

Note the presence of a coherence condition $\cohbox{l}{}$ to
ensuring that both sides of the equality in $\downlayer{l}{}$ and $\downcube{l}{}$
are in the same type. The proof of $\cohbox{l}{}$ itself requires
an higher-dimensional coherence condition which we obtain by
working here in ETT where all proofs of an
equality are identified (principle of Unicity of Identity Proofs). Note that if the proofs of the same equality were not equated, there would be a need for arbitrary many
higher-dimensional coherences (see e.g.~\cite{Herbelin15} for a
discussion on the de facto need for recursive higher-dimensional
coherence conditions in formulating higher-dimensional structures in
type theory). Note also that for a given
$n$, the coherence conditions evaluate to a reflexivity proof, so that
the construction evaluates to an effective sequence of types of
iterated relations not mentioning $\downbox{l}{}$ nor $\cohbox{l}{}$ anymore.

We call the structure thus defined {\em bare truncated cubical sets}:
{\em bare} because it can be seen as defining a cubical equivalent to
semi-simplicial sets with only faces as part of the structure
(otherwise said, another terminology could have been ``semi-cubical''
sets); {\em truncated} because we consider only such cubical sets up
to some fixed dimension.

On top of the basic definitions on
Figures~\ref{fig:barecubicalsetstructure},
\ref{fig:barecubicalsetfaces} and \ref{fig:barecubicalsetcoherences},
we can define on Figure~\ref{fig:macros} and~\ref{fig:macroscont} a few other concepts at a
more standard level of abstraction. In particular, a homogeneous
$n$-box in the above sense is defined to be an object of type
$\mybox{l}^{n,n}(D_{n})$ for $D_{n} \defeq (A,=_A,...,=^n_A)$ the initial
segment of $n$-th first iterated equalities over $A$ (by convention, a
homogeneous $0$-box shall be the canonical singleton type). A $n$-tube
is of type $\mybox{l}^{n+1,n}(D_{n+1})$. An homogeneous (proper) $n$-cube
in some $n$-box $d$ is of type $\mycube{l}^{n+1,n}(\hd(D_{n+1}))(\tl(D_{n+1}))(d)$ and a
full $n$-cube is of type $\mycube{l}^{n+1,0}(\hd(D_{n+1}))(\tl(D_{n+1})))(\star)$.

Note that the components of an $n$-box or $n$-tube are tuples
associated to the left while the components of an $n$-cube are tuples
associated to the right. Figure~\ref{fig:macros} show how to compute
the $n$-box surrounding a full $n$-cube over a prefix $D_{n+1}$ of
iterated equalities (see $\border{}$).

Figure~\ref{fig:macros} also shows how to compute the faces of a box or of a cube.

\begin{figure*}
\centerline{ \framebox{$
\begin{array}{llcl}
\multicolumn{4}{c}{\mbox{\it Type of full $n$-boxes}}\\
\\
\mybox{l}^{n} & (D:\partialcubset{l}^{n}) & : & \sort{l}\\
\mybox{l}^{n} & D & \defeq & \mybox{l}^{n,n}(D)\\
\\
\multicolumn{4}{c}{\mbox{\it Type of $n$-tubes}}\\
\\
\tube{l}^{n} & (D:\partialcubset{l}^{n+1}) & : & \sort{l}\\
\tube{l}^{n} & D & \defeq & \mybox{l}^{n+1,n}(D)\\
\\
\multicolumn{4}{c}{\mbox{\it Type of full $n$-cubes}}\\
\\
\mycube{l}^{n} & (D:\partialcubset{l}^{n+1}) & : & \sort{l}\\
\mycube{l}^{n} & (D,E) & \defeq & \mycube{l}^{n,0}(D)(E)(\star)\\
\\
\multicolumn{4}{c}{\mbox{\it Type of a proper $n$-cube over some $n$-box}}\\
\\
\propercube{l}^{n} & (D:\partialcubset{l}^{n+1})~(d:\mybox{l}^{n}(\hd(D))) & : & \sort{l}\\
\propercube{l}^{n} & (D,E)~d & \defeq & E(d)\\
\\
\multicolumn{4}{c}{\mbox{\it Border of a full $n$-cube}}\\
\\
\border{l}^{n} & (D:\partialcubset{l}^{n+1})~(c:\mycube{l}^{n}(D)) & : & \mybox{l}^{n}(\hd(D))\\
\border{l}^{n} & D~c & \defeq & \border{l}^{n,0}(D)(\star)(c)\\
\\
\multicolumn{4}{c}{\mbox{\it where the border of partial cubes is defined by}}\\
\\
\border{l}^{n,p} & (D:\partialcubset{l}^{n+1})~(d:\mybox{l}^{n,p}(\hd(D)))~(c:\mycube{l}^{n,p}(\hd(D))(\tl(E))(d)) & : & \mybox{l}^{n}(\hd(D))\\
\border{l}^{n,p,[p=n]} & D~d~c & \defeq & d\\
\border{l}^{n,p,[p<n]} & D~d~(b,c) & \defeq & \border{l}^{n,p+1}(D)(d,b)(c)\\
\end{array}
$
}}
\caption{Standard notions}
\label{fig:macros}
\end{figure*}

\begin{figure*}
\centerline{ \framebox{$
\begin{array}{llcl}
\multicolumn{4}{c}{\mbox{$q$-th projection of an $n$-box}}\\
\\
\downbox{l}{\epsilon}^{n,q,[q < n]} & (D:\partialcubset{l}^{n})~(d:\mybox{l}^{n}(D)) &:& \mybox{l}^{n-1}(\hd(D))\\
\downbox{l}{\epsilon}^{n,q} & D~(d,\_) &\defeq& \downbox{l}{\epsilon}^{n,q,n-1}(D)(d)\\
\\
\multicolumn{4}{c}{\mbox{$q$-th face of an $n$-cube}}\\
\\
\downcube{l}{\epsilon}^{n,q,[q < n]} & (D:\partialcubset{l}^{n+1})~(c:\mycube{l}^{n}(D)) &:& \mycube{l}^{n-1}(\hd(D))\\
\downcube{l}{\epsilon}^{n,q} & (D,E)~c &\defeq& \downcube{l}{\epsilon}^{n,q,0}(D)(E)(\star)(c)\\
\\
\multicolumn{4}{c}{\mbox{\it where the extension of $\downbox{l}{}$ to $p>q$ is}}\\
\\
\downbox{l}{\epsilon}^{n,q,p,[q < p < n]} & (D:\partialcubset{l}^{n})~(d:\mybox{l}^{n,p}(D))& : & \mybox{l}^{n-1}(\hd(D))\\
\downbox{l}{\epsilon}^{n,q,q+1} & D~(d,b) & \defeq & \border{l}^{n-1,q}(\hd(D))(\downbox{l}{\epsilon}^{n,q,q}(D)(d))(b_{\epsilon})\\
\downbox{l}{\epsilon}^{n,q,p,[q < p-1]} & D~(d,b) & \defeq & \downbox{l}{\epsilon}^{n,q,p-1}(D)(d)
\end{array}
$
}}
\caption{Standard notions (continued)}
\label{fig:macroscont}
\end{figure*}

\subsection{Types as cubical sets}

We shall interpret types as cubical sets, themselves obtained as the
coinductive limit of truncated cubical sets, see Figure~\ref{fig:barecubicalset}.

\begin{figure*}
\centerline{ \framebox{$
\begin{array}{llcl}
\multicolumn{4}{c}{\mbox{Full (non-truncated) bare cubical sets}}\\
\\
\mycubset_l && \defeq & \mycubset_l^0(\star)\\
\\
\mycubset_l^n & (D:\partialcubset{l}^n) & : & \sort{l+1}\\
\mycubset_l^n & D & \defeq & \Sigma R:(\mybox{l}^{n,n}(D) \imp \sort{l}).\,\mycubset_l^{n+1}(D,R)
\end{array}
$
}}
\caption{Definition of a bare cubical set (coinductive structure)}
\label{fig:barecubicalset}
\end{figure*}

\subsection{Cubes of types}

\subsection{Heterogeneous $n$-cubes}

While homogeneous $n$-boxes and $n$-cubes are useful to interpret
types as cubical $\omega$-groupoids, we need to define heterogeneous
$n$-cubes over $n$-cubes of types to interpret both judgements and
iterated equalities.

The structure of heterogeneous cubes is similar to the one of
homogeneous cubes but with two levels, one level of heterogeneous
types and another heterogeneous level for fillers.
%% We make it parameterized over two functors:
%% $$
%% \begin{array}{llll}
%% \phi_n & (D:\myheterocubetype{l}^{n,n}) &:& \sort{l+1}\\
%% \psi_n & (D:\myheterocubetype{l}^{n,n})~(P:F(D))~(d:\myheterocube{l}^{n,n}(D)) & : &\sort{l}\\
%% \end{array}
%% $$
%% which, in the basic case of iterated parametricity, as in Bernardy, Coquand and
%% Moulin~\cite{BernardyCoquandMoulin15}, shall be instantiated by
%% $$
%% \begin{array}{llll}
%% \phi_n & D & \defeq & \myheterobox{l}^{n,n}(D) \imp \sort{l}\\
%% \psi_n & D~P~d & \defeq & P\,d\\
%% \end{array}
%% $$

The construction is a large mutual definition dispatched on
Figures~\ref{fig:heterobarecubicalsettype},
\ref{fig:heterobarecubicalset},
\ref{fig:heterobarecubicalsetfacestype},
\ref{fig:heterobarecubicalsetfaces},
\ref{fig:heterobarecubicalsetcoherencestype} and
\ref{fig:heterobarecubicalsetcoherences}.

\begin{figure*}
\centerline{ \framebox{$
\begin{array}{llcl}
\myheteroboxtype{l}^{n,p,[p \leq n]} & & : & \sort{l+1}\\
\myheteroboxtype{l}^{n,0} & & \defeq & \unittype\\
\myheteroboxtype{l}^{n,p'+1} & & \defeq & \Sigma D:\myheteroboxtype{l}^{n,p'}.\,\myheterolayertype{l}^{n,p'}(D)\\
\\
\myheterolayertype{l}^{n,p,[p < n]} & (D:\myheteroboxtype{l}^{n,p}) & : & \sort{l+1}\\
\myheterolayertype{l}^{n,p} & D & \defeq & \!\!\begin{array}{l}\myheterocubetype{l}^{n-1,p}(\downboxtype{l}{L}^{n,p,p}(D)) \\\times\; \myheterocubetype{l}^{n-1,p}(\downboxtype{l}{R}^{n,p,p}(D))\end{array}\\
\\
\myheterocubetype{l}^{n,p,[p \leq n]} & (D:\myheteroboxtype{l}^{n,p}) & : & \sort{l+1}\\
\myheterocubetype{l}^{n,p,[p = n]} & D & \defeq & \myheterobox{l}^{n,n}(D) \imp \sort{l}\\
\myheterocubetype{l}^{n,p,[p < n]} & D & \defeq & \Sigma B:\myheterolayertype{l}^{n,p}(D).\,\myheterocubetype{l}^{n,p+1}(D,B)\\
\end{array}
$
}}
\caption{Definition of a heterogeneous cube (cube of higher-order relations)}
\label{fig:heterobarecubicalsettype}
\end{figure*}

\begin{figure*}
\centerline{ \framebox{$
\begin{array}{llcl}
\myheterobox{l}^{n,p,[p \leq n]} & (D:\myheteroboxtype{l}^{n,n}) & : & \sort{l}\\
\myheterobox{l}^{n,0} & D & \defeq & \unittype\\
\myheterobox{l}^{n,p'+1,[p' < n]} & D & \defeq & \Sigma d:\myheterobox{l}^{n,p'}(D).\,\myheterolayer{l}^{n,p'}(D)(d)\\
\\
\myheterolayer{l}^{n,p,[p < n]} & \!\!\!\begin{array}{l}(D:\myheteroboxtype{l}^{n,n})\\(d:\myheterobox{l}^{n,p}(D))\end{array}& : & \sort{l}\\
\myheterolayer{l}^{n,p} & D ~d & \defeq & \!\!\begin{array}{l}\myheterocube{l}^{n-1,p}(\downboxtype{l}{L}^{n,p,n-1}(\hd(D)))(\tl(D)_L)(\heterodownbox{l}{L}^{n,p,p}(D)(d)) \\\times\; \myheterocube{l}^{n-1,p}(\downboxtype{l}{R}^{n,p,n-1}(\hd(D)))(\tl(D)_R)(\heterodownbox{l}{R}^{n,p,p}(D)(d))\end{array}\\
\\
\myheterocube{l}^{n,p,[p \leq n]} & \!\!\!\begin{array}{l}(D:\myheteroboxtype{l}^{n,n})\\(E:\myheterocubetype{l}^{n,n}(D))\\(d:\myheterobox{l}^{n,p}(D))\end{array}& : & \sort{l}\\
\myheterocube{l}^{n,p,[p = n]} & D~E~d & \defeq & E(d)\\
\myheterocube{l}^{n,p,[p < n]} & D~E~d & \defeq & \Sigma b:\myheterolayer{l}^{n,p}(D)(d).\,\myheterocube{l}^{n,p+1}(D)(E)(d,b)\\
\\
\end{array}
$
}}
\caption{Definition of a heterogeneous cube (cube of terms)}
\label{fig:heterobarecubicalset}
\end{figure*}

\begin{figure*}
\centerline{ \framebox{$
\begin{small}
\begin{array}{llcl}
\downboxtype{l}{\epsilon}^{n,q,p,[p \leq q < n]} & (D:\myheteroboxtype{l}^{n,p}) & : & \myheteroboxtype{l}^{n-1,p}\\
\downboxtype{l}{\epsilon}^{n,q,0} & \unitpoint & \defeq & \unitpoint\\
\downboxtype{l}{\epsilon}^{n,q,p'+1} & (D,B) & \defeq & (\downboxtype{l}{\epsilon}^{n,q,p'}(D),\downlayertype{l}{\epsilon}^{n,q,p'}(D)(B))\\
\\
\downlayertype{l}{\epsilon}^{n,q,p,[p < q < n]} & \!\!\!\begin{array}{l}(D:\myheteroboxtype{l}^{n,p})\\(B:\myheterolayertype{l}^{n,p}(D))\end{array}& : & \myheterolayertype{l}^{n-1,p}(\downboxtype{l}{\epsilon}^{n,q,p}(D))\\
\downlayertype{l}{\epsilon}^{n,q,p} & D~(C_0,C_1) & \defeq & \!\!\begin{array}{l}(\overrightarrow{\cohboxtype{l}{\epsilon,L}^{n,q,p,p}(D)}(\downcubetype{l}{\epsilon}^{n-1,q-1,p}(\downboxtype{l}{L}^{n,p,p}(D))(C_0)),\\\;\overrightarrow{\cohboxtype{l}{\epsilon,R}^{n,q,p,p}(D)}(\downcubetype{l}{\epsilon}^{n-1,q-1,p}(\downboxtype{l}{R}^{n,p,p}(D))(C_1)))\end{array}\\
\\
\downcubetype{l}{\epsilon}^{n,p,q,[p \leq q < n]} & \!\!\!\begin{array}{l}(D:\myheteroboxtype{l}^{n,p})\\(C:\myheterocubetype{l}^{n,p}(D))\end{array}& : & \myheterocubetype{l}^{n-1,p}(\downboxtype{l}{\epsilon}^{n,q,p}(D))\\
\downcubetype{l}{\epsilon}^{n,q,p,[p=q]} & D~(B,\_) & \defeq & B_{\epsilon}\\
\downcubetype{l}{\epsilon}^{n,q,p,[p<q]} & D~(B,C) & \defeq & \letinsplit{B'}{\downlayertype{l}{\epsilon}^{n,q,p}(D)(B)}{(B',\downcubetype{l}{\epsilon}^{n,q,p+1}(D,B')(C))}\\
\\
\multicolumn{4}{c}{\mbox{TODO: add $\downboxtype{}{}$ for $p>q$}}
\end{array}
\end{small}
$
}}
\caption{Definition of a heterogeneous cube (faces of higher-order relations)}
\label{fig:heterobarecubicalsetfacestype}
\end{figure*}

\begin{figure*}
\centerline{ \framebox{$
\begin{small}
\begin{array}{llcl}
\heterodownbox{l}{\epsilon}^{n,q,p,[p \leq q < n]} & \!\!\!\begin{array}{l}(D:\myheteroboxtype{l}^{n,n})\\(d:\myheterobox{l}^{n,p}(D))\end{array}& : & \myheterobox{l}^{n-1,p}(\downboxtype{l}{\epsilon}^{n,q,n-1}(\hd(D)))\\
\heterodownbox{l}{\epsilon}^{n,q,0} & D~\unitpoint & \defeq & \unitpoint\\
\heterodownbox{l}{\epsilon}^{n,q,p'+1} & D~(d,b) & \defeq & (\heterodownbox{l}{\epsilon}^{n,q,p'}(D)(d),\heterodownlayer{l}{\epsilon}^{n,q,p'}(D)(d)(b))\\
\\
\heterodownlayer{l}{\epsilon}^{n,q,p,[p < q < n]} & \!\!\!\begin{array}{l}(D:\myheteroboxtype{l}^{n,n})\\(d:\myheterobox{l}^{n,p}(D))\\(b:\myheterolayer{l}^{n,p}(D)(d))\end{array}& : & \myheterolayer{l}^{n-1,p}(\downboxtype{l}{\epsilon}^{n,q,n-1}(\hd(D)))(\heterodownbox{l}{\epsilon}^{n,q,p}(D)(d))\\
\heterodownlayer{l}{\epsilon}^{n,q,p} & D~d~c & \defeq & \!\!\begin{array}{l}(\!\!\!\begin{array}{l}(\overrightarrow{\cohboxtype{l}{\epsilon,L}^{n,q,p,p}(D)(d)},\\\overrightarrow{\heterocohbox{l}{\epsilon,L}^{n,q,p,p}(D)(d)})\end{array}(\heterodowncube{l}{\epsilon}^{n-1,q-1,p}\left(\!\!\!\begin{array}{l}\downboxtype{l}{L}^{n,p,n-1}(D)\\\tl(D)_L\\\heterodownbox{l}{L}^{n,p,p}(D)(d)\\c_L\end{array}\right)),\\\;\!\!\!\begin{array}{l}(\overrightarrow{\cohboxtype{l}{\epsilon,R}^{n,q,p,p}(D)(d)},\\\overrightarrow{\heterocohbox{l}{\epsilon,R}^{n,q,p,p}(D)(d)})\end{array}(\heterodowncube{l}{\epsilon}^{n-1,q-1,p}\left(\!\!\!\begin{array}{l}\downboxtype{l}{R}^{n,p,n-1}(D)\\\tl(D)_R\\\heterodownbox{l}{R}^{n,p,p}(D)(d)\\c_R\end{array}\right)))\end{array}\\
\\
\heterodowncube{l}{\epsilon}^{n,q,p,[p \leq q < n]} & \!\!\!\begin{array}{l}(D:\myheteroboxtype{l}^{n,n})\\(E:\myheterocubetype{l}^{n,n}(D))\\(d:\myheterobox{l}^{n,p}(D))\\(c:\myheterocube{l}^{n,p}(D)(E)(d))\end{array}& : & \myheterocube{l}^{n-1,p}(\downboxtype{l}{\epsilon}^{n,q,n-1}(D))(\tl(D)_{\epsilon})(\heterodownbox{l}{\epsilon}^{n,q,p}(D)(d))\\
\heterodowncube{l}{\epsilon}^{n,q,p,[p=q]} & D~E~d~(b,\_) & \defeq & b_{\epsilon}\\
\heterodowncube{l}{\epsilon}^{n,q,p,[p<q]} & D~E~d~(b,c) & \defeq & \letinsplit{b'}{\heterodownlayer{l}{\epsilon}^{n,q,p}(D)(d)(b)}{(b',\heterodowncube{l}{\epsilon}^{n,q,p+1}(D)(E)(d,b')(c))}\\
%\\
%\multicolumn{4}{c}{\mbox{TODO: add $\heterodownbox{}{}$ for $n>q$}}
\end{array}
\end{small}
$
}}
\caption{Definition of a heterogeneous cube (faces of terms)}
\label{fig:heterobarecubicalsetfaces}
\end{figure*}

\begin{figure*}
\centerline{ \framebox{$
\begin{small}
\begin{array}{llcl}
\cohboxtype{l}{\epsilon,\epsilon'}^{\!\!\!\tiny\begin{array}{l}n,q,p,r\\\mbox{}[p \leq r < q < n]\end{array}} & \!\!\!\begin{array}{l}(D:\myheteroboxtype{l}^{n,p})\end{array}& : & \!\!\!\begin{array}{ll}\downboxtype{l}{\epsilon}^{n-1,q,p}(\downboxtype{l}{\epsilon'}^{n,r,p}(D)) \\ \eqett \downboxtype{l}{\epsilon'}^{n-1,r,p}(\downboxtype{l}{\epsilon}^{n,q,p}(D))\end{array}\\
\cohboxtype{l}{\epsilon,\epsilon'}^{n,q,r,0} & D~\unitpoint & \defeq & \reflett(\unitpoint)\\
\cohboxtype{l}{\epsilon,\epsilon'}^{n,q,r,p'+1} & D~(d,b) & \defeq & (\cohboxtype{l}{\epsilon,\epsilon'}^{n,q,p,r,p'}(D)(d),\cohlayertype{l}{\epsilon,\epsilon'}^{n,q,r,p'}(D)(d)(b))\\
\\
\cohlayertype{l}{\epsilon,\epsilon'}^{\!\!\!\tiny\begin{array}{l}n,q,r,p\\\mbox{}[p < r < q < n]\end{array}} & \!\!\!\begin{array}{l}(D:\myheteroboxtype{l}^{n,p})\\(B:\myheterolayertype{l}^{n,p}(D)\end{array}& : & \!\!\!\begin{array}{ll}\downlayertype{l}{\epsilon}^{n-1,q-1,p}(\downboxtype{l}{\epsilon'}^{n,r,p}(D))(\downlayertype{l}{\epsilon'}^{n,r,p}(D)(B)) \\ \eqett \downlayertype{l}{\epsilon'}^{n-1,r-1,p}(\downboxtype{l}{\epsilon}^{n,q,p}(D))(\downlayertype{l}{\epsilon}^{n,q,p}(D)(B))\end{array}\\
\cohlayertype{l}{\epsilon,\epsilon'}^{n,q,r,p} & D~C & \defeq & \!\!\begin{array}{l}(\cohcubetype{l}{\epsilon,\epsilon'}^{n-1,q-1,r-1,p}(\downboxtype{l}{L}^{n,p,p}(D))(C_L),\\\;\cohcubetype{l}{\epsilon,\epsilon'}^{n-1,q-1,r-1,p}(\downboxtype{l}{R}^{n,p,p}(D))(C_R))\end{array}\\
\\
\cohcubetype{l}{\epsilon,\epsilon'}^{\!\!\!\tiny\begin{array}{l}n,q,r,p\\\mbox{}[p \leq r < q < n]\end{array}} & \!\!\!\begin{array}{l}(D:\myheteroboxtype{l}^{n,p})\\(C:\myheterocubetype{l}^{n,p}(D))\end{array}& : & \!\!\!\begin{array}{ll}\downcubetype{l}{\epsilon}^{n-1,q-1,p}(\downboxtype{l}{\epsilon'}^{n,q,p}(D))(\downcubetype{l}{\epsilon'}^{n,r,p}(D)(C)) \\ \eqett \downcubetype{l}{\epsilon'}^{n-1,r-1,p}(\downboxtype{l}{\epsilon}^{n,q,p}(D))(\downcubetype{l}{\epsilon}^{n,q,p}(D)(C))\end{array}\\
\cohcubetype{l}{\epsilon,\epsilon'}^{n,q,r,p,[p=r]} & D~(B,\_) & \defeq & \reflett(\downcubetype{l}{\epsilon}^{n-1,q-1,p}(\downboxtype{l}{\epsilon'}^{n,q,p}(D))(B_{\epsilon}))\\
\cohcubetype{l}{\epsilon,\epsilon'}^{n,q,r,p,[p<r)} & D~(B,C) & \defeq & \!\!\begin{array}{l}(\cohlayertype{l}{\epsilon,\epsilon'}^{n,q,r,p}(D)(B),\\\;\cohcubetype{l}{\epsilon,\epsilon'}^{n,q,r,p+1}(D,\downlayertype{l}{\epsilon}^{n,q,p}(D)(B))(C))\end{array}\\
\\
\multicolumn{4}{c}{\mbox{TODO: add ${\cohboxtype{}{}}$ for $p>q$}}
\end{array}
\end{small}
$
}}
\caption{Definition of a heterogeneous cube (compatibility of faces of higher-order relations)}
\label{fig:heterobarecubicalsetcoherencestype}
\end{figure*}

\begin{figure*}
\centerline{\framebox{$
\begin{small}
\begin{array}{llcl}
\heterocohbox{l}{\epsilon,\epsilon'}^{\!\!\!\tiny\begin{array}{l}n,q,r,p\\\mbox{}[p \leq r < q < n]\end{array}} & \!\!\!\begin{array}{l}(D:\myheteroboxtype{l}^{n,n})\\(d:\myheterobox{l}^{n,p}(D))\end{array}& : & \!\!\!\begin{array}{ll}\heterodownbox{l}{\epsilon}^{n-1,q-1,p}(\downboxtype{l}{\epsilon'}^{n,r,p}(\hd(D)))(\heterodownbox{l}{\epsilon'}^{n,r,p}(D)(d)) \\ \eqett \heterodownbox{l}{\epsilon'}^{n-1,r-1,p}(\downboxtype{l}{\epsilon}^{n,q,p}(\hd(D)))(\heterodownbox{l}{\epsilon}^{n,q,p}(D)(d))\end{array}\\
\heterocohbox{l}{\epsilon,\epsilon'}^{n,q,r,0} & D~\unitpoint & \defeq & \reflett(\unitpoint)\\
\heterocohbox{l}{\epsilon,\epsilon'}^{n,q,r,p'+1} & D~(d,b) & \defeq & (\heterocohbox{l}{\epsilon,\epsilon'}^{n,q,r,p'}(D)(d),\heterocohlayer{l}{\epsilon,\epsilon'}^{n,q,r,p'}(D)(d)(b))\\
\\
\heterocohlayer{l}{\epsilon,\epsilon'}^{\!\!\!\tiny\begin{array}{l}n,q,r,p\\\mbox{}[p < r < q < n]\end{array}} & \!\!\!\tiny\begin{array}{l}(D:\myheteroboxtype{l}^{n,p})\\(d:\myheterobox{l}^{n,p}(D))\\(b:\myheterolayer{l}^{n,p}(D)(d))\end{array}& : & \!\!\!\begin{array}{ll}\heterodownlayer{l}{\epsilon}^{n-1,q-1,p}(\downboxtype{l}{\epsilon'}^n(D))(\heterodownbox{l}{\epsilon'}^{n,r,p}(D)(d))(\heterodownlayer{l}{\epsilon'}^{n,r,p}(D)(d)(b)) \\ \eqett \heterodownlayer{l}{\epsilon'}^{n-1,r-1,p}(\downboxtype{l}{\epsilon}^n(D))(\heterodownbox{l}{\epsilon}^{n,r,p}(D)(d))(\heterodownlayer{l}{\epsilon}^{n,r,p}(D)(d)(b))\end{array}\\
\heterocohlayer{l}{\epsilon,\epsilon'}^{n,q,r,p} & D~d~c & \defeq & \!\!\begin{array}{l}(\heterocohcube{l}{\epsilon,\epsilon'}^{n,q,r,p}(D)(\heterodownbox{l}{L}^{n,p,p}(D)(d))(c_L),\\\;\heterocohcube{l}{\epsilon,\epsilon'}^{n,q,r,p}(D)(\heterodownbox{l}{R}^{n,p,p}(D)(d))(c_R))\end{array}\\
\\
\heterocohcube{l}{\epsilon,\epsilon'}^{\!\!\!\tiny\begin{array}{l}n,q,r,p\\\mbox{}[p \leq r < q < n]\end{array}} & \!\!\!\tiny\begin{array}{l}(D:\myheteroboxtype{l}^{n,p})\\(d:\myheterobox{l}^{n,p}(D))\\(b:\myheterocube{l}{??}^{n,p}(D)(d))\end{array}& : & \!\!\!\begin{array}{ll}\heterodowncube{l}{\epsilon}^{n-1,q-1,p}(\downboxtype{l}{\epsilon'}^{n,q,p}(D))(\heterodownbox{l}{\epsilon'}^{n,r,p}(D)(d))(\heterodowncube{l}{\epsilon'}^{n,r,p}(D)(d)(b)) \\ \eqett \heterodowncube{l}{\epsilon'}^{n-1,r-1,p}(\downboxtype{l}{\epsilon}^{n,q,p}(D))(\heterodownbox{l}{\epsilon}^{n,q,p}(D)(d))(\heterodowncube{l}{\epsilon}^{n,q,p}(D)(d)(b))\end{array}\\
\heterocohcube{l}{\epsilon,\epsilon'}^{n,q,r,p,[p=r]} & D~d~(b,\_) & \defeq & \reflett(\heterodowncube{l}{\epsilon}^{n-1,q-1,p}(\downboxtype{l}{\epsilon'}^n(D))(\heterodownbox{l}{\epsilon'}^{n,q,p}(D)(d))(b_{\epsilon}))\\
\heterocohcube{l}{\epsilon,\epsilon'}^{n,q,r,p,[p<r)} & D~d~(b,c) & \defeq & \!\!\begin{array}{l}(\heterocohlayer{l}{\epsilon,\epsilon'}^{n,q,r,p}(\downboxtype{l}{\epsilon}^n(D))(d)(b),\\\;\heterocohcube{l}{\epsilon,\epsilon'}^{n,q,r,p+1}(D)(d,\heterodownlayer{l}{\epsilon}^{n,q,p}(\downboxtype{l}{\epsilon?}^n(D))(d)(b))(c))\end{array}\\
\end{array}
\end{small}
$
}}
\caption{Definition of a heterogeneous cube (compatibility of faces of terms)}
\label{fig:heterobarecubicalsetcoherences}
\end{figure*}

TODO: Unify the different variants of $\Sigma$-types: $\times$,
records, names of the projections.

\subsection{Dependent cubes}

See Figure~\ref{fig:heterobaredepcube}.

\begin{figure*}
\centerline{ \framebox{$
\begin{array}{llcl}
\myheterodepboxtype{l}^{n,p,[p \leq n]} & (D:\myheteroboxtype{l}^{n,n}) & : & U_{l+1}\\
\myheterodepboxtype{l}^{n,0} & D & \defeq & \unittype\\
\myheterodepboxtype{l}^{n,p'+1} & D & \defeq & \Sigma d:\myheterodepboxtype{l}^{n,p'}(D).\,\myheterolayertype{l}^{n,p'}(D)(d)\\
\\
\myheterodeplayertype{l}^{n,p,[p < n]} & \!\!\!\begin{array}{l}(D:\myheteroboxtype{l}^{n,n})\\(d:\myheterodepboxtype{l}^{n,p}(D))\end{array}& : & \sort{l+1}\\
\myheterodeplayertype{l}^{n,p} & D~d & \defeq & \!\!\!\begin{array}{l}\myheterodepcubetype{l}^{n-1,p}(\downboxtype{l}{L}^{n,n-1}(\hd(D)))(\tl(D)_L)(\heterodepdownboxtype{L}^{n,p,p}(D)(d)) \\\times\; \myheterodepcubetype{l}^{n-1,p}(\downboxtype{l}{L}^{n,n-1}(\hd(D)))(\tl(D)_R)(\heterodepdownboxtype{R}^{n,p,p}(D)(d))\end{array}\\
\\
\multicolumn{4}{c}{\mbox{+ definition of $\heterodepdownboxtype{\epsilon}$}}\\
\\
\myheterodepcubetype{l}^{n,p,[p < n]} & \!\!\!\begin{array}{l}(D:\myheteroboxtype{l}^{n,n})\\(E:\myheterocubetype{l}^{n,n}(D))\\(d:\myheterodepboxtype{l}^{n,p}(D))\end{array}& : & \sort{l+1}\\
\myheterodepcubetype{l}^{n,p,[p = n]} & D~E~d & \defeq & \Pi d':\myheterobox{l}^{n,n}(D). \Pi c:\myheterocube{l}^{n,n}(D)(E)(d'). \myheterobox{l}^{n,n}(\myappdepboxtype{l}^{n,n}(D)(d)(d')) \imp \sort{l}\\
\myheterodepcubetype{l}^{n,p,[p < n]} & D~E~d & \defeq & \Sigma b:\myheterodeplayertype{l}^{n,p}(D)(d).\,\myheterodepcubetype{l}^{n,p+1}(D)(d,b)\\
\end{array}
$
}}
\caption{Definition of a heterogeneous dependent cube of higher-order relations}
\label{fig:heterobaredepcube}
\end{figure*}

\begin{figure*}
\centerline{ \framebox{$
\begin{array}{llcl}
\myappdepboxtype{l}^{n,p,[p \leq n]} & \!\!\!\begin{array}{l}(D:\myheteroboxtype{l}^{n,n})\\(d:\myheterodepboxtype{l}^{n,p}(D))\\(d':\myheterobox{l}^{n,p}(D))\end{array}& : & \myheteroboxtype{l}^{n,p}\\
\myappdepboxtype{l}^{n,0} & D~\star~\star & \defeq & \star\\
\myappdepboxtype{l}^{n,p'+1} & D~(d,b)~(d',b') & \defeq & (\myappdepboxtype{l}^{n,p'}(D)(d)(d'),\myappdeplayertype{l}^{n,p'}(D)(d)(d')(b)(b'))\\
\\
\myappdeplayertype{l}^{n,p,[p \leq n]} & \!\!\!\begin{array}{l}(D:\myheteroboxtype{l}^{n,n})\\(d:\myheterodepboxtype{l}^{n,p}(D))\\(d':\myheterobox{l}^{n,p}(D))\\(b:\myheterodeplayertype{l}^{n,p}(D)(d))\\(b':\myheterolayer{l}^{n,p}(D)(d'))\end{array} & : & \myheterolayertype{l}^{n,p}(\myappdepboxtype{l}^{n,p'}(D)(d)(d'))\\
\myappdeplayertype{l}^{n,p} & D~d~d'~c~c' & \defeq & \!\!\!\begin{array}{l}(\myappdepcubetype{l}^{n-1,p}\!\!\!\begin{array}{l}(\downboxtype{l}{L}^{n,n-1,n-1}(\hd(D)))\\(\heterodepdownbox{L}^{n,n-1,n-1}(d))\\(\heterodownbox{l}{L}^{n,n-1,n-1}(d'))\end{array}(c_L)(c_L'), \\~\myappdepcubetype{l}^{n-1,p}\!\!\!\begin{array}{l}(\downboxtype{l}{R}^{n,n-1,n-1}(\hd(D)))\\(\heterodepdownbox{R}^{n,n-1,n-1}(d))\\(\heterodownbox{l}{R}^{n,n-1,n-1}(d'))\end{array}(c_R)(c_R'))\end{array}\\
\\
\multicolumn{4}{c}{\mbox{+ proofs of commutations $\downboxtype{l}{}$/$\myappdepboxtype{}$}}\\
\\
\myappdepcubetype{l}^{n,p,[p \leq n]} & \!\!\!\begin{array}{l}(D:\myheteroboxtype{l}^{n,n})\\(d:\myheterodepboxtype{l}^{n,p}(D))\\(d':\myheterobox{l}^{n,p}(D))\\(c:\myheterodepcubetype{l}^{n,p}(D)(d))\\(c':\myheterocube{l}^{n,p}(D)(d'))\end{array} & : & \myheterocubetype{l}^{n,p}(\myappdepboxtype{l}^{n,p'}(D)(d)(d'))\\
\myappdepcubetype{l}^{n,p,[p = n]} & D~d~d'~c~c' & \defeq & (c\,d'\,c')\\
\myappdepcubetype{l}^{n,p,[p < n]} & D~d~d'~(b,c)~(b',c') & \defeq & (\myappdeplayertype{l}^{n,p}(D)(d)(d')(b)(b'),\myappdepcubetype{l}^{n,p+1}(D)(d)(d')(c)(c'))\\
\end{array}
$
}}
\caption{Definition of a heterogeneous dependent cube of higher-order relations (application)}
\label{fig:heterobaredepcubemap}
\end{figure*}
\iffalse %%%
\subsection{Symmetric cartesian structure of cubes}

In order to interpret abstraction and application over a variable of
the interval we need to equip the bare structure of cubical sets with
arbitrary maps from a finite set of variables of the interval to
another finite set of variables of the interval of same or larger
cardinality (if we want the application of the same variable to be
allowed several times, we also to allow maps to a finite set of
smaller cardinality).

There are different ways to canonically represent such maps. One of
these ways is to factorize the maps using reflexivities
(i.e. degeneracies in the language of cubical sets, or identities in
the language of category theory) and permutations (called symmetries
in the context of cubical sets).

The additional structure defining a symmetric cubical set with
degeneracies is given on Figure~\ref{fig:symcubicalset},
\ref{fig:reflexivity} and \ref{fig:permutation}. To allow maps to a
finite set of smaller cardinality, we also need diagonals which are
additionally presented on Figure~\ref{fig:diagonals}. Also,
connections shall be needed to support dependent composition. These
are on Figure~\ref{fig:connections}.

\begin{figure*}
\centerline{ \framebox{$
\begin{array}{llcl}
\partialsymcubset^n & (D:\partialcubset{l}^n) & : & \sort{l+1}\\
\partialsymcubset^0 & \star & \defeq & \unittype\\
\partialsymcubset^{n+1} & (D,R) & \defeq & \Sigma S:\partialsymcubset^n(D).\,\issymcubset^n(D)(R)(S)\\
\\
\issymcubset^n & \!\!\!\begin{array}{l}(D:\partialcubset{l}^{n})\\(R:\mybox{l}^{n,n}(D) \imp \sort{l})\\(S:\partialsymcubset^n(D))\end{array}& \defeq & \{\\
&&& \mathsf{reflexive} ~:~ \reflexive^n(D)(R)(S);\\
&&& \mypermute ~:~ \permutation^n(D)(R)(S);\\
&&& \diagprop ~:~ \diagprop^n(D)(R)(S);\\
&&& \}\\
\end{array}
$
}}
\caption{Definition of a truncated symmetric cartesian cubical set}
\label{fig:symcubicalset}
\end{figure*}

\begin{figure*}
\centerline{ \framebox{$
\begin{small}
\begin{array}{llcl}
\reflexive_l^n & \!\!\!\begin{array}{l}(D:\partialcubset{l}^{n})\\(R:\mybox{l}^{n,n}(D)\imp \sort{l})\end{array}& : & \sort{l}\\
\reflexive^0 & \unitpoint~A & \defeq & \unittype\\
\reflexive^{n+1} & (D,R_n)~(R^{n+1}) & \defeq & \!\!\!\begin{array}{l}\Pi d:\mybox{l}^{n,n}(\hd(D)).\, \Pi c:R_n\,d.\,\\ R^{n+1}(\reflbox^{n+1,n}(D)(d),(\overrightarrow{\cohrefleqbox{R}^{n+1,n}(D)(d)}(c),\overrightarrow{\cohrefleqbox{L}^{n+1,n}(D)(d)}(c)))\end{array}\\
\\
\reflbox^{n+1,p,[p \leq n]} & \!\!\!\begin{array}{l}(D : \partialcubset{l}^{n+1})\\(d:\mybox{l}^{n,p}(\hd(D)))\end{array}& : & \mybox{l}^{n+1,p}(D)\\
\reflbox^{n+1,0} & D~\unitpoint & \defeq & \unitpoint\\
\reflbox^{n+1,p+1} & D~(d,b) & \defeq & (\reflbox^{n+1,p}(D)(d),\refllayer^{n+1,p}(D)(d)(b))\\
\\
\refllayer^{n+2,p,[p \leq n]} & \!\!\!\begin{array}{l}(D : \partialcubset{l}^{n+2})\\(d:\mybox{l}^{n+1,p}(\hd(D)))\\(b:\mylayer{l}^{n+1,p}(\hd(D))(d)\end{array}& : & \mylayer{l}^{n+2,p}(D)(\reflbox^{n+2,p}(D)(d))\\
\refllayer^{n+2,p} & D~d~c & \defeq & \!\!\!\begin{array}{l}(\overrightarrow{\cohreflbox{L}^{n+2,p,p}(D)(d)}(\reflcube^{n+2,p}(D)(\downbox{l}{L}^{n+1,p,p}(\hd(D))(d))(c_L)),\\\;\overrightarrow{\cohreflbox{R}^{n+2,p,p}(D)(d)}(\reflcube^{n+2,p}(D)(\downbox{l}{R}^{n+1,p,p}(\hd(D))(d))(c_R)))\end{array}\\
\\
\reflcube^{n+2,p,[p \leq n]} & \!\!\!\begin{array}{l}(D : \partialcubset{l}^{n+2})\\(d:\mybox{l}^{n,p}(\hd(\hd(D))))\\(c:\mycube{l}^{n+1,p}(\hd(D))(d))\end{array}& : & \mycube{l}^{n+2,p}(D)(\reflbox^{n+1,p}(\hd(D))(d))\\
\reflcube^{n+2,p,[p = n]} & (D,R)~d~c & \defeq & ((\overrightarrow{\cohrefleqbox{L}^{n+2}(D)(d)}(c),\overrightarrow{\cohrefleqbox{R}^{n+2}(D)(d)}(c)),\reflexive^{n+1}(D)(R)(d)(c))\\
\reflcube^{n+3,p,[p < n]} & D~d~(b,c) & \defeq & (\refllayer^{n+2,p}(D)(d)(b),\reflcube^{n+3,p+1}(D)(d)(c))\\
\\
\cohrefleqbox{\epsilon}^{\!\!\!\tiny\begin{array}{l}n,p\\\mbox{}[p \leq n]\end{array}} & \!\!\!\begin{array}{l}(D:\partialcubset{l}^{n+2})\\(d:\mybox{l}^{n+1,p+1}(\hd(D)))\end{array}& : & \!\!\!\begin{array}{ll}\downbox{l}{\epsilon}^{n+2,p+1,n+1}(D)(\reflbox^{n+2,p+1}(D)(d)) \\ \eqett d\end{array}\\
\cohrefleqbox{\epsilon}^{n,0} & D~\unitpoint & \defeq & \reflett(\unitpoint)\\
\cohrefleqbox{\epsilon}^{n+1,p+1} & D~(d,b) & \defeq & (\cohrefleqbox{\epsilon}^{n+1,p}(D)(d),\cohrefleqlayer{\epsilon}^{n+1,p}(D)(d)(b))\\
\\
\cohrefleqlayer{\epsilon}^{\!\!\!\tiny\begin{array}{l}n+1,p\\\mbox{}[p \leq n]\end{array}} & \!\!\!\begin{array}{l}(D:\partialcubset{l}^{n+3})\\(d:\mybox{l}^{n+2,p+1}(\hd(D)))\\(b:\mylayer{l}^{n+2,p+1}(\hd(D))(d))\end{array}& : & \!\!\!\begin{array}{ll}\downlayer{l}{\epsilon}^{n+3,p+1,n+2}(D)(\reflbox^{n+3,p+1}(D)(d))(\refllayer^{n+3,p+1}(D)(d)(b)) \\ \eqett b\end{array}\\
\cohrefleqlayer{\epsilon}^{n+1,p} & D~d~(c_L,c_R) & \defeq & \!\!\!\begin{array}{l}(\cohrefleqcube{\epsilon}^{n+1,p}(D)(\downbox{l}{L}^{n+3,p+1,p+1}(D)(d))(c_L),\\\;\cohrefleqcube{\epsilon}^{n+1,p}(D)(\downbox{l}{R}^{n+3,p+1,p+1}(D)(d))(c_R))\end{array}\\
\\
\cohrefleqcube{\epsilon}^{\!\!\!\tiny\begin{array}{l}n+1,p\\\mbox{}[p \leq n]\end{array}} & \!\!\!\begin{array}{l}(D:\partialcubset{l}^{n+3})\\(d:\mybox{l}^{n+1,p+1}(\hd(\hd(D))))\\(c:\mycube{l}^{n+2,p+1}(\hd(D))(d))\end{array}& : & \!\!\!\begin{array}{ll}\downcube{l}{\epsilon}^{n+3,p+1,n+2}(D)(\reflbox^{n+3,p+1}(D)(d))(\reflcube^{n+3,p+1}(D)(d)(c)) \\ \eqett c\end{array}\\
\cohrefleqcube{\epsilon}^{n+1,p,[n=p]} & D~d~c & \defeq & \reflett(c)\\
\cohrefleqcube{\epsilon}^{n+2,p,[n>p)} & D~d~(b,c) & \defeq & \!\!\!\begin{array}{l}(\cohrefleqlayer{\epsilon}^{n+2,p}(\hd(D))(d)(b),\\\;\cohrefleqcube{\epsilon}^{n+2,p+1}(D)(d,\downlayer{l}{\epsilon}^{n+2,p+1,n+1}(\hd(D))(d)(b))(c))\end{array}\\
\\
\cohreflbox{\epsilon}^{\!\!\!\tiny\begin{array}{l}n+2,p,q\\\mbox{}[p \leq q \leq n]\end{array}} & \!\!\!\begin{array}{l}(D:\partialcubset{l}^{n+2})\\(d:\mybox{l}^{n+1,p}(\hd(D)))\end{array}& : & \!\!\!\begin{array}{ll}\downbox{l}{\epsilon}^{n+2,p,q}(D)(\reflbox^{n+2,p}(D)(d)) \\ \eqett \reflbox^{n+1,p}(\hd(D))(\downbox{l}{\epsilon}^{n+1,p,q}(\hd(D))(d))\end{array}\\
\cohreflbox{\epsilon}^{n+2,0,q} & D~\unitpoint & \defeq & \reflett(\unitpoint)\\
\cohreflbox{\epsilon}^{n+3,p+1,q+1} & D~(d,b) & \defeq & (\cohreflbox{\epsilon}^{n+3,p,q+1}(D)(d),\cohrefllayer{\epsilon}^{n+3,p,q+1}(D)(d)(b))\\
\\
\cohrefllayer{\epsilon}^{\!\!\!\tiny\begin{array}{l}n+3,p,q+1\\\mbox{}[p \leq q \leq n]\end{array}} & \!\!\!\begin{array}{l}(D:\partialcubset{l}^{n+3})\\(d:\mybox{l}^{n+2,p}(\hd(D)))\\(b:\mylayer{l}^{n+2,p}(\hd(D))(d))\end{array}& : & \!\!\!\begin{array}{ll}\downlayer{l}{\epsilon}^{n+3,p,q+1}(D)(\reflbox^{n+3,p}(D)(d))(\refllayer^{n+3,p}(D)(d)(b)) \\ \eqett \refllayer^{n+2,p}(\hd(D))(\downbox{l}{\epsilon}^{n+2,p,q+1}(\hd(D))(d))(\downlayer{l}{\epsilon}^{n+3,p,q+1}(\hd(D))(d)(b))\end{array}\\
\cohrefllayer{\epsilon}^{n+3,p,q+1} & D~d~c & \defeq & \!\!\!\begin{array}{l}(\cohreflcube{\epsilon}^{n+3,p,q+1}(D)(\downbox{l}{L}^{n+3,p,p}(D)(d))(c_R),\\\;\cohreflcube{\epsilon}^{n+3,p,q+1}(D)(\downbox{l}{R}^{n+3,p,p}(D)(d))(c_R))\end{array}\\
\\
\cohreflcube{\epsilon}^{\!\!\!\tiny\begin{array}{l}n+3,p,q+1\\\mbox{}[p \leq q \leq n]\end{array}} & \!\!\!\begin{array}{l}(D:\partialcubset{l}^{n+3})\\(d:\mybox{l}^{n+1,p}(D))\\(b:\mycube{l}^{n+2,p}(D)(d))\end{array}& : & \!\!\!\begin{array}{ll}\downcube{l}{\epsilon}^{n+3,p,q+1}(D)(\reflbox^{n+3,p}(D)(d))(\reflcube^{n+3,p}(D)(d)(b)) \\ \eqett \reflcube^{n+2,p}(\hd(D))(\downbox{l}{\epsilon}^{n+2,p,q+1}(D)(d))(\downcube{l}{\epsilon}^{n+2,p,q+1}(D)(d)(b))\end{array}\\
\cohreflcube{\epsilon}^{n+3,p,q+1,[p=q]} & D~d~(b,\_) & \defeq & \reflett(\reflcube^{n+2,p}(\hd(D))(\downbox{l}{\epsilon'}^{n+3,p,q+2}(D)(d))(b_{\epsilon}))\\
\cohreflcube{\epsilon}^{n+4,p,q+1,[p<q)} & D~d~(b,c) & \defeq & \!\!\!\begin{array}{l}(\cohrefllayer{\epsilon}^{n+3,p,q+1}(\hd(D))(d)(b),\\\;\cohreflcube{\epsilon}^{n+4,p+1,q+1}(D)(d,\downlayer{l}{\epsilon}^{n+3,p,q+1}(\hd(D))(d)(b))(c))\end{array}\\
\end{array}
\end{small}
$
}}
\caption{Specification of reflexivity in a cubical set (TODO: check the cohreflcube part; check whether it is normal that we don't need reflexivity in directions other than the top one; point out where UIP is used)}
\label{fig:reflexivity}
\end{figure*}

\begin{figure*}
\centerline{ \framebox{$
\begin{array}{llcl}
\permutation_{\sigma}^n & (D:\partialcubset{l}^{n}) & : & \sort{}\\
\permutation_{\sigma}^0 & D & \defeq & \unittype\\
\permutation_{\sigma}^{n+1} & (D,R) & \defeq & \Pi d:\mybox{l}^{n,n}(D).\, R(d) \imp R(\permutebox_{\sigma}^{n,n}(D)(d))\\
\\
\permutebox_{\sigma}^{n,p} & (D : \partialcubset{l}^{n})~(d:\mybox{l}^{n,n}(D)) & : & \mybox{l}^{n,p}(D)\\
\permutebox_{k,\sigma}^{n,p} & D~d & : & ...
\end{array}
$
}}
\caption{Specification of permutations in a cubical set}
\label{fig:permutation}
\end{figure*}

\begin{figure*}
\centerline{ \framebox{$
\begin{array}{llcl}
\diagonal^n & (D:\partialcubset{l}^{n}) & : & \sort{}\\
\diagonal^0 & D & \defeq & \unittype\\
\diagonal^{n+1} & ((D,R),R') & \defeq & \Pi d:\mybox{l}^{n+1,n+1}(D,R).\, R'(d) \imp R(\diagbox^{n}(D,R)(d))\\
\\
\diagbox^{n} & (D : \partialcubset{l}^{n+1})~(d:\mybox{l}^{n+1,n+1}(D) & : & \mybox{l}^{n,n}(\hd(D))\\
...
\end{array}
$
}}
\caption{Specification of diagonals in a cubical set}
\label{fig:diagonals}
\end{figure*}

\begin{figure*}
\centerline{ \framebox{$
\begin{array}{llcl}
\connection^n & (D:\partialcubset{l}^{n+2}) & : & \sort{}\\
\connection^0 & D & \defeq & \unittype\\
\connection^{n+1} & ((D,R),R') & \defeq & \Pi d:\mybox{l}^{n+1,n+1}(D,R).\, R'(d) \imp R(\connbox^{n}(D,R)(d))\\
\\
\connbox^{n} & (D : \partialcubset{l}^{n+2})~(d:\mybox{l}^{n+1,n+1}(\hd(D)) & : & \mybox{l}^{n+2,n+2}(D)\\
...
\end{array}
$
}}
\caption{Specification of connections in a cubical set}
\label{fig:connections}
\end{figure*}

We shall not need it, but the definition of a full non-truncated symmetric cubical set is shown on Figure~\ref{fig:fullsymcubicalset}.

\begin{figure*}
\centerline{ \framebox{$
\begin{array}{llcl}
\mysymcubset_l && \defeq & \mysymcubset_l^0(\star)(\star)\\
\\
\mysymcubset_l^n & \!\!\!\begin{array}{l}(D:\partialcubset{l}^n)\\(S:\partialsymcubset^n(D))\end{array}& : & \sort{l+1}\\
\mysymcubset_l^n & D~S & \defeq & \Sigma R:(\mybox{l}^{n,n}(D) \imp \sort{l}).\,\Sigma E:\issymcubset^n(D)(R)(S).\,\mycubset_l^{n+1}(D,R)(S,E)\\
\end{array}
$
}}
\caption{Full (non-truncated) symmetric cartesian cubical set}
\label{fig:fullsymcubicalset}
\end{figure*}

\subsection{Cubical $\omega$-groupoids}

The truncated bare cubical set structure is inherent to iterated
parametricity. The requirement of the relations to be reflexive and
stable by permutation is inherent to abstraction over an axis variable
and to (linear) application to an axis variable. In particular, in a
(non-cartesian) framework of pure parametricity, such as Bernardy,
Coquand and Moulin~\cite{BernardyCoquandMoulin15}, these are the
minimal requirements to interpret a type. For instance, to interpret
the cubical type theory from~\cite{BernardyCoquandMoulin15}, a type
variable of the source language can simply be interpreted as a type of
the target language, canonically interpreting each higher-dimensional
relation by iterations of the identity type of the target language.
This interpretation would be compatible with any type for which the
equality assigned to this type in the translation coincides with
identity. This is case for $\Sigma$-types and also for $\Pi$-types
since ETT satisfies functional extensionality. Since identity is
truncated by virtue of the uniqueness of identity proofs in ETT, this
would mean interpreting each type by a degenerated higher-dimensional
structure. Thus, it would not support the interpretation of
non-trivial types such as the circle, or more generally $n$-spheres,
or more generally higher-inductive types.

Thus, to support the interpretation of types with non degenerated
higher-dimensional structure, and in particular to support
higher-inductive types, it is required to interpret types by means of
cubical sets with a non-trivial higher-dimensional structure as high
as required to interpret such type. In particular, to interpret types
with unbounded homotopy levels, one need to interpret types of the
source language by means of untruncated cubical sets as defined in
Figure~\ref{fig:barecubicalset}. This would be the case
of~\cite{BernardyCoquandMoulin15} but we need more to interpret
transport.

To support transport, we need each higher-dimensional relation over an
$n$-box to be equipped with a composition operator. If, additionally,
we want that composition is coherent, i.e. that it transports to equal
elements (this is needed to define transport over dependent types), we
shall need to enforce this as a requirement. If we additionally expect
the composition to to be ``regular'' meaning that composition along a
degenerated tube is the identity and the map from a degenerated filler
to a homogeneous equality to be the identity too. Note that we require
composition only in the direction of the main faces of an
$n$-cube. This is because our homogeneous $n$-cubes are required to be
stable by permutation, so compositions in all other directions can be
derived from the composition in the main direction.

All this is described in Figures~\ref{fig:compositionstructure}
and~\ref{fig:compositionproperties} and we conjecture that the
resulting definition provides with a definition of semi-strict
$\omega$-groupoid based on cubical sets. For that reason, we call it
cubical $\omega$-groupoid.

Note that the diagonal structure could a priori be derived from the
composition structure.

Note that if $G$ is a cubical $\omega$-groupoid and
$a_0:\hd(G).R\star$ and $a_1:\hd(G)(\star)$ (i.e. $a_0$ and $a_1$ are
two points of the groupoid, then $\tl(\tl(G))$ can be seen as a
cubical $\omega$-groupoid by specializing all its $n$-cubes to
$(n-1)$-cubes completed with degeneracies of $a_0$ and
$a_1$. Otherwise said, there is a map from $G_1:\mygpd^{1}(A)(E)$ to
$G':\mygpd_0(\star)(\star)$ such that $\hd(G')$ is
$\hd(G_1)(\star,(a_1,a_2))$ (A FAIRE PRÉCISÉMENT).

\begin{figure*}
\centerline{ \framebox{$
\begin{array}{llcl}
\mygpd_l && \defeq & \mygpd_l^0(\star)(\star)\\
\\
\mygpd_l^0 & \!\!\!\begin{array}{l}(D:\partialcubset{l}^n)\\(S:\partialhascomp^n(D))\end{array}& : & \sort{l+1}\\
\mygpd_l^n & D~S & \defeq & \Sigma R:(\mybox{l}^{n,n}(D) \imp \sort{l}).\Sigma E:\hascomp^n(D)(R)(S).\,\mygpd_l^{n+1}(D,R)(S,E)\\
\\
\partialhascomp^n & (D:\partialcubset{l}^n) & : & \sort{l+1}\\
\partialhascomp^0 & \star & \defeq & \unittype\\
\partialhascomp^{n+1} & (D,R) & \defeq & \Sigma S:\partialhascomp^n(D).\,\hascomp^n(D)(R)(S)\\
\\
\hascomp^n & \!\!\!\begin{array}{l}(D:\partialcubset{l}^{n})\\(R:\mybox{l}^{n,n}(D) \imp \sort{l})\\(S:\partialhascomp^n(D))\end{array}& \defeq & \{\\
&&& \mathsf{hassymcubset} ~:~ \issymcubset^n(D)(R);\\
&&& \overrightarrow{\cdot} ~:~ \coercivelr^n(D)(R);\\
&&& \overleftarrow{\cdot} ~:~ \coerciverl^n(D)(R);\\
%&&& \overleftarrow{\cdot} :
% \Pi a:\left(\begin{array}{c}
%          \Sigma a_0:\left(\begin{array}{c}\mybox{l}^{n,n-1}(D)\\ \times\\ \mybox{l}^{n,n-1}(D)\end{array}\right).a^{00}=a^{01}\\
%          \times\\
%          \Sigma a_1:\left(\begin{array}{c}\mybox{l}^{n,n-1}(D)\\ \times\\ \mybox{l}^{n,n-1}(D)\end{array}\right).a^{10}=a^{11}\\
%          \end{array}\right). a^{01} = a^{11} \imp a^{00} = a^{10};\\
&&& \reglr ~:~ \regularitylr^n(D)(R)(S);\\
&&& \regrl ~:~ \regularityrl^n(D)(R)(S);\\
%\Pi a:\left(\begin{array}{c}\mybox{l}^{n,n-1}(D)\\ \times\\ \mybox{l}^{n,n-1}(D)\end{array}\right).\Pi a_{\star}:a_0 = a_1.\overrightarrow{\cdot}(((a_0,a_0),\refl(a_0)),((a_1,a_1),\refl(a_1)),a_{\star}) \equiv a\\
&&& \Overrightarrow{1ex}{\cdot} ~:~ \Coercivelr^n(D)(R);\\
&&& \Overleftarrow{1ex}{\cdot} ~:~ \Coerciverl^n(D)(R);\\
&&& \Reglr{\cdot} ~:~ \Regularitylr^n(D)(R)(S);\\
&&& \Regrl{\cdot} ~:~ \Regularityrl^n(D)(R)(S);\\
&&& \coebacklr{\cdot} ~:~ \backcoercivelr^n(D)(R);\\
&&& \coebackrl{\cdot} ~:~ \backcoerciverl^n(D)(R);\\
&&& \regbacklr{\cdot} ~:~ \regularitybacklr^n(D)(R)(S);\\
&&& \regbackrl{\cdot} ~:~ \regularitybackrl^n(D)(R)(S);\\
&&& \Coebacklr{\cdot} ~:~ \Coercivebacklr^n(D)(R);\\
&&& \Coebackrl{\cdot} ~:~ \Coercivebackrl^n(D)(R);\\
&&& \Regbacklr{\cdot} ~:~ \Regularitybacklr^n(D)(R)(S);\\
&&& \Regbackrl{\cdot} ~:~ \Regularitybackrl^n(D)(R)(S);\\
&&& \}\\
\end{array}
$
}}
\caption{Definition of a cubical groupoid}
\label{fig:compositionstructure}
\end{figure*}

\begin{figure*}
\centerline{ \framebox{$
\begin{array}{llcl}
\coercivelr^0 & D~R & \defeq & \unittype\\
\coercivelr^{n+1} & D~R & \defeq & \Pi d:\mybox{l}^{n+1,n}(D,R).\, R(\downbox{l}{L}^{n+1,n,n}(D)(d)) \imp R(\downbox{l}{R}^{n+1,n,n}(D)(d))\\
\\
\coerciverl^0 & D~R & \defeq & \unittype\\
\coerciverl^{n+1} & D~R & \defeq & \Pi d:\mybox{l}^{n+1,n}(D,R).\, R(\downbox{l}{R}^{n+1,n,n}(D)(d)) \imp R(\downbox{l}{L}^{n+1,n,n}(D)(d))\\
\\
\regularitylr^0 & D~R~S & \defeq & \unittype\\
\regularitylr^{n+1} & D~R~S & \defeq & \Pi d:\mybox{l}^{n,n}(D).\, \overrightarrow{\cdot}(\reflbox^{n+1}(D)(d))(a) \equiv_{ETT} a\\
\\
\regularityrl^0 & D~R~S & \defeq & \unittype\\
\regularityrl^{n+1} & D~R~S & \defeq & \Pi d:\mybox{l}^{n,n}(D).\, \overleftarrow{\cdot}(\reflbox^{n+1}(D)(d))(a) \equiv_{ETT} a\\
\\
...
\end{array}
$
}}
\caption{Definition of a groupoid (properties of a groupoid)}
\label{fig:compositionproperties}
\end{figure*}

\subsection{Types as $n$-cubes of equivalences}

To support transport, or dependent transport, or univalence, extra
structure is needed to relate types. We obtain this extra structure by
taking the instance for $\phi_n$ and $\psi_n$ given on
Figure~\ref{fig:equivalence}.  Instead of just returning a relation to
$\sort{}$, we return a relation $R$ which first returns an
$\omega$-groupoid rather than just a type and, second, returns the
property that the relation is an equivalence.

MANY REMAINING QUESTIONS...

\begin{figure*}
\centerline{ \framebox{$
\begin{array}{llcl}
\phi_n & D & \defeq & \{\\
&&& R ~:~ \myheterobox{l}^{n,n}(D) \imp \mygpd_l\\
&&& E ~:~ \isequivalence^{n}(D)(R)\\
%&&& E' ~:~\isequivalence'^{n}(D)(R)(E)\\
%&&& E'' ~:~\isequivalence''^{n}(D)(R)(E)(E')\\
&&& \}\\
\psi_n & D~P~d & \defeq & P.R\,d\\
\\
\isequivalence^{n} & \!\!\!\begin{array}{l}(D:\myheteroboxtype{l}^{n,n})\\(R:\myheterobox{l}^{n,n}(D) \imp \mygpd_l)\end{array}& : & \sort{}\\
\isequivalence^{n} & D~R & \defeq &\\
 \{\\
\multicolumn{4}{c}{\begin{array}{llll}
&&&\rightarrow^{n+1} ~:~ \Pi d:\myheterobox{l}^{n+1,n}(D).\,\heterodownbox{l}{L}^{n+1,n,n}(D)(d) \imp \heterodownbox{l}{R}^{n+1,n,n}(D)(d)\\
&&&\leftarrow^{n+1} ~:~ \Pi d:\myheterobox{l}^{n+1,n}(D).\heterodownbox{l}{R}^{n+1,n,n}(D)(d) \imp \heterodownbox{l}{L}^{n+1,n,n}(D)(d)\\
&&&\Rightarrow^{n+1} ~:~ \Pi d:\myheterobox{l}^{n+1,n}(D).\,\Pi a:\heterodownbox{l}{L}^{n+1,n,n}(D)(d).\, R(d,(a,\rightarrow^{n+1}(d)(a)))\\
&&&\Leftarrow^{n+1} ~:~ \Pi d:\myheterobox{l}^{n+1,n}(D).\,\Pi a:\heterodownbox{l}{R}^{n+1,p,p}(D).\, R(d,(\leftarrow^{n+1}(d)(a),a))\\
&&&\overrightarrow{\mathsf{coe}}^{n+1} ~:~ \Pi (d,(a_0,a_1)):\myheterobox{l}^{n+1,n+1}(D).\, \tl(D)_1.R(d,(\rightarrow^{n+1}(d)(a_0),a_1))\\
&&&\overleftarrow{\mathsf{coe}}^{n+1} ~:~ \Pi (d,(a_0,a_1)):\myheterobox{l}^{n+1,n+1}(D).\, \tl(D)_0.R(d,(a_0,\leftarrow^{n+1}(d)(a_1)))\\
&&&\Overrightarrow{1ex}{\mathsf{coe}}^{n+3} ~:~ \Pi (d,(a_0,a_1)):\myheterobox{l}^{n+1,n+1}(D).\, R(D,(a,\rightarrow(p)(a)))\\
&&&\Overleftarrow{1ex}{\mathsf{coe}}^{n+3} ~:~ \Pi d:\myheterobox{l}^{n+1,n}(D).\,\Pi (a_0,a_1):(\heterodownbox{l}{L}^{n,p,p}(D) \times \heterodownbox{l}{R}^{n,p,p}(D)).\, \Pi a_{\star}:R(D,a).\, (D).\, R(D,(a,\rightarrow(p)(a)))\\
  \end{array}}\\
\}\\
\end{array}
$
}}
\caption{Specializing heterogeneous cubes to heterogeneous cubes over cubes of equivalences}
\label{fig:equivalence}
\end{figure*}

\fi %%%
\iffalse
$$
\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!
\begin{array}{lll}
\semsort{l}^{0,0} & \defeq & \sort{l} \\
\semsort{l}^{0,1} & \defeq & \Sigma A:\sort{l}.\,(A\imp A \imp \sort{l})\\
\semsort{l}^{0,2} & \defeq & \Sigma (A,=_A):(\Sigma A:\sort{l}.\,A\imp A \imp \sort{l}).\,\Pi a_{00}.\,\Pi a_{01}:A.\, a_{00} =_A a_{01} \imp \Pi a_{00}:A.\,\Pi a_{11}:A.\, a_{10} =_A a_{11} \imp a_{00} =_A a_{10} \imp a_{01} =_A a_{11} \imp \sort\
{l};\\
\semsort{l}^{1,0} & \defeq & \{\\
& &
\begin{array}{lll}
(A_0,=_{0}) &:& \semsort{l}^{0,1};\\
(A_1,=_{1}) &:& \semsort{l}^{0,1};\\
=_{\star} &:& A_0 \imp A_1 \imp \sort{l};\\
\rightarrow &:& A_0 \imp A_1;\\
\leftarrow &:& A_1 \imp A_0;\\
\Rightarrow &:& \Pi a_0:A_0.\, a_0 =_{\star} \rightarrow(a_0)\\
\Leftarrow &:& \Pi a_1:A_1.\, \leftarrow(a_1) =_{\star} a_1\\
%\mbox{reg} &:& A_0 =_{ETT} A_1 \imp \Pi a:A_0.\,(\rightarrow(a)=_{ETT} a \times \leftarrow(a)=_{ETT} a \times \Rightarrow(a) =_{ETT} \Leftarrow(a))\\
\end{array}\\
&&\}\\
\semsort{l}^{2,0} & \defeq & \{\\
& &
\begin{array}{l}
(((A_{00},=_{00},=_{=_{00}}),(A_{01},=_{01},=_{=_{01}})),(=_{0\star},\leftrightarrow_{0\star},\Leftrightarrow_{0\star})) : \semsort{l}^{1,1};\\
(((A_{10},=_{10},=_{=_{10}}),(A_{11},=_{11},=_{=_{11}})),(=_{1\star},\leftrightarrow_{1\star},\Leftrightarrow_{1\star})) : \semsort{l}^{1,1};\\
(=_{\star 0},\leftrightarrow_{\star 0},\Leftrightarrow_{\star 0});\\
(=_{\star 1},\leftrightarrow_{\star 1},\Leftrightarrow_{\star 1});\\
=_{=_{\star\star}} : \Pi a_{00}:A_{00}.\,\Pi a_{01}:A_{01}.\, a_{00} =_{0\star} a_{01} \imp \Pi a_{00}:A_{00}.\,\Pi a_{11}:A_{11}.\, a_{10} =_{1\star} a_{11} \imp a_{00} =_{\star 0} a_{10} \imp a_{01} =_{\star 1} a_{11} \imp \sort{l};\\
\rightarrow_{\star\diamond} : \Pi a_{00}:A_{00}.\,\Pi a_{01}:A_{01}.\, a_{00} =_{0\star} a_{01} \imp (\rightarrow_{\star 0}(a_{00}) =_{1\star} \rightarrow_{\star 1}(a_{01}))\\
\rightarrow_{\diamond\star} : \Pi a_{00}:A_{00}.\,\Pi a_{10}:A_{10}.\, a_{00} =_{\star 0} a_{10} \imp (\rightarrow_{0\star}(a_{00}) =_{\star 1} \rightarrow_{1 \star}(a_{10}))\\
\leftarrow_{\star\diamond} ...\\
\leftarrow_{\diamond\star} ...\\
\Rightarrow ... \mbox{referring to $=_{00}$ etc}\\
\Leftarrow ...\\
%\mbox{reg} &:& A_0 =_{ETT} A_1 \imp \Pi a:A_0.(\rightarrow(a)=_{ETT} a \times \leftarrow(a)=_{ETT} a \times \Rightarrow(a) =_{ETT} \Leftarrow(a))\\
\end{array}\\
&&\}\\
\end{array}
$$

Such construction will typically be a refinement of the previous
construction of $\partialcubset{l}^n$.
\fi

\iffalse
Thanks to the definition of $\partialcubset{l}^n$, we can define an $\omega$-groupoid
as a stream of equalities in all dimensions together with a property
of transportation between parallel such equalities (i.e. between
equalities connected by a tube).

$$
\begin{array}{llcl}
\groupoid & & \defeq & \Sigma A:\sort{i}.\,\mathsf{isgroupoid}(A)\\
\\
\mathsf{isGroupoid} & A & \defeq & \Sigma =_A:A \imp A \imp \sort{i}.\,\\
& & & \Sigma \mathsf{reflexive} : \Pi a:A.\, a =_A a.\,\\
& & & \groupoidn(0)((\star,A),=_A)\\
\\
\groupoidn & (n:\mathbb{N})~(D:\partialcubset{l}^{n+2}) & : & \sort{i+1}\\
\groupoidn & n~(D,E) & \defeq & \exists \epsilon : (\Pi d_0 : \mybox{l}^{n,n}(D).\,\Pi d_1 : \mybox{l}^{n,n}(D).\, E(d_0) \simeq E(d_1)).\,\groupoidn(n+1)(...\\
A \simeq_{\sort{i}} B & & \defeq &
 \Sigma \{=_{\_}\, : A \rightarrow B \rightarrow \sort{i}.\,\\
& & & \Pi a_0:A.\, \Pi a_1:A.\, \Pi a_\star: a_0 =_A a_1.\, \Pi b_0:B.\, \Pi b_1:B.\, \Pi b_\star:b_0 =_B b_1.\, isGroupoid (a = b)\\
& & & (\Sigma \overrightarrow{\_} : A \rightarrow B.\,\\
& & & \Sigma \Overrightarrow{1ex}{\_} : \Pi a:A.\, a =_{\_} \overrightarrow{\_}(a).\,\\
& & & \Sigma \overrightarrow{\mathsf{coe}} : \Pi a:A.\,\Pi b:B.\,\, a =_{\_} b \rightarrow \overrightarrow{\_}(a) =_B b.\,\\
& & & \Pi a:A.\,\Pi b:B.\,\, a =_{\_} b \rightarrow \overrightarrow{\_}(a) =_ b.\,\\
& & & \Sigma \overleftarrow{\_} : B \rightarrow A.\,\\
& & & \Sigma \Overleftarrow{1ex}{\_} : \Pi b:B.\, \overleftarrow{\_}(b) =_{\_} b; \\
& & & \Sigma \overleftarrow{\mathsf{coe}} : \Pi a:A.\,\Pi b:B.\, a =_{\_} b \rightarrow a =_B \overleftarrow{\_}(a).\,\\
& & \Sigma \overrightarrow{\mathsf{coe}} : \Pi a:A.\,\Pi b:B.\, a =_{\_} b \rightarrow \overrightarrow{\_}(a) =_B b.\\
\\
\end{array}
$$

\fi

\iffalse
To each type $A$ is associated a structure of $\omega$-groupoid which
we define as follows:

Each type $A$ comes with:
\begin{itemize}
\item an equality $=^n_A$ between $n$-cubes of this type
\item a reflexity proof $\reflterm{n}{a} : a =^n_A a$ for any $n$-cube
  $a$ in $A$
\item a connection $\nwconn{n}{p} : [p,p] =^{n+1}_A [\refltermn{n}{A}{a_1},\refltermn{n}{A}{a_1}]$ for any $n+1$-cube $p:a_0 =^n_A a_1$ over $A$
\item a connection $\seconn{n}{p} : [\refltermn{n}{A}{a_0},\refltermn{n}{A}{a_0}] =^{n+1}_A [p,p]$ for any $n+1$-cube $p:a_0 =^n_A a_1$ over $A$
\item ...
\end{itemize}

We define the following ``record'' type:
$$
\begin{array}{lcl}
  A \simeq B & \defeq & \{=_{\_}\, : A \rightarrow B \rightarrow \sort;\\
& & \overrightarrow{\_} : A \rightarrow B; \overleftarrow{\_} : B \rightarrow A; \\
& & \Overrightarrow{1ex}{\_} : \Pi a:A.\, a =_{\_} \overrightarrow{\_}(a); \Overleftarrow{1ex}{\_} : \Pi b:B.\, \overleftarrow{\_}(b) =_{\_} b; \\
& &  : \Pi a:A.\,\Pi b:B.\, a =_{\_} b \rightarrow \overrightarrow{\_}(a) =_B b;\\
& & ...\}
\end{array}
$$
\fi
\iffalse %%%
\subsection{Reflexivities}

We need to provide reflexivities to turn $n$-cubes into
$(n+1)$-cubes. For $n$-cubes of types and equivalences, this means
being able to prove the equivalence $A \simeq A$ from $A$ being a
cubical $\omega$-groupoid, to prove the equality $\epsilon = \epsilon$
for $\epsilon$ an arbitrary general equivalence of level $n$.

For the former, this shall come by taking the identity for
$\rightarrow$, $\leftarrow$, $\overrightarrow{\mathsf{coe}}$ and
$\overleftarrow{\mathsf{coe}}$ and by taking the reflexivity and
connections coming with the definition of cubical $\omega$-groupoid.

For the latter, we shall probably need an extra property to
$\rightarrow$, $\leftarrow$, $\overrightarrow{\mathsf{coe}}$ and
$\overleftarrow{\mathsf{coe}}$, namely that they respect equality.

For an heterogeneous $n$-cubes over some $n$-cube of types and
relations, this shall come from the property that the relations are
themselves cubical $\omega$-groupoid and thus have reflexivities.

For the latter, this shall come from the structure of types.  For type
variables, it shall come from the requirement that such type variable
are cubical groupoids in the definition of $n$-cubes. It shall then be
proved also that the type constructors ($\Pi$, $\Sigma$, $\mathbb{N}$,
...) preserve the property of being a cubical $\omega$-groupoid and
the property of being equivalent.

\subsection{Dependent sums}

\subsection{Dependent products}

We believe that it is enough to interpret a dependent product in
dimension $n$ as its usual interpretation as an $n$-cube of dependent
products over $n$-cubes, together, in each of the $3^n$ $p$-subcube of
this cube, of a copy of the precomputation of the $p$ possible
diagonals in this subcube.

For dependent products to propagate reflexivities, the assumption that
functions preserve equality shall have to be enforced.

\subsection{Structure of the cubes of derivations in the target}

For $\Gamma$ a typing context with $n$ declarations of axes, the $3^n$
derivations in the target constituting the interpretation of a source
derivation shall be indexed by a substitution where each variable of
axis can take three values: $0$ for the left point, $1$ for the right
point, and $\star$ for the connecting line (i.e., these three values
are the defining components of an interval over connected endpoints
$0$ and $1$).

In this very same substitution, ordinary variables will be interpreted
as internal $p$-cubes if the variable has $p$ variables of axes before
it at the time it is declared.

Substitutions of typing contexts of the source can thus be described
by the following grammar (we use $\sigma$ to range over such
substitution):
$$
\begin{array}{lcl}
r & ::= & 0 ~|~ 1 ~|~ \star\\
\sigma, \tau & ::= & \emptysigma ~|~ \sigma, a:=t:A ~|~ \sigma, i:=r\\
\end{array}
$$

We define a notion of valid substitution $\sigma$ of source type
$\Gamma$ in a well-formed ETT typing context $\Delta$ as follows:
$$
\seq{}
    {\Delta \vDash \emptysigma : \emptyctx}
\qquad
\seq{\Delta \vDash \sigma : \Gamma
\qquad \Gamma \vdash A : \sort{l} \qquad \Delta \vdash_{ECC} t : \semnew{\sigma}{A}
}
    {\Delta \vDash (\sigma,a:=t:A) : (\Gamma,a:A)}
\qquad
\seq{\Delta \vDash \sigma : \Gamma}
    {\Delta \vDash (\sigma,i:=r) : (\Gamma,i)}
$$

%TODO: deal with the need for the translation to know the type (in
%practice, the translation has to be done on derivations rather than on
%terms).

Then, writing $\semnew{\sigma}{t}$ for the ETT derivation component
over $\sigma$ of a derivation of $\Gamma \vdash t : A$ such that
$\Delta \vDash \Gamma$, we expect the following invariant:

\begin{lemma}
$\Gamma \vdash t : A$ and $\Delta \vDash \sigma : \Gamma$ implies
$\Delta \vdash_{ECC} \semnew{\sigma}{t} : \applytype{\sigma}{\emptysigma}{\semnew{\sigma}{A}}{t}$
\end{lemma}
where $\applytype{\sigma}{\emptysigma}{\semnew{\sigma}{B}}{t}$ builds
the equality type representing in ETT the border of the
$\sigma$-component of the interpretation of a proof $b$ of type $B$ (TODO: rewrite $\applytype{}{}{}{}$ in terms of $\myheteroboxtype{l}$ and $\myheterobox{l}$):

$$
\begin{array}{lcll}
\applytype{\emptysigma}{\tau}{B}{b} & \defeq & B\\
\applytype{\sigma,a:=t:A}{\tau}{B}{b} & \defeq & \applytype{\sigma}{a:=tA,\tau}{B}{b}\\
\applytype{\sigma,i:=0}{\tau}{B}{b} & \defeq & \applytype{\sigma}{i:=0,\tau}{B}{b}\\
\applytype{\sigma,i:=1}{\tau}{B}{b} & \defeq & \applytype{\sigma}{i:=1,\tau}{B}{b}\\
%\applytype{\sigma,i:=j}{\tau}{B}{b} & \defeq & \applytype{\sigma}{i:=j,\tau}{B}{b}\\
\applytype{\sigma,i:=\star}{\tau}{B}{b} & \defeq & \applytype{\sigma}{i:=\star,\tau}{(\undertau{\sigma,i=0}{\shrink{0}{(t\mapsto t.0)}{\tau}}{b}) =_B (\undertau{\sigma,i=1}{\shrink{0}{(t\mapsto t.1)}{\tau}}{b})}{b}
\end{array}
$$
where, for $\sigma,i:=r,\tau$ an initial substitution, and $r$ being
$0$ or $1$, $\undertau{\sigma,i:=r}{\tau}{b}$ computes the internal
representation of the face $r$ of the interpretation of the component
$\sigma,i:=\star,\tau$ of $b$.

$$
\begin{array}{lcll}
\undertau{\sigma}{\emptysigma}{b} & \defeq & \semnew{\sigma}{b} \\
\undertau{\sigma}{a:=t,\tau}{b} & \defeq & \undertau{\sigma,a:=t}{\tau}{b}\\
\undertau{\sigma}{i:=0,\tau}{b} & \defeq & \undertau{\sigma,i:=0}{\tau}{b} \\
\undertau{\sigma}{i:=1,\tau}{b} & \defeq & \undertau{\sigma,i:=1}{\tau}{b} \\
%\undertau{\sigma}{i:=j,\tau}{b} & \defeq & \undertau{\sigma,i:=j}{\tau}{b} \\
\undertau{\sigma}{i:=\star,\tau}{b} & \defeq & (\undertau{\sigma,i:=0}{\tau}{b},\undertau{\sigma,i:=1}{\tau}{b},\undertau{\sigma,i:=\star}{\tau}{b})\\
\end{array}
$$

$$
\begin{array}{lcll}
\shrink{k}{f}{\emptysigma} & \defeq & \emptysigma\\
\shrink{k}{f}{a:=t:A,\sigma} & \defeq & (a:=\under{k}{f}{a}:A),\shrink{k}{f}{\sigma}\\
\shrink{k}{f}{i:=\star,\sigma} & \defeq & i:=\star,\shrink{k+1}{f}{\sigma}\\
\end{array}
$$

For instance, if $i,j,k,a:A \vdash b(a):B$ of dimension 3 and $\sigma$ is
$i:=\star,j:=0,k:=\star,a:=t:A$ which denotes the 2-dimensional face numbered
$0$ in axis $j$ of the expected $3$-cube, then
$\applytype{\sigma}{\emptysigma}{B}{b}$ builds (dropping the names of
axes and listing their value in sequence):
$$\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!(\semnew{000a_{00}}{b},\semnew{001a_{01}}{b},\semnew{00\star (a_{00},a_{01},a_{0\star})}{b})
 =_{(\semnew{000 a_{00}}{b},\semnew{i:=100a_{10}}{b},\semnew{\star00a_{0}}{b})
  =_{\semnew{\star0\star a}{B}} (\semnew{001a_{01}}{b},\semnew{101}{b},\semnew{\star01a_{1}}{b})}
(\semnew{100a_{10}}{b},\semnew{101a_{11}}{b},\semnew{10\star (a_{10},a_{11},a_{1\star})}{b})$$
\fi %%%
\iffalse
\subsection{A ranger}

$$
\begin{array}{lcll}
\reflsort{0} & \defeq & \sort{}\\
\reflsort{n+1} & \defeq & (\lambda A_0:\semsort{n}.\lambda A_1:\semsort{n}.A_0 \simeq A_1,\lambda A:\semsort{n}.A,\lambda A:\semsort{n}.\reflsort{n},...,...,...,...,...,...))\\
\\
%\simeq_0 & \defeq & \simeq\\
%\simeq_{n+1} & \defeq & \sort{}\\
%\\
\refltypen{n}{(A:\sort{})} & : & A \simeq A\\
\refltypen{n}{A} & \defeq & (\lambda a_0:A.\lambda a_1:A.a_0 =_A a_1,\lambda a_0:A.a_0,\lambda a_0:A.\refltermn{n}{A}{a_0},...,...,...,...,...,...))\\
\\
\# \emptysigma & \defeq & 0\\
\# (\sigma,a:A) & \defeq & \#\sigma\\
\# (\sigma,i:=0) & \defeq & (\#\sigma)\\
\# (\sigma,i:=1) & \defeq & (\#\sigma)\\
\# (\sigma,i:=\star) & \defeq & (\#\sigma) + 1\\
\\
\semctx{\sigma}{i, \Delta} & \defeq &
  \semctx{\sigma, i}{\Delta} \\
\semctx{\sigma}{a:A, \Delta} & \defeq &
  a : \semnew{\sigma}{A}, \semctx{\sigma, a:A}{\Delta} \\
\\
\elt{0}{B} & \defeq & B\\
\elt{n+1}{(B_0,B_1,B_\star)} & \defeq &
  \Sigma b_0:\elt{n}{B_0}.
  \Sigma b_1:\elt{n}{B_1}.
  b_0 =_{B_\star} b_1\\
\end{array}
$$
\fi
\iffalse %%%
\subsection{Core of the translation}

Translation of types (TODO: $\elt{}{}$ should just be the $\myheterobox{l}$ function).

$$
\begin{array}{lcll}
\semtypenew{\sigma}{A} & \defeq & \elt{\#\sigma}{\semnew{\sigma}{A}}\\
\elt{0}{B} & \defeq & B\\
\elt{n+1}{(B_0,B_1,B_\star)} & \defeq &
  \Sigma b_0:\elt{n}{B_0}.
  \Sigma b_1:\elt{n}{B_1}.
  b_0 =_{B_\star} b_1\\
\\
\# \emptysigma & \defeq & 0\\
\# (\sigma,a:A) & \defeq & \#\sigma\\
\# (\sigma,i:=0) & \defeq & (\#\sigma)\\
\# (\sigma,i:=1) & \defeq & (\#\sigma)\\
\# (\sigma,i:=\star) & \defeq & (\#\sigma) + 1\\
\end{array}
$$

\noindent Translation of terms (sketch):

$$
\begin{array}{lcll}
\semnew{\sigma}{a} & \defeq & \access{\sigma}{a}\\
\semnew{\sigma}{\lambda i.t} & \defeq & \semnew{\sigma,i:=\star}{t}\\
\semnew{\sigma}{t \, i} & \defeq & \diag{i}{\semnew{\sigma}{t}}\\
\semnew{\sigma}{t =_\epsilon u} & \defeq & \semnew{\sigma}{t} =_{\semnew{\sigma}{\epsilon}} \semnew{\sigma}{u}\\
%\semnew{\sigma}{\mktuplenew{a_0:A_0}{a_1:A_1}{\textgoth{c}}{R}{\mktuplein{f^\rightarrow}{p^\rightarrow}{r^\rightarrow}{\alpha^\rightarrow}}{\mktuplein{f^\leftarrow}{p^\leftarrow}{r^\leftarrow}{\alpha^\leftarrow}}} & \defeq & (\semnew{\sigma,a_0:A_0,a_1:A_1}{R},\semnew{\sigma,a_0:A_0}{f^\rightarrow},...,...,...,\semnew{\sigma,a_1:A_1}{f^\leftarrow},...,...,...)\\
\semnew{\sigma}{\sort{l}} & \defeq & \semsort{l}^{\#\sigma,0}\\
\semnew{\sigma}{(t,u)} & \defeq & (\semnew{\sigma}{t},\semnew{\sigma}{u})\\
\semnew{\sigma}{\pi_1(t)} & \defeq & \pi_1(\semnew{\sigma}{t})\\
\semnew{\sigma}{\pi_2(t)} & \defeq & \pi_2(\semnew{\sigma}{t})\\
\semnew{\sigma}{\Sigma a:A.B} & \defeq & \Sigma a:\semtypenew{\sigma}{A}.\semtypenew{\sigma,a:=a:A}{B}\\
\semnew{\sigma}{\lambda a:A.t} & \defeq & \\%\semlam{\#\sigma,0}{\sigma}{a \mapsto a}{\semnew{\sigma}{A}}{t} \\
\semnew{\sigma}{t\,u} & \defeq & \\%\semapp{\#\sigma,0}{\semnew{\sigma}{t}}{\semnew{\sigma}{u}} \\
\semnew{\sigma}{\Pi a:A.B} & \defeq & \\%\semprod{\#\sigma,0}{\sigma}{a \mapsto a}{\semnew{\sigma}{A}}{B}\\
\\
\access{\sigma, i:=0}{a} & \defeq & \access{\sigma}{a} \\
\access{\sigma, i:=1}{a} & \defeq & \access{\sigma}{a} \\
%\access{\sigma, i:=j}{a} & \defeq & \access{\sigma}{a} \\
\access{\sigma, i:=\star}{a} & \defeq & (\refltermn{}{A}{t}:A) \qquad & \mbox{if $\access{\sigma}{a}$ is $t:A$}\\
\access{\sigma, a:=t:A}{a} & \defeq & (t:A) \\
\access{\sigma, b:=u:B}{a} & \defeq & \access{\sigma}{a} & a \neq b\\
\end{array}
$$

Note that the interpretation of an explicit proof of equivalence
derives from its definition as a combination of $\Sigma$ and $\Pi$
types. Similarly, the clause for $t =_\epsilon u$ is actually derivable
as a projection from the $\Sigma$-type used to define an equivalence.

The reflexivity $\refltermn{}{}{t}$ remains to be made more precise.

\subsection{``Syntactic'' version of the translation}

We believe that it would be possible to define a variant of the
translation which maps a source derivation into a single derivation in
the target by combining the $3^n$ judgements constituting the
interpretation into an iterated $\Sigma$-type collecting all
judgements into ones. This time, each $n$-cube shall have to
destructed and constructed so that each constructor and eliminator of
the source language can be applied to each component of the tuple.
\fi %%%
\iffalse
$$
\begin{array}{lcl}
\sigma & ::= & \emptysigma ~|~ \sigma, i ~|~ \sigma, a:=t\\
\end{array}
$$

$$
\begin{array}{lcl}
A \simeq B & \defeq & \Sigma =\, : A \rightarrow B \rightarrow \sort. \Sigma ...\\
\end{array}
$$

A few expected invariants:

$$
\seq{\semctx{\emptysigma}{\Gamma} \vdash' B : \semnew{|\Gamma|}{\sort{}}}
    {\semctx{\emptysigma}{\Gamma} \vdash' \elt{|\Gamma|}{B} : \sort{}}
$$

$$
\seq{\Gamma \vdash t : A}
    {\semctx{\emptysigma}{\Gamma} \vdash' \semnew{|\Gamma|}{t} : \elt{|\Gamma|}{\semnew{|\Gamma|}{A}}}
$$

$$
\begin{array}{lcll}
\under{0}{f}{t} & \defeq & f\,t\\
\under{n+1}{f}{t} & \defeq & (\under{n}{f}{\pi_0\,t}, \under{n}{f}{\pi_1\,t}, \under{n}{f}{\pi_\star\,t})\\
\\
|\emptyctx|  & \defeq & \emptysigma\\
|\Gamma, i|  & \defeq & |\Gamma|, i\\
|\Gamma, a|  & \defeq & |\Gamma|, a:=a\\
\\
\# \emptysigma & \defeq & 0\\
\# (\sigma,a:=t) & \defeq & \#\sigma\\
\# (\sigma,i) & \defeq & (\#\sigma) + 1\\
\\
\semctx{\sigma}{i, \Delta} & \defeq &
  \semctx{\sigma, i}{\Delta} \\
\semctx{\sigma}{a:A, \Delta} & \defeq &
  a : \semnew{\sigma}{A}, \semctx{\sigma, a:A}{\Delta} \\
\\
\semtypenew{\sigma}{A} & \defeq & \elt{\#\sigma}{\semnew{\sigma}{A}}\\
\\
\semnew{\sigma}{a} & \defeq & \access{\sigma}{a}\\
\semnew{\sigma}{\lambda i.t} & \defeq & \semnew{\sigma,i}{t}\\
\semnew{\sigma}{t \, i} & \defeq & \diag{i}{\semnew{\sigma}{t}}\\
\semnew{\sigma}{t =_\epsilon u} & \defeq & \semnew{\sigma}{t} =_{\semnew{\sigma}{\epsilon}} \semnew{\sigma}{u}\\
\semnew{\sigma}{\mktuplenew{a_0:A_0}{a_1:A_1}{\textgoth{c}}{R}{\mktuplein{f^\rightarrow}{p^\rightarrow}{r^\rightarrow}{\alpha^\rightarrow}}{\mktuplein{f^\leftarrow}{p^\leftarrow}{r^\leftarrow}{\alpha^\leftarrow}}} & \defeq & (\semnew{\sigma,a_0:A_0,a_1:A_1}{R},\semnew{\sigma,a_0:A_0}{f^\rightarrow},...,...,...,\semnew{\sigma,a_1:A_1}{f^\leftarrow},...,...,...)\\
\semnew{\sigma}{\sort{l}} & \defeq & \semsort{l}^{\#\sigma,0}\\
%\semnew{\sigma}{\lambda a:A.t} & \defeq & \semlam{\#\sigma,0}{\sigma}{a \mapsto a}{\semnew{\sigma}{A}}{t} \\
%\semnew{\sigma}{t\,u} & \defeq & \semapp{\#\sigma,0}{\semnew{\sigma}{t}}{\semnew{\sigma}{u}} \\
%\semnew{\sigma}{\Pi a:A.B} & \defeq & \semprod{\#\sigma,0}{\sigma}{a \mapsto a}{\semnew{\sigma}{A}}{B}\\
\\
\access{\sigma, i}{a} & \defeq & \lift{(\access{\sigma}{a})} \\
\access{\sigma, a:=t}{a} & \defeq & t \\
\access{\sigma, b:=t}{a} & \defeq &
  \access{\sigma}{a} & a \neq b\\
\end{array}
$$
$$
\begin{array}{lcll}
\semsort{0} & \defeq & \sort{}\\
\semsort{n+1} & \defeq & (\semsort{n},\semsort{n},(...,...,...,...,...,...,...,...))\\
\\
\multicolumn{4}{l}{\mbox{Insert the ``coe'' between lifted and non-lifted expressions, check...}}\\
\semlam{0,k}{\sigma}{f}{A}{t} & \defeq & \lambda a:\elt{k}{A}.\semnew{\sigma,(a:=f a)}{t}\\
\semlam{n+1,k}{\sigma}{f}{A}{t} & \defeq & \left(
  \begin{array}{l}
  \semlam{n,k}{\sigma}{(\under{k}{\liftlr{}}{})\circ f}{(\under{k}{\pi_0}{A})}{t}\\
  \semlam{n,k}{\sigma}{(\under{k}{\liftrl{}}{})\circ f}{(\under{k}{\pi_1}{A})}{t}\\
  \semlam{n,k+1}{\sigma}{f}{A}{t}\\
  \end{array}\right)\\
\\
\semapp{0,k}{t}{u} & \defeq & t\,u\\
\semapp{n+1,k}{t}{u} & \defeq & \left(
  \begin{array}{l}
  \semapp{n,k}{(\pi_0\,t)}{(\under{k}{\pi_0}{u})}\\
  \semapp{n,k}{(\pi_1\,t)}{(\under{k}{\pi_1}{u})}\\
  \semapp{n,k+1}{(\pi_\star\,t)}{u}\\
  \end{array}\right)\\
\\
\multicolumn{4}{l}{\mbox{First approximation}}\\
\semprod{0,k}{\sigma}{f}{A}{B} & \defeq & \Pi a:\elt{k}{A}.\semnew{\sigma,(a:=f a)}{B}\\
\semprod{n+1,k}{\sigma}{f}{A}{B} & \defeq & \left(
  \begin{array}{l}
  \semprod{n,k}{\sigma}{(\under{k}{\liftlr{}}{})\circ f}{(\under{k}{\pi_0}{A})}{t}\\
  \semprod{n,k}{\sigma}{(\under{k}{\liftrl{}}{})\circ f}{(\under{k}{\pi_1}{A})}{t}\\
  (\lambda f_0:\semprod{n,k}{\sigma}{(\under{k}{\liftlr{}}{})\circ f}{(\under{k}{\pi_0}{A})}{t}.\\
   ~\lambda f_1:\semprod{n,k}{\sigma}{(\under{k}{\liftlr{}}{})\circ f}{(\under{k}{\pi_1}{A})}{t}.\\
   ~\Pi a:\semnew{\sigma}{A}.f_0\,(\pi_0\, a) =_{\semnew{\sigma,(a:=a)}{B}} f_1\, (\pi_1\, a),\\
   ~...,...,...,...,...,...,...,...)
  \end{array}\right)\\
\\
\lift{t} & \defeq & (t,t,\refl{t})\\
\liftlr{t} & \defeq &
     (t,
      \overrightarrow{\elt{\sigma}{\pi_\star \semnew{\sigma}{A}}}(t),
      \overrightarrow{\overrightarrow{\elt{\sigma}{\pi_\star \semnew{\sigma}{A}}}}(t))\\
\liftrl{t} & \defeq &
     (\overleftarrow{\elt{\sigma}{\pi_\star \semnew{\sigma}{A}}}(t),
      t,
      \overleftarrow{\overleftarrow{\elt{\sigma}{\pi_\star \semnew{\sigma}{A}}}}(t))\\
\end{array}
$$

Variante sans projection de variables

$$
\begin{array}{lcl}
\semlambis{n+1,k}{A}{t} & \defeq & \left(
  \begin{array}{l}
  \semlambis{n,k}{(\under{k}{\liftlr{}}{})\circ f}{(\under{k}{\pi_0}{A})}{t}\\
  \semlambis{n,k}{(\under{k}{\liftrl{}}{})\circ f}{(\under{k}{\pi_1}{A})}{t}\\
  \semlambis{n,k+1}{A}{\pi_\star\, t}\\
  \end{array}\right)\\
\\
\semapp{0,k}{t}{u} & \defeq & t\,u\\
\semapp{n+1,k}{t}{u} & \defeq & \left(
  \begin{array}{l}
  \semapp{n,k}{(\pi_0\,t)}{(\under{k}{\pi_0}{u})}\\
  \semapp{n,k}{(\pi_1\,t)}{(\under{k}{\pi_1}{u})}\\
  \semapp{n,k+1}{(\pi_\star\,t)}{u}\\
  \end{array}\right)\\
\\
\semprod{0,k}{\sigma}{f}{A}{B} & \defeq & \Pi a:\elt{k}{A}.\semnew{\sigma,(a:=f a)}{B}\\
\semprod{n+1,k}{\sigma}{f}{A}{B} & \defeq & \left(
  \begin{array}{l}
  \semprod{n,k}{\sigma}{(\under{k}{\liftlr{}}{})\circ f}{(\under{k}{\pi_0}{A})}{t}\\
  \semprod{n,k}{\sigma}{(\under{k}{\liftrl{}}{})\circ f}{(\under{k}{\pi_1}{A})}{t}\\
  (\lambda f_0:\semprod{n,k}{\sigma}{(\under{k}{\liftlr{}}{})\circ f}{(\under{k}{\pi_0}{A})}{t}.\\
   ~\lambda f_1:\semprod{n,k}{\sigma}{(\under{k}{\liftlr{}}{})\circ f}{(\under{k}{\pi_1}{A})}{t}.\\
   ~\Pi a:\semnew{\sigma}{A}.f_0\,(\pi_0\, a) =_{\semnew{\sigma,(a:=a)}{B}} f_1\, (\pi_1\, a),\\
   ~...,...,...,...,...,...,...,...)
  \end{array}\right)\\
\end{array}
$$

OBSOLÈTE

$$
\begin{array}{lcl}
k & ::= & 0 ~|~ 1 ~|~ \star \\
\tau & ::= & \emptyctx ~|~ \tau, i:=k ~|~ \tau, a\\
\end{array}
$$

$$
\begin{array}{lcl}
\incrstep{i}{\tau}{F} & \defeq &
  (F{((i:=0,\tau)},F{(i:=1,\tau)},F{(i:=\star,\tau)})\\
\\
\distrstep{i}{\tau}{F} & \defeq &
  (F{(i:=0)\tau},F{(i:=1)\tau},F{(i:=\star)\tau})\\
\\
  \incrstep{i}{\tau}{(\tau \mapsto \itsemtype{\Gamma}{\uparrow\sigma}{\tau}{A})}\\
\itsemtype{\Gamma,a:A}{\sigma}{\tau}{A} & \defeq &
  \itsemtype{\Gamma}{a:=a,\sigma}{\tau}{A}\\
\itsemtype{\emptyctx}{\sigma}{\tau}{A} & \defeq &
  \semtype{\sigma}{\tau}{A}\\
\\
\itsemtype{\Gamma,i}{\sigma}{\tau}{A} & \defeq &
  \incrstep{i}{\tau}{(\tau \mapsto \itsemtype{\Gamma}{\uparrow\sigma}{\tau}{A})}\\
\itsemtype{\Gamma,a:A}{\sigma}{\tau}{A} & \defeq &
  \itsemtype{\Gamma}{a:=a,\sigma}{\tau}{A}\\
\itsemtype{\emptyctx}{\sigma}{\tau}{A} & \defeq &
  \semtype{\sigma}{\tau}{A}\\
\\
\itsemterm{\Gamma,i}{\sigma}{\tau}{t:A} & \defeq &
  \incrstep{i}{\tau}{(\tau \mapsto \itsemterm{\Gamma}{\uparrow\sigma}{\tau}{t:A})}\\
\itsemterm{\Gamma,a:A}{\sigma}{\tau}{t:A} & \defeq &
  \itsemterm{\Gamma}{a:=a,\sigma}{\tau}{t:A}\\
\itsemterm{\emptyctx}{\sigma}{\tau}{A} & \defeq &
  \semterm{\sigma}{\tau}{A}\\
\\
\semtype{\sigma}{\emptyctx}{\sort{}} & \defeq &
  \sort{}\\
\\
\semtype{\sigma}{\tau,i=0}{\sort{}} & \defeq &
  \sort{}\\
\semtype{\sigma}{\tau,i=1}{\sort{}} & \defeq &
  \sort{}\\
\semtype{\sigma}{\tau,i=\star}{\sort{}} & \defeq &
  (\lambda A_0:\sort{}.\lambda A_1:\sort{}.A_0 \simeq A_1, ..., ..., ..., ..., ..., ..., ..., ...)\\
\\
\semtype{\sigma}{\emptyctx}{\Pi a:A.B} & \defeq &
  \Pi a:\semtype{\sigma}{\emptyctx}{A}.\semtype{\sigma,a:=a}{\emptyctx}{B}\\
\\
\semtype{\sigma}{\tau,i:=0}{\Pi a:A.B} & \defeq &
  \Pi a_0:\semtype{\sigma}{\tau,i:=0}{A}.
  \semtype{\sigma,a:=
     (a_0,
      \overrightarrow{\semtype{\sigma}{\tau,i=\star}{A}}(a_0),
      \overrightarrow{\overrightarrow{\semtype{\sigma}{\tau,i=\star}{A}}}(a_0))}
     {\tau,i:=0}{B}\\
\semtype{\sigma}{\tau,i:=1}{\Pi a:A.B} & \defeq &
  \Pi a_1:\semtype{\sigma}{\tau,i:=1}{A}.
  \semtype{\sigma,a:=
     (\overleftarrow{\semtype{\sigma}{\tau,i=\star}{A}}(a_1),
      a_1,
      \overleftarrow{\overleftarrow{\semtype{\sigma}{\tau,i=\star}{A}}}(a_1))}
     {\tau,i:=1}{B}\\
\semtype{\sigma}{\tau,i:=\star}{\Pi a:A.B} & \defeq &
  (\lambda f_0:\Pi a_0:\semtype{\sigma}{\tau,i:=0}{A}.
  \semtype{\sigma,a:=
     (a_0,
      \overrightarrow{\semtype{\sigma}{\tau,i=\star}{A}}(a_0),
      \overrightarrow{\overrightarrow{\semtype{\sigma}{\tau,i=\star}{A}}}(a_0))}
     {\tau,i:=0}{B}.\\
& &  \lambda f_1:\Pi a_1:\semtype{\sigma}{\tau,i:=1}{A}.\semtype{\sigma,a:=
     (\overleftarrow{\semtype{\sigma}{\tau,i=\star}{A}}(a_1),
      a_1,
      \overleftarrow{\overleftarrow{\semtype{\sigma}{\tau,i=\star}{A}}}(a_1))}
     {\tau,i:=1}{B}.\\
& &  \Pi a_0:\phi(\incrstep{i}{\tau}{(\tau \mapsto \semtype{\sigma}{\tau}{A})}).
  \Pi a_1:\phi(\incrstep{i}{\tau}{(\tau \mapsto \semtype{\sigma}{\tau}{A})}).
  f_0\, a_0 =_{\semtype{\sigma,a:=a}{\tau,i:=\star}{B}} f_1\, a_1,\\
& &
  ..., ...,   ..., ...,   ..., ...,   ..., ...)\\
\\
\semterm{\sigma}{\tau,i:=0}{\lambda a:A.t} & \defeq &
  \lambda a_0:\semtype{\sigma}{\tau,i:=0}{A}.
  \semterm{\sigma,a:=
     (a_0,
      \overrightarrow{\semtype{\sigma}{\tau,i=\star}{A}}(a_0),
      \overrightarrow{\overrightarrow{\semtype{\sigma}{\tau,i=\star}{A}}}(a_0))}
     {\tau,i:=0}{t}\\
\semterm{\sigma}{\tau,i:=1}{\lambda a:A.t} & \defeq &
  \lambda a_1:\semtype{\sigma}{\tau,i:=1}{A}.
  \semterm{\sigma,a:=
     (a_1,
      \overleftarrow{\semtype{\sigma}{\tau,i=\star}{A}}(a_1),
      \overleftarrow{\overleftarrow{\semtype{\sigma}{\tau,i=\star}{A}}}(a_1))}
     {\tau,i:=1}{t}\\
\semterm{\sigma}{\tau,i:=\star}{\lambda a:A.t} & \defeq &
  \lambda a:\phi(\incrstep{i}{\tau}{(\tau \mapsto \semtype{\sigma}{\tau}{A})}).
  \semterm{\sigma,a:=a}{\tau,i:=\star}{t}\\
\\
\semterm{\sigma}{\tau,i:=0}{t\,u} & \defeq &
  \semterm{\sigma}{\tau,i:=0}{t}\,\semterm{\sigma}{\tau,i:=0}{u}\\
\semterm{\sigma}{\tau,i:=1}{t\,u} & \defeq &
  \semterm{\sigma}{\tau,i:=1}{t}\,\semterm{\sigma}{\tau,i:=1}{u}\\
\semterm{\sigma}{\tau,i:=\star}{t\,u} & \defeq &
  \semterm{\sigma}{\tau,i:=\star}{t}\,\incrstep{i}{\tau}{\tau \mapsto \semterm{\sigma}{\tau}{u}}\\
\\
%\semtype{\sigma}{\tau}{X} & \defeq &
%  \proj{\tau}{\sigma(X)} \\
%\\
%\semterm{\sigma}{\tau}{a} & \defeq &
%  \proj{\tau}{\sigma(a)} \\
%\\
\end{array}
$$
\fi

\bibliographystyle{plain}
\bibliography{biblio-en,extra}

\end{document}

((=₀⋆, ...) ≃₂ (=₁⋆, ...)) ≜ λ(=⋆₀, ...).λ(=⋆₁, ...).
∀a₀₀a₀₁a₁₀a₁₁.... -> Type

((Type,Type,(≃,λx.x,...)),(Type,Type,(≃,λx.x,...)),((≃,λx.x,...),(≃,λx.x,...),(≃_2,λx.x,...))

((Πa:A₀₀.B₀₀),(Πa:A₀₁.B₀₁),(≃,λx.x,...)),(Type,Type,(≃,λx.x,...)),((≃,λx.x,...),(≃,λx.x,...),(≃_2,λx.x,...))

(Πa:A₀₀.B₀₀),(Πa:A₀₁.B₀₁),(≃,λx.x,...)),(Type,Type,(≃,λx.x,...)),((≃,λx.x,...),(≃,λx.x,...),(≃_2,λx.x,...))

          A₀                    A₁                              A⋆
/ A₀₀               \ / A₁₀               \ / =_A⋆₀ : A₀.₀→A₁.₀→U                     \
| A₀₁               | | A₁₁               | | =_A⋆₁ : A₀.₁→A₁.₁→U                     |
\ =_A₀⋆ : A₀₀→A₀₁→U / \ =_A₁⋆ : A₁₀→A₁₁→U / \ =_A⋆⋆ : Πa₀:ϕ(A₀).Πa₁:ϕ(A₁)             /
                                              a₀.₀ =_A⋆₀ a₁.₀ → a₀.₁ =_A⋆₁ a₁.₁ → U

Structure d'un carré de type A (qui lui-même est un carré) :

Les indices sur les variables font partie du nom. Les indices sur les
termes ou types sont des suites de projection.

t  ≜ (t₀,t₁,t⋆) : {a₀ : {a₀₀ : A₀₀;           a₀₁ : A₀₁;           a₀⋆ : a₀₀ =_A₀⋆ a₀₁};
                   a₁ : {a₁₀ : A₁₀;           a₁₁ : A₁₁;           a₁⋆ : a₁₀ =_A₁⋆ a₁₁};
                   a⋆ : {a⋆₀ : t₀₀ =_A⋆₀ t₁₀; a⋆₁ : t₁₀ =_A⋆₁ t₁₁; a⋆⋆ : a⋆₀ =_A⋆⋆ a⋆₁}}
t₀ ≜ (t₀₀,t₀₁,t₀⋆) : {a₀₀ : A₀₀;           a₀₁ : A₀₁;           a₀⋆ : a₀₀ =_A₀⋆ a₀₁}
t₁ ≜ (t₁₀,t₁₁,t₁⋆) : {a₁₀ : A₁₀;           a₁₁ : A₁₁;           a₁⋆ : a₁₀ =_A₁⋆ a₁₁}
t⋆ ≜ (t⋆₀,t⋆₁,t⋆⋆) : {a⋆₀ : t₀₀ =_A⋆₀ t₁₀; a⋆₁ : t₁₀ =_A⋆₁ t₁₁; a⋆⋆ : a⋆₀ =_A⋆⋆ a⋆₁}
                     ≡ t₀ =_ {a⋆₀:A⋆₀; a⋆₁:A⋆₁; a⋆⋆:a⋆₀ =_A⋆⋆ a⋆₁} t₁

                                 t : A
    /---------------------------------------------------------------------\
        t₀ : A₀                 t₁ : A₁                 t⋆ : t₀ =_A⋆ t₁
/ t₀₀ : A₀₀           \ / t₁₀ : A₁₀           \ / t⋆₀ : t₀₀ =_A⋆₀ t₁₀        \
| t₀₁ : A₀₁           | | t₁₁ : A₁₁           | | t⋆₁ : t₀₁ =_A⋆₁ t₁₁        |
\ t₀⋆ : t₀₀ =_A₀⋆ t₀₁ / \ t₁⋆ : t₁₀ =_A₁⋆ t₁₁ / \ t⋆⋆ : t⋆₀ =_A⋆⋆(t₀,t₁) t⋆₁ /

       t₀⋆
   t₀₀ ---> t₀₁
    |        |
t⋆₀ |  t⋆⋆   | t⋆₁
    V        V
   t₁₀ ---> t₁₁
       t₁⋆

Dans le type Πa:A.B

t₀⋆ : (t₀₀ =_(Πa₀⋆:A₀⋆.B₀⋆) t₀₁) ≡ Πa₀:{a₀₀;a₀₁;a₀⋆:a₀₀ =_A₀⋆ a₀₁}.(t₀₀ a₀₀ =_B₀⋆(a₀₀ a₀₁ a₀⋆) t₀₁ a₀₁)
t⋆⋆ : (t₀⋆ =_(Πa⋆⋆:A⋆⋆.B⋆⋆) t₁⋆) ≡
          Πa:{a₀:{a₀₀;a₀₁;a₀⋆:a₀₀ =_A₀⋆ a₀₁};
              a₁:{a₁₀;a₁₁;a₁⋆:a₁₀ =_A₁⋆ a₁₁};
              a⋆:{a⋆₀;a⋆₁;a⋆⋆:a⋆₀ =_A⋆⋆ a⋆₁}}.
          (t₀⋆ a₀ =_B⋆⋆[a⋆⋆] t₁⋆ a₁)

/ λa₀₀:A₀₀.t₀₀{a:=...} : A₀₀           \ / λa₁₀:A₁₀.t₁₀{a:=...} : A₁₀           \ / λa₀:Σ(A₀₀,A₁₀,A⋆₀).t⋆₀ :            \
|                                      | |                                      | |   λa₀₀.t₀₀ =_(Πa⋆₀:A⋆₀.B⋆₀) λa₁₀.t₁₀ |
| λa₀₁:A₀₁.t₀₁{a:=...} : A₀₁           | | λa₁₁:A₁₁.t₁₁{a:=...} : A₁₁           | | λa₁:Σ(A₀₁,A₁₁,A⋆₁).t⋆₁ :             |
|                                      | |                                      | |   λa₀₁.t₀₁ =_(Πa⋆₁:A⋆₁.B⋆₁) λa₁₁.t₁₁ |
| λa₀:A₀.t₀⋆{a:=...} :                 | | λa₀:A₀.t₁⋆{a:=...} :                 | | λa:A.t⋆⋆ :                           |
\   λa₀₀.t₀₀ =_(Πa₀⋆:A₀⋆.B₀⋆) λa₀₁.t₀₁ / \   λa₁₀.t₁₀ =_(Πa₁⋆:A₁⋆.B₁⋆) λa₁₁:t₁₁ / \   λa₀.t⋆₀ =_(Πa⋆⋆:A⋆⋆.B⋆⋆) λa₁.t⋆₁  /

                                                   app(t,u)
   /-------------------------------------------------------------------------------------------------------------------------------------------------\
         app(t₀,u₀)                               app(t₁,u₁)                                        app(t⋆,u⋆)
/ t₀₀ u₀₀ : B₀₀[u₀₀]                   \ / t₁₀ u₁₀ : B₁₀[u₁₀]                  \ / t⋆₀ (u₀₀,u₁₀,u⋆₀) : t₀₀ u₀₀ =_B⋆₀[u⋆₀] t₁₀ u₁₀                       \
| t₀₁ u₀₁ : B₀₁[u₀₁]                   | | t₁₁ u₁₁ : B₁₁[u₁₁]                  | | t⋆₁ (u₀₁,u₁₁,u⋆₁) : t₀₁ u₀₁ =_B⋆₁[u⋆₁] t₁₁ u₁₁                       |
\ t₀⋆ u₀  : t₀₀ u₀₀ =_B₀⋆[u₀⋆] t₀₁ u₀₁ / \ t₁⋆ u₁ : t₁₀ u₁₀ =_B₁⋆[u₁⋆] t₁₁ u₁₁ / \ t⋆⋆ u             : t⋆₀ (u₀₀,u₁₀,u⋆₀) =_B⋆⋆[u⋆⋆] t⋆.₁ (u₀₁,u₁₁,u⋆₁) /

= = = = = = =

Mq π...π(t) π...π(u) :

((λa:A₀₀.t₀₀),(λa:A₀₁.t₀₁),(λa:A₀₀.λa:A₀₁.λa⋆:a₀₀=a₀₁.t₀⋆.)),(...,...,(≃,λx.x,...)),((≃,λx.x,...),(≃,λx.x,...),(≃_2,λx.x,...))

  ⇑σ Type     ≜ (Type,Type,(≃,λx.x,...))
  ⇑σ (Πc:C.D) ≜ (Πc₀:ϕ(⇑σC)₀.(ϕ(⇑(σ,c:=((#₀(ϕ(⇑(σ)C))⋆)c₀))D))₀,
                 Πc₁:ϕ(⇑σC)₁.(ϕ(⇑(σ,c:=((#₀(ϕ(⇑(σ)C))⋆)c₁))D))₁,
                 (λf₀.λf₁.Πc:ϕ(⇑σC).f₀ c.0 =_(ϕ(⇑(σ,c:=c)D)⋆) f₁ c.1,
                  ...))   (9 com
  ⇑σ (Σc:C.D) ≜ (Σc₀:ϕ(⇑σC)₀.(ϕ(⇑(σ,c:=((#₀(ϕ(⇑(σ)C))⋆)c₀))D))₀,
                 Σc₁:ϕ(⇑σC)₁.(ϕ(⇑(σ,c:=((#₁(ϕ(⇑(σ)C))⋆)c₁))D))₁,
                 (λq₀.λq₁.Σp:(q₀.1 =_(ϕ(⇑σC)⋆) q₁.1).(q₀.2 =_(ϕ(⇑(σ,c:=c)D)⋆) q₁.2))
  ⇑σ (t u)    ≜ ((⇑σt)₀ (⇑σu)₀,
                 (⇑σt)₁ (⇑σu)₁,
                 (⇑σt)⋆ (⇑σu))  on va avoir besoin de coe ici ??
  ⇑σ (λc:C.t) ≜ (λc₀:ϕ(⇑σC)₀.(⇑(σ,c:=((#₀(ϕ(⇑(σ)C))⋆)c₀))t)₀,
                 λc₁:ϕ(⇑σC)₁.(⇑(σ,c:=((#₁(ϕ(⇑(σ)C))⋆)c₁))t)₁,
                 λc:ϕ(⇑σC).(⇑(σ,c:=c)t)⋆)
  ⇑σ (t,u)    ≜ (((⇑σt)₀,(⇑σu)₀),
                 ((⇑σt)₁,(⇑σu)₁),
                 ((⇑σt)⋆,(⇑σu)⋆))  on va avoir besoin de coe ici ??
  ⇑σ (t.1)    ≜ ((⇑σt)₀.1,
                 (⇑σt)₁.1,
                 (⇑σt)⋆.1)  on va avoir besoin de coe ici ??
  ⇑σ (t.2)    ≜ ((⇑σt)₀.2,
                 (⇑σt)₁.2,
                 (⇑σt)⋆.2)  on va avoir besoin de coe ici ??
  ⇑σ c        ≜ σ(c)   (où chaque traversée d'un i dans σ avant de trouver c induit un a↦(a,a,⇑σ'a)
                        avec σ' préfixe de σ avant i)
  ⇑σ =ⁿ_Ν     ≜ (=ⁿ_Ν,=ⁿ_N,(=ⁿ⁺¹_,λx.x,...))   (9 composantes dans la 3e composante)
  ⇑σ 0ⁿ       ≜ (0ⁿ,0ⁿ,0ⁿ⁺¹)             (où 0ⁿ⁺¹ prouve Γ ⊢ 0ⁿ =ⁿ⁺¹_N 0ⁿ)
  ⇑σ (Sⁿ t)   ≜ (Sⁿ (⇑σt)₀,Sⁿ (⇑σt)₁,Sⁿ⁺¹ (⇑σt)⋆)
                    (où Sⁿ⁺¹ prouve Γ ⊢ (Sⁿ n) =ⁿ⁺¹_N (Sⁿ m) à partir de Γ ⊢ n =ⁿ_N m)
  ⇑σ (λi.t)   ≜ (⇑(σ,i)t)⋆
  ⇑σ (t i)    ≜ ⇑(σ\i) t ???
  ⇑σ ([α₁,...,α_n] =ⁿ_X [β₁,...,β_n]) prédéfini en fonction
      des ⇑σαᵢ et ⇑σβᵢ pour chaque n-cube de X (y compris pour n=0)