Prove that $f$ is continuous if and only if $\text{osc}(f,a) = 0$ Let $(X,d)$ be a metric space, let $f:X\rightarrow \mathbb{R}$, and let $a\in X$. Define the oscillation of $f$ at $a$ by $$\text{osc}(f,a) = \inf_{r>0}(\sup \{|f(x) - f(y)| : x,y \in B_r(a)\}).$$
(Note: $B_r(a) = \{x: |x - a| < r\}).$
Prove that $f$ is continuous if and only if $\text{osc}(f,a) = 0$
I'm stumped, but here's what I know:
If $f$ is continuous then $(\forall\epsilon>0)(\exists\delta>0)$ such that $d(x,y)<\delta \implies d(f(x), f(y)) < \epsilon$
So then $|f(x) - f(y)| < \epsilon$. How does the fact that $x,y\in B_r(a)$ related to $|f(x) - f(y)|$? I'm having trouble understanding precisely what $\inf_{r>0}(\sup \{|f(x) - f(y)| : x,y \in B_r(a)\})$ means. Please explain that as you help out with this proof. 
 A: Let $\omega(r)=\sup \{|f(x) - f(y)| : x,y \in B_r(a)\}$.
Suppose that $f$ is continuous. Let $\varepsilon \gt 0$. Then there is a
$\delta \gt 0$ such that 
$$
|w-a| \leq \delta \Rightarrow |f(w)-f(a)| \leq \epsilon \tag{1}
$$
Let $r\leq \delta$, and let $x,y\in B_r(a)$. Using (1) with $w=x$ and $w=y$, we see 
that $|f(x)-f(a)|\leq \varepsilon$ and $|f(y)-f(a)| \leq \varepsilon$. Then
$|f(x)-f(y)| \leq |f(x)-f(a)|+|f(a)-f(y)| \leq 2\varepsilon$.
We have shown
$$
r\leq \delta, x,y\in B_r(a) \Rightarrow |f(x)-f(y)| \leq 2\varepsilon \tag{2}
$$
So
$$
r \leq \delta \Rightarrow \omega(r) \leq 2\varepsilon \tag{3}
$$
This entails 
$$
{\sf osc}(f,a) \leq 2\varepsilon \tag{4}
$$
Since (4) holds for any $\varepsilon \gt 0$, we deduce ${\sf osc}(f,a) \leq 0$, and hence
${\sf osc}(f,a)=0$.
Conversely, suppose ${\sf osc}(f,a)=0$. Let $\varepsilon \gt 0$. By hypothesis,
${\sf inf}_{r\gt 0}\omega(r) =0 < \varepsilon$. So there is a $\delta > 0$ such that
$\omega(\delta) < \varepsilon$. This means that :
$$
w_1,w_2\in B_{\delta}(a) \Rightarrow |f(w_1)-f(w_2)| < \varepsilon \tag{5}
$$
Let $x\in B_\delta(a)$. Then in (5) above, we may take $w_1=x,w_2=a$. This shows :
$$
|x-a| < \delta \Rightarrow |f(x)-f(a)| < \varepsilon \tag{6}
$$
So $f$ is continuous at $a$.
