Metamath Proof Explorer


Theorem ballotlemro

Description: Range of R is included in O . (Contributed by Thierry Arnoux, 17-Apr-2017)

Ref Expression
Hypotheses ballotth.m 𝑀 ∈ ℕ
ballotth.n 𝑁 ∈ ℕ
ballotth.o 𝑂 = { 𝑐 ∈ 𝒫 ( 1 ... ( 𝑀 + 𝑁 ) ) ∣ ( ♯ ‘ 𝑐 ) = 𝑀 }
ballotth.p 𝑃 = ( 𝑥 ∈ 𝒫 𝑂 ↦ ( ( ♯ ‘ 𝑥 ) / ( ♯ ‘ 𝑂 ) ) )
ballotth.f 𝐹 = ( 𝑐𝑂 ↦ ( 𝑖 ∈ ℤ ↦ ( ( ♯ ‘ ( ( 1 ... 𝑖 ) ∩ 𝑐 ) ) − ( ♯ ‘ ( ( 1 ... 𝑖 ) ∖ 𝑐 ) ) ) ) )
ballotth.e 𝐸 = { 𝑐𝑂 ∣ ∀ 𝑖 ∈ ( 1 ... ( 𝑀 + 𝑁 ) ) 0 < ( ( 𝐹𝑐 ) ‘ 𝑖 ) }
ballotth.mgtn 𝑁 < 𝑀
ballotth.i 𝐼 = ( 𝑐 ∈ ( 𝑂𝐸 ) ↦ inf ( { 𝑘 ∈ ( 1 ... ( 𝑀 + 𝑁 ) ) ∣ ( ( 𝐹𝑐 ) ‘ 𝑘 ) = 0 } , ℝ , < ) )
ballotth.s 𝑆 = ( 𝑐 ∈ ( 𝑂𝐸 ) ↦ ( 𝑖 ∈ ( 1 ... ( 𝑀 + 𝑁 ) ) ↦ if ( 𝑖 ≤ ( 𝐼𝑐 ) , ( ( ( 𝐼𝑐 ) + 1 ) − 𝑖 ) , 𝑖 ) ) )
ballotth.r 𝑅 = ( 𝑐 ∈ ( 𝑂𝐸 ) ↦ ( ( 𝑆𝑐 ) “ 𝑐 ) )
Assertion ballotlemro ( 𝐶 ∈ ( 𝑂𝐸 ) → ( 𝑅𝐶 ) ∈ 𝑂 )

Proof

