TITLE: Embedding dimension=minimum dimension of a local embedding?
QUESTION [9 upvotes]: Let $X$ be a scheme locally of finite type over a field $k$, and let $p \in X$ be a $k$-point with ${\rm  dim}\; {\Omega_{X}}_{|p}={\rm dim}\; \mathfrak{m}_{p}/\mathfrak{m}^{2}_{p}=m$ (the 'embedding dimension' of the local ring at $p$). 
Then a paper that I'm reading asserts that there is a Zariski open neighbourhood $ p \in U \subseteq X$
and a closed immersion $ U \hookrightarrow M$, where $M$ is a regular (maybe even smooth) scheme over $k$ of dimension $m$. (Clearly $m$ is the minimal dimension for which such an embedding is possible.)
I would like a reference or explanation for this fact, which I have not been able to find in standard commutative algebra books (though it is probably there somewhere). Presumably this is the reason that 
${\rm dim}\;\mathfrak{m}_{p}/\mathfrak{m}^{2}_{p}$ is called the embedding dimension of a local ring.
I would also like a reference or explanation showing that one cannot always take $M=\mathbb{A}^{m}$.

REPLY [7 votes]: One algebraic version of this statement is that if $A$ is a local ring with embedding dimension $m$ and $A$ is the quotient of a regular local ring, then $A$ is the quotient of a regular local ring of dimension $m$. Write $A = R/I$ where $R$ is a regular local ring and suppose that $R$ has dimension $n$. Then we have a surjection of the Zariski cotangent spaces of the two rings $m_R/m_R^2 \rightarrow m_A/m_A^2$. We can find a basis for the kernel of this map consisting of $n-m$ vectors. Lift these to elements $f_1, \ldots, f_{n-m}$ in the kernel of $A \rightarrow R$ and let $S = R / \langle f_1, \ldots, f_{n-m}\rangle$ so that $A = S/J$ for some ideal $J$. Then I just have to show that $S$ is a regular local ring of dimension $e$. By construction, its Zariski cotangent space has dimension exactly $m$, and by the Krull principal ideal theorem, it has dimension at least $m$, so it must be a regular local ring of dimension $m$.
In the setting that you asked, every local ring of a scheme of finite type over a field is the quotient of a regular local ring since it is the quotient of a localization of affine space. If you apply the argument above then you get equations $f_1, \ldots, f_{n-m}$ which define a regular scheme at $p$ and thus in a neighborhood of $p$. This is your scheme $M$.
As for your question about whether $M$ can always be chosen to be $\mathbb A^m$, the answer is certainly not. Just take $p$ to be a smooth point on any non-rational variety. Then pretty much by definition, there is no neighborhood of $p$ which is isomorphic to an open subset of affine space. It would take some more work to think of an example where $p$ is singular, but it seems like a sufficiently singular point of a variety in a non-rational variety would work. (Although, I believe any zero-dimensional scheme of embedding dimension $m$ and finite type over a field has a closed immersion into affine space of dimension $m$.)