# Inequality of convexity with the middle point only

A function $f\colon X\to \mathbb R$ is called convex if

$$\forall (x,y)\in X^2,\quad \forall t\in[0,1],\quad f(tx+(1-t)y)\leqslant tf(x)+(1-t)f(y).$$

Intuitively, it would seem that if we only impose that condition for $t=\frac 12$ we would get the same set of convex functions.

For a continuous function, I believe this is true (the following drawing convinced me): My problem is that I was not able to find a counter-example, even for a discontinuous function.

I do believe there exists one though.

So what would be a function $\varphi$ which would verified (i) but not (ii) ?

$$(i) \quad \forall (x,y)\in X^2,\quad \varphi\left(\frac {x+y}2\right)\leqslant \frac{\varphi(x)+ \varphi(y)}2.$$

$$(ii) \quad \forall (x,y)\in X^2,\quad \forall t\in[0,1],\quad \varphi(tx+(1-t)y)\leqslant t \varphi(x)+(1-t) \varphi(y).$$

Here is one. Consider a Hamel basis $B$ of the real numbers over the rationals, let $b_0$ be one member of $B$, and let $f(x) = c_{b_0}$ where $x = \sum_{b \in B} c_b b$ is the unique expression of $x$ as a finite linear combination of members of $B$ with $c_b$ rational. Then $f$ is midpoint-convex, in fact $f((x+y)/2) = f(x)/2 + f(y)/2$, but $f$ is not convex.