2
$\begingroup$

Let $n$ be a positive integer and let $(a_1,...,a_n)$ be a permutation of $\{1,2,...,n\}$. Define $$A_k = \{ a_i | a_i < a_k, i >k\} \\ B_k = \{a_i | a_i > a_k, i < k\}$$ for $1 \leq k \leq n$. Prove that $\sum^{n}_{k=1} |A_k| = \sum^{n}_{k=1} |B_k|$.

The problem confuses me a bit. It asks to prove that both sets will have the same cardinality, but for example, if I choose $n = 10$ and $k = 4$, for the $A_k$ part I will have $i > k$, which means $5...10$, so I have $6$ elements, while in the set $B_k$, I have $i < k$, so I will have $1...3$, meaning $4$ elements. Am I interpreting the problem correctly, if not, can someone improve and help?

$\endgroup$
0

3 Answers 3

5
$\begingroup$

Consider the permutation $\pi=(a_1,\ldots,a_n)$. For each $k$, $A_k$ is the set of terms of $\pi$ that are listed after $a_k$ and are smaller than $a_k$. If $\pi=(4,6,3,1,2,5)$, for instance, $A_3=\{1,2\}$: the terms $a_4=1$ and $a_5=2$ come after $a_3=3$ and are smaller than $a_3$. $A_2=\{1,2,3,5\}$: the terms $a_3=3,a_4=1,a_5=2$, and $a_6=5$ are all smaller than $a_2=6$. $B_k$, on the other hand, is the set of terms that are listed before $a_k$ and are larger than $a_k$, so $B_3=\{4,6\}$, and $B_2=\varnothing$: both of the terms before $a_3$ are larger than $a_3$, and none of the terms before $a_2$ is larger than $a_2$.

What we’re looking at here are inversions: if $1\le k<\ell\le n$, the pair $\langle k,\ell\rangle$ is an inversion of the permutation $\pi$ if $a_k>a_\ell$. In other words, each times an integer is listed before a smaller integer, we have an inversion.

HINT: Show that $\sum_{k=1}^n|A_k|$ and $\sum_{k=1}^n|B_k|$ both count the inversions.

$\endgroup$
11
  • $\begingroup$ I still don't get exactly the sets $A_k$ and $B_k$. For $A_k$ you say it is the terms that are listed after $a_k$ and are smaller than $a_k$, so in your example $A_3$, should be $A_3 = \{1,2\}$, cause they come after $a_3 = 3$ and are smaller than $3$. But you have written $A_3 = \{4,5\}$, where $4$ comes before $a_3 = 3$ and it also is bigger than it, and also $5$ is bigger than $3$. Also $A_2 = \{3,1,2,5\}$ according to your definition, not $A_2 = \{3,4,5,6\}$. Same for $B_3$, according to your definition $B_3 = \{4,6\}$, but you have $B_3 = \{1,2\}$. $\endgroup$
    – user72151
    Commented Nov 8, 2015 at 16:07
  • $\begingroup$ @portal: My apologies: for some reason I listed the indices of the terms instead of the terms themselves. Your numbers are correct, and I’ve fixed the answer. $\endgroup$ Commented Nov 8, 2015 at 19:58
  • $\begingroup$ Maybe I am missing something, but to me it seems that the inversions are counted in this sum once, not twice. (See also the examples posted in the other answer.) $\endgroup$ Commented Nov 8, 2015 at 21:22
  • $\begingroup$ @Martin: You are of course correct: when I wrote that, I was apparently mentally amalgamating the $A$s and $B$s. $\endgroup$ Commented Nov 8, 2015 at 21:25
  • $\begingroup$ I read in Wikipedia about inversions, and I understood that it is simply the number of pairs that are out of order in a permutation, and that we can count them using an inversion vector. For example, in the permutation that you have used in your answer, we have the inversion pairs, $(4,3), (4,1), (4,2), (6,3), (6,2), (6,1), (6,5), (3,1), (3,2)$, which is $9$ pairs, and I can easily see that $\sum_{k=1}^n|A_k| = 9$, because we will have $|A_1| = 3, |A_2| = 4, |A_3| = 2$, and the rest are zeroes. But, I'm having difficulty in providing an arguments that the sums count the inversions. $\endgroup$
    – user72151
    Commented Nov 9, 2015 at 16:47
1
$\begingroup$

For $n = 3$, we have the permutations $(1,2,3), (1,3,2), (2,1,3), (2,3,1), (3,1,2), (3,2,1)$. Using a simple Java program I wrote, I've enumerated the sets $A_k$ and $B_k$ for $ 1 \le k \le n$ for each permutation, as well as the value of $\sum^{n}_{k=1} |A_k|$ and $\sum^{n}_{k=1} |B_k|$ for each permutation below

(1, 2, 3)
A1 = {}
A2 = {}
A3 = {}
B1 = {}
B2 = {}
B3 = {}
sum |Ak| = 0
sum |Bk| = 0

