Inversions and length #
An inversion of a permutation σ ∈ S_n is a pair (i, j) of elements of [n] such that i < j and σ(i) > σ(j).
See Definition 1.3.1 (def.perm.invs) in the source.
Instances For
The length (or Coxeter length) of a permutation σ is the number of inversions of σ. This is denoted ℓ(σ) in the source.
See Definition 1.3.1 (def.perm.invs) part (b) in the source.
Equations
Instances For
For any σ ∈ S_n, we have ℓ(σ) ∈ {0, 1, ..., n choose 2}.
See Proposition 1.3.3 (prop.perm.lengths-k-small-k) part (a) in the source.
The only permutation σ ∈ S_n with ℓ(σ) = 0 is the identity map.
See Proposition 1.3.3 (prop.perm.lengths-k-small-k) part (b) in the source.
The inversion count is preserved under taking inverses.
For a permutation σ, the pair (i, j) with i < j is an inversion of σ iff σ(i) > σ(j). For σ⁻¹, the pair (a, b) with a < b is an inversion iff σ⁻¹(a) > σ⁻¹(b). The map (a, b) ↦ (σ⁻¹(b), σ⁻¹(a)) gives a bijection between inversions of σ⁻¹ and σ.
The number of permutations σ ∈ S_n with ℓ(σ) = 0 is 1.
See Proposition 1.3.3 (prop.perm.lengths-k-small-k) part (b) in the source.
The longest element w₀ ∈ S_n is the permutation with OLN n(n-1)(n-2)...21, i.e., the reversal permutation.
Note: This is equivalent to Fin.revPerm from Mathlib. See longestElement_eq_revPerm.
Equations
Instances For
The longest element is equal to Fin.revPerm from Mathlib.
The set of inversions of the longest element w₀ is exactly the set of all pairs (i, j) with i < j. That is, every pair is an inversion.
The longest element w₀ ∈ S_n has length n choose 2, the maximum possible length.
This is because every pair (i, j) with i < j is an inversion of w₀, since w₀ reverses the order of elements.
See Proposition 1.3.3 (prop.perm.lengths-k-small-k) part (c) in the source.
The only permutation σ ∈ S_n with ℓ(σ) = n choose 2 is w₀.
See Proposition 1.3.3 (prop.perm.lengths-k-small-k) part (c) in the source.
The number of permutations σ ∈ S_n with ℓ(σ) = n choose 2 is 1.
See Proposition 1.3.3 (prop.perm.lengths-k-small-k) part (c) in the source.
If n ≥ 1, then the number of permutations σ ∈ S_n with ℓ(σ) = 1 is n - 1. These are precisely the simple transpositions s_i.
See Proposition 1.3.3 (prop.perm.lengths-k-small-k) part (d) in the source.
Helper lemmas for symmetry of length distribution #
The non-inversions of a permutation σ: pairs (i, j) with i < j and σ i < σ j.
This is the complement of inv σ within the set of ordered pairs.
The non-inversions are exactly the pairs where σ preserves the order.
Instances For
The inversion count of w₀ * σ equals the number of non-inversions of σ.
This expresses a fundamental duality: multiplying by the longest element w₀ swaps inversions and non-inversions.
The inversion count of w₀ * σ equals n choose 2 minus the inversion count of σ.
This shows that multiplication by the longest element w₀ "complements" the length: if σ has k inversions, then w₀ * σ has (n choose 2) - k inversions.
The longest element w₀ is an involution: w₀ * w₀ = 1.
This follows from the fact that w₀ = Fin.revPerm and revPerm is an involution.
The inverse of the longest element is itself: w₀⁻¹ = w₀.
This follows from longestElement_mul_self.
Explicit computation of the longest element: w₀(i) = n - 1 - i.
This shows that w₀ reverses the order of elements.
The number of σ ∈ S_n with ℓ(σ) = k equals the number with ℓ(σ) = (n choose 2) - k. This is the symmetry of the length distribution.
See Proposition 1.3.3 (prop.perm.lengths-k-small-k) part (f) in the source.
Lehmer codes #
The notation [m]_0 for {0, 1, ..., m} #
See Definition 1.3.5 (def.perm.lehmer1) part (b) in the source.
[m]_0 for natural numbers is just {0, 1, ..., m}
Equations
Instances For
Lehmer entry and Lehmer code definitions #
For σ ∈ S_n and i ∈ [n], we define ℓ_i(σ) as the number of j > i such that σ(i) > σ(j). This counts how many elements to the right of position i are smaller than σ(i).
This is the canonical definition of Lehmer entry used throughout the project.
The equivalent formulation i < j ∧ σ j < σ i is provided by lehmerEntry_eq_filter_lt.
See Definition 1.3.5 (def.perm.lehmer1) part (a) in the source.
Instances For
The Lehmer code of σ ∈ S_n is the n-tuple (ℓ_1(σ), ℓ_2(σ), ..., ℓ_n(σ)).
This is the canonical definition using a function type Fin n → ℕ.
For the list representation, use lehmerCode_toList.
See Definition 1.3.5 (def.perm.lehmer1) part (e) in the source.
Instances For
Each entry of a Lehmer code satisfies the bound ℓ_i(σ) ≤ n - i - 1. This shows the Lehmer code map is well-defined into H_n.
See Definition 1.3.5 (def.perm.lehmer1) part (d) in the source.
The length of σ equals the sum of its Lehmer code entries: ℓ(σ) = ℓ_1(σ) + ℓ_2(σ) + ... + ℓ_n(σ).
See Proposition 1.3.6 (prop.perm.lehmer.l) in the source.
Alternative characterization of lehmerEntry using σ j < σ i instead of σ i > σ j.
These are equivalent conditions.
The list representation of the Lehmer code has length n.
The i-th element of the list representation equals the function value.
The set of Lehmer codes #
The set H_n of valid Lehmer codes. An n-tuple (j_1, ..., j_n) is in H_n if and only if j_i ≤ n - i - 1 for each i ∈ [n].
This is [n-1]_0 × [n-2]_0 × ... × [0]_0.
See Definition 1.3.5 (def.perm.lehmer1) part (c) in the source.
Instances For
The Lehmer code of any permutation lies in H_n.
The set H_n has size n!.
See Definition 1.3.5 (def.perm.lehmer1) part (c) in the source.
The Lehmer code map L : S_n → H_n is injective.
See Theorem 1.3.7 (thm.perm.lehmer.bij) in the source.
The Lehmer code map L : S_n → H_n is a bijection.
See Theorem 1.3.7 (thm.perm.lehmer.bij) in the source.
Lexicographic order #
Lexicographic order on n-tuples of integers. We say (a_1, ..., a_n) <_lex (b_1, ..., b_n) if there exists k ∈ [n] such that a_k ≠ b_k and the smallest such k satisfies a_k < b_k.
Note: This is essentially Pi.Lex (· < ·) (· < ·) from Mathlib, specialized to Fin n → ℤ.
We define it directly here to match the source presentation.
See Definition 1.3.8 (def.perm.lehmer.lex-ord) in the source.
Instances For
The lexicographic order is a strict total order on n-tuples of integers:
for any a, b, exactly one of a = b, lexLt a b, or lexLt b a holds.
This completes the proof that <_lex defines a strict total order on ℤⁿ.
See Definition 1.3.8 (def.perm.lehmer.lex-ord) in the source.
Alternative characterization of Lehmer entry: ℓ_i(σ) = |{v < σ(i) : v ∉ σ({0, ..., i-1})}|
This is the number of elements smaller than σ(i) that haven't been "used" yet (i.e., are not in the image of positions before i).
See the proof of Theorem 1.3.7 (thm.perm.lehmer.bij) in the source.
If σ, τ ∈ S_n satisfy (σ(1), ..., σ(n)) <_lex (τ(1), ..., τ(n)), then L(σ) <_lex L(τ).
Proposition prop.perm.lehmer.lex from the source.
The proof uses the alternative characterization of Lehmer entries: ℓ_i(σ) counts elements smaller than σ(i) that are not in the image of positions before i. If σ and τ agree on positions below k and σ(k) < τ(k), then:
- For i < k: ℓ_i(σ) = ℓ_i(τ) (since the images below i are equal and σ(i) = τ(i))
- At k: ℓ_k(σ) < ℓ_k(τ) (since σ(k) is available for τ but not for σ)
Generating function for length #
Helper lemma: Lehmer code entry is strictly less than n - i.
The generating function for permutation lengths: ∑_{σ ∈ S_n} x^{ℓ(σ)} = [n]_x!
This equals the product (1+x)(1+x+x²)...(1+x+...+x^{n-1}).
See Proposition 1.3.4 (prop.perm.length.gf) in the source.