Metamath Proof Explorer


Theorem ballotlemrinv0

Description: Lemma for ballotlemrinv . (Contributed by Thierry Arnoux, 18-Apr-2017)

Ref Expression
Hypotheses ballotth.m
|- M e. NN
ballotth.n
|- N e. NN
ballotth.o
|- O = { c e. ~P ( 1 ... ( M + N ) ) | ( # ` c ) = M }
ballotth.p
|- P = ( x e. ~P O |-> ( ( # ` x ) / ( # ` O ) ) )
ballotth.f
|- F = ( c e. O |-> ( i e. ZZ |-> ( ( # ` ( ( 1 ... i ) i^i c ) ) - ( # ` ( ( 1 ... i ) \ c ) ) ) ) )
ballotth.e
|- E = { c e. O | A. i e. ( 1 ... ( M + N ) ) 0 < ( ( F ` c ) ` i ) }
ballotth.mgtn
|- N < M
ballotth.i
|- I = ( c e. ( O \ E ) |-> inf ( { k e. ( 1 ... ( M + N ) ) | ( ( F ` c ) ` k ) = 0 } , RR , < ) )
ballotth.s
|- S = ( c e. ( O \ E ) |-> ( i e. ( 1 ... ( M + N ) ) |-> if ( i <_ ( I ` c ) , ( ( ( I ` c ) + 1 ) - i ) , i ) ) )
ballotth.r
|- R = ( c e. ( O \ E ) |-> ( ( S ` c ) " c ) )
Assertion ballotlemrinv0
|- ( ( C e. ( O \ E ) /\ D = ( ( S ` C ) " C ) ) -> ( D e. ( O \ E ) /\ C = ( ( S ` D ) " D ) ) )

Proof

Step Hyp Ref Expression
1 ballotth.m
 |-  M e. NN
2 ballotth.n
 |-  N e. NN
3 ballotth.o
 |-  O = { c e. ~P ( 1 ... ( M + N ) ) | ( # ` c ) = M }
4 ballotth.p
 |-  P = ( x e. ~P O |-> ( ( # ` x ) / ( # ` O ) ) )
5 ballotth.f
 |-  F = ( c e. O |-> ( i e. ZZ |-> ( ( # ` ( ( 1 ... i ) i^i c ) ) - ( # ` ( ( 1 ... i ) \ c ) ) ) ) )
6 ballotth.e
 |-  E = { c e. O | A. i e. ( 1 ... ( M + N ) ) 0 < ( ( F ` c ) ` i ) }
7 ballotth.mgtn
 |-  N < M
8 ballotth.i
 |-  I = ( c e. ( O \ E ) |-> inf ( { k e. ( 1 ... ( M + N ) ) | ( ( F ` c ) ` k ) = 0 } , RR , < ) )
9 ballotth.s
 |-  S = ( c e. ( O \ E ) |-> ( i e. ( 1 ... ( M + N ) ) |-> if ( i <_ ( I ` c ) , ( ( ( I ` c ) + 1 ) - i ) , i ) ) )
10 ballotth.r
 |-  R = ( c e. ( O \ E ) |-> ( ( S ` c ) " c ) )
11 1 2 3 4 5 6 7 8 9 10 ballotlemrval
 |-  ( C e. ( O \ E ) -> ( R ` C ) = ( ( S ` C ) " C ) )
12 11 adantr
 |-  ( ( C e. ( O \ E ) /\ D = ( ( S ` C ) " C ) ) -> ( R ` C ) = ( ( S ` C ) " C ) )
13 simpr
 |-  ( ( C e. ( O \ E ) /\ D = ( ( S ` C ) " C ) ) -> D = ( ( S ` C ) " C ) )
14 12 13 eqtr4d
 |-  ( ( C e. ( O \ E ) /\ D = ( ( S ` C ) " C ) ) -> ( R ` C ) = D )
15 1 2 3 4 5 6 7 8 9 10 ballotlemrc
 |-  ( C e. ( O \ E ) -> ( R ` C ) e. ( O \ E ) )
16 15 adantr
 |-  ( ( C e. ( O \ E ) /\ D = ( ( S ` C ) " C ) ) -> ( R ` C ) e. ( O \ E ) )
17 14 16 eqeltrrd
 |-  ( ( C e. ( O \ E ) /\ D = ( ( S ` C ) " C ) ) -> D e. ( O \ E ) )
18 1 2 3 4 5 6 7 8 9 ballotlemsf1o
 |-  ( C e. ( O \ E ) -> ( ( S ` C ) : ( 1 ... ( M + N ) ) -1-1-onto-> ( 1 ... ( M + N ) ) /\ `' ( S ` C ) = ( S ` C ) ) )
19 18 simprd
 |-  ( C e. ( O \ E ) -> `' ( S ` C ) = ( S ` C ) )
20 19 adantr
 |-  ( ( C e. ( O \ E ) /\ D = ( ( S ` C ) " C ) ) -> `' ( S ` C ) = ( S ` C ) )
21 20 eqcomd
 |-  ( ( C e. ( O \ E ) /\ D = ( ( S ` C ) " C ) ) -> ( S ` C ) = `' ( S ` C ) )
22 21 13 imaeq12d
 |-  ( ( C e. ( O \ E ) /\ D = ( ( S ` C ) " C ) ) -> ( ( S ` C ) " D ) = ( `' ( S ` C ) " ( ( S ` C ) " C ) ) )
23 simpl
 |-  ( ( C e. ( O \ E ) /\ D = ( ( S ` C ) " C ) ) -> C e. ( O \ E ) )
24 1 2 3 4 5 6 7 8 9 10 ballotlemirc
 |-  ( C e. ( O \ E ) -> ( I ` ( R ` C ) ) = ( I ` C ) )
25 24 adantr
 |-  ( ( C e. ( O \ E ) /\ D = ( ( S ` C ) " C ) ) -> ( I ` ( R ` C ) ) = ( I ` C ) )
26 14 fveq2d
 |-  ( ( C e. ( O \ E ) /\ D = ( ( S ` C ) " C ) ) -> ( I ` ( R ` C ) ) = ( I ` D ) )
27 25 26 eqtr3d
 |-  ( ( C e. ( O \ E ) /\ D = ( ( S ` C ) " C ) ) -> ( I ` C ) = ( I ` D ) )
28 1 2 3 4 5 6 7 8 9 ballotlemieq
 |-  ( ( C e. ( O \ E ) /\ D e. ( O \ E ) /\ ( I ` C ) = ( I ` D ) ) -> ( S ` C ) = ( S ` D ) )
29 23 17 27 28 syl3anc
 |-  ( ( C e. ( O \ E ) /\ D = ( ( S ` C ) " C ) ) -> ( S ` C ) = ( S ` D ) )
30 29 imaeq1d
 |-  ( ( C e. ( O \ E ) /\ D = ( ( S ` C ) " C ) ) -> ( ( S ` C ) " D ) = ( ( S ` D ) " D ) )
31 18 simpld
 |-  ( C e. ( O \ E ) -> ( S ` C ) : ( 1 ... ( M + N ) ) -1-1-onto-> ( 1 ... ( M + N ) ) )
32 f1of1
 |-  ( ( S ` C ) : ( 1 ... ( M + N ) ) -1-1-onto-> ( 1 ... ( M + N ) ) -> ( S ` C ) : ( 1 ... ( M + N ) ) -1-1-> ( 1 ... ( M + N ) ) )
33 23 31 32 3syl
 |-  ( ( C e. ( O \ E ) /\ D = ( ( S ` C ) " C ) ) -> ( S ` C ) : ( 1 ... ( M + N ) ) -1-1-> ( 1 ... ( M + N ) ) )
34 eldifi
 |-  ( C e. ( O \ E ) -> C e. O )
35 1 2 3 ballotlemelo
 |-  ( C e. O <-> ( C C_ ( 1 ... ( M + N ) ) /\ ( # ` C ) = M ) )
36 35 simplbi
 |-  ( C e. O -> C C_ ( 1 ... ( M + N ) ) )
37 23 34 36 3syl
 |-  ( ( C e. ( O \ E ) /\ D = ( ( S ` C ) " C ) ) -> C C_ ( 1 ... ( M + N ) ) )
38 f1imacnv
 |-  ( ( ( S ` C ) : ( 1 ... ( M + N ) ) -1-1-> ( 1 ... ( M + N ) ) /\ C C_ ( 1 ... ( M + N ) ) ) -> ( `' ( S ` C ) " ( ( S ` C ) " C ) ) = C )
39 33 37 38 syl2anc
 |-  ( ( C e. ( O \ E ) /\ D = ( ( S ` C ) " C ) ) -> ( `' ( S ` C ) " ( ( S ` C ) " C ) ) = C )
40 22 30 39 3eqtr3rd
 |-  ( ( C e. ( O \ E ) /\ D = ( ( S ` C ) " C ) ) -> C = ( ( S ` D ) " D ) )
41 17 40 jca
 |-  ( ( C e. ( O \ E ) /\ D = ( ( S ` C ) " C ) ) -> ( D e. ( O \ E ) /\ C = ( ( S ` D ) " D ) ) )