\input{preamble}

% OK, start here.
%
\begin{document}

\title{Differential Graded Algebra}


\maketitle

\phantomsection
\label{section-phantom}

\tableofcontents

\section{Introduction}
\label{section-introduction}

\noindent
In this chapter we talk about differential graded algebras, modules,
categories, etc. A basic reference is \cite{Keller-Deriving}.
A survey paper is \cite{Keller-survey}.

\medskip\noindent
Since we do not worry about length of exposition in the Stacks project
we first develop the material in the setting of categories of differential
graded modules. After that we redo the constructions in the setting of
differential graded modules over differential graded categories.



\section{Conventions}
\label{section-conventions}

\noindent
In this chapter we hold on to the convention that {\it ring} means
commutative ring with $1$. If $R$ is a ring, then an {\it $R$-algebra $A$}
will be an $R$-module $A$ endowed with an $R$-bilinear map $A \times A \to A$
(multiplication) such that multiplication is associative and has a unit.
In other words, these are unital associative $R$-algebras
such that the structure map $R \to A$ maps into the center of $A$.

\medskip\noindent
{\bf Sign rules.} In this chapter we will work with graded algebras
and graded modules often equipped with differentials. The sign rules on
underlying complexes will always be (compatible with) those introduced in
More on Algebra, Section \ref{more-algebra-section-sign-rules}.
This will occasionally cause the multiplicative structure to be
twisted in unexpected ways especially when considering left modules
or the relationship between left and right modules.





\section{Differential graded algebras}
\label{section-dga}


\noindent
Just the definitions.

\begin{definition}
\label{definition-dga}
Let $R$ be a commutative ring. A {\it differential graded algebra over $R$}
is either
\begin{enumerate}
\item a chain complex $A_\bullet$ of $R$-modules endowed with
$R$-bilinear maps $A_n \times A_m \to A_{n + m}$,
$(a, b) \mapsto ab$ such that
$$
\text{d}_{n + m}(ab) = \text{d}_n(a)b + (-1)^n a\text{d}_m(b)
$$
and such that $\bigoplus A_n$ becomes an associative and unital
$R$-algebra, or
\item a cochain complex $A^\bullet$ of $R$-modules endowed with
$R$-bilinear maps $A^n \times A^m \to A^{n + m}$, $(a, b) \mapsto ab$
such that
$$
\text{d}^{n + m}(ab) = \text{d}^n(a)b + (-1)^n a\text{d}^m(b)
$$
and such that $\bigoplus A^n$ becomes an associative and unital $R$-algebra.
\end{enumerate}
\end{definition}

\noindent
We often just write $A = \bigoplus A_n$ or $A = \bigoplus A^n$ and
think of this as an associative unital $R$-algebra endowed with a
$\mathbf{Z}$-grading and an $R$-linear operator $\text{d}$ whose square
is zero and which satisfies the Leibniz rule as explained above. In this case
we often say ``Let $(A, \text{d})$ be a differential graded algebra''.

\medskip\noindent
The Leibniz rule relating differentials and multiplication on a differential
graded $R$-algebra $A$ exactly means that the multiplication map defines
a map of cochain complexes
$$
\text{Tot}(A^\bullet \otimes_R A^\bullet) \to A^\bullet
$$
Here $A^\bullet$ denote the underlying cochain complex of $A$.

\begin{definition}
\label{definition-homomorphism-dga}
A {\it homomorphism of differential graded algebras}
$f : (A, \text{d}) \to (B, \text{d})$ is an algebra map $f : A \to B$
compatible with the gradings and $\text{d}$.
\end{definition}

\begin{definition}
\label{definition-cdga}
A differential graded algebra $(A, \text{d})$ is {\it commutative} if
$ab = (-1)^{nm}ba$ for $a$ in degree $n$ and $b$ in degree $m$.
We say $A$ is {\it strictly commutative} if in addition $a^2 = 0$
for $\deg(a)$ odd.
\end{definition}

\noindent
The following definition makes sense in general but is perhaps
``correct'' only when tensoring commutative differential graded
algebras.

