$\mathbb{A}^2\backslash\{(0,0)\}$ is not affine variety In our lecture notes we have this example, with the proof why $X = \Bbb{A}^2\setminus \{(0,0)\}$ is not an affine variety:

Let $i:X\hookrightarrow \mathbb{A}^2$ be an inclusion map. We show, that any regular function on $X$ extends uniquely to a regular function on $\mathbb{A}^2$, so that $i^*:k[x,y]\hookrightarrow \mathscr{O}(X)$ is an isomorphism.
Then we have, if $X$ was affine, $i$ is an isomorphism, which is not the case.

So we want to see that $i^*$ is an isomorphism. Therefore note that $\mathscr{O}(X)$ is a subring of the function field $k(x,y)$, that contains $k[x,y]$. 
Take $P=(a,b)\in X$. Then $\mathscr{O}_{X,P}=\mathscr{O}_{\mathbb{A}^2,P}=k[x,y]_{\mathfrak{m}_P}$ whith $\mathfrak{m}_P=(x-a,y-b)$ is maximal ideal of $k[x,y]$.
-> Here is my first questions. How did we get this continued equality? I don't see how this is connected... (my commutative algebra knowledge has some gaps.)
But accepting that, we have $\mathscr{O}(X)\subset\bigcap\limits_{P\not=(0,0)}k[\mathfrak{m}_P]$. And this intersection lies inside of k(x,y).
Now we take $f=\frac{g}{h}\in K(x,y)$ with $g,h\in k[x,y]$ coprime.
Then $f\in k[x,y]_{\mathfrak{m}_P}$ iff $h(P)\not=0$. (Use that $k[x,y]$ is a UFD).
-> First, how did we see that $k[x,y]$ is UFD? And then, how did we conclude out of this the above property?
If $h$ is not a unit, then there are infinitely many $P\in \mathbb{A}^2$ such that $h(P)=0$ and thus also such points in $X$, and so $f\not\in\mathscr{O}(X)$.
So we have that $f\in\mathscr{O}(X)$ if $h$ is a unit. So $f\in k[x,y]$.
Thus $k[x,y]=\mathscr{O}(X)$ and hence $X$ not affine.
-> Now the last question, why does follow that $X$ is not affine?

I hope my questions are not too stupid, and that someone feels like helping!

All the best, Luca :)
 A: It can help to see the most elementary form on an argument when we are struggling with an abstract one. The most reduced form of this problem is: If a rational function is defined on the punctured plane, then it is defined at the origin as well. 
The pole set of a rational function $r$ on the plane is an algebraic subset of the plane. Define $J_r = \{ G\in k[x,y] \mid \overline{G}r\in k[x,y] \}$ where the overline denotes the embedding of $G$ into the function field $k(x,y).$ Then the pole set of $r$ is precisely $V(J_r).$ We show that a rational function can not have $\{(0,0)\}$ as its pole set. If we had $V(J_r)=V(x,y)$ then by the Nullstellensatz, sufficiently large powers of $x$ and $y$ are in $J_r,$ so by the definition of $J_r$ it is possible to write (with no common factors)
$$ r = \frac{p_1}{x^s} = \frac{p_2}{y^t}$$
where $p_1,p_2\in k[x,y]$ and this is an equality in the function field. But this can't be, since $y^tp_1 = p_2 x^s$ implies $y$ divides either $p_2$ or $x.$ 
Another approach is to write $r  = \dfrac{f}{g}$ in lowest terms (unique up to scalar multiplication). If $\deg g\geq 1$ then $V(g)$ is an infinite set, while $V(f)\cap V(g)$ is a finite set since $f$ and $g$ have no common factors. Therefore $r$ must have infinitely many poles. Here I have used some elementary factors about plane curves developed in section 1.6 of Fulton's book on Algebraic Curves.
A: Let me try to answer your questions.


*

*The reason why $\mathcal{O}_{P,X} = \mathcal{O}_{P,\Bbb{A}^2}$ is because for any point $P$ in an affine variety $Y$ and $U \subseteq Y$ open, we have that $\mathcal{O}_{P,U} \cong \mathcal{O}_{P,Y}$. This should essentially be immediate (what is the definition of the local ring at a point?) The second equality comes from Theorem 1.3.2 (c) of Hartshorne.

*That $k[x,y]$ is a UFD is a standard fact in basic abstract algebra. More generally for any UFD $R$, the polynomial ring in $n$ number of variables over $R$ is also a UFD. For your second question, suppose I take a quotient of two polynomials $f = g/h$ with $h$ and $g$ coprime. Suppose that there is another representation $g'/h'$ of $f$ with $g'$ and $h'$ coprime. Then it will follow that $h'g =g'h$ which means to say that $h| h'g$. By unique factorization, it follows that every prime factor of $h$ divides $h'$ and in fact $h|
h'$ since $h$ divides $h'g$ but not $g$. 
Similarly we conclude that $h' | h$ and so upto multiplication by a scalar, $h' = h$. Mutadis mutandis the same argument also shows that $g' = g$ and so the representation of $f$ as a quotient of two polynomials is unique upto multiplication by a scalar. Thus whenever we choose an element $f$ of $k(x,y)$, essentially to ask questions about whether a denominator vanishes, it is enough to work with just any representative of $f$ as a quotient of two polynomials with no common factor.
Thus if $f \in k[x,y]_{\mathfrak{m}_P}$ then $f$ can be written as the quotient of two polynomials $g/h$ with $h(P) \neq 0$ (definition of the localization at $\mathfrak{m}_P$). Conversely if $f = g/h$ with $h(P) \neq 0$, then for any other representative $g'/h'$ of $f$, $h'(P) \neq 0$ too for $h'$ is a non-zero scalar multiple of $h$. Thus $f \in k[x,y]_{\mathfrak{m}_P}$. 

*Once you know that $k[x,y] = \mathcal{O}(X)$ it is clear that $i^\ast$ is an isomorphism. But now their is an equivalence of categories between affine varieties over $k$ and finitely generated integral domains over $k$, and so if $X$ is affine the map $i$ has to be an isomorphism too. But this is impossible because it is not even surjective! Thus $X$ cannot be an affine variety.
