A function with the following properties is always bounded, uniformly continuous, and if $\exists \lim_{x\to \infty} f(x)$ then $f$ is constant. Let $f: \mathbb{R} \to \mathbb{R}$ be a continuous function with the following property: Given $\epsilon > 0$, there exists a positive real number $r > 0$ and a set $D \subset \mathbb{R}$ such that

*

*Any interval $I$ with length $r >0$, is such that $D \cap I \ne \emptyset$

*$|f(x+t) - f(x)| < \epsilon$ for any $t \in D$ and $x\in \mathbb{R}$
Show that a function with those properties is always bounded, uniformly continuous, and if $\exists \lim_{x\to \infty} f(x)$ then $f$ is constant.

I've been stuck trying to prove this for a while. I think that any $f$ is a periodic function, like $\sin$, and that would imply that it is bounded and that if $\exists \lim_{x\to \infty} f(x)$ then $f$ is constant. But I don't know how to show that $f$ is periodic, nor if it is the best approach for this proof.
 A: This is a partial answer.
I prove only the last statement: if $\lim_{x \to \infty} f(x)$ exists, then $f$ is constant. The proof is by contradiction.
Suppose $f$ is not constant, and pick two distinct real numbers $x_0$ and $y_0$ such that
$$f(x_0) < f(y_0)$$
Call $3A = f(y_0) - f(x_0)$, which is a positive real number. Moreover, denote by $L= \lim_{x \to \infty} f(x)$.
By our assumption on $f$, for all $\varepsilon >0$ there exists $D( \varepsilon ) \subseteq \Bbb R$ and $r( \varepsilon) >0$ such that the two conditions are satisfied.
Consider for all $n \ge 0$ the sets
$$D_n = D( A 3^{-n} )$$ and the positive real numbers
$$r_n = r( A 3^{-n} )$$
Moreover, we construct a sequence $(x_n, y_n) \in \Bbb R^2$ recursively, starting from $(x_0,y_0)$ previously defined, and with the property that

*

*$x_n, y_n \in D_n$

*$x_{n+1}> x_n+1$ and $y_{n+1}>y_n+1$ (this is always possible, since $D_n$ is unbounded)

Note that $\lim_{n \to \infty} x_n = + \infty$ and $\lim_{n \to \infty} y_n = + \infty$.
Now we are ready to construct our contradiction. For all $n \ge 1$ you have
$$|f(x_0 + x_n) - f(x_0) | = \left| \sum_{k=1}^{n-1} f(x_0+x_{k+1}) - f(x_0 + x_k)  + (f(x_0 + x_1) - f(x_0))\right| \le$$
$$ \le \sum_{k=1}^{n-1} |f(x_0+x_{k+1}) - f(x_0 + x_k)|  + |f(x_0 + x_1) - f(x_0)| \le$$
$$ \le \sum_{k=1}^{n-1} |f(x_0+x_{k+1})- f(x_0)| + |f(x_0)- f(x_0 + x_k)|  + |f(x_0 + x_1) - f(x_0)| \le$$
$$ \le \sum_{k=1}^{n-1} A 3^{-(k+1)} + A 3^{-k}  + A 3^{-1} \le \sum_{k=1}^{\infty} A 3^{-(k+1)} + A 3^{-k}  + A 3^{-1} = A$$
With a similar method we can prove that
$$|f(y_0 + y_n) - f(y_0) | \le A$$
Taking the limit as $n \to \infty$ we get
$$|L - f(x_0)| \le A , \ |L - f(y_0)| \le A$$ thus
$$3A= |f(y_0) - f(x_0)| \le |L - f(x_0)| + |L - f(y_0)| \le 2A$$
A contradiction.
My argument relies on picking smaller and smaller $\varepsilon_n$, such that the series of all $\varepsilon_n$ is smaller than one fixed constant we need.
Since $f$ is not too far from $f(x_0)$ somewhere far from $x_0$ and the same holds for $y_0$, you can get a contradiction in this way.
I think that proving $f$ is bounded and uniformly continuous uses the same argument. Maybe one can show that $f$ is Lipschitz too.
A: To show that $f$ is bounded, take $\epsilon = 1$ (or any other number), and get the associated $r$ and $D$. Since $f$ is continuous, it is bounded on the interval $[0, r]$ -- call a possible bound $M$. Then for any $x \in \mathbb R$, we can find $t \in D \cap [-x, -x + r]$, so that
$$
|f(x)| = |f(x) + f(x+t) - f(x+t)| \leq |f(x + t)| + |f(x) - f(x+t)| \leq M + 1.
$$
Thus $f$ is bounded by $M+1$.
To show that $f$ is uniformly continuous, let $\epsilon$ be arbitrary. Now get $r, D$ associated to $\epsilon/4$. Since $f$ is continuous, it is uniformly continuous on $[0, r + 1]$, and we can find a $\delta < 1$ such that for any $x, y \in [0, r + 1] $ we have that $|x-y| < \delta \implies |f(x) - f(y)| < \epsilon/4$. We claim that this $\delta$ works to show uniform continuity for $f$ for our original $\epsilon$. To this end, take $x, y \in \mathbb R$ with $|x - y| < \delta$. Again take $t \in D \cap [-x, -x + r]$, so that
$$
|f(x) - f(y)| \leq |f(x) - f(x+t)| + |f(x + t) - f(y + t)| + |f(y + t) - f(y)| \leq \frac\epsilon4 + \frac\epsilon4 + \frac\epsilon4 < \epsilon.
$$
Together with Crostul's partial answer, this answers the question.
A: This should be a comment except that it is much too long. I will answer the sub-(sub-)question of whether $f$ is necessarily periodic in the negative; that is, we will construct an $f$ that satisfies the constraints but is not periodic.
First, define $f_0 : \mathbb Z \to \mathbb R$ by setting
$$
f_0(n) = \begin{cases} 0 & \text{if $n = 0$;}\\
2^{-k} & \text{if $n \neq 0$ and $2^k$ is the largest power of two dividing $n$}.
\end{cases}
$$
Then we extend $f_0$ to a function $f: \mathbb R \to \mathbb R$ by linear interpolation on each interval $[k, k+1]$. Note that $f$ is not periodic: $f(x) = 0 \iff x = 0$.
Now let us prove that it satisfies the hypotheses of the problem. Let $\epsilon > 0$ be given, and take $K$ so that $2^{-K} < \epsilon$. Then I claim that taking $D = \{m2^K \mid m \in \mathbb Z\}$ and $r$ any number greater than $2^K$ works. Clearly $r$ is large enough, so it remains to prove that for $x \in \mathbb R$ and $t \in D$, we have $|f(x + t) - f(x)| < \epsilon$. Since $t$ is an integer, the fractional parts of $x + t$ and $x$ are identical. Since $f$ is defined for non-integral arguments by linear interpolation, if $|f(x+t) - f(x)|$ exceeds $\epsilon$, then so does at least one of $|f(\lfloor x + t\rfloor) - f(\lfloor x \rfloor)|$ and $|f(\lceil x + t\rceil) - f(\lceil x \rceil)|$, so without loss of generality we can take $x$ to be an integer, too.
Let $x = j2^k$ with $j$ odd. Then the largest power of two dividing $x + t = j2^k + 2^K$ is the minimum of $k$ and $K$. If it is equal to $k$, then $f(x) = f(x + t)$. If it is equal to $K$, then $K < k$, so $2^{-K} > 2^{-k}$, and
$$
|f(x + t) - f(x)| = |2^{-K} - 2^{-k}| \leq 2^{-K} < \epsilon.
$$
