Assumption in Spivak's Calculus Chapter 7-13b 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.
 A: If $f$ is not continuous at $a$, then for some $\varepsilon > 0$ we can find x's arbitrarily close to $a$ such that $\lvert f(x) - f(a) \rvert \geq \varepsilon$
We can assume an endless number such x's arbitrarily close to $a$ and $> a$, or else $< a$. Let's assume the first. (At least one of these has to be true, or else $f$ would be continuous at $a$.)


Here's my problem:  is independent of , which means it doesn't have to obey >>AC, it could obey AD, BC or BD instead.


We can assume the existence of infinitely many points obeying either C or D.
Using your case terminology and assuming the first point $x_0$ fits $AC$, there must be a point $x_1$ such that $a < x_1 < x_0$ with $f(x_1) = f(a) + \varepsilon/2$ (because of the IVT).
Now, we can select $x_2$ with $a < x_2 < x_1$ where $x_2$ fits either case $AC$ or case $BC$, both of which lead to $f$ duplicating values ($f(a) + \varepsilon/2$, or $f(a)$, respectively, again because of the IVT.)
You should be able to use very similar arguments for all other cases, first for the initial point being BC instead of AC, and next, for x's $< a$ instead of $> a$.
Drawing a picture might help.
A: 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) $.
