Let's say I have a permutation of $n$ integers defined like this $(a_1, a_2,\ldots,a_n)$. I have also two sets defined like this $A_k = \{ a_i | a_i < a_k, i > k\}$ and $B_i = \{a_k | a_k > a_i, i > k\}$. Clearly, we are talking about inversions, but I read an argument somewhere, that the above sets can be rewritten as:
$$|A_k| = |\{(a_i, a_k) | a_i < a_k, i > k \}| = |B_i|$$
I see that it talks about inversions, and that one element comes from the set $A_k$, and one from $B_i$. And the sets count the number of inversions. But, how did I get to the above equality from my two initial sets? Is there any intermediate step that I'm missing? I need to explain this to someone highly mathematical, and although I do get the general idea of inversions and what the sets tell us, I still kind of lack the explanation. Any more elaborate explanation?