Prove that if $a\in [0,1]$, then $\lim\limits_{x \to a} f(x) =0$ Supose that for any natural number $n$, $A_n$ is a finite set of numbers from $[0,1]$, and that $A_m$ and $A_n$ have no common elements if $m \neq n$, ie
$$m \neq n \Rightarrow A_n\cap A_m=\emptyset$$
Let $f$
$$f(x)=  \begin{cases} 1/n & \text{for } x \in A_n \cr 0 & \text{for } x \notin A_n \text{ for any }n \end{cases}$$
I guess the definition is clear: If $x$ is in some of the $A_n$ then we map it to $1/n$, and if $x$ is in no $A_n$ the function is zero. It's like a modified characteristic function.
$$f(x) =\sum_{n \in \Bbb N} \frac 1 n  \chi_{A_n}$$
(Thanks Asaf)
I have to prove that $$\lim_{x \to a }f(x)=0$$ for all $a$ in $[0,1]$
This is my inutuitive interpretation of the problem.
Since all the $A_n$ are finite sets, the union  $S= \bigcup_{n \in \Bbb N}A_n$ of the sets is countably infinite. (Maybe this has to be proven before, but I think it is true.)
This means that $f(x)\neq 0$ for countable infinite many $x$. But then the set of $x$ such that $f(x)=0$ is uncountable, since $[0,1]$ is uncountable so $f$ is $0$ almost everywhere in $[0,1]$.
Although this is not homework, I'd like you to help me find the way to the "solving argument", maybe show how it can be done for $a=1/2$. This is from Spivak's Calculus, so all the set theoretic things I wrote don't really apply, it should probably be proven by some basic set arguments and the definition of the limit.

