TITLE: The interior of $\{f \leq 0\}$ is $\{ f < 0\}$
QUESTION [7 upvotes]: Let $X\subseteq \mathbb{R}^n$, $f: X \rightarrow \mathbb{R}$: what further conditions on $X$ and $f$ do we need to ensure that $\text{Int}\{x|f(x)\leq 0\}=\{x|f(x)<0\}$?
Context: I've encountered this kind of question when dealing with open bounded $X$ with $C^1$ boundary, in partial differential equations, but I'm sure that one could benefit from such a fact in optimization, for instance.
Clearly, continuity is not enough, since $f:[0,1]\rightarrow \mathbb{R} , f(x)=0$ is such that $[0,1]=\{f\leq 0\}$, but the interior of this set is not the empty set.

REPLY [2 votes]: If $f$ is continuous, it is easy to see that $$\tag 
{1}\{x:f(x)<0\}\subseteq \text{Int}\{x:f(x)\le 0\}$$
This holds because the LHT is open and the RHT is, by definition, the biggest open subset of $\{x:f(x)\le 0\}$.
Let us first suppose $X=\mathbb{R}^n$:
One necessary and sufficient condition for equality, provided that $f$ is differentiable, is that $\nabla f\neq 0$ on $f^{-1}(0)$.
To prove it, let $x$ be a point inside $\text{Int}\{x:f(x)\le 0\}\backslash \{x:f(x)<0\}$. This means that $x$ is locally a maximum, and thus $\nabla f=0$
This clearly generalizes to open subsets of $\mathbb{R}^n$.
It is now easy to see that, for general $X$ and continuous $f$, a necessary and sufficient condition is that $f^{-1}(0)$ does not contain local maxima (although this is not a very useful condition)
Note that some kind of regularity hypotesis is necessary: as Whitney proved, given a closed subset $K$ of $\mathbb{R}^n$, there's always a $\mathcal{C}^\infty(\mathbb{R}^n)$ function with $f^{-1}(0)=K$. Given such an $f$, considering $f^2$ gives you a class of smooth examples with strict (or trivial) inclusion.