If $f(f(f(x)))+f(x)=2$ for all $0≤x≤2$ then find $\int_0^2 f(x) dx$ 
If $f(f(f(x)))+f(x)=2$ for all $0≤x≤2$, where $f(x)$ is a continuous function, then find $\int_0^2 f(x) dx$

Substitute $f(x)=2-t$ to get $$\begin{equation} f(f(2-t))=t \end{equation}$$
Take inverse on both sides and then integrate from $0$ to $2$
$$\int_0^2f(2-t)=\int_0^2f^{-1}(t)$$
On the other hand, substituting $f(f(x))=z$ in original equation gives $$f(z)=2-f^{-1}(z)$$
Putting the value of $f^{-1}(z)$ back we can solve for $\int_0^2 f(x) dx=2$
My solution gave me the right answer, but it's clearly wrong because 1) the range of $f(x)$ or $f(f(x))$ need not be a subset of the domain and 2) inverse of $f(x)$ may not exist. Also, the given data $0≤x≤2$ seems to be superfluous here. So what is the proper way of doing it?
 A: $f$ is not invertible. Consider
$$f(f(f(x)))=2-f(x)$$
and suppose $f$ is increasing on $[0,2]$. Then
\begin{align*}
f(f(f(0)))<f(f(f(2))),\quad 2-f(0)>2-f(2)
\end{align*}
Conversly, suppose $f$ is decreasing on $[0,2]$. Then
\begin{align*}
f(f(f(0)))>f(f(f(2))),\quad 2-f(0)<2-f(2)
\end{align*}
It leads contradiction, so $f$ cannot increase or decrease on $[0,2]$. There's a trivial solution $f(x)=1$ to the functional equation that has
$$\int_0^2 f(x)dx=2$$
And I'm not sure that there exists other function satisfying the equation.

Edit:
We can prove $f(x)=1$. Suppose $f$ is a function defined in closed interval $[0,2]$. If $y$ is in range of $f$, then $2-y$ is also in range of $f$ by
$$f\circ f\circ f(x)=2-f(x).$$
Since continuous function maps closed interval to closed interval
$$f([0,2])=[1-p,1+p]$$
for $0\leq p$. Then suppose $0<p$ and consider $f:[1-p,1+p]\to[1-p,1+p]$. Then following holds.
$$f\circ f(x)=2-x$$
Note that $f$ is invertible since
$$f\circ f\circ f\circ f(x)=x\quad\Rightarrow\quad f^{-1}(x)=f\circ f\circ f(x)$$
We already verified that $f$ is not invertible, so $p=0$, that is $f$ is constant.
