\chapter{Homological theory of local rings}

We will then apply the general theory to commutative algebra proper. The use
of homological machinery provides a new and elegant characterization of regular local
rings (among noetherian local rings, they are the ones with finite global
dimension) and leads to proofs of several difficult results about them.
For instance, we will be able to prove the rather important result (which one
repeatedly uses in algebraic geometry) that a
regular local ring is a UFD.
As another example, the aforementioned criterion leads to a direct proof of
the otherwise non-obvious that a localization of a regular local ring at a
prime ideal is still a regular local ring.

\textbf{Note: right now, the material on regular local rings is still missing!
It should be added.}

\section{Depth}

In this section, we first introduce the notion of \emph{depth} for local rings
via the $\ext$ functor, and then show that depth can be measured as the length
of a maximal \emph{regular sequence}. After this, we study the theory of
regular sequences in general (on not-necessarily-local rings), and show that
the depth of a module can be bounded in terms of both its dimension and its
associated primes. 
\subsection{Depth over local rings}

Throughout, let $(R, \mathfrak{m})$ be  a noetherian
local ring. Let $k = R/\mathfrak{m}$ be the residue field. 

Let $M \neq 0$ be a finitely generated $R$-module. We are going to define an
arithmetic invariant of $M$, called the \emph{depth}, that will measure in
some sense the torsion of $M$.

\begin{definition}
The \textbf{depth} of $M$ is equal to the smallest integer $i$
such that
$\ext^i(k,M) \neq 0$. If there is no such integer, we set $\depth M = \infty$.
\end{definition}

We shall give another characterization of this shortly that makes no reference
to $\ext$ functors, and is purely elementary.
We will eventually see that there is always such an $i$ (at least if $M \neq
0$), so $\depth M < \infty$.

\begin{example}[Depth zero] Let us characterize when a module $M$ has depth zero. 
Depth zero is equivalent to saying that $\ext^0(k,M) = \hom_R(k, M) \neq 0$,
i.e. that there is a
nontrivial morphism
\[ k \to M.  \]
As $k = R/\mathfrak{m}$, the existence of such a map is
equivalent to the existence of a nonzero $x$
such that $\ann(x) = \mathfrak{m}$, i.e. $\mathfrak{m} \in
\ass(M)$. So depth
zero is equivalent to having $\mathfrak{m} \in \ass(M)$.
\end{example}

Suppose now that $\depth(M) \neq 0$. In particular,
$\mathfrak{m} \notin
\ass(M)$. Since $\ass(M)$ is finite, prime avoidance implies that
$\mathfrak{m}
\not\subset \bigcup_{\mathfrak{p} \in \ass(M)} \mathfrak{p}$.
Thus
$\mathfrak{m}$ contains an element which is a nonzerodivisor on
$M$ (see \cref{assmdichotomy}). So we find:

\begin{proposition} \label{depthzero}
$M$ has depth zero iff every element in $\mathfrak{m}$ is a
zerodivisor on $M$.
\end{proposition}

Now suppose $\depth M \neq 0$. There is $a \in \mathfrak{m}$
which is a
nonzerodivisor on $M$, i.e.  such that there is
an exact sequence
\[ 0 \to M \stackrel{a}{\to} M \to M/aM \to 0.  \]
For each $i$, there is an  exact sequence in $\ext$ groups:
\begin{equation} \label{extlongextdepth}\ext^{i-1}(k,M/aM) \to \ext^i(k,M) \stackrel{a}{\to} \ext^i(k,M)
\to \ext^i(k,
M/aM) \to \ext^{i+1}(k,M)  .\end{equation}
However, the map $a: \ext^i(k,M) \to \ext^i(k,M)$ is zero as
multiplication by $a$
kills $k$. (If $a$ kills a module $N$,
then it kills
$\ext^*(N,M)$ for all $M$.) We see from this that
\[ \ext^i(k,M) \hookrightarrow \ext^i(k,M/aM)  \]
is injective, and
\[ \ext^{i-1}(k, M/aM) \twoheadrightarrow \ext^i(k,M)  \]
is surjective.

\begin{corollary} \label{depthdropsbyone}
If $a \in \mathfrak{m}$ is a nonzerodivisor on $M$, then
\[ \depth(M/aM) = \depth M -1.  \]
\end{corollary}
\begin{proof}
When $\depth M = \infty$, this is easy (left to the reader) from
the exact
sequence. Suppose $\depth(M) = n$. We would like to see that
$\depth M/aM =
n-1$. That is, we want to see that $\ext^{n-1}(k,M/aM) \neq 0$,
but
$\ext^i(k,M/aM) =
0$ for $i < n-1$. This is direct from the sequence \eqref{extlongextdepth} above.
In fact, surjectivity of $\ext^{n-1}(k,M/aM) \to \ext^n(k,M)$
shows that
$\ext^{n-1}(k,M/aM) \neq 0$. Now let $i < n-1$. 
Then in \eqref{extlongextdepth}, $\ext^i(k, M/aM)$ is sandwiched between two
zeros, so it is zero.
\end{proof}

The moral of the above discussion is that one quotients out by a nonzerodivisor, the depth drops by one.
In fact, we have described a recursive algorithm for computing
$\depth(M)$.
\begin{enumerate}
\item If $\mathfrak{m}  \in \ass(M)$, output zero.
\item If $\mathfrak{m} \notin \ass(M)$, choose an element $a
\in\mathfrak{m}$
which is a nonzerodivisor on $M$. Output $\depth(M/aM) +1$.
\end{enumerate}


If one wished to apply this in practice, one would probably start by
looking for a
nonzerodivisor $a_1 \in \mathfrak{m}$ on $M$, and then looking for
one on $M/a_1
M$, etc.
From this we make:

\begin{definition}
Let $(R, \mathfrak{m})$ be a local noetherian ring, $M$ a finite
$R$-module. A
sequence $a_1, \dots, a_n \in \mathfrak{m}$ is said to be
\textbf{$M$-regular} iff:
\begin{enumerate}
\item $a_1$ is a nonzerodivisor on $M$
\item $a_2$ is a nonzerodivisor on $M/a_1 M$
\item  $\dots$
\item $a_i$ is a nonzerodivisor on $M/(a_1, \dots, a_{i-1})M$
for all $i$.
\end{enumerate}
A regular sequence $a_1, \dots, a_n$ is \textbf{maximal } if it
can be extended
no further, i.e. there is no $a_{n+1}$ such that $a_1, \dots,
a_{n+1}$ is
$M$-regular.
\end{definition}

We now get the promised ``elementary'' characterization of depth. 
\begin{corollary} \label{depthregular}
$\depth(M)$ is the length of every maximal $M$-regular
sequence. In particular,
all $M$-regular sequences have the same length.
\end{corollary}

\begin{proof}
If $a_1, \dots, a_n$ is $M$-regular, then
\[ \depth M/(a_1, \dots, a_i)M = \depth M -i  \]
for each $i$, by an easy induction on $i$ and the \cref{depthdropsbyone}.
From this the result is clear, because depth zero occurs precisely when
$\mathfrak{m}$ is an associated prime (\cref{depthzero}). But it is also clear 
that a regular sequence $a_1, \dots, a_n$ is maximal precisely when every
element of $\mathfrak{m}$ acts as a zerodivisor on $M/(a_1, \dots, a_n) M$,
that is, $\mathfrak{m} \in \ass(M/(a_1, \dots, a_n)M)$.
\end{proof}

\begin{remark}
We could \emph{define} the depth via the length of a maximal
$M$-regular sequence.
\end{remark}

Finally, we can bound the depth in terms of the dimension. 

\begin{corollary}\label{depthboundlocal} Let $M \neq 0$. Then the depth of $M$ is finite. In fact,
\begin{equation} \label{depthbound} \depth M \leq \dim M.  \end{equation}
\end{corollary}
\begin{proof}
When $\depth M = 0$, the assertion is obvious.
Otherwise,
there is $ a \in \mathfrak{m}$ which is a nonzerodivisor on $M$.
We know that
\[ \depth M/aM = \depth M -1  \]
and (by \cref{dimdropsbyone})
\[ \dim  M/aM = \dim  M -1.  \]
By induction on $\dim M$, we have that $\depth M/aM \leq \dim M/aM$.
From this the
induction step is clear, because $\depth$ and $\dim$ both drop by one after
quotienting.
\end{proof}

Generally, the depth is not the dimension.
\begin{example}
Given any $M$, adding $k$ makes the depth zero: $M \oplus k$
has $\mathfrak{m}$ as an associated prime. But the dimension
 does not
jump to zero just by adding a copy of $k$. If $M$ is a direct sum of pieces of
differing dimensions, then the bound \eqref{depthbound} does not exhibit
equality.
In fact, if $M, M'$ are finitely generated modules, then we have
\[ \depth M \oplus M' = \min \left(\depth M, \depth M' \right),  \]
which follows at once from the definition of depth in terms of
vanishing $\ext$ groups.
\end{example}

\begin{exercise} 
Suppose $R$ is a noetherian local ring whose depth (as a module over itself)
is zero. If $R$ is reduced, then $R$ is a field. 
\end{exercise} 

Finally, we include a result that states that the depth does not depend
on the ring so much as the module.
\begin{proposition}[Depth and change of rings]
Let $(R, \mathfrak{m}) \to (S, \mathfrak{n})$ be a morphism of
noetherian local rings. Suppose $M$ is a finitely generated $S$-module,
which is also finitely generated as an $R$-module. Then 
$\depth_R M = \depth_S M$.
\end{proposition} 
\begin{proof} 
It is clear that we have the inequality $\depth_R M \leq \depth_S M$, by the
interpretation of depth via regular sequences. Let $x_1, \dots, x_n \in R$
be a maximal $M$-sequence. We need to show that it is a maximal $M$-sequence
in $S$ as well. By quotienting, we may replace $M$ with $M/(x_1,\dots, x_n)M$;
we then have to show that if $M$ has depth zero as an $R$-module, it has
depth zero as an $S$-module.

But then $\hom_R(R/\mathfrak{m}, M) \neq 0$. This is a $R$-submodule of
$M$, consisting of elements killed by $\mathfrak{m}$,
and in fact it is a $S$-submodule. We are going to show that $\mathfrak{n}$
annihilates some element of it, which will imply that $\depth_S M = 0$.

To see this, note that $\hom_R(R/\mathfrak{m}, M)$ is artinian as an
$R$-module (as it is killed by $\mathfrak{m}$). As a result, it is an
artinian $S$-module, which means it contains $\mathfrak{n}$ as an
associated prime, proving the claim and the result.
\end{proof} 
\subsection{Regular sequences}

In the previous subsection, we defined the notion of \emph{depth} of a
finitely generated module over a noetherian local ring using the $\ext$
functors. We then showed that the depth was the length of a maximal regular
sequence. 

Now, although it will not be necessary for the main results in this chapter, we want to generalize this to the case of a non-local ring. Most of the
same arguments go through, though there are some subtle differences. For
instance, regular sequences remain regular under permutation in the local
case, but not in general. Since there will be some repetition, we shall try to
be brief.

We start by generalizing the idea of a regular sequence which is not required
to be contained in the maximal ideal of a local ring.
Let $R$ be a noetherian ring, and $M$ a finitely generated $R$-module. 
\begin{definition} 
A sequence $x_1, \dots, x_n \in R$ is \textbf{$M$-regular} (or is an
\textbf{$M$-sequence}) if for each $k \leq n$, $x_k$ is a nonzerodivisor on the
$R$-module $M/(x_1, \dots, x_{k-1}) M$ and also $(x_1, \dots, x_n) M \neq M$. 	\end{definition} 

So $x_1$ is a nonzerodivisor on $M$, by the first part. That is, the homothety
$M \stackrel{x_1}{\to} M$ is injective. 
The last condition is also going to turn out to be necessary for us. In the
previous subsection, it was automatic as $\mathfrak{m}M \neq M$ (unless $M =
0$) by Nakayama's lemma as $M$ was assumed finitely generated.	


The property of being a regular sequence is inherently an inductive one. Note
that $x_1, \dots, x_n$ is a regular sequence on $M$ if and only if $x_1$ is a
zerodivisor on $M$ and $x_2, \dots, x_n$ is an $M/x_1 M$-sequence.


\begin{definition} 
If $M$ is an $R$-module and $I \subset R$ an ideal, then we write $\depth_I M$
for the length of the length-maximizing $M$-sequence contained in $I$.
When $R$ is local and $I \subset R$ the maximal ideal, then we just write
$\depth M$ as before.
\end{definition} 