Attempt of proof:
DEFINITION: $$\lim_{x \to a}f(x)=L$$ if $\forall \epsilon >0 \exists \delta >0 : 0<|x-a|<\delta \Rightarrow |f(x)-L|<\epsilon$. This is Spivak's definition. Note that 
$0<|x-a|$ means the limit excludes the point $a$. Suggested by t.b. is the notation 
$$\lim_{\substack{x \to a \\ x \neq a}} f(x)$$
T Let $f : [0,1] \to \mathbb Q$ such that $$f(x) = \sum_{n \in \Bbb N} \frac{\chi_{A_n}(x)}{n}$$
then $$a \in [0,1] \Rightarrow \lim_{x \to a} f(x) = 0$$ 
P (Based on Zhang's idea).
Since $A_1$ is finite, there exists a $\delta_1 >0$ such that no $x \in A_1$ is in $(a-\delta_1,a)\cup (a,a+\delta_1)$. Thus, $|f(x)|< \dfrac 1 2$ for $0<|x-a|<\delta_1$. Similarily, $\exists \delta_2 >0 : x\in A_2 \wedge x \notin (a-\delta_2,a)\cup (a,a+\delta_2) $ so $|f(x)|< \dfrac 1 3 $ for $0<|x-a|<\delta_2$. Analogously, 
$$\exists \delta_n >0 : x\in A_n \wedge x \notin (a-\delta_n,a)\cup (a,a+\delta_n) $$, so $$|f(x)|< \dfrac 1 n \text{ for } 0<|x-a|<\delta_n$$
Revised:
Let $\epsilon>0$ be given. Let $N\in \mathbb N$ such that $1/N < \epsilon$. Let $n \geq N$, and $$\delta = \min    \{ \delta_1,\cdots,\delta_n\}$$ Then
$$0<|x-a|<\delta \Rightarrow |f(x)|<\epsilon$$  ∎.

Today I was discussing this problem with a professor and at first glance he thought it was the case that
$$S= \bigcup_{n \in \Bbb N}A_n= [0,1]$$ 
I provided the following explanation.
By Cantor's proof, $[0,1]$ is uncountable. I'll use $\sim$ to say there is a bijection between two sets $A$ and $B$. Since all the $A_n$ are finite, their cardinality is a natural number, so
$$A_1 \sim \left \{ 1,2,\cdots, |A_1| \right \}$$
$$A_2 \sim \{ |A_1|+1,\cdots, |A_1|+|A_2| \}$$
$$\cdots$$
$$A_n \sim \left\{ \sum_{k <n}|A_k|+1,\cdots, \sum_{k \leq n} |A_k|\right\}$$
Then, taking the union produces
 $$\bigcup_{n \in \Bbb N}A_n\sim  \Bbb N$$ 
so the set $S$ is countable and thus can't be $[0,1]$. 

So far, I have these satisfactory ideas, but I want to write an acceptable proof. 
anon: If $g$ and $f$ differ at only a finite number of points then $\lim f = \lim g$. We define a useful $g_m$ such that it differs with $f$ at only a finite amount of points, and we show $0 \leq g_m \leq 1/m$.
I got this one and hope I can devise a proof.
Levon/Glouglou/Zhang Show that for any sequence $x_n$ s.t. $x_n \to a$, there exists an $n_0$ such that $$\{ x_k \}_{k \geq n_0}\cap A_n=\emptyset$$ for all $n \in \Bbb N$.
This means that for a suitable $\delta$, the set $M=\{ x : x \in [a-\delta,a+\delta]\}$ contains no $x \in A_n$, so $f(x) < \epsilon$ (actually it is strictly $0$) in that neighborhood of $a$.
 A: Your interpretation is not quite correct. For example the function
$$f(x) = \left\{
\begin {array} {ll}
1 & x \text { is rational} \\
0 & x \text { is irrational}
\end {array}
\right.$$
also has the property that it is nonzero only on countably many points. However, at no point the limit of this function exists. (Because you can approximate each number by rationals and by irrationals).
As a hint I would suggest the following. If $a, \varepsilon$ and $n$ are given, then you can peak $\delta$ so small that the $\delta$ neighbourhood of $a$ does not contain numbers from $A_1, ..., A_n$.
A: Hint : consider an arbitrary sequence $x_n$ converging to $a$ (the value of $a$ is of no consequence here). You have to show that $\lim_{n \rightarrow \infty} f(x_n)=0$. What can be said about the set of integers $n$ such that $f(x_n)$ is greater than, say, $1/N$ ?
EDIT
You seem to want a complete solution now. Here it is.
It is known that $\lim_{x \rightarrow a} f(x)=0$ iff for any sequence $x_n \rightarrow a$, $\lim_{n \rightarrow \infty} f(x_n)=0$. Let $(x_n)$ be such a sequence, $\epsilon >0$, and $N$ an integer so that for every $n \geq N$, $\frac{1}{n} \leq \epsilon$. The union $\cup_{n \leq N} A_n$ being finite, there is a $n_0$ such that for any $n \geq n_0$, $n \notin \cup_{m \leq N} A_m$. Therefore, for every $n$ greater than $n_0$, $|f(x_n)| \leq \epsilon$ since $f(x_n)$ is equal to $\frac{1}{k}$ with $k \geq N$ if $x_k$ belongs to a $A_k$, and 0 otherwise. 
So we have proven that for arbitrary $\epsilon$, there is a $n_0$ such that for any $n \geq n_0$, $|f(x_n) \leq \epsilon$, which is exactly what we wanted.
A: The key is that $A_n$ are all finite. Can you see that if an ant approaches $a$ without touching $a$, for any $n$, eventually it will leave $A_1, A_2, \cdots, A_n$? If you see that then you are one step to the answer.
A: Here's my thought process for a derivation. Let $g$ and $h$ be $\Bbb R\to\Bbb R$ functions.


*

*Prove that if $g(x)$ and $h(x)$ differ at only one value $x\in\Bbb R$, then for all $a\in\Bbb R$ the limits $$\lim_{x\to a}\,g(x)=\lim_{x\to a}\,h(x)$$ are still the same. (Split into two cases: $a$ is "that one value," and otherwise.)

*Invoke induction to conclude that all of the limits for $g,h$ are still always equal whenever $g$ and $h$ differ at only a finite number of $x$ values (not necessarily just one value).

*Define the functions $$f_m(x)=\sum_{n\ge m}\frac{\chi_{A_n}(x)}{n}=\begin{cases}\frac{1}{n} & \text{if } x\in A_n\text{ and }n\ge m \\[8pt] 0 & \text{otherwise}.\end{cases}$$ Observe that 

*

*$f=f_1$, 

*$f_m$ and $f_{m+1}$ differ only for $x\in A_m$ (which is finite), and 

*$\forall x\in\Bbb R:~~ 0\le f_m(x)\le \frac{1}{m}$.



Added: The claim is actually only true under a certain definition of the limit. For example, if $u\in A_k$ then $f(u)=1/k$, so every neighborhood of $u$ will contain a point $x_0$ such that $f(x_0)=1/k$ (in particular, $x_0=u$ itself), hence there is no neighborhood $I$ of $u$ in which $|f(x)-0|<\delta=1/k$ for all $x\in I$, hence the limit under this definition cannot be $0$. Instead we need a definition of the limit that ignores the point $u$. The easiest version is to say that if the left and right limits exist and are equal, we set this value to be "the" limit, and otherwise say the limit does not exist. We'll use this.
Suppose $f,g$ are equal except at the point $u$. If $a\ne u$ then we can choose a neighborhood of $a$ that does not include $u$ in which $f$ and $g$ are everywhere equal, hence the limits of $f,g$ at $a$ must be equal. If $a=u$ then we see that the right limits of $f,g$ must be equal because they are the same function on $(u,\infty)$, and the same for the left limits and $(-\infty,u)$, hence if "the" limits for $f,g$ exist they must be equal.
A: Hint:
For any $\varepsilon > 0$, the set $\{ x\ |\ f(x) > \varepsilon \}$ is finite.
