Representing all rational numbers between $\dfrac{1}{2}$ and $1$ How do I show that
$$\dfrac{2^{\left\lfloor\frac12 a_1\right\rfloor} + 2^{\left\lfloor\frac12 a_2\right\rfloor}  + \ldots + 2^{\left\lfloor\frac12 a_n \right\rfloor}}{2^{\left\lceil\frac12 a_1\right\rceil} + 2^{\left\lceil\frac12 a_2\right\rceil} + \ldots + 2^{\left\lceil\frac12 a_n \right\rceil}}$$
represents all rationals between $\dfrac{1}{2}$ and $1$, where $a_1, a_2, \ldots, a_n \in \mathbb{N}$?
I have tried representing few rationals such as $\dfrac{7}{8}$ and $\dfrac{5}{8}$ and it seems like we can represent all of them. However I'm not completely sure why and don't have a rigorous proof.
For example
$$\dfrac{5}{8} = \dfrac{2^{\left\lfloor\frac12 3\right\rfloor} + 2^{\left\lfloor\frac12 4\right\rfloor}  + 2^{\left\lfloor\frac12 5 \right\rfloor}}{2^{\left\lceil\frac12 3\right\rceil} + 2^{\left\lceil\frac12 4\right\rceil} + 2^{\left\lceil\frac12 5 \right\rceil}}$$
$$\dfrac{7}{8} = \dfrac{2^{\left\lfloor\frac12 1\right\rfloor} + 2^{\left\lfloor\frac12 2\right\rfloor}  + 2^{\left\lfloor\frac12 4 \right\rfloor}}{2^{\left\lceil\frac12 1\right\rceil} + 2^{\left\lceil\frac12 2\right\rceil} + 2^{\left\lceil\frac12 4 \right\rceil}}$$
Any help would be highly appreciated. Thanks

Some nice answers have been posted, but I'm still adding this answer since it gives a straightforward non-recursive way to get a representation.
That the expression is in $[{1 \over 2},1]$ is easy to see.
For the other way, consider ${x \over y} \in [{1 \over 2},1]$ and let $m=y-x$. Then $x-m \geq 0$.
Express $x-m=(a_k a_{k-1} \dots a_0)_2$ and $m=(b_l b_{l-1} \dots b_0)_2$ expressed in binary [$0 \notin \{a_k,b_l\}$].
Then, I claim that $\{2i : a_i = 1\} \cup \{2j+1 : b_j =1 \}$ gives our representation.
Indeed,
$$
{\sum_{a_i=1}2^{\lfloor{2i \over 2}\rfloor}+\sum_{b_j=1}2^{\lfloor{2j+1 \over 2}\rfloor} \over \sum_{a_i=1}2^{\lceil{2i \over 2}\rceil}+\sum_{b_j=1}2^{\lceil{2j+1 \over 2}\rceil}}
= {\sum_i a_i 2^i+\sum_j b_j 2^j \over \sum_i a_i 2^i+\sum_j b_j 2^{j+1}}
= {x-m+m \over x-m+2m} = {x \over y}
$$
The last line is due to the fact that in case of non-integers (i.e. ${2j+1 \over 2}$), the ceilings increase the powers of $2$ by $1$ and hence the number expressed is multiplied by $2$.
As an example, for $7 \over 10$, $x=7,y=10,m=3$.
Now, $x-m=4=(100)_2$ and $m=3=(11)_2$.
Using our algorithm, the representative numbers are $4,3,1$.
Indeed, ${2^{\lfloor{4 \over 2}\rfloor}+2^{\lfloor{3 \over 2}\rfloor}+2^{\lfloor{1 \over 2}\rfloor} \over 2^{\lceil{4 \over 2}\rceil}+2^{\lceil{3 \over 2}\rceil}+2^{\lceil{1 \over 2}\rceil}} = {2^2+2^1+2^0 \over 2^2+2^2+2^1} = {4+2+1 \over 4+4+2} = {7 \over 10}$.
I just noticed that @TheSimpliFire has done a similar thing in the comments, but I started writing it sometime ago, had some coffee, and then finished it. So I somehow missed his/her comment. Anyway, if you (@TheSimpliFire) decide to make it into an answer, please let me know and I'll remove mine.
