To show that f is a bijection, it must be shown that f is one-one and onto.
Let us first prove that it's one-one.
Definition of one-one: A function g is said to be one-one if:
g(x1)=g(x2)⟺x1=x2
Here, let (a1,b1),(a2,b2)∈A×B be two elements such that:
f(a1,b1)=f(a2,b2)
Then, using the definition of the function gives:
(b1,a1)=(b2,a2)⟹b1=b2 and a1=a2
∴(a1,b1)=(a2,b2)
This finishes the proof that f is one-one.
Now, to prove that it's onto:
Definition of onto: A function h:X→Y is said to be onto iff for every y∈Y, there exists an x∈X such that:
h(x)=y
Here, let (b,a) be any element of the set B×A.
Then the element (a,b) belongs to the set A×B
And we have that f(a,b)=(b,a).
This finishes the proof that f is onto.
Therefore, we have now proven that f is a bijection.