Preimage of diagonal subscheme is a closed subscheme Let $\alpha: X\to S$ and $\beta:Y\to S$ be $S$-schemes and let $\Delta\subseteq Y\times_S Y$ be the diagonal subscheme defined as follows (following Eisenbud-Harris): for each affine open subscheme $\text{Spec}(A)\subseteq Y\times_S Y$ with $\beta\vert_{\text{Spec}(A)} : \text{Spec}(A)\to \text{Spec}(B)\subseteq S$ we set $\mathcal{O}_\Delta (\text{Spec}(A)) = \text{Spec}(A\otimes_B A)/I$, where $I$ is the ideal generated by all elements of the form $a\otimes 1 - 1\otimes a\in A\otimes_B A$.
Suppose that $\Delta$ is a closed subscheme of $Y\times_S Y$ under the inclusion $i:\Delta \hookrightarrow Y\times_S Y$. Then it is closed as a topological space and the morphism on structure sheaves $i^\#: \mathcal{O}_Y \to i_* \mathcal{O}_\Delta$ is surjective ($=$ surjective on all the stalks).
Now suppose that $\phi, \psi: X\to Y$ are two $S$-morphisms commuting with the structural morphisms to the base (so $\alpha = \beta\circ\phi = \beta\circ\psi$). I want to show that the locus of $X$ on which $\phi$ and $\psi$ agree is a closed subscheme with the above assumption on $\Delta$. Using the UMP of the fibre product $Y\times_S Y$ it's easy to construct a canonical morphism $\sigma: X\to Y\times_S Y$ which composes under the two projections to $\phi$ resp. $\psi$. Then the locus on which $\phi$ and $\psi$ agree is $V:=\sigma^{-1} (\Delta)$. Clearly, as a topological space, this is a closed subspace of $X$. What I would like to show, however, is that it defines the structure of a closed subscheme on $X$. For this I need to show the morphism of sheaves $i^\# : \mathcal{O}_X \to j_* \mathcal{O}_V$ induced by the inclusion $j: V\hookrightarrow X$ is surjective.
Since $V$ is the preimage of $\Delta$ under $\sigma$ we have a Cartesian diagram of schemes

Assuming I've done everything right we then take stalks of the corresponding sheaf morphisms at $x\in V$ (considered as a point in $X$) to obtain the commutative diagram of local rings

Then put in the stalks of the inverse image sheaf to get the commutative diagram

Note that the bottom arrow is surjective. Now I want to show that the top arrow is surjective; by commutativity of the diagram it suffices to show that the left arrow
$${\sigma\vert_V}_x^\# : (i_* \mathcal{O}_\Delta)_{\sigma(x)} \to (j_* \mathcal{O}_V)_x$$
is surjective. My gut feeling is that it is actually an isomorphism (by some abstract argument about pullbacks) but I've got lost along the way with all the sheaves. Does anyone know how to prove this, tell me it's utter nonsense or suggest a simpler way of doing things? 
Note: apologies for the wildly varying diagram sizes. I can't figure out how to do them on MSE's LaTeX system so they're embedded images.
 A: Let $\varphi,\psi:X\to Y$ be morphisms of $S$-schemes; by definition the following diagrams commute:
\begin{equation}
\require{AMScd}
\begin{CD}
X @>\varphi>> Y\\
@V\psi VV & @VV\upsilon V\\
Y @>>\upsilon> S\\
Y\times_SY @>pr_1>> Y\\
@Vpr_2VV & @VV\upsilon V\\
Y @>>\upsilon> S
\end{CD};
\end{equation}
by universal property of $Y\times_SY$, there exists a unique $S$-morphism of schemes $(\varphi,\psi):X\to Y\times_SY$ such that:
\begin{equation}
pr_1\circ(\varphi,\psi)=\varphi,\,pr_2\circ(\varphi,\psi)=\psi.
\end{equation}
Let $\Delta_{Y/S}=\Delta$ be the diagonal $S$-morphism of $Y$; considering the diagram:
\begin{equation}
\require{AMScd}
\begin{CD}
Z @>j>> Y\\
@V i VV & @VV\Delta V\\
X @>>(\varphi,\psi)> Y\times_SY
\end{CD}
\end{equation}
where $Z$ is the fibre product of the previous diagram.
By construction, $(Z,i)$ is a locally closed subscheme of $X$, because $\Delta$ is a locally closed morphism of $S$-schemes; if $\Delta$ is a closed morphism of $S$-schemes, that is $Y$ is a separated $S$-scheme, then $(Z,i)$ is a closed subscheme of $X$.
Indeed, let $\{Y_i\}_{i\in I}$ be an affine open covering of $Y$, let $\{S_j\}_{j\in J}$  be an open affine covering of $S$; by construction $\left\{Y_{i_1}\times_{S_j}Y_{i_2}\mid Y_{i_1},Y_{i_2}\subseteq\upsilon^{-1}(S_j)\right\}_{i_1,i_2\in I,j\in J}$ is an affine open covering of $Y\times_SY$. One can consider the morphism of $S_j$-schemes $\Delta_{ij}:Y_i\to Y_i\times_{S_j}Y_i$, where $\upsilon^{-1}(S_j)\supseteq Y_i$; because these scheme are affine over affine schemes, then $\Delta_{ij}$ are closed morphisms between affine schemes.
Let $\left\{X_{ijk}\subseteq(\varphi,\psi)^{-1}\left(Y_i\times_{S_j}Y_i\right)\right\}_{i\in I,j\in J,k\in K}$ be an affine open covering of $X$; passing to the ring homomorphisms:
\begin{gather}
m_{ij}=\left(\Delta_{ij}\right)^{*}:a\otimes b\in B\otimes_RB=\mathcal{O}_{Y_i}(Y_i)\otimes_{\mathcal{O}_{S_j}(S_j)}\mathcal{O}_{Y_i}(Y_i)\to ab\in B=\mathcal{O}_{Y_i}(Y_i),\\
n_{ijk}=\left((\varphi,\psi)_{|X_{ijk}}\right)^{*}:a\otimes b\in B\otimes_RB\to\left(\varphi_{|X_{ijk}}\right)^{*}(a)\left(\psi_{|X_{ijk}}\right)^{*}(b)\in A=\mathcal{O}_{X_{ijk}}(X_{ijk});
\end{gather}
let $\left\{Z_{ijk}\subseteq i^{-1}(X_{ijk})\cap j^{-1}(Y_i)\right\}_{i\in I,j\in J,k\in K}$ be an open affine covering of $Z$, passing to ring homomorphisms: because $p_{ijk}=\left(i_{|Z_{ijk}}\right)^{*}$ is given by the base change of $m_{ij}$ via $n_{ijk}$, then it is a surjective homomorphism.
The previous property of the $p_{ijk}$'s pass to the localization at any point of $z$, that is for any $z\in Z,\,i^{*}_z$ is a surjective homomorphism; because $\Delta$ induces a homeomorphism between $Y$ and a closed subscheme of $Y\times_SY$, then $i$ holds the same property, and $i$ is a closed immersion of $Z$ in $X$.
For example, one can consult Bosch - Algebraic Geometry and Commutative Algebra, proposition 7.3.14.
