I am reading "Measure, Integration & Real Analysis" by Sheldon Axler.
The following exercise is Exercise 22 on p.39 in Exercises 2B in this book.
Exercise 22
Suppose $B\subset\mathbb{R}$ and $f:B\to\mathbb{R}$ is an increasing function. Prove that $f$ is continuous at every element of $B$ except for a countable subset of $B$.
I tried to solve Exercise 22 but I was not able to solve it.
I found the following:
lorenzo's question and his proof
Hagen von Eitzen's proof
I think lorenzo tried to fill the gap in Hagen von Eitzen's proof.
First I checked Hagen von Eitzen's proof:
Let $C:=\{x\in B:f\text{ is not continuous at }x\}.$
Let $b\in B.$
If $\{f(x):x\in B,x<b\}=\emptyset$ and $\{f(x):x\in B,b<x\}=\emptyset$, then $B=\{b\}$ and $f$ is continuous at $b$.
Let $b\in C.$
Then, since $f$ is not continuous at $b$, $\{f(x):x\in B,x<b\}\neq\emptyset$ or $\{f(x):x\in B,b<x\}\neq\emptyset.$
We prove the following inequality:
$$\sup\{f(x):x\in B,x<b\}<\inf\{f(x):x\in B,b<x\}.$$
For any $y\in\{f(x):x\in B,x<b\}$, $y\leq f(b)$ because $f$ is an increasing function.
So, $\sup\{f(x):x\in B,x<b\}\leq f(b).$
For any $y\in\{f(x):x\in B,b<x\}$, $f(b)\leq y$ because $f$ is an increasing function.
So, $f(b)\leq\inf\{f(x):x\in B,b<x\}.$
Therefore, $\sup\{f(x):x\in B,x<b\}\leq f(b)\leq\inf\{f(x):x\in B,b<x\}.$(Case 1) We consider the case in which $\{f(x):x\in B,x<b\}=\emptyset$ and $\{f(x):x\in B,b<x\}\neq\emptyset.$
$\sup\{f(x):x\in B,x<b\}=-\infty$ and $f(b)<\inf\{f(x):x\in B,b<x\}$ (if $f(b)=\inf\{f(x):x\in B,b<x\}$, then $f$ is continuous at $b$. This is a contradiction.)
Therefore, in this case, $\sup\{f(x):x\in B,x<b\}< f(b)<\inf\{f(x):x\in B,b<x\}.$(Case 2) We consider the case in which $\{f(x):x\in B,x<b\}\neq\emptyset$ and $\{f(x):x\in B,b<x\}=\emptyset.$
$\inf\{f(x):x\in B,b<x\}=\infty$ and $\sup\{f(x):x\in B,x<b\}<f(b)$ (if $\sup\{f(x):x\in B,x<b\}=f(b)$, then $f$ is continuous at $b$. This is a contradiction.)
Therefore, in this case, $\sup\{f(x):x\in B,x<b\}< f(b)<\inf\{f(x):x\in B,b<x\}.$(Case 3) We consider the case in which $\{f(x):x\in B,x<b\}\neq\emptyset$ and $\{f(x):x\in B,b<x\}\neq\emptyset.$
$\sup\{f(x):x\in B,x<b\}<f(b)$ or $f(b)<\inf\{f(x):x\in B,b<x\}$ holds. (if $\sup\{f(x):x\in B,x<b\}=f(b)$ and $f(b)=\inf\{f(x):x\in B,b<x\}$, then $f$ is continuous at $b$. This is a contradiction.)
Therefore, in this case, $\sup\{f(x):x\in B,x<b\}\leq f(b)<\inf\{f(x):x\in B,b<x\}.$ or $\sup\{f(x):x\in B,x<b\}< f(b)\leq\inf\{f(x):x\in B,b<x\}.$Therefore, $\sup\{f(x):x\in B,x<b\}<\inf\{f(x):x\in B,b<x\}$ holds.
Next I checked lorenzo's proof.
lorenzo wrote like the following:
$I_d=:(\sup_{x<d,\ x\in B}f(x),\inf_{x>d,\ x\in B} f(x))$ is a non-empty interval in $\mathbb{R}$ hence there must be a rational number $q_d$ in it which we can choose and since $I_d\cap I_{d'}=\emptyset$ for $d\neq d'$ $\cdots$Let $B=(-\infty,-1]\cup [1,\infty)$.
Suppose $f$ is a real-valued function on $B$ such that $f(x)=x-1$ if $x<-1$ and $f(-1)=-1$ and $f(1)=1$ and $f(x)=x+1$ if $1<x.$
Let $d=-1$ and $d'=1$.
Then, $I_d=(\sup_{x<d,\ x\in B}f(x),\inf_{x>d,\ x\in B} f(x))=(-2,1).$
Then, $I_{d'}=(\sup_{x<d',\ x\in B}f(x),\inf_{x>d',\ x\in B} f(x))=(-1,2).$
So, $I_d\cap I_{d'}=(-1,1)\neq\emptyset.$
So, I think lorenzo's proof needs to be modified.
How to modify lorenzo's proof?