Solution (source code)

= Solution

Here <subvariety> means a closed affine <subvariety>. Suppose first that $F^\#$ is onto, and write $X\subseteq\mathbb A^n$, $Y\subseteq\mathbb A^m$. Put $J=\ker F^\#$ and $Z=V_Y(J)$. Choose $g_i\in A(Y)$ with $F^\#g_i=x_i|_X$ and let $G:Z\to\mathbb A^n$ have components $g_i|_Z$.

If $h\in I(X)$, then $F^\#(h(g_1,\ldots,g_n))=h|_X=0$, so $h(g_1,\ldots,g_n)\in J$. It vanishes on $Z$, proving $G(Z)\subseteq X$. The chosen lifts give $G\circ F=\operatorname{id}_X$, and $F(X)\subseteq Z$ by the definition of $J$.

Let the components of $F$ be <polynomial functions> $f_1,\ldots,f_m$ on $X$. For each target coordinate $y_j$, the element $y_j-f_j(g_1,\ldots,g_n)$ has zero <pullback>, hence belongs to $J$. It vanishes on $Z$, giving $F\circ G=\operatorname{id}_Z$. Both maps have <polynomial> components, so $F$ is an <isomorphism> onto the <closed subvariety> $Z$.

Conversely, if $F:X\to Z\subseteq Y$ is an <isomorphism> onto a <closed subvariety>, <restriction> $A(Y)\to A(Z)$ is <surjective>, and the <pullback> $A(Z)\to A(X)$ of that <isomorphism> is an <isomorphism>. Their composition is $F^\#$, proving
$$
\boxed{F^\#\text{ onto}\iff F\text{ is a closed embedding}.}
$$
The word closed matters: an <isomorphism> onto a merely locally <closed subset> need not induce a <surjective> coordinate-ring map. For example $\mathbb G_m\hookrightarrow\mathbb A^1$ induces $k[t]\hookrightarrow k[t,t^{-1}]$.