\subsection{Time Stepping Algorithm}\label{sec:time stepping}

In \Cyder, radionuclide contaminants flow outward from the central component,
usually the waste form. An implicit time stepping method arrives at the updated
state of each component, radially outward, as a function of both the past state
and the current state of the system. Mass balance is conducted in each
component at each time step. These calculations proceed from the innermost
component (e.g. the waste form) to the outermost component (e.g. the far field), with mass transfer calculations conducted
at the boundaries. As mass flows from inner components to outer components, the
mass balances in both components are updated.  Thus, nuclide release
information passes radially outward from the waste stream sequentially through
each containment layer to the geosphere in a generic geometry of the form in
Figure \ref{fig:repo_layout}.
The default timestep in \Cyclus, and therefore in \Cyder, is one month.

At each component interface where mass transfer occurs and within each component
where mass balances take place, the flow model is solved with the most up to
date information available.  To illustrate the algorithm by which mass flow
calculations are conducted through the system of components at each time step,
the phases of a single time step for a simple pair of components will be
described.

The flow of the timestepping algorithm is seen in Figures \ref{fig:vols},
\ref{fig:vols_trans}, and \ref{fig:vols_update} and is detailed further in the
following sections.  For the remaining discussion, the source of material, $i$, is the
inner component (i.e. the waste form) and the next destination of the material,
$j$, is the adjacent outer component (i.e. the waste package). This example
will be carried through the explanation of all five phases of the timestepping
algorithm.

\input{./nuclide_models/timesteps/timesteps_fig}

\FloatBarrier

\subsubsection{Phase 1: Initial Conditions}

At the beginning of a timestep, the initial conditions in both the source and
the sink are equal to the final updated state of the previous time step.
On the first time step, initial mass inventories of each component in
the repository system must be defined. In the example case of the source and
sink, this might be

\begin{align}
 m_i(t_0) = 10 \mbox{[kg]}\\
 m_j(t_0) = 0.
\end{align}

\subsubsection{Phase 2: Interior Mass Balance}

The mass distribution, $m_i(\vec{r})$, and concentration profile,
$C_i(\vec{r})$, in the interior source volume $i$ at time $t_n$ are calculated
based on the initial condition, any influxes, and the physics of its mass
balance model.  The four different mathematical models available for this mass
distribution and concentration profile calculation are discussed in Section
\ref{sec:mass_balance}.

The resulting mass distribution and concentration profiles fully inform
the conditions on the boundary at $r_i$. This information is made available
to the external component, $j$ in order to support the next phase, the mass
transfer calculation. In the example case of the source and sink, this step
defines the concentration profile across each volume,

\begin{align}
C_i(r) = f(r)
C_j(r) = 0\\
\intertext{where}
\int f(r)dV = 10.
\end{align}

\subsubsection{Phase 3: Mass Transfer Calculation}

The mass transfer, $m_{ij}(t_n)$ from the source volume $i$ to the sink volume
$j$ is calculated next, based on the up to date conditions in volume $i$ (where
$0\le r \le r_i$) determined in Phase 2 and the initial conditions in volume
$j$ (where $r_i \le r \le r_j$). The mass transfer is calculated according to
the mass transfer mode preference of the mass balance model of volume $j$, as
discussed in Section \ref{sec:mass_transfer}.

In the example case of the source and sink, mass transfered from $i$ to $j$ is
determined based on conditions in $i$ and the mass transfer mode between $i$
and $j$. Said another way, the mass transfer rate $m_{ij}$ between $i$ and $j$
is equivalent to the time derivative $\dot{m}$ of the mass released from $i$ and
simultaneously entering $j$,

\begin{align}
m_{ij}= -\dot{m_i} = \dot{m_j}.
\end{align}

\subsubsection{Phase 4: Exterior Mass Balance}

When a mass flux $m_{ij}$ is determined between volumes $i$ and $j$, the
mass is added to the exterior sink volume $j$. Accordingly, necessary updates
are made to the mass balance and concentration profile as discussed in Section
\ref{sec:mass_balance}. In the case of the source and sink, the mass change in
phase 3 is added to the external component, $j$,

\begin{align}
        m_j(t_n) &= m_j(t_{n-1}) + \int_{t_{n-1}}^{t_n}m_{ij}dt\\
                 &= m_j(t_{n-1}) + m_{ij}(t_n).
\end{align}

\subsubsection{Phase 5: Interior Mass Balance Update}

When a mass flux $m_{ij}(t_n)$ is determined between volumes $i$ and $j$, and
the mass added to the exterior sink volume $j$ (as in phase 4) it is also
extracted from the interior source volume $i$.  When the material is extracted
from the interior source volume, the contained mass distribution and
concentration profile are updated to reflect this change,

\begin{align}
  m_{i}(t_n^*) &= m_i(t_n) - m_{ij}(t_n).
\end{align}


\documentclass[a4paper]{iagproc}

\usepackage{xcolor}
\usepackage{minted}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{caption}
\usepackage{gensymb}
\usepackage{lmodern}
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{array}
\usepackage{upquote}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{rotating}
\usepackage[hidelinks]{hyperref}
\usepackage{forest}
\usetikzlibrary{mindmap,shadows, shapes, arrows, positioning}

