Ring of regular functions For $V\subseteq \mathbb A^n$ an affine variety set $$\Gamma (V)=\{f:V\to K| \exists F\in K[x_1,\dots,x_n]\text{ such that }f(c)=F(c)\forall c\in V\}=\{f:V\to K|f\text{ is regular}\}$$ $$K(V)=Frac(\Gamma(V)),\text{ }O_p(V)=\{f\in K(V)|f \text{ defined at } p\in V\}=\{f\in K(V)| \exists a,b\in \Gamma(V)\text{ with }f=\frac{a}{b},\text{ }b(p)\neq 0\}$$
and if $U$ is quasi affine $$O(U)=\{f:U\to K| f\text{ is regular}\}$$$$=\{f:U\to K|\forall p\in U,\exists U_p\subseteq U \text{ open },g,h\in K[x_1,\dots,x_n] \text{ with } f_{|U}=\frac{g_{|U}}{h_{|U}}\} \text{ and }h(p)\neq 0\text{ }\forall p\in U_p\}$$
So we have 2 definitions for being regular, in the affine case, and the quasi affine case.
First I don't understand why $O(V)=\Gamma(V)$ if $V$ is affine, one direction is clear, for the other we consider a local property and somehow we want to show that it satisfies something global. A proof I have says $O(V) \subseteq O_p(V)$ and uses $\Gamma(V)=\bigcap_{p\in V}O_p(V)$. But at this point it's not clear why an element of $O(V)$ should be a quotient on whole $V$
My attempt : Take $p,p'\in V$ consider $U_p,U_{p'}\subseteq V$, we have $U_p\cap U_{p'}\neq \emptyset $ and $\frac{g_p}{h_p}=\frac{g_{p'}}{h_{p'}}$. We have that $U_p\cap U_{p'}\subseteq U_p,U_{p'}$ is irreducible, dense, and those quotients are continuous so we get that $\frac{g_p}{h_p}=\frac{g_{p'}}{h_{p'}}$ on $U_p\cup U_{p'}$. We also get that $h_p(p')=h_{p'}(p')\neq 0$. So in fact we get that $f=\frac{g_p}{h_p}$, since we must have that $h_p(v)\neq 0$ $\forall v\in V$ we get $h_p\in K$ so $f$ is regular with the definition of an affine variety.
And I'm not sure about how to think about $O(V)$. Can be all functions in it be seen as a quotient of polynomials ? If not are there some great cases where we can just say "Take $f\in O(V)$, since V is ... we can write $f=\frac{a}{b}$ for $a,b\in K[x_1,\dots, x_n]$" ?
Is it possible to get some help ?
 A: It is not correct in general to think of $\mathcal{O}(V)$ as being quotients of polynomials. Elements of $\mathcal{O}(V)$ are functions that are locally quotients of polynomials, e.g functions from $V$ to $k$ that are locally rational. What this equality in the case where $V$ is affine is saying is that functions that are locally rational on an affine variety are globally polynomials.
To see this let $f$ be a regular function on $V$ in the second sense (meaning locally rational), so that every $p \in V$ has some neighborhood $U_p$ with $f = \frac{g_p}{h_p}$ on $U_p$. Since $U_p$ is open, $V \setminus U_p$ is closed and we have some function $v_p$ that vanishes on it but not at $p$. Then restrict $f$ to $D(v_p)$, the subset of $V$ where $v_p$ does not vanish, which contains $p$ and is contained in $U_p$. Here we may write $f = \frac{g_p}{h_p} = \frac{v_p g_p}{v_p h_p}$, and then $v_p h_p f = v_p g_p$. Note that this last equality is true globally, on all of $V$: it is obvious on $D(v_p)$, and outside of $D(v_p)$ it must be true because $v_p$ is zero. $h_p f = g_p$ may only be true locally, on $U_p$, which is why we had to introduce the $v_p$.
By quasi-compactness finitely many of the $D(v_p)$ cover $V$, say $v_1, \ldots, v_n$ with corresponding $g_1, h_1, \ldots, g_n, h_n$. Now the $v_1 h_1, \ldots, v_n h_n$ must have no common zeroes or else $f$ would not be defined! Then we have $c_1, \ldots, c_n$ with $c_1 v_1 h_1 + \ldots + c_n v_n h_n = 1$, so that $f = \sum c_i v_i h_i f = \sum c_i v_i g_i$, which is a polynomial in $K$.
So generally, no, when $V$ is not affine we may not say that for $f \in \mathcal{O}(V)$, $f = \frac{a}{b}$ where $a, b \in K[x_1, \ldots, x_n]$. However, $V$ may be covered by neighborhoods $V_p$ of every point where this is true. What this means is that when we are trying to check a local property of $f$ (meaning we want to say that $f$ has property P on some neighborhood of every point) we may restrict $f$ to a neighborhood where $f = \frac{a}{b}$ is true.
If you have seen some commutative algebra, this may make you think of local properties in that context (meaning properties of a ring, module, or homomorphism that hold if and only if they hold for the localization of that ring or module at every prime or maximal ideal). This isn't coincidental: you will see if you explore more algebraic geometry that we can translate statements about your variety or morphism on a neighborhood of a point $p$ to statements about the localization of the coordinate ring at a prime ideal corresponding to $p$.
This is why defining $f$ as being locally rational rather than globally rational is still useful: it provides strong conditions on what $f$ looks like in the localization at each point, which suffices to prove statements about local properties of our variety $V$ and its coordinate ring $\mathcal{O}(V)$.
