TITLE: Question about proof of Hartshorne book Lemma III.2.4
QUESTION [5 upvotes]: Let $(X,\mathcal{O}_X)$ be a ringed space. For any open subet $U \subseteq X$, Let $\mathcal{O}_U$ denote the sheaf $j_!(\mathcal{O}_X|_U)$ which is the restriction of $\mathcal{O}_X$ to $U$, extended by zero outside $U$.
Let $\mathcal{I}$ be an injective $\mathcal{O}_X$-module.
Then, why ${\rm Hom}_\mathcal{O_X}(\mathcal{O}_U, \mathcal{I})=\mathcal{I}(U)$??

REPLY [3 votes]: If $H$ is a presheaf and $G$  a sheaf on a toplogical space $X$, we have the characteristic relation for the sheafification $H^s$ of $F$:  $$\text {Hom}(H,G)=\text {Hom}(H^s,G)$$
Applying this to the presheaf $H=j_? \mathcal F$ whose sheafification is $H^s=j_!F$ (cf. Hartshorne exercise 1.19 (b): we have $(j_?\mathcal F)(V)=\mathcal F(V)$ if $V\subseteq U$ and $H=(j_?\mathcal F)(V)=0$ else), we are reduced to proving $$\text {Hom}_X(j_?(\mathcal O_X\mid U),\mathcal I)=\mathcal I(U)$$
which is easy, and has nothing to do with the injectivity of $\mathcal I$ !
[To spell it out : given a section $s\in \mathcal I(U)$, you get for any $V\subseteq U$ the morphism $\mathcal O_X(V)\to \mathcal I(V):\phi\mapsto \phi\cdot s\mid V$ and this yields an isomorphism $\mathcal I(U)\stackrel {\cong}{\to}   \text {Hom}_X (j_?(\mathcal O_X\mid U),\mathcal I)  $]