Back to Combinatorics

Chapter 8: Permutation Structure

October 10, 2026 Wasil Zafar 22 min read

Cycles, descents, inversions, and patterns reveal hidden order

Table of Contents

  1. What changes when permutations are classified by cycles or descents?
  2. 8.1 Cycle decompositions and Stirling numbers of the first kind
  3. 8.2 Permutations with restricted cycle structure
  4. 8.3 Derangements and involutions
  5. 8.4 Descents, ascents, and Eulerian numbers
  6. 8.5 Inversions and permutation statistics
  7. 8.6 Pattern-avoiding permutations
  8. 8.7 Permutation posets and weak/Bruhat orders
  9. 8.8 Mahonian statistics and q-enumeration
  10. Compare permutation statistics and discover a pattern-avoidance recurrence

What changes when permutations are classified by cycles or descents?

Counting all permutations gives $n!$, but many questions ask how those permutations behave. If labels represent objects and a permutation tells us where each object moves, its cycles describe repeated movement. If the same permutation is read as a list, its descents describe local drops and its inversions measure disorder across pairs.

These are different views of the same finite set. This chapter develops counting recurrences by inserting or removing the largest label, then uses them to compare distributions. Begin with permutations and combinations, the enumeration methods in algorithmic generation, and the distinction between labeled and unlabeled structures in partitions and structure types.

Three Structural Views of Permutations for S3 Three visual cards comparing cycle structure, descent counts, and inversion counts for permutations of 3 elements. Three Structural Lenses for Permutations of {1, 2, 3} (n! = 6) 1. Cycle Structure c(3, k) Action on set (Orbits) 231 ➔ (1 2 3) [1 cycle] Counts: [2, 3, 1] for k=1,2,3 2. Descents A(3, k) Local adjacent drops (πᵢ > πᵢ₊₁) 231 ➔ 3 > 1 [1 descent] Counts: [1, 4, 1] for k=0,1,2 3. Inversions inv(π) Global pair disorder (i < j, πᵢ > πⱼ) 231 ➔ (2,1), (3,1) [2 inv] Counts: [1, 2, 2, 1] for inv=0..3
Figure 8.0: Comparing cycle structure, descents, and inversions for all 6 permutations of $S_3$.
Motivating Problem

What changes when permutations are classified by cycles or descents?

Take all permutations of $\{1,2,3\}$. In one-line notation, $231$ means that $1$ maps to $2$, $2$ maps to $3$, and $3$ maps to $1$. A descent is a position whose entry exceeds the next entry.

One-line notationDisjoint cyclesNumber of cyclesNumber of descents
$123$$(1)(2)(3)$30
$132$$(1)(23)$21
$213$$(12)(3)$21
$231$$(123)$11
$312$$(132)$11
$321$$(13)(2)$22

For example, the orbit trace for $231$ is $1\to2\to3\to1$, giving one cycle. Its list has one drop, from $3$ to $1$, giving one descent.

Question to revisit. Why are the cycle counts $2,3,1$ for one, two, and three cycles, while the descent counts are $1,4,1$ for zero, one, and two descents? Both distributions sum to $6$, but neither determines the other. A successful explanation must identify the statistic being counted and a reversible construction that proves its recurrence.

8.1 Cycle decompositions and Stirling numbers of the first kind

Write $[n]=\{1,\ldots,n\}$ and let $S_n$ be the set of bijections $\pi:[n]\to[n]$. The one-line notation $\pi_1\cdots\pi_n$ records $\pi_i=\pi(i)$. To find a cycle, start at an unused label and repeatedly apply $\pi$. Because the map is a bijection on a finite set, this process returns to its starting label. Repeat with unused labels until every label is included.

The notation $(a_1a_2\cdots a_r)$ means $a_1\to a_2\to\cdots\to a_r\to a_1$. Rotating the notation represents the same cycle; changing its orientation generally changes the permutation. Disjoint cycles can be written in any order. Include fixed points as cycles of length one when counting cycles.

Worked example. For $\pi=2413$, the trace is $1\to2\to4\to3\to1$, so its decomposition is $(1243)$. The entry $4$ is an image, not the statement that the fourth position is fixed.

Let $c(n,k)$ count permutations in $S_n$ with exactly $k$ cycles. These are the unsigned Stirling numbers of the first kind. There is one empty permutation with zero cycles, so $c(0,0)=1$; impossible indices have count zero. In particular, $c(n,0)=0$ for $n\ge1$.

