# If $Z:=\bigcap_{x\in U}U$, prove that $(Z,\mathcal{O}_X\big|_Z)\simeq (\text{Spec}(\mathcal{O}_{X,x}),\mathcal{O}_{\text{Spec}(\mathcal{O}_{X,x})})$

Let $$(X,\mathcal{O}_X)$$ be a scheme. For a fixed $$x\in X$$, let $$Z:=\bigcap_{U\ni x}U$$, where each $$U$$ is open in $$X$$. Prove that the scheme $$(Z,\mathcal{O}_X\big|_Z)$$ is isomorphic to $$(\text{Spec}(\mathcal{O}_{X,x}),\mathcal{O}_{\text{Spec}(\mathcal{O}_{X,x})})$$.

Here's where I'm at:

Because of the local nature of the problem, we may assume $$X$$ to be affine, say $$X=\text{Spec}(A)$$. Since the principal open sets are a basis of the topology, we may say $$Z=\bigcap_{x\in X_f}X_f$$, so $$\mathfrak{p}\in Z\Leftrightarrow f\notin\mathfrak{p}$$ for all $$f\notin x\Leftrightarrow \mathfrak{p}\subset x$$ and $$Z=\{\mathfrak{p}\in X \mid \mathfrak{p}\subset x\}$$. Then it's natural to define \begin{align*} \varphi:\text{Spec}(\mathcal{O}_{X,x})&\to Z\\ \mathfrak{p}\cdot \mathcal{O}_{X,x}&\mapsto \mathfrak{p} \end{align*}

which is easily seen to be a homeomorphism.

My difficulty is how to define the morphism of sheaves $$\varphi^\#:\mathcal{O}_X\big|_Z\to \varphi_*\mathcal{O}_Y$$, where $$Y:=\text{Spec}(\mathcal{O}_{X,x})$$. Since $$\mathcal{O}_X\big|_Z$$ is the sheafification of the pre-sheaf $$\mathcal{F}$$ on $$Z$$ given by $$U\subset Z\mapsto \varinjlim_{V\supset U}\mathcal{O}_X(V)$$, then I should define a morphism $$\psi:\mathcal{F}\to \varphi_*\mathcal{O}_Y$$ in order to obtain a morphism $$\mathcal{O}_X\big|_Z\to \varphi_*\mathcal{O}_Y$$ by the universal property.

How am I supposed to define $$\psi$$?

Now let us explain. Recall how we get a map out of a directed limit: if we have a limit $$A=\lim_{\rightarrow} A_i$$, then in order to get a map $$A\to B$$, we can specify a compatible system of maps $$A_i\to B$$ as $$i$$ ranges over our index category.
By the fact that $$i:\operatorname{Spec} \mathcal{O}_{X,x}\to X$$ is a morphism of schemes, we get a morphism of sheaves $$\mathcal{O}_X \to i_*\mathcal{O}_{\operatorname{Spec} \mathcal{O}_{X,x}}$$, or equivalently for every open subset $$W\subset X$$, we get a map $$\mathcal{O}_X(W)\to (i_*\mathcal{O}_{\operatorname{Spec} \mathcal{O}_{X,x}})(W)=\mathcal{O}_{\operatorname{Spec} \mathcal{O}_{X,x}}(W\cap \operatorname{Spec}\mathcal{O}_{X,x})$$ which is compatible with restrictions from $$W$$ to any smaller open subset $$W'$$. This means that if we fix the open set $$U=W\cap\operatorname{Spec}\mathcal{O}_{X,x}$$, we get a compatible system of maps from $$\mathcal{O}_X(V)\to \mathcal{O}_{\operatorname{Spec}\mathcal{O}_{X,x}}(U)$$ where $$V$$ ranges over all open sets of $$X$$ which contain $$U$$. But by the definition of the directed limit, this means we have a map from the directed limit $$\lim_{\rightarrow V\supset U}\mathcal{O}_X(V)$$ to $$\mathcal{O}_Y(U)$$, where I commit the sin of identifying $$U$$ with it's image under the homeomorphism between $$Z$$ and $$\operatorname{Spec} \mathcal{O}_{X,x}$$. Compatibility with restriction is clear from the construction above, so this is exactly the data we need to define the morphism $$\mathcal{O}_X|_Z \to \varphi_*\mathcal{O}_Y$$ and we are done.