permutation_order_prob_sum
For every natural number n, the sum of permutation_order_prob n m over all m in permutation_orders n equals 1.
Statement
theorem permutation_order_prob_sum (n : ℕ) : ∑ m ∈ permutation_orders n, permutation_order_prob n m = 1- Source
- arXiv:2605.15063
- Verified
- 29 Nov 2026
- Axioms
Classical.choiceQuot.soundpropext- Built on 2
- permutation_ordersFor any natural number n, permutation_orders n is the finite set of distinct orders of permutations in the symmetric group S_n.
- permutation_order_probFor natural numbers n and m, permutation_order_prob n m is the real probability that a uniformly random permutation in S_n has order m,…
Read back from the Lean
For every natural number $n$, the sum over all $m$ in the set of orders of permutations of Fin n (the image of orderOf on Equiv.Perm (Fin n)) of permutation_order_prob n m (the fraction of permutations of Fin n with order $m$, defined as the number of such permutations divided by $n!$) is equal to $1$ (in $\mathbb{R}$).
Written by a model that saw only the Lean, never the English above. If the two disagree, that is worth a challenge.
The proof, explained
The theorem states that the probabilities of all distinct permutation orders in the symmetric group $S_n$ sum to $1$. The proof first partitions $S_n$ into fibers by permutation order; because these fibers partition the whole group of size $n!$, the sum of their cardinalities equals $n!$. Unfolding the definition of the probability as the fiber size divided by $n!$, we factor the common denominator $n!$ out of the sum. Substituting the fiber sum identity reduces the total probability to $n! / n!$, which evaluates to $1$ because $n! \neq 0$.
The sum of the sizes of the order fibers over all realized permutation orders in $S_n$ equals $n!$.
We establish the auxiliary lemma `hcard` by partitioning the symmetric group $S_n$ (represented by `Finset.univ` on `Equiv.Perm (Fin n)`) into fibers according to the order of each permutation, via `Finset.card_eq_sum_card_fiberwise`. The requirement that the order of every permutation in $S_n$ belongs to `permutation_orders n` holds by definition of the image (`Finset.mem_image_of_mem` and `Finset.mem_univ`). We then evaluate the total number of permutations as $|S_n| = |\mathrm{Fin}\ n|! = n!$ using `Finset.card_univ`, `Fintype.card_perm`, and `Fintype.card_fin`, and equate the two sides.
uses
Finset.card_eq_sum_card_fiberwise,Finset.mem_image_of_mem,Finset.mem_univ,Finset.card_univ,Fintype.card_perm,Fintype.card_finhave hcard : ∑ m ∈ permutation_orders n, (Finset.univ.filter (fun σ : Equiv.Perm (Fin n) => orderOf σ = m)).card = n.factorial := by have h := Finset.card_eq_sum_card_fiberwise (s := (Finset.univ : Finset (Equiv.Perm (Fin n)))) (t := permutation_orders n) (f := orderOf) (by intro x _ exact Finset.mem_image_of_mem _ (Finset.mem_univ x)) rw [Finset.card_univ, Fintype.card_perm, Fintype.card_fin] at h simpa using h.symm
The sum of the probabilities equals the sum of the fiber cardinalities divided by $n!$.
Unfolding the definition of `permutation_order_prob`, each summand is the number of permutations of order $m$ divided by $n!$. We then apply `Finset.sum_div` in reverse to pull the common denominator $n!$ out of the finite sum.
uses
Finset.sum_divsimp only [permutation_order_prob] rw [← Finset.sum_div]
The numerator simplifies to $n!$, reducing the expression to $n! / n!$.
Using the auxiliary identity `hcard` cast from $\mathbb{N}$ to $\mathbb{R}$ via `exact_mod_cast`, we rewrite the numerator $\sum_{m} |\{\sigma \in S_n \mid \mathrm{orderOf}(\sigma) = m\}|$ as $n!$.
rw [show ∑ m ∈ permutation_orders n, ((Finset.univ.filter (fun σ : Equiv.Perm (Fin n) => orderOf σ = m)).card : ℝ) = (n.factorial : ℝ) from by exact_mod_cast hcard]
The quotient $n! / n!$ equals $1$.
Since $n! \neq 0$ for every natural number $n$ by `Nat.factorial_ne_zero`, its cast to $\mathbb{R}$ is non-zero by `Nat.cast_ne_zero.mpr`. The lemma `div_self` then concludes that $n! / n! = 1$.
uses
div_self,Nat.cast_ne_zero.mpr,Nat.factorial_ne_zeroexact div_self (Nat.cast_ne_zero.mpr (Nat.factorial_ne_zero n))
Finset.card_eq_sum_card_fiberwise- For a function $f$ mapping a finite set $s$ into a finite set $t$, the cardinality of $s$ equals the sum over all $b \in t$ of the sizes of the fibers $\{a \in s \mid f(a) = b\}$.
Finset.mem_image_of_mem- If an element $a$ belongs to a finite set $s$, then $f(a)$ belongs to the image of $s$ under $f$.
Finset.mem_univ- Every element of a finite type belongs to the universal finset `Finset.univ`.
Finset.card_univ- The cardinality of the universal finset `Finset.univ` of a finite type equals the cardinality of the type.
Fintype.card_perm- The number of permutations of a finite type $\alpha$ is $(|\alpha|)!$.
Fintype.card_fin- The cardinality of the standard finite type `Fin n` is $n$.
Finset.sum_div- A sum of terms with a common denominator equals the sum of the numerators divided by that denominator: $\sum_{i \in s} (f(i) / a) = (\sum_{i \in s} f(i)) / a$.
div_self- Any non-zero element divided by itself equals $1$.
Nat.cast_ne_zero.mpr- If a natural number is non-zero, its cast to a division ring of characteristic zero (such as $\mathbb{R}$) is non-zero.
Nat.factorial_ne_zero- The factorial of every natural number is non-zero.
- The auxiliary combinatorial identity `hcard` is proved over the natural numbers $\mathbb{N}$, whereas probabilities and division are computed over the real numbers $\mathbb{R}$; line 13 casts the identity from $\mathbb{N}$ to $\mathbb{R}$ using the tactic `exact_mod_cast`.
Written by a model (gemini-3.8-flash) from the Lean proof and the goal states Lean reported at each step. Lean verified the proof; this explanation is a reading aid and is not itself machine-checked.
Lean source view module on GitHub
Choose a tactic — a marked line — to see the goals Lean had before and after it, as in Lean’s infoview. Step with ← → or j k.
/-- The sum of permutation order probabilities over all distinct orders in S_n is 1. -/theorem permutation_order_prob_sum (n : ℕ) : ∑ m ∈ permutation_orders n, permutation_order_prob n m = 1 := by have hcard : ∑ m ∈ permutation_orders n, (Finset.univ.filter (fun σ : Equiv.Perm (Fin n) => orderOf σ = m)).card = n.factorial := by have h := Finset.card_eq_sum_card_fiberwise (s := (Finset.univ : Finset (Equiv.Perm (Fin n)))) (t := permutation_orders n) (f := orderOf) (by intro x _ exact Finset.mem_image_of_mem _ (Finset.mem_univ x)) rw [Finset.card_univ, Fintype.card_perm, Fintype.card_fin] at h simpa using h.symm simp only [permutation_order_prob] rw [← Finset.sum_div] rw [show ∑ m ∈ permutation_orders n, ((Finset.univ.filter (fun σ : Equiv.Perm (Fin n) => orderOf σ = m)).card : ℝ) = (n.factorial : ℝ) from by exact_mod_cast hcard] exact div_self (Nat.cast_ne_zero.mpr (Nat.factorial_ne_zero n))