Stirling Numbers of the First Kind Recurrence Breakdown c(4,2) = 11 Visual breakdown of inserting element 4 into permutations of 3 elements to form 2 cycles: either as a singleton or after one of 3 existing labels. Stirling Recurrence (1st Kind): c(n, k) = c(n-1, k-1) + (n-1) c(n-1, k) Case 1: Element n forms singleton cycle (n) Permutation of [n-1] must have k - 1 cycles Example: (1 2 3) + (4) ➔ 2 cycles Count = c(3, 1) = 2 ways + Case 2: Insert n after one of n - 1 labels Permutation of [n-1] already has k cycles (3 choices for a) (1 2)(3) ➔ (1 4 2)(3) or (1 2 4)(3) or (1 2)(3 4) Count = 3 × c(3, 2) = 3 × 3 = 9 ways Total c(4, 2) = 2 + 9 = 11 Permutations in S₄ with 2 Cycles ✓
Figure 8.1: Inserting $n=4$ into permutations of $S_3$ to prove $c(4,2) = 11$.

Insert the label $n$ into a permutation of $[n-1]$. There are two disjoint possibilities:

  1. Make $(n)$ a singleton cycle. The smaller permutation must have $k-1$ cycles.
  2. Insert $n$ after an existing label $a$: replace $a\to b$ by $a\to n\to b$. There are $n-1$ choices of $a$, and the number of cycles stays $k$.

Removing $n$ reverses exactly one of these constructions. Thus, for $n\ge1$,

$$ c(n,k)=c(n-1,k-1)+(n-1)c(n-1,k). $$

Starting with $c(0,0)=1$ gives:

$n$$c(n,1)$$c(n,2)$$c(n,3)$$c(n,4)$
11000
21100
32310
461161

For instance, $c(4,2)=c(3,1)+3c(3,2)=2+9=11$. Each row sums to $n!$ because every permutation has exactly one cycle count.

If $t$ is a formal variable, multiplying the recurrence by $t^k$ and summing yields

$$ \sum_{k=0}^{n}c(n,k)t^k=t(t+1)\cdots(t+n-1), $$

with empty product $1$ when $n=0$. This polynomial records the whole cycle distribution. Some texts use signed numbers $s(n,k)=(-1)^{n-k}c(n,k)$. State which convention you use. The Stirling numbers of the second kind from Chapter 7 count set partitions; here each block also has a cyclic order.

Exercise. Find $c(5,4)$ without listing all $120$ permutations. Hint: four cycles on five labels force a single nontrivial cycle. Answer: choose its two labels, giving $\binom52=10$; the recurrence gives $c(4,3)+4c(4,4)=6+4=10$.

8.2 Permutations with restricted cycle structure

A cycle type specifies numbers $m_j$, where $m_j$ is the number of cycles of length $j$. Necessarily

$$ \sum_{j=1}^{n}j m_j=n. $$

For a fixed feasible type, the number of permutations is

$$ \frac{n!}{\displaystyle\prod_{j=1}^{n}j^{m_j}m_j!}. $$

To prove this, fix slots for the cycles, grouped by length. Arrange the labels in a list and cut it into the prescribed slots. There are $n!$ lists. Each length-$j$ cycle can be rotated in $j$ ways without changing it, giving the factor $j^{m_j}$. The $m_j$ cycles of the same length can be exchanged among their slots, giving $m_j!$. All labels are distinct, so these representation choices have exactly the stated multiplicity.

The 5 Cycle Types of S4 Visual grid showing the 5 cycle types of S4 with their symmetry formulas and exact counts. Cycle Type Decomposition for S₄ (Sum = 24 Permutations) 1+1+1+1 (1⁴) Identity 24 / (1⁴ · 4!) Count = 1 2+1+1 (2¹ 1²) Single Transposition 24 / (2¹ · 2!) Count = 6 2+2 (2²) Double Transposition 24 / (2² · 2!) Count = 3 3+1 (3¹ 1¹) 3-Cycle 24 / (3¹ · 1!) Count = 8 4 (4¹) 4-Cycle 24 / (4¹ · 1!) Count = 6 Total = 1 + 6 + 3 + 8 + 6 = 24 = 4! Permutations ✓
Figure 8.2: The five cycle types of $S_4$ and their conjugacy class size formula.

