Question about the proof that $(D(f),\mathcal{O}_{\operatorname{Spec}A}|_{D(f)})\cong (\operatorname{Spec}A_f,\mathcal{O}_{\operatorname{Spec}A_f})$ I am trying to prove/understand why $(D(f),\mathcal{O}_{\operatorname{Spec}A}|_{D(f)})\cong (\operatorname{Spec}A_f,\mathcal{O}_{\operatorname{Spec}A_f})$. This problem appears in Vakil's algebraic geometry notes as problem 4.3.B.
I know that since $D(f)=\{P\in\operatorname{Spec}A\mid f\not\in P\}$, we can identify $D(f)$ and $\operatorname{Spec}A_f$. So let $\pi:D(f)\rightarrow \operatorname{Spec}A$ be the natural map.
I'd now like to show that $\mathcal{O}_{\operatorname{Spec}A_f}\rightarrow \pi^*\mathcal{O}_{\operatorname{Spec}A}|_{D(f)}$ is an isomorphism of sheaves. The hint given is to notice that distinguished open sets of $\operatorname{Spec}A_f$ are already distinguished open sets in $\operatorname{Spec}A$.
If we consider $D(g/f^n)=\{P\in\operatorname{Spec}A_f\mid g/f^n\not\in P\}$, then how can we think of this as a distinguished open set in $\operatorname{Spec}A$? It doesn't make sense to ask if $g/f^n$ is not in a prime ideal of $A$. Is really saying that the corresponding prime ideal of $A$ doesn't contain $g$?
Further, I know that $\mathcal{O}_{\operatorname{Spec}A_f}(D(g/1))$ is the localization of $A_f$  is the localization of $A_f$ at all elements that do not vanish outside of $V(g/1)$. That is, the localization of $A_f$ at $\{a/f^n\in A_f\mid D(g/1)\subset D(g/f^n)\}$.
And how do we describe $\mathcal{O}_{\operatorname{Spec}A}|_{D(f)}(D(g))$?
How can I go about finish this problem/seeing the isomorphism?
 A: There's a lot of confusion in your post: as is, your proposed morphism of sheaves does not make any sense. The map you consider should not be the embedding $\pi \colon D(f) \to \mathrm{Spec}(A)$, but rather the embedding $\mathrm{Spec}(\alpha) \colon \mathrm{Spec}(A_{f}) \to \mathrm{Spec}(A)$ induced by the canonical localization map $\alpha \colon A \to A_{f}$. As you note, $\pi := \mathrm{Spec}(\alpha)$ is an open embedding whose image is $D(f)$, so we may view it as an isomorphism of topological spaces $\mathrm{Spec}(A_{f}) \to D(f)$.
Moving to sheaves, let me recall what the sheaf $\mathcal{O}_{\mathrm{Spec}(A)}|_{D(f)}$ is. For any open set $U \subset D(f)$, $U$ is likewise an open set of $\mathrm{Spec}(A)$, and by definition we have $\mathcal{O}_{\mathrm{Spec}(A)}|_{D(f)}(U) = \mathcal{O}_{\mathrm{Spec}(A)}(U)$. The key, then, is understanding which distinguished opens of $\mathrm{Spec}(A)$ are contained in $D(f)$ - more on this shortly. Moreover, the map $\pi$ comes with an associated morphism of sheaves $\mathcal{O}_{\mathrm{Spec}(A)} \to \pi_{\ast}\mathcal{O}_{\mathrm{Spec}(A_{f})}$, which on global sections is $\alpha$ and on distiniguished opens is the (induced) localization map. The corresponding morphism of sheaves $\mathcal{O}_{\mathrm{Spec}(A)}|_{D(f)} \to \pi_{\ast}\mathcal{O}_{\mathrm{Spec}(A_{f})}$ is induced by $\mathcal{O}_{\mathrm{Spec}(A)} \to \pi_{\ast}\mathcal{O}_{\mathrm{Spec}(A_{f})}$ in the obvious way; on global sections, it is the identity map $A_{f} \to A_{f}$, since $\mathcal{O}_{\mathrm{Spec}(A)}|_{D(f)}(D(f)) = \mathcal{O}_{\mathrm{Spec}(A)}(D(f)) = A_{f}$, and $\pi^{-1}(D(f)) = \mathrm{Spec}(A_{f})$.
All that remains is to understand why $\mathcal{O}_{\mathrm{Spec}(A)}|_{D(f)} \to \pi_{\ast}\mathcal{O}_{\mathrm{Spec}(A_{f})}$ is an isomorphism of sheaves on $D(f)$. It suffices to check this on a basis for the topology on $D(f)$, which is given by the distinguished opens of $\mathrm{Spec}(A)$ contained in $D(f)$. With the above details settled, here is a guide to the approach, which I leave to you.
(1) First, show that we have a containment of distinguished opens $D(g) \subset D(f)$ if and only if $f$ is a unit of $A_{g}$. (This is exercise 3.5F of Vakil - very much worth doing, if you haven't done so yet.)
(2) Next, show that $\pi^{-1}(D(g)) = D(\alpha(g)) = D(g/1)$ for any $g \in A$. (There is nothing special about $\pi$ here, to be clear: for any morphism of rings $u \colon A \to B$ and any $g \in A$, one has $\mathrm{Spec}(u)^{-1}(D(g)) = D(u(g))$.)
(3) Finally, we put things together. Let $D(g)$ be a distinguished open of $\mathrm{Spec}(A)$ which is contained in $D(f)$, which by (1) ensures that $f$ is a unit in $A_{g}$. We have
$$\pi_{\ast}\mathcal{O}_{\mathrm{Spec}(A_{f})}(D(g)) = \mathcal{O}_{\mathrm{Spec}(A_{f})}(D(\pi(g))) = (A_{f})_{g/1}$$
and
$$\mathcal{O}_{\mathrm{Spec}(A)}|_{D(f)}(D(g)) = \mathcal{O}_{\mathrm{Spec}(A)}(D(g)) = A_{g}$$.
The map $A_{g} \to (A_{f})_{g/1}$ is the universal map induced by $\alpha \colon A \to A_{f}$. Your task is to show that this map $A_{g} \to (A_{f})_{g/1}$ is an isomorphism, which I leave to you. (I would use the universal property of localization to get a map $(A_{f})_{g/1} \to A_{g}$. You will use that $f$ is invertible in $A_{g}$ to get a map $A_{f} \to A_{g}$ first.)