Step Hyp Ref Expression
1 ballotth.m 𝑀 ∈ ℕ
2 ballotth.n 𝑁 ∈ ℕ
3 ballotth.o 𝑂 = { 𝑐 ∈ 𝒫 ( 1 ... ( 𝑀 + 𝑁 ) ) ∣ ( ♯ ‘ 𝑐 ) = 𝑀 }
4 ballotth.p 𝑃 = ( 𝑥 ∈ 𝒫 𝑂 ↦ ( ( ♯ ‘ 𝑥 ) / ( ♯ ‘ 𝑂 ) ) )
5 ballotth.f 𝐹 = ( 𝑐𝑂 ↦ ( 𝑖 ∈ ℤ ↦ ( ( ♯ ‘ ( ( 1 ... 𝑖 ) ∩ 𝑐 ) ) − ( ♯ ‘ ( ( 1 ... 𝑖 ) ∖ 𝑐 ) ) ) ) )
6 ballotth.e 𝐸 = { 𝑐𝑂 ∣ ∀ 𝑖 ∈ ( 1 ... ( 𝑀 + 𝑁 ) ) 0 < ( ( 𝐹𝑐 ) ‘ 𝑖 ) }
7 ballotth.mgtn 𝑁 < 𝑀
8 ballotth.i 𝐼 = ( 𝑐 ∈ ( 𝑂𝐸 ) ↦ inf ( { 𝑘 ∈ ( 1 ... ( 𝑀 + 𝑁 ) ) ∣ ( ( 𝐹𝑐 ) ‘ 𝑘 ) = 0 } , ℝ , < ) )
9 ballotth.s 𝑆 = ( 𝑐 ∈ ( 𝑂𝐸 ) ↦ ( 𝑖 ∈ ( 1 ... ( 𝑀 + 𝑁 ) ) ↦ if ( 𝑖 ≤ ( 𝐼𝑐 ) , ( ( ( 𝐼𝑐 ) + 1 ) − 𝑖 ) , 𝑖 ) ) )
10 ballotth.r 𝑅 = ( 𝑐 ∈ ( 𝑂𝐸 ) ↦ ( ( 𝑆𝑐 ) “ 𝑐 ) )
11 1 2 3 4 5 6 7 8 9 10 ballotlemrval ( 𝐶 ∈ ( 𝑂𝐸 ) → ( 𝑅𝐶 ) = ( ( 𝑆𝐶 ) “ 𝐶 ) )
12 imassrn ( ( 𝑆𝐶 ) “ 𝐶 ) ⊆ ran ( 𝑆𝐶 )
13 1 2 3 4 5 6 7 8 9 ballotlemsf1o ( 𝐶 ∈ ( 𝑂𝐸 ) → ( ( 𝑆𝐶 ) : ( 1 ... ( 𝑀 + 𝑁 ) ) –1-1-onto→ ( 1 ... ( 𝑀 + 𝑁 ) ) ∧ ( 𝑆𝐶 ) = ( 𝑆𝐶 ) ) )
14 13 simpld ( 𝐶 ∈ ( 𝑂𝐸 ) → ( 𝑆𝐶 ) : ( 1 ... ( 𝑀 + 𝑁 ) ) –1-1-onto→ ( 1 ... ( 𝑀 + 𝑁 ) ) )
15 f1ofo ( ( 𝑆𝐶 ) : ( 1 ... ( 𝑀 + 𝑁 ) ) –1-1-onto→ ( 1 ... ( 𝑀 + 𝑁 ) ) → ( 𝑆𝐶 ) : ( 1 ... ( 𝑀 + 𝑁 ) ) –onto→ ( 1 ... ( 𝑀 + 𝑁 ) ) )
16 forn ( ( 𝑆𝐶 ) : ( 1 ... ( 𝑀 + 𝑁 ) ) –onto→ ( 1 ... ( 𝑀 + 𝑁 ) ) → ran ( 𝑆𝐶 ) = ( 1 ... ( 𝑀 + 𝑁 ) ) )
17 14 15 16 3syl ( 𝐶 ∈ ( 𝑂𝐸 ) → ran ( 𝑆𝐶 ) = ( 1 ... ( 𝑀 + 𝑁 ) ) )
18 12 17 sseqtrid ( 𝐶 ∈ ( 𝑂𝐸 ) → ( ( 𝑆𝐶 ) “ 𝐶 ) ⊆ ( 1 ... ( 𝑀 + 𝑁 ) ) )
19 11 18 eqsstrd ( 𝐶 ∈ ( 𝑂𝐸 ) → ( 𝑅𝐶 ) ⊆ ( 1 ... ( 𝑀 + 𝑁 ) ) )
20 f1of1 ( ( 𝑆𝐶 ) : ( 1 ... ( 𝑀 + 𝑁 ) ) –1-1-onto→ ( 1 ... ( 𝑀 + 𝑁 ) ) → ( 𝑆𝐶 ) : ( 1 ... ( 𝑀 + 𝑁 ) ) –1-1→ ( 1 ... ( 𝑀 + 𝑁 ) ) )
21 14 20 syl ( 𝐶 ∈ ( 𝑂𝐸 ) → ( 𝑆𝐶 ) : ( 1 ... ( 𝑀 + 𝑁 ) ) –1-1→ ( 1 ... ( 𝑀 + 𝑁 ) ) )
22 eldifi ( 𝐶 ∈ ( 𝑂𝐸 ) → 𝐶𝑂 )
23 1 2 3 ballotlemelo ( 𝐶𝑂 ↔ ( 𝐶 ⊆ ( 1 ... ( 𝑀 + 𝑁 ) ) ∧ ( ♯ ‘ 𝐶 ) = 𝑀 ) )
24 22 23 sylib ( 𝐶 ∈ ( 𝑂𝐸 ) → ( 𝐶 ⊆ ( 1 ... ( 𝑀 + 𝑁 ) ) ∧ ( ♯ ‘ 𝐶 ) = 𝑀 ) )
25 24 simpld ( 𝐶 ∈ ( 𝑂𝐸 ) → 𝐶 ⊆ ( 1 ... ( 𝑀 + 𝑁 ) ) )
26 id ( 𝐶 ∈ ( 𝑂𝐸 ) → 𝐶 ∈ ( 𝑂𝐸 ) )
27 f1imaeng ( ( ( 𝑆𝐶 ) : ( 1 ... ( 𝑀 + 𝑁 ) ) –1-1→ ( 1 ... ( 𝑀 + 𝑁 ) ) ∧ 𝐶 ⊆ ( 1 ... ( 𝑀 + 𝑁 ) ) ∧ 𝐶 ∈ ( 𝑂𝐸 ) ) → ( ( 𝑆𝐶 ) “ 𝐶 ) ≈ 𝐶 )
28 21 25 26 27 syl3anc ( 𝐶 ∈ ( 𝑂𝐸 ) → ( ( 𝑆𝐶 ) “ 𝐶 ) ≈ 𝐶 )
29 11 28 eqbrtrd ( 𝐶 ∈ ( 𝑂𝐸 ) → ( 𝑅𝐶 ) ≈ 𝐶 )
30 hasheni ( ( 𝑅𝐶 ) ≈ 𝐶 → ( ♯ ‘ ( 𝑅𝐶 ) ) = ( ♯ ‘ 𝐶 ) )
31 29 30 syl ( 𝐶 ∈ ( 𝑂𝐸 ) → ( ♯ ‘ ( 𝑅𝐶 ) ) = ( ♯ ‘ 𝐶 ) )
32 24 simprd ( 𝐶 ∈ ( 𝑂𝐸 ) → ( ♯ ‘ 𝐶 ) = 𝑀 )
33 31 32 eqtrd ( 𝐶 ∈ ( 𝑂𝐸 ) → ( ♯ ‘ ( 𝑅𝐶 ) ) = 𝑀 )
34 1 2 3 ballotlemelo ( ( 𝑅𝐶 ) ∈ 𝑂 ↔ ( ( 𝑅𝐶 ) ⊆ ( 1 ... ( 𝑀 + 𝑁 ) ) ∧ ( ♯ ‘ ( 𝑅𝐶 ) ) = 𝑀 ) )
35 19 33 34 sylanbrc ( 𝐶 ∈ ( 𝑂𝐸 ) → ( 𝑅𝐶 ) ∈ 𝑂 )