IMO 2017: Determine all functions $f: \mathbb{R} \to\mathbb{R}$ such that, for all real numbers $x$ and $y$, $f(f(x)f(y)) + f(x +y) = f(xy)$. 
EDİT: I think I've repair the error in the solution. I want to know if I'm fixing it properly. I'm just a student, not a mathematician. Please focus on the "backbone" of my writing. 

I want to prove that, the following substitution is correct:

$$ x\mapsto f^{-1}(x)$$

Statement: For a function to have an inverse, each element $y ∈ Y $ must correspond to no more than one $x ∈ X; $a function $f$ with this property is called one-to-one or an injection.
The function $f(x)$  is an injective and $f$ is an invertible function. In other words, if $f(0)≠0$, for function $f(x)$, the inverse function $f^{-1}(x)$ is exist.
$f(x)=f(0)-\frac {x}{f(0)} \Rightarrow f^{-1}(x)=f(0)(f(0)-x)$ and  $f(f^{-1}(x))=x$ for all $x\in\mathbb {R}$. For this reason, we can applying the substitution $ x\mapsto f^{-1}(x), x\in\mathbb{R}.$
For example:
If $f(f(x))=f(x)-5 , x\in\mathbb{R}$, then  $f(x)=x-5$ must be. Because,  the function $f(x)$  is an injective and $f$ is an invertible function. Applying  $x\mapsto f^{-1}(x)$ we have $f(x-5)=x-10 \Rightarrow f(x)=x-5.$
I hope you can understand what I mean. Can you tell me that this approach is wrong or true? 

Problem:  Let $\mathbb{R}$ be the set of real numbers. Determine all functions $f:  \mathbb{R} \to\mathbb{R}$ such that, for all real numbers $x$ and $y$, $$f \big(f(x)f(y)\big) + f(x +y) = f(xy).$$ 

I ask You to confirm that the solution is sufficient / insufficient / missing / incorrect or correct. Here is my attempts: 

Are there any problems in my substitutions?



 A: I know that this is more of a comment than an answer to the question, but it is too long. 
 Here is the error in the OP's logic.  Injectivity does not imply having an inverse.  Being both injective and surjective does.  Here is a counterexample to the OP's claim that $f(x)$ can be replaced by $x$ if $f$ is injective.  
For a nonnegative integer $k$, let $t_k$ denote $\left\lfloor\dfrac{(-1)^kk}{2}\right\rfloor$.  Then, every integer appears as $t_k$ for exactly once $k\in\mathbb{Z}_{\geq0}$.  Thus, for each $n$, we write $\tau(n)$ for the unique $k\in\mathbb{Z}_{\geq 0}$ such that $n=t_k$.  In other words,
$$\tau(n)=\begin{cases}2n&\text{if }n\in\mathbb{Z}_{\geq 0}\,,\\-2n-1&\text{if }n\in\mathbb{Z}_{<0}\,.\end{cases}$$ 
(Well, I should have started with defining $\tau$ instead of $\left\{t_k\right\}_{k\in\mathbb{Z}_{\geq 0}}$.)
Now, let $f:\mathbb{R}\to\mathbb{R}$ be defined as
$$f(x)=x-\lfloor x\rfloor+\tau\big(\lfloor x\rfloor \big)\tag{*}$$
for every $x\in\mathbb{R}$.  Observe that $f$ is injective and
$$f\big(f(x)\big)=f(x)+\big\lfloor f(x)\big\rfloor$$
for each $x\in\mathbb{R}$.   (Certainly, $f$ is not surjective because the range is $\mathbb{R}_{\geq 0}$, and not the whole $\mathbb{R}$.)  
However, it is not correct to say that
$$f(x)=x+\lfloor x\rfloor$$
for all $x\in\mathbb{R}$.   This is because $f(-1)=\tau(-1)=1$ by (*), so $$f(-1)\neq -2=(-1)+\big\lfloor (-1)\big\rfloor\,.$$

