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 ⊒ 𝐷 = ( π‘₯ ∈ Fin ↦ ( β™― β€˜ { 𝑓 ∣ ( 𝑓 : π‘₯ –1-1-ontoβ†’ π‘₯ ∧ βˆ€ 𝑦 ∈ π‘₯ ( 𝑓 β€˜ 𝑦 ) β‰  𝑦 ) } ) )
Assertion derangfmla ( ( 𝐴 ∈ Fin ∧ 𝐴 β‰  βˆ… ) β†’ ( 𝐷 β€˜ 𝐴 ) = ( ⌊ β€˜ ( ( ( ! β€˜ ( β™― β€˜ 𝐴 ) ) / e ) + ( 1 / 2 ) ) ) )

Proof

Step Hyp Ref Expression
1 derangfmla.d ⊒ 𝐷 = ( π‘₯ ∈ Fin ↦ ( β™― β€˜ { 𝑓 ∣ ( 𝑓 : π‘₯ –1-1-ontoβ†’ π‘₯ ∧ βˆ€ 𝑦 ∈ π‘₯ ( 𝑓 β€˜ 𝑦 ) β‰  𝑦 ) } ) )
2 oveq2 ⊒ ( 𝑛 = π‘š β†’ ( 1 ... 𝑛 ) = ( 1 ... π‘š ) )
3 2 fveq2d ⊒ ( 𝑛 = π‘š β†’ ( 𝐷 β€˜ ( 1 ... 𝑛 ) ) = ( 𝐷 β€˜ ( 1 ... π‘š ) ) )
4 3 cbvmptv ⊒ ( 𝑛 ∈ β„•0 ↦ ( 𝐷 β€˜ ( 1 ... 𝑛 ) ) ) = ( π‘š ∈ β„•0 ↦ ( 𝐷 β€˜ ( 1 ... π‘š ) ) )
5 1 4 derangen2 ⊒ ( 𝐴 ∈ Fin β†’ ( 𝐷 β€˜ 𝐴 ) = ( ( 𝑛 ∈ β„•0 ↦ ( 𝐷 β€˜ ( 1 ... 𝑛 ) ) ) β€˜ ( β™― β€˜ 𝐴 ) ) )
6 5 adantr ⊒ ( ( 𝐴 ∈ Fin ∧ 𝐴 β‰  βˆ… ) β†’ ( 𝐷 β€˜ 𝐴 ) = ( ( 𝑛 ∈ β„•0 ↦ ( 𝐷 β€˜ ( 1 ... 𝑛 ) ) ) β€˜ ( β™― β€˜ 𝐴 ) ) )
7 hashnncl ⊒ ( 𝐴 ∈ Fin β†’ ( ( β™― β€˜ 𝐴 ) ∈ β„• ↔ 𝐴 β‰  βˆ… ) )
8 7 biimpar ⊒ ( ( 𝐴 ∈ Fin ∧ 𝐴 β‰  βˆ… ) β†’ ( β™― β€˜ 𝐴 ) ∈ β„• )
9 1 4 subfacval3 ⊒ ( ( β™― β€˜ 𝐴 ) ∈ β„• β†’ ( ( 𝑛 ∈ β„•0 ↦ ( 𝐷 β€˜ ( 1 ... 𝑛 ) ) ) β€˜ ( β™― β€˜ 𝐴 ) ) = ( ⌊ β€˜ ( ( ( ! β€˜ ( β™― β€˜ 𝐴 ) ) / e ) + ( 1 / 2 ) ) ) )
10 8 9 syl ⊒ ( ( 𝐴 ∈ Fin ∧ 𝐴 β‰  βˆ… ) β†’ ( ( 𝑛 ∈ β„•0 ↦ ( 𝐷 β€˜ ( 1 ... 𝑛 ) ) ) β€˜ ( β™― β€˜ 𝐴 ) ) = ( ⌊ β€˜ ( ( ( ! β€˜ ( β™― β€˜ 𝐴 ) ) / e ) + ( 1 / 2 ) ) ) )
11 6 10 eqtrd ⊒ ( ( 𝐴 ∈ Fin ∧ 𝐴 β‰  βˆ… ) β†’ ( 𝐷 β€˜ 𝐴 ) = ( ⌊ β€˜ ( ( ( ! β€˜ ( β™― β€˜ 𝐴 ) ) / e ) + ( 1 / 2 ) ) ) )