[proofplan]
Choose affine embeddings $X\subseteq \mathbb A_k^n$ and $Y\subseteq \mathbb A_k^m$, and write the coordinate functions on the $Y$-factor as $y_1,\dots,y_m$. If $\varphi$ is regular, its coordinate functions are regular functions on $X$, and the graph is exactly the common zero locus of the regular functions $y_j-f_j$ on $X\times Y$. The projection to $X$ is then inverted by the regular section $x\mapsto (x,\varphi(x))$. Conversely, if the graph is closed and its projection to $X$ is an isomorphism, then composing the inverse $X\to\Gamma_\varphi$ with the projection to $Y$ recovers $\varphi$, hence $\varphi$ is regular.
[/proofplan]
custom_env
admin
[step:Write the graph of a regular map as a common zero locus]
Assume first that $\varphi:X\to Y$ is regular. Fix affine embeddings $X\subseteq \mathbb A_k^n$ and $Y\subseteq \mathbb A_k^m$. Let
\begin{align*}
y_j:Y\to k
\end{align*}
denote the restriction to $Y$ of the $j$-th coordinate function on $\mathbb A_k^m$, for each $j\in\{1,\dots,m\}$. Since $\varphi$ is regular, define regular functions
\begin{align*}
f_j:X\to k,\qquad f_j:=y_j\circ\varphi.
\end{align*}
For each $j\in\{1,\dots,m\}$, define the regular function
\begin{align*}
h_j:X\times Y\to k,\qquad h_j(x,y):=y_j(y)-f_j(x).
\end{align*}
Then, for $(x,y)\in X\times Y$,
\begin{align*}
h_j(x,y)=0\text{ for all }j
\end{align*}
if and only if
\begin{align*}
y_j(y)=y_j(\varphi(x))\text{ for all }j.
\end{align*}
The affine coordinates separate points of the subvariety $Y\subseteq\mathbb A_k^m$, so this is equivalent to $y=\varphi(x)$. Hence
\begin{align*}
\Gamma_\varphi=V_{X\times Y}(h_1,\dots,h_m),
\end{align*}
so $\Gamma_\varphi$ is a closed subvariety of $X\times Y$.
[/step]
custom_env
admin
[step:Construct the regular inverse to the first projection]
Let
\begin{align*}
s:X\to X\times Y,\qquad s(x):=(x,\varphi(x)).
\end{align*}
The coordinate functions of $s$ are the coordinate functions of $X$ together with the functions $f_1,\dots,f_m$, so $s$ is regular as a map into $X\times Y$. Its image is contained in $\Gamma_\varphi$, so it defines a regular map
\begin{align*}
s:X\to \Gamma_\varphi.
\end{align*}
The restricted projection
\begin{align*}
\pi_X|_{\Gamma_\varphi}:\Gamma_\varphi\to X
\end{align*}
satisfies
\begin{align*}
(\pi_X|_{\Gamma_\varphi}\circ s)(x)=x
\end{align*}
for every $x\in X$, and
\begin{align*}
(s\circ \pi_X|_{\Gamma_\varphi})(x,\varphi(x))=(x,\varphi(x))
\end{align*}
for every $(x,\varphi(x))\in\Gamma_\varphi$. Thus $s$ is the inverse of $\pi_X|_{\Gamma_\varphi}$, and $\pi_X|_{\Gamma_\varphi}$ is an isomorphism of affine varieties.
[/step]
custom_env
admin
[step:Recover the original map from the inverse projection]Conversely, assume that $\Gamma_\varphi$ is a closed subvariety of $X\times Y$ and that
\begin{align*}
\pi_X|_{\Gamma_\varphi}:\Gamma_\varphi\to X
\end{align*}
is an isomorphism. Let
\begin{align*}
\psi:X\to\Gamma_\varphi
\end{align*}
denote its inverse isomorphism, and let
\begin{align*}
\pi_Y:X\times Y\to Y
\end{align*}
denote the second projection. Since projections of affine products are regular, the restricted map
\begin{align*}
\rho_Y:\Gamma_\varphi\to Y,\qquad \rho_Y(x,y):=y
\end{align*}
is regular. Therefore the composition
\begin{align*}
\rho_Y\circ\psi:X\to Y
\end{align*}
is regular.
For each $x\in X$, the point $\psi(x)$ is the unique point of $\Gamma_\varphi$ whose first coordinate is $x$. By the definition of the graph, that point is $(x,\varphi(x))$. Hence
\begin{align*}
(\rho_Y\circ\psi)(x)=\varphi(x)
\end{align*}
for every $x\in X$. Therefore $\varphi=\rho_Y\circ\psi$, so $\varphi$ is regular.[/step]
custom_env
admin
[guided]We now prove the converse with all maps named explicitly. The assumption says two things. First, $\Gamma_\varphi$ is not merely a set: it is a closed subvariety of $X\times Y$. Second, the first projection restricts to an isomorphism
\begin{align*}
\pi_X|_{\Gamma_\varphi}:\Gamma_\varphi\to X.
\end{align*}
Because this map is an isomorphism, it has a regular inverse. Denote that inverse by
\begin{align*}
\psi:X\to\Gamma_\varphi.
\end{align*}
The graph sits inside the product $X\times Y$, and the product has a second projection
\begin{align*}
\pi_Y:X\times Y\to Y.
\end{align*}
Restrict this projection to the closed subvariety $\Gamma_\varphi$ and call the restriction
\begin{align*}
\rho_Y:\Gamma_\varphi\to Y,\qquad \rho_Y(x,y):=y.
\end{align*}
This map is regular because it is the restriction of a coordinate projection from an affine product. Since $\psi$ is regular and regular maps are closed under composition, the map
\begin{align*}
\rho_Y\circ\psi:X\to Y
\end{align*}
is regular.
It remains to identify this regular map with the original set map $\varphi$. Fix $x\in X$. Since $\psi$ is inverse to $\pi_X|_{\Gamma_\varphi}$, the point $\psi(x)$ is the unique point of $\Gamma_\varphi$ whose first coordinate is $x$. But the definition of the graph gives exactly one such point, namely $(x,\varphi(x))$. Therefore
\begin{align*}
\psi(x)=(x,\varphi(x)).
\end{align*}
Applying $\rho_Y$ gives
\begin{align*}
(\rho_Y\circ\psi)(x)=\rho_Y(x,\varphi(x))=\varphi(x).
\end{align*}
Since this holds for every $x\in X$, we have $\varphi=\rho_Y\circ\psi$. The right-hand side is regular, so $\varphi$ is regular.[/guided]
custom_env
admin
[step:Combine the two implications]
The first two steps show that every regular map has a closed graph whose first projection is an isomorphism. The third step shows that any set map with this graph property is regular. Therefore $\varphi$ is regular if and only if $\Gamma_\varphi$ is a closed subvariety of $X\times Y$ and $\pi_X|_{\Gamma_\varphi}:\Gamma_\varphi\to X$ is an isomorphism.
[/step]