Metamath Proof Explorer


Theorem derangen

Description: The derangement number is a cardinal invariant, i.e. it only depends on the size of a set and not on its contents. (Contributed by Mario Carneiro, 22-Jan-2015)

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

Proof

Step Hyp Ref Expression
1 derang.d 𝐷 = ( 𝑥 ∈ Fin ↦ ( ♯ ‘ { 𝑓 ∣ ( 𝑓 : 𝑥1-1-onto𝑥 ∧ ∀ 𝑦𝑥 ( 𝑓𝑦 ) ≠ 𝑦 ) } ) )
2 1 derangenlem ( ( 𝐴𝐵𝐵 ∈ Fin ) → ( 𝐷𝐴 ) ≤ ( 𝐷𝐵 ) )
3 ensym ( 𝐴𝐵𝐵𝐴 )
4 3 adantr ( ( 𝐴𝐵𝐵 ∈ Fin ) → 𝐵𝐴 )
5 enfi ( 𝐴𝐵 → ( 𝐴 ∈ Fin ↔ 𝐵 ∈ Fin ) )
6 5 biimpar ( ( 𝐴𝐵𝐵 ∈ Fin ) → 𝐴 ∈ Fin )
7 1 derangenlem ( ( 𝐵𝐴𝐴 ∈ Fin ) → ( 𝐷𝐵 ) ≤ ( 𝐷𝐴 ) )
8 4 6 7 syl2anc ( ( 𝐴𝐵𝐵 ∈ Fin ) → ( 𝐷𝐵 ) ≤ ( 𝐷𝐴 ) )
9 1 derangf 𝐷 : Fin ⟶ ℕ0
10 9 ffvelrni ( 𝐴 ∈ Fin → ( 𝐷𝐴 ) ∈ ℕ0 )
11 6 10 syl ( ( 𝐴𝐵𝐵 ∈ Fin ) → ( 𝐷𝐴 ) ∈ ℕ0 )
12 9 ffvelrni ( 𝐵 ∈ Fin → ( 𝐷𝐵 ) ∈ ℕ0 )
13 12 adantl ( ( 𝐴𝐵𝐵 ∈ Fin ) → ( 𝐷𝐵 ) ∈ ℕ0 )
14 nn0re ( ( 𝐷𝐴 ) ∈ ℕ0 → ( 𝐷𝐴 ) ∈ ℝ )
15 nn0re ( ( 𝐷𝐵 ) ∈ ℕ0 → ( 𝐷𝐵 ) ∈ ℝ )
16 letri3 ( ( ( 𝐷𝐴 ) ∈ ℝ ∧ ( 𝐷𝐵 ) ∈ ℝ ) → ( ( 𝐷𝐴 ) = ( 𝐷𝐵 ) ↔ ( ( 𝐷𝐴 ) ≤ ( 𝐷𝐵 ) ∧ ( 𝐷𝐵 ) ≤ ( 𝐷𝐴 ) ) ) )
17 14 15 16 syl2an ( ( ( 𝐷𝐴 ) ∈ ℕ0 ∧ ( 𝐷𝐵 ) ∈ ℕ0 ) → ( ( 𝐷𝐴 ) = ( 𝐷𝐵 ) ↔ ( ( 𝐷𝐴 ) ≤ ( 𝐷𝐵 ) ∧ ( 𝐷𝐵 ) ≤ ( 𝐷𝐴 ) ) ) )
18 11 13 17 syl2anc ( ( 𝐴𝐵𝐵 ∈ Fin ) → ( ( 𝐷𝐴 ) = ( 𝐷𝐵 ) ↔ ( ( 𝐷𝐴 ) ≤ ( 𝐷𝐵 ) ∧ ( 𝐷𝐵 ) ≤ ( 𝐷𝐴 ) ) ) )
19 2 8 18 mpbir2and ( ( 𝐴𝐵𝐵 ∈ Fin ) → ( 𝐷𝐴 ) = ( 𝐷𝐵 ) )