Prove that $f(ax + (1-a)y) = \frac{1}{y-x}\int_x^y f(t)dt$ implies $a = \frac{1}{2}$ 
Let $f: \mathbb{R} \to \mathbb{R}$ be a non-constant function, integrable on every interval $[x,y] \subset \mathbb{R}$ and $a \in \mathbb{R}$ such that $$f(ax + (1-a)y) = \frac{1}{y-x}\int_x^y{f(t)dt}, \quad \forall x<y$$
  Prove that $\displaystyle a = \frac{1}{2}$.

This is a small part from another problem. If I can prove that $\displaystyle{a = \frac{1}{2}}$ then the whole problem is solved, but I don't know how.
Edit:
If $f$ is integrable, then the function $F : \mathbb{R} \to \mathbb{R}, F(x) = \displaystyle{\int_m^x{f(t)dt}}, m \in \mathbb{R}$ is continuous. Since we have that $\displaystyle{f(ax + (1-a)y) = \frac{1}{y-x}\int_x^y{f(t)dt}, \forall x<y}$, then $f$ is continuous and $F$ is differentiable. This implies that $f \in C^{\infty}(\mathbb{R})$.
If $\displaystyle{a = \frac{1}{2}}$, then $\displaystyle{f\left(\frac{x+y}{2}\right) = \frac{1}{y-x}\int_x^y{f(t)dt}, \forall x < y}$. So we have equality in the Hermite-Hadamard inequality, which is achieved when $f$ is linear on that interval.
 A: We know $f$ is differentiable on $\mathbb R.$ If $f$ is constant, then any $a$ will work.
If $f$ is not constant, then $f'(x_0)\ne 0$ for some $x_0.$ For simplicity, assume at first that $x_0 = 0$ and $f(0)=0.$ Then $f(y) = f'(0)y + o(y)$ as $y\to 0.$ It follows that
$$\tag 1 f((1-a)y) = f'(0)(1-a)y + o(y)\,\,\text {as } y\to 0.$$
We also have
$$ f((1-a)y) = f(a\cdot 0 +(1-a)y) = \frac{1}{y}\int_0^y f(t)\,dt$$ $$\tag 2 = \frac{1}{y}\int_0^y (f'(0)t + o(t))\,dt = \frac{1}{y}(f'(0)y^2/2 + o(y^2))= f'(0)y/2 +o(y).$$
Equating $(1)$ with the last expression in $(2),$ and finally using $f'(0)\ne 0,$ we obtain $1-a=1/2,$ and thus $a=1/2,$ as desired.
What about the assumption $x_0 =0=f(x_0)?$ This special case implies the general case, simply because if $f$ has the given property, then so does $x\to f(x+d)+c$ for any constants $c,d.$
A: $\def\d{\mathrm{d}}$The proof for $f \in C^\infty(\mathbb{R})$ is skipped for simplicity since @C_M already knows how to prove it :) Now define$$
F(x) = \int_0^x f(t) \,\d t, \quad x \in \mathbb{R}
$$
then $F \in C^\infty(\mathbb{R})$.
For any $x \in \mathbb{R}$ and $h > 0$, since$$
\int_{x_1}^{x_2} f(t) \,\d t = (x_2 - x_1) f(ax_1 + (1 - a)x_2)), \quad \forall x_1 < x_2
$$
i.e.$$
F(x_2) - F(x_1) = (x_2 - x_1) F'(ax_1 + (1 - a)x_2)), \quad \forall x_1 < x_2
$$
set $(x_1, x_2) = (x - (1 - a)h, x + ah)$ to get$$
F(x + ah) - F(x - (1 - a)h) = h F'(x). \quad \forall x \in \mathbb{R},\ h > 0
$$
Therefore, \begin{align*}
0 &= \frac{\partial^2}{\partial h^2}(h F'(x)) = \frac{\partial^2}{\partial h^2}(F(x + ah) - F(x - (1 - a)h))\\
&= a^2 F''(x + ah) - (1 - a)^2 F''(x - (1 - a)h). \quad \forall x \in \mathbb{R},\ h > 0
\end{align*}
For any $x_1 < x_2$, set $(x, h) = (a x_1 + (1 - a)x_2, x_2 - x_1)$ to get$$
(1 - a)^2 F''(x_1) = a^2 F''(x_2). \quad \forall x_1 < x_2 \tag{1}
$$
Now, because $f$ is not constant, then $F'' = f'$ is not always zero. Suppose $F''(x_0) \neq 0$. If $a = 0$, set $(x_1, x_2) = (x_0, x_0 + 1)$ in (1), then $F''(x_0) = 0$, a contradiction. Analogously, if $a = 1$, there is also a contradiction. Thus $a \neq 0, 1$, which implies $\dfrac{1 - a}{a} \neq 0$ and $F''(x) \neq 0 \ (\forall x \in \mathbb{R})$.
Next, on the one hand, from (1) there is$$
F''(2) = \left( \frac{1 - a}{a} \right)^2 F''(0).
$$
On the other hand, from (1) there is$$
F''(2) = \left( \frac{1 - a}{a} \right)^2 F''(1) = \left( \frac{1 - a}{a} \right)^4 F''(0).
$$
Therefore,$$
\left( \frac{1 - a}{a} \right)^4 = \left( \frac{1 - a}{a} \right)^2 \Longrightarrow \frac{1 - a}{a} = \pm 1.
$$
Since $\dfrac{1 - a}{a} = 1 \Leftrightarrow a = \dfrac{1}{2}$ and $\dfrac{1 - a}{a} = -1 \Leftrightarrow 1 - a = -a$, then $a = \dfrac{1}{2}$.

From this it can be proved that $f = F'$ is a linear function.
