Let $f:\mathbb R^n\to \mathbb R$ be $C^1$ and satisfy following condition: For every $x\in\mathbb R^n$ there exists some $\varepsilon_x > 0$ such that for every $y$ with $\|y - x\| < \varepsilon_x$ it follows $$ f(y) \ge f(x) + \nabla f(x)^T (y - x). $$ Is $f$ convex?
Note: This is a follow-up question to 'Locally' Convex Function, whose accepted answer assumes $C^2$.
Obviously a proof for $n=1$ suffices.
This is a much uglier proof than I had anticipated.
The key result is that if a real valued $h$ is convex on an interval and attains a $\max$ in interior of the interval then $h$ is constant on the interval.
It is sufficient to prove that $\phi:I \to \mathbb{R}$ is convex, where $I=[0,1]$ and $\phi$ is defined by $\phi(t) = f(ty+(1-t)x)$.
Let $\eta(t) = \phi(t) -l(t)$ where $l(t) = t \phi(1)+(1-t)\phi(0)$. Note that $\eta(0)=\eta(1) = 0$.
Let $t^* \in I$ maximise $\eta$ and suppose $\eta(t^*) > 0$. Note that $\eta(t) \le \eta(t^*)$ for $t \in I$. It is clear that the set $M= \{t \in I | \eta(t)=\eta(t^*) \}$ is closed. Note that $\eta'(t) =0 $ for all $t \in M$ (since all points are maximisers).
We will show that $M$ is open, hence connected and so equal to $I$ which will give a contradiction.
Pick $t' \in M$. There is some $\epsilon>0$ such that $\phi(t'+h)-\phi(t') \ge \phi'(t')h$ for $|h|< \epsilon$. Since $l'(t'+h)-l(t') = l'(t') h$, we see that $\eta(t'+h)-\eta(t') \ge \eta'(t')h = 0$ for $|h| <\epsilon$.
In particular, $\eta(t'+h) = \eta(t')$ for $|h| <\epsilon$ and so $(t'-\epsilon,t'+\epsilon) \subset M$. Hence $M$ is open which means that $\eta(0) = \eta(t^*)>0$, a contradiction.
Hence $\eta(t) \le 0 $ for all $I$ and so $f$ is convex.
Note that only differentiability was used.