\section{Introduction}

%\begin{itemize}
%\item Tuning is important in deep learning and tuning is hard.
%\item People do (a) adaptive (b) method with knob. (Fix momentum and only investigate lr).
%\item momentum accelerates. better understanding the behavior of momentum is interesting better tuner with less tuning. We revisit mom sgd and found the robustness to lr and variation. As well as related to async. And derive simple theory to analyze.
%\item These properties makes mom sgd a good candidate for auto tuning. We investigate a quadratic model and propose an simple and easy to understand tuner. It is faster than Adam
%\item We also connect to async theory and develope component and better than others in asynchrony.
%\end{itemize}

\outline{[Problem.]}
%Deep learning involves the use of very large datasets to fit large, complex models.
Accelerated forms of stochastic gradient descent (SGD), pioneered by
\citet{polyak1964some} and \citet{nesterov1983method}, are the de-facto
training algorithms for deep learning.
Their use requires a sane choice for their {\em hyperparameters}:
typically a {\em learning rate} and {\em momentum parameter} \citep{sutskever2013importance}.
\outline{[Hardness.]}
%Hyperparameter tuning is often cited as being the number-one factor in extracting good performance from deep learning systems.
%It is by far the most time consuming phase of developing a new deep learning model or system.
%One could say that tuning is {\em the hidden cost of modern machine learning},
However, tuning hyperparameters is arguably the most time-consuming part of deep learning, with thousands of grad-student-hours sacrificed and many papers outlining best tuning practices written
\cite{bengio2012practical,orr2003neural,bengio2012deep,bottou2012stochastic}.

\outline{[previous approach]}
Deep learning researchers have proposed a number of methods to deal with hyperparameter optimization.
Na\"ive methods, like the grid-search,
are prohibitively expensive for all but the smallest problems.
Smart black-box methods \cite{bergstra2012random,snoek2012practical}
do not explicitly take into account the problem specifics and spend time testing multiple configurations.
Adaptive methods provide an attractive alternative.
They aim to tune a single run on the fly and have been largely successful in relieving practitioners of tuning the learning rate.
Algorithms like Adagrad \cite{duchi2011adaptive}, RMSProp \cite{tieleman2012lecture} and Adam \cite{kingma2014adam} use the magnitude of gradient elements to tune learning rates {\em individually for each variable}. A common limitation of state-of-the-art adaptive methods is that they do not tune their momentum.
%Finally, methods like the one proposed by \citet{schaul2013no} use simple models and simple measurements to tune a global learning rate for the standard SGD update.

\outline{[limitation of previous approach]}
Momentum is a fundamental parameter at the heart of the acceleration process, lending its name to the most ubiquitous accelerated method \cite{polyak1964some}, simply dubbed {\em momentum}.
Classic \cite{polyak1964some} and recent results \cite{sutskever2013importance} alike show that proper momentum tuning has a significant impact on training speed.
%Unfortunately, there exists no method that automatically tunes its momentum parameter.
%Large-scale systems pose extra tuning challenges.
\jianedits{Momentum becomes even more critical on distributed systems.
Recently, \citet{mitliagkas2016asynchrony} showed that, in asynchronous-parallelization~\cite{recht2011hogwild,dean2012large,chilimbi2014project,hadjis2016omnivore},
a technique for efficient distributed training without synchronization locks,
%introduces additional momentum-like dynamics to momentum SGD, and
one can manually reduce algorithmic momentum to accelerate convergence~\cite{hadjis2016omnivore}.
As part of a collaboration with an industry affiliate and a big research lab, we verify that tuning momentum dramatically improves convergence on thousand-node scales.
However, grid-searching momentum on very large cluster jobs becomes especially challenging.
We believe that better understanding of momentum and its rich properties is interesting in its own right and could yield a next generation of adaptive methods that perform {\em automatic momentum tuning}. }
%Increasing model and dataset sizes motivate parallelization \cite{dean2012large,chilimbi2014project,hadjis2016omnivore,chen2016revisiting}.
% Asynchronous methods \cite{recht2011hogwild} provide efficient parallelization by training without locking or synchronization.
%The exact effect of asynchrony on the optimization process has been a mystery, though empirical results have shown great successes \cite{recht2011hogwild,dean2012large,chilimbi2014project,hadjis2016omnivore}.
%Recent work by \citet{mitliagkas2016asynchrony} reveals that asynchrony introduces additional momentum-like dynamics to the optimization process,
%a statement that can be made {\em exact} for the momentum SGD algorithm.
%\jianedits{Recent work by \citet{mitliagkas2016asynchrony} reveals that asynchrony introduces additional momentum-like dynamics to momentum SGD, and one can manually reduce algorithmic momentum to accelerate convergence~\cite{hadjis2016omnivore}}.

%As part of a collaboration with an industry affiliate and a big research lab, we had the opportunity to verify this phenomenon on thousand-node scales.
%Tuning the momentum value improves convergence speed,
%however grid-searching momentum values at that scale becomes challenging.
%Recent work \cite{hadjis2016omnivore} uses this theoretical understanding to perform targeted, efficient hyperparameter searches.
%We believe that better understanding of momentum and its rich properties is interesting in its own right and could yield a next generation of adaptive methods with {\em automatic momentum tuning}.

%%%%%%%% old un smoothed version %%%%%%%%%%%%%%%%%%
%%Large-scale systems pose extra tuning challenges.
%Momentum tuning becomes even more critical on large-scale, parallel systems.
%%Increasing model and dataset sizes motivate parallelization \cite{dean2012large,chilimbi2014project,hadjis2016omnivore,chen2016revisiting}.
% Asynchronous methods \cite{recht2011hogwild} provide efficient parallelization by training without locking or synchronization.
%The exact effect of asynchrony on the optimization process has been a mystery, though empirical results have shown great successes \cite{recht2011hogwild,dean2012large,chilimbi2014project,hadjis2016omnivore}.
%%Recent work by \citet{mitliagkas2016asynchrony} reveals that asynchrony introduces additional momentum-like dynamics to the optimization process,
%%a statement that can be made {\em exact} for the momentum SGD algorithm.
%\jianedits{Recent work by \citet{mitliagkas2016asynchrony} reveals that asynchrony introduces additional momentum-like dynamics to momentum SGD, and one can manually reduce algorithmic momentum to accelerate convergence~\cite{hadjis2016omnivore}}.
%
%As part of a collaboration with an industry affiliate and a big research lab, we had the opportunity to verify this phenomenon on thousand-node scales.
%Tuning the momentum value improves convergence speed,
%however grid-searching momentum values at that scale becomes challenging.
%Recent work \cite{hadjis2016omnivore} uses this theoretical understanding to perform targeted, efficient hyperparameter searches.
%We believe that better understanding of momentum and its rich properties is interesting in its own right and could yield a next generation of adaptive methods that also perform {\em automatic momentum tuning}.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{wrapfigure}[11]{R}{0.46\textwidth}
\vspace{-1.0em}
\begin{minipage}{1.0\linewidth}
\begin{figure}[H]
	\includegraphics[width=1.0\linewidth]{experiment_results/spotlight.pdf}
	\caption{\tuner comparing to Adam.}
\end{figure}
\end{minipage}
\end{wrapfigure}
We revisit the basic SGD update that uses Polyak's momentum and a single learning rate for all variables.
We empirically show that, when hand-tuned, momentum SGD achieves faster convergence than Adam for a large class of models.
We then formulate the optimization update as a dynamical system and study certain robustness properties of the momentum operator.
Building on our analysis, we design \tuner, an automatic hyperparameter tuner for momentum SGD.
\tuner tunes the learning rate and momentum on the fly, and uses a novel {\em closed-loop control architecture} to compensate for the added dynamics of asynchrony.
Specifically:
\begin{itemize}[leftmargin=2em]
\item
The momentum operator's spectral radius is constant in a large subset of the hyperparameter space we call {\em the robust region}.
This is a known, but relatively obscure property.
Our analysis in Section~\ref{sec:momentum_operator} gives a novel interpretation:
momentum is robust to learning rate misspecification and curvature variation,
two desirable properties for deep learning.
%\item
%We analyze the momentum operator in Section~\ref{sec:momentum_operator} with focus on its spectral radius. More specifically, the spectral radius can be constant under conditions.
%We expose previously unknown insights from the simple property:
%the momentum operator can yield constant convergence rates even when the learning rate is grossly mis-tuned.
%Furthermore, constant convergence rates are empirically possible for some non-convex objectives,
%where curvature dramatically varies spatially.%  (a factor of more than $1000\times$ when momentum is set to $0.9$).
\item
In Section~\ref{sec:sync_tuner}, we use these insights and a simple quadratic model analysis to design \tuner, an automatic tuner for momentum SGD.
\tuner uses on-the-fly measurements from the gradients of the system to tune both learning rate and momentum.
%\item We use these insights and the analysis of a quadratic model to design
%\tuner in Section~\ref{sec:sync_tuner}. To tune the learning rate and momentum, the tuner minimize the squared distance from the minimum of a local quadratic approximation at each step of the algorithm.
%\item In Section~\ref{sec:async_tuner}, we present the first asynchrony-aware tuner.
%We first provide a measurement component to estimate the total amount of momentum in a running system, including the extra momentum due to asynchrony.
%Then, we propose \asynctuner, a closed-loop version of \tuner, that uses the measurement component and a negative feedback loop to bring the total amount of momentum to the levels suggested by the tuning rule.
%\item
%Furthermore, \tuner is {\em asynchrony-aware}.
%It uses a {\em novel momentum-measurement mechanism} that is part of a {\em closed-loop} design to automatically tune the value of momentum when asynchrony introduces extra momentum dynamics.
\item In Section~\ref{sec:async_tuner}, we present \asynctuner
%an asynchrony-aware tuner.
\jianedits{for asynchronous training}.
\jianedits{It} measures the total momentum in a running system, including any asynchrony-induced momentum.
This measurement is used in a negative feedback loop to control the value of algorithmic momentum.% on the fly.
%With the estimates, it use a negative feedback loop to bring the total momentum to the level suggested by \asynctuner.

%\item We present an analysis of the momentum operator in Section~\ref{sec:momentum_operator}.
%We focus on the fact that its spectral radius is constant in a certain robust region.
%We expose previously unknown insights that stem from that simple property:
%the momentum operator can yield constant convergence rates even when the learning rate is grossly mis-tuned.
%Furthermore, constant convergence rates are possible for certain non-convex objectives,
%where curvature can vary dramatically (a factor of more than $1000\times$ when momentum is set to $0.9$).
\end{itemize}

%Asynchronous methods \cite{recht2011hogwild} provide very efficient parallelization by doing away with locking and synchronization.

%and propose \tuner, an automatic tuner for its hyperparameters.
%A key component of \tuner is principled momentum-tuning in both synchronous and asynchronous settings.
%\tuner is competitive or better that state-of-the-art adaptive methods and is asynchrony-aware by using a novel design based on measuring the level of momentum on the fly and using a closed-loop control module for momentum.

%\outline{[OUR RESULTS]}
%We demonstrate experimentally, in Section~\ref{sec:experiments}, that
%for a large class of networks, hand-tuned momentum SGD is competitive with Adam ($0.88-1.82\times$), even though it uses fixed hyperparameters throughout execution.
%On ResNets, momentum SGD can achieve a $1.25-1.82\times$ speedup over Adam.
%\tuner is competitive with, and sometimes better, than state-of-the-art adaptive methods. The speedup is over $2\times$ on ResNets and $1.18\times$ on LSTMs.
%Other adaptive algorithms do not tune their momentum parameter and suffer, as a result, in asynchronous settings.
%Hand-tuning momentum for Adam can improve its convergence rate by up to $2\times$, when using $16$ asynchronous workers.
%Finally, closing the momentum loop in \tuner yields a speedup of $1.3-3\times$, when using $16$ asynchronous workers.
%Closed-loop \tuner achieves a speedup of about $2.7\times$ over Adam on 16 asynchronous workers.
%\begin{itemize}
%\item For a large class of networks, hand-tuned momentum SGD is competitive with Adam ($0.88-1.82\times$), even though it uses fixed hyperparameters throughout execution.
%On ResNets, momentum SGD can achieve a $1.25-1.82\times$ speedup over Adam.
%\item \tuner is competitive with, and sometimes better, than state-of-the-art adaptive methods. The speedup is over $2\times$ on ResNets and $1.18\times$ on LSTMs.
%\item  Other adaptive algorithms do not tune their momentum parameter and suffer, as a result, in asynchronous settings.
%Hand-tuning momentum for Adam can improve its convergence rate by up to $2\times$, when using $16$ asynchronous workers.
%\item  Closing the momentum loop in \tuner yields a speedup of $1.3-3\times$, when using $16$ asynchronous workers.
%Closed loop \tuner achieves a speedup of about $2.7\times$ over Adam on 16 asynchronous workers.
%\end{itemize}

\outline{[empirical performance statement on \tuner]}
We introduce our contributions in Sections~\ref{sec:momentum_operator},\ref{sec:sync_tuner},\ref{sec:async_tuner}.
In Section~\ref{sec:experiments}, we demonstrate empirically that
\tuner offers \jianedits{competitive or significantly better performance} compared to:
(i) hand-tuned momentum SGD (a speedup of up to 2.3x);
and (ii) hand-tuned Adam (up to 2.8x speedup).
	\jianedits{In an asynchronous setting, we demonstrate that Adam, the state-of-the-art adaptive method, suffers from lack of momentum tuning.}
%Specifically, when we hand-tune Adam's momentum, its asynchronous performance improves by at least 2.5x.
In the same setting, the closed-loop control architecture speeds up \tuner by up to 2x,
%closing \tuner's momentum loop improves its performance by 1.5x-3x.
\jianedits{allowing \Asynctuner to outperform Adam with a more than 2.7x speedup}.
\jianedits{As a conclusion, we present related work in Section~\ref{sec:related} and discussion in Section~\ref{sec:discussion}.}
%We conclude with related work in Section~\ref{sec:related} and discussion in Section~\ref{sec:discussion}

%We introduce our contributions in Sections~\ref{sec:momentum_operator},\ref{sec:sync_tuner},\ref{sec:async_tuner}.
%Section~\ref{sec:experiments} gives experimental validation of our claims and we conclude with related work in Section~\ref{sec:related} and discussion in Section~\ref{sec:discussion}.


