The derangements formula
ProvedFamousTheorems.card_derangements_eq_numDerangementscombinatoricsmathlib
Counting permutations with no fixed point.
The number of derangements of an -element set — permutations leaving nothing in place — is
equivalently the nearest integer to .
Inclusion–exclusion over the fixed points gives the alternating sum directly. The striking consequence is that the proportion of derangements tends to and does so extremely fast — so in the hat-check problem, the chance nobody gets their own hat back is essentially independent of the number of people.
Studied by Pierre de Montmort in 1708 as the problème des rencontres, and one of the founding problems of enumerative combinatorics.
Preamble
import Mathlib
Formal statement
namespace FamousTheorems
theorem card_derangements_eq_numDerangements : ∀ (α : Type*) [Fintype α] [DecidableEq α],
Fintype.card (derangements α) = numDerangements (Fintype.card α) := by sorry
end FamousTheoremsSource
One of Freek Wiedijk's "100 theorems"; formalized in Mathlib. Proof here reduces to the corresponding Mathlib result.