We now show that the generic dimension of the tangent space of an (irreducible) variety $V$ matches the dimension of $V$ itself.  Replacing $V$ by a suitable affine open subset and using that the dimension of a typical quotient $M_v/M_v^2$ is unchanged if the coordinate ring $K[V]$ is replaced by its localization $K{V]_{M_v}$, we may assume by a result proved last time that $V$ is a hypersurface in $K^n$, defined by a single equation $f=0$ for some irreducible
$f\in S=K[x_1,\ldots,x_n]$; then the principal ideal $(f)$ generated by $f$ is clearly minimal, not properly containing any other nonzero prime ideal, so the dimension of $V$ is $n-1$.  Now we just have to see that the set of points in $V$ at which the gradient of $f$ vanishes, which is closed in $V$, is a proper subset, so that the gradient of $f$ is not identically 0 on $V$.  Since $f$ is irreducible and its partial derivatives have lesser degree, the gradient $\nabla f$ of $f$ vanishes on $V$ if and only if
$\nabla f = 0$.  This is clearly impossible in characteristic 0; in prime characteristic $p$, it would force $f$ to be a polynomial in the $p$th powers $x_1^p,\ldots,x_n^p$ of the variables $x_i$, whence by taking $p$th roots of its coefficients (possible since $K$ is algebraically closed) we would have
$f = g^p$ for some $g\in S$, contradicting the irreducibility of $f$.  Thus the generic dimension of the tangent space of $V$ indeed matches its dimension $n-1$, as desired, and at nongeneric points the dimension of the tangent space increases.  (Thus our point of view is different than in Math 126, for example, where we would say instead that the tangent space is undefined at any point where the Jacobian matrix has the wrong corank.  Note also that such points would be excluded by definition in any smooth manifold.)  For reducible varieties $V$, we define the tangent space in the same way and the same result holds, but note here that singular points can arise when irreducible components intersect; for example, the origin is a singular point of the variety with equation $xy = 0$, even though this point is nonsingular in both the $x$- and $y$-axes,  Finally, observe that (as mentioned previously) the origin is singular in our old friend the curve with equation $x^2 - y^3 = 0$, so that the coordinate ring of this curve is \lq\lq bad" in another sense (in addition not to being integrally closed), in that it is singular at the maximal ideal $(x,y)$.  (It turns out that these two failures, one of nonsingularity and the other of integral closedness, are equivalent for curves, but not for higher-dimensional varieties.)

We now discuss the behavior of dimension for general commutative rings $A$.  So far, we have used the Krull dimension, according to which the dimension of $A$ is the largest $n$ for which there is a strictly ascending chain $P_0\subset\cdots\subset P_n$ of prime ideals of $A$, or $\infty$ if arbitrarily long such chains exist).  Later we will give two other definitions of dimension for Noetherian local rings (having exactly one maximal ideal), which turn out to be equivalent to this one; recall for any prime ideal $P$ of such a ring that $A_P$ is Noetherian local (Noetherian because any ideal of its takes the form $I_P$ for some ideal of $A$ and so is generated by any set of generators in $A$; local because its unique maximal ideal is $PA_P$).  For now we want to generalize the notion of irreducibility (of varieties) to any commutative Noetherian ring $A$.  Call an ideal $I$ of $A$ {\sl irreducible} if it is not the intersection of two ideals properly containing it.  Then one easily checks that any ideal of $A$ is a finite intersection of irreducible ones, which is unique up to reordering if none of them contains another (the proof is parallel to our proof that every variety in $K^n$ is uniquely a finite union of irreducible ones).  Now we observe that {\sl any irreducible ideal $I$ is {\bf primary} in the sense that if it contains a product $xy$, it contains either $x$ or a power $y^n$ of $y$}.  By passing to the quotient it is enough to prove this for $I=0$; suppose accordingly that $xy=0$ but $y\ne0$.  Let
$I_n = \{z\in A$:  x^nz = 0\}$; then the $I_n$ form an ascending chain of ideals in $A$, which must stabilize, so that $I_n = I_{n+1}$ for some $n$.  Then $(x^n)\cap (y) = 0$, for if $a\in (y)$, then
$ax = 0$; if also $a\in (x^n)$, then $a=bx^n$ for some $b$, whence $ax = 0$ forces
$b\in I_{n+1} = I_n$, and $a=0$, as claimed.  But then $(0)$ is the intersection of $(x^n)$ and $(y)$, whence irreducibility forces $x^n = 0$, as desired.  It follows easily that {\sl any irreducible ideal has prime radical} and thus that {\sl any radical ideal $J$ of $A$ is a finite intersection of prime ideals $P_i$, which is unique up to reordering if no $P_i$ contains another} (just like radical ideals in polynomial rings).  We call the $P_i$ the {\sl minimal primes over $J$}; note that these same prime ideals may be regarded the minimal ones over any ideal with radical $J$.  Given now a prime ideal $P$ of finite {\sl height} $m$ (so that there is a strictly ascending chain of prime ideals $P_0\subset\cdots\subset P_m=P$, but no longer such chain), choose elements $x_1,\ldots,x_m$ of $P$ such that, for all indices $i\le m$, every prime ideal of $A$ containing $x_1,\ldots,x_i$ has height at least $i$ inductively, as follows.  This is trivial for $i=0$; if $i>0$ and $x_1,\ldots,x_{i-1}$ have been constructed, let $P_1\ldots,P_m$ be the minimal primes of $(x_1,\ldots,x_{i-1}$ of height exactly $i-1$, if any; if there are none, then we can just set $x_i = 0$.  Then the ideal $P$ cannot be contained in any of the $P_i$, since its height is larger than $i-1$.  We claim that $P$ cannot be contained in their union either.  Indeed, if we inductively choose $y_j$ in $P$ but not in any $P_k$ for any index $k<i$ with the possible exception of $k=j$, then if any $y_j$ fails to lie in $P_j$, then we are done and can take $x_i = y_j$; otherwise the sum of products $\sum_{j=1}^{i-1} \prod_{k\ne j} (x_1\cdots x_k\cdots x_{i-1}$ lies in $P$ but not any $P_i$ and so can be taken as $x_i$; in either case $x_1,\ldots,x_i$ have the desired property.  Thus $P$ is one of the minimal primes of
$J=(x_1,\ldots,x_m)$ in $A$.  If $A$ is local and $P$ is its unique maximal ideal, then the radical of $J$ must be $P$, if $P$ has finite height $h$, since then $P$ is the only prime ideal of this height.  We will give two other characterizations of dimension and prove that the dimension of $K[x_1,\ldots,x_n]$ is $n$ next week.  