Solution (source code)

= Solution

The <coincidence locus of two scheme morphisms> is the fibre product
$$
E=X\times_{(f,g),\,Y\times_kY,\,\Delta_Y}Y.
$$
The <diagonal morphism> $\Delta_Y$ is a <locally closed immersion>, and this property is stable under <base change of a morphism of schemes>, so $E\hookrightarrow X$ is locally closed. The <universal property of a fibre product> says that a morphism $T\to X$ factors through $E$ exactly when $f|_T=g|_T$. Thus $E$ is the largest locally closed subscheme on which they coincide. If $Y$ is <separated scheme>[separated], $\Delta_Y$ is a <closed immersion>, and its base change $E\hookrightarrow X$ is closed.