a) Let f be the function where f(0)=0 and f(x) is the largest power of 2 dividing 2x for x=0. The integer 0 is evidently f-rare, so it remains to verify the functional equation.
Since f(2x)=2f(x) for all x, it suffices to verify the functional equation when at least one of x and y is odd (the case x=y=0 being trivial). If y is odd, then we have
f(f(x+y)+y)=2=f(f(x)+y)
since all the values attained by f are even. If, on the other hand, x is odd and y is even, then we already have
f(x+y)=2=f(x)
from which the functional equation follows immediately.
b) An easy inductive argument (substituting x+ky for x) shows that
f(f(x+ky)+y)=f(f(x)+y)
for all integers x, y and k. If v is an f-rare integer and a is the least element of Xv, then by substituting y=a−f(x) in the above, we see that
f(x+k⋅(a−f(x)))−f(x)+a∈Xv
for all integers x and k, so that in particular
f(x+k⋅(a−f(x)))⩾f(x)
for all integers x and k, by assumption on a. This says that on the (possibly degenerate) arithmetic progression through x with common difference a−f(x), the function f attains its minimal value at x.
Repeating the same argument with a replaced by the greatest element b of Xv shows that
f(x+k⋅(b−f(x)))⩽f(x)
for all integers x and k. Combined with the above inequality, we therefore have
f(x+k⋅(a−f(x))⋅(b−f(x)))=f(x)
for all integers x and k.
Thus if f(x)=a,b, then the set Xf(x) contains a nondegenerate arithmetic progression, so is infinite. So the only possible f-rare integers are a and b.
In particular, the f-rare integer v we started with must be one of a or b, so that f(v)=f(a)=f(b)=v. This means that there cannot be any other f-rare integers v′, as they would on the one hand have to be either a or b, and on the other would have to satisfy f(v′)=v′. Thus v is the unique f-rare integer.