On a *ringed space*, show that the non vanishing set of $f$ is open, and that it is invertible there This is an exercise of Ravi Vakil that I solved by a very trivial argument without using the hint. For this reason I'm worried that I might have missed something.

If $f$ is a function on a locally ringed space $X$, show that the subset of $X$ where $f$ doesn't vanish is open. (Hint: show that if $f$ is a function on a ringed space $X$, show that (sic) the subset of $X$ where the germ of $f$ is invertible is open)

Solution: Assuming that the first sentence means "$f$ is an element of $\mathcal O_X$", and that $\mathcal O_X$ is a ring of continuous functions on $X$, we just pull back the closed set $\{0\}$ to $X$ via $f^{-1}$. Under a continuous function the pull back of a closed set is closed, and therefore the complement of the locus where $f$ doesn't vanish is closed.
Questions:
1) is my solution correct?
2) I know it is true for the special example of schemes, but for a ringed space in general why is the locus of where a function $f$ doesn't vanish the same of where the germ of $f$ is invertible? The most I can say is that this is true for locally ringed spaces (and not for just ringed spaces as the hint suggests), because if the germ of a function is non-zero at a point $p$ in a locally ringed space $X$, $f_p$ can't belong to the maximal ideal $\mathfrak m_p$. For if it did, then under the homomorphism $ev_p: \mathcal O_{X,p} \rightarrow k$ the maximal ideal of $k$, which is $(0)$, would not pull back to $\mathfrak m_p$ (it would miss $f_p$).
 A: When he says function, he refers to any $f \in \mathcal{O}_X(U)$
1) No, $\mathcal O_X$ is just a sheaf and $f$ need not be a function at all.
2) To vanish at $p$ means that the germ $[f]_x$ is in the maximal ideal of the local ring $\mathcal O_{X,p}$
3) To be invertible at $p$ means that the stalk $[f]_x$ is in $\mathcal O_{X,p}^*$, a unit.
Now:
If $f$ is invertible at $p$ means that $[f]_p [g]_p=[1]_p$. By the definition this holds on a open nhood $f|_V g|_V = 1|_V$ so that the invertible locus is open.
Now if $\mathcal O_{X,p}$is a local ring and $[f]_x$ does not vanish, so $[f]_x \notin \mathfrak{m}_x$ is invertible
A: There is a subtle and interesting point in this context  that one really has  to understand:
let me try to be as clear as possible rather than concise.
a) Let $(X,\mathscr O_X)$ be a ringed space that is not necessarily locally ringed.
Then given  $f\in \mathscr O_X(X)$, we can ask whether the germ $ f_x\in  \mathscr O_{X,x}$ at $x\in X$ is invertible i.e. if $f_x\in  \mathscr O_{X,x}^\star$.
Note carefully that the ring $\mathscr O_{X,x}$ is absolutely arbitrary and should not be assumed local.
In this set-up the set of points $x\in X$ with $f_x\in  \mathscr O_{X,y}^\star$ is open:
Indeed if $f_x\in  \mathscr O_{X,x}^\star$ there exists a germ $g_x$ with $f_xg_x=1\in \mathscr O_{X,x}$ and thus on a suitable open neighbourhood $U$ of $x$ there exists a representative $g\in \mathscr O_X(U)$ of $g_x$ satisfying $f|U\cdot g=1\in \mathscr O_X(U)$.
It is then clear that for all $y\in U$ we also have $f_y\in  \mathscr O_{X,y}^\star$ since $f_y\cdot g_y=1\in  \mathscr O_{X,y}$ :  the promised openness has been proved .
As a digression, let me add that the reasoning above easily implies (by covering $X$ by suitable open $U$'s and using the unicity of inverses in a ring) that a global section $f\in  \mathscr O_X(X)$ is invertible if and only if all its germs are invertible: $$f\in \mathscr O_X(X)^\star \iff (\forall x\in X) \; f_x\in \mathscr O_{X,x}^\star \quad (\bigstar)$$
$\\$
b) Suppose now that $(X,\mathscr O_X)$ is a locally ringed space.
Each point $x\in X$ then acquires a residue field $\kappa(x)= \mathscr O_{X,x}/\mathfrak m_x$ and a function $f\in \mathscr O_X(X)$ now receives  a value $f(x)=\text {class} (f_x) \in \mathscr O_{X,x}/\mathfrak m_x=\kappa(x)$.
This value is close to the classical interpretation of the value of a function but it is crucial to understand the enormous difference between $f_x$ and $f(x)$.
The charm of local rings  is that invertibility of $f_x$ is now exactly equivalent to the rather concrete requirement of having non-zero value: $$f_x\in  \mathscr O_{X,x}^\star \iff f(x)\neq 0\in \kappa(x)  \quad   \quad (\bigstar \bigstar) $$  In particular, taking   $(\bigstar)$ into account, we get:  $f\in \mathscr O_X(X)^\star \iff (\forall x\in X) \; f(x)\neq 0\in \kappa(x)$
$\\$
c) So the set of points where $f(x)\neq 0$ is open thanks to the above equivalence $(\bigstar \bigstar)$ and the openness result in a).
As an aside, I find it a little intriguing that the trivial-looking assertion of openness of $f(x)\neq 0$  requires such a roundabout proof.
