Stalk of the sheaf of regular functions on a subvariety Suppose $Y$ is a subvariety of a variety $X$ (according to Hartshorne this means if $X$ is quasi-affine or quasi projective then $Y$ is a locally closed subset of $X$, c.f. exercise 3.10, chapter 1).  Now given $i : Y \to X$ the inclusion map, I am trying to figure out what the stalk at $x \in Y$ of $i_\ast(\mathcal{O}_Y) $ is. Now if I unwind the definitions, firstly for any open set $U \subseteq X$ we have $i_\ast(\mathcal{O}_Y)(U) = \mathcal{O}_Y(U \cap Y)$. I guess that the stalk at $x$ of $i_\ast (\mathcal{O}_Y) $ should consist of pairs $\langle U \cap Y,f \rangle$ where $f$ is a regular function on $U \cap Y$. 
However why should it be the case that on stalks the map induced from restriction $(\mathcal{O}_X)_x \to (i_\ast \mathcal{O}_Y)_x$ is surjective? This seems to be saying to me that any regular function on an open subset $U \cap Y$ of $Y$ is the restriction of some regular function on an open subset of $X$, but is this true?
 A: 1) Yes, we have for the stalk of $i_\ast(\mathcal{O}_Y) $ at $x$ the equality  $(i_\ast \mathcal{O}_Y)_x=\mathcal{O}_{Y,x} $ : as you write, this follows from the definitions.  
2) Yes, the canonical morphism of local rings $\mathcal{O}_{X,x}\to \mathcal{O}_{Y,x}$ is an epimorphism.
Its kernel is $\mathcal I_x$, the stalk at $x$ of the sheaf of ideals $\mathcal I=\mathcal I_Y$ defining $Y$ in $X$. 
These are not theorems but essentially definitions: the modern point of view is that closed subvarieties or, better, closed subschemes of a  scheme $X$ correspond by definition to quasi-coherent ideals of $\mathcal O_X$: cf. Hartshorne, Proposition II 5.9 and this answer to Ravi Vakil's query, emphasizing that in the affine case closed subschemes of $Spec(A)$ are in perfect bijective correspondence with ideals of the ring $A$.
In my opinion elementary presentations of varieties tend to hide this simple and beautiful correspondence, replacing it by ad hoc, easy but not so transparent constructions.
A: Let me illustrate how to find the lift of regular functions. (And I agree the comments that the former answer didn't reveal it clearly)
In short: to see the surjectivity, we need to use the definition of regular functions, in the affine case!
Here I adopt the definitions in Hartshorne, Chapter 1.
First we can find an affine cover of $X$. So $\forall (U,f)\in (i_{\ast}\mathcal{O}_{Y})_{x}$, we may assume that $U$ is an open subset of an affine space. Also now $Y\cap U$ is a quasi-affine variety since it is a subvariety of a quasi-affine variety $U$. Since $f$ is regular at $x$, we can find an open neighborhood of $x$ in $Y\cap U$, on which $f$ is a quotient of two polynomials. Note that these two polynomials are lived in the affine space. So we can view the quotient in the affine space and find a open neighborhood of $x$ in $U$, on which the quotient is still regular, since the zero set of the denominator is closed. We denote the quotient as $\bar{f}$ and find that $(V,\bar{f})\mapsto (U,f)$.
