Lemma 20.7.1. Let $X$ be a ringed space. Let $U \subset X$ be an open subspace.

1. If $\mathcal{I}$ is an injective $\mathcal{O}_ X$-module then $\mathcal{I}|_ U$ is an injective $\mathcal{O}_ U$-module.

2. For any sheaf of $\mathcal{O}_ X$-modules $\mathcal{F}$ we have $H^ p(U, \mathcal{F}) = H^ p(U, \mathcal{F}|_ U)$.

Proof. Denote $j : U \to X$ the open immersion. Recall that the functor $j^{-1}$ of restriction to $U$ is a right adjoint to the functor $j_!$ of extension by $0$, see Sheaves, Lemma 6.31.8. Moreover, $j_!$ is exact. Hence (1) follows from Homology, Lemma 12.29.1.

By definition $H^ p(U, \mathcal{F}) = H^ p(\Gamma (U, \mathcal{I}^\bullet ))$ where $\mathcal{F} \to \mathcal{I}^\bullet$ is an injective resolution in $\textit{Mod}(\mathcal{O}_ X)$. By the above we see that $\mathcal{F}|_ U \to \mathcal{I}^\bullet |_ U$ is an injective resolution in $\textit{Mod}(\mathcal{O}_ U)$. Hence $H^ p(U, \mathcal{F}|_ U)$ is equal to $H^ p(\Gamma (U, \mathcal{I}^\bullet |_ U))$. Of course $\Gamma (U, \mathcal{F}) = \Gamma (U, \mathcal{F}|_ U)$ for any sheaf $\mathcal{F}$ on $X$. Hence the equality in (2). $\square$

In your comment you can use Markdown and LaTeX style mathematics (enclose it like $\pi$). A preview option is available if you wish to see how it works out (just click on the eye in the toolbar).