This formula makes restrictions precise. To forbid fixed points, impose $m_1=0$. To allow only cycles of lengths one and two, impose $m_j=0$ for $j\ge3$. Sum the type counts over all feasible vectors satisfying the restriction.

Worked example. On five labels, the type consisting of one 3-cycle and one 2-cycle has count $5!/(3\cdot2)=20$. Equivalently, choose the three labels in $\binom53=10$ ways, give them one of two cyclic orientations, and use the remaining two labels in their unique 2-cycle.

Exercise. How many permutations of $[5]$ consist of a single cycle? Hint: fix the first displayed label as $1$ to remove rotational ambiguity. Answer: $4!=24$, agreeing with $5!/5$.

Proof Workshop

Permutations with restricted cycle structure: a worked example

Classify every permutation of $[4]$ by its cycle lengths. A partition of $4$ specifies the lengths, but each entry below counts labeled permutations.

Cycle lengthsNonzero multiplicitiesCalculationCount
$1+1+1+1$$m_1=4$$4!/4!$1
$2+1+1$$m_2=1,m_1=2$$4!/(2\cdot2!)$6
$2+2$$m_2=2$$4!/(2^2\cdot2!)$3
$3+1$$m_3=1,m_1=1$$4!/3$8
$4$$m_4=1$$4!/4$6

The three permutations of type $2+2$ are $(12)(34)$, $(13)(24)$, and $(14)(23)$. The eight of type $3+1$ arise by choosing the fixed label in four ways and orienting the remaining 3-cycle in two ways.

Checks. Every type uses four labels, the five cases are disjoint, and their counts sum to $24$. Grouping by the number of cycles gives $6,11,6,1$, exactly the Stirling row from Section 8.1. Omitting the rotation factors would count cycle notations rather than permutations.

8.3 Derangements and involutions

A derangement has no fixed point: $\pi(i)\ne i$ for every label. Its cycles all have length at least two. An involution satisfies $\pi^2=\mathrm{id}$, meaning that applying it twice returns every label to itself. Its cycles have length one or two: a longer cycle does not return a label after two steps.

These conditions can overlap. In the diagram, each arrow represents one application of the permutation. A loop marks a fixed point, and two opposite arrows mark a 2-cycle. The left permutation is a derangement but not an involution; the middle is an involution but not a derangement; the right satisfies both.

Derangements and Involutions on Four Labels Three panels comparing a derangement, an involution, and a fixed-point-free involution on 4 elements. Derangements vs. Involutions on {1, 2, 3, 4} (1 2 3 4) 12 34 Derangement: Yes | Involution: No (1 2)(3)(4) 12 34 Derangement: No | Involution: Yes (1 2)(3 4) 12 34 Derangement: Yes | Involution: Yes
Figure 8.3: Comparing derangements (no fixed points) and involutions ($\pi^2 = \text{id}$).

Let $D_n$ count derangements. Set $D_0=1$ and $D_1=0$. For $n\ge2$, choose $j=\pi(1)$ in $n-1$ ways. If $1$ and $j$ form a 2-cycle, removing them leaves a derangement on $n-2$ labels. Otherwise, remove $1$ from its longer cycle by joining its predecessor directly to $j$. The result is a derangement on the remaining $n-1$ labels. Conversely, insert $1$ immediately before $j$ in any such derangement. Therefore

$$ D_n=(n-1)(D_{n-1}+D_{n-2}). $$

This gives $D_2=1$, $D_3=2$, and $D_4=9$. As a separate check, inclusion–exclusion on the events “label $i$ is fixed” gives

$$ D_n=\sum_{j=0}^{n}(-1)^j\binom nj(n-j)! =n!\sum_{j=0}^{n}\frac{(-1)^j}{j!}. $$

Here a chosen set of $j$ fixed labels leaves $(n-j)!$ unrestricted permutations, explaining each term.

Let $I_n$ count involutions. Set $I_0=I_1=1$. Label $1$ is either fixed or paired with one of the other $n-1$ labels, so

$$ I_n=I_{n-1}+(n-1)I_{n-2}\qquad(n\ge2). $$

An involution with $j$ transpositions has type $2^j1^{n-2j}$, hence

$$ I_n=\sum_{j=0}^{\lfloor n/2\rfloor}\frac{n!}{2^j j!(n-2j)!}. $$

