Diagonal morphism (algebraic geometry)

In algebraic geometry, given a morphism of schemes formula_1, the diagonal morphism
is a morphism determined by the universal property of the fiber product formula_3 of "p" and "p" applied to the identity formula_4 and the identity formula_5.
It is a special case of a graph morphism: given a morphism formula_6 over "S", the graph morphism of it is formula_7 induced by formula_8 and the identity formula_5. The diagonal embedding is the graph morphism of formula_5.
By definition, "X" is a separated scheme over "S" (formula_1 is a separated morphism) if the diagonal morphism is a closed immersion. Also, a morphism formula_1 locally of finite presentation is an unramified morphism if and only if the diagonal embedding is an open immersion.
Explanation.
As an example, consider an algebraic variety over an algebraically closed field "k" and formula_13 the structure map. Then, identifying "X" with the set of its "k"-rational points, formula_14 and formula_15 is given as formula_16; whence the name diagonal morphism.
Separated morphism.
A separated morphism is a morphism formula_17 such that the fiber product of formula_17 with itself along formula_17 has its diagonal as a closed subscheme — in other words, the diagonal morphism is a "closed immersion".
As a consequence, a scheme formula_20 is separated when the diagonal of formula_20 within the "scheme product" of formula_20 with itself is a closed immersion. Emphasizing the relative point of view, one might equivalently define a scheme to be separated if the unique morphism formula_23 is separated.
Notice that a topological space "Y" is Hausdorff iff the diagonal embedding 
is closed. In algebraic geometry, the above formulation is used because a scheme which is a Hausdorff space is necessarily empty or zero-dimensional. The difference between the topological and algebro-geometric context comes from the topological structure of the fiber product (in the category of schemes) formula_25, which is different from the product of topological spaces.
Any "affine" scheme "Spec A" is separated, because the diagonal corresponds to the surjective map of rings (hence is a closed immersion of schemes):
Let formula_27 be a scheme obtained by identifying two affine lines through the identity map except at the origins (see gluing scheme#Examples). It is not separated. Indeed, the image of the diagonal morphism formula_28 image has two origins, while its closure contains four origins.
Use in intersection theory.
A classic way to define the intersection product of algebraic cycles formula_29 on a smooth variety "X" is by intersecting (restricting) their cartesian product with (to) the diagonal: precisely,
where formula_31 is the pullback along the diagonal embedding formula_32.