While we will in fact have a similar characterization of $\depth$ in terms of
$\ext$, in this section we \emph{define} it via regular sequences.

\begin{example} 
The basic example one is supposed to keep in mind is the polynomial ring $R =
R_0[x_1, \dots, x_n]$ and $M = R$. Then the sequence $x_1, \dots, x_n$ is
regular in $R$.
\end{example} 

\begin{example} 
Let $(R, \mathfrak{m})$ be a regular local ring, and let $x_1, \dots, x_n$ be a
regular system of parameters in $R$ (i.e. a system of generators for
$\mathfrak{m}$ of minimal size). Then we have seen that the
$\left\{x_i\right\}$ form a regular sequence on $R$, in any order. This is
because each quotient $R/(x_1, \dots, x_i)$ is itself regular, hence a domain.
\end{example} 

As before, we have a simple characterization of depth zero:
\begin{proposition} Let $R$ be noetherian, $M$ finitely generated.
If $M$ is an $R$-module with $IM \neq M$, then $M$ has depth zero if and only
if $I $ is contained in an element of $\ass(M)$.
\end{proposition} 
\begin{proof} 
This is analogous to \cref{depthzero}. Note than an ideal consists of
zerodivisors on $M$ if and only if it is contained in an associated prime
(\cref{assmdichotomy}).
\end{proof} 

The above proof used \cref{assmdichotomy}, a key fact which will be used
repeatedly in the sequel.
This is one reason the theory of depth works best for finitely generated
modules over noetherian rings.

The first observation to make is that regular sequences are \textit{not}
preserved by permutation. This is one nice characteristic that we would like
but is not satisfied.

\begin{example} Let $k $ be a field.
Consider $R=k[x,y]/((x-1)y, yz)$. Then $x,z$ is a regular sequence on $R$. Indeed,
$x$ is a nonzerodivisor and $R/(x) = k[z]$.  However, $z,
x$ is not a regular sequence because $z$ is a zerodivisor in $R$.
\end{example} 

Nonetheless, regular sequences \emph{are} preserved by permutation for local rings under
suitable noetherian hypotheses: 
\begin{proposition} 
Let $R$ be a noetherian local ring and $M$ a finite $R$-module. Then if $x_1,
\dots, x_n$ is a $M$-sequence contained in the maximal ideal, so is any permutation $x_{\sigma(1)}, \dots,
x_{\sigma(n)}$.
\end{proposition} 
\begin{proof} 
It is clearly enough to check this for a transposition. Namely, if we have an
$M$-sequence
\[ x_1, \dots, x_i, x_{i+1}, \dots x_n  \]
we would like to check that so is
\[ x_1, \dots, x_{i+1}, x_i, \dots, x_n.  \]
It is here that we use the inductive nature. Namely, all we need to do is check
that
\[ x_{i+1}, x_i, \dots,x_n  \]
is regular on $M/(x_1, \dots,x_{i-1}) M$, since the first part of the sequence
will automatically be regular. Now $x_{i+2}, \dots, x_n$ will automatically be
regular on $M/(x_1, \dots, x_{i+1})M$. So all we need to show is that
$x_{i+1}, x_i$ is regular on $M/(x_1, \dots, x_{i-1})M$.

The moral of the story is that we have reduced to the following lemma.

