Embedding dimension=minimum dimension of a local embedding? 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}$.
 A: 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$.)
A: Let me give you a proof in the complex category.
Assume that $U \subset X$ is an open neighborhood of $p \in X$ which is a closed complex subvariety of a domain $D \subset \mathbb{C}^n$ with coordinates $z_1, \ldots, z_n$. Let $f_1, \ldots, f_k$ be functions on $D$ such that $$\mathcal{O}_{X,p}=\mathcal{O}_{D, p}/(\overline{f}_1, \ldots, \overline{f}_k),$$ where $\overline{f}_i$ denotes the germ of $f_i$ at the point $p \in D$.
Then one proves that $$m=\textrm{embdim}_p X= n- \textrm{rank}J_p(f_1, \ldots, f_k),$$ 
where $J_p(f_1, \ldots, f_k)=\big( \frac{\partial f_i}{\partial z_j}(p) \big)$ is the Jacobian matrix of the $f_i$ at $p$.
Then by the Implicit Function Theorem it follows that a neighborhood of $p \in X$ can be realized as a closed complex subvariety of $\mathbb{C}^{n- \textrm{rank}J_p}=\mathbb{C}^m$.
For a reference with more details, see for instance [Okuma, Plurigenus of Surface Singularities, Chapter 1, p. 1-2].
A: Presumably the algebraic analogue of something that uses the Implicit Function Theorem involves saying the word "etale" a lot. Thus:
Let $x_1,...,x_m$ be a lift of a basis of $m_p/m_P^2$ to the ring regular functions of some open affine neighborhood $U$ of $P$. Then the map $U \to \textrm{Spec} k[x_1,..,x_m]$ has image some closed subscheme $\textrm{Spec} k[x_1,..,x_m]/I$. This map is etale at $P$ since it induces an isomorphism on formal completions of local rings, so it is etale in some neighborhood of $P$, so it is locally the vanishing set of $n$ equations in $n$ variables over $k[x_1,...,x_m]/I$ whose Jacobian is a unit. Lift those equations arbitrarily from $k[x_1,...,x_m]/I$ to $k[x_1,...,x_m]$. Because everything in $I$ is degree two or higher at zero/$P$, the Jacobian is still invertible at zero/$P$, thus invertible on an open neighborhood.
The vanishing set of the lift of those equations is a cover of $\textrm{Spec}k[x_1,..,x_m]$, etale in a neighborhood of the origin, thus smooth and dimension $m$ in a neighborhood of the origin. The closed subscheme cut out by the ideal $I$ is the same as the vanishing set of the original equations over $k[x_1,...,x_m]/I$, which was locally isomorphic to $U$. Thus  $U$ is locally a closed subscheme of a variety smooth of dimension $m$.
