I have the following problem. Let $A$ be a set and $B\neq\emptyset$ be a proper subset. Prove the existence of a function $f:A\to A$ such that $f\circ f=f$ and $\text{im}~f=B$.
In the case where $A$ is finite, it suffices to pick a point of $B$, say $x$, and define $f(A)=\{x\}$ while $f_{|B}=\text{id}_{B\to B}$. If $A$ is infinite, I do not know if this argument carries over, as I am very unfamiliar with all possible uses of Axiom of Choice.
Thanks for any advice!
The axiom of choice is absolutely not needed here.
We only need to choose one element from $b$, since it's not empty we can do it. And the axiom of choice is not needed. Then simply map everything not in $B$ to $b$, while keeping the rest in place.
This is similar to the problem of inversing functions. The axiom of choice is needed in order to construct an injective inverse to a surjective function, but it is not needed in order to construct a surjective inverse to an injective function. (Well, between non-empty sets anyway.)
And this problem is a particular use for the above construction. Here the injection function is $f(b)=b$ from $B$ into $A$.