Does the set of all piecewise constant functions form a subspace of the vector space $\mathbb{R}^\mathbb{R}$ over $\mathbb{R}$? A function $f\in \mathbb{R}^\mathbb{R}$ is piecewise constant if and only if it is a constant function $x\to c$ or there exist $a_1<a_2<\cdots<a_n$ and $c_0,...,c_n$ in $\mathbb{R}$ such that $$f: x\to \begin{cases}
c_0 & x<a_1\\
c_i & a_i\leq x < a_{i+1}\\
c_n & a_n\leq x
\end{cases}$$
where $1\leq i \leq n$. Does the set of all piecewise constant functions form a subspace of the vector space $\mathbb{R}^\mathbb{R}$ over $\mathbb{R}$?
I've been stuck on this one for a bit. Any solutions or hints are greatly appreciated.
 A: The hard part of this is showing that a sum of piecewise constant functions is piecewise constant.  Suppose $f$ and $g$ are piecewise constant, with the pieces for $f$ being given by the numbers $a_1<a_2<\dots<a_n$ and the pieces for $g$ being given by the numbers $a_1'<a_2'<\dots<a_m'$.  Let $b_1<b_2<\dots<b_N$ be all of the numbers $\{a_1,\dots,a_n,a_1',\dots,a_m'\}$ put in order (probably $N=n+m$, but it might be smaller if $a_i=a_j'$ for some $i,j$).  Can you prove that $f+g$ is piecewise constant with the pieces given by these numbers $b_i$?
A: Every function you describe is a linear combination of characteristic functions
$$
           \chi_{(-\infty,a)},\chi_{[a,b)},\chi_{[b,\infty)},
$$
where $\chi_{E}(s)=1$ if $s \in E$ and is $0$ if $s \notin E$. It may be easier for you to work with such functions because, for example, the following is a way to decompose into common partition:
\begin{align}
     A\chi_{[a,b)}+B\chi_{[c,d)} & =A\chi_{[a,b)}(\chi_{(-\infty,c]}+\chi_{[c,d)}+\chi_{[d,\infty)}) \\
      & +B(\chi_{(-\infty,a)}+\chi_{[a,b)}+\chi_{[b,\infty)})\chi_{[c,d)}.
\end{align}
Any of the products is another one of the 3 basic types, or is $0$.
