Solution (source code)

= Solution

We first prove the local algebra fact behind regularity in codimension one. Let $(A,\mathfrak m)$ be a one-dimensional normal Noetherian local domain. Choose $0\ne a\in\mathfrak m$. Its radical is $\mathfrak m$, so some $\mathfrak m^n$ lies in $(a)$; take minimal $n$. If $n=1$, then $\mathfrak m=(a)$. Otherwise choose $b\in\mathfrak m^{n-1}\setminus(a)$ and put $z=b/a$ in the <fraction field>. We have $z\notin A$ but $z\mathfrak m\subseteq A$.

If $z\mathfrak m\subseteq\mathfrak m$, express multiplication by $z$ on a finite generating set of $\mathfrak m$. The <determinant trick> gives a monic polynomial in $z$ annihilating $\mathfrak m$; as this ideal is nonzero in a domain, the polynomial itself vanishes. Normality would then give $z\in A$, a contradiction. Hence there is $u\in\mathfrak m$ with $zu$ a unit of $A$. Every $v\in\mathfrak m$ satisfies $v=u(zv)/(zu)$, proving $\mathfrak m=(u)$. The <maximal ideal> therefore has one generator in dimension one, so $A$ is a <regular local ring>, indeed a <discrete valuation ring>. This proves <one-dimensional normal local rings are discrete valuation rings> directly.

Now a codimension-one point of the <normal variety> has such a <local ring>, and a codimension-zero <local ring> is a field. Both are regular. Since the algebraically closed ground field is perfect, regularity and smoothness agree for this finite-type variety, and the <Jacobian criterion> makes the <singular locus> closed. It contains no codimension-zero or codimension-one point. Therefore every <irreducible component> of the <singular locus> has codimension at least two, giving
$$
\boxed{\dim\operatorname{Sing}(X)\le d-2.}
$$
For $d\le1$ this means the <singular locus> is empty. In particular the singular set itself is the required closed subset, not merely a set contained in some larger one.