Density of a set of numbers. Firstly, I introduce a notation. $\Bbb{N}$ denotes the set of natural numbers, $0$ included.
For $E \subseteq \Bbb{N}$ and $n \in \Bbb{N}$, I denote by
$$\pi_E(n) = |E \cap \{ 1, \dots , n\}|$$ and
$$\pi E = \pi_E^{-1}(E) = \{ k \in \Bbb{N} : \pi_E(k) \in E\}$$
Hence, for example, if $E$ denotes the set of even numbers, $\pi E$ denotes the set of numbers having an even number of smaller-or-equal even numbers. Since the sequence $\{ \pi_E(n) \}_n$ is
$$1,1,2,2,3,3,4,4, 5,5,6,6,7,7,8,8 ,\dots$$
we have that $\pi E = \{ 2,3,6,7, 10,11, 14,15 \dots\} = \{ n \in \Bbb{N}: n \pmod{4} \in \{ 2,3\}\}$.
This was just for fun, but I realized that both $E$ and $\pi E$ have density $1/2$, i.e.
$$\lim_{n \to \infty} \frac{1}{n} |E \cap \{ 1, \dots , n\}| = \frac 12 = \lim_{n \to \infty} \frac{1}{n} |\pi E \cap \{ 1, \dots , n\}|$$
A similar pattern appears for other sets $E \subseteq \Bbb{N}$: I checked that this holds for sets of the form $E=a\Bbb{N}$ (with $a >1$) and for the set of perfect squares.
So my question is: does it exist any theorem about $\pi E$ in literature, and is it true that it has the same density of $E$ (provided the latter exists)?
PS: I realized that every finite set of the form $E=\{ 1, \dots , n\}$ is a counterexample. Anyway, I had infinite sets in my mind, so please, consider only the case when $E$ is an infinite set.
 A: This is hopeless. For example, we can build a set $E$ of density $1/2$, such that $\pi E$ will not have density $1/2$, as follows: I'm going to include one half of the numbers in $N^2\le n<(N+1)^2$ in $E$, for each $N\ge 1$. Then $E$ will have density $1/2$, and for this it does not matter which numbers exactly I choose.
Summary: The exact procedure is a bit tedious to describe, but the idea is extremely simple. We're free to determine which numbers exactly from $[N^2, (N+1)^2)$ go into $E$; the only requirement is that we must choose one half of them. Each time we put a new number into $E$, the counting function $\pi_E$ increases by $1$, and we can now simply deliberately spend a lot of time at a value $\notin E$, by just refusing to put new elements into $E$ for as long as possible.
Let me try to describe this in somewhat greater detail. The procedure is recursive, so assume that $E$ has already been defined for $n<N^2$.
On $N^2\le n< (N+1)^2$, let's start out by putting numbers into $E$, until $\pi_E(n)$ has increased to a value that is not in $E$, if there is one (note that since $\pi_E(N^2)\simeq N^2/2$, this only refers to the part of $E$ already constructed). The next $N$ numbers will not go into $E$ then, and the remainder of $[N^2, (N+1)^2)$ will be in $E$.
Then, by construction, $\pi_E(n)\notin E$ for at least $1/2$ of the numbers $N^2\le n < (N+1)^2$ (from the interval of constancy of $\pi_E$). So $\pi E$ could only have density $1/2$ if $\ge (1-\epsilon)N$ of the numbers between $N^2/2$ and $N^2/2+N$ were in $E$ for most large $N$, but clearly this contradicts the fact that $E$ has density $1/2$.
