Pullback of localisations of commutative ring Let $R$ be a commutative ring with unity. Let $s,t\in R$ such that $Rs+Rt=R$ . Consider the maps $g: R_s \to R_{st}$ as $g(a/s^n)=a/s^n=at^n/(st)^n$ and $f: R_t \to R_{st}$ as $f(b/t^m)=b/t^m=bs^m/(st)^m$. Then how to show that the fiber product 
https://en.m.wikipedia.org/wiki/Pullback_(category_theory) along these maps is $R$ ? i.e. that $R_s \times_{R_{st}} R_t$ is canonically isomorphic to $R$ ? 
 A: If $\frac{a}{s^n} = \frac{b}{t^m}$ in $R_{st}$ (with $a,b\in R$), then there is $r \in \{(st)^k, k\in \mathbb N\}$ such that $rt^ma = rs^n b$ in $R$, so for some $k$, $s^kt^{m+k} a = s^{n+k}t^k b$ in $R$. 
But now $Rt^{m+k}+Rs^{n+k} = R$ (exercise: if $t,s$ are comaximal, so are $t^l, s^p$ for all $l,p$), therefore for some $u,v$, $t^{m+k}u + s^{n+k}v = 1$. 
It follows that $s^k(1-vs^{n+k})a = s^{n+k}t^kbu$, so that $s^k a = s^{n+k}t^kbu + vs^{n+2k}a$ in $R$. 
Dividing by $s^{n+k}$ in $R_s$, we get $\frac{a}{s^n}= \frac{t^kbu + vs^k}{1}$, so $\frac{a}{s^n}$ comes from $R$, similarly for $\frac{b}{t^m}$. 
Therefore $R\to R_s\times_{R_{st}}R_t$ is surjective. 
Moreover, if $\frac{a}{1} = 0$ in $R_s$ and in $R_t$, then for some $m,n$ we have $s^m a = 0, t^n a= 0$, so by comaximality again we get $a=0$, that is, $R\to R_s\times_{R_{st}}R_t$ is injective; therefore it is an isomorphism. 
(Note : I used the explicit description of the pullback, that is $A\times_C B = \{(a,b) \in A\times B \mid p(a) = q(b)\}$, for maps $p:A\to C, q:B\to C$)
Note that this is a special case (which contains all the information) of the proof of the sheaf property for the structural sheaf of $\operatorname{Spec}A$ in algebraic geometry.