A possible remedy is given here.  As Zvi said, if $f$ satisfies the functional equation, then so does $-f$.  Thus, in the case $f(0)\neq 0$, it suffices to assume that $f(0)=-1$.  From the OP's work, we have
$$f\big(f(x)\,f(0)\big)+f(x)=f(0)\text{ for all }x\in\mathbb{R}\,.$$
As $f(0)=-1$, we get
$$f\big(-f(x)\big)+f(x)=-1\text{ for all }x\in\mathbb{R}\,.\tag{*}$$
This shows that
$$f\Big(-f\big(-f(x)\big)\Big)+f\big(-f(x)\big)=-1\text{ for all }x\in\mathbb{R}\,.\tag{#}$$
From  (*) and (#), we see that
$$f\Big(-f\big(-f(x)\big)\Big)=f(x)\text{ for each }x\in\mathbb{R}\,.\tag{$\star$}$$
Here is where we can use Zvi's result that $f$ is injective.  Since $f$ is injective, ($\star$) implies that
$$-f\big(-f(x)\big)=x\text{ for each }x\in\mathbb{R}\,.\tag{@}$$
Together with (*), we have
$$-x+f(x)=f\big(-f(x)\big)+f(x)=-1\,,$$
whence
$$f(x)=x-1\text{ for all }x\in\mathbb{R}\,.$$
Note that (@) also implies that $f$ is surjective.  This provides an alternative route as it allows substituting $x$ for $f(x)$ in (*) to get $f(-x)+x=-1$, or $f(-x)=-x-1$ for all $x\in\mathbb{R}$.  Thus, we also arrive at $f(x)=x-1$ for all $x\in\mathbb{R}$ in this manner.  I, however, fail to find a way to approach this problem without knowing injectivity of $f$.  It seems to be pivotal to solving the problem.
A: Empy2 pointed out the error in your proof.  You cannot deduce that $f\big(f(x)f(0)\big)+f(x)=f(0)$ for all $x$ implies $f\big(xf(0)\big)+x=f(0)$ for all $x$.  This only works only for $x$ in the range of $f$.  I am presenting a different solution.
If $f(0)=0$, as you showed, we have
$$f(0)+f(x)=f\big(f(x)f(0)\big)+f(x+0)=f(x\cdot 0)=f(0)$$
so $f(x)=0$ for all $x$.  We assume that $f(0)\ne 0$ from now on.  We claim that $f(c)=0$ implies that $c=1$.
Suppose that $f(c)=0$ for some $c\ne 1$.  Then, we have
$$f\Biggl(f(c)f\left(\frac{c}{c-1}\right)\Biggr)+f\left(c+\frac{c}{c-1}\right)=f\Biggl(c\left(\frac{c}{c-1}\right)\Biggr).$$
That is,
$$f(0)+f\left(\frac{c^2}{c-1}\right)=f\left(\frac{c^2}{c-1}\right),$$
or $f(0)=0$, contradicting the assumption that $f(0)\ne 0$.  Therefore, the hypothesis that $c\ne1$ is false.
Now, we note that for every $x\ne1$, 
$$f\Biggl(f(x)f\left(\frac{x}{x-1}\right)\Biggr)+f\left(x+\frac{x}{x-1}\right)=f\Biggl(x\left(\frac{x}{x-1}\right)\Biggr),$$
so
$$f\Biggl(f(x)f\left(\frac{x}{x-1}\right)\Biggr)+f\left(\frac{x^2}{x-1}\right)=f\left(\frac{x^2}{x-1}\right).$$
So,
$$f\Biggl(f(x)f\left(\frac{x}{x-1}\right)\Biggr)=0$$
and we then conclude from our claim above that
$$f\left(\frac{x}{x-1}\right)=\frac{1}{f(x)}\tag{1}$$
for every $x\ne 1$.  In particular, this shows that $f(1)=0$, since there does exist $c$ such that $f(c)=0$.
From (1), we get $f(0)=\pm 1$.  Observe that $f$ is a solution if and only if $-f$ is also a solution.  We can without loss of generality assume that $f(0)=-1$.  Plugging $y\mapsto 1$ in the original functional equation, we have
$$-1+f(x+1)=f(0)+f(x+1)=f\big(f(x)f(1)\big)+f(x+1)=f(x\cdot1)=f(x),$$
or
$$f(x+1)=f(x)+1.\tag{2}$$
By induction, $f(x+n)=f(x)+n$ for all integers $n$.  
Here, we claim that $f$ is injective.  Suppose that $f(u)=f(v)$ for some $u,v\in\mathbb{R}$.  Pick a positive integer $n$ so large that $4(u+n)< (v+n+1)^2$.  Hence, there are two distinct $a,b\in\mathbb{R}$ such that $u+n=ab$ and $v+n+1=a+b$ (since $a$ and $b$ are the roots of the polynomial $t^2-(v+n+1)t+(u+n)$, which have two distinct real roots).  Therefore,
$$f\big(f(a)f(b)\big)+f(a+b)=f(ab)=f(u+n)=f(u)+n.$$
But $f(a+b)=f(v+n+1)=f(v)+n+1=f(u)+n+1$.  That is, by (2), we have $$f\big(f(a)f(b)+1\big)=f\big(f(a)f(b)\big)+1=0.$$  This means $f(a)f(b)+1=1$, or $f(a)f(b)=0$.  Consequently, $f(a)=0$ or $f(b)=0$, which means $a=1$ or $b=1$.  Without loss of generality, $b=1$, so $u+n=ab=a$ and $v+n+1=a+b=a+1$.  That is, $u=a-n=v$.
Now, substitute $y\mapsto 1-x$ in the original functional equation.  We then have
$$f\big(f(x)f(1-x)\big)=f\big(f(x)f(1-x)\big)+f(1)=f\big(x(1-x)\big).$$
Thus, by injectivity,
$$f(x)f(1-x)=x(1-x).$$
Then, we take $y\mapsto -x$ in the original functional equation to get
$$f\big(f(x)f(-x)\big)-1=f\big(f(x)f(-x)\big)+f(0)=f\big(x(-x)\big).$$
Thus,
$$f\big(f(x)f(-x)\big)=f(-x^2)+1=f(-x^2+1)$$
by (2).  By injectivity,
$$f(x)f(-x)=-x^2+1.$$
From (2), we also have
\begin{align}f(x)&=f(x)\Big(\big(f(-x)+1\big)-f(-x)\Big)\\&=f(x)\big(f(1-x)-f(-x)\big)=f(x)f(1-x)-f(x)f(-x),\end{align}
so
$$f(x)=x(1-x)-(-x^2+1)=x-1.$$
It is easy to see that $f(x)=x-1$ is indeed a solution.  Therefore, all solutions are $f(x)=0$, $f(x)=x-1$, and $f(x)=1-x$.
A: The argument beginning with "We will prove that such $x$ exists" is fallacious. You begin by assuming that $k=f(x)$ for some $x$ and you do need that assumption in the following derivation (as otherwise, the functional equation makes no claim about $f(kf(0))$ etc.). At face value, your argument shows

If $k\in\Bbb R$ and there exists $x$ with $f(x)=k$, then one possible such $x$ is $x=f(0)^2-kf(0)$.

In fact, we see immediately that the bolder claim you try make, i.e., 

If $k\in\Bbb R$, then there exists $x$ with $f(x)=k$, namely $x=f(0)^2-kf(0)$.

is false, simply because the non-surjective
$$\tag1f(x)=0\qquad \text{for all }x\in\Bbb R$$
is obviously a solution.

Note that $f(f(0)^2)+f(0)=f(0)$ implies that $0$ is in the image of $f$ (namely $f(x_0)=0$ for $x_0:=f(0)^2$).
Then by setting $y=x_0$, we get
$$ f(0)+f(x+x_0)=f(xx_0)\qquad\text{for all }x.$$
If we find $x$ with $x+x_0=xx_0$, this leads to $f(0)=0$. Indeed, we find such $x$, namely $x=-\frac{x_0}{1-x_0}$ unless $x_0=1$, a case to be treated separately below. 
So we have two cases:


*

*$f(0)=0$. Then with $y=0$, we obtain $f(0)+f(x)=f(0)$, i.e., solution $(1)$.

*$f(0)\ne 0$ and $x_0=1$. Then $f(0)+f(x+1)=f(x)$ and by induction we see that $f(n)=(n-1)a$ with $a:=f(0)$. Then 
$$ f(f(3)f(0)) + f(3+0)=f(3\cdot 0)\iff f(-2a^2)-2a=a$$
and
$$ f(f(-1)f(2)) + f(-1+2)=f((-1)\cdot 2)\iff f(-2a^2)+0=-3a,$$
whence by elimination of $f(-2a^2)$ we get $f(0)=a=0$, contradiction.
We conclude that $(1)$ is the only solution to the functional equation.
