% Modified based on Xiaoming Sun's template
\documentclass{article}
\usepackage{amsmath,amsfonts,amsthm,amssymb}
\usepackage{setspace}
\usepackage{fancyhdr}
\usepackage{lastpage}
\usepackage{extramarks}
\usepackage{chngpage}
\usepackage{soul,color}
\usepackage{graphicx,float,wrapfig}

\usepackage{hyperref}
\hypersetup{
    colorlinks=true,
    linkcolor=blue,
    filecolor=magenta,
    urlcolor=cyan,
}

\newcommand{\Class}{Mathematics for Computer Science}

% Homework Specific Information. Change it to your own
\newcommand{\Title}{Homework 1}

% In case you need to adjust margins:
\topmargin=-0.45in      %
\evensidemargin=0in     %
\oddsidemargin=0in      %
\textwidth=6.5in        %
\textheight=9.0in       %
\headsep=0.25in         %

% Setup the header and footer
\pagestyle{fancy}                                                       %
\chead{\Title}  %
\rhead{\firstxmark}                                                     %
\lfoot{\lastxmark}                                                      %
\cfoot{}                                                                %
\rfoot{Page\ \thepage\ of\ \protect\pageref{LastPage}}                          %
\renewcommand\headrulewidth{0.4pt}                                      %
\renewcommand\footrulewidth{0.4pt}                                      %

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Some tools
\newcommand{\enterProblemHeader}[1]{\nobreak\extramarks{#1}{#1 continued on next page\ldots}\nobreak%
                                    \nobreak\extramarks{#1 (continued)}{#1 continued on next page\ldots}\nobreak}%
\newcommand{\exitProblemHeader}[1]{\nobreak\extramarks{#1 (continued)}{#1 continued on next page\ldots}\nobreak%
                                   \nobreak\extramarks{#1}{}\nobreak}%

\newcommand{\homeworkProblemName}{}%
\newcounter{homeworkProblemCounter}%
\newenvironment{homeworkProblem}[1][Problem \arabic{homeworkProblemCounter}]%
  {\stepcounter{homeworkProblemCounter}%
   \renewcommand{\homeworkProblemName}{#1}%
   \section*{\homeworkProblemName}%
   \enterProblemHeader{\homeworkProblemName}}%
  {\exitProblemHeader{\homeworkProblemName}}%

\newcommand{\homeworkSectionName}{}%
\newlength{\homeworkSectionLabelLength}{}%
\newenvironment{homeworkSection}[1]%
  {% We put this space here to make sure we're not connected to the above.

   \renewcommand{\homeworkSectionName}{#1}%
   \settowidth{\homeworkSectionLabelLength}{\homeworkSectionName}%
   \addtolength{\homeworkSectionLabelLength}{0.25in}%
   \changetext{}{-\homeworkSectionLabelLength}{}{}{}%
   \subsection*{\homeworkSectionName}%
   \enterProblemHeader{\homeworkProblemName\ [\homeworkSectionName]}}%
  {\enterProblemHeader{\homeworkProblemName}%

   % We put the blank space above in order to make sure this margin
   % change doesn't happen too soon.
   \changetext{}{+\homeworkSectionLabelLength}{}{}{}}%

\newcommand{\Answer}{\ \\\textbf{Answer:} }
\newcommand{\Acknowledgement}[1]{\ \\{\bf Acknowledgement:} #1}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Make title
\title{\textmd{\bf \Class: \Title}}
\date{March 1, 2019}
\author{Xingyu Su 2015010697}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}
\begin{spacing}{1.1}
\maketitle \thispagestyle{empty}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Begin edit from here

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% HOMEWORK-1-LPV 1.8.26
\begin{homeworkProblem}[LPV 1.8.26]
Find the number of all 20-digit integers in which no two consecutive digits are the same.

\Answer

The first digit has 0-9 ten choices, and the second will have only 9 choices left because it can not be the same with the first digit. So as all the left 18-digits. As a result, the answer should be:

$10 \cdot 9^{19} = 1441151880758558720 \approx 1.44\times10^{18} $

\end{homeworkProblem}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% HOMEWORK-1-LPV 1.8.29
\begin{homeworkProblem}[LPV 1.8.29]
What is the number of ways to color n objects with 3 colors if every color must be used at least once?

\Answer

For the case of $n<2$, obviously the answer is 0, and when $n = 3$, answer is 1. Considering a big n, the answer should be equal to the permutations of choosing any color of 3 for any object substract the permutations of choosing any 2 colors of 3 for any object.

Generally, The answer $ans$ is:

    \hspace{1em} if $n<2$, $ans=0$

    \hspace{1em} if $n \geq 3$, $ans=\binom{3}{3} \times 3^n - \binom{3}{2}\times 2^n$

\end{homeworkProblem}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% HOMEWORK-1-LPV 2.1.8
\begin{homeworkProblem}[LPV 2.1.8]
Prove that the sum of the first $n$ squares $1+4+9+\cdots+n^2$ is $n(n+1)(2n+1)/6.$

\Answer

Consider $n=1$, we have $1=1*(1+1)*(2*1+1)/6$, so the equation is proved to be true when $n=1$.

Consider the equation is true when $n=k$, then we have:

\hspace{1em}
$\sum_{i=1}^{k+1}{i^2}
=\sum_{i=1}^k{i^2}+(k+1)^2
=\frac{k(k+1)(2k+1)}{6}+(k+1)^2
=\frac{(k+1)[2k^2+k+6(k+1)]}{6}
=\frac{(k+1)(k+2)(2k+3)}{6}
$

which means $\sum_{i=1}^{n}{i^2}=\frac{n(n+1)(2n+1)}{6}$ is true when $n=k+1$.

So the equation is true for all positive numbers $n=1, 2, 3, \cdots$

\end{homeworkProblem}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% HOMEWORK-1-LPV 2.1.13
\begin{homeworkProblem}[LPV 2.1.13]
Read carefully the following induction proof:

Assertion: Balabala...

Proof: Balabala...

But the assertion we proved is clearly wrong; where is the error?

\Answer

Because the \textbf{Proof} part used more than 2 lines, but the induction part can only prove the \textbf{Assertion} is true when there are two lines.

\end{homeworkProblem}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% HOMEWORK-1-LPV 2.5.2
\begin{homeworkProblem}[LPV 2.5.2]
What is the following sum?

$0 \cdot \binom{n}{0} + 1 \cdot \binom{n}{1} + 2 \cdot \binom{n}{2} + \cdots + (n-1) \cdot \binom{n}{n-1} + n \cdot \binom{n}{n}$

Experiment, conjecture the value, and then prove it. (Try to prove the result by induction and also by combinatorial arguments.)

\Answer

Denote the sum of the equation as $f(n)$, and do experiments for $n=1,2,3,4,5$, we can get:

\hspace{1em} $n=1$, $f(1)=0+1=1=1 \times 2^0$

\hspace{1em} $n=2$, $f(2)=0+1 \times 2+2 \times 1=4=2 \times 2^1$

\hspace{1em} $n=3$, $f(3)=0+1 \times 3+2 \times 3+3 \times 1=12=3 \times 2^2$

\hspace{1em} $n=4$, $f(4)=0+1 \times 4+2 \times 6+3 \times 4+4 \times 1=32=4 \times 2^3$

\hspace{1em} $n=5$, $f(5)=0+1 \times 5+2 \times 10+3 \times 10+4 \times 5+5 \times 1=80=5 \times 2^4$

From induction, we can guess when $n=k$, $f(k)=k\times 2^{k-1}$. And here we can get:

\hspace{1em} $\binom{n}{m} = \binom{n-1}{m-1} \times n / m$

\hspace{1em} $m \binom{n}{m} = \binom{n-1}{m-1}\times n$

So:

\hspace{1em} $\sum_{m=1}^n m \binom{n}{m} = \sum_{m=1}^n (\binom{n-1}{m-1} \times n) =  n \times \sum_{m=0}^{n-1} \binom{n}{m} = n 2^{n-1}$

\end{homeworkProblem}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% HOMEWORK-1-LPV 2.5.7
\begin{homeworkProblem}[LPV 2.5.7]

We select 38 even positive integers, all less than 1000. Prove that there will be two of them whose difference is at most 26.

\Answer

If every each two numbers' difference is bigger than 26, consider the fisrt number is 2, then the next is at least 29, which in result should be 30. With this strategy, after choosing the first 38 even positive integers, we will get 2, 30, ... , 1010, 1038. So smallest difference between any 2 numbers should be smaller than 28.

If every each two numbers' difference is no smaller than 26, consider the fisrt number is 2, then the next is at least 27, which in result should be 28. With this strategy, after choosing the first 38 even positive integers, we will get 2, 28, ... , 938, 964. So smallest difference between any 2 numbers is 26.

\end{homeworkProblem}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% HOMEWORK-1-Special Problem 1
\begin{homeworkProblem}[Special Problem 1]
\hspace{1em}
(a) In the birthday problem discussed in class (with 72 students present), using the same probability space, let $T_1$ be the event that there is a triple-collision, i.e. three students having the same birthday. Calculate the numerical value of $Pr\{T_1\}$.

(b) In the same probability space as above, let $T_2$ be the event that there are at least 6 disjoint same-birthday pairs of students. Calculate the numerical value of $Pr\{T_2\}$.

\Answer

(a) Consider the opposite conditions, we can get all events count as below:

\hspace{1em}
$|\Omega| - |T_1| = A^{72}_{366}+C^{2}_{72}A^{71}_{366}+C^{2}_{72}C^{2}_{70}A^{70}_{366}/{2!}+\cdots+C^{2}_{72}C^{2}_{70}\cdots C^{2}_{2}A^{36}_{366}/{36!}$

\hspace{1em}
$Pr\{T_1\} = 1 - |T_1|/|\Omega| = 1-\frac{1}{366^{72}}(\frac{1}{2^0 0!}A^{72}_{366}+\frac{1}{2^1 1!}A^{2}_{72}A^{71}_{366}+\frac{1}{2^2 2!}A^{4}_{72}A^{70}_{366}+\cdots+\frac{1}{2^{36} 36!}A^{72}_{72}A^{36}_{366})$

Which is found true in (2) of \href{https://ac.els-cdn.com/S0378375804002721/1-s2.0-S0378375804002721-main.pdf?_tid=7580fe67-40c2-467b-8487-b348cae793a5&acdnat=1551672820_3458fd64ec45ba9465eb28ddba80e341}{doi:10.1016/j.jspi.2003.11.015}:  %DevSkim: ignore DS173237

\hspace{1em}
$Pr\{T_1\} = 1 - \sum_{i=0}^{[n/2]}{\frac{m!n!}{i!(n-2i)!(m-n+i)!2^im^n}}$

The result is calculated to be $Pr\{T_1\}=0.3267$. And Figure 1 shows the probability of triple-collision with number of students varies from 10 to 100.

\begin{figure}[h]
  \centering
  \includegraphics[width=0.6\linewidth]{figures/hw1_fig1}
  \caption{Probability of triple-collision with number of students varies from 10 to 100.}
  \label{fig:triple-collision}
\end{figure}

(b) The conditions are very hard and after hours thinking I gived it up. But a statistic counting is done by `python' as shown in Figure 2, from which the result is $Pr\{T_2\} \approx 0.0612$

\begin{figure}[h]
  \centering
  \includegraphics[width=0.6\linewidth]{figures/hw1_fig2}
  \caption{Probability of six or more disjoint pairs}
  \label{fig:six-disjoint}
\end{figure}

\end{homeworkProblem}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% HOMEWORK-1-Special Problem 2
\begin{homeworkProblem}[Special Problem 2]

\hspace{1em}
(a) Develop a mathematical probability model for the Monte Hall Problem discussed in class. Specify mathematically the events corresponding, respectively, to the success of the strategies Switch and No-Switch. Show that $Pr\{No\ Switch\} = 1/3$, and $Pr\{Switch\} = 2/3$.

(b) Suppose Host Monte Hall puts the coveted car behind doors 1, 2, 3 with probabilities 1/2, 1/3, 1/6 respectively (instead of uniformly as in class). Assume the contestant initially picks door 1. How should you modify your probability space? What is the value of $Pr\{No\ Switch\}$ and $Pr\{Switch\}$.

\Answer

(a) It's easy to denote three doors to be 1, 2, 3 with probalibities 1/3, 1/3, 1/3 respectively. Assume the contestant initially picks door 1. So with initial guess:

\hspace{1em}
$Pr\{car\ in\ 1\} = 1/3$, $Pr\{car\ in\ 2\ or\ 3\} = 2/3$

We can know that conditional probabilities is:

\hspace{1em}
$Pr\{Switch\} = Pr(Switch\ win | car\ in\ 1) + Pr(Switch\ win | car\ in\ 2\ or\ 3) = Pr\{car\ in\ 1\} \times 0+Pr\{car\ in\ 2\ or\ 3\} \times 1 = 1/3 \times 0 + 2/3 \times 1 = 2/3 $

\hspace{1em}
$Pr\{No\ Switch\} = Pr(No\ Switch\ win | car\ in\ 1) + Pr(No\ Switch\ win | car\ in\ 2\ or\ 3) = Pr\{car\ in\ 1\} \times 1 + Pr\{car\ in\ 2\ or\ 3\} \times 0 = 1/3 \times 1 + 2/3 \times 0 = 1/3 $

(b) Similarly to (a), we can get:

\hspace{1em}
$Pr\{car\ in\ 1\} = 1/2$, $Pr\{car\ in\ 2\ or\ 3\} = 1/2$

So we can know that conditional probabilities is:

\hspace{1em}
$Pr\{Switch\} = Pr(Switch\ win | car\ in\ 1) + Pr(Switch\ win | car\ in\ 2\ or\ 3) = Pr\{car\ in\ 1\} \times 0+Pr\{car\ in\ 2\ or\ 3\} \times 1 = 1/2 \times 0 + 1/2 \times 1 = 1/2 $

\hspace{1em}
$Pr\{No\ Switch\} = Pr(No\ Switch\ win | car\ in\ 1) + Pr(No\ Switch\ win | car\ in\ 2\ or\ 3) = Pr\{car\ in\ 1\} \times 1 + Pr\{car\ in\ 2\ or\ 3\} \times 0 = 1/2 \times 1 + 1/2 \times 0 = 1/2 $

\end{homeworkProblem}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% HOMEWORK-1-Special Problem 3
\begin{homeworkProblem}[Special Problem 3]

\hspace{1em}
A 4 by 4 box is filled with integers 1,2,...,15 with the lower right corner initially left empty. (See the figure on next page.) At any time there is exactly one cell empty. At each step you may move to the empty cell one of its adjacent number. Question: Prove that the second configuration cannot be reached from the first configuration.

\begin{figure}[h]
  \centering
  \includegraphics[width=0.5\linewidth]{figures/hw1_fig3}
  \caption{4 by 4 box for Special Problem 3.}
  \label{fig:boxes}
\end{figure}

\Answer

There are to truth easy to be found:

\hspace{1em}
(1) When the blank box moves around and returns to it's original position, the number of it's moves must be even.

\hspace{1em}
(2) Denote one set of box values as one state (blank can be denote as 0 or any number bigger than 15). If after $m$ times of value changes, state \textbf{a} turns to be state \textbf{b}. Then for any route from state \textbf{a} to state \textbf{b}, the number of value changes $n$ must have relationship with $m$:

\hspace{2em}
$mod(|m-n|,2) = 0$

Denote left box matrix as state $s_1$, right box matrix as state $s_2$. Using truth (1), the number of moves of blank must be even number. But with truth (2), the moves between $s_1$ and $s_2$ must be odd number. The conflict reveals that $s_2$ cannot be reached by $s_1$.

\end{homeworkProblem}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% ACKNOWLEGEMENT
\Acknowledgement{

[1] Thanks to \href{https://en.wikipedia.org/wiki/Birthday_problem}{Wikipedia: Birthday problem} and \href{https://ac.els-cdn.com/S0378375804002721/1-s2.0-S0378375804002721-main.pdf?_tid=7580fe67-40c2-467b-8487-b348cae793a5&acdnat=1551672820_3458fd64ec45ba9465eb28ddba80e341}{doi:10.1016/j.jspi.2003.11.015} for SP1(a) % DevSkim: ignore DS173237

}

% End edit to here
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\end{spacing}
\end{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


\chapter{Reflective subuniverses}\label{chap:reflective}

In this chapter we study reflective subuniverses. Reflective subuniverses were first introduced in section 7.7 of \cite{hottbook}, and were studied in much more detail in \cite{RijkeShulmanSpitters}.

In \cref{sec:prop-rfsu} we establish the basic closure properties of reflective subuniverses. In particular, we show in \cref{prp:local_pb} that pullbacks of $L$-local types are again $L$-local. It follows that cartesian products of $L$-local types and identity types of $L$-local types are again $L$-local. In \cref{lem:modal-Pi} we show that any dependent product of $L$-local types is also $L$-local, regardless of whether the indexing type is $L$-local or not. We use this fact in \cref{thm:modal-pres-prod} to show that the map $\modalunit\times\modalunit:X\times Y\to LX\times LY$ is an $L$-localization, and that the $L$-localization of a proposition is again a proposition.

In \cref{sec:accessible} we study accessible reflective subuniverses.

In \cref{sec:separated} we introduce the notion of $L$-separated type, for any reflective subuniverse $L$, and we show that the subuniverse of $L$-separated types is again a reflective subuniverse. The contents of \cref{sec:separated} are joint work with Dan Christensen, Morgan Opie, and Luis Scoccola. As a corollary we obtain in \cref{thm:truncation} that the $k$-truncation can be constructed, for any $k\geq -2$. A more elementary way of obtaining this result appears in \cite{joinconstruction}.

\section{Localizations}
\label{sec:prop-rfsu}

A \define{subuniverse} is simply a subtype of the universe. Note that we do not require that subuniverses are closed under any type constructors\footnote{In particular, we will see that reflective subuniverses aren't necessarily closed under $\Sigma$.}
For any subuniverse $P:\UU\to\prop$, we write $\UU_P\defeq \sm{X:\UU}P(X)$, and we say that $X:\UU$ is a $P$-type if $X$ is in $\UU_P$, i.e.~if $P(X)$ holds.

\begin{defn}
Let $P:\UU\to\prop$ be a subuniverse, and let $X$ be a type. A \define{$P$-localization} of $X$ is a triple $(Y,l,p)$ consisting of a $P$-type $Y:\UU_P$, a map $l:X\to Y$, and a term $p$ witnessing that the map
\begin{equation*}
l^\ast : (Y\to Z)\to (X\to Z)
\end{equation*}
is an equivalence, for every $Z:\UU_P$. This property is also called the \define{universal property} of the $P$-localization of $X$.
\end{defn}

In other words, a $P$-localization of $X$ is a map $l:X\to Y$ into a $P$-type $Y$, such that every map $f:X\to Z$ into a $P$-type $Z$ extends uniquely along $l$, as indicated in the diagram
\begin{equation*}
\begin{tikzcd}
X \arrow[r,"f"] \arrow[d,swap,"l"] & Z. \\
Y \arrow[ur,densely dotted]
\end{tikzcd}
\end{equation*}

\begin{prp}\label{lem:reflective_uniqueness}
For any subuniverse $P:\UU\to \prop$ and any type $X$, the type of $P$-localizations of $X$ is a proposition.
\end{prp}

\begin{proof}
Consider $(Y,f,p)$ and $(Y',f',p')$ of the described type. Since $p$ and $p'$
are terms of a proposition, it suffices to show that $(Y,f)=(Y',f')$. In
other words, we have to find an equivalence $g:Y\to Y'$ such that $g\circ f'=f$.

By $p(Y')$, the type of
pairs $(g,h)$ consisting of a function $g:Y\to Y'$ such that $h:g\circ f=f'$ is contractible. By
$p'(Y)$, the type of pairs $(g',h')$ consisting of a function $g':Y'\to Y$
such that $h':g'\circ f'=f$ is contractible.

Now $g'\circ g$ is a function such that $g'\circ g\circ f=g'\circ f'=f$, as
is $\idfunc[Y]$. By contractibility, it follows that $g'\circ g=\idfunc[Y]$.
Similarly, $g\circ g'=\idfunc[Y']$.
\end{proof}

\begin{prp}\label{thm:subuniv-modal}
Consider a subuniverse $P:\UU\to\prop$ and a $P$-localization $l:X\to Y$. The following are equivalent:
\begin{enumerate}
\item $X$ is a $P$-type (i.e.~$X$ is in $\UU_P$).
\item The $P$-localization $l:X\to Y$ is an equivalence.
\item The map $\precomp{l}:(Y\to X)\to (X\to X)$ is an equivalence.
\item The $P$-localization $l:X\to Y$ has a retraction.
\end{enumerate}
\end{prp}

\begin{proof}
  Certainly if $l$ is an equivalence, then $X$ is in $P$ since it is equivalent to the type $Y:\UU_P$.
  Conversely, if $X$ is in $P$ then $\idfunc[X]$ has the same universal property of $l$; so by \cref{lem:reflective_uniqueness} they are equivalent and hence $l$ is an equivalence. This shows that (i) holds if and only if (ii) holds.

  It is clear that (ii) implies (iii). Furthermore, (iii) implies (iv) because the fiber of $\precomp{l}$ at $\idfunc[X]$ is contractible. In particular, there is a function $g:Y\to X$ equipped with a homotopy $g\circ l\htpy\idfunc$. In other words,$l$ has a retraction. To see that (iv) implies (ii), suppose $g$ is a retraction of $l$, i.e.\ $g\circ l = \idfunc[X]$.
  Then $l\circ g\circ l = l$, so $l\circ g$ is a factorization of $l$ through itself.
  By uniqueness of such factorizations, $l\circ g = \idfunc[Y]$.
  Thus $g$ is also a section of $l$, hence $l$ is an equivalence.
\end{proof}

\begin{cor}\label{cor:unit_local}
For any subuniverse $P$, the unit type $\unit$ has a $P$-localization if and only if $\unit$ is already a $P$-type.
\end{cor}

\begin{proof}
Immediate from the fact that $\unit$ is a retract of any pointed type.
\end{proof}

The universal property of $P$-localization is by itself not sufficient to imply a dependent universal property. However, we have the following `constrained' dependent universal property.

\begin{prp}\label{theorem:generalized-induction}
Let $P$ be a subuniverse, and let $l:X\to Y$ be a $P$-localization. Furthermore, consider a type family $Z:Y\to\UU$ such that the total space $\sm{y:Y}Z(y)$ is a $P$-type.
Then the precomposition map
\[
  \precomp{l} : \Big(\prd{y:Y}Z(y)\Big) \lra \Big(\prd{x:X}Z(l(x))\Big)
\]
is an equivalence.
\end{prp}

\begin{proof}
Since $Y$ is a $P$-type and $\sm{y:Y}Z(y)$ is a $P$-type, the precomposition maps $\precomp{l}$ in the commuting square
\[
  \begin{tikzcd}
    (Y\to \sm{y:Y}Z(y)) \arrow[r,"\precomp{l}"] \arrow[d,swap,"\proj 1\circ\blank"] & (X\to \sm{y:Y}Z(y)) \arrow[d,"\proj 1\circ\blank"] \\
    (Y\to Y) \arrow[r,swap,"\precomp{l}"] & (X\to Y)
  \end{tikzcd}
\]
are equivalences. It follows that they induce an equivalence from the fiber of the left-hand map $\proj 1\circ\blank$ at $\idfunc[Y]$ to the fiber of the right-hand map $\proj 1\circ\blank$ at $l$. In other words, we have an equivalence
\[
  \precomp{l} : \Big(\prd{y:Y}Z(y)\Big) \lra \Big(\prd{x:X}Z(l(y))\Big).\qedhere
\]
\end{proof}

\begin{prp}
Let $P:\UU\to\prop$ be a subuniverse, and write $\tilde{\UU}_P \defeq\sm{X:\UU_P}X$. The projection
$\proj1:\tilde{\UU}_P \to\UU_P$ classifies the small maps whose fibers satisfy $P$.
\end{prp}

\begin{proof}
Let $f:Y\to X$ be any map into $X$. Then $\fibf{f}:X\to\UU$ factors through
$\UU_P$ if and only if all the fibers of $f$ satisfy $P$. Let us write
$P(f)$ for $\prd{x:X}P(\fib{f}{x})$. Then we see that the equivalence
$\chi$ of Theorem 4.8.3 of \cite{TheBook} restricts to an
equivalence
\begin{equation*}
\chi^P:(\sm{Y:\UU}{f:Y\to X}P(f))\to(X\to\UU_P).
\end{equation*}
Now observe that the outer square and the square on the right in the diagram
\begin{equation*}
\begin{tikzcd}[column sep=6em]
Y \arrow[d,swap,"f"] \arrow[rr,"{\lam{y}\pairr{\fib{f}{f(y)},\blank,\pairr{y,\refl{f(y)}}}}"] & & \tilde{\UU}_P \arrow[r] \arrow[d] & \tilde{\UU} \arrow[d] \\
X \arrow[rr,swap,"{\fibf{f}}"] & & \UU_P \arrow[r] & \UU
\end{tikzcd}
\end{equation*}
are pullback squares. Hence the square on the left is a pullback square.
\end{proof}

\begin{defn}
A \define{reflective subuniverse} $L$ is a subuniverse $\UU_L\to \UU$ equipped with an $L$-localization
\begin{equation*}
\modalunit[X]:X\to LX
\end{equation*}
for every type $X:\UU$. The $L$-localization $\modalunit[X]:X\to LX$ is sometimes also called the \define{unit} of the localization. A type in $\UU_L$ is also said to be \define{local}.
\end{defn}

\begin{thm}\label{thm:subuniverse-rs}
The data of any two reflective subuniverses with the same local types are the same.
\end{thm}

\begin{proof}
Immediate from the fact that the type of localizations is a proposition.
\end{proof}

\begin{lem}
  Any reflective subuniverse is a functor up to homotopy: given $f:A\to B$ we have an induced map $L f : L A \to L B$, preserving identities and composition up to homotopy.
  Moreover, $\modalunit$ is a natural transformation up to homotopy, i.e.\ for any $f$ we have $L f \circ \modalunit[A] = \modalunit[B] \circ f$.
\end{lem}

\begin{proof}
  Define $L f$ to be the unique function such that $L f \circ \modalunit[A] = \modalunit[B] \circ f$, using the universal property of $\modalunit[A]$.
  The rest is easy to check using further universal properties.
\end{proof}

\begin{cor}\label{cor:local_retract}
The subuniverse of $L$-local types is closed under retracts.
\end{cor}

\begin{proof}
Consider an $L$-local type $Y$, and suppose that $i:X\to Y$ has a retraction $r:Y\to X$. By the functoriality of $L$ it follows that $LX$ is also a retract of $LY$, since we have $Lr\circ Li\htpy \idfunc$. Therefore we see that the $L$-localization $\modalunit :X\to LX$ is a retract of the $L$-localization $\modalunit : Y\to LY$, as indicated in the diagram
\begin{equation*}
\begin{tikzcd}
X \arrow[r,"i"] \arrow[d,swap,"\modalunit"] & Y \arrow[d,swap,"\modalunit"] \arrow[r,"r"] & X \arrow[d,"\modalunit"] \\
LX \arrow[r,swap,"Li"] & LY \arrow[r,swap,"Lr"] & LX.
\end{tikzcd}
\end{equation*}
Since $\modalunit : Y\to LY$ is an equivalence, and equivalences are closed under retracts, it follows that $\modalunit :X\to LX$ is an equivalence, hence $X$ is $L$-local.
\end{proof}

\begin{defn}
A map $f:A\to B$ is said to be an \define{$L$-equivalence} if $Lf:LA\to LB$ is an equivalence.
\end{defn}

\begin{prp}\label{lem:local_equivalence}
For a map $f : A \to B$ the following are equivalent:
\begin{enumerate}
\item $f$ is an $L$-equivalence.
\item For any $L$-local type $X$, the precomposition map
\begin{equation*}
\precomp{f} : (B \to X) \to (A \to X)
\end{equation*}
is an equivalence.
\end{enumerate}
\end{prp}

\begin{proof}
Suppose first that $f$ is an $L$-equivalence, and let $X$ be $L$-local. Then the square
\begin{equation*}
\begin{tikzcd}
X^{LB} \arrow[r,"\precomp{Lf}"] \arrow[d,swap,"\precomp{\eta}"] & X^{LA} \arrow[d,"\precomp{\eta}"] \\
X^{B} \arrow[r,swap,"\precomp{f}"] & X^{A}
\end{tikzcd}
\end{equation*}
commutes. In this square the two vertical maps are equivalences by the universal property of localization, and the top map is an equivalence since $L f$ is an equivalence. Therefore the map $\precomp{f}:X^B\to X^A$ is an equivalence, as desired.

Conversely, assume that $\precomp{f} : X^B \to X^A$ is an equivalence for every $L$-local type $X$. By the square above it follows that $\precomp{L f}:X^{L B}\to X^{L A}$ is an equivalence for every $L$-local type $X$. The fiber of $L A^{L B}\to L A^{L A}$ at $\idfunc:L A\to L A$ is contractible, so we obtain a retraction $g$ of $L f$. To see that $g$ is also a section observe that the fiber of $L B^{L B}\to L B^{L A}$ at $L f$ is contractible. This fiber contains $(\idfunc[L B],\refl{L f})$. However, we also have an identification $p:\precomp{L f}(L f\circ g)=L f$, since
\begin{equation*}
\precomp{L f}(L f\circ g)\jdeq (L f \circ g)\circ L f\jdeq L f \circ (g\circ L f) = L f.
\end{equation*}
Therefore $(L f\circ g,p)$ is in the fiber of $\precomp{L f}:L B^{L B}\to L B^{L A}$ at $L f$. By the contractibility of the fibers it follows that $(L f\circ g,p)=(\idfunc[L B],\refl{L f})$, so it follows that $L f\circ g=\idfunc[L B]$. In other words, $g$ is both a retraction and a section of $L f$, so $L f$ is an equivalence.
\end{proof}

\begin{cor}\label{cor:localization_lequiv}
Let $f:X\to Y$ be a map into an $L$-local type $Y$. Then the following are equivalent:
\begin{enumerate}
\item $f$ is an $L$-localization.
\item $f$ is an $L$-equivalence.
\end{enumerate}
In particular, the map $\modalunit[X]:X\to LX$ is an $L$-equivalence.
\end{cor}

\begin{cor}\label{cor:localization_retract}
Any retract of an $L$-localization is again an $L$-localization.
\end{cor}

\begin{proof}
Suppose that $f:A\to B$ is a retract of an $L$-localization $l:X\to Y$. Then $B$ is $L$-local by the previous claim.
Moreover, $Lf$ is a retract of $Ll$, which is an equivalence, so $f$ is an $L$-equivalence. Therefore $f$ is an $L$-localization by \cref{cor:localization_lequiv}.
\end{proof}

\begin{prp}\label{thm:rsu-galois}
  Given a reflective subuniverse $L$, a type $X$ is $L$-local if and only if $(\blank \circ f) : (B\to X) \to (A\to X)$ is an equivalence, for any $L$-equivalence $f:A\to B$.
\end{prp}

\begin{proof}
  If $L f$ is an equivalence and $X$ is $L$-local, then by the universal property of $\modalunit$, we have a commutative square
  \[
  \begin{tikzcd}[column sep=large]
    X^{LB} \ar[r,"\blank\circ Lf"] & X^{LA} \\
    X^{B} \ar[r,"\blank\circ f"'] \ar[from=u,"{\blank\circ \modalunit[B]}"'] &
    X^{A} \ar[from=u,"{\blank\circ \modalunit[A]}"]
  \end{tikzcd}
  \]
  in which all but the top map are equivalences; thus so is the top map.

  Conversely, since $L\modalunit[X]$ is an equivalence, the hypothesis implies that
  $(\blank \circ \modalunit[X]) : (L X\to X) \to (X\to X)$
  is an equivalence.
  In particular, its fiber over $\idfunc[X]$ is inhabited, i.e.\ $\modalunit[X]$ has a retraction; hence $X$ is $L$-local.
\end{proof}

\begin{prp}\label{lem:Lequiv_total}
For any family
\begin{equation*}
f:\prd{x:X}P(x)\to Q(x)
\end{equation*}
of $L$-equivalences, the induced map on total spaces
\begin{equation*}
\total{f}:\Big(\sm{x:X}P(x)\Big)\to \Big(\sm{x:X} Q(x)\Big)
\end{equation*}
is an $L$-equivalence.
\end{prp}

\begin{proof}
Note that we have a commuting square
\begin{equation*}
\begin{tikzcd}[column sep=7em]
Y^{\sm{x:X}Q(x)} \arrow[d,swap,"\mathsf{ev\usc{}pair}"] \arrow[r,"\precomp{\total{f}}"] & Y^{\sm{x:X}P(x)} \arrow[d,"\mathsf{ev\usc{}pair}"] \\
\prd{x:X}Y^{Q(x)} \arrow[r,swap,"\lam{g}{x}g(x)\circ f(x)"] & \prd{x:X}Y^{P(x)}
\end{tikzcd}
\end{equation*}
in which all but the top map are known to be equivalences. Therefore the top map is an equivalence, so the claim follows by \cref{lem:local_equivalence}.
\end{proof}

\begin{cor}[Theorem 1.24 of \cite{RijkeShulmanSpitters}]\label{lem:sum_idempotent}
For any family $P:X\to\UU$, the map
\begin{equation*}
\lam{(x,y)}\eta(x,\eta(y)) : \Big(\sm{x:X}P(x)\Big)\to L\Big(\sm{x:X}LP(x)\Big)
\end{equation*}
is a localization.
\end{cor}

\begin{lem}\label{lem:localization_uphtpy}
For any two maps $f,g:LX\to Y$ into an $L$-local type $Y$, the map
\begin{equation*}
(f\htpy g) \to (f\circ \modalunit\htpy g\circ\modalunit)
\end{equation*}
given by $H\mapsto H\cdot\modalunit$, is an equivalence.
\end{lem}

\begin{proof}
The square
\begin{equation*}
\begin{tikzcd}[column sep=huge]
(f=g) \arrow[r,"\apfunc{\precomp{\modalunit}}"] \arrow[d,swap,"\mathsf{htpy\usc{}eq}"] & (f\circ \modalunit=g\circ\modalunit) \arrow[d,"\mathsf{htpy\usc{}eq}"] \\
(f\htpy g) \arrow[r,swap,"\lam{H}H\cdot\modalunit"] & (f\circ\modalunit\htpy g\circ\modalunit)
\end{tikzcd}
\end{equation*}
commutes, and all but one of the maps are known equivalences. Therefore it follows that the bottom map is an equivalence, as claimed.
\end{proof}

\begin{prp}\label{prp:local_pb}
Consider a pullback square
\begin{equation*}
\begin{tikzcd}
C \arrow[d,swap,"p"] \arrow[r,"q"] & B \arrow[d,"g"] \\
A \arrow[r,swap,"f"] & X
\end{tikzcd}
\end{equation*}
with $H:f\circ p\htpy g\circ q$. If $A$, $B$, and $X$ are $L$-local types, then so is $C$.
\end{prp}

\begin{proof}
We have the commuting square
\begin{equation*}
\begin{tikzcd}
(LC\to C) \arrow[d,swap,"\mathsf{cone\usc{}map}"] \arrow[r,"\precomp{\modalunit}"] & (C\to C) \arrow[d,"\mathsf{cone\usc{}map}"] \\
\mathsf{cone}(LC) \arrow[r,densely dotted] & \mathsf{cone}(C)
\end{tikzcd}
\end{equation*}
where the bottom map is the equivalence given by $(\tilde{p},\tilde{q},\tilde{H})\mapsto (\tilde{p}\circ\eta,\tilde{q}\circ\eta,\tilde{H}\cdot \eta)$. This is an equivalence by the assumption that $A$, $B$, and $X$ are local, and an application of \cref{lem:localization_uphtpy}. The two vertical maps are equivalences by the assumption that $C$ is a pullback. Therefore it follows that the top map is an equivalence. By \cref{thm:subuniv-modal}(iii) this suffices to show that $C$ is $L$-local.
\end{proof}

\begin{cor}\label{cor:local_prod}
Cartesian products of $L$-local types are $L$-local.
\end{cor}

\begin{proof}
Suppose that $X$ and $Y$ are $L$-local. Then their cartesian product is a pullback
\begin{equation*}
\begin{tikzcd}
X\times Y \arrow[d,swap,"\proj 1"] \arrow[r,"\proj 2"] & Y \arrow[d] \\
X \arrow[r] & \unit,
\end{tikzcd}
\end{equation*}
Since the unit type is $L$-local for any reflective subuniverse by \cref{cor:unit_local}, the claim follows.
\end{proof}

\begin{cor}\label{lem:rs_idstable}
If $X$ is $L$-local, then so is the identity type $x=y$ for any $x,y:X$.
\end{cor}

\begin{proof}
This follows at once from the pullback square
\begin{equation*}
\begin{tikzcd}
(x=y) \arrow[d] \arrow[r] & \unit \arrow[d,"\mathsf{const}_y"] \\
\unit \arrow[r,swap,"\mathsf{const}_x"] & X,
\end{tikzcd}
\end{equation*}
noting that the unit type is $L$-local for any reflective subuniverse by \cref{cor:unit_local}, and $X$ is $L$-local by assumption.
\end{proof}

\begin{prp}\label{lem:modal-Pi}
Given a reflective subuniverse,
if $P(x)$ is $L$-local for every $x:X$, then so is $\prd{x:X}P(x)$. In particular, the type $Y^X$ is $L$-local whenever $Y$ is $L$-local.
\end{prp}

\begin{proof}
Consider the commuting square
\begin{equation*}
\begin{tikzcd}
\Big(L\Big(\prd{y:X}P(y)\Big)\to \prd{x:X}P(x)\Big) \arrow[r,"\precomp{\modalunit}"] \arrow[d,swap,"\mathsf{swap}"] & \Big(\Big(\prd{y:X}P(y)\Big)\to \prd{x:X}P(x)\Big) \arrow[d,"\mathsf{swap}"] \\
\Big(\prd{x:X} L\Big(\prd{y:X}P(y)\Big)\to P(x)\Big) \arrow[r,"\eqvsym"] & \Big(\prd{x:X}\Big(\prd{y:X}P(y)\Big)\to P(x)\Big)
\end{tikzcd}
\end{equation*}
The vertical maps swap the order of the arguments, and are therefore equivalences. The bottom map is an equivalence by the assumption that each $P(x)$ is $L$-local. By \cref{thm:subuniv-modal}(iii) this suffices to show that $\prd{x:X}P(x)$ is $L$-local.
\end{proof}

\begin{cor}\label{cor:local_equiv}
For any two $L$-local types $X$ and $Y$, the type of equivalences $\eqv{X}{Y}$ is again $L$-local.
\end{cor}

\begin{proof}
The type $\eqv{X}{Y}$ is equivalent to the pullback
  \[
    \begin{tikzcd}[column sep=8em]
      (\eqv{X}{Y}) \arrow[r] \arrow[d] & \unit \arrow[d,"\mathsf{const}_{(\idfunc[X],\idfunc[Y])}"] \\
      Y^X\times X^Y\times X^Y
         \arrow[r,swap,"{(f,g,h) \mapsto (hf,fg)}"] & X^X\times Y^Y.
    \end{tikzcd}
  \]
  of $L$-local types, so it is $L$-local.
\end{proof}

\begin{rmk}
Similarly it follows that $\mathsf{is\usc{}trunc}_k(X)$ is $L$-local for any $L$-local type $X$, and $\mathsf{is\usc{}trunc}_k(f)$ is $L$-local for any map $f:X\to Y$ between $L$-local types.
\end{rmk}

\begin{prp}\label{thm:modal-pres-prod}
For any two types $X$ and $Y$, the map
\begin{equation*}
\modalunit\times\modalunit : X\times Y \to LX \times LY
\end{equation*}
is an $L$-localization.
Thus $L$-localization preserves finite products, for any reflective subuniverse $L$.
\end{prp}

\begin{proof}
First we note that the product $LX\times LY$ is indeed $L$-local by \cref{cor:local_prod}. To see that $\modalunit\times\modalunit$ is an $L$-localization, consider an $L$-local type $Z$. Then we have the commuting square
\begin{equation*}
\begin{tikzcd}[column sep=9em]
(LX\times LY\to Z) \arrow[r,"\precomp{(\modalunit\times\modalunit)}"] \arrow[d,swap,"\mathsf{ev\usc{}pair}"] & (X\times Y\to Z) \arrow[d,"\mathsf{ev\usc{}pair}"] \\
(LX\to (LY\to Z)) \arrow[r,swap,"{\lam{f}{x}{y}f(\modalunit(x),\modalunit(y))}"] & (X\to (Y\to Z)).
\end{tikzcd}
\end{equation*}
The bottom map is an equivalence by the fact that $Z$ and $LY\to Z$ are both $L$-local types, and the vertical maps are equivalences too. Therefore $\modalunit\times\modalunit$ is an $L$-localization.
\end{proof}

\begin{cor}\label{lem:modal-pres-prop}
Given any reflective subuniverse, the modal operator preserves propositions.
\end{cor}
\begin{proof}
  A type $P$ is a proposition if and only if the diagonal $P\to P\times P$ is an equivalence.
  The result then follows from \cref{thm:modal-pres-prod}.
\end{proof}

By contrast, localizations, and even modalities, do not generally preserve $n$-types for any $n\ge 0$.
For instance, the ``shape'' modality of~\cite{shulman2015brouwer} takes the topological circle, which is a 0-type, to the homotopical circle, which is a 1-type, and the topological 2-sphere, which is also a 0-type, to the homotopical 2-sphere, which is (conjecturally) not an $n$-type for any finite $n$.

\section{The reflective subuniverse of separated types}\label{sec:separated}

\begin{defn}
Consider a subuniverse $P:\UU\to\prop$. We say that a type $X$ is \define{$P$-separated} if the identity types of $X$ are $P$-types. We write $P'$ for the subuniverse of $P$-separated types.
\end{defn}

\begin{eg}
We define $\istrunc{} : \Z_{\geq-2}\to\UU\to\UU$ by induction on $k:\Z_{\geq -2}$, taking
\begin{align*}
\istrunc{-2}(A) & \defeq \iscontr(A) \\
\istrunc{k+1}(A) & \defeq \prd{x,y:A}\istrunc{k}(\id{x}{y}).\qedhere
\end{align*}
For any type $A$, we say that $A$ is \define{$k$-truncated}, or a \define{$k$-type}, if there is a term of type $\istrunc{k}(A)$. We say that a map $f:A\to B$ is $k$-truncated if its fibers are $k$-truncated.

In other words, the subuniverse of $(n+1)$-truncated types is precisely the subuniverse of \define{$n$-separated types}, i.e. the subuniverse of types whose identity types are $n$-truncated.
\end{eg}

\begin{defn}
Let $L$ be a reflective subuniverse and let $X : \UU$ be a type.
An \define{$L'$-localization} of a type $X$ is a localization with respect to the subuniverse of $L$-separated types.
\end{defn}

In other words, a type $X$ is $L$-separated if its diagonal $\Delta:X\to X\times X$ is classified by $\UU_L$.

\begin{eg}\label{example:truncationisseparated}
Given $n \geq -2$, the subuniverse of $(n+1)$-truncated types is precisely the subuniverse of separated types for the reflective subuniverse of $n$-truncated types.
\end{eg}

\begin{lem}
Any $L$-local type is $L$-separated.
\end{lem}

\begin{proof}
Immediate by \cref{lem:rs_idstable}.
\end{proof}

\begin{lem}
Any small subtype of an $L$-separated type is again $L$-separated. In particular, any small proposition is $L$-separated.
\end{lem}

The following lemma can be proven directly. However, it also follows once we have shown that the subuniverse of $L$-separated types is a reflective subuniverse, so we will omit the proof.

\begin{lem}
The subuniverse of $L$-separated types is closed under pullbacks, retracts, and dependent products of families of $L$-separated types.
\end{lem}

\begin{rmk}[Move to modalities]
If $L$ is closed under dependent sums, then $L'$ is also closed under dependent sums,
    by the characterization of identity types of dependent sums~\cite[Theorem~2.7.2]{hottbook}.
    So, given that separated types form a reflective subuniverse, it will follow that if $L$ is a modality,
    then so is $L'$.
\end{rmk}

\begin{prp}\label{lemma:separatedpluslocalisseparated}
If $X$ is an $L$-separated type and $P:X\to \UU_L$ is a family of $L$-local types, then the type
$\sm{x:X}P(x)$ is $L$-separated.
\end{prp}

\begin{proof}
For any $(x,p)$ and $(y,q)$ in $\sm{x:X}P(x)$, the type $(x,p)=(y,q)$ is equivalent to the pullback
\[
  \begin{tikzcd}[column sep=huge]
    (x,p)=(y,q) \arrow[r] \arrow[d] & \unit \arrow[d,"q"] \\
    (x=y) \arrow[r,swap,"\transfib{P}{-}{p}"] & P(y)
  \end{tikzcd}
\]
of $L$-local types, so it is $L$-local.
\end{proof}

\begin{cor}\label{proposition:inductionLseparated}
Suppose $l':X\to Y'$ is an $L'$-localization, and let $P:L'X \to \UU_L$ be a family of $L$-local types.
Then the precomposition map
\[
    \precomp{l'}: \prd{y':Y'} P(y') \simeq \prd{x : X} P(l'(x)).
\]
is an equivalence.
\end{cor}

\begin{proof}
This follows immediately from \cref{theorem:generalized-induction}.
\end{proof}

\begin{prp}\label{prop:UU_L-is-L-separated}
Any small subtype of the subuniverse $\UU_L$ is $L$-separated.
\end{prp}

\begin{proof}
    Note that for any two $L$-local types $A$ and $B$ we have $\eqv{(A=B)}{(\eqv{A}{B})}$ by univalence and the
    fact that being $L$-local is a mere proposition. Therefore the claim follows from \cref{cor:local_equiv}.
\end{proof}

The only thing that prevents $\UU_L$ from actually being $L$-separated is the fact that $\UU_L$ is not small. In other words, we could say that $\UU_L$ is \define{essentially $L$-separated}. Using the fact that the image of a small type into $\UU_L$ is essentially small, the condition of being essentially $L$-separated suffices to eliminate from $L'X$ into $\UU_L$.

\begin{lem}\label{lemma:extendtoUL}
Consider an $L'$-localization $l':X\to Y'$. Then any type family $P:X\to\UU_L$ of $L$-local types has a unique extension along $l'$
\begin{equation*}
\begin{tikzcd}
X \arrow[d,swap,"{l'}"] \arrow[r,"P"] & \UU_L. \\
Y' \arrow[ur,densely dotted]
\end{tikzcd}
\end{equation*}
\end{lem}

\begin{proof}
    We prove the first form of the statement.
    By \cref{prop:UU_L-is-L-separated}, the identity types of $\UU_L$ are
    equivalent to small types, i.e., $\UU_L$ is a locally small type.
    By the join construction~\cite{joinconstruction}, the image of $P$
    can be taken to be a small type $I$ in $\UU$, so there is a factorization
    of $P$ into a surjection $\hat{P} : X \to I$ followed by
    an embedding $i : I \to \UU_L$:
\begin{equation*}
\begin{tikzcd}
X \arrow[d,swap,"\modalunit'"] \arrow[r,"P"] \arrow[dr,swap,"\hat{P}"] & \UU_L \\
L'X & I \arrow[u,swap,"i"]
\end{tikzcd}
\end{equation*}

    Since the identity types of $I$ are equivalent to identity types
    of $\UU_L$, and $I$ is small, it follows that the identity types of $I$ are actually $L$-local.
    This means that $I$ is an $L$-separated type, so we can extend $\hat{P}$ to $L' X$
    giving us the desired extension of $P$ by composing with $i$.

    Since $X \to L'X$ is surjective (\cref{thm:separation_characterization}),
    any such extension must factor through the image $I$.
    So uniqueness follows from the universal property of $L'$-localization.
\end{proof}

Before we show that $L'$-localizations exist for any type $X$, we characterize them.
To establish our characterization of $L'$-localizations, we need the following simple lemma, that allows us to construct unique extensions.

\begin{lem}\label{lem:unique_extension}
Let $g:A\to B$ and $f:A\to C$ be maps for which we have a unique extension
\[
  \begin{tikzcd}
    \fib{g}{b} \arrow[r,"f\circ\proj 1"] \arrow[d] & C \\
    \unit \arrow[ur,densely dotted]
  \end{tikzcd}
\]
for every $b:B$.
Then $f$ extends uniquely along $g$.
\end{lem}

\begin{proof}
By assumption we have
\[
  \prd{b:B}\iscontr\Big(\sm{c:C}\prd{a:A}{p:g(a)=b} f(a)=c\Big).
\]
The center of contraction gives us an extension
\[
  \begin{tikzcd}
    A \arrow[r,"f"] \arrow[d,swap,"g"] & C \\
    B \arrow[ur,densely dotted,swap,"\tilde{f}"]
  \end{tikzcd}
\]
and its uniqueness follows from the contraction.
\end{proof}

\begin{thm}\label{thm:separation_characterization}
Consider a map $l':X\to Y'$, where $Y'$ is assumed to be $L$-separated. Then the following are equivalent:
\begin{enumerate}
\item The map $l':X\to Y'$ is an $L'$-localization.
\item The map $l':X\to Y'$ is surjective, and for each $x,y:X$, the map
\begin{equation*}
\apfunc{l'}:(x=y)\to (l'(x)=l'(y))
\end{equation*}
is an $L$-localization.
\end{enumerate}
\end{thm}

\begin{proof}
First, suppose that $l':X\to Y'$ is an $L'$-localization. To see that $l'$ is surjective, we note that $\im(l')$ is $L$-separated since it is a subtype of $Y'$, so the surjective map $q:X\to\im(l')$ extends uniquely along $l'$.
\[
  \begin{tikzcd}
    X \arrow[r,"q"] \arrow[d,swap,"l'"] & \im(l') \\
    Y' \arrow[ur,densely dotted,swap,"h"]
  \end{tikzcd}
\]
By the universal property of $L'$-localization it follows that $h$ is a section of the image inclusion $\im(l')\to Y'$. In particular, the image inclusion is both surjective and an embedding, so it must be an equivalence. It follows that $l'$ is surjective.

Next, we need to show that for each $x,y:X$, the map
\begin{equation*}
\apfunc{l'}:(x=y)\to (l'(x)=l'(y))
\end{equation*}
is an $L$-localization. Fix $x : X$.
Since $l'$ is an $L'$-localization, there is a unique extension
\begin{equation*}
\begin{tikzcd}[column sep=huge]
X \arrow[r,"y\mapsto L(x=y)"] \arrow[d,swap,"{l'}"] & \UU_L. \\
Y' \arrow[ur,densely dotted,swap,"P"]
\end{tikzcd}
\end{equation*}
The family $P$ comes equipped with a point $p_0:P(l'(x))$ that is induced by $\eta(\refl{x}):L(x=x)$. Moreover, by the fact that $P$ extends $y\mapsto L(x=y)$ we have a pullback square
\begin{equation*}
\begin{tikzcd}
\sm{y:X}L(x=y) \arrow[d] \arrow[r] & \sm{y':Y'}P(y') \arrow[d] \\
X \arrow[r,swap,"{l'}"] & Y'
\end{tikzcd}
\end{equation*}
Thus we see that our claim follows by \cref{thm:id_fundamental}, once we show that the total space of $P$ is contractible.

For the center of contraction of $\sm{y:L'X}P(y)$ we take $(l'(x),\eta(\refl{x}))$.
It remains to construct a contraction
\begin{equation*}
\prd{y':Y'}{p:P(y')}(l'(x),\eta(\refl{x}))=(y',p).
\end{equation*}
Since the fibers of $P$ are $L$-local, it follows by \cref{lemma:separatedpluslocalisseparated} that the total space of $P$ is $L$-separated. Therefore we obtain by \cref{lem:modal-Pi} that the type
\[
  \prd{p:P(y')} (l'(x),\eta(\refl{x}))=(y',p)
\]
is $L$-local for every $y':Y'$. Thus \cref{proposition:inductionLseparated} reduces the problem to
constructing a term of type
\begin{equation*}
\prd{y:X}{p:L(x=y)}(l'(x),\eta(\refl{x}))=(l'(y),p).
\end{equation*}

Furthermore, for $y : X$ we have equivalences
\begin{align*}
    \Big(\sm{p:L(x=y)}(l'(x),\eta(\refl{x}))=(l'(y),p)\Big)
 & \eqvsym \Big(\sm{p:L(x=y)}{\alpha:l'(x)=l'(y)} \trans{\alpha}{\eta(\refl{x})} = p \Big) \\
 & \eqvsym \sm{\alpha:l'(x) = l'(y)} \unit \\
 & \eqvsym l'(x) = l'(y),
\end{align*}
where the last type is clearly $L$-local.
So we can apply \cref{theorem:generalized-induction} to reduce the problem to
the problem of constructing a term of type
\begin{equation*}
    \prd{y:X}{p:x=y}(l'(x),\eta(\refl{x}))=(l'(y),\eta(p)).
\end{equation*}
This can be done by a simple application of path induction. This completes the proof that (i) implies (ii).

To show that (ii) implies (i), assume that $l'$ is surjective, and that for every $x,y:X$ the map
\begin{equation*}
\apfunc{l'}:(x=y)\to (l'(x)=l'(y))
\end{equation*}
is an $L$-localization. Our goal to show that $l'$ satisfies the universal property of $L'$-localization, so assume $f : X \to Z$ is a map into an $L$-separated type $Z$.

By \cref{lem:unique_extension}, it is enough to show that $f$ restricts to a unique constant map
on the fibers of $l'$. This means that we must show that
\[
  \sm{z:Z}\prd{x:X} (l'(x)=y') \lra (f(x)=z)
\]
is contractible for every $y':Y'$.
Since this is a mere proposition, and $l'$ is surjective, we can assume that
$y' = l'(y)$.  In other words, it suffices to show that
\[
  \sm{z:Z}\prd{x:X} (l'(x)=l'(y)) \lra (f(x)=z)
\]
is contractible for every $y:X$.

Since $Z$ is assumed to be $L$-separated and $\mathsf{ap}_{l'}$ is assumed to be an $L$-localization,
this type is equivalent to
\[
  \sm{z:Z}\prd{x:X} (x=y) \lra (f(x)=z)
\]
and it is easy to see that this is a contractible type by applying the contractibility of
the total space of the path fibration twice.
\end{proof}

Our final goal for this section is to show that $L'$ is a reflective subuniverse, i.e.~that there is an $L'$-localization for every type $X:\UU$.
We will use a `local version' of the type theoretic Yoneda Lemma.

% Variable names chosen to match the place where we use this.
\begin{lem}\label{lemma:local_yoneda}
For each $y:X$ and each $P:X\to \UU_L$, the map
\[
  \mathsf{ev\usc{}locrefl}:\Big(\prd{z:X}L(y=z)\to P(z)\Big) \lra P(y)
\]
given by $f\mapsto f(y,\eta(\refl{y}))$ is an equivalence.
\end{lem}

\begin{proof}
By the universal property of $L(y=z)$ and identity elimination,
the map in the statement can be factored as follows:
\begin{align*}
\Big(\prd{z:X}L(y=z)\to P(z)\Big) & \simeq \Big(\prd{z:X}(y=z)\to P(z)\Big) \\
& \simeq P(y).\qedhere
\end{align*}
\end{proof}

\begin{thm}\label{thm:Lsep}
For any reflective subuniverse $L$, the subuniverse of $L$-separated types is again reflective. We will write
\begin{equation*}
\modalunit':X\to L'X
\end{equation*}
for the $L'$-localization of a type $X$.
\end{thm}

\begin{proof}
Fix a type $X : \UU$. Let $\mathcal{Y}_L:X\to (X\to\UU)$ be given by
\[
\mathcal{Y}_L(x,y)\defeq L(x=y).
\]
We would like to define $L' X$ to be $\im(\mathcal{Y}_L)$, but this is a subtype of
$X \to \UU$, so it is not small (i.e., it does not live in $\UU$).
However, since $\UU$ is locally small, so is $X \to \UU$.
Thus the join construction~\cite{joinconstruction} implies that the image
is equivalent to a small type which we denote $L' X$.
This comes equipped with a surjective map
\[
\eta':X \lra L'X,
\]
which we take to be the unit of the reflective subuniverse.

To show that $\eta'$ is a localization, we apply \cref{thm:separation_characterization}.
First we show that $L' X$ is $L$-separated.  Since $\eta'$ is surjective
and being $L$-local is a proposition, it is enough to show that
$\eta'(x) = \eta'(y)$ is $L$-local for $x$ and $y$ in $X$.
Since $L' X$ embeds in $X \to \UU$, we have an equivalence between
$\eta'(x) = \eta'(y)$ and $(\lambda z . L(x = z)) = (\lambda z . L(y = z))$.
The latter is equivalent to $\prd{z:X} L(x = z) = L(y = z)$, which
is $L$-local by \cref{prop:UU_L-is-L-separated}.

It remains to show that the canonical map $L(x=y)\to (\eta'(x)=\eta'(y))$ is an equivalence.
By the above argument, combined with univalence,
the problem reduces to showing that the canonical map
\[
    L(x=y) \lra \left(\prd{z:X} L(x=z) \simeq L(y=z)\right)\]
is an equivalence.
Using symmetry of equivalences, it suffices to show that the map
\[
    L(x=y) \lra \left(\prd{z:X} L(y=z) \simeq L(x=z)\right)
\]
is an equivalence.
Moreover, since the forgetful map from equivalences to maps is an embedding,
it is enough to show that the composite map
\[
    \alpha_{x,y} : L(x=y) \lra \left(\prd{z:X} L(y=z) \to L(x=z)\right)
\]
is an equivalence.
Indeed, if $i$ is an embedding and $i \circ g$ is an equivalence,
then $i$ is surjective.  Therefore $i$ is an equivalence and hence so is $g$.

By the local Yoneda Lemma~\ref{lemma:local_yoneda}, with $P(z) \defeq L(x = z)$, there is an equivalence
\[
\beta_{x,y}: L(x=y) \lra \Big(\prd{z:X} L(y=z) \to L(x=z)\Big)
\]
which sends $p : L(x = y)$ to the unique function $f$ such that
$f(x, \eta(\refl{x})) = p$.
So it suffices to show that $\alpha_{x,y} = \beta_{x,y}$.
By the universal property of $L(x=y)$, it is enough to show that
$\alpha_{x,y} \circ \eta = \beta_{x,y} \circ \eta$ as maps
$(x=y) \to \big(\prd{z:X} L(y=z) \to L(x=z)\big)$.
Letting $x$ and $y$ vary and using path induction, we reduce the
problem to showing that $\alpha_{x,x}(\eta(\refl{x})) = \beta_{x,x}(\eta(\refl{x}))$.

Since $\alpha_{x,y}$ is defined by path induction, it is easy to see
that $\alpha_{x,x}(\eta(\refl{x}))$ is equal to $\lam{z}\idfunc[L(x=z)]$.
On the other hand, $\beta_{x,x}(\eta(\refl{x}))$ is the unique function $f$ such that
$f(x, \eta(\refl{x})) = \eta(\refl{x})$.
Therefore, this $f$ must also equal $\lam{z}\idfunc[L(x=z)]$,
showing that $\alpha_{x,x}(\eta(\refl{x})) = \beta_{x,x}(\eta(\refl{x}))$.
\end{proof}

\begin{thm}\label{thm:truncation}
For each $k\geq -2$, the subuniverse of $k$-truncated types is reflective.
\end{thm}

\begin{proof}
The subuniverse of contractible types is obviously reflective, it's localization is just the constant function $\lam{X}\unit$ mapping every type to the unit type. Since the subuniverse of $(k+1)$-truncated types is precisely the subuniverse of $k$-separated types, the claim follows inductively by \cref{thm:Lsep}.
\end{proof}

\section{\texorpdfstring{$L$}{L}-local maps}

\begin{defn}
A map $f:A\to B$ is said to be \define{$L$-local} if its fibers are $L$-local.
\end{defn}

\begin{thm}
Let $B$ be a type family over $A$. Then the following are equivalent:
\begin{enumerate}
\item For each $x:A$ the type $B(x)$ is $L$-local.
\item The projection map
\begin{equation*}
\proj 1 : \Big(\sm{x:A}B(x)\Big)\to A
\end{equation*}
is an $L$-local map.
\end{enumerate}
\end{thm}

\begin{proof}
Immediate from the equivalences $\eqv{B(x)}{\fib{\proj 1}{x}}$.
\end{proof}

\begin{thm}\label{thm:trunc_ap}
Let $f:A\to B$ be a map. The following are equivalent:
\begin{enumerate}
\item The map $f$ is $L'$-local.
\item For each $x,y:A$, the map
\begin{equation*}
\apfunc{f} : (x=y)\to (f(x)=f(y))
\end{equation*}
is $L$-local.
\item The diagonal $\delta_f:A\to A\times_B A$ of $f$ is $L$-local.
\end{enumerate}
\end{thm}

\begin{proof}
First we show that for any $s,t:\fib{f}{b}$ there is an equivalence
\begin{equation*}
\eqv{(s=t)}{\fib{\apfunc{f}}{\ct{\proj 2(s)}{\proj 2(t)^{-1}}}}
\end{equation*}
We do this by $\Sigma$-induction on $s$ and $t$, and then we calculate using basic manipulations of identifications that
\begin{align*}
(\pairr{x,p}=\pairr{y,q}) & \eqvsym \sm{r:x=y} \mathsf{tr}_{f(\blank)=b}(r,p)=q \\
& \eqvsym \sm{r:x=y} \ct{\ap{f}{r}^{-1}}{p}=q \\
& \eqvsym \sm{r:x=y} \ap{f}{r}=\ct{p}{q^{-1}} \\
& \jdeq \fib{\apfunc{f}}{\ct{p}{q^{-1}}}.
\end{align*}
By these equivalences, it follows that if $\apfunc{f}$ is $L$-local, then for each $s,t:\fib{f}{b}$ the identity type $s=t$ is an $L$-local type.

For the converse, note that we have equivalences
\begin{align*}
\fib{\apfunc{f}}{p} & \eqvsym ((x,p)=(y,\refl{f(y)})).
\end{align*}
Therefore it follows that if $f$ is $L'$-local, then the identity type $(x,p)=(y,\refl{f(y)})$ in $\fib{f}{f(y)}$ is $L$-local for any $p:f(x)=f(y)$, and therefore $\fib{\apfunc{f}}{p}$ is $L$-local.
\end{proof}

\begin{thm}
Let $f:\prd{x:A}B(x)\to C(x)$ be a fiberwise transformation. Then the following are equivalent:
\begin{enumerate}
\item For each $x:A$ the map $f(x)$ is $L$-local.
\item The induced map
\begin{equation*}
\total{f}:\Big(\sm{x:A}B(x)\Big)\to\Big(\sm{x:A}C(x)\Big)
\end{equation*}
is $L$-local.
\end{enumerate}
\end{thm}

\begin{proof}
This follows directly from \cref{lem:fib_total}.
\end{proof}

\section{Quasi-left-exactness of \texorpdfstring{$L'$}{L'}-localization}\label{ss:lex}

We now explain how $L$ and $L'$ together behave similarly to a \define{lex modality},
i.e., a modality that preserves pullbacks.
Theorem~3.1 of \cite{RijkeShulmanSpitters} gives 13 equivalent characterizations of a lex modality,
and it turns out that these hold for any reflective subuniverse
if the modal operator is replaced by $L$ and $L'$ in the appropriate way.
The propositions in this section show this for parts (ix), (x), (xii) and (xi)
of Theorem~3.1, respectively.
The proofs use the dependent elimination of $L'$ in a crucial way,
but do not use the specific construction of $L'$-localization, just the existence.

Before proving the next result,
we need a lemma, which follows directly from the dependent elimination of $L'$.

\begin{lem}\label{lemma:Lequivalencetotalspaces}
Let $P:L'X\to \UU$ be a type family over $L'X$.
Then the map
\begin{equation*}
f:\Big(\sm{x:X} P(\eta'(x))\Big)\to \Big(\sm{y:L'X}P(y)\Big)
\end{equation*}
given by $(x,p)\mapsto (\eta'(x),p)$ is an $L$-equivalence.
\end{lem}

\begin{proof}
For any $L$-local type $Z$ we have the commuting square
\begin{equation*}
\begin{tikzcd}[column sep=9em]
\Big(\Big(\sm{y : L'X} P(y)\Big)\to Z\Big) \arrow[r,"{\lam{f}{(x,p)}f(\eta'(x),p)}"] \arrow[d,swap,"\mathsf{ev\usc{}pair}"] & \left(\sm{x:X} P(\eta' x)\right) \to Z \arrow[d,"\mathsf{ev\usc{}pair}"] \\
\prd{y : L'X} (P(y) \to Z) \arrow[r,swap,"{\lam{f}{x}{y}f(\eta'(x),y)}"] & \prd{x : X} (P(\eta' x) \to Z)
\end{tikzcd}
\end{equation*}
The bottom map is an equivalence by \cref{proposition:inductionLseparated}, using that $Z$ and $P(y) \to Z$ are $L$-local.
The two vertical maps are also equivalences, so it follows that the top map is an equivalence. The claim now follows from \cref{lem:local_equivalence}.
\end{proof}

\begin{prp}\label{remark:preservationpullbacks} % like RSS Thm 3.1 (x)
Consider a commuting cube of the form
\begin{equation*}
\begin{tikzcd}
& A\times_X B \arrow[d,densely dotted] \arrow[dl] \arrow[dr] \\
A \arrow[d,swap,"\eta'"] & L'A\times_{L'X} L'B \arrow[dl] \arrow[dr] & B \arrow[dl,crossing over] \arrow[d,"\eta'"] \\
L'A \arrow[dr] & X \arrow[from=ul,crossing over] \arrow[d,swap,"\eta'"] & L'B \arrow[dl] \\
& L'X.
\end{tikzcd}
\end{equation*}
Then the map $A\times_X B\to L'A\times_{L'X} L'B$ is an $L$-equivalence.
\end{prp}

\begin{proof}
Consider the following commuting square
\begin{equation*}
\begin{tikzcd}
\sm{x:A}{y:B}f(x)=g(y) \arrow[r,densely dotted] \arrow[d] & \sm{x':L'A}{y':L'B} L'f(x')=L'g(y') \\
\sm{x:A}{y:B}\eta'(f(x))=\eta'(g(y)) \arrow[r] & \sm{x:A}{y:B}L'f(\eta'(x))=L'g(\eta'(y)) \arrow[u]
\end{tikzcd}
\end{equation*}
In this square, the downwards morphism on the left is the induced map on total spaces of the map $\apfunc{\eta'}:(f(x)=g(y))\to (\eta'(f(x))=\eta'(g(y)))$, which is an $L$-equivalence by \cref{thm:separation_characterization} and \cref{lem:Lequiv_total}. The bottom map is an equivalence, obtained from the naturality squares $\eta'\circ f\htpy L'f\circ \eta'$ and $\eta'\circ g\htpy L'g\circ \eta'$. In particular, it is an $L$-equivalence. The upwards map on the right is an $L$-equivalence by \cref{lemma:Lequivalencetotalspaces}. Therefore, the asserted map is a composite of $L$-equivalences, so it is also an $L$-equivalence.
\end{proof}

As a consequence we get a result about the preservation of certain fiber sequences.

\begin{cor}\label{corollary:preservationfibersequences2}
    Given a fiber sequence $F \hookrightarrow E \twoheadrightarrow B$, there is a map of fiber sequences
\begin{equation*}
\begin{tikzcd}
F \arrow[r,hookrightarrow] \arrow[d] & E \arrow[r,->>,"p"] \arrow[d,swap,"\eta'"] & B \arrow[d,"\eta'"] \\
F' \arrow[r,hookrightarrow] & L'E \arrow[r,->>,swap,"L'p"] & L'B
\end{tikzcd}
\end{equation*}
    in which the left vertical map is an $L$-equivalence.\qed
\end{cor}

\section{Connected maps}
\label{sec:connected-maps}

\begin{defn}
A map $f:A\to B$ is said to be \define{$L$-connected} if $L(\fib{f}{b})$ is contractible for every $b:B$. In particular, a type $A$ is $L$-connected if and only if $LA$ is contractible.
\end{defn}

In the following proposition we characterize $L'$-connected types. We will establish a similar claim for maps in \cref{cor:L'connected_maps}

\begin{prp}\label{lem:L'connected_types}
A type $A$ is $L'$-connected if and only if $A$ is merely inhabited (i.e.~$\brck{A}$ holds), and the identity types of $A$ are $L$-connected.
\end{prp}

\begin{proof}
$A$ is $L'$-connected if and only if $A\to\unit$ is an $L'$-localization. By \cref{thm:separation_characterization} this holds if and only if $A\to\unit$ is surjective, and the maps $(x=y)\to \loopspace\unit$ are $L$-localizations --- in other words: if and only if $A$ is merely inhabited and the identity types of $A$ are $L$-connected.
\end{proof}

In the following proposition we provide two equivalent conditions to a map being $L$-connected.

\begin{prp}\label{prop:nconnected_tested_by_lv_n_dependent types}
Consider a map $f:A\to B$. The following are equivalent:
\begin{enumerate}
\item $f$ is $L$-connected.\label{item:conntest1}
\item For every family $P:B\to \UU_L$ of $L$-local types, the map
\begin{equation*}
\lam{s} s\circ f :\Parens{\prd{b:B} P(b)}\to\Parens{\prd{a:A}P(f(a))}.
\end{equation*}
is an equivalence.\label{item:conntest2}
\item For every family $P:B\to \UU_L$ of $L$-local types, the map
\begin{equation*}
\lam{s} s\circ f :\Parens{\prd{b:B} P(b)}\to\Parens{\prd{a:A}P(f(a))}.
\end{equation*}
has a section.\label{item:conntest3}
\end{enumerate}
\end{prp}

\begin{proof}
First suppose $f$ is $L$-connected and let $P:B\to \UU_L$. Then the map
\begin{equation*}
\lam{p}\mathsf{const}_p : P(b)\to (\fib{f}{b}\to P(b))
\end{equation*}
is an equivalence for every $b:B$, since $L(\fib{f}{b})$ is assumed to be contractible.
Therefore we obtain a commuting square
\begin{equation*}
\begin{tikzcd}[column sep=large]
\prd{b:B}P(b) \arrow[r] \arrow[d] & \prd{a:A}P(f(a)) \\
\prd{b:B}\big(\fib{f}{b}\to P(b)\big) \arrow[r,swap,"\mathsf{evpair}"] & \prd{b:B}{a:A}(f(a)=b)\to P(b) \arrow[u,swap,"\evrefl"]
\end{tikzcd}
\end{equation*}
in which three out of four maps are known equivalences. The remaining map must therefore also be an equivalence.

Thus,~\ref{item:conntest1}$\Rightarrow$\ref{item:conntest2}, and clearly~\ref{item:conntest2}$\Rightarrow$\ref{item:conntest3}.
To show~\ref{item:conntest3}$\Rightarrow$\ref{item:conntest1}, let
$P(b)\defeq L(\fib{f}b)$.
Then~\ref{item:conntest3} yields a map $c:\prd{b:B} L(\fib{f}b)$ with
$c(f(a))=\modalunit{\pairr{a,\refl{f(a)}}}$. To show that each $L(\fib{f}b)$ is contractible, we will show that $c(b)=w$ for any $b:B$ and $w:L(\fib{f}b)$.
In other words, we must show that the identity function $L(\fib{f}b) \to L(\fib{f}b)$ is equal to the constant function at $c(b)$.
By the universal property of $L(\fib{f}b)$, it suffices to show that they become equal when precomposed with $\modalunit[\fib{f}b]$, i.e.\ we may assume that $w = \modalunit\pairr{a,p}$ for some $a:A$ and $p:f(a)=b$.
But now path induction on $p$ reduces our goal to the given $c(f(a))=\modalunit{\pairr{a,\refl{f(a)}}}$.
\end{proof}

\begin{cor}\label{connectedtotruncated}
A type $A$ is $L$-connected if and only if the ``constant functions'' map
$
  B \to (A\to B)
$
is an equivalence for every modal type $B$.\qed
\end{cor}

Dually, we will prove in \cref{thm:detect-right-by-fibers} that when $L$ is a modality, if this holds for all $L$-connected $A$ then $B$ is $L$-local.

\begin{cor}
If $f:A\to B$ is an $L$-connected map into an $L$-local type $B$, then $f$ is an $L$-localization. (The converse only holds when $L$ is a modality.)
\end{cor}

\begin{prp}\label{cor:L'equivalenceisLconnected}
Consider a map $f:A\to B$.
\begin{enumerate}
\item If $f$ is an $L'$-equivalence, then $f$ is $L$-connected.
\item If $f$ is $L$-connected, then $f$ is an $L$-equivalence.
\end{enumerate}
\end{prp}

\begin{proof}
The first statement is a direct consequence of \cref{corollary:preservationfibersequences2}, since we get for each $b:B$ a map of fiber sequences
\begin{equation*}
\begin{tikzcd}
\fib{f}{b} \arrow[r] \arrow[d] & A \arrow[r,"f"] \arrow[d,swap,"\eta'"] & B \arrow[d,"\eta'"] \\
\fib{L'f}{\eta'b} \arrow[r] & L'A \arrow[r,swap,"L'f"] & L'B
\end{tikzcd}
\end{equation*}
in which the induced map $\fib{f}{b}\to\fib{L'f}{\eta'b}$ is an $L$-equivalence. Since $L'f$ is an equivalence, it follows that $\fib{L'f}{\eta'b}$ is contractible, so we conclude that $\fib{f}{b}$ is $L$-connected. It follows that $f$ is $L$-connected.

For the second statement, we observe that if $f$ is $L$-connected, then by \cref{prop:nconnected_tested_by_lv_n_dependent types} it induces an equivalence
\begin{equation*}
\precomp{f} : (B\to X)\to (A\to X)
\end{equation*}
for every $L$-local type $X$. Therefore we conclude by \cref{lem:local_equivalence} that $f$ is an $L$-equivalence.
\end{proof}

\begin{prp}\label{thm:rsu-compose-cancel} % like RSS Thm 3.1 (xi)
Consider a commuting triangle
\begin{equation*}
\begin{tikzcd}[column sep=tiny]
A \arrow[rr,"h"] \arrow[dr,swap,"f"] & & B \arrow[dl,"g"] \\
& X
\end{tikzcd}
\end{equation*}
\begin{enumerate}
\item If $h$ is $L$-connected, then the following are equivalent:
\begin{enumerate}
\item $f$ is $L$-connected.
\item $g$ is $L$-connected.
\end{enumerate}
\item If $f$ is $L'$-connected, then the following are equivalent:
\begin{enumerate}
\item $g$ is $L'$-connected.
\item $h$ is $L$-connected.
\end{enumerate}
In particular, $g$ is $(n+1)$-connected if and only if $h$ is $n$-connected, assuming that $f$ is $(n+1)$-connected.
\end{enumerate}
\end{prp}

\begin{proof}
For the first statement suppose that $h$ is $L$-connected.
  For any $z:C$ we have
  \begin{align*}
    L(\fib{g\circ h}{z})
    & \eqvsym
      L(\sm{p:\fib{g}{z}}\fib{h}{\proj1(p)}) \\
    & \eqvsym
      L(\sm{p:\fib{g}{z}}L(\fib{h}{\proj1(p)})) \\
    & \eqvsym
      L(\sm{p:\fib{g}{z}}\unit) \\
    & \eqvsym
      L(\fib{g}{z}).
  \end{align*}
  using the fact that $h$ is $L$-connected.
  Thus, one is contractible if and only if the other is. We conclude that $f$ is $L$-connected if and only if $g$ is.

For the second statement, suppose that $f$ is $L'$-connected.
    If $g$ is $L'$-connected, then both $g\circ h$ and $g$ are $L'$-equivalences,
    and thus $h$ is an $L'$-equivalence. Then \cref{cor:L'equivalenceisLconnected}
    implies that $h$ is $L$-connected.

    For the converse, notice that taking fibers over each $x:X$ reduces the problem
    to showing that given an $L$-connected map $h : A \to B$
    such that $A$ is $L'$-connected, it follows that $B$ is $L'$-connected.

    Since $L'A$ is contractible, it follows that $L'B$ is contractible if and only if $L'h:L'A\to L'B$ is an equivalence.
    Therefore it suffices to show that the fibers of $L'h$ are contractible. Moreover, since $\eta':B\to L'B$ is a surjective map by \cref{thm:separation_characterization}, it is enough to show that $\fib{L'h}{\eta'(b)}$ is contractible for every $b:B$.
First we observe that, $\eqv{\fib{L'h}{\eta'(b)}}{\loopspace{L'B,\eta'(b)}}$ since $L'A$ is contractible.
    Now we observe using \cref{corollary:preservationfibersequences2} that we have for every $b:B$ a morphism of fiber sequences
\begin{equation*}
\begin{tikzcd}
\fib{h}{b} \arrow[r,hookrightarrow] \arrow[d,densely dotted] & A \arrow[d,swap,"\eta'"] \arrow[r,"h"] & B \arrow[d,"\eta'"] \\
\loopspace{L'B,\eta'(b)} \arrow[r,hookrightarrow] & L'A \arrow[r,swap,"L'h"] & L'B
\end{tikzcd}
\end{equation*}
in which the map on the left is an $L$-equivalence. However, the type $\loopspace{L'B,\eta'(b)}$ is $L$-local, so it follows that the map
\begin{equation*}
\fib{h}{b}\to \loopspace{L'B,\eta(b)}
\end{equation*}
is an $L$-localization. Now it follows by our assumption that $h$ is $L$-connected that $\loopspace{L'B,\eta(b)}$ is contractible. We conclude that $\fib{L'h}{\eta'(b)}$ is contractible, and therefore that $L'B$ is contractible.
\end{proof}

\begin{rmk}
In general it is not true that if $g$ and $g\circ h$ are $\modal$-connected then $h$ is; this is one of the equivalent characterizations of lex modalities (Theorem 3.1 of \cite{RijkeShulmanSpitters}).

The above proposition almost gives us a 3-for-2 property that combines $L$ and $L'$.
However the map $\emptyt \to \unit$ is $(-2)$-connected, and $\unit$ is $(-1)$-connected,
whereas $\emptyt$ is not $(-1)$-connected. So the remaining implication of the 3-for-2 property
does not hold. One can show the weaker result that the composite of an $L$-connected map followed by
an $L'$-connected map is $L$-connected.
\end{rmk}

\begin{rmk}
\cref{thm:separation_characterization} allows us to give a concrete description of
the extension defined in \cref{lemma:extendtoUL}.
Using an argument similar to the one used in the proof of \cref{remark:preservationpullbacks},
one can show that given an $L'$-localization $\eta' : X \to L' X$
and a map $f: Y \to X$ with $L$-local fibers, $f$ is the pullback of
the fiberwise $L$-localization of $\eta' \circ f$.
\end{rmk}

\begin{defn}
A commuting square
\begin{equation*}
\begin{tikzcd}
A\arrow[d,swap,"f"] \arrow[r,"h"] & B \arrow[d,"g"] \\
X \arrow[r,swap,"i"] & Y
\end{tikzcd}
\end{equation*}
is said to be \define{$L$-cartesian} if its gap map is $L$-connected.
\end{defn}

\begin{prp}
Consider a commuting square
\begin{equation*}
\begin{tikzcd}
A\arrow[d,swap,"f"] \arrow[r,"h"] & B \arrow[d,"g"] \\
X \arrow[r,swap,"i"] & Y.
\end{tikzcd}
\end{equation*}
\begin{enumerate}
\item Suppose that $g$ is surjective, and that the square is $L$-cartesian. Then the following are equivalent:
\begin{enumerate}
\item The map $h:A\to B$ is $L$-connected.
\item The map $i:X\to Y$ is $L$-connected.
\end{enumerate}
\item Suppose that $i:X\to Y$ is $L'$-connected. Then the following are equivalent:
\begin{enumerate}
\item The map $h:A\to B$ is $L'$-connected.
\item The square is $L$-cartesian.
\end{enumerate}
\end{enumerate}
\end{prp}

\begin{proof}
For the first statement we observe that by \cref{thm:rsu-compose-cancel} $h$ is an $L$-connected if and only if $g^\ast i$ is an $L$-connected. Since $g$ is assumed to be surjective, it follows that $g^\ast i$ is $L$-connected if and only if $i$ is $L$-connected.

For the second statement we observe that, since $i:X\to Y$ is assumed to be $L'$-connected, the map $g^\ast i:X\times_Y B\to B$. Now it follows by \cref{thm:rsu-compose-cancel} that the gap map is $L$-connected if and only if $h$ is $L'$-connected.
\end{proof}

\begin{cor}\label{cor:L'connected_maps}
A map $f:A\to B$ is a $L'$-connected if and only if $f$ is surjective and $\delta_f:A\to A\times_B A$ is a $L$-connected.
\end{cor}

\begin{proof}
Since every proposition is $L'$-local, it follows that $\brck{X}=\brck{L'X}$ for any type $X$. In particular, if $X$ is $L'$-connected, then $\brck{X}=\unit$. From this observation it follows that if $f$ is $L'$-connected, then $f$ is surjective. Furthermore, since the identity function $\idfunc[A]:A\to A$ is obviously $L'$-connected, it follows that the square
\begin{equation*}
\begin{tikzcd}
A \arrow[d] \arrow[r] & A \arrow[d,"f"] \\
A \arrow[r,swap,"f"] & B
\end{tikzcd}
\end{equation*}
is $L$-cartesian. In other words: $\delta_f:A\to A\times_B A$ is $L$-connected.

Now suppose that $f$ is surjective and that $\delta_f$ is $L$-connected. Then the fibers of $\delta_f$ are $L$-connected. Since we have equivalences
\begin{equation*}
((x,p)=(y,q))\eqvsym \fib{\delta_f}{x,y,\ct{p}{q^{-1}}}
\end{equation*}
for any $(x,p),(y,q):\fib{f}{b}$ it follows by \cref{lem:L'connected_types} that $\fib{f}{b}$ is $L'$-connected for every $b:B$. In other words: $f$ is $L'$-connected.
\end{proof}

A commuting square is said to be a \define{quasi-pullback} if its gap map is surjective. In other words, quasi-pullback squares are the same as $(-1)$-cartesian squares.

\begin{cor}
A map $f:A\to B$ is $n$-connected if and only if the gap map of the commuting square
\begin{equation*}
\begin{tikzcd}
A \arrow[r,"f"] & B \arrow[d] \\
A^{\sphere{k}} \arrow[r,swap,"f^{\sphere{k}}"] & B^{\sphere{k}}
\end{tikzcd}
\end{equation*}
is a quasi-pullback square, for each $-1\leq k\leq n$. A map is therefore $\infty$-connected if this square is a quasi-pullback for all $k$
\end{cor}

\begin{cor}\label{cor:ptd_connected}
A pointed connected type $A$ is $L'$-connected if and only if the map $\unit\to A$ is $L$-connected.
\end{cor}

\begin{proof}
If $A$ is $L'$-connected, then its loop space is $L$-connected. It follows that the square
\begin{equation*}
\begin{tikzcd}
\unit \arrow[r] \arrow[d] & \unit \arrow[d] \\
\unit \arrow[r] & A
\end{tikzcd}
\end{equation*}
is $L$-cartesian. Since the map $\unit\to\unit$ is obviously $L$-connected and the map $\unit\to A$ is surjective by the assumption that $A$ is connected, it follows that the map $\unit\to A$ is $L$-connected.

For the converse, suppose that the map $\unit\to A$ is $L$-connected. Then the identity types of $A$ are $L$-connected, since all identity types of $A$ are merely equal to $\loopspace{A}$. Therefore it follows by \cref{lem:L'connected_types} that $A$ is $L'$-connected.
\end{proof}

\begin{cor}\label{lem:nconnected_postcomp_variation}
Let $P:A\to\UU$ and $Q:B\to\UU$ be type families, and let
\begin{equation*}
g:\prd{x:A}P(x)\to Q(f(x))
\end{equation*}
be a fiberwise transformation over $f:A\to B$.
\begin{enumerate}
\item Suppose that each $g_x:P(x)\to Q(f(x))$ is $L$-connected. Then we have the following:
\begin{enumerate}
\item If $f$ is $L$-connected, then $\total[f]{g}$ is $L$-connected.
\item If each $Q(x)$ is merely inhabited and $\total[f]{g}$ is $L$-connected, then $f$ is $L$-connected.
\end{enumerate}
\item Suppose that $f$ is $L'$-connected. Then the following are equivalent:
\begin{enumerate}
\item Each $g_x:P(x)\to Q(f(x))$ is $L$-connected.
\item The map $\total[f]{g}$ is $L'$-connected.
\end{enumerate}
\end{enumerate}
\end{cor}

\begin{prp}\label{prop:nconn_fiber_to_total}
Let $P,Q:A\to\type$ be type families and $f:\prd{a:A} \Parens{P(a)\to Q(a)}$. Then the following are equivalent
\begin{enumerate}
\item Each $f(a):P(a)\to Q(a)$ is $L$-connected.
\item The map $\total{f}: \sm{a:A}P(a) \to \sm{a:A} Q(a)$ is an $L$-connected.
\end{enumerate}
\end{prp}

\begin{proof}
By \cref{lem:fib_total} we have $\fib{\total f}{\pairr{x,v}}\eqvsym\fib{f(x)}v$
for each $x:A$ and $v:Q(x)$. Hence $L(\fib{\total f}{\pairr{x,v}})$ is contractible if and only if
$L(\fib{f(x)}v)$ is contractible.
\end{proof}

Of course, the ``if'' direction of \cref{prop:nconn_fiber_to_total} is a special case of \cref{lem:nconnected_postcomp_variation}.
This suggests a similar generalization of the ``only if'' direction of \cref{prop:nconn_fiber_to_total}, which would be a version of \cref{lem:nconnected_postcomp_variation} asserting that if $f$ and $\varphi$ are $L$-connected then so is each $g_a$.

\endinput
\section{These results should go to where they are first needed}
\begin{lem}\label{lemma:orthogonalcomposition}
    If the maps in a type sequence
\begin{equation*}
\begin{tikzcd}
X_0 \arrow[r,"h_0"] & X_1 \arrow[r,"h_1"] & X_2 \arrow[r,"h_2"] & \cdots
\end{tikzcd}
\end{equation*}
    are $L$-equivalences, then the transfinite composite $\overline{h} : X_0 \to \colim_n X_n$ is an $L$-equiva\-lence.
\end{lem}

\begin{proof}
    By \cref{lem:local_equivalence}, it is enough to check that
    $\precomp{\overline{h}} : (\colim_n X_n \to Z) \to (X_0 \to Z)$
    is an equivalence for every $L$-local type $Z$.
    By the induction principle of the sequential colimit,
    we can factor $\precomp{\overline{h}}$ as
\begin{equation*}
\begin{tikzcd}
(\colim_n X_n \to Z) \arrow[r,"\eqvsym"] & \mathsf{lim}_n (X_n\to Z) \arrow[r] & X_0\to Z.
\end{tikzcd}
\end{equation*}
    and by hypothesis the transition maps $(X_{n+1} \to Z) \to (X_n \to Z)$ in the limit diagram are equivalences,
    so the second map is an equivalence as was to be shown.
\end{proof}

In \cref{section:localizationaway}, we will be interested in the effect of localization on the homotopy groups of a type.
For this, we need to understand the relationship between localization and truncation.
Since truncations are also examples of reflections onto reflective subuniverses,
the following two general lemmas will be useful.

\begin{lem}[{\cite[Lemma 3.29]{RijkeShulmanSpitters}}]\label{lemma:commutelocalization}
    Let $K$ and $L$ be reflective subuniverses such that $L$ preserves $K$-local types in the sense that $LX$ is $K$-local whenever $X$ is $K$-local.
    Then the types that are both $K$-local and $L$-local form a reflective subuniverse,
    and $LK = LKL$ is the reflector.
    If in addition $K$ preserves $L$-local types, then $KL = LK$.
\end{lem}

We include the proof since it is straightforward.

\begin{proof}
  For each $X$, there is a natural composite $X \to KX \to LKX$.  The codomain
  $LKX$ is both $K$-local and $L$-local, and this map has the desired universal
  property.
  The same argument applies to the composite $X \to LX \to KLX \to LKLX$.
  Therefore, by the uniqueness of reflectors, we have $LK = LKL$.

  If $K$ preserves $L$-local types, then $KL$ is also a reflector, and therefore $KL=LK$.
\end{proof}

\begin{lem}\label{lemma:comparelocalization}
    Let $K$ and $L$ be reflective subuniverses with $K$ contained in $L$.
    Write $\eta^K$ and $\eta^L$ for the units.
    \begin{enumerate}
    \item If $f$ is an $L$-equivalence, then it is a $K$-equivalence.
          In particular, for any $X$, $K\eta^L_X : KX \to KLX$ is an equivalence.
    \item If $X$ is $K$-local, then $\eta^L_X : X \to LX$ is an equivalence.
          In particular, for any $X$, $\eta^L_{KX} : KX \to LKX$ is an equivalence.
    \item If $X$ is a type such that $LX$ is $K$-local, then the
          natural map $LX \to KX$ is an equivalence.
    \end{enumerate}
\end{lem}

\begin{proof}
(1) follows from \cref{lem:local_equivalence}, and (2) is clear.
For (3), one checks that the unit $\eta^L_X : X \to LX$ has the universal
property of $K$-localization.
\end{proof}

\section{Localization with respect to a family of maps}\label{section:localization}

In this section, we discuss localization with respect to a family of maps.
%% Vague:
%In \cref{ss:basic-properties} we give the definition,
%present some examples, and prove some basic properties.
Our primary examples are localization at the degree $k$ map from $\sphere{1}$ to $\sphere{1}$
and localization at a family of such maps.
%We quote a result of~\cite{RijkeShulmanSpitters} showing that in the special case when $B$ is $1$,
%the localization one obtains is a modality.

In \cref{ss:basic-properties}, we prove some basic properties and study some consequences
of the general theory of separated subuniverses in the case of localization with respect to families of maps.
In \cref{ss:connectedness}, we give conditions under which
$f$-localization preserves coproducts and connectedness.
Finally, \cref{ss:orthogonal-factorization-systems} contains results about the interaction between
orthogonal factorization systems and localizations at families of maps, generalizing some
previous results. The results in \cref{ss:orthogonal-factorization-systems} are not used in the rest
of the paper.

\subsection{Local types and their properties}\label{ss:basic-properties}

We recall the following definitions from~\cite{RijkeShulmanSpitters}.
\begin{defn}\
\begin{enumerate}
\item    Let $f: \prd{i:I} A_i \to B_i$ be a family of maps indexed by a type $I$.
    A type $X$ is \define{$f$-local} if
    $\precomp{f_i} : (B_i \to X) \to (A_i \to X)$ is an equivalence for every $i : I$.
\item Let $A:I\to\UU$ be a family of types. A type $X$ is said to be \define{$A$-null} if it is $u$-local for the family of maps $u:\prd{i:I}A_i\to\unit$.
\end{enumerate}
\end{defn}

As previously noted, \cite[Theorem 2.16]{RijkeShulmanSpitters} shows that for every
family $f$, the $f$-local types form a reflective subuniverse.
The localization $L_f X$ is constructed as a higher inductive type,
and we write $\eta_X : X \to L_f X$ for the unit.
In the case of a family $A:I\to\UU$, localization at the unique family $u:\prd{i:I}A_i \to \unit$ is called \define{$A$-nullification}.
By \cite[Theorem 2.17]{RijkeShulmanSpitters}, the reflective subuniverse of $A$-null types is stable under dependent sums and therefore $A$-nullification is a modality (\cref{thm:ssrs-characterize}).

\begin{eg} We recall the following basic examples from~\cite{RijkeShulmanSpitters}.
\begin{enumerate}
\item The unit type is $f$-local for any map $f$.
\item A type $X$ is $(\emptyt\to\unit)$-local if and only if $X$ is contractible.
\item A type $X$ is $(\sphere{n+1}\to\unit)$-local if and only if $X$ is $n$-truncated.
\end{enumerate}
\end{eg}

When $f$ consists of pointed map between pointed types, we can test whether
a type $X$ is local using the pointed mapping types.

\begin{lem}\label{lemma:pointed}
    If $f : \prd{i:I} A_i \to B_i$ is a pointed map between pointed types,
    then a type $X$ is $f$-local if and only if
    $\precomp{f_i} : (B \pto X) \to (A \pto X)$ is an equivalence
    for every base point $x : X$ and every $i : I$.
    If $X$ is connected, then it is enough to check this for one $x : X$.
\end{lem}

\begin{proof}
    The second claim follows from the first one, since
    $\isequiv$ is a mere proposition.
    For the first claim, fix $i : I$ and consider the diagram
\begin{equation*}
\begin{tikzcd}
(B_i \to_\ast X) \arrow[d] \arrow[r,hookrightarrow] & (B_i\to X) \arrow[d] \arrow[r,"\evpt"] & X \arrow[d,equals] \\
(A_i \to_\ast X) \arrow[r,hookrightarrow] & (A_i \to X) \arrow[r,swap,"\evpt"] & X
\end{tikzcd}
\end{equation*}
    where the horizontal sequences are fiber sequences with the fiber taken over
    some $x : X$. Since fiberwise maps are equivalences exactly when they are fiberwise
    equivalences, the vertical map in the middle is an equivalence if and
    only if the vertical map on the left is an equivalence for every $x : X$.
\end{proof}

Since the pointed mapping space $\unit\to_\ast X$ is contractible for any pointed space $X$, we have the following corollary.

\begin{cor}\label{cor:pointed_null}
If $A$ is a family of pointed types, then a type $X$ is $A$-null
if and only if $(A_i \pto X)$ is contractible
for every base point $x : X$ and every $i : I$. \qed
\end{cor}

We turn to a comparison of $L_f$ and $L_{\suspsym f}$.
The next corollary follows immediately from \cref{lemma:characterizationsigmaflocal}
and \cref{thm:separation_characterization}.

\begin{cor}\label{remark:commutativitylooplocalization}
    Let $f : \prd{i:I} A_i \to B_i$.
    For any pointed type $X$, we have
    $\loopspacesym L_{\susp{f}} X \simeq L_f \loopspacesym X$. \qed
\end{cor}

This result is a type theoretic analog of \cite[Theorem 3.1]{Bousfield} and \cite[3.A.1]{Farjoun}.
Interestingly, the classical proofs use delooping techniques which are not yet available in type theory.
Our proof instead makes essential use of a universe.

Given this corollary, we are led to consider the relationship between $f$-local types and $\suspsym f$-local types, as a step towards comparing $L_f$ and $L_{\suspsym f}$.

\begin{thm}\label{theorem:characterizinglocalness}
    Let $f: \prd{i:I} A_i \to B_i$ and let $n \geq 1$.
    Consider the following conditions on a type $X$:
    \begin{enumerate}
    \item $X$ is $f$-local.
    \item $X$ is $\suspsym^{n-1} C_f$-null,
    where $C_f$ is the family of cofibers of the family $f$.
    \item $X$ is $\suspsym^{n} f$-local.
    \end{enumerate}
    Then (1) $\Rightarrow$ (2) $\Rightarrow$ (3).
    Moreover, if the pointed mapping spaces $(A_i \pto X)$ and $(B_i \pto X)$
    are $(n-1)$-connected for all choices of base point $x : X$
    and every $i : I$,
    then the three conditions are equivalent.
\end{thm}

\begin{proof}
We will show the required implications for each $i : I$.
So, without loss of generality we consider a single map $f : A \to B$.

By \cref{lemma:pointed}, it suffices to consider pointed mapping
spaces for each $x : X$.
With $x$ chosen, we have a long fiber sequence
\begin{equation*}
\begin{tikzcd}
& & \cdots \arrow[dll,out=352,in=172] \\
(\suspsym C_f \pto X) \arrow[r] & (\suspsym B \pto X) \arrow[r] & (\suspsym A \pto X) \arrow[dll,out=352,in=172] \\
(C_f \pto X) \arrow[r] & (B\pto X) \arrow[r] & (A\pto X)
\end{tikzcd}
\end{equation*}

Assuming (1), from the first fiber sequence in the diagram above
it follows that $(C_f \pto X)$ is contractible. This means that $X$ is $C_f$-null and
thus $\suspsym^{n-1} C_f$-null, since any $C_f$-null type is also $C_f$-separated. Thus (1) implies (2).

To see that (2) implies (3), consider a piece of the above fiber sequence:
\[
  (\suspsym^{n} B \pto X) \xrightarrow{\precomp{(\suspsym^n f)}}
  (\suspsym^n A\pto X) \lra (\suspsym^{n-1} C_f \pto X).
\]
If (2) holds, then the base of the fiber sequence is contractible and thus the inclusion of the
fiber in the total space
is an equivalence, proving (3).

Finally, we show that (3) implies (1) under the connectedness hypotheses.
Notice that we can express
$\precomp{(\suspsym^{n} f)} : (\suspsym^n B \pto X) \to (\suspsym^n A \pto X)$ as
\[
    (\suspsym^n B\pto X) \simeq \loopspacesym^n(B \pto X) \xrightarrow{\loopspacesym^n (\precomp{f})}
    \loopspacesym^n(A \pto X) \simeq (\suspsym^n A \pto X),
\]
using~\cite[Lemma~6.5.4]{hottbook}.
If $X$ is $\suspsym^{n}f$-local, it follows that $\loopspacesym^n (\precomp{f})$ is an equivalence.
By hypothesis, $(A\pto X)$ and $(B\pto X)$ are $(n-1)$-connected, and so by~\cite[Corollary~8.8.2]{hottbook} applied $n$ times
it follows that $\precomp{f} : (B \pto X) \to (A \pto X)$ is an equivalence.
\end{proof}

%\begin{eg}
%    Consider the unique map $\underline{n} : \sphere{n} \to \unit$.
%    For a pointed type $X$, composition with $\underline{n}$ induces the unique pointed map
%    \[
%        \unit \simeq (\unit \pto X) \to (\sphere{n} \pto X) \simeq \loopspacesym^n X.
%    \]
%    By \cref{lemma:pointed}, a type $X$ is $\underline{n}$-local if and only if
%    this map is an equivalence for every point $x$ in $X$.
%    Therefore, $X$ is $\underline{n}$-local if and only if $X$ is $(n-1)$-truncated.
%\end{eg}

\subsection{Preservation of coproducts and connectedness}\label{ss:connectedness}

We begin this section by studying conditions under which
$f$-localization preserves coproducts.
By a coproduct, we mean a set-indexed $\Sigma$-type.
We first prove a lemma, which will also be used in \cref{example:notlex}.

\begin{lem}\label{lemma:setsarelocal}
    Let $f : \prd{i:I} A_i \to B_i$ be a family of pointed maps
    between pointed, connected types.
    Then a coproduct of $f$-local types is $f$-local.
    In particular, sets are $f$-local.
\end{lem}

\begin{proof}
    It suffices to prove the lemma for each $f_i$, so we assume
    that we are given a single map $f : A \to B$.
    Let $J$ be a set and let $T : J \to \UU$ be a type family.
    Since $A$ is pointed and connected, any map $A \to \sm{j:J} T_j$ factors through a well-defined summand
    $T_j$, so we have $(A \to \sm{j:J} T_j) \simeq \sm{j:J} (A \to T_j)$. The same is true for $B$, so
    we can factor the map $\precomp{f} : (B \to \sm{j:J} T_j) \to (A \to \sm{j:J} T_j)$ as
    \[
        \Big(B \to \sm{j:J} T_j \Big) \simeq \sm{j:J} (B \to T_j) \simeq \sm{j:J} (A \to T_j) \simeq \Big(A \to \sm{j:J} T_j\Big),
    \]
    which shows that $\sm{j:J} T_j$ is $f$-local.

    Since $\unit$ is $f$-local, a special case is that $\sm{j:J} \unit \simeq J$ is $f$-local.
\end{proof}

\begin{cor}
    Let $f : \prd{i:I} A_i \to B_i$ be a family of pointed maps
    between pointed, connected types.
    Then $f$-localization preserves coproducts.
\end{cor}

\begin{proof}
    Let $J$ be a set and let $S : J \to \UU$ be a type family.
    Consider the coproduct $\sm{j:J} S_j$.
    By \cref{lemma:setsarelocal}, $\sm{j:J} L_f S_j$ is $f$-local. We claim that the natural
    map $\sm{j:J} S_j \to \sm{j:J} L_f S_j$ is a localization.
    Let $Y$ be $f$-local. Then we have
    \[
        \Bigg( \bigg( \sm{j:J} S_j \bigg) \to Y \Bigg) \simeq \prd{j:J} (S_j \to Y) \simeq
        \prd{j:J} (L_f S_j \to Y) \simeq \Bigg( \bigg( \sm{j:J} L_f S_j \bigg) \to Y \Bigg).\qedhere
    \]
\end{proof}

\medskip

Our next goal is to give conditions under which $f$-localization
preserves $n$-connected\-ness.

\begin{prp}\label{prop:Kequiv-Lf}
Let $K$ be a reflective subuniverse and let $f$ be a family of $K$-equiva\-lences.
Then $\eta : X \to L_f X$ is a $K$-equivalence for every $X$.
\end{prp}

\begin{proof}
Since each $f_i$ is a $K$-equivalence, every $K$-local type is $f$-local,
by \cref{lem:local_equivalence}.
Therefore, $\eta : X \to L_f X$ is a $K$-equivalence
by \cref{lemma:comparelocalization}(1).
\end{proof}

\begin{cor}\label{cor:preserve-n-connected}
For $n \geq -1$, let $f$ be a family of maps such that each $\trunc{n}{f_i}$ is an equivalence.
If $X$ is $n$-connected, then $L_f X$ is $n$-connected.
\end{cor}

\begin{proof}
Let $K$ be the subuniverse of $n$-truncated types.
Then each $f_i$ is a $K$-equivalence, by assumption.
It follows from \cref{prop:Kequiv-Lf} that $X \to L_f X$ is a $K$-equivalence.
Thus, if $\trunc{n}{X}$ is contractible, so is $\trunc{n}{L_f X}$.
\end{proof}

\subsection{Orthogonal factorization systems}\label{ss:orthogonal-factorization-systems}

In this section, we strengthen \cref{cor:preserve-n-connected}, using
the framework of orthogonal factorization systems.
While we do not need this generalization in the rest of the paper,
the stronger results will likely be of independent interest.

Roughly speaking, an \define{orthogonal factorization system} consists of
classes $\LLL$ and $\RRR$ of maps such that every map factors uniquely as
$r \circ l$, with $l$ in $\LLL$ and $r$ in $\RRR$.
See~\cite{RijkeShulmanSpitters} for more information.
The reader not familiar with orthogonal factorization systems can assume
that $\LLL$ is the class of $n$-connected maps
and $\RRR$ is the class of $n$-truncated maps for some $n \geq -2$;
this case is treated in~\cite[Section 7.6]{hottbook}.
(For example, when $n = -1$, $\LLL$ consists of the surjective maps
and $\RRR$ consists of the embeddings.)

\begin{lem}\label{lemma:subtypes}
    Let $(\LLL, \RRR)$ be an orthogonal factorization system and
    let $f : \prd{i:I} A_i \to B_i$ be a family of maps in $\LLL$.
    If $r : S \to X$ is in $\RRR$ and $X$ is $f$-local, then $S$ is $f$-local.
    In particular, if each $f_i$ is surjective,
    then any subtype of an $f$-local type is $f$-local.
\end{lem}

\begin{proof}
    Suppose that $X$ is $f$-local
    and that $r : S \to X$ is in $\RRR$.
    Fix $i : I$.
    Since $f_i$ is in $\LLL$ and $r$ is in $\RRR$, the following square is a pullback:
\begin{equation*}
\begin{tikzcd}
S^{B_i} \arrow[r,"\precomp{f_i}"] \arrow[d,swap,"r^{B_i}"] & S^{A_i} \arrow[d,"r^{A_i}"] \\
X^{B_i} \arrow[r,swap,"\precomp{f_i}"] & X^{A_i}
\end{tikzcd}
\end{equation*}
    This follows from~\cite[Lemma~1.44]{RijkeShulmanSpitters}, which says that the fibers of
    the map comparing $S^{B_i}$ to the pullback are contractible.
    The bottom arrow is an equivalence since $X$ is $f$-local,
    so the top arrow is an equivalence, as required.
\end{proof}
% The previous proof was missing awkward details about the witnesses
% to the various commuting squares and triangles.

\begin{thm}\label{theorem:localizationpreservesconnected}
    Let $(\LLL, \RRR)$ be an orthogonal factorization system and
    let $f$ be a family of maps in $\LLL$.
    Then $\eta : X \to L_f X$ is in $\LLL$ for every $X$.
\end{thm}

%Note that if $A$ is pointed and $B$ is connected, then $f$ is surjective.

\begin{proof}
    Factor the unit map as $X \xrightarrow{l} I \xrightarrow{r} L_f X$, with $l$ in $\LLL$
    and $r$ in $\RRR$.
    By \cref{lemma:subtypes},
    $I$ is $f$-local. This gives us a map $\overline{l} : L_f X \to I$
    such that $r \circ \overline{l} \circ \eta = r \circ l = \eta$.
    By the universal property of $L_f X$, it must be the case that $r \circ \overline{l}$
    is homotopic to the identity of $L_f X$.
    Similarly, $\overline{l} \circ r$ is an automorphism of $I$ that respects the
    factorization, so it must be homotopic to the identity of $I$.
    Thus $r$ is an equivalence and so $\eta = r \circ l$ is in $\LLL$.
\end{proof}

\begin{cor}\label{cor:preserve-n-connected-stronger}
    For $n \geq -1$, let $f$ be a family of $(n-1)$-connected maps.
    If $X$ is $n$-connected, then $L_f X$ is $n$-connected.
\end{cor}

\begin{proof}
    Applying \cref{theorem:localizationpreservesconnected} with
    $\LLL$ the $(n-1)$-connected maps and $\RRR$ the $(n-1)$-truncated maps
    gives that $\eta : X \to L_f X$ is $(n-1)$-connected.
%    \note{The last sentence is wishy-washy, but giving details about basepoints is messy.
%    I think there must be a sharper argument; can anyone find it?}
    By examining homotopy groups, it follows that when $X$ is $n$-connected,
    so is $L_f X$.
\end{proof}

\cref{prop:Kequiv-Lf} and \cref{theorem:localizationpreservesconnected} are very similar.
To compare them in a concrete situation, take $K$ to be the subuniverse of $n$-truncated
types and consider the orthogonal factorization system in which $\LLL$ is the
class of $n$-connected maps.
If a map $g$ is $n$-connected, then $Kg = \trunc{n}{g}$ is an equivalence, so
\cref{theorem:localizationpreservesconnected} makes a stronger assumption on $f$
and gives a stronger conclusion about $\eta : X \to L_f X$.
Thus neither result implies the other.

On the other hand, \cref{cor:preserve-n-connected-stronger} has the same
conclusion as \cref{cor:preserve-n-connected}, but makes a weaker hypothesis,
since if $\trunc{n}{f}$ is an equivalence then $f$ is $(n-1)$-connected.
This is strictly weaker.  For example, if $n = 0$, the former is the
condition that $f$ is a bijection on components, while the latter is
the condition that $f$ is surjective on components.
% Similarly, for $n = -1$,
% being $-1$-connected is the same as being surjective.
% But being an equivalence under $\trunc{-1}{-}$ is the same as being
% a logical equivalence, which is much weaker.  E.g. \emph{any} map
% between pointed types is a logical equivalence.


% Lecture for ph2a Caltech 2017: Vibrations and Waves
\documentclass[pdf, handout, hideothersubsections]{beamer}
\usepackage{beamerthemeshadow}
\mode<presentation>
  {
    \usefonttheme{structuresmallcapsserif}
    \usetheme{Darmstadt}
    \usecolortheme{whale}
    %\useinnertheme{circles}
%    \useoutertheme{tree}
  }

\usepackage{svg}
\usepackage{xmpmulti}
\usepackage{mathtools}
%\usepackage{enumitem}
\usepackage{hyperref}
\hypersetup{
    pdffitwindow=true,     % window fit to page when opened
    colorlinks=true,       % false: boxed links; true: colored links
    linkcolor=orange,      % color of internal links
    citecolor=green,       % color of links to bibliography
    filecolor=magenta,     % color of file links
    urlcolor=blue,         % color of external links
    pdfstartview={Fit}
}

% Fonts/encoding
\renewcommand{\UrlFont}{\ttfamily\tiny}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
%\usepackage[sc,medium,raggedright]{titlesec}
\usepackage{newtxmath}
%\usepackage{libertine}
\usepackage[osf]{ebgaramond}

\graphicspath{{Figures/}}

\begin{document}
\title{Interference \& Diffraction}
\author{Caltech: ph2a}
\date{28 - Nov - 2017}

\frame{\titlepage}

\frame{\frametitle{Table of Contents}\tableofcontents}

\setbeamerfont{footnote}{size=\tiny}

\begin{frame}
\frametitle{Feynman}

\centering
``No one has ever been able to define the difference between
interference and diffraction satisfactorily.'' \\

-Feynman Lectures, 30-1

\end{frame}

\section{Interference of Two Sources}
\begin{frame}
\frametitle{Huygen's Principle: Review}
\begin{columns}
  \begin{column}{0.3\textwidth}
    \includegraphics[width=0.99\textwidth]{Huygen.pdf}
  \end{column}

  \begin{column}{0.7\textwidth}
    \begin{itemize}
    \item A \emph{Wavefront} is a surface over which an optical wave has a
      constant phase.

    \item In 3D, a point source emits spherical waves; i.e. it will emit
      spherical wavefronts.

    \item For 2D, the wavefronts are circles.

    \item Huygen's principle: the propagation of an arbitrary wave can be
      understood by imagining that each piece of a wavefront emits a
      secondary spherical wavelet.
      The coherent superpostion of
      these wavelets determines the new wavefront.
    \end{itemize}
  \end{column}
\end{columns}
\end{frame}

\begin{frame}
\frametitle{Interference of Two Waves}
Let us consider two point sources of some kind of wave (need not be
electromagnetic):
\begin{columns}

  \begin{column}{0.4\textwidth}
    \includegraphics[width=0.99\textwidth]{TwoSource.jpg}
  \end{column}

  \begin{column}{0.6\textwidth}
\begin{align*}
\Psi &= \action<+->{A(r_1) e^{i (k r_1 - \omega t)} + A(r_2) e^{i (k r_2 - \omega t)}\\}
     \action<+->{&\simeq A \Big[e^{i (k r_1 - \omega t)} + e^{i (k r_2 - \omega t)}\Big] \\}
     \action<+->{&= A e^{i (k r - \omega t)} \times 2 \cos{k (r_2 -
                   r_1)} \\}
\action<+->{|\Psi|^2 &= 4 |A|^2 cos^2[k (r_2 - r_1)] \\}
\action<+->{|\Psi|^2 &= 4 |A|^2 cos^2[2 \pi \frac{d}{\lambda} \sin{\theta}]}
\end{align*}

where $\delta \phi$ is the phase \emph{difference}, $d$ is the average
distance from the slits to the source, and $\theta$ is the angle to
the point on the screen.
  \end{column}

  \end{columns}
\end{frame}

\begin{frame}
\frametitle{2 Sources}

\centering
\includegraphics[width=0.85\textwidth]{../../Simulations/IMGintpattern_f5000_n2.png}

\end{frame}

\section{Interference of N Sources}
\begin{frame}
\frametitle{3 Sources}

\centering
\includegraphics[width=0.85\textwidth]{../../Simulations/IMGintpattern_f5000_n3.png}

\end{frame}

\begin{frame}
\frametitle{N Sources}

\centering
\includegraphics[width=0.85\textwidth]{../../Simulations/IMGintpattern_f5000_n9.png}

see animations...

\end{frame}

\begin{frame}
\frametitle{N Sources}

\begin{columns}
\begin{column}{0.5\textwidth}
\includegraphics[width=0.99\textwidth]{diffraction_grating_geometry.jpg}
\end{column}

\begin{column}{0.5\textwidth}
Constructive Interference: maxima at $m \lambda = d sin \theta$, where
$m = ..., -2, -1, 0, 1, 2,...$

Sketch of Derivation:\\
$\Psi(r, \theta, t) = A(r) e^{-i \omega t} \sum_{p=-N/2}^{N/2} e^{i k
  r_p}$ \\
$r_2 - r_1 = d \sin{\theta}$ \\
$r_3 - r_1 = 2 d \sin{\theta}$ \\
$r_4 - r_1 = 3 d \sin{\theta}$ \\
So, for the angle between maxima $\sin{\theta} = \lambda / d$. Or, for
the case where the screen is far away, $\theta \simeq \lambda / d$.
\end{column}

\end{columns}
\end{frame}

\begin{frame}
\frametitle{N Sources}

\begin{columns}
\begin{column}{0.5\textwidth}
\includegraphics[width=0.99\textwidth]{f30-01_tc_big.pdf}
\end{column}

\begin{column}{0.5\textwidth}
\begin{enumerate}
\item The wave from each slit has approximately the same amplitude, $A$.
\pause
\item The phase, $\phi$, from each slit is slightly retarded with respect to
  the adjacent one.
\pause
\item From trigonometry, we can see that $A = 2 r \sin{\phi/2}$
\pause
\item The angle $OQT = n \phi$, and so $A_R = 2 r \sin{n \phi / 2}$
\pause
\item So the amplitude $A_R = A \frac{\sin{n \phi /2}}{\sin{\phi/2}}$
    and
\pause
\item The intensity $I = I_0 \frac{\sin^2{n \phi /2}}{\sin^2{\phi/2}}$

\end{enumerate}
\end{column}

\end{columns}

\end{frame}

\begin{frame}
\frametitle{N Sources}

\centering
\includegraphics[width=0.85\textwidth]{../../Simulations/Nslits.pdf}

\end{frame}

%\section{Antennae}

\section{Interferometers}

\section{Optical Resonator / Etalon}
\begin{frame}
\frametitle{The Fabry-Perot Interferometer}
... review of last week's calculation...
\begin{enumerate}
\item A Fabry-Perot resonator consists of two mirrors separated by a
  distance $L$, each with an \emph{amplitude} reflectivity, $r$.

\item As we did for the single layer anti-reflection coating, we can
  write down the relationships between all the fields.

\item Assuming that the mirrors are moving very slowly, with respect
  to the round trip travel time for the light, we can find the
  quasi-static solution to the fields.

\item Take a few minutes to solve for the fields...
\end{enumerate}

As with the mass-spring and electrical (RLC) SHO, the optical
(laser-mirror) resonator also has a resonant frequency and a Q. Why?
\end{frame}

\begin{frame}
\frametitle{The Fabry-Perot Interferometer}

\centering
\includegraphics[width=0.99\textwidth]{../../Simulations/FabryPerot.pdf}

\end{frame}

\section{Summary}
\begin{frame}
\frametitle{Summary}
\begin{itemize}
  \item The interference of waves can be understood using superposition
  \item Multiple wave interference is a natural extension of this method
  \item Interferometers are precise measurement tools: can convert
    optical phase changes into measureable power.

  \item A diffraction grating gives a multi-slit diffraction pattern.
  \item For N slits, the angle between diffraction maxima is the
    wavelength over the slit spacing.
  \item By symmetry, the \emph{resolving} power (in radians) of a set
    of coherent receivers is set by the size of the receiver array.

\end{itemize}
\footnotetext[1]{\url{https://readingfeynman.org/2014/07/14/diffraction-gratings}}
\end{frame}

\end{document}