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.
any two strictly increasing chains
are contained in maximal strictly increasing chains from p to q of the same (finite) length. If this is the definition you use, there are counterexamples of "codimension is complementary to dimension", see https://math.stackexchange.com/questions/49136/is-operatornameheight-mathfrakp-dim-a-mathfrakp-dim-a-true/49285#49285.
– Zichen Gao Dec 31 '22 at 19:36