Metamath Proof Explorer


Theorem ballotlemsval

Description: Value of S . (Contributed by Thierry Arnoux, 12-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 ) − 𝑖 ) , 𝑖 ) ) )
Assertion ballotlemsval ( 𝐶 ∈ ( 𝑂𝐸 ) → ( 𝑆𝐶 ) = ( 𝑖 ∈ ( 1 ... ( 𝑀 + 𝑁 ) ) ↦ if ( 𝑖 ≤ ( 𝐼𝐶 ) , ( ( ( 𝐼𝐶 ) + 1 ) − 𝑖 ) , 𝑖 ) ) )

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 simpl ( ( 𝑑 = 𝐶𝑖 ∈ ( 1 ... ( 𝑀 + 𝑁 ) ) ) → 𝑑 = 𝐶 )
11 10 fveq2d ( ( 𝑑 = 𝐶𝑖 ∈ ( 1 ... ( 𝑀 + 𝑁 ) ) ) → ( 𝐼𝑑 ) = ( 𝐼𝐶 ) )
12 11 breq2d ( ( 𝑑 = 𝐶𝑖 ∈ ( 1 ... ( 𝑀 + 𝑁 ) ) ) → ( 𝑖 ≤ ( 𝐼𝑑 ) ↔ 𝑖 ≤ ( 𝐼𝐶 ) ) )
13 11 oveq1d ( ( 𝑑 = 𝐶𝑖 ∈ ( 1 ... ( 𝑀 + 𝑁 ) ) ) → ( ( 𝐼𝑑 ) + 1 ) = ( ( 𝐼𝐶 ) + 1 ) )
14 13 oveq1d ( ( 𝑑 = 𝐶𝑖 ∈ ( 1 ... ( 𝑀 + 𝑁 ) ) ) → ( ( ( 𝐼𝑑 ) + 1 ) − 𝑖 ) = ( ( ( 𝐼𝐶 ) + 1 ) − 𝑖 ) )
15 12 14 ifbieq1d ( ( 𝑑 = 𝐶𝑖 ∈ ( 1 ... ( 𝑀 + 𝑁 ) ) ) → if ( 𝑖 ≤ ( 𝐼𝑑 ) , ( ( ( 𝐼𝑑 ) + 1 ) − 𝑖 ) , 𝑖 ) = if ( 𝑖 ≤ ( 𝐼𝐶 ) , ( ( ( 𝐼𝐶 ) + 1 ) − 𝑖 ) , 𝑖 ) )
16 15 mpteq2dva ( 𝑑 = 𝐶 → ( 𝑖 ∈ ( 1 ... ( 𝑀 + 𝑁 ) ) ↦ if ( 𝑖 ≤ ( 𝐼𝑑 ) , ( ( ( 𝐼𝑑 ) + 1 ) − 𝑖 ) , 𝑖 ) ) = ( 𝑖 ∈ ( 1 ... ( 𝑀 + 𝑁 ) ) ↦ if ( 𝑖 ≤ ( 𝐼𝐶 ) , ( ( ( 𝐼𝐶 ) + 1 ) − 𝑖 ) , 𝑖 ) ) )
17 simpl ( ( 𝑐 = 𝑑𝑖 ∈ ( 1 ... ( 𝑀 + 𝑁 ) ) ) → 𝑐 = 𝑑 )
18 17 fveq2d ( ( 𝑐 = 𝑑𝑖 ∈ ( 1 ... ( 𝑀 + 𝑁 ) ) ) → ( 𝐼𝑐 ) = ( 𝐼𝑑 ) )
19 18 breq2d ( ( 𝑐 = 𝑑𝑖 ∈ ( 1 ... ( 𝑀 + 𝑁 ) ) ) → ( 𝑖 ≤ ( 𝐼𝑐 ) ↔ 𝑖 ≤ ( 𝐼𝑑 ) ) )
20 18 oveq1d ( ( 𝑐 = 𝑑𝑖 ∈ ( 1 ... ( 𝑀 + 𝑁 ) ) ) → ( ( 𝐼𝑐 ) + 1 ) = ( ( 𝐼𝑑 ) + 1 ) )
21 20 oveq1d ( ( 𝑐 = 𝑑𝑖 ∈ ( 1 ... ( 𝑀 + 𝑁 ) ) ) → ( ( ( 𝐼𝑐 ) + 1 ) − 𝑖 ) = ( ( ( 𝐼𝑑 ) + 1 ) − 𝑖 ) )
22 19 21 ifbieq1d ( ( 𝑐 = 𝑑𝑖 ∈ ( 1 ... ( 𝑀 + 𝑁 ) ) ) → if ( 𝑖 ≤ ( 𝐼𝑐 ) , ( ( ( 𝐼𝑐 ) + 1 ) − 𝑖 ) , 𝑖 ) = if ( 𝑖 ≤ ( 𝐼𝑑 ) , ( ( ( 𝐼𝑑 ) + 1 ) − 𝑖 ) , 𝑖 ) )
23 22 mpteq2dva ( 𝑐 = 𝑑 → ( 𝑖 ∈ ( 1 ... ( 𝑀 + 𝑁 ) ) ↦ if ( 𝑖 ≤ ( 𝐼𝑐 ) , ( ( ( 𝐼𝑐 ) + 1 ) − 𝑖 ) , 𝑖 ) ) = ( 𝑖 ∈ ( 1 ... ( 𝑀 + 𝑁 ) ) ↦ if ( 𝑖 ≤ ( 𝐼𝑑 ) , ( ( ( 𝐼𝑑 ) + 1 ) − 𝑖 ) , 𝑖 ) ) )
24 23 cbvmptv ( 𝑐 ∈ ( 𝑂𝐸 ) ↦ ( 𝑖 ∈ ( 1 ... ( 𝑀 + 𝑁 ) ) ↦ if ( 𝑖 ≤ ( 𝐼𝑐 ) , ( ( ( 𝐼𝑐 ) + 1 ) − 𝑖 ) , 𝑖 ) ) ) = ( 𝑑 ∈ ( 𝑂𝐸 ) ↦ ( 𝑖 ∈ ( 1 ... ( 𝑀 + 𝑁 ) ) ↦ if ( 𝑖 ≤ ( 𝐼𝑑 ) , ( ( ( 𝐼𝑑 ) + 1 ) − 𝑖 ) , 𝑖 ) ) )
25 9 24 eqtri 𝑆 = ( 𝑑 ∈ ( 𝑂𝐸 ) ↦ ( 𝑖 ∈ ( 1 ... ( 𝑀 + 𝑁 ) ) ↦ if ( 𝑖 ≤ ( 𝐼𝑑 ) , ( ( ( 𝐼𝑑 ) + 1 ) − 𝑖 ) , 𝑖 ) ) )
26 ovex ( 1 ... ( 𝑀 + 𝑁 ) ) ∈ V
27 26 mptex ( 𝑖 ∈ ( 1 ... ( 𝑀 + 𝑁 ) ) ↦ if ( 𝑖 ≤ ( 𝐼𝐶 ) , ( ( ( 𝐼𝐶 ) + 1 ) − 𝑖 ) , 𝑖 ) ) ∈ V
28 16 25 27 fvmpt ( 𝐶 ∈ ( 𝑂𝐸 ) → ( 𝑆𝐶 ) = ( 𝑖 ∈ ( 1 ... ( 𝑀 + 𝑁 ) ) ↦ if ( 𝑖 ≤ ( 𝐼𝐶 ) , ( ( ( 𝐼𝐶 ) + 1 ) − 𝑖 ) , 𝑖 ) ) )