\chapter{Discussion}
The findings of the study lead to the following points of general interest, beginning with the pairwise interactions. For the $T^p - T^-$ pairwise competition, the limitation of testosterone for $T^p$ and that of oxygen for $T^-$ has a major influence on competition and its outcomes. Increasing the limitation of a given resource for one cell relative to the other leads to the more-limited cell going extinct, regardless of specific identity. Only when the limitations are balanced between two types was coexistence observed. Resource levels can therefore act as control levers of the strength of competitive interactions between cell types and therefore determine the feasibility of coexistence. In addition to resource limitations, the relative initial seeding proportion of the cells can push the outcome in favour of the dominant cell. $T^-$ in conventional terms has an advantage due to its shorter doubling time and the requirement of one less resource. A model that doesn’t account for explicit resource dynamics and limitations might therefore predict that $T^-$ always wins. Although competition coefficients can be made to disfavour $T^-$ , justification for such an artefact isn’t straightforward, particularly compared to the emergence of coexistence we observed in our model due to resource limitation effects.

Similar to $T^p - T^-$, the relative limitation for a given resource of one cell over the other, as well as the relative seeding proportion of the cells, both influence the outcomes of the $T^+ - T^p$ pairwise competition. Resource limitations can in fact be directly compared here unlike $T^p - T^-$, as both the cell types share the same qualitative resource dependencies. $T^p$ has an advantage over $T^+$ with oxygen limitations as the latter requires the former for testosterone. However, with testosterone limitation, $T^p$ has a disadvantage relative to $T^+$ as it would be doubly growth-limited by both testosterone and $T^+$ density. Even though symmetric limitation of a resource across both the cell types produces a similar effect, the difference with testosterone is much more pronounced than with oxygen limitation, possibly indicating a stronger dependence on testosterone for these two cell types.

The general trend discussed above holds for the three-way competition as well. Due to the doubling time advantage of $T^-$ and homogeneous limitations across cell types, testosterone limitations on $T^p$ and $T^+$ have a higher influence on maintaining coexistence between the cells. In this context, it has been possible to identify zones of resource limitation for both testosterone and oxygen where the system goes from coexistence to $T^-$ domination. Strong testosterone limitation without a numerical advantage of higher initial seeding density for $T^p$ leads to $T^-$ domination with no influence from oxygen. Weak testosterone limitation with a numerical advantage for $T^p$ leads to coexistence with no influence of oxygen. Meanwhile, in the other cases where testosterone limitation is intermediate, the outcomes of competition are pushed either towards coexistence or $T^-$ dominance by the oxygen limitation.

This framework used for studying competition alone then helps us understand the outcomes of therapy in mechanistic terms. $T^p$ and $T^+$ are the only cell types to depend on testosterone and hence only they respond to abiraterone. SOC creates an additional limitation of testosterone by reducing the production rates and hence pushes these two cell types to extinction. AT would have no influence where $T^p$ and $T^+$ are pushed to extinction by competition alone and maximum influence when the tumour is dominated by $T^p$ and $T^+$. The resource limitations and seeding proportions therefore have an influence on the success of AT. The success of AT also depends crucially on the therapy window. Higher window would lead to better success, but at the increased physiological cost of maintaining a larger tumour. Meanwhile, with a smaller window achieving control would be more difficult and there would be a higher risk of competitive release. While this mechanistic information makes for a thorough understanding of the system from first principles, it also highlights the gap between the modelling approach and clinical reality. It is clear that application of such ecologically-aware treatment strategies would also require a quantum shift in the nature of information that can be realistically obtained from a cancer patient over meaningful timescales.

Insofar as eliminating the treatment-resistant cell type, all the therapy strategies we tried have been a failure. But, some of this failure has been informative, and it has been possible to avoid or delay competitive release in some cases by maintaining a non-zero population of the responsive cell types $T^+$ and $T^p$. This is broadly in line with current thinking in the field regarding the goals of AT, which are more focused on achieving control than a complete cure. It is worth noting however, that the total tumour burden even when control was achieved was very close to the model’s maximum effective carrying capacity. This could point to an important gap in the conceptualisation of AT that does not include the physiological cost of control over cure. It may then be worth investigating if AT could also be designed to address ways of minimising this cost alongside tumour control.

This study has been an attempt at a proof of concept to illustrate how ecological dynamics within a cancer system can inform progression as well as therapeutic decisions and outcomes. Based on its results so far, the following lines of further development are worth highlighting:
\begin{enumerate}
  \item The exploration of combination therapy in this study has been limited. While the effects of docetaxel in the model were determined based on available experimental data, the ways in which it can be applied are still open modelling questions that can include the frequency of docetaxel, the magnitude of the dose, and the phase shift between abiraterone and docetaxel. Methods of combination therapy other than docetaxel are also known clinically (radiation, steroids, etc) and some of these can be incorporated into the framework of the current model to understand the dynamics of combination therapy better.
  \item The cell types considered here are an oversimplification of actual cells in a biological system, which are highly variable in their functions and phenotypes. Cancer systems in particular can show an even higher degree of such heterogeneity due to their higher mutation rates and genomic instability. Bringing this to bear on the modelling approach we have taken, exploring a heterogeneity of cellular response across cell types to resource availability would be of interest here due to its strong influence on the outcomes of somatic competition and its effect on therapy. This is how pairwise competition has been explored in this study, and its extension to three-way competition should be informative.
  \item In addition to heterogeneity, the cells can also switch their phenotype based on environmental conditions due to phenotypic plasticity. While some theoretical studies have explored the effect of mutational changes within the context of cell competition \cite{Snippert}, phenotypic plasticity remains understudied. It is possible, however, that implementing plasticity or heterogeneous responses would be much easier with an individual based model, which opens up whole new possibilities of exploring the ecological dynamics of the system.
  \item An individual-based model also allows for the addition of spatial heterogeneity to the system, which is an important component of biological variation in cancer populations. Solid tumours in particular have well-known gradients of resources between the tumour core and edge \cite{Fontaine}, which could again open up even more channels of investigation.
\end{enumerate}

These are possible ways in which the current study could be extended and broadened in scope. However, a more general comment on the modelling approach itself is also justified at this point.

Mathematical modelling is a really powerful tool in biology which helps in understanding a system without use of an actual system for the main experimentation. This can be very useful when experimenting on the actual system or biological model is not possible due to ethics, health risks, etc. However, one must keep in mind that all biological models are simplifications and involve many assumptions. Quoting \cite{Box} ``All models are wrong, but some are useful". There are no objective criteria for what makes a good model, or a fair set of prior assumptions. Every model makes assumptions that are manifestations of constraints inherent to the mathematical framework and data availability.