For $n=4$, this is $1+6+3=10$. Only the three involutions of type $2+2$ are also derangements, agreeing with the previous table.

Exercise. Count fixed-point-free involutions on six labels. Hint: every cycle must have length two. Answer: $6!/(2^3 3!)=15$. On an odd number of labels the count is zero; on $2m$ labels it is $(2m)!/(2^m m!)$.

8.4 Descents, ascents, and Eulerian numbers

For a nonempty permutation, define its descent set and descent number by

$$ \operatorname{Des}(\pi)=\{i:1\le i\lt n,\ \pi_i>\pi_{i+1}\}, \qquad \operatorname{des}(\pi)=|\operatorname{Des}(\pi)|. $$

An ascent satisfies $\pi_i\lt\pi_{i+1}$. Distinct entries guarantee that each of the $n-1$ adjacent comparisons is exactly one of these, so the ascent and descent numbers sum to $n-1$. For $3142$, the descent positions are $1$ and $3$, while position $2$ is an ascent.

The Eulerian number $A(n,k)$ counts permutations with $k$ descents. Use $A(0,0)=1$, $A(1,0)=1$, and zero for impossible indices. For $n\ge2$,

$$ A(n,k)=(k+1)A(n-1,k)+(n-k)A(n-1,k-1). $$

Eulerian Recurrence Gap Insertion Diagram Inserting element 4 into permutation 213 showing 2 descent-preserving gaps and 2 descent-increasing gaps. Eulerian Recurrence: Inserting Label n = 4 into π = 213 (des = 1) 1. Preserving Gaps (k + 1 = 2 ways) Insert into existing descent gap or at the end 2 [4] 1 3 ➔ 2413 | 2 1 3 [4] ➔ 2134 Descents stay k = 1 2. Increasing Gaps (n - k = 2 ways) Insert at front or into existing ascent gap [4] 2 1 3 ➔ 4213 | 2 1 [4] 3 ➔ 2143 Descents increase to k = 2 A(n, k) = (k + 1) A(n-1, k) + (n - k) A(n-1, k-1) ✓
Figure 8.4: Inserting element $n=4$ into gaps of $213$ demonstrates the two terms of the Eulerian recurrence.

To prove it, insert the largest label $n$ into one of the $n$ gaps of a permutation of length $n-1$. If the old permutation has $d$ descents, inserting into a descent gap replaces one drop by one drop; appending at the end also preserves $d$. These are $d+1$ gaps. Inserting into an ascent gap creates a new descent, as does inserting at the front. These are the other $n-1-d$ gaps.

To finish with $k$ descents, start either with $k$ and preserve them in $k+1$ ways, or with $k-1$ and increase the count in $n-k$ ways. Deleting $n$ reverses the construction.

Worked example. The row for $n=3$ is $1,4,1$. Therefore

$$ A(4,1)=2\cdot4+3\cdot1=11, \qquad A(4,2)=3\cdot1+2\cdot4=11. $$

The full row is $1,11,11,1$, summing to $24$. Replacing every value $x$ by $n+1-x$ exchanges ascents and descents, proving $A(n,k)=A(n,n-1-k)$ for $n\ge1$.

Exercise. Insert $4$ into $213$. Which insertions preserve its one descent? Hint: inspect the existing descent gap and the end. Answer: $2413$ and $2134$ preserve it; $4213$ and $2143$ have two descents.

8.5 Inversions and permutation statistics

A permutation statistic is a numerical measurement assigned to each permutation. An inversion is a pair of positions $(i,j)$ with $i\lt j$ and $\pi_i>\pi_j$. Define

$$ \operatorname{inv}(\pi)=\#\{(i,j):1\le i\lt j\le n,\ \pi_i>\pi_j\}. $$

Descents compare neighbors; inversions compare all pairs. The major index weights descent positions:

$$ \operatorname{maj}(\pi)=\sum_{i\in\operatorname{Des}(\pi)}i. $$

Dissecting Permutation Statistics for 3142 Diagram analyzing the permutation 3142 for descents, inversions, and major index. Anatomy of Statistics for Permutation π = 3142 31 42 i = 1i = 2 i = 3i = 4 Descents (Adjacent Drops) Des(π) = {1, 3} ➔ des = 2 Inversions (All Inverted Pairs) (3,1), (3,2), (4,2) ➔ inv = 3 Major Index (Sum of Descents) 1 + 3 = 4 ➔ maj = 4 Adjacent cost = inv(π) = 3 swaps | Arbitrary cost = n - cyc(π) = 4 - 1 = 3 swaps ✓
Figure 8.5: Dissecting the descent set, inversion set, and major index for $\pi = 3142$.

