<s>[INST] Find all functions $f$ such that $f(x-f(y)) = f(f(x)) - f(y) - 1$ Find all functions $f : \mathbb{Z} \to \mathbb{Z}$ such that $f(x-f(y)) = f(f(x)) - f(y) - 1$. 
So far, I've managed to prove that if $f$ is linear, then either $f(x) = x + 1$ or $f(x) = -1$ must be true. I did this by plugging in $x=0$ to the above equation, which yields
$$ f(-f(y)) = f(f(0)) - f(y) - 1$$
and plugging in $x$ instead of $y$ and subtracting, this becomes
$$ f(-f(y)) - f(-f(x)) = f(x) - f(y)$$
Assuming $f(x) = ax + b$ then gives
\begin{align*}
f(-ay-b) - f(-ax-b) = ax - ay &\Rightarrow -a^2y - ab + a^2x + ab = a(x-y) \\&\Rightarrow a^2(x-y) = a(x-y) .
\end{align*}
Thus $a=1$ or $a=0$. If $a=0$, then the original equation becomes $b = b - b - 1$, thus $b=-1$. If $a=1$, the original equation becomes
$$ x-y-b+b = x+2b-y-b-1 \Longrightarrow b=1.$$
I briefly tried finding a quadratic function that works but didn't find anything. So my question is: how can I either show that $f$ must be linear or find all other representations?
 [/INST] Let $f\colon \Bbb Z\to \Bbb Z$ be a any function function with $$\tag0f(x-f(y)) = f(f(x)) - f(y) - 1$$
for all $x,y\in\Bbb Z$.
Letting $y=f(x)$ we find $$f(x-f(f(x)))=-1. $$
So for $a=-f(f(0))$ we have $f(a)=-1$. Then with $y=a$, $$\tag1f(x+1)=f(f(x)) $$
Then $(0)$ becomes
$$\tag2 f(x-f(y))=f(x+1)-f(y)-1 $$
Or with $g(x):=f(x)+1$ (and $x\leftarrow x-1$)
$$\tag3g(x-g(y))=g(x)-g(y)$$
From $(3)$ we see that the image of $g$ is a subgroup of $\Bbb Z$, hence it is either $\{0\}$ (in which case $f(x)=-1$), or $c\Bbb Z$ for some $c\ge 1$.
In that case,  for $n\in\Bbb Z$ we find $y$ with $g(y)=nc$ and so have $g(x+ nc)=g(x)+nc$. Thus  $g$ is determined by the values $g(0),\ldots, g(c-1)$. On the other hand, these values can indeed be chosen freely. In other words:
Claim 1. Let $c\in\Bbb N$ and $b_0,\ldots, b_{c-1}\in\Bbb Z$. Then the function $g$ given by 
$$ g(x)= (n+b_r)c$$
where $x=nc+r$, $0\le r<c$
is a solution to $(3)$, and all non-zero solutions of $(3)$ are obtained this way.
Proof.
Let $x=nc+r$, $y=mc+s$ with $0\le r,s<c$. Then 
$$\begin{align}g(x-g(y))&=g(nc+r-(m+b_s)c)\\
&=g((n-m-b_s)c+r)\\
&=(n-m-b_s+b_{r})c\\
&=(n+b_r)c-(m+b_s)c\\&=g(x)-g(y)\end{align}$$
That all non-zero solutions are of this form has been shown above. $\square$
Then the solutions $f$ of $(2)$  (apart from $f(x)=-1$) are precisely those of the form $f(x)=g(x)-1$ with $g$ as in Claim 1.
Such $f$ is a solution to the original $(0)$ if and only if we additionally have $(1)$ for all $x$.
Note that for $x=nc+r$, $0\le r<c$, we have $f(x)=g(x)-1=(n+b_r)c-1=(n+b_r-1)c+c-1$ so that $$f(f(x))=(n+b_r-1+b_{c-1})c-1.$$ 
On the other hand, 
$$f(x+1)=g(x+1)-1=\begin{cases}(n+b_{r+1})c-1&\text{if }r<c-1\\(n+1+b_0)c-1&\text{if }r=c-1\end{cases}$$
We conclude that $b_{r+1}=b_r+b_{c-1}-1$ for $0\le r<c-1$, and that $2b_{c-1}-1=b_0+1$. From the first we see that $b_r=b_0+rb_{c-1}-r$, so 
$$\begin{align}b_{c-1}&=b_0+1+(c-1)b_{c-1}-c\\
&=2b_{c-1}-1+(c-1)b_{c-1}-c\\
&=(c+1)b_{c-1}-c-1\end{align}$$ and finally
$$b_{c-1} = \frac {c+1}c.$$
This is an integer only for $c=1$ and in that case we arrive at $b_0=2$
Thus the only solutions to $(0)$ apart from $f(x)=-1$ is
$$f(x)=x+1.$$
</s>