Metamath Proof Explorer


Theorem derangval

Description: Define the derangement function, which counts the number of bijections from a set to itself such that no element is mapped to itself. (Contributed by Mario Carneiro, 19-Jan-2015)

Ref Expression
Hypothesis derang.d 𝐷 = ( 𝑥 ∈ Fin ↦ ( ♯ ‘ { 𝑓 ∣ ( 𝑓 : 𝑥1-1-onto𝑥 ∧ ∀ 𝑦𝑥 ( 𝑓𝑦 ) ≠ 𝑦 ) } ) )
Assertion derangval ( 𝐴 ∈ Fin → ( 𝐷𝐴 ) = ( ♯ ‘ { 𝑓 ∣ ( 𝑓 : 𝐴1-1-onto𝐴 ∧ ∀ 𝑦𝐴 ( 𝑓𝑦 ) ≠ 𝑦 ) } ) )

Proof

Step Hyp Ref Expression
1 derang.d 𝐷 = ( 𝑥 ∈ Fin ↦ ( ♯ ‘ { 𝑓 ∣ ( 𝑓 : 𝑥1-1-onto𝑥 ∧ ∀ 𝑦𝑥 ( 𝑓𝑦 ) ≠ 𝑦 ) } ) )
2 f1oeq2 ( 𝑥 = 𝐴 → ( 𝑓 : 𝑥1-1-onto𝑥𝑓 : 𝐴1-1-onto𝑥 ) )
3 f1oeq3 ( 𝑥 = 𝐴 → ( 𝑓 : 𝐴1-1-onto𝑥𝑓 : 𝐴1-1-onto𝐴 ) )
4 2 3 bitrd ( 𝑥 = 𝐴 → ( 𝑓 : 𝑥1-1-onto𝑥𝑓 : 𝐴1-1-onto𝐴 ) )
5 raleq ( 𝑥 = 𝐴 → ( ∀ 𝑦𝑥 ( 𝑓𝑦 ) ≠ 𝑦 ↔ ∀ 𝑦𝐴 ( 𝑓𝑦 ) ≠ 𝑦 ) )
6 4 5 anbi12d ( 𝑥 = 𝐴 → ( ( 𝑓 : 𝑥1-1-onto𝑥 ∧ ∀ 𝑦𝑥 ( 𝑓𝑦 ) ≠ 𝑦 ) ↔ ( 𝑓 : 𝐴1-1-onto𝐴 ∧ ∀ 𝑦𝐴 ( 𝑓𝑦 ) ≠ 𝑦 ) ) )
7 6 abbidv ( 𝑥 = 𝐴 → { 𝑓 ∣ ( 𝑓 : 𝑥1-1-onto𝑥 ∧ ∀ 𝑦𝑥 ( 𝑓𝑦 ) ≠ 𝑦 ) } = { 𝑓 ∣ ( 𝑓 : 𝐴1-1-onto𝐴 ∧ ∀ 𝑦𝐴 ( 𝑓𝑦 ) ≠ 𝑦 ) } )
8 7 fveq2d ( 𝑥 = 𝐴 → ( ♯ ‘ { 𝑓 ∣ ( 𝑓 : 𝑥1-1-onto𝑥 ∧ ∀ 𝑦𝑥 ( 𝑓𝑦 ) ≠ 𝑦 ) } ) = ( ♯ ‘ { 𝑓 ∣ ( 𝑓 : 𝐴1-1-onto𝐴 ∧ ∀ 𝑦𝐴 ( 𝑓𝑦 ) ≠ 𝑦 ) } ) )
9 fvex ( ♯ ‘ { 𝑓 ∣ ( 𝑓 : 𝐴1-1-onto𝐴 ∧ ∀ 𝑦𝐴 ( 𝑓𝑦 ) ≠ 𝑦 ) } ) ∈ V
10 8 1 9 fvmpt ( 𝐴 ∈ Fin → ( 𝐷𝐴 ) = ( ♯ ‘ { 𝑓 ∣ ( 𝑓 : 𝐴1-1-onto𝐴 ∧ ∀ 𝑦𝐴 ( 𝑓𝑦 ) ≠ 𝑦 ) } ) )