A function continuous and bounded on a closed and bounded set but not uniformly continuous there

I'm reading 'Counterexamples in analysis by Bernard Gelbaum' which has this as one the counterexample
Function is defined on $\Bbb{Q}$$\cap$$[0,2]$ which is closed and bounded set

$f(x) = \begin{cases} 0, & \text{if 0$\lex\lt\sqrt2$} \\ 1, & \text{if$\sqrt2\ltx\le$2 } \end{cases}$

I concluded that it is a continuous function since co-domain is {${0,1}$} and $f^{-1}$ {$0$} and $f^{-1}${$1$} are closed in $\Bbb{Q}$$\cap$$[0,2]$ ( i. e. inverse image of closed sets is closed and hence $f$ is continuous ) but I'm facing trouble in proving that it is not uniformly continuous. Please help.

Also author mentioned that field $\Bbb{Q}$ is not complete and hence we can have such example . If possible then please explain this point also.

• If the field was complete (e.g. $\mathbb{R}$) continuous function on a closed bounded interval must be uniformly continuous – user160738 Nov 19 '16 at 18:18
• I know this property of complete fields but my question is about fields like $\Bbb{Q}$ which are not complete, why these kind of properties do not hold for such fields. – Math_Explorer Nov 19 '16 at 18:25
• Title needs changing. We are not on an interval. Also $\mathbb Q \cap [0,2]$ is not closed in $\mathbb R.$ In what sense is it closed? – zhw. Nov 19 '16 at 18:44
• @zhw. $[0,2] \cap \Bbb Q$ is closed in $\Bbb Q$. :) – Error 404 Nov 20 '16 at 3:51
• @zhw. I changed the title. Thanks for noticing it. And as Vikrant Desai has mentioned $[0,2]$$\cap$$\Bbb{Q}$ is closed in $\Bbb{Q}$ . :) – Math_Explorer Nov 20 '16 at 5:12

Well some minute points regarding continuity of $f$:

You also need to verify that inverse image of all the opens sets viz.$\{\{0\},\{1\},\{0,1\},\emptyset\}$ are all open .

Regarding uniform continuity of $f$:

Since $\Bbb Q$ is dense ,there exists a sequence $x_n\in [0,\sqrt 2]\cap \Bbb Q$ such that $x_n\to \sqrt 2\implies |x_n-\sqrt 2|<\frac{1}{n}\forall n$.

Similarly since $\Bbb Q$ is dense ,there exists a sequence $y_n\in [\sqrt 2,2]\cap \Bbb Q$ such that $y_n\to \sqrt 2\implies |\sqrt 2-y_n|<\frac{1}{n}\forall n$.

Hence $|x_n-y_n|\le |x_n-\sqrt 2|+|\sqrt 2-y_n|\le \frac{1}{n}\forall n$ but $|f(x_n)-f(y_n)|=1$.

NOTE:Since $\Bbb Q$ is not complete hence it has gaps and always such an example is available

• Thank you so much for pointing out those minute points about continuity. I think each of the set in { {$0$}, {$1$}, {$0$,$1$},$\phi$ } is both open and closed, and their inverse images are also both open and closed in $\Bbb{Q}$ $\cap$ $[0,2]$ ( by subspace topology). I understood your explanation about uniform continuity. You mentioned that always such examples are available for $\Bbb{Q}$. Can you please share the link of any such example which shows properties of complete fields are not valid for fields which are not complete. :) – Math_Explorer Nov 20 '16 at 5:37
• Extremely sorry but I don't have a link to share at this moment. – Learnmore Nov 20 '16 at 5:41
• Okay ! No problem ! I was curious to know the results which are valid only for complete field and not for fields like $\Bbb{Q}$. :p – Math_Explorer Nov 20 '16 at 5:45
• Well you can do one thing .Just open any book on "Metric Spaces" and read the chapter titled "Completeness";I think you will get many properties about Complete Metric Spaces there – Learnmore Nov 20 '16 at 5:49
• Thank you ! I will definitely read it . :) – Math_Explorer Nov 20 '16 at 6:00

Your proof for continuity is correct.

Suppose $f$ is uniformly continuous.

Let $d$ be the metric on $[0,2] \cap \Bbb Q$ which is induced from usual metric on $\Bbb R.$

Let $\epsilon = \frac 12$. Then $\exists \delta \gt 0$ such that $d(x,y) \lt \delta \implies |f(x)-f(y)| \lt \frac 12 \; \forall x,y \in [0,2] \cap \Bbb Q.$

Now if we take $x \in [0, \sqrt{2}] \cap \Bbb Q$ and $y \in [\sqrt{2},2] \cap \Bbb Q$ such that $d(x,y) \lt \delta$, then $|f(x)-f(y)|=|0-1|=1 \not\lt \frac 12.$

So our assumption that $f$ is uniformly continuous is false.