How to compute the dimension of $V(f,g)$ in $\mathbb Z[x_1,...,x_n]$ Consider the ring $R = \mathbb Z[x_1,...,x_n]$ and let $\text{Spec}(R) = \{q \subset R : q \text{ a prime ideal}\}$ be the set of prime ideals of $R$. For $I \subset R$ an ideal, define $V(I) = \{q \in \text{Spec}(R) : I \subset q\}$ to be the set of prime ideals containing $I$. The $V(I)$'s are the closed sets of $\text{Spec}(R)$ in the Zariski topology.
For $f, g \in R \setminus \{0\}$ prime elements, I'm asked to compute $\dim V(I)$, where $I = (f,g)$ and the dimension is defined as here and is linked to here in the sense that $\dim V(I) = \dim (R/\text{rad}(I))$.
If $R$ were a finitely generated $K$-algebra for a field $K$, it would be easier. So I've tried to consider the quotient $\mathbb Z/p[x_1,...,x_n]$ for a prime $p$ in $\mathbb Z$.
However, I am not sure on whether $(f)$ and $(g)$ would still be prime in this quotient, but maybe I can choose $p$ so it is always the case. Even if they are, $I$ is not necessarily prime so this is also a problem.
So I wanted to quotient first by $(f)$ and then by $(g)$ to have the quotient by $(f,g)$ but again, we don't know if $(\bar{g})$ is prime in $\mathbb Z/p[x_1,...,x_n]/(f)$...
Has anyone got an idea ?
 A: For problems like this its very helpful to think geometrically (ignoring the fact that we don't have varieties), and then use the necessary theorems to justify our geometric intuition.
We want to think to think of $V(f)$ as an irreducible subspace of $\text{Spec}(R)$, and if this $f$ were a (nice) function on a manifold, we would expect its zeroset to be codimension one. Then $V(f,g)$ is the zeroset of the function $g$ restricted to the vanishing set of $f$, so this function could be either zero, or invertible on $V(f)$, or restrict to a function with zeroes as expected, resulting in a codimension $2$ space inside $\text{Spec}(R)$.
So now lets make these three cases precise. The tool for dealing with expected codimension is Krull's principal ideal theorem, which since $f$ is a prime element implies that $V(f)$ is codimension $1$ in $\text{Spec}(R)$, and since $R$ is caternary (aka, codimension is complementary to dimension EDIT- This isn’t all that’s needed, see comments), this implies $V(f)$ has dimension $n$, since $R$ has dimension $n+1$.
Now, if $g=f$, then $g$ restricts to zero on $V(f)$, equivalently, is in the ideal generated by $f$, and this gives our first case, where $V(f,g)$ is dimension $n$.
The second case is when $g$ doesn't vanish on $V(f)$, which is to say $g$ is a unit in $R/(f)$. In this case, our vanishing set is empty, which agrees with the fact that $R/(f,g)$ is the zero ring since $g$ is a unit in $R/(f)$.
The last case is when the expected thing happens, we get a nonzero element of the domain $R/(f)$, though now $g$ might not be a prime element in this ring, it could have vanishing set with multiple components, for instance: $$f=2$$ $$g=2+x^2-y^2$$
Now we use the principal ideal theorem again, this time in full, which tells us that the irreducible components of $V(f,g)$ inside $V(f)$ will all be codimension $1$, so since the catenary property passes to quotients, we see that in this case $V(f,g)$ will be codimension $2$ in $\text{Spec}(R)$, and will have all irreducible components of dimension $n-1$.
This exhausts the three cases, and all of these can occur, for an example of the second case, we can take: $$f=x$$ $$g=x+1$$
Geometrically, this is taking our two codimension one subsets to be translates of each other, so of course they won't intersect.
A: Here is a more elementary proof that doesn't use notions of catenary rings. The case when $f,g$ are not coprime is easy. So we only discuss the case when they are coprime.
$\dim V(f,g)=\dim R/(f,g)$.  Let $I=(f,g)$. If $1\in(f,g)$, then $\dim V(f,g)=0$. We claim that $\dim V(f,g)=n-1$ in other cases. Firstly, $\text{height}(I)\leq 2$ and since $(0)\subset (f) \subset P_i$ is a chain of length $2$ for any $i$, we know that $\text{height}(I)=2$. Then by the inequality
$\dim R/I+\text{height}(I)\leq \dim R$, we know that $\dim R/I \leq n-1$. To show that $\dim R/I\geq n-1$, we wish to find a chain of prime ideals of length $n-1$ that contain $(f,g)$.
Let's first deal with the case when $(f,g)\cap \mathbb{Z}=(0)$. Let $I=(f,g)$. Consider the localization homomorphism $i:\mathbb{Z}[x_1,\cdots,x_n]\to \mathbb{Q}[x_1,\cdots,x_n]$. Then $I^e=(f,g)$. It's clear that $I^e\neq (1)$. Therefore $\text{height }(I^e)\leq 2$. Thus there exists a chain of length $n-2$ of prime ideals $\mathfrak{p}_0\subset \cdots \mathfrak{p}_{n-2}$ with $I^e\subset \mathfrak{p}_0$. They can be pulled back to a chain of prime ideals $\mathfrak{p}_0^c\subset \cdots \mathfrak{p}_{n-2}^c$ with $I\subset \mathfrak{p}_0^c$. Since neither of the $\mathfrak{p}_i^c$ contains an integer, we know that they are disjoint from the multiplicative set. Since their extended ideals are distinct, they are also distinct ideals by property of localization. Moreover, we claim that any maximal ideal $\mathfrak{m}$ in $\mathbb{Z}[x_1,\cdots,x_n]$ must contain a prime integer. This is because $\mathbb{Z}[x_1,\cdots,x_n]/\mathfrak{m}$ is a field which is finitely generated over $\mathbb{Z}$, therefore it must be a finite field $\mathbb{F}_p$. Thus $p\in\mathfrak{m}$. With this observation and the fact that $\mathfrak{p}_{n-2}$ doesn't contain any integer, we know that $\mathfrak{p}_{n-2}$ is not maximal. So we can extend the chain of prime ideal by adding a maximal ideal in the end. In this way we find a chain of prime ideals of length $n-1$ over $I$.
In the case when $(f,g)\cap \mathbb{Z}=(n)$ where $n>1$, let $p$ be a prime number that divides $n$. We will denote $\mathbb{F}_p[x_1,\cdots,x_n]$ by $R_p$ and will use $\bar f$ to denote the image of a polynomial $f\in \mathbb{Z}[x_1,\cdots,x_n]$ in $R_p$. We claim that $(\bar f,\bar g)$ will be contained in some non-trivial principal ideal $\bar{h}$ in $R_p$, and hence we can find a chain of prime ideals of length $n-1$ in $R_p$ that contains $(\bar{h})$ (Since $\text{height }((\bar{h}))=1$) then pull it back to a chain of prime ideals of length $n-1$ in $R$ that contains $(f,g)$, and we can conclude that $\dim R/I\geq n-1$. To see this, note that $(\bar f, \bar g)\subset (\bar h)$ is equivalent to saying that $\bar h$ is a common divisor of $\bar f$ and $\bar g$. So we only need to prove that $\bar f$ and $\bar g$ are not coprime in $R_p$. If they are, since $n\in(f,g)$ in $R$, we know that there exist $h_1,h_2 \in R$ such that $fh_1+gh_2=n$. Since $p\mid n$, we have $\bar{f}\overline{h_1}+\bar{g}\overline{h_2}=\bar 0$ in $R_p$. If $\bar{f}$ and $\bar{g}$ are coprime, we will have $\bar g \mid \overline{h_1}$ and $\bar{f}\mid \overline{h_2}$. Thus $h_1=gg'+pg''$ and $h_2=ff'+pf''$ for some polynomials $g',g'',f',f''\in R$. Substituing $h_1$ and $h_2$ in the equation $fh_1+gh_2=n$, we will get $fg(g'+f')+p(fg''+gf'')=n$. Thus $p$ must divide $fg(g'+f')$, therefore $p$ must divide one of $f,g$ or $f'+g'$. In either case, $\frac{1}{p}fg(g'+f')\in (f,g)$. Therefore, $\frac{1}{p}fg(f'+g')+fg''+gf''=\frac{n}{p}$, so $n/p\in (f,g)$, leading to a contrary that $(f,g)\cap \mathbb{Z}=(n)$. Thus $\bar f$ and $\bar{g}$ are not coprime.
