Let $f: R \to R$ be a function such that the closure of its graph contains as a subset the graph of a uniformly continuous function. Does there exist a dense subset $S$ of $R$ such that the restricted function $fS: S \to R$ is uniformly continuous?

1$\begingroup$ If $f_S$ is uniformly continuous then it can be natuarlly extended to a uniformly continuous function on the closure of $S$. Hence $f$ itself has to be uniformly continuous. If you weaken the assumption to "there is a sequence of sets $S_n$ such that their union is dense in $R$ and f restricted to $S_n$ is uniformly continuous on $S_n$" then it's true for measurable functions by Lusin's Theorem. $\endgroup$ – Martin Kell Dec 26 '18 at 16:27

1$\begingroup$ @MartinKell: It's true that $f_S$ will extend to a uniformly continuous function (call it $g$), but $f$ need not agree with $g$ on $S^c$, so we cannot conclude that $f$ is uniformly continuous. $\endgroup$ – Nate Eldredge Dec 26 '18 at 16:44
Consider the following modification of the Dirichlet "popcorn" function: $$f(x) = \begin{cases} 1/q, & \text{$x \in \mathbb{Q}$, $x=p/q$ in lowest terms} \\ 1, & x \notin \mathbb{Q},\, x < 0 \\ 2, & x \notin \mathbb{Q}, \, x > 0.\end{cases}$$ Since every real number can be approximated by rationals with arbitrarily large denominator, the closure of the graph of $f$ contains the $x$axis, which is the uniformly continuous function $0$.
Let $S \subset \mathbb{R}$ be dense. If $f_S$ is uniformly continuous, then it extends to a unique uniformly continuous function $g$ on all of $\mathbb{R}$, and we have $f=g$ on $S$.
If $S$ contains a negative irrational number $x$, then $g(x) = f(x) = 1$. Let $y$ be any positive number in $S$. If $y$ is rational, we have $g(y) = f(y) = 0$. Then by the continuity of $g$, there would have to be some $z \in S$ with $f(z) = g(z) \in (3/4, 1/4)$ which is impossible. If $y$ is irrational, we get a similar contradiction since $g(y) = f(y) = 2$. So $S$ does not contain any negative irrational. Similarly, $S$ does not contain any positive irrational.
So we must have $S \subset \mathbb{Q}$. But this is similarly impossible. The rationals in $S$ cannot all have the same denominator (in lowest terms), so let $x_1 = p_1/q_1, x_2 = p_2/q_2 \in S$, where $q_1 < q_2$. Then by the continuity of $g$ there must be some $y \in S$ with $f(y) = g(y) \in (\frac{1}{q_1}, \frac{1}{q_1+1})$, but $f$ never takes on any such value.

$\begingroup$ Slight simplification of the proof: $S$ cannot contain a single rational number, since $f$ is discontinuous at every rational, hence so is $f_S$ for any dense $S$. Thus $S\subseteq\mathbb R\setminus\mathbb Q$, but then we have problems around $0$. $\endgroup$ – Wojowu Dec 26 '18 at 17:08

2$\begingroup$ @Wojowu: It's not quite that simple, I think. For instance, the function $f=1_\mathbb{Q}$ is discontinuous at every rational (and every irrational), but its restriction to $S=\mathbb{Q}$ is uniformly continuous. So the fact that $f$ is discontinuous at the rationals doesn't immediately rule out the possibility for $S$ to contain rationals. We would have to work a little harder. I guess the key is that $f$ has a "jump" discontinuity at every rational. $\endgroup$ – Nate Eldredge Dec 26 '18 at 17:16

$\begingroup$ You are right, I was a little too quick there. We can either use jump discontinuity as you mention, or we can observe $(q,f(q))$ is an isolated point of the graph. $\endgroup$ – Wojowu Dec 26 '18 at 17:24

$\begingroup$ @მამუკაჯიბლაძე: Yes, thank you. Fixed. $\endgroup$ – Nate Eldredge Dec 27 '18 at 15:49