Solution (source code)

= Solution

The image $f/1$ is a <unit> in the <localization at a prime ideal> $R_{\mathfrak p}$, because $f\notin\mathfrak p$. The <universal property of localization>, applied to the <ring homomorphism> $R\to R_{\mathfrak p}$ and the <multiplicative subset> $\{1,f,f^2,\ldots\}$, gives a unique <ring homomorphism> fixing the image of $R$:
$$
\boxed{\theta_f:R_f\longrightarrow R_{\mathfrak p},\qquad \theta_f(a/f^n)=a/f^n.}
$$
Fixing the image of $R$ is exactly the required compatibility with the <algebra over a ring> structures. Uniqueness also follows directly: such a <ring homomorphism> must send $1/f$ to the inverse of $f/1$, and these elements together with $R$ generate $R_f$.