How to show that the set of points of continuity is a $G_{\delta}$

I am trying to solve this exercise from Royden's 3rd edition.

The question is as follows: Let $f$ be a real-valued function defined for all real numbers. Show that the set of points at which $f$ is continuous is a $G_{\delta}$.

Let $$A_n = \{y : \text{there is a }~\delta_y \gt 0 : |f(s)-f(t)|\lt 1/n ~ \text{whenever}~ s,t \in (y-\delta, y+\delta)\}\;.$$

Then by the definition of open sets, $A_n$ is open.

To complete the proof, I need help in showing that $f$ is continuous at say $x$ if and only if $x\in \cap A_n$.

If $f$ is continuous at $x$, the there is a $\delta \gt 0$ such that $|f(x) - f(a)| \lt 1/n$ whenever, $x\in (a-\delta, a+\delta)$. so $x \in A_n$ son it must be in $\cap A_n$.

Thanks.


Solution 1:

If $f$ is continuous in $x$ there exist $\delta_x$ such that $$ |f(s) - f(x)| \ < \dfrac{1}{2n} \ \text{whenever} \ s \in \left(x - \delta_x, x + \delta_x \right) $$ Hence if $s,t \in \left( x - \delta_x, x + \delta_x \right)$, we have $$ |f(s) - f(t)| \le |f(s) - f(x)| + |f(x) - f(t)| \le 1 /n. $$

Solution 2:

A point $x \in \bigcap_n A_n$ iff, for every $\varepsilon>0$ there exists $\delta>0$ such that $|f(t)-f(s)|<\varepsilon$ whenever $x-\delta < s \leq t < x+\delta$. But this condition, via some triangular inequality, is simply the definition of continuity at the point $x$.