I am studying localization right now from the lecture notes given by our instructor. In this notes he describes an example of localization what he told us yesterday in the class. Here's this $:$
Let $\mathcal k$ be a field. Let $A= \mathcal k [X_1,X_2, \cdots, X_n].$ Let $\mathfrak p$ be a prime ideal of $A.$ Consider the variety $V$ of $\mathfrak p$ defined by $$V := \{ (a_1,a_2,\cdots,a_n) \in \mathcal {k^n} : f(a_1,a_2, \cdots , a_n) = 0\ \forall f \in \mathfrak p \}.$$ Let $S = A \setminus \mathfrak p.$ Then clearly $S$ is a multiplicatively closed set. Let $A_{\mathfrak p}$ denote the localization of $A$ w.r.t. the multiplicatively closed set $S$ (which we usually denote by $S^{-1} A.$ Our instructor gave $A_{\mathfrak p}$ a name which is "$A$ localized at $\mathfrak p$"). Then $$A_{\mathfrak p} = \left \{\frac f g : g \notin \mathfrak p \right \}.$$
Now what is meant by $g \notin \mathfrak p$? What can I say about $g$ in terms of $V$? Our instructor told us that $g \notin \mathfrak p \implies$ $g$ is nowhere vanishing on $V.$ But how do I say that? If $g \in \mathfrak p$ then it is clear that $g$ will vanish at all points of $V.$ But what will happen if $g \notin \mathfrak p$? Can $g$ then vanish at all or some points of $V$? I am very confused at this stage and I got stuck here. Can somebody please help me to clear my confusion? Then it will be really very helpful for me.
Thank you very much for your valuable time.
Your question contains many questions.
In general, the localization $S^{-1}R$ of a commutative ring $R$ at a multiplicatively closed subset $S\subset R$ consists of fractions of the form $\tfrac rs$ with $r\in R$ and $s\in S$. In this case $R=A$ and $S=A\setminus\mathfrak{p}$, so $s\in S$ is equivalent to $s\notin\mathfrak{p}$. So indeed $$A_{\mathfrak{p}} =S^{-1}A =\left\{\frac fg:\ f\in R,\ g\in S\right\} =\left\{\frac fg:\ f,g\in A,\ g\notin\mathfrak{p}\ \right\}.$$
Unfortunately, not much in general. A simple classical example is given by $k=\Bbb{R}$ and $n=1$. The ring $A=\Bbb{R}[X]$ has the two prime ideals $\mathfrak{p}_1=(X^2+1)$ and $\mathfrak{p}_2=(X^2+2)$, and the corresponding varieties are both empty, i.e. $V_1=V_2=\varnothing$. We have $$X^2+2\notin\mathfrak{p}_1,\ X^2+2\in\mathfrak{p}_2, \qquad\text{ and }\qquad X^2+1\in\mathfrak{p}_1,\ X^2+1\notin\mathfrak{p}_2,$$ but there is clearly no way to tell from the corresponding varieties because $V_1=V_2$.
The example given in the comments illustrates that for some $\mathfrak{p}$ there exist $g\notin\mathfrak{p}$ that vanish on all of $V$. Indeed the example above also illustrates this, albeit vacuously; every $g\in\Bbb{R}[X]$ vanishes on $V_1$ and $V_2$ because $V_1=V_2=\varnothing$.
However, this does not provide a counterexample to the claim that
The example in the comments does give a counterexample; take $n=2$ and $\mathfrak{p}=(X_1)\subset k[X_1,X_2]$. Then $V=\{(0,x):\ x\in k\}$ and $g=X_2\notin\mathfrak{p}$, but $g(0,0)=0$, so $g$ is not nowhere vanishing on $V$.
Even worse; if we take $k=\Bbb{R}$ again and $\mathfrak{p}=(X_1^2+X_2^2)\subset\Bbb{R}[X_1,X_2]$ then $V=\{(0,0)\}$, and $g=X_1\notin\mathfrak{p}$ but $g(0,0)=0$ so $g$ vanishes everywhere on $V$.
The situation is better if $k$ is algebraically closed. Then it follows from the Nullstellensatz that if $\mathfrak{p}\subset A$ is prime and $g\in A$ vanishes on all of $V$, then $g\in\mathfrak{p}$. So conversely, if $g\notin\mathfrak{p}$ then $g(a)\neq0$ for some $a\in V$.