How to understand Lemma 4.4 in Hartshorne, Chapter 2? I have essentially the same question as in some question of Hartshorne book Lemma (II.4.4).
However, even with the answer in that question, I am still confused what does ''local homomorphism of $O_{x_0,Z}$ to $R$ is compatible with the inclusion $k(x_1) \subset K$'' mean, and why?
In particular, I noticed there were people asking why this local homomorphism is injective in the comment, therefore I wonder if anyone can explain this more clearly.
 A: Step 1: If $A\to B$ is a morphism of schemes with $a\mapsto b$, then we have an induced local map on local rings $\mathcal{O}_{B,b}\to\mathcal{O}_{A,a}$. This should be familiar from the definition of a morphism of locally ringed spaces: if you need some jogging of your memory, it may be helpful to recall the affine case and use the universal property of localization.
Step 2: If $A$ is a scheme with $a_1,a_0$ points so that $a_1$ is a generalization of $a_0$, there is a natural map $\mathcal{O}_{A,a_0}\to \mathcal{O}_{A,a_1}$, and it's a localization. You can see this either by calculating on an open affine neighborhood of $a_0$, where it correpsonds to the fact that $R_\mathfrak{q}$ maps to $R_\mathfrak{p}$ by localizing for $\mathfrak{p}\subset\mathfrak{q}$ prime ideals, or from the definition of the stalks as inverse limits over open neighborhoods: any open neighborhood of $a_0$ contains $a_1$ and thus there's a natural map induced on the limits.
Step 3: If $A\to B$ is any map of schemes with $a_0\mapsto b_0$, $a_1\mapsto b_1$, and $b_0\in \overline{\{b_1\}}$, then we also have that $a_0\in\overline{\{a_1\}}$ and the following diagram commutes:
$$\require{AMScd}
\begin{CD}
\mathcal{O}_{B,b_0} @>{}>> \mathcal{O}_{A,a_0}\\
@V{}VV @VV{}V \\
\mathcal{O}_{B,b_1} @>{}>> \mathcal{O}_{A,a_1}
\end{CD}$$
This is a combination of steps 1 and 2. If you want to see it in a more hands-on way, you can let $A$ and $B$ be affine (by selecting an open affine neighborhood of $b_0$ [this contains $b_1$ since open subsets are stable under generalization] and then an open affine neighborhood of $a_0$   [also containing $a_1$ for the same reason] contained in it's preimage) and use the universal property of localization a couple times.

Now to apply the above to our situation. In our case, $A=\operatorname{Spec} R$, $a_0$ is the maximal ideal $\mathfrak{m}\subset R$, $a_1=(0)\subset R$, $B=X$, and $b_0=x_0$, $b_1=x_1$. Rewriting our commutative  diagram, we have
$$\require{AMScd}
\begin{CD}
\mathcal{O}_{X,x_0} @>{}>> R\\
@V{}VV @VV{}V \\
\mathcal{O}_{X,x_1} @>{}>> K
\end{CD}$$
where the horizontal maps are local maps of local rings. Now we use a couple of universal properties: first, letting $I=\ker \mathcal{O}_{X,x_0}\to R$, the map $\mathcal{O}_{X,x_0}\to R$ factors through $\mathcal{O}_{X,x_0}/I$. As $I$ is the kernel of a morphism to a domain, it's prime, and so the map $\mathcal{O}_{X,x_1}\to K$ factors through $\mathcal{O}_{X,x_1}/I_I$. We may further note that $I_I$ is the maximal ideal of $\mathcal{O}_{X,x_1}$ as our map is a local map of local rings where the target is a field. This corresponds to restricting to $Z$ with the reduced induced structure, since $I$ is prime. Replacing $\mathcal{O}_{X,x_0}/I$ and $\mathcal{O}_{X,x_1}/I$ with $\mathcal{O}_{Z,x_0}$ and $\mathcal{O}_{Z,x_1}=k(x_1)$ we have the following commutative diagram, where the horizontal arrows are still local ring maps:
$$\require{AMScd}
\begin{CD}
\mathcal{O}_{Z,x_0} @>{}>> R\\
@V{}VV @VV{}V \\
k(x_1) @>{}>> K
\end{CD}$$
This commutative diagram is what Hartshorne means by a local homomorphism of $\mathcal{O}_{Z,x_0} \to R$ compatible with the inclusion $k(x_1)\to K$.
