If $f \circ g = f$, prove that $f$ is a constant function.

Suppose $A$ is a nonempty set and $f: A \rightarrow A$ and for all $g:A \rightarrow A,$ $f \circ g = f$. Prove that $f$ is a constant function.

This result seems obvious, but I can't seem to find a way to prove it. The book I got this problem from hinted that the reader should consider what would happen if $g$ were a constant function. I considered that case and it was easy to prove that $f$ was a constant function, but I can't find any way to prove it when $g$ is not a constant function. At this point I'm not really sure how to approach this problem anymore. Thanks in advance for any help!


Solution 1:

The assumption is that $f\circ g=f$ for all $g:A\to A$. Thus, you can pick any $a_0\in A$ and let $g:A\to A:a\mapsto a_0$ and know that $$f(a)=f\big(g(a)\big)=f(a_0)$$ for all $a\in A$. This already tells you that $f$ is constant: it assigns the value $f(a_0)$ to every $a\in A$. You don’t need to consider any other functions $g:A\to A$.

Solution 2:

If $A$ is a one-element set, there is nothing to prove. If there are two distinct objects $a$ and $a'$ such that $f(a)\ne f(a')$, let $g$ be any function such that $g(a)=g(a')$.

Solution 3:

Suppose that $|A| = 1$. Then all functions $f:A \to A$ are constant.

Now suppose that $|A| > 1$ (or infinite). Let's suppose that $f$ is not constant. For my purposes, let's say that $f(0) = 0$ and $f(1) = 1$, and that we go from $\mathbb{R} \to \mathbb{R}$. But then suppose that $g(0) = g(1) = 0$.

Then we see that $f \circ g \neq f$.

Can you generalize this to your setting?