Worked example. For $3142$, the inversion pairs of positions are $(1,2)$, $(1,4)$, and $(3,4)$, corresponding to value pairs $(3,1)$, $(3,2)$, and $(4,2)$. Thus its inversion number is $3$, descent number is $2$, and major index is $1+3=4$.

PermutationDescent setInversionsMajor index
$123$$\varnothing$00
$132$$\{2\}$12
$213$$\{1\}$11
$231$$\{2\}$22
$312$$\{1\}$21
$321$$\{1,2\}$33

The inversion and major-index columns have the same frequency distribution, although their values differ on individual permutations. Section 8.8 proves that this agreement holds for every $S_n$.

The Lehmer digits from Chapter 5 count smaller entries to the right of each position. Their sum is $\operatorname{inv}(\pi)$, since each inversion is counted once by its left position. Exchanging an adjacent inverted pair lowers the inversion count by exactly one: all comparisons with other entries contribute the same total before and after the exchange. Repeatedly exchanging such pairs eventually sorts the list, using exactly $\operatorname{inv}(\pi)$ exchanges. No adjacent exchange changes the count by more than one, so fewer cannot suffice.

If arbitrary pairs of positions may be exchanged, the minimum is instead $n-\operatorname{cyc}(\pi)$, where $\operatorname{cyc}$ denotes the number of cycles. A transposition either joins two cycles or splits one, changing the count by one. Reaching the identity, with $n$ cycles, therefore needs at least this many exchanges. A length-$r$ cycle can be undone in $r-1$ exchanges, attaining the bound after summing over all cycles.

For $321=(13)(2)$, one arbitrary exchange sorts the list, while three adjacent exchanges are necessary. This distinction matters when a rearrangement system permits only neighboring moves.

Exercise. Find the three statistics for $2413$. Hint: list the smaller entries to the right of each position. Answer: its descent set is $\{2\}$, inversion count is $1+2+0+0=3$, and major index is $2$.

8.6 Pattern-avoiding permutations

Optional extension. This section is not required for the chapter foundation. A classical pattern concerns relative order in a subsequence; its selected positions need not be adjacent.

A permutation contains the pattern $132$ if some positions $i\lt j\lt k$ satisfy

$$ \pi_i\lt\pi_k\lt\pi_j. $$

It avoids $132$ if no such triple exists. For example, $2413$ contains it at positions $1,2,4$: the values $2,4,3$ have relative order $1,3,2$. On three labels, only the permutation $132$ contains this pattern, so five permutations avoid it.

Catalan Structure of 132-Avoiding Permutations Decomposition of 132-avoiding permutations around the maximum element n showing left block L with larger elements and right block R with smaller elements. Decomposition of 132-Avoiding Permutations: π = L · n · R Left Block L (Length ℓ) Must contain LARGER values {n-ℓ, ..., n-1} ➔ C_ℓ choices Maximum n n Fixed separator Right Block R (Length n - 1 - ℓ) Must contain SMALLER values {1, ..., n-1-ℓ} ➔ C_{n-1-ℓ} choices Catalan Recurrence: C_n = ∑_{ℓ=0}^{n-1} C_ℓ C_{n-1-ℓ} ➔ 1, 1, 2, 5, 14, 42, 132 ✓
Figure 8.6: Catalan recurrence for $132$-avoiding permutations by splitting around the maximum entry $n$.

Let $C_n$ count $132$-avoiding permutations of $[n]$, with $C_0=1$. Place the largest value $n$ between a left block $L$ and a right block $R$. Every value in $L$ must exceed every value in $R$: otherwise a smaller left value, $n$, and a larger right value form $132$.

If $L$ has length $\ell$, its labels are therefore the largest $\ell$ labels remaining, and $R$ receives the smallest $n-1-\ell$. Standardizing a block means replacing its smallest value by $1$, its next-smallest by $2$, and so on. Both standardized blocks must avoid $132$, giving $C_\ell C_{n-1-\ell}$ choices.

