Solution (source code)

= Solution

Work on <affine open subsets>. Their <coordinate rings> are <Noetherian rings> and <integrally closed domains>. At a <prime ideal> of <height of a prime ideal> one, the <local ring> is a one-dimensional <Noetherian local ring> which is an <integrally closed domain>, hence a <discrete valuation ring> and therefore a <regular local ring>. At the generic point the <local ring> is a <field>, hence a <regular local ring>. For a brief justification of the one-dimensional <local ring> fact, take $0\ne a\in\mathfrak m$ in a one-dimensional <Noetherian local ring> $R$ which is an <integrally closed domain>. Some $\mathfrak m^n\subset(a)$; choose the least such $n$, and choose $b\in\mathfrak m^{n-1}\setminus(a)$. Then $q=b/a\notin R$, but $q\mathfrak m\subset R$. If $q\mathfrak m\subset\mathfrak m$, the <determinant trick> applied to the finitely generated faithful module $\mathfrak m$ would make $q$ integral over $R$, a contradiction. Hence the ideal $q\mathfrak m$ contains a unit and equals $R$. Thus $\mathfrak m=q^{-1}R$ is principal. A one-dimensional <Noetherian local ring> with principal maximal ideal is a <discrete valuation ring>. Therefore a <normal variety> is <regular in codimension one>.

The ground <field> is an <algebraically closed field>, hence a <perfect field>, so having a <regular local ring> is equivalent to being a <smooth point of a variety> here. Moreover, the <smooth locus of a variety> is open, making the <singular locus> closed. If an <irreducible component> of the <singular locus> had <algebraic codimension> zero or one, its generic point would have a <regular local ring> by the preceding argument, a contradiction. Consequently every such component has <algebraic codimension> at least two.

One can read the numerical bound directly from chains of <prime ideals>, without identifying <algebraic dimension> with <transcendence degree>. For a <prime ideal> $P$ of <height of a prime ideal> at least two in an <affine chart>, append a chain $(0)\subsetneq P_1\subsetneq P$ below any chain in the quotient by $P$. Its length increases by two. Thus $\dim A/P\le\dim A-2$. Since a nonempty <affine open subset> of the <irreducible variety> $X$ has <algebraic dimension> $d$,
$$
\boxed{\dim\operatorname{Sing}(X)\le d-2.}
$$
For $d=0$ or $1$, this means the <singular locus> is empty; take $\dim\varnothing=-\infty$.