Prove that if $\lim_{n \to \infty} f(x_n) = f(\lim_{n \to \infty} x_n)$ for all sequences that converge to $x$, then $f$ is continuous [duplicate]

Let $\lim_{n \to \infty} f(x_n) = f(x)$ for all sequences $\{ x_n \}$ such that $\lim_{n \to \infty} x_n = x$. I am trying to prove that $f$ is continuous.

I know that for all $\varepsilon > 0$ there exists $N \in \mathbb{N}$ such that $|f(x) - f(x_n)| < \varepsilon$ for all $n \ge N$. I also know that there exists $\delta > 0$ such that $|x - x_n| < \delta$ for all $n \in \mathbb{N}$, since a convergent sequence is bounded.

But I need to find a number $\delta > 0$ such that $|f(x) - f(x_0)| < \varepsilon$, if $|x - x_0| < \delta$. For any sequence $\{ x_n \}$ there will be an $x_0 \notin \{ x_n \}$ such that $|x - x_0| < \delta$, since the reals are not countable. I guess I need to show that any $x_0$ belongs to some sequence that converges to $x$ and that satisfies $|x - x_0| < \delta$. Is this the correct approach or am I missing something?

marked as duplicate by Guy Fsone, Cameron Williams, Martin R, Community♦Jan 31 '18 at 20:09

HINT: you can use the contrapositive statement to prove the result, that is, showing that $A\implies B$ is equivalent to show that $\lnot B\implies\lnot A$.

Let $S:=\{(x_n):x_n\in{\rm dom}(f)\text{ and }\lim x_n=x\}$. In this case it means that showing that

$$\forall(x_n)\in S: \lim f(x_n)=f(x)\implies f\text{ is continuous at }x$$

is equivalent to show that

$$f\text{ is not continuous at }x\implies\exists(x_n)\in S:\lim f(x_n)\neq f(x)$$

Suppose that $f$ is discontinuous at $x_0$. Then there is a $\varepsilon>0$ such that, for each $\delta>0$, there is a number $x$ such that $|x-x_0|<\delta$ and $\bigl|f(x)-f(x_0)\bigr|\geqslant\varepsilon$. In particular, for each $n\in\mathbb N$, there is a $x_n$ such that $|x-x_n|<\frac1n$ and that $\bigl|f(x_n)-f(x_0)\bigr|\geqslant\varepsilon$. So, $\lim_{n\to\infty}x_n=x_0$, but $\lim_{n\to\infty}f(x_n)\neq f(x_0)$.

Suppose by contradiction that $f(x)\not\rightarrow f(x_0)$ as $x\rightarrow x_0$. Then, there exists $\varepsilon>0$ such that for every $\delta>0$ there exists $x\in(x_0-\delta,x_0+\delta)$ such that $|f(x)-f(x_0)|>\varepsilon$.

We use this to construct a sequence that convergence to $x_0$:

For $\delta=1$ there exists $x_1\in (x_0-1,x_0+1)$ such that $|f(x_0)-f(x_1)|>\varepsilon$.

For $\delta=\frac{1}{2}$ there exists $x_2\in(x_0-\frac{1}{2},x_0+\frac{1}{2})$ such that $|f(x_0)-f(x_2)|>\varepsilon$.

Continue this way...

For $\delta = \frac{1}{n}$ there exists $x_n\in(x_0-\frac{1}{n},x_0+\frac{1}{n})$ such that $|f(x_0)-f(x_n)|>\varepsilon$.

Now $|x_0-x_n|<\frac{1}{n}\rightarrow 0$ as $n\rightarrow\infty$, therefore $x_n\rightarrow x_0$ But, $|f(x_0)-f(x_n)|>\varepsilon$ for every $n\in\mathbb{N}$ this contradicts the assumption.