I was looking at proofs of the following: Let $X\subseteq\mathbb{R}$. If $f:X \to \mathbb{R}$ is injective and continuous, then $f$ is strictly monotonic.
I am working with the following definition: $f$ is monotonic increasing if for all $a<b$ we have $f(a)\leq f(b)$. $f$ is strictly monotonic increasing if for all $a<b$ we have $f(a)<f(b)$. Monotonic decreasing and strictly monotonic decreasing are analogous.
Many answers, such as this one, use the following result, which is what this post is about: if $f$ is not monotone, then there exist $a<b<c$ such that $f(a)>f(b)<f(c)$ or $f(a)<f(b)>f(c)$.
The result is intuitive, but the proof that I came up with and would like some verification for is kind of obnoxious (if you don't want to check the whole thing just glance at parts of it and skip to the end):
PROOF: Since $f$ is not monotonic increasing, there exists $x,y\in X$ such that $x<y$ and $f(x)>f(y)$. Similarly, since $f$ is not monotonic decreasing, there exists $v,w\in X$ such that $v<w$ and $f(v)<f(w)$.
First, suppose $x=v$. Then $w\neq y$, otherwise $f(x)>f(y)=f(w)>f(v)=f(x)$. So since $x=v<w$ and $x<y$ we have either $x<y<w$ or $x<w<y$.
Case $x<y<w$: We know $f(x)>f(y)$. But we also have $f(w)>f(v)=f(x)>f(y)$. So we have $x<y<w$ and $f(x)>f(y)<f(w)$, which is what we're looking for.
Case $x<w<y$: We have $f(w)>f(v)=f(x)>f(y)$. So we have $x<w<y$ and $f(x)<f(w)>f(y)$, which is what we're looking for.
Now assume that $x\neq v$.
Now suppose $x=w$. In this case we'd be done since $v<w=x<y$ and $f(v)<f(w)=f(x)>f(y)$. So we may assume $x\neq w$.
Now suppose $y=v$. In this case we'd also be done since $x<y=v<w$ and $f(x)>f(y)=f(v)<f(w)$. So we may assume $y\neq v$.
Now suppose $y=w$. Then either $v<x<y$ or $x<v<y$.
Case $v<x<y$: We have $f(v)<f(w)=f(y)<f(x)$. Hence $f(v)<f(x)>f(y)$ and we're done.
Case $x<v<y$: We have $f(x)>f(y)=f(w)>f(v)$. Hence $f(x)>f(v)<f(y)$ and we're done.
Now assume $y\neq w$.
Here are our assumptions so far: $x\neq v$, $x\neq w$, $y\neq v$, $y\neq w$.
Let us consider all the ways of ordering the values $x,y,v,w$ while ensuring $x<y$ and $v<w$: \begin{gather} v<w<x < y \\ v<x<w < y\\ v<x<y < w\\ x<v<w < y\\ x<v<y < w\\ x<y<v<w \end{gather} I will go through each of the 6 cases and show that we can find $a<b<c$ such that $f(a)>f(b)<f(c)$ or $f(a)<f(b)>f(c)$.
Case 1: If $f(w)>f(x)$, then $v<w<x$ and $f(v)<f(w)>f(x)$. If $f(w)\leq f(x)$, then $v<x<y$ and $f(v)<f(w)\leq f(x)>f(y)$.
Case 2: If $f(v)<f(x)$, then $v<x<y$ and $f(v)<f(x)>f(y)$. If $f(v)\geq f(x)$, then $v<w<y$ and $f(v)<f(w)>f(x)>f(y)$.
Case 3: If $f(v)<f(x)$ then $v<x<y$ and $f(v)<f(x)>f(y)$. If $f(v)\geq f(x)$ then $v<y<w$ and $f(v) > f(y)<f(w)$.
Case 4: If $f(x)>f(v)$ then $x<v<w$ and $f(x)>f(v)<f(w)$. If $f(x)\leq f(v)$ then $v<w<y$ and $f(v)<f(w)>f(y)$.
Case 5: If $f(x)>f(v)$ then $x<v<w$ and $f(x)>f(v)<f(w)$. If $f(x)\leq f(v)$ then $x<y<w$ and $f(x)>f(y)<f(w)$.
Case 6: If $f(y)<f(v)$ then $x<y<v$ and $f(x)>f(y)<f(v)$. If $f(y)\geq f(v)$ then $x<v<w$ and $f(x)>f(v)<f(w)$.
END OF PROOF.
I would like to know if there is a more elegant way of proving this from the definitions that does not devolve into tedious case by case analysis.
Here is an alternative proof, but I am not sure whether it is more elegant because it also involves cases.
Let $T(X)$ denote the set of all triples $(a,b,c)$ with $a,b,c \in X$ such that $a < b < c$. We want to show that $f$ not monotonic implies $$P: \quad \exists (a,b,c) \in T(X) : [f(a) > f(b) \wedge f(b) < f(c)] \vee [f(a) < f(b) \wedge f(b) > f(c)] .$$ We can do this by contradiction, i.e. by showing that $$\neg P: \quad \forall (a,b,c) \in T(X) : [f(a) \le f(b) \vee f(b) \ge f(c)] \wedge [f(a) \ge f(b) \vee f(b) \le f(c)]$$ implies that $f$ is monotonic. But $\neg P$ means $$\forall (a,b,c) \in T(X) : [f(a) \le f(b) \wedge f(a) \ge f(b)] \vee [f(b) \ge f(c) \wedge f(a) \ge f(b)] \vee [f(a) \le f(b) \wedge f(b) \le f(c)] \vee [f(b) \ge f(c) \wedge f(b) \le f(c)] ,$$ i.e. $$\forall (a,b,c) \in T(X) : [f(a) = f(b)] \vee [f(a) \ge f(b) \ge f(c)] \vee [f(a) \le f(b) \le f(c)] \vee [f(b) = f(c)] .$$ Consider any two $a, c \in X$ such that $a < c$. We claim that $f$ is monotonic on $X \cap [a,c]$. More precisely, $f$ is monotonic increasing on $X \cap [a,c]$ if $f(a) \le f(c)$ and monotonic decreasing if $f(a) \ge f(c)$. We only consider $f(a) \le f(c)$, the other case is similar.
For any $b \in X$ such that $a < b < c$ all of the above four alternatives for $(a,b,c)$ show that $f(a) \le f(b) \le f(c)$. Note that the second alternative can only occur when $f(a) = f(c)$.
Now let $b, b' \in X \cap [a,c]$ such that $b < b'$. If $b = a$ and $b' = c$, then by assumption $f(b) \le f(b')$. If either $b = a$ or $b' = c$, then 1. shows that $f(b) \le f(b')$. If $a < b < b' < c$, then $f(b) \le f(c)$ by 1., and another application of 1. shows that $f(b) \le f(b')$.
Now let us show that $f$ is monotonic. If $f$ is constant, then this trivially true. So let us look at the case that $f$ is non-constant, i.e. there exist $r, s \in X$ such that $r < s$ and $f(r) \ne f(s)$. We claim that $f$ is monotonic increasing if $f(r) < f(s)$ and monotonic decreasing if $f(r) > f(s)$. We only consider $f(r) < f(s)$, the other case is similar. Let $u,v \in X$ such that $u < v$. Define $a = \min(r,u), c = \max(s,v)$. We know that $f$ is monotonic on $X \cap [a,c]$. Since $r,s \in X \cap [a,c]$ and $f(r) < f(s)$, we conclude that $f$ is monotonic increasing on $X \cap [a,c]$. Hence $f(u) \le f(v)$ since $u,v \in [a,b]$.