Is $\operatorname{height} \mathfrak{p} + \dim A / \mathfrak{p} = \dim A$ true?

Yours is a very interesting and subtle question, which often generates confusion. First let us give a name to the property you are interested in: a ring $A$ will be said to satisfy (DIM) if for all $\mathfrak p \in \operatorname{Spec}(A)$ we have $$\operatorname{height}(\mathfrak p) +\dim A/\mathfrak p=\dim(A) \quad \quad (\text{DIM})$$
The main misconception is to believe that this follows from catenarity:
Fact 1: A catenary ring, or even a universally catenary ring, does not satisfy (DIM) in general.
Counterexample: Let $(R,\mathfrak m)$ be a discrete valuation ring whose maximal ideal has uniformizing parameter $\pi$, i.e. $\mathfrak m =(\pi)$. Let $A=R[T]$, the polynomial ring over $R$. The ring $A$ has dimension $2.$ Then for the maximal ideal $\mathfrak p=(\pi T-1)$, the relation (DIM) is false: $\operatorname{height}(\mathfrak p)+\dim A/\mathfrak p= 1+0=1\neq 2=\dim (A)$.
And this even though $A$ is as nice as can be: an integral domain, noetherian, regular, universally catenary,...

Happily here are two positive results:

Fact 2: A finitely generated integral algebra over a field satisfies (DIM) (and is universally catenary).
So, by the algebro-geometric dictionary, an affine variety $X$ has the pleasant property that for each integral subvariety $Y\subset X$ we have, as hoped, $\operatorname{dimension}(Y) + \operatorname{codimension}(Y)$ $=$ $\operatorname{dimension}(X).$

Fact 3: A Cohen-Macaulay local ring satisfies (DIM) (and is universally catenary).
For example a regular ring is Cohen-Macaulay. This "explains" why my counter-example above was not local.

The paradox resolved. How is it possible for a catenary ring $A$ not to satisfy (DIM)? Here is how. If you have an inclusion of two primes $\mathfrak p\subsetneq \mathfrak q$ catenarity says that you can complete it to a saturated chain of primes $\mathfrak p\subsetneq \mathfrak p_1\subsetneq \ldots \subsetneq \mathfrak p_{r-1} \subsetneq \mathfrak q$ and that all such completions will have length the same length $r$. Fine. But what can you say if you have just one prime $\mathfrak p$ ? Not much! The catenary ring $A$ may have dimension $\dim(A) > \operatorname{height}( \mathfrak p) +\dim(A/\mathfrak p)$ because it possesses a long chain of primes avoiding the prime $\mathfrak p$ altogether. In my counterexample above the only saturated chain of primes containing $\mathfrak p=(\pi T-1)$ is $0\subsetneq \mathfrak p$. However the ring $A$ has dimension 2 because of the saturated chain of primes $0\subsetneq (\pi) \subsetneq (\pi,T)$, which avoids $\mathfrak p$.

Addendum. Here is why the ideal $\mathfrak p$ in the counter-example is maximal. We have $A/\mathfrak p=R[T]/(\pi T-1)=R[1/\pi]=\operatorname{Frac}(R)$, since the fraction field of a discrete valuation ring can be obtained just by inverting a uniformizing parameter. So $A/\mathfrak p$ is a field and $\mathfrak p$ is maximal.


The statement with the hypotheses given in Hartshorne is true.

For a reference, see COR 13.4 on pg. 290 of Eisenbud's Commutative Algebra.

The general idea of proof is this: Consider a maximal chain of prime ideals in $A$ which includes the given prime $\mathfrak p$, the length of which is dim $A$ (see Thm A, pg. 290 of Eisenbud). It follows that $\dim A = \operatorname{height} \mathfrak p + \dim A/\mathfrak p$.


Although this is an old question, I thought it was worth mentioning a recent paper by Heinrich that corrects the statements in EGA$0_{\text{IV}}$ mentioned in the comments.

Let us start with some definitions (following [Heinrich, Def. 1.2, Prop. 4.1]):

Definition. Let $X$ be a topological space which is $T_0$, noetherian, and finite dimensional.

  1. The space $X$ is biequidimensional if all maximal chains of irreducible closed subsets of $X$ have the same length.
  2. The space $X$ is weakly biequidimensional if it is equidimensional, equicodimensional, and catenary.
  3. A closed subset $Y \subseteq X$ satisfies the dimension formula if $$\dim(X) = \dim(Y) + \operatorname{codim}(Y,X).$$

The often cited result from EGA$0_{\text{IV}}$ is the following:

Claim [EGA$0_{\text{IV}}$, Prop. 14.3.3, Cor. 14.3.5]. Let $X$ be a topological space which is $T_0$, noetherian, and finite dimensional. The following are equivalent:

  1. The space $X$ is biequidimensional.
  2. The space $X$ is weakly biequidimensional.

Moreover, either of these equivalent conditions implies the following:

  1. Every closed subset $Y \subseteq X$ satisfies the dimension formula.

This is not quite correct; Heinrich shows that (1) implies both (2) and (3) [Heinrich, Lem. 2.1, Prop. 4.1], but that (2) does not imply (3):

Example [Heinrich, Ex. 3.7]. The ring $A$ obtained by localizing the ring $$\frac{k[u, v, w, x, y, z]}{(uy, uz, vy, vz, wy, wz)}$$ away from $(u,v,w,y,z)$ and $(u,v,w,x,y − 1,z − 1)$ is weakly biequidimensional but does not satisfy the dimension formula: the prime ideal $\mathfrak{p} = (u,v,w,y)$ satisfies $$\operatorname{ht}(\mathfrak{p})+\dim(A/\mathfrak{p}) = 1+1 = 2 < 3 = \dim(A).$$ See [Heinrich, Ex. 3.7] for details.

A preprint by Emerton and Gee gives a correct variant of the Claim above; see [Emerton and Gee, Lem. 2.32]. The basic difference is that the Claim is true if $X$ is assumed to be irreducible.