Conversely, assemble any two avoiding blocks with these label sets around $n$. A pattern entirely within a block is excluded. A triple meeting both blocks but excluding $n$ cannot be $132$, since its first entry belongs to the larger-valued left block and is not the smallest. A triple involving $n$ would need $n$ in its middle position and a left value smaller than a right value, which is also excluded. This proves the converse and the recurrence

$$ C_n=\sum_{\ell=0}^{n-1}C_\ell C_{n-1-\ell}\qquad(n\ge1). $$

These are the Catalan numbers, beginning $1,1,2,5,14,42,132$ for $n=0$ through $6$. The recurrence has the same shape as splitting an ordered binary tree at its root into left and right subtrees.

Worked example. For $n=4$, split by the number of entries left of $4$. The contributions are $1\cdot5$, $1\cdot2$, $2\cdot1$, and $5\cdot1$, totaling $14$. For $\ell=2$, the left labels are $\{2,3\}$ and the right label is $1$; the possibilities are $2341$ and $3241$.

Exercise. Explain why $2143$ fails to avoid $132$. Hint: the triple need not use consecutive positions. Answer: positions $1,3,4$ give $2,4,3$. Merely scanning neighboring triples would miss this occurrence.

8.7 Permutation posets and weak/Bruhat orders

Optional graduate extension. A partial order is a relation that is reflexive, antisymmetric, and transitive. A cover $u\lessdot v$ means $u\lt v$ with no element strictly between them. Hasse diagrams draw covers upward. The planned sections 17.1 on partial orders and 30.8 on Coxeter groups and Bruhat order provide fuller background; find them in the series roadmap. The definitions here require only permutations and inversion counts.

We use right weak order: its upward covers swap adjacent positions of a permutation when the inversion count increases by one. Strong Bruhat order allows any two positions to be swapped, provided the inversion count increases by exactly one. These conventions agree with the cover definitions in Stanley and Postnikov's Bruhat-order notes. math.mit.edu

In each case, define $u\le v$ when $u=v$ or an upward sequence of covers leads from $u$ to $v$. Reachability is transitive, and strictly increasing inversion counts prevent directed cycles, proving antisymmetry. Every cover raises the rank $\operatorname{inv}$ by one. This rank measures height in the order, rather than the lexicographic rank used in enumeration algorithms.

Hasse Diagram for S3 Right Weak and Strong Bruhat Orders Hasse diagram of S3 comparing right weak order covers and strong Bruhat order extra covers. Hasse Diagram of S₃: Right Weak Order vs. Strong Bruhat Order 123 213 132 231 312 321 Solid: Right Weak Covers (Adjacent Swaps) | Dashed Red: Strong Bruhat Covers (Non-Adjacent Swaps) ✓
Figure 8.7: Hasse diagram comparing Right Weak Order (solid lines) and Strong Bruhat Order (dashed extra edges) on $S_3$.

For $S_3$, all right weak covers lie on these two chains:

$$ 123\lessdot213\lessdot231\lessdot321, \qquad 123\lessdot132\lessdot312\lessdot321. $$

Strong Bruhat order has two additional covers, $213\lessdot312$ and $132\lessdot231$, each obtained by exchanging positions $1$ and $3$. Thus $213$ and $312$ are comparable in strong Bruhat order but incomparable in right weak order.

Here is a practical test for a strong cover. Suppose $i\lt j$ and the entries are $a=\pi_i\lt b=\pi_j$. Swapping them changes the inversion number by

$$ 1+2\#\{k:i\lt k\lt j,\ a\lt\pi_k\lt b\}. $$

The pair $(i,j)$ contributes one new inversion. Each intervening entry strictly between $a$ and $b$ contributes two more; other intervening entries have unchanged total contribution. Entries outside the interval also have unchanged total contribution. Consequently, the swap is a cover precisely when no intervening value lies strictly between $a$ and $b$.

Worked example. In $213$, swapping the first and third entries exchanges $2$ and $3$. The intervening value $1$ lies outside that value interval, so the inversion count rises from $1$ to $2$: this is the strong cover to $312$. In contrast, swapping the endpoints of $123$ raises the count from $0$ to $3$, so it is not a cover.

Exercise. Find the strong upward covers of $132$ and identify the right weak ones. Hint: test all three pairs of positions. Answer: the strong successors are $312$ and $231$; only $312$ is a right weak successor. The swap to $123$ goes downward. Equal inversion counts alone never establish comparability between distinct permutations.

8.8 Mahonian statistics and q-enumeration

