Why is the inverse image sheaf a sheaf of rings Given an inclusion of topological spaces $i:X \hookrightarrow Y$ where $(Y,\mathcal{O}_Y)$ is a ringed topological space, I'm trying to understand why $(X,i^{-1}\mathcal{O}_Y)$ is a ringed topological space.
Now I see why $(i^{-1}\mathcal{O}_Y)_x$ for any $x \in X$must be a local ring, given that stalks of the inverse image sheaf are the same as stalks on the sheaf $\mathcal{O}_Y$. But while trying to write the entire proof out I realized I didn't quite understand what the ring structure on the inverse image sheaf looks like (for this inclusion case and in general).
By definition, the inverse image sheaf is the sheaf associated to the presheaf $U \mapsto$ lim $_{W \supset i(U)}\mathcal{O}_Y(W)$, which going by Hartsehorne's construction of the sheafification (page 64, Prop-Def 1.2), is the set of functions
$\{f:U \rightarrow \bigcup_{p \in U} ($lim $_{W \supset U}\mathcal{O}_Y(W))_p\}$
But I don't see explicitly what the ring structure on this looks like. Any help would be appreciated
 A: What is an element of $(\lim_{W\supseteq i(U)}\mathcal{O}_Y(W))_p$?  Well, it is an element of $\lim_{W\supseteq i(U)}\mathcal{O}_Y(W)$ for some neighborhood $U$ of $p$ (modulo the equivalence relation given by restriction to smaller neighborhoods).  And what is such an element?  It is just an element of $\mathcal{O}_Y(W)$ for some $W$ that contains $i(U)$ (again, modulo an equivalence relation that lets us restrict to smaller neighborhoods).  Now suppose you have a second such element, which is an element of $\mathcal{O}_Y(W')$ for some $W'$ that contains $i(U')$ for some other neighborhood $U'$ of $p$.  How do you add or multiply these two elements?  Well, you just restrict them both to $\mathcal{O}_Y(W\cap W')$, which contains $i(U\cap U')$, and then add or multiply them using the ring structure of $\mathcal{O}_Y(W\cap W')$.
In more abstract terms, all we're doing in this construction is taking certain directed colimits of rings of the form $\mathcal{O}_Y(W)$.  The forgetful functor from rings to sets preserves directed colimits, so we could have just taken all our colimits in the category of rings, rather than in the category of sets.  This would make it so everything is obviously a ring, and we'd still have the same underlying sets.
