Combinatorics of permutations part 3 Marilena Barnabei Università di Bologna Inversions of a permutation Let σ = x1x2…xn be a permutation in Sn. The pair of values (xi, xj) is said to be an inversion of σ if i < j and xi > xj. The number of inversions of σ is denoted by the symbol inv(σ). Example σ = 3 1 5 2 4 has 4 inversions, namely, (3, 1), (3, 2), (5, 2), (5, 4). Obviously, ⎛ ⎞ 0 ≤ inv(σ ) ≤ ⎜n ⎟, ⎝ 2 ⎠ and the minimum value is attained only by the identity permutation € ε, while the maximum is attained only by the reverse permutation ψ. Denote by Invn(x) the generating function of inversions of the permutations in Sn: Inv n (x) = ∑ x inv(σ ). σ ∈Sn € Theorem For every integer n ≥ 2 we have: (*) Inv n (x) = (1+ x)(1+ x + x 2 )L(1+ x + x 2 +K + x n−1). Proof We want to prove that each one of the n! monomials we obtain by performing the products in the right-hand side of (*) € corresponds to a permutation in Sn. We proceed by induction on n. For n = 2, the permutation 1 2 has no inversions (hence, it corresponds to the term 1), and 2 1 has one inversion (and it corresponds to the term x). Hence the assertion is true. Suppose now the assertion true for Sn–1. If σ is a permutation in Sn–1, we insert (in n different ways) the symbol n in σ to get a permutation σ in Sn. Inserting n in the i-th position gives rise to a number of new inversions (with respect to the inversions of σ) equal to the number of elements to the right of n, namely, n–i. Hence, the monomial corresponding to σ is now multiplied by xn–i, and we get Invn(x) = (1 + x + x2 + ... + xn–1) Invn–1(x). This gives the assertion. Denote by B(n,k) the number of permutations in Sn with k inversions, namely, the coefficient of xk in the polynomial Invn(x). The sequence B(n,k) has a symmetry similar to the symmetry of Eulerian numbers, namely, B(n,k) = B(n, ( ) − k). n 2 In fact, if a permutation σ has k inversions, its reverse σr ⎛n ⎞ has ⎜ ⎟ − k inversions. ⎝ 2 ⎠€ Moreover: € Theorem For every n, the sequence B(n,0), B(n,1),K, B(n, is log-concave. ( )) n 2 Proof It is easily seen that the convolution product of log € sequences is log-concave. Since, for every k, the -concave sequence of coefficients of the polynomial 1 + x + ... + xk is obviously log-concave, the assertion follows from the preceding result. The inversion table k n 0 1 2 3 4 5 6 5 3 1 7 8 9 10 4 1 1 1 2 1 1 3 1 2 2 1 4 1 3 5 6 5 1 4 9 15 20 22 20 15 9 Theorem For every k ≤ n we have: B(n+1,k) = B(n+1,k–1) + B(n,k). Proof Let σ = x1x2…xn+1 be a permutation in Sn+1 with k ≤ n inversions. If xn+1 = n+1, we can delete the last element of σ leaving the number of inversions unchanged, hence obtaining a permutation in Sn with k inversions. Every such permutation can be obtained in this way. If xi = n+1 for i ≤ n, interchange xi and xi+1. The resulting permutation σ has now k–1 inversions. Note that in σ the element n+1 is not at the first position. On the other hand, in every permutation in Sn+1 whose number of inversions is k–1 < k ≤ n the greatest symbol occupies a position different from the first one, since, when the symbol n+1 is at the first position, the number of inversions of the permutation is at least n. Hence, in this way we get all permutations in Sn+1 with k–1 inversions. Major index Let σ be a permutation in Sn. The major index of σ is defined to be the sum of its descents : maj(σ ) = ∑i. i∈Des(σ ) Example Let σ = 3 5 2 4 6 1. Then Des(σ) = {2,5}, hence maj(σ) = 7. € Theorem The two statistics “number of inversions” and “major index” are equidistributed in Sn, namely, ∑ x inv(σ ) = ∑ x maj(σ ). σ ∈Sn σ ∈Sn Proof We define recursively a bijection φ of Sn into itself, such € that for every σ we have maj(σ) = inv(φ(σ)). If n ≤ 2, set φ(σ) = σ. If n > 2, we add numbers to φ(σ) one at a time: suppose σ = σ1σ2…σn and begin by setting φ(1) = σ1, φ(2) = σ1σ2. To find φ(3), start with σ1σ2σ3. Then if σ3 > σ2, draw a bar after each element of σ1σ2σ3 which is less than σ3, while if σ3 < σ2, draw a bar after each element of σ1σ2σ3 which is greater than σ3. Also add a bar before σ1. For example, if σ = 4137562, we now have |41|3. Now regard the numbers between two consecutive bars as “blocks”, and in each block, move the last element to the beginning, and finally remove all of the bars. We end up with φ(3) = 143. Proceeding inductively, we begin by adding σi to the end of φ(i−1). Then if σi > σi−1,draw a bar after each element of φ(i−1) which is less than σi, while if σi < σi−1, draw a bar after each element of φ(i−1) which is greater than σi . Also draw a bar before the first element of φ(i−1). Then in each block, move the last element to the beginning, and finally remove all of the bars. If σ = 4137562, the successive stages of the algorithm yield 143 = φ(3) |1|4|3|7 → 1437 = φ(4) |1437|5 → 71435 = φ(5) |71|4|3|5|6 → 174356 = φ(6) |17|4|3|5|6|2 → 7143562 = φ(7), so φ(4137562) = 7143562. Note that maj(4137562) = 11 = inv(7143562). It is easily seen by induction that the map φ is a bijection. Bruhat order The Bruhat order relation over Sn is defined as follows: σ < τ if σ can be obtained from τ multiplying it by a finite number of transpositions, each one of which involves the elements of an inversion of τ. Example The Hasse diagrams of S2 and S3 are the following: 321 21 12 231 312 132 213 123 S2 S3 Theorem The set Sn endowed with the Bruhat order is ranked. Proof We show that, if the permutation τ = x1x2…xn covers σ, then τ has exactly one more inversion than σ. In fact, if τ covers σ, σ can be obviously obtained from τ by interchanging the elements xi, xj (with xj < xi and i < j) of a single inversion. Hence, σ = τ (xi xj). Suppose that τ has at least two inversions more than σ. This implies that there exists an index k such that i < k < j and xj < xk < xi. In this case, setting π = τ (xi xk), we have σ < π < τ, and τ does not cover σ. Hence, all saturated chains between the minimum of the poset (namely, the identity permutation) and a given permutation σ have length inv(σ), and this is the rank of σ. Let σ = x1x2…xn be a permutation. For every pair (a, b) with 1 ≤ a, b ≤ n, set σ(a, b) = |{i ≤ a; xi ≥ b}|. In the graphical representation of σ, σ(a, b) is the number of points of σ lying in the rectangle with basis a and height n–b+1, attached to the north-west corner of the grid: σ = 3 7 1 4 2 5 6; σ(4, 3) = 3. Theorem σ ≤ τ in the Bruhat order if and only if σ(a, b) ≤ τ(a, b) for every a, b. Proof Suppose σ ≤ τ. Note that, interchanging in τ the elements of any inversion, the numbers τ(a, b) can not increase. Hence σ(a, b) ≤ τ(a, b) for every a, b. Conversely, suppose σ(a, b) ≤ τ(a, b) for every a, b. Let σ = x1x2…xn, τ = y1y2…yn, and set a = n–1. The condition σ(n–1, b) ≤ τ(n–1, b) for every b implies xn ≥ yn. If xn = yn, we can delete the last element from σ and τ, and show that σ ≤ τ by induction. If xn > yn, then in τ there is an element yi such that yi = xn and i < n. This implies that (yi, yn) is an inversion of τ , the permutation π = τ (yi, yn) is such that π < τ, and π has the same last element than σ. It is easy to verify that σ(a, b) ≤ π(a, b) for every a, b, hence we can proceed again by induction. € τ = 3 7 1 4 2 5 6; τ(4, 3) = 3. σ = 1 2 3 4 7 5 6; σ(4, 3) = 2. Theorem σ ≤ τ in the Bruhat order whenever σ‒1 ≤ τ‒1. Proof By the preceding result it suffices to show that, if σ(a, b) ≤ τ(a, b) for every a, b, then σ‒1(a, b) ≤ τ‒1(a, b) for every a, b. Recall that the graphical representation of σ‒1 is obtained from that of σ by flipping it around the main diagonal. We must prove that, if we choose any south-east rectangle, it contains at most as many points of σ as of τ. Choose two values a and b, and suppose that the north-west rectangle with basis a and height b contains A points of σ and B points of τ; then the other rectangles contain the number of points in the figure: A a–A n–A–b+1 A+b–a–1 B a–B σ Since, by hypothesis, A ≤ B, we have also A+b–a–1 ≤ B+b–a–1, and the assertion is true. n–B–b+1 B+b–a–1 τ The cycle decomposition of a permutation The type of a permutation σ is defined to be the n-tuple (a1, a2, ..., an), where ai denotes the number of cycles of length i in the cycle decomposition of σ. N.B. Sometimes, the type of σ is defined also to be the sequence of its cycle lengths, written in non-increasing order. In this case, of course, the type is a partition of the integer n. Example Let σ = 2 8 3 7 6 5 1 4 9 = (9) (56) (3) (12847). The type of σ is either the 9-tuple (2, 1, 0, 0, 1, 0, 0, 0, 0), or the partition of 9 λ = (5, 2, 1, 1). Recall that two permutations σ, τ are conjugate (namely, there exists a permutation γ such that τ = γ-1 σ γ) if and only if they have the same type. Theorem Let (a1, a2, ..., an) be an n-tuple of non-negative integers such that n ∑ i ai = n. i=1 The number of permutations in Sn of type (a1, a2, ..., an) equals n! € a1 a2 a1! a2!Lan ! 1 2 Ln an . Proof Write the integers 1, 2, ..., n in any order (n! ways). Then € put some parentheses, denoting the cycles, in such a way that the first a1 elements are the 1-cycles of the permutation, the following 2a2 form the 2-cycles, and so on. In this way we get all permutations of type (a1, a2, ..., an). Every such permutation appears many times. In fact, for every i, the ai cycles of length i can be rearranged (in i! ways), and within every cycle the elements can be cyclically permuted (i cyclic permutations for each one of the ai cycles). Example Let n = 4, and consider the type (2, 1, 0, 0). The permutation (1) (3) (24) comes from 4 = 2!. 21 permutations, namely, 1324 (1) (3) (24) 1342 (1) (3) (42) 3124 (3) (1) (24) 3142 (3) (1) (42) The signless Stirling numbers of the first kind Denote by c(n,k) the number of permutations in Sn which can be decomposed into k disjoint cycles. The numbers c(n,k) are called the signless Stirling numbers of the first kind. We have: • c(0,0) = 1 (convention); • c(n,0) = 0 for n > 0; • c(n,1) = (n–1)!; • c(n,n) = 1; ⎛n ⎞ • c(n,n–1) = ⎜ ⎟. ⎝ 2 ⎠ € Theorem For every n, k ≥ 0 we have: c(n +1,k) = n c(n,k) + c(n,k − 1). Proof Consider a permutation in Sn+1 with k cycles; the element n+1 can € be a fixed point, and hence it is a cycle of length 1; then, if we remove it, we get a permutation in Sn with k–1 cycles. Otherwise, the element n+1 belongs to a cycle of length at least 2. If we remove this element we get a permutation in Sn with k cycles. In this last case, the same permutation in Sn is obtained n times. Example The permutation in S8 whose cycle decomposition is (5 6 8) (2 4 3) (1 7) can be obtained by deleting the symbol 9 from the following 8 permutations in S9: (5 9 6 8) (2 4 3) (1 7) (5 6 8 9) (2 4 3) (1 7) (5 6 9 8) (2 4 3) (1 7) (5 6 8) (2 9 4 3) (1 7) (5 6 8) (2 4 9 3) (1 7) (5 6 8) (2 4 3 9) (1 7) (5 6 8) (2 4 3) (1 9 7) (5 6 8) (2 4 3) (1 7 9) The table of the signless Stirling numbers of the first kind k n 0 1 2 3 4 5 1 1 2 0 1 3 0 0 1 4 0 2 3 1 5 0 6 11 6 1 6 0 24 50 35 10 7 0 720 1764 1624 735 175 6 7 21 1 1 Theorem For every positive integer n we have: n x(x +1)L(x + n − 1) = ∑ c(n,k) x k . k =0 Proof Denote by b(n,k) the coefficient of xk in the polynomial pn(x) € = x(x+1)...(x+n–1). We have of course b(n,0) = 0 for every n > 0, and b(0,0) = 1. Moreover, since pn(x) = (x+n–1) pn–1(x), the coefficients b(n,k) satisfy the same recurrence as the numbers c(n,k), namely b(n+1,k) = b(n,k–1) + n b(n,k). This implies that the two sequences coincide. Corollary For every n > 0 the polynomial c(n,1) x + c(n,2) x2 + ... + c(n,n) xn has only real zeros, hence, the sequence of its coefficients is log-concave. The Stirling numbers of the first kind The Stirling numbers of the first kind s(n,k) are defined to be the coefficients in the expansion of the polynomials (x)n with respect to the basis xk: (x)n = n ∑ s(n,k) x k . k =0 Since, of course, (x)n+1 € = (x–n) (x)n = x (x)n – n (x)n, the sequence s(n,k) satisfies the recurrence s(n +1,k) = s(n,k − 1) − n s(n,k). Comparing this with the recurrence satisfied by the sequence c(n,k), and considering the initial values, we get € s(n,k) = (−1)n−k c(n,k). € Theorem Consider the generating function n F(x,u) = ∑ un ∑ s(n,k)x n! . k n≥0 k =0 We have: € F(x,u) = (1+u)x. Proof The coefficient of un in F(x,u) is n 1 (x)n ⎛ x ⎞ k s(n,k) x = = ⎜ ⎟, ∑ n! n! ⎝ n ⎠ k =0 and this is precisely the coefficient of un in (1+u)x. € Recall that, for every n, we have n x = n ∑ S(n,k) (x)k , k =0 where S(n,k) are the Stirling numbers of the second kind. Hence, we € get : ⎧1 if n = m ∑ s(n,k)S(k,m) = ⎨ ⎩0 if n ≠ m k € Permutations as product of transpositions Recall that every permutation can be written as product of transpostions (= permutations consisting of one cycle of length 2 and n–2 cycles of length 1). There are many ways of writing a permutation as a product of (not necessarily disjoint) transpositions. We want to determine the number of such minimal representations. We can restrict our attention to cyclic permutations, recalling that a cycle of length k is the product of (at least) k–1 transpositions. First of all, we can determine a criterion that allows us to decide whether the product of n–1 transpositions is a cycle of length n. Let t1, t2, ..., tq be transpositions of Sn. We associate to the q-tuple (t1, t2, ..., tq) a graph G(t1, t2, ..., tq) with vertex set {1, 2, ..., n} and q edges, as follows: two vertices a, b are adjacent in the graph if there exists an index such that ti = (a, b). Conversely, given a graph with n vertices with labels from 1 to n and q edges, we can associate to it a set of q transpositions in Sn, and hence q! (not necessarily distinct) permutations obtained by multiplying the q transpositions, in every possible order. Examples 1. Consider the 5 transpositions in S6: t1 = (1, 2), t2 = (1, 4), t3 = (1, 5), t4 = (2, 3), t5 = (3, 4). The graph G(t1, t2, t3, t4, t5) is: 2 1 3 6 4 5 2. Consider now t1 = (1, 3), t2 = (1, 4), t3 = (2, 5), t4 = (2, 6), The graph G(t1, t2, t3, t4, t5) is: 1 2 3 6 4 5 t5 = (3, 4), Recall that a tree is a connected graph without circuits. As a consequence, a tree with n vertices has n–1 edges. Theorem Let t1, t2, ..., tn–1 be distinct transpositions in Sn. The product σ = t1 t2 ... tn–1 is a cyclic permutation if and only if the graph G(t1, t2, ..., tn–1) is a tree. Proof Suppose σ is a cycle. Then for every a = 2, ..., n there exists an integer k such that σ k(1) = a. This implies that in the graph there is a path (= a sequence of adjacent edges) from 1 to a, hence, the graph is connected. Since G has n–1 edges, it is a tree. Conversely, suppose that the graph G(t1, t2, ..., tn–1) is a tree. We prove that the permutation σ is a cycle by induction on n. For n = 2 the assertion is trivially verified. Suppose now the assertion true for n–1. Consider a leaf a (= a vertex incident with a single edge) of the graph G(t1, t2, ..., tn–1). Deleting from G the vertex a and the unique edge incident with it (corresponding to some transposition tk = (a, b)) we obtain a tree G’ with n–1 vertices and n–2 edges. By induction hypothesis, this tree corresponds to a cyclic permutation τ in Sn–1. Since a is a leaf of G, there is a unique transposition among t1, t2, ..., tn–1 containing a, namely, tk. This implies that the product τ tk is a cycle of length n. Example Consider the 5 transpositions in S6: t1 = (1, 2), t2 = (1, 4), t3 = (1, 6), t4 = (2, 3), The graph G(t2, t3, t4, t5, t6) is a tree: 1 4 6 2 3 5 and the product t1 t2 t3 t4 t5 = 3 4 5 6 2 1 = (135246) is a cycle. t5 = (2, 5). Corollary Let t1, t2, ..., tn–1 distinct transpositions in Sn. If the product t1 t2 ... tn–1 is a cyclic permutation, then every other product tτ(1) tτ(2) ... tτ(n–1) is a cyclic permutation, for every index permutation τ. Example Consider the transpositions of the preceding example: t1 = (1, 2), t2 = (1, 4), t3 = (1, 6), t4 = (2, 3), t5 = (2, 5). The associated graph is the tree 1 4 6 2 3 5 Multiplying the same transpositions in a different order, we get for example the cycle t3 t2 t4 t5 t1 = 6 3 5 2 1 4 = (164235). We need to know the number of distinct trees with n vertices labelled 1, 2, ..., n. Theorem (Cayley) Foe every n ≥ 2 the number of trees with vertex set [n] = {1, 2, ..., n} is nn–2. Proof Denote by Tn the number of trees with vertex set [n]. We count in two different ways the number of sequences of edges that can be added to the empty graph to obtain a rooted tree (= a tree with a selected vertex, called root). We can costruct one of such sequences by choosing one of the Tn trees with n vertices, choosing the root (n choices), and choosing one of the (n–1)! possibile sequences of adding the edges of the chosen graph. Hence, n! Tn possible choices. Another way of counting the rooted trees is adding step by step an edge to the empty graph, counting the number of choices available at each step. Suppose we have chosen n–k edges. At this point, the graph we obtained is certainly without circuits, but not necessarily connected: it will be the union of k rooted trees. At this step we have n(k–1) possible choices for the next edge: its first vertex v can be chosen among the n available vertices, and the second vertex r can be chosen among the roots of the trees not containing the vertex v (k–1 choices). After adding the edge (v, r), we obtain the union of k–1 trees: the tree containing v and the tree containing r are now the same. We choose the root of the tree containing v to be the root of the “new” tree. Multiplying the number of choices we have at the first, second step,. etc., we obtain the total number of choices, namely, n ∏ n(k − 1) = nn−1(n − 1)! = nn−2 n!. k =2 This gives the assertion. € Example The Tn trees for the first values of n: n=2 1 n=3 2 1 2 1 2 3 3 3 1 2 n=4 1 4 1 4 1 3 1 2 2 3 3 2 2 4 3 4 2 4 2 3 2 4 2 1 1 3 1 4 3 1 3 4 3 4 3 2 3 1 3 4 1 2 1 4 2 4 2 1 1 4 2 4 4 2 4 3 1 3 1 3 1 2 2 3 Theorem There are nn–2 ways of writing a given cyclic permutation in Sn as the product of n–1 transpositions. Proof We can consider without loss of generality the cyclic permutation (12...n). We will define a bijection between the set of all trees with vertex set [n] and the set of (n–1)-tuples of transpositions (t1, t2, ..., tn–1) such that t1 t2 ... tn–1 = (12...n). Let T be a tree with vertex set [n]. For every vertex i = 2,3,...,n there exists in T a path from 1 to i, whose last edge is (a, i). Denote by si the transposition (a i), and set τ = s2 s3 ... sn. By a previous result τ is a cyclic permutation. Define now a new permutation π by setting for every k = 1,2,...,n, π(k) = τk–1(1). It is easily checked that π τ π–1 = (12...n). For every i set ti = π si π–1. We have: • t2, t3, ..., tn are transpositions; • t2 t3 ... tn = π τ π–1 = (12...n). We have defined a function Φ that maps a tree T to an (n–1) -tuple (t2, t3, ..., tn) of transpositions such that t2 t3 ... tn = (12...n). We must now prove that Φ is a bijection. To do this, we observe that, given a tree T with vertex set [n], the map Φ associates with T an (n–1)-tuple of transpositions (t2, t3, ..., tn) such that t1 t2 ... tn–1 = (12...n) and a permutation π previously defined. Note that T is exactly the tree G(s2, s3, ..., sn) associated with the set of transpositions {s2, s3, ..., sn}, with si = π–1ti π. This implies that, if we modify the labels of the vertices of T according to the permutation π–1, we get the tree associated with {t2, t3, ..., tn}. Hence, the map Φ is injective. Given now an (n–1)-tuple of transpositions (t2, t3, ..., tn) with t1 t2 ... tn–1 = (12...n), consider the tree G(t2, t3, ..., tn). For every i = 2, 3, ..., n, let xi be the further vertex of the edge ti in the path from the vertex 1 to the vertex i in G. We define a permutation ξ in Sn by setting ξ(1) = 1, ξ(xi) = i for i = 2, 3, ..., n. Denote by T the tree obtained from G by relabelling its vertices according to the permutation ξ. We have Φ(T) = (t2, t3, ..., tn). In fact, the permutation ξ coincides with the permutation π associated with T, since the edges of T correspond to the transpositions ξ–1ti ξ. Example Consider the tree T: 3 4 6 2 5 1 7 8 The map associates with T the transpositions t2 = (14), t3 = (24), t4 = (34), t5 = (16), t6 = (56), t7 = (17), t8 = (1 8), and the permutation π = 1 3 4 2 6 5 7 8, with π–1 = 1 4 2 3 6 5 7 8. The tree G(t2, t3, ..., t8) is 2 3 5 4 6 1 7 8 and it is obtained from T by relabelling the vertices according to π–1. Multisets Let U be a non-empty set. A multiset in U of length n is a map m :U → N such that ∑m(x) = n. x∈U € For every x in U, the value m(x) is called the multiplicity of x in m. € of m is defined to be the set The support Supp(m) = {x ∈ U; m(x) > 0}. If m is a multiset in U of length n, with Supp(m) = {x1, x2, ..., xk}, the following notation is often used: h h m = {x1 1 ,x2 2 ,K,xk hk }, where hi = m(xi), or also, € m = {x1,K,x1, x2 ,K,x2 ,K,xk ,K,xk }. 1 424 3 1424 3 1424 3 h1 times h2 times k We have of course ∑ hi = n. i=1 € € hk times Theorem Let U be a finite set of cardinality s. The number of multisets in U of length n is ⎛s + n − 1⎞ ⎜ ⎟. ⎝ n ⎠ Proof Without loss of generality, suppose U = {1, 2, ...., s}. Given a multiset in U of length n, m = {x1, x2, ..., xn}, with € x1 ≤ x2 ≤ ... ≤ xn, for every i set yi = xi + i – 1. The elements y1, y2, ..., yn are distinct, hence they are a subset of {1, 2, ...., s+n–1}. So, we have defined a bijection between the family of multisets in U of length n and the family of subsets of {1, 2, ...., s+n–1} of cardinality n. This gives the assertion. Permutations of multisets and multinomial coefficients Let h h h m = {x1 1 ,x2 2 ,K,xk k } be a multiset in U = {1, 2, ..., s} of length n. A permutation of m is a list of length n in the set U where the symbol € x1 appears h1 times, the symbol x2 appears h2 times, and so on. It is immediately seen that the number of permutations of m is n! (*) . h1!h2!Lhk ! The integer (*) is called multinomial coefficient, and is denoted as ⎛ ⎞ n n! € = ⎜ ⎟. h1!h2!Lhk ! ⎝ h1,h2 ,K,hk ⎠ We have € ⎛ n ⎞ ⎛ n ⎞ ⎜ ⎟ = ⎜ ⎟, h ,h ⎝ 1 2 ⎠ ⎝ h1⎠ ⎛ ⎞ ⎛ n ⎞ ⎛n − h1⎞ ⎛n − h1 − h2 −K − hk −1⎞ n ⎜ ⎟ = ⎜ ⎟ ⎜ ⎟K ⎜ ⎟. h ,h ,K,h h ⎝ 1 2 hk ⎠ k ⎠ ⎝ 1⎠ ⎝ h2 ⎠ ⎝ € Given a permutation p = y1 y2 ... yn of the multiset m, we define an inversion of p to be a pair of integers (i, j) with i < j and yi > yj. For example, p = 3 2 2 1 4 has the 5 inversions (1, 2), (1, 3), (1, 4), (2, 4), (3, 4). We want to determine an expression for the generating function ∑ q inv(p), p∈Sm where Sm denotes the set of permutations of the multiset m. To this € aim, we need the notion of Gaussian coefficient. Gaussian coefficients Let q be a variable. For every positive integer n, set 2 [n]q = 1+ q + q +K + q n−1 1− q n = , 1− q ([n]q is called a Gaussian integer), and € [n]q != [n]q [n − 1]q L[1]q = (1− q n )(1− q n−1)L(1− q) (1− q) n , (Gaussian factorial). € Note that, for q = 1, the polynomial [n]q takes the value n, and the Gaussian factorial [n]q! takes the value n!. We now define the (n, k)-th Gaussian coefficient (or q-binomial coefficient) to be ⎧(1− q n )L(1− q n−k +1) ⎪⎪ if k ≤ n [n]q ! ⎡n⎤ k . ⎢⎣k ⎥⎦ = [k] ![n − k] ! = ⎨ (1− q )L(1− q) q q q ⎪ ⎪⎩ 0 if k > n Example € ⎡4⎤ (1− q 4 )(1− q 3 ) = (1+ q 2 )(1+ q + q 2 ) = 1+ q + 2q 2 + q 3 + q 4 . ⎢ ⎥ = ⎣2⎦q (1− q 2 )(1− q) Properties: ⎡n⎤ ⎡ n ⎤ ⎢⎣k ⎥⎦ = ⎢⎣n − k ⎥⎦ ; q q ⎡n⎤ ⎡n⎤ = 1= ⎢⎣0⎥⎦ ⎢⎣n⎥⎦ ; q q ⎡n⎤ ⎡ n ⎤ = [n] = q ⎢ ⎢⎣1⎥⎦ ⎥⎦ ; n − 1 ⎣ q q ⎡n⎤ ⎡n − 1⎤ ⎡n − 1⎤ k ⎡n − 1⎤ n−k ⎡n − 1⎤ = q + = + q ⎢⎣k ⎥⎦ ⎢⎣ k ⎥⎦ ⎢⎣k − 1⎥⎦ ⎢⎣ k ⎥⎦ ⎢⎣k − 1⎥⎦ . q q q q q € The Gaussian coefficients are apparently rational functions in q, bt they are indeed polynomials with integer coefficients. In fact, we have: Theorem Let n, k be non negative integers, with k ≤ n. Denote by an,k,i the number of subsets of cardinality k of the set {1, 2, ..., n} such that the sum of their elements equals ⎛k +1⎞ i + ⎜ ⎟. ⎝ 2 ⎠ Then € k(n−k) ⎡n⎤ i ⎢ ⎥ = ∑ an,k,i q . ⎣k ⎦q i=0 Proof Let S be a subset of cardinality k of {1, 2, ..., n} such that the sum of its elements is i + ½ k(k+1). € not contain the symbol n, it corresponds to a subset of If S does {1, 2, ..., n–1} of cardinality k such that the sum of its elements is i + ½ k(k+1). Otherwise, S corresponds to a subset of {1, 2, ..., n–1} of cardinality k–1 such that the sum of its elements is i + ½ k(k+1) – n = k–n+i + ½ k(k–1). This implies that an,k,i = an–1,k,i + an–1,k–1,k–n+i . Set now k(n−k) An,k (q) = ∑ an,k,i q i . i=0 The preceding considerations yield the following recurrence for the polynomials An,k(q): € An,k(q) = An–1,k(q) + qn–k An–1,k–1(q), and this is the recurrence satisfied by the Gaussian coefficients. Since the inital values of the two sequences are the same, the assertion is true. Example Let n = 4, k = 2. Consider all the 2-element subsets of the set {1,2,3,4}. Two of these sum up to 5, namely,{1,4} and {2,3}, while all the other 4 sum up to different numbers. Hence, A4,2(q) = 1 + q + 2q2 + q3 + q4, and this is precisely ⎡4⎤ ⎢ ⎥ . ⎣2⎦q € Gaussian coefficients have an interesting linear algebra interpretation: Theorem Let q be a prime power, and let V be a vector space of dimension over the Galois field GF(q). The number of vector subspaces of V of dimension k is ⎡n⎤ ⎢ ⎥ . ⎣k ⎦q Proof First of all, we count the number of k-tuples of linearly independent vectors in V. The first vector can be any non-zero € n–1 choices). The second vector can be any vector of V (q vector, except for a mutiple of the first one (qn–q choices), and so on. In conclusion, the number of k-tuples of linearly independent vectors in V is (qn–1) (qn–q) ... (qn–qk–1). Any one of these k-tuples is a basis of a subspace of V of dimension k, and this subspace has (qk–1) (qk–q) ... (qk–qk–1) different bases, by the same argument. Hence, the number of such subspaces is (q n − 1)L(q n − q k −1) (q k − 1)L(q k − q k −1) € = (1− q n )L(1− q n−k +1) (1− q k )L(1− q) ⎡n⎤ = ⎢ ⎥ . ⎣k ⎦q It is also possible to define the multinomial Gaussian coefficients: if h1, h2, ..., hk are integers such that h1 + h2 + ..., hk = n, we set ⎡ ⎤ [n]q ! n = . ⎢ ⎥ ⎣h1,h2 ,K,hk ⎦q [h1]q ![h2 ]q !L[hk ]q ! h h h Theorem Let m = {1 1 ,2 2 ,K,k k } be a multiset of length n, € and let Sm be the set of its permutations. We have ⎡ ⎤ n € ∑ q inv(p) = ⎢ ⎥ . ⎣h1,h2 ,K,hk ⎦q p∈S m Proof Consider first the case k = 2. In this case, m contains h€ 1 copies of the symbol 1 and h2 = n – h1 copies of the symbol 2. An inversion will be simply an occurrence of the symbol 2 that appears before an occurrence of the symbol 1. We proceed by induction on n: for n = 1 the assertion is trivially verified. Suppose the assertion true for n–1, and consider a multiset m of length n in {1, 2}. A permutation of m can either end by 2, and in this case its last element is involved in no inversions, or by 1, and its last element is involved in h2 = n – h1 inversions. Then, by the induction hypothesis, we have ∑q p∈Sm inv(p) ⎡n − 1⎤ ⎡ ⎤ n−h1 n − 1 = ⎢ ⎥ + q ⎢ ⎥ . ⎣ h1 ⎦q ⎣h1 − 1⎦q ∑ q inv(p) This implies that the polynomials € p∈Sm satisfy the same recurrence € as ⎡ n ⎤ ⎡ n ⎤ ⎢ ⎥ = ⎢ ⎥ , ⎣h1⎦q ⎣h1,h2 ⎦q with the same initial conditions. Hence, the assertion is true. We now prove the general case by induction on k. Suppose € the multiset m = {1h1 ,2h2 ,K,k hk } that the assertion is true for and consider the multiset m+ = {1h1 ,2h2 ,K,k hk ,(k +1)hk+1 }. Note that every permutation p of m+ is completely determined by the pair (p’,p”), where p’ is the permutation obtained from p € different from k+1, and p” is by replacing by 1 all the elements € obtained from p by deleting all the occurrences of k+1. For example, if m+ = {12, 23, 3, 42}, and p = 21243142, we have p’ = 11141141, p” = 212312. It is evident that the permutations p of m+ correspond bijectively to the pairs (p’, p”), and that inv(p) = inv(p’) + inv(p”). Hence, denoting by 2 the multiset consisting of h1 + h2 + ..., hk copies of 1 and hk+1 copies of 2, we get ∑ q inv(p) = ∑ q inv(pʹ′) ∑ q inv(pʹ′ʹ′). p∈S m+ pʹ′∈S2 pʹ′ʹ′∈Sm ⎡ ⎤ €The first summand is ⎢ n ⎥ , as we have shown. ⎣hk +1⎦q By the induction hypothesis, the second summand is € ⎡ n − hk +1 ⎤ ⎢ ⎥ . ⎣h1,h2 ,K,hk ⎦q The product of these two quantities is precisely € ⎡ ⎤ n ⎢ ⎥ . ⎣h1,h2 ,K,hk ,hk +1⎦q €