Proving $f(f^{-1}(x))=x$ While reading about inverse functions I found a statement showing "$f\{f^{-1}(x)\}=x$". I know it is correct but I tried to prove it by taking an simple example.

Suppose there is a function $y=f(x)$ given as, $f:$ $\ce{A=B}$. Here $A$ and $B$ represents domain and range respectively and are sets given as $A=\{1\}$ &amp; $B=\{2\}$, then $f(x)$ can be also written as $f(x)=\{(1,2)\}$. So for $x=1$ (domain), $y=2$ (range). Where $1$ belongs to $A$ and $2$ belongs to $B$.  

Also $f^{-1}(x)=\{(2,1)\}$.
Now $f\{f^{-1}(x)\}=\{(2,2)\}$, i.e. identity function of range $y$, i.e. set $B$. As in identity function range $=$ domain. Therefore $y=x$. Hence $f\{f^{-1}(x)\}=x$ Am I correct in explaining this? As I think my method of explanation is wrong. Please tell me the right one &amp; please point out my mistakes.
Let $f:X \to Y$ and $A \subseteq Y$. The preimage of a set is defined as follows:

$$f^{-1}(A)=\{x \in X \mid f(x) \in A\}.$$

This means that the preimage of $\{x\}$ (i. e. $f^{-1}(\{x\})$ are exactly the elements so that $f$ applied them lands you in $\{x\}$, as in $f(f^{-1}(\{x\}))=x.$
Consider $f:A\longrightarrow B$ such that given $a\in A$, $f(a)=b$ and suppose there exists $f^{-1}:B\longrightarrow A$ that, given $b\in B$, $f^{-1}(b)=a$. 

We define the identity function as follows:
$$Id_{A}:A\longrightarrow A$$
$$a\mapsto Id_{A}(a)= a$$
$$Id_{B}:B\longrightarrow B$$
$$b\mapsto Id_{B}(b)= b$$

If we define
$$f(f^{-1}):B\longrightarrow B$$
$$b\mapsto f(f^{-1}(b))=f(a)=b$$
And
$$f^{-1}(f):A\longrightarrow A$$
$$a\mapsto f^{-1}(f(a))=f^{-1}(b)=a$$

Therefore, the composition of inverses acts like $Id_{A}$ and like $Id_{B}$. As they are defined on the same domain, we have that:

$$f(f^{-1})=Id_{B}$$
$$f^{-1}(f)=Id_{A}$$