This is my first attempt at a proof so I feel it's probably wrong. A problem similar to this one
For a function $f:S\to S$, if $f$ is injective, then $f\circ f\circ f$ is injective
Suggested using proof by contrapositive but something feels off about it. The book (Rudins Analysis) cryptically suggests 'Suppose $f(a)=f(b)$ and apply $f$ to both sides.' as the solution to this problem but I'm still not sure how that becomes a formal proof so here's my attempt.
Suppose $a \in S$ and $b \in S$. By definition $f(f(a))=f(f(b))$ implies that $f(a)=f(b)$.
Using proof by contrapositive, if $f$ is not injective there exists a value $a'$ that is not $a$ such that
$\exists a' \ni f(a)=f(a') \text{ and } a \neq a'$
but applying the function $f$ to both sides implies
$\exists f(a') \ni f(f(a))=f(f(a')) \text{ and } f(a) \neq f(a')$
This contradicts the assumption that $f \circ f$ is injective thus proving by contradiction. $\blacksquare$
Best Answer
You wrote that “By definition $f(f(a))=f(f(b))$ implies that $f(a)=f(b)$.” By definition of what?
Then you wrote that “there exists a value $a′$ that is not $a$”. What is $a$?
You can prove it following Rudin's suggestions: is $f$ is not injective, then there are $a,b\in S$ such that $a\neq b$ and that $f(a)=f(b)$. But then $f\bigl(f(a)\bigr)=f\bigl(f(b)\bigr)$, which is impossible, since we are assuming that $f\circ f$ is injective.