\begin{definition}
\label{definition-tensor-product}
Let $R$ be a ring.
Let $(A, \text{d})$, $(B, \text{d})$ be differential graded algebras over $R$.
The {\it tensor product differential graded algebra} of $A$ and $B$
is the algebra $A \otimes_R B$ with multiplication defined by
$$
(a \otimes b)(a' \otimes b') = (-1)^{\deg(a')\deg(b)} aa' \otimes bb'
$$
endowed with differential $\text{d}$ defined by the rule
$\text{d}(a \otimes b) = \text{d}(a) \otimes b + (-1)^m a \otimes \text{d}(b)$
where $m = \deg(a)$.
\end{definition}

\begin{lemma}
\label{lemma-total-complex-tensor-product}
Let $R$ be a ring.
Let $(A, \text{d})$, $(B, \text{d})$ be differential graded algebras over $R$.
Denote $A^\bullet$, $B^\bullet$ the underlying cochain complexes.
As cochain complexes of $R$-modules we have
$$
(A \otimes_R B)^\bullet = \text{Tot}(A^\bullet \otimes_R B^\bullet).
$$
\end{lemma}

\begin{proof}
Recall that the differential of the total complex is given by
$\text{d}_1^{p, q} + (-1)^p \text{d}_2^{p, q}$ on $A^p \otimes_R B^q$.
And this is exactly the same as the rule for the differential
on $A \otimes_R B$ in
Definition \ref{definition-tensor-product}.
\end{proof}






\section{Differential graded modules}
\label{section-modules}

\noindent
Our default in this chapter is right modules;
we discuss left modules in Section \ref{section-left-modules}.

\begin{definition}
\label{definition-dgm}
Let $R$ be a ring.
Let $(A, \text{d})$ be a differential graded algebra over $R$.
A (right) {\it differential graded module} $M$ over $A$ is a right $A$-module
$M$ which has a grading $M = \bigoplus M^n$ and a differential $\text{d}$
such that $M^n A^m \subset M^{n + m}$, such that
$\text{d}(M^n) \subset M^{n + 1}$, and such that
$$
\text{d}(ma) = \text{d}(m)a + (-1)^n m\text{d}(a)
$$
for $a \in A$ and $m \in M^n$. A
{\it homomorphism of differential graded modules} $f : M \to N$
is an $A$-module map compatible with gradings and differentials.
The category of (right) differential graded $A$-modules is denoted
$\text{Mod}_{(A, \text{d})}$.
\end{definition}

\noindent
Note that we can think of $M$ as a cochain complex $M^\bullet$
of (right) $R$-modules. Namely, for $r \in R$ we have $\text{d}(r) = 0$
and $r$ maps to a degree $0$ element of $A$, hence
$\text{d}(mr) = \text{d}(m)r$.

\medskip\noindent
The Leibniz rule relating differentials and multiplication on a differential
graded $R$-module $M$ over a differential graded $R$-algebra $A$
exactly means that the multiplication map defines a map of cochain complexes
$$
\text{Tot}(M^\bullet \otimes_R A^\bullet) \to M^\bullet
$$
Here $A^\bullet$ and $M^\bullet$ denote the underlying cochain complexes
of $A$ and $M$.

\begin{lemma}
\label{lemma-dgm-abelian}
Let $(A, d)$ be a differential graded algebra. The category
$\text{Mod}_{(A, \text{d})}$ is abelian and has arbitrary limits and colimits.
\end{lemma}

\begin{proof}
Kernels and cokernels commute with taking underlying $A$-modules.
Similarly for direct sums and colimits. In other words, these operations
in $\text{Mod}_{(A, \text{d})}$ commute with the forgetful functor to the
category of $A$-modules. This is not the case for products and limits.
Namely, if $N_i$, $i \in I$ is a family of
differential graded $A$-modules, then the product $\prod N_i$ in
$\text{Mod}_{(A, \text{d})}$ is given by setting $(\prod N_i)^n = \prod N_i^n$
and $\prod N_i = \bigoplus_n (\prod N_i)^n$. Thus we see that the product
does commute with the forgetful functor to the category of graded $A$-modules.
A category with products and equalizers has limits, see
Categories, Lemma \ref{categories-lemma-limits-products-equalizers}.
\end{proof}

\noindent
Thus, if $(A, \text{d})$ is a differential graded
algebra over $R$, then there is an exact functor
$$
\text{Mod}_{(A, \text{d})} \longrightarrow \text{Comp}(R)
$$
of abelian categories. For a differential graded module $M$ the
cohomology groups $H^n(M)$ are defined as the cohomology of the
corresponding complex of $R$-modules. Therefore, a short exact
sequence $0 \to K \to L \to M \to 0$ of differential graded modules
gives rise to a long exact sequence
\begin{equation}
\label{equation-les}
H^n(K) \to H^n(L) \to H^n(M) \to H^{n + 1}(K)
\end{equation}
of cohomology modules, see
Homology, Lemma \ref{homology-lemma-long-exact-sequence-cochain}.

\medskip\noindent
Moreover, from now on we borrow all the terminology used for
complexes of modules. For example, we say that a differential
graded $A$-module $M$ is {\it acyclic} if $H^k(M) = 0$ for
all $k \in \mathbf{Z}$. We say that a homomorphism $M \to N$
of differential graded $A$-modules is a {\it quasi-isomorphism}
if it induces isomorphisms $H^k(M) \to H^k(N)$ for all $k \in \mathbf{Z}$.
And so on and so forth.

\begin{definition}
\label{definition-shift}
Let $(A, \text{d})$ be a differential graded algebra.
Let $M$ be a differential graded module whose underlying complex
of $R$-modules is $M^\bullet$. For any $k \in \mathbf{Z}$
we define the {\it $k$-shifted module} $M[k]$ as follows
\begin{enumerate}
\item the underlying complex of $R$-modules of $M[k]$ is $M^\bullet[k]$,
i.e., we have $M[k]^n = M^{n + k}$ and
$\text{d}_{M[k]} = (-1)^k\text{d}_M$ and
\item as $A$-module the multiplication
$$
(M[k])^n \times A^m \longrightarrow (M[k])^{n + m}
$$
is equal to the given multiplication $M^{n + k} \times A^m \to M^{n + k + m}$.
\end{enumerate}
For a morphism $f : M \to N$ of differential graded $A$-modules
we let $f[k] : M[k] \to N[k]$ be the map equal to $f$ on underlying
$A$-modules. This defines a functor
$[k] : \text{Mod}_{(A, \text{d})} \to \text{Mod}_{(A, \text{d})}$.
\end{definition}

\noindent
Let us check that with this choice the Leibniz rule is satisfied.
Let $x \in M[k]^n = M^{n + k}$ and $a \in A^m$ and denoting
$\cdot_{M[k]}$ the product in $M[k]$ then we see
\begin{align*}
\text{d}_{M[k]}(x \cdot_{M[k]} a)
& =
(-1)^k \text{d}_M(xa) \\
& =
(-1)^k \text{d}_M(x) a + (-1)^{k + n + k} x \text{d}(a) \\
& =
\text{d}_{M[k]}(x) a + (-1)^n x \text{d}(a) \\
& =
\text{d}_{M[k]}(x) \cdot_{M[k]} a + (-1)^n x \cdot_{M[k]} \text{d}(a)
\end{align*}
This is what we want as $x$ has degree $n$ as a homogeneous element of $M[k]$.
We also observe that with these choices we may think of
the multiplication map as the map of complexes
$$
\text{Tot}(M^\bullet[k] \otimes _R A^\bullet) \to
\text{Tot}(M^\bullet \otimes _R A^\bullet)[k] \to
M^\bullet[k]
$$
where the first arrow is
More on Algebra, Section \ref{more-algebra-section-sign-rules}
(\ref{more-algebra-item-shift-tensor}) which in this
case does not involve a sign. (In fact, we could have deduced
that the Liebniz rule holds from this observation.)

\medskip\noindent
The remarks in Homology, Section \ref{homology-section-homotopy-shift} apply.
In particular, we will identify the cohomology groups of all shifts
$M[k]$ without the intervention of signs.

\medskip\noindent
At this point we have enough structure to talk about {\it triangles},
see Derived Categories, Definition \ref{derived-definition-triangle}.
In fact, our next goal is to develop enough theory to be able to
state and prove that the homotopy category of differential graded
modules is a triangulated category. First we define the homotopy category.






\section{The homotopy category}
\label{section-homotopy}

\noindent
Our homotopies take into account the $A$-module structure and the
grading, but not the differential (of course).

\begin{definition}
\label{definition-homotopy}
Let $(A, \text{d})$ be a differential graded algebra. Let
$f, g : M \to N$ be homomorphisms of differential graded $A$-modules.
A {\it homotopy between $f$ and $g$} is an $A$-module map $h : M \to N$
such that
\begin{enumerate}
\item $h(M^n) \subset N^{n - 1}$ for all $n$, and
\item $f(x) - g(x) = \text{d}_N(h(x)) + h(\text{d}_M(x))$ for
all $x \in M$.
\end{enumerate}
If a homotopy exists, then we say $f$ and $g$ are {\it homotopic}.
\end{definition}

\noindent
Thus $h$ is compatible with the $A$-module structure and the grading
but not with the differential. If $f = g$ and $h$ is a homotopy
as in the definition, then $h$ defines a morphism $h : M \to N[-1]$
in $\text{Mod}_{(A, \text{d})}$.

\begin{lemma}
\label{lemma-compose-homotopy}
Let $(A, \text{d})$ be a differential graded algebra.
Let $f, g : L \to M$ be homomorphisms of differential graded $A$-modules.
Suppose given further homomorphisms $a : K \to L$, and $c : M \to N$.
If $h : L \to M$ is an $A$-module map which defines a homotopy between
$f$ and $g$, then $c \circ h \circ a$ defines a homotopy between
$c \circ f \circ a$ and $c \circ g \circ a$.
\end{lemma}

\begin{proof}
Immediate from Homology, Lemma \ref{homology-lemma-compose-homotopy-cochain}.
\end{proof}

\noindent
This lemma allows us to define the homotopy category as follows.

\begin{definition}
\label{definition-complexes-notation}
Let $(A, \text{d})$ be a differential graded algebra.
The {\it homotopy category}, denoted $K(\text{Mod}_{(A, \text{d})})$, is
the category whose objects are the objects of
$\text{Mod}_{(A, \text{d})}$ and whose morphisms are homotopy classes
of homomorphisms of differential graded $A$-modules.
\end{definition}

\noindent
The notation $K(\text{Mod}_{(A, \text{d})})$ is not standard but at least is
consistent with the use of $K(-)$ in other places of the Stacks project.

\begin{lemma}
\label{lemma-homotopy-direct-sums}
Let $(A, \text{d})$ be a differential graded algebra.
The homotopy category $K(\text{Mod}_{(A, \text{d})})$
has direct sums and products.
\end{lemma}

\begin{proof}
Omitted. Hint: Just use the direct sums and products as in
Lemma \ref{lemma-dgm-abelian}. This works because we saw that
these functors commute with the forgetful functor to the category
of graded $A$-modules and because $\prod$ is an exact functor
on the category of families of abelian groups.
\end{proof}







\section{Cones}
\label{section-cones}

\noindent
We introduce cones for the category of differential graded modules.

\begin{definition}
\label{definition-cone}
Let $(A, \text{d})$ be a differential graded algebra.
Let $f : K \to L$ be a homomorphism of differential graded $A$-modules.
The {\it cone} of $f$ is the differential graded $A$-module
$C(f)$ given by $C(f) = L \oplus K$ with grading
$C(f)^n = L^n \oplus K^{n + 1}$ and
differential
$$
d_{C(f)} =
\left(
\begin{matrix}
\text{d}_L & f \\
0 & -\text{d}_K
\end{matrix}
\right)
$$
It comes equipped with canonical morphisms of complexes $i : L \to C(f)$
and $p : C(f) \to K[1]$ induced by the obvious maps $L \to C(f)$
and $C(f) \to K$.
\end{definition}

\noindent
The formation of the cone triangle is functorial in the following sense.

\begin{lemma}
\label{lemma-functorial-cone}
Let $(A, \text{d})$ be a differential graded algebra.
Suppose that
$$
\xymatrix{
K_1 \ar[r]_{f_1} \ar[d]_a & L_1 \ar[d]^b \\
K_2 \ar[r]^{f_2} & L_2
}
$$
is a diagram of homomorphisms of differential graded $A$-modules which is
commutative up to homotopy.
Then there exists a morphism $c : C(f_1) \to C(f_2)$ which gives rise to
a morphism of triangles
$$
(a, b, c) : (K_1, L_1, C(f_1), f_1, i_1, p_1) \to
(K_1, L_1, C(f_1), f_2, i_2, p_2)
$$
in $K(\text{Mod}_{(A, \text{d})})$.
\end{lemma}

\begin{proof}
Let $h : K_1 \to L_2$ be a homotopy between $f_2 \circ a$ and $b \circ f_1$.
Define $c$ by the matrix
$$
c =
\left(
\begin{matrix}
b & h \\
0 & a
\end{matrix}
\right) :
L_1 \oplus K_1 \to L_2 \oplus K_2
$$
A matrix computation show that $c$ is a morphism of differential
graded modules. It is trivial that $c \circ i_1 = i_2 \circ b$, and it is
trivial also to check that $p_2 \circ c = a \circ p_1$.
\end{proof}











\section{Admissible short exact sequences}
\label{section-admissible}

\noindent
An admissible short exact sequence is the analogue of termwise split exact
sequences in the setting of differential graded modules.

\begin{definition}
\label{definition-admissible-ses}
Let $(A, \text{d})$ be a differential graded algebra.
\begin{enumerate}
\item A homomorphism $K \to L$ of differential graded $A$-modules
is an {\it admissible monomorphism} if there exists a graded $A$-module
map $L \to K$ which is left inverse to $K \to L$.
\item A homomorphism $L \to M$ of differential graded $A$-modules
is an {\it admissible epimorphism} if there exists a graded $A$-module
map $M \to L$ which is right inverse to $L \to M$.
\item A short exact sequence $0 \to K \to L \to M \to 0$ of differential
graded $A$-modules is an {\it admissible short exact sequence}
if it is split as a sequence of graded $A$-modules.
\end{enumerate}
\end{definition}

\noindent
Thus the splittings are compatible with all the data except for
the differentials. Given an admissible short exact sequence we
obtain a triangle; this is the reason that we require our splittings
to be compatible with the $A$-module structure.

\begin{lemma}
\label{lemma-admissible-ses}
Let $(A, \text{d})$ be a differential graded algebra.
Let $0 \to K \to L \to M \to 0$ be an admissible short exact sequence
of differential graded $A$-modules. Let $s : M \to L$ and $\pi : L \to K$
be splittings such that $\Ker(\pi) = \Im(s)$.
Then we obtain a morphism
$$
\delta = \pi \circ \text{d}_L \circ s : M \to K[1]
$$
of $\text{Mod}_{(A, \text{d})}$ which induces the boundary maps
in the long exact sequence of cohomology (\ref{equation-les}).
\end{lemma}

\begin{proof}
The map $\pi \circ \text{d}_L \circ s$ is compatible with the $A$-module
structure and the gradings by construction. It is compatible with
differentials by Homology, Lemmas
\ref{homology-lemma-ses-termwise-split-cochain}.
Let $R$ be the ring that $A$ is a differential graded algebra over.
The equality of maps is a statement about $R$-modules. Hence this
follows from Homology, Lemmas
\ref{homology-lemma-ses-termwise-split-cochain} and
\ref{homology-lemma-ses-termwise-split-long-cochain}.
\end{proof}

\begin{lemma}
\label{lemma-make-commute-map}
Let $(A, \text{d})$ be a differential graded algebra. Let
$$
\xymatrix{
K \ar[r]_f \ar[d]_a & L \ar[d]^b \\
M \ar[r]^g & N
}
$$
be a diagram of homomorphisms of differential graded $A$-modules
commuting up to homotopy.
\begin{enumerate}
\item If $f$ is an admissible monomorphism, then $b$ is homotopic to a
homomorphism which makes the diagram commute.
\item If $g$ is an admissible epimorphism, then $a$ is homotopic to a
morphism which makes the diagram commute.
\end{enumerate}
\end{lemma}

\begin{proof}
Let $h : K \to N$ be a homotopy between $bf$ and $ga$, i.e.,
$bf - ga = \text{d}h + h\text{d}$. Suppose that $\pi : L \to K$
is a graded $A$-module map left inverse to $f$. Take
$b' = b - \text{d}h\pi - h\pi \text{d}$.
Suppose $s : N \to M$ is a graded $A$-module map right inverse to $g$.
Take $a' = a + \text{d}sh + sh\text{d}$.
Computations omitted.
\end{proof}

\begin{lemma}
\label{lemma-make-injective}
Let $(A, \text{d})$ be a differential graded algebra.
Let $\alpha : K \to L$ be a homomorphism of differential graded
$A$-modules. There exists a factorization
$$
\xymatrix{
K \ar[r]^{\tilde \alpha} \ar@/_1pc/[rr]_\alpha &
\tilde L \ar[r]^\pi & L
}
$$
in $\text{Mod}_{(A, \text{d})}$ such that
\begin{enumerate}
\item $\tilde \alpha$ is an admissible monomorphism (see
Definition \ref{definition-admissible-ses}),
\item there is a morphism $s : L \to \tilde L$
such that $\pi \circ s = \text{id}_L$ and such that
$s \circ \pi$ is homotopic to $\text{id}_{\tilde L}$.
\end{enumerate}
\end{lemma}

\begin{proof}
The proof is identical to the proof of
Derived Categories, Lemma \ref{derived-lemma-make-injective}.
Namely, we set $\tilde L = L \oplus C(1_K)$ and we use elementary
properties of the cone construction.
\end{proof}

\begin{lemma}
\label{lemma-sequence-maps-split}
Let $(A, \text{d})$ be a differential graded algebra.
Let $L_1 \to L_2 \to \ldots \to L_n$
be a sequence of composable homomorphisms of
differential graded $A$-modules.
There exists a commutative diagram
$$
\xymatrix{
L_1 \ar[r] &
L_2 \ar[r] &
\ldots \ar[r] &
L_n \\
M_1 \ar[r] \ar[u] &
M_2 \ar[r] \ar[u] &
\ldots \ar[r] &
M_n \ar[u]
}
$$
in $\text{Mod}_{(A, \text{d})}$ such that each $M_i \to M_{i + 1}$
is an admissible monomorphism and each $M_i \to L_i$
is a homotopy equivalence.
\end{lemma}

\begin{proof}
The case $n = 1$ is without content.
Lemma \ref{lemma-make-injective} is the case $n = 2$.
Suppose we have constructed the diagram
except for $M_n$. Apply Lemma \ref{lemma-make-injective} to
the composition $M_{n - 1} \to L_{n - 1} \to L_n$.
The result is a factorization $M_{n - 1} \to M_n \to L_n$
as desired.
\end{proof}



\begin{lemma}
\label{lemma-nilpotent}
Let $(A, \text{d})$ be a differential graded algebra.
Let $0 \to K_i \to L_i \to M_i \to 0$, $i = 1, 2, 3$
be admissible short exact sequence of differential graded $A$-modules.
Let $b : L_1 \to L_2$ and $b' : L_2 \to L_3$
be homomorphisms of differential graded modules such that
$$
\vcenter{
\xymatrix{
K_1 \ar[d]_0 \ar[r] &
L_1 \ar[r] \ar[d]_b &
M_1 \ar[d]_0 \\
K_2 \ar[r] & L_2 \ar[r] & M_2
}
}
\quad\text{and}\quad
\vcenter{
\xymatrix{
K_2 \ar[d]^0 \ar[r] &
L_2 \ar[r] \ar[d]^{b'} &
M_2 \ar[d]^0 \\
K_3 \ar[r] & L_3 \ar[r] & M_3
}
}
$$
commute up to homotopy. Then $b' \circ b$ is homotopic to $0$.
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-make-commute-map} we can replace $b$ and $b'$ by
homotopic maps such that the right square of the left diagram commutes
and the left square of the right diagram commutes. In other words, we have
$\Im(b) \subset \Im(K_2 \to L_2)$ and
$\Ker((b')^n) \supset \Im(K_2 \to L_2)$.
Then $b \circ b' = 0$ as a map of modules.
\end{proof}
















\section{Distinguished triangles}
\label{section-distinguished}

\noindent
The following lemma produces our distinguished triangles.

\begin{lemma}
\label{lemma-triangle-independent-splittings}
Let $(A, \text{d})$ be a differential graded algebra. Let
$0 \to K \to L \to M \to 0$ be an admissible short exact sequence
of differential graded $A$-modules. The triangle
\begin{equation}
\label{equation-triangle-associated-to-admissible-ses}
K \to L \to M \xrightarrow{\delta} K[1]
\end{equation}
with $\delta$ as in Lemma \ref{lemma-admissible-ses} is, up to canonical
isomorphism in $K(\text{Mod}_{(A, \text{d})})$, independent of the choices
made in Lemma \ref{lemma-admissible-ses}.
\end{lemma}

\begin{proof}
Namely, let $(s', \pi')$ be a second choice of splittings as in
Lemma \ref{lemma-admissible-ses}. Then we claim that $\delta$ and $\delta'$
are homotopic. Namely, write $s' = s + \alpha \circ h$ and
$\pi' = \pi + g \circ \beta$ for some unique homomorphisms
of $A$-modules $h : M \to K$ and $g : M \to K$ of degree $-1$.
Then $g = -h$ and $g$ is a homotopy between $\delta$ and $\delta'$.
The computations are done in the proof of
Homology, Lemma \ref{homology-lemma-ses-termwise-split-homotopy-cochain}.
\end{proof}

\begin{definition}
\label{definition-distinguished-triangle}
Let $(A, \text{d})$ be a differential graded algebra.
\begin{enumerate}
\item If $0 \to K \to L \to M \to 0$ is an admissible short exact sequence
of differential graded $A$-modules, then the {\it triangle associated
to $0 \to K \to L \to M \to 0$} is the triangle 
(\ref{equation-triangle-associated-to-admissible-ses})
of $K(\text{Mod}_{(A, \text{d})})$.
\item A triangle of $K(\text{Mod}_{(A, \text{d})})$ is called a
{\it distinguished triangle} if it is isomorphic to a triangle
associated to an admissible short exact sequence
of differential graded $A$-modules.
\end{enumerate}
\end{definition}









\section{Cones and distinguished triangles}
\label{section-cones-and-triangles}

\noindent
Let $(A, \text{d})$ be a differential graded algebra.
Let $f : K \to L$ be a homomorphism of differential graded $A$-modules.
Then $(K, L, C(f), f, i, p)$ forms a triangle:
$$
K \to L \to C(f) \to K[1]
$$
in $\text{Mod}_{(A, \text{d})}$ and hence in $K(\text{Mod}_{(A, \text{d})})$.
Cones are {\bf not} distinguished triangles in general, but the difference
is a sign or a rotation (your choice). Here are two precise statements.

\begin{lemma}
\label{lemma-rotate-cone}
Let $(A, \text{d})$ be a differential graded algebra.
Let $f : K \to L$ be a homomorphism of differential graded modules.
The triangle $(L, C(f), K[1], i, p, f[1])$ is
the triangle associated to the admissible short exact sequence
$$
0 \to L \to C(f) \to K[1] \to 0
$$
coming from the definition of the cone of $f$.
\end{lemma}

\begin{proof}
Immediate from the definitions.
\end{proof}

\begin{lemma}
\label{lemma-rotate-triangle}
Let $(A, \text{d})$ be a differential graded algebra.
Let $\alpha : K \to L$ and $\beta : L \to M$
define an admissible short exact sequence
$$
0 \to K \to L \to M \to 0
$$
of differential graded $A$-modules.
Let $(K, L, M, \alpha, \beta, \delta)$
be the associated triangle. Then the triangles
$$
(M[-1], K, L, \delta[-1], \alpha, \beta)
\quad\text{and}\quad
(M[-1], K, C(\delta[-1]), \delta[-1], i, p)
$$
are isomorphic.
\end{lemma}

\begin{proof}
Using a choice of splittings we write $L = K \oplus M$ and we identify
$\alpha$ and $\beta$ with the natural inclusion and projection maps.
By construction of $\delta$ we have
$$
d_B =
\left(
\begin{matrix}
d_K & \delta \\
0 & d_M
\end{matrix}
\right)
$$
On the other hand the cone of $\delta[-1] : M[-1] \to K$
is given as $C(\delta[-1]) = K \oplus M$ with differential identical
with the matrix above! Whence the lemma.
\end{proof}

\begin{lemma}
\label{lemma-third-isomorphism}
Let $(A, \text{d})$ be a differential graded algebra.
Let $f_1 : K_1 \to L_1$ and $f_2 : K_2 \to L_2$ be homomorphisms of
differential graded $A$-modules. Let
$$
(a, b, c) :
(K_1, L_1, C(f_1), f_1, i_1, p_1)
\longrightarrow
(K_1, L_1, C(f_1), f_2, i_2, p_2)
$$
be any morphism of triangles of $K(\text{Mod}_{(A, \text{d})})$.
If $a$ and $b$ are homotopy equivalences then so is $c$.
\end{lemma}

\begin{proof}
Let $a^{-1} : K_2 \to K_1$ be a homomorphism of differential graded $A$-modules
which is inverse to $a$ in $K(\text{Mod}_{(A, \text{d})})$.
Let $b^{-1} : L_2 \to L_1$ be a homomorphism of differential graded $A$-modules
which is inverse to $b$ in $K(\text{Mod}_{(A, \text{d})})$.
Let $c' : C(f_2) \to C(f_1)$ be the morphism from
Lemma \ref{lemma-functorial-cone} applied to
$f_1 \circ a^{-1} = b^{-1} \circ f_2$.
If we can show that $c \circ c'$ and $c' \circ c$ are isomorphisms in
$K(\text{Mod}_{(A, \text{d})})$
then we win. Hence it suffices to prove the following: Given
a morphism of triangles
$(1, 1, c) : (K, L, C(f), f, i, p)$
in $K(\text{Mod}_{(A, \text{d})})$ the morphism $c$ is an isomorphism
in $K(\text{Mod}_{(A, \text{d})})$.
By assumption the two squares in the diagram
$$
\xymatrix{
L \ar[r] \ar[d]_1 &
C(f) \ar[r] \ar[d]_c &
K[1] \ar[d]_1 \\
L \ar[r] &
C(f) \ar[r] &
K[1]
}
$$
commute up to homotopy. By construction of $C(f)$ the rows
form admissible short exact sequences. Thus we see that
$(c - 1)^2 = 0$ in $K(\text{Mod}_{(A, \text{d})})$ by
Lemma \ref{lemma-nilpotent}.
Hence $c$ is an isomorphism in $K(\text{Mod}_{(A, \text{d})})$
with inverse $2 - c$.
\end{proof}

\noindent
The following lemma shows that the collection of triangles of the homotopy
category given by cones and the distinguished triangles are the same
up to isomorphisms, at least up to sign!

\begin{lemma}
\label{lemma-the-same-up-to-isomorphisms}
Let $(A, \text{d})$ be a differential graded algebra.
\begin{enumerate}
\item Given an admissible short exact sequence
$0 \to K \xrightarrow{\alpha} L \to M \to 0$
of differential graded $A$-modules there exists a homotopy equivalence
$C(\alpha) \to M$ such that the diagram
$$
\xymatrix{
K \ar[r] \ar[d] & L \ar[d] \ar[r] &
C(\alpha) \ar[r]_{-p} \ar[d] & K[1] \ar[d] \\
K \ar[r]^\alpha & L \ar[r]^\beta &
M \ar[r]^\delta & K[1]
}
$$
defines an isomorphism of triangles in $K(\text{Mod}_{(A, \text{d})})$.
\item Given a morphism of complexes $f : K \to L$
there exists an isomorphism of triangles
$$
\xymatrix{
K \ar[r] \ar[d] & \tilde L \ar[d] \ar[r] &
M \ar[r]_{\delta} \ar[d] & K[1] \ar[d] \\
K \ar[r] & L \ar[r] &
C(f) \ar[r]^{-p} & K[1]
}
$$
where the upper triangle is the triangle associated to a
admissible short exact sequence $K \to \tilde L \to M$.
\end{enumerate}
\end{lemma}

\begin{proof}
Proof of (1). We have $C(\alpha) = L \oplus K$ and we simply define
$C(\alpha) \to M$ via the projection onto $L$ followed by $\beta$.
This defines a morphism of differential graded modules because the
compositions $K^{n + 1} \to L^{n + 1} \to M^{n + 1}$ are zero.
Choose splittings $s : M \to L$ and $\pi : L \to K$ with
$\Ker(\pi) = \Im(s)$ and set
$\delta = \pi \circ \text{d}_L \circ s$ as usual.
To get a homotopy inverse we take
$M \to C(\alpha)$ given by $(s , -\delta)$. This is compatible with
differentials because $\delta^n$ can be characterized as the
unique map $M^n \to K^{n + 1}$ such that
$\text{d} \circ s^n - s^{n + 1} \circ \text{d} = \alpha \circ \delta^n$,
see proof of
Homology, Lemma \ref{homology-lemma-ses-termwise-split-cochain}.
The composition $M \to C(f) \to M$ is the identity.
The composition $C(f) \to M \to C(f)$ is equal to the morphism
$$
\left(
\begin{matrix}
s \circ \beta & 0 \\
-\delta \circ \beta & 0
\end{matrix}
\right)
$$
To see that this is homotopic to the identity map
use the homotopy $h : C(\alpha) \to C(\alpha)$
given by the matrix
$$
\left(
\begin{matrix}
0 & 0 \\
\pi & 0
\end{matrix}
\right) :
C(\alpha) = L \oplus K
\to
L \oplus K = C(\alpha)
$$
It is trivial to verify that
$$
\left(
\begin{matrix}
1 & 0 \\
0 & 1
\end{matrix}
\right)
-
\left(
\begin{matrix}
s \\
-\delta
\end{matrix}
\right)
\left(
\begin{matrix}
\beta & 0
\end{matrix}
\right)
=
\left(
\begin{matrix}
\text{d} & \alpha \\
0 & -\text{d}
\end{matrix}
\right)
\left(
\begin{matrix}
0 & 0 \\
\pi & 0
\end{matrix}
\right)
+
\left(
\begin{matrix}
0 & 0 \\
\pi & 0
\end{matrix}
\right)
\left(
\begin{matrix}
\text{d} & \alpha \\
0 & -\text{d}
\end{matrix}
\right)
$$
To finish the proof of (1) we have to show that the morphisms
$-p : C(\alpha) \to K[1]$ (see
Definition \ref{definition-cone})
and $C(\alpha) \to M \to K[1]$ agree up
to homotopy. This is clear from the above. Namely, we can use the homotopy
inverse $(s, -\delta) : M \to C(\alpha)$
and check instead that the two maps
$M \to K[1]$ agree. And note that
$p \circ (s, -\delta) = -\delta$ as desired.

\medskip\noindent
Proof of (2). We let $\tilde f : K \to \tilde L$,
$s : L \to \tilde L$
and $\pi : L \to L$ be as in
Lemma \ref{lemma-make-injective}. By
Lemmas \ref{lemma-functorial-cone} and \ref{lemma-third-isomorphism}
the triangles $(K, L, C(f), i, p)$ and
$(K, \tilde L, C(\tilde f), \tilde i, \tilde p)$
are isomorphic. Note that we can compose isomorphisms of
triangles. Thus we may replace $L$ by
$\tilde L$ and $f$ by $\tilde f$. In other words
we may assume that $f$ is an admissible monomorphism.
In this case the result follows from part (1).
\end{proof}







\section{The homotopy category is triangulated}
\label{section-homotopy-triangulated}

\noindent
We first prove that it is pre-triangulated.

\begin{lemma}
\label{lemma-homotopy-category-pre-triangulated}
Let $(A, \text{d})$ be a differential graded algebra.
The homotopy category $K(\text{Mod}_{(A, \text{d})})$
with its natural translation functors and distinguished triangles
is a pre-triangulated category.
\end{lemma}

\begin{proof}
Proof of TR1. By definition every triangle isomorphic to a distinguished
one is distinguished. Also, any triangle $(K, K, 0, 1, 0, 0)$
is distinguished since $0 \to K \to K \to 0 \to 0$ is
an admissible short exact sequence. Finally, given any homomorphism
$f : K \to L$ of differential graded $A$-modules the triangle
$(K, L, C(f), f, i, -p)$ is distinguished by
Lemma \ref{lemma-the-same-up-to-isomorphisms}.

\medskip\noindent
Proof of TR2. Let $(X, Y, Z, f, g, h)$ be a triangle.
Assume $(Y, Z, X[1], g, h, -f[1])$ is distinguished.
Then there exists an admissible short exact sequence
$0 \to K \to L \to M \to 0$ such that the associated
triangle $(K, L, M, \alpha, \beta, \delta)$
is isomorphic to $(Y, Z, X[1], g, h, -f[1])$. Rotating back we see
that $(X, Y, Z, f, g, h)$ is isomorphic to
$(M[-1], K, L, -\delta[-1], \alpha, \beta)$.
It follows from Lemma \ref{lemma-rotate-triangle} that the triangle
$(M[-1], K, L, \delta[-1], \alpha, \beta)$
is isomorphic to
$(M[-1], K, C(\delta[-1]), \delta[-1], i, p)$.
Precomposing the previous isomorphism of triangles with $-1$ on $Y$
it follows that $(X, Y, Z, f, g, h)$ is isomorphic to
$(M[-1], K, C(\delta[-1]), \delta[-1], i, -p)$.
Hence it is distinguished by
Lemma \ref{lemma-the-same-up-to-isomorphisms}.
On the other hand, suppose that $(X, Y, Z, f, g, h)$ is distinguished.
By Lemma \ref{lemma-the-same-up-to-isomorphisms} this means that it is
isomorphic to a triangle of the form
$(K, L, C(f), f, i, -p)$ for some morphism $f$ of
$\text{Mod}_{(A, \text{d})}$. Then the rotated triangle
$(Y, Z, X[1], g, h, -f[1])$ is
isomorphic to $(L, C(f), K[1], i, -p, -f[1])$ which is
isomorphic to the triangle
$(L, C(f), K[1], i, p, f[1])$.
By Lemma \ref{lemma-rotate-cone} this triangle is distinguished.
Hence $(Y, Z, X[1], g, h, -f[1])$ is distinguished as desired.

\medskip\noindent
Proof of TR3. Let $(X, Y, Z, f, g, h)$ and $(X', Y', Z', f', g', h')$
be distinguished triangles of $K(\mathcal{A})$ and let $a : X \to X'$
and $b : Y \to Y'$ be morphisms such that $f' \circ a = b \circ f$. By
Lemma \ref{lemma-the-same-up-to-isomorphisms} we may assume that
$(X, Y, Z, f, g, h) = (X, Y, C(f), f, i, -p)$ and
$(X', Y', Z', f', g', h') = (X', Y', C(f'), f', i', -p')$.
At this point we simply apply Lemma \ref{lemma-functorial-cone}
to the commutative diagram given by $f, f', a, b$.
\end{proof}

\noindent
Before we prove TR4 in general we prove it in a special case.

\begin{lemma}
\label{lemma-two-split-injections}
Let $(A, \text{d})$ be a differential graded algebra. Suppose that
$\alpha : K \to L$ and $\beta : L \to M$ are admissible monomorphisms
of differential graded $A$-modules. Then there exist distinguished triangles
$(K, L, Q_1, \alpha, p_1, d_1)$, $(K, M, Q_2, \beta \circ \alpha, p_2, d_2)$
and $(L, M, Q_3, \beta, p_3, d_3)$ for which TR4 holds.
\end{lemma}

\begin{proof}
Say $\pi_1 : L \to K$ and $\pi_3 : M \to L$ are homomorphisms
of graded $A$-modules which are left inverse to $\alpha$ and $\beta$.
Then also $K \to M$ is an admissible monomorphism with left
inverse $\pi_2 = \pi_1 \circ \pi_3$. Let us write $Q_1$, $Q_2$
and $Q_3$ for the cokernels of $K \to L$, $K \to M$, and $L \to M$.
Then we obtain identifications (as graded $A$-modules)
$Q_1 = \Ker(\pi_1)$, $Q_3 = \Ker(\pi_3)$ and
$Q_2 = \Ker(\pi_2)$. Then $L = K \oplus Q_1$ and
$M = L \oplus Q_3$ as graded $A$-modules. This implies
$M = K \oplus Q_1 \oplus Q_3$. Note that $\pi_2 = \pi_1 \circ \pi_3$
is zero on both $Q_1$ and $Q_3$. Hence $Q_2 = Q_1 \oplus Q_3$.
Consider the commutative diagram
$$
\begin{matrix}
0 & \to & K & \to & L & \to & Q_1 & \to & 0 \\
  &     & \downarrow &     & \downarrow &     & \downarrow  & \\
0 & \to & K & \to & M & \to & Q_2 & \to & 0 \\
  &     & \downarrow &     & \downarrow &     & \downarrow  & \\
0 & \to & L & \to & M & \to & Q_3 & \to & 0
\end{matrix}
$$
The rows of this diagram are admissible short exact sequences, and
hence determine distinguished triangles by definition. Moreover
downward arrows in the diagram above are compatible with the chosen
splittings and hence define morphisms of triangles
$$
(K \to L \to Q_1 \to K[1])
\longrightarrow
(K \to M \to Q_2 \to K[1])
$$
and
$$
(K \to M \to Q_2 \to K[1])
\longrightarrow
(L \to M \to Q_3 \to L[1]).
$$
Note that the splittings $Q_3 \to M$ of the bottom sequence in the
diagram provides a splitting for the split sequence
$0 \to Q_1 \to Q_2 \to Q_3 \to 0$ upon composing with $M \to Q_2$.
It follows easily from this that the morphism $\delta : Q_3 \to Q_1[1]$
in the corresponding distinguished triangle
$$
(Q_1 \to Q_2 \to Q_3 \to Q_1[1])
$$
is equal to the composition $Q_3 \to L[1] \to Q_1[1]$.
Hence we get a structure as in the conclusion of axiom TR4.
\end{proof}

\noindent
Here is the final result.

\begin{proposition}
\label{proposition-homotopy-category-triangulated}
Let $(A, \text{d})$ be a differential graded algebra. The homotopy category
$K(\text{Mod}_{(A, \text{d})})$ of differential graded $A$-modules with its
natural translation functors and distinguished triangles is a triangulated
category.
\end{proposition}

\begin{proof}
We know that $K(\text{Mod}_{(A, \text{d})})$ is a pre-triangulated category.
Hence it suffices to prove TR4 and to prove it we can use
Derived Categories, Lemma \ref{derived-lemma-easier-axiom-four}.
Let $K \to L$ and $L \to M$ be composable morphisms of
$K(\text{Mod}_{(A, \text{d})})$. By
Lemma \ref{lemma-sequence-maps-split} we may assume that
$K \to L$ and $L \to M$ are admissible monomorphisms.
In this case the result follows from
Lemma \ref{lemma-two-split-injections}.
\end{proof}











\section{Left modules}
\label{section-left-modules}

\noindent
Everything we have said sofar has an analogue in the setting
of left differential graded modules, except that one has to
take care with some sign rules.

\medskip\noindent
Let $(A, \text{d})$ be a differential graded $R$-algebra.
Exactly analogous to right modules, we define a
{\it left differential graded $A$-module} $M$ as a left
$A$-module $M$ which has a grading $M = \bigoplus M^n$
and a differential $\text{d}$, such that $A^n M^m \subset M^{n + m}$,
such that $\text{d}(M^n) \subset M^{n + 1}$, and such that
$$
\text{d}(am) = \text{d}(a) m + (-1)^{\deg(a)}a \text{d}(m)
$$
for homogeneous elements $a \in A$ and $m \in M$. As before this
Leibniz rule exactly signifies that the multiplication defines
a map of complexes
$$
\text{Tot}(A^\bullet \otimes_R M^\bullet) \to M^\bullet
$$
Here $A^\bullet$ and $M^\bullet$ denote the complexes of $R$-modules
underlying $A$ and $M$.

\begin{definition}
\label{definition-opposite-dga}
Let $R$ be a ring. Let $(A, \text{d})$ be a differential graded algebra
over $R$. The {\it opposite differential graded algebra} is the differential
graded algebra $(A^{opp}, \text{d})$ over $R$ where $A^{opp} = A$
as a graded $R$-module, $\text{d} = \text{d}$, and multiplication is
given by
$$
a \cdot_{opp} b = (-1)^{\deg(a)\deg(b)} b a
$$
for homogeneous elements $a, b \in A$.
\end{definition}

\noindent
This makes sense because
\begin{align*}
\text{d}(a \cdot_{opp} b)
& =
(-1)^{\deg(a)\deg(b)} \text{d}(b a) \\
& =
(-1)^{\deg(a)\deg(b)} \text{d}(b) a +
(-1)^{\deg(a)\deg(b) + \deg(b)}b\text{d}(a) \\
& =
(-1)^{\deg(a)}a \cdot_{opp} \text{d}(b) + \text{d}(a) \cdot_{opp} b
\end{align*}
as desired. In terms of underlying complexes of $R$-modules
this means that the diagram
$$
\xymatrix{
\text{Tot}(A^\bullet \otimes_R A^\bullet)
\ar[rrr]_-{\text{multiplication of }A^{opp}}
\ar[d]_{\text{commutativity constraint}} & & &
A^\bullet \ar[d]^{\text{id}} \\
\text{Tot}(A^\bullet \otimes_R A^\bullet)
\ar[rrr]^-{\text{multiplication of }A} & & &
A^\bullet
}
$$
commutes. Here the commutativity constraint on the symmetric monoidal
category of complexes of $R$-modules is given in
More on Algebra, Section \ref{more-algebra-section-sign-rules}.

\medskip\noindent
Let $(A, \text{d})$ be a differential graded algebra over $R$.
Let $M$ be a left differential graded $A$-module. We will denote
$M^{opp}$ the module $M$ viewed as a right $A^{opp}$-module with
multiplication $\cdot_{opp}$ defined by the rule
$$
m \cdot_{opp} a = (-1)^{\deg(a)\deg(m)} a m
$$
for $a$ and $m$ homogeneous. This is compatible with differentials
because we could have used the diagram
$$
\xymatrix{
\text{Tot}(M^\bullet \otimes_R A^\bullet)
\ar[rrr]_-{\text{multiplication on }M^{opp}}
\ar[d]_{\text{commutativity constraint}} & & &
M^\bullet \ar[d]^{\text{id}} \\
\text{Tot}(A^\bullet \otimes_R M^\bullet)
\ar[rrr]^-{\text{multiplication on }M} & & &
M^\bullet
}
$$
to define the multiplication $\cdot_{opp}$ on $M^{opp}$.
To see that it is an associative multiplication we compute for
homogeneous elements $a, b \in A$ and $m \in M$ that
\begin{align*}
m \cdot_{opp} (a \cdot_{opp} b)
& =
(-1)^{\deg(a)\deg(b)} m \cdot_{opp} (ba) \\
& =
(-1)^{\deg(a)\deg(b) + \deg(ab)\deg(m)} bam \\
& =
(-1)^{\deg(a)\deg(b) + \deg(ab)\deg(m) + \deg(b)\deg(am)}
(am) \cdot_{opp} b \\
& =
(-1)^{\deg(a)\deg(b) + \deg(ab)\deg(m) + \deg(b)\deg(am) + \deg(a)\deg(m)}
(m \cdot_{opp} a) \cdot_{opp} b \\
& =
(m \cdot_{opp} a) \cdot_{opp} b
\end{align*}
Of course, we could have been shown this using the compatibility between
the associativity and commutativity constraint on the symmetric monoidal
category of complexes of $R$-modules as well.

\begin{lemma}
\label{lemma-left-right}
Let $(A, \text{d})$ be a differential graded $R$-algebra.
The functor $M \mapsto M^{opp}$ from the category of
left differential graded $A$-modules to the category of right
differential graded $A^{opp}$-modules is an equivalence.
\end{lemma}

\begin{proof}
Omitted.
\end{proof}

\noindent
Mext, we come to shifts. Let $(A, \text{d})$ be a differential graded algebra.
Let $M$ be a left differential graded $A$-module whose underlying complex
of $R$-modules is denoted $M^\bullet$.
For any $k \in \mathbf{Z}$ we define the {\it $k$-shifted module}
$M[k]$ as follows
\begin{enumerate}
\item the underlying complex of $R$-modules of $M[k]$ is $M^\bullet[k]$
\item as $A$-module the multiplication
$$
A^n \times (M[k])^m \longrightarrow (M[k])^{n + m}
$$
is equal to $(-1)^{nk}$ times the given multiplication
$A^n \times M^{m + k} \to M^{n + m + k}$.
\end{enumerate}
Let us check that with this choice the Leibniz rule is satisfied.
Let $a \in A^n$ and $x \in M[k]^m = M^{m + k}$ and denoting
$\cdot_{M[k]}$ the product in $M[k]$ then we see
\begin{align*}
\text{d}_{M[k]}(a \cdot_{M[k]} x)
& =
(-1)^{k + nk} \text{d}_M(ax) \\
& =
(-1)^{k + nk} \text{d}(a) x + (-1)^{k + nk + n} a \text{d}_M(x) \\
& =
\text{d}(a) \cdot_{M[k]} x + (-1)^{nk + n} a \text{d}_{M[k]}(x) \\
& =
\text{d}(a) \cdot_{M[k]} x + (-1)^n a \cdot_{M[k]} \text{d}_{M[k]}(x)
\end{align*}
This is what we want as $a$ has degree $n$ as a homogeneous element of $A$.
We also observe that with these choices we may think of
the multiplication map as the map of complexes
$$
\text{Tot}(A^\bullet \otimes_R M^\bullet[k]) \to
\text{Tot}(A^\bullet \otimes_R M^\bullet)[k] \to
M^\bullet[k]
$$
where the first arrow is
More on Algebra, Section \ref{more-algebra-section-sign-rules}
(\ref{more-algebra-item-shift-tensor}) which in this
case involves exactly the sign we chose above. (In fact, we could have deduced
that the Liebniz rule holds from this observation.)

\medskip\noindent
With the rule above we have canonical identifications
$$
(M[k])^{opp} = M^{opp}[k]
$$
of right differential graded $A^{opp}$-modules
defined without the intervention of signs, in other words, the equivalence
of Lemma \ref{lemma-left-right} is compatible with shift functors.

\medskip\noindent
Our choice above necessitates the following definition.

\begin{definition}
\label{definition-shift-graded-module}
Let $R$ be a ring. Let $A$ be a $\mathbf{Z}$-graded $R$-algebra.
\begin{enumerate}
\item Given a right graded $A$-module $M$ we define the
{\it $k$th shifted $A$-module} $M[k]$ as the same as
a right $A$-module but with grading $(M[k])^n = M^{n + k}$.
\item Given a left graded $A$-module $M$ we define the
{\it $k$th shifted $A$-module} $M[k]$ as the module
with grading $(M[k])^n = M^{n + k}$ and multiplication
$A^n \times (M[k])^m \to (M[k])^{n + m}$
equal to $(-1)^{nk}$ times the given multiplication
$A^n \times M^{m + k} \to M^{n + m + k}$.
\end{enumerate}
\end{definition}

\noindent
Let $(A, \text{d})$ be a differential graded algebra. Let
$f, g : M \to N$ be homomorphisms of left differential graded $A$-modules.
A {\it homotopy between $f$ and $g$} is a graded $A$-module map
$h : M \to N[-1]$ (observe the shift!) such that
$$
f(x) - g(x) = \text{d}_N(h(x)) + h(\text{d}_M(x))
$$
for all $x \in M$. If a homotopy exists, then we say $f$ and $g$ are
{\it homotopic}. Thus $h$ is compatible with the $A$-module structure
(with the shifted one on $N$) and the grading (with shifted grading on $N$)
but not with the differential. If $f = g$ and $h$ is a homotopy, then
$h$ defines a morphism $h : M \to N[-1]$ of left differential
graded $A$-modules.

\medskip\noindent
With the rule above we find that $f, g : M \to N$ are homotopic if
and only if the induced morphisms
$f^{opp}, g^{opp} : M^{opp} \to N^{opp}$
are homotopic as right differential graded $A^{opp}$-module homomorphisms
(with the same homotopy).

\medskip\noindent
The homotopy category, cones, admissible short exact sequences,
distinguished triangles are all defined in exactly the same manner
as for right differential graded modules (and everything agrees
on underlying complexes of $R$-modules with the constructions for
complexes of $R$-modules). In this manner we obtain the analogue of
Proposition \ref{proposition-homotopy-category-triangulated}
for left modules as well, or we can deduce it by working
with right modules over the opposite algebra.



\section{Tensor product}
\label{section-tensor-product}

\noindent
Let $R$ be a ring. Let $A$ be an $R$-algebra (see
Section \ref{section-conventions}). Given a right $A$-module $M$
and a left $A$-module $N$ there is a {\it tensor product}
$$
M \otimes_A N
$$
This tensor product is a module over $R$. As an $R$-module $M \otimes_A N$
is generated by symbols $x \otimes y$ with $x \in M$ and $y \in N$ subject
to the relations
$$
\begin{matrix}
(x_1 + x_2) \otimes y - x_1 \otimes y - x_2 \otimes y, \\
x \otimes (y_1 + y_2) - x \otimes y_1 - x \otimes y_2, \\
xa \otimes y - x \otimes ay
\end{matrix}
$$
for $a \in A$, $x, x_1, x_2 \in M$ and $y, y_1, y_2 \in N$.
We list some properties of the tensor product

\medskip\noindent
In each variable the tensor product is right exact, in fact commutes
with direct sums and arbitrary colimits.

\medskip\noindent
The tensor product $M \otimes_A N$ is the receptacle of the universal
$A$-bilinear map $M \times N \to M \otimes_A N$, $(x, y) \mapsto x \otimes y$.
In a formula
$$
\text{Bilinear}_A(M \times N, Q) = \Hom_R(M \otimes_A N, Q)
$$
for any $R$-module $Q$.

\medskip\noindent
If $A$ is a $\mathbf{Z}$-graded algebra and $M$, $N$ are graded
$A$-modules then $M \otimes_A N$ is a graded $R$-module.
Then $n$th graded piece $(M \otimes_A N)^n$ of $M \otimes_A N$
is equal to
$$
\Coker\left(
\bigoplus\nolimits_{r + t + s = n}
M^r \otimes_R A^t \otimes_R N^s \to
\bigoplus\nolimits_{p + q = n} M^p \otimes_R N^q
\right)
$$
where the map sends $x \otimes a \otimes y$ to
$x \otimes ay - xa \otimes y$ for
$x \in M^r$, $y \in N^s$, and $a \in A^t$ with $r + s + t = n$.
In this case the map $M \times N \to M \otimes_A N$ is $A$-bilinear
and compatible with gradings and universal in the sense that
$$
\text{GradedBilinear}_A(M \times N, Q) =
\Hom_{\text{graded }R\text{-modules}}(M \otimes_A N, Q)
$$
for any graded $R$-module $Q$ with an obvious notion of graded
bilinar map.

\medskip\noindent
If $(A, \text{d})$ is a differential graded algebra and
$M$ and $N$ are left and right differential graded $A$-modules, then
$M \otimes_A N$ is a differential graded $R$-module with differential
$$
\text{d}(x \otimes y) =
\text{d}(x) \otimes y + (-1)^{\deg(x)}x \otimes \text{d}(y)
$$
for $x \in M$ and $y \in N$ homogeneous. In this case the map
$M \times N \to M \otimes_A N$ is $A$-bilinear, compatible with gradings,
and compatible with differentials and universal in the sense that
$$
\text{DifferentialGradedBilinear}_A(M \times N, Q) =
\Hom_{\text{Comp}(R)}(M \otimes_A N, Q)
$$
for any differential graded $R$-module $Q$ with an obvious notion of
differential graded bilinar map.






\section{Hom complexes and differential graded modules}
\label{section-hom-complexes}

\noindent
We urge the reader to skip this section.

\medskip\noindent
Let $R$ be a ring and let $M^\bullet$ be a complex of $R$-modules.
Consider the complex of $R$-modules
$$
E^\bullet = \Hom^\bullet(M^\bullet, M^\bullet)
$$
introduced in
More on Algebra, Section \ref{more-algebra-section-hom-complexes}.
By More on Algebra, Lemma \ref{more-algebra-lemma-composition}
there is a canonical composition law
$$
\text{Tot}(E^\bullet \otimes_R E^\bullet) \to E^\bullet
$$
which is a map of complexes. Thus we see that $E^\bullet$ with this
multiplication is a differential graded $R$-algebra which we will
denote $(E, \text{d})$. Moreover, viewing $M^\bullet$ as
$\Hom^\bullet(R, M^\bullet)$ we see that composition defines a multiplication
$$
\text{Tot}(E^\bullet \otimes_R M^\bullet) \to M^\bullet
$$
which turns $M^\bullet$ into a {\bf left} differential graded $E$-module
which we will denote $M$.

\begin{lemma}
\label{lemma-left-module-structure}
In the situation above, let $A$ be a differential graded $R$-algebra.
To give a left $A$-module structure on $M$ is the same thing as
giving a homomorphism $A \to E$ of differential graded $R$-algebras.
\end{lemma}

\begin{proof}
Proof omitted. Observe that no signs intervene in this correspondence.
\end{proof}

\noindent
We continue with the discussion above and we assume given another
complex $N^\bullet$ of $R$-modules. Consider the complex
of $R$-modules $\Hom^\bullet(M^\bullet, N^\bullet)$ introduced in
More on Algebra, Section \ref{more-algebra-section-hom-complexes}.
As above we see that composition
$$
\text{Tot}(\Hom^\bullet(M^\bullet, N^\bullet) \otimes_R E^\bullet)
\to \Hom^\bullet(M^\bullet, N^\bullet)
$$
defines a multiplication which turns $\Hom^\bullet(M^\bullet, N^\bullet)$
into a {\bf right} differential graded $E$-module. Using
Lemma \ref{lemma-left-module-structure} we
conclude that given a left differential graded $A$-module $M$ and
a complex of $R$-modules $N^\bullet$ there is a canonical
right differential graded $A$-module whose underlying complex
of $R$-modules is $\Hom^\bullet(M^\bullet, N^\bullet)$ and
where multiplication
$$
\Hom^n(M^\bullet, N^\bullet) \times A^m \longrightarrow
\Hom^{n + m}(M^\bullet, N^\bullet)
$$
sends $f = (f_{p, q})_{p + q = n}$ with $f_{p, q} \in \Hom(M^{-q}, N^p)$
and $a \in A^m$ to the element $f \cdot a = (f_{p, q} \circ a)$ where
$f_{p, q} \circ a$ is the map
$$
M^{-q - m} \xrightarrow{a} M^{-q} \xrightarrow{f_{p, q}} N^p, \quad
x \longmapsto f_{p, q}(ax)
$$
without the intervention of signs. Let us use the notation
$\Hom(M, N^\bullet)$ to denote this right differential graded $A$-module.

\begin{lemma}
\label{lemma-characterize-hom}
Let $R$ be a ring. Let $(A, \text{d})$ be a differential graded $R$-algebra.
Let $M'$ be a right differential graded $A$-module and let
$M$ be a left differential graded $A$-module.
Let $N^\bullet$ be a complex of $R$-modules. Then we have
$$
\Hom_{\text{Mod}_{(A, d)}}(M', \Hom(M, N^\bullet)) =
\Hom_{\text{Comp}(R)}(M' \otimes_A M, N^\bullet)
$$
where $M \otimes_A M$ is viewed as a complex of $R$-modules
as in Section \ref{section-tensor-product}.
\end{lemma}

\begin{proof}
Let us show that both sides correspond to graded $A$-bilinear maps
$$
M' \times M \longrightarrow N^\bullet
$$
compatible with differentials. We have seen this is true for the right
hand side in Section \ref{section-tensor-product}. Given an element
$g$ of the left hand side, the equality of
More on Algebra, Lemma \ref{more-algebra-lemma-compose}
determines a map of complexes of $R$-modules
$g' : \text{Tot}(M' \otimes_R M) \to N^\bullet$.
In other words, we obtain a graded $R$-bilinear
map $g'' : M' \times M \to N^\bullet$ compatible with differentials.
The $A$-linearity of $g$ translates immediately
into $A$-bilinarity of $g''$.
\end{proof}

\noindent
Let $R$, $M^\bullet$, $E^\bullet$, $E$, and $M$ be as above.
However, now suppose given a differential graded $R$-algebra $A$
and a {\bf right} differential graded $A$-module structure on $M$.
Then we can consider the map
$$
\text{Tot}(A^\bullet \otimes_R M^\bullet)
\xrightarrow{\psi}
\text{Tot}(A^\bullet \otimes_R M^\bullet)
\to
M^\bullet
$$
where the first arrow is the commutativity constraint on the
differential graded category of complexes of $R$-modules.
This corresponds to a map
$$
\tau : A^\bullet \longrightarrow E^\bullet
$$
of complexes of $R$-modules. Recall that
$E^n = \prod_{p + q = n} \Hom_R(M^{-q}, M^p)$
and write $\tau(a) = (\tau_{p, q}(a))_{p + q = n}$ for $a \in A^n$.
Then we see
$$
\tau_{p, q}(a) : M^{-q} \longrightarrow M^p,\quad
x \longmapsto (-1)^{\deg(a)\deg(x)}x a = (-1)^{-nq}xa
$$
This is not compatible with the product on $A$ as the readed should
expect from the discussion in Section \ref{section-left-modules}.
Namely, we have
$$
\tau(a a') = (-1)^{\deg(a)\deg(a')}\tau(a') \tau(a)
$$
We conclude the following lemma is true

\begin{lemma}
\label{lemma-right-module-structure}
In the situation above, let $A$ be a differential graded $R$-algebra.
To give a right $A$-module structure on $M$ is the same thing as
giving a homomorphism $\tau : A \to E^{opp}$
of differential graded $R$-algebras.
\end{lemma}

\begin{proof}
See discussion above and note that the construction of $\tau$
from the multiplication map $M^n \times A^m \to M^{n + m}$
uses signs.
\end{proof}

\noindent
Let $R$, $M^\bullet$, $E^\bullet$, $E$, $A$ and $M$ be as above
and let a right differential graded $A$-module structure on $M$
be given as in the lemma. In this case there is a canonical left
differential graded $A$-module whose underlying complex of $R$-modules is
$\Hom^\bullet(M^\bullet, N^\bullet)$. Namely, for multiplication
we can use
\begin{align*}
\text{Tot}(A^\bullet \otimes_R \Hom^\bullet(M^\bullet, N^\bullet))
& \xrightarrow{\psi}
\text{Tot}(\Hom^\bullet(M^\bullet, N^\bullet) \otimes_R A^\bullet) \\
& \xrightarrow{\tau}
\text{Tot}(\Hom^\bullet(M^\bullet, N^\bullet) \otimes_R
\Hom^\bullet(M^\bullet, M^\bullet)) \\
& \to
\text{Tot}(\Hom^\bullet(M^\bullet, N^\bullet)
\end{align*}
The first arrow uses the commutativity constraint on the category
of complexes of $R$-modules, the second arrow is described above, and
the third arrow is the composition law for the Hom complex.
Each map is a map of complexes, hence the result is a map of complexes.
In fact, this construction turns $\Hom^\bullet(M^\bullet, N^\bullet)$
into a left differential graded $A$-module (associativity of the multiplication
can be shown using the symmetric monoidal structure or by a direct calculation
using the formulae below). Let us explicate the multiplication
$$
A^n \times \Hom^m(M^\bullet, N^\bullet) \longrightarrow
\Hom^{n + m}(M^\bullet, N^\bullet)
$$
It sends $a \in A^n$ and
$f = (f_{p, q})_{p + q = m}$ with $f_{p, q} \in \Hom(M^{-q}, N^p)$
to the element $a \cdot f$ with constituents
$$
(-1)^{nm}f_{p, q} \circ \tau_{-q, q + n}(a) =
(-1)^{nm - n(q + n)}f_{p, q} \circ a =
(-1)^{np + n} f_{p, q} \circ a
$$
in $\Hom_R(M^{-q - n}, N^p)$ where $f_{p, q} \circ a$ is the map
$$
M^{-q - n} \xrightarrow{a} M^{-q} \xrightarrow{f_{p, q}} N^p,\quad
x \longmapsto f_{p, q}(xa)
$$
Here a sign of $(-1)^{np + n}$ does intervene.  Let us use the notation
$\Hom(M, N^\bullet)$ to denote this left differential graded $A$-module.

\begin{lemma}
\label{lemma-characterize-hom-other-side}
Let $R$ be a ring. Let $(A, \text{d})$ be a differential graded $R$-algebra.
Let $M$ be a right differential graded $A$-module and let
$M'$ be a left differential graded $A$-module.
Let $N^\bullet$ be a complex of $R$-modules. Then we have
$$
\Hom_{\text{left diff graded }A\text{-modules}}(M', \Hom(M, N^\bullet)) =
\Hom_{\text{Comp}(R)}(M \otimes_A M', N^\bullet)
$$
where $M \otimes_A M'$ is viewed as a complex of $R$-modules
as in Section \ref{section-tensor-product}.
\end{lemma}

\begin{proof}
Let us show that both sides correspond to graded $A$-bilinear maps
$$
M \times M' \longrightarrow N^\bullet
$$
compatible with differentials. We have seen this is true for the right
hand side in Section \ref{section-tensor-product}. Given an element
$g$ of the left hand side, the equality of
More on Algebra, Lemma \ref{more-algebra-lemma-compose}
determines a map of complexes
$g' : \text{Tot}(M' \otimes_R M) \to N^\bullet$.
We precompose with the commutativity constraint to get
$$
\text{Tot}(M \otimes_R M') \xrightarrow{\psi}
\text{Tot}(M' \otimes_R M) \xrightarrow{g'}
N^\bullet
$$
which corresponds to a graded $R$-bilinear
map $g'' : M \times M' \to N^\bullet$ compatible with differentials.
The $A$-linearity of $g$ translates immediately into $A$-bilinarity of $g''$.
Namely, say $x \in M^e$ and $x' \in (M')^{e'}$ and $a \in A^n$. Then
on the one hand we have
\begin{align*}
g''(x, ax')
& =
(-1)^{e(n + e')} g'(ax' \otimes x) \\
& =
(-1)^{e(n + e')} g(ax')(x) \\
& =
(-1)^{e(n + e')} (a \cdot g(x'))(x) \\
& =
(-1)^{e(n + e') + n(n + e + e') + n} g(x')(xa)
\end{align*}
and on the other hand we have
$$
g''(xa, x') = (-1)^{(e + n)e'} g'(x' \otimes xa) =
(-1)^{(e + n)e'} g(x')(xa) 
$$
which is the same thing by a trivial mod $2$ calculation of the exponents.
\end{proof}

\begin{remark}
\label{remark-evaluation-map-left}
Let $R$ be a ring. Let $A$ be a differential graded $R$-algebra.
Let $M$ be a left differential graded $A$-module. Let
$N^\bullet$ be a complex of $R$-modules. The constructions above
produce a right differential graded $A$-module $\Hom(M, N^\bullet)$
and then a leftt differential graded $A$-module
$\Hom(\Hom(M, N^\bullet), N^\bullet)$. We claim there is an
evaluation map
$$
ev : M \longrightarrow \Hom(\Hom(M, N^\bullet), N^\bullet)
$$
in the category of left differential graded $A$-modules. To define it, by
Lemma \ref{lemma-characterize-hom} it suffices to construct an
$A$-bilinear pairing
$$
\Hom(M, N^\bullet) \times M \longrightarrow N^\bullet
$$
compatible with grading and differentials. For this we take
$$
(f, x) \longmapsto f(x)
$$
We leave it to the reader to verify this is compatible with grading,
differentials, and $A$-bilinear. The map $ev$ on underlying complexes
of $R$-modules is More on Algebra, Item (\ref{more-algebra-item-evaluation}).
\end{remark}

\begin{remark}
\label{remark-evaluation-map-right}
Let $R$ be a ring. Let $A$ be a differential graded $R$-algebra.
Let $M$ be a right differential graded $A$-module. Let
$N^\bullet$ be a complex of $R$-modules. The constructions above
produce a left differential graded $A$-module $\Hom(M, N^\bullet)$
and then a right differential graded $A$-module
$\Hom(\Hom(M, N^\bullet), N^\bullet)$. We claim there is an evaluation map
$$
ev : M \longrightarrow \Hom(\Hom(M, N^\bullet), N^\bullet)
$$
in the category of right differential graded $A$-modules. To define it, by
Lemma \ref{lemma-characterize-hom} it suffices to construct an
$A$-bilinear pairing
$$
M \times \Hom(M, N^\bullet) \longrightarrow N^\bullet
$$
compatible with grading and differentials. For this we take
$$
(x, f) \longmapsto (-1)^{\deg(x)\deg(f)}f(x)
$$
We leave it to the reader to verify this is compatible with grading,
differentials, and $A$-bilinear. The map $ev$ on underlying complexes
of $R$-modules is More on Algebra, Item (\ref{more-algebra-item-evaluation}).
\end{remark}

\begin{remark}
\label{remark-shift-dual}
Let $R$ be a ring. Let $A$ be a differential graded $R$-algebra.
Let $M^\bullet$ and $N^\bullet$ be complexes of $R$-modules.
Let $k \in \mathbf{Z}$ and consider the isomorphism
$$
\Hom^\bullet(M^\bullet, N^\bullet)[-k]
\longrightarrow
\Hom^\bullet(M^\bullet[k], N^\bullet)
$$
of complexes of $R$-modules defined in
More on Algebra, Item (\ref{more-algebra-item-shift-hom}).
If $M^\bullet$ has the structure of a left, resp.\ right
differential graded $A$-module, then this is a map of
right, resp.\ left differential graded $A$-modules (with the
module structures as defined in this section).
We omit the verification; we warn the reader that the
$A$-module structure on the shift of a left graded $A$-module
is defined using a sign, see
Definition \ref{definition-shift-graded-module}.
\end{remark}






\section{Projective modules over algebras}
\label{section-projectives-over-algebras}

\noindent
In this section we discuss projective modules over algebras analogous to
Algebra, Section \ref{algebra-section-projective}.
This section should probably be moved somewhere else.

\medskip\noindent
Let $R$ be a ring and let $A$ be an $R$-algebra, see
Section \ref{section-conventions} for our conventions.
It is clear that $A$ is a projective right $A$-module since
$\Hom_A(A, M) = M$ for any right $A$-module $M$ (and thus $\Hom_A(A, -)$
is exact). Conversely, let $P$ be a projective right $A$-module. Then
we can choose a surjection
$\bigoplus_{i \in I} A \to P$ by choosing a set $\{p_i\}_{i \in I}$
of generators of $P$ over $A$. Since $P$ is projective there is a
left inverse to the surjection, and we find that $P$ is isomorphic
to a direct summand of a free module, exactly as in the commutative case
(Algebra, Lemma \ref{algebra-lemma-characterize-projective}).

\medskip\noindent
We conclude
\begin{enumerate}
\item the category of $A$-modules has enough projectives,
\item $A$ is a projective $A$-module,
\item every $A$-module is a quotient of a direct sum of copies of $A$,
\item every projective $A$-module is a direct summand of a direct
sum of copies of $A$.
\end{enumerate}



\section{Projective modules over graded algebras}
\label{section-projectives-over-graded-algebras}

\noindent
In this section we discuss projective graded modules over graded algebras
analogous to Algebra, Section \ref{algebra-section-projective}.

\medskip\noindent
Let $R$ be a ring. Let $A$ be a $\mathbf{Z}$-graded algebra over $R$.
Section \ref{section-conventions} for our conventions.
Let $\text{Mod}_A$ denote the category of graded right $A$-modules.
For an integer $k$ let $A[k]$ denote the shift of $A$.
For a graded right $A$-module we have
$$
\Hom_{\text{Mod}_A}(A[k], M) = M^{-k}
$$
As the functor $M \mapsto M^{-k}$ is exact on $\text{Mod}_A$ we
conclude that $A[k]$ is a projective object of $\text{Mod}_A$.
Conversely, suppose that $P$ is a projective object of $\text{Mod}_A$.
By choosing a set of homogeneous generators of $P$ as an $A$-module,
we can find a surjection
$$
\bigoplus\nolimits_{i \in I} A[k_i] \longrightarrow P
$$
Thus we conclude that a projective object of $\text{Mod}_A$ is
a direct summand of a direct sum of the shifts $A[k]$.

\medskip\noindent
We conclude
\begin{enumerate}
\item the category of graded $A$-modules has enough projectives,
\item $A[k]$ is a projective $A$-module for every $k \in \mathbf{Z}$,
\item every graded $A$-module is a quotient of a direct sum of
copies of the modules $A[k]$ for varying $k$,
\item every projective $A$-module is a direct summand of a direct
sum of copies of the modules $A[k]$ for varying $k$.
\end{enumerate}




\section{Projective modules and differential graded algebras}
\label{section-projective-over-differential-graded}

\noindent
If $(A, \text{d})$ is a differential graded algebra and $P$ is
an object of $\text{Mod}_{(A, \text{d})}$ then we say
{\it $P$ is projective as a graded $A$-module} or sometimes
{\it $P$ is graded projective} to mean that $P$
is a projective object of the abelian category $\text{Mod}_A$
of graded $A$-modules as in
Section \ref{section-projectives-over-graded-algebras}.

\begin{lemma}
\label{lemma-target-graded-projective}
Let $(A, \text{d})$ be a differential graded algebra.
Let $M \to P$ be a surjective homomorphism of differential graded
$A$-modules. If $P$ is projective as a graded $A$-module, then
$M \to P$ is an admissible epimorphism.
\end{lemma}

\begin{proof}
This is immediate from the definitions.
\end{proof}

\begin{lemma}
\label{lemma-hom-from-shift-free}
Let $(A, d)$ be a differential graded algebra. Then we have
$$
\Hom_{\text{Mod}_{(A, \text{d})}}(A[k], M) =
\Ker(\text{d} : M^{-k} \to M^{-k + 1})
$$
and
$$
\Hom_{K(\text{Mod}_{(A, \text{d})})}(A[k], M) = H^{-k}(M)
$$
for any differential graded $A$-module $M$.
\end{lemma}

\begin{proof}
Immediate from the definitions.
\end{proof}







\section{Injective modules over algebras}
\label{section-modules-noncommutative}

\noindent
In this section we discuss injective modules over algebras
analogous to
More on Algebra, Section \ref{more-algebra-section-injectives-modules}.
This section should probably be moved somewhere else.

\medskip\noindent
Let $R$ be a ring and let $A$ be an
$R$-algebra, see Section \ref{section-conventions} for our conventions.
For a right $A$-module $M$ we set
$$
M^\vee = \Hom_\mathbf{Z}(M, \mathbf{Q}/\mathbf{Z})
$$
which we think of as a left $A$-module by the multiplication
$(a f)(x) = f(xa)$. Namely, $((ab)f)(x) = f(xab) = (bf)(xa) = (a(bf))(x)$.
Conversely, if $M$ is a left $A$-module, then $M^\vee$ is a right
$A$-module. Since $\mathbf{Q}/\mathbf{Z}$ is an injective abelian
group (More on Algebra, Lemma \ref{more-algebra-lemma-injective-abelian}), the
functor $M \mapsto M^\vee$ is exact
(More on Algebra, Lemma \ref{more-algebra-lemma-vee-exact}).
Moreover, the evaluation map $M \to (M^\vee)^\vee$ is
injective for all modules $M$
(More on Algebra, Lemma \ref{more-algebra-lemma-ev-injective}).

\medskip\noindent
We claim that $A^\vee$ is an injective right $A$-module. Namely, given
a right $A$-module $N$ we have
$$
\Hom_A(N, A^\vee) =
\Hom_A(N, \Hom_\mathbf{Z}(A, \mathbf{Q}/\mathbf{Z})) = N^\vee
$$
and we conclude because the functor $N \mapsto N^\vee$ is exact.
The second equality holds because
$$
\Hom_\mathbf{Z}(N, \Hom_\mathbf{Z}(A, \mathbf{Q}/\mathbf{Z})) =
\Hom_\mathbf{Z}(N \otimes_\mathbf{Z} A, \mathbf{Q}/\mathbf{Z})
$$
by Algebra, Lemma \ref{algebra-lemma-hom-from-tensor-product}.
Inside this module $A$-linearity exactly picks out the bilinear maps
$\varphi : N \times A \to \mathbf{Q}/\mathbf{Z}$ which
have the same value on $x \otimes a$ and $xa \otimes 1$, i.e.,
come from elements of $N^\vee$.

\medskip\noindent
Finally, for every right $A$-module $M$ we can choose a surjection
$\bigoplus_{i \in I} A \to M^\vee$ to get an injection
$M \to (M^\vee)^\vee \to \prod_{i \in I} A^\vee$.

\medskip\noindent
We conclude
\begin{enumerate}
\item the category of $A$-modules has enough injectives,
\item $A^\vee$ is an injective $A$-module, and
\item every $A$-module injects into a product of copies of $A^\vee$.
\end{enumerate}





\section{Injective modules over graded algebras}
\label{section-modules-noncommutative-graded}

\noindent
In this section we discuss injective graded modules over graded algebras
analogous to
More on Algebra, Section \ref{more-algebra-section-injectives-modules}.

\medskip\noindent
Let $R$ be a ring. Let $A$ be a $\mathbf{Z}$-graded algebra over $R$.
Section \ref{section-conventions} for our conventions.
If $M$ is a graded $R$-module we set
$$
M^\vee =
\bigoplus\nolimits_{n \in \mathbf{Z}}
\Hom_\mathbf{Z}(M^{-n}, \mathbf{Q}/\mathbf{Z}) =
\bigoplus\nolimits_{n \in \mathbf{Z}} (M^{-n})^\vee
$$
as a graded $R$-module (no signs in the actions of $R$ on the
homogeneous parts). If $M$ has the structure of a left graded
$A$-module, then we define a right graded $A$-module structure
on $M^\vee$ by letting $a \in A^m$ act by
$$
(M^{-n})^\vee \to (M^{-n - m})^\vee, \quad
f \mapsto f \circ a
$$
as in Section \ref{section-hom-complexes}.
If $M$ has the structure of a right graded
$A$-module, then we define a left graded $A$-module structure
on $M^\vee$ by letting $a \in A^n$ act by
$$
(M^{-m})^\vee \to (M^{-m - n})^\vee, \quad
f \mapsto (-1)^{nm}f \circ a
$$
as in Section \ref{section-hom-complexes} (the sign is forced on
us because we want to use the same formula for the case
when working with differential graded modules --- if you only
care about graded modules, then you can omit the sign here).
On the category of (left or right) graded $A$-modules the
functor $M \mapsto M^\vee$ is exact (check on graded pieces).
Moreover, there is an injective evaluation map
$$
ev : M \longrightarrow (M^\vee)^\vee, \quad
ev^n = (-1)^n \text{ the evaluation map }M^n \to ((M^n)^\vee)^\vee
$$
of graded $R$-modules, see
More on Algebra, Item (\ref{more-algebra-item-evaluation}).
This evaluation map is a left, resp.\ right $A$-module homomorphism
if $M$ is a left, resp.\ right $A$-module, see
Remarks \ref{remark-evaluation-map-left} and \ref{remark-evaluation-map-right}.
Finally, given $k \in \mathbf{Z}$ there is a canonical isomorphism
$$
M^\vee[-k] \longrightarrow (M[k])^\vee
$$
of graded $R$-modules which uses a sign and which, if
$M$ is a left, resp.\ right $A$-module, is an isomorphism
of right, resp.\ left $A$-modules. See Remark \ref{remark-shift-dual}.

\medskip\noindent
We claim that $A^\vee$ is an injective object of the category
$\text{Mod}_A$ of graded right $A$-modules. Namely, given a graded
right $A$-module $N$ we have
$$
\Hom_{\text{Mod}_A}(N, A^\vee) =
\Hom_{\text{Comp}(\mathbf{Z})}(N \otimes_A A, \mathbf{Q}/\mathbf{Z})) =
(N^0)^\vee
$$
by Lemma \ref{lemma-characterize-hom}
(applied to the case where all the differentials are zero).
We conclude because the functor $N \mapsto (N^0)^\vee = (N^\vee)^0$
is exact.

\medskip\noindent
Finally, for every graded right $A$-module $M$ we can choose a surjection
of graded left $A$-modules
$$
\bigoplus\nolimits_{i \in I} A[k_i] \to M^\vee
$$
where $A[k_i]$ denotes the shift of $A$ by $k_i \in \mathbf{Z}$.
We do this by choosing homogeneous generators for $M^\vee$.
In this way we get an injection
$$
M \to (M^\vee)^\vee \to \prod A[k_i]^\vee = \prod A^\vee[-k_i]
$$
Observe that the products in the formula above are products in the
category of graded modules (in other words, take products in each degree
and then take the direct sum of the pieces).

\medskip\noindent
We conclude that
\begin{enumerate}
\item the category of graded $A$-modules has enough injectives,
\item for every $k \in \mathbf{Z}$ the module $A^\vee[k]$ is injective, and
\item every $A$-module injects into a product in the category of graded
modules of copies of shifts $A^\vee[k]$.
\end{enumerate}





\section{Injective modules and differential graded algebras}
\label{section-modules-noncommutative-differential-graded}

\noindent
If $(A, \text{d})$ is a differential graded algebra and $I$ is
an object of $\text{Mod}_{(A, \text{d})}$ then we say
{\it $I$ is injective as a graded $A$-module} or sometimes
{\it $I$ is graded injective} to mean
that $I$ is a injective object of the abelian category $\text{Mod}_A$
of graded $A$-modules.

\begin{lemma}
\label{lemma-source-graded-injective}
Let $(A, \text{d})$ be a differential graded algebra.
Let $I \to M$ be an injective homomorphism of differential graded
$A$-modules. If $I$ is graded injective, then
$I \to M$ is an admissible monomorphism.
\end{lemma}

\begin{proof}
This is immediate from the definitions.
\end{proof}

\noindent
Let $(A, \text{d})$ be a differential graded algebra. If $M$ is a
left, resp.\ right differential graded $A$-module, then
$$
M^\vee = \Hom^\bullet(M^\bullet, \mathbf{Q}/\mathbf{Z})
$$
with $A$-module structure constructed in
Section \ref{section-modules-noncommutative-graded} is a
right, resp.\ left differential graded $A$-module by the
discussion in Section \ref{section-hom-complexes}.
By Remarks
\ref{remark-evaluation-map-left} and \ref{remark-evaluation-map-right}
there evaluation map of Section \ref{section-modules-noncommutative-graded}
$$
M \longrightarrow (M^\vee)^\vee
$$
is a homomorphism of left, resp.\ right differential graded $A$-modules

\begin{lemma}
\label{lemma-map-into-dual}
Let $(A, \text{d})$ be a differential graded algebra. If
$M$ is a left differential graded $A$-module and $N$ is a
right differential graded $A$-module, then
\begin{align*}
\Hom_{\text{Mod}_{(A, \text{d})}}(N, M^\vee)
& =
\Hom_{\text{Comp}(\mathbf{Z})}(N \otimes_A M, \mathbf{Q}/\mathbf{Z}) \\
& =
\text{DifferentialGradedBilinear}_A(N \times M, \mathbf{Q}/\mathbf{Z})
\end{align*}
\end{lemma}

\begin{proof}
The first equality is Lemma \ref{lemma-characterize-hom}
and the second equality was shown in Section \ref{section-tensor-product}.
\end{proof}

\begin{lemma}
\label{lemma-hom-into-shift-dual-free}
Let $(A, \text{d})$ be a differential graded algebra. Then we have
$$
\Hom_{\text{Mod}_{(A, \text{d})}}(M, A^\vee[k]) =
\Ker(\text{d} : (M^\vee)^k \to (M^\vee)^{k + 1})
$$
and
$$
\Hom_{K(\text{Mod}_{(A, \text{d})})}(M, A^\vee[k]) = H^k(M^\vee)
$$
as functors in the differential graded $A$-module $M$.
\end{lemma}

\begin{proof}
This is clear from the discussion above.
\end{proof}















\section{P-resolutions}
\label{section-P-resolutions}

\noindent
This section is the analogue of
Derived Categories, Section \ref{derived-section-unbounded}.

\medskip\noindent
Let $(A, \text{d})$ be a differential graded algebra.
Let $P$ be a differential graded $A$-module. We say $P$
{\it has property (P)} if it there exists a filtration
$$
0 = F_{-1}P \subset F_0P \subset F_1P \subset \ldots \subset P
$$
by differential graded submodules such that
\begin{enumerate}
\item $P = \bigcup F_pP$,
\item the inclusions $F_iP \to F_{i + 1}P$ are admissible
monomorphisms,
\item the quotients $F_{i + 1}P/F_iP$ are isomorphic as differential
graded $A$-modules to a direct sum of $A[k]$.
\end{enumerate}
In fact, condition (2) is a consequence of condition (3), see
Lemma \ref{lemma-target-graded-projective}. Moreover, the reader
can verify that as a graded $A$-module $P$ will be isomorphic to a
direct sum of shifts of $A$.

\begin{lemma}
\label{lemma-property-P-sequence}
Let $(A, \text{d})$ be a differential graded algebra.
Let $P$ be a differential graded $A$-module. If $F_\bullet$
is a filtration as in property (P), then we obtain an
admissible short exact sequence
$$
0 \to
\bigoplus\nolimits F_iP \to
\bigoplus\nolimits F_iP \to P \to 0
$$
of differential graded $A$-modules.
\end{lemma}

\begin{proof}
The second map is the direct sum of the inclusion maps.
The first map on the summand $F_iP$ of the source is the sum
of the identity $F_iP \to F_iP$ and the negative of the inclusion
map $F_iP \to F_{i + 1}P$. Choose homomorphisms $s_i : F_{i + 1}P \to F_iP$
of graded $A$-modules which are left inverse to the inclusion maps.
Composing gives maps $s_{j, i} : F_jP \to F_iP$ for all $j > i$.
Then a left inverse of the first arrow maps $x \in F_jP$ to
$(s_{j, 0}(x), s_{j, 1}(x), \ldots, s_{j, j - 1}(x), 0, \ldots)$
in $\bigoplus F_iP$.
\end{proof}

\noindent
The following lemma shows that differential graded modules with
property (P) are the dual notion to K-injective modules
(i.e., they are K-projective in some sense). See
Derived Categories, Definition \ref{derived-definition-K-injective}.

\begin{lemma}
\label{lemma-property-P-K-projective}
Let $(A, \text{d})$ be a differential graded algebra.
Let $P$ be a differential graded $A$-module with property (P).
Then
$$
\Hom_{K(\text{Mod}_{(A, \text{d})})}(P, N) = 0
$$
for all acyclic differential graded $A$-modules $N$.
\end{lemma}

\begin{proof}
We will use that $K(\text{Mod}_{(A, \text{d})})$ is a triangulated
category (Proposition \ref{proposition-homotopy-category-triangulated}).
Let $F_\bullet$ be a filtration on $P$ as in property (P).
The short exact sequence of Lemma \ref{lemma-property-P-sequence}
produces a distinguished triangle. Hence by
Derived Categories, Lemma \ref{derived-lemma-representable-homological}
it suffices to show that
$$
\Hom_{K(\text{Mod}_{(A, \text{d})})}(F_iP, N) = 0
$$
for all acyclic differential graded $A$-modules $N$ and all $i$.
Each of the differential graded modules $F_iP$ has a finite filtration
by admissible monomorphisms, whose graded pieces are direct sums
of shifts $A[k]$. Thus it suffices to prove that
$$
\Hom_{K(\text{Mod}_{(A, \text{d})})}(A[k], N) = 0
$$
for all acyclic differential graded $A$-modules $N$ and all $k$.
This follows from Lemma \ref{lemma-hom-from-shift-free}.
\end{proof}

\begin{lemma}
\label{lemma-good-quotient}
Let $(A, \text{d})$ be a differential graded algebra.
Let $M$ be a differential graded $A$-module. There exists a homomorphism
$P \to M$ of differential graded $A$-modules with the following
properties
\begin{enumerate}
\item $P \to M$ is surjective,
\item $\Ker(\text{d}_P) \to \Ker(\text{d}_M)$ is surjective, and
\item $P$ sits in an admissible short exact sequence
$0 \to P' \to P \to P'' \to 0$ where $P'$, $P''$ are direct sums
of shifts of $A$.
\end{enumerate}
\end{lemma}

\begin{proof}
Let $P_k$ be the free $A$-module with generators $x, y$ in degrees
$k$ and $k + 1$. Define the structure of a differential graded
$A$-module on $P_k$ by setting $\text{d}(x) = y$ and $\text{d}(y) = 0$.
For every element $m \in M^k$ there is a homomorphism
$P_k \to M$ sending $x$ to $m$ and $y$ to $\text{d}(m)$.
Thus we see that there is a surjection from a direct sum
of copies of $P_k$ to $M$. This clearly produces $P \to M$
having properties (1) and (3). To obtain property (2) note
that if $m \in \Ker(\text{d}_M)$ has degree $k$, then there is a map
$A[k] \to M$ mapping $1$ to $m$. Hence we can achieve (2) by adding
a direct sum of copies of shifts of $A$.
\end{proof}

\begin{lemma}
\label{lemma-resolve}
Let $(A, \text{d})$ be a differential graded algebra.
Let $M$ be a differential graded $A$-module. There exists a homomorphism
$P \to M$ of differential graded $A$-modules such that
\begin{enumerate}
\item $P \to M$ is a quasi-isomorphism, and
\item $P$ has property (P).
\end{enumerate}
\end{lemma}

\begin{proof}
Set $M = M_0$. We inductively choose short exact sequences
$$
0 \to M_{i + 1} \to P_i \to M_i \to 0
$$
where the maps $P_i \to M_i$ are chosen as in Lemma \ref{lemma-good-quotient}.
This gives a ``resolution''
$$
\ldots \to P_2 \xrightarrow{f_2} P_1 \xrightarrow{f_1} P_0 \to M \to 0
$$
Then we set
$$
P = \bigoplus\nolimits_{i \geq 0} P_i
$$
as an $A$-module with grading given by
$P^n = \bigoplus_{a + b = n} P_{-a}^b$ and
differential (as in the construction of the total complex associated
to a double complex) by
$$
\text{d}_P(x) = f_{-a}(x) + (-1)^a \text{d}_{P_{-a}}(x)
$$
for $x \in P_{-a}^b$. With these conventions $P$ is indeed a differential
graded $A$-module. Recalling that each $P_i$ has a two step filtration
$0 \to P_i' \to P_i \to P_i'' \to 0$ we set
$$
F_{2i}P = \bigoplus\nolimits_{i \geq j \geq 0} P_j
\subset
\bigoplus\nolimits_{i \geq 0} P_i = P
$$
and we add $P'_{i + 1}$ to $F_{2i}P$ to get $F_{2i + 1}$.
These are differential graded submodules and the successive quotients
are direct sums of shifts of $A$. By
Lemma \ref{lemma-target-graded-projective} we see that
the inclusions $F_iP \to F_{i + 1}P$ are admissible monomorphisms.
Finally, we have to show that the map $P \to M$ (given by the
augmentation $P_0 \to M$) is a quasi-isomorphism. This follows from
Homology, Lemma \ref{homology-lemma-good-resolution-gives-qis}.
\end{proof}





\section{I-resolutions}
\label{section-I-resolutions}

\noindent
This section is the dual of the section on P-resolutions.

\medskip\noindent
Let $(A, \text{d})$ be a differential graded algebra.
Let $I$ be a differential graded $A$-module. We say $I$
{\it has property (I)} if it there exists a filtration
$$
I = F_0I \supset F_1I \supset F_2I \supset \ldots \supset 0
$$
by differential graded submodules such that
\begin{enumerate}
\item $I = \lim I/F_pI$,
\item the maps $I/F_{i + 1}I \to I/F_iI$ are admissible epimorphisms,
\item the quotients $F_iI/F_{i + 1}I$ are isomorphic as differential
graded $A$-modules to products of the modules $A^\vee[k]$ constructed
in Section \ref{section-modules-noncommutative-differential-graded}.
\end{enumerate}
In fact, condition (2) is a consequence of condition (3), see
Lemma \ref{lemma-source-graded-injective}. The reader can verify that as
a graded module $I$ will be isomorphic to a product of $A^\vee[k]$.

\begin{lemma}
\label{lemma-property-I-sequence}
Let $(A, \text{d})$ be a differential graded algebra.
Let $I$ be a differential graded $A$-module. If $F_\bullet$
is a filtration as in property (I), then we obtain an
admissible short exact sequence
$$
0 \to I \to
\prod\nolimits I/F_iI \to
\prod\nolimits I/F_iI \to 0
$$
of differential graded $A$-modules.
\end{lemma}

\begin{proof}
Omitted. Hint: This is dual to Lemma \ref{lemma-property-P-sequence}.
\end{proof}

\noindent
The following lemma shows that differential graded modules with
property (I) are the analogue of K-injective modules. See
Derived Categories, Definition \ref{derived-definition-K-injective}.

\begin{lemma}
\label{lemma-property-I-K-injective}
Let $(A, \text{d})$ be a differential graded algebra.
Let $I$ be a differential graded $A$-module with property (I).
Then
$$
\Hom_{K(\text{Mod}_{(A, \text{d})})}(N, I) = 0
$$
for all acyclic differential graded $A$-modules $N$.
\end{lemma}

\begin{proof}
We will use that $K(\text{Mod}_{(A, \text{d})})$ is a triangulated
category (Proposition \ref{proposition-homotopy-category-triangulated}).
Let $F_\bullet$ be a filtration on $I$ as in property (I).
The short exact sequence of Lemma \ref{lemma-property-I-sequence}
produces a distinguished triangle. Hence by
Derived Categories, Lemma \ref{derived-lemma-representable-homological}
it suffices to show that
$$
\Hom_{K(\text{Mod}_{(A, \text{d})})}(N, I/F_iI) = 0
$$
for all acyclic differential graded $A$-modules $N$ and all $i$.
Each of the differential graded modules $I/F_iI$ has a finite filtration
by admissible monomorphisms, whose graded pieces are
products of $A^\vee[k]$. Thus it suffices to prove that
$$
\Hom_{K(\text{Mod}_{(A, \text{d})})}(N, A^\vee[k]) = 0
$$
for all acyclic differential graded $A$-modules $N$ and all $k$.
This follows from Lemma \ref{lemma-hom-into-shift-dual-free}
and the fact that $(-)^\vee$ is an exact functor.
\end{proof}

\begin{lemma}
\label{lemma-good-sub}
Let $(A, \text{d})$ be a differential graded algebra.
Let $M$ be a differential graded $A$-module. There exists a homomorphism
$M \to I$ of differential graded $A$-modules with the following
properties
\begin{enumerate}
\item $M \to I$ is injective,
\item $\Coker(\text{d}_M) \to \Coker(\text{d}_I)$ is injective,
and
\item $I$ sits in an admissible short exact sequence
$0 \to I' \to I \to I'' \to 0$ where $I'$, $I''$ are products
of shifts of $A^\vee$.
\end{enumerate}
\end{lemma}

\begin{proof}
We will use the functors $N \mapsto N^\vee$ (from left to right
differential graded modules and from right to left differential
graded modules) constructed in
Section \ref{section-modules-noncommutative-differential-graded}
and all of their properties.
For every $k \in \mathbf{Z}$ let $Q_k$ be the free left $A$-module with
generators $x, y$ in degrees $k$ and $k + 1$. Define the structure of a
left differential graded $A$-module on $Q_k$ by setting $\text{d}(x) = y$
and $\text{d}(y) = 0$. Arguing exactly as in the proof of
Lemma \ref{lemma-good-quotient} we find a surjection
$$
\bigoplus\nolimits_{i \in I} Q_{k_i} \longrightarrow M^\vee
$$
of left differential graded $A$-modules. Then we can consider the injection
$$
M \to (M^\vee)^\vee \to (\bigoplus\nolimits_{i \in I} Q_{k_i})^\vee =
\prod\nolimits_{i \in I} I_{k_i}
$$
where $I_k = Q_{-k}^\vee$ is the ``dual'' right differential graded $A$-module.
Further, the short exact sequence $0 \to A[-k - 1] \to Q_k \to A[-k] \to 0$
produces a short exact sequence
$0 \to A^\vee[k] \to I_k \to A^\vee[k + 1] \to 0$.

\medskip\noindent
The result of the previous paragraph produces $M \to I$
having properties (1) and (3). To obtain property (2), suppose
$\overline{m} \in \Coker(\text{d}_M)$ is a nonzero element of
degree $k$. Pick a map $\lambda : M^k \to \mathbf{Q}/\mathbf{Z}$
which vanishes on $\Im(M^{k - 1} \to M^k)$ but not on $m$. By
Lemma \ref{lemma-hom-into-shift-dual-free}
this corresponds to a homomorphism $M \to A^\vee[k]$ of
differential graded $A$-modules which does not vanish on $m$.
Hence we can achieve (2) by adding
a product of copies of shifts of $A^\vee$.
\end{proof}

\begin{lemma}
\label{lemma-right-resolution}
Let $(A, \text{d})$ be a differential graded algebra.
Let $M$ be a differential graded $A$-module. There exists a homomorphism
$M \to I$ of differential graded $A$-modules such that
\begin{enumerate}
\item $M \to I$ is a quasi-isomorphism, and
\item $I$ has property (I).
\end{enumerate}
\end{lemma}

\begin{proof}
Set $M = M_0$. We inductively choose short exact sequences
$$
0 \to M_i \to I_i \to M_{i + 1} \to 0
$$
where the maps $M_i \to I_i$ are chosen as in Lemma \ref{lemma-good-sub}.
This gives a ``resolution''
$$
0 \to M \to I_0 \xrightarrow{f_0} I_1 \xrightarrow{f_1} I_1 \to \ldots
$$
Denote $I$ the differential graded $A$-module with graded parts
$$
I^n = \prod\nolimits_{i \geq 0} I^{n - i}_i
$$
and differential defined by
$$
\text{d}_I(x) = f_i(x) + (-1)^i \text{d}_{I_i}(x)
$$
for $x \in I_i^{n - i}$. With these conventions $I$ is indeed a differential
graded $A$-module. Recalling that each $I_i$ has a two step filtration
$0 \to I_i' \to I_i \to I_i'' \to 0$ we set
$$
F_{2i}I^n = \prod\nolimits_{j \geq i} I^{n - j}_j
\subset
\prod\nolimits_{i \geq 0} I^{n - i}_i = I^n
$$
and we add a factor $I'_{i + 1}$ to $F_{2i}I$ to get $F_{2i + 1}I$.
These are differential graded submodules and the successive quotients
are products of shifts of $A^\vee$. By
Lemma \ref{lemma-source-graded-injective} we see that
the inclusions $F_{i + 1}I \to F_iI$ are admissible monomorphisms.
Finally, we have to show that the map $M \to I$ (given by the
augmentation $M \to I_0$) is a quasi-isomorphism. This follows from
Homology, Lemma \ref{homology-lemma-good-right-resolution-gives-qis}.
\end{proof}






\section{The derived category}
\label{section-derived}

\noindent
Recall that the notions of acyclic differential graded modules
and quasi-isomorphism of differential graded modules make sense
(see Section \ref{section-modules}).

\begin{lemma}
\label{lemma-acyclic}
Let $(A, \text{d})$ be a differential graded algebra.
The full subcategory $\text{Ac}$ of $K(\text{Mod}_{(A, \text{d})})$
consisting of acyclic modules is a strictly full saturated triangulated
subcategory of $K(\text{Mod}_{(A, \text{d})})$.
The corresponding saturated multiplicative system
(see Derived Categories, Lemma \ref{derived-lemma-operations})
of $K(\text{Mod}_{(A, \text{d})})$ is the class $\text{Qis}$
of quasi-isomorphisms. In particular, the kernel of the localization
functor
$$
Q : K(\text{Mod}_{(A, \text{d})}) \to
\text{Qis}^{-1}K(\text{Mod}_{(A, \text{d})})
$$
is $\text{Ac}$. Moreover, the functor $H^0$ factors through $Q$.
\end{lemma}

\begin{proof}
We know that $H^0$ is a homological functor by the long exact
sequence of homology (\ref{equation-les}).
The kernel of $H^0$ is the subcategory of acyclic objects and
the arrows with induce isomorphisms on all $H^i$ are the
quasi-isomorphisms. Thus this lemma is a special case of
Derived Categories, Lemma \ref{derived-lemma-acyclic-general}.

\medskip\noindent
Set theoretical remark. The construction of the localization in
Derived Categories, Proposition
\ref{derived-proposition-construct-localization}
assumes the given triangulated category is ``small'', i.e., that the
underlying collection of objects forms a set. Let $V_\alpha$ be a
partial universe (as in Sets, Section \ref{sets-section-sets-hierarchy})
containing $(A, \text{d})$ and where the cofinality of $\alpha$
is bigger than $\aleph_0$
(see Sets, Proposition \ref{sets-proposition-exist-ordinals-large-cofinality}).
Then we can consider the category $\text{Mod}_{(A, \text{d}), \alpha}$
of differential graded $A$-modules contained in $V_\alpha$.
A straightforward check shows that all the constructions used in
the proof of Proposition \ref{proposition-homotopy-category-triangulated}
work inside of $\text{Mod}_{(A, \text{d}), \alpha}$
(because at worst we take finite direct sums of differential graded modules).
Thus we obtain a triangulated category
$\text{Qis}_\alpha^{-1}K(\text{Mod}_{(A, \text{d}), \alpha})$.
We will see below that if $\beta > \alpha$, then the transition functors
$$
\text{Qis}_\alpha^{-1}K(\text{Mod}_{(A, \text{d}), \alpha})
\longrightarrow
\text{Qis}_\beta^{-1}K(\text{Mod}_{(A, \text{d}), \beta})
$$
are fully faithful as the morphism sets in the quotient categories
are computed by maps in the homotopy categories from P-resolutions
(the construction of a P-resolution in the proof of Lemma \ref{lemma-resolve}
takes countable direct sums as well as direct sums indexed over subsets
of the given module). The reader should therefore think of the category
of the lemma as the union of these subcategories.
\end{proof}

\noindent
Taking into account the set theoretical remark at the end of the
proof of the preceding lemma we define the derived category as follows.

\begin{definition}
\label{definition-unbounded-derived-category}
Let $(A, \text{d})$ be a differential graded algebra.
Let $\text{Ac}$ and $\text{Qis}$ be as in Lemma \ref{lemma-acyclic}.
The {\it derived category of $(A, \text{d})$} is the triangulated
category
$$
D(A, \text{d}) =
K(\text{Mod}_{(A, \text{d})})/\text{Ac} =
\text{Qis}^{-1}K(\text{Mod}_{(A, \text{d})}).
$$
We denote $H^0 : D(A, \text{d}) \to \text{Mod}_R$ the unique functor
whose composition with the quotient functor gives back the functor
$H^0$ defined above.
\end{definition}

\noindent
Here is the promised lemma computing morphism sets in the
derived category.

\begin{lemma}
\label{lemma-hom-derived}
Let $(A, \text{d})$ be a differential graded algebra.
Let $M$ and $N$ be differential graded $A$-modules.
\begin{enumerate}
\item Let $P \to M$ be a P-resolution as in
Lemma \ref{lemma-resolve}. Then
$$
\Hom_{D(A, \text{d})}(M, N) =
\Hom_{K(\text{Mod}_{(A, \text{d})})}(P, N)
$$
\item Let $N \to I$ be an I-resolution as in
Lemma \ref{lemma-right-resolution}. Then
$$
\Hom_{D(A, \text{d})}(M, N) =
\Hom_{K(\text{Mod}_{(A, \text{d})})}(M, I)
$$
\end{enumerate}
\end{lemma}

\begin{proof}
Let $P \to M$ be as in (1). Since $P \to M$ is a quasi-isomorphism we see that
$$
\Hom_{D(A, \text{d})}(P, N) = \Hom_{D(A, \text{d})}(M, N)
$$
by definition of the derived category. A morphism
$f : P \to N$ in $D(A, \text{d})$ is equal to
$s^{-1}f'$ where $f' : P \to N'$ is a morphism and
$s : N \to N'$ is a quasi-isomorphism. Choose a distinguished triangle
$$
N \to N' \to Q \to N[1]
$$
As $s$ is a quasi-isomorphism, we see that $Q$ is acyclic. Thus
$\Hom_{K(\text{Mod}_{(A, \text{d})})}(P, Q[k]) = 0$ for all $k$ by
Lemma \ref{lemma-property-P-K-projective}. Since
$\Hom_{K(\text{Mod}_{(A, \text{d})})}(P, -)$
is cohomological, we conclude that we can lift $f' : P \to N'$
uniquely to a morphism $f : P \to N$. This finishes the proof.

\medskip\noindent
The proof of (2) is dual to that of (1) using
Lemma \ref{lemma-property-I-K-injective} in stead of
Lemma \ref{lemma-property-P-K-projective}.
\end{proof}

\begin{lemma}
\label{lemma-derived-products}
Let $(A, \text{d})$ be a differential graded algebra. Then
\begin{enumerate}
\item $D(A, \text{d})$ has both direct sums and products,
\item direct sums are obtained by taking direct sums of differential graded
modules,
\item products are obtained by taking products of differential
graded modules.
\end{enumerate}
\end{lemma}

\begin{proof}
We will use that $\text{Mod}_{(A, \text{d})}$ is an abelian category
with arbitrary direct sums and products, and that these give rise
to direct sums and products in $K(\text{Mod}_{(A, \text{d})})$.
See Lemmas \ref{lemma-dgm-abelian} and \ref{lemma-homotopy-direct-sums}.

\medskip\noindent
Let $M_j$ be a family of differential graded $A$-modules.
Consider the graded direct sum $M = \bigoplus M_j$ which is a
differential graded $A$-module with the obvious.
For a differential graded $A$-module $N$ choose a quasi-isomorphism
$N \to I$ where $I$ is a differential graded $A$-module with property (I).
See Lemma \ref{lemma-right-resolution}.
Using Lemma \ref{lemma-hom-derived} we have
\begin{align*}
\Hom_{D(A, \text{d})}(M, N)
& =
\Hom_{K(A, \text{d})}(M, I) \\
& =
\prod \Hom_{K(A, \text{d})}(M_j, I) \\
& =
\prod \Hom_{D(A, \text{d})}(M_j, N)
\end{align*}
whence the existence of direct sums in $D(A, \text{d})$ as given in
part (2) of the lemma.

\medskip\noindent
Let $M_j$ be a family of differential graded $A$-modules.
Consider the product $M = \prod M_j$ of differential graded $A$-modules.
For a differential graded $A$-module $N$ choose a quasi-isomorphism
$P \to N$ where $P$ is a differential graded $A$-module with property (P).
See Lemma \ref{lemma-resolve}.
Using Lemma \ref{lemma-hom-derived} we have
\begin{align*}
\Hom_{D(A, \text{d})}(N, M)
& =
\Hom_{K(A, \text{d})}(P, M) \\
& =
\prod \Hom_{K(A, \text{d})}(P, M_j) \\
& =
\prod \Hom_{D(A, \text{d})}(N, M_j)
\end{align*}
whence the existence of direct sums in $D(A, \text{d})$ as given in
part (3) of the lemma.
\end{proof}

\begin{remark}
\label{remark-P-resolution}
Let $R$ be a ring. Let $(A, \text{d})$ be a differential graded $R$-algebra.
Using P-resolutions we can sometimes reduce statements about general
objects of $D(A, \text{d})$ to statements about $A[k]$. Namely, let
$T$ be a property of objects of $D(A, \text{d})$ and assume that
\begin{enumerate}
\item if $K_i$, $i \in I$ is a family of objects of $D(A, \text{d})$
and $T(K_i)$ holds for all $i \in I$, then $T(\bigoplus K_i)$,
\item if $K \to L \to M \to K[1]$ is a distinguished triangle of
$D(A, \text{d})$ and $T$ holds for two, then $T$
holds for the third object, and
\item $T(A[k])$ holds for all $k \in \mathbf{Z}$.
\end{enumerate}
Then $T$ holds for all objects of $D(A, \text{d})$. This is clear from
Lemmas \ref{lemma-property-P-sequence} and \ref{lemma-resolve}.
\end{remark}







\section{The canonical delta-functor}
\label{section-canonical-delta-functor}

\noindent
Let $(A, \text{d})$ be a differential graded algebra.
Consider the functor
$\text{Mod}_{(A, \text{d})} \to K(\text{Mod}_{(A, \text{d})})$.
This functor is {\bf not} a $\delta$-functor in general.
However, it turns out that the functor
$\text{Mod}_{(A, \text{d})} \to D(A, \text{d})$ is a
$\delta$-functor. In order to see this we have to define
the morphisms $\delta$ associated to a short exact sequence
$$
0 \to K \xrightarrow{a} L \xrightarrow{b} M \to 0
$$
in the abelian category $\text{Mod}_{(A, \text{d})}$.
Consider the cone $C(a)$ of the morphism $a$. We have $C(a) = L \oplus K$
and we define $q : C(a) \to M$ via the projection to $L$ followed
by $b$. Hence a homomorphism of differential graded $A$-modules
$$
q : C(a) \longrightarrow M.
$$
It is clear that $q \circ i = b$ where $i$ is as in
Definition \ref{definition-cone}.
Note that, as $a$ is injective, the kernel of $q$ is identified with the
cone of $\text{id}_K$ which is acyclic. Hence we see that
$q$ is a quasi-isomorphism. According to
Lemma \ref{lemma-the-same-up-to-isomorphisms}
the triangle
$$
(K, L, C(a), a, i, -p)
$$
is a distinguished triangle in $K(\text{Mod}_{(A, \text{d})})$.
As the localization functor
$K(\text{Mod}_{(A, \text{d})}) \to D(A, \text{d})$ is
exact we see that $(K, L, C(a), a, i, -p)$ is a distinguished
triangle in $D(A, \text{d})$. Since $q$ is a quasi-isomorphism
we see that $q$ is an isomorphism in $D(A, \text{d})$.
Hence we deduce that
$$
(K, L, M, a, b, -p \circ q^{-1})
$$
is a distinguished triangle of $D(A, \text{d})$.
This suggests the following lemma.

\begin{lemma}
\label{lemma-derived-canonical-delta-functor}
Let $(A, \text{d})$ be a differential graded algebra. The functor
$\text{Mod}_{(A, \text{d})} \to D(A, \text{d})$
defined has the natural structure of a $\delta$-functor, with
$$
\delta_{K \to L \to M} = - p \circ q^{-1}
$$
with $p$ and $q$ as explained above.
\end{lemma}

\begin{proof}
We have already seen that this choice leads to a distinguished
triangle whenever given a short exact sequence of complexes.
We have to show functoriality of this construction, see
Derived Categories, Definition \ref{derived-definition-delta-functor}.
This follows from Lemma \ref{lemma-functorial-cone} with a bit of
work. Compare with
Derived Categories, Lemma \ref{derived-lemma-derived-canonical-delta-functor}.
\end{proof}

\begin{lemma}
\label{lemma-homotopy-colimit}
Let $(A, \text{d})$ be a differential graded algebra. Let
$M_n$ be a system of differential graded modules. Then the derived
colimit $\text{hocolim} M_n$ in $D(A, \text{d})$ is represented
by the differential graded module $\colim M_n$.
\end{lemma}

\begin{proof}
Set $M = \colim M_n$. We have an exact sequence of differential graded modules
$$
0 \to \bigoplus M_n \to \bigoplus M_n \to M \to 0
$$
by Derived Categories, Lemma \ref{derived-lemma-compute-colimit}
(applied the underlying complexes of abelian groups).
The direct sums are direct sums in $D(\mathcal{A})$ by
Lemma \ref{lemma-derived-products}.
Thus the result follows from the definition
of derived colimits in Derived Categories,
Definition \ref{derived-definition-derived-colimit}
and the fact that a short exact sequence of complexes
gives a distinguished triangle
(Lemma \ref{lemma-derived-canonical-delta-functor}).
\end{proof}








\section{Linear categories}
\label{section-linear}

\noindent
Just the definitions.

\begin{definition}
\label{definition-linear-category}
Let $R$ be a ring. An {\it $R$-linear category $\mathcal{A}$} is a category
where every morphism set is given the structure of an $R$-module
and where for $x, y, z \in \Ob(\mathcal{A})$ composition law
$$
\Hom_\mathcal{A}(y, z) \times \Hom_\mathcal{A}(x, y)
\longrightarrow
\Hom_\mathcal{A}(x, z)
$$
is $R$-bilinear.
\end{definition}

\noindent
Thus composition determines an $R$-linear map
$$
\Hom_\mathcal{A}(y, z) \otimes_R \Hom_\mathcal{A}(x, y)
\longrightarrow
\Hom_\mathcal{A}(x, z)
$$
of $R$-modules. Note that we do not assume $R$-linear categories to be
additive.

\begin{definition}
\label{definition-functor-linear-categories}
Let $R$ be a ring. A {\it functor of $R$-linear categories}, or an
{\it $R$-linear functor} is a functor $F : \mathcal{A} \to \mathcal{B}$
where for all objects $x, y$ of $\mathcal{A}$ the map
$F : \Hom_\mathcal{A}(x, y) \to \Hom_\mathcal{B}(F(x), F(y))$
is a homomorphism of $R$-modules.
\end{definition}







\section{Graded categories}
\label{section-graded}

\noindent
Just some definitions.

\begin{definition}
\label{definition-graded-category}
Let $R$ be a ring. A {\it graded category $\mathcal{A}$
over $R$} is a category where every morphism set is given the structure
of a graded $R$-module and where for
$x, y, z \in \Ob(\mathcal{A})$ composition is $R$-bilinear and induces
a homomorphism
$$
\Hom_\mathcal{A}(y, z) \otimes_R \Hom_\mathcal{A}(x, y)
\longrightarrow
\Hom_\mathcal{A}(x, z)
$$
of graded $R$-modules (i.e., preserving degrees).
\end{definition}

\noindent
In this situation we denote $\Hom_\mathcal{A}^i(x, y)$ the degree $i$
part of the graded object $\Hom_\mathcal{A}(x, y)$, so that
$$
\Hom_\mathcal{A}(x, y) =
\bigoplus\nolimits_{i \in \mathbf{Z}} \Hom_\mathcal{A}^i(x, y)
$$
is the direct sum decomposition into graded parts.

\begin{definition}
\label{definition-functor-graded-categories}
Let $R$ be a ring. A {\it functor of graded categories over $R$}, or a
{\it graded functor}
is a functor $F : \mathcal{A} \to \mathcal{B}$ where for all objects
$x, y$ of $\mathcal{A}$ the map
$F : \Hom_\mathcal{A}(x, y) \to \Hom_\mathcal{A}(F(x), F(y))$
is a homomorphism of graded $R$-modules.
\end{definition}

\noindent
Given a graded category we are often interested in the
corresponding ``usual'' category of maps of degree $0$.
Here is a formal definition.

\begin{definition}
\label{definition-H0-of-graded-category}
Let $R$ be a ring. Let $\mathcal{A}$ be a graded category
over $R$. We let {\it $\mathcal{A}^0$} be the category with the
same objects as $\mathcal{A}$ and with
$$
\Hom_{\mathcal{A}^0}(x, y) = \Hom^0_\mathcal{A}(x, y)
$$
the degree $0$ graded piece of the graded module of morphisms of
$\mathcal{A}$.
\end{definition}

\begin{definition}
\label{definition-graded-direct-sum}
Let $R$ be a ring. Let $\mathcal{A}$ be a graded category over $R$.
A direct sum $(x, y, z, i, j, p, q)$ in $\mathcal{A}$ (notation as in
Homology, Remark \ref{homology-remark-direct-sum})
is a {\it graded direct sum} if $i, j, p, q$ are homogeneous
of degree $0$.
\end{definition}

\begin{example}[Graded category of graded objects]
\label{example-graded-category-graded-objects}
Let $\mathcal{B}$ be an additive category. Recall that we have defined
the category $\text{Gr}(\mathcal{B})$ of graded objects of $\mathcal{B}$ in
Homology, Definition \ref{homology-definition-graded}.
In this example, we will construct a graded category
$\text{Gr}^{gr}(\mathcal{B})$ over $R = \mathbf{Z}$
whose associated category $\text{Gr}^{gr}(\mathcal{B})^0$
recovers $\text{Gr}(\mathcal{B})$.
As objects of $\text{Gr}^{gr}(\mathcal{B})$
we take graded objects of $\mathcal{B}$. Then, given graded objects
$A = (A^i)$ and $B = (B^i)$ of $\mathcal{B}$ we set
$$
\Hom_{\text{Gr}^{gr}(\mathcal{B})}(A, B) =
\bigoplus\nolimits_{n \in \mathbf{Z}} \Hom^n(A, B)
$$
where the graded piece of degree $n$ is the abelian group of homogeneous
maps of degree $n$ from $A$ to $B$. Explicitly we have
$$
\Hom^n(A, B) = \prod\nolimits_{p + q = n} \Hom_\mathcal{B}(A^{-q}, B^p)
$$
(observe reversal of indices and observe that we have a product here and
not a direct sum). In other words, a degree $n$ morphism $f$
from $A$ to $B$ can be seen as a system $f = (f_{p, q})$ where
$p, q \in \mathbf{Z}$, $p + q = n$ with
$f_{p, q} : A^{-q} \to B^p$ a morphism of $\mathcal{B}$.
Given graded objects $A$, $B$, $C$ of $\mathcal{B}$
composition of morphisms in $\text{Gr}^{gr}(\mathcal{B})$ is defined
via the maps
$$
\Hom^m(B, C) \times \Hom^n(A, B) \longrightarrow \Hom^{n + m}(A, C)
$$
by simple composition $(g, f) \mapsto g \circ f$ of homogeneous
maps of graded objects. In terms of components we have
$$
(g \circ f)_{p, r} = g_{p, q} \circ f_{-q, r}
$$
where $q$ is such that $p + q = m$ and $-q + r = n$.
\end{example}

\begin{example}[Graded category of graded modules]
\label{example-gm-gr-cat}
Let $A$ be a $\mathbf{Z}$-graded algebra over a ring $R$. We will construct
a graded category $\text{Mod}^{gr}_A$ over $R$ whose associated category
$(\text{Mod}^{gr}_A)^0$ is the category of graded $A$-modules. As objects
of $\text{Mod}^{gr}_A$ we take right graded $A$-modules (see
Section \ref{section-projectives-over-algebras}). Given graded
$A$-modules $L$ and $M$ we set
$$
\Hom_{\text{Mod}^{gr}_A}(L, M) =
\bigoplus\nolimits_{n \in \mathbf{Z}} \Hom^n(L, M)
$$
where $\Hom^n(L, M)$ is the set of right $A$-module maps $L \to M$ which
are homogeneous of degree $n$, i.e., $f(L^i) \subset M^{i + n}$ for
all $i \in \mathbf{Z}$. In terms of components, we have that
$$
\Hom^n(L, M) \subset \prod\nolimits_{p + q = n} \Hom_R(L^{-q}, M^p)
$$
(observe reversal of indices) is the subset consisting of those
$f = (f_{p, q})$ such that
$$
f_{p, q}(m a) = f_{p - i, q + i}(m)a
$$
for $a \in A^i$ and $m \in L^{-q - i}$. For graded $A$-modules
$K$, $L$, $M$ we define composition in $\text{Mod}^{gr}_A$ via
the maps
$$
\Hom^m(L, M) \times \Hom^n(K, L) \longrightarrow \Hom^{n + m}(K, M)
$$
by simple composition of right $A$-module maps: $(g, f) \mapsto g \circ f$.
\end{example}

\begin{remark}
\label{remark-graded-shift-functors}
Let $R$ be a ring. Let $\mathcal{D}$ be an $R$-linear category endowed with a
collection of $R$-linear functors $[n] : \mathcal{D} \to \mathcal{D}$,
$x \mapsto x[n]$ indexed by $n \in \mathbf{Z}$ such that
$[n] \circ [m] = [n + m]$ and $[0] = \text{id}_\mathcal{D}$ (equality as
functors). This allows us to construct a graded category $\mathcal{D}^{gr}$
over $R$ with the same objects of $\mathcal{D}$ setting
$$
\Hom_{\mathcal{D}^{gr}}(x, y) =
\bigoplus\nolimits_{n \in \mathbf{Z}} \Hom_\mathcal{D}(x, y[n])
$$
for $x, y$ in $\mathcal{D}$. Observe that $(\mathcal{D}^{gr})^0 = \mathcal{D}$
(see Definition \ref{definition-H0-of-graded-category}). Moreover, the graded
category $\mathcal{D}^{gr}$ inherits $R$-linear graded functors $[n]$
satisfying $[n] \circ [m] = [n + m]$ and $[0] = \text{id}_{\mathcal{D}^{gr}}$
with the property that
$$
\Hom_{\mathcal{D}^{gr}}(x, y[n]) = \Hom_{\mathcal{D}^{gr}}(x, y)[n]
$$
as graded $R$-modules compatible with composition of morphisms.

\medskip\noindent
Conversely, suppose given a graded category $\mathcal{A}$ over $R$ endowed
with a collection of $R$-linear graded functors $[n]$
satisfying $[n] \circ [m] = [n + m]$ and $[0] = \text{id}_\mathcal{A}$
which are moreover equipped with isomorphisms
$$
\Hom_\mathcal{A}(x, y[n]) = \Hom_\mathcal{A}(x, y)[n]
$$
as graded $R$-modules compatible with composition of morphisms. Then
the reader easily shows that $\mathcal{A} = (\mathcal{A}^0)^{gr}$.

\medskip\noindent
Here are two examples of the relationship
$\mathcal{D} \leftrightarrow \mathcal{A}$ we established above:
\begin{enumerate}
\item Let $\mathcal{B}$ be an additive category. If
$\mathcal{D} = \text{Gr}(\mathcal{B})$, then
$\mathcal{A} = \text{Gr}^{gr}(\mathcal{B})$ as in
Example \ref{example-graded-category-graded-objects}.
\item If $A$ is a graded ring and $\mathcal{D} = \text{Mod}_A$
is the category of graded right $A$-modules, then
$\mathcal{A} = \text{Mod}^{gr}_A$, see Example \ref{example-gm-gr-cat}.
\end{enumerate}
\end{remark}






\section{Differential graded categories}
\label{section-dga-categories}

\noindent
Note that if $R$ is a ring, then $R$ is a differential graded algebra
over itself (with $R = R^0$ of course). In this case a differential
graded $R$-module is the same thing as a complex of $R$-modules.
In particular, given two differential graded $R$-modules $M$ and $N$
we denote $M \otimes_R N$ the differential graded $R$-module
corresponding to the total complex associated to the double
complex obtained by the tensor product of the complexes of $R$-modules
associated to $M$ and $N$.

\begin{definition}
\label{definition-dga-category}
Let $R$ be a ring. A {\it differential graded category $\mathcal{A}$
over $R$} is a category where every morphism set is given the structure
of a differential graded $R$-module and where for
$x, y, z \in \Ob(\mathcal{A})$ composition is $R$-bilinear and induces
a homomorphism
$$
\Hom_\mathcal{A}(y, z) \otimes_R \Hom_\mathcal{A}(x, y)
\longrightarrow
\Hom_\mathcal{A}(x, z)
$$
of differential graded $R$-modules.
\end{definition}

\noindent
The final condition of the definition signifies the following:
if $f \in \Hom_\mathcal{A}^n(x, y)$ and
$g \in \Hom_\mathcal{A}^m(y, z)$ are homogeneous
of degrees $n$ and $m$, then
$$
\text{d}(g \circ f) = \text{d}(g) \circ f + (-1)^mg \circ \text{d}(f)
$$
in $\Hom_\mathcal{A}^{n + m + 1}(x, z)$. This follows from the sign
rule for the differential on the total complex of a double complex, see
Homology, Definition \ref{homology-definition-associated-simple-complex}.

\begin{definition}
\label{definition-functor-dga-categories}
Let $R$ be a ring. A {\it functor of differential graded categories over $R$}
is a functor $F : \mathcal{A} \to \mathcal{B}$ where for all objects
$x, y$ of $\mathcal{A}$ the map
$F : \Hom_\mathcal{A}(x, y) \to \Hom_\mathcal{A}(F(x), F(y))$
is a homomorphism of differential graded $R$-modules.
\end{definition}

\noindent
Given a differential graded category we are often interested in the
corresponding categories of complexes and homotopy category.
Here is a formal definition.

\begin{definition}
\label{definition-homotopy-category-of-dga-category}
Let $R$ be a ring. Let $\mathcal{A}$ be a differential graded category
over $R$. Then we let
\begin{enumerate}
\item the {\it category of complexes of $\mathcal{A}$}\footnote{This may
be nonstandard terminology.} be the category
$\text{Comp}(\mathcal{A})$ whose objects are the same as the objects
of $\mathcal{A}$ and with
$$
\Hom_{\text{Comp}(\mathcal{A})}(x, y) =
\Ker(d : \Hom^0_\mathcal{A}(x, y) \to \Hom^1_\mathcal{A}(x, y))
$$
\item the {\it homotopy category of $\mathcal{A}$} be the category
$K(\mathcal{A})$ whose objects are the same as the objects
of $\mathcal{A}$ and with
$$
\Hom_{K(\mathcal{A})}(x, y) = H^0(\Hom_\mathcal{A}(x, y))
$$
\end{enumerate}
\end{definition}

\noindent
Our use of the symbol $K(\mathcal{A})$ is nonstandard, but at least
is compatible with the use of $K(-)$ in other chapters of the Stacks project.

\begin{definition}
\label{definition-dg-direct-sum}
Let $R$ be a ring. Let $\mathcal{A}$ be a differential graded category over
$R$. A direct sum $(x, y, z, i, j, p, q)$ in $\mathcal{A}$ (notation as in
Homology, Remark \ref{homology-remark-direct-sum})
is a {\it differential graded direct sum} if $i, j, p, q$ are homogeneous
of degree $0$ and closed, i.e., $\text{d}(i) = 0$, etc.
\end{definition}

\begin{lemma}
\label{lemma-functorial}
Let $R$ be a ring. A functor $F : \mathcal{A} \to \mathcal{B}$
of differential graded categories over $R$ induces functors
$\text{Comp}(\mathcal{A}) \to \text{Comp}(\mathcal{B})$
and $K(\mathcal{A}) \to K(\mathcal{B})$.
\end{lemma}

\begin{proof}
Omitted.
\end{proof}

\begin{example}[Differential graded category of complexes]
\label{example-category-complexes}
Let $\mathcal{B}$ be an additive category. We will construct
a differential graded category $\text{Comp}^{dg}(\mathcal{B})$
over $R = \mathbf{Z}$ whose associated category of complexes
is $\text{Comp}(\mathcal{B})$ and whose associated homotopy
category is $K(\mathcal{B})$. As objects of $\text{Comp}^{dg}(\mathcal{B})$
we take complexes of $\mathcal{B}$. Given complexes
$A^\bullet$ and $B^\bullet$ of $\mathcal{B}$, we sometimes also
denote $A^\bullet$ and $B^\bullet$ the corresponding graded objects
of $\mathcal{B}$ (i.e., forget about the differential).
Using this abuse of notation, we set
$$
\Hom_{\text{Comp}^{dg}(\mathcal{B})}(A^\bullet, B^\bullet) =
\Hom_{\text{Gr}^{gr}(\mathcal{B})}(A^\bullet, B^\bullet) =
\bigoplus\nolimits_{n \in \mathbf{Z}} \Hom^n(A, B)
$$
as a graded $\mathbf{Z}$-module with notation and definitions as
in Example \ref{example-graded-category-graded-objects}.
In other words, the $n$th graded piece is
the abelian group of homogeneous morphism of degree $n$ of graded objects
$$
\Hom^n(A^\bullet, B^\bullet) =
\prod\nolimits_{p + q = n} \Hom_\mathcal{B}(A^{-q}, B^p)
$$
Observe reversal of indices and observe we have a direct product
and not a direct sum. For an element
$f \in \Hom^n(A^\bullet, B^\bullet)$ of degree $n$ we set
$$
\text{d}(f) = \text{d}_B \circ f - (-1)^n f \circ \text{d}_A
$$
The sign is exactly as in
More on Algebra, Section \ref{more-algebra-section-sign-rules}.
To make sense of this we think of $\text{d}_B$ and $\text{d}_A$
as maps of graded objects of $\mathcal{B}$ homogeneous of degree $1$
and we use composition in the category $\text{Gr}^{gr}(\mathcal{B})$
on the right hand side. In terms of components, if $f = (f_{p, q})$ with
$f_{p, q} : A^{-q} \to B^p$ we have
\begin{equation}
\label{equation-differential-hom-complex}
\text{d}(f_{p, q}) =
\text{d}_B \circ f_{p, q} - (-1)^{p + q} f_{p, q} \circ \text{d}_A 
\end{equation}
Note that the first term of this expression is in
$\Hom_\mathcal{B}(A^{-q}, B^{p + 1})$ and the second term is in
$\Hom_\mathcal{B}(A^{-q - 1}, B^p)$. The reader checks that
\begin{enumerate}
\item $\text{d}$ has square zero,
\item an element $f$ in $\Hom^n(A^\bullet, B^\bullet)$
has $\text{d}(f) = 0$ if and only if the morphism
$f : A^\bullet \to B^\bullet[n]$ of graded objects of $\mathcal{B}$
is actually a map of complexes,
\item in particular, the category of complexes of
$\text{Comp}^{dg}(\mathcal{B})$ is equal to $\text{Comp}(\mathcal{B})$,
\item the morphism of complexes defined by $f$ as in (2)
is homotopy equivalent to zero if and only if $f = \text{d}(g)$
for some $g \in \Hom^{n - 1}(A^\bullet, B^\bullet)$.
\item in particular, we obtain a canonical isomorphism
$$
\Hom_{K(\mathcal{B})}(A^\bullet, B^\bullet)
\longrightarrow
H^0(\Hom_{\text{Comp}^{dg}(\mathcal{B})}(A^\bullet, B^\bullet))
$$
and the homotopy category of $\text{Comp}^{dg}(\mathcal{B})$ is equal to
$K(\mathcal{B})$.
\end{enumerate}
Given complexes $A^\bullet$, $B^\bullet$, $C^\bullet$ we define
composition
$$
\Hom^m(B^\bullet, C^\bullet) \times \Hom^n(A^\bullet, B^\bullet)
\longrightarrow
\Hom^{n + m}(A^\bullet, C^\bullet)
$$
by composition $(g, f) \mapsto g \circ f$ in the graded category
$\text{Gr}^{gr}(\mathcal{B})$, see
Example \ref{example-graded-category-graded-objects}.
This defines a map of differential graded modules
$$
\Hom_{\text{Comp}^{dg}(\mathcal{B})}(B^\bullet, C^\bullet)
\otimes_R
\Hom_{\text{Comp}^{dg}(\mathcal{B})}(A^\bullet, B^\bullet)
\longrightarrow
\Hom_{\text{Comp}^{dg}(\mathcal{B})}(A^\bullet, C^\bullet)
$$
as required in Definition \ref{definition-dga-category}
because
\begin{align*}
\text{d}(g \circ f) & =
\text{d}_C \circ g \circ f - (-1)^{n + m} g \circ f \circ \text{d}_A \\
& =
\left(\text{d}_C \circ g - (-1)^m g \circ \text{d}_B\right) \circ f +
(-1)^m g \circ \left(\text{d}_B \circ f - (-1)^n f \circ \text{d}_A\right) \\
& =
\text{d}(g) \circ f + (-1)^m g \circ \text{d}(f)
\end{align*}
as desired.
\end{example}

\begin{lemma}
\label{lemma-additive-functor-induces-dga-functor}
Let $F : \mathcal{B} \to \mathcal{B}'$ be an additive functor between
additive categories. Then $F$ induces a functor of differential
graded categories
$$
F : \text{Comp}^{dg}(\mathcal{B}) \to \text{Comp}^{dg}(\mathcal{B}')
$$
of Example \ref{example-category-complexes}
inducing the usual functors on the category of complexes and the
homotopy categories.
\end{lemma}

\begin{proof}
Omitted.
\end{proof}

\begin{example}[Differential graded category of differential graded modules]
\label{example-dgm-dg-cat}
Let $(A, \text{d})$ be a differential graded algebra over a ring $R$. We will
construct a differential graded category $\text{Mod}^{dg}_{(A, \text{d})}$
over $R$ whose category of complexes is $\text{Mod}_{(A, \text{d})}$ and
whose homotopy category is $K(\text{Mod}_{(A, \text{d})})$.
As objects of $\text{Mod}^{dg}_{(A, \text{d})}$
we take the differential graded $A$-modules. Given differential
graded $A$-modules $L$ and $M$ we set
$$
\Hom_{\text{Mod}^{dg}_{(A, \text{d})}}(L, M) =
\Hom_{\text{Mod}^{gr}_A}(L, M) = \bigoplus \Hom^n(L, M)
$$
as a graded $R$-module where the right hand side is defined as in
Example \ref{example-gm-gr-cat}. In other words, the $n$th graded piece
$\Hom^n(L, M)$ is the $R$-module of right $A$-module maps homogeneous
of degree $n$. For an element $f \in \Hom^n(L, M)$ we set
$$
\text{d}(f) = \text{d}_M \circ f - (-1)^n f \circ \text{d}_L
$$
To make sense of this we think of $\text{d}_M$ and $\text{d}_L$
as graded $R$-module maps and we use composition of graded
$R$-module maps. It is clear that $\text{d}(f)$ is homogeneous of
degree $n + 1$ as a graded $R$-module map, and it is $A$-linear
because
\begin{align*}
\text{d}(f)(xa)
& =
\text{d}_M(f(x) a) - (-1)^n f (\text{d}_L(xa)) \\
& =
\text{d}_M(f(x)) a + (-1)^{\deg(x) + n} f(x) \text{d}(a) 
- (-1)^n f(\text{d}_L(x)) a - (-1)^{n + \deg(x)} f(x) \text{d}(a) \\
& = \text{d}(f)(x) a
\end{align*}
as desired (observe that this calculation would not work without the
sign in the definition of our differential on $\Hom$). Similar formulae
to those of Example \ref{example-category-complexes} hold for the
differential of $f$ in terms of components.
The reader checks (in the same way as in
Example \ref{example-category-complexes}) that
\begin{enumerate}
\item $\text{d}$ has square zero,
\item an element $f$ in $\Hom^n(L, M)$ has $\text{d}(f) = 0$ if and only if
$f : L \to M[n]$ is a homomorphism of differential graded $A$-modules,
\item in particular, the category of complexes of
$\text{Mod}^{dg}_{(A, \text{d})}$ is $\text{Mod}_{(A, \text{d})}$,
\item the homomorphism defined by $f$ as in (2) is homotopy equivalent
to zero if and only if $f = \text{d}(g)$ for some
$g \in \Hom^{n - 1}(L, M)$.
\item in particular, we obtain a canonical isomorphism
$$
\Hom_{K(\text{Mod}_{(A, \text{d})})}(L, M)
\longrightarrow
H^0(\Hom_{\text{Mod}^{dg}_{(A, \text{d})}}(L, M))
$$
and the homotopy category of $\text{Mod}^{dg}_{(A, \text{d})}$ is
$K(\text{Mod}_{(A, \text{d})})$.
\end{enumerate}
Given differential graded $A$-modules $K$, $L$, $M$ we define
composition
$$
\Hom^m(L, M) \times \Hom^n(K, L) \longrightarrow \Hom^{n + m}(K, M)
$$
by composition of homogeneous right $A$-module maps $(g, f) \mapsto g \circ f$.
This defines a map of differential graded modules
$$
\Hom_{\text{Mod}^{dg}_{(A, \text{d})}}(L, M) \otimes_R
\Hom_{\text{Mod}^{dg}_{(A, \text{d})}}(K, L) \longrightarrow
\Hom_{\text{Mod}^{dg}_{(A, \text{d})}}(K, M)
$$
as required in
Definition \ref{definition-dga-category}
because
\begin{align*}
\text{d}(g \circ f) & =
\text{d}_M \circ g \circ f - (-1)^{n + m} g \circ f \circ \text{d}_K \\
& =
\left(\text{d}_M \circ g - (-1)^m g \circ \text{d}_L\right) \circ f +
(-1)^m g \circ \left(\text{d}_L \circ f - (-1)^n f \circ \text{d}_K\right) \\
& =
\text{d}(g) \circ f + (-1)^m g \circ \text{d}(f)
\end{align*}
as desired.
\end{example}

\begin{lemma}
\label{lemma-homomorphism-induces-dga-functor}
Let $\varphi : (A, \text{d}) \to (E, \text{d})$ be a homomorphism of
differential graded algebras. Then $\varphi$ induces a functor of differential
graded categories
$$
F :
\text{Mod}^{dg}_{(E, \text{d})}
\longrightarrow
\text{Mod}^{dg}_{(A, \text{d})}
$$
of Example \ref{example-dgm-dg-cat} inducing obvious restriction functors
on the categories of differential graded modules and homotopy categories.
\end{lemma}

\begin{proof}
Omitted.
\end{proof}

\begin{lemma}
\label{lemma-construction}
Let $R$ be a ring. Let $\mathcal{A}$ be a differential graded category
over $R$. Let $x$ be an object of $\mathcal{A}$. Let
$$
(E, \text{d}) = \Hom_\mathcal{A}(x, x)
$$
be the differential graded $R$-algebra of endomorphisms of $x$.
We obtain a functor
$$
\mathcal{A} \longrightarrow \text{Mod}^{dg}_{(E, \text{d})},\quad
y \longmapsto \Hom_\mathcal{A}(x, y)
$$
of differential graded categories by letting $E$ act on
$\Hom_\mathcal{A}(x, y)$ via composition in $\mathcal{A}$.
This functor induces functors
$$
\text{Comp}(\mathcal{A}) \to \text{Mod}_{(A, \text{d})}
\quad\text{and}\quad
K(\mathcal{A}) \to K(\text{Mod}_{(A, \text{d})})
$$
by an application of Lemma \ref{lemma-functorial}.
\end{lemma}

\begin{proof}
This lemma proves itself.
\end{proof}









\section{Obtaining triangulated categories}
\label{section-review}

\noindent
In this section we discuss the most general setup to which the arguments
proving Derived Categories, Proposition
\ref{derived-proposition-homotopy-category-triangulated} and
Proposition \ref{proposition-homotopy-category-triangulated} apply.

\medskip\noindent
Let $R$ be a ring. Let $\mathcal{A}$ be a differential graded category
over $R$. To make our argument work, we impose some axioms on $\mathcal{A}$:
\begin{enumerate}
\item[(A)] $\mathcal{A}$ has a zero object and differential
graded direct sums of two objects
(as in Definition \ref{definition-dg-direct-sum}).
\item[(B)] there are functors $[n] : \mathcal{A} \longrightarrow \mathcal{A}$
of differential graded categories such that
$[0] = \text{id}_\mathcal{A}$ and $[n + m] = [n] \circ [m]$
and given isomorphisms
$$
\Hom_\mathcal{A}(x, y[n]) = \Hom_\mathcal{A}(x, y)[n]
$$
of differential graded $R$-modules compatible with composition.
\end{enumerate}

\noindent
Given our differential graded category $\mathcal{A}$ we say
\begin{enumerate}
\item a sequence $x \to y \to z$ of morphisms of $\text{Comp}(\mathcal{A})$
is an {\it admissible short exact sequence} if there exists
an isomorphism $y \cong x \oplus z$ in the underlying graded category
such that $x \to z$ and $y \to z$ are (co)projections.
\item a morphism $x\to y$ of $\text{Comp}(\mathcal{A})$ is an
{\it admissible monomorphism} if it extends to an
admissible short exact sequence $x\to y\to z$.
\item a morphism $y\to z$ of $\text{Comp}(\mathcal{A})$ is an
{\it admissible epimorphism} if it extends to an
admissible short exact sequence $x\to y\to z$.
\end{enumerate}
The next lemma tells us an admissible short exact sequence gives a
triangle, provided we have axioms (A) and (B).

\begin{lemma}
\label{lemma-get-triangle}
Let $\mathcal{A}$ be a differential graded category satisfying
axioms (A) and (B). Given an admissible short exact sequence
$x \to y \to z$ we obtain (see proof) a triangle
$$
x \to y \to z \to x[1]
$$
in $\text{Comp}(\mathcal{A})$ with the property that any two compositions
in $z[-1] \to x \to y \to z \to x[1]$ are zero in $K(\mathcal{A})$.
\end{lemma}

\begin{proof}
Choose a diagram
$$
\xymatrix{
x \ar[rr]_1 \ar[rd]_a & & x \\
& y \ar[ru]_\pi \ar[rd]^b & \\
z \ar[rr]^1 \ar[ru]^s & & z
}
$$
giving the isomorphism of graded objects $y \cong x \oplus z$ as in the
definition of an admissible short exact sequence. Here are some equations
that hold in this situation
\begin{enumerate}
\item $1 = \pi a$ and hence $\text{d}(\pi) a = 0$,
\item $1 = b s$ and hence $b \text{d}(s) = 0$,
\item $1 = a \pi + s b$ and hence $a \text{d}(\pi) + \text{d}(s) b = 0$,
\item $\pi s = 0$ and hence $\text{d}(\pi)s + \pi \text{d}(s) = 0$,
\item $\text{d}(s) = a \pi \text{d}(s)$ because
$\text{d}(s) = (a \pi + s b)\text{d}(s)$ and $b\text{d}(s) = 0$,
\item $\text{d}(\pi) = \text{d}(\pi) s b$ because
$\text{d}(\pi) = \text{d}(\pi)(a \pi + s b)$ and $\text{d}(\pi)a = 0$,
\item $\text{d}(\pi \text{d}(s)) = 0$ because if we postcompose it
with the monomorphism $a$ we get
$\text{d}(a\pi \text{d}(s)) = \text{d}(\text{d}(s)) = 0$, and
\item $\text{d}(\text{d}(\pi)s) = 0$ as by (4) it is the negative
of $\text{d}(\pi\text{d}(s))$ which is $0$ by (7).
\end{enumerate}
We've used repeatedly that $\text{d}(a) = 0$, $\text{d}(b) = 0$,
and that $\text{d}(1) = 0$. By (7) we see that
$$
\delta = \pi \text{d}(s) = - \text{d}(\pi) s : z \to x[1]
$$
is a morphism in $\text{Comp}(\mathcal{A})$. By (5) we see that
the composition $a \delta = a \pi \text{d}(s) = \text{d}(s)$
is homotopic to zero. By (6) we see that the composition
$\delta b = - \text{d}(\pi)sb = \text{d}(-\pi)$ is homotopic to zero.
\end{proof}

\noindent
Besides axioms (A) and (B) we need an axiom concerning the existence of
cones. We formalize everything as follows.

\begin{situation}
\label{situation-ABC}
Here $R$ is a ring and $\mathcal{A}$ is a differential graded category
over $R$ having axioms (A), (B), and
\begin{enumerate}
\item[(C)] given an arrow $f : x \to y$ of degree $0$ with
$\text{d}(f) = 0$ there exists an admissible short exact sequence
$y \to c(f) \to x[1]$ in $\text{Comp}(\mathcal{A})$ such that the map
$x[1] \to y[1]$ of Lemma \ref{lemma-get-triangle} is equal to $f[1]$.
\end{enumerate}
\end{situation}

\noindent
We will call $c(f)$ a {\it cone} of the morphism $f$.
If (A), (B), and (C) hold, then
cones are functorial in a weak sense.

\begin{lemma}
\label{lemma-cone}
\begin{slogan}
The homotopy category is a triangulated category.
This lemma proves a part of the axioms of a triangulated category.
\end{slogan}
In Situation \ref{situation-ABC} suppose that
$$
\xymatrix{
x_1 \ar[r]_{f_1} \ar[d]_a & y_1 \ar[d]^b \\
x_2 \ar[r]^{f_2} & y_2
}
$$
is a diagram of $\text{Comp}(\mathcal{A})$ commutative up to homotopy.
Then there exists a morphism $c : c(f_1) \to c(f_2)$ which gives rise to
a morphism of triangles
$$
(a, b, c) : (x_1, y_1, c(f_1)) \to (x_1, y_1, c(f_1))
$$
in $K(\mathcal{A})$.
\end{lemma}

\begin{proof}
The assumption means there exists a morphism $h : x_1 \to y_2$ of degree
$-1$ such that $\text{d}(h) = b f_1 - f_2 a$. Choose isomorphisms
$c(f_i) = y_i \oplus x_i[1]$ of graded objects compatible with the
morphisms $y_i \to c(f_i) \to x_i[1]$. Let's denote
$a_i : y_i \to c(f_i)$, $b_i : c(f_i) \to x_i[1]$, $s_i : x_i[1] \to c(f_i)$,
and $\pi_i : c(f_i) \to y_i$ the given morphisms. Recall that
$x_i[1] \to y_i[1]$ is given by $\pi_i \text{d}(s_i)$. By axiom (C)
this means that
$$
f_i = \pi_i \text{d}(s_i) = - \text{d}(\pi_i) s_i
$$
(we identify $\Hom(x_i, y_i)$ with $\Hom(x_i[1], y_i[1])$
using the shift functor $[1]$).
Set $c = a_2 b \pi_1 + s_2 a b_1 + a_2hb$. Then, using the
equalities found in the proof of Lemma \ref{lemma-get-triangle}
we obtain
\begin{align*}
\text{d}(c)
& =
a_2 b \text{d}(\pi_1) + \text{d}(s_2) a b_1 + a_2 \text{d}(h) b_1 \\
& =
- a_2 b f_1 b_1 + a_2 f_2 a b_1 + a_2 (b f_1 - f_2 a) b_1 \\
& = 0
\end{align*}
(where we have used in particular that
$\text{d}(\pi_1) = \text{d}(\pi_1) s_1 b_1 = f_1 b_1$ and
$\text{d}(s_2) = a_2 \pi_2 \text{d}(s_2) = a_2 f_2$).
Thus $c$ is a degree $0$ morphism $c : c(f_1) \to c(f_2)$ of $\mathcal{A}$
compatible with the given morphisms $y_i \to c(f_i) \to x_i[1]$.
\end{proof}

\noindent
In Situation \ref{situation-ABC} we say that a triangle
$(x, y, z, f, g, h)$ in $K(\mathcal{A})$ is a
{\it distinguished triangle} if there exists an admissible
short exact sequence $x' \to y' \to z'$ such that
$(x, y, z, f, g, h)$ is isomorphic as a triangle in $K(\mathcal{A})$
to the triangle $(x', y', z', x' \to y', y' \to z', \delta)$
constructed in Lemma \ref{lemma-get-triangle}. We will show below that
$$
\boxed{
K(\mathcal{A})\text{ is a triangulated category}
}
$$
This result, although not as general as one might think, applies to a
number of natural generalizations of the cases covered so far in the
Stacks project. Here are some examples:
\begin{enumerate}
\item Let $(X, \mathcal{O}_X)$ be a ringed space. Let $(A, d)$ be a
sheaf of differential graded $\mathcal{O}_X$-algebras. Let
$\mathcal{A}$ be the differential graded category of differential
graded $A$-modules. Then $K(\mathcal{A})$ is a triangulated category.
\item Let $(\mathcal{C}, \mathcal{O})$ be a ringed site. Let $(A, d)$ be a
sheaf of differential graded $\mathcal{O}$-algebras. Let
$\mathcal{A}$ be the differential graded category of differential
graded $A$-modules. Then $K(\mathcal{A})$ is a triangulated category.
See Differential Graded Sheaves, Proposition
\ref{sdga-proposition-homotopy-category-triangulated}.
\item Two examples with a different flavor may be found in Examples, Section
\ref{examples-section-nongraded-differential-graded}.
\end{enumerate}

\noindent
The following simple lemma is a key to the construction.

\begin{lemma}
\label{lemma-id-cone-null}
In Situation \ref{situation-ABC}
given any object $x$ of $\mathcal{A}$, and the cone $C(1_x)$ of the
identity morphism $1_x : x \to x$, the identity morphism on
$C(1_x)$ is homotopic to zero.
\end{lemma}

\begin{proof}
Consider the admissible short exact sequence given by axiom (C).
$$
\xymatrix{
x \ar@<0.5ex>[r]^a  &
C(1_x) \ar@<0.5ex>[l]^{\pi} \ar@<0.5ex>[r]^b &
x[1]\ar@<0.5ex>[l]^s
}
$$
Then by Lemma \ref{lemma-get-triangle}, identifying hom-sets under
shifting, we have $1_x=\pi d(s)=-d(\pi)s$ where $s$ is regarded as
a morphism in $\Hom_{\mathcal{A}}^{-1}(x,C(1_x))$. Therefore
$a=a\pi d(s)=d(s)$ using formula (5) of Lemma \ref{lemma-get-triangle},
and $b=-d(\pi)sb=-d(\pi)$ by formula (6) of Lemma \ref{lemma-get-triangle}.
Hence
$$
1_{C(1_x)} = a\pi + sb = d(s)\pi - sd(\pi) = d(s\pi)
$$
since $s$ is of degree $-1$.
\end{proof}

\noindent
A more general version of the above lemma will appear in
Lemma \ref{lemma-cone-homotopy}. The following lemma is the
analogue of Lemma \ref{lemma-make-commute-map}.

\begin{lemma}
\label{lemma-homo-change}
In Situation \ref{situation-ABC} given a diagram
$$
\xymatrix{x\ar[r]^f\ar[d]_a & y\ar[d]^b\\
z\ar[r]^g & w}
$$
in $\text{Comp}(\mathcal{A})$ commuting up to homotopy. Then
\begin{enumerate}
\item If $f$ is an admissible monomorphism, then $b$ is homotopic
to a morphism $b'$ which makes the diagram commute.
\item If $g$ is an admissible epimorphism, then $a$ is homotopic
to a morphism $a'$ which makes the diagram commute.
\end{enumerate}
\end{lemma}

\begin{proof}
To prove (1), observe that the hypothesis implies that there is some
$h\in\Hom_{\mathcal{A}}(x,w)$ of degree $-1$ such that $bf-ga=d(h)$.
Since $f$ is an admissible monomorphism, there is a morphism
$\pi : y \to x$ in the category $\mathcal{A}$ of degree $0$.
Let $b' = b - d(h\pi)$. Then
\begin{align*}
b'f = bf - d(h\pi)f
= &
bf - d(h\pi f) \quad (\text{since }d(f) = 0) \\
= &
bf-d(h) \\
= &
ga
\end{align*}
as desired. The proof for (2) is omitted.
\end{proof}

\noindent
The following lemma is the analogue of Lemma \ref{lemma-make-injective}.

\begin{lemma}
\label{lemma-factor}
In Situation \ref{situation-ABC} let $\alpha : x \to y$
be a morphism in $\text{Comp}(\mathcal{A})$. Then there exists
a factorization in $\text{Comp}(\mathcal{A})$:
$$
\xymatrix{
x \ar[r]^{\tilde{\alpha}}  &
\tilde{y} \ar@<0.5ex>[r]^{\pi} &
y\ar@<0.5ex>[l]^s
}
$$
such that
\begin{enumerate}
\item $\tilde{\alpha}$ is an admissible monomorphism, and
$\pi\tilde{\alpha}=\alpha$.
\item There exists a morphism
$s:y\to\tilde{y}$ in $\text{Comp}(\mathcal{A})$
such that $\pi s=1_y$ and $s\pi$ is homotopic to $1_{\tilde{y}}$. 
\end{enumerate}
\end{lemma}

\begin{proof}
By axiom (A), we may let $\tilde{y}$ be the differential graded direct
sum of $y$ and $C(1_x)$, i.e., there exists a diagram
$$
\xymatrix@C=3pc{
y \ar@<0.5ex>[r]^s  &
y\oplus C(1_x) \ar@<0.5ex>[l]^{\pi} \ar@<0.5ex>[r]^{p} &
C(1_x)\ar@<0.5ex>[l]^t
}
$$
where all morphisms are of degree zero, and in
$\text{Comp}(\mathcal{A})$. Let $\tilde{y} = y \oplus C(1_x)$.
Then $1_{\tilde{y}} = s\pi + tp$. Consider now the diagram
$$
\xymatrix{
x \ar[r]^{\tilde{\alpha}}  &
\tilde{y} \ar@<0.5ex>[r]^{\pi} &
y\ar@<0.5ex>[l]^s
}
$$
where $\tilde{\alpha}$ is induced by the morphism $x\xrightarrow{\alpha}y$
and the natural morphism $x\to C(1_x)$ fitting in the admissible
short exact sequence
$$
\xymatrix{
x \ar@<0.5ex>[r]  &
C(1_x) \ar@<0.5ex>[l] \ar@<0.5ex>[r] &
x[1]\ar@<0.5ex>[l]
}
$$
So the morphism $C(1_x)\to x$ of degree 0 in this diagram,
together with the zero morphism $y\to x$, induces a degree-0
morphism $\beta : \tilde{y} \to x$. Then $\tilde{\alpha}$ is an
admissible monomorphism since it fits into the admissible short
exact sequence
$$
\xymatrix{
x\ar[r]^{\tilde{\alpha}} &
\tilde{y} \ar[r] &
x[1]
}
$$
Furthermore, $\pi\tilde{\alpha} = \alpha$ by the construction of
$\tilde{\alpha}$, and $\pi s = 1_y$ by the first diagram. It
remains to show that $s\pi$ is homotopic to $1_{\tilde{y}}$.
Write $1_x$ as $d(h)$ for some degree $-1$ map. Then, our
last statement follows from
\begin{align*}
1_{\tilde{y}} - s\pi
= &
tp \\
= &
t(dh)p\quad\text{(by Lemma \ref{lemma-id-cone-null})} \\
= &
d(thp)
\end{align*}
since $dt = dp = 0$, and $t$ is of degree zero. 
\end{proof}

\noindent
The following lemma is the analogue of Lemma \ref{lemma-sequence-maps-split}.

\begin{lemma}
\label{lemma-analogue-sequence-maps-split}
In Situation \ref{situation-ABC}
let $x_1 \to x_2 \to \ldots \to x_n$
be a sequence of composable morphisms in $\text{Comp}(\mathcal{A})$.
Then there exists a commutative diagram in $\text{Comp}(\mathcal{A})$:
$$
\xymatrix{x_1\ar[r] & x_2\ar[r] & \ldots\ar[r] & x_n\\
y_1\ar[r]\ar[u] & y_2\ar[r]\ar[u] & \ldots\ar[r] & y_n\ar[u]}
$$
such that each $y_i\to y_{i+1}$ is an admissible monomorphism
and each $y_i\to x_i$ is a homotopy equivalence.
\end{lemma}

\begin{proof}
The case for $n=1$ is trivial: one simply takes $y_1 = x_1$ and the
identity morphism on $x_1$ is in particular a homotopy equivalence.
The case $n = 2$ is given by Lemma \ref{lemma-factor}. Suppose we have
constructed the diagram up to $x_{n - 1}$. We apply
Lemma \ref{lemma-factor} to the composition
$y_{n - 1} \to x_{n-1} \to x_n$ to obtain $y_n$. Then
$y_{n - 1} \to y_n$ will be an admissible monomorphism, and
$y_n \to x_n$ a homotopy equivalence.
\end{proof}

\noindent
The following lemma is the analogue of Lemma \ref{lemma-nilpotent}.

\begin{lemma}
\label{lemma-triseq}
In Situation \ref{situation-ABC} let $x_i \to y_i \to z_i$
be morphisms in $\mathcal{A}$ ($i=1,2,3$) such that
$x_2 \to y_2\to z_2$ is an admissible short exact sequence.
Let $b : y_1 \to y_2$ and $b' : y_2\to y_3$ be morphisms
in $\text{Comp}(\mathcal{A})$ such that
$$
\vcenter{
\xymatrix{
x_1 \ar[d]_0 \ar[r] &
y_1 \ar[r] \ar[d]_b &
z_1 \ar[d]_0 \\
x_2 \ar[r] & y_2 \ar[r] & z_2
}
}
\quad\text{and}\quad
\vcenter{
\xymatrix{
x_2 \ar[d]^0 \ar[r] &
y_2 \ar[r] \ar[d]^{b'} &
z_2 \ar[d]^0 \\
x_3 \ar[r] & y_3 \ar[r] & z_3
}
}
$$
commute up to homotopy. Then $b'\circ b$ is homotopic to $0$.
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-homo-change}, we can replace $b$ and $b'$
by homotopic maps $\tilde{b}$ and $\tilde{b}'$, such that the right
square of the left diagram commutes and the left square of the right
diagram commutes. Say $b = \tilde{b} + d(h)$ and $b'=\tilde{b}'+d(h')$
for degree $-1$ morphisms $h$ and $h'$ in $\mathcal{A}$. Hence
$$
b'b = \tilde{b}'\tilde{b} + d(\tilde{b}'h + h'\tilde{b} + h'd(h))
$$
since $d(\tilde{b})=d(\tilde{b}')=0$, i.e. $b'b$ is homotopic to
$\tilde{b}'\tilde{b}$. We now want to show that $\tilde{b}'\tilde{b}=0$.
Because $x_2\xrightarrow{f} y_2\xrightarrow{g} z_2$ is an admissible
short exact sequence, there exist degree $0$ morphisms
$\pi : y_2 \to x_2$ and $s : z_2 \to y_2$ such that
$\text{id}_{y_2} = f\pi + sg$. Therefore
$$
\tilde{b}'\tilde{b} = \tilde{b}'(f\pi + sg)\tilde{b} = 0
$$
since $g\tilde{b} = 0$ and $\tilde{b}'f = 0$ as consequences
of the two commuting squares.
\end{proof}

\noindent
The following lemma is the analogue of
Lemma \ref{lemma-triangle-independent-splittings}.

\begin{lemma}
\label{lemma-analogue-triangle-independent-splittings}
In Situation \ref{situation-ABC}
let $0 \to x \to y \to z \to 0$ be an admissible short
exact sequence in $\text{Comp}(\mathcal{A})$. The triangle
$$
\xymatrix{x\ar[r] & y\ar[r] & z\ar[r]^{\delta} & x[1]}
$$
with $\delta : z \to x[1]$ as defined in Lemma \ref{lemma-get-triangle}
is up to canonical isomorphism in $K(\mathcal{A})$, independent of the
choices made in Lemma \ref{lemma-get-triangle}.
\end{lemma}

\begin{proof}
Suppose $\delta$ is defined by the splitting
$$
\xymatrix{
x \ar@<0.5ex>[r]^{a} &
y \ar@<0.5ex>[r]^b\ar@<0.5ex>[l]^{\pi} &
z \ar@<0.5ex>[l]^s
}
$$
and $\delta'$ is defined by the splitting with $\pi',s'$
in place of $\pi,s$. Then
$$
s'-s = (a\pi + sb)(s'-s) = a\pi s'
$$
since $bs' = bs = 1_z$ and $\pi s = 0$. Similarly,
$$
\pi' - \pi = (\pi' - \pi)(a\pi + sb) = \pi'sb
$$
Since $\delta = \pi d(s)$ and $\delta' = \pi'd(s')$
as constructed in Lemma \ref{lemma-get-triangle}, we may compute
$$
\delta' = \pi'd(s') = (\pi + \pi'sb)d(s + a\pi s') = \delta + d(\pi s')
$$
using $\pi a = 1_x$, $ba = 0$, and $\pi'sbd(s') = \pi'sba\pi d(s') = 0$
by formula (5) in Lemma \ref{lemma-get-triangle}.
\end{proof}

\noindent
The following lemma is the analogue of Lemma \ref{lemma-rotate-cone}.

\begin{lemma}
\label{lemma-restate-axiom-c}
In Situation \ref{situation-ABC}
let $f: x \to y$ be a morphism in $\text{Comp}(\mathcal{A})$.
The triangle $(y, c(f), x[1], i, p, f[1])$ is the triangle associated
to the admissible short exact sequence 
$$
\xymatrix{y\ar[r] & c(f) \ar[r] & x[1]}
$$
where the cone $c(f)$ is defined as in Lemma \ref{lemma-get-triangle}.
\end{lemma}

\begin{proof}
This follows from axiom (C).
\end{proof}

\noindent
The following lemma is the analogue of Lemma \ref{lemma-rotate-triangle}.

\begin{lemma}
\label{lemma-cone-rotate-isom}
In Situation \ref{situation-ABC} let $\alpha : x \to y$ and $\beta : y \to z$
define an admissible short exact sequence
$$
\xymatrix{
x \ar[r] &
y\ar[r] &
z
}
$$
in $\text{Comp}(\mathcal{A})$. Let $(x, y, z, \alpha, \beta, \delta)$
be the associated triangle in $K(\mathcal{A})$. Then, the triangles
$$
(z[-1], x, y, \delta[-1], \alpha, \beta)
\quad\text{and}\quad
(z[-1], x, c(\delta[-1]), \delta[-1], i, p)
$$
are isomorphic. 
\end{lemma}

\begin{proof}
We have a diagram of the form
$$
\xymatrix{
z[-1]\ar[r]^{\delta[-1]}\ar[d]^1 &
x\ar@<0.5ex>[r]^{\alpha}\ar[d]^1 &
y\ar@<0.5ex>[r]^{\beta}\ar@{.>}[d]\ar@<0.5ex>[l]^{\tilde{\alpha}} &
z\ar[d]^1\ar@<0.5ex>[l]^{\tilde\beta} \\
z[-1] \ar[r]^{\delta[-1]} &
x\ar@<0.5ex>[r]^i &
c(\delta[-1]) \ar@<0.5ex>[r]^p\ar@<0.5ex>[l]^{\tilde i} &
z\ar@<0.5ex>[l]^{\tilde p}
}
$$
with splittings to $\alpha, \beta, i$, and $p$ given by
$\tilde{\alpha}, \tilde{\beta}, \tilde{i},$ and $\tilde{p}$ respectively.
Define a morphism $y \to c(\delta[-1])$ by
$i\tilde{\alpha} + \tilde{p}\beta$ and a morphism
$c(\delta[-1]) \to y$ by $\alpha \tilde{i} + \tilde{\beta} p$.
Let us first check that these define morphisms in $\text{Comp}(\mathcal{A})$.
We remark that by identities from Lemma \ref{lemma-get-triangle},
we have the relation
$\delta[-1] = \tilde{\alpha}d(\tilde{\beta}) = -d(\tilde{\alpha})\tilde{\beta}$
and the relation $\delta[-1] = \tilde{i}d(\tilde{p})$. Then
\begin{align*}
d(\tilde{\alpha})
& =
d(\tilde{\alpha})\tilde{\beta}\beta \\
& =
-\delta[-1]\beta
\end{align*}
where we have used equation (6) of
Lemma \ref{lemma-get-triangle} for the first equality and
the preceeding remark for the second. Similarly, we obtain
$d(\tilde{p}) = i\delta[-1]$. Hence
\begin{align*}
d(i\tilde{\alpha} + \tilde{p}\beta)
& =
d(i)\tilde{\alpha} + id(\tilde{\alpha}) +
d(\tilde{p})\beta + \tilde{p}d(\beta) \\
& =
id(\tilde{\alpha}) + d(\tilde{p})\beta \\
& =
-i\delta[-1]\beta + i\delta[-1]\beta \\
& =
0
\end{align*}
so $i\tilde{\alpha} + \tilde{p}\beta$ is indeed a morphism of
$\text{Comp}(\mathcal{A})$. By a similar calculation,
$\alpha \tilde{i} + \tilde{\beta} p$ is also a morphism of
$\text{Comp}(\mathcal{A})$. It is immediate that these morphisms
fit in the commutative diagram. We compute:
\begin{align*}
(i\tilde{\alpha} + \tilde{p}\beta)(\alpha \tilde{i} + \tilde{\beta} p)
& =
i\tilde{\alpha}\alpha\tilde{i} + i\tilde{\alpha}\tilde{\beta}p
+ \tilde{p}\beta\alpha\tilde{i} + \tilde{p}\beta\tilde{\beta}p \\
& =
i\tilde{i} + \tilde{p}p \\
& =
1_{c(\delta[-1])}
\end{align*}
where we have freely used the identities of
Lemma \ref{lemma-get-triangle}. Similarly, we compute
$(\alpha \tilde{i} + \tilde{\beta} p)(i\tilde{\alpha} + \tilde{p}\beta) = 1_y$,
so we conclude $y \cong c(\delta[-1])$. Hence, the two triangles in question
are isomorphic.
\end{proof}

\noindent
The following lemma is the analogue of
Lemma \ref{lemma-third-isomorphism}.

\begin{lemma}
\label{lemma-analogue-third-isomorphism}
In Situation \ref{situation-ABC} let $f_1 : x_1 \to y_1$ and
$f_2 : x_2 \to y_2$ be morphisms in $\text{Comp}(\mathcal{A})$. Let 
$$
(a,b,c): (x_1,y_1,c(f_1), f_1, i_1, p_1) \to (x_2,y_2, c(f_2), f_2, i_1, p_1)
$$
be any morphism of triangles in $K(\mathcal{A})$.
If $a$ and $b$ are homotopy equivalences, then so is $c$. 
\end{lemma}

\begin{proof}
Since $a$ and $b$ are homotopy equivalences, they are invertible in
$K(\mathcal{A})$ so let $a^{-1}$ and $b^{-1}$ denote their inverses
in $K(\mathcal{A})$, giving us a commutative diagram 
$$
\xymatrix{
x_2\ar[d]^{a^{-1}}\ar[r]^{f_2} &
y_2\ar[d]^{b^{-1}}\ar[r]^{i_2} &
c(f_2)\ar[d]^{c'} \\
x_1\ar[r]^{f_1} &
y_1 \ar[r]^{i_1} &
c(f_1)
}
$$
where the map $c'$ is defined via Lemma \ref{lemma-cone} applied to the left
commutative box of the above diagram. Since the diagram commutes
in $K(\mathcal{A})$, it suffices by Lemma \ref{lemma-triseq} to
prove the following: given a morphism of triangle
$(1,1,c): (x,y,c(f),f,i,p)\to (x,y,c(f),f,i,p)$
in $K(\mathcal{A})$, the map $c$ is an isomorphism in
$K(\mathcal{A})$. We have the commutative diagrams in $K(\mathcal{A})$:
$$
\vcenter{
\xymatrix{
y\ar[d]^{1}\ar[r] &
c(f)\ar[d]^{c}\ar[r] &
x[1]\ar[d]^{1} \\
y\ar[r] &
c(f) \ar[r] &
x[1]
}
}
\quad\Rightarrow\quad
\vcenter{
\xymatrix{
y\ar[d]^{0}\ar[r] &
c(f)\ar[d]^{c-1}\ar[r] &
x[1]\ar[d]^{0} \\
y\ar[r] &
c(f) \ar[r] &
x[1]
}
}
$$
Since the rows are admissible short exact sequences, we obtain
the identity $(c-1)^2 = 0$ by Lemma \ref{lemma-triseq}, from
which we conclude that $2-c$ is inverse to $c$ in $K(\mathcal{A})$
so that $c$ is an isomorphism. 
\end{proof}

\noindent
The following lemma is the analogue of
Lemma \ref{lemma-the-same-up-to-isomorphisms}.

\begin{lemma}
\label{lemma-cone-homotopy}
In Situation \ref{situation-ABC}.
\begin{enumerate}
\item Given an admissible short exact sequence
$x\xrightarrow{\alpha} y\xrightarrow{\beta} z$.
Then there exists a homotopy equivalence
$e:C(\alpha)\to z$ such that the diagram
\begin{equation}
\label{equation-cone-isom-triangle}
\vcenter{
\xymatrix{
x\ar[r]^{\alpha}\ar[d] &
y\ar[r]^{b}\ar[d] &
C(\alpha)\ar[r]^{-c}\ar@{.>}[d]^{e} &
x[1]\ar[d] \\
x\ar[r]^{\alpha} &
y\ar[r]^{\beta} &
z\ar[r]^{\delta} & x[1]
}
}
\end{equation}
defines an isomorphism of triangles in $K(\mathcal{A})$. Here
$y\xrightarrow{b}C(\alpha)\xrightarrow{c}x[1]$
is the admissible short exact sequence given as in axiom (C).
\item Given a morphism
$\alpha : x \to y$ in $\text{Comp}(\mathcal{A})$, let
$x \xrightarrow{\tilde{\alpha}} \tilde{y} \to y$ be the
factorization given as in Lemma \ref{lemma-factor}, where the admissible
monomorphism $x \xrightarrow{\tilde{\alpha}} y$ extends to the
admissible short exact sequence
$$
\xymatrix{
x \ar[r]^{\tilde{\alpha}} &
\tilde{y} \ar[r] & z
}
$$
Then there exists an isomorphism of triangles
$$
\xymatrix{
x \ar[r]^{\tilde{\alpha}} \ar[d] &
\tilde{y} \ar[r] \ar[d] &
z \ar[r]^{\delta} \ar@{.>}[d]^{e} &
x[1] \ar[d] \\
x \ar[r]^{\alpha} &
y \ar[r] &
C(\alpha) \ar[r]^{-c} &
x[1]
}
$$
where the upper triangle is the triangle
associated to the sequence
$x \xrightarrow{\tilde{\alpha}} \tilde{y} \to z$.
\end{enumerate}
\end{lemma}

\begin{proof}
For (1), we consider the more complete diagram, \emph{without} the
sign change on $c$:
$$
\xymatrix{
x\ar@<0.5ex>[r]^{\alpha} \ar[d] &
y\ar@<0.5ex>[l]^{\pi} \ar@<0.5ex>[r]^{b}\ar[d] &
C(\alpha)\ar@<0.5ex>[l]^{p} \ar@<0.5ex>[r]^{c}\ar@{.>}@<0.5ex>[d]^{e} &
x[1]\ar@<0.5ex>[l]^{\sigma} \ar[d]\ar@<0.5ex>[r]^{\alpha} &
y[1]\ar@<0.5ex>[l]^{\pi} \\
x\ar@<0.5ex>[r]^{\alpha} &
y\ar@<0.5ex>[r]^{\beta} \ar@<0.5ex>[l]^{\pi} &
z\ar[r]^{\delta}\ar@<0.5ex>[l]^{s} \ar@{.>}@<0.5ex>[u]^{f} &
x[1]
}
$$
where the admissible short exact sequence
$x\xrightarrow{\alpha} y\xrightarrow{\beta} z$
is given the splitting $\pi$, $s$, and the admissible short exact sequence
$y\xrightarrow{b}C(\alpha)\xrightarrow{c}x[1]$ is given the splitting
$p$, $\sigma$. Note that (identifying hom-sets under shifting)
$$
\alpha = pd(\sigma) = -d(p)\sigma,\quad
\delta = \pi d(s) = -d(\pi)s
$$
by the construction in Lemma \ref{lemma-get-triangle}.

\medskip\noindent
We define $e=\beta p$ and $f=bs-\sigma\delta$. We first check that they are
morphisms in $\text{Comp}(\mathcal{A})$. To show that $d(e)=\beta d(p)$
vanishes, it suffices to show that $\beta d(p)b$ and $\beta d(p)\sigma$
both vanish, whereas
$$
\beta d(p)b = \beta d(pb) = \beta d(1_y) = 0,\quad
\beta d(p)\sigma = -\beta\alpha = 0
$$
Similarly, to check that $d(f)=bd(s)-d(\sigma)\delta$ vanishes,
it suffices to check the post-compositions by $p$ and $c$ both vanish,
whereas
\begin{align*}
pbd(s) - pd(\sigma)\delta
= &
d(s)-\alpha\delta = d(s)-\alpha\pi d(s) = 0 \\
cbd(s)-cd(\sigma)\delta
= &
-cd(\sigma)\delta = -d(c\sigma)\delta = 0
\end{align*}
The commutativity of left two squares of the
diagram \ref{equation-cone-isom-triangle} follows directly from definition.
Before we prove the commutativity of the right square (up to homotopy),
we first check that $e$ is a homotopy equivalence. Clearly,
$$
ef=\beta p (bs-\sigma\delta)=\beta s=1_z
$$
To check that $fe$ is homotopic to $1_{C(\alpha)}$, we first observe
$$
b\alpha = bpd(\alpha) = d(\sigma),\quad
\alpha c = -d(p)\sigma c = -d(p),\quad
d(\pi)p = d(\pi)s\beta p = -\delta\beta p
$$
Using these identities, we compute
\begin{align*}
1_{C(\alpha)} = &
bp + \sigma c
\quad (\text{from }y \xrightarrow{b} C(\alpha) \xrightarrow{c} x[1]) \\
= &
b(\alpha\pi + s\beta)p + \sigma(\pi\alpha)c
\quad (\text{from }x \xrightarrow{\alpha} y \xrightarrow{\beta} z) \\
= &
d(\sigma)\pi p + bs\beta p - \sigma\pi d(p)
\quad (\text{by the first two identities above}) \\
= &
d(\sigma)\pi p + bs\beta p - \sigma\delta\beta p
+ \sigma\delta\beta p - \sigma\pi d(p) \\
= &
(bs - \sigma\delta)\beta p + d(\sigma)\pi p
- \sigma d(\pi)p - \sigma\pi d(p)\quad
(\text{by the third identity above}) \\
= &
fe + d(\sigma \pi p)
\end{align*}
since $\sigma \in \Hom^{-1}(x, C(\alpha))$
(cf. proof of Lemma \ref{lemma-id-cone-null}).
Hence $e$ and $f$ are homotopy inverses.
Finally, to check that the right square of
diagram \ref{equation-cone-isom-triangle} commutes up to homotopy,
it suffices to check that $-cf=\delta$. This follows from
$$
-cf = -c(bs-\sigma\delta) = c\sigma\delta = \delta
$$
since $cb=0$.

\medskip\noindent
For (2), consider the factorization
$x\xrightarrow{\tilde{\alpha}}\tilde{y}\to y$
given as in Lemma \ref{lemma-factor}, so the second morphism
is a homotopy equivalence. By Lemmas \ref{lemma-cone} and
\ref{lemma-analogue-third-isomorphism}, there
exists an isomorphism of triangles between
$$
x \xrightarrow{\alpha} y \to C(\alpha) \to x[1]
\quad\text{and}\quad
x \xrightarrow{\tilde{\alpha}} \tilde{y} \to C(\tilde{\alpha}) \to x[1]
$$
Since we can compose isomorphisms of triangles, by replacing
$\alpha$ by $\tilde{\alpha}$, $y$ by $\tilde{y}$, and $C(\alpha)$ by
$C(\tilde{\alpha})$, we may assume $\alpha$ is an admissible monomorphism.
In this case, the result follows from (1).
\end{proof}

\noindent
The following lemma is the analogue of
Lemma \ref{lemma-homotopy-category-pre-triangulated}.

\begin{lemma}
\label{lemma-analogue-homotopy-category-pre-triangulated}
In Situation \ref{situation-ABC} the homotopy category $K(\mathcal{A})$
with its natural translation functors and distinguished triangles
is a pre-triangulated category.
\end{lemma}

\begin{proof}
We will verify each of TR1, TR2, and TR3. 

\medskip\noindent
Proof of TR1. By definition every triangle isomorphic to a distinguished
one is distinguished. Since
$$
\xymatrix{x\ar[r]^{1_x} & x\ar[r] & 0}
$$
is an admissible short exact sequence, $(x, x, 0, 1_x, 0, 0)$
is a distinguished triangle. Moreover, given a morphism
$\alpha : x \to y$ in $\text{Comp}(\mathcal{A})$, the triangle
given by $(x, y, c(\alpha), \alpha, i, -p)$ is distinguished by
Lemma \ref{lemma-cone-homotopy}.

\medskip\noindent
Proof of TR2. Let $(x,y,z,\alpha,\beta,\gamma)$ be a triangle and
suppose $(y,z,x[1],\beta,\gamma,-\alpha[1])$ is distinguished.
Then there exists an admissible short exact sequence
$0 \to x' \to y' \to z' \to 0$ such that the associated triangle
$(x',y',z',\alpha',\beta',\gamma')$ is isomorphic to
$(y,z,x[1],\beta,\gamma,-\alpha[1])$. After rotating, we conclude
that $(x,y,z,\alpha,\beta,\gamma)$ is isomorphic to
$(z'[-1],x',y', \gamma'[-1], \alpha',\beta')$. By
Lemma \ref{lemma-cone-rotate-isom},
we deduce that $(z'[-1],x',y', \gamma'[-1], \alpha',\beta')$ is
isomorphic to $(z'[-1],x',c(\gamma'[-1]), \gamma'[-1], i, p)$.
Composing the two isomorphisms with sign changes as indicated in
the following diagram:
$$
\xymatrix@C=3pc{
x\ar[r]^{\alpha}\ar[d] &
y\ar[r]^{\beta}\ar[d] &
z\ar[r]^{\gamma}\ar[d] &
x[1]\ar[d] \\
z'[-1]\ar[r]^{-\gamma'[-1]}\ar[d]_{-1_{z'[-1]}} &
x \ar[r]^{\alpha'}\ar@{=}[d] &
y' \ar[r]^{\beta'} \ar[d] &
z'\ar[d]^{-1_{z'}} \\
z'[-1]\ar[r]^{\gamma'[-1]} &
x \ar[r]^{\alpha'} &
c(\gamma'[-1]) \ar[r]^{-p} &
z'
}
$$
We conclude that $(x,y,z,\alpha,\beta,\gamma)$ is distinguished by
Lemma \ref{lemma-cone-homotopy} (2). Conversely, suppose that
$(x,y,z,\alpha,\beta,\gamma)$ is distinguished, so that by
Lemma \ref{lemma-cone-homotopy} (1), it is isomorphic to a
triangle of the form $(x',y', c(\alpha'), \alpha', i, -p)$
for some morphism $\alpha': x' \to y'$ in $\text{Comp}(\mathcal{A})$.
The rotated triangle $(y,z,x[1],\beta,\gamma, -\alpha[1])$ is
isomorphic to the triangle $(y',c(\alpha'), x'[1], i, -p, -\alpha[1])$
which is isomorphic to $(y',c(\alpha'), x'[1], i, p, \alpha[1])$.
By Lemma \ref{lemma-restate-axiom-c}, this triangle is distinguished,
from which it follows that $(y,z,x[1], \beta,\gamma, -\alpha[1])$
is distinguished.

\medskip\noindent
Proof of TR3: Suppose $(x,y,z, \alpha,\beta,\gamma)$ and
$(x',y',z',\alpha',\beta',\gamma')$ are distinguished triangles
of $\text{Comp}(\mathcal{A})$ and let $f: x \to x'$ and
$g: y \to y'$ be morphisms such that
$\alpha' \circ f = g \circ \alpha$. By
Lemma \ref{lemma-cone-homotopy}, we may assume that
$(x,y,z,\alpha,\beta,\gamma)= (x,y,c(\alpha),\alpha, i, -p)$
and $(x',y',z', \alpha',\beta',\gamma')= (x',y',c(\alpha'), \alpha',i',-p')$.
Now apply Lemma \ref{lemma-cone}
and we are done.
\end{proof}

\noindent
The following lemma is the analogue of Lemma \ref{lemma-two-split-injections}.

\begin{lemma}
\label{lemma-dgc-analogue-tr4}
In Situation \ref{situation-ABC} given admissible monomorphisms
$x \xrightarrow{\alpha} y$, $y \xrightarrow{\beta} z$ in $\mathcal{A}$,
there exist distinguished triangles
$(x,y,q_1,\alpha,p_1,\delta_1)$, $(x,z,q_2,\beta\alpha,p_2,\delta_2)$
and $(y,z,q_3,\beta,p_3,\delta_3)$ for which TR4 holds.
\end{lemma}

\begin{proof}
Given admissible monomorphisms $x\xrightarrow{\alpha} y$ and
$y\xrightarrow{\beta}z$, we can find distinguished triangles,
via their extensions to admissible short exact sequences,
$$
\xymatrix{
x\ar@<0.5ex>[r]^{\alpha} &
y\ar@<0.5ex>[l]^{\pi_1} \ar@<0.5ex>[r]^{p_1} &
q_1 \ar[r]^{\delta_1} \ar@<0.5ex>[l]^{s_1} &
x[1]
}
$$
$$
\xymatrix{
x\ar@<0.5ex>[r]^{\beta\alpha} &
z\ar@<0.5ex>[l]^{\pi_1\pi_3} \ar@<0.5ex>[r]^{p_2} &
q_2 \ar[r]^{\delta_2} \ar@<0.5ex>[l]^{s_2} &
x[1]
}
$$
$$
\xymatrix{
y\ar@<0.5ex>[r]^{\beta} &
z\ar@<0.5ex>[l]^{\pi_3} \ar@<0.5ex>[r]^{p_3} &
q_3 \ar[r]^{\delta_3} \ar@<0.5ex>[l]^{s_3} &
x[1]
}
$$
In these diagrams, the maps $\delta_i$ are defined as
$\delta_i = \pi_i d(s_i)$ analagous to the maps defined in
Lemma \ref{lemma-get-triangle}.
They fit in the following solid commutative diagram
$$
\xymatrix@C=5pc@R=3pc{
x\ar@<0.5ex>[r]^{\alpha} \ar@<0.5ex>[dr]^{\beta\alpha} &
y\ar@<0.5ex>[d]^{\beta} \ar@<0.5ex>[l]^{\pi_1} \ar@<0.5ex>[r]^{p_1} &
q_1 \ar[r]^{\delta_1} \ar@<0.5ex>[l]^{s_1} \ar@{.>}[dd]^{p_2\beta s_1} &
x[1] \\
 &
z \ar@<0.5ex>[u]^{\pi_3}\ar@<0.5ex>[d]^{p_3}
\ar@<0.5ex>[dr]^{p_2} \ar@<0.5ex>[ul]^{\pi_1\pi_3} & & \\
 &
q_3\ar@<0.5ex>[u]^{s_3} \ar[d]^{\delta_3} &
q_2 \ar@{.>}[l]^{p_3s_2} \ar@<0.5ex>[ul]^{s_2} \ar[dr]^{\delta_2} \\
 &
y[1] & & x[1]}
$$
where we have defined the dashed arrows as indicated.
Clearly, their composition $p_3s_2p_2\beta s_1 = 0$
since $s_2p_2 = 0$. We claim that they both are morphisms of
$\text{Comp}(\mathcal{A})$. We can check this using equations in
Lemma \ref{lemma-get-triangle}:
$$
d(p_2\beta s_1) = p_2\beta d(s_1) = p_2\beta\alpha\pi_1 d(s_1) = 0
$$
since $p_2\beta\alpha = 0$, and
$$
d(p_3s_2) = p_3d(s_2) = p_3\beta\alpha\pi_1\pi_3 d(s_2) = 0
$$
since $p_3\beta = 0$. To check that $q_1\to q_2\to q_3$
is an admissible short exact sequence, it remains to show
that in the underlying graded category, $q_2 = q_1\oplus q_3$
with the above two morphisms as coprojection and projection.
To do this, observe that in the underlying graded category
$\mathcal{C}$, there hold
$$
y = x\oplus q_1,\quad
z = y\oplus q_3 = x\oplus q_1\oplus q_3
$$
where $\pi_1\pi_3$ gives the projection morphism onto the first
factor: $x\oplus q_1\oplus q_3\to z$. By axiom (A) on
$\mathcal{A}$, $\mathcal{C}$ is an additive category, hence
we may apply
Homology, Lemma \ref{homology-lemma-additive-cat-biproduct-kernel}
and conclude that
$$
\Ker(\pi_1\pi_3) = q_1\oplus q_3
$$
in $\mathcal{C}$. Another application of
Homology, Lemma \ref{homology-lemma-additive-cat-biproduct-kernel}
to $z = x\oplus q_2$ gives $\Ker(\pi_1\pi_3) = q_2$.
Hence $q_2\cong q_1\oplus q_3$ in $\mathcal{C}$.
It is clear that the dashed morphisms defined above give
coprojection and projection.

\medskip\noindent
Finally, we have to check that the morphism
$\delta : q_3 \to q_1[1]$ induced by the admissible
short exact sequence $q_1\to q_2\to q_3$ agrees with
$p_1\delta_3$. By the construction in
Lemma \ref{lemma-get-triangle}, the morphism $\delta$ is given by
\begin{align*}
p_1\pi_3s_2d(p_2s_3)
= &
p_1\pi_3s_2p_2d(s_3) \\
= &
p_1\pi_3(1-\beta\alpha\pi_1\pi_3)d(s_3) \\
= &
p_1\pi_3d(s_3)\quad (\text{since }\pi_3\beta = 0) \\
= &
p_1\delta_3
\end{align*}
as desired. The proof is complete.
\end{proof}

\noindent
Putting everything together we finally obtain the analogue
of Proposition \ref{proposition-homotopy-category-triangulated}.

\begin{proposition}
\label{proposition-ABC-homotopy-category-triangulated}
In Situation \ref{situation-ABC} the homotopy category $K(\mathcal{A})$
with its natural translation functors and distinguished triangles is a
triangulated category.
\end{proposition}

\begin{proof}
By Lemma \ref{lemma-analogue-homotopy-category-pre-triangulated} we know that
$K(\mathcal{A})$ is pre-triangulated. Combining
Lemmas \ref{lemma-analogue-sequence-maps-split} and
\ref{lemma-dgc-analogue-tr4} with
Derived Categories, Lemma \ref{derived-lemma-easier-axiom-four},
we conclude that $K(\mathcal{A})$ is a triangulated category.
\end{proof}

\begin{lemma}
\label{lemma-functor-between-ABC}
Let $R$ be a ring. Let $F : \mathcal{A} \to \mathcal{B}$ be a functor
between differential graded categories over $R$ satisfying axioms
(A), (B), and (C) such that $F(x[1]) = F(x)[1]$.
Then $F$ induces an exact functor
$K(\mathcal{A}) \to K(\mathcal{B})$ of triangulated categories.
\end{lemma}

\begin{proof}
Namely, if $x \to y \to z$ is an admissible short exact sequence
in $\text{Comp}(\mathcal{A})$, then $F(x) \to F(y) \to F(z)$
is an admissible short exact sequence in $\text{Comp}(\mathcal{B})$.
Moreover, the ``boundary'' morphism $\delta = \pi\text{d}(s) : z \to x[1]$
constructed in Lemma \ref{lemma-get-triangle} produces the morphism
$F(\delta) : F(z) \to F(x[1]) = F(x)[1]$ which is equal to the boundary
map $F(\pi) \text{d}(F(s))$ for the admissible short exact sequence
$F(x) \to F(y) \to F(z)$.
\end{proof}





\section{Bimodules}
\label{section-bimodules}

\noindent
We continue the discussion started in Section \ref{section-tensor-product}.

\begin{definition}
\label{definition-bimodule}
Bimodules. Let $R$ be a ring.
\begin{enumerate}
\item Let $A$ and $B$ be $R$-algebras. An {\it $(A, B)$-bimodule}
is an $R$-module $M$ equippend with $R$-bilinear maps
$$
A \times M \to M, (a, x) \mapsto ax
\quad\text{and}\quad
M \times B \to M, (x, b) \mapsto xb
$$
such that the following hold
\begin{enumerate}
\item $a'(ax) = (a'a)x$ and $(xb)b' = x(bb')$,
\item $a(xb) = (ax)b$, and
\item $1 x = x = x 1$.
\end{enumerate}
\item Let $A$ and $B$ be $\mathbf{Z}$-graded $R$-algebras. A
{\it graded $(A, B)$-bimodule} is an $(A, B)$-bimodule $M$ which
has a grading $M = \bigoplus M^n$ such that
$A^n M^m \subset M^{n + m}$ and $M^n B^m \subset M^{n + m}$.
\item Let $A$ and $B$ be differential graded $R$-algebras. A
{\it differential graded $(A, B)$-bimodule} is a graded $(A, B)$-bimodule
which comes equipped with a differential
$\text{d} : M \to M$ homogeneous of degree $1$
such that $\text{d}(ax) = \text{d}(a)x + (-1)^{\deg(a)}a\text{d}(x)$ and
$\text{d}(xb) = \text{d}(x)b + (-1)^{\deg(x)}x\text{d}(b)$
for homogeneous elements $a \in A$, $x \in M$, $b \in B$.
\end{enumerate}
\end{definition}

\noindent
Observe that a differential graded $(A, B)$-bimodule
$M$ is the same thing as a right differential graded
$B$-module which is also a left differential graded
$A$-module such that the grading and differentials agree
and such that the $A$-module structure commutes with
the $B$-module structure. Here is a precise statement.

\begin{lemma}
\label{lemma-what-makes-a-bimodule-dg}
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$ be
differential graded algebras over $R$. Let $M$ be a right differential
graded $B$-module. There is a $1$-to-$1$ correspondence
between $(A, B)$-bimodule structures on $M$ compatible with the given
differential graded $B$-module structure and homomorphisms
$$
A
\longrightarrow
\Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(M, M)
$$
of differential graded $R$-algebras.
\end{lemma}

\begin{proof}
Let $\mu : A \times M \to M$ define a left differential graded $A$-module
structure on the underlying complex of $R$-modules $M^\bullet$ of $M$.
By Lemma \ref{lemma-left-module-structure} the structure $\mu$ corresponds
to a map $\gamma : A \to \Hom^\bullet(M^\bullet, M^\bullet)$
of differential graded $R$-algebras. The assertion of the lemma is simply
that $\mu$ commutes with the $B$-action, if and only if $\gamma$ ends
up inside
$$
\Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(M, M) \subset
\Hom^\bullet(M^\bullet, M^\bullet)
$$
We omit the detailed calculation.
\end{proof}

\noindent
Let $M$ be a differential graded $(A, B)$-bimodule. Recall from
Section \ref{section-left-modules} that the left differential graded
$A$-module structure corresponds to a right differential graded
$A^{opp}$-module structure. Since the $A$ and $B$ module structures
commute this gives $M$ the structure of a differential graded
$A^{opp} \otimes_R B$-module:
$$
x \cdot (a \otimes b) = (-1)^{\deg(a)\deg(x)} axb
$$
Conversely, if we have a differential graded $A^{opp} \otimes_R B$-module
$M$, then we can use the formula above to get a differential graded
$(A, B)$-bimodule.

\begin{lemma}
\label{lemma-bimodule-over-tensor}
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$
be differential graded algebras over $R$. The construction above
defines an equivalence of categories
$$
\begin{matrix}
\text{differential graded}\\
(A, B)\text{-bimodules}
\end{matrix}
\longleftrightarrow
\begin{matrix}
\text{right differential graded }\\
A^{opp} \otimes_R B\text{-modules}
\end{matrix}
$$
\end{lemma}

\begin{proof}
Immediate from discussion the above.
\end{proof}

\noindent
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$ be
differential graded $R$-algebras.
Let $P$ be a differential graded $(A, B)$-bimodule. We say $P$
{\it has property (P)} if it there exists a filtration
$$
0 = F_{-1}P \subset F_0P \subset F_1P \subset \ldots \subset P
$$
by differential graded $(A, B)$-bimodules such that
\begin{enumerate}
\item $P = \bigcup F_pP$,
\item the inclusions $F_iP \to F_{i + 1}P$ are split as graded
$(A, B)$-bimodule maps,
\item the quotients $F_{i + 1}P/F_iP$ are isomorphic as differential
graded $(A, B)$-bimodules to a direct sum of $(A \otimes_R B)[k]$.
\end{enumerate}

\begin{lemma}
\label{lemma-bimodule-resolve}
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$ be
differential graded $R$-algebras. Let $M$ be a differential graded
$(A, B)$-bimodule. There exists a homomorphism $P \to M$
of differential graded $(A, B)$-bimodules which is a quasi-isomorphism
such that $P$ has property (P) as defined above.
\end{lemma}

\begin{proof}
Immediate from Lemmas \ref{lemma-bimodule-over-tensor} and
\ref{lemma-resolve}.
\end{proof}

\begin{lemma}
\label{lemma-bimodule-property-P-sequence}
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$ be
differential graded $R$-algebras. Let $P$ be a
differential graded $(A, B)$-bimodule having property (P)
with corresponding filtration $F_\bullet$, then we obtain a
short exact sequence
$$
0 \to
\bigoplus\nolimits F_iP \to
\bigoplus\nolimits F_iP \to P \to 0
$$
of differential graded $(A, B)$-bimodules which is split as a sequence
of graded $(A, B)$-bimodules.
\end{lemma}

\begin{proof}
Immediate from Lemmas \ref{lemma-bimodule-over-tensor} and
\ref{lemma-property-P-sequence}.
\end{proof}















\section{Bimodules and tensor product}
\label{section-bimodules-tensor}

\noindent
Let $R$ be a ring. Let $A$ and $B$ be $R$-algebras. Let $M$ be a right
$A$-module. Let $N$ be a $(A, B)$-bimodule. Then
$M \otimes_A N$ is a right $B$-module.

\medskip\noindent
If in the situation of the previous paragraph
$A$ and $B$ are $\mathbf{Z}$-graded algebras,
$M$ is a graded $A$-module, and $N$ is a graded $(A, B)$-bimodule,
then $M \otimes_A N$ is a right graded $B$-module. The construction
is functorial in $M$ and defines a functor
$$
- \otimes_A N :
\text{Mod}^{gr}_A
\longrightarrow
\text{Mod}^{gr}_B
$$
of graded categories as in Example \ref{example-gm-gr-cat}. Namely, if
$M$ and $M'$ are graded $A$-modules and $f : M \to M'$ is an $A$-module
homomorphism homogeneous of degree $n$, then
$f \otimes \text{id}_N : M \otimes_A N \to M' \otimes_A N$
is a $B$-module homomorphism homogeneous of degree $n$.

\medskip\noindent
If in the situation of the previous paragraph
$(A, \text{d})$ and $(B, \text{d})$ are differential graded algebras,
$M$ is a differential graded $A$-module, and $N$ is a differential
graded $(A, B)$-bimodule, then $M \otimes_A N$ is a right
differential graded $B$-module.

\begin{lemma}
\label{lemma-tensor}
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$
be differential graded algebras over $R$. Let $N$ be a
differential graded $(A, B)$-bimodule. Then
$M \mapsto M \otimes_A N$ defines a functor
$$
- \otimes_A N :
\text{Mod}^{dg}_{(A, \text{d})}
\longrightarrow
\text{Mod}^{dg}_{(B, \text{d})}
$$
of differential graded categories. This functor induces functors
$$
\text{Mod}_{(A, \text{d})} \to \text{Mod}_{(B, \text{d})}
\quad\text{and}\quad
K(\text{Mod}_{(A, \text{d})}) \to K(\text{Mod}_{(B, \text{d})})
$$
by an application of Lemma \ref{lemma-functorial}.
\end{lemma}

\begin{proof}
Above we have seen how the construction defines a functor of underlying
graded categories. Thus it suffices to show that the construction is
compatible with differentials. Let $M$ and $M'$ be differential
graded $A$-modules and let $f : M \to M'$ be an $A$-module homomorphism
which is homogeneous of degree $n$. Then we have
$$
\text{d}(f) = \text{d}_{M'} \circ f - (-1)^n f \circ \text{d}_M
$$
On the other hand, we have
$$
\text{d}(f \otimes \text{id}_N) =
\text{d}_{M' \otimes_A N} \circ
(f \otimes \text{id}_N)
- (-1)^n
(f \otimes \text{id}_N) \circ \text{d}_{M \otimes_A N}
$$
Applying this to an element $x \otimes y$ with $x \in M$ and
$y \in N$ homogeneous we get
\begin{align*}
\text{d}(f \otimes \text{id}_N)(x \otimes y)
= &
\text{d}_{M'}(f(x)) \otimes y + (-1)^{n + \deg(x)}f(x) \otimes \text{d}_N(y) \\
& - (-1)^n f(\text{d}_M(x)) \otimes y
- (-1)^{n + \deg(x)}f(x) \otimes \text{d}_N(y) \\
= &
\text{d}(f) (x \otimes y)
\end{align*}
Thus we see that $\text{d}(f) \otimes \text{id}_N =
\text{d}(f \otimes \text{id}_N)$ and the proof is complete.
\end{proof}

\begin{remark}
\label{remark-shift-tensor-no-sign}
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$
be differential graded algebras over $R$. Let $N$ be a
differential graded $(A, B)$-bimodule. Let $M$ be a right differential
graded $A$-module. Then for every $k \in \mathbf{Z}$ there
is an isomorphism
$$
(M \otimes_A N)[k] \longrightarrow
M[k] \otimes_A N
$$
of right differential graded $B$-modules defined without the intervention
of signs, see More on Algebra, Section \ref{more-algebra-section-sign-rules}.
\end{remark}

\noindent
If we have a ring $R$ and $R$-algebras $A$, $B$, and $C$,
a right $A$-module $M$, an $(A, B)$-bimodule $N$, and a
$(B, C)$-bimodule $N'$, then
$N \otimes_B N'$ is a $(A, C)$-bimodule and we have
$$
(M \otimes_A N) \otimes_B N' = M \otimes_A (N \otimes_B N')
$$
This equality continuous to hold in the graded and in the differential
graded case. See More on Algebra, Section \ref{more-algebra-section-sign-rules}
for sign rules.






\section{Bimodules and internal hom}
\label{section-bimodules-hom}

\noindent
Let $R$ be a ring. If $A$ is an $R$-algebra (see our conventions
in Section \ref{section-conventions}) and $M$, $M'$ are right
$A$-modules, then we define
$$
\Hom_A(M, M') = \{f : M \to M' \mid f \text{ is }A\text{-linear}\}
$$
as usual.

\medskip\noindent
Let $R$-be a ring. Let $A$ and $B$ be $R$-algebras. Let
$N$ be an $(A, B)$-bimodule. Let $N'$ be a right $B$-module.
In this situation we will think of
$$
\Hom_B(N, N')
$$
as a right $A$-module using precomposition.

\medskip\noindent
Let $R$-be a ring. Let $A$ and $B$ be $\mathbf{Z}$-graded $R$-algebras. Let
$N$ be a graded $(A, B)$-bimodule. Let $N'$ be a right graded $B$-module.
In this situation we will think of the graded $R$-module
$$
\Hom_{\text{Mod}^{gr}_B}(N, N')
$$
defined in Example \ref{example-gm-gr-cat} as a right graded $A$-module
using precomposition. The construction is functorial in $N'$ and defines
a functor
$$
\Hom_{\text{Mod}^{gr}_B}(N, -) :
\text{Mod}^{gr}_B
\longrightarrow
\text{Mod}^{gr}_A
$$
of graded categories as in Example \ref{example-gm-gr-cat}. Namely, if
$N_1$ and $N_2$ are graded $B$-modules and $f : N_1 \to N_2$ is a $B$-module
homomorphism homogeneous of degree $n$, then the induced map
$\Hom_{\text{Mod}^{gr}_B}(N, N_1) \to \Hom_{\text{Mod}^{gr}_B}(N, N_2)$
is an $A$-module homomorphism homogeneous of degree $n$.

\medskip\noindent
Let $R$ be a ring. Let $A$ and $B$ be differential $\mathbf{Z}$-graded
$R$-algebras. Let $N$ be a differential graded $(A, B)$-bimodule.
Let $N'$ be a right differential graded $B$-module. In this situation
we will think of the differential graded $R$-module
$$
\Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(N, N')
$$
defined in Example \ref{example-dgm-dg-cat} as a right differential
graded $A$-module using precomposition as in the graded case. This
is compatible with differentials because multiplication is the
composition
$$
\Hom_{\text{Mod}^{dg}_B}(N, N') \otimes_R A \to
\Hom_{\text{Mod}^{dg}_B}(N, N') \otimes_R
\Hom_{\text{Mod}^{dg}_B}(N, N) \to
\Hom_{\text{Mod}^{dg}_B}(N, N')
$$
The first arrow uses the map
of Lemma \ref{lemma-what-makes-a-bimodule-dg} and the second
arrow is the composition in the differential graded category
$\text{Mod}^{dg}_{(B, \text{d})}$.

\begin{lemma}
\label{lemma-hom}
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$
be differential graded algebras over $R$. Let $N$ be a
differential graded $(A, B)$-bimodule. The construction above
defines a functor
$$
\Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(N, -) :
\text{Mod}^{dg}_{(B, \text{d})}
\longrightarrow
\text{Mod}^{dg}_{(A, \text{d})}
$$
of differential graded categories. This functor induces functors
$$
\text{Mod}_{(B, \text{d})} \to \text{Mod}_{(A, \text{d})}
\quad\text{and}\quad
K(\text{Mod}_{(B, \text{d})}) \to K(\text{Mod}_{(A, \text{d})})
$$
by an application of Lemma \ref{lemma-functorial}.
\end{lemma}

\begin{proof}
Above we have seen how the construction defines a functor of underlying
graded categories. Thus it suffices to show that the construction is
compatible with differentials. Let $N_1$ and $N_2$ be differential
graded $B$-modules. Write
$$
H_{12} = \Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(N_1, N_2),\quad
H_1 = \Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(N, N_1),\quad
H_2 = \Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(N, N_2)
$$
Consider the composition
$$
c : H_{12} \otimes_R H_1 \longrightarrow H_2
$$
in the differential graded category $\text{Mod}^{dg}_{(B, \text{d})}$.
Let $f : N_1 \to N_2$ be a $B$-module homomorphism which is homogeneous
of degree $n$, in other words, $f \in H_{12}^n$.
The functor in the lemma sends $f$ to $c_f : H_1 \to H_2$, $g \mapsto c(f, g)$.
Simlarly for $\text{d}(f)$. On the other hand, the differential on
$$
\Hom_{\text{Mod}^{dg}_{(A, \text{d})}}(H_1, H_2)
$$
sends $c_f$ to $\text{d}_{H_2} \circ c_f - (-1)^n c_f \circ \text{d}_{H_1}$.
As $c$ is a morphism of complexes of $R$-modules we have
$\text{d} c(f, g) = c(\text{d}f, g) + (-1)^n c(f, \text{d}g)$.
Hence we see that
\begin{align*}
(\text{d}c_f)(g)
& =
\text{d}c(f,g) - (-1)^n c(f, \text{d}g) \\
& =
c(\text{d}f, g) + (-1)^n c(f, \text{d}g)  - (-1)^n c(f, \text{d}g) \\
& =
c(\text{d}f, g) = c_{\text{d}f}(g)
\end{align*}
and the proof is complete.
\end{proof}

\begin{remark}
\label{remark-shift-hom-no-sign}
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$
be differential graded algebras over $R$. Let $N$ be a
differential graded $(A, B)$-bimodule. Let $N'$ be a right differential
graded $B$-module. Then for every $k \in \mathbf{Z}$ there
is an isomorphism
$$
\Hom_{\text{Mod}^{gr}_B}(N, N')[k]
\longrightarrow
\Hom_{\text{Mod}^{gr}_B}(N, N'[k])
$$
of right differential graded $A$-modules defined without the intervention
of signs, see More on Algebra, Section \ref{more-algebra-section-sign-rules}.
\end{remark}

\begin{lemma}
\label{lemma-tensor-hom-adjunction}
Let $R$ be a ring. Let $A$ and $B$ be $R$-algebras.
Let $M$ be a right $A$-module, $N$ an $(A, B)$-bimodule, and
$N'$ a right $B$-module. Then we have a canonical isomorphism
$$
\Hom_B(M \otimes_A N, N') = \Hom_A(M, \Hom_B(N, N'))
$$
of $R$-modules.
If $A$, $B$, $M$, $N$, $N'$ are compatibly graded, then we have a
canonical isomorphism
$$
\Hom_{\text{Mod}_B^{gr}}(M \otimes_A N, N') =
\Hom_{\text{Mod}_A^{gr}}(M, \Hom_{\text{Mod}_B^{gr}}(N, N'))
$$
of graded $R$-modules
If $A$, $B$, $M$, $N$, $N'$ are compatibly differential graded, then
we have a canonical isomorphism
$$
\Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(M \otimes_A N, N') =
\Hom_{\text{Mod}^{dg}_{(A, \text{d})}}(M,
\Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(N, N'))
$$
of complexes of $R$-modules.
\end{lemma}

\begin{proof}
Omitted. Hint: in the ungraded case interpret both sides as $A$-bilinear maps
$\psi : M \times N \to N'$ which are $B$-linear on the right.
In the (differential) graded case, use the isomorphism of
More on Algebra, Lemma \ref{more-algebra-lemma-compose}
and check it is compatible with the module structures.
Alternatively, use the isomorphism of Lemma \ref{lemma-characterize-hom}
and show that it is compatible with the $B$-module structures.
\end{proof}







\section{Derived Hom}
\label{section-restriction}

\noindent
This section is analogous to
More on Algebra, Section \ref{more-algebra-section-RHom}.

\medskip\noindent
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$
be differential graded algebras over $R$. Let $N$ be a
differential graded $(A, B)$-bimodule. Consider the functor
\begin{equation}
\label{equation-restriction}
\Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(N, -) :
\text{Mod}_{(B, \text{d})}
\longrightarrow
\text{Mod}_{(A, \text{d})}
\end{equation}
of Section \ref{section-bimodules-hom}.

\begin{lemma}
\label{lemma-restriction-homotopy}
The functor (\ref{equation-restriction}) defines an exact functor
$K(\text{Mod}_{(B, \text{d})}) \to K(\text{Mod}_{(A, \text{d})})$
of triangulated categories.
\end{lemma}

\begin{proof}
Via Lemma \ref{lemma-hom} and
Remark \ref{remark-shift-hom-no-sign}
this follows from the general principle of
Lemma \ref{lemma-functor-between-ABC}.
\end{proof}

\noindent
Recall that we have an exact functor
of triangulated categories
$$
\Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(N, -) :
K(\text{Mod}_{(B, \text{d})}) \to K(\text{Mod}_{(A, \text{d})})
$$
see Lemma \ref{lemma-restriction-homotopy}. Consider the diagram
$$
\xymatrix{
K(\text{Mod}_{(B, \text{d})}) \ar[d] \ar[rr]_{\text{see above}} \ar[rrd]_F & &
K(\text{Mod}_{(A, \text{d})}) \ar[d] \\
D(B, \text{d}) \ar@{..>}[rr] & &
D(A, \text{d})
}
$$
We would like to construct a dotted arrow as the
{\it right derived functor} of the composition $F$.
({\it Warning}: in most interesting cases the diagram will not commute.)
Namely, in the general setting of
Derived Categories, Section \ref{derived-section-derived-functors}
we want to compute the
right derived functor of $F$ with respect to the multiplicative system of
quasi-isomorphisms in $K(\text{Mod}_{(A, \text{d})})$.

\begin{lemma}
\label{lemma-derived-restriction}
In the situation above, the right derived functor of $F$ exists.
We denote it $R\Hom(N, -) : D(B, \text{d}) \to D(A, \text{d})$.
\end{lemma}

\begin{proof}
We will use
Derived Categories, Lemma \ref{derived-lemma-find-existence-computes}
to prove this. As our collection $\mathcal{I}$
of objects we will use the objects with property (I).
Property (1) was shown in Lemma \ref{lemma-right-resolution}.
Property (2) holds because if $s : I \to I'$ is a quasi-isomorphism
of modules with property (I), then $s$ is a homotopy equivalence
by Lemma \ref{lemma-hom-derived}.
\end{proof}

\begin{lemma}
\label{lemma-functoriality-derived-restriction}
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$ be
differential graded $R$-algebras. Let $f : N \to N'$ be a
homomorphism of differential graded $(A, B)$-bimodules.
Then $f$ induces a morphism of functors
$$
- \circ f : R\Hom(N', -) \longrightarrow R\Hom(N, -)
$$
If $f$ is a quasi-isomorphism, then $f \circ -$ is an isomorphism of
functors.
\end{lemma}

\begin{proof}
Write $\mathcal{B} = \text{Mod}^{dg}_{(B, \text{d})}$ the
differential graded category of differential graded $B$-modules, see
Example \ref{example-dgm-dg-cat}.
Let $I$ be a differential graded $B$-module with property (I).
Then $f \circ - : \Hom_\mathcal{B}(N', I) \to \Hom_\mathcal{B}(N, I)$
is a map of differential graded $A$-modules. Moreover, this is functorial
with respect to $I$. Since the functors
$ R\Hom(N', -)$ and $R\Hom(N, -)$ are
computed by applying $\Hom_\mathcal{B}$ into objects with property (I)
(Lemma \ref{lemma-derived-restriction}) we obtain a transformation of functors
as indicated.

\medskip\noindent
Assume that $f$ is a quasi-isomorphism. Let $F_\bullet$ be the
given filtration on $I$. Since $I = \lim I/F_pI$ we see that
$\Hom_\mathcal{B}(N', I) = \lim \Hom_\mathcal{B}(N', I/F_pI)$ and
$\Hom_\mathcal{B}(N, I) = \lim \Hom_\mathcal{B}(N, I/F_pI)$.
Since the transition maps in the system $I/F_pI$ are split
as graded modules, we see that the transition maps in the
systems $\Hom_\mathcal{B}(N', I/F_pI)$ and $\Hom_\mathcal{B}(N, I/F_pI)$
are surjective. Hence $\Hom_\mathcal{B}(N', I)$, resp. $\Hom_\mathcal{B}(N, I)$
viewed as a complex of abelian groups computes $R\lim$ of the system
of complexes
$\Hom_\mathcal{B}(N', I/F_pI)$, resp. $\Hom_\mathcal{B}(N, I/F_pI)$.
See More on Algebra, Lemma \ref{more-algebra-lemma-compute-Rlim}.
Thus it suffices to prove each
$$
\Hom_\mathcal{B}(N', I/F_pI) \to \Hom_\mathcal{B}(N, I/F_pI)
$$
is a quasi-isomorphism. Since the surjections $I/F_{p + 1}I \to I/F_pI$
are split as maps of graded $B$-modules we see that
$$
0 \to \Hom_\mathcal{B}(N', F_pI/F_{p + 1}I) \to
\Hom_\mathcal{B}(N', I/F_{p + 1}I) \to
\Hom_\mathcal{B}(N', I/F_pI) \to 0
$$
is a short exact sequence of differential graded $A$-modules.
There is a similar sequence for $N$ and $f$ induces a map
of short exact sequences. Hence by induction on $p$ (starting with $p = 0$
when $I/F_0I = 0$) we conclude that it suffices to show that
the map
$\Hom_\mathcal{B}(N', F_pI/F_{p + 1}I) \to \Hom_\mathcal{B}(N, F_pI/F_{p + 1}I)$
is a quasi-isomorphism. Since $F_pI/F_{p + 1}I$ is a product of shifts of
$A^\vee$ it suffice to prove
$\Hom_\mathcal{B}(N', B^\vee[k]) \to \Hom_\mathcal{B}(N, B^\vee[k])$
is a quasi-isomorphism. By Lemma \ref{lemma-hom-into-shift-dual-free}
it suffices to show $(N')^\vee \to N^\vee$ is a quasi-isomorphism.
This is true because $f$ is a quasi-isomorphism and $(\ )^\vee$
is an exact functor.
\end{proof}

\begin{lemma}
\label{lemma-derived-restriction-exts}
Let $(A, \text{d})$ and $(B, \text{d})$ be differential graded algebras
over a ring $R$. Let $N$ be a differential graded $(A, B)$-bimodule.
Then for every $n \in \mathbf{Z}$ there are isomorphisms
$$
H^n(R\Hom(N, M)) = \Ext^n_{D(B, \text{d})}(N, M)
$$
of $R$-modules functorial in $M$. It is also functorial in $N$
with respect to the operation described in
Lemma \ref{lemma-functoriality-derived-restriction}.
\end{lemma}

\begin{proof}
In the proof of Lemma \ref{lemma-derived-restriction}
we have seen
$$
R\Hom(N, M) = 
\Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(N, I)
$$
as a differential graded $A$-module
where $M \to I$ is a quasi-isomorphism of $M$ into a differential
graded $B$-module with property (I). Hence this complex has the
correct cohomology modules by Lemma \ref{lemma-hom-derived}.
We omit a discussion of the functorial nature of these
identifications.
\end{proof}

\begin{lemma}
\label{lemma-compute-derived-restriction}
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$ be
differential graded $R$-algebras. Let $N$ be a differential
graded $(A, B)$-bimodule. If
$\Hom_{D(B, \text{d})}(N, N') = \Hom_{K(\text{Mod}_{(B, \text{d})})}(N, N')$
for all $N' \in K(B, \text{d})$, for example if $N$
has property (P) as a differential graded $B$-module, then
$$
R\Hom(N, M) = \Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(N, M)
$$
functorially in $M$ in $D(B, \text{d})$.
\end{lemma}

\begin{proof}
By construction (Lemma \ref{lemma-derived-restriction})
to find $R\Hom(N, M)$ we choose a quasi-isomorphism
$M \to I$ where $I$ is a differential graded $B$-module
with property (I) and we set
$R\Hom(N, M) = \Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(N, I)$.
By assumption the map
$$
\Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(N, M) \longrightarrow
\Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(N, I)
$$
induced by $M \to I$ is a quasi-isomorphism, see discussion in
Example \ref{example-dgm-dg-cat}. This proves the lemma.
If $N$ has property (P) as a $B$-module, then we see that the
assumption is satisfied by Lemma \ref{lemma-hom-derived}.
\end{proof}




\section{Variant of derived Hom}
\label{section-variant}

\noindent
Let $\mathcal{A}$ be an abelian category. Consider the differential graded
category $\text{Comp}^{dg}(\mathcal{A})$ of complexes of $\mathcal{A}$, see
Example \ref{example-category-complexes}.
Let $K^\bullet$ be a complex of $\mathcal{A}$. Set
$$
(E, \text{d}) = \Hom_{\text{Comp}^{dg}(\mathcal{A})}(K^\bullet, K^\bullet)
$$
and consider the functor of differential graded categories
$$
\text{Comp}^{dg}(\mathcal{A}) \longrightarrow \text{Mod}^{dg}_{(E, \text{d})},
\quad
X^\bullet
\longmapsto
\Hom_{\text{Comp}^{dg}(\mathcal{A})}(K^\bullet, X^\bullet)
$$
of Lemma \ref{lemma-construction}.

\begin{lemma}
\label{lemma-existence-of-derived}
In the situation above. If the right derived functor $R\Hom(K^\bullet, -)$
of $\Hom(K^\bullet, -) : K(\mathcal{A}) \to D(\textit{Ab})$
is everywhere defined on $D(\mathcal{A})$, then we obtain a canonical exact
functor
$$
R\Hom(K^\bullet, -) : D(\mathcal{A}) \longrightarrow D(E, \text{d})
$$
of triangulated categories which reduces to the usual one  on taking
associated complexes of abelian groups.
\end{lemma}

\begin{proof}
Note that we have an associated functor
$K(\mathcal{A}) \to K(\text{Mod}_{(E, \text{d})})$ by
Lemma \ref{lemma-construction}.
We claim this functor is an exact functor of triangulated categories.
Namely, let $f : A^\bullet \to B^\bullet$ be a map of complexes
of $\mathcal{A}$. Then a computation shows that
$$
\Hom_{\text{Comp}^{dg}(\mathcal{A})}(K^\bullet, C(f)^\bullet)
=
C\left(
\Hom_{\text{Comp}^{dg}(\mathcal{A})}(K^\bullet, A^\bullet) \to
\Hom_{\text{Comp}^{dg}(\mathcal{A})}(K^\bullet, B^\bullet)
\right)
$$
where the right hand side is the cone in $\text{Mod}_{(E, \text{d})}$
defined earlier in this chapter.
This shows that our functor is compatible with cones, hence with
distinguished triangles. Let $X^\bullet$ be an object of $K(\mathcal{A})$.
Consider the category of quasi-isomorphisms $s : X^\bullet \to Y^\bullet$.
We are given that the functor
$(s : X^\bullet \to Y^\bullet) \mapsto \Hom_\mathcal{A}(K^\bullet, Y^\bullet)$
is essentially constant when viewed in $D(\textit{Ab})$.
But since the forgetful functor $D(E, \text{d}) \to D(\textit{Ab})$
is compatible with taking cohomology, the same thing is true in
$D(E, \text{d})$. This proves the lemma.
\end{proof}

\noindent
{\bf Warning:} Although the lemma holds as stated and may be useful
as stated, the differential algebra $E$ isn't the ``correct'' one unless
$H^n(E) = \Ext^n_{D(\mathcal{A})}(K^\bullet, K^\bullet)$
for all $n \in \mathbf{Z}$.





\section{Derived tensor product}
\label{section-base-change}

\noindent
This section is analogous to More on Algebra, Section
\ref{more-algebra-section-derived-base-change}.

\medskip\noindent
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$ be
differential graded algebras over $R$. Let $N$ be a
differential graded $(A, B)$-bimodule. Consider the functor
\begin{equation}
\label{equation-bc}
\text{Mod}_{(A, \text{d})}
\longrightarrow
\text{Mod}_{(B, \text{d})},\quad
M \longmapsto M \otimes_A N
\end{equation}
defined in Section \ref{section-bimodules-tensor}.

\begin{lemma}
\label{lemma-bc-homotopy}
The functor (\ref{equation-bc}) defines an exact functor
of triangulated categories
$K(\text{Mod}_{(A, \text{d})}) \to K(\text{Mod}_{(B, \text{d})})$.
\end{lemma}

\begin{proof}
Via Lemma \ref{lemma-tensor} and
Remark \ref{remark-shift-tensor-no-sign}
this follows from the general principle of
Lemma \ref{lemma-functor-between-ABC}.
\end{proof}

\noindent
At this point we can consider the diagram
$$
\xymatrix{
K(\text{Mod}_{(A, \text{d})}) \ar[d] \ar[rr]_{- \otimes_A N} \ar[rrd]_F & &
K(\text{Mod}_{(B, \text{d})}) \ar[d] \\
D(A, \text{d}) \ar@{..>}[rr] & &
D(B, \text{d})
}
$$
The dotted arrow that we will construct below will be the
{\it left derived functor} of the composition $F$.
({\it Warning}: the diagram will not commute.)
Namely, in the general setting of
Derived Categories, Section \ref{derived-section-derived-functors}
we want to compute the
left derived functor of $F$ with respect to the multiplicative system of
quasi-isomorphisms in $K(\text{Mod}_{(A, \text{d})})$.

\begin{lemma}
\label{lemma-derived-bc}
In the situation above, the left derived functor of $F$ exists.
We denote it
$- \otimes_A^\mathbf{L} N : D(A, \text{d}) \to D(B, \text{d})$.
\end{lemma}

\begin{proof}
We will use
Derived Categories, Lemma \ref{derived-lemma-find-existence-computes}
to prove this. As our collection $\mathcal{P}$
of objects we will use the objects with property (P).
Property (1) was shown in Lemma \ref{lemma-resolve}.
Property (2) holds because if $s : P \to P'$ is a quasi-isomorphism
of modules with property (P), then $s$ is a homotopy equivalence
by Lemma \ref{lemma-hom-derived}.
\end{proof}

\begin{lemma}
\label{lemma-functoriality-bc}
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$ be
differential graded $R$-algebras. Let $f : N \to N'$ be a
homomorphism of differential graded $(A, B)$-bimodules.
Then $f$ induces a morphism of functors
$$
1\otimes f :
- \otimes_A^\mathbf{L} N
\longrightarrow
- \otimes_A^\mathbf{L} N'
$$
If $f$ is a quasi-isomorphism, then $1 \otimes f$ is an isomorphism of
functors.
\end{lemma}

\begin{proof}
Let $M$ be a differential graded $A$-module with property (P).
Then $1 \otimes f : M \otimes_A N \to M \otimes_A N'$ is a
map of differential graded $B$-modules. Moreover, this is functorial
with respect to $M$. Since the functors
$- \otimes_A^\mathbf{L} N$ and $- \otimes_A^\mathbf{L} N'$ are
computed by tensoring on objects with property (P)
(Lemma \ref{lemma-derived-bc}) we obtain a transformation of functors
as indicated.

\medskip\noindent
Assume that $f$ is a quasi-isomorphism. Let $F_\bullet$ be the
given filtration on $M$. Observe that
$M \otimes_A N = \colim F_i(M) \otimes_A N$ and
$M \otimes_A N' = \colim F_i(M) \otimes_A N'$.
Hence it suffices to show that
$F_n(M) \otimes_A N \to F_n(M) \otimes_A N'$
is a quasi-isomorphism (filtered colimits are exact, see
Algebra, Lemma \ref{algebra-lemma-directed-colimit-exact}).
Since the inclusions $F_n(M) \to F_{n + 1}(M)$
are split as maps of graded $A$-modules we see that
$$
0 \to F_n(M) \otimes_A N \to F_{n + 1}(M) \otimes_A N \to
F_{n + 1}(M)/F_n(M) \otimes_A N \to 0
$$
is a short exact sequence of differential graded $B$-modules.
There is a similar sequence for $N'$ and $f$ induces a map
of short exact sequences. Hence by induction on $n$ (starting with $n = -1$
when $F_{-1}(M) = 0$) we conclude that it suffices to show that
the map $F_{n + 1}(M)/F_n(M) \otimes_A N \to F_{n + 1}(M)/F_n(M) \otimes_A N'$
is a quasi-isomorphism. This is true because $F_{n + 1}(M)/F_n(M)$
is a direct sum of shifts of $A$ and the result is true for $A[k]$
as $f : N \to N'$ is a quasi-isomorphism.
\end{proof}

\begin{lemma}
\label{lemma-compute-bc}
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$ be
differential graded $R$-algebras. Let $N$ be a differential graded
$(A, B)$-bimodule which has property (P) as a left differential graded
$A$-module. Then $M \otimes_A^\mathbf{L} N$ is computed by
$M \otimes_A N$ for all differential graded $A$-modules $M$.
\end{lemma}

\begin{proof}
Let $f : M \to M'$ be a homomorphism of differential graded $A$-modules
which is a quasi-isomorphism. We claim that $f \otimes \text{id} :
M \otimes_A N \to M' \otimes_A N$ is a quasi-isomorphism. If this
is true, then by the construction of the derived tensor product
in the proof of Lemma \ref{lemma-derived-bc} we obtain the desired result.
The construction of the map $f \otimes \text{id}$ only depends
on the left differential graded $A$-module structure on $N$.
Moreover, we have $M \otimes_A N = N \otimes_{A^{opp}} M =
N \otimes_{A^{opp}}^\mathbf{L} M$ because $N$ has property (P) as
a differential graded $A^{opp}$-module. Hence the claim follows
from Lemma \ref{lemma-functoriality-bc}.
\end{proof}

\begin{lemma}
\label{lemma-tensor-hom-adjoint}
Let $R$ be a ring.
Let $(A, \text{d})$ and $(B, \text{d})$ be differential graded $R$-algebras.
Let $N$ be a differential graded $(A, B)$-bimodule.
Then the functor
$$
- \otimes_A^\mathbf{L} N : D(A, \text{d}) \longrightarrow D(B, \text{d})
$$
of Lemma \ref{lemma-derived-bc} is a left adjoint to the functor
$$
R\Hom(N, -) : D(B, \text{d}) \longrightarrow D(A, \text{d})
$$
of Lemma \ref{lemma-derived-restriction}.
\end{lemma}

\begin{proof}
This follows from Derived Categories, Lemma
\ref{derived-lemma-pre-derived-adjoint-functors-general}
and the fact that $- \otimes_A N$ and
$\Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(N, -)$ are adjoint by
Lemma \ref{lemma-tensor-hom-adjunction}.
\end{proof}

\begin{example}
\label{example-map-hom-tensor}
Let $R$ be a ring. Let $(A, \text{d}) \to (B, \text{d})$ be a
homomorphism of differential graded $R$-algebras. Then we can
view $B$ as a differential graded $(A, B)$-bimodule and we get a functor
$$
- \otimes_A B : D(A, \text{d}) \longrightarrow D(B, \text{d})
$$
By Lemma \ref{lemma-tensor-hom-adjoint} the left adjoint of this
is the functor $R\Hom(B, -)$. For a differential graded $B$-module
let us denote $N_A$ the differential graded $A$-module obtained
from $N$ by restriction via $A \to B$. Then we clearly have
a canonical isomorphism
$$
\Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(B, N) \longrightarrow N_A,\quad
f \longmapsto f(1)
$$
functorial in the $B$-module $N$. Thus we see that
$R\Hom(B, -)$ is the restriction functor and we obtain
$$
\Hom_{D(A, \text{d})}(M, N_A) =
\Hom_{D(B, \text{d})}(M \otimes^\mathbf{L}_A B, N)
$$
bifunctorially in $M$ and $N$ exactly as in the case of commutative rings.
Finally, observe that restriction is a tensor functor as well,
since $N_A = N \otimes_B {}_BB_A = N \otimes_B^\mathbf{L} {}_BB_A$
where ${}_BB_A$ is $B$ viewed as a differential graded $(B, A)$-bimodule.
\end{example}

\begin{lemma}
\label{lemma-tensor-with-compact-fully-faithful}
With notation and assumptions as in Lemma \ref{lemma-tensor-hom-adjoint}.
Assume
\begin{enumerate}
\item $N$ defines a compact object of $D(B, \text{d})$, and
\item the map $H^k(A) \to \Hom_{D(B, \text{d})}(N, N[k])$ is an
isomorphism for all $k \in \mathbf{Z}$.
\end{enumerate}
Then the functor $-\otimes_A^\mathbf{L} N$ is fully faithful.
\end{lemma}

\begin{proof}
Our functor has a left adjoint given by
$R\Hom(N, -)$ by Lemma \ref{lemma-tensor-hom-adjoint}.
By Categories, Lemma \ref{categories-lemma-adjoint-fully-faithful}
it suffices to show that for a differential graded $A$-module $M$
the map
$$
M \longrightarrow R\Hom(N, M \otimes_A^\mathbf{L} N)
$$
is an isomorphism in $D(A, \text{d})$. For this it suffices to show that
$$
H^n(M) \longrightarrow
\text{Ext}^n_{D(B, \text{d})}(N, M \otimes_A^\mathbf{L} N)
$$
is an isomorphism, see Lemma \ref{lemma-derived-restriction-exts}.
Since $N$ is a compact object the right hand side commutes
with direct sums. Thus by Remark \ref{remark-P-resolution}
it suffices to prove this map is an isomorphism for $M = A[k]$.
Since $(A[k] \otimes_A^\mathbf{L} N) = N[k]$ by
Remark \ref{remark-shift-tensor-no-sign},
assumption (2) on $N$ is that the result holds for these.
\end{proof}

\begin{lemma}
\label{lemma-base-change-K-flat}
Let $R \to R'$ be a ring map. Let $(A, \text{d})$ be a differential
graded $R$-algebra. Let $(A', \text{d})$ be the base change, i.e.,
$A' = A \otimes_R R'$. If $A$ is K-flat as a complex of $R$-modules,
then
\begin{enumerate}
\item $- \otimes_A^\mathbf{L} A' : D(A, \text{d}) \to D(A', \text{d})$
is equal to the right derived functor of
$$
K(A, \text{d}) \longrightarrow K(A', \text{d}),\quad
M \longmapsto M \otimes_R R'
$$
\item the diagram
$$
\xymatrix{
D(A, \text{d}) \ar[r]_{- \otimes_A^\mathbf{L} A'} \ar[d]_{restriction} &
D(A', \text{d}) \ar[d]^{restriction} \\
D(R) \ar[r]^{- \otimes_R^\mathbf{L} R'} & D(R')
}
$$
commutes, and
\item if $M$ is K-flat as a complex of $R$-modules, then the
differential graded $A'$-module $M \otimes_R R'$ represents
$M \otimes_A^\mathbf{L} A'$.
\end{enumerate}
\end{lemma}

\begin{proof}
For any differential graded $A$-module $M$ there is a canonical map
$$
c_M : M \otimes_R R' \longrightarrow M \otimes_A A'
$$
Let $P$ be a differential graded $A$-module with property (P).
We claim that $c_P$ is an isomorphism and that $P$ is K-flat
as a complex of $R$-modules. This will prove all the results
stated in the lemma by formal arguments using the definition
of derived tensor product in Lemma \ref{lemma-derived-bc} and
More on Algebra, Section \ref{more-algebra-section-derived-tensor-product}.

\medskip\noindent
Let $F_\bullet$ be the filtration on $P$ showing that $P$ has property (P).
Note that $c_A$ is an isomorphism and $A$ is K-flat as a complex
of $R$-modules by assumption. Hence the same is true for
direct sums of shifts of $A$ (you can use
More on Algebra, Lemma \ref{more-algebra-lemma-colimit-K-flat}
to deal with direct sums if you like).
Hence this holds for the complexes $F_{p + 1}P/F_pP$.
Since the short exact sequences
$$
0 \to F_pP \to F_{p + 1}P \to F_{p + 1}P/F_pP \to 0
$$
are split exact as sequences of graded modules, we can argue
by induction that $c_{F_pP}$ is an isomorphism for all $p$
and that $F_pP$ is K-flat as a complex of $R$-modules (use
More on Algebra, Lemma \ref{more-algebra-lemma-K-flat-two-out-of-three}).
Finally, using that $P = \colim F_pP$ we conclude that
$c_P$ is an isomorphism and that $P$ is K-flat
as a complex of $R$-modules (use
More on Algebra, Lemma \ref{more-algebra-lemma-colimit-K-flat}).
\end{proof}

\begin{lemma}
\label{lemma-RHom-is-tensor}
Let $R$ be a ring.
Let $(A, \text{d})$ and $(B, \text{d})$ be differential graded $R$-algebras.
Let $T$ be a differential graded $(A, B)$-bimodule.
Assume
\begin{enumerate}
\item $T$ defines a compact object of $D(B, \text{d})$, and
\item $S = \Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(T, B)$
represents $R\Hom(T, B)$ in $D(A, \text{d})$.
\end{enumerate}
Then $S$ has a structure of a differential graded $(B, A)$-bimodule
and there is an isomorphism
$$
N \otimes_B^\mathbf{L} S \longrightarrow R\Hom(T, N)
$$
functorial in $N$ in $D(B, \text{d})$.
\end{lemma}

\begin{proof}
Write $\mathcal{B} = \text{Mod}^{dg}_{(B, \text{d})}$.
The right $A$-module structure on $S$ comes from the map
$A \to \Hom_\mathcal{B}(T, T)$ and the composition
$\Hom_\mathcal{B}(T, B) \otimes \Hom_\mathcal{B}(T, T)
\to \Hom_\mathcal{B}(T, B)$ defined in Example \ref{example-dgm-dg-cat}.
Using this multiplication a second time there is a map
$$
c_N :
N \otimes_B S = \Hom_\mathcal{B}(B, N) \otimes_B \Hom_\mathcal{B}(T, B)
\longrightarrow
\Hom_\mathcal{B}(T, N)
$$
functorial in $N$. Given $N$ we can choose quasi-isomorphisms
$P \to N \to I$ where $P$, resp.\ $I$ is a differential graded $B$-module
with property (P), resp.\ (I). Then using $c_N$ we obtain a map
$P \otimes_B S \to \Hom_\mathcal{B}(T, I)$ between the objects
representing $S \otimes_B^\mathbf{L} N$ and $R\Hom(T, N)$.
Clearly this defines a transformation of functors $c$ as in the lemma.

\medskip\noindent
To prove that $c$ is an isomorphism of functors, we may
assume $N$ is a differential graded $B$-module which
has property (P). Since $T$ defines a compact object in
$D(B, \text{d})$ and since both sides of the arrow define
exact functors of triangulated categories, we reduce using
Lemma \ref{lemma-property-P-sequence}
to the case where $N$ has a finite filtration whose
graded pieces are direct sums of $B[k]$. Using again that
both sides of the arrow are exact functors of triangulated
categories and compactness of $T$ we reduce to
the case $N = B[k]$. Assumption (2) is exactly the
assumption that $c$ is an isomorphism in this case.
\end{proof}






\section{Composition of derived tensor products}
\label{section-compose-tensor-functors}

\noindent
We encourage the reader to skip this section.

\medskip\noindent
Let $R$ be a ring. Let $(A, \text{d})$, $(B, \text{d})$, and
$(C, \text{d})$ be differential graded $R$-algebras.
Let $N$ be a differential graded $(A, B)$-bimodule.
Let $N'$ be a differential graded $(B, C)$-module.
We denote $N_B$ the bimodule $N$ viewed as a differential graded
$B$-module (forgetting about the $A$-structure). There is a canonical map
\begin{equation}
\label{equation-plain-versus-derived}
N_B \otimes_B^\mathbf{L} N'
\longrightarrow
(N \otimes_B N')_C
\end{equation}
in $D(C, \text{d})$. Here $(N \otimes_B N')_C$ denotes the
$(A, C)$-bimodule $N \otimes_B N'$ viewed as a
differential graded $C$-module. Namely, this map
comes from the fact that the derived tensor product always maps to the
plain tensor product (as it is a left derived functor).

\begin{lemma}
\label{lemma-compose-tensor-functors-general}
Let $R$ be a ring. Let $(A, \text{d})$, $(B, \text{d})$, and
$(C, \text{d})$ be differential graded $R$-algebras.
Let $N$ be a differential graded $(A, B)$-bimodule.
Let $N'$ be a differential graded $(B, C)$-module.
Assume (\ref{equation-plain-versus-derived}) is an isomorphism.
Then the composition
$$
\xymatrix{
D(A, \text{d}) \ar[rr]^{- \otimes_A^\mathbf{L} N} & &
D(B, \text{d}) \ar[rr]^{- \otimes_B^\mathbf{L} N'} & &
D(C, \text{d})
}
$$
is isomorphic to $- \otimes_A^\mathbf{L} N''$ with
$N'' = N \otimes_B N'$ viewed as $(A, C)$-bimodule.
\end{lemma}

\begin{proof}
Let us define a transformation of functors
$$
(- \otimes_A^\mathbf{L} N) \otimes_B^\mathbf{L} N'
\longrightarrow
- \otimes_A^\mathbf{L} N''
$$
To do this, let
$M$ be a differential graded $A$-module with property (P).
According to the construction of the functor $- \otimes_A^\mathbf{L} N''$
of the proof of Lemma \ref{lemma-derived-bc} the plain tensor
product $M \otimes_A N''$ represents $M \otimes_A^\mathbf{L} N''$
in $D(C, \text{d})$. Then we write
$$
M \otimes_A N'' =
M \otimes_A (N \otimes_B N') =
(M \otimes_A N) \otimes_B N'
$$
The module $M \otimes_A N$ represents $M \otimes_A^\mathbf{L} N$
in $D(B, \text{d})$. Choose a quasi-isomorphism $Q \to M \otimes_A N$
where $Q$ is a differential graded $B$-module with property (P). Then
$Q \otimes_B N'$ represents
$(M \otimes_A^\mathbf{L} N) \otimes_B^\mathbf{L} N'$ in
$D(C, \text{d})$.
Thus we can define our map via
$$
(M \otimes_A^\mathbf{L} N) \otimes_B^\mathbf{L} N' =
Q \otimes_B N' \to
M \otimes_A N \otimes_B N' =
M \otimes_A^\mathbf{L} N''
$$
The construction of this map is functorial in $M$ and compatible
with distinguished triangles and direct sums; we omit the details.
Consider the property $T$ of objects $M$ of $D(A, \text{d})$ 
expressing that this map is an isomorphism. Then
\begin{enumerate}
\item if $T$ holds for $M_i$ then $T$ holds for $\bigoplus M_i$,
\item if $T$ holds for $2$-out-of-$3$ in a distinguished
triangle, then it holds for the third, and
\item $T$ holds for $A[k]$ because here we obtain a shift
of the map (\ref{equation-plain-versus-derived}) which we
have assumed is an isomorphism.
\end{enumerate}
Thus by Remark \ref{remark-P-resolution} property $T$
always holds and the proof is complete.
\end{proof}

\noindent
Let $R$ be a ring. Let $(A, \text{d})$, $(B, \text{d})$, and
$(C, \text{d})$ be differential graded $R$-algebras.
We temporarily denote $(A \otimes_R B)_B$ the differential
graded algebra $A \otimes_R B$ viewed as a (right) differential
graded $B$-module, and ${}_B(B \otimes_R C)_C$ the differential
graded algebra $B \otimes_R C$ viewed as a differential graded
$(B, C)$-bimodule. Then there is a canonical map
\begin{equation}
\label{equation-plain-versus-derived-algebras}
(A \otimes_R B)_B \otimes_B^\mathbf{L} {}_B(B \otimes_R C)_C
\longrightarrow
(A \otimes_R B \otimes_R C)_C
\end{equation}
in $D(C, \text{d})$ where $(A \otimes_R B \otimes_R C)_C$
denotes the differential
graded $R$-algebra $A \otimes_R B \otimes_R C$ viewed as a
(right) differential graded $C$-module. Namely, this map
comes from the identification
$$
(A \otimes_R B)_B \otimes_B {}_B(B \otimes_R C)_C =
(A \otimes_R B \otimes_R C)_C
$$
and the fact that the derived tensor product always maps to the
plain tensor product (as it is a left derived functor).

\begin{lemma}
\label{lemma-compose-tensor-functors-general-algebra}
Let $R$ be a ring. Let $(A, \text{d})$, $(B, \text{d})$, and
$(C, \text{d})$ be differential graded $R$-algebras. Assume
that (\ref{equation-plain-versus-derived-algebras}) is an isomorphism.
Let $N$ be a differential graded $(A, B)$-bimodule.
Let $N'$ be a differential graded $(B, C)$-bimodule.
Then the composition
$$
\xymatrix{
D(A, \text{d}) \ar[rr]^{- \otimes_A^\mathbf{L} N} & &
D(B, \text{d}) \ar[rr]^{- \otimes_B^\mathbf{L} N'} & &
D(C, \text{d})
}
$$
is isomorphic to $- \otimes_A^\mathbf{L} N''$ for a differential graded
$(A, C)$-bimodule $N''$ described in the proof.
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-functoriality-bc} we may replace $N$ and $N'$ by
quasi-isomorphic bimodules. Thus we may assume $N$, resp.\ $N'$
has property (P) as differential graded
$(A, B)$-bimodule, resp.\ $(B, C)$-bimodule, see
Lemma \ref{lemma-bimodule-resolve}. We claim the lemma holds
with the $(A, C)$-bimodule $N'' = N \otimes_B N'$.
To prove this, it suffices to show that
$$
N_B \otimes_B^\mathbf{L} N' \longrightarrow (N \otimes_B N')_C
$$
is an isomorphism in $D(C, \text{d})$, see
Lemma \ref{lemma-compose-tensor-functors-general}.

\medskip\noindent
Let $F_\bullet$ be the filtration on $N$ as in property (P) for bimodules.
By Lemma \ref{lemma-bimodule-property-P-sequence}
there is a short exact sequence
$$
0 \to
\bigoplus\nolimits F_iN \to
\bigoplus\nolimits F_iN \to N \to 0
$$
of differential graded $(A, B)$-bimodules which is split as a sequence
of graded $(A, B)$-bimodules. A fortiori this is an admissible short exact
sequence of differential graded $B$-modules and this produces a distinguished
triangle
$$
\bigoplus\nolimits F_iN_B \to
\bigoplus\nolimits F_iN_B \to N_B \to
\bigoplus\nolimits F_iN_B[1]
$$
in $D(B, \text{d})$. Using that $- \otimes_B^\mathbf{L} N'$
is an exact functor of triangulated categories and commutes
with direct sums and using that $- \otimes_B N'$ transforms
admissible exact sequences into admissible exact sequences
and commutes with direct sums we reduce to proving
that
$$
(F_pN)_B \otimes_B^\mathbf{L} N' \longrightarrow (F_pN)_B \otimes_B N'
$$
is a quasi-isomorphism for all $p$. Repeating the argument
with the short exact sequences of $(A, B)$-bimodules
$$
0 \to F_pN \to F_{p + 1}N \to F_{p + 1}N/F_pN \to 0
$$
which are split as graded $(A, B)$-bimodules
we reduce to showing the same statement for $F_{p + 1}N/F_pN$.
Since these modules are direct sums of shifts of $(A \otimes_R B)_B$
we reduce to showing that
$$
(A \otimes_R B)_B \otimes_B^\mathbf{L} N'
\longrightarrow
(A \otimes_R B)_B \otimes_B N'
$$
is a quasi-isomorphism.

\medskip\noindent
Choose a filtration $F_\bullet$ on $N'$ as in property (P) for bimodules.
Choose a quasi-isomorphism $P \to (A \otimes_R B)_B$
of differential graded $B$-modules where $P$ has property (P).
We have to show that
$P \otimes_B N' \to (A \otimes_R B)_B \otimes_B N'$ is
a quasi-isomorphism because $P \otimes_B N'$ represents
$(A \otimes_R B)_B \otimes_B^\mathbf{L} N'$ in $D(C, \text{d})$
by the construction in Lemma \ref{lemma-derived-bc}.
As $N' = \colim F_pN'$ we find
that it suffices to show that
$P \otimes_B F_pN' \to (A \otimes_R B)_B \otimes_B F_pN'$
is a quasi-isomorphism. Using the short exact sequences
$0 \to F_pN' \to F_{p + 1}N' \to F_{p + 1}N'/F_pN' \to 0$
which are split as graded $(B, C)$-bimodules we reduce to showing
$P \otimes_B F_{p + 1}N'/F_pN' \to
(A \otimes_R B)_B \otimes_B F_{p + 1}N'/F_pN'$
is a quasi-isomorphism for all $p$.
Then finally using that $F_{p + 1}N'/F_pN'$
is a direct sum of shifts of ${}_B(B \otimes_R C)_C$
we conclude that it suffices to show that
$$
P \otimes_B {}_B(B \otimes_R C)_C \to
(A \otimes_R B)_B \otimes_B {}_B(B \otimes_R C)_C
$$
is a quasi-isomorphism. Since $P \to (A \otimes_R B)_B$
is a resolution by a module satisfying property (P)
this map of differential graded $C$-modules
represents the morphism (\ref{equation-plain-versus-derived-algebras})
in $D(C, \text{d})$ and the proof is complete.
\end{proof}

\begin{lemma}
\label{lemma-compose-tensor-functors}
Let $R$ be a ring. Let $(A, \text{d})$, $(B, \text{d})$, and
$(C, \text{d})$ be differential graded $R$-algebras.
If $C$ is K-flat as a complex of $R$-modules, then
(\ref{equation-plain-versus-derived-algebras})
is an isomorphism and the conclusion of
Lemma \ref{lemma-compose-tensor-functors-general-algebra} is valid.
\end{lemma}

\begin{proof}
Choose a quasi-isomorphism $P \to (A \otimes_R B)_B$ of differential
graded $B$-modules, where $P$ has property (P). Then we have to show
that
$$
P \otimes_B (B \otimes_R C) \longrightarrow
(A \otimes_R B) \otimes_B (B \otimes_R C)
$$
is a quasi-isomorphism. Equivalently we are looking at
$$
P \otimes_R C \longrightarrow
A \otimes_R B \otimes_R C
$$
This is a quasi-isomorphism if $C$ is K-flat as a complex of $R$-modules by
More on Algebra, Lemma \ref{more-algebra-lemma-K-flat-quasi-isomorphism}.
\end{proof}





\section{Variant of derived tensor product}
\label{section-variant-base-change}

\noindent
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site. Then we have the functors
$$
\text{Comp}(\mathcal{O}) \to K(\mathcal{O}) \to D(\mathcal{O})
$$
and as we've seen above we have differential graded enhancement
$\text{Comp}^{dg}(\mathcal{O})$. Namely, this is the differential
graded category of Example \ref{example-category-complexes} associated
to the abelian category $\textit{Mod}(\mathcal{O})$.
Let $K^\bullet$ be a complex of $\mathcal{O}$-modules in other
words, an object of $\text{Comp}^{dg}(\mathcal{O})$. Set
$$
(E, \text{d}) =
\Hom_{\text{Comp}^{dg}(\mathcal{O})}(K^\bullet, K^\bullet)
$$
This is a differential graded $\mathbf{Z}$-algebra. We claim there is
an analogue of the derived base change in this situation.

\begin{lemma}
\label{lemma-tensor-with-complex}
In the situation above there is a functor
$$
- \otimes_E K^\bullet :
\text{Mod}^{dg}_{(E, \text{d})}
\longrightarrow
\text{Comp}^{dg}(\mathcal{O})
$$
of differential graded categories. This functor sends $E$ to $K^\bullet$
and commutes with direct sums.
\end{lemma}

\begin{proof}
Let $M$ be a differential graded $E$-module. For every object $U$ of
$\mathcal{C}$ the complex $K^\bullet(U)$ is a left differential
graded $E$-module as well as a right $\mathcal{O}(U)$-module.
The actions commute, so we have a bimodule.
Thus, by the constructions in
Sections \ref{section-tensor-product} and \ref{section-bimodules}
we can form the tensor product
$$
M \otimes_E K^\bullet(U)
$$
which is a differential graded $\mathcal{O}(U)$-module, i.e., a complex
of $\mathcal{O}(U)$-modules. This construction is functorial with respect
to $U$, hence we can sheafify to get a complex of $\mathcal{O}$-modules
which we denote
$$
M \otimes_E K^\bullet
$$
Moreover, for each $U$ the construction determines a functor
$\text{Mod}^{dg}_{(E, \text{d})} \to \text{Comp}^{dg}(\mathcal{O}(U))$
of differential graded categories by Lemma \ref{lemma-tensor}.
It is therefore clear that we obtain a functor as stated in the lemma.
\end{proof}

\begin{lemma}
\label{lemma-tensor-with-complex-homotopy}
The functor of Lemma \ref{lemma-tensor-with-complex} defines an exact functor
of triangulated categories
$K(\text{Mod}_{(E, \text{d})}) \to K(\mathcal{O})$.
\end{lemma}

\begin{proof}
The functor induces a functor between homotopy categories by
Lemma \ref{lemma-functorial}.
We have to show that $- \otimes_E K^\bullet$ transforms distinguished
triangles into distinguished triangles.
Suppose that $0 \to K \to L \to M \to 0$ is an admissible short
exact sequence of differential graded $E$-modules. Let $s : M \to L$ be
a graded $E$-module homomorphism which is left inverse to $L \to M$.
Then $s$ defines a map $M \otimes_E K^\bullet \to L \otimes_E K^\bullet$
of graded $\mathcal{O}$-modules (i.e., respecting $\mathcal{O}$-module
structure and grading, but not differentials)
which is left inverse to $L \otimes_E K^\bullet \to M \otimes_E K^\bullet$.
Thus we see that
$$
0 \to K \otimes_E K^\bullet \to L \otimes_E K^\bullet \to
M \otimes_E K^\bullet \to 0
$$
is a termwise split short exact sequences of complexes, i.e., a
defines a distinguished triangle in $K(\mathcal{O})$.
\end{proof}

\begin{lemma}
\label{lemma-tensor-with-complex-derived}
The functor $K(\text{Mod}_{(E, \text{d})}) \to K(\mathcal{O})$
of Lemma \ref{lemma-tensor-with-complex-homotopy} has a left derived
version defined on all of $D(E, \text{d})$. We denote it
$- \otimes_E^\mathbf{L} K^\bullet : D(E, \text{d}) \to D(\mathcal{O})$.
\end{lemma}

\begin{proof}
We will use
Derived Categories, Lemma \ref{derived-lemma-find-existence-computes}
to prove this. As our collection $\mathcal{P}$
of objects we will use the objects with property (P).
Property (1) was shown in Lemma \ref{lemma-resolve}.
Property (2) holds because if $s : P \to P'$ is a quasi-isomorphism
of modules with property (P), then $s$ is a homotopy equivalence
by Lemma \ref{lemma-hom-derived}.
\end{proof}

\begin{lemma}
\label{lemma-upgrade-tensor-with-complex-derived}
Let $R$ be a ring. Let $\mathcal{C}$ be a site. Let $\mathcal{O}$
be a sheaf of commutative $R$-algebras. Let $K^\bullet$
be a complex of $\mathcal{O}$-modules.
The functor
of Lemma \ref{lemma-tensor-with-complex-derived} has the following
property: For every $M$, $N$ in $D(E, \text{d})$ there is a
canonical map
$$
R\Hom(M, N)
\longrightarrow
R\Hom_\mathcal{O}(M \otimes_E^\mathbf{L} K^\bullet,
N \otimes_E^\mathbf{L} K^\bullet)
$$
in $D(R)$ which on cohomology modules gives the maps
$$
\Ext^n_{D(E, \text{d})}(M, N) \to
\Ext^n_{D(\mathcal{O})}
(M \otimes_E^\mathbf{L} K^\bullet, N \otimes_E^\mathbf{L} K^\bullet)
$$
induced by the functor $- \otimes_E^\mathbf{L} K^\bullet$.
\end{lemma}

\begin{proof}
The right hand side of the arrow is the global derived hom introduced
in Cohomology on Sites, Section \ref{sites-cohomology-section-global-RHom}
which has the correct cohomology modules.
For the left hand side we think of $M$ as a $(R, A)$-bimodule and
we have the derived $\Hom$ introduced in Section \ref{section-restriction}
which also has the correct cohomology modules.
To prove the lemma we may assume $M$ and $N$ are differential graded
$E$-modules with property (P); this does not change the left hand
side of the arrow by
Lemma \ref{lemma-functoriality-derived-restriction}.
By Lemma \ref{lemma-compute-derived-restriction}
this means that the left hand side of the arrow becomes
$\Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(M, N)$.
In Lemmas \ref{lemma-tensor-with-complex},
\ref{lemma-tensor-with-complex-homotopy}, and
\ref{lemma-tensor-with-complex-derived}
we have constructed a functor
$$
- \otimes_E K^\bullet :
\text{Mod}^{dg}_{(E, \text{d})}
\longrightarrow
\text{Comp}^{dg}(\mathcal{O})
$$
of differential graded categories
and we have shown that $- \otimes_E^\mathbf{L} K^\bullet$ is computed
by evaluating this functor
on differential graded $E$-modules with property (P).
Hence we obtain a map of complexes of $R$-modules
$$
\Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(M, N)
\longrightarrow
\Hom_{\text{Comp}^{dg}(\mathcal{O})}
(M \otimes_E K^\bullet, N \otimes_E K^\bullet)
$$
For any complexes of $\mathcal{O}$-modules
$\mathcal{F}^\bullet$, $\mathcal{G}^\bullet$ there
is a canonical map
$$
\Hom_{\text{Comp}^{dg}(\mathcal{O})}
(\mathcal{F}^\bullet, \mathcal{G}^\bullet) =
\Gamma(\mathcal{C},
\SheafHom^\bullet(\mathcal{F}^\bullet, \mathcal{G}^\bullet))
\longrightarrow
R\Hom_\mathcal{O}(\mathcal{F}^\bullet, \mathcal{G}^\bullet).
$$
Combining these maps
we obtain the desired map of the lemma.
\end{proof}

\begin{lemma}
\label{lemma-tensor-with-complex-hom-adjoint}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site.
Let $K^\bullet$ be a complex of $\mathcal{O}$-modules.
Then the functor
$$
- \otimes_E^\mathbf{L} K^\bullet :
D(E, \text{d})
\longrightarrow
D(\mathcal{O})
$$
of Lemma \ref{lemma-tensor-with-complex-derived} is a left adjoint
of the functor
$$
R\Hom(K^\bullet, -) : D(\mathcal{O}) \longrightarrow D(E, \text{d})
$$
of Lemma \ref{lemma-existence-of-derived}.
\end{lemma}

\begin{proof}
The statement means that we have
$$
\Hom_{D(E, \text{d})}(M, R\Hom(K^\bullet, L^\bullet)) =
\Hom_{D(\mathcal{O})}(M \otimes^\mathbf{L}_E K^\bullet, L^\bullet)
$$
bifunctorially in $M$ and $L^\bullet$. To see this we may replace $M$
by a differential graded $E$-module $P$ with property (P).
We also may replace $L^\bullet$ by a K-injective complex of
$\mathcal{O}$-modules $I^\bullet$. The computation
of the derived functors given in the lemmas referenced in the statement
combined with Lemma \ref{lemma-hom-derived} translates the above into
$$
\Hom_{K(\text{Mod}_{(E, \text{d})})}
(P, \Hom_\mathcal{B}(K^\bullet, I^\bullet)) =
\Hom_{K(\mathcal{O})}(P \otimes_E K^\bullet, I^\bullet)
$$
where $\mathcal{B} = \text{Comp}^{dg}(\mathcal{O})$. 
There is an evaluation map from right to left functorial
in $P$ and $I^\bullet$ (details omitted).
Choose a filtration $F_\bullet$ on $P$ as in the definition of property (P).
By Lemma \ref{lemma-property-P-sequence} and the fact that
both sides of the equation are homological functors in $P$
on $K(\text{Mod}_{(E, \text{d})})$
we reduce to the case where $P$ is replaced by
the differential graded $E$-module $\bigoplus F_iP$.
Since both sides turn direct sums in the variable $P$
into direct products we reduce to the case where $P$ is one of the
differential graded $E$-modules $F_iP$.
Since each $F_iP$ has a finite filtration (given by admissible
monomorphisms) whose graded pieces are graded projective $E$-modules
we reduce to the case where $P$ is a graded projective $E$-module.
In this case we clearly have
$$
\Hom_{\text{Mod}^{dg}_{(E, \text{d})}}
(P, \Hom_\mathcal{B}(K^\bullet, I^\bullet)) =
\Hom_{\text{Comp}^{dg}(\mathcal{O})}(P \otimes_E K^\bullet, I^\bullet)
$$
as graded $\mathbf{Z}$-modules (because this statement reduces to the case
$P = E[k]$ where it is obvious). As the isomorphism is compatible with
differentials we conclude.
\end{proof}

\begin{lemma}
\label{lemma-fully-faithful-in-compact-case}
Let $(\mathcal{C}, \mathcal{O})$ be a ringed site.
Let $K^\bullet$ be a complex of $\mathcal{O}$-modules.
Assume
\begin{enumerate}
\item $K^\bullet$ represents a compact object of $D(\mathcal{O})$, and
\item $E = \Hom_{\text{Comp}^{dg}(\mathcal{O})}(K^\bullet, K^\bullet)$
computes the ext groups of $K^\bullet$ in $D(\mathcal{O})$.
\end{enumerate}
Then the functor
$$
- \otimes_E^\mathbf{L} K^\bullet :
D(E, \text{d})
\longrightarrow
D(\mathcal{O})
$$
of Lemma \ref{lemma-tensor-with-complex-derived} is fully faithful.
\end{lemma}

\begin{proof}
Because our functor has a left adjoint given by
$R\Hom(K^\bullet, -)$ by Lemma \ref{lemma-tensor-with-complex-hom-adjoint}
it suffices to show for a differential graded $E$-module $M$ that the map
$$
H^0(M) \longrightarrow
\Hom_{D(\mathcal{O})}(K^\bullet, M \otimes_E^\mathbf{L} K^\bullet)
$$
is an isomorphism. We may assume that $M = P$ is a differential graded
$E$-module which has property (P). Since $K^\bullet$ defines a
compact object, we reduce using
Lemma \ref{lemma-property-P-sequence}
to the case where $P$ has a finite filtration whose graded pieces
are direct sums of $E[k]$. Again using compactness we reduce
to the case $P = E[k]$. The assumption on $K^\bullet$ is that
the result holds for these.
\end{proof}











\section{Characterizing compact objects}
\label{section-compact}

\noindent
Compact objects of additive categories are defined in
Derived Categories, Definition \ref{derived-definition-compact-object}.
In this section we characterize compact objects of the derived
category of a differential graded algebra.

\begin{remark}
\label{remark-source-graded-projective}
Let $(A, \text{d})$ be a differential graded algebra. Is there a
characterization of those differential graded $A$-modules $P$
for which we have
$$
\Hom_{K(A, \text{d})}(P, M) =  \Hom_{D(A, \text{d})}(P, M)
$$
for all differential graded $A$-modules $M$? Let
$\mathcal{D} \subset K(A, \text{d})$ be the full subcategory
whose objects are the objects $P$ satisfying the above. Then $\mathcal{D}$
is a strictly full saturated triangulated subcategory of $K(A, \text{d})$.
If $P$ is projective as a graded $A$-module, then to see where $P$
is an object of $\mathcal{D}$ it is enough to check that
$\Hom_{K(A, \text{d})}(P, M) = 0$ whenever $M$ is acyclic.
However, in general it is not enough to assume that $P$ is projective as
a graded $A$-module. Example: take $A = R = k[\epsilon]$ where $k$ is
a field and $k[\epsilon] = k[x]/(x^2)$ is the ring of dual numbers.
Let $P$ be the object with $P^n = R$ for all $n \in \mathbf{Z}$
and differential given by multiplication by $\epsilon$. Then
$\text{id}_P \in \Hom_{K(A, \text{d})}(P, P)$ is a nonzero element
but $P$ is acyclic.
\end{remark}

\begin{remark}
\label{remark-graded-projective-is-compact}
Let $(A, \text{d})$ be a differential graded algebra. Let us say a
differential graded $A$-module $M$ is {\it finite} if $M$ is generated,
as a right $A$-module, by finitely many elements. If $P$ is a
differential graded $A$-module which is finite graded projective,
then we can ask: Does $P$ give a compact object of $D(A, \text{d})$?
Presumably, this is not true in general, but we do not know a
counter example. However, if $P$ is also an object of the category
$\mathcal{D}$ of Remark \ref{remark-source-graded-projective},
then this is the case (this follows from the fact that direct sums
in $D(A, \text{d})$ are given by direct sums of modules; details omitted).
\end{remark}

\begin{lemma}
\label{lemma-factor-through-nicer}
Let $(A, \text{d})$ be a differential graded algebra. Let $E$ be a compact
object of $D(A, \text{d})$. Let $P$ be a differential graded $A$-module
which has a finite filtration
$$
0 = F_{-1}P \subset F_0P \subset F_1P \subset \ldots \subset F_nP = P
$$
by differential graded submodules such that
$$
F_{i + 1}P/F_iP \cong \bigoplus\nolimits_{j \in J_i} A[k_{i, j}]
$$
as differential graded $A$-modules for some sets $J_i$ and integers $k_{i, j}$.
Let $E \to P$ be a morphism of $D(A, \text{d})$.
Then there exists a differential graded submodule $P' \subset P$ such that
$F_{i + 1}P \cap P'/(F_iP \cap P')$ is equal to
$\bigoplus_{j \in J'_i} A[k_{i, j}]$ for some finite subsets
$J'_i \subset J_i$ and such that $E \to P$ factors through $P'$.
\end{lemma}

\begin{proof}
We will prove by induction on $-1 \leq m \leq n$ that there exists
a differential graded submodule $P' \subset P$  such that
\begin{enumerate}
\item $F_mP \subset P'$,
\item for $i \geq m$ the quotient $F_{i + 1}P \cap P'/(F_iP \cap P')$ is
isomorphic to $\bigoplus_{j \in J'_i} A[k_{i, j}]$ for some finite subsets
$J'_i \subset J_i$, and
\item $E \to P$ factors through $P'$.
\end{enumerate}
The base case is $m = n$ where we can take $P' = P$.

\medskip\noindent
Induction step. Assume $P'$ works for $m$.
For $i \geq m$ and $j \in J'_i$ let $x_{i, j} \in F_{i + 1}P \cap P'$
be a homogeneous element of degree $k_{i, j}$ whose image in
$F_{i + 1}P \cap P'/(F_iP \cap P')$ is the generator in
the summand corresponding to $j \in J_i$. The
$x_{i, j}$ generate $P'/F_mP$ as an $A$-module. Write
$$
\text{d}(x_{i, j}) = \sum x_{i', j'} a_{i, j}^{i', j'} + y_{i, j}
$$
with $y_{i, j} \in F_mP$ and $a_{i, j}^{i', j'} \in A$.
There exists a finite subset
$J'_{m - 1} \subset J_{m - 1}$ such that each $y_{i, j}$ maps to
an element of the submodule $\bigoplus_{j \in J'_{m - 1}} A[k_{m - 1, j}]$
of $F_mP/F_{m - 1}P$. Let $P'' \subset F_mP$ be the inverse
image of $\bigoplus_{j \in J'_{m - 1}} A[k_{m - 1, j}]$ under
the map $F_mP \to F_mP/F_{m - 1}P$. Then we see that the $A$-submodule
$$
P'' + \sum x_{i, j}A
$$
is a differential graded submodule of the type we are looking for. Moreover
$$
P'/(P'' + \sum x_{i, j}A) =
\bigoplus\nolimits_{j \in J_{m - 1} \setminus J'_{m - 1}} A[k_{m - 1, j}]
$$
Since $E$ is compact, the composition of the given map $E \to P'$
with the quotient map, factors through a finite direct subsum of
the module displayed above. Hence after enlarging $J'_{m - 1}$
we may assume $E \to P'$ factors through
$P'' + \sum x_{i, j}A$ as desired.
\end{proof}

\noindent
It is not true that every compact object of $D(A, \text{d})$ comes
from a finite graded projective differential graded $A$-module,
see Examples, Section \ref{examples-section-interesting-compact}.

\begin{proposition}
\label{proposition-compact}
Let $(A, \text{d})$ be a differential graded algebra. Let $E$ be an
object of $D(A, \text{d})$. Then the following are equivalent
\begin{enumerate}
\item $E$ is a compact object,
\item $E$ is a direct summand of an object of $D(A, \text{d})$
which is represented by a differential graded module $P$ which
has a finite filtration $F_\bullet$ by differential graded submodules
such that $F_iP/F_{i - 1}P$ are finite direct sums of shifts of $A$.
\end{enumerate}
\end{proposition}

\begin{proof}
Assume $E$ is compact. By Lemma \ref{lemma-resolve} we may assume that $E$
is represented by a differential graded $A$-module $P$ with property (P).
Consider the distinguished triangle
$$
\bigoplus F_iP \to \bigoplus F_iP \to P
\xrightarrow{\delta} \bigoplus F_iP[1]
$$
coming from the admissible short exact sequence of
Lemma \ref{lemma-property-P-sequence}. Since $E$ is compact we have
$\delta = \sum_{i = 1, \ldots, n} \delta_i$ for some
$\delta_i : P \to F_iP[1]$. Since the composition of $\delta$
with the map $\bigoplus F_iP[1] \to \bigoplus F_iP[1]$ is zero
(Derived Categories, Lemma \ref{derived-lemma-composition-zero})
it follows that $\delta = 0$ (follows as $\bigoplus F_iP \to \bigoplus F_iP$
maps the summand $F_iP$ via the difference of $\text{id}$ and the inclusion
map into $F_{i - 1}P$).
Thus we see that the identity on $E$ factors through
$\bigoplus F_iP$ in $D(A, \text{d})$ (by
Derived Categories, Lemma \ref{derived-lemma-split}).
Next, we use that $P$ is compact again to see that the map
$E \to \bigoplus F_iP$ factors through $\bigoplus_{i = 1, \ldots, n} F_iP$
for some $n$. In other words, the identity on $E$ factors through
$\bigoplus_{i = 1, \ldots, n} F_iP$. By
Lemma \ref{lemma-factor-through-nicer}
we see that the identity of $E$ factors as $E \to P \to E$
where $P$ is as in part (2) of the statement of the lemma.
In other words, we have proven that (1) implies (2).

\medskip\noindent
Assume (2). By
Derived Categories, Lemma \ref{derived-lemma-compact-objects-subcategory}
it suffices to show that $P$ gives a compact object. Observe that
$P$ has property (P), hence we have
$$
\Hom_{D(A, \text{d})}(P, M) = \Hom_{K(A, \text{d})}(P, M)
$$
for any differential graded module $M$ by Lemma \ref{lemma-hom-derived}.
As direct sums in $D(A, \text{d})$ are given by direct sums of
graded modules (Lemma \ref{lemma-derived-products}) we reduce
to showing that $\Hom_{K(A, \text{d})}(P, M)$ commutes with direct
sums. Using that $K(A, \text{d})$ is a triangulated category,
that $\Hom$ is a cohomological functor in the first
variable, and the filtration on $P$, we reduce to the case that
$P$ is a finite direct sum of shifts of $A$. Thus we reduce to
the case $P = A[k]$ which is clear.
\end{proof}

\begin{lemma}
\label{lemma-compact-implies-bounded}
Let $(A, \text{d})$ be a differential graded algebra.
For every compact object $E$ of $D(A, \text{d})$ there
exist integers $a \leq b$ such that $\Hom_{D(A, \text{d})}(E, M) = 0$
if $H^i(M) = 0$ for $i \in [a, b]$.
\end{lemma}

\begin{proof}
Observe that the collection of objects of $D(A, \text{d})$ for which
such a pair of integers exists is a saturated, strictly full triangulated
subcategory of $D(A, \text{d})$.
Thus by Proposition \ref{proposition-compact} it suffices to prove
this when $E$ is represented by a differential graded module $P$ which
has a finite filtration $F_\bullet$ by differential graded submodules
such that $F_iP/F_{i - 1}P$ are finite direct sums of shifts of $A$.
Using the compatibility with triangles, we see that it suffices
to prove it for $P = A$. In this case $\Hom_{D(A, \text{d})}(A, M) = H^0(M)$
and the result holds with $a = b = 0$.
\end{proof}

\noindent
If $(A, \text{d})$ is just an algebra placed in degree $0$
with zero differential or more generally lives in
only a finite number of degrees, then we do obtain the
more precise description of compact objects.

\begin{lemma}
\label{lemma-compact}
Let $(A, \text{d})$ be a differential graded algebra. Assume that $A^n = 0$
for $|n| \gg 0$. Let $E$ be an object of $D(A, \text{d})$.
The following are equivalent
\begin{enumerate}
\item $E$ is a compact object, and
\item $E$ can be represented by a differential graded $A$-module $P$
which is finite projective as a graded $A$-module and satisfies
$\Hom_{K(A, \text{d})}(P, M) = \Hom_{D(A, \text{d})}(P, M)$
for every differential graded $A$-module $M$.
\end{enumerate}
\end{lemma}

\begin{proof}
Let $\mathcal{D} \subset K(A, \text{d})$ be the triangulated subcategory
discussed in Remark \ref{remark-source-graded-projective}.
Let $P$ be an object of $\mathcal{D}$ which is finite projective
as a graded $A$-module. Then $P$ represents a compact object of
$D(A, \text{d})$ by Remark \ref{remark-graded-projective-is-compact}.

\medskip\noindent
To prove the converse, let $E$ be a compact object of $D(A, \text{d})$.
Fix $a \leq b$ as in Lemma \ref{lemma-compact-implies-bounded}.
After decreasing $a$ and increasing $b$ if necessary, we may also
assume that $H^i(E) = 0$ for $i \not \in [a, b]$ (this follows
from Proposition \ref{proposition-compact} and our assumption on $A$).
Moreover, fix an integer $c > 0$ such that $A^n = 0$ if $|n| \geq c$.

\medskip\noindent
By Proposition \ref{proposition-compact} we see that $E$ is a direct
summand, in $D(A, \text{d})$, of a differential graded $A$-module $P$
which has a finite filtration $F_\bullet$ by differential
graded submodules such that $F_iP/F_{i - 1}P$ are finite direct sums
of shifts of $A$. In particular, $P$ has property (P) and we have
$\Hom_{D(A, \text{d})}(P, M) = \Hom_{K(A, \text{d})}(P, M)$ for any
differential graded module $M$ by Lemma \ref{lemma-hom-derived}.
In other words, $P$ is an object of the triangulated
subcategory $\mathcal{D} \subset K(A, \text{d})$ discussed in
Remark \ref{remark-source-graded-projective}.
Note that $P$ is finite free as a graded $A$-module.

\medskip\noindent
Choose $n > 0$ such that $b + 4c - n < a$.
Represent the projector onto $E$ by an endomorphism $\varphi : P \to P$ of
differential graded $A$-modules. Consider the distinguished triangle
$$
P \xrightarrow{1 - \varphi} P \to C \to P[1]
$$
in $K(A, \text{d})$ where $C$ is the cone of the first arrow. Then
$C$ is an object of $\mathcal{D}$,
we have $C \cong E \oplus E[1]$ in $D(A, \text{d})$, and
$C$ is a finite graded free $A$-module.
Next, consider a distinguished triangle
$$
C[1] \to C \to C' \to C[2]
$$
in $K(A, \text{d})$ where $C'$ is the cone on a morphism $C[1] \to C$
representing the composition
$$
C[1] \cong E[1] \oplus E[2] \to E[1] \to E \oplus E[1] \cong C
$$
in $D(A, \text{d})$. Then we see that $C'$ represents $E \oplus E[2]$.
Continuing in this manner we see that we can find a differential
graded $A$-module $P$ which is an object of $\mathcal{D}$,
is a finite free as a graded $A$-module, and represents $E \oplus E[n]$.

\medskip\noindent
Choose a basis $x_i$, $i \in I$ of homogeneous elements for $P$ as an
$A$-module. Let $d_i = \deg(x_i)$.
Let $P_1$ be the $A$-submodule of $P$ generated by $x_i$ and
$\text{d}(x_i)$ for $d_i \leq a - c - 1$.
Let $P_2$ be the $A$-submodule of $P$ generated by $x_i$ and
$\text{d}(x_i)$ for $d_i \geq b - n + c$.
We observe
\begin{enumerate}
\item $P_1$ and $P_2$ are differential graded submodules of $P$,
\item $P_1^t = 0$ for $t \geq a$,
\item $P_1^t = P^t$ for $t \leq a - 2c$,
\item $P_2^t = 0$ for $t \leq b - n$,
\item $P_2^t = P^t$ for $t \geq b - n + 2c$.
\end{enumerate}
As $b - n + 2c \geq a - 2c$ by our choice of $n$
we obtain a short exact sequence of differential graded $A$-modules
$$
0 \to P_1 \cap P_2 \to P_1 \oplus P_2 \xrightarrow{\pi} P \to 0
$$
Since $P$ is projective as a graded $A$-module this is an admissible
short exact sequence (Lemma \ref{lemma-target-graded-projective}).
Hence we obtain a boundary map
$\delta : P \to (P_1 \cap P_2)[1]$ in $K(A, \text{d})$, see
Lemma \ref{lemma-admissible-ses}.
Since $P = E \oplus E[n]$ and since $P_1 \cap P_2$ lives in
degrees $(b - n, a)$ we find that
$\Hom_{D(A, \text{d})}(E \oplus E[n], (P_1 \cap P_2)[1])$ is
zero. Therefore $\delta = 0$ as a morphism in $K(A, \text{d})$
as $P$ is an object of $\mathcal{D}$.
By Derived Categories, Lemma \ref{derived-lemma-split}
we can find a map $s : P \to P_1 \oplus P_2$ such that
$\pi \circ s = \text{id}_P + \text{d}h + h\text{d}$ for some $h : P \to P$
of degree $-1$. Since $P_1 \oplus P_2 \to P$ is surjective and since $P$
is projective as a graded $A$-module we can choose a homogeneous
lift $\tilde h : P \to P_1 \oplus P_2$ of $h$. Then we change
$s$ into $s + \text{d} \tilde h + \tilde h \text{d}$ to get
$\pi \circ s = \text{id}_P$. This means we obtain a direct
sum decomposition $P = s^{-1}(P_1) \oplus s^{-1}(P_2)$.
Since $s^{-1}(P_2)$ is equal to $P$ in degrees $\geq b - n + 2c$
we see that $s^{-1}(P_2) \to P \to E$ is a quasi-isomorphism,
i.e., an isomorphism in $D(A, \text{d})$. This finishes the proof.
\end{proof}








\section{Equivalences of derived categories}
\label{section-equivalence}

\noindent
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$ be differential
graded $R$-algebras. A natural question that arises in nature is what
it means that $D(A, \text{d})$ is equivalent to $D(B, \text{d})$
as an $R$-linear triangulated category. This is a rather subtle question
and it will turn out it isn't always the correct question to ask.
Nonetheless, in this section we collection some conditions
that guarantee this is the case.

\medskip\noindent
We strongly urge the reader to take a look at the groundbreaking
paper \cite{Rickard} on this topic.

\begin{lemma}
\label{lemma-qis-equivalence}
Let $R$ be a ring. Let $(A, \text{d}) \to (B, \text{d})$ be a
homomorphism of differential graded algebras over $R$, which induces
an isomorphism on cohomology algebras. Then
$$
- \otimes_A^\mathbf{L} B : D(A, \text{d}) \to D(B, \text{d})
$$
gives an $R$-linear equivalence of triangulated categories with
quasi-inverse the restriction functor $N \mapsto N_A$.
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-tensor-with-compact-fully-faithful}
the functor $M \longmapsto M \otimes_A^\mathbf{L} B$ is
fully faithful. By Lemma \ref{lemma-tensor-hom-adjoint}
the functor $N \longmapsto R\Hom(B, N) = N_A$ is a right adjoint, see
Example \ref{example-map-hom-tensor}.
It is clear that the kernel of $R\Hom(B, -)$ is zero.
Hence the result follows from
Derived Categories, Lemma
\ref{derived-lemma-fully-faithful-adjoint-kernel-zero}.
\end{proof}

\noindent
When we analyze the proof above we see that we obtain the
following generalization for free.

\begin{lemma}
\label{lemma-tilting-equivalence}
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$ be 
differential graded algebras over $R$. Let $N$ be a
differential graded $(A, B)$-bimodule. Assume that
\begin{enumerate}
\item $N$ defines a compact object of $D(B, \text{d})$,
\item if $N' \in D(B, \text{d})$ and
$\Hom_{D(B, \text{d})}(N, N'[n]) = 0$ for $n \in \mathbf{Z}$,
then $N' = 0$, and
\item the map $H^k(A) \to \Hom_{D(B, \text{d})}(N, N[k])$ is an
isomorphism for all $k \in \mathbf{Z}$.
\end{enumerate}
Then
$$
- \otimes_A^\mathbf{L} N : D(A, \text{d}) \to D(B, \text{d})
$$
gives an $R$-linear equivalence of triangulated categories.
\end{lemma}

\begin{proof}
By Lemma \ref{lemma-tensor-with-compact-fully-faithful}
the functor $M \longmapsto M \otimes_A^\mathbf{L} N$ is
fully faithful. By Lemma \ref{lemma-tensor-hom-adjoint}
the functor $N' \longmapsto R\Hom(N, N')$ is a right adjoint.
By assumption (3) the kernel of $R\Hom(N, -)$ is zero.
Hence the result follows from
Derived Categories, Lemma
\ref{derived-lemma-fully-faithful-adjoint-kernel-zero}.
\end{proof}

\begin{remark}
\label{remark-tilting-equivalence}
In Lemma \ref{lemma-tilting-equivalence} we can replace
condition (2) by the condition that $N$ is a classical
generator for $D_{compact}(B, d)$, see
Derived Categories, Proposition
\ref{derived-proposition-generator-versus-classical-generator}.
Moreover, if we knew that $R\Hom(N, B)$ is a compact object
of $D(A, \text{d})$, then it suffices to check that $N$
is a weak generator for $D_{compact}(B, \text{d})$.
We omit the proof; we will add it here if we ever
need it in the Stacks project.
\end{remark}

\noindent
Sometimes the $B$-module $P$ in the lemma below is called an
``$(A, B)$-tilting complex''.

\begin{lemma}
\label{lemma-rickard}
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$ be
differential graded $R$-algebras. Assume that $A = H^0(A)$.
The following are equivalent
\begin{enumerate}
\item $D(A, \text{d})$ and $D(B, \text{d})$ are equivalent as $R$-linear
triangulated categories, and
\item there exists an object $P$ of $D(B, \text{d})$ such that
\begin{enumerate}
\item $P$ is a compact object of $D(B, \text{d})$,
\item if $N \in D(B, \text{d})$ with $\Hom_{D(B, \text{d})}(P, N[i]) = 0$
for $i \in \mathbf{Z}$, then $N = 0$,
\item $\Hom_{D(B, \text{d})}(P, P[i]) = 0$ for $i \not = 0$ and
equal to $A$ for $i = 0$.
\end{enumerate}
\end{enumerate}
The equivalence $D(A, \text{d}) \to D(B, \text{d})$
constructed in (2) sends $A$ to $P$.
\end{lemma}

\begin{proof}
Let $F : D(A, \text{d}) \to D(B, \text{d})$ be an equivalence.
Then $F$ maps compact objects to compact objects. Hence $P = F(A)$ is
compact, i.e., (2)(a) holds. Conditions (2)(b) and (2)(c) are immediate
from the fact that $F$ is an equivalence.

\medskip\noindent
Let $P$ be an object as in (2). Represent $P$ by a
differential graded module with property (P). Set
$$
(E, \text{d}) = \Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(P, P)
$$
Then $H^0(E) = A$ and $H^k(E) = 0$ for $k \not = 0$ by
Lemma \ref{lemma-hom-derived} and assumption (2)(c).
Viewing $P$ as a $(E, B)$-bimodule and using
Lemma \ref{lemma-tilting-equivalence} and assumption (2)(b)
we obtain an equivalence
$$
D(E, \text{d}) \to D(B, \text{d})
$$
sending $E$ to $P$.
Let $E' \subset E$ be the differential graded $R$-subalgebra
with
$$
(E')^i = \left\{
\begin{matrix}
E^i & \text{if }i < 0 \\
\Ker(E^0 \to E^1) & \text{if }i = 0 \\
0 & \text{if }i > 0
\end{matrix}
\right.
$$
Then there are quasi-isomorphisms of differential graded
algebras $(A, \text{d}) \leftarrow (E', \text{d}) \rightarrow (E, \text{d})$.
Thus we obtain equivalences
$$
D(A, \text{d}) \leftarrow D(E', \text{d}) \rightarrow D(E, \text{d})
\rightarrow D(B, \text{d})
$$
by Lemma \ref{lemma-qis-equivalence}.
\end{proof}

\begin{remark}
\label{remark-lift-equivalence-to-dga}
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$ be differential
graded $R$-algebras. Suppose given an $R$-linear equivalence
$$
F : D(A, \text{d}) \longrightarrow D(B, \text{d})
$$
of triangulated categories. Set $N = F(A)$. Then $N$ is a differential
graded $B$-module. Since $F$ is an equivalence and $A$ is a compact
object of $D(A, \text{d})$, we conclude that $N$ is a compact object
of $D(B, \text{d})$. Since $A$ generates $D(A, \text{d})$ and
$F$ is an equivalence, we see that $N$ generates $D(B, \text{d})$.
Finally, $H^k(A) = \Hom_{D(A, \text{d})}(A, A[k])$ and as $F$ an equivalence
we see that $F$ induces an isomorphism
$H^k(A) = \Hom_{D(B, \text{d})}(N, N[k])$ for all $k$.
In order to conclude that there is an equivalence
$D(A, \text{d}) \longrightarrow D(B, \text{d})$ which
arises from the construction in
Lemma \ref{lemma-tilting-equivalence}
all we need is a left $A$-module structure on $N$
compatible with derivation and commuting
with the given right $B$-module structure. In fact, it
suffices to do this after replacing $N$ by a quasi-isomorphic
differential graded $B$-module.
The module structure can be constructed in certain cases.
For example, if we assume that $F$ can be lifted to a
differential graded functor
$$
F^{dg} :
\text{Mod}^{dg}_{(A, \text{d})}
\longrightarrow
\text{Mod}^{dg}_{(B, \text{d})}
$$
(for notation see Example \ref{example-dgm-dg-cat})
between the associated differential graded categories,
then this holds. Another case is discussed in the proposition below.
\end{remark}

\begin{proposition}
\label{proposition-rickard}
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$ be
differential graded $R$-algebras. Let $F : D(A, \text{d}) \to D(B, \text{d})$
be an $R$-linear equivalence of triangulated categories. Assume that
\begin{enumerate}
\item $A = H^0(A)$, and
\item $B$ is K-flat as a complex of $R$-modules.
\end{enumerate}
Then there exists an $(A, B)$-bimodule $N$ as in
Lemma \ref{lemma-tilting-equivalence}.
\end{proposition}

\begin{proof}
As in Remark \ref{remark-lift-equivalence-to-dga} above, we set $N = F(A)$
in $D(B, \text{d})$. We may assume that $N$ is a differential graded
$B$-module with property (P). Set
$$
(E, \text{d}) = \Hom_{\text{Mod}^{dg}_{(B, \text{d})}}(N, N)
$$
Then $H^0(E) = A$ and $H^k(E) = 0$ for $k \not = 0$ by
Lemma \ref{lemma-hom-derived}.
Moreover, by the discussion in Remark \ref{remark-lift-equivalence-to-dga}
and by Lemma \ref{lemma-tilting-equivalence}
we see that $N$ as a $(E, B)$-bimodule induces an
equivalence $- \otimes_E^\mathbf{L} N : D(E, \text{d}) \to D(B, \text{d})$.
Let $E' \subset E$ be the differential graded $R$-subalgebra
with
$$
(E')^i = \left\{
\begin{matrix}
E^i & \text{if }i < 0 \\
\Ker(E^0 \to E^1) & \text{if }i = 0 \\
0 & \text{if }i > 0
\end{matrix}
\right.
$$
Then there are quasi-isomorphisms of differential graded
algebras $(A, \text{d}) \leftarrow (E', \text{d}) \rightarrow (E, \text{d})$.
Thus we obtain equivalences
$$
D(A, \text{d}) \leftarrow D(E', \text{d}) \rightarrow D(E, \text{d})
\rightarrow D(B, \text{d})
$$
by Lemma \ref{lemma-qis-equivalence}.
Note that the quasi-inverse $D(A, \text{d}) \to D(E', \text{d})$
of the left vertical arrow is given
by $M \mapsto M \otimes_A^\mathbf{L} A$ where $A$ is viewed as a
$(A, E')$-bimodule, see Example \ref{example-map-hom-tensor}.
On the other hand the functor $D(E', \text{d}) \to D(B, \text{d})$ is given by
$M \mapsto M \otimes_{E'}^\mathbf{L} N$ where $N$ is as above.
We conclude by Lemma \ref{lemma-compose-tensor-functors}.
\end{proof}

\begin{remark}
\label{remark-rickard}
Let $A, B, F, N$ be as in Proposition \ref{proposition-rickard}.
It is not clear that $F$ and the functor
$G(-) = - \otimes_A^\mathbf{L} N$ are isomorphic.
By construction there is an isomorphism
$N = G(A) \to F(A)$ in $D(B, \text{d})$.
It is straightforward to extend this to a functorial isomorphism
$G(M) \to F(M)$ for $M$ is a differential graded $A$-module which
is graded projective (e.g., a sum of shifts of $A$).
Then one can conclude that $G(M) \cong F(M)$ when $M$ is a cone
of a map between such modules. We don't know whether more is true
in general.
\end{remark}

\begin{lemma}
\label{lemma-rickard-rings}
Let $R$ be a ring.
Let $A$ and $B$ be $R$-algebras. The following are equivalent
\begin{enumerate}
\item there is an $R$-linear equivalence $D(A) \to D(B)$
of triangulated categories,
\item there exists an object $P$ of $D(B)$ such that
\begin{enumerate}
\item $P$ can be represented by a finite complex
of finite projective $B$-modules,
\item if $K \in D(B)$ with $\Ext^i_B(P, K) = 0$ for
$i \in \mathbf{Z}$, then $K = 0$, and
\item $\Ext^i_B(P, P) = 0$ for $i \not = 0$ and
equal to $A$ for $i= 0$.
\end{enumerate}
\end{enumerate}
Moreover, if $B$ is flat as an $R$-module, then this is also
equivalent to
\begin{enumerate}
\item[(3)] there exists an $(A, B)$-bimodule $N$ such that
$- \otimes_A^\mathbf{L} N : D(A) \to D(B)$ is an equivalence.
\end{enumerate}
\end{lemma}

\begin{proof}
The equivalence of (1) and (2) is a special case of
Lemma \ref{lemma-rickard} combined with the result of
Lemma \ref{lemma-compact} characterizing compact objects of $D(B)$
(small detail omitted).
The equivalence with (3) if $B$ is $R$-flat follows from
Proposition \ref{proposition-rickard}.
\end{proof}

\begin{remark}
\label{remark-centers}
Let $R$ be a ring. Let $A$ and $B$ be $R$-algebras.
If $D(A)$ and $D(B)$ are equivalent as $R$-linear triangulated
categories, then the centers of $A$ and $B$ are isomorphic
as $R$-algebras. In particular, if $A$ and $B$ are commutative,
then $A \cong B$. The rather tricky proof can be found in
\cite[Proposition 9.2]{Rickard} or \cite[Proposition 6.3.2]{KZ}.
Another approach might be to use Hochschild cohomology (see
remark below).
\end{remark}

\begin{remark}
\label{remark-hochschild-cohomology}
Let $R$ be a ring. Let $(A, \text{d})$ and $(B, \text{d})$ be differential
graded $R$-algebras which are derived equivalent, i.e., such that there
exists an $R$-linear equivalence $D(A, \text{d}) \to D(B, \text{d})$
of triangulated categories. We would like to show that certain invariants
of $(A, \text{d})$ and $(B, \text{d})$ coincide. In many situations
one has more control of the situation. For example, it may happen
that there is an equivalence of the form
$$
- \otimes_A \Omega : D(A, \text{d}) \longrightarrow D(B, \text{d})
$$
for some differential graded $(A, B)$-bimodule
$\Omega$ (this happens in the situation of
Proposition \ref{proposition-rickard} and is often true
if the equivalence comes from a geometric construction).
If also the quasi-inverse of our functor is given as
$$
- \otimes_B^\mathbf{L} \Omega' : D(B, \text{d}) \longrightarrow D(A, \text{d})
$$
for a differential graded $(B, A)$-bimodule $\Omega'$
(and as before such a module $\Omega'$ often exists in practice).
In this case we can consider the functor
$$
D(A^{opp} \otimes_R A, \text{d})
\longrightarrow
D(B^{opp} \otimes_R B, \text{d}),\quad
M \longmapsto \Omega' \otimes^\mathbf{L}_A M \otimes_A^\mathbf{L} \Omega
$$
on derived categories of bimodules (use
Lemma \ref{lemma-bimodule-over-tensor} to turn bimodules into
right modules).
Observe that this functor sends the $(A, A)$-bimodule $A$ to
the $(B, B)$-bimodule $B$. Under suitable conditions
(e.g., flatness of $A$, $B$, $\Omega$ over $R$, etc)
this functor will be an equivalence as well.
If this is the case, then it follows that we have isomorphisms
of Hochschild cohomology groups
$$
HH^i(A, \text{d}) =
\Hom_{D(A^{opp} \otimes_R A, \text{d})}(A, A[i])
\longrightarrow
\Hom_{D(B^{opp} \otimes_R B, \text{d})}(B, B[i]) =
HH^i(B, \text{d}).
$$
For example, if $A = H^0(A)$, then $HH^0(A, \text{d})$
is equal to the center of $A$, and this gives a conceptual proof
of the result mentioned in Remark \ref{remark-centers}.
If we ever need this remark we will provide a precise statement
with a detailed proof here.
\end{remark}



\section{Resolutions of differential graded algebras}
\label{section-resolution-dgas}

\noindent
Let $R$ be a ring. Under our assumptions the free $R$-algebra
$R\langle S \rangle$ on a set $S$ is the algebra with $R$-basis
the expressions
$$
s_1 s_2 \ldots s_n
$$
where $n \geq 0$ and $s_1, \ldots, s_n \in S$ is a sequence of
elements of $S$. Multiplication is given by concatenation
$$
(s_1 s_2 \ldots s_n) \cdot (s'_1 s'_2 \ldots s'_m) =
s_1 \ldots s_n s'_1 \ldots s'_m
$$
This algebra is characterized by the property that the map
$$
\Mor_{R\text{-alg}}(R\langle S \rangle, A) \to
\text{Map}(S, A),\quad
\varphi \longmapsto (s \mapsto \varphi(s))
$$
is a bijection for every $R$-algebra $A$.

\medskip\noindent
In the category of graded $R$-algebras our set $S$ should come
with a grading, which we think of as a map $\deg : S \to \mathbf{Z}$.
Then $R\langle S\rangle$ has a grading such that the monomials
have degree
$$
\deg(s_1 s_2 \ldots s_n) = \deg(s_1) + \ldots + \deg(s_n)
$$
In this setting we have
$$
\Mor_{\text{graded }R\text{-alg}}(R\langle S \rangle, A) \to
\text{Map}_{\text{graded sets}}(S, A),\quad
\varphi \longmapsto (s \mapsto \varphi(s))
$$
is a bijection for every graded $R$-algebra $A$.

\medskip\noindent
If $A$ is a graded $R$-algebra and $S$ is a graded set,
then we can similarly form $A\langle S \rangle$.
Elements of $A\langle S \rangle$ are
sums of elements of the form
$$
a_0 s_1 a_1 s_2 \ldots a_{n - 1} s_n a_n
$$
with $a_i \in A$ modulo the relations that these expressions
are $R$-multilinear in $(a_0, \ldots, a_n)$.
Thus for every sequence $s_1, \ldots, s_n$ of elements of $S$
there is an inclusion
$$
A \otimes_R \ldots \otimes_R A \subset A\langle S \rangle
$$
and the algebra is the direct sum of these. With this definition the
reader shows that the map
$$
\Mor_{\text{graded }R\text{-alg}}(A\langle S \rangle, B) \to
\Mor_{\text{graded }R\text{-alg}}(A, B) \times
\text{Map}_{\text{graded sets}}(S, B),
$$
sending $\varphi$ to $(\varphi|_A, (s \mapsto \varphi(s)))$
is a bijection for every graded $R$-algebra $A$.
We observe that if $A$ was a free graded $R$-algebra,
then so is $A\langle S \rangle$.

\medskip\noindent
Suppose that $A$ is a differential graded $R$-algebra and
that $S$ is a graded set. Suppose moreover for every $s \in S$
we are given a homogeneous element $f_s \in A$ with $\deg(f_s) = \deg(s) + 1$
and $\text{d}f_s = 0$. Then there exists a unique structure of
differential graded algebra on $A\langle S \rangle$ with
$\text{d}(s) = f_s$. For example, given $a, b, c \in A$ and
$s, t \in S$ we would define
\begin{align*}
\text{d}(asbtc)
& =
\text{d}(a)sbtc + (-1)^{\deg(a)}a f_s b t c +
(-1)^{\deg(a) + \deg(s)} as\text{d}(b)tc \\
& + (-1)^{\deg(a) + \deg(s) + \deg(b)} asb f_t c +
(-1)^{\deg(a) + \deg(s) + \deg(b) + \deg(t)} asbt\text{d}(c)
\end{align*}
We omit the details.

\begin{lemma}
\label{lemma-K-flat-resolution}
Let $R$ be a ring. Let $(B, \text{d})$ be a differential graded $R$-algebra.
There exists a quasi-isomorphism $(A, \text{d}) \to (B, \text{d})$ of
differential graded $R$-algebras with the following properties
\begin{enumerate}
\item $A$ is K-flat as a complex of $R$-modules,
\item $A$ is a free graded $R$-algebra.
\end{enumerate}
\end{lemma}

\begin{proof}
First we claim we can find $(A_0, \text{d}) \to (B, \text{d})$
having (1) and (2) inducing a surjection on cohomology.
Namely, take a graded set $S$ and for each $s \in S$
a homogeneous element $b_s \in \Ker(d : B \to B)$ of degree $\deg(s)$
such that the classes $\overline{b}_s$ in $H^*(B)$
generate $H^*(B)$ as an $R$-module.
Then we can set $A_0 = R\langle S \rangle$ with zero differential
and $A_0 \to B$ given by mapping $s$ to $b_s$.

\medskip\noindent
Given $A_0 \to B$ inducing a surjection on cohomology we construct
a sequence
$$
A_0 \to A_1 \to A_2 \to \ldots B
$$
by induction. Given $A_n \to B$ we set $S_n$ be a graded set
and for each $s \in S_n$ we let $a_s \in \Ker(A_n \to A_n)$
be a homogeneous element of degree $\deg(s) + 1$
mapping to a class $\overline{a}_s$ in $H^*(A_n)$
which maps to zero in $H^*(B)$. We choose $S_n$ large enough
so that the elements $\overline{a}_s$ generate $\Ker(H^*(A_n) \to H^*(B))$
as an $R$-module. Then we set
$$
A_{n + 1} = A_n\langle S_n \rangle
$$
with differential given by $\text{d}(s) = a_s$ see discussion above.
Then each $(A_n, \text{d})$ satisfies (1) and (2), we omit the details.
The map $H^*(A_n) \to H^*(B)$ is surjective as this was true for $n = 0$.

\medskip\noindent
It is clear that $A = \colim A_n$ is a free graded $R$-algebra.
It is K-flat by More on Algebra, Lemma \ref{more-algebra-lemma-colimit-K-flat}.
The map $H^*(A) \to H^*(B)$ is an isomorphism as it is surjective
and injective: every element of $H^*(A)$ comes from an element of
$H^*(A_n)$ for some $n$ and if it dies in $H^*(B)$, then it dies
in $H^*(A_{n + 1})$ hence in $H^*(A)$.
\end{proof}

\noindent
As an application we prove the ``correct'' version of
Lemma \ref{lemma-compose-tensor-functors-general-algebra}.

\begin{lemma}
\label{lemma-compose-tensor-functors-tor}
Let $R$ be a ring. Let $(A, \text{d})$, $(B, \text{d})$, and
$(C, \text{d})$ be differential graded $R$-algebras. Assume
$A \otimes_R C$ represents $A \otimes^\mathbf{L}_R C$ in $D(R)$.
Let $N$ be a differential graded $(A, B)$-bimodule.
Let $N'$ be a differential graded $(B, C)$-bimodule.
Then the composition
$$
\xymatrix{
D(A, \text{d}) \ar[rr]^{- \otimes_A^\mathbf{L} N} & &
D(B, \text{d}) \ar[rr]^{- \otimes_B^\mathbf{L} N'} & &
D(C, \text{d})
}
$$
is isomorphic to $- \otimes_A^\mathbf{L} N''$ for some differential graded
$(A, C)$-bimodule $N''$.
\end{lemma}

\begin{proof}
Using Lemma \ref{lemma-K-flat-resolution}
we choose a quasi-isomorphism $(B', \text{d}) \to (B, \text{d})$
with $B'$ K-flat as a complex of $R$-modules.
By Lemma \ref{lemma-qis-equivalence}
the functor $-\otimes^\mathbf{L}_{B'} B : D(B', \text{d}) \to D(B, \text{d})$
is an equivalence with quasi-inverse given by restriction.
Note that restriction is canonically isomorphic to the functor
$- \otimes^\mathbf{L}_B B : D(B, \text{d}) \to D(B', \text{d})$
where $B$ is viewed as a $(B, B')$-bimodule.
Thus it suffices to prove the lemma for the compositions
$$
D(A) \to D(B) \to D(B'),\quad
D(B') \to D(B) \to D(C),\quad
D(A) \to D(B') \to D(C).
$$
The first one is Lemma \ref{lemma-compose-tensor-functors}
because $B'$ is K-flat as a complex of $R$-modules.
The second one is true because
$B \otimes_B^\mathbf{L} N' = N' = B \otimes_B N'$
and hence Lemma \ref{lemma-compose-tensor-functors-general} applies.
Thus we reduce to the case where $B$ is K-flat as a complex
of $R$-modules.

\medskip\noindent
Assume $B$ is K-flat as a complex of $R$-modules. It suffices to
show that (\ref{equation-plain-versus-derived-algebras}) is an
isomorphism, see
Lemma \ref{lemma-compose-tensor-functors-general-algebra}.
Choose a quasi-isomorphism $L \to A$ where $L$ is a differential
graded $R$-module which has property (P). Then it is clear that
$P = L \otimes_R B$ has property (P) as a differential graded $B$-module.
Hence we have to show that $P \to A \otimes_R B$
induces a quasi-isomorphism
$$
P \otimes_B (B \otimes_R C)
\longrightarrow
(A \otimes_R B) \otimes_B (B \otimes_R C)
$$
We can rewrite this as
$$
P \otimes_R B \otimes_R C \longrightarrow A \otimes_R B \otimes_R C
$$
Since $B$ is K-flat as a complex of $R$-modules, it
follows from
More on Algebra, Lemma \ref{more-algebra-lemma-K-flat-quasi-isomorphism}
that it is enough
to show that
$$
P \otimes_R C \to A \otimes_R C
$$
is a quasi-isomorphism, which is exactly our assumption.
\end{proof}

\noindent
The following lemma does not really belong in this section, but there
does not seem to be a good natural spot for it.

\begin{lemma}
\label{lemma-countable}
Let $(A, \text{d})$ be a differential graded algebra with
$H^i(A)$ countable for each $i$. Let $M$ be an object of $D(A, \text{d})$.
Then the following are equivalent
\begin{enumerate}
\item $M = \text{hocolim} E_n$ with $E_n$ compact in $D(A, \text{d})$, and
\item $H^i(M)$ is countable for each $i$.
\end{enumerate}
\end{lemma}

\begin{proof}
Assume (1) holds. Then we have $H^i(M) = \colim H^i(E_n)$ by
Derived Categories, Lemma \ref{derived-lemma-cohomology-of-hocolim}.
Thus it suffices to prove that $H^i(E_n)$ is countable for each $n$.
By Proposition \ref{proposition-compact} we see that $E_n$
is isomorphic in $D(A, \text{d})$ to a direct summand of a
differential graded module $P$ which has a finite filtration
$F_\bullet$ by differential graded submodules
such that $F_jP/F_{j - 1}P$ are finite direct sums of shifts of $A$.
By assumption the groups $H^i(F_jP/F_{j - 1}P)$ are countable.
Arguing by induction on the length of the filtration and using
the long exact cohomology sequence we conclude that (2) is true.
The interesting implication is the other one.

\medskip\noindent
We claim there is a countable differential graded
subalgebra $A' \subset A$ such that the inclusion map
$A' \to A$ defines an isomorphism on cohomology.
To construct $A'$ we choose countable differential graded
subalgebras
$$
A_1 \subset A_2 \subset A_3 \subset \ldots
$$
such that (a) $H^i(A_1) \to H^i(A)$ is surjective, and (b)
for $n > 1$ the kernel of the map $H^i(A_{n - 1}) \to H^i(A_n)$
is the same as the kernel of the map $H^i(A_{n - 1}) \to H^i(A)$.
To construct $A_1$ take any countable collection of cochains
$S \subset A$ generating the cohomology of $A$ (as a ring or as
a graded abelian group) and let
$A_1$ be the differential graded subalgebra of $A$ generated by $S$.
To construct $A_n$ given $A_{n - 1}$ for each cochain $a \in A_{n - 1}^i$
which maps to zero in $H^i(A)$ choose $s_a \in A^{i - 1}$
with $\text{d}(s_a) = a$ and let $A_n$ be the differential graded
subalgebra of $A$ generated by $A_{n - 1}$ and the elements $s_a$.
Finally, take $A' = \bigcup A_n$.

\medskip\noindent
By Lemma \ref{lemma-qis-equivalence}
the restriction map $D(A, \text{d}) \to D(A', \text{d})$,
$M \mapsto M_{A'}$ is an equivalence. Since the cohomology
groups of $M$ and $M_{A'}$ are the same, we see that it
suffices to prove the implication (2) $\Rightarrow$ (1)
for $(A', \text{d})$.

\medskip\noindent
Assume $A$ is countable. By the exact same type of argument as
given above we see that for $M$ in $D(A, \text{d})$
the following are equivalent: $H^i(M)$ is countable for each $i$
and $M$ can be represented by a countable differential graded module.
Hence in order to prove the implication (2) $\Rightarrow$ (1)
we reduce to the situation described in the next paragraph.

\medskip\noindent
Assume $A$ is countable and that $M$ is a countable differential graded
module over $A$. We claim there exists a homomorphism
$P \to M$ of differential graded $A$-modules such that
\begin{enumerate}
\item $P \to M$ is a quasi-isomorphism,
\item $P$ has property (P), and
\item $P$ is countable.
\end{enumerate}
Looking at the proof of the construction of P-resolutions in
Lemma \ref{lemma-resolve} we see that it suffices to show that
we can prove Lemma \ref{lemma-good-quotient}
in the setting of countable differential graded modules.
This is immediate from the proof.

\medskip\noindent
Assume that $A$ is countable and that $M$ is a countable
differential graded module with property (P). Choose a filtration
$$
0 = F_{-1}P \subset F_0P \subset F_1P \subset \ldots \subset P
$$
by differential graded submodules such that we have
\begin{enumerate}
\item $P = \bigcup F_pP$,
\item $F_iP \to F_{i + 1}P$ is an admissible monomorphism,
\item isomorphisms of differential graded modules
$F_iP/F_{i - 1}P \to \bigoplus_{j \in J_i} A[k_j]$
for some sets $J_i$ and integers $k_j$.
\end{enumerate}
Of course $J_i$ is countable for each $i$. For each $i$ and
$j \in J_i$ choose $x_{i, j} \in F_iP$ of degree $k_j$ whose
image in $F_iP/F_{i - 1}P$ generates the summand corresponding
to $j$.

\medskip\noindent
Claim: Given $n$ and finite subsets $S_i \subset J_i$, $i = 1, \ldots, n$
there exist finite subsets $S_i \subset T_i \subset J_i$, $i = 1, \ldots, n$
such that $P' = \bigoplus_{i \leq n} \bigoplus_{j \in T_i} Ax_{i, j}$
is a differential graded submodule of $P$. This was shown in the
proof of Lemma \ref{lemma-factor-through-nicer} but it is also
easily shown directly: the elements $x_{i, j}$ freely generate
$P$ as a right $A$-module. The structure of $P$ shows that
$$
\text{d}(x_{i, j}) = \sum\nolimits_{i' < i} x_{i', j'}a_{i', j'}
$$
where of course the sum is finite.
Thus given $S_0, \ldots, S_n$ we can first choose
$S_0 \subset S'_0, \ldots, S_{n - 1} \subset S'_{n - 1}$ with
$\text{d}(x_{n, j}) \in \bigoplus_{i' < n, j' \in S'_{i'}} x_{i', j'}A$
for all $j \in S_n$. Then by induction on $n$ we can choose
$S'_0 \subset T_0, \ldots, S'_{n - 1} \subset T_{n - 1}$
to make sure that $\bigoplus_{i' < n, j' \in T_{i'}} x_{i', j'}A$
is a differential graded $A$-submodule. Setting $T_n = S_n$ we find that
$P' = \bigoplus_{i \leq n, j \in T_i} x_{i, j}A$ is as desired.

\medskip\noindent
From the claim it is clear that $P = \bigcup P'_n$
is a countable rising union of $P'_n$ as above.
By construction each $P'_n$ is a differential graded module with
property (P) such that the filtration is finite and the succesive
quotients are finite direct sums of shifts of $A$. Hence $P'_n$
defines a compact object of $D(A, \text{d})$, see for example
Proposition \ref{proposition-compact}. Since
$P = \text{hocolim} P'_n$ in $D(A, \text{d})$
by Lemma \ref{lemma-homotopy-colimit}
the proof of the implication (2) $\Rightarrow$ (1) is complete.
\end{proof}




\input{chapters}

\bibliography{my}
\bibliographystyle{amsalpha}

\end{document}
