TITLE: Existence of $\vee$ or $\wedge$ for non-monotonic functions
QUESTION [9 upvotes]: This question is inspired by a discussion in chat with wj32. We allow for equality in the definition of increasing and decreasing and call a function monotonic if it is increasing or decreasing. If $f:\mathbb R\to \mathbb R$ is not monotonic, are there three points $x<y<z$ such that $f(y)<f(x),f(z)$ or $f(y)>f(x),f(z)$? For convenience, call these the $\vee$ and $\wedge$ formations respectively.

REPLY [8 votes]: It's a purely combinatorial matter. The main task is to reduce the number of cases to be considered as much as possible.
It suffices to consider a surjective function $f:\ \{1,2,3,4\}\to\{1',\ldots,n'\}$ with the property that there exists a pair $x<y$ with $f(x)<f(y)$ and a pair $u<v$ with $f(u)>f(v)$. Here $n\in\{2,3,4\}$.
I shall only deal with the case $n=4$.
If at least one of $2$ and $3$ is mapped onto $1'$ or $4'$ we are done.
If $f(2)=2$ and $f(3)=3$ then $f(1)=4'$, and we have a $\vee$ over $\{1,2,3\}$.
If $f(2)=3'$ and $f(3)=2'$ then $f(1)=1'$, and we have a $\wedge$ over $\{1,2,3\}$.