Question: Let $Y$ be a separated scheme over a scheme $S$. Then for any couple of parallel $S$ morphisms $f,g : X\to Y$, the set $Z=[x\in X: f(x)=g(x)]$ is closed in $X$.
Attempt : Consider the fibered product $Y×_S Y$ with $p_1$ and $p_2$ projections , using morphisms $f$ and $g$, there exists a unique morphism of schemes $h:X\to Y×_S Y$ such that $p_1\circ h = f$ and $p_2\circ h = g$. Let $\Delta : Y\to Y×_S Y$ denote the diagonal morphism, I am trying to show that $Z=h^{-1}(\Delta(Y))$. I have shown that $h^{-1}(\Delta(Y))$ is a subset of $Z$ but I am not able to show the other containment.
Thanks in advance.
Since we can take $X=Y\times_S Y$, $f=\pi_1$ and $g=\pi_2$, which by definition means that $h=Id_Y$, your question becomes: "I proved that $\Delta(Y)\subset Y\times_S Y$ is included in $\{x\in Y\times_S Y\,|\, \pi_1(x)=\pi_2(x)\}$, but are they equal?".
This question has been addressed several times on the site. I feel like When is diagonal morphism the diagonal map gives the clearest answer.
To paraphrase the beginning of the answer: you can take $S=\operatorname{Spec}(\mathbb{R})$ and $Y=\operatorname{Spec}(\mathbb{C})$. Then since $S$ is topologically a point, all points $x\in Y\times_S Y$ satisfy $\pi_1(x)=\pi_2(x)$, and $Y\times_S Y$ has two points since $\mathbb{C}\otimes_\mathbb{R} \mathbb{C}\simeq \mathbb{C}\times \mathbb{C}$. On the other hand, $\Delta(Y)$ clearly has only one point since $Y$ itself has only one point. So the inclusion is strict.