13b) Suppose $f$ is a function that satisfies the intermediate value theorem (IVT), and takes on each value only once. Prove that $f$ is continuous.
Spivak's proof of this problem can be found here:
Spivak's Calculus Chapter 7-13b
(That link is actually a question a I wrote up earlier, but it's not really relevant to this one).
My question is about the "annoying technicalities" in the proof. TLDR: I don't see how they are justified.
Annoying technicality 1) $|f(x)-f(a)|> \epsilon \implies f(x)>f(a) + \epsilon ~~~~~\text{OR} ~~~~f(x)<f(a)- \epsilon$
Annoying technicality 2) $0<|x-a| \implies x>a ~~~~\text{OR} ~~~~x<a$
Let's call "$f(x)>f(a) + \epsilon$" Option A, and "$f(x)<f(a)- \epsilon$" Option B.
Likewise, call "$x>a$" Option C, and "$x<a$" Option D.
Ok so there are 4 Cases: AC, AD, BC, or BD.
Then Spivak says: "Let's pick $f(x)>f(a)+ \epsilon$ and $x>a$" (Presumably without loss of generality). So he picks AC to start, fine.
However, in step (2) he reuses AC to construct the number $z$.
Here's my problem: $z$ is independent of $x$, which means it doesn't have to obey AC, it could obey AD, BC or BD instead.
Fortunately if z obeys AD or BC, then it's easy to adjust Spivak's proof to make the contradiction at the end. However I cannot see a way to do it if z obeys BD (not without making another assumption anyway, which would be very laborious to deal with and will probably lead to infinite descent!).
Can we adjust the proof to make it work when $z$ obeys BD, or is an entirely new approach necessary (or even possible???)?
Update: I have found a solution for the BD case, however it involves an extra 9 cases of analysis and is quite tedious, and definitely not worth adjusting for the other 3 cases when $x$ doesn't obey AC. Fortunately I can use the symmetry of the 4 quadrants to bypass the other 3 cases, by introducing a new function $g$, based on $f$. I pretty sure that's enough to prove the entire theorem, but man it was not easy nor elegant. 3 + 9 + 3 = 15 separate individual cases that all have to be considered . If anyone has a method that can prove the theorem more elegantly I'd like to know. If anyone wants to see my proof, ask below.
Let's assume that $f$ is injective and satisfies IVT on an interval $I$. Let $a, b\in I$ with $a<b$. By injectivity we have either $f(a) <f(b) $ or $f(a) >f(b) $. We consider first case and show that $f$ is strictly increasing on $I$.
First we deal with the behavior of $f$ on interval $[a, b] $. If $a<c<b$ then we can show $f(a) <f(c) <f(b) $. Clearly we can't have $f(a) =f(c) $. Assuming $f(a) >f(c) $ gives us $f(c) <f(a) <f(b) $ and by IVT there is some point in $[c, b] $ at which $f$ takes the value $f(a) $ and gives a contradiction. Thus we must have $f(a) <f(c) $. In similar manner we can prove that $f(c) <f(b) $.
Next let $a< c<d< b$ and we can prove $f(c)<f(d)$. Suppose $f(c)>f(d)$. Then we have $f(d)<f(c)<f(b)$ and IVT gives a point in $(d,b)$ where $f$ takes the value $f(c)$ thereby giving a contradiction. Therefore we must have $f(c)<f(d)$.
It follows that $f$ is strictly increasing on $[a,b]$. If there are any points in $I$ to the left of $a$ or to the right of $b$ we can adapt the same proof to the part of $I$ lying left of $a$ or to the right of $b$ without much hassle (you may give it a try).
Thus $f$ is strictly increasing on $I$.
Next consider a point $c\in I$. Due to the monotone nature of $f$ the limits $f(c+)=\lim_{x\to c^+}f(x), f(c-)=\lim_{x\to c^-}f(x)$ exist (if $c$ is an end point of $I$ only one of these limits makes sense, for a proof see latter half of the answer). We also have $$f(c-) \leq f(c)\leq f(c+)$$ ($f$ is strictly increasing) and we next show that the inequalities above are actually equalities and $f$ is thus continuous at $c$.
If $f(c-) <f(c) $ then the values between these numbers are not taken by $f$ contradicting the IVT property. Same happens for the case $f(c) <f(c+) $.
Let's add a missing piece (based on comment from asker) about the existence of one sided limits of a monotone function.
Let us assume that $f$ is increasing on some interval $I$ and $c\in I$ is an interior point of $I$. Then the one sided limits of $f$ at $c$ namely $f(c-), f(c+) $ exist and we have $$f(c-) \leq f(c)\leq f(c+)$$ To prove this consider the set $$A=\{f(x) \mid x\in I, x<c\}$$ Then $A$ is non-empty and bounded above by $f(c)$. By completeness of real numbers $\sup A$ exists and $\sup A\leq f(c)$. We show that $f(c-)=\sup A$.
Let $\epsilon>0$ be arbitrarily given. By definition of supremum there is a member $b\in A$ such that $$\sup A - \epsilon<b\leq \sup A$$ and this by definition of $A$ implies the existence of a number $x_0\in I$ with $x_0<c$ such that $b=f(x_0)$. Consider $\delta=c-x_0>0$. If $0<c-x<\delta$ then we have $x\in I, x_0<x<c$ and $$|f(x) - \sup A |=\sup A - f(x) \leq \sup A-f(x_0)=\sup A - b<\epsilon $$ This shows that $f(c-) =\sup A\leq f(c) $.