To prove that if a function $f : \mathbb R \to \mathbb R$ is locally increasing at every point then the function is increasing I am trying to prove that if $f : \mathbb R \to \mathbb R$ is locally increasing at every point , i.e. if for every $x\in \mathbb R , \exists r_x >0$ such that $f(a)\ge f(b) , $ whenever $ x+r_x >a>b>x-r_x $ , then $f$ is increasing everywhere . 
I have proceeded as : Let $a,b \in \mathbb R , a<b$ ; we want to show $f(a) \le f(b)$ ; now for each $p \in [a,b]$ , there is an open n.b.d. of $p$ in which $f$ is increasing , so by these open intervals , we get an open cover of $[a,b]$ and since $[a,b]$ is compact we can get a finite subcover ; but then I am stuck ; can the proof be finished in this way ? Or is there any better way ? Please help . Thanks in advance 
 A: Suppose by contradiction that $x<y$ and $f(x)>f(y).$
Let $S=\{z\geq x : \forall w\in [x,z]\;( f(x)\leq f(w)\;)\}.$ Then $x< \sup S\leq y\;$ and also  $[x,\sup S)\subset S.$
Now $\exists t\in (0, (-x+\sup S)\;)\;\forall w\in [-t+\sup S, \sup S]\;(f(w)\leq f(\sup S)\;).$ 
And  for such $t$ we have  $-t+\sup S\in S$ so $f(x)\leq f(-t+\sup S)$, which, combined with the previous sentence , gives $f(x)\leq f(-t+\sup S)\leq f(\sup S).$ Therefore $\forall w\in [x,\sup S]\;(f(x)\leq f(\sup S)\;).$ That is,from the def'n of $S$, we have $$\sup S\in S.$$ But $\exists u>0\;\forall w\in [\sup S,u+\sup S]\;(f(\sup S)\leq f(w)\;).$ Therefore for some $u>0$ we have $\forall w\in [x,u+\sup S]\;(f(x)\leq f(w)\;)$, but for such $u$ we have, from the def'n of $S$, that    $$\sup S\geq \sup [x,u+\sup S]=u+\sup S>\sup S,$$ which is absurd.
Note that the role of $y>x$ satisfying $f(y)<f(x)$ was to force the number  $\sup S$ to exist.That is that such $y$ implies that  $S$ has an upper bound, which leads to absurdity.      
