Prove that a function $f: A \rightarrow B$ is surjective if $f(f^{-1}(Y)) = Y$ for all $Y \subseteq B$.
My approach:
Suppose $f(f^{-1}(Y)) = Y$ for all $Y \subseteq B$. Now suppose $b \in B$. We want to show that there exists an element $a \in A$ for which $f(a) = b$.
Consider the set $\{b\}$. Since $\{b\} \subseteq B$, it must be that $f(f^{-1}(\{b\})) = \{b\}$.
Now, for the sake of contradiction, suppose that $f^{-1}(\{b\}) = \emptyset$. Then $f(f^{-1}(\{b\})) = \{f(x) : x \in f^{-1}(\{b\})\} = \{f(x) : x \in \emptyset\} = \emptyset$, a contradiction because $f(f^{-1}(\{b\})) = \{b\}$ as stated above. Hence $f^{-1}(\{b\}) \neq \emptyset$.
Then there must exist an element $a \in f^{-1}(\{b\}) = \{x \in A : f(x) \in \{b\}\}$. Therefore $f(a) = b$, so $f$ is surjective.
Is this correct?
Note: This question was already asked in this thread, however, there were only answers given for the direction "$f$ is surjective $\Rightarrow$ $f(f^{-1}(Y)) = Y$" and not the other way around.
Thanks in advance!