If all points of a real function with positive values would be local minimum, can one say it is constant function?

My answer is: Such a function must be constant. Suppose (for puoposes of contradiction) $f$ is a nonconstant function $f : \mathbb R \to (0,+\infty)$ such that $$ \forall x\in\left(a-\frac{1}{f(a)},a+\frac{1}{f(a)}\right),\quad f(x) \ge f(a) . $$

For $m > 0$, define $U_m := \{x : f(x)>m\}$.

Lemma 1: For all $m \in \mathbb R$, the set $U_m$ is open.
Proof. Let $x \in U_m$. Then $(x-1/f(x),x+1/f(x)) \subseteq U_m$. So $U_m$ is open.

Define $\mathcal G = \{(a,b,m) : a < b, f(a)\le m, f(b)\le m, \text{ and }\forall x\in(a,b),f(x)> m\}$.

Lemma 2: Let $a,b \in \mathbb R$ with $f(a) \ne f(b)$, and $m>0$. Then there exists $a_1, b_1$ with $a < a_1 < b_1 < b$ and $m_1 \ge m$ such that $(a_1,b_1,m_1) \in \mathcal G$.
Proof. One of $f(a), f(b)$ is smaller, assume WLOG that $f(a) < f(b)$. Now $U_{f(a)}$ is open, $a \notin U_{f(a)}$, and $b \in U_{f(a)}$. The maximal open interval $(c,d) \subseteq U_{f(a)}$ with $c<b< d$ is nonempty, in fact $(c,b) = (c,d) \cap (a,b) \ne \varnothing$. By maximality, $f(c) \le f(a)$. Choose $e$ with $c < e < b$. For $x \in (c,e)$ we have $f(c) < f(x)$ so $c \le x-1/f(x)$ and thus $f(x) \ge 1/(x-c)$. Thus $f(x)$ is unbounded on $(c,e)$. Let $m_1$ be such that $m_1 \ge m, m_1 > f(c), m_1 > f(e)$. The open set $U_{m_1}$ has $U_{m_1} \cap (c,e) \ne \varnothing$ and $c,e \notin U_{m_1}$. So let $(a_1,b_1)$ be a maximal open subinterval of the open set $U_{m_1} \cap (c,e)$.

Lemma 3: Let $(a_1, b_1, m_1) \in \mathcal G$, and let $m > m_1$. Then there exist $a_2, b_2$ with $a_1 < a_2 < b_2 < b_1$ and $m_2 \ge m$ such that $(a_2, b_2, m_2) \in \mathcal G$.
Proof: If $f(a_1) \ne f(b_1)$, apply Lemma 2 directly. Otherwise, pick any $c \in (a_1,b_1)$ and apply Lemma 2 to $a_1, c, m$.

Main Proof: We assume $f$ is not constant. So there exist $a_1 < b_1$ with $f(a_1) \ne f(b_1)$. By Lemma 2 there exist $a_2, b_2$ with $a_1 < a_2 < b_2 < b_1$ and $m_2 > 2$ so that $(a_2,b_2,m_2) \in \mathcal G$. Then by Lemma 3, there exist $a_3, b_3$ with $a_2 < a_3 < b_3 < b_2$ and $m_3 > 3$ so that $(a_3,b_3,m_3) \in \mathcal G$. Continuing recursively, we get sequences $(a_k), (b_k), (m_k)$ so that $$ \forall k:\quad a_k < a_{k+1} < b_{k+1} < b_k,\quad m_k > k,\quad\text{and } (a_k,b_k,m_k)\in\mathcal G . $$ The sequence $(a_k)$ is increasing and bounded above, so it converges. Let $a = \lim_{k\to\infty} a_k$. Then $a_k < a_{k+1} \le a \le b_{k+1} < b_k$. From $(a_k,b_k,m_k) \in \mathcal G$ we conclude $f(a) > m_k > k$. This is true for all $k$, so $f(a)$ is not a real number, a contradiction.


This is not an answer but it greatly narrows down the class of functions $f$ with the described property.

  1. If $c>0$, then the sets $f^{-1}([c,+\infty))$ and $f^{-1}((c,+\infty))$ are both open.

Indeed, every $x$ in any of these sets comes with an open ball of radius $\frac{1}{f(x)}$.

Consequently, the sets $A_c=f^{-1}((-\infty, c))$ and $B_c=f^{-1}((-\infty, c])$ are both closed. In particular, $f$ is lower semi-continuous.

  1. Let $x\in B_c$. We know that if $d(y,x)<\frac{1}{c}\le \frac{1}{f(x)}$, then $f(x)\le f(y)$. On the other hand, if $y\in B_c$ and $d(y,x)<\frac{1}{c}$, then $d(y,x)<\frac{1}{f(y)}$, from where $f(y)\le f(x)$. Hence, if $y\in B_c$ and $d(y,x)<\frac{1}{c}$, we get $f(y)= f(x)$.

Not only this means that $f$ is locally a constant on $B_c$, but also that $f^{-1}(c)$ is closed.

  1. Let us prove the following strengthening of the Baire's theorem: let $X$ be a complete metric space, and let $B_n$ be a sequence of closed sets such that $X=\bigcup B_n$. Then $X=\overline{\bigcup int B_n}$.

Indeed, if $U\subset X\backslash \bigcup int B_n$ is open and nonempty, it is metrizable with a complete metric, and $B_n\cap U$ is closed in $U$. Since $U=\bigcup (B_n\cap U)$, from the usual Baire's theorem, there is $m$ such that $V=int (B_m\cap U) \ne \varnothing$. But then $V=int (B_m\cap U)=int B_m\cap U\subset int B_m \backslash \bigcup int B_n=\varnothing$. contradiction.

  1. So, combining these observation we get the following picture: there is a dense open set $U$ such that $f$ is locally constant on $U$; every level set of $f$ is closed, and the distance between elements of $f^{-1}(c)$ and $f^{-1}(d)$ is at least $\frac{1}{\max \{c,d\}}$.

The only way it's not a constant function is when the components of $U$ are like the gaps in the Cantor set. So the possible counterexample may be constructed like the Cantor's staircase, but the smaller the component, the larger is the value on it. I was unable to perform this fine tuning though, maybe it's impossible.