Finding $f(B)$, $f^{-1}(C)$ and $f(D)$ when $f: \mathcal P(\mathbb Z)\to \mathcal P(\mathbb Z)$, $f(X)=X'$

As you do, I will assume that $\mathbb{N}$ does not contain $0$, and define $\mathbb{Z}^- := \{n \in \mathbb{Z} : n < 0\}$.


First, by definition \begin{align*} f(B) &= \{f(\{3 k : k \in \mathbb{N}\}), f(\emptyset)\}\\ &= \{\mathbb{Z} \setminus \{3 k : k \in \mathbb{N}\}, \mathbb{Z} \setminus \emptyset\}\\ &= \{\{0\} \cup \mathbb{Z}^- \cup \{3 k - 2 : k \in \mathbb{N}\} \cup \{3 k - 1 : k \in \mathbb{N}\}, \mathbb{Z}\}. \end{align*} This is a bit different to what you have written (you are missing the negative multiples of $3$).


Next, the statement $f^{-1}(C) = C'$ is not correct. For starters, $f^{-1}(C)$ should be a subset of $\mathcal{P}(\mathbb{Z})$ and not merely $\mathbb{Z}$. By the definition of the preimage we instead have \begin{align*} f^{-1}(C) &= \{S \in \mathcal{P}(\mathbb{Z}) : f(S) \in C\}\\ &= \{S \in \mathcal{P}(\mathbb{Z}) : \mathbb{Z} \setminus S \in C\}\\ &= \{S \in \mathcal{P}(\mathbb{Z}) : \mathbb{Z} \setminus S = \{n : n \in \mathbb{Z}, 2 \mid n\}\} \cup \{S \in \mathcal{P}(\mathbb{Z}) : \mathbb{Z} \setminus S = \mathbb{N}\}\\ &= \{S \in \mathcal{P}(\mathbb{Z}) : S = \mathbb{Z} \setminus \{n : n \in \mathbb{Z}, 2 \mid n\}\} \cup \{S \in \mathcal{P}(\mathbb{Z}) : S = \mathbb{Z} \setminus \mathbb{N}\}\\ &= \{S \in \mathcal{P}(\mathbb{Z}) : S = \{n : n \in \mathbb{Z}, 2 \not\mid n\}\} \cup \{S \in \mathcal{P}(\mathbb{Z}) : S = \{0\} \cup \mathbb{Z}^-\}\\ &= \{ \{2 n + 1 : n \in \mathbb{Z}\}, \{0\} \cup \mathbb{Z}^- \}. \end{align*} Nonetheless, your calculation has come out right.


Finally similarly we can compute that \begin{align*} f^{-1}(\{D\}) &= \{S \in \mathcal{P}(\mathbb{Z}) : \mathbb{Z} \setminus S = D\}\\ &= \{S \in \mathcal{P}(\mathbb{Z}) : S = \mathbb{Z} \setminus D\}\\ &= \mathbb{Z} \setminus D\\ &= \{n : n \in \mathbb{Z}, \text{ $n$ is not prime}\}. \end{align*} This agrees with your calculation (in this case the slight modification $f^{-1}(\{D\}) = D'$ is true, unlike the previous case). I hope this helps!