Say that a function $f$ defined on $\mathbb{Q}^n$ is *midpoint convex* if $f((x+y)/2) \le (f(x) + f(y))/2$. Say that it is *rationally convex* if, for $\lambda \in \mathbb{Q} \cap [0,1]$ and $\bar \lambda = 1-\lambda$, we have $f(\lambda x + \bar\lambda y) \le \lambda f(x) + \bar\lambda f(y)$.


Clearly every rationally-convex function is midpoint-convex.


**Question:** Is a midpoint-convex function on $\mathbb{Q}^n$ necessarily rationally-convex?


**Background:** I'm looking for sufficient conditions for a function on $\mathbb{Q}^n$ to extend to a continuous function on $\mathbb{R}^n$. The following results are known and/or easy:


* Rationally-convex functions on $\mathbb{Q}^n$ are continuous; similarly real-convex functions on $\mathbb{R}^n$ are continuous. (I'm sticking to "proper" functions, with real values, for convenience.)
* Using the axiom of choice, there are rationally-convex functions on $\mathbb{R}$. (Take a $\mathbb{Q}$-basis of $\mathbb{R}^n$ and go from there.)
* Every rationally-convex function $f$ on $\mathbb{Q}^n$ extends continuously to a real-convex function. (Define the extension to be the $\liminf$ of the nearby rational values, and check the result is convex.) As a result, every rationally-convex function on $\mathbb{Q}^n$ extends to a continuous function on $\mathbb{R}^n$.
* Every measurable, midpoint-convex function on $\mathbb{R}^n$ is continuous. (Attributed by Wikipedia to Sierpinski, I have not read the reference. There are many prior questions on MathOverflow that are answered by this theorem.)


These all seem like it should be implying midpoint-convex implies rationally-convex, but I couldn't quite close the loop.


In the case I'm actually interested in, this is a side issue, since my function $f$ is additionally (rationally)-homogeneous, and homogeneous and midpoint-convex implies rationally-convex. But I was curious and could not find it in the literature.



Does midpoint-convex imply rationally convex?
Assume that $g$ defined on $\mathbb{Q}^n$ is midpoint convex. First we show that we can extend the midpoint inequality to arbitrary means:


$g((x\_1+\dots+x\_m)/m)\leq (g(x\_1)+\dots+g(x\_m))/m$ for any $m\in\mathbb{Z}\_{\geq1}$


We can easily prove this for $m=2^k$ by using midpoint convexity $k$ times. 


For general $m\leq 2^{i}$ you take $x\_1,\dots,x\_m$ plus $2^i-m$ copies of $x'=(x\_1+\dots+x\_m)/m$


This gives $$g(x')=g\left(\frac{(2^i-m)x'+x\_1+\cdots+x\_m}{2^i}\right) \le\frac{(2^i-m)g(x')+g(x\_1)+\dots+g(x\_m)}{2^i},$$ which implies $g(x')=g((x\_1+\dots+x\_m)/m) \leq (g(x\_1)+\dots+g(x\_m))/m$ for any $m\in\mathbb{Z}\_{\geq1}$.


Finally, taking $a$ copies of $x$ and $b$ copies of $y$ we obtain $$g(\frac{ax+by}{a+b})\leq \frac{ag(x)+bg(y)}{a+b}=\left[\frac{a}{a+b}\right]g(x)+\left[\frac{b}{a+b}\right]g(y)$$ for $a,b\in \mathbb{Z}\_\geq0$ not both zero and hence that $g$ is rationally convex.