Optional advanced extension. Here $q$ is a formal variable: its exponent records a statistic, rather than a numerical probability. Section 6.7 of binomial coefficients and identities introduces related q-analogues. The planned Section 10.1 develops generating functions; consult the series roadmap. The polynomial argument below is self-contained.

Define the q-integer $[r]_q=1+q+\cdots+q^{r-1}$ for $r\ge1$. The inversion enumerator is

$$ F_n(q)=\sum_{\pi\in S_n}q^{\operatorname{inv}(\pi)}. $$

Insert the largest label $n$ into each gap of a permutation of length $n-1$. Its new inversions are exactly the entries to its right, giving each increment $0,1,\ldots,n-1$ once. Removing $n$ is the inverse operation. Therefore

$$ F_n(q)=[n]_qF_{n-1}(q)=\prod_{r=1}^{n}[r]_q, \qquad F_0(q)=1. $$

Major Index Increments under Element Insertion Diagram showing major index increments when inserting 4 into 213 producing shift values 0, 1, 2, and 3. Inserting Label n = 4 into π = 213 (maj = 1) Gives Increments {0, 1, 2, 3} End Gap (Pos 3) 2134 maj = 1 Shift = +0 Descent Gap (Pos 1) 2413 maj = 2 Shift = +1 Front Gap (Pos 0) 4213 maj = 3 Shift = +2 Ascent Gap (Pos 2) 2143 maj = 4 Shift = +3 Increments sum to q⁰ + q¹ + q² + q³ = [4]_q ➔ Proves Equidistribution of maj and inv! ✓
Figure 8.8: Major index shift under element insertion generates the q-factorial factor $[4]_q$.

For example, $F_3(q)=(1+q)(1+q+q^2)=1+2q+2q^2+q^3$, agreeing with the table in Section 8.5. If $M(n,s)$ is the coefficient of $q^s$, then

$$ M(n,s)=\sum_{j=0}^{n-1}M(n-1,s-j), $$

with $M(0,0)=1$ and zero for negative or impossible indices. At $q=1$ the polynomial becomes $n!$; its degree $\binom n2$ is the maximum inversion count.

A statistic is called Mahonian when it has this distribution on every $S_n$. The major index is Mahonian:

$$ \sum_{\pi\in S_n}q^{\operatorname{maj}(\pi)} =\sum_{\pi\in S_n}q^{\operatorname{inv}(\pi)}. $$

The largest-label insertion approach also appears in MIT's algebraic-combinatorics solutions. ocw.mit.edu

For completeness, take a permutation of length $m\ge1$ with $d$ descents and insert $m+1$. Appending changes the major index by zero. In a descent gap at position $i$, the descent shifts from $i$ to $i+1$, and later descents also shift; the increase equals the number of descents at or after $i$. Reading these gaps from right to left gives increments $1,\ldots,d$.

At the front, the increase is $d+1$. In an ascent gap at position $i$, it is $i+1$ plus the number of later descents. If this is the $a$th ascent gap from the left, that number is $d-i+a$, so the increase is $d+a+1$. Thus the front and ascent gaps give $d+1,\ldots,m$. All gaps together give $0,\ldots,m$ exactly once. Induction, starting with the empty permutation, proves the same q-factorial recurrence.

Worked example. The major index of $213$ is $1$. Inserting $4$ at the front, after the first entry, after the second, or at the end produces $4213,2413,2143,2134$. Their major indices are $3,2,4,1$, so the increments are $2,1,3,0$.

Exercise. Does equidistribution survive restricting to $132$-avoiding permutations? Hint: remove $132$ from the table for $S_3$. Answer: the remaining inversion enumerator is $1+q+2q^2+q^3$, while the major-index enumerator is $1+2q+q^2+q^3$. They differ. A theorem for all permutations cannot automatically be transferred to a restricted family.

Compare permutation statistics and discover a pattern-avoidance recurrence

Cycle counting and q-enumeration use the same principle: assign a weight to each permutation, then follow how a reversible insertion changes that weight. The cycle weight $t^{\operatorname{cyc}(\pi)}$ leads to the rising product $t(t+1)\cdots(t+n-1)$. The inversion weight $q^{\operatorname{inv}(\pi)}$ leads to the q-factorial $\prod_{r=1}^n[r]_q$. These products summarize different distributions on the same $n!$ objects.

To study both simultaneously, define

