Let $X$ be an algebraic variety, $U\subset X$ open and $f\in \mathcal{O}_X(U)$ such that for all $P\in U$ we have that $f(P)\neq 0$. I want to prove that $f$ is a unit in $\mathcal{O}_X(U)$.
My approach is the following. Pick an arbitrary $P\in U$. We define the local ring of $X$ at $P$ as follows:
$$\mathcal{O}_{X, P}:=\left\{(U, f): U \subset X\right. \text{ is open, } P \in U, \text{ and }\left.f \in \mathcal{O}_X(U)\right\} / \sim,$$ where $(U, f) \sim(V, g)$ if and only if there is an open $W \subset U \cap V$ with $P \in W$ such that $f=g$ on $W$.
This is a local ring whose maximal ideal is $\mathfrak{m}_P$, which are precisely the functions that vanish on $P$ (here I am being a bit sloppy in the sense that elements of the local rings aren't really functions but pairs $(U,f)$ but it doesn't really affect the argument). Since $f$ does not vanish on $P$ we have that $f$ (or $(U,f)$ if you prefer) is not in this maximal ideal. Therefore it is a unit so we can find $(V,g)$ such that $g\in \mathcal{O}_X(V)$ and $(U\cap V,fg|_{U\cap V})=(U\cap V,1)$. Now I want to say: "since this can be done for any $P$, we get that $f$ is indeed a unit of $\mathcal{O}_X(U)$". But am not so sure about this last part. I think that perhaps for different points I get different $g$'s, so that $f$ does not have a global inverse but many local inverses that don't glue well. I am seeking help in (at least) one of the following ways:
- Finishing this argument
- Showing that this argument is incorrect
- Giving me a different argument