Let $X$ and $Y$ be schemes and $x$ a point on $X$. Let $f:X\rightarrow Y$ be a morphism. Recall this induces a map $f_x:\mathcal O_{Y,f(x)}\rightarrow \mathcal O_{X,x}$ on the level of sheaves.
Consider the projection $g:X\times_Y \operatorname{Spec}\mathcal O_{Y,y}\rightarrow\operatorname{Spec} \mathcal O_{Y,y}$. Let $x'$ be the inverse of $x$ under $X\times_Y \operatorname{Spec}\mathcal O_{Y,y}\rightarrow X$. Why do we have $f_x=g_{x'}$?
This is stated without justification in Liu's book, but I'm having trouble seeing why it is true. I think we can reduce to the case where $X$ and $Y$ are affine. The associated ring map seems to be, if $Y=\operatorname{Spec} A$ and $X=\operatorname{Spec} B$,
$$ A_{\mathfrak p} \rightarrow A_{\mathfrak p} \otimes_A B \cong (A\backslash \mathfrak p)^{-1}B,$$
where we consider $B$ as an $A$-module via the map $\phi: A\rightarrow B$ associated to the map of global sections induced by $f$. I know that the stalk map $X\rightarrow Y$ corresponds to
$$A_{\mathfrak p} \rightarrow B_{\phi^{-1}(\mathfrak p)}.$$
So the question now seem to reduce to verifying that $B\backslash \phi^{-1} (\mathfrak p)$ is $\phi^{-1}(A\backslash \mathfrak p)$. And they equal.
But the first map I gave is a map of rings, while the second is a map of stalks. So why do they seem to be the same? I also don't know what $x'$ is in the tensor product or how to make sure it gets sent to the right thing in $\operatorname{Spec} \mathcal O_{Y,y}$. I would greatly appreciate any clarification.
(My apologies for yet another elementary question about fiber products. I'm having an absolutely dreadful time learning about them.)
Addendum. The proof of the following theorem begins, "By the base change $\operatorname{Spec} \mathcal O_{Y,y}\rightarrow Y$, which preserves the local rings in the inequality, we may reduce to $Y=\operatorname{Spec} A$, where $A$ is a Noetherian local ring and $y$ is the closed point of $Y$." I suspect this has something to do with my question above. I would appreciate any explanation, especially of the "preserves the local rings" part.
Let $f:X\rightarrow Y$ be a morphism of locally Noetherian schemes. Let $x\in X$ and $y=f(x)$. Then
$$\dim \mathcal O_{X_y,x} \ge \dim \mathcal O_{X,x} - \dim \mathcal > O_{Y,y}.$$
If $f$ is flat, then we have equality.
Your stalk map for the original $X = Spec B \to Y = Spec A$ is correct, so let's work out the other map.
The $g$ map is $Spec B_p = Spec (A \backslash p)^{-1} B \to Spec A_p$ like you mentioned. If $q = \phi^{-1}(p)$ is your $x$, then your $x'$ corresponds to the ideal $qB_p$ in $B_p$. The stalk map for $g$ then corresponds to $A_p \to (B_p)_{qB_p}$. This is the same as $A_p \to B_q$ map, by going through the isomorphism $B_q \cong (B_p)_{qB_p}$. That this is an isomorphism is Atiyah Macdonald Exercise 3.4. (Write down what you think the isomorphism should be, and check it :) )