\title{Reverse Polish Notation}
\author{Ian McLoughlin (\href{https://ianmcloughlin.github.io}{ianmcloughlin.github.io})}
\begin{document}

\maketitle
\noindent
Reverse Polish notation is a syntax for writing expressions involving operators and operands.
When the number of operands that each operator takes is fixed, reverse Polish notation does not require any brackets, or precedence of operators, to unambiguously represent an expression.

\subsection*{Example}
Let’s start with an example.
Consider the following bracketed expression.

$$ ((5 + 4) \times 9) \div (6 - 3) $$

This expression is written in what we call infix notation -- the (binary) operators are written in-between their (two) operands.
The operators in this case are the common addition, subtraction, multiplication and division.
The operands are the numbers to which these operators are to be applied: 5, 4, 9, 6 and 3.
In reverse Polish notation (RPN), this expression is written as:

$$ 5 \quad 4 \quad + \quad 9 \quad \times \quad  6 \quad 3 \quad - \quad \div $$

The difference between the RPN form and the infix form is simply that the operator is written after its two operands, rather than between them.

\subsection*{Benefits of RPN}
We are so used to using the infix notation, why would we use RPN instead?
There are three main benefits.

Firstly, RPN does not require bracketing.
In infix notation, brackets are needed in expressions such as $(3 + 4) \times 5$.
Without them, 4 would be multiplied 5 giving 20, which in turn would be added to 3.
This is following the usual convention of giving multiplication a higher precedence than addition.
That would give the result as 23, rather than the correct answer of 35.
In fact, RPN does not require any hierarchy of operators at all.

Secondly, RPN expressions can be evaluated using a simple algorithm.
The algorithm involves a single pass of reading the expression from left to right.
The intermediate calculations can be done as they arise.
Contrast this with expressions in infix notation such as $3 + 4 \times 5$.
In this case the expression must be fully read from left to right before any intermediate calculation can be performed and the expression can be interpreted.

Finally, when an RPN expression is to be evaluated by a computer, less memory and less instructions are used as compared with infix expressions.
Less memory is needed, because the computer can apply the operators when they are read, as noted above.
With infix expressions, the computer must read and store the expression before parsing it.
Less instructions are needed with RPN for the same reason.

\subsection*{Evaluation and the stack}
Let's now evaluate the above RPN expression:
$$ 5 \quad 4 \quad + \quad 9 \quad \times \quad  6 \quad 3 \quad - \quad \div $$
Evaluation can be done using a single stack.
A stack is a simple data structure that permits only two operations: pushing and popping.

Pushing involves placing an item on the top of the stack.
This is the only way to put a new item into the stack, to place it on top.
Popping involves removing the item on the top of the stack.
This is the only way to remove an item from the stack, to take the top item.
In this way, a stack is a last-in-first-out mechanism -- the last item in must be the first item out.

In evaluating an RPN expression, a stack is used to store numbers.
These numbers can be either the original operands in the expression, or the result of applying some of the operators in the expression to some of the operands.

An RPN expression is read item by item from left to right.
Two simple rules are used as each item is read.
The first is applied when the item is a number: push the number to the top of the stack.
The second is applied when the item is an operator: pop the first element off the stack, pop the next element off the stack, apply the operator to them, and finally push the result to the top of the stack.
So, the rules are:
\begin{description}
  \item[Number:] push number to stack.
  \item[Operator:] pop twice from stack, apply operator, push result.
\end{description}

The following table depicts the stack as each symbol of our example RPN expression is read.
\begin{center}
  \begin{tabular}[b]{lccccccccc}
    \toprule
    & $5$ & $4$ & $+$ & $9$ & $\times$ & $6$  & $3$  & $-$  & $\div$ \\
    \midrule \\
    \multirow{3}{6mm}[-2mm]{\begin{sideways}Stack\end{sideways}}
    & $ $ & $ $ & $ $ & $ $ &     $ $  & $ $  & $3$  & $ $  & $ $    \\
    & $ $ & $4$ & $ $ & $9$ &     $ $  & $6$  & $6$  & $3$  & $ $    \\
    & $5$ & $5$ & $9$ & $9$ &     $81$ & $81$ & $81$ & $81$ & $27$    \\
    \bottomrule
  \end{tabular}
\end{center}
So, when the first item, $5$ is read, it is a number so it's pushed to the empty stack.
The second item, $4$, is a number too so it is pushed to the stack.
The third is the operator $+$, so the top item on the stack ($4$) is popped, then the next item ($5$) is available for popping and is popped.
The numbers are added to give $9$, and then the $9$ is pushed to the stack.
The final answer is what is left on the stack once the full expression has been read, and this must be a single number.

\subsection*{Order of the operands}
One technicality to watch out for is the order of the operands.
With addition and multiplication, the order does not matter.
For instance, $4+5=5+4=9$.
However, with subtraction and division order does matter: $5-4 \neq 4-5$.

In RPN, using the everyday operators like plus and minus, the convention is for $5 \ 4 \ -$ to mean $5-4$, and not $4-5$.
It doesn't really matter, so long as we agree on what we mean and are consistent.
Consider the following idea: creating a new operator $\ominus$ that is defined as $5 \ominus 4 = 4 - 5$.
Then we can use $\ominus$ in our RPN expressions.
So, $5 \ 4 \ \ominus$ in RPN would evaluate as $5 \ominus 4 = 4 - 5$ in infix.

\subsection*{Valid RPN expressions}
An interesting question to ask is \emph{what combinations of operators and operands constitute valid RPN expressions?}
An expression like $+ \ - \ 5$ is clearly not valid.
Neither is an expression like $+ \ 5 \ 4$.

Note that valid RPN expressions always have one more number than operators.
Every operator needs two operands, and so two operators need three operands, three need four, and so on.
Also, note that the stack algorithm needs to work.
It only works if the following two conditions hold:
\begin{enumerate}
  \item There are at least two numbers on the stack whenever an operator is read.
  \item There is exactly one number on the stack when the end of the expression is reached.
\end{enumerate}
The first rule implies that every RPN expression must begin with two numbers.
The second rule implies that every RPN expression must end with an operator.

While necessary, these last two stipulations are not sufficient.
For example, the expression $1 \ 2 \ 3 \ + \ + \ + \ 4 \ 5 \ +$ both starts with two numbers and ends with an operator.
It even has the correct number of operators relative to numbers.
However, upon reading the third $+$ symbol, the stack has only a single item on it and the operator cannot be applied.
We must read the expression and keep track of the size of the stack to confirm that the stack contains two numbers for every operator read.
Only then we will have a valid RPN expression.

\subsection*{Evaluation trees}
RPN expressions can be decomposed into evaluation trees.
An evaluation tree for an RPN expression has operators for internal vertices, where their operands are their children, and the numbers in the expression are the leaves.
The first operand for an operator is drawn as the left-most child, and last is the right-most.
So, for instance, the evaluation tree for the above expression is as follows.
\begin{center}
  \forestset{default preamble={for tree={circle,draw}}}
  \begin{forest}
    [$\div$
      [$\times$
        [$+$
          [$5$]
          [$4$]]
        [$9$]]
      [$-$
        [$6$]
        [$3$]]]
  \end{forest}
\end{center}

\nocite{*}
\bibliographystyle{plain}
\bibliography{bibliography}
\end{document}


\section{Task B}
\label{sec:task-b}

The same plots as in section~\ref{sec:task-a} were obtained for the case
when the right truss has a 5\% bigger cross-sectional area,
\(A_{2} = A_{1} \cdot 1.05\), compared to the left truss.
The plots are given in figure~\ref{fig:plots-B} for the left truss.
\begin{figure}[th]
  \centering
  % Force - deflection:
  \begin{subfigure}[t]{\textwidth}
    \begin{tikzpicture}
      \begin{axis}[
        width = 0.95\textwidth,
        height=\axisdefaultheight,
        tick label style={/pgf/number format/fixed},
        try min ticks=6,
        minor tick num=1,
        grid=both,
        xlabel = {\( (Y - y) / L \), [-]},
        ylabel = {\( F / (E A) \), [-]},
        xmin = 0,
        xmax = 2,
        ymin = -0.15,
        ymax = 0.2,
        legend cell align=left,
        legend style={anchor=south east, at={(1,0)}}
        ]
        \addplot+ table[skip first n=1] {data/force_deflection_elastic_B.dat}; % + = same automatically determined styles, but in addition it uses [options]
        \addlegendentry{elastic}
        \addplot+ table[skip first n=1] {data/force_deflection_plastic_B.dat};
        \addlegendentry{plastic}
      \end{axis}
    \end{tikzpicture}
    \caption{Force - deflection}
  \end{subfigure}

  % Stress - strain:
  \begin{subfigure}[t]{0.48\textwidth}
    \begin{tikzpicture}[baseline,yscale=1.0, xscale=1.0]
      \begin{axis}[
        try min ticks=7,
        minor tick num=1,
        grid=both,
        xlabel = {strain, [-]},
        ylabel = {Kirchhoff stress, [kN/mm\textsuperscript{2}]},
        xmin = -0.4,
        xmax = 0.3,
        xtick={-0.4, -0.2, 0, 0.2},
        ymin = -30,
        ymax = 30,
        legend cell align=left,
        legend style={anchor=south east, at={(1,0)}}
        ]
        \addplot+ table[skip first n=1] {data/stress_strain_elastic_B.dat};
        \addlegendentry{elastic}
        \addplot+ table[skip first n=1] {data/stress_strain_plastic_B.dat};
        \addlegendentry{plastic}
      \end{axis}
    \end{tikzpicture}
    \caption{Constitutive behaviour}
  \end{subfigure}
  % Total - plastic strain:
  \begin{subfigure}[t]{0.48\textwidth}
    \begin{tikzpicture}[baseline,yscale=1.0, xscale=1.0]
      \begin{axis}[
        % try min ticks=8,
        minor tick num=1,
        grid=both,
        xlabel = {total strain, [-]},
        ylabel = {plastic strain, [-]},
        xmin = -0.4,
        xmax = 0.3,
        ymin = -0.27,
        ymax = 0.15
        ]
        \addplot+ [mark=none] table[skip first n=1] {data/tot_pl_strain_B.dat};
        \addplot+  table[skip first n=1] {data/tot_pl_strain_B.dat}; % Plot again using style of 2nd element in cycle list.
      \end{axis}
    \end{tikzpicture}
    \caption{Plastic - total strain}
  \end{subfigure}
  \caption{Plots of large deflection elasto-plastic behaviour of the fist truss when \(A_{2} = 1.05 A_{1}\).}
  \label{fig:plots-B}
\end{figure}

In addition, the displacement of the initially upper joint is shown in
figure~\ref{fig:node-displ}.
As could be anticipated, the joint moves in the direction of the truss with
larger cross-sectional area when that truss is stretched.
\begin{figure}[th]
  \centering
  \begin{tikzpicture}[baseline,yscale=1.0, xscale=1.0]
    \begin{axis}[
      % try min ticks=8,
      width = 0.7\textwidth,
      minor tick num=1,
      grid=both,
      xlabel = {horizontal displacement, [mm]},
      ylabel = {vertical displacement, [mm]},
      legend cell align=left,
      legend style={anchor=north east, at={(1,1)}},
      every axis plot/.append style={line width=0.8pt}, % 0.4 - default
      xmin=-12,
      xmax=30,
      ymin=-300,
      ymax=0
      ]
      \addplot+ [mark=none] table[skip first n=1] {data/node_displ_elastic_B.dat};
      \addlegendentry{elastic, \(A_{2} = 1.05 A_{1}\)}
      \addplot+ [mark=none] table[skip first n=1] {data/node_displ_plastic_B.dat};
      \addlegendentry{plastic, \(A_{2} = 1.05 A_{1}\)}
      \addplot+ [mark=none, dashed] table[skip first n=1] {data/node_displ_plastic_B_1percent.dat};
      \addlegendentry{plastic, \(A_{2} = 1.01 A_{1}\)}
      \addplot+ [mark=none, densely dotted] table[skip first n=1] {data/node_displ_plastic_B_10percent.dat};
      \addlegendentry{plastic, \(A_{2} = 1.1 A_{1}\)}
    \end{axis}
  \end{tikzpicture}
  \caption{Displacement of the initially upper node of the first (left) truss.}
  \label{fig:node-displ}
\end{figure}

It is worth mentioning that the elasto-plastic solution required rather small
displacement increments to get a smooth solution.

%%% Local Variables:
%%% mode: latex
%%% TeX-master: "../main"
%%% End:


\chapter{Compact types}\label{chap:compact}

In this chapter we introduce the notion of compact type, and we show that the compact types are closed under finite coproducts, $\Sigma$-types, finite products, pushouts, reflexive coequalizers, and retracts. In particular it follows that the spheres are compact.

In \cref{sec:localization_compact} we show that if $P$ and $Q$ are families of compact types, then the subuniverse of $F$-local types is reflective. Of course, one might impose stronger assumptions on the type theory so that the subuniverse of $F$-local types is reflective for any family $F$ of maps (see for instance \cite{RijkeShulmanSpitters}). The setting of this dissertation is that of univalent type theory in which the universes are closed under homotopy pushouts, so we have to find a different way to define localizations.

The idea is to approximate the $F$-localization of a type $X$ by iterated `quasi $F$-local extensions' of $X$, by which we mean a map $l:X\to Y$ equipped with a diagonal filler for the square
\begin{equation*}
\begin{tikzcd}
X^{Q_i} \arrow[r,"l\circ\blank"] \arrow[d,swap,"\blank\circ F_i"] & Y^{Q_i} \arrow[d,"\blank\circ F_i"] \\
X^{P_i} \arrow[r,swap,"l\circ \blank"] & Y^{P_i},
\end{tikzcd}
\end{equation*}
for each $i:I$. We show in \cref{prp:colim_local} that, provided that $F$ is a family of maps between compact types, the sequential colimit of type sequence
\begin{equation*}
\begin{tikzcd}
X_0 \arrow[r,"l_0"] & X_1 \arrow[r,"l_1"] & X_2 \arrow[r,"l_2"] & \cdots
\end{tikzcd}
\end{equation*}
is $F$-local if each $l_n$ has the structure of a quasi $F$-local extension. We show that there is an initial quasi $F$-local extension $l:X\to QL_F X$, for every type $X$, and in \cref{thm:localization} we show that the sequential colimit $X\to QL_F^\infty$ is an $F$-localization. We establish in \cref{thm:localization} that if $F$ is a family of maps between compact types, then the subuniverse of $F$-local types is a reflective subuniverse. Furthermore, if $A$ is a family of compact types, then the subuniverse of $A$-null types is a modality.

Dan Christensen pointed out that this construction of $F$-localization already appears in section 1.B of \cite{Farjoun}, where arbitrary localizations are constructed by iterating the initial quasi $F$-local extension transfinitely many times. We stick to the case $\omega$ since larger ordinals are not yet as well understood in homotopy type theory. A minor note is that in Theorem B.5 Dror Farjoun only establishes that the transfinite colimit $QL_F^\kappa X$ localizes the homotopy groups. Our proofs are therefore different than Dror Farjoun's.

\section{Compact types}

\begin{defn}
Consider a type sequence $\mathcal{A}\jdeq (A,f)$, and let $X$ be a type. We define the type sequence $\mathcal{A}^X$ to consist of
\begin{equation*}
\begin{tikzcd}
A_0^X \arrow[r,"f_0\circ \blank"] & A_1^X \arrow[r,"f_1\circ\blank"] & A_2^X \arrow[r,"f_2\circ\blank"] & \cdots.
\end{tikzcd}
\end{equation*}
Furthermore, given a natural transformation $\tau:\mathsf{Seq}(\mathcal{A},\mathcal{B})$ of type sequences, we define the natural transformation $\tau^X$ to consist of
\begin{equation*}
\begin{tikzcd}[column sep=large]
A_0^X \arrow[r,"f_0\circ \blank"] \arrow[d,swap,"\tau_0\circ\blank"] & A_1^X \arrow[r,"f_1\circ\blank"] \arrow[d,swap,"\tau_1\circ\blank"] & A_2^X \arrow[r,"f_2\circ\blank"] \arrow[d,swap,"\tau_2\circ\blank"] & \cdots \\
B_0^X \arrow[r,swap,"g_0\circ \blank"] & B_1^X \arrow[r,swap,"g_1\circ\blank"] & B_2^X \arrow[r,swap,"g_2\circ\blank"] & \cdots
\end{tikzcd}
\end{equation*}
where the naturality squares commute by whiskering the naturality squares of $\tau$.
\end{defn}

In particular, if $\tau:\mathsf{Seq}(\mathcal{A},\Delta Y)$ is a cocone with vertex $Y$, then $\tau^X :\mathsf{Seq}(\mathcal{A}^X,(\Delta Y)^X)$ is a cocone with vertex $Y^X$, since $(\Delta Y)^X \jdeq \Delta (Y^X)$.

\begin{defn}
We call a type $X$ \define{(sequentially) compact} if for any type sequence
\begin{equation*}
\begin{tikzcd}
A_0 \arrow[r] & A_1 \arrow[r] & A_2 \arrow[r] & \cdots
\end{tikzcd}
\end{equation*}
the map
\begin{equation*}
\mathsf{seq\usc{}ind}(\mathsf{constr}(\mathcal{A})^X)
  : \tfcolim(X\to A_n)\to(X\to A_\infty)
\end{equation*}
is an equivalence.
\end{defn}

\begin{eg}
The empty type is compact, simply because $X^\emptyt$ is contractible for any type $X$, and a sequential colimit of contractible types is contractible.
\end{eg}

\begin{eg}
The unit type is compact because $\lam{x}\mathsf{const}_x:X\to X^\unit$ is an equivalence for any type $X$. Thus we obtain a natural equivalence
\begin{equation*}
\begin{tikzcd}
A_0 \arrow[d] \arrow[r] & A_1 \arrow[d] \arrow[r] & A_2 \arrow[d] \arrow[r] & \cdots \\
A_0^\unit \arrow[r] & A_1^\unit \arrow[r] & A_2^\unit \arrow[r] & \cdots.
\end{tikzcd}
\end{equation*}
Thus we obtain a commuting triangle
\begin{equation*}
\begin{tikzcd}[column sep=0]
 & A_\infty \arrow[dl] \arrow[dr] & \phantom{\mathsf{colim}(A_n^\unit)} \\
\mathsf{colim}(A_n^\unit) \arrow[rr] & & A_\infty^\unit.
\end{tikzcd}
\end{equation*}
where two out of three maps are equivalences. Therefore the unit type is compact by the 3-for-2 property.
\end{eg}

We will show in the remainder of this section that the compact types are closed under finite coproducts, $\Sigma$-types (and therefore also finite products), pushouts, reflexive coequalizers, and retracts. In the following example we note that compact types are not closed under pullbacks, and are not closed under exponentiation either.

\begin{rmk}
The compact types are not closed under identity types, because $\Z$ is not compact
and $\eqv{\Z}{\Omega(\Sn^1)}$. To see that $\Z$ is not compact, consider
the sequence $A_n\defeq\nat_{-n}$, where $\nat_{-n}$ is a version of the natural
numbers of starting at $-n$ and $A_n\to A_{n+1}$ is the inclusion map. The colimit
of $A_n$ is $\Z$ and the image of the map $\tfcolim(\Z\to A_n)\to (\Z\to\Z)$ is
the set of maps that are bounded from below. Thus, it is not surjective.

Also, the compact types are not closed under exponentiation. We have
the equivalence $\eqv{(\Sn^1\to\Sn^1)}{\Sn^1\times\Z}$, which is not
compact.
\end{rmk}

\begin{lem}
Finite coproducts of compact types are compact.
\end{lem}

\begin{proof}
We have already seen that the empty type is compact.
Thus it remains to show that compact types are closed under disjoint
sums.

Suppose that $X$ and $Y$ are compact. Then we have a commuting diagram of the form
\begin{equation*}
\begin{tikzcd}
\mathsf{colim}(\mathcal{A}^{X+Y}) \arrow[r] \arrow[d] & \mathsf{colim}(\mathcal{A}^X\times \mathcal{A}^Y) \arrow[r] & \mathsf{colim}(\mathcal{A}^X)\times\mathsf{colim}(\mathcal{A}^Y) \arrow[d] \\
A_{\infty}^{X+Y} \arrow[rr] & & A_\infty^X \times A_\infty^Y
\end{tikzcd}
\end{equation*}
where all but one of the maps are equivalences. Thus the remaining map is an equivalence too.
\end{proof}

\begin{defn}
Let $\mathcal{A}:X\to \mathsf{Seq}$ be an indexed type sequence. Then we define the type sequence $\prd{x:X}\mathcal{A}(x)$ to consist of
\begin{equation*}
\begin{tikzcd}[column sep=7em]
\prd{x:X}A_0(x) \arrow[r,"{\lam{h}{x}f_0(x,h(x))}"] & \prd{x:X}A_1(x) \arrow[r,"{\lam{h}{x}f_1(x,h(x))}"] & \cdots
\end{tikzcd}
\end{equation*}
\end{defn}

\begin{prp}
Let $\mathcal{A}:X\to\mathsf{Seq}$ be an indexed type sequence, indexed by a compact type $X$.
Then the canonical map
\begin{equation*}
\tfcolim\Big(\prd{x:X}A_n(x)\Big) \to \Big(\prd{x:X} A_\infty(x)\Big)
\end{equation*}
is an equivalence.
\end{prp}

\begin{proof}
Consider the commuting diagram
\begin{equation*}
\begin{tikzcd}
\mathsf{colim}\Big(\prd{x:X}\mathcal{A}(x)\Big) \arrow[d] \arrow[r] & \prd{x:X}A_\infty(x) \arrow[d] \arrow[r] & \unit \arrow[d,"\mathsf{const}_{\idfunc[X]}"] \\
\mathsf{colim}\Big(X\to\sm{x:X}A_n(x)\Big) \arrow[r] & \Big(X\to \sm{x:X}A_\infty(x)\Big) \arrow[r,swap,"\proj 1\circ\blank"] & (X\to X).
\end{tikzcd}
\end{equation*}
The square on the right and the outer rectangle are pullback squares. Hence the square on the left is a pullback square. Now observe that the type $\sm{x:X}A_\infty(X)$ is the sequential colimit of the type sequence $\sm{x:X}A_n(x)$, by \cref{thm:colim_sigma}. Therefore it follows by the assumption that $X$ is compact, that the bottom map in the left square is an equivalence. We conclude that the top map in the left square is an equivalence, proving the claim.
\end{proof}

\begin{cor}
Suppose $X$ is compact, and $Y(x)$ is compact for each $x:X$. Then the total space $\sm{x:X}Y(x)$ is also compact.
\end{cor}

\begin{proof}
Let $\mathcal{A}$ be a type sequence. Then we have the following commuting pentagon
\begin{equation*}
\begin{tikzcd}[column sep=-5em]
& \mathsf{colim}\Big(\mathcal{A}^{\sm{x:X}Y(x)}\Big) \arrow[rr] \arrow[dl] & & A_\infty^{\sm{x:X}Y(x)} \arrow[dr] \\
\mathsf{colim}\Big(\prd{x:X}\mathcal{A}^{Y(x)}\Big) \arrow[drr] & & & & \prd{x:X} A_\infty^{Y(x)} \\
& & \prd{x:X}\mathsf{colim}\Big(\mathcal{A}^{Y(x)}\Big) \arrow[urr] & \phantom{\mathsf{colim}\Big(\mathcal{A}^{\sm{x:X}Y(x)}\Big)} & \phantom{\mathsf{colim}\Big(\prd{x:X}\mathcal{A}^{Y(x)}\Big)}
\end{tikzcd}
\end{equation*}
in which all but the top map are known to be equivalences. Hence it follows that the top map is an equivalence, which shows that $\sm{x:X}Y(x)$ is compact.
\end{proof}

\begin{cor}
Compact types are closed under finite products.
\end{cor}

\begin{prp}\label{prp:pushout_compact}
Compact types are closed under pushouts.
\end{prp}

\begin{proof}
Consider a span $\mathcal{S}\jdeq (S,f,g)$ from $X$ to $Y$, where $X$, $Y$, and $S$ are assumed to be compact, and let $\mathcal{A}$ be a type sequence.
Then we have the commuting pentagon
\begin{equation*}
\begin{tikzcd}[column sep=-5em]
& \mathsf{colim}\Big(\mathcal{A}^{X\sqcup^{S} Y}\Big) \arrow[rr] \arrow[dl] &[-2em] &[-2em] A_\infty^{X\sqcup^S Y} \arrow[dr] \\
\mathsf{colim}\Big(\mathcal{A}^X\times_{\mathcal{A}^S}\mathcal{A}^Y\Big) \arrow[drr] & & & & A_\infty^X \times_{A_\infty^S} A_\infty^Y \\
& & \mathsf{colim}(\mathcal{A}^X)\times_{\mathsf{colim}(\mathcal{A}^S)}\mathsf{colim}(\mathcal{A}^Y) \arrow[urr] & \phantom{\mathsf{colim}\Big(\mathcal{A}^{X\sqcup^{S} Y}\Big)} & \phantom{\mathsf{colim}\Big(\mathcal{A}^X\times_{\mathcal{A}^S}\mathcal{A}^Y\Big)}
\end{tikzcd}
\end{equation*}
In this diagram, the downwards maps from the top left and from the top right are equivalences by the universal property of pushouts. The downwards map to the left side to the bottom is an equivalence since sequential colimits preserve pullbacks by \cref{thm:seq_colim_pb}. The map from the bottom to the right side is an equivalence by the assumption that $X$, $Y$, and $S$ are all compact types. Therefore we conclude that the top map is an equivalence, which proves the claim.
\end{proof}

\begin{cor}
Compact types are closed under joins, suspensions, and wedges. Furthermore, the cofiber of a map between compact types is again compact. In particular, all the spheres and the finite dimensional real and complex projective spaces are compact, and the smash product of compact pointed types is again compact.
\end{cor}

\begin{defn}
A reflexive graph $\mathcal{A}$ is said to be compact its types of vertices and (the total space of) edges are compact.
\end{defn}

\begin{cor}
The reflexive coequalizer of a compact reflexive graph is again compact.
\end{cor}

\begin{proof}
This follows immediately from \cref{prp:pushout_compact,thm:rcoeq_is_pushout}.
\end{proof}

\begin{prp}
Compact types are closed under retracts.
\end{prp}

\begin{proof}
Suppose that $Y$ is a retract of a compact type $X$, i.e.~we have $i:Y\to X$ and $r:X\to Y$ such that $r\circ i=\mathrm{id}_Y$.
Note that for any type $Z$, the type $Z^Y$ is a retract of $Z^X$, since we have the section-retraction pair
\begin{equation*}
\begin{tikzcd}
Z^Y \arrow[r,"\blank\circ r"] & Z^X \arrow[r,"\blank\circ i"] & Z^Y.
\end{tikzcd}
\end{equation*}
It follows that for any type sequence $\mathcal{A}$ we have a section-retraction pair
\begin{equation*}
\begin{tikzcd}
\tfcolim(\mathcal{A}^Y) \arrow[r] \arrow[d] & \tfcolim(\mathcal{A}^X) \arrow[r] \arrow[d] & \tfcolim(\mathcal{A}^Y) \arrow[d]\\
A_\infty^Y \arrow[r] & A_\infty^X \arrow[r] & A_\infty^Y
\end{tikzcd}
\end{equation*}
of morphisms. Note that the downward morphism in the middle is an equivalence by the assumption that $X$ is compact. Recall from Theorem 4.7.4 of \cite{hottbook} that a retract of an equivalence is again an equivalence, so the claim follows.
\end{proof}

\section{Localizing at maps between compact types}\label{sec:localization_compact}
In this section, we assume to have $P,Q:I\to\UU$ and a family of maps $F:\prd{i:I} P(i)\to Q(i)$.

Recall type of diagonal fillers for a commuting square
\begin{equation*}
\begin{tikzcd}
A \arrow[d,swap,"f"] \arrow[r,"i"] & B \arrow[d,"g"] \\
X \arrow[r,swap,"j"] & Y
\end{tikzcd}
\end{equation*}
with $H:j\circ f\htpy g\circ i$ is defined to be the fiber of the gap map
\begin{equation*}
\mathsf{gap}:B^X \to B^A\times_{Y^A} Y^X
\end{equation*}
at the point $(i,j,\mathsf{eq\usc{}htpy}(H))$.

\begin{defn}
A \define{quasi $F$-local extension} of $X$ consists of a map $l:X\to Y$ equipped with a diagonal filler for the commuting square
\begin{equation*}
\begin{tikzcd}
X^{Q_i} \arrow[r,"l\circ\blank"] \arrow[d,swap,"\blank\circ F_i"] & Y^{Q_i} \arrow[d,"\blank\circ F_i"] \\
X^{P_i} \arrow[r,swap,"l\circ \blank"] & Y^{P_i},
\end{tikzcd}
\end{equation*}
for each $i:I$.
\end{defn}

\begin{lem}\label{lem:qflocal_local}
For any map $l:X\to Y$ into an $F$-local type $Y$, the type of diagonal fillers for the commuting square
\begin{equation*}
\begin{tikzcd}
X^{Q_i} \arrow[r,"l\circ\blank"] \arrow[d,swap,"\blank\circ F_i"] & Y^{Q_i} \arrow[d,"\blank\circ F_i"] \\
X^{P_i} \arrow[r,swap,"l\circ \blank"] & Y^{P_i},
\end{tikzcd}
\end{equation*}
is contractible. In particular, any such map is a quasi $F$-local extension.
\end{lem}

\begin{proof}
If $Y$ is $F$-local, then the map $F_i^\ast : Y^{Q_i}\to Y^{P_i}$ is an equivalence, for any $i:I$. Since equivalences are right orthogonal to any map, the claim follows.
\end{proof}

\begin{lem}\label{lem:equiv_colim_diagfiller}
Suppose $h:\mathsf{Seq}(\mathcal{A},\mathcal{B})$ is a natural transformation of type sequences equipped with the structure of a diagonal filler for each naturality square
\begin{equation*}
\begin{tikzcd}
A_n \arrow[r,"f_n"] \arrow[d,swap,"h_n"] & A_{n+1} \arrow[d,"h_{n+1}"] \\
B_n \arrow[r,swap,"g_n"] \arrow[ur,densely dotted] & B_{n+1}.
\end{tikzcd}
\end{equation*}
Then the map $h_\infty : A_\infty\to B_\infty$ is an equivalence.
\end{lem}

\begin{proof}
Let us write $j_n:B_n\to A_{n+1}$ for the diagonal fillers, which come equipped with homotopies
\begin{align*}
J_n & : f_n\htpy j_n\circ h_n \\
K_n & : h_{n+1}\circ j_n \htpy g_n \\
L_n & : \ct{(h_{n+1}\cdot J_n)}{(K_n\cdot h_n)} \htpy H_n
\end{align*}
Note that $j$ is a natural transformation from $\mathcal{B}$ to the shifted sequence $\mathsf{shift}(\mathcal{A})$, with the homotopies $\ct{(f_{n+1}\cdot K_n)}{(J_{n+1}\cdot g_n)}: f_{n+1}\circ j_n \htpy j_{n+1}\circ g_n$ filling the naturality squares.

We claim that the composite $j\circ h$ is just the natural transformation $f:\mathcal{A}\to \mathsf{shift}(\mathcal{A})$. Indeed, we have the homotopy $J_n : j_n\circ h_n\htpy f_n$. Moreover, the type of $j_{n+1}\cdot L_n$
\begin{equation*}
\ct{(j_{n+1}\cdot h_{n+1}\cdot J_n)}{(j_{n+1}\cdot K_n\cdot h_n)} \htpy j_{n+1}\cdot H_n
\end{equation*}
is equivalent to the type of homotopies
\begin{align*}
& \ct{(J_{n+1}\cdot f_n)}{(j_{n+1}\cdot h_{n+1} \cdot J_n)}{(j_{n+1}\cdot K_n\cdot h_n)}{(j_{n+1}\cdot H_n)} \\
& \qquad\qquad \htpy \ct{\mathsf{htpy\usc{}refl}_{(f_{n+1}\circ f_n)}}{(J_{n+1}\cdot f_n)},
\end{align*}
filling the diagram
\begin{equation*}
\begin{tikzcd}
A_n \arrow[rr,"f_n"] \arrow[dr,"h_n"] \arrow[dd,swap,"f_n"] &[-1em] & A_{n+1} \arrow[dd,swap,"f_{n+1}" very near start] \arrow[dr,"h_{n+1}"] &[-1em] \\
& B_n \arrow[dl,swap,"j_n"] \arrow[rr,crossing over,"g_n" near start] & & B_{n+1} \arrow[dl,"j_{n+1}"] \\[1em]
A_{n+1} \arrow[urrr,crossing over,"h_{n+1}"] \arrow[rr,swap,"f_{n+1}"] & \phantom{A_{n+2}} & A_{n+2} & \phantom{A_{n+2}}
\end{tikzcd}
\end{equation*}
Therefore we obtain the coherence of the naturality squares needed to conclude that $f=j\circ h$ as natural transformations.

Likewise, the composite $\mathsf{shift}(h) \circ j$ is just the natural transformation $g:\mathcal{B}\to \mathsf{shift}(\mathcal{B})$. Therefore we obtain a commuting diagram
\begin{equation*}
\begin{tikzcd}[column sep=huge,row sep=large]
\mathsf{colim}(\mathcal{A}) \arrow[d,swap,"\mathsf{colim}(h)"] \arrow[r,"\mathsf{colim}(f)"] & \mathsf{colim}(\mathsf{shift}(\mathcal{A})) \arrow[d,"\mathsf{colim}(\mathsf{shift}(h))"] \\
\mathsf{colim}(\mathcal{B}) \arrow[r,swap,"\mathsf{colim}(g)"] \arrow[ur,"\mathsf{colim}(j)"] & \mathsf{colim}(\mathsf{shift}(\mathcal{B}))
\end{tikzcd}
\end{equation*}
Since both $\tfcolim(f)$ and $\tfcolim(g)$ are equivalences, it follows by the 6-for-2 property of equivalences (see Exercise 4.5 of \cite{hottbook}), that the remaining maps are equivalences. In particular $\tfcolim(h)$ is an equivalence.
\end{proof}

\begin{prp}\label{prp:colim_local}
Suppose $F$ is a family of maps between compact types, and let
\begin{equation*}
\begin{tikzcd}
X_0 \arrow[r,"l"] & X_1 \arrow[r,"l"] & X_2 \arrow[r,"l"] & \cdots
\end{tikzcd}
\end{equation*}
be a sequence of types in which each $X_{n+1}$ is a quasi $F$-local extension of $X_n$. Then the sequential colimit $X_\infty$ is $F$-local.
\end{prp}

\begin{proof}
We have a natural transformation $F_i^\ast : \mathsf{Seq}(\mathcal{X}^{Q_i},\mathcal{X}^{P_i})$ for which each naturality square comes equipped with a diagonal filler
\begin{equation*}
\begin{tikzcd}
X_0^{Q_i} \arrow[d,swap,"F_i^\ast"] \arrow[r] & X_1^{Q_i} \arrow[d,swap,"F_i^\ast"] \arrow[r] & X_2^{Q_i} \arrow[d,swap,"F_i^\ast"] \arrow[r] & \cdots \\
X_0^{P_i} \arrow[r] \arrow[ur,densely dotted] & X_1^{P_i} \arrow[r] \arrow[ur,densely dotted] & X_2^{P_i} \arrow[r] \arrow[ur,densely dotted] & \cdots
\end{tikzcd}
\end{equation*}
by the assumption that each $l_n:X_n\to X_{n+1}$ is a quasi $F$-local extension. Therefore $\mathsf{colim}(F_i^\ast)$ is an equivalence. Note that we have the commuting square
\begin{equation*}
\begin{tikzcd}
\mathsf{colim}(X_n^{Q_i}) \arrow[r] \arrow[d,swap,"\mathsf{colim}(F_i^\ast)"] & X_{\infty}^{Q_i} \arrow[d,"F_i^\ast"] \\
\mathsf{colim}(X_n^{P_i}) \arrow[r] & X_\infty^{P_i}
\end{tikzcd}
\end{equation*}
in which the top and bottom maps are equivalences by the assumption that $P_i$ and $Q_i$ are compact. Therefore we conclude that $F_i^\ast : X_\infty^{Q_i}\to X_\infty^{P_i}$ is an equivalence. It follows that $X_\infty$ is $F$-local.
\end{proof}

Our goal is now to construct the initial quasi $F$-local extension of a type $X$, and use it to show that the subuniverse of $F$-local types is reflective. For any $i:I$, we have the maps
\begin{align*}
F_i : P_i \to Q_i \\
F_i^\ast : X^{Q_i} \to X^{P_i}.
\end{align*}
In the following characterization of quasi $F$-local extensions we use the pushout-product $F_i^\ast\mathbin{\square} F_i$, which is defined as follows
\begin{equation*}
\begin{tikzcd}
X^{Q_i}\times P_i \arrow[r] \arrow[d] & X^{Q_i}\times Q_i \arrow[ddr,bend left=15] \arrow[d] \\
X^{P_i}\times P_i \arrow[drr,bend right=15] \arrow[r] & \big(X^{P_i} \times P_i\big)\sqcup^{\big(X^{Q_i}\times P_i\big)}\big(X^{Q_i}\times Q_i\big) \arrow[dr,densely dotted,swap,"F_i^\ast\mathbin{\square} F_i"] \\
& & X^{P_i}\times Q_i
\end{tikzcd}
\end{equation*}
by the universal property of pushouts. Also note that the outer square in the diagram
\begin{equation*}
\begin{tikzcd}
X^{Q_i}\times P_i \arrow[r] \arrow[d] & X^{Q_i}\times Q_i \arrow[ddr,bend left=15,"\mathsf{ev}"] \arrow[d] &[2em] \\
X^{P_i}\times P_i \arrow[drr,bend right=15,swap,"\mathsf{ev}"] \arrow[r] & \big(X^{P_i} \times P_i\big)\sqcup^{\big(X^{Q_i}\times P_i\big)}\big(X^{Q_i}\times Q_i\big) \arrow[dr,densely dotted,swap,"\varepsilon_i"] \\
& & X
\end{tikzcd}
\end{equation*}
commutes, so we get a map $\varepsilon_i$ as indicated.

\begin{lem}\label{lem:qflocal_characterize}
For any type $l:X\to Y$, the type of $I$-indexed families of diagonal fillers for the squares
\begin{equation*}
\begin{tikzcd}
X^{Q_i} \arrow[r,"l\circ\blank"] \arrow[d,swap,"\blank\circ F_i"] & Y^{Q_i} \arrow[d,"\blank\circ F_i"] \\
X^{P_i} \arrow[r,swap,"l\circ \blank"] & Y^{P_i}
\end{tikzcd}
\end{equation*}
is equivalent to the type of morphisms $j: \Big(\sm{i:I}X^{P_i}\times Q_i\Big)\to Y$ equipped with a homotopy witnessing that the square
\begin{equation*}
\begin{tikzcd}[column sep=6em]
\sm{i:I}\Big(\big(X^{P_i} \times P_i\big)\sqcup^{\big(X^{Q_i}\times P_i\big)}\big(X^{Q_i}\times Q_i\big)\Big) \arrow[r,"\total{\lam{i}F_i^\ast\mathbin{\square} F_i}"] \arrow[d,swap,"\lam{(i,t)}\varepsilon_i(t)"] & \sm{i:I} X^{P_i}\times Q_i \arrow[d] \\
X \arrow[r] & Y
\end{tikzcd}
\end{equation*}
commutes.
\end{lem}

\begin{proof}
It suffices to show that for each $i:I$, the type of diagonal fillers in the first description is equivalent to the type of maps $j:X^{P_i}\times Q_i\to Y$ equipped with a homotopy witnessing that the square
\begin{equation*}
\begin{tikzcd}[column sep=huge]
\Big(\big(X^{P_i} \times P_i\big)\sqcup^{\big(X^{Q_i}\times P_i\big)}\big(X^{Q_i}\times Q_i\big)\Big) \arrow[r,"F_i^\ast\mathbin{\square} F_i"] \arrow[d,swap,"\varepsilon_i"] & X^{P_i}\times Q_i \arrow[d] \\
X \arrow[r] & Y
\end{tikzcd}
\end{equation*}
commutes. The type $X^{P_i}\to Y^{Q_i}$ is equivalent to the type $X^{P_i}\times Q_i\to Y$ by adjointness.

By the dependent universal property of pushouts established in \cref{thm:pushout_up}, the type $l\circ \varepsilon_i \htpy j\circ (F_i^\ast\mathbin{\square} F_i)$ is equivalent to the type of triples $(K,L,M)$ consisting of
\begin{align*}
K & : \prd{f:P_i\to X}{p:P_i} l(f(p))=j(f,F_i(p)) \\
L & : \prd{g:Q_i\to X}{q:Q_i} l(g(q))=j(g\circ F_i,q) \\
M & : \prd{g:Q_i\to X}{p:P_i} K(g\circ F_i,p)=L(g,F_i(p)).
\end{align*}
The type of such quadruples $(j,K,L,M)$ is also equivalent to the fiber of the gap map
\begin{equation*}
(X^{P_i}\to Y^{Q_i})\to \Big(X^{Q_i}\to Y^{Q_i}\Big)\times_{\big(X^{Q_i}\to Y^{P_i}\big)}\Big(X^{P_i}\to Y^{P_i}\Big)
\end{equation*}
at $(l^{Q_i},l^{P_i},\mathsf{htpy\usc{}refl})$.
\end{proof}

\begin{defn}
For any type $X$, we define the initial quasi $F$-local extension $l:X\to QL_FX$ of $X$ to be the pushout
\begin{equation*}
\begin{tikzcd}[column sep=large]
\sm{i:I}\Big(\big(X^{P_i} \times P_i\big)\sqcup^{\big(X^{Q_i}\times P_i\big)}\big(X^{Q_i}\times Q_i\big)\Big) \arrow[r,"F_i^\ast\mathbin{\square} F_i"] \arrow[d,swap,"\lam{(i,t)}\varepsilon_i(t)"] & \sm{i:I} X^{P_i}\times Q_i \arrow[d] \\
X \arrow[r,swap,"l"] & QL_FX
\end{tikzcd}
\end{equation*}
\end{defn}

\begin{rmk}
The initial quasi $F$-local extension of a type $X$ is initial by the universal property of the pushout and the characterization of \cref{lem:qflocal_characterize}.
\end{rmk}

\begin{eg}
Consider the family of maps consisting just of the terminal projection $\bool\to\unit$. We sketch an argument that the quasi $\bool$-local extension of $X$ is equivalent to $\join{X}{X}$, i.e.~that we have a pushout square
\begin{equation*}
\begin{tikzcd}
(X^2\times \bool)\sqcup^{X\times \bool} X \arrow[r] \arrow[d] & X^2 \arrow[d] \\
X \arrow[r] & \join{X}{X}
\end{tikzcd}
\end{equation*}
To see this, we note first that the pushouts
\begin{equation*}
\begin{tikzcd}
S \arrow[d] \arrow[r] & B \arrow[d] & S+S \arrow[d] \arrow[r] & S \arrow[d] \\
A \arrow[r] & A \sqcup^S B & A+B \arrow[r] & (A+B)\sqcup^{(S+S)} S
\end{tikzcd}
\end{equation*}
are equivalent, for any span $A \leftarrow S \rightarrow B$. Therefore it follows that the pushouts
\begin{equation*}
\begin{tikzcd}
X \arrow[d] \arrow[r] & X^2 \arrow[d] & X\times \bool \arrow[d] \arrow[r] & X \arrow[d] \\
X^2 \arrow[r] & X^2 \sqcup^X X^2 & X^2\times \bool \arrow[r] & (X^2\times\bool)\sqcup^{(X\times\bool)} X
\end{tikzcd}
\end{equation*}
are equivalent. Therefore it suffices to compute the pushout
\begin{equation*}
\begin{tikzcd}
X^2 \sqcup^X X^2 \arrow[r,"\nabla_{\delta_X}"] \arrow[d,swap,"{[\pi_1,\pi_2,\mathsf{htpy\usc{}refl}_{\idfunc[X]}]}"] & X^2 \arrow[d] \\
X \arrow[r] & X\sqcup^{(X^2 \sqcup^X X^2)}X^2.
\end{tikzcd}
\end{equation*}
Now we observe that for any cube
\begin{equation*}
\begin{tikzcd}
& A_{111} \arrow[dl] \arrow[d] \arrow[dr] \\
A_{110} \arrow[d] & A_{101} \arrow[dl] \arrow[dr] & A_{011} \arrow[d] \\
A_{100} \arrow[dr] & A_{010} \arrow[d] \arrow[from=ul,crossing over] \arrow[from=ur,crossing over] & A_{001} \arrow[dl] \\
& A_{000}
\end{tikzcd}
\end{equation*}
the following are equivalent:
\begin{enumerate}
\item The cube is cocartesian.
\item The the square
\begin{equation*}
\begin{tikzcd}
A_{011}\sqcup^{A_{111}} A_{101} \arrow[r] \arrow[d] & A_{001} \arrow[d] \\
A_{010}\sqcup^{A_{110}} A_{100} \arrow[r] & A_{000}
\end{tikzcd}
\end{equation*}
is cocartesian.
\end{enumerate}
We cite \cite{Munson} for this observation, and the analogous result in homotopy type theory is work in progress. Using the above equivalence, it follows that the pushout $X^2\sqcup ^X X^2$ is the colimit of the diagram
\begin{equation*}
\begin{tikzcd}
& X \arrow[dl] \arrow[d] \arrow[dr] \\
X \arrow[d] & X^2 \arrow[dl,swap,"\pi_1" very near start] \arrow[dr] & X^2 \arrow[dl,crossing over,swap,"\pi_2" very near start] \arrow[d] \\
X & X \arrow[from=ul,crossing over] & X^2
\end{tikzcd}
\end{equation*}
Furthermore, by the same equivalence we see that another way of computing this colimit is as the following pushout
\begin{equation*}
\begin{tikzcd}
X^2 \arrow[r,"\pi_2"] \arrow[d,swap,"\pi_1"] & X \arrow[d] \\
X \arrow[r] & X\sqcup^{X^2} X,
\end{tikzcd}
\end{equation*}
which is the join $\join{X}{X}$.
\end{eg}

\begin{prp}
If $X$ is $F$-local, then $l:X\to QL_F X$ is an equivalence.
\end{prp}

\begin{proof}
If $X$ is $F$-local, then each $F_i^\ast$ is an equivalence. It follows that the pushout-product $F_i^\ast\mathbin{\square} F_i$ is an equivalence. Since pushouts of equivalences are equivalences, the claim follows.
\end{proof}

\begin{thm}\label{thm:localization}
For any type $X$ and any family $F:\prd{a:A}P(a)\to Q(a)$ of maps between
compact types, the subuniverse of $F$-local types is reflective.
\end{thm}

\begin{proof}
We define the localization $\eta:X\to LX$ as the sequential colimit
\begin{equation*}
\begin{tikzcd}
X \arrow[r] & QL_F X \arrow[r] & QL_F^2 X \arrow[r] & \cdots
\end{tikzcd}
\end{equation*}
Since each $l:QL_F^n X\to QL_F^{n+1}X$ has the structure of a quasi $F$-local extension, it follows by \cref{prp:colim_local} that $LX$ is $F$-local. It remains to show that for any $F$-local type $Y$, the precomposition map
\begin{equation*}
\eta^\ast : (LX\to Y)\to (X\to Y)
\end{equation*}
is an equivalence.

We first show that the map
\begin{equation*}
l^\ast : (QL_F X\to Y)\to (X\to Y)
\end{equation*}
is an equivalence. To see this, note that we have a commuting triangle
\begin{equation*}
\begin{tikzcd}[column sep=tiny]
& \mathsf{cocone}(Y) \arrow[dr,"\pi_1"] & \phantom{(QL_F X\to Y)} \\
(QL_F X\to Y) \arrow[rr] \arrow[ur,"\mathsf{cocone\usc{}map}"] & & (X\to Y)
\end{tikzcd}
\end{equation*}
We note that by \cref{lem:qflocal_characterize}, the fiber of $\pi_1:\mathsf{cocone}(Y)\to (X\to Y)$ is equivalent to the type of diagonal fillers of the square
\begin{equation*}
\begin{tikzcd}
X^{Q_i} \arrow[r,"l\circ\blank"] \arrow[d,swap,"\blank\circ F_i"] & Y^{Q_i} \arrow[d,"\blank\circ F_i"] \\
X^{P_i} \arrow[r,swap,"l\circ \blank"] & Y^{P_i},
\end{tikzcd}
\end{equation*}
This type of diagonal fillers is contractible by \cref{lem:qflocal_local}, since $Y$ is assumed to be $F$-local. In other words, the map $\pi_1:\mathsf{cocone}(Y)\to (X\to Y)$ is an equivalence. Since $\mathsf{cocone\usc{}map}:(QL_F X\to Y)\to \mathsf{cocone}(Y)$ is an equivalence by the universal property of $QL_F X$, we conclude by the 3-for-2 property that the map
\begin{equation*}
l^\ast : (QL_F X\to Y)\to (X\to Y)
\end{equation*}
is an equivalence.

We conclude that any map $g:X\to Y$ extends uniquely to a cocone on the type sequence
\begin{equation*}
\begin{tikzcd}
X \arrow[r] & QL_F X \arrow[r] & QL_F^2 X \arrow[r] & \cdots,
\end{tikzcd}
\end{equation*}
and therefore it follows that $\eta^\ast:(LX\to Y)\to (X\to Y)$ is an equivalence.
\end{proof}

\begin{cor}
For any family $N:I\to \UU$ of compact types, the subuniverse of $N$-null types is a modality.
\end{cor}

\endinput

\section{An orthogonal factorization system associated to a reflective subuniverse presented by a family of maps between compact types}
\sectionmark{An orthogonal factorization system}
\label{sec:nonstable-factsys}

\marginnote{This section corresponds to section 2.4 in \cite{RijkeShulmanSpitters}}
We have seen in \cref{sec:modal-refl-subun} that $\Sigma$-closed reflective subuniverses are equivalent to stable orthogonal factorization systems.
Without $\Sigma$-closedness and stability, this equivalence fails.
However, we can still say:

\begin{lem}
  Any orthogonal factorization system has an underlying reflective subuniverse, consisting of those types $X$ such that $X\to\unit$ is in $\cR$.
\end{lem}
\begin{proof}
  If $Y$ is modal in this sense, then by orthogonality for squares
  \[
  \begin{tikzcd}
    A \ar[d,"f"'] \ar[r] & Y \ar[d] \\ B \ar[r] & \unit
  \end{tikzcd}
  \]
  we see that if $f:A\to B$ lies in $\cL$, then precomposition
  \[ (-\circ f) : (B\to Y) \to (A\to Y) \]
  is an equivalence.
  Thus, it suffices to show that for every $X$ there is an $\cL$-map $X\to \modal X$ where $\modal X\to \unit$ is in $\cR$; but this is just an $(\cL,\cR)$-factorization of the map $X\to\unit$.
\end{proof}

Conversely, in classical category theory there are various ways of extending a reflective subcategory to a factorization system.
One canonical one is considered in~\cite{chk:reflocfact}\marginnote{Mike:But the "canonical"
factorization system from~\cite{chk:reflocfact} is, I believe,
precisely the one that you *have* constructed for a modality in
chapter 8!  Does this construction definitely fail for an arbitrary
reflective subuniverse?  In any case, this sentence should probably be
modified.}, but this is harder to reproduce homotopy-theoretically.
Instead, if we have an \emph{accessible} reflective subuniverse presented by localization at a family of maps, we can generalize the construction of localization to produce a factorization system (though in general the result will depend on the choice of presentation, not just on the reflective subuniverse we started with). We present here a construction of an orthogonal factorization associated to a family of maps, analogous to the construction in 2.4 of \cite{RijkeShulmanSpitters}, which used recursive higher inductive types.

For simplicity we work with only one map $f:A\to B$ instead of a family of maps $f:\prd{i:I}A_i\to B_i$.
It is straightforward to generalize the construction to a family of maps.

\begin{defn}
Let $f:A\to B$ and let $g:X\to Y$ be maps. A \define{quasi-$f$-right extension} of $g$ consists of a commuting triangle
\begin{equation*}
\begin{tikzcd}[column sep=tiny]
X \arrow[rr,"l"] \arrow[dr,swap,"g"] & & X' \arrow[dl,"g'"] \\
& Y
\end{tikzcd}
\end{equation*}
equipped with a diagonal filler for the square
\begin{equation*}
\begin{tikzcd}
X^B \arrow[r] \arrow[d] & X'^B \arrow[d] \\
X^A\times_{Y^A}Y^B \arrow[r] & X'^A\times_{Y^A}Y^B.
\end{tikzcd}
\end{equation*}
\end{defn}

\begin{prp}
Suppose $f:A\to B$ is a map between compact types, and suppose we are given a sequence
\begin{equation*}
\begin{tikzcd}
X_0 \arrow[r,"l"] \arrow[dr,swap,"g_0"] & X_1 \arrow[r,"l"] \arrow[d,swap,"g_1" near start] & X_2 \arrow[r,"l"] \arrow[dl,swap,"g_2"] & \cdots \arrow[dll,bend left=10] \\
& Y
\end{tikzcd}
\end{equation*}
where each $g_{n+1}$ is a quasi-$f$-right extension of $g_n$. Then the map $g_\infty:X_\infty\to Y$ is right orthogonal to $f$.
\end{prp}

\begin{proof}
Since pullbacks are preserved by sequential colimits and since $A$ and $B$ are assumed to be compact, we have a commuting square
\begin{equation*}
\begin{tikzcd}
\mathsf{colim}_n(X_n^B) \arrow[r] \arrow[d,swap,"\mathsf{colim}(\mathsf{gap})"] & X_\infty^B \arrow[d,"\mathsf{gap}"] \\
\mathsf{colim}_n(X_n^A\times_{Y^A}Y^B) \arrow[r] & X_\infty^A\times_{Y^A}Y^B
\end{tikzcd}
\end{equation*}
in which the top and bottom maps are equivalences.

Moreover, since each naturality square in the natural transformation
\begin{equation*}
\begin{tikzcd}
X_0^B \arrow[r,"l"] \arrow[d,swap,"\mathsf{gap}"] & X_1^B \arrow[r,"l"] \arrow[d,swap,"\mathsf{gap}"] & X_2^B \arrow[r,"l"] \arrow[d,swap,"\mathsf{gap}"] & \cdots \\
X_0^A\times_{Y^A} Y^B \arrow[r] & X_1^A\times_{Y^A}Y^B \arrow[r] & X_2^A\times_{Y^A}Y^B \arrow[r] & \cdots
\end{tikzcd}
\end{equation*}
has a diagonal filler, it follows by \cref{lem:equiv_colim_diagfiller} that the colimit $\mathsf{colim}(\mathsf{gap})$ is an equivalence. Thus we conclude that the gap map $X_\infty^B\to X_\infty^A\times_{Y^A}Y^B$ is an equivalence.
\end{proof}

\begin{defn}
Consider maps $f:A\to B$ and $g:X\to Y$. We define the \define{initial quasi-$f$-right extension} $QR_f(g):QR_f X\to Y$
%\marginnote{Obviously the terminology might need some consideration}
of $g$ to be the cogap map of the cube
\begin{equation*}
\begin{tikzcd}
& X^B\times A \arrow[dl] \arrow[dr] \arrow[d] & \phantom{(X^A\times_{Y^A}Y^B)\times B} \\
X^B \times B \arrow[d] & (X^A\times_{Y^A} Y^B)\times A \arrow[dl] \arrow[dr] & X \arrow[dl,crossing over] \arrow[d] \\
(X^A\times_{Y^A}Y^B)\times B \arrow[dr] & X \arrow[from=ul,crossing over] \arrow[d] & X \arrow[dl] \\
& Y
\end{tikzcd}
\end{equation*}
\end{defn}

\begin{rmk}
Equivalently, the quasi-$f$-right extension $QR_f(g):QR_f X \to Y$ is described as the cogap map of the square
\begin{equation*}
\begin{tikzcd}
(X^B\times B)\sqcup^{(X^B\times A)}((X^A\times_{Y^A} Y^B)\times A) \arrow[d,swap,"\mathsf{gap}\mathbin{\square} f"] \arrow[r] & X \arrow[d,"g"] \\
(X^A\times_{Y^A} Y^B)\times B \arrow[r] & Y,
\end{tikzcd}
\end{equation*}
where $\mathsf{gap}:X^B \to X^A\times_{Y^A} Y^B$ is the gap map of the square
\begin{equation*}
\begin{tikzcd}
X^B \arrow[r] \arrow[d] & Y^B \arrow[d] \\
X^A \arrow[r] & Y^A.
\end{tikzcd}
\end{equation*}
\end{rmk}

\begin{lem}
For any $g:X\to Y$, the initial quasi-$f$-right extension of $g$ is a quasi-$f$-right extension of $g$.
\end{lem}

\begin{lem}
Suppose $g:X\to Y$ is right orthogonal to $f:A\to B$. Then the map $q:X\to QR_fX$ is an equivalence.
\end{lem}

\begin{proof}
If $g$ is right orthogonal to $f$, then (by definition) the gap map $\mathsf{gap}:X^B\to X^A\times_{Y^A} Y^B$ is an equivalence. It follows that the pushout-product $\mathsf{gap}\mathbin{\square} f$ is an equivalence, and hence $q:X\to QR_f X$ is an equivalence.
\end{proof}

\begin{defn}
Consider a map $g$. We define the $f$-right factor $g_\mathcal{R}:QR_f^{\infty} X\to Y$ of $g$ to be the colimit of the sequence
\begin{equation*}
\begin{tikzcd}
X \arrow[dr] \arrow[r] & QR_fX \arrow[d] \arrow[r] & QR_f^2 X \arrow[ld] \arrow[r] & \cdots \arrow[dll,bend left=10] \\
& T
\end{tikzcd}
\end{equation*}
\end{defn}

\begin{prp}
For any map $h:Z\to Y$ that is right orthogonal to $f:A\to B$, the map
\begin{equation*}
\mathsf{hom}_Y(g_{\mathcal{R}},h)\to \mathsf{hom}_Y(g,h)
\end{equation*}
is an equivalence.
\end{prp}

\begin{thm}
For any map $f:A\to B$ between compact types, let $\mathcal{R}$ denote the class of maps which are right orthogonal to $f$, and let $\mathcal{L}$ be the class of maps which are left orthogonal to every map in $\mathcal{R}$. Then $(\mathcal{L},\mathcal{R})$ forms an orthogonal factorization system.
\end{thm}

\section{Inductive types specified by families of compact types}


\chapter*{ Stay Tuned for next chapters!}

\section*{i'll keep posting next chapters whenever i've spare time.}

\bigskip

Tikz Pictures to be used in next chapters.

\begin{tikzpicture}
  \matrix (m) [matrix of math nodes, row sep=5em, column sep=5em]
    { 0 & A  & B  & C  & 0 \\
      0 & A' & B' & C' & 0 \\ };
  { [start chain] \chainin (m-1-1);
    \chainin (m-1-2);
    { [start branch=A] \chainin (m-2-2)
        [join={node[right,labeled] {\eta_1}}];}
    \chainin (m-1-3) [join={node[above,labeled] {\varphi}}];
    { [start branch=B] \chainin (m-2-3)
        [join={node[right,labeled] {\eta_2}}];}
    \chainin (m-1-4) [join={node[above,labeled] {\psi}}];
    { [start branch=C] \chainin (m-2-4)
        [join={node[right,labeled] {\eta_3}}];}
    \chainin (m-1-5); }
  { [start chain] \chainin (m-2-1);
    \chainin (m-2-2);
    \chainin (m-2-3) [join={node[above,labeled] {\varphi'}}];
    \chainin (m-2-4) [join={node[above,labeled] {\psi'}}];
    \chainin (m-2-5); }
\end{tikzpicture}

\begin{tikzcd}
A \arrow[rd] \arrow[r, "\phi"] & B \arrow[d] \\
& C
\end{tikzcd}

\begin{tikzcd}[row sep=small]
& B \arrow[dd] \\
A \arrow[ur] \arrow[dr] & \\
& C
\end{tikzcd}

\begin{tikzcd}[column sep=small]
& A \arrow[dl] \arrow[dr] & \\
B \arrow{rr} & & C
\end{tikzcd}

\begin{tikzcd}
A \arrow[to=Z, red] \arrow[to=2-2, blue]
& B \\
|[alias=Z]| C
& D
\arrow[from=ul, to=1-2, purple]
\end{tikzcd}

\begin{tikzpicture}[domain=0:4]\draw[very thin,color=gray] (-0.1,-1.1) grid (3.9,3.9);\draw[->] (-0.2,0) -- (4.2,0) node[right] {$x$};\draw[->] (0,-1.2) -- (0,4.2) node[above] {$f(x)$};\draw[color=red] plot (\x,\x) node[right] {$f(x) =x$};\draw[color=blue] plot (\x,{cos(\x r)}) node[right] {$f(x) = \cos x$};\draw[color=orange] plot (\x,{0.05*exp(\x)}) node[right] {$f(x) = \frac{1}{20} \mathrm e^x$};\end{tikzpicture}


%!TEX root = vorlage.tex

\subsection{The data}

The experiments were done on the \textit{Instrument segmentation and tracking}
dataset of the Endoscopic Vision Challenge
\enquote{EndoVis}\footnote{\href{http://endovis.grand-challenge.org/}{http://endovis.grand-challenge.org}}.
It contains photos of minimal-invasive operations. The dataset already contains
a training-test-split. The training data consists of four operations. Each
operation has 40~RGB~images in a resolution of $\SI{640}{\pixel} \times
\SI{480}{\pixel}$. The test set has 10~more images of those 4~operations as
well as 50~images for 2~more operations. This means, in total the training data
consist of $4 \cdot 40 = 160$ photos and the testing contains $4 \cdot 10 + 2
\cdot 50 = 140$ photos. As each pixel has to be classified as \textit{medical
instrument} or \textit{background}, there are
$140 \cdot 640 \cdot 480 = \num{43008000}$ classifications to be done for
testing.

The training data consist of $\SI{90.5}{\percent}$ background
($\SI{90.8}{\percent}$ in the testing data); the remaining pixels are medical
instruments. This means an accuracy of $\SI{90.8}{\percent}$ can be reached
without looking at the test image.

Analyzing the data, one can also see that some positions in the image are more
likely than others to contain a medical instrument. This is visualized
in~\cref{fig:medical-instrument-positions}.

\begin{figure}[ht]
    \centering
    \includegraphics[width=\linewidth]{images/instrument-positions.png}
    \caption{Position of medical instruments in the training data.
             The brighter the color, the more often was a medical instrument
             at this position. One can clearly see that the borders contain
             medical instruments less often. Also, in the center they are much
             more often.}
    \label{fig:medical-instrument-positions}
\end{figure}


%\documentclass[11pt]{article}
\documentclass{asme2ej}
\usepackage{amsmath,amssymb,graphicx,bm}
\usepackage{listings, xcolor, subcaption, placeins}
\usepackage{undertilde}
\usepackage{algorithm,algpseudocode}
\usepackage{multicol}
\usepackage{makecell}
\usepackage[table]{colortbl}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% If you want to define a new command, you can do it like this:
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\C}{\mathbb{C}}
\newcommand{\e}{\bm{e}}
\newcommand{\TEN}[1]{\underline{\underline{#1}}}
\newcommand{\TOT}[1]{\underline{\underline{\underline{#1}}}}
\newcommand{\VEC}[1]{\utilde{#1}}
\newcommand{\UVEC}[1]{\underline{#1}}
\newcommand{\PK}[1]{\TEN{\tau}^{(#1)}}
\newcommand{\cauchy}{\TEN{\sigma}}
\newcommand{\st}{$^{\text{st}}$}
\newcommand{\nd}{$^{\text{nd}}$}
\newcommand\defeq{\mathrel{\stackrel{\makebox[0pt]{\mbox{\normalfont\tiny def}}}{=}}}
\newcommand{\micro}[1]{{#1}'}
\newcommand{\GDNSDOF}{$\left\{\breve{Q}\right\}$}
\newcommand{\GMMCDOF}{$\left\{\breve{D}\right\}$}

\graphicspath{{./img/}}

%% If you want to use a function like ''sin'' or ''cos'', you can do it like this
%% (we probably won't have much use for this)
% \DeclareMathOperator{\sin}{sin}   %% just an example (it's already defined)

\begin{document}
\title{Overlap Coupling Implementation}
\author{Nathan Miller}

\maketitle

\begin{abstract}
The documentation for the overlap coupling is presented. This documentation details the theoretical background of the implementation along with the implementation into code. Documentation which also communicates the method by which the coupling is joined into the simulation tool Abaqus using the SIMULIA Co-Simulation Engine (CSE) is also detailed.
\end{abstract}

\input{./tex/nomenclature.tex}

\section{Introduction}

One of the most powerful (and exciting) applications of the micromorphic continuum theory is in the development of an overlap coupling between regions of low fidelity which are modeled using the micromorphic continuum and regions of high fidelity which model the microstructural response directly. In this way, models can be developed which both can efficiently solve problems via using high fidelity representations of the material only in the regions where this is absolutely necessary. The Micromorphic continuum can be used in other regions where this assumption is accurate enough.

Importantly, the communication between length scales is bi-directional in that neither the DNS nor the continuum representation are exclusively driven by the other. Rather, the information is communicated between the two using an overlap coupling scheme as developed by \cite{bib:klein06}. We now describe the theoretical background for the coupling process.

\section{Degree of Freedom Coupling}

The coupling between the degrees of freedom in the micromorphic and DNS domains is shown in Figure~\ref{fig:overlapping_domains}. As can be seen, the DNS can either be interacting with the micromorphic continuum or a standard continuum. The full micromorphic domain can be written as $\overline{\mathcal{B}}^h \cup \hat{\mathcal{B}}^h \cup \tilde{\mathcal{B}}^h$. Our primary goal is to reduce the size of the DNS domain $\overline{\mathcal{B}}^h$ and still retain the macro-response. In this way we will reduce the cost of a simulation which, in general, could be intractable to one which can be solved in a reasonable amount of computational time.

\begin{figure}[htb!]
\centering
\includegraphics[width=0.7\textwidth]{overlapping_domains.pdf}
\caption{Schematic of overlapping domains}
\label{fig:overlapping_domains}
\end{figure}

We interpolate the micromorphic finite element to the DNS DOF to provide boundary conditions on the DNS in the reference configuration by recognizing that the macro and micro degree of freedom vectors at macro DOF node $a$ and micro DOF node $b$ can be mapped to the DNS point via
\begin{align*}
\VEC{u}_{\alpha} &= \sum_{a \in \breve{\mathcal{N}}} N_a^{u,e} \left(\VEC{X}_{\alpha}^h\right) \VEC{d}_a^e(t)\\
\left\{\phi\right\}^e_{\alpha} &= \sum_{b \in \breve{\mathcal{M}}} N_b^{\phi,e} \left(\VEC{X}_\alpha\right) \left\{\phi\right\}_b^e(t)\\
\end{align*}

for all $\alpha \in \breve{\mathcal{A}}$. We note that for any point in the DNS $\alpha$ we can also write with respect to the center of mass of the associated micromorphic element $e$
\begin{align*}
\left(\micro{\VEC{x}}\right)_{\alpha}^e &= \VEC{x}^e + \VEC{\xi}_{\alpha}^e
\end{align*}

where $\VEC{x}^e$ is the global position of the center of mass of $e$ and $\VEC{\xi}_{\alpha}^e$ is the location of the DNS node $\alpha$ with respect to $\VEC{x}^e$. We also note that we can write
\begin{align*}
\VEC{x}^e &= \VEC{X}^e + \VEC{u}^e\\
\VEC{\xi}_{\alpha}^e &= \TEN{\chi}_{\alpha}^e \cdot \VEC{\Xi}_{\alpha}^e = \left(\TEN{I} + \TEN{\phi}_{\alpha}^e\right) \cdot \VEC{\Xi}_{\alpha}^e\\
\end{align*}

where $\TEN{\phi}_{\alpha}^e$ is found by reconstructing $\left\{\phi\right\}_{\alpha}^e$ into tensor form. By asserting that we can write
\begin{align*}
\left(\micro{\VEC{x}}\right)_{\alpha}^e &\defeq \left(\micro{\VEC{X}}\right)_{\alpha}^e + \left(\micro{\VEC{u}}\right)_{\alpha}^e\\
\end{align*}

where $\left(\micro{\VEC{u}}\right)_{\alpha}^e$ is defined as a micro-displacement vector we can write
\begin{align*}
\left(\micro{\VEC{x}}\right)_{\alpha}^e &= \left(\micro{\VEC{X}}\right)_{\alpha}^e + \left(\micro{\VEC{u}}\right)_{\alpha}^e\\
\end{align*}

\section{Coupling Scheme}

\FloatBarrier

\bibliographystyle{asme2ej}
\bibliography{micromorphic}

\end{document}


\section{Cascaded Shadow Maps}

In order to implement shadows in the scenes the use of some Shadow Mapping technique was required.
The simple shadow mapping algorithm would not be sufficient for large space scenes. Using just
a single shadowmap leads to difficulties in adjusting it to avoid surface acne and aliasing
problems. Additionally, this would require a very high and impractical resolution in order capture both large
space scenes and being able to show the desirable level of detail. Cascaded Shadow Maps approach
helps bypass these problems by providing higher resolution of the depth texture near the viewer lower
resolution far away. This is achieved by splitting the camera view frustum and creating a separate depth-map
for each partition (see Figures~\ref{fig:csmsplits},\ref{fig:csmbufs}).

\begin{figure}[h]
    \centering
    \includegraphics[scale=0.25, clip=true]{./image/csmsplits.png}
    \caption{Visualized frustum splits}
\label{fig:csmsplits}
\end{figure}

The algorithm is composed of two main parts:
\begin{enumerate}
\item For every frustum split render the scene depth from the light point of view (POV)
\item While rendering the scene from the camera POV, pick and use the matching shadow map for the current
    fragment's Z value
\end{enumerate}

For the creation of each depth map, the split planes, view and projection matrices for each split
must be first calculated. The procedure for each split is:

\begin{enumerate}
\item Calculate near and far split distances
\item Create the projection for the split using previously calculated near and far values
\item Extract the split frustum points by multiplying the inverse projection-view matrix
    with each of the vertices of an NDC cube (note that the prespective division must
    be performed manually)
\item Find the centroid of the previously calculated split frustum
\item Create the view matrix with the eye being the light position looking towards the centroid
\item Transform the split vertices to the light view space
\item Find the frustum bounding box in view space
\item Create an orthogonal projection matrix with the corners of the previously calculated bounding box
\item Save calculated split projection, view matrices and near, far planes for later use
\end{enumerate}

Next, the scene needs to be rendered for each split for the purpose of creating the shadow maps.
In each split render, the vertices are transformed by their respective projection and view matrices
that have been already calculated. Note that the final stored depths must be in linear space.
An intermediate geometry shader with invocations number set to the split number can also be used
to avoid multiple draws. Before rendering the shadow maps it is recommended to switch to front
face culling to avoid peter-panning effects~\footnote{Petter Panning effect is when objects with missing shadows
appear to be detached from and to float above the surface, just like Peter Pan.}.

When using the shadow maps in the shading phase, all that needs to be done is choose the shadow
map layer to use according to the depth of the current vertex in view space. After that
the fragment must be transformed from world to light space and check if it is in shadow like
the normal shadowmapping algorithm. Optional PCF can be applied after that.

\begin{figure}[b]
    \centering
    \includegraphics[scale=0.3, clip=true]{./image/csmbufs.png}
    \caption{Depth maps for each frustum split}
\label{fig:csmbufs}
\end{figure}


\documentclass[12pt,english]{article}

\input{fragments/preamble_packages.tex}
\input{fragments/preamble_layout.tex}
\input{fragments/preamble_citation.tex}
\bibliography{bib/ref_one, bib/ref_two}

\makeatother

\begin{document}\fontsize{12}{14}\rm

\title{Research Proposal Template}

\author{\href{http://fanwangecon.github.io/}{Fan Wang} \thanks{See \href{https://fanwangecon.github.io/Tex4Econ/}{Tex4Econ} for more latex examples.}}

\maketitle

According to \textcite{becker_human_1986}, ipsum dolor sit amet, consectetur adipiscing elit. Integer placerat nunc orci, id pellentesque lacus ullamcorper at. Mauris venenatis gravida magna non dapibus. Nullam vel consequat purus, id luctus dui. Suspendisse vel auctor nulla. Proin ipsum felis, efficitur eu eleifend vitae, efficitur pellentesque mauris \autocite{case_lasting_2005, conti_understanding_2010}.

\section{\href{https://papers.ssrn.com/sol3/papers.cfm?abstract_id=3167023}{Research Design}\label{sec:design}}

Let $\tau$ be the fraction of poorest children receiving price discounts and $\delta$ be the percentage price discount that children receive. $Z\left(\tau,\delta\right)$ is the total cost of a subsidy in grams of protein for 1970, 1972, 1974 and 1976 cohorts, given reference point distribution $\Gamma$ for each cohort:

\begin{equation}
\label{eq:targetcost}
Z\left(\tau,\delta\right) =
\sum\limits_{
	\substack{
	\mathrm{cohort} \\ \in{\left\{70,72,74,76\right\}}}
	}
\left\{\delta\cdot
\int_{\epsilon}
\int_{Y_{min}}^{F_{Y}^{-1}\left(\tau\right)}
\int_{X}
N\Big(
\substack{
	Y,X,\epsilon; \\
	\delta, \Gamma_{\mathrm{cohort}}
}
\Big)f\left(X|Y\right)f\left(Y\right)f\left(\epsilon\right)\mathrm{d}X\mathrm{d}Y\mathrm{d}\epsilon\right\}
\end{equation}

In Section \ref{sec:data}, we categorized villages by their school closure status. Among the 193 villages that did not have village schools in 2011 and experienced school closure between 1999 and 2010, there were 45 villages where the closed village school was a teaching-point. Among the 430 villages that had village schools in 2011 and did not experience school closure, there were 44 villages where the village school in 2011 was a teaching-point. Teaching-point village primary schools offer up to 4 years of within-village primary education partly with the aim of reducing travel distance for students. While teaching-points might offer proximity and small-school benefits for young village students, when quality is defined  narrowly in terms of the physical facility quality and teacher qualifications, teaching-points are of lower quality compared to other primary schools. In this section, we analyze the heterogeneity of closure effects by teaching-points status.

We estimate:
\begin{singlespace}\vspace*{-\baselineskip}
	\begin{eqnarray}
	\label{eq:tp}
	E_{pvia} & = & \phi + \beta_{v}  + \rho_{pa} + \rho^{\tau}_{a} \cdot \text{TP}_{v}
	\nonumber \\
	&  & + \sum_{\tau \in \left\{0, 1\right\}}
	\left(
	\sum_{z=1}^Z \tilde{\lambda^{\tau}_{z}} \cdot \mathbb{1} \left\{ l_{z}\leq t_{i}\leq u_{z} \right\}
	\cdot c_{v}
	\right)
	\cdot \mathbb{1} \left\{ \text{TP}_{v} = \tau \right\}
	\\
	&  &
	+ X_i \cdot \gamma + X_i \cdot \text{TP}_{v} \cdot \gamma^{\tau} \nonumber\\
	&  & + \epsilon_{i}  \nonumber
	\end{eqnarray}
\end{singlespace}\noindent\ignorespaces
where $\text{TP}_v = 1$ if the village had a teaching-point school in 2011 or had a teaching-point school that was closed before 2001. Equation \ref{eq:tp} allows teaching-point villages to have differential age patterns and covariate effects.

\section{Literature and Relevance}

Village closure information is taken from a village head survey, which was collected in conjunction with household surveys. Village heads were asked if the village currently had a primary school, and asked about the year of school closure if the village school had been closed. Based on the village heads survey, there are four categories of closure status. The first category includes 193 villages that did not have village schools in 2011 and experienced school closure between 1999 and 2010. In the second category, which included 22 villages, a school closure year between 1999 and 2010 was reported, but village heads also reported that the village currently had a school in 2011. In this case, it is plausible that new schools were built in these 22 villages after school closure.\footnote{Generally students went to schools in township centers after village school closure, but in these 22 villages, it is possible that a new consolidated school was built inside these villages.} In the third category, 430 villages had village schools in 2011 and did not experience school closure.\footnote{We do not have survey information on the opening year of the schools. The vast majority of these schools should have been established in the 1980s and early 1990s when the central government aimed to have a school in each village to provide education to rural children.} Finally, the fourth category includes 48 villages that had never had a primary school and 35 that do not currently have a school but had a village primary school at some point between 1954 and 1999. In the following analysis, we designate the first and second categories as school closure. The third and fourth categories are coded as non-closure.\footnote{We will test the robustness of regression results to dropping the second and fourth categories from the closure and non-closure groups.}

\section{Feasibility and Local Support}

Table \ref{regone} presents estimates of \(\lambda \) in Equation \ref{eq:targetcost}. The first panel presents overall results, while the sex-specific results are shown in the second and third panels. In each panel, we compare three subsets of children below age 14 against baseline group -- those between 14 and 21 at the time of school closure. Columns 1 and 2 include all individuals between 1 and 44 years of age in 2011, columns 3 and 4 restrict to individuals between 10 and 34, and columns 5 and 6 restrict further to individuals between 15 and 34 years of age. The even-numbered columns drop villages that never had a school from the villages without closure group (category 4 as defined in data section). All regressions include several individual and household controls.\footnote{All regressions include controls for households size, a dummy for if the individual is Han and a categorical variable for the relative wealth. The relative wealth variable is based on the survey question that asked households if they are better or worse off than village average. We do not have income measures for all families. The village income per capita variable shown in summary Table \ref{regone} is from the village-head survey and not based on household incomes.} All standard errors are clustered at the village-level. Column 1 contains our focal main result, other columns contain results for robustness checks which we discuss later.

\begin{figure}[h]
	\centering
	\caption{\small Effect of School Closure on Educational Attainment (Number of Grades Completed by 2011) by 15 Age-at-Closure Group.}
	\includegraphics[width=1.0\textwidth, center]{"img/GM14S2B15_cvnc_1no".png}
	\captionsetup{width=1.0\textwidth}
	\caption*{\footnotesize Each $a$--$b$ group shows impact of closure on grades completed by 2011 for children who were between $a$ and $b$ years of age at the time of school closure. These results correspond to results from column 1 of Table \ref{regone} which had 5 age-at-closure groups. \label{figoneb}}
\end{figure}

As noted earlier, school closures typically imply disruption, greater distance, and better quality school facilities for affected students. Our prior analyses showed that the impact of closure on attainment is not of short-term duration, indicating that there is limited short-term disruption effects of closure on attainment. To investigate mechanisms behind the impacts of school closure on educational attainment, we analyze how the two possible factors --  distance to school and quality of school -- are linked to enrollment status at the time of the survey. Here, we focus only on children between 5 to 12 years of age in 2011, ages at which nearly all children attend primary school in 2011.\footnote{Although previously in regressions on educational attainment we include children who were age 13 at year of closure into the group that may still attend primary school and therefore be exposed to school closure, we only include children who are in the age range that is definitely for primary school in the enrollment regression here.} For these children, we have information about distance to primary school and primary school quality.\footnote{For older individuals in the survey who are included in the earlier attainment regressions, we do not have measures for the quality of school when they were attending primary school.} We use children from both villages with and without school closure in these regressions. The data for these analyses come from columns 2 and 3 of Table \ref{figoneb}.

Primary school enrollment in 2011 is high but not full. For children at 5 years of age, the enrollment rate is 10 percent. At age 6 and 7, the enrollment rate increases to 47 percent and then 83 percent. Enrollment peaks at 94.4 percent at age 11.\footnote{After primary school, at age 13, 15 and 17, enrollment rates drops to 92, 82, and 55 percent respectively.} In the following regressions, we analyze the relationship between distance, quality and school enrollment.

We regress enrollment on distance to closest primary school and quality of these schools. Regressions control for county fixed effects, province-specific age fixed effects, village per capita income, village per capita land size, village population size, household relative wealth, the number of household members and household ethnicity. Despite the controls, the coefficients we obtain for distance to school and quality of school would not be causal if there are unobserved village-level attributes that affect enrollment and that are also correlated with distance and quality. Our inclusion of village-level controls and county fixed effects, however, seeks to reduce the risk of omitted variables bias our estimates.

\pagebreak
\begingroup
\setstretch{1.0}
%\setstretch{1.1}
\setlength\bibitemsep{0pt}
\printbibliography
\endgroup
\pagebreak

\end{document}


\section{Further Research}

  %\subsection{Trust Transfer Algorithms}
    When a purchase is made, outgoing direct trust must be reduced such that (\ref{primetrust}) holds. Trust redistribution
    algorithms for this will be discussed in a future paper.

  %\subsection{Dynamic Setting}
    Our game is static. In a future dynamic setting, users should be able to play simultaneously, freely join, depart or
    disconnect temporarily from the network. An interesting analysis would involve modelling repeated purchases with the
    respective edge updates on the trust graph and treating trust on the network as part of the utility function. Other types
    of multisigs, such as 1-of-3, can be explored.

  %\subsection{Zero knowledge}
    MaxFlow in our case needs complete network knowledge, which can lead to privacy issues \cite{deanonymisation}. Calculating
    the flows in zero knowledge remains an open question. SilentWhispers \cite{silentwhispers} and its centralized
    predecessor, PrivPay \cite{privpay}, offer insight into how privacy can be achieved.

  %\subsection{Implementation and Experimental Results}
    A wallet implementation of our game on any blockchain is welcome. Experimental results can be harvested by a simulation or
    implementation of Trust Is Risk. Afterwards, our system can be used in decentralized social networks, such as Synereo
    \cite{synereo}, and other applications.


\documentclass[prd,onecolumn,amsmath,amssymb,floatfix,superscriptaddress,notitlepage]{revtex4-1}
\usepackage{graphicx,epsfig}
\usepackage{caption}
\def\be{\begin{equation}}
\def\ee{\end{equation}}
\def\ben{\begin{equation*}}
\def\een{\end{equation*}}

\def\ba{\begin{eqnarray}}
\def\ea{\end{eqnarray}}
\def\ban{\begin{eqnarray*}}
\def\ean{\end{eqnarray*}}
\newcommand{\refsec}[1]{section~\ref{sec:#1}}
\newcommand{\refeq}[1]{Eq.~(\ref{eqn:#1})}
\newcommand{\refssec}[1]{section~\ref{subsec:#1}}
\newcommand{\reffig}[1]{Fig.~\ref{fig:#1}}
\newcommand{\refFig}[1]{Fig.~\ref{fig:#1}}
\newcommand{\reftab}[1]{Tab.~\ref{tab:#1}}

\newcommand{\bl}{{\bf l}}
\newcommand{\bL}{{\bf L}}

%%% BEGIN DOCUMENT
\begin{document}
\title{CMB DC Mode}
\author{}
\affiliation{Department of Astronomy \& Astrophysics, University of Chicago, Chicago IL 60637}
\date{\today}

\maketitle

\section{variance test}

\begin{figure}[htbp]
\begin{center}
\includegraphics[scale=0.3]{./images/box.pdf}
%\label{default}
\end{center}
\end{figure}

One way to compute the variance is just to sum over all the modes that are super-sample mode considering the width of the box $\theta_{box}\rightarrow l_{max}=\frac{2\pi}{\theta_{box}}$:

\be \label{eqn:lmax}
(\sigma^{\kappa})^{2}=\sum_{0}^{l_{max}=\frac{2\pi}{\theta_{box}}}\frac{2\ell+1}{4\pi}C_{\ell}^{\kappa}
\ee

\begin{figure}[htbp]
\begin{center}
\includegraphics[scale=0.4]{./images/Ckappa.pdf}
\caption{Power spectrum}
%\caption{default}
%\label{default}
\end{center}
\end{figure}

where the convergence power is releted to the lensing one by $C^{\kappa}=\ell^{2}(\ell+1)^{2}C^{\phi}/4$.

Increasing the size of the survey, reduce the number of large scale modes that can be consider as super-survey, and so the variance is reduced. This reduce the ``super sample covariance '' effect.
Now the width of the survey could be derived from the total area, assuming it covers a circular area, by $\pi \theta_{box}^{2}=\text{Area}(\frac{\pi}{180})^{2}$.
In this case $l_{max}=\frac{2\pi}{\theta_{box}}=\frac{2\pi}{\sqrt{(\text{tot Area})/\pi} (\pi/180)}=\frac{360\sqrt\pi}{\sqrt{\text{tot Area}}}=\frac{638}{\sqrt{\text{tot Area}}}$, where the total area has to be expressed in degree squared. For a 1000 deg$^{2}$ we get $l_{max}\approx20$

We want to compare this effect to the precision on the measurement of the angular size of sound horizon at last scattering, cause the effect of this background mode can be seen as if the fraction of the sky tested by the survey would have been sitted on a slightly over or under dense region, a slightly closed or open universe. The effect on the power spectrum is the same as a change in the curvature: a shift in the power spectrum.
The current precision reach by planck is $\frac{\sigma_{\theta^{\star}}}{\theta^{\star}}=\frac{0.00006}{1.041}=0.00057$.

We can improve this rough estimate by introducing a simple window function for the survey.

The variance in a 2D flat sky approximation become:
\be
\sigma^{2}_{\kappa}=\int \frac{d^{2}~q}{(2\pi)^{2 }}|\tilde W(q)|^{2} P(q),
\ee
where $\tilde W(q)$ is the fourier transform of the window function (we used the usual Fourier transform conventions).
As a window we can choose a uniform circular disk or radius $R=\theta_{box}$ (normalized so that $\int d^{2}x ~W(x)=1$) in the small angle approximation.
We have
\ba
|\tilde W(q)|&=&\int d^{2}x e^{-i q\cdot x} \Theta(r-R)/(\pi R^{2})\\
&=&\int_{0}^{\infty} x~dx \int_{0}^{2\pi} d\theta e^{-i qx\cos\theta} \Theta(r-R)/(\pi R^{2})\\
&=&1/(\pi R^{2}) \int_{0}^{R} xdx~ \int_{0}^{2\pi} d\theta e^{-i qx\cos\theta} \\
&=&1/(q \pi R^{2}) \int_{0}^{R} xdx~ 2\pi q J_{0}(xq) \\
&=&\frac{2\pi}{\pi R^{2} q^{2}}\int_{0}^{R} d(xq) xq J_{0}(xq) \\
&=&\frac{2\pi}{\pi R^{2} q^{2}}Rq J_{1}(Rq) \\
&=&\frac{2~J_{1}(Rq)}{Rq}. \\
\ea
We have used two properties of bessel functions
\ba
&&J_{n}=\frac{i^{-n}}{\pi}\int_{0}^{\pi}d\theta e^{ix\cos\theta}cos(n\theta)\\
&&\frac{d}{dx}[xJ_{1}(x)]=xJ_{0}(x)\\
\ea

The variance become:
\ba \label{eqn:integral}
\sigma_{\kappa}^{2}&=&\int \frac{d^{2}~\ell}{(2\pi)^{2}} \left(\frac{2~J_{1}(\ell~\theta_{box})}{\ell~\theta_{box}}\right)^{2} C_{\ell}\\
&=&\int \frac{d\ell}{(2\pi)} \ell \left(\frac{2~J_{1}(\ell~\theta_{box})}{\ell~\theta_{box}}\right)^{2} C_{\ell}
\ea
It can also be approximated by a sum
\be \label{eqn:approx}
\sigma_{\kappa}^{2}=\sum \frac{2\ell+1}{4\pi} \left(\frac{2~J_{1}(\ell~\theta_{box})}{\ell~\theta_{box}}\right)^{2} C_{\ell}.
\ee

\begin{figure}[htbp]
\begin{center}
\includegraphics[scale=0.6]{./images/window.pdf}
%\caption{default}
%\label{default}
\end{center}
\end{figure}

\begin{figure}[htbp]
\begin{center}
\includegraphics[scale=0.6]{./images/variance.pdf}
\caption{Integral correspond to \refeq{integral} Sum approximation is \refeq{approx} . No window lmax correspond to \refeq{lmax} which I think is pretty different cause it is like having a rectangle window function in Fourier space which give you an un-normalized sync window function in space domain. }
%\label{default}
\end{center}
\end{figure}

\section{Fisher\_estimate}

I compute the value of  $C^{\rm{fid}}_{\ell}$s using CAMB and with those I compute the Fisher estimates of the effect we are looking for, given the accuracy (beam and white noise) of a detector. See Wayne's notes.

The super sample modes shift the CMB power spectrum and so we have:
\begin{equation}\label{eqn:Cfiducial}
C_l = C_l^{\rm fid} \left[ 1+ \frac{\partial \ln (l^2 C_l^{\rm fid} )}{\partial \ln l} s \right].
\end{equation}
Notice that the effect is stronger where the derivatives are bigger, near the peaks.
Now we can perform a Fisher estimate of $\sigma_s^2$ (no other parameters marignalized) and compare it to $\sigma_\kappa^2$.
I compute:
\begin{equation}
\frac{\partial C_{\ell}}{\partial s}=C^{\rm fid}\frac{\partial \ln (l^2 C_l^{\rm fid}) }{\partial \ln l},
\end{equation}
directly from the spline function I use to fit the spectrum (maybe we need something more accurate?); after that, following the fisher formalism:
\ben
F_{ss}=\sum_{\ell}\frac{1}{(\delta C_{\ell})^{2}}\left( C^{\rm fid}\frac{\partial \ln (l^2 C_l^{\rm fid} )}{\partial \ln l}\right)^{2}
\een
\ben
F_{ss}=\sum_{\ell}\frac{(2\ell+1)f_{\rm sky}}{2[C^{\rm{fid}}_{\ell}+N_{\ell}]^{2}}\left( C^{\rm fid}\frac{\partial \ln (l^2 C_l^{\rm fid} )}{\partial \ln l}\right)^{2}
\een
Now we can estimate the accuracy on $\sigma_{s}^{2}$ using $\sigma_{s}^{2}=F_{ss}^{-1}$

\be
N_{\ell}=\left( 4 \mu K \left(\frac{\pi}{10800}\right)\right)\exp\{-\ell(\ell+1)\theta\left(\frac{\pi}{10800}\right)/(8\log 2)\}.
\ee
I put the equation explicitly cause I am not sure that when they quote an accuracy they mean this or the same divided by the T$_{CMB}$.

The next questions is where in the ($\ell_{max},f_{sky}$) region the effect $\sigma_{\kappa}^{2}$ is bigger than the accuracy we can reach in measuring it estimated using the fisher matrix approach, $\sigma_{s}^{2}$.
This can be seen in \reffig{comparison} where we have plotted $\sigma_{s}^{2}f_{sky}$ as a function of $l_{max}$ and horizontal lines that correspond to the value of $\sigma_{\kappa}^{2}f_{sky}$ for different survey areas.

\begin{figure}[htbp]
\begin{center}
\includegraphics[scale=0.6]{./Images/variancecompare.pdf}
\caption{The solid curves represent $\sigma_{s}^{2}f_{sky}$ estimated from power spectra as a function of $l_{max}$.
The red one is computed using the temperature data only $F_{ss} = {2 \over f_{sky}(2\ell+1)} \left(\frac{\partial \ln(\ell^{2}C^{T})}{\partial \ln\ell}\right)^{2}$;The green one is computed using the E-mode data only $F_{ss} = {2 \over f_{sky}(2\ell+1)} \left(\frac{\partial \ln(\ell^{2}C^{E})}{\partial \ln\ell}\right)^{2}$, and the blue one combine the 2 set of data using the full expression \refeq{fishertot2}.
Horizontal lines  correspond to the value of $\sigma_{\kappa}^{2}f_{sky}$ for different survey areas.}
\label{fig:comparison}
\end{center}
\end{figure}

\subsection{Polarization}

We expect the effect of the super sample covariance to be bigger in the case of the lensed polarization field, Because the unlensed polarization peaks are rather sharper than in the temperature case, this actually means that the effect of lensing is quantitatively more important on the $C_{l}^{E}$ spectrum. Let us start, in the flat sky approximation, by computing the E field trispectrum:
\be
<\tilde E(\ell_{1})~\tilde E(\ell_{2})~\tilde E(\ell_{3})~\tilde E(\ell_{4})> (2\pi)^{2} \delta(\ell_{1}+\ell_{2}+\ell_{3}+\ell_{4})\tilde T(\ell_{1}+\ell_{2}+\ell_{3}+\ell_{4})
\ee
As we did for the temperature field, we can express the lensed field respect to the unlensed one by expanding in series the spin-2 component of the polarization tensor
\ba
\tilde P(\mathbf{n})&=&P(\mathbf{n}+\nabla \phi)\nonumber\\
&\approx& P(\mathbf{n})+\nabla \phi \nabla P(\mathbf{n})+ ...\nonumber
\ea
Using the harmonic expansion definitions in flat sky:
\ba
P=Q+iU=-\int\frac{d^{2}\mathbf{l}}{2\pi}[E(\mathbf{l})+iB(\mathbf{l})]e^{2i\phi_{l}}e^{i\mathbf{l}\mathbf{n}}
\ea
we get
\ba
\tilde E(\mathbf{l})&\approx& E(\mathbf{l})-\int\frac{d^{2}\mathbf{l'}}{2\pi}~\mathbf{l'}\cdot(\mathbf{l}-\mathbf{l'})\cos2(\phi_{l}-\phi_{l'})\psi(\mathbf{l}-\mathbf{l'})E(\mathbf{l'})\nonumber\\
&&-\frac12 \int\frac{d^{2}\mathbf{l_{1}}}{2\pi}\frac{d^{2}\mathbf{l_{2}}}{2\pi}~ \cos2(\phi_{l}-\phi_{l'}) ~\bl_{1}(\bl_{1}+\bl_{2}-\bl)~\bl_{1}\cdot\bl_{2}E(\bl_{1})\psi(\bl_{2})\psi^{*}(\bl_{1}+\bl_{2}-\bl)\\
\tilde B(\mathbf{l})&\approx&-\int\frac{d^{2}\mathbf{l'}}{2\pi}~\mathbf{l'}\cdot(\mathbf{l}-\mathbf{l'})\sin2(\phi_{l}-\phi_{l'})\psi(\mathbf{l}-\mathbf{l'})E(\mathbf{l'})
\ea
neglecting higher order in $\phi$ and primordial un-lensed B modes.

We are interested in the connected part of the lensed trispectrum $<\tilde X(\bl_{1})\tilde X(\bl_{2})\tilde X(\bl_{3})\tilde X(\bl_{4})>_{c}$ with $XXXX=\{EEEE,BBBB,EETT\}$ in a particular configuration where the modes are coupled together via a long wavelength mode \bL.

For example in the EEEE case we have

\ba
<\tilde E(\bl_{1})\tilde E(\bl_{2})\tilde E(\bl_{3})\tilde E(\bl_{4})>_{c}&\approx& \frac{1}{2(2\pi)^{2}}\delta(\bl_{1}+\bl_{2}+\bl_{3}+\bl_{4})\\
&& \times \left[ C^{\psi}_{|\bl_{1}+\bl_{3}|}C^{E}_{\bl_{3}}C^{E}_{\bl_{4}}W_{E}(\bl_{1};-\bl_{3})W_{E}(\bl_{2};-\bl_{4})+\text{perm}\right]
\ea
where $W_{E}(\bl;-\bl')=\bl' \cdot (\bl -\bl') \cos 2(\phi_{l} - \phi_{l'})$ and perm means all permutations of the $\bl_{i}$. In the squeezed quadrilateral configuration we are interested in, $\bl_{1}+\bl_{2}=\bL=-(\bl_{3}+\bl_{4})$ the phases between different modes are small, i.e $\phi_{\bl_{i}+\bl_{j}}<<1$ and we can approximate at first order $\sin\approx0$ and $\cos\approx1$. Doing so we see that the lensed E mode shows exactly the same structure of the T fields and so going thorough the same algebra we get:
\ba
T^{EE}(\bl_{1},\bl_{2},\bl_{3},\bl_{4}) = \frac14~C^{E}_{l_{1}}C^{E}_{l_{1}}L^{4} C^{\phi\phi}_{l} \frac{\partial \ln l^{2}C^{E}_{l}}{\partial\ln l}\Big|_{l_1} \frac{\partial \ln l^{2}C^{E}_{l}}{\partial\ln l}\Big|_{l_3}.
\ea

In our configuration $<\tilde B(\bl_{1})\tilde B(\bl_{2})\tilde B(\bl_{3})\tilde B(\bl_{4})>_{c}=0$.

Furthermore we can compute:
\ba
T^{TE}(\bl_{1},\bl_{2},\bl_{3},\bl_{4}) = \frac14~C^{TE}_{l_{1}}C^{TE}_{l_{1}}L^{4} C^{\phi\phi}_{l} \frac{\partial \ln l^{2}C^{ET}_{l}}{\partial\ln l}\Big|_{l_1} \frac{\partial \ln l^{2}C^{TE}_{l}}{\partial\ln l}\Big|_{l_3}.
\ea

Now we can combine all the CMB observations to get the best, variance limited, estimate of $\sigma_{s}^{2}$ and compare it with $\sigma_{\kappa}^{2}$.

\begin{equation}
F_{ss} =
\sum_{\ell}\sum_{XY}\left(\frac{\partial C_{\ell}^{X}}{\partial s}\right)({\rm Cov}^{C_{\ell}^{X},C_{\ell}^{Y}})^{-1}\left(\frac{\partial C_{\ell}^{Y}}{\partial s}\right).
\end{equation}
where $XY\in$ $TT$, $TE$, $EE$, $BB$. We are using a guassian approximation for the covariance matrix ${\rm Cov}^{XY,WZ}_{\ell_1 \ell_2}  ={1 \over 2\ell_1+1} [ C_{\ell_1}^{XW}C_{\ell_1}^{YZ} + C_{\ell_1}^{XZ}C_{\ell_1}^{YW}]$. Because the B power spectra get no contribution from super sample effect we have
\ba\label{eqn:fishertot1}
F_{ss} &=& \left(\frac{\partial C^{T}}{\partial s}\right)^{2} \left[{2 \over f_{sky}(2\ell+1)}  C_{\ell}^{T}C_{\ell}^{T} \right]^{-1}\ +\nonumber\\
&&\left(\frac{\partial C^{E}}{\partial s}\right)^{2} \left[{2 \over f_{sky}(2\ell+1)}  C_{\ell}^{E}C_{\ell}^{E} \right]^{-1}\nonumber\\
&&\left(\frac{\partial C^{E}}{\partial s}\right) \left[{2 \over f_{sky}(2\ell+1)}  C_{\ell}^{T}C_{\ell}^{E} \right]^{-1}\left(\frac{\partial C^{T}}{\partial s}\right) +\nonumber\\
&&\left(\frac{\partial C^{ET}}{\partial s}\right)^{2} \left[{2 \over f_{sky}(2\ell+1)}  C_{\ell}^{ET}C_{\ell}^{ET} \right]^{-1} +\nonumber\\
&&\left(\frac{\partial C^{E}}{\partial s}\right) \left[{2 \over f_{sky}(2\ell+1)}  C_{\ell}^{E}C_{\ell}^{TE} \right]^{-1}\left(\frac{\partial C^{TE}}{\partial s}\right) +\nonumber\\
&&\left(\frac{\partial C^{T}}{\partial s}\right) \left[{2 \over f_{sky}(2\ell+1)}  C_{\ell}^{T}C_{\ell}^{TE} \right]^{-1}\left(\frac{\partial C^{TE}}{\partial s}\right).
\ea
Note that from \refeq{Cfiducial}, $\frac{\partial C^{X}}{\partial s}\propto C^{X}$ and we have

\begin{align}\label{eqn:fishertot2}
F_{ss} &= {2 \over f_{sky}(2\ell+1)} \biggr[\left(\frac{\partial \ln(\ell^{2}C^{T})}{\partial \ln\ell}\right)^{2}  + \left(\frac{\partial \ln(\ell^{2}C^{E})}{\partial \ln\ell}\right)^{2}\nonumber \\
& \left(\frac{\partial \ln(\ell^{2}C^{E})}{\partial \ln\ell}\right)\left(\frac{\partial \ln(\ell^{2}C^{T})}{\partial \ln\ell}\right) + \left(\frac{\partial \ln(\ell^{2}C^{ET})}{\partial \ln\ell}\right)^{2}\nonumber\\
&+ \left(\frac{\partial \ln(\ell^{2}C^{E})}{\partial \ln\ell}\right)\left(\frac{\partial \ln(\ell^{2}C^{TE})}{\partial \ln\ell}\right)+ \left(\frac{\partial \ln(\ell^{2}C^{T})}{\partial \ln\ell}\right)\left(\frac{\partial \ln(\ell^{2}C^{TE})}{\partial \ln\ell}\right)\biggr].
\end{align}

\end{document}


% !TEX root=../report.tex

\section{Our base language}

Let us start by defining our host language.
It is a simple $\lambda$-calculus.
Next to abstraction, application and variables,
it contains constants for booleans, integers and strings
and some basic operations on them.
We will embed our task language \emph{into} this basic language.
This means we can use all the power of the host language,
such as arithmetic operations and (higher order) functions,
in our task language.
Because all the constructs in our host language are standard,
we will not give typing rules and semantic rules here.
For this we refer to standard work like \textcite{books/Pierce02TAPL} and \textcite{books/Harper16PFPL}.

\subsection{Syntax}
\label{sec:syntax}

\begin{grammar}
  Expressions
    & e &::= & \lambda x:\tau.\ e & – abstraction \\
    &   &\mid& e_1\ e_2           & – application \\
    &   &\mid& x                  & – variable \\
    &   &\mid& c                  & – constant \\
    &   &\mid& e_1 \star e_2      & – operator \\
    &   &\mid& \If{e_1}{e_2}{e_3} & – branching \\
    &   &\mid& p                  & – pretask \\
  Constants
    & c &::= & B                  & – boolean \\
    &   &\mid& I                  & – integer \\
    &   &\mid& S                  & – string \\
  Pretasks
    & p &::= & \ldots             & (to be defined) \\
\end{grammar}
Expressions are typed abstractions, applications, variables or constants.
Constants can be booleans, integers or strings.
The $\star$ represents a general notion of operators.
With $\If{}{}{}$ one can do basic branching.
The syntactic category of pretasks will be defined in the upcoming sections.
Pretasks $p$ are tasks \emph{in making},
just as expressions are values in making.
A \emph{task} will be introduced in \autoref{sec:evaluation}.

We will use double quotation marks ($\str{}$) to denote strings.
Integers are denoted by their decimal representation,
and booleans are written $\True$ and $\False$.
In the remaining of this report,
we will freely make use of the logic operators $\Not$, $\land$, and $\lor$,
arithmetic operators $+$, $-$, $\times$,
and the string append operator $\pp$.
Also, we will use the standard comparison operations $<$, $\le$, $\equiv$, $\not\equiv$, $\ge$, and $>$
as builtins.
Only when referring to operators in general we will use $\star$.

\subsection{Typing}

\begin{grammar}
  Types
    & \tau &::= & \tau_1 \to \tau_2 & – function type \\
    &      &\mid& \beta             & – basic type \\
    &      &\mid& \Task \tau        & – task type \\
  Basic types
    &\beta &::= & \Bool             & – boolean type \\
    &      &\mid& \Int              & – integer type \\
    &      &\mid& \String           & – string type \\
\end{grammar}
Typing of our expressions $e$ is as to be expected,
and won't be given in this document.
There is one big difference with respect to standard work.
This is the addition of a type for tasks $\Task \tau$.
Typing rules are of the form $\boxed{\Gamma \infers e : \tau}$,
which we read as \enquote{in environment $\Gamma$, expression $e$ has type $\tau$}.

\subsection{Evaluation}
\label{sec:evaluation}

To express evaluation,
we use the big step semantics of our host language.
Turning an expression $e$ into a value $v$ is denoted by $\boxed{e \evaluate v}$.
The rules to evaluate expressions $e$ do not differ from standard work.

\begin{grammar}
  Values
    & v &::= & \lambda x.\ e  & – abstractions \\
    &   &\mid& c              & – constants \\
    &   &\mid& t              & – tasks \\
  Tasks
    & t &::= & \ldots         & – (to be defined for each $p$) \\
\end{grammar}
Regarding our base language, lambda abstractions are values, as are all constants.
Each \emph{pretask} $p$ we will encounter in the upcoming sections,
will be accompanied by a corresponding \emph{task} $t$.
Tasks are also values with respect to evaluation.
This means pretasks will be eagerly evaluated to tasks by the relation $\evaluate$.\footnote{
  The same applies to pairs,
  which we will add to our host language in \autoref{sec:pairing}.
}
This suggestion by \textcite[p. 323]{books/Harper16PFPL}
makes it easier to reason about data constructors.