# Why can a locally constant function on $\mathbb{Q}_p$ be expressed as a linear combination of characteristic functions?

I saw some remark that any locally constant function $f:\mathbb Q_p \to \mathbb C$ can be written as $$f(x)=\sum_{i=1}^{\infty}c_i1_{U_i}(x), c_i\in\mathbb C$$ for some open subsets $U_i\in\mathbb Q_p$. Why is it possible? And furthermore, if $f$ is also compactly supported, can it be finite linear combination? If the answer is yes, why?

-

Suppose that $f:\mathbb{Q}_p\to\mathbb{C}$ is locally constant. For each $k\geq 0$ the set $p^{-k}\mathbb{Z}_p\subset\mathbb{Q}_p$ is compact, so it can be covered by finitely many open sets on which $f$ is constant, so $f(p^{-k}\mathbb{Z}_p)$ is finite. By taking the union over $k$, we see that the image $C=f(\mathbb{Q}_p)$ is countable. For notational simplicity I'll assume that $C$ is infinite, so it can be enumerated (without repetition) as $c_1,c_2,\dotsc$ say. Local constancy means that the sets $U_i=f^{-1}\{c_i\}$ are open, and they form a disjoint cover of $\mathbb{Q}_p$. Now $f=\sum_i c_i\chi_{U_i}$.
And if $f$ is compactly supported, then a finite number of terms will do, as we have a covering of the support by the opens which appear in the sum with non-zero coefficient. – Julien Puydt Sep 15 '11 at 12:10