Prove the approximation of the identity function on $\mathbb{\bar{R}}_+$ by an increasing sequence of simple functions. 
For each $n$ in $\mathbb{N}^*$, let  $$d_n(r) = \sum_{k=1}^{n2^n}
 \frac{k-1}{2^n} 1_{[\frac{k-1}{2^n}, \frac{k}{2^n})} (r)+ n 1_{[n,
 \infty]}(r), r\in \mathbb{\bar{R}}_+,$$
Then, each $d_n$ is an increasing right-continuous simple function on
  $\mathbb{\bar{R}}_+$ and $d_n(r)$ increases to $r$ for each $r$ in
  $\mathbb{\bar{R}}_+$ as $n \rightarrow \infty$.

This is given as an lemma in my textbook without proof. It doesn't look obvious to me at all. Even understanding the function itself is hard for me.
Can someone kindly explain to me the function, how to interpret and understand it and prove the lemma?
It seems to be that $1_{[\frac{k-1}{2^n}, \frac{k}{2^n})}(r)$ is satisfied only when $k = n2^n$ which is the last case of the summation. Why do we need the summation then, instead of taking the last term only?
 A: In terms of the greatest integer $[x]$ not exceeding $x$ you can write $d_n (r)=\frac {[2^{n}r]} {2^{n}}$ if $r \leq n$ and $d_n(r)=n$ if $r>n$.  Proof of the fact that $\frac {[2^{n} x]} {2^{n}} $ increases to $x$ as $ n$ increases to $\infty $ for every $x\geq 0$: we have $x-\frac 1 {2^{n}} =\frac {2^{n} x-1} {2^{n}} <\frac {[2^{n} x]} {2^{n}} \leq \frac {2^{n} x} {2^{n}}=x $. By the Squeeze Theorem $\frac {[2^{n} x]} {2^{n}}  \to x$. Next we prove that $2[y] \leq [2y]$ for all $y \geq 0$: if $n \leq y <n+1$ then $2n \leq 2y <2n+2$ so either $2n \leq 2y <2n+1$  or $2n+ \leq 2y <2n+2$. Hence $[y]=n$ and $[2y] =2n$ or $[2y]=2n+1$. It follows that $[2y] \geq 2n =2[y]$ in both cases. Taking $y=2^{n}x$ we get $\frac {[2^{n} x]} {2^{n}} \leq \frac {[2^{n+1} x]} {2^{n+1}} $. This completes the proof.
A: The idea behind this is that you split the interval $[0,n)$ into $2^n$ equally sized intervals and on each interval you set the value equal to the value at the left point and on the interval $[n, \infty)$ you have to set $n$ (I think you have a typo)
Letting $n \rightarrow \infty$ the partition gets smaller and smaller and you can see that the function $d_n(r)$ increases to $r$ simply because the mesh of the partition converges to $0$.
Right continuity follows from the fact that we are using $[,)$ type of intervals for the approximation.
