Something that isn't continuous can be proven to be continuous (so it is continuous - definitions - but doesn't look it!)

I'm sorry to post this, either I am right and it is continuous, or because I am on $\mathbb{Q}$ not $\mathbb{R}$ that saying "if that delta works, any smaller delta will!" (which can be proven by by some * value theorem) does not work.

Consider this, now I was trying to prove it isn't continuous, I am now convinced it is. $f:\mathbb{Q}\rightarrow\{1,2\}$ (I chose 1 and 2 to make the sketch nicer) given by $f(x)=1$ if $x<\sqrt{2}$ and $f(x)=2$ otherwise/$x>\sqrt{2}$ - it is important that this change happen about a number in $\mathbb{R}$ but not $\mathbb{Q}$.

Now I remember when proving the continuity of 1/x over a year ago, I learnt that it is helpful (necessary) to bound delta above when you have points of discontinuity, this stops it getting too close, it also keeps it to one side of the discontinuous point.

I seek to prove $\forall\epsilon>0\exists\delta>0:|x-a|<\delta\implies|f(x)-f(a)|<\epsilon$ to mean continuous at $a$.

Now that upper bound I mentioned, because this function is flat I don't need to find a smaller delta that's a function of epsilon and take the minimum. The proof is trivial.

Let $\delta=|\sqrt{2}-a|$, now if $|x-a|<\delta$ I am saying in words "The distance from x to a is less than the distance from a to that nasty point" which means $x\in(a-\delta,a+\delta)$ which is clearly a ... chunk of the domain either entirely before that $\sqrt{2}$ or after.

On this $f(x)-f(a)=0$ which is less than $\epsilon$ for all $\epsilon>0$, thus I have proved that this function is continuous. EVEN though it has a jump in it! It is continuous on $\mathbb{Q}$

What I think I have learnt

I think I have learnt that while 1 and 2 seem far apart for real numbers, or even fractions, in the set {1,2} there is no middle value. So the jump is not actually a jump at all.

With this I am not sure if the $\sqrt{2}$ thing is actually significant. If we had a function that was 1 if $x\le\frac{1}{2}$ say, else 2. does this have the "no-jump" quality? I can see a case for no, if $\epsilon<1$ then no it cannot be continuous, because there can be a change near $x=\frac{1}{2}$ by a value of more than one, no matter how small $\delta$ (at x=0.5).

HOWEVER it might be yes. If you say "the change must be -1,0 or 1" thus confining $\epsilon$ to take 1, it is still no (as 1 is not less than 1) but one could question whether it is fair to try and impose this "less than" on {1,2} in this way. If it ever changes there can be no smaller jump. I am reading about the issue, I'm posing this because my foundations have somewhat crumbled, I'd like some help patching them back up.

My apologies for the naff format/style of this question, it suffers from me thinking about what I am writing and flicking between several different ways and making sure it is consistent. I've read it twice and it is awful, but I cannot think how else to phrase it.

-
I think you are taking $\{1,2\}$ a bit too literally. The question is merely to study the function $f:\mathbb{Q}\to\mathbb{R}$ whose range (i.e. image) happens to be $\{1,2\}$. – user72694 Mar 23 '14 at 15:02
@user72694 I made the question up. That is a source of my confusion though, I do "sort of" realise that in the end. I do see no reason though why the function cannot take it to $\{1,2\}$ or $\{a,b\}$ or $\{\text{triangle},\text{square}\}$ for that matter, I can order these, "a" comes before "b", a triangle has less edges than a square.... – Alec Teal Mar 23 '14 at 15:04
@Peter yes, that's the definition, I see that BUT it jumps. I keep wanting to fall back on intuition, if I had a magic pen that only drew on points in $\mathbb{Q}$ I'd have to lift the pen! Depending on how you see $\{1,2\}$ of course. – Alec Teal Mar 23 '14 at 15:10
Does the function really have a jump at any rational point x = a ? Assume $a<\sqrt(2)$. then there exists a rational number b>a with $b<\sqrt(2)$. An analogue argument holds for $a>\sqrt(2)$. So at which RATIONAL point does the function have a jump ? – Peter Mar 23 '14 at 15:10
@Peter I see that, I did the proof, but the jump is not imaginary, for all the theorems I know, I cannot use any of them in this - which is really annoying. – Alec Teal Mar 23 '14 at 15:13

Your proof is correct. The function $f$ is continuous, and your argument that "if this $\delta$ works then so will any smaller $\delta$" is perfectly sound.

This example does tend to challenge people's intuition about continuity. One way I like to think about it is that continuity is a pointwise property. If you want to claim that a function $f : X \to Y$ is not continuous, you have to exhibit a point $x \in X$ where that discontinuity occurs. Here with $X = \mathbb{Q}$, you would like to say the discontinuity occurs at $x = \sqrt{2}$, but of course that isn't a point of $\mathbb{Q}$. Indeed, there's no point of $\mathbb{Q}$ where a discontinuity occurs, so the function must be continuous.

One way of addressing this issue is via the concept of uniform continuity. It would be a good exercise to show that, although your function $f$ is continuous, it is not uniformly continuous. Indeed, another great exercise is to show that a function $f : \mathbb{Q} \to \mathbb{R}$ is uniformly continuous if and only if it has a continuous extension to $\mathbb{R}$, i.e., $f = g|_{\mathbb{Q}}$ for some continuous $g : \mathbb{R} \to \mathbb{R}$. In some sense, uniform continuity is able to detect jumps that occur at "holes" in the domain.

-
Please do reply to the book thing in the question's comments. I have to ask because I don't want to post a separate question, is it true that $f:\mathbb{N}\rightarrow(\text{anything})$ is continuous? If I pick a delta < 1 the "proof" follows. – Alec Teal Mar 23 '14 at 15:27
@AlecTeal: Yes indeed, every function on $\mathbb{N}$ is continuous (and even uniformly continuous). – Nate Eldredge Mar 23 '14 at 15:30
For a function over the natural numbers, does it make sense to define a delta ? As I understood, the function must be defined for the point "near" the desired one. Otherwise, the values cannot be compared (because one of them is not defined). Or did I miss something ? – Peter Mar 23 '14 at 15:39
@Peter: I'm not sure what precise definition of continuity you are working with (authors vary). You could post it if you like, but if you inspect it carefully I think you will find that every function on $\mathbb{N}$ is continuous. – Nate Eldredge Mar 23 '14 at 16:35
@Peter: In general, a function is continuous iff the preimage of every open set is open. In the sense of taking the open sets as unions of open intervals around the points (which is implied in the $\epsilon-\delta$ def.), all singletons $\{n\}$ are open--and so all subsets of $\mathbb{N}$ are open. This is an example of a discrete topology, and every function from a discrete topological space to any other topological space is continuous. If the topology on $\mathbb{N}$ is taken to be something else, not all functions from it will be continuous. – Stan Liou Mar 23 '14 at 21:12

A more simple-minded example to illustrate the point is the function $f(x)=\frac{1}{x}$. Note that $f$ is continuous at every point where it is defined. If you insist on assigning a value to $f$ at the origin, the resulting function will necessarily be discontinuous. Similarly the function you mentioned is continuous everywhere it is defined. If you assign a value to it at $\sqrt{2}$ it will become discontinuous.

Edit 1. I just noticed that @JiK made the same point in a comment. If you wish you can format your comment as an answer and I will delete mine.

-