TITLE: $\mathbb{A}^2\backslash\{(0,0)\}$ is not affine variety
QUESTION [17 upvotes]: 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 :)

REPLY [3 votes]: 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.