Injective functions with intermediate-value property are continuous. Better proof? A function $f: \mathbb{R} \to \mathbb{R}$ is said to have the intermediate-value property if for any $a$, $b$ and $\lambda \in [f(a),f(b)]$ there is $x \in [a,b]$ such that $f(x)=\lambda$.
A function $f$ is injective if $f(x)=f(y) \Rightarrow x=y$.
Now it is the case that every injective function with the intermediate-value property is continuous. I can prove this using the following steps:


*

*An injective function with the intermediate-value property must be monotonic.

*A monotonic function possesses left- and right-handed limits at each point.

*For a function with the intermediate-value property the left- and right-handed limits at $x$, if they exist, equal $f(x)$.


I am not really happy with this proof. Particularly I don't like having to invoke the intermediate-value property twice.
Can there be a shorter or more elegant proof?
 A: I don't know if this is shorter or elegant, and in particular it does use the hypotheses more than once, but here's something.  
Given your 1., assume WLOG that $f$ is increasing.  Then for all $a\lt b$, $f(a,b)\subseteq (f(a),f(b))$, and thus $(a,b)\subseteq f^{-1}(f(a),f(b))$.  Since each element of $(f(a),f(b))$ has a preimage point in $(a,b)$ and $f$ is injective, $f^{-1}(f(a),f(b))\subseteq (a,b)$.  Combining, $f^{-1}(f(a),f(b))=(a,b)$.  I'll show that this implies that the inverse image of each open interval is open, which implies continuity.
Let $x\lt y$ and suppose that $t$ is in $f^{-1}(x,y)$.  Let $b>t$.  Since $f^{-1}(f(t),f(b))=(t,b)$ and $f(t)\lt y$, there is a $b'$ with $t\lt b' \lt b$ and $f(b')\lt y$.  Thus $f^{-1}(f(t),f(b'))=(t,b')$ is contained in $f^{-1}(x,y)$.  Applying a similar argument on the other side, there is an $a'\lt t$ such that $(a',t)$ is contained in $f^{-1}(x,y)$.  Together this implies that $t$ is in the interior of $f^{-1}(x,y)$.
A: As you note, f is injective and has the intermediate value property => f is monotonic.  We may assume f is increasing.
Now for any x and any small* ε > 0, we have by the IVP 


*

*c in [x-1, x] such that f(c) =  f(x)-ε and

*d in [x, x+1] such that f(d)=f(x)+ε.  
Then we choose δ=min(x-c,d-x).  Since f is increasing, any point within δ of x maps to a point within ε of f(x); thus f is continuous.
*By "small" ε, I mean ε smaller than both f(x)-f(x-1) and f(x+1)-f(x), so that the condition of the IVP is satisfied.
I also invoke the IVP more than once.  Perhaps the other Jonas will supply a proof with just one use of the IVP!
A: [I thought of another proof that uses the IVP and injectiveness once. Putting it as a community wiki answer.]
Assume on the contrary that $f$ is not continuous at $x$. Then there is a sequence $x_n$ converging to $x$ such that $f(x_n)$ does not converge to $f(x)$. Then there is $\epsilon>0$  and a subsequence $x_{n_k}$ such that $f(x_{n_k}) \notin (f(x)-\epsilon,f(x)+\epsilon)$. 
There must either be a further subsequence $x_{n_j}$ such that $f(x_{n_j}) \leq f(x)-\epsilon$ or a subsequence $x_{n_q}$ such that $f(x_{n_q}) \geq f(x)+\epsilon$ (or both). Assume without loss of generality the former. 
Since  $f(x_{n_j}) \leq f(x)-\epsilon < f(x)$, by the IVP for every $j$ there is a $y_j$ such that $x_{n_j}\leq y_j < x$ and $f(y_j)=f(x)-\epsilon$. 
Because $f$ is injective, all the $y_j$ must be the same, say $y$. Because $x_{n_j}$ converges to $x$, $y=x$ by the sandwich theorem. But $f(y)\neq f(x)$. Hence a contradiction.