(1, 3, 2)
A1 = {}
A2 = {2}
A3 = {}
B1 = {}
B2 = {}
B3 = {3}
sum |Ak| = 1
sum |Bk| = 1

(2, 1, 3)
A1 = {1}
A2 = {}
A3 = {}
B1 = {}
B2 = {2}
B3 = {}
sum |Ak| = 1
sum |Bk| = 1

(2, 3, 1)
A1 = {1}
A2 = {1}
A3 = {}
B1 = {}
B2 = {}
B3 = {2, 3}
sum |Ak| = 2
sum |Bk| = 2

(3, 1, 2)
A1 = {1, 2}
A2 = {}
A3 = {}
B1 = {}
B2 = {3}
B3 = {3}
sum |Ak| = 2
sum |Bk| = 2

(3, 2, 1)
A1 = {2, 1}
A2 = {1}
A3 = {}
B1 = {}
B2 = {3}
B3 = {3, 2}
sum |Ak| = 3
sum |Bk| = 3

I'm still working on a formal proof to answer this question, which I'll try to add to this answer later.

For now, does this clarify what the problem is asking?

$\endgroup$
0
$\begingroup$

Let us change the notation a bit (simply by renaming the variables). We have $$ \begin{align*} A_k &= \{a_i; a_i<a_k, i>k\}\\ B_i &= \{a_k; a_k>a_i, k<i\} \end{align*} $$ Now the relation between these two sets is more obvious.

We can also rewrite the above equalities as $$ \begin{align*} |A_k| &= |\{(a_i,a_k); a_i<a_k, i>k\}|\\ |B_i|&=|\{(a_i,a_k); a_i<a_k, i>k\}| \end{align*} $$

Now we can see that both sums express the same thing - namely the number of pairs $(a_i,a_k)$ such that $a_i<a_k$ and $i>k$. That is, the number of inversion of the given permutation (see Wikipedia, MathWorld or elsewhere.)


In your post you find an example for which $|A_k|\ne|B_k|$. That is possible, but this is not the claim you are trying to prove. You are trying to show that $\sum\limits_{k=1}^n|A_k|=\sum\limits_{k=1}^n|B_k|$. In order to have the same sume, the summands need not necessarily be the same.

$\endgroup$
5
  • $\begingroup$ I simply don't get why you can exchange $i$ and $k$ indices without changing the meaning of the sets. I see that the original $A_k$ set, which is defined like, $A_k = \{ a_i | a_i < a_k, i >k\}$, means that we take the terms that come after $a_k$, and are smaller than $a_k$ in value. While, the changed set you have, $A_k = \{a_k; a_i<a_k, i>k\}$, gives me an impression, that we take the terms that come after $a_k$, but are bigger than $a_k$ in value. $\endgroup$
    – user72151
    Commented Nov 9, 2015 at 16:37
  • $\begingroup$ @portal You are right, in the set $A_k$ I head a typo. What I meant was to interchange $i$ and $k$ in the definition of $B_k$. (Which, of course, can be done. These letters are just names of variables and it does not matter how they are called.) I hope that I did not make some more typos there. $\endgroup$ Commented Nov 9, 2015 at 16:41
  • $\begingroup$ Yes, now looks fine, $B_k$ is the same set as in the original problem. But, I don't exactly understand this part $|A_k| = |\{a_i; a_i<a_k, i>k\}| = |\{a_k; a_i<a_k, i>k\}| = |B_k|$, as long as I understood, you have said that cardinality of $A_k$ is the same as the cardinality of $B_k$, or I understood it like that, because after all $A_k = \{a_i; a_i<a_k, i>k\}$, and $B_k = \{a_k; a_i<a_k, i>k\}$. How can we be sure that they have the same cardinality? I simply don't see it. $\endgroup$
    – user72151
    Commented Nov 9, 2015 at 17:01
  • $\begingroup$ @portal They are not of the same cardinality and I did not claim that in my post. But you are right that the equality you copied from my post to your last comment is nonsense. Luckily, the two most relevant equalities $|A_k| = |\{(a_i,a_k); a_i<a_k, i>k\}|$ and $|B_i| = |\{(a_i,a_k); a_i<a_k, i>k\}|$ are still true. (In my last edit I have tried to both correct the mistakes and rewrite this in a way which is a bit clearer.) I apologize for the mistakes. $\endgroup$ Commented Nov 9, 2015 at 17:13
  • $\begingroup$ Thanks Martin. I got your idea, and I see that both sums express the same thing, and that we are talking about inversions. But, I still have a trouble to explain this to someone else. I mean okay, we change the variables of $B$ so that both sets point to the same thing, and in the pair one number comes from $A$, one from $B$, but if someone asks me, how did you conclude that they both express pairs, I can only say, because both sums have the same structure. $\endgroup$
    – user72151
    Commented Nov 10, 2015 at 18:05

You must log in to answer this question.