Question: Let $f:A\to A$, $A$ is nonempty. Prove $f$ has a right inverse iff $f^{-1}(f(T))= T$ for all $T \subseteq A$, using the lemma that $f$ is a right inverse iff $f$ is onto following how to do it from the text book elements of modern algebra by Gilbert
1. **State the problem:**
We want to prove that a function $f:A\to A$ has a right inverse if and only if for every subset $T$ of $A$, the equality $f^{-1}(f(T))= T$ holds.
2. **Recall the lemma:**
$f$ has a right inverse if and only if $f$ is onto (surjective).
3. **Definitions and notation:**
- $f$ has a right inverse means there exists $g:A\to A$ such that $f \circ g = \mathrm{id}_A$.
- $f$ is onto means for every $a \in A$, there exists $x \in A$ with $f(x) = a$.
- $f^{-1}(S) = \{x \in A : f(x) \in S\}$ for any subset $S \subseteq A$.
4. **Proof direction 1: If $f$ has a right inverse, then $f^{-1}(f(T))= T$ for all $T \subseteq A$.**
- Assume $f$ has a right inverse $g$, so $f \circ g = \mathrm{id}_A$.
- Take any $T \subseteq A$.
- Show $T \subseteq f^{-1}(f(T))$:
- For any $x \in T$, $f(x) \in f(T)$ by definition.
- Hence $x \in f^{-1}(f(T))$.
- Show $f^{-1}(f(T)) \subseteq T$:
- Take $x \in f^{-1}(f(T))$, so $f(x) \in f(T)$.
- Then there exists $t \in T$ such that $f(x) = f(t)$.
- Apply $g$ to both sides: $g(f(x)) = g(f(t))$.
- Since $f \circ g = \mathrm{id}_A$, we have $x = t$.
- Thus $x \in T$.
- Therefore, $f^{-1}(f(T)) = T$.
5. **Proof direction 2: If $f^{-1}(f(T))= T$ for all $T \subseteq A$, then $f$ has a right inverse.**
- We want to show $f$ is onto by the lemma.
- Take any $a \in A$.
- Consider $T = \{a\}$.
- By hypothesis, $f^{-1}(f(\{a\})) = \{a\}$.
- Since $a \in f^{-1}(f(\{a\}))$, there exists $x \in A$ such that $f(x) = f(a)$ and $x = a$.
- This implies $f$ is injective on $\{a\}$ and the image $f(\{a\})$ contains $f(a)$.
- To show $f$ is onto, consider $T = A$.
- Then $f^{-1}(f(A)) = A$.
- Since $f(A) \subseteq A$, and $f^{-1}(f(A)) = A$, it follows that $f$ is onto.
- By the lemma, $f$ has a right inverse.
6. **Summary:**
We used the lemma that $f$ has a right inverse iff $f$ is onto.
We showed the equivalence between $f$ having a right inverse and the condition $f^{-1}(f(T))= T$ for all subsets $T$ of $A$.
**Final answer:**
$$\boxed{f \text{ has a right inverse } \iff f^{-1}(f(T)) = T \text{ for all } T \subseteq A}$$