A closed subset of a prevariety is a prevariety My question comes from Gathmann's notes https://www.mathematik.uni-kl.de/~gathmann/class/alggeom-2014/alggeom-2014.pdf on page 42 Exercise 5.13.

Let $Y$ be a closed subset of a prevariety $X$, considered as a ringed space with the
  structure sheaf of Construction 5.12 (b). Prove for every affine open subset $U ⊂ X$ that the ringed
  space $U∩Y$ (considered as an open subset of the ringed space $Y$ as in Definition 4.1 (c)) is isomorphic
  to the affine variety $U∩Y$ (considered as an affine subvariety of the affine variety $U$).
In particular, this shows that Construction 5.12 (b) makes $Y$ into a prevariety, and that this prevariety
  is isomorphic to the affine variety $Y$ if $X$ is itself affine (and thus $Y$ an affine subvariety of $X$).

The construction 5.12 is to define $\mathcal{O}_Y (U)$ to be the $K$-algebra of functions $U → K$ that are locally
restrictions of functions on $X$, or formally
$\mathcal{O}_Y (U) := \{ϕ : U → K : $for all $a ∈ U$ there are an open neighborhood $V$ of $a$ in $X$
and $ψ ∈ \mathcal{O}_X (V) $ with $ ϕ = ψ $ on $U∩V\}$.
My confusion is showing the affine variety $U∩Y$ is isomorphic to the ringed
space $U∩Y$. My initial idea is to use the identity map, but I am not really sure how to check the sheaves are equivalent
After that, a closed subset of a prevariety is indeed a prevariety. I can refer to the proof from https://www.math.upenn.edu/~siegelch/Notes/ag.pdf on page 9 on Proposition 1.19.
Any help is appreciated.
 A: I am also unsure of my solution to this problem, so any corrections are welcome! I think you are on the right track, the isomorphism must be the identity map. The only thing that is problematic is showing that the sheaves of regular function are the same.
The question calls for us to view $U \cap Y$ in two ways. First, we view $U \cap Y$ as a closed subset of $U$. In this case, the sheaf $O_{U \cap Y}$ is by definition: For any $V$ open in $U \cap Y$, $O_{U \cap Y} (V) = \{ \varphi : V \to K :$ for all $a \in V$ there exists an open neighborhood $ N$ of $U$ containing $a$, and $\psi \in O_{U}(N)$ with $\varphi = \psi$ on $V \cap N \}$. Then, we note that $O_U(N) = O_X(N) |_U = O_X(N)$ where the second equality is because $N \subset U$.
On the other hand, we can view $U \cap Y$ as an open subset of $Y$. Then for any $V$ open subset of $U \cap Y$, we have that the sheaf is just the restriction: $O_{U \cap Y}(V) = O_{Y} (V)$. Lets apply the definition of $O_{Y} (V')$. By definition, for any $V'$ open in $Y$, $O_Y(V') = \{ \varphi : V' \to K : $ for all $a \in V'$ there exists an open neighborhood $N'$ of $X$ containing $a$, and $\psi$ in $O_X(N')$ with $\varphi = \psi$ on $V' \cap N' \}$.
Then just need to show that the restriction of the last set to $U \cap Y$ is equal to the first set. Since $V'$ is going to be an open subset of $U \cap Y$, we can replace "$V'$ open in $Y$" with "$V'$ open in $U \cap Y$".
$N'$ is an open subset of $X$, and $N' \subset U \cap Y$, so $N'$ is an open neighborhood of $U$ also. So we can replace "open neighborhood $N'$ of $X$" with "open neighborhood $N'$ of $U$". Then both sets can be seen to be equal.
