Dimension of hypersuface of irreducible k-scheme of finite type I am looking at Algrabic Geometry written by Gortz and Wedhorn, there is a theorem(theorem 5.32):
Let $X$ be an integral k-scheme of finite type, and let $f \in \Gamma\left(X, O_X\right)$ be a non-unit, and different from 0.(i. $e ., \emptyset \subsetneq V(f) \subsetneq X$ ). Then $V(f)$ is equi-codimensional of codimension 1 in $X$.
I wonder if it's correct for arbitary irreducible k-scheme of finite type under the assumption that $\emptyset \subsetneq V(f) \subsetneq X$ . My idea is that for arbitary
irreducible k-scheme of finite type $X$, we have the reduced scheme $X_{red}$ associated with it.
Let $g$ be the canonical morphism $g: X_{red} \rightarrow X$ and $g^{\sharp} :\Gamma\left(X, O_X\right) \rightarrow \Gamma\left(X_{red}, O_{X_{red}}\right)$.
Then $g^{-1}(V(f))=V_{red}(g^{\sharp}(f))$ because if we look locally (restrict f on a affine open subset) we may assume that  $X=Spec(A)$ and $X_{red}=Spec(A/nil(A))$ then clearly $g^{-1}V(f)=V_{red}(g^{\sharp}(f))$ where $g^{\sharp}(f)$ is the image of $f$ under the quotient map $A \rightarrow A/nil(A)$. It then follows since $g$ is a topological isomophism.
My question is
1.Is there something wrong with my proof?
2.If my proof is not correct, is there any theorem about the dimension of the hypersurface in irreducible k-scheme of finite type?
 A: I think you need to check your assumptions on $f$: If $f \in \mathcal{O}^*$ is a unit, then you already noticed that $V(f)= \emptyset$ and if $f=0$ then $V(f)=X$.
So far so good, but if $X$ is not reduced, you can also have $V(f)=X$ if you choose $f$ to be nilpotent, i.e. locally in $\mathbf{Spec}(A)$ is $f$ contained in the $nil(A)$. An example is given by @DouglasMolin.
Your misconception might be that $g^\#(f)$ under the image of the canonical $A \rightarrow A/nil(A)$ is zero if and only if $f$ is nilpotent so $f$ is zero on $X_{red}$.
So I try to address your assumptions now: Lets check on opens $\mathbf{Spec}(A)$ and take one component of $V(f)$:
Edit: If you want to use $V(f) \neq X$ then note that also $g^{-1}V(f)= V(g^\#(f)) \neq X_{red}$, so $g^\#(f)\neq 0$, so by Krull principal ideal theorem every minimal prime $\mathfrak{p}$ lying over $g^\#(f)$ has $\text{height}=1$. Then $\text{height}(\mathfrak{p}) + \dim A / \mathfrak{p} = \dim A$ implies that $V(f)_{red}=\mathbf{Spec}(A/\mathfrak{p})$ is of codim. 1.
I think its correct but you need to say $g^\#(f)$ is non-zero und maybe use Krulls theorem for the dimension.
