The Image of Diagonal Morphism $\Delta(X)$ I'm trying to understand the fact from Algebraic Geometry which is just assumed to be true everywhere I see it. The fact is that:
Let $X$ be a scheme and $X \to S$ a morphism. Denote by $\Delta_{X/S} : X \to X \times_S X$
the diagonal morphism. Let $Z = \{y \in X \times_S X : p_1(y) \equiv p_2(y)\}$. Where $p_1,p_2: X \times_S X\to X$ projections and 
if  we have $f, g : K \to X$ be morphisms of schemes, let $x \in K$, and let $i_x : \operatorname{Spec} (\kappa(x)) \to K$
denote the associated canonical morphism. Then we say $f(x) \equiv g(x)$ if $f \circ i_x = g \circ i_x$. Equivalently: $f(x) = g(x)$ and the maps on residue fields $\kappa(f(x)) \to \kappa(x)$ induced by $f^{\#}_x$, $g^{\#}_x$
are equal.
Show that $Z = \Delta_{X/S}(X)$
I spent a lot of time trying to understand it myself, but I think I'm missing important in my understanding of Schemes. I will appreciate any help!
 A: As noted in the comments, $ \Delta(X) \subset Z $ is obvious. 
It is enough to prove the other direction in the case that $ S = \operatorname{Spec} B $ and $ X = \operatorname{Spec} A $ are affine. Then $ X \times_S X = \operatorname{Spec}(A \otimes_B A) $ and let $ y \in Z $ correspond to the prime ideal $ P $ of $ A \otimes_B A $. Let $ i_1, i_2 : A \rightarrow A \otimes_B A $ be the maps $ i_1(a) = a \otimes 1 $, $ i_2(a) = 1 \otimes a $ and $ m : A \otimes_B A \rightarrow A $ the multiplication. Then the condition on $ y $ translates to: $ i_1^{-1}(P) = i_2^{-1}(P) = Q $ for a prime $ Q $ of $ A $ and the induced maps $ i_1^{\#}, i_2^{\#} : k(Q) \rightarrow k(P) $ are equal. In particular, evaluating at $ a \in A $, this implies that $ a \otimes 1 - 1 \otimes a \in P $ for all $ a \in A $.
Of course, the candidate element $ x \in X = \operatorname{Spec} A $ is the prime $ Q $ and the goal is to show that $ m^{-1}(Q) = P $. The following computation makes this clear: $$ a \otimes a' \pmod P = (a \otimes 1 - 1 \otimes a)(1 \otimes a') + 1 \otimes aa' \pmod P = 1 \otimes aa' \mod P $$ So if $ \gamma = \sum a \otimes a' $, then $ \gamma \pmod P = \beta \pmod P $ where $ \beta = \sum 1 \otimes aa' = 1 \otimes \sum aa' = 1 \otimes m(\gamma) $. Therefore $ \gamma \in P $ iff $ \beta \in P $ and from the fact that $ i_2^{-1}(P) =  Q $, $ \beta \in P $ iff $ m(\gamma) \in Q $. This proves the assertion $ m^{-1}(Q) = P $ and hence $ y $ is the image of $ x = Q $ under $ \Delta $.
In the general case, as noted by KReiser in the comments, let $ W $ and $ U $ be open neighborhoods of $ x $ and $ s $ respectively. Then $ W \times_U W $ is an open neighborhood of $ y $ in the fiber product (This is because the maps $ \operatorname{Spec} k(y) \rightarrow X \times_S X \xrightarrow{p_i} W $ induce a map $ \operatorname{Spec} k(y) \rightarrow W \times_U W $).
