If $f : X \to Z$ is a morphism of schemes, which factors through an open $i : U \to Z$ on the level of topological spaces... then is there a (unique) morphism of schemes $g : X \to U$ which makes the diagram commute.
I believe I just proved this (it is a tautology, just define the map to be the restriction of $f^{\#}$ on the relevant opens), but I want to make sure that I am not fooling myself (this stuff feels so complicated...).
Can someone comment?
Let $g \colon X \to U$ denote the topological map.
Proof. Let $V \subseteq U$ be open. Then $f^{-1}(V) = g^{-1}(V)$, so $$(f_* \mathcal O_X|_U)(V) = f_* \mathcal O_X (V) = \mathcal O_X (f^{-1} V) = \mathcal O_X(g^{-1}V) = (g_* \mathcal O_X)(V).$$
Proof. The identification of Lemma 1 is an isomorphism of sheaves of rings.
Proof. One is the colimit over all opens $V \subseteq Z$ containing $z$, and the other over all $V \subseteq U$ containing $z$. The latter forms a cofinal system in the former, thus the colimits agree.
Proof. Lemma 1 and Lemma 2 show that it is a morphism of ringed spaces. Let $x \in X$. By assumption, the map $f^\#_x \colon \mathcal O_{Z, f(x)} \to \mathcal O_{X,x}$ is a local ring homormophism, hence by Lemma 3 so is $g^\#_x \colon \mathcal O_{U,f(x)} \to \mathcal O_{X,x}$.
Remark. One then needs to go on to prove that $f$ factors through $g$, and that such a factorisation is unique. I will not carry out these steps.