The concept of carrying capacity in a logistic or Lotka-Volterra system is a debated topic and even more so in cancer systems \cite{McLeod,Deisboeck}. Our model also assumes a carrying capacity derived from a rather arbitrary equilibrium value, $y_i^*$, given in \autoref{K_eq}. However, this arbitrariness is partially alleviated since this carrying capacity is not explicitly fixed and instead is dynamically affected by the current concentration of resources. Nevertheless, it still suffers from the same setbacks of any model that invokes a carrying capacity, which is both difficult to define biologically (especially for cancer populations characterised by ``uncontrolled" growth) and usually impossible to separate from the intrinsic growth rate. This leads to the possibility that a modelling approach that does not involve the carrying capacity at all where the resource availability is directly linked to growth rate in a consumer-resource type model may be better suited to study cancer systems that are typically at the edge of resource availability. Furthermore, comparing the differences between such alternate modelling strategies could itself form an informative study of modelling assumptions and their impact on inferences.

The inherently exponential nature of the model made it very sensitive to parameter values and to small fluctuations in environmental conditions. This is borne out particularly clearly in how this system responds to the application of therapy almost instantaneously. The rapidity of these responses could likely hide subtler dynamics that may be more accessible to a different modelling approach that is designed to pick up on them.

Our modelling approach has been more mechanistic in nature than data driven. We have started with parameters from fundamental processes governing the system for the overall behaviour to emerge out of it. A data driven model on the other hand, fits the parameters to clinical data. One could argue that such a data driven model reflects closer to reality since it follows the same dynamics, however, such models don’t give valuable insight into these fundamental processes and act as black boxes. It may then be useful to explore ways of integrating clinical data more closely into mechanistic models, potentially resulting in mechanistic insight that can be applied more directly to clinical practice.


\chapter{Axiom of adjunction}


\documentclass{article}
\usepackage[elliptic]{qed}

\begin{document}

\section*{Defining variables}

We can define a variable for use later in the document by using the
equivalence (\verb!\equiv!) symbol inside an equation:
%
\begin{qed}
    x \equiv \sqrt{16}
\end{qed}
%
Note the icon next to the equation; \textsf{qed} did not perform
any tests but instead stored the expression for $x$.
%
We can then reference $x$ in subsequent equations, and \textsf{qed}
will recognize it and automatically substitute its definition:
%
\begin{qed}
    x = 4
\end{qed}
%
For convenience, users can also use the starred version of the
equivalence commmand (\verb!\equiv*!), which behaves in the same
way but typesets as a regular equality symbol:
%
%
\begin{qed}
    y \equiv* \sqrt{25}
\end{qed}
%
This works just as before:
%
\begin{qed}
    y = 5
\end{qed}
%
%
\end{document}


\subsection{\texorpdfstring{$\pi$-c}{Pi C}alculus}\label{subsec:pi-calculus}

    The $\pi$-calculus was designed by Robin Milner, Joachim Parrow and David Walker in 1992 as an extension of Milner's work on CCS.
    It was supposed to remain similar to the $\lambda$-calculus as described in~\ref{ssec:lambda-calculus} and improve on CCS by allowing channel names themselves to be sent across channels.

    \begin{definition}{Syntax\\}
        Explained here by~\cite{pi-calculus-intro}\footnotemark, the $\pi$-calculus is constructed from the recursive definition of an expression $P$:
        \footnotetext{See~\cite{pi-calculus} for the original definitions and semantics. The following are functionally equivalent and \textit{I personally believe that the further research on the topic has led to improved definitions and descriptions of the subject.}}
        \begin{center} % revise from ccs document? %
            \begin{tabular}{ l l l }
                $P \quad \defeq$    & $Q \; | \; R$         & (concurrency) \\
                                    & $Q + P$               & (choice) \\
                                    & $c(x).Q$              & (input prefix) \\
                                    & $\bar{c}(x).Q$        & (output prefix) \\
                                    & $\tau.P$              & (silent prefix) \\
                                    & if $x = y$ then $P$   & (match) \\
                                    & $vx.Q$                & (restriction)~\footnotemark\\
                                    & $Q!$                  & (replication)~\footnotemark\\
                                    & $\textbf{0}$          & (null process) \\
            \end{tabular}
        \end{center}
        \addtocounter{footnote}{-1}\footnotetext{This explicitly declares x as local within Q.}
        \stepcounter{footnote}\footnotetext{Replication is defined in theory as $P! \defeq{} P \; | \; P!$. This causes problems in computation as to how much to replicate and is in fact computed differently.}
        where all operations are as found in CCS.
        The notable difference is allowing the sending and receiving of channel names over a channel, similar to passing pointers in traditional programs.
    \end{definition}
    It is worth noting that the match and choice operators are not strictly needed, but are often included as they are usually required to be defined within the calculus anyway.
    The lack of the relabelling operator from CCS (written $\{b / a\}$) may be surprising at first, but the same can be achieved through a definition.
    That is, $P\{a'/a, b'/b\}$ can be recreated within the $\pi$-calculus by \textit{identifying} $P(x, y)$ with $P\{x/a, y/b\}$ in a fashion similar to C-style functions.
    This is simply for the purpose of saving an otherwise unnecessary operator.

    \begin{example*}
        Suppose a process $P$ needs to send multiple names $a, b, c \ldots$ to another process $Q$, but there exist multiple such $Q$s that are all listening on the same channel.
        The naive approach may lead to $Q_1$ receiving $a$, $Q_2$ receiving $b$ etc\ldots
        $P$ can begin by transmitting a private channel name $p$, then transmitting each $a, b, c \ldots$ on $p$:
        \begin{align*}
            (vp) \, \bar{c} p \, . \, \bar{p} a \, . \, \bar{p} b \, . \, \bar{p} c \, . \, P
        \end{align*}
        Then $Q$ must prepare to receive a name then $a, b, c \ldots$ along that named channel, binding each to any desired name:
        \begin{align*}
            c(p) \, . \, p(x) \, . \, p(y) \, . \, p(z) \, . \, Q
        \end{align*}
    \end{example*}
    Note how a generalisation of this could allow $P$ to send a pair of names $(x, a)$ and $Q$ could bind the value $a$ to the name $x$, allowing for hash-map or set-like behaviour.
    \textit{In my opinion, the simplicity of this encoding and the expressiveness it may provide is outstanding.}

    \begin{remarks}
        Built mostly on the work of Milner and CCS, the $\pi$-calculus demonstrated that a simplification in design can (and usually does) lead to a more expressive language.
        There is not much else noteworthy except for the increased ease of use of the calculus over CCS --- the encoding of any examples in \ref{ssec:lambda-calculus} is left as an exercise to the reader in either $\pi$-calculus or CCS.
        While it provides the expressiveness required for Turing-completeness, it does not lend itself to understandability nor clarity of the problem encoding when presented as a standalone expression within the calculus, unless the reader is well-acquainted with the subject in advance.
        Furthermore, larger expressions quickly become unreadable without liberal use of identifiers.
    \end{remarks}


\documentclass{article}

\input{preamble-articles}

\title{Notes on the smash product}
\author{Floris van Doorn \and Stefano Piceghello}
\date{\today}
\usepackage{fullpage}
\newcommand{\pmap}{\to}
\newcommand{\lpmap}{\xrightarrow}
\newcommand{\smsh}{\wedge}
\renewcommand{\phi}{\varphi}
\renewcommand{\epsilon}{\varepsilon}
\newcommand{\tr}{\cdot}
\renewcommand{\o}{\ensuremath{\circ}}
\newcommand{\auxl}{\mathsf{auxl}}
\newcommand{\auxr}{\mathsf{auxr}}
\newcommand{\gluel}{\mathsf{gluel}}
\newcommand{\gluer}{\mathsf{gluer}}
\newcommand{\sy}{^{-1}}
\newcommand{\const}{\ensuremath{\mathbf{0}}\xspace}
\newcommand{\alphabar}{\overline{\alpha}}
\newcommand{\rhobar}{\overline{\rho}}
\newcommand{\lambdabar}{\overline{\lambda}}
\newcommand{\gammabar}{\overline{\gamma}}
\newcommand{\zeroh}{\mathsf{z}}
\newcommand{\oneh}{\mathsf{u}}
\newcommand{\two}{\mathsf{b}}
\newcommand{\twist}{\mathsf{tw}}
\newcommand{\mc}{\mathcal}

\begin{document}

\maketitle

\section{Pointed Types}

\begin{defn}
  We work in the $(\infty,1)$-category of pointed types.
  \begin{itemize}
  \item The objects are pointed types $A$, types together with a basepoint $a_0:A$.
\item 1-cells are pointed maps $f:A\to B$ which are maps with a chosen path $f_0:f(a_0)=b_0$. We
  write $A\pmap B$ for pointed maps and $A\pmap B\pmap C$ means $A\pmap (B\pmap C)$.
\item 2-cells are pointed homotopies. A pointed homotopy $h:f\sim g$ is a homotopy with a chosen 2-path
  $h(a_0) \tr g_0 = f_0$.
\item As 3-cells (or higher cells) we take equalities between 2-cells (or higher cells).
\end{itemize}
\end{defn}

\begin{rmk}\label{rmk:pointed-types}
  All types, maps and homotopies in these notes are pointed, unless explicitly mentioned
  otherwise. Whenever we say that a diagram of $n$-cells commutes we mean it in the sense that there
  is an $(n+1)$-cell witnessing it.
\item Pointed homotopies are equivalent to equalities of pointed types: $(f\sim g)\equiv (f=g)$. So
  we could have chosen to define our 2-cells as equalities between 1-cells. We choose not to, since
  the aforementioned equivalence requires function extensionality. In a type theory where function
  extensionality does not compute (like Lean) it is better to define the type of pointed homotopies
  manually so that the underlying homotopy of a 2-cell is definitionally equal to the homotopy we
  started with. In diagrams, we will denote pointed homotopies by equalities, but we always mean
  pointed homotopies.
\item The type $A\to B$ of pointed maps from $A$ to $B$ is itself pointed, with as basepoint the
  constant map $0\equiv0_{A,B}:A\to B$ which has as underlying function $\lam{a:A}b_0$. We have the homotopies:
  \begin{align*}
  \zeroh_g &: 0 \o g \sim 0 & \zeroh'_f &: f \o 0 \sim 0\\
  \oneh_f &: f \o \idfunc \sim f & \oneh'_g &: \idfunc \o g \sim g
  \end{align*}
  satisfying
  \begin{align*}
  \zeroh_{\idfunc} &= \oneh_0 & \zeroh'_{\idfunc} &= \oneh'_0 \\
  \zeroh_0 &= \zeroh'_0 & \oneh_{\idfunc} &= \oneh'_{\idfunc}
  \end{align*}
\item A pointed equivalence is a pointed map $f : A \to B$ whose underlying map is an
  equivalence. In this case, we can find a pointed map $f\sy:B\to A$ with pointed homotopies
  $f\o f\sy\sim0$ and $f\sy\o f\sim0$.
\end{rmk}

\begin{defn}\label{def:b-and-tw}
We define the pointed equivalences:
  \[\two : (\bool \to X) \simeq X\] where $\bool$ is the type of booleans (pointed in $0_\bool$) with underlying map defined with $\two(f) \defeq f(1_\bool)$, and
  \[\twist : (A \to B \to X) \simeq (B \to A \to X)\]
  with underlying map defined with $\twist(f) \defeq \lam{b}\lam{a}f(a)(b)$.
\end{defn}

\begin{lem}\label{lem:composition-pointed}
  Given maps $f:A'\pmap A$ and $g:B\pmap B'$. Then there are maps
  $(f\pmap C):(A\pmap C)\pmap(A'\pmap C)$ and $(C\pmap g):(C\pmap B)\pmap(C\pmap B')$ given by
  precomposition with $f$, resp. postcomposition with $g$. The map $\lam{g}C\pmap g$ preserves the basepoint, giving rise to a map $$(C\pmap ({-})):(B\pmap B')\pmap(C\pmap B)\pmap(C\pmap B').$$
  Also, the following square commutes:
\begin{center}
\begin{tikzcd}
(A\pmap B) \arrow[r,"A\pmap g"]\arrow[d,"f\pmap B"] & (A\pmap B')\arrow[d,"f\pmap B'"] \\
(A'\pmap B) \arrow[r,"A'\pmap g"] & (A'\pmap B')
\end{tikzcd}
\end{center}

\end{lem}

\section{Naturality and a version of the Yoneda lemma}

\begin{defn}\label{def:naturality}
	A (1-coherent) \emph{functor} $F$ between pointed types is a function $F_0:\type^*\to\type^*$ with an action of morphisms $F_1 : (A \to^* B) \to (FA \to^* FB)$ such that $F_1(g \o f)\sim F_1g \o F_1 f$ and $F_1\idfunc[A]\sim\idfunc[F_0A]$. We will write both $F_0$ and $F_1$ as $F$. A functor $F$ is \emph{pointed} if $F\unit$ is contractible. In this case $F0_{A,B}\sim 0_{FA,FB}$.
	Let $F$, $G$ be functors of pointed types. Suppose that we have a transformation $\theta_X : F(X) \to G(X)$ for all pointed types $X$.
	% \begin{center}
	% \begin{tikzcd}
	% 	F(A)
	% 		\arrow[r, "F(f)"]
	% 		\arrow[d, swap, "\theta_A"]
	% 	& F(B)
	% 		\arrow[d, "\theta_B"]
	% 	\\
	% 	G(A)
	% 		\arrow[r, swap, "G(f)"]
	% 	& G(B)
	% \end{tikzcd}
	% \end{center}
	We define the following notions of naturality for $\theta$:
	\begin{itemize}
		\item \textbf{naturality} will refer to a pointed homotopy
		\[p_\theta(f) : G(f) \o \theta_A \sim \theta_B \o F(f)\]
		for every $f : A \to B$ and \textbf{weak naturality} to the underlying (non-pointed) homotopy;
		\item \textbf{pointed naturality} will refer to the same pointed homotopy, with the additional condition that $p_\theta(0) = (p_\theta)_0$, where
		\[(p_\theta)_0 : G(0) \o \theta_A \sim 0 \o \theta_A \sim 0 \sim \theta_B \o 0 \sim \theta_B \o F(0)\]
		is the canonical proof of the pointed homotopy $G(0) \o \theta_A \sim \theta_B \o F(0)$, whereas \textbf{pointed weak naturality} will refer to the corresponding non-pointed condition.
	\end{itemize}
\end{defn}

\begin{rmk}
	The relation between the four notions of naturality is as expected: naturality implies weak naturality, and pointed implies simple. Weak naturality is generally ill-behaved: for example, weak naturality of $\theta$ does not imply weak naturality of $\theta \to X$ or $X \to \theta$, whereas the implication holds for naturality.
\end{rmk}

\begin{rmk}
	The equivalences $\two$ and $\twist$ as defined in \autoref{def:b-and-tw} are natural in all their arguments and pointed natural in the last argument.
\end{rmk}

\begin{lem}[Yoneda]\label{lem:yoneda}
	Let $A$, $B$ be pointed types, and assume, for all pointed types $X$, a pointed equivalence $\phi_X : (B \to X) \simeq (A \to X)$, natural in $X$, i.e. for all $f : X \to X'$ there is a pointed homotopy \[ p_\phi(f) : (A \to f) \o \phi_X \sim \phi_{X'} \o (B \to f) \]
%	 making the following diagram commute for all $f : X \to X'$:
%	\begin{center}
%	\begin{tikzcd}
%		(B \to X)
%			\arrow[r, "\phi_X"]
%			\arrow[d, swap, "f \o -"]
%		& (A \to X)
%			\arrow[d, "f \o -"]
%		\\
%		(B \to X')
%			\arrow[r, swap,"\phi_{X'}"]
%		& (A \to X')
%	\end{tikzcd}
%	\end{center}
	Then there exists a pointed equivalence $\psi_\phi : A \simeq B$.
\end{lem}
\begin{proof}
	We define $\psi_\phi \defeq \phi_B(\idfunc[B]) : A \to B$ and $\psi_\phi\sy \defeq \phi_A\sy(\idfunc[A]):B\to A$. The given naturality square for $f \defeq \psi_\phi\sy$ yields $\psi_\phi\sy \o \phi_B (\idfunc[B]) \judgeq \psi_\phi\sy \o \psi_\phi \sim \phi_A (\psi_\phi\sy \o \idfunc[B]) \judgeq \phi_A (\phi_A\sy (\idfunc[A])) \sim \idfunc[A]$, and similarly for the inverse composition.
\end{proof}

\begin{lem}\label{lem:yoneda-pointed}
	Assume $A$, $B$, $\phi_X$ and $p$ as in \autoref{lem:yoneda}, and assume moreover that $\phi$ is pointed natural. Then there is a pointed homotopy $(\psi_\phi \to X) \sim \phi_X$.
\end{lem}

\begin{proof}
	Let $f : B \to X$. The underlying homotopy is obtained by:
	\begin{align*}
		(\psi_\phi \to X)(f) &\judgeq f \o \psi_\phi\\
		&\sim \phi_X (f \o \idfunc) &&\text{(by $p_\phi(f)(\idfunc)$)}\\
		&\sim \phi_X (f) &&\text{(by $\mapfunc{\phi_X}(\oneh_f)$)}
	\end{align*}
	To show that this is a pointed homotopy, we need to prove that the following diagram commutes:
	\begin{center}
	\begin{tikzcd}[column sep=4em]
		(\psi_\phi \to X)(0)
			\arrow[rr, equals, "p_\phi(0)(\idfunc)\tr\mapfunc{\phi_X}(\oneh_0)"]
			\arrow[dr, equals, swap, "\zeroh_{\psi_\phi}"]
		&&\phi_X(0)
			\arrow[dl, equals, "(\phi_X)_0"]
		\\
		&0
	\end{tikzcd}
	\end{center}
	where the top-left expression is definitionally equal to $0 \o \phi_X(\idfunc)$, the horizontal path comes from the underlying homotopy and $(\phi_X)_0$ is the canonical path from $\phi_X(0)$ to $0$. Since $\phi_X$ is pointed natural, we have that
	$p_{\phi_X}(0)(\idfunc) = (p_{\phi_X})_0(\idfunc)$, which, in this case, is the concatenation:
	\begin{align*}
	0\o \phi_X(\idfunc)
	&= 0 &&\text{(by $\zeroh_{q_X(\idfunc)}$)}\\
	&= \phi_X(0) &&\text{(by $(\phi_X)_0\sy$)}\\
	&= \phi_X(0\o 1) &&\text{(by $(\mapfunc{\phi_X}(\zeroh_{\idfunc}))\sy$)}
	\end{align*}
	The diagram then commutes by cancellation of inverses and using that $\zeroh_{\idfunc} = \oneh_0$.
\end{proof}

\section{Smash Product}\label{sec:smash}

\begin{defn}
  The smash of $A$ and $B$ is the HIT generated by the point constructor $(a,b)$ for $a:A$ and $b:B$
  and two auxilliary points $\auxl,\auxr:A\smsh B$ and path constructors $\gluel_a:(a,b_0)=\auxl$
  and $\gluer_b:(a_0,b)=\auxr$ (for $a:A$ and $b:B$). $A\smsh B$ is pointed with point $(a_0,b_0)$.
\end{defn}
\begin{rmk}
  This definition of $A\smsh B$ is basically the pushout of
  $\bool\leftarrow A+B\to A \times B$.  A more traditional definition of $A\smsh B$ is the pushout
  $\unit\leftarrow A\vee B\to A \times B$; here $\vee$ denotes the wedge product, which can be
  equivalently described as either the pushout $A\leftarrow \unit\to B$ or
  $\unit\leftarrow \bool\to A + B$. These two definitions of $A\smsh B$ are equivalent, because in
  the following diagram the top-left square and the top rectangle are pushout squares, hence the
  top-right square is a pushout square by applying the pushout lemma. Another application of the
  pushout lemma then states that the two definitions of $A\smsh B$ are equivalent.
\begin{center}
\begin{tikzcd}
\bool \arrow[r]\arrow[d] & A+B     \arrow[r]\arrow[d] & \bool \arrow[d] \\
\unit \arrow[r]          & A\vee B \arrow[r]\arrow[d] & \unit \arrow[d] \\
                     & A\times B        \arrow[r] & A\smsh B
\end{tikzcd}
\end{center}

\end{rmk}
\begin{lem}\label{lem:smash-general}
	The smash product is functorial: if $f:A\pmap A'$ and $g:B\pmap B'$ then
    $f\smsh g:A\smsh B\pmap A'\smsh B'$. We write $A\smsh g$ or $f\smsh B$ if one of the
    functions is the identity function. Moreover, if $p:f\sim f'$ and $q:g\sim g'$ then $p\smsh q:f\smsh g\sim f'\smsh g'$; this operation preserves reflexivities, symmetries and transitivies. We will write $p \smsh g$ or $f \smsh q$ if one of the homotopies is reflexivity.
%	The smash product satisfies the following properties.
%  \begin{itemize}
%  \item The smash product is functorial: if $f:A\pmap A'$ and $g:B\pmap B'$ then
%    $f\smsh g:A\smsh B\pmap A'\smsh B'$. We write $A\smsh g$ or $f\smsh B$ if one of the
%    functions is the identity function.
%  \item The smash product preserves composition, which gives rise to the interchange law:
%    \[i:(f' \o f)\smsh (g' \o g) \sim f' \smsh g' \o f \smsh g\]
%  \item If $p:f\sim f'$ and $q:g\sim g'$ then $p\smsh q:f\smsh g\sim f'\smsh g'$. This operation
%    preserves reflexivities, symmetries and transitivies.
%  \item There are homotopies $f\smsh0\sim0$ and $0\smsh g\sim 0$ such that the following diagrams
%    commute for given homotopies $p : f\sim f'$ and $q : g\sim g'$.
%    \begin{center}
%\begin{tikzcd}
%f\smsh 0 \arrow[rr, equals,"p\smsh1"]\arrow[dr,equals] & &
%f'\smsh 0\arrow[dl,equals] \\
%& 0 &
%\end{tikzcd}
%\qquad
%\begin{tikzcd}
%0\smsh g\arrow[rr, equals,"1\smsh q"]\arrow[dr,equals] & &
%0\smsh g'\arrow[dl,equals] \\
%& 0 &
%\end{tikzcd}
%\end{center}
%\end{itemize}
\end{lem}

\begin{lem}\label{lem:interchange}
	The smash product preserves composition, which gives rise to the interchange law:
    \[i:(f_2 \o f_1)\smsh (g_2 \o g_1) \sim f_2 \smsh g_2 \o f_1 \smsh g_1\]
    for maps $A_1\lpmap{f_1}A_2\lpmap{f_2}A_3$ and $B_1\lpmap{g_1}B_2\lpmap{g_2}B_3$.
\end{lem}
\begin{proof}
	Let us denote the basepoints of $A_i$ and $B_i$ with $a_i$ and $b_i$ respectively. We first apply induction on the paths that all the maps in the statement respect the basepoint. We verify the underlying homotopy of $i$ by induction on terms $x$ of the domain $A_1 \smsh B_1$ of the two maps; this can be defined on point constructors $(a,b)$, $\auxl$ and $\auxr$ to be the identity path. If $x$ varies over $\gluel_a$, we need to fill the following square:
	\begin{equation}\label{eq:i-gluel}
	\begin{tikzcd}
		(f_2(f_1(a)), b_3)
			\arrow[r,equals,"1"]
			\arrow[d,swap,equals,"\mapfunc{(f_2 \o f_1)\smsh (g_2 \o g_1)}(\gluel_a)"]
		& (f_2(f_1(a)), b_3)
			\arrow[d,equals,"\mapfunc{f_2 \smsh g_2 \o f_1 \smsh g_1}(\gluel_a)"]
		\\
		\auxl
			\arrow[r,swap,equals,"1"]
		&\auxl
	\end{tikzcd}
	\end{equation}
	This reduces to proving that
	\[\mapfunc{(f_2(f_1(a)),-)}(g_2\o g_1)_0 \tr \gluel_{f_2(f_1(a))} = \mapfunc{(f_2(f_1(a)),-)}(\mapfunc{g_2}{(g_1)}_0 \tr {(g_2)}_0) \tr \gluel_{f_2(f_1(a))}\]
	Since we assumed that ${(g_1)}_0$ and ${(g_2)}_0$ are the identity path, the claim is easily verified. The case for $x$ varying over $\gluer_b$ is entirely analogous, giving the square:
	\begin{equation}\label{eq:i-gluer}
	\begin{tikzcd}
		(a_3, g_2(g_1(b))
			\arrow[r,equals,"1"]
			\arrow[d,swap,equals,"\mapfunc{(f_2 \o f_1)\smsh (g_2 \o g_1)}(\gluer_b)"]
		& (a_3, g_2(g_1(b))
			\arrow[d,equals,"\mapfunc{f_2 \smsh g_2 \o f_1 \smsh g_1}(\gluer_b)"]
		\\
		\auxr
			\arrow[r,swap,equals,"1"]
		&\auxr
	\end{tikzcd}
	\end{equation}
	The resulting homotopy is pointed, as $i(a_1,b_1) \judgeq 1$ and the proofs that the two maps respect the basepoint are assumed to be the identity path.
\end{proof}

\begin{lem}\label{lem:smash-zero}
	There are homotopies
	\begin{align*}
	t_g : 0\smsh g\sim 0 && t'_f : f\smsh0\sim0
	\end{align*}
	such that the following diagrams
    commute for given homotopies $p : g\sim g'$ and $q : f\sim f'$.
    \begin{equation}\label{eq:t-triangles}
	\begin{tikzcd}
	0\smsh g
		\arrow[rr, equals,"1\smsh p"]
		\arrow[dr,equals,swap,"t_g"]
	&& 0\smsh g'\arrow[dl,equals,"t_{g'}"]
	&f\smsh 0
		\arrow[rr, equals,"q\smsh 1"]
		\arrow[dr,equals,swap, "t'_f"]
	&& f'\smsh 0\arrow[dl,equals,"t'_{f'}"]
	\\
	& 0
	&&& 0
	\end{tikzcd}
%	\qquad\qquad
%	\begin{tikzcd}
%	f\smsh 0
%		\arrow[rr, equals,"q\smsh 1"]
%		\arrow[dr,equals,swap, "t'_f"]
%	&& f'\smsh 0\arrow[dl,equals,"t'_{f'}"]
%	\\
%	& 0
%	\end{tikzcd}
	\end{equation}
\end{lem}
\begin{proof}
	We will define the homotopy $t_g : 0 \smsh g$, with $0 : A_1 \to A_2$ and $g : B_1 \to B_2$ (with the notational convention for the basepoints as in \autoref{lem:interchange}); the definition for $t'_f$ is analogous. First, we apply induction on the path that $g$ respects the basepoint. The underlying homotopy of $t_g$ is given by induction on terms $x : A_1 \smsh B_1$. On point constructors, we define:
	\begin{align*}
	t_g (a,b) &\defeq \gluer_{g(b)} \tr \gluer_{b_2}\sy && : (a_2, g(b)) = (a_2, b_2)\\
	t_g (\auxl) &\defeq \gluel_{a_2}\sy && : \auxl = (a_2, b_2)\\
	t_g (\auxr) &\defeq \gluer_{b_2}\sy && : \auxr = (a_2, b_2)
	\end{align*}
	If $x$ varies over $\gluel_a$, after some reductions, we need to fill the following square:
	\begin{equation}\label{eq:t-gluel}
	\begin{tikzcd}[column sep=7em]
		(a_2, g(b_1))
			\arrow[r,equals,"\gluer_{b_2} \tr \gluer_{b_2}\sy"]
			\arrow[d,swap,equals, "\gluel_{a_2}"]
		& (a_2, b_2)
			\arrow[d,equals,"1"]
		\\
		\auxl
			\arrow[r,swap,equals, "\gluel_{a_2}\sy"]
		& (a_2, b_2)
	\end{tikzcd}
	\end{equation}
	Similarly, if $x$ varies over $\gluer_b$, we need to fill the following square:
	\begin{equation}\label{eq:t-gluer}
	\begin{tikzcd}[column sep=7em]
		(a_2, g(b))
			\arrow[r,equals,"\gluer_{g(b)} \tr \gluer_{b_2}\sy"]
			\arrow[d,swap,equals, "\gluer_{g(b)}"]
		& (a_2, b_2)
			\arrow[d,equals,"1"]
		\\
		\auxr
			\arrow[r,swap,equals, "\gluer_{b_2}\sy"]
		& (a_2, b_2)
	\end{tikzcd}
	\end{equation}
	The squares in (\ref{eq:t-gluel}) and (\ref{eq:t-gluer}) can both be filled by simple path algebra. The resulting homotopy is pointed, as $t_g(a_1,b_1)$ is equal to the identity path and the proof that $g$ respects the basepoint is also assumed to be the identity path. Finally, for $p : g \sim g'$, the diagram on the left in (\ref{eq:t-triangles}) commutes by induction on $p$.
\end{proof}

\begin{lem}\label{lem:smash-coh}
 	Suppose that we have maps $A_1\lpmap{f_1}A_2\lpmap{f_2}A_3$ and $B_1\lpmap{g_1}B_2\lpmap{g_2}B_3$
 	and suppose that either $f_1$ or $f_2$ is constant. Then there are two homotopies
  $(f_2 \o f_1)\smsh (g_2 \o g_1)\sim 0$, one which uses the interchange law and one which does not. These two homotopies are equal. Specifically, the following two diagrams commute:
	\begin{center}
	\begin{tikzcd}
		(f_2 \o 0)\smsh (g_2 \o g_1)
			\arrow[r, equals, "i"]
			\arrow[dd, swap, equals, "\zeroh' \smsh (g_2 \o g_1)"]
		&(f_2 \smsh g_2)\o (0 \smsh g_1)
			\arrow[d, equals, "(f_2 \smsh g_2) \o t_{g_1}"]
		\\
		& (f_2 \smsh g_2)\o 0
			\arrow[d,equals, "\zeroh'"]
		\\
		0\smsh (g_2 \o g_1)
			\arrow[r,equals, swap, "t_{g_2 \o g_1}"]
		& 0
	\end{tikzcd}
	\qquad
	\begin{tikzcd}
		(0 \o f_1)\smsh (g_2 \o g_1)
			\arrow[r, equals, "i"]
			\arrow[dd, swap, equals, "\zeroh \smsh (g_2 \o g_1)"]
		& (0 \smsh g_2)\o (f_1 \smsh g_1)
			\arrow[d,equals, "t_{g_2} \o (f_1 \smsh g_1)"]
		\\
		& 0\o (f_1 \smsh g_1)
			\arrow[d,equals, "\zeroh"]
		\\
		0\smsh (g_2 \o g_1)
			\arrow[r,swap, equals, "t_{g_2 \o g_1}"]
		& 0
	\end{tikzcd}
	\end{center}

\end{lem}
\begin{proof}
%  We will only do the case where $f_1\jdeq 0$, i.e. fill the diagram on the left. The other case is similar (and slightly easier).

	\textbf{Case $f_1\judgeq 0$ (diagram on the left)}. First apply induction on the paths that $f_2$, $g_1$ and $g_2$
  respect the basepoint. In this case $f_2\o0$ is definitionally equal to $0$, and the canonical
  proof that $f_2\o 0\sim0$ is (definitionally) equal to reflexivity. This means that the homotopy
  $(f_2 \o 0)\smsh (g_2 \o g_1)\sim0\smsh (g_2 \o g_1)$ is also equal to reflexivity, and also the
  path that $f_2 \smsh g_2$ respects the basepoint is reflexivity, hence the homotopy
  $(f_2 \smsh g_2)\o 0\sim0$ is also reflexivity. This means we need to fill the following square:
	\begin{center}
	\begin{tikzcd}
		(f_2 \o 0)\smsh (g_2 \o g_1)
			\arrow[r, equals,"i"]
			\arrow[d, swap, equals,"1"]
		& (f_2 \smsh g_2)\o (0 \smsh g_1)
			\arrow[d,equals,"(f_2\smsh g_2)\o t_{g_1}"]
		\\
		0 \smsh (g_2 \o g_1)
			\arrow[r, swap, equals,"t_{g_1 \o g_2}"]
		& 0
	\end{tikzcd}
	\end{center}
  For the underlying homotopy, take $x : A_1\smsh B_1$ and apply induction on $x$. Suppose
  $x\equiv(a,b)$ for $a:A_1$ and $b:B_1$. With the notational convention for basepoints as in \autoref{lem:interchange}, we have to fill the square (we use that the paths that the maps respect the basepoints are reflexivity):
  \begin{equation}\label{eq:pent-left-ab}
    \begin{tikzcd}[column sep=5em]
	(a_3,g_2(g_1(b)))
      	\arrow[r, equals,"1"]
      	\arrow[d,swap,equals,"1"]
		%\arrow[d,equals,"\gluer_{g_2(g_1(b))}\tr\gluer_{g_2(g_1(b_1))}\sy"]
	& (a_3,g_2(g_1(b)))
		\arrow[d,equals,"\mapfunc{f_2\smsh g_2}(\gluer_{g_1(b)}\tr\gluer_{b_2}\sy)"]
	\\
	(a_3,g_2(g_1(b)))
		\arrow[r,swap,equals,"\gluer_{g_2(g_1(b))}\tr\gluer_{b_3}\sy"]
	& (a_3,b_3)
    \end{tikzcd}
    \end{equation}
   Now $\mapfunc{h\smsh k}(\gluer_z)=\gluer_{k(z)}$, so by general groupoid laws we see that the path on the bottom is equal to the path on the right, which means we can fill the square. For the other point constructors, the squares to fill are similar: if $x \judgeq \auxl$, we have:
      \begin{equation}\label{eq:pent-left-auxl}
    \begin{tikzcd}[column sep=5em]
      \auxl \arrow[r, equals,"1"]
      \arrow[d,swap,equals,"1"] &
      \auxl \arrow[d,equals,"\mapfunc{f_2\smsh g_2}(\gluel_{a_2}\sy)"] \\
      \auxl \arrow[r,swap, equals,"\gluel_{a_3}\sy"] &
      (a_3,b_3)
    \end{tikzcd}
 \end{equation}
	which we can fill, as the path on the bottom is definitionally equal to $\gluel_{a_3}\sy$ (as we applied path induction on the path that $f_2$ respects the basepoint) and the path on the right  also reduces to $\gluel_{a_3}\sy$ using that $\mapfunc{h\smsh k}(\gluel_z)=\gluel_{h(z)}$. Similarly, we can fill the square for $x \judgeq \auxr$, which is:
  \begin{equation}\label{eq:pent-left-auxr}
    \begin{tikzcd}[column sep=5em]
      \auxr \arrow[r, equals,"1"]
      \arrow[d,swap,equals,"1"] &
      \auxr \arrow[d,equals,"\mapfunc{f_2\smsh g_2}(\gluer_{b_2}\sy)"] \\
      \auxr \arrow[r,swap, equals,"\gluer_{b_3}\sy"] &
      (a_3,b_3)
    \end{tikzcd}
  \end{equation}
	If $x$ varies over $\gluel_a$, after some reductions, we need to fill the following cube, where the front and the back are the squares in (\ref{eq:pent-left-ab}) for $(a,b_1)$ and (\ref{eq:pent-left-auxl}) respectively; the left square is degenerate; the other three sides are the squares in the definition of $i$ and $t$ to show that they respect $\gluel_a$ (given in (\ref{eq:i-gluel}) and (\ref{eq:t-gluel}) respectively), where we also apply $f_2 \smsh g_2$ to the square on the right. We suppress in the diagram the arguments of $\gluer$ in $\gluer\tr\gluer\sy$ (which match, so the concatenation results equal to the identity path).
	\begin{equation}\label{eq:pent-left-gluel}
	\begin{tikzcd}[column sep=5em]
	& \auxl
		\arrow[rr, equals, "1"]
		\arrow[dd, swap, equals, near end, "1"]
	&& \auxl
		\arrow[dd, equals, "\mapfunc{f_2\smsh g_2} (\gluel_{a_2}\sy)"]
	\\
	(a_3,b_3)
		\arrow[ur, equals, "\gluel_{a_3}"]
		\arrow[dd, swap, equals, "1"]
		\arrow[rr, equals, crossing over, near end, "1"]
	&& (a_3,b_3)
		\arrow[ur, equals, near start, "\mapfunc{f_2\smsh g_2}(\gluel_{a_2})"]
		%\arrow[dd, equals, near start, "\mapfunc{f_2\smsh g_2}(\gluer\tr\gluer\sy)"]
	\\
	& \auxl
		\arrow[rr, swap, equals, near start, "\gluel_{a_3}\sy"]
	&& (a_3,b_3)
	\\
	(a_3,b_3)
		\arrow[ur, equals, "\gluel_{a_3}"]
		\arrow[rr, swap, equals, "\gluer\tr\gluer\sy"]
	&& (a_3,b_3)
		\arrow[ur, swap, equals, "1"] %1
		\arrow[from=uu, equals, crossing over, very near start, "\mapfunc{f_2 \smsh g_2}(\gluer\tr\gluer\sy)"]
	\end{tikzcd}
	\end{equation}
	Similarly, if $x$ varies over $\gluer_b$, we need to fill the cube below: the front and the back are the squares in (\ref{eq:pent-left-ab}) for $(a_1,b)$ and (\ref{eq:pent-left-auxr}) respectively; the left square is again degenerate; the other three sides come from the fact that $i$ and $t$ respect $\gluer_b$ (given in (\ref{eq:i-gluer}) and (\ref{eq:t-gluer}) respectively). Again, we omit the arguments of $\gluer$ in $\gluer\tr\gluer\sy$ (in this case, not a priori judgementally equal).
	\begin{equation}\label{eq:pent-left-gluer}
	\begin{tikzcd}[column sep=4em]
	& \auxr
		\arrow[rr, equals,"1"]
		\arrow[dd, swap, equals, near end,"1"]
	&& \auxr
		\arrow[dd,equals,"\mapfunc{f_2\smsh g_2}(\gluer_{b_2}\sy)"]
	\\
	(a_3,g_2(g_1(b)))
		\arrow[rr, equals, near end, crossing over, "1"]
		\arrow[dd, swap, equals, "1"]
		\arrow[ur, equals, "\gluer_{g_2(g_1(b))}"]
	&& (a_3,g_2(g_1(b)))
		\arrow[ur, equals, near start, "\mapfunc{f_2\smsh g_2}(\gluer_{g_1(b)})"]
	\\
	& \auxr
		\arrow[rr, swap, equals, near start, "\gluer_{b_3}\sy"]
	&& (a_3,b_3)
	\\
	(a_3,g_2(g_1(b)))
		\arrow[rr, swap, equals,"\gluer\tr\gluer\sy"]
		\arrow[ur, equals, near end, "\gluer_{g_2(g_1(b))}"]
	&& (a_3,b_3)
		\arrow[from=uu, equals, crossing over, very near start, "\mapfunc{f_2\smsh g_2}(\gluer\tr\gluer\sy)"]
		\arrow[ur, swap, equals, "1"]
	\end{tikzcd}
	\end{equation}
  %After canceling applications of  $\mapfunc{h\smsh k}(\gluer_z)=\gluer_{k(z)}$ on various sides of the squares (TODO).
  In order to fill the cubes in (\ref{eq:pent-left-gluel}) and (\ref{eq:pent-left-gluer}), we generalize the paths and fill the cubes by path induction. The cube in (\ref{eq:pent-left-gluel}) can be generalized to a cube:
  \begin{center}
  	\begin{tikzcd}[column sep=3em]
	& h(y)
		\arrow[rr, equals,"1"]
		\arrow[dd, swap, equals, near end,"1"]
	&& h(y)
		\arrow[dd,equals,"\mapfunc{h}(p_l\sy)"]
	\\
	h(x)
		\arrow[rr, equals, near end, crossing over, "1"]
		\arrow[dd, swap, equals, "1"]
		\arrow[ur, equals, "q_l"]
	&& h(x)
		\arrow[ur, equals, near start, "\mapfunc{h}(p_l)"]
	\\
	& h(y)
		\arrow[rr, swap, equals, near start, "q_l\sy"]
	&& h(x)
	\\
	h(x)
		\arrow[rr, swap, equals,"q_r\tr q_r\sy"]
		\arrow[ur, equals, "q_l"]
	&& h(x)
		\arrow[from=uu, equals, crossing over, near start, "\mapfunc{h}(p_r\tr p_r\sy)"]
		\arrow[ur, swap, equals, "1"]
	\end{tikzcd}
	\end{center}
	for $X$ and $X'$ pointed types; a map $h : X \to X'$; terms $x$, $y$ $z : X$; paths $p_l : x = y$, $p_r : x = z$, $q_l : h(x) = h(y)$, $q_r : h(x) = h(z)$; and 2-paths $s_l : \mapfunc{h}(p_l) = q_l$ (for the back and the top) and $s_r : \mapfunc{h}(p_r) = q_r$ (for the right side). This cube is filled by path induction on $s_l$, $s_r$, $p_l$ and $p_r$. The cube in (\ref{eq:pent-left-gluer}) can be generalized to a similar cube:
	 \begin{center}
  	\begin{tikzcd}[column sep=3em]
	& h(y)
		\arrow[rr, equals,"1"]
		\arrow[dd, swap, equals, near end,"1"]
	&& h(y)
		\arrow[dd,equals,"\mapfunc{h}(p_b)"]
	\\
	h(x)
		\arrow[rr, equals, near end, crossing over, "1"]
		\arrow[dd, swap, equals, "1"]
		\arrow[ur, equals, "q_l"]
	&& h(x)
		\arrow[ur, equals, near start, "\mapfunc{h}(p_l)"]
	\\
	& h(y)
		\arrow[rr, swap, equals, near start, "q_b"]
	&& h(z)
	\\
	h(x)
		\arrow[rr, swap, equals,"q_l\tr q_b"]
		\arrow[ur, equals, "q_l"]
	&& h(z)
		\arrow[from=uu, equals, crossing over, near start, "\mapfunc{h}(p_l\tr p_b)"]
		\arrow[ur, swap, equals, "1"]
	\end{tikzcd}
	\end{center}
	for paths $p_l : x = y$, $p_b : y = z$, $q_l : h(x) = h(y)$, $q_b : h(y) = h(z)$ and for 2-paths $s_l : \mapfunc{h}(p_l) = q_l$ (for the top) and $s_b : \mapfunc{h}(p_b) = q_b$ (for the back).

	\textbf{Case $f_2\judgeq 0$ (diagram on the right)}.	(TODO)

  To show that this homotopy is pointed, (TODO)

\end{proof}

\begin{thm}\label{thm:smash-functor-right}
Given pointed types $A$, $B$ and $C$, the functorial action of the smash product induces a map
$$({-})\smsh C:(A\pmap B)\pmap(A\smsh C\pmap B\smsh C)$$
which is natural in $A$, pointed natural in $B$ and dinatural in $C$.
\end{thm}
The naturality and dinaturality means that the following squares commute for $f : A' \to A$ $g:B\to B'$ and $h:C\to C'$.
\begin{center}
\begin{tikzcd}[column sep=5em]
(A\pmap B) \arrow[r,"({-})\smsh C"]\arrow[d,"f\pmap B"] &
(A\smsh C\pmap B\smsh C)\arrow[d,"f\smsh C\pmap B\smsh C"] \\
(A'\pmap B) \arrow[r,"({-})\smsh C"] &
(A'\smsh C\pmap B\smsh C)
\end{tikzcd}
\qquad
\begin{tikzcd}[column sep=5em]
(A\pmap B) \arrow[r,"({-})\smsh C"]\arrow[d,"A\pmap g"] &
(A\smsh C\pmap B\smsh C)\arrow[d,"A\smsh C\pmap g\smsh C"] \\
(A\pmap B') \arrow[r,"({-})\smsh C"] &
(A\smsh C\pmap B'\smsh C)
\end{tikzcd}
\begin{tikzcd}[column sep=5em]
(A\pmap B) \arrow[r,"({-})\smsh C"]\arrow[d,"({-})\smsh C'"] &
(A\smsh C\pmap B\smsh C)\arrow[d,"A\smsh C\pmap B\smsh h"] \\
(A\smsh C'\pmap B\smsh C') \arrow[r,"A\smsh h\pmap B\smsh C'"] &
(A\smsh C\pmap B\smsh C')
\end{tikzcd}
\end{center}
\begin{proof}
First note that $\lam{f}f\smsh C$ preserves the basepoint so that the map is indeed pointed.

Let $k:A\pmap B$. Then as homotopy the naturality in $A$ becomes
$(k\o f)\smsh C=k\smsh C\o f\smsh C$. To prove an equality between pointed maps, we need to give
a pointed homotopy, which is given by interchange. To show that this homotopy is pointed, we need to
fill the following square (after reducing out the applications of function extensinality), which follows from \autoref{lem:smash-coh}.
\begin{center}
\begin{tikzcd}
(0 \o f)\smsh C \arrow[r, equals]\arrow[dd,equals] &
(0 \smsh C)\o (f \smsh C)\arrow[d,equals] \\
& 0 \o (f \smsh C)\arrow[d,equals] \\
0\smsh C \arrow[r,equals] &
0
\end{tikzcd}
\end{center}
The naturality in $B$ is almost the same: for the underlying homotopy we need to show
$i:(g \o k)\smsh C = g\smsh C \o k\smsh C$. For the pointedness we need to fill the following
square, which follows from the left pentagon in \autoref{lem:smash-coh}.
\begin{center}
\begin{tikzcd}
(g \o 0)\smsh C \arrow[r, equals]\arrow[dd,equals] &
(g \smsh C)\o (0 \smsh C)\arrow[d,equals] \\
& (g\smsh C) \o 0\arrow[d,equals] \\
0\smsh C \arrow[r,equals] &
0
\end{tikzcd}
\end{center}
To show that this naturality is pointed, we need to show that if $g=0$ then this homotopy is the same as the concatenation $q_0$ of the following pointed homotopies:
$$({-})\smsh C \circ (A \to 0)\sim ({-})\smsh C \circ 0 \sim 0 \sim 0 \circ ({-})\smsh C\sim 0\smsh B \circ ({-})\smsh C.$$
To show that the underlying homotopies are the same, we need to show that $i(0,f,\idfunc[C],\idfunc[C])$ is equal to the following concatenation of pointed homotopies
$$q_0(f):(0\circ f)\smsh C\sim 0\smsh C \sim 0 \sim 0 \circ f\smsh C\sim 0\smsh B \circ f\smsh C,$$
which is the right pentagon in \autoref{lem:smash-coh}.
To show that these pointed homotopies respect the basepoint in the same way, we need to show that (TODO)
``$R\mathrel\square(0\smsh C \circ t)\cdot q_0=L$ where $L$ and $R$ are the left and right pentagons applied to $0$ and $\square$ is whiskering.''

The dinaturality in $C$ is a bit harder. For the underlying homotopy we need to show
$B\smsh h\o k\smsh C=k\smsh C'\o A\smsh h$. This follows by applying interchange twice:
$$B\smsh h\o k\smsh C\sim(\idfunc[B]\o k)\smsh(h\o\idfunc[C])\sim(k\o\idfunc[A])\smsh(\idfunc[C']\o h)\sim k\smsh C'\o A\smsh h.$$
To show that this homotopy is pointed, we need to fill the following square:
\begin{center}
  \begin{tikzcd}
    B\smsh h\o 0\smsh C \arrow[r, equals]\arrow[d,equals] &
    (\idfunc[B]\o 0)\smsh(h\o\idfunc[C]) \arrow[r, equals]\arrow[d,equals] &
    (0\o\idfunc[A])\smsh(\idfunc[C']\o h)\arrow[r, equals]\arrow[d,equals] &
    0\smsh C'\o A\smsh h\arrow[d,equals] \\
    B\smsh h\o 0 \arrow[d,equals] &
    0\smsh(h\o\idfunc[C]) \arrow[r, equals]\arrow[d,equals] &
    0\smsh(\idfunc[C']\o h) \arrow[d,equals] &
    0\o A\smsh h\arrow[d,equals] \\
    B\smsh h\o 0 \arrow[r, equals] &
    0 \arrow[r, equals] &
    0 \arrow[r, equals] &
    0
  \end{tikzcd}
\end{center}
The left and the right squares are filled by \autoref{lem:smash-coh}. The squares in the middle
are filled by (corollaries of) \autoref{lem:smash-general}.
\end{proof}

\section{Adjunction}

\begin{lem}\label{lem:unit-counit}
  There is a unit $\eta_{A,B}\equiv\eta:A\pmap B\pmap A\smsh B$ natural in $A$ and counit
  $\epsilon_{B,C}\equiv\epsilon : (B\pmap C)\smsh B \pmap C$ dinatural in $B$ and pointed natural in $C$.
  These maps satisfy the unit-counit laws:
  $$(A\to\epsilon_{A,B})\o \eta_{A\to B,A}\sim \idfunc[A\to B]\qquad
  \epsilon_{B,A\smsh B}\o \eta_{A,B}\smsh B\sim\idfunc[A\smsh B].$$
\end{lem}
Note: $\eta$ is also dinatural in $B$, but we don't need this.
\begin{proof}
  We define $\eta ab=(a,b)$. We define the path that $\eta a$ respects the basepoint as
  $$(\eta a)_0\defeq\gluel_a\tr\gluel_{a_0}\sy:(a,b_0)=(a_0,b_0).$$ Also, $\eta$ itself respects the basepoint. To show this, we need to give $\eta_0:\eta (a_0)\sim 0$. The underlying maps are homotopic, by $$\eta_0b\defeq\gluer_b\cdot\gluer_{b_0}\sy:(a_0,b)=(a_0,b_0).$$ To show that
  this homotopy is pointed, we need to show that the two given proofs of $(a_0,b_0)=(a_0,b_0)$ are
  equal, but they are both equal to reflexivity:
  $$\eta_{00}:\gluel_{a_0}\tr\gluel_{a_0}\sy=1=\gluer_{b_0}\tr\gluer_{b_0}\sy.$$
  This defines the unit. To show that it is natural in $A$, we need to give the following pointed homotopy $p_\eta(f)$ for $f:A\to A'$.
  \begin{center}
	\begin{tikzcd}
	A \arrow[r,"\eta"]\arrow[d,"f"] &
	(B\pmap A \smsh B)\arrow[d,"B\to f\smsh B"] \\
	A' \arrow[r,"\eta"] &
	(B\pmap A'\smsh B)
	\end{tikzcd}
  \end{center}
  We may assume that $f_0$ is reflexivity. For the underlying homotopy we need to define for $a:A$ that $p_\eta(f,a):\eta(fa)\sim f\smsh B \circ \eta a$, which is another pointed homotopy. For $b:B$ we have $\eta(fa,b)\equiv(fa,b)\equiv(f\smsh B)(\eta ab).$
  The homotopy $p_\eta(f,a)$ is pointed, since $$(f\smsh B \circ \eta a)_0=\apfunc{f\smsh B}(\gluel_a\cdot\gluel_{a_0}\sy)=\gluel_{fa}\cdot\gluel_{a_0'}\sy=(\eta(fa))_0.$$
  Now we need to show that $p_\eta(f)$ is pointed, for which we need to fill the following diagram.
  \begin{center}
	\begin{tikzcd}
	\eta(fa_0) \arrow[equals,rr,"{p_\eta(f,a_0)}"]\arrow[dr,equals,"{\eta_0}"] & &
	f\smsh B \circ \eta a_0\arrow[dl,equals,"{f\smsh B\circ\eta_0}"] \\
	& 0_{B,A'\smsh B} &
	\end{tikzcd}
  \end{center}
  These pointed homotopies have equal underlying homotopies, since for $b:B$ we have
  $$p_\eta(f,a_0,b)\cdot\apfunc{f\smsh B}(\eta_0 b)=1\cdot\apfunc{f\smsh B}(\gluer_b\cdot\gluer_{b_0}\sy)=\gluer_{b}\cdot\gluer_{b_0}\sy=\eta_0b.$$
  The homotopies are pointed in the same way (TODO).

  To define the counit, given $x:(B\pmap C)\smsh B$, we construct
  $\epsilon (x):C$ by induction on $x$. If $x\jdeq(f,b)$ we set $\epsilon(f,b)\defeq f(b)$. If $x$
  is either $\auxl$ or $\auxr$ then we set $\epsilon (x)\defeq c_0:C$. If $x$ varies over $\gluel_f$
  then we need to show that $f(b_0)=c_0$, which is true by $f_0$. If $x$ varies over $\gluer_b$ we
  need to show that $0(b)=c_0$ which is true by reflexivity. Now $\epsilon_0\defeq 1:\epsilon(0_{B,C},b_0)=c_0$ shows that $\epsilon$ is pointed.

  Now we need to show that the counit is dinatural in $B$ and pointed natural in $C$. (TODO)

  Finally, we need to show the unit-counit laws. For the underlying homotopy of the first one, let
  $f:A\to B$. We need to show that $p_f:\epsilon\o\eta f\sim f$. We define $p_f(a)=1:\epsilon(f,a)=f(a)$. To show that $p_f$ is a pointed homotopy, we need to show that
  $p_f(a_0)\tr f_0=\mapfunc{\epsilon}(\eta f)_0\tr \epsilon_0$, which reduces to
  $f_0=\mapfunc{\epsilon}(\gluel_f\tr\gluel_0\sy)$, but we can reduce the right hand side: (note:
  $0_0$ denotes the proof that $0(a_0)=b_0$, which is reflexivity)
  $$\mapfunc{\epsilon}(\gluel_f\tr\gluel_0\sy)=\mapfunc{\epsilon}(\gluel_f)\tr(\mapfunc{\epsilon}(\gluel_0))\sy=f_0\tr 0_0\sy=f_0.$$
  Now we need to show that $p$ itself respects the basepoint of $A\to B$, i.e. that the composite
  $\epsilon\o\eta(0)\sim\epsilon\o0\sim0$ is equal to $p_{0_{A,B}}$. The underlying
  homotopies are the same for $a : A$; on the one side we have
  $\mapfunc{\epsilon}(\gluer_{a}\tr\gluer_{a_0}\sy)$ and on the other side we have reflexivity
  (note: this typechecks since $0_{A,B}a\equiv0_{A,B}a_0$). These paths are equal, since
  $$\mapfunc{\epsilon}(\gluer_{a}\tr\gluer_{a_0}\sy)=\mapfunc{\epsilon}(\gluer_{a})\tr(\mapfunc\epsilon(\gluer_{a_0}))\sy=1\cdot1\sy\equiv1.$$
  Both pointed homotopies are pointed in the same way, which requires some path-algebra, and we skip the proof here.

  For the underlying homotopy of the second unit-counit law, we need to show for $x:A\smsh B$ that
  $q(x):\epsilon((\eta\smsh B)x)=x$, which we prove by induction to $x$. If $x\equiv(a,b)$ then we can define $q(a,b)\defeq1_{(a,b)}$. If $x$ is $\auxl$ or $\auxr$ then the left-hand side reduces to $(a_0,b_0)$, so we can define $q(\auxl)\defeq\gluel_{a_0}$ and $q(\auxr)\defeq\gluer_{b_0}$. The following computation shows that $q$ respects $\gluel_a$:
  $$\apfunc{\epsilon\circ\eta\smsh B}(\gluel_a)\cdot\gluel_{a_0}= \apfunc{\epsilon}(\gluel_{\eta a})\cdot\gluel_{a_0}=(\eta a)_0\cdot\gluel_{a_0}=\gluel_a\cdot\gluel_{a_0}\sy\cdot\gluel_{a_0}=\gluel_a.$$
  To show that it respects $\gluer_b$ we compute
  $$\apfunc{\epsilon\circ\eta\smsh B}(\gluer_b)\cdot\gluer_{b_0}=
  \apfunc{\epsilon({-},b)}(\eta_0)\cdot\apfunc{\epsilon}(\gluer_b)\cdot\gluer_{b_0}=
  \apfunc{\lam{f}fb}(\eta_0)\cdot\gluer_{b_0}=
  \eta_0b\cdot\gluer_{b_0}=
  %\gluer_b\cdot\gluer_{b_0}\sy\cdot\gluer_{b_0}=
  \gluer_b.$$
  To show that $q$ is a pointed homotopy, we need to show that $(\epsilon\circ\eta\smsh B)_0=1$, For this we compute $$(\epsilon\circ\eta\smsh B)_0=\apfunc{\epsilon({-},b_0)}(\eta_0)=\eta_0b_0=\gluer_{b_0}\cdot\gluer_{b_0}\sy=1.$$
\end{proof}

\begin{defn}
The function $e\jdeq e_{A,B,C}:(A\pmap B\pmap C)\pmap(A\smsh B\pmap C)$ is defined as the composite
$$(A\pmap B\pmap C)\lpmap{({-})\smsh B}(A\smsh B\pmap (B\pmap C)\smsh B)\lpmap{A\smsh B \pmap\epsilon}(A\smsh B\pmap C).$$
\end{defn}

\begin{lem}
  The function $e$ is invertible, hence gives a pointed equivalence $$(A\pmap B\pmap C)\simeq(A\smsh B\pmap C).$$
\end{lem}
\begin{proof}
  Define
  $$\inv{e}_{A,B,C}:(A\smsh B\pmap C)\lpmap{B\pmap({-})}((B\pmap A\smsh B)\pmap (B\pmap
  C))\lpmap{\eta\pmap(B\pmap C)}(A\pmap B\pmap C).$$ It is easy to show that $e$ and $\inv{e}$ are
  inverses as unpointed maps from the unit-counit laws (\autoref{lem:unit-counit}) and naturality of $\eta$ and $\epsilon$.
%   For $f : A\pmap B\pmap C$ we have
%   \begin{align*}
%     \inv{e}(e(f))&\equiv(\eta\pmap(B\pmap C))\o (B\pmap((A\smsh B\pmap\epsilon)\of\smsh B))\\
%                  &= (\eta\pmap(B\pmap C))\o (B\pmap(A\smsh B\pmap\epsilon))\o(B\pmapf\smsh B)\\
% %                 &= (\eta\pmap(B\pmap C))\o (B\pmap(A\smsh B\pmap\epsilon))\o(B\pmapf\smsh B)\\
%   \end{align*}
\end{proof}
\begin{lem}\label{lem:e-natural}
	The function $e$ is natural in $A$, $B$ and pointed natural in $C$.
\end{lem}
\begin{proof}
	\textbf{Naturality of $e$ in $A$}. Suppose that $f:A'\pmap A$. Then the following diagram commutes. The left square commutes by naturality of $({-})\smsh B$ in the first argument and the right square commutes because composition on the left commutes with composition on the right.
	\begin{center}
	\begin{tikzcd}
		(A\pmap B\pmap C) \arrow[r,"({-})\smsh B"]\arrow[d,"f\pmap B\pmap C"] &
		(A\smsh B\pmap (B\pmap C)\smsh B) \arrow[r,"A\smsh B\pmap\epsilon"]\arrow[d,"f\smsh B\pmap\cdots"]  &
		(A\smsh B\pmap C)\arrow[d,"f\smsh B\pmap C"] \\
		(A'\pmap B\pmap C) \arrow[r,"({-})\smsh B"] &
		(A'\smsh B\pmap (B\pmap C)\smsh B) \arrow[r,"A\smsh B\pmap\epsilon"] &
		(A'\smsh B\pmap C)
	\end{tikzcd}
	\end{center}

	\textbf{Naturality of $e$ in $C$}. Suppose that $f:C\pmap C'$. Then in the following diagram the left square commutes by naturality of $({-})\smsh B$ in the second argument (applied to $B\pmap f$) and the right square commutes by applying the functor $A\smsh B \pmap({-})$ to the naturality of $\epsilon$ in the second argument.
	\begin{center}
	\begin{tikzcd}
		(A\pmap B\pmap C) \arrow[r]\arrow[d] &
		(A\smsh B\pmap (B\pmap C)\smsh B) \arrow[r]\arrow[d] &
		(A\smsh B\pmap C)\arrow[d] \\
		(A\pmap B\pmap C') \arrow[r] &
		(A\smsh B\pmap (B\pmap C')\smsh B) \arrow[r] &
		(A\smsh B\pmap C')
	\end{tikzcd}
	\end{center}
Pointed naturality: TODO.

	\textbf{Naturality of $e$ in $B$}. Suppose that $f:B'\pmap B$. Here the diagram is a bit more
complicated, since $({-})\smsh B$ is dinatural (instead of natural) in $B$. Then we get the
following diagram. The front square commutes by naturality of $({-})\smsh B$ in the second argument
	(applied to $f\pmap C$). The top square commutes by naturality of $({-})\smsh B$ in the third
argument, the back square commutes because composition on the left commutes with composition on the
	right, and finally the right square commutes by applying the functor $A\smsh B' \pmap({-})$ to the
	naturality of $\epsilon$ in the first argument.
	\begin{center}
	\begin{tikzcd}[row sep=scriptsize, column sep=-4em]
		& (A\smsh B\pmap (B\pmap C)\smsh B) \arrow[rr] \arrow[dd] & & (A\smsh B'\pmap (B\pmap C)\smsh B)\arrow[dd] \\
		(A\pmap B\pmap C) \arrow[ur] \arrow[rr, crossing over] \arrow[dd] & & (A\smsh B'\pmap (B\pmap C)\smsh B') \arrow[ur] \\
		& (A\smsh B\pmap C)\arrow[rr] &  & (A\smsh B'\pmap C) \\
		(A\pmap B'\pmap C) \arrow[rr] & & (A\smsh B'\pmap (B'\pmap C)\smsh B') \arrow[ur] \arrow[from=uu, crossing over]
	\end{tikzcd}
	\end{center}

\end{proof}
\begin{rmk}
  Instead of showing that $e$ is natural, we could instead show that $e^{-1}$ is natural. In
  that case we need to show that the map $A\to({-}):(B\to C)\to(A\to B)\to(A\to C)$ is natural in
  $A$, $B$ and $C$. This might actually be easier, since we don't need to work with any higher
  inductive type to prove that.
\end{rmk}

\section{Symmetric monoid product}
We aim to prove that the smash product is a (1-coherent) symmetric monoidal product [REF: Brunerie] for pointed types, i.e., that
\[(\type^*,\, \bool,\, \smsh,\, \alpha,\, \lambda,\, \rho,\, \gamma)\]
is a symmetric monoidal category, with the type of booleans $\bool$ (pointed in $0_\bool$) as unit, and for suitable instances of $\alpha$, $\lambda$, $\rho$ and $\gamma$ witnessing associativity, left- and right unitality and the braiding for $\smsh$ and satisfying appropriate coherence relations (associativity pentagon; unitors triangle; braiding-unitors triangle; associativity-braiding hexagon; double braiding).

Using \autoref{lem:yoneda} (Yoneda) we can prove associativity, left- and right unitality and braiding equivalences for the smash product, in the following way.

\begin{defn}\label{def:equiv-precursors}
	The following pointed equivalences are defined for $A$, $B$, $C$ and $X$ pointed types:
	\begin{itemize}
		\item $\alphabar_X : (A \smsh (B \smsh C) \to X) \simeq ((A \smsh B) \smsh C \to X)$ as the composition of the equivalences:
			\begin{align*}
			    A \smsh (B \smsh C)\to X&\simeq A \to B\smsh C\to X && (e\sy)\\
			    &\simeq A \to B\to C\to X && (A \to e\sy)\\
			    &\simeq A \smsh B\to C\to X && (e)\\
		    	&\simeq (A \smsh B)\smsh C\to X. && (e)
			\end{align*}
		\item $\lambdabar_X : (B \to X) \simeq (\bool \smsh B \to X)$ as the composition of the equivalences:
			\begin{align*}
				B \to X &\simeq \bool \to B \to X && (\two\sy)\\
				&\simeq \bool \smsh B \to X && (e)
			\end{align*}
		\item $\rhobar_X : (A \to X) \simeq (A \smsh \bool \to X)$ as the composition of the equivalences:
			\begin{align*}
				A \to X &\simeq A \to \bool \to X && (A \to \two\sy)\\
				&\simeq A \smsh \bool \to X && (e)
			\end{align*}
		\item $\gammabar_X : (B \smsh A \to X) \simeq (A \smsh B \to X)$ as the composition of the equivalences:
			\begin{align*}
				B \smsh A \to X &\simeq B \to A \to X && (e\sy)\\
				&\simeq A \to B \to X && (\twist)\\
				&\simeq A \smsh B \to X && (e)
			\end{align*}
	\end{itemize}
\end{defn}

\begin{rmk}\label{rmk:alrg-pointed-natural}
	The equivalences in \autoref{def:equiv-precursors} are natural in all their arguments and pointed natural in $X$, by (pointed) naturality of $e$ (\autoref{lem:e-natural} and \autoref{lem:e-pointed-natural}), $c$ and $t$. In particular, we will use:
	\begin{align*}
	f \o \alphabar(g) &\sim \alphabar(f \o g) & f \o \lambdabar(g) &\sim \lambdabar(f \o g)\\
	f \o \rhobar(g) &\sim \rhobar(f \o g) & f \o \gammabar(g) &\sim \gammabar(f \o g)
	\end{align*}
\end{rmk}

\begin{defn}\label{def:smash-alrg}
	We define the following equivalences, natural in all their arguments, with inverses provided as in \autoref{lem:yoneda}:
	\begin{itemize}
		\item $\alpha\defeq\alphabar_{A \smsh (B \smsh C)}(\idfunc) : (A \smsh B) \smsh C \simeq A \smsh (B \smsh C)$ (associativity of the smash product), with inverse $\alpha\sy\defeq\alphabar\sy_{(A \smsh B) \smsh C}(\idfunc)$;
		\item $\lambda \defeq \lambdabar_B(\idfunc) : \bool \smsh B \simeq B$ and $\rho \defeq \rhobar_A(\idfunc) : A \smsh \bool \simeq A$ (left- and right unitors for the smash product), with inverses $\lambda\sy\defeq \lambdabar_{\bool\smsh B}\sy(\idfunc)$ and $\rho\sy\defeq \rhobar_{A\smsh \bool}\sy(\idfunc)$, respectively;
		\item $\gamma \defeq \gammabar_{B\smsh A} (\idfunc) : A \smsh B \simeq B \smsh A$ (braiding for the smash product), with inverse $\gamma\sy \defeq \gammabar_{A \smsh B}\sy (\idfunc)$.
	\end{itemize}
	$\alpha$, $\lambda$, $\rho$ and $\gamma$ are natural in all their arguments, as $\alphabar$, $\lambdabar$, $\rhobar$ and $\gammabar$ are.
\end{defn}

\begin{lem}\label{lem:bar-homotopy}
	There are pointed homotopies
	\begin{align*}
	\alphabar_X &\sim \alpha \to X
		& \lambdabar_X &\sim \lambda \to X
	\\
	\rhobar_X &\sim \rho \to X
		& \gammabar_X &\sim \gamma \to X
	\end{align*}
\end{lem}

\begin{proof}
	This follows directly from \autoref{lem:yoneda-pointed} and \autoref{rmk:alrg-pointed-natural}.
\end{proof}

\begin{thm}[Associativity pentagon]\label{thm:smash-associativity-pentagon}
	For $A$, $B$, $C$ and $D$ pointed types, there is a pointed homotopy
	\[\alpha \o \alpha \sim (A \smsh \alpha) \o \alpha \o (\alpha \smsh D)\]
	corresponding to the commutativity of the following diagram:
	\begin{center}
	\begin{tikzcd}
		&((A \smsh B) \smsh (C \smsh D))
			\arrow[dr, "\alpha"]
		\\
		(((A \smsh B) \smsh C) \smsh D)
			\arrow[ru, "\alpha"]
			\arrow[d, swap, "\alpha \smsh D"]
		&& (A \smsh (B \smsh (C \smsh D)))
		\\
		((A \smsh (B \smsh C)) \smsh D)
			\arrow[rr, swap, "\alpha"]
		&& (A \smsh ((B \smsh C) \smsh D))
			\arrow[u, swap, "A \smsh \alpha"]
	\end{tikzcd}
%	\begin{tikzcd}
%		(((A \smsh B) \smsh C) \smsh D)
%			\arrow[rr, "\alpha"]
%			\arrow[d, swap, "\alpha \smsh D"]
%		&& ((A \smsh B) \smsh (C \smsh D))
%			\arrow[d, "\alpha"]
%		\\
%		((A \smsh (B \smsh C)) \smsh D)
%			\arrow[r, swap, "\alpha"]
%		& (A \smsh ((B \smsh C) \smsh D))
%			\arrow[r, swap, "A \smsh \alpha"]
%		& (A \smsh (B \smsh (C \smsh D)))
%	\end{tikzcd}
	\end{center}
\end{thm}
\begin{proof}
	We articulate the proof in several steps. A map homotopic to both sides of the sought homotopy will be constructed via the equivalence
	\begin{align*}
		\alphabar^4 : (A \smsh (B \smsh (C \smsh D)) \to X) &\simeq (((A \smsh B) \smsh C) \smsh D \to X)
		\intertext{(natural in all its arguments), defined as the composite:}
		A \smsh (B \smsh (C \smsh D)) \to X
		&\simeq A \to B \smsh (C \smsh D) \to X && \text{($e\sy$)}\\
		&\simeq A \to B \to C \smsh D \to X &&\text{($A \to e\sy$)}\\
		&\simeq A \to B \to C \to D \to X &&\text{($A \to B \to e\sy$)}\\
		&\simeq A \smsh B \to C \to D \to X &&\text{($e$)}\\
		&\simeq (A \smsh B) \smsh C \to D \to X &&\text{($e$)}\\
		&\simeq ((A \smsh B) \smsh C) \smsh D \to X && \text{($e$)}
		\intertext{giving $\alphabar^4(\idfunc) : ((A \smsh B) \smsh C) \smsh D) \simeq A \smsh (B \smsh (C \smsh D))$. Moreover, in order to simplify the expressions of $\alpha \smsh D$ and $A \smsh \alpha$, we also define:}
		\alphabar^R : ((A \smsh (B \smsh C)) \smsh D \to X) &\simeq (((A \smsh B) \smsh C) \smsh D \to X)
		\intertext{as the composite:}
		(A \smsh (B \smsh C)) \smsh D \to X
		&\simeq A \smsh (B \smsh C) \to D \to X &&\text{($e\sy$)}\\
		&\simeq (A \smsh B) \smsh C \to D \to X &&\text{($\alphabar$)}\\
		&\simeq ((A \smsh B) \smsh C) \smsh D \to X &&\text{($e$)}
		\intertext{and}
		\alphabar^L : (A \smsh (B \smsh (C \smsh D)) \to X) &\simeq (A \smsh ((B \smsh C) \smsh D) \to X)
		\intertext{as the composite:}
		A \smsh (B \smsh (C \smsh D)) \to X
		&\simeq A \to B \smsh (C \smsh D) \to X &&\text{($e\sy$)}\\
		&\simeq A \to (B \smsh C) \smsh D \to X &&\text{($A \to \alphabar$)}\\
		&\simeq A \smsh ((B \smsh C) \smsh D) \to X &&\text{($e$)}
	\end{align*}
	also natural in their arguments. Evaluating these equivalences to the identity function, we get new arrows that fit in the original diagram:
	\begin{center}
	\begin{tikzcd}
		&((A \smsh B) \smsh (C \smsh D))
			\arrow[dr, "\alpha"]
		\\
		(((A \smsh B) \smsh C) \smsh D)
			\arrow[ru, "\alpha"]
			\arrow[d, swap, "\alpha \smsh D"]
			\arrow[d, bend left=40, "\alphabar^R(\idfunc)"]
			\arrow[rr, "\alphabar^4(\idfunc)"]
		&& (A \smsh (B \smsh (C \smsh D)))
		\\
		((A \smsh (B \smsh C)) \smsh D)
			\arrow[rr, swap, "\alpha"]
		&& (A \smsh ((B \smsh C) \smsh D))
			\arrow[u, swap, "A \smsh \alpha"]
			\arrow[u, bend left=40, "\alphabar^L(\idfunc)"]
	\end{tikzcd}
	\end{center}

	The theorem is then proved once we show the chain of homotopies:
	\begin{equation}\label{eq:alphafour}
	\alpha \o \alpha
	\sim \alphabar^4(\idfunc)
	\sim \alphabar^L(\idfunc) \o \alpha \o \alphabar^R(\idfunc)
	\sim (A \smsh \alpha) \o \alpha \o (\alpha \smsh D)
	\end{equation}

	To verify the first homotopy in (\ref{eq:alphafour}), we see that:
	\begin{align*}
		\alpha \o \alpha
		&\judgeq \alphabar(\idfunc) \o \alphabar(\idfunc)\\
		&\sim (\alphabar \o \alphabar) (\idfunc) &&\text{(naturality of $\alphabar$)}\\
		&\judgeq (e \o e \o (A \to e\sy) \o e\sy \o e \o e \o (A \to e\sy) \o e\sy)(\idfunc)\\
		&\sim (e \o e \o (A \to e\sy) \o e \o (A \to e\sy) \o e\sy)(\idfunc) &&\text{(cancelling)}\\
		&\sim (e \o e \o e \o (B \to A \to e\sy) \o (A \to e\sy) \o e\sy)(\idfunc) &&\text{(naturality of $e$)}\\
		&\judgeq \alphabar^4(\idfunc)
	\end{align*}

	The second homotopy in (\ref{eq:alphafour}) is verified by (right-to-left):
	\begin{align*}
		\alphabar^L(\idfunc) \o \alpha \o \alphabar^R(\idfunc)
		&\judgeq \alphabar^L(\idfunc) \o \alphabar(\idfunc) \o \alphabar^R(\idfunc)\\
		&\sim (\alphabar^R \o \alphabar \o \alphabar^L)(\idfunc) &&\text{(nat. of $\alphabar$ and $\alphabar^R$)}\\
		&\judgeq (e \o \alphabar \o e\sy \o e \o e \o (A \to e\sy) \o e\sy \o e \o (A \to \alphabar) \o e\sy)(\idfunc)\\
		&\sim (e \o \alphabar \o e \o (A \to e\sy) \o (A \to \alphabar) \o e\sy)(\idfunc) &&\text{(cancelling)}\\
		&\sim (e \o \alphabar \o e \o (A \to (e\sy \o \alphabar)) \o e\sy)(\idfunc) &&\text{(funct. of $A\to -$)}\\
		&\judgeq (e \o e \o e \o (A \to e\sy) \o e\sy \o e \\
		&\hspace{3em}\o (A \to (e\sy \o e \o e \o (B \to e\sy) \o e\sy)) \o e\sy)(\idfunc)\\
		&\sim (e \o e \o e \o (A \to ((B \to e\sy) \o e\sy)) \o e\sy)(\idfunc) &&\text{(cancelling)}\\
		&\sim (e \o e \o e \o (B \to A \to e\sy) \o (A \to e\sy) \o e\sy)(\idfunc) &&\text{(funct. of $A \to -$)}\\
		&\judgeq \alphabar^4(\idfunc)
	\end{align*}

	In order to prove the last homotopy in (\ref{eq:alphafour}), it is sufficient to show that $\alphabar^R(\idfunc) \sim \alpha \smsh D$ and that $\alphabar^L(\idfunc) \sim A \smsh \alpha$. We have:
	\begin{align*}
		\alphabar^R(\idfunc)
		&\judgeq e(\alphabar (e\sy(\idfunc)))\\
		&\sim e (\alphabar (\eta))\\
		&\sim e (\eta \o \alphabar(\idfunc)) &&\text{(naturality of $\alphabar$)}\\
		&\judgeq \epsilon \o (\eta \o \alpha) \smsh D\\
		&\sim \epsilon \o (\eta \smsh D) \o (\alpha \smsh D) &&\text{(distrib. of $\smsh$)}\\
		&\sim \alpha \smsh D &&\text{(\autoref{lem:unit-counit})}
	\end{align*}
	and, lastly,
	\begin{align*}
		\alphabar^L(\idfunc)
		&\judgeq e(\alphabar \o e\sy(\idfunc))\\
		&\sim e(\alphabar \o \eta)\\
		&\sim e((\alpha \to A \smsh (B \smsh (C \smsh D))) \o \eta) &&\text{(\autoref{lem:bar-homotopy})}\\
		&\sim e((B \smsh (C \smsh D) \to A \smsh \alpha) \o \eta) &&\text{(dinaturality of $\eta$)}\\
		&\sim (A \smsh \alpha) \o e(\eta) &&\text{(naturality of $e$)}\\
		&\sim A \smsh \alpha &&\text{(\autoref{lem:unit-counit})}
	\end{align*}
	thus proving the desired homotopy.
\end{proof}

\begin{thm}[Unitors triangle]\label{thm:smash-unitors-triangle}
	For $A$ and $B$ pointed types, there is a pointed homotopy
	\[(A \smsh \lambda) \o \alpha \sim (\rho \smsh B)\]
	corresponding to the commutativity of the following diagram:
	\begin{center}
	\begin{tikzcd}
	((A \smsh \bool) \smsh B)
		\arrow[rr, "\alpha"]
		\arrow[dr, swap, "\rho \smsh B"]
	&& (A \smsh (\bool \smsh B))
		\arrow[dl, "A \smsh \lambda"]
	\\
	& (A \smsh B)
	\end{tikzcd}
	\end{center}
\end{thm}
\begin{proof}
	By an argument similar to the one for $\alphabar^L$ and $\alphabar^R$ in \autoref{thm:smash-associativity-pentagon}, one can verify the homotopies $A \smsh \lambda \sim (e \o (A \to \lambdabar) \o e\sy)(\idfunc)$ and $\rho \smsh B \sim (e \o \rhobar \o e)(\idfunc)$, simplifying the expressions in the sought homotopy. Then:
	\begin{align*}
		(A \smsh \lambda) \o \alpha
		&\sim e(\lambdabar \o e\sy(\idfunc)) \o \alphabar(\idfunc) &&\text{(simplification)}\\
		&\sim \alphabar(e(\lambdabar \o e\sy(\idfunc)) &&\text{(naturality of $\alphabar$)}\\
		&\judgeq e(e(e\sy \o e\sy (e(\lambdabar \o e\sy(\idfunc)))))\\
		&\sim e(e(e\sy \o \lambdabar \o e\sy(\idfunc))) &&\text{(cancelling)}\\
		&\judgeq e(e(e\sy \o e \o \two\sy \o e\sy(\idfunc)))\\
		&\sim e(e(\two\sy \o e\sy(\idfunc))) &&\text{(cancelling)}\\
		&\judgeq (e \o \rhobar \o e\sy)(\idfunc)\\
		&\sim \rho \smsh B &&\text{(simplification)}
	\end{align*}
	gives the desired homotopy.
\end{proof}

\begin{thm}[Braiding-unitors triangle]\label{thm:smash-braiding-unitors}
	For a pointed type $A$, there is a pointed homotopy
	\[\lambda \o \gamma \sim \rho\]
	corresponding to the commutativity of the following diagram:
	\begin{center}
	\begin{tikzcd}
	(A \smsh \bool)
		\arrow[rr, "\gamma"]
		\arrow[dr, swap, "\rho"]
	&& (\bool \smsh A)
		\arrow[dl, "\lambda"]
	\\
	& A
	\end{tikzcd}
	\end{center}
\end{thm}
\begin{proof}
	We have:
	\begin{align*}
		\lambda \o \gamma
		&\judgeq \lambdabar(\idfunc) \o \gammabar(\idfunc)\\
		&\sim (\gammabar \o \lambdabar)(\idfunc) &&\text{(naturality of $\gammabar$)}\\
		&\judgeq (e \o \twist \o e\sy \o e \o \two\sy)(\idfunc)\\
		&\sim (e \o \twist \o \two\sy)(\idfunc) &&\text{(cancelling)}\\
		&\sim (e \o (A \to \two\sy))(\idfunc)\\
		&\judgeq \rhobar(\idfunc) \judgeq \rho
	\end{align*}
	where the last homotopy is given by $(A \to c) \o \two \sim \twist : (\bool \to A \to X) \to (A \to X)$.
\end{proof}

\begin{lem}\label{lem:pentagon-c}
	The following diagram commutes, for $A$, $B$, $C$ and $X$ pointed types:
	\begin{center}
	\begin{tikzcd}[column sep=7em]
		(B \smsh C \to A \to X)
			\arrow[r, "e\sy"]
			\arrow[dd, swap, "\twist"]
		& (B \to C \to A \to X)
			\arrow[d, "B \to \twist"]
		\\
		& (B \to A \to C \to X)
			\arrow[d, "\twist"]
		\\
		(A \to B \smsh C \to X)
			\arrow[r, swap, "A \to e\sy"]
		& (A \to B \to C \to X)
	\end{tikzcd}
	\end{center}
\end{lem}
\begin{proof}
	Unfolding the definition of $e\sy$, we get the diagram:
	\begin{center}
	\begin{tikzcd}[column sep=6em]
		(B \smsh C \to A \to X)
			\arrow[rr, bend left=10, "e\sy"]
			\arrow[r, swap, "C\to -"]
			\arrow[dd, swap, "\twist"]
		& ((C \to B \smsh C) \to C \to A \to X)
			\arrow[r, swap, "\eta \to C \to A \to X"]
			\arrow[d, swap, "(C \to B \smsh C) \to \twist"]
		& (B \to C \to A \to X)
			\arrow[d, "B \to \twist"]
		\\
		& ((C \to B \smsh C) \to A \to C \to X)
			\arrow[r, swap, "\eta \to A \to C \to X"]
			\arrow[d, swap, "\twist"]
		& (B \to A \to C \to X)
			\arrow[d, "\twist"]
		\\
		(A \to B \smsh C \to X)
			\arrow[rr, swap, bend right=10, "A \to e\sy"]
			\arrow[r, "A \to (C \to -)"]
		& (A \to (C \to B \smsh C) \to C \to X)
			\arrow[r, "A \to (\eta \to C \to X)"]
		& (A \to B \to C \to X)
	\end{tikzcd}
	\end{center}
	The square in the top right is by \autoref{lem:composition-pointed}, the square on the bottom right is naturality of $\twist$. The commutativity of the pentagon on the left is TODO (it is a diagram of a 1-coherent symmetric closed category).
\end{proof}

\begin{thm}[Associativity-braiding hexagon]\label{thm:smash-associativity-braiding}
	For pointed types $A$, $B$ and $C$, there is a pointed homotopy
	\[\alpha \o \gamma \o \alpha \sim (B \smsh \gamma) \o \alpha \o (\gamma \smsh C)\]
	corresponding to the commutativity of the following diagram:
	\begin{center}
	\begin{tikzcd}
		((A \smsh B) \smsh C)
			\arrow[r, "\alpha"]
			\arrow[d, swap, "\gamma \smsh C"]
		&(A \smsh (B \smsh C))
			\arrow[r, "\gamma"]
		& ((B \smsh C) \smsh A)
			\arrow[d, "\alpha"]
		\\
		((B \smsh A) \smsh C))
			\arrow[r, swap, "\alpha"]
		& (B \smsh (A \smsh C))
			\arrow[r, swap, "B \smsh \gamma"]
		& (B \smsh (C \smsh A))
	\end{tikzcd}
	\end{center}
\end{thm}
\begin{proof}
	The proof is structured similarly to the one for \autoref{thm:smash-associativity-pentagon}: the homotopies
	\begin{align*}
	B \smsh \gamma &\sim \gammabar^L(\idfunc) &\text{with\ \ } \gammabar^L &\defeq e \o (B \to \gammabar) \o e\sy\\
	\gamma \smsh C &\sim \gammabar^R(\idfunc) &\text{with\ \ } \gammabar^R &\defeq e \o \gammabar \o e\sy
	\end{align*}
	can be proven in exactly the same way and, using these simplifications, we will show that both sides of the sought homotopy are homotopic to the same equivalence. Indeed we have:
	\begin{align*}
		\alpha \o \gamma \o \alpha
		&\judgeq \alphabar(\idfunc) \o \gammabar(\idfunc) \o \alphabar(\idfunc)\\
		&\sim (\alphabar \o \gammabar \o \alphabar)(\idfunc) &&\text{(naturality of $\gammabar$ and $\alphabar$)}\\
		&\judgeq (e \o e \o (A \to e\sy) \o e\sy \o e \o \twist \o e\sy \o e \o e \o (B \to e\sy) \o e\sy)(\idfunc)\\
		&\sim (e \o e \o (A \to e\sy) \o \twist \o e \o (B \to e\sy) \o e\sy)(\idfunc) &&\text{(cancelling)}\\
		&\sim (e \o e \o \twist \o (B \to \twist) \o e\sy \o e \o (B \to e\sy) \o e\sy)(\idfunc) &&\text{(\autoref{lem:pentagon-c})}\\
		&\sim (e \o e \o \twist \o (B \to \twist) \o (B \to e\sy) \o e\sy)(\idfunc) &&\text{(cancelling)}
	\end{align*}
	and
	\begin{align*}
		(B \smsh \gamma) \o \alpha \o (\gamma \smsh C)
		&\sim \gammabar^L(\idfunc) \o \alphabar \o \gammabar^R(\idfunc) &&\text{(simplification)}\\
		&\sim (\gammabar^R \o \alphabar \o \gammabar^L)(\idfunc) &&\text{(nat. of $\alphabar$ and $\gammabar^R$)}\\
		&\judgeq (e \o \gammabar \o e\sy \o e \o e \o (B \to e\sy) \o e\sy \o e \o (B \to \gammabar) \o e\sy)(\idfunc)\\
		&\sim (e \o \gammabar \o e \o (B \to e\sy) \o (B \to \gammabar) \o e\sy)(\idfunc) &&\text{(cancelling)}\\
		&\sim (e \o \gammabar \o e \o (B \to (e\sy \o \gammabar)) \o e\sy)(\idfunc) &&\text{(funct. of $B \to -$)}\\
		&\judgeq (e \o e \o \twist \o e\sy \o e \o (B \to (e\sy \o e \o \twist \o e\sy)) \o e\sy)(\idfunc)\\
		&\sim (e \o e \o \twist \o (B \to \twist) \o (B \to e\sy) \o e\sy)(\idfunc) &&\text{(cancelling)}
	\end{align*}
	proving the commutativity of the diagram.
\end{proof}

\begin{thm}[Double braiding]\label{thm:smash-double-braiding}
	For $A$ and $B$ pointed types, there is a pointed homotopy
	\[\gamma \o \gamma \sim \idfunc\]
	corresponding to the commutativity of the following diagram:
	\begin{center}
	\begin{tikzcd}
	(A \smsh B)
		\arrow[r, "\gamma"]
		\arrow[dr, equals]
	& (B \smsh A)
		\arrow[d, "\gamma"]
	\\
	& (A \smsh B)
	\end{tikzcd}
	\end{center}
\end{thm}
\begin{proof}
	Using that $\twist \o \twist \sim \idfunc$, we get:
	\begin{align*}
		\gamma \o \gamma
		&\judgeq \gammabar(\idfunc) \o \gammabar(\idfunc)\\
		&\sim (\gammabar \o \gammabar)(\idfunc) &&\text{(naturality of $\gammabar$)}\\
		&\judgeq (e \o \twist \o e\sy \o e \o \twist \o e\sy)(\idfunc)\\
		&\sim \idfunc &&\text{(cancelling)}
	\end{align*}
	as desired.
\end{proof}

\begin{cor}
	$(\type^*,\, \bool,\, \smsh,\, \alpha,\, \lambda,\, \rho,\, \gamma)$ has a structure of a symmetric monoidal category, for $\alpha$, $\lambda$, $\rho$ and $\gamma$ as in \autoref{def:smash-alrg}.
\end{cor}
\begin{proof}
	Follows by the theorems in this section.
\end{proof}

\section{Discussion}

Many results in \autoref{sec:smash} about $({-}) \smsh B$ can be generalized to arbitrary pointed $\infty$-functors $\type^*\to\type^*$. Internally in HoTT we cannot talk about $\infty$-categories and $\infty$-functors (as far as we know), and therefore we cannot express this internally. But we only need finitely many coherences, so that we can formulate these results internally for arbitrary functors with enough coherences. However, when we tried this, we run into the problem that we needed all (or at least, some) coherences in the definition of a tricategory and functor for tricategories, which are harder to check than the result we wanted to prove. Here we sketch this argument.

$\type^*$ is a pointed $(\infty,1)$-category meaning it has an zero object $\unit$, which is an object that is both (homotopy-)initial and (homotopy-)terminal. Given two pointed $(\infty,1)$-categories $\mc{A}$ and $\mc{B}$, we call a map $F:\mc{A}\to\mc{B}$ a 1-coherent functor if it satisfies all the coherences of a functor (i.e. an action on morphisms and a 2-cell stating that $F$ respects compositions and identities), a 2-coherent functor if it satisfies all the coherences of a bifunctor (a functor between bicategories) and a 3-coherent functor if it satisfies all the coherences of a trifunctor (a functor between tricategories).
% Add reference:
% @article{gurski2006algebraic,
% title={An algebraic theory of tricategories},
% author={Gurski, Nick},
% year={2007},
% url={http://gauss.math.yale.edu/~mg622/tricats.pdf}
% }

We call $F:\mc{A}\to\mc{B}$ pointed if it preserves the zero object, i.e. if $F\unit=\unit$. If $F$ is a pointed 1-coherent functor, we can then show that $F(0_{A,B})=0_{FA,FB}$, where $0_{A,B}$ is the zero morphism (the canonical morphism $A\to\unit\to B$).

If $F$ is a pointed 2-coherent functor (or more precisely a 1-coherent functor which a coherence for the associativity 2-cell), then we can show that \autoref{lem:smash-coh} holds for $F$. We can show that the two pentagons have the same filler if $F$ is a 3-coherent functor.

Now we can also show \autoref{thm:smash-functor-right} more generally, but we will only formulate that for functors between pointed types. If $F:\type^*\to\type^*$ is a 2-coherent pointed functor, then it induces a map
$(A\to B)\to(FA\to FB)$ which is natural in $A$ and $B$. Moreover, if $F$ is 3-coherent then this is a pointed natural transformation in $B$.

\section{References}
\begin{itemize}
\item (TODO)
\item An algebraic theory of tricategories, Nick Gurski
\item Closed Categories, Samuel Eilenberg and G. Max Kelly (Chapter 2, Theorem 5.3, 1-categorical account of getting a monoidal category from a enriched adjunction in a closed category)
\item Permutative categories, multicategories, and algebraic K-theory, A D Elmendorf and M A Mandell (Lemma 4.20 gives a 1-categorical account that if C is a symmetric monoidal closed bicomplete 1-category, then the category of pointed objects is a symmetric monoidal closed bicomplete 1-category).
\item On embedding closed categories, B.J. Day and M.L. Laplaza (definition of symmetric closed category).
\item Maybe: Handbook of Categorical Algebra 2  Categories and Structures, F Borceux. (Bjorn used it to look things up about symmetric monoidal closed categories)
\end{itemize}
\end{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{thm}[Associativity]\label{thm:smash-associativity}
  The smash product is associative: there is an equivalence $\alpha : (A \smsh B) \smsh C \simeq A \smsh (B \smsh C)$ which is natural in $A$, $B$ and $C$.
\end{thm}
\begin{proof}
  For a pointed type $X$, let $\alphabar_X$ be the composite of the following equivalences:
  \begin{align*}
    A \smsh (B \smsh C)\to X&\simeq A \to B\smsh C\to X && (e\sy)\\
    &\simeq A \to B\to C\to X && (A \to e\sy)\\
    &\simeq A \smsh B\to C\to X && (e)\\
    &\simeq (A \smsh B)\smsh C\to X. && (e)
  \end{align*}
  $\alphabar_X$ is natural in $A,B,C,X$ by repeatedly applying \autoref{lem:e-natural}. Let
  $\alpha\defeq\alphabar_{A \smsh (B \smsh C)}(\idfunc)$ and
  $\alpha\sy\defeq\alphabar\sy_{(A \smsh B) \smsh C}(\idfunc)$. These maps are inverses by \autoref{lem:yoneda}; lastly, $\alpha$ is natural in $A$, $B$
  and $C$, since $\alphabar_X$ is.
\end{proof}

\begin{thm}[Unitors]\label{thm:smash-unitors}
	The type of booleans $\bool$ is a left- and right unit for the smash product: there are equivalences
	$\lambda : (\bool \smsh B) \simeq B$ and $\rho : (A \smsh \bool) \simeq A$, respectively natural in $B$ and in $A$.
\end{thm}
\begin{proof}
	We define $\lambdabar_X$ as the following composition of equivalences:
	\begin{align*}
		B \to X &\simeq \bool \to B \to X && (t\sy)\\
			&\simeq \bool \smsh B \to X && (e)
		\end{align*}
	and, similarly, $\rhobar_X$ as the composition:
	\begin{align*}
		A \to X &\simeq A \to \bool \to X && (A \to t\sy)\\
			&\simeq A \smsh \bool \to X && (e)
	\end{align*}
	for any pointed type $X$, where $t : (\bool \to X) \simeq X$ is the pointed equivalence with underlying function sending $f : \bool \to X$ to $f(1_\bool) : X$. Both $\lambdabar_X$ and $\rhobar_X$ are natural in their arguments by multiple applications of \autoref{lem:e-natural}. By an argument similar to \autoref{thm:smash-associativity}, we can define $\lambda \defeq \lambdabar_B(\idfunc)$ and $\rho \defeq \rhobar_A(\idfunc)$ together with the corresponding inverses, yielding the sought natural equivalences.
\end{proof}

\begin{thm}[Braiding]\label{thm:smash-braiding}
	The smash product is symmetric, i.e. there are equivalences $\gamma : A \smsh B \simeq B \smsh A$, natural in $A$ and $B$.
\end{thm}
\begin{proof}
	We define $\gammabar_X$, for $X$ a pointed type, as the composition of the following equivalences:
	\begin{align*}
		B \smsh A \to X &\simeq B \to A \to X && (e\sy)\\
			&\simeq A \to B \to X && (c)\\
			&\simeq A \smsh B \to X && (e)
	\end{align*}
	where $c : (A \to B \to X) \simeq (B \to A \to X)$ is the obvious pointed equivalence, natural in $A$, $B$ and $X$. $\gamma_X$ is then also natural in all its arguments, by myltiple applications of \autoref{lem:e-natural}; then, as in \autoref{thm:smash-associativity}, we can define $\gamma \defeq \gammabar_{B\smsh A} (\idfunc)$ and $\gamma\sy \defeq \gammabar_{A \smsh B}\sy (\idfunc)$
\end{proof}