$$ H_n(t,q)=\sum_{\pi\in S_n}t^{\operatorname{cyc}(\pi)}q^{\operatorname{inv}(\pi)}. $$

Setting $q=1$ recovers the cycle polynomial; setting $t=1$ recovers the inversion polynomial. These marginal distributions do not assert independence. For instance, in $S_3$ the unique permutation with three cycles has zero inversions.

In data rearrangement, a permutation describes a desired arrangement of distinct records. Its cycle count determines the minimum number of unrestricted exchanges, while its inversion count determines the minimum number of neighboring exchanges. Specifying the allowed operation is therefore essential before using a count as a measure of work.

Investigation

Compare permutation statistics and discover a pattern-avoidance recurrence

Inputs and scope. Use all permutations of $[n]$ for $0\le n\le6$, including the single empty permutation. Tasks 1–5 form a 25-point foundation investigation. The pattern recurrence and joint-statistic exploration are optional extensions.

  1. Warm-up classification, 5 points. Build the cycle-type table for $S_4$ and extract its cycle-count distribution. Report derangements, involutions, and their intersection. Solution check: the cycle counts for one through four cycles are $6,11,6,1$; the three requested totals are $9,10,3$.
  2. Statistic comparison, 5 points. For $3142$, list the descent positions and inversion pairs, then explain its minimum sorting costs under adjacent and arbitrary exchanges. Solution check: descents $\{1,3\}$, inversion pairs $(1,2),(1,4),(3,4)$, major index $4$, adjacent cost $3$, and arbitrary cost $3$ because it has one cycle.
  3. Proof, 5 points. Derive either the Stirling recurrence or the Eulerian recurrence. State initial conditions, separate the cases, and explain the inverse operation. Hint: insert the largest label; for cycles distinguish singleton versus insertion into an orbit, and for descents distinguish descent gaps and the end from ascent gaps and the front. Solution outline: the reversible classifications in Sections 8.1 and 8.4 give the displayed recurrences, without overlap or omission.
  4. Exact enumeration, 5 points. Generate permutations without duplicates. For each, traverse cycles using a visited-label set, scan adjacent pairs for descents, scan all pairs for inversions, and sum descent positions for major index. Compare the histograms with the recurrences. Solution check: on $S_4$, descent frequencies are $1,11,11,1$; inversion and major-index frequencies for values zero through six are both $1,3,5,6,5,3,1$. All histograms must sum to $24$.
  5. Interpretation and validation, 5 points. Explain why matching inversion and major-index histograms does not mean equal values on each permutation. Check $n=0$ and $n=1$, the total $n!$, and the identities $\sum c(n,k)=n!$ and $\sum A(n,k)=n!$. Solution outline: $132$ already has inversion number $1$ and major index $2$; the empty permutation has zero cycles and zero values for these statistics, while the singleton has one cycle and zero descents, inversions, and major index.

Optional pattern extension. Count $132$-avoiding permutations by testing every triple of positions. Group survivors by the number $\ell$ of entries left of the maximum. For $n=4$, the group sizes should be $5,2,2,5$. Conjecture a recurrence, then prove it by showing that all left values exceed all right values and standardizing the two blocks. The complete argument in Section 8.6 gives $C_n=\sum_{\ell=0}^{n-1}C_\ell C_{n-1-\ell}$ and counts $1,1,2,5,14,42,132$ through $n=6$. A table supports the conjecture; the reversible decomposition proves it for every $n$.

Optional q and order extension. Use the major-index gap argument to prove equidistribution, or construct both orders on $S_3$ and identify their differing covers. Compute the joint cycle–inversion polynomial

$$ H_3(t,q)=t^3+t^2(2q+q^3)+2tq^2. $$

Verify both marginals and explain why this polynomial does not factor into independent cycle and inversion distributions. You may also compare statistics within a fixed cycle type; report your observations as finite evidence unless you supply a proof.

Deliverables and assessment. Submit the classification table, the worked statistic calculation, one reversible proof, the exact histograms or a reproducible enumeration trace, and a paragraph interpreting the results. Within each five-point task, award two points for correct results, two for reasoning or a reproducible method, and one for the specified checks. Optional extensions add depth but are not required for full foundation credit.

Next in the Series

In Chapter 9: Inclusion-Exclusion and Möbius Inversion, we'll explore Correct overcounting, then generalize cancellation to ordered sets.