\begin{lemma} 
Let $R$ be a noetherian local ring. Let $N$
be a finite $R$-module and 
$a,b \in R$ an $N$-sequence contained in the maximal ideal. Then so is $b,a$.
\end{lemma} 
\begin{proof}
We can prove this as follows. First, $a$ will be a nonzerodivisor on $N/bN$.
Indeed, if not then we can write
\[ an = bn'  \]
for some $n,n' \in N$ with $n \notin bN$. But $b$ is a nonzerodivisor on
$N/aN$, which means that $bn' \in aN$ implies $n' \in aN$. Say $n' = an''$. So
$an = ba n''$. As $a$ is a nonzerodivisor on $N$, we see that $n = bn''$. Thus
$n \in bN$, contradiction.
This part has not used the fact that $R$ is local.

Now we claim that $b$ is a nonzerodivisor on $N$. Suppose $n \in N$ and $bn =
0$. Since $b$ is a nonzerodivisor on $N/aN$, we have that $n \in aN$, say $n =
an'$. Thus 
\[ b(an') = a(bn') = 0.  \]
The fact that $N \stackrel{a}{\to} N$ is injective implies that $bn' = 0$. So
we can do the same and get $n' = an''$, $n'' = a n^{(3)}, n^{(3)} =a n^{(4)}$, and
so on. It follows that $n$ is a multiple of $a, a^2,a^3, \dots$, and hence in
$\mathfrak{m}^j N$ for each $j$ where $\mathfrak{m} \subset R$ is the maximal
ideal. The Krull intersection theorem now implies that $n = 0$. 

Together, these arguments imply that $b,a$ is an $N$-sequence, proving the
lemma.
\end{proof} 
The proof of the result is now complete.
\end{proof}


One might wonder what goes wrong, and why permutations do not preserve
regular sequences in general; after all, oftentimes we can reduce results
to their analogs for local rings. Yet the fact that regularity is preserved by
permutations for local rings does not extend to arbitrary rings.
The problem is that regular sequences do \emph{not} localize. Well, they almost
do, but the final condition that $(x_1, \dots, x_n) M \neq M$ doesn't get
preserved.
We can state:

\begin{proposition} 
Suppose $x_1, \dots, x_n$ is an $M$-sequence. Let $N$ be a flat $R$-module.
Then if $(x_1, \dots, x_n)M \otimes_R N \neq M \otimes N$, then $x_1, \dots, x_n$
is an $M \otimes_R N$-sequence.
\end{proposition} 
\begin{proof} 
This is actually very easy now. The fact that $x_i: M/(x_1, \dots, x_{i-1})M
\to M/(x_1, \dots, x_{i-1})M$ is injective is preserved when $M$ is replaced by
$M \otimes_R N$ because the functor $- \otimes_R N$ is exact. 
\end{proof} 

In particular, it follows that if we have a good reason for supposing that
$(x_1,\dots, x_n) M \otimes N \neq M \otimes N$, then we'll already be
done. For instance, if $N$ is the localization of $R$ at a prime ideal
containing the $x_i$. Then we see that automatically $x_1, \dots, x_n$ is an
$M_{\mathfrak{p}} = M \otimes_R R_{\mathfrak{p}}$-sequence. 

Finally, we have an analog of the previous correspondence between depth and
the vanishing of $\ext$. Since the argument is analogous to
\cref{depthregular}, we omit it.
\begin{theorem}
\label{depthextI}
Let $R$ be a ring. Suppose $M$ is an $R$-module and $IM \neq M$.
All maximal $M$-sequences in $I$ have the same length. This length is the
smallest value of $r$ such that $\mathrm{Ext}^r(R/I, M) \neq 0$.
\end{theorem} 

\begin{exercise} 
Suppose $I$ is an ideal in $R$. Let $M$ be an $R$-module such that $IM \neq
M$. Show that $\depth_I M \geq 2$ if and only if the natural map
\[ M \simeq \hom(R, M) \to \hom(I, M)  \]
is an isomorphism.
\end{exercise} 


\subsection{Powers of regular sequences}

Regular sequences don't necessarily behave well with respect to permutation or
localization without additional hypotheses. However, in all cases they behave
well with respect to taking powers. The upshot of this is that the invariant
called \textit{depth} that we will soon introduce is invariant under passing to
the radical.

We shall deduce this from the following easy fact.
\begin{lemma} 
Suppose we have an exact sequence of $R$-modules
\[  0 \to M' \to M \to M'' \to 0.  \]
Suppose the sequence $x_1, \dots, x_n \in R$ is $M'$-regular and $M''$-regular.
Then it is $M$-regular.
\end{lemma} 
The converse is not true, of course.
\begin{proof} 
Morally, this is the snake lemma. For instance, the fact that multiplication by
$x_1$ is injective on $M', M''$ implies by the snake diagram that $M
\stackrel{x_1}{\to} M$ is injective. However, we don't a priori know that a
simple inductive argument on $n$ will work to prove this. The reason is that it needs
to be seen that quotienting each term by $(x_1, \dots, x_{n-1})$ will preserve
exactness. However, a general fact will tell us that this is indeed the case.
See below.

Anyway, this general fact now lets us induct on $n$. If we assume
that $x_1, \dots, x_{n-1}$ is $M$-regular, we need only prove that $x_{n}:
M/(x_1, \dots, x_{n-1})M
\to M/(x_1, \dots, x_{n-1})$ is injective. (It is not surjective or the
sequence would not be $M''$-regular.) But we have the exact sequence by the
next lemma,
\[ 0 \to M'/(x_1 \dots x_{n-1})M' \to M/(x_1 \dots x_{n-1})M \to  M''/(x_1
\dots x_{n-1})M'' \to 0 \]
and the injectivity of $x_n$ on the two ends implies it at the middle by the
snake lemma.
\end{proof} 

So we need to prove:
\begin{lemma} 
Suppose $0 \to M' \to M \to M'' \to 0$ is a short exact sequence. Let $x_1,
\dots, x_m$ be an $M''$-sequence. Then the sequence
\[ 0 \to M'/(x_1 \dots x_m)M' \to M/(x_1 \dots x_m)M \to   M''/(x_1 \dots
x_m)M'' \to 0\]
is exact as well.
\end{lemma} 
One argument here uses the fact that the Tor functors vanish when one has a
regular sequence like this. We can give a direct argument. 
\begin{proof} 
By induction, this needs only be proved when $m=1$, since we have the recursive
description of regular sequences: in general, $x_2 \dots x_m$ will be regular
on $M''/x_1 M''$. 
In any case, we have exactness except possibly at the left as the tensor
product is right-exact. So let $m' \in M'$; suppose $m'$ maps to a multiple of
$x_1$ in $M$. We need to show that $m'$ is a multiple of $x_1$ in $M'$. 

Suppose $m'$ maps to $x_1 m$. Then $x_1m$ maps to zero in $M''$, so by regularity $m$
maps to zero in $M''$. Thus $m$ comes from something, $\overline{m}'$, in $M'$. In particular
$m' - x_1 \overline{m}'$ maps to zero in $M$, so it is zero in $M'$. Thus
indeed $m'$ is a multiple of $x_1$ in $M'$.
\end{proof} 

With this lemma proved, we can state:
\begin{proposition} 
\label{powregseq}
Let $M$ be an $R$-module and $x_1, \dots, x_n$ an $M$-sequence. Then $x_1^{a_1}
,\dots, x_n^{a_n}$ is an $M$-sequence for any $a_1, \dots, a_n \in
\mathbb{Z}_{>0}$.
\end{proposition} 

\begin{proof}
We will use:
\begin{lemma} 
Suppose $x_1, \dots, x_i, \dots, x_n$ and $x_1, \dots, x_i', \dots, x_n$ are
$M$-sequences for some $M$. Then so is $x_1, \dots, x_i x_i', \dots, x_n$.
\end{lemma} 

\begin{proof} 
As usual, we can mod out by $(x_1 \dots x_{i-1})$ and thus assume that $i=1$.
We have to show that if $x_1, \dots, x_n$ and $x_1', \dots, x_n$ are
$M$-sequences, then so is $x_1 x_1', \dots, x_n$.

We have an exact sequence
\[ 0 \to x_1 M/x_1 x_1' M \to M/x_1 x_1' M \to  M/x_1  M \to 0.  \]
Now $x_2, \dots, x_n$ is regular  on the last term by assumption, and also on
the first term, which is isomorphic to $M/x_1' M$ as $x_1$ acts as a
nonzerodivisor on $M$. So $x_2, \dots, x_n$ is regular on both ends, and thus
in the middle. This means that 
\[ x_1 x_1', \dots, x_n  \]
is $M$-regular. That proves the lemma. 
\end{proof} 

So we now can prove the proposition. It is trivial if $\sum a_i = n$ (i.e. if
all are $1$) it is clear. In general, we can use complete induction on $\sum
a_i$. Suppose we know the result for smaller values of $\sum a_i$. We can
assume that some $a_j >1$. 
Then  the sequence
\[ x_1^{a_1}, \dots x_j^{a_j} , \dots x_n^{a_n} \]
is obtained from the sequences
\[  x_1^{a_1}, \dots,x_j^{a_j - 1}, \dots, x_n^{a_n} \]
and
\[  x_1^{a_1}, \dots,x_j^{1}, \dots, x_n^{a_n} \]
by multiplying the middle terms. But the complete induction hypothesis implies
that both those two sequences are $M$-regular, so we can apply the lemma. 
\end{proof} 

In general, the product of two regular sequences is not a regular sequence. For
instance, consider a regular sequence $x,y$ in some finitely generated module $M$ over a
noetherian local ring. Then $y,x$ is regular, but the product sequence $xy, xy$
is \emph{never} regular.


\subsection{Depth}

We make the following definition slightly differently than in the local case:

\begin{definition} 
Suppose $I$ is an ideal such that $IM \neq M$. Then we define the
\textbf{$I$-depth of $M$} to be the maximum length of a maximal $M$-sequence contained
in $I$. When $R$ is a local ring and $I$ the maximal ideal, then that number is
simply called the \textbf{depth} of $M$.

The \textbf{depth} of a proper ideal $I \subset R$ is its depth on $R$.
\end{definition} 


The definition is slightly awkward, but it turns out that all maximal
$M$-sequences in $I$ have the same length, as we saw in \cref{depthextI}. So we can use any of them to compute
the depth. 

The first thing we can prove using the above machinery is that depth is really
a ``geometric'' invariant, in that it depends only on the radical of $I$.

\begin{proposition} 
Let $R$ be a ring, $I \subset R$ an ideal, and $M$ an $R$-module
with $IM \neq M$. Then $\mathrm{depth}_I M = \mathrm{depth}_{\mathrm{Rad}(I)} M$.
\end{proposition} 
\begin{proof} 
The inequality $\mathrm{depth}_I M \leq \mathrm{depth}_{\mathrm{Rad} I} M$ is trivial, so we need only
show that if $x_1, \dots, x_n$ is an $M$-sequence in $\mathrm{Rad}(I)$, then there is
an $M$-sequence of length $n$ in $I$. For this we just take a high power
\[ x_1^N, \dots, x_n^{N}  \]
where $N$ is large enough such that everything is in $I$. We can do this as
powers of $M$-sequences are $M$-sequences (\cref{powregseq}).
\end{proof} 

This was a fairly easy consequence of the above result on powers of regular
sequences. On the other hand, we want to give another proof, because it will
let us do more. Namely, we will show that depth is really a function of prime
ideals.

For convenience, we set the following condition: if $IM = M$, we define
\[ \mathrm{depth}_I (M) = \infty.  \]

\begin{proposition} \label{depthlocal}
Let $R$ be a noetherian ring, $I \subset R$ an ideal, and $M$ a finitely generated $R$-module. 
Then
\[ \mathrm{depth}_I M = \min_{\mathfrak{p} \in V(I)} \mathrm{depth}_{\mathfrak{p}} M .  \]
\end{proposition} 

So the depth of $I$ on $M$ can be calculated  from the depths at each
prime containing $I$. In this sense, it is clear that $\mathrm{depth}_I (M)$ depends
only on $V(I)$ (and the depths on those primes), so clearly it depends only on
$I$ \emph{up to radical}.

\begin{proof} 
In this proof, we shall {use the fact that the length of every maximal
$M$-sequence is the same} (\cref{depthextI}).

It is obvious that we have an inequality
\[ \mathrm{depth}_I \leq  \min_{\mathfrak{p} \in V(I)} \mathrm{depth}_{\mathfrak{p}} M \]
as each of those primes contains $I$. 
We are to prove that there is 
a prime $\mathfrak{p}$ containing $I$ with
\[ \mathrm{depth}_I M = \mathrm{depth}_{\mathfrak{p}} M . \]
But we shall actually prove the stronger statement that there is $\mathfrak{p}
\supset I$ with $\mathrm{depth}_{\mathfrak{p}} M_{\mathfrak{p}} = \mathrm{depth}_I M$. Note
that localization at a prime can only increase depth because an $M$-sequence in
$\mathfrak{p}$ leads to an $M$-sequence in $M_{\mathfrak{p}}$ thanks to
Nakayama's lemma and the flatness of localization.

So let $x_1, \dots, x_n \in I$ be a $M$-sequence of maximum length. Then $I$
acts by zerodivisors on 
$M/(x_1 , \dots, x_n) M$ or we could extend the sequence further. 
In particular, $I$ is contained in an associated prime of $M/(x_1, \dots, x_n)
M$ by elementary commutative algebra (basically, prime avoidance).

Call this associated prime $\mathfrak{p} \in V(I)$. Then $\mathfrak{p}$ is an
associated prime of $M_{\mathfrak{p}}/(x_1, \dots, x_n) M_{\mathfrak{p}}$,
and in particular acts only by zerodivisors on this module. 
Thus the $M_{\mathfrak{p}}$-sequence $x_1, \dots, x_n$ can be extended no
further in $\mathfrak{p}$. In particular, since  the depth
can be computed as the length of \emph{any} maximal $M_{\mathfrak{p}}$-sequence,
\[ \mathrm{depth}_{\mathfrak{p}} M_{\mathfrak{p}} = \mathrm{depth}_I M. \]
\end{proof} 

Perhaps we should note a corollary of the argument above:
\begin{corollary} \label{depthlocal2}
Hypotheses as above, we have $\mathrm{depth}_I M  \leq \mathrm{depth}_\mathfrak{p} M_{\mathfrak{p}}$ for
any prime $\mathfrak{p} \supset I$. However, there is at least one $\mathfrak{p}
\supset I$ where equality holds. \end{corollary}

We are thus reduced to analyzing depth in the local case.

\begin{exercise} 
\label{exer:depthcompletion}
If $(R, \mathfrak{m})$ is a local noetherian ring and $M$ a finitely
generated $R$-module, then show that $\depth M = \depth_{\hat{R}} \hat{M}$,
where $\hat{M}$ is the $\mathfrak{m}$-adic completion. (Hint: use $\hat{M}= M
\otimes_R \hat{R}$, and the fact that $\hat{R}$ is flat over $R$.)
\end{exercise} 
\subsection{Depth and dimension}

Consider an $R$-module $M$, which is always assumed to be finitely generated.
Let $I \subset R$ be an ideal with $IM \neq M$. 
We deduce from the previous subsections:
\begin{proposition} 
Let $M$ be a finitely generated module over the noetherian ring $R$. Then
\[ \mathrm{depth}_I M \leq \dim M  \]
for any ideal $I \subset R$ with $IM \neq M$.
\end{proposition} 
\begin{proof} 
We have proved this when $R$ is a \emph{local}  ring
(\cref{depthboundlocal}). Now we just use \cref{depthlocal2} to reduce to the
local case. 
\end{proof} 

This does not tell us much about how $\mathrm{depth}_I M$ depends on $I$, though; it
just says something about how it depends on $M$. In particular, it is not very
helpful when trying to estimate $\mathrm{depth} I = \mathrm{depth}_I R$.
Nonetheless, there is a somewhat stronger result, which we will need in the
future.
We start by stating the version in the local case. 

\begin{proposition} \label{localdepthassbound}
Let $(R,\mathfrak{m})$ be a noetherian local ring. Let $M$ be a finite
$R$-module. Then the depth of $\mathfrak{m}$ on $M$ is at most the dimension of
$R/\mathfrak{p}$ for $\mathfrak{p}$ an associated prime of $M$:
\[ \depth M \leq \min_{\mathfrak{p} \in \ass(M)}\dim R/\mathfrak{p}.  \]
\end{proposition} 

This is sharper than the bound $\depth M \leq \dim M$, because each $\dim
R/\mathfrak{p}$ is at most $\dim M$ (by definition).
\begin{proof}
To prove this, first assume that the depth is zero. In that case, the result is
immediate. We shall now argue inductively.
Assume that that this is true for modules of smaller depth. 
We will quotient out appropriately to shrink the
support and change the associated 
primes. Namely, choose a $M$-regular (nonzerodivisor on $M$) $x \in R$. 
Then $\mathrm{depth} M/xM = \mathrm{depth} M -1$. 

Let $\mathfrak{p}_0$ be an associated prime of $M$.
We  claim that $\mathfrak{p}_0$ is \emph{properly} contained in an associated prime of
$M/xM$. 
We will prove this below.
Thus $\mathfrak{p}_0$ is properly contained in some $\mathfrak{q}_0 \in
\ass(M/xM)$.

Now we know that $\mathrm{depth} M/xM = \mathrm{depth} M -1$. Also, by the inductive
hypothesis, we know that $\dim R/\mathfrak{q}_0 \geq \mathrm{depth} M/xM = \mathrm{depth} M
-1$. But the dimension of $R/\mathfrak{q}_0$ is strictly smaller than that of
$R/\mathfrak{p}_0$, so at least $\dim R/\mathfrak{p}_0 +1 \geq \mathrm{depth} M$. This
proves the lemma, modulo the result:

\begin{lemma} \label{screwylemmaonquotientassprime} 
Let $(R, \mathfrak{m})$ be a noetherian local ring. Let $M$ be a finitely
generated $R$-module, $x \in \mathfrak{m}$ an $M$-regular element.
Then each element of $\ass(M)$ is properly contained in an element of
$\ass(M/xM)$.
\end{lemma} 
So if we quotient by a regular element, we can make the associated primes jump
up.
\begin{proof} Let $\mathfrak{p}_0 \in \ass(M)$; we want to show
$\mathfrak{p}_0$ is properly contained in something in $\ass(M/xM)$.

Indeed, $x \notin \mathfrak{p}_0$, so $\mathfrak{p}_0$ cannot itself be
an associated prime. 
However, $\mathfrak{p}_0$ annihilates a nonzero element of $M/xM$. To see this,
consider a maximal principal submodule of $M$ annihilated by $\mathfrak{p}_0$.
Let this submodule be $Rz$ for some $z \in M$. Then if $z$ is a multiple of
$x$, say $z = xz'$, then $Rz'$ would be a larger
submodule of $M$ annihilated by $\mathfrak{p}_0$---here we are using the fact
that $x$ is a nonzerodivisor on $M$. So the image of this $z$ in $M/xM$ is
nonzero and is clearly annihilated by $\mathfrak{p}_0$. 
It follows $\mathfrak{p}_0$ is contained in an element of
$\ass(M/xM)$, necessarily properly.
\end{proof}

\end{proof} 
\begin{exercise} 
Another argument  for \cref{screwylemmaonquotientassprime} is given in \S 16 of \cite{EGA}, vol. IV, by reducing to
the coprimary case. Here is a sketch.

The strategy is to use the existence of an exact sequence
\[ 0 \to M' \to M \to M'' \to 0  \]
with $\ass(M'') = \ass(M) - \left\{\mathfrak{p}_0\right\}$ and
$\ass(M') = \left\{\mathfrak{p}_0\right\}$. 
Quotienting by $x$ preserves exactness, and we get
\[ 0 \to M'/xM' \to M/xM \to M''/xM'' \to 0.  \]
Now $\mathfrak{p}_0$ is properly contained in every associated prime of
$M'/xM'$ (as it acts nilpotently on $M'$). It follows that any element of
$\ass(M'/xM') \subset \ass(M/xM)$ will do the job.

In essence, the point is that the result is \emph{trivial} when $\ass(M)
= \left\{\mathfrak{p}_0\right\}$.
\end{exercise} 

\begin{exercise} 
Here is a simpler argument for \cref{screwylemmaonquotientassprime},
following \cite{Se65}. 
Let $\mathfrak{p}_0 \in \ass(M)$, as before. Again as before, we want  to show that
$\hom_R(R/\mathfrak{p}_0, M/xM) \neq 0$.
But we have an exact sequence 
\[ 0 \to \hom_R(R/\mathfrak{p}_0, M) 
\stackrel{x}{\to} \hom_R(R/\mathfrak{p}_0, M) \to
\hom_R(R/\mathfrak{p}_0, M/xM) ,
\]
and since the first map is not surjective (by Nakayama), the last
object is nonzero.
\end{exercise} 

Finally, we can globalize the results:

\begin{proposition} 
Let $R$ be a noetherian ring, $I \subset R$ an ideal, and $M$ a finitely
generated module. Then $\mathrm{depth}_I M$ is at most the length of every  chain
of primes in $\mathrm{Spec} R$ that starts at an associated prime of $M$ and
ends at a prime containing $I$.
\end{proposition} 

\begin{proof} Currently omitted. 
\begin{comment}
Consider a chain of primes $\mathfrak{p}_0 \subset \dots \subset
\mathfrak{p}_k$ where $\mathfrak{p}_0$ is an associated prime and
$\mathfrak{p}_k$ contains $I$. 
The goal is to show that 
\[  \mathrm{depth}_I M \leq k .  \]
By localization, we can assume that $\mathfrak{p}_k$ is the maximal ideal of
$R$; recall that localization can only increase the depth.
We can also assume $I$ is this maximal ideal, by increasing it.

In this case, the result follows from the local version
(\cref{localdepthassbound}). 
\end{comment}
\end{proof}


\section{Cohen-Macaulayness}

\subsection{Cohen-Macaualay modules over a local ring}
For a local noetherian ring, we have discussed two invariants of a module:
dimension and depth. They generally do not coincide, and Cohen-Macaulay
modules will be those where they do.

Let $(R, \mathfrak{m})$ be a noetherian local ring.
\begin{definition} 
A finitely generated $R$-module $M$ is \textbf{Cohen-Macaulay} if $\depth M =
\dim M$. The ring $R$ is called \textbf{Cohen-Macaulay} if it is
Cohen-Macaulay as a module over itself.
\end{definition} 

We already know that the inequality $\leq$ always holds. 
If there is a system of parameters for $M$ (i.e., a sequence $x_1, \dots, x_r
\in \mathfrak{m}$ such that $M/(x_1, \dots, x_r) M$ is artinian) which is a
regular sequence on $M$, then $M$ is Cohen-Macaulay: we see in fact that
$\dim M  = \depth M = r$.
This is the distinguishing trait of Cohen-Macaulay rings.

Let us now give a few examples:

\begin{example}[Regular local rings are Cohen-Macaulay]
If $R$ is regular, then $\depth R = \dim R$, so $R$ is Cohen-Macaulay.

Indeed, we have seen that if $x_1, \dots, x_n$ is a regular system of parameters
for $R$ (i.e. a minimal set of generators for $\mathfrak{m}$), then $n
= \dim R$ and the $\left\{x_i\right\}$ form a regular sequence. See the remark
after \cref{quotientreg44}; the point is that $R/(x_1, \dots, x_{i-1})$ is
regular for each $i$ (by the aforementioned corollary), and hence a
domain, so $x_i$
acts on it by a nonzerodivisor.
\end{example}

The next example easily shows that a Cohen-Macaulay ring need not be
regular, or even a domain:
\begin{example}[Local artinian rings are Cohen-Macaulay]
Any local
artinian ring, because the dimension is zero for an artinian
ring. 
\end{example}


\begin{example}[Cohen-Macaulayness and completion]
A finitely generated module $M$ is Cohen-Macaulay if and only if its
completion $\hat{M}$ is; this follows from \cref{exer:depthcompletion}.
\end{example} 

Here is a slightly harder example.
\begin{example} 
A normal local domain $(R, \mathfrak{m})$ of dimension 2 is Cohen-Macaulay. This is a special case
of Serre's criterion for normality.

Here is an argument. If $x \in \mathfrak{m}$ is nonzero, we want to
show that $\depth R/(x) = 1$.
To do this, we need to show that $\mathfrak{m} \notin \ass(R/(x))$ for
each such $x$, because then $\depth R/(x) \geq 1$ (which is all we need).
However, suppose the contrary; then there is $y$ not divisible by $x$ such
that $\mathfrak{m}y \subset (x)$. 
So $y/x \notin R$, but $\mathfrak{m} (y/x) \subset R$. 

This, however, implies $\mathfrak{m}$ is principal. Indeed, we either have
$\mathfrak{m}(y/x) = R$, in which case  $\mathfrak{m}$ is generated by $x/y$,
or $\mathfrak{m}(y/x) \subset \mathfrak{m}$. The latter would imply
that $y/x$ is integral over $R$ (as multiplication by it stabilizes a
finitely generated $R$-module), and by normality $y/x \in R$. We have seen
much of this argument before. 
\end{example} 

\begin{example}
Consider $\mathbb{C}[x,y]/(xy)$, the coordinate ring of the
union of two axes
intersecting at the origin. This is not
regular, as its localization at the origin 
is not a domain. 
We will later show that this is a Cohen-Macaulay ring, though.
\begin{comment}
Indeed, we can project the associated variety
$X = V(xy)$
onto the affine line by adding the coordinates. This corresponds
to the map
\[ \mathbb{C}[z] \to \mathbb{C}[x,y]/(xy)  \]
sending $z \to x+y$. This makes $\mathbb{C}[x,y]/(xy)$ into a
free
$\mathbb{C}[z]$-module of rank two (with generators $1, x$), as
one can check.
So by the previous result (strictly speaking, its extension to
non-domains),
the ring in question is Cohen-Macaulay.
\end{comment}
\end{example}

\begin{example}
$R=\mathbb{C}[x,y,z]/(xy, xz)$ is not Cohen-Macaulay (at the
origin). The associated variety looks
geometrically like the union of the plane $x=0$ and the line
$y=z=0$ in affine
3-space. Here there are two components of different dimensions
intersecting.
Let's choose a regular sequence (that is, regular after
localization at the
origin). The dimension at the origin is clearly two because of
the plane.
First, we need a nonzerodivisor in this ring, which vanishes at
the origin, say
$ x+y+z$. (Check this.) When we quotient by
this, we get
\[ S=\mathbb{C}[x,y,z]/(xy,xz, x+y+z) = \mathbb{C}[y,z]/(
(y+z)y, (y+z)z). \]

The claim is that $S$ localized at the ideal corresponding to
$(0,0)$ has depth
zero. We have $y+z \neq 0$, which is killed by both $y,z$, and
hence by the
maximal ideal at zero. In particular the maximal ideal at zero
is an associated
prime, which implies the claim about the depth.
\end{example}

As it happens, a Cohen-Macaulay variety is always
equidimensional. The rough
reason is that each irreducible piece puts an upper bound on the
depth given by
the dimension of the piece. If any piece is too small, the total
depth will be
too small.


Here is the deeper statement:

\begin{proposition} \label{dimthing}
Let $(R, \mathfrak{m})$ be a noetherian local ring, $M$ a finitely generated,
Cohen-Macaulay $R$-module.
Then:
\begin{enumerate}
\item For each $\mathfrak{p}  \in \ass(M)$, we have $\dim M = \dim
R/\mathfrak{p}$.
\item Every associated prime of $M$ is minimal (i.e. minimal in $\supp M$).
\item  $\supp M$ is equidimensional.
\end{enumerate}
\end{proposition} 
In general, there may be nontrivial inclusion relations among the
associated primes of a general module. However, this cannot happen for a Cohen-Macaulay
module.
\begin{proof} 
The first statement implies all the others. (Recall that
\emph{equidimensional} means that all the irreducible components of $\supp
M$, i.e. the $\spec R/\mathfrak{p}$, have the same dimension.) 
But this in turn follows from the bound of  \cref{localdepthassbound}.
\end{proof} 

Next, we would like to obtain a criterion for when a quotient of a
Cohen-Macaulay module is still Cohen-Macaulay.
The answer will be similar to \cref{quotientreg} for regular local rings.

\begin{proposition} \label{quotientCM}
Let $M$ be a Cohen-Macaulay module over the local noetherian ring $(R,
\mathfrak{m})$. If $x_1, \dots, x_n \in \mathfrak{m}$ is a $M$-regular
sequence, then $M/(x_1, \dots, x_n)M$ is Cohen-Macaulay of dimension (and
depth) $\dim M - n$. 
\end{proposition} 
\begin{proof} 
Indeed, we reduce to the case $n=1$ by induction.
But then, because $x_1$ is a nonzerodivisor on $M$, we have $\dim
M/x_1 M = \dim M -1$ and $\depth M/x_1 M = \depth M -1$. Thus 
\[ \dim M/x_1 M = \depth M/x_1M.  \]
\end{proof} 

So, if we are given a Cohen-Macaulay module $M$ and want one of a smaller
dimension, we just have to find $x \in \mathfrak{m}$ not contained in any of
the minimal primes of $\supp M$ (these are the only associated primes). Then,
$M/xM$ will do the job.

\subsection{The non-local case}

More generally, we would like to make the definition:
\begin{definition} \label{generalCM}
 A general noetherian ring $R$ is
\textbf{Cohen-Macaulay} if
$R_{\mathfrak{p}}$ is Cohen-Macaulay for all $\mathfrak{p} \in
\spec R$.
\end{definition}

We should check that these definitions coincide for a local noetherian ring. 
This, however, is not entirely obvious; we have to show that localization
preserves Cohen-Macaulayness.
In this subsection, we shall do that, and we shall furthermore show that Cohen-Macaulay rings are \emph{catenary}, or
more generally that Cohen-Macaulay modules are catenary. (So far we have
seen that they are equidimensional, in the local case.)


We shall deduce this from the following result, which states that for a
Cohen-Macaulay module, we can choose partial systems of parameters in any
given prime ideal in the support.

\begin{proposition} \label{CMintermediatep}
Let $M$ be a Cohen-Macaulay module over the local noetherian ring $(R,
\mathfrak{m})$, and let $\mathfrak{p} \in \supp M$.
Let $x_1, \dots, x_r \in \mathfrak{p}$ be a maximal $M$-sequence contained in
$\mathfrak{p}$. Then:
\begin{enumerate}
\item $\mathfrak{p}$ is an associated and minimal prime of $M/(x_1, \dots, x_r)M$. 
\item $\dim R/\mathfrak{p} = \dim M -r$
\end{enumerate}
\end{proposition} 
\begin{proof} 
We know (\cref{quotientCM}) that $M/(x_1, \dots, x_r)M$ is a Cohen-Macaulay module too. 
Clearly $\mathfrak{p}$ is in its support, since all the $x_i \in
\mathfrak{p}$. 
The claim is that $\mathfrak{p}$ is an associated prime---or minimal prime, it
is the same thing---of $M/(x_1, \dots, x_r)M$. If not, there is $x \in
\mathfrak{p}$ that is a nonzerodivisor on this quotient, which means that
$\left\{x_1, \dots, x_r\right\}$ was not maximal as claimed. 

Now we need to verify the assertion on the dimension. Clearly $\dim M/(x_1,
\dots, x_r)M = \dim M - r$, and moreover $\dim R/\mathfrak{p} =
\dim M/(x_1, \dots, x_r)$ by \cref{dimthing}. Combining these gives
the second assertion.
\end{proof} 

\begin{corollary} \label{CMloc}
Hypotheses as above, 
 $\dim M_{\mathfrak{p}}  = r = \dim M - \dim R/\mathfrak{p} $.
Moreover, $M_{\mathfrak{p}}$ is a Cohen-Macaulay module over
$R_{\mathfrak{p}}$.
\end{corollary} 
This result shows that \cref{generalCM} is a reasonable definition.
\begin{proof} 
Indeed, if we consider the conclusions of \cref{intermediatep}, we find that
$x_1, \dots, x_r$ becomes a system of parameters for $M_{\mathfrak{p}}$: we
have that $M_{\mathfrak{p}}/(x_1, \dots, x_r)M_{\mathfrak{p}}$ is an
artinian $R_{\mathfrak{p}}$-module, while the sequence is also regular. The
first claim follows, as does the second: any module with a system of
parameters that is a regular sequence is Cohen-Macaulay.
\end{proof} 

As a result, we can get the promised result that a Cohen-Macaulay ring is
catenary.
\begin{proposition} 
If $M$ is Cohen-Macaulay over the local noetherian ring $R$, then $\supp M$ is a catenary space.
\end{proposition} 

In other words, if $\mathfrak{p} \subset \mathfrak{q}$ are elements of
$\supp M$, then every maximal chain of prime ideals from $\mathfrak{p}$ to
$\mathfrak{q}$ has the same length. 
\begin{proof} 
We will show that
\( \dim R/\mathfrak{p} = \dim R/\mathfrak{q} + \dim
R_{\mathfrak{q}}/\mathfrak{p} R_{\mathfrak{q}}, \) a claim that
suffices to establish catenariness.
We will do this by using the dimension formulas computed earlier.

Namely, we know that
$M$ is catenary over $R$, so  by \cref{CMloc}
\[ \dim_{R_{\mathfrak{q}}} M_{\mathfrak{q}} = \dim M - \dim
R/\mathfrak{q}, \quad
\dim_{ R_{\mathfrak{p}}} M_{\mathfrak{p}} = \dim M - \dim R/\mathfrak{p}.
\]
Moreover, $M_{\mathfrak{q}} $ is Cohen-Macaulay over
$R_{\mathfrak{q}}$. As a result, we have (in view of the previous equation)
\[ \dim_{R_{\mathfrak{p}}}
M_{\mathfrak{p}} = \dim_{R_{\mathfrak{q}}} M_{\mathfrak{q}} - \dim
R_{\mathfrak{q}}/\mathfrak{p}R_{\mathfrak{q}} = 
\dim M - \dim R/\mathfrak{q} - \dim
R_{\mathfrak{q}}/\mathfrak{p}R_{\mathfrak{q}} 
.  \]
Combining, we find
\[ \dim M - \dim R/\mathfrak{p} =  \dim M - \dim R/\mathfrak{q} - \dim
R_{\mathfrak{q}}/\mathfrak{p}R_{\mathfrak{q}} ,
 \]
which is what we wanted.
\end{proof} 

It thus follows that any Cohen-Macaulay ring, and thus any \emph{quotient} of a
Cohen-Macaualay ring, is catenary. In particular, it follows any non-catenary
local noetherian ring cannot be expressed as a quotient of a
Cohen-Macaulay (e.g. regular) local ring. 

It also follows immediately that if $R$ is any regular (not necessarily local)
ring, then $R$ is catenary, and the same goes for any quotient of $R$.
In particular, since a polynomial ring over a field is regular, we find:
\begin{proposition} 
Any affine ring is catenary. 
\end{proposition} 

\subsection{Reformulation of Serre's criterion}

Much earlier, we proved criteria for a noetherian ring to be reduced and (more
interestingly) normal.
We can state them more cleanly using the theory of depth developed.

\begin{definition} 
Let $R$ be a noetherian ring, and let $k \in \mathbb{Z}_{\geq 0}$.
\begin{enumerate}
\item We say that $R$ satisfies \textbf{condition $R_k$} if, for every
prime ideal $\mathfrak{p} \in \spec R$ with $\dim R_{\mathfrak{p}} \leq k$,
the local ring $R_{\mathfrak{p}}$ is regular.
\item $R$ satisfies \textbf{condition $S_k$} if $\depth R_{\mathfrak{p}} \geq
\inf(k, \dim R_{\mathfrak{p}})$ for all $\mathfrak{p} \in \spec R$.
\end{enumerate}
\end{definition} 

A Cohen-Macaulay ring satisfies all the conditions $S_k$, and conversely. The
condition $R_k$ means geometrically that the associated variety 
is regular (i.e., smooth, at least if one works over an algebraically closed
field) outside a subvariety of codimension $\geq k$.



Recall that, according to \cref{reducedcrit1}, a noetherian ring is \textit{reduced} iff:
\begin{enumerate}
\item For any minimal prime $\mathfrak{p} \subset R$,
$R_{\mathfrak{p}}$ is a
field.
\item Every associated prime of $R$ is minimal.
\end{enumerate}

Condition 1 can be restated as follows. The ideal
$\mathfrak{p}\subset R$ is
minimal if and only if it is zero-dimensional, and $R_{\mathfrak{p}}$  is
regular if and only if it is a
field. So the first condition is that \emph{for every height
zero prime,
$R_{\mathfrak{p}}$ is regular.}
In other words, it is the condition $R_0$.

For the second condition,
$\mathfrak{p} \in
\ass(R)$ iff $\mathfrak{p} \in \ass(R_{\mathfrak{p}})$, which is
equivalent to
$\depth R_{\mathfrak{p}} = 0$. So the second condition states that for primes
$\mathfrak{p} \in \spec R$ of height at least 1, $\mathfrak{p} \notin
\ass(R_{\mathfrak{p}})$, or $\depth(R_{\mathfrak{p}}) \geq 1$. This
is the condition $S_1$.

We find:
\begin{proposition} 
A noetherian ring is reduced if and only if it satisfies $R_0$ and $S_1$.
\end{proposition} 

In particular, for a Cohen-Macaulay ring, checking if it is reduced is
easy; one just has to check $R_0$ (if the localizations at minimal primes are
reduced).


Serre's criterion for normality is in the same spirit, but harder.
Recall that
a noetherian ring is \textit{normal} if it is a finite direct
product of
integrally closed domains.

The earlier form of Serre's criterion (see \cref{serrecrit1}) was:
\begin{proposition}
Let $R$ be a local ring.
Then $R$ is normal iff
\begin{enumerate}
\item  $R$ is reduced.
\item For every height one prime $\mathfrak{p}  \in \spec R$,
$R_{\mathfrak{p}}$ is a DVR (i.e. regular).
\item For every nonzerodivisor $x \in R$, every associated prime
of $R/(x)$ is
minimal.
\end{enumerate}
\end{proposition}
In view of the criterion for reducedness, these conditions are equivalent to:
\begin{enumerate}
\item For every prime $\mathfrak{p}$ of height $\leq 1$,
$R_{\mathfrak{p}} $ is regular.
\item For every prime $\mathfrak{p}$ of height $\geq 1$,
$\depth R_{\mathfrak{p}} \geq 1$ (necessary for reducedness)
\item $\depth R_{\mathfrak{p}} \geq 2$ for $\mathfrak{p}$ containing but not
minimal over any
principal ideal $(x)$ for $x$ a nonzerodivisor. This 
is the last
condition of the proposition; to say $\depth R_{\mathfrak{p}} \geq 2$ is to
say that $\depth R_{\mathfrak{p}}/(x)R_{\mathfrak{p}} \geq 1$, or
$\mathfrak{p} \notin
\ass(R_{\mathfrak{p}}/(x)R_{\mathfrak{p}})$.
\end{enumerate}

Combining all this, we find:
\begin{theorem}[Serre's criterion] A noetherian ring is normal
if and only if it satisfies the conditions $R_1$ and $S_2$.
\end{theorem}

Again, for a Cohen-Macaulay ring, the last condition is automatic, as
the depth is the
codimension.

\section{Projective dimension and free resolutions}

We shall introduce the notion of \emph{projective dimension} of a module; this
will be the smallest projective resolution it admits (if there is none such,
the dimension is $\infty$). We can think of it as measuring how far a module is
from being projective. Over a noetherian \emph{local} ring, we will show that
the projective dimension can be calculated very simply using the $\tor$ functor
(which is an elaboration of the story that a projective module over a local
ring is free).

Ultimately we want to show that a noetherian local ring is regular if and only
if every finitely generated module admits a finite free resolution. Although we
shall not get to that result until the next section, we will at least relate
projective dimension to a more familiar invariant of a module: \emph{depth.}

\subsection{Introduction}
\newcommand{\pr}{\mathrm{pd}}
Let $R$ be a commutative ring, $M$ an $R$-module.

\begin{definition}
The \textbf{projective dimension} of $M$ is the largest integer
$n$ such that
there exists  a module $N$ with
\[ \ext^n(M,N) \neq 0.  \]
We allow $\infty$, if arbitrarily large such $n$ exist. 
We write $\pr(M)$ for the projective dimension. For convenience, we set $\pr(0)
= - \infty$.
\end{definition}

So, if $m> n = \pr(M)$, then we have $\ext^m(M, N) = 0$ for \emph{all} modules $N$, and
$n$ is the smallest integer with this property.
As an example, note that $\pr(M) = 0$ if and only if $M$ is projective and
nonzero. Indeed, we have seen that
the $\ext$ groups
$\ext^i(M,N), i >0$
vanish always for $M$ projective, and conversely.

To compute $\pr(M)$ in general, one can proceed as follows.
Take any $M$. Choose a surjection $P \twoheadrightarrow M$ with
$P$ projective;
call the kernel $K$ and draw a short exact sequence
\[ 0 \to K \to P \to M \to 0.  \]
For any $R$-module $N$, we have a long exact sequence
\[ \ext^{i-1}(P,N) \to \ext^{i-1}(K,N) \to \ext^i(M,N) \to
\ext^i(P, N). \]
If $i >0$, the right end vanishes; if $i >1$, the left end
vanishes. So if $i
>1$, this map $\ext^{i-1}(K,N) \to \ext^i(M,N)$ is an
\emph{isomorphism}.

Suppose that $\pr(K) = d \geq 0$. We find that
$\ext^{i-1}(K,N)=0$ for $i-1
> d$.
This implies that $\ext^i(M,N) = 0$ for such $i > d+1$. In
particular, $\pr(M)
\leq d+1$.
This argument is completely reversible if $d >0$.
Then we see from these isomorphisms that
\begin{equation} \label{pdeq} \boxed{\pr(M) = \pr(K)+1}, \quad \mathrm{unless} \ \pr(M)=0
\end{equation}
If $M$ is projective, the sequence $0 \to K \to P \to M \to 0$
splits, and
$\pr(K)=0$ too.

The upshot is that {we can compute projective dimension
by choosing a
projective resolution.}
\begin{proposition}\label{pdprojectiveresolution}
Let $M$ be an $R$-module. Then $\pr(M) \leq n$ iff there exists
a finite
projective resolution of $M$ having $n+1$ terms,
\[ 0 \to P_n \to \dots \to P_1 \to P_0 \to M \to 0.  \]
\end{proposition}
\begin{proof}
Induction on $n$. When $n = 0$, $M$ is projective, and we can
use the
resolution $0 \to M \to M \to 0$.

Suppose $\pr(M) \leq n$, where $n >0$. We can get a short exact
sequence
\[ 0 \to K \to P_0 \to M \to 0  \]
with $P_0$ projective, so $\pr(K) \leq n-1$ by \eqref{pdeq}. The inductive
hypothesis implies
that there is a projective resolution of $K$ of length $\leq
n-1$. We can
splice this in with the short exact sequence to get a projective
resolution of
$M$ of length $n$.

The argument is reversible. Choose any projective resolution
\[  0 \to P_n \to \dots \to P_1 \to P_0 \to M \to 0 \]
and split into short exact sequences, and then one argue inductively to show
that $\pr(M) \leq n$.
\end{proof}

Let $\pr(M) = n$. Choose any projective resolution $\dots \to P_2 \to P_1 \to P_0 \to M$. Choose $K_i = \ker(P_i \to P_{i-1})$ for each $i$.  Then there is a short exact sequence $0 \to K_0 \to P_0 \to M
\to 0$. Moreover,
there are exact sequences
\[ 0 \to K_i \to P_i \to K_{i-1} \to 0  \]
for each $i$. From these, and from \eqref{pdeq}, we see that the projective dimensions
of the $K_i$
drop by one as $i$ increments. So $K_{n-1}$ is projective if
$\pr(M) = n$ as
$\pr(K_{n-1})=0$. In particular, we can get a projective
resolution
\[ 0 \to K_{n-1} \to P_{n-1} \to \dots \to P_0 \to M \to 0  \]
which is of length $n$.
In particular, if one has a (possibly infinite) projective resolution $M$, one can stop after going out $n$ terms, because the kernels
will become
projective. In other words, the projective resolution can be made to
\emph{break off} at the $n$th term. 
This applies to \emph{any} projective resolution. 
Conversely, since any module has a (possibly infinite) projective resolution,
we find:

\begin{proposition} 
We have $\pr(M) \leq n$ if any projective resolution
\[ \dots \to P_1 \to P_0 \to M \to 0  \]
breaks off at the $n$th stage: that is, the kernel of $P_{n-1} \to P_{n-2}$ is
projective.
\end{proposition} 


If $\pr(M) \leq n$, then by definition we have $\ext^{n+1}(M, N) = 0$ for
\emph{any} module $N$. By itself, this does not say anything about the $\tor$
functors.
However, the criterion for projective dimension enables us to show:

\begin{proposition} \label{pdfd}
If $\pr(M) \leq n$, then $\tor_m(M, N) = 0$ for $m > n$.
\end{proposition} 
One can define an analog of projective dimension with the $\tor$ functors,
called \emph{flat dimension}, and it follows that the flat dimension is at most
the projective dimension.

In fact, we have more generally:
\begin{proposition} 
Let $F$ be a right-exact functor on the category of $R$-modules, and let $\{L_i
F\}$ be its left derived functors. 
If $\pr(M) \leq n$, then $L_i F(M) = 0$ for $i > n$.
\end{proposition} 

Clearly this implies the claim about $\tor$ functors.
\begin{proof} 
Recall how $L_i F(M)$ can be computed. Namely, one chooses a projective
resolution $P_\bullet \to M$ (any will do), and compute the homology of the
complex 
$F(P_\bullet)$. However, we can choose $P_\bullet \to M$ such that $P_i = 0$
for $i > n$ by \cref{pdprojectiveresolution}. Thus $F(P_\bullet)$ is
concentrated in degrees between $0$ and $n$, and the result becomes clear when
one takes the homology.
\end{proof} 

In general, flat modules are not projective (e.g. $\mathbb{Q}$ is flat, but not
projective, over $\mathbb{Z}$), and while one can use projective dimension to
bound ``flat dimension'' (the analog for $\tor$-vanishing), one cannot use the
flat dimension to bound the projective dimension. For a local ring, we will see
that it is possible in the next subsection. 

\subsection{$\tor$ and projective dimension}

Over  a noetherian \emph{local} ring, there is a much simpler way to test whether a
finitely generated module is projective. This is a special case of the very
general flatness criterion \cref{bigflatcriterion}, but we can give a simple
direct proof. So we prefer to keep things self-contained. 

\begin{theorem} \label{localflateasy}
Let $M$ be a finitely generated module over the noetherian local ring $(R,
\mathfrak{m})$, with residue field $k = R/\mathfrak{m}$. Then, if $\tor_1(M, k)
= 0$, $M$ is free.
\end{theorem} 
In particular, projective---or even flat---modules which are of finite type
over $R$ are automatically free.
This is a strengthening of the earlier theorem (\cref{}) that a finitely
generated projective
module over a local ring is free.
\begin{proof} 
Indeed, we can find a free module $F$ and a surjection $F \to M$ such that $F
\otimes_R k \to M \otimes_R k$ is an isomorphism. To do this, choose elements
of $M$ that form a basis of $M \otimes_R k$, and then define a map $F \to M$
via these elements; it is a surjection by Nakayama's lemma.

Let $K$ be the kernel of $F \twoheadrightarrow M$, so there is an exact sequence 
\[ 0 \to K \to F \to M \to 0.  \]
We want to show that $K = 0$, which will imply that $M = 0$. By Nakayama's
lemma, it suffices to show that $K \otimes_R k = 0$. But we have an exact
sequence
\[ \tor_1(M, k) \to K \otimes_R k \to F \otimes_R k \to M \otimes_R k \to 0.  \]
The last map is an isomorphism, and $\tor_1(M, k) = 0$, which implies that $K
\otimes_R k = 0$. The result is now proved.
\end{proof} 

As a result, we can compute the projective dimension of a module in terms of
$\tor$.
\begin{corollary} 
Let $M$ be a finitely generated module over the noetherian local ring $R$ with
residue field $k$. Then $\pr(M)$ is the largest integer $n$
such that 
$\tor_n(M, k) \neq 0$.
It is also the smallest integer $n$ such that $\tor_{n+1}(M, k) = 0$.
\end{corollary} 
There is a certain symmetry: if $\ext$ replaces $\tor$, then one has the
definition of depth. We will show later that there is indeed a useful connection
between projective dimension and depth.
\begin{proof} 
We will show that if
$\tor_{n+1}(M, k) = 0$, then $\pr(M) \leq n$. 
This implies the claim, in view of \cref{pdfd}. Choose a (possibly infinite)
projective resolution
\[ \dots \to P_1 \to P_0 \to M \to 0.  \]
Since $R$ is noetherian, we can assume that each $P_i$ is \emph{finitely
generated.}

Write $K_i = \ker(P_i \to P_{i-1})$, as before; these are finitely generated
$R$-modules. We want to show that $K_{n-1}$
is projective, which will establish the claim, as then the projective
resolution will ``break off.''
But we have an exact sequence
\[ 0 \to K_0 \to P_0 \to M \to 0,  \]
which shows that $\tor_n(K_0, k) = \tor_{n+1}(M, k)= 0$. 
Using the exact sequencese $0 \to K_{i} \to P_i \to K_{i-1} \to 0$, we
inductively work downwards to get that $\tor_1(K_{n-1}, k) =0$. So $K_{n-1}$ is
projective by \cref{localflateasy}.
\end{proof} 

In particular, we find that if $\pr(k) \leq n$, then $\pr(M) \leq n$ for all
$M$. This is because if $\pr(k) \leq n$, then $\tor_{n+1}(M, k) = 0$ by using
the relevant resolution of $k$ (see \cref{pdfd}, but for $k$).
\begin{corollary} 
Suppose there exists $n$ such that $\tor_{n+1}(k, k) = 0$. 
Then every finitely generated $R$-module has a finite free resolution of length
at most $n$.
\end{corollary} 

We have thus seen that $k$ is in some sense the ``worst'' $R$-module, in that it is
as far from being projective, or that it has the largest projective dimension.
We can describe this worst-case behavior with the next concept:

\begin{definition} 
Given a ring $R$, the \textbf{global dimension} is the $\sup$ of the projective
dimensions of all finitely generated $R$-modules. 
\end{definition} 

So, to recapitulate: the global dimension of a noetherian local ring $R$ is the
projective dimension of its residue field $k$, or even the \emph{flat}
dimension of the residue field. 
\subsection{Minimal projective resolutions}
Usually projective resolutions are non-unique; they are only unique up to
chain homotopy. We will introduce a certain restriction that enforces
uniqueness. These ``minimal'' projective resolutions will make it extremely
easy to compute the groups $\tor_{\bullet}(\cdot, k)$.

Let $(R, \mathfrak{m})$ be a local noetherian ring with residue field $k$, $M$ a
finitely generated $R$-module.
All tensor products will be over $R$.

\begin{definition}
A projective resolution $P_\bullet \to M$ of finitely generated
modules is \textbf{minimal} if for each $i$, the
induced map $P_i \otimes k \to P_{i-1} \otimes
k$ is
zero, and the map $P_0 \otimes k \to
M/\mathfrak{m}M$ is an isomorphism.
\end{definition}

In other words, the complex $P_\bullet \otimes k$ is isomorphic to $M \otimes
k$.
This is equivalent to saying that for each $i$, the map $P_i
\to\ker(P_{i-1}
\to P_{i-2})$ is an isomorphism modulo $\mathfrak{m}$.

\begin{proposition}
Every $M$ (over a local noetherian ring) has a minimal
projective resolution.
\end{proposition}
\begin{proof}
Start with a module $M$. Then $M/\mathfrak{m}M$ is a
finite-dimensional vector
space over $k$, of dimension say $d_0$. We can
choose a basis for that vector space, which
we can lift to $M$. That determines a map of free modules
\[ R^{d_0} \to M,  \]
which is a surjection by Nakayama's lemma. It is by construction
an
isomorphism modulo $\mathfrak{m}$. Then define $K =
\ker(R^{d_0}\to M)$; this
is finitely generated by noetherianness, and we
can do the same thing for $K$, and repeat to get a map $R^{d_1}
\twoheadrightarrow K$ which is an isomorphism modulo
$\mathfrak{m}$. Then
\[ R^{d_1} \to R^{d_0} \to M \to 0  \]
is exact, and minimal; we can continue this by the same
procedure.
\end{proof}


\begin{proposition}
Minimal projective resolutions are unique up to isomorphism.
\end{proposition}
\begin{proof}
Suppose we have one minimal projective resolution:
\[ \dots \to P_2 \to P_1 \to P_0 \to M \to 0  \]
and another:
\[ \dots \to Q_2 \to Q _1 \to Q_0 \to M \to 0  .\]
There is always a map of projective resolutions $P_* \to Q_*$ by
general
homological algebra. There is, equivalently, a commutative
diagram
\[\xymatrix{ \dots \ar[d] \ar[r] & P_2\ar[d] \ar[r] & P_1
\ar[d]\ar[r]
& P_0 \ar[d] \ar[r] & M \ar[d]^{\mathrm{id}} \ar[r] & 0 \\
 \dots  \ar[r] &   Q_2  \ar[r] &  Q_1   \ar[r]
&  Q_0   \ar[r] &   M  \ar[r] &   0 } \]
If both resolutions are minimal, the claim is that this map is
an isomorphism.
That is, $\phi_i: P_i \to Q_i$ is an isomorphism, for each $i$.

To see this, note that $P_i, Q_i$ are finite free
$R$-modules.\footnote{We are
using the fact that a finite projective module over a local ring
is
\emph{free}.} So $\phi_i$ is an isomorphism iff $\phi_i$ is an
isomorphism
modulo the maximal ideal, i.e. if
\[ P_i/\mathfrak{m}P_i \to Q_i/\mathfrak{m}Q_i  \]
is an isomorphism. Indeed, if $\phi_i$ is an isomorphism, then
its tensor
product with $R/\mathfrak{m}$ obviously is an isomorphism.
Conversely suppose
that the reductions mod $\mathfrak{m}$ make an isomorphism. Then
the ranks of
$P_i, Q_i$ are the same, and $\phi_i$ is an $n$-by-$n$ matrix
whose determinant
is not in the maximal ideal, so is invertible. This means that
$\phi_i$ is invertible by the
usual formula for the inverse matrix.

So we are to check that $P_i / \mathfrak{m}P_i \to Q_i /
\mathfrak{m}Q_i$ is an
isomorphism for each $i$. This is equivalent to the assertion
that
\[ (Q_i/\mathfrak{m}Q_i)^{\vee} \to
(P_i/\mathfrak{m}P_i)^{\vee}\]
is an isomorphism. But this is the map
\[ \hom_R(Q_i, R/\mathfrak{m}) \to \hom_R(P_i, R/\mathfrak{m}).
\]
If we look at the chain complexes $\hom(P_*, R/\mathfrak{m}),
\hom(Q_*,
R/\mathfrak{m})$, the cohomologies
compute the $\ext$ groups of $(M, R/\mathfrak{m})$. But all the
maps in this
chain complex are zero because the resolution is minimal, and we
have that the
image of $P_i$ is contained in $\mathfrak{m}P_{i-1}$ (ditto for
$Q_i$). So the
cohomologies are just the individual terms, and the maps
$ \hom_R(Q_i, R/\mathfrak{m}) \to \hom_R(P_i, R/\mathfrak{m})$
correspond to
the identities on $\ext^i(M, R/\mathfrak{m})$. So these are
isomorphisms.\footnote{We are sweeping under the rug the
statement that $\ext$
can be computed via \emph{any} projective resolution. More
precisely, if you
take any two projective resolutions, and take the induced maps
between the
projective resolutions, hom them into $R/\mathfrak{m}$, then the
maps on
cohomology are isomorphisms.}
\end{proof}


\begin{corollary}
If $\dots \to P_2 \to P_1 \to P_0 \to M$ is a minimal projective
resolution of
$M$, then the ranks $\mathrm{rank}(P_i)$ are well-defined (i.e.
don't depend
on the choice of the minimal resolution).
\end{corollary}
\begin{proof}
Immediate from the proposition. In fact, the ranks are the
dimensions (as
$R/\mathfrak{m}$-vector spaces) of $\ext^i(M, R/\mathfrak{m})$.
\end{proof}

\subsection{The Auslander-Buchsbaum formula}



\begin{theorem}[Auslander-Buschsbaum formula]
Let $R$ be a local noetherian ring, $M$ a finitely generated $R$-module of
finite
projective dimension. If $\pr(R) <
\infty$, then $\pr(M) = \depth(R) - \depth(M)$.
\end{theorem}

\begin{proof}
Induction on $\pr(M)$. When $\pr(M)=0$, then $M$ is projective,
so isomorphic
to $R^n$ for some $n$. Thus $\depth(M) = \depth(R)$.

Assume $\pr(M) > 0$.
Choose a surjection $P \twoheadrightarrow M$ and write an exact
sequence
\[ 0 \to K \to P \to M \to 0,  \]
where $\pr(K) = \pr(M)-1$. We also know by induction that
\[ \pr(K) = \depth R - \depth(K).  \]
What we want to prove is that
\[ \depth R - \depth M = \pr(M) = \pr(K)+1.  \]
This is equivalent to wanting know that $\depth(K) = \depth (M)
+1$.
In general, this may not be true, though, but we will prove it
under
minimality hypotheses.

Without loss of generality, we can choose that $P$ is
\emph{minimal}, i.e.
becomes an isomorphism modulo the maximal ideal $\mathfrak{m}$.
This means
that the rank of $P$ is $\dim M/\mathfrak{m}M$.
So $K = 0$ iff $P \to M$ is an isomorphism; we've assumed that
$M$ is not
free, so $K \neq 0$.

Recall that the depth of $M$ is the smallest value $i$ such
that$\ext^i(R/\mathfrak{m}, M) \neq 0$. So we should look at the long exact
sequence from the above short exact sequence:
\[ \ext^i(R/\mathfrak{m}, P) \to  \ext^i(R/\mathfrak{m},M)  \to
\ext^{i+1}(R/\mathfrak{m}, K) \to \ext^{i+1}(R/\mathfrak{m},
P).\]
Now $P$ is just a direct sum of copies of $R$, so
$\ext^i(R/\mathfrak{m}, P)$
and $\ext^{i+1}(R/\mathfrak{m}, P)$ are zero if $i+1< \depth R$.
In
particular, if $i+1< \depth R$, then the map $
\ext^i(R/\mathfrak{m},M) \to
\ext^{i+1}(R/\mathfrak{m}, K) $ is an isomorphism.
So we find that $\depth M + 1 = \depth K$ in this case.

We have seen that \emph{if $\depth K < \depth R$, then } by
taking $i$ over
all integers $< \depth K$, we find that
\[ \ext^{i}(R/\mathfrak{m}, M) = \begin{cases}
0 & \mathrm{if \ } i+1 < \depth K \\
\ext^{i+1}(R/\mathfrak{m},K) & \mathrm{if \ } i+1 = \depth K
\end{cases}. \]
In particular, we are \textbf{done} unless $\depth K \geq \depth
R$.
By the inductive hypothesis, this is equivalent to saying that
$K$ is
projective.

So let us consider the case where $K$ is projective, i.e.
$\pr(M)=1$.
We want to show that $\depth M = d-1$ if $d = \depth R$.
We need a
slightly different argument in this case. Let $d = \depth(R) =
\depth (P) =
\depth(K)$ since $P,K$ are free. We have a short exact sequence
\[ 0 \to K \to P \to M \to 0  \]
and a long exact sequence of $\ext$ groups:
\[ 0 \to \ext^{d-1}(R/\mathfrak{m}, M) \to
\ext^d(R/\mathfrak{m}, K) \to \ext^d(R/\mathfrak{m}, P) .\]
We know that $\ext^d(R/\mathfrak{m}, K)$ is nonzero as $K$ is
free and $R$ has
depth $d$. However, $\ext^i(R/\mathfrak{m}, K) =
\ext^i(R/\mathfrak{m}, P)=0$
for $i<d$. This implies that $\ext^{i-1}(R/\mathfrak{m}, M)=0$
for $i<d$.

We will show:
\begin{quote}
The map $\ext^d(R/\mathfrak{m}, K) \to \ext^{d}(R/\mathfrak{m},
P)$ is zero.
\end{quote}
This will imply that the depth of $M$ is \emph{precisely} $d-1$.
This is because the matrix $K \to P$ is given by multiplication
by a matrix
with coefficients in $\mathfrak{m}$ as $K/\mathfrak{m}K \to
P/\mathfrak{m}P$
is zero. In particular, the map on the $\ext$ groups is zero,
because it is
annihilated by $\mathfrak{m}$.
\end{proof}

\begin{example} \label{abregularloc}
Consider the case of a \emph{regular} local ring $R$ of dimension $n$. Then
$\depth(R) = n$, so we have
\[ \pr(M) + \depth(M) = n,  \]
for every finitely generated $R$-module $M$.
In particular, $\depth(M) = n$ if and only if $M$ is free.
\end{example} 

\begin{example}[The Cohen-Macaulay locus is open]
Let $R$ be a regular noetherian ring (i.e. one all of whose localizations are
regular). Let $M$ be a finitely generated $R$-module. 
We consider the locus $Z \subset \spec R$ consisting of prime ideals
$\mathfrak{p} \in \spec R$ such that $M_{\mathfrak{p}}$ is a Cohen-Macaulay
$R$-module. 
We want to show that this is an \emph{open} subset. 

\newcommand{\codp}{\mathrm{codepth}}
Namely, over a local ring $(A, \mathfrak{m})$, define the \emph{codepth} of a
finitely generated $A$-module $N$ as $\codp N = \dim N - \depth N \geq 0$; we
have that $\codp N = 0$ if and only if $N$ is Cohen-Macaulay.
We are going to show that the function $\mathfrak{p} \mapsto
\codp_{R_{\mathfrak{p}}}
M_{\mathfrak{p}}$ is  upper semicontinuous on $\spec R$.
To do this, we use  the Auslander-Buchsbaum formula $\depth_{R_{\mathfrak{p}}} M_{\mathfrak{p}} = \dim
R_{\mathfrak{p}} - \pr_{R_{\mathfrak{p}}} M_{\mathfrak{p}}$ (see
\cref{abregularloc}). We will show below
that $\mathfrak{p} \mapsto \pr_{R_{\mathfrak{p}}} M_{\mathfrak{p}}$ is upper
semi-continuous on $\spec R$. 
Thus, we have
\[ \codp_{R_{\mathfrak{p}}} M_{\mathfrak{p}} =  -\left( \dim R_{\mathfrak{p}} -
\dim_{R_{\mathfrak{p}}} M_{\mathfrak{p}}\right) + \pr_{R_{\mathfrak{p}}}
M_{\mathfrak{p}},   \]
where the second term is upper semi-continuous. 
The claim is that the first term is upper semi-continuous. If we consider
$\supp M \subset \spec R$, then the bracketed difference measures the
\emph{local codimension} of $\supp M \subset \spec R$. 
Namely, $\dim R_{\mathfrak{p}} - \dim \supp M_{\mathfrak{p}}$ is the local
codimension because $R_{\mathfrak{p}}$ is regular, and consequently $\spec
R_{\mathfrak{p}}$ is biequidimensional (\add{argument}).
The local codimension of any set is always lower semi-continuous
(\add{reference in the section on topological dim}). 
As a result, the codepth is upper semi-continuous. 

We just need to prove the assertion that 
$\mathfrak{p} \mapsto \pr_{R_{\mathfrak{p}}} M_{\mathfrak{p}}$ is upper
semi-continuous. That is, we need to show that if $M_{\mathfrak{p}}$ admits a
projective resolution of length $n$ by finitely generated modules, then there is a projective resolution of
length $n$ of $M_{\mathfrak{q}}$ for $\mathfrak{q}$ in some Zariski
neighborhood. But a projective resolution of $M_{\mathfrak{p}}$ ``descends'' to
a projective (even free) resolution of $M_g$ for some $g \notin \mathfrak{p}$,
which gives the result by localization. 

If $R$ is the \emph{quotient} of a regular ring, the same result holds (because
the Cohen-Macaulay locus behaves properly with respect to quotients). In
particular, this result holds for $R$ an affine ring.
\end{example} 


\begin{example}
Let $R = \mathbb{C}[x_1, \dots, x_n]/\mathfrak{p}$ for
$\mathfrak{p}$ prime.
Choose an injection $R' \to R$ where $R' = \mathbb{C}[y_1,
\dots, y_m]$ and
$R$ is a finitely generated $R'$-module. This exists by the Noether
normalization lemma.

We wanted to show:

\begin{theorem}
$R$ is Cohen-Macaulay\footnote{That is, its localizations at any
prime---or,
though we haven't proved yet, at any maximal ideal---are.} iff
$R$ is a
projective $R'$-module.
\end{theorem}

We shall use the fact that projectiveness can be tested locally
at every
maximal ideal.

\begin{proof}
Choose a maximal ideal $\mathfrak{m} \subset R'$. We will show
that
$R_{\mathfrak{m}}$ is a free $R'_{\mathfrak{m}}$-module via the
injection of
rings $R'_{\mathfrak{m}} \hookrightarrow R_{\mathfrak{m}}$
(where
$R_{\mathfrak{m}}$ is defined as $R$ localized at the
multiplicative subset
of elements of $R' - \mathfrak{m}$) at each $\mathfrak{m}$ iff
Cohen-Macaulayness holds.

Now $R'_{\mathfrak{m}}$ is a regular local ring, so its depth is
$m$. By the
Auslander-Buchsbaum formula, $R_{\mathfrak{m}}$ is projective as
an
$R'_{\mathfrak{m}}$-module iff
\[ \depth_{R'_{\mathfrak{m}}} R_{\mathfrak{m}} = m.  \]
Now $R$ is a projective module iff the above condition holds for
all maximal
ideals $\mathfrak{m} \subset R'$. The claim is that this is
equivalent to
saying that $\depth R_{\mathfrak{n}} = m = \dim
R_{\mathfrak{n}}$
for every maximal ideal $\mathfrak{n} \subset R$ (depth over
$R$!).

These two statements are almost the same, but one is about the
depth of $R$ as
an $R$-module, and another as an $R'$-module.

\begin{quote}
Issue: There may be several maximal ideals of $R$ lying over the
maximal ideal
$\mathfrak{m} \subset R'$.
\end{quote}

The problem is that $R_{\mathfrak{m}}$ is not generally local,
and not
generally equal to $R_{\mathfrak{n}}$ if $\mathfrak{n}$ lies
over
$\mathfrak{m}$. Fortunately, depth makes sense even over
semi-local rings
(rings with finitely many maximal ideals).

Let us just assume that this does not occur, though. Let us
assume that
$R_{\mathfrak{m}}$ is a local ring for every maximal ideal
$\mathfrak{m}
\subset R$. Then we are reduced to showing that if $S =
R_{\mathfrak{m}}$,
then the depth of $S$ as an $R'_{\mathfrak{m}}$-module is the
same as the
depth as an $R_{\mathfrak{m}}$-module. That is, the depth
doesn't depend too
much on the ring, since $R'_{\mathfrak{m}}, R_{\mathfrak{m}}$
are ``pretty
close.'' If you believe this, then you believe the theorem, by
the first
paragraph.


Let's prove this claim in a more general form:

\begin{proposition}
Let $\phi: S' \to S$ be a local\footnote{I.e. $\phi$ sends
non-units into
non-units.} map of local noetherian rings such that $S$ is a
finitely generated
$S'$-module. Then, for any finitely generated $S$-module $M$,
\[ \depth_S M = \depth_{S'} M.  \]
\end{proposition}
With this, the theorem will be proved.

\begin{remark}
This result generalizes to the semi-local case, which is how
one side-steps
the issue above.
\end{remark}

\begin{proof}
By induction on $\depth_{S'} M$. There are two cases.

Let $\mathfrak{m}', \mathfrak{m}$ be the maximal ideals of $S',
S$.
If $\depth_{S'}(M) >0$, then there is an element $a$ in
$\mathfrak{m}'$ such
that
\[ M \stackrel{\phi(a)}{\to} M \]
is injective. Now $\phi(a) \in \mathfrak{m}$. So $\phi(a)$ is a
nonzerodivisor, and we have an exact sequence
\[ 0 \to M \stackrel{\phi(a)}{\to} M \to M/\phi(a) M \to 0.  \]
Thus we find
\[ \depth_{S} M > 0 . \]
Moreover, we find that $\depth_S M = \depth_S (M/\phi(a) M) +1$
and
$\depth_{S'} M = \depth_{S'}(M/\phi(a) M))+1$. The inductive
hypothesis now
tells us that
\[ \depth_S M = \depth_{S'}M.  \]

The hard case is where $\depth_{S'} M = 0$. We need to show that
this is
equivalent to $\depth_{S} M = 0$. So we know at first that
$\mathfrak{m}' \in
\ass(M)$. That is, there is an element $x \in M$ such that
$\ann_{S'}(x) =
\mathfrak{m}'$.
Now $\ann_S(x) \subsetneq S$ and contains $\mathfrak{m}' S$.

$Sx \subset M$ is a submodule, surjected onto by $S$ by the map
$a \to ax$.
This map actually, as we have seen, factors through
$S/\mathfrak{m}' S$. Here
$S$ is a finite $S'$-module, so $S/\mathfrak{m}'S$ is a finite
$S'/\mathfrak{m}'$-module. In particular, it is a
finite-dimensional vector space
over a field. It is thus a local artinian ring. But $Sx$ is a
module over this
local artinian ring. It must have an associated prime, which is
a maximal
ideal in $S/\mathfrak{m}'S$. The only maximal ideal can be
$\mathfrak{m}/\mathfrak{m}'S$. It follows that $\mathfrak{m}
\in\ass(Sx)
\subset \ass(M)$.

In particular, $\depth_S M = 0$ too, and we are done.
\end{proof}

\end{proof}
\end{example}

\begin{comment}We shall eventually prove:

\begin{proposition}
Let $R = \mathbb{C}[X_1, \dots, X_n]/\mathfrak{p}$ for
$\mathfrak{p}$ prime.
Choose an injective map $\mathbb{C}[y_1, \dots, y_n]
\hookrightarrow R$ making $R$ a
finite module. Then $R$ is Cohen-Macaulay iff $R$ is projective
as a module
over $\mathbb{C}[y_1, \dots, y_n]$.\footnote{In fact, this is
equivalent to
freeness, although we will not prove it. Any projective finite
module over a
polynomial ring over a field is free, though this is a hard
theorem.}
\end{proposition}

The picture is that the inclusion $\mathbb{C}[y_1, \dots, y_m ]
\hookrightarrow
\mathbb{C}[x_1, \dots, x_n]/\mathfrak{p}$ corresponds to a map
\[ X \to \mathbb{C}^m  \]
for $X = V(\mathfrak{p}) \subset \mathbb{C}^n$. This statement
of freeness is a
statement about how the fibers of this finite map stay similar
in some sense.

\end{proof}
\end{comment}

\section{Serre's criterion and its consequences}


 We would like to prove
Serre's
criterion for regularity.

\begin{theorem}
Let $(R, \mathfrak{m})$ be a local noetherian ring. Then $R$ is
regular iff
$R/\mathfrak{m}$ has finite projective dimension. In this case,
$\pr(R/\mathfrak{m}) = \dim R$.
\end{theorem}

\add{proof}


\subsection{First consequences}


\begin{proposition} 
Let $(R, \mathfrak{m}) \to (S, \mathfrak{n})$ be a flat, local homomorphism of noetherian local
rings. If $S$ is regular, so is $R$.
\end{proposition} 
\begin{proof} 
Let $n = \dim S$.
Let $M$ be a finitely generated $R$-module, and consider a resolution
\[ P_n \to P_{n-1} \to \dots \to P_0 \to M \to 0,  \]
where all the $\left\{P_i\right\}$ are finite free $R$-modules. If we can show
that the kernel of $P_n \to P_{n-1}$ is projective, then it will follow that
$M$ has finite projective dimension. Since $M$ was arbitrary, it will follow
that $R$ is regular too, by Serre's criterion.

Let $K$ be the kernel, so there is an exact sequence
\[ 0 \to K \to  P_n \to P_{n-1} \to \dots \to P_0 \to M \to 0, \]
which we can tensor with $S$, by flatness:
\[ 0 \to K \otimes_R S \to  P_n \otimes_R S  \to P_{n-1} \otimes_R S \to \dots
\to P_0 \otimes_R S  \to M \otimes_R S\to 0. \]
Because any finitely generated $S$-module has projective dimension $\leq n$, it
follows that $K \otimes_R S$ is projective, and in particular flat.

But now $S$ is \emph{faithfully flat} over $R$ (see \cref{}), and it follows
that $K $ is $R$-flat. Thus $K$ is projective over $R$, proving the claim. 
\end{proof} 

\begin{theorem} 
The localization of a regular local ring at a prime ideal is regular. 
\end{theorem} 
Geometrically, this means that  to test whether a nice scheme (e.g. a variety) is regular
(i.e., all the local rings are regular), one only has to test the \emph{closed}
points.
\begin{proof} 
Let $(R, \mathfrak{m})$ be a regular local ring. Let $\mathfrak{p} \in \spec R$
be a prime ideal; we wish to show that $R_{\mathfrak{p}}$ is regular. 
To do this, let $M$ be a finitely generated $R_{\mathfrak{p}}$-module. Then we
can find a finitely generated $R$-submodule $N \subset M$ such that 
the natural map $N_{\mathfrak{p}} \to M$ is an isomorphism.
If we take a finite free resolution of $N$ by $R$-modules and localize at
$\mathfrak{p}$, we get a finite free resolution of $M$ by
$R_{\mathfrak{p}}$-modules. 

It now follows that $M$ has finite projective dimension as an
$R_{\mathfrak{p}}$-module. By Serre's criterion, this implies that
$R_{\mathfrak{p}}$ is regular. 
\end{proof} 

\subsection{Regular local rings are factorial}

We now aim to prove that a regular local ring is factorial.

First, we need:
\begin{definition} 
Let $R$ be a noetherian ring and $M$ a f.gen. $R$-module.  Then $M$ is
\textbf{stably free} if $M \oplus R^k$ is free for some $k$.
\end{definition} 

Stably free obviously implies ``projective.'' 
Free implies stably free, clearly---take $k=0$. Over a local ring, a finitely
generated projective module is free, so all three notions are equivalent. Over a
general ring, these notions are generally different.

We will need the following lemma:

\begin{lemma} 
Let $M$ be an $R$-module with a finite free resolution. If $M$ is projective,
it is stably free.
\end{lemma} 
\begin{proof} 
There is an exact sequence
\[ 0 \to F_k \to F_{k-1} \to \dots \to F_1 \to F_0 \to M \to 0  \]
with the $F_i$ free and finitely generated, by assumption. 

We induct on the length $k$ of the resolution. We know that if $N$ is the
kernel of $F_0 \to M$, then $N$ is projective (as the sequence $0 \to N \to
F_0 \to M \to 0$ splits) so there is a resolution
\[ 0 \to F_k \to \dots \to F_1 \to N \to 0.  \]
By the inductive hypothesis, $N$ is stably free. 
So there is a free module $R^d$ such that $N \oplus R^d$ is free.

We know that $M \oplus N=F_0$ is
free. Thus $M \oplus N \oplus R^d = F_0 \oplus R^d$ is free and $N \oplus R^d$
is free. Thus $M$ is stably free.
\end{proof} 


\begin{remark} 
Stably freeness does \textbf{not} generally imply freeness, though it does
over a local noetherian ring.
\end{remark} 

Nonetheless,

\begin{proposition} 
Stably free does imply free for invertible modules. 
\end{proposition} 
\begin{proof} 
Let $I$ be stably free and invertible. We must show that $I \simeq R$.
Without loss of generality, we can assume that $\spec R$ is connected, i.e.
$R$ has no nontrivial idempotents. We will assume this in order to talk about
the \textbf{rank} of a projective module.

We know that $I \oplus R^n \simeq R^m$ for some $m$. We know that $m=n+1$ by
localization. So $I \oplus R^n \simeq R^{n+1}$ for some $n$.
We will now need to construct the \textbf{exterior powers}, for which we
digress:

\begin{definition} 
Let $R$ be a commutative ring and $M$ an $R$-module. Then $\wedge M$, the
\textbf{exterior algebra on $M$}, is the free (noncommutative) graded $R$-algebra
generated by $M$ (with product $\wedge$) with just enough relations such that
$\wedge$ is anticommutative (and, \emph{more strongly}, $x \wedge x=0$ for
$x$ degree one).
\end{definition} 

Clearly $\wedge M$ is a quotient of the \textbf{tensor algebra} $T(M)$, which is by
definition $R
\oplus M \oplus M \otimes M \oplus \dots \oplus M^{\otimes n} \oplus \dots$.
The tensor algebra is a graded $R$-algebra in an obvious way: $(x_1 \otimes
\dots \otimes x_a) . (y_1 \otimes \dots \otimes y_b) = x_1 \otimes \dots
\otimes x_a \otimes y_1 \otimes \dots \otimes y_b$. This is an associative
$R$-algebra. 
Then 
\[ \wedge M = T(M)/( x \otimes x, \ x,y \in M).  \]
The grading on $\wedge M$ comes from the grading of $T(M)$. 

We are interested in basically one example:
\begin{example} 
Say $M = R^m$. Then $\wedge^m M = R$. If $e_1, \dots, e_m \in M$ are
generators, then $e_1 \wedge \dots \wedge e_m$ is a generator. More generally,
$\wedge^k M$ is free on $e_{i_1} \wedge \dots \wedge e_{i_k}$ for $i_1 < \dots <
i_k$.
\end{example} 

We now make:

\begin{definition} 
If $M$ is a projective $R$-module of rank $n$, then 
\[ \det(M) = \wedge^n M.  \]
\end{definition} 
If $M$ is free, then $\det(M)$ is free of rank one. So, as we see by
localization, $\det(M)$ is always an
invertible module for $M$ locally free (i.e. projective) and $\wedge^{n+1}M = 0$.

\begin{lemma} 
$\det(M \oplus N) = \det M \otimes \det N$.
\end{lemma} 
\begin{proof} 
This isomorphism is given by wedging $\wedge^{\mathrm{top}} M \otimes
\wedge^{\mathrm{top}} N \to \wedge^{\mathrm{top}}(M \oplus N)$. This is easily
checked for oneself.
\end{proof} 

Anyway, let us finally go back to the proof. If $I \oplus R^n = R^{n+1}$, then
taking determinants shows that
\[ \det I \otimes R = R,  \]
so $\det I = R$. But this is $I$ as $I$ is of rank one. So $I$ is free.

\end{proof} 

\begin{theorem} 
A regular local ring is factorial.
\end{theorem} 

Let $R$ be a regular local ring of dimension $n$. We want to show that $R$ is factorial. 
Choose a prime ideal $\mathfrak{p}$ of height one. 
We'd like to show that $\mathfrak{p}$ is principal. 

\begin{proof} 
Induction on $n$. If $n=0$, then we are done---we have a field. 

If $n=1$, then a height one prime is maximal, hence principal, because
regularity is equivalent to the ring's being a DVR. 

Assume $n>1$.  The prime ideal $\mathfrak{p}$ has height one, so it is
contained in  a maximal ideal $\mathfrak{m}$. Note that $\mathfrak{m}^2
\subset \mathfrak{m}$ as well. I claim that there is an element $x$ of
$\mathfrak{m} - \mathfrak{p} - \mathfrak{m}^2$. This follows as an argument
like prime avoidance. To see that $x$ exists, choose $x_1 \in \mathfrak{m} - \mathfrak{p}$ and $x_2
\in \mathfrak{m} - \mathfrak{m}^2$. We are done unless $x_1 \in
\mathfrak{m}^2$ and $x_2 \in \mathfrak{p}$ (or we could take $x$ to be $x_1$
or $x_2$). In this case, we just take $x = x_1 + x_2$.

So choose $x \in \mathfrak{m} - \mathfrak{p} - \mathfrak{m}^2$. Let us examine
the ring $R_{x} = R[1/x]$, which contains an ideal $\mathfrak{p}[x^{-1}]$.
This is a proper ideal as $x \notin \mathfrak{p}$. Now $R[1/x]$ is regular
(i.e. its localizations at primes are regular local). The dimension, however,
is of dimension less than $n$ since by inverting $x$ we have removed
$\mathfrak{m}$. By induction we can assume that $R_x$ is locally factorial.

Now $\mathfrak{p}R_{x}$ is prime and of height one, so it is invertible as
$R_x$ is locally factorial.
In particular it is projective.

But $\mathfrak{p}$ has a finite resolution by $R$-modules (by regularity), so
$\mathfrak{p}R_x$ has a finite free resolution. In particular,
$\mathfrak{p}R_{x}$ is stably free and invertible, hence free. 
Thus $\mathfrak{p}R_x$ is \textbf{principal}.

We want to show that $\mathfrak{p}$ is principal, not just after localization.
We know that there is a $y \in \mathfrak{p}$ such that $y$ generates
$\mathfrak{p}R_x$. Choose $y$ such that $(y) \subset \mathfrak{p}$ is as large
as possible. We can do this since $R$ is noetherian. This implies that $x
\nmid y$ because otherwise we could use $y/x$ instead of $y$. 

We shall now show that
\[ \mathfrak{p} = (y).  \]
So suppose $z \in \mathfrak{p}$. We know that $y$ generates $\mathfrak{p}$
\textbf{after $x$ is inverted.} In particular, $z \in \mathfrak{p}R_x$. That
is, $zx^a \in (y)$ for $a$ large.  That is, we can write
\[ zx^a = yw, \quad \mathrm{for \ some} \ w \in R . \]
We chose $x$ such that $x \notin \mathfrak{m}^2$. In particular, $R/(x)$ is
regular, hence an integral domain; i.e. $x$ is a prime element. We find that
$x$ must divide one of $y,w$ if $a>0$. But we know that $x \nmid y$, so $x
\mid w$.  Thus $w = w'x$ for some $x$. We find that, cancelling $x$,
\[ zx^{a-1} = yw'  \]
and we can repeat this argument over and over until we find that 
\[ z \in (y).  \]
\end{proof} 



