Suppose $I\subseteq\Bbb{R}$ is an interval and $f:I\rightarrow\Bbb{R}$ real function. Then $f$ is continuous and injective if and only if it's monotone. I successfully managed to prove $\Rightarrow$ by using intermediate value theorem. But I couldn't find a way to prove the $\Leftarrow$. Specifically I'm struggling to show that it must be continuous. My go:
$\Rightarrow$: Assume $f$ is injective continuous but not monotonic. Thus for some $x,y,z\in I$ for which $x<y<z$ holds, we have either $$f(x)\leq f(y) \wedge f(y)\geq f(z) \tag{1}$$ or $$f(x)\geq f(y) \wedge f(y)\leq f(z)\tag{2}$$ (but not both). Suppose (1). If $f(x)=f(y)$ or $f(y)=f(z)$ or $f(x)=f(z)$ then $f$ is not injective. Thus $f(x)<f(y) \wedge f(y)>f(z)$. Now there are two possibilities: $f(x)<f(z)$ or $f(x)>f(z)$. Assume $f(x)<f(z)$, thus $f(x)<f(z)<f(y)$. Because $f$ is continuous, we can apply intermediate value theorem. So there exists some $c\in(x,y)$ such that $f(c)=f(z)$, but $z\notin (x,y)$ thus $c\neq z$ which shows $f$ is not injective. Other cases are simmilar. We always get a contradiction that $f$ was injective thus we conclude that $f$ must be monotonic.
$\Leftarrow$: Assume $f$ is monotonic on $I$. That means for any $x,y\in I,x<y$ we have either $f(x)<f(y)$ or $f(x)>f(y)$ (but not both). Assume $f$ is strictly increasing. Thus we have implication $x<y\Rightarrow f(x)<f(y)$ which shows $f$ is injective. On the other hand assume $f$ is strictly decreasing. Thus $x<y\Rightarrow f(x)>f(y)$ directly shows $f$ is injective.
Are we somehow able to prove that the function must be continuous in the second case? It also seems weird to me that we have to assume $f$ is continuous. I think that $f$ is injective iff it's monotonic must hold (if not, I'd like a counterexample or a proof). In the first part we actually used the continuity only to apply intermediate value theorem. So my question is, how is it with the continuity? Is there a way to prove (especially the $\Rightarrow$ withouht assuming continuity?
Define $f:(0,2):\mathbb R$ by $x\mapsto x$ if $x<1$ and $x\mapsto x+1$ otherwise.
The function is strictly monotonically increasing, but not continuous at $1$.
See the comment of Lorenzo for further explanation.