Metamath Proof Explorer


Theorem derangfmla

Description: The derangements formula, which expresses the number of derangements of a finite nonempty set in terms of the factorial. The expression |_( x + 1 / 2 ) is a way of saying "rounded to the nearest integer". This is part of Metamath 100 proof #88. (Contributed by Mario Carneiro, 23-Jan-2015)

Ref Expression
Hypothesis derangfmla.d D = x Fin f | f : x 1-1 onto x y x f y y
Assertion derangfmla A Fin A D A = A ! e + 1 2

Proof

Step Hyp Ref Expression
1 derangfmla.d D = x Fin f | f : x 1-1 onto x y x f y y
2 oveq2 n = m 1 n = 1 m
3 2 fveq2d n = m D 1 n = D 1 m
4 3 cbvmptv n 0 D 1 n = m 0 D 1 m
5 1 4 derangen2 A Fin D A = n 0 D 1 n A
6 5 adantr A Fin A D A = n 0 D 1 n A
7 hashnncl A Fin A A
8 7 biimpar A Fin A A
9 1 4 subfacval3 A n 0 D 1 n A = A ! e + 1 2
10 8 9 syl A Fin A n 0 D 1 n A = A ! e + 1 2
11 6 10 eqtrd A Fin A D A = A ! e + 1 2