MPE Home Metamath Proof Explorer < Previous   Next >
Nearby theorems
Mirrors  >  Home  >  MPE Home  >  Th. List  >  sadaddlem Structured version   Unicode version

Theorem sadaddlem 13683
Description: Lemma for sadadd 13684. (Contributed by Mario Carneiro, 9-Sep-2016.)
Hypotheses
Ref Expression
sadaddlem.c  |-  C  =  seq 0 ( ( c  e.  2o ,  m  e.  NN0  |->  if (cadd ( m  e.  (bits `  A ) ,  m  e.  (bits `  B ) ,  (/)  e.  c ) ,  1o ,  (/) ) ) ,  ( n  e.  NN0  |->  if ( n  =  0 ,  (/) ,  ( n  - 
1 ) ) ) )
sadaddlem.k  |-  K  =  `' (bits  |`  NN0 )
sadaddlem.1  |-  ( ph  ->  A  e.  ZZ )
sadaddlem.2  |-  ( ph  ->  B  e.  ZZ )
sadaddlem.3  |-  ( ph  ->  N  e.  NN0 )
Assertion
Ref Expression
sadaddlem  |-  ( ph  ->  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) )  =  (bits `  (
( A  +  B
)  mod  ( 2 ^ N ) ) ) )
Distinct variable groups:    m, c, n    A, c, m    B, c, m    n, N
Allowed substitution hints:    ph( m, n, c)    A( n)    B( n)    C( m, n, c)    K( m, n, c)    N( m, c)

Proof of Theorem sadaddlem
StepHypRef Expression
1 sadaddlem.k . . . . . . . . . . . . 13  |-  K  =  `' (bits  |`  NN0 )
21fveq1i 5713 . . . . . . . . . . . 12  |-  ( K `
 ( (bits `  A )  i^i  (
0..^ N ) ) )  =  ( `' (bits  |`  NN0 ) `  ( (bits `  A )  i^i  ( 0..^ N ) ) )
3 sadaddlem.1 . . . . . . . . . . . . . . . 16  |-  ( ph  ->  A  e.  ZZ )
4 2nn 10500 . . . . . . . . . . . . . . . . . 18  |-  2  e.  NN
54a1i 11 . . . . . . . . . . . . . . . . 17  |-  ( ph  ->  2  e.  NN )
6 sadaddlem.3 . . . . . . . . . . . . . . . . 17  |-  ( ph  ->  N  e.  NN0 )
75, 6nnexpcld 12050 . . . . . . . . . . . . . . . 16  |-  ( ph  ->  ( 2 ^ N
)  e.  NN )
83, 7zmodcld 11749 . . . . . . . . . . . . . . 15  |-  ( ph  ->  ( A  mod  (
2 ^ N ) )  e.  NN0 )
9 fvres 5725 . . . . . . . . . . . . . . 15  |-  ( ( A  mod  ( 2 ^ N ) )  e.  NN0  ->  ( (bits  |`  NN0 ) `  ( A  mod  ( 2 ^ N ) ) )  =  (bits `  ( A  mod  ( 2 ^ N ) ) ) )
108, 9syl 16 . . . . . . . . . . . . . 14  |-  ( ph  ->  ( (bits  |`  NN0 ) `  ( A  mod  (
2 ^ N ) ) )  =  (bits `  ( A  mod  (
2 ^ N ) ) ) )
11 bitsmod 13653 . . . . . . . . . . . . . . 15  |-  ( ( A  e.  ZZ  /\  N  e.  NN0 )  -> 
(bits `  ( A  mod  ( 2 ^ N
) ) )  =  ( (bits `  A
)  i^i  ( 0..^ N ) ) )
123, 6, 11syl2anc 661 . . . . . . . . . . . . . 14  |-  ( ph  ->  (bits `  ( A  mod  ( 2 ^ N
) ) )  =  ( (bits `  A
)  i^i  ( 0..^ N ) ) )
1310, 12eqtrd 2475 . . . . . . . . . . . . 13  |-  ( ph  ->  ( (bits  |`  NN0 ) `  ( A  mod  (
2 ^ N ) ) )  =  ( (bits `  A )  i^i  ( 0..^ N ) ) )
14 bitsf1o 13662 . . . . . . . . . . . . . 14  |-  (bits  |`  NN0 ) : NN0
-1-1-onto-> ( ~P NN0  i^i  Fin )
15 f1ocnvfv 6006 . . . . . . . . . . . . . 14  |-  ( ( (bits  |`  NN0 ) : NN0
-1-1-onto-> ( ~P NN0  i^i  Fin )  /\  ( A  mod  ( 2 ^ N
) )  e.  NN0 )  ->  ( ( (bits  |`  NN0 ) `  ( A  mod  ( 2 ^ N ) ) )  =  ( (bits `  A )  i^i  (
0..^ N ) )  ->  ( `' (bits  |`  NN0 ) `  (
(bits `  A )  i^i  ( 0..^ N ) ) )  =  ( A  mod  ( 2 ^ N ) ) ) )
1614, 8, 15sylancr 663 . . . . . . . . . . . . 13  |-  ( ph  ->  ( ( (bits  |`  NN0 ) `  ( A  mod  (
2 ^ N ) ) )  =  ( (bits `  A )  i^i  ( 0..^ N ) )  ->  ( `' (bits  |`  NN0 ) `  ( (bits `  A )  i^i  ( 0..^ N ) ) )  =  ( A  mod  ( 2 ^ N ) ) ) )
1713, 16mpd 15 . . . . . . . . . . . 12  |-  ( ph  ->  ( `' (bits  |`  NN0 ) `  ( (bits `  A
)  i^i  ( 0..^ N ) ) )  =  ( A  mod  ( 2 ^ N
) ) )
182, 17syl5eq 2487 . . . . . . . . . . 11  |-  ( ph  ->  ( K `  (
(bits `  A )  i^i  ( 0..^ N ) ) )  =  ( A  mod  ( 2 ^ N ) ) )
1918oveq2d 6128 . . . . . . . . . 10  |-  ( ph  ->  ( A  -  ( K `  ( (bits `  A )  i^i  (
0..^ N ) ) ) )  =  ( A  -  ( A  mod  ( 2 ^ N ) ) ) )
2019oveq1d 6127 . . . . . . . . 9  |-  ( ph  ->  ( ( A  -  ( K `  ( (bits `  A )  i^i  (
0..^ N ) ) ) )  /  (
2 ^ N ) )  =  ( ( A  -  ( A  mod  ( 2 ^ N ) ) )  /  ( 2 ^ N ) ) )
213zred 10768 . . . . . . . . . 10  |-  ( ph  ->  A  e.  RR )
227nnrpd 11047 . . . . . . . . . 10  |-  ( ph  ->  ( 2 ^ N
)  e.  RR+ )
23 moddifz 11741 . . . . . . . . . 10  |-  ( ( A  e.  RR  /\  ( 2 ^ N
)  e.  RR+ )  ->  ( ( A  -  ( A  mod  ( 2 ^ N ) ) )  /  ( 2 ^ N ) )  e.  ZZ )
2421, 22, 23syl2anc 661 . . . . . . . . 9  |-  ( ph  ->  ( ( A  -  ( A  mod  ( 2 ^ N ) ) )  /  ( 2 ^ N ) )  e.  ZZ )
2520, 24eqeltrd 2517 . . . . . . . 8  |-  ( ph  ->  ( ( A  -  ( K `  ( (bits `  A )  i^i  (
0..^ N ) ) ) )  /  (
2 ^ N ) )  e.  ZZ )
267nnzd 10767 . . . . . . . . 9  |-  ( ph  ->  ( 2 ^ N
)  e.  ZZ )
277nnne0d 10387 . . . . . . . . 9  |-  ( ph  ->  ( 2 ^ N
)  =/=  0 )
28 inss1 3591 . . . . . . . . . . . . . 14  |-  ( (bits `  A )  i^i  (
0..^ N ) ) 
C_  (bits `  A
)
29 bitsss 13643 . . . . . . . . . . . . . 14  |-  (bits `  A )  C_  NN0
3028, 29sstri 3386 . . . . . . . . . . . . 13  |-  ( (bits `  A )  i^i  (
0..^ N ) ) 
C_  NN0
31 fzofi 11817 . . . . . . . . . . . . . 14  |-  ( 0..^ N )  e.  Fin
32 inss2 3592 . . . . . . . . . . . . . 14  |-  ( (bits `  A )  i^i  (
0..^ N ) ) 
C_  ( 0..^ N )
33 ssfi 7554 . . . . . . . . . . . . . 14  |-  ( ( ( 0..^ N )  e.  Fin  /\  (
(bits `  A )  i^i  ( 0..^ N ) )  C_  ( 0..^ N ) )  -> 
( (bits `  A
)  i^i  ( 0..^ N ) )  e. 
Fin )
3431, 32, 33mp2an 672 . . . . . . . . . . . . 13  |-  ( (bits `  A )  i^i  (
0..^ N ) )  e.  Fin
35 elfpw 7634 . . . . . . . . . . . . 13  |-  ( ( (bits `  A )  i^i  ( 0..^ N ) )  e.  ( ~P
NN0  i^i  Fin )  <->  ( ( (bits `  A
)  i^i  ( 0..^ N ) )  C_  NN0 
/\  ( (bits `  A )  i^i  (
0..^ N ) )  e.  Fin ) )
3630, 34, 35mpbir2an 911 . . . . . . . . . . . 12  |-  ( (bits `  A )  i^i  (
0..^ N ) )  e.  ( ~P NN0  i^i 
Fin )
37 f1ocnv 5674 . . . . . . . . . . . . . . 15  |-  ( (bits  |`  NN0 ) : NN0 -1-1-onto-> ( ~P NN0  i^i  Fin )  ->  `' (bits  |`  NN0 ) : ( ~P NN0  i^i 
Fin ) -1-1-onto-> NN0 )
38 f1of 5662 . . . . . . . . . . . . . . 15  |-  ( `' (bits  |`  NN0 ) : ( ~P NN0  i^i  Fin ) -1-1-onto-> NN0  ->  `' (bits  |` 
NN0 ) : ( ~P NN0  i^i  Fin )
--> NN0 )
3914, 37, 38mp2b 10 . . . . . . . . . . . . . 14  |-  `' (bits  |`  NN0 ) : ( ~P NN0  i^i  Fin )
--> NN0
401feq1i 5572 . . . . . . . . . . . . . 14  |-  ( K : ( ~P NN0  i^i 
Fin ) --> NN0  <->  `' (bits  |` 
NN0 ) : ( ~P NN0  i^i  Fin )
--> NN0 )
4139, 40mpbir 209 . . . . . . . . . . . . 13  |-  K :
( ~P NN0  i^i  Fin ) --> NN0
4241ffvelrni 5863 . . . . . . . . . . . 12  |-  ( ( (bits `  A )  i^i  ( 0..^ N ) )  e.  ( ~P
NN0  i^i  Fin )  ->  ( K `  (
(bits `  A )  i^i  ( 0..^ N ) ) )  e.  NN0 )
4336, 42mp1i 12 . . . . . . . . . . 11  |-  ( ph  ->  ( K `  (
(bits `  A )  i^i  ( 0..^ N ) ) )  e.  NN0 )
4443nn0zd 10766 . . . . . . . . . 10  |-  ( ph  ->  ( K `  (
(bits `  A )  i^i  ( 0..^ N ) ) )  e.  ZZ )
453, 44zsubcld 10773 . . . . . . . . 9  |-  ( ph  ->  ( A  -  ( K `  ( (bits `  A )  i^i  (
0..^ N ) ) ) )  e.  ZZ )
46 dvdsval2 13559 . . . . . . . . 9  |-  ( ( ( 2 ^ N
)  e.  ZZ  /\  ( 2 ^ N
)  =/=  0  /\  ( A  -  ( K `  ( (bits `  A )  i^i  (
0..^ N ) ) ) )  e.  ZZ )  ->  ( ( 2 ^ N )  ||  ( A  -  ( K `  ( (bits `  A )  i^i  (
0..^ N ) ) ) )  <->  ( ( A  -  ( K `  ( (bits `  A
)  i^i  ( 0..^ N ) ) ) )  /  ( 2 ^ N ) )  e.  ZZ ) )
4726, 27, 45, 46syl3anc 1218 . . . . . . . 8  |-  ( ph  ->  ( ( 2 ^ N )  ||  ( A  -  ( K `  ( (bits `  A
)  i^i  ( 0..^ N ) ) ) )  <->  ( ( A  -  ( K `  ( (bits `  A )  i^i  ( 0..^ N ) ) ) )  / 
( 2 ^ N
) )  e.  ZZ ) )
4825, 47mpbird 232 . . . . . . 7  |-  ( ph  ->  ( 2 ^ N
)  ||  ( A  -  ( K `  ( (bits `  A )  i^i  ( 0..^ N ) ) ) ) )
491fveq1i 5713 . . . . . . . . . . . 12  |-  ( K `
 ( (bits `  B )  i^i  (
0..^ N ) ) )  =  ( `' (bits  |`  NN0 ) `  ( (bits `  B )  i^i  ( 0..^ N ) ) )
50 sadaddlem.2 . . . . . . . . . . . . . . . 16  |-  ( ph  ->  B  e.  ZZ )
5150, 7zmodcld 11749 . . . . . . . . . . . . . . 15  |-  ( ph  ->  ( B  mod  (
2 ^ N ) )  e.  NN0 )
52 fvres 5725 . . . . . . . . . . . . . . 15  |-  ( ( B  mod  ( 2 ^ N ) )  e.  NN0  ->  ( (bits  |`  NN0 ) `  ( B  mod  ( 2 ^ N ) ) )  =  (bits `  ( B  mod  ( 2 ^ N ) ) ) )
5351, 52syl 16 . . . . . . . . . . . . . 14  |-  ( ph  ->  ( (bits  |`  NN0 ) `  ( B  mod  (
2 ^ N ) ) )  =  (bits `  ( B  mod  (
2 ^ N ) ) ) )
54 bitsmod 13653 . . . . . . . . . . . . . . 15  |-  ( ( B  e.  ZZ  /\  N  e.  NN0 )  -> 
(bits `  ( B  mod  ( 2 ^ N
) ) )  =  ( (bits `  B
)  i^i  ( 0..^ N ) ) )
5550, 6, 54syl2anc 661 . . . . . . . . . . . . . 14  |-  ( ph  ->  (bits `  ( B  mod  ( 2 ^ N
) ) )  =  ( (bits `  B
)  i^i  ( 0..^ N ) ) )
5653, 55eqtrd 2475 . . . . . . . . . . . . 13  |-  ( ph  ->  ( (bits  |`  NN0 ) `  ( B  mod  (
2 ^ N ) ) )  =  ( (bits `  B )  i^i  ( 0..^ N ) ) )
57 f1ocnvfv 6006 . . . . . . . . . . . . . 14  |-  ( ( (bits  |`  NN0 ) : NN0
-1-1-onto-> ( ~P NN0  i^i  Fin )  /\  ( B  mod  ( 2 ^ N
) )  e.  NN0 )  ->  ( ( (bits  |`  NN0 ) `  ( B  mod  ( 2 ^ N ) ) )  =  ( (bits `  B )  i^i  (
0..^ N ) )  ->  ( `' (bits  |`  NN0 ) `  (
(bits `  B )  i^i  ( 0..^ N ) ) )  =  ( B  mod  ( 2 ^ N ) ) ) )
5814, 51, 57sylancr 663 . . . . . . . . . . . . 13  |-  ( ph  ->  ( ( (bits  |`  NN0 ) `  ( B  mod  (
2 ^ N ) ) )  =  ( (bits `  B )  i^i  ( 0..^ N ) )  ->  ( `' (bits  |`  NN0 ) `  ( (bits `  B )  i^i  ( 0..^ N ) ) )  =  ( B  mod  ( 2 ^ N ) ) ) )
5956, 58mpd 15 . . . . . . . . . . . 12  |-  ( ph  ->  ( `' (bits  |`  NN0 ) `  ( (bits `  B
)  i^i  ( 0..^ N ) ) )  =  ( B  mod  ( 2 ^ N
) ) )
6049, 59syl5eq 2487 . . . . . . . . . . 11  |-  ( ph  ->  ( K `  (
(bits `  B )  i^i  ( 0..^ N ) ) )  =  ( B  mod  ( 2 ^ N ) ) )
6160oveq2d 6128 . . . . . . . . . 10  |-  ( ph  ->  ( B  -  ( K `  ( (bits `  B )  i^i  (
0..^ N ) ) ) )  =  ( B  -  ( B  mod  ( 2 ^ N ) ) ) )
6261oveq1d 6127 . . . . . . . . 9  |-  ( ph  ->  ( ( B  -  ( K `  ( (bits `  B )  i^i  (
0..^ N ) ) ) )  /  (
2 ^ N ) )  =  ( ( B  -  ( B  mod  ( 2 ^ N ) ) )  /  ( 2 ^ N ) ) )
6350zred 10768 . . . . . . . . . 10  |-  ( ph  ->  B  e.  RR )
64 moddifz 11741 . . . . . . . . . 10  |-  ( ( B  e.  RR  /\  ( 2 ^ N
)  e.  RR+ )  ->  ( ( B  -  ( B  mod  ( 2 ^ N ) ) )  /  ( 2 ^ N ) )  e.  ZZ )
6563, 22, 64syl2anc 661 . . . . . . . . 9  |-  ( ph  ->  ( ( B  -  ( B  mod  ( 2 ^ N ) ) )  /  ( 2 ^ N ) )  e.  ZZ )
6662, 65eqeltrd 2517 . . . . . . . 8  |-  ( ph  ->  ( ( B  -  ( K `  ( (bits `  B )  i^i  (
0..^ N ) ) ) )  /  (
2 ^ N ) )  e.  ZZ )
67 inss1 3591 . . . . . . . . . . . . . 14  |-  ( (bits `  B )  i^i  (
0..^ N ) ) 
C_  (bits `  B
)
68 bitsss 13643 . . . . . . . . . . . . . 14  |-  (bits `  B )  C_  NN0
6967, 68sstri 3386 . . . . . . . . . . . . 13  |-  ( (bits `  B )  i^i  (
0..^ N ) ) 
C_  NN0
70 inss2 3592 . . . . . . . . . . . . . 14  |-  ( (bits `  B )  i^i  (
0..^ N ) ) 
C_  ( 0..^ N )
71 ssfi 7554 . . . . . . . . . . . . . 14  |-  ( ( ( 0..^ N )  e.  Fin  /\  (
(bits `  B )  i^i  ( 0..^ N ) )  C_  ( 0..^ N ) )  -> 
( (bits `  B
)  i^i  ( 0..^ N ) )  e. 
Fin )
7231, 70, 71mp2an 672 . . . . . . . . . . . . 13  |-  ( (bits `  B )  i^i  (
0..^ N ) )  e.  Fin
73 elfpw 7634 . . . . . . . . . . . . 13  |-  ( ( (bits `  B )  i^i  ( 0..^ N ) )  e.  ( ~P
NN0  i^i  Fin )  <->  ( ( (bits `  B
)  i^i  ( 0..^ N ) )  C_  NN0 
/\  ( (bits `  B )  i^i  (
0..^ N ) )  e.  Fin ) )
7469, 72, 73mpbir2an 911 . . . . . . . . . . . 12  |-  ( (bits `  B )  i^i  (
0..^ N ) )  e.  ( ~P NN0  i^i 
Fin )
7541ffvelrni 5863 . . . . . . . . . . . 12  |-  ( ( (bits `  B )  i^i  ( 0..^ N ) )  e.  ( ~P
NN0  i^i  Fin )  ->  ( K `  (
(bits `  B )  i^i  ( 0..^ N ) ) )  e.  NN0 )
7674, 75mp1i 12 . . . . . . . . . . 11  |-  ( ph  ->  ( K `  (
(bits `  B )  i^i  ( 0..^ N ) ) )  e.  NN0 )
7776nn0zd 10766 . . . . . . . . . 10  |-  ( ph  ->  ( K `  (
(bits `  B )  i^i  ( 0..^ N ) ) )  e.  ZZ )
7850, 77zsubcld 10773 . . . . . . . . 9  |-  ( ph  ->  ( B  -  ( K `  ( (bits `  B )  i^i  (
0..^ N ) ) ) )  e.  ZZ )
79 dvdsval2 13559 . . . . . . . . 9  |-  ( ( ( 2 ^ N
)  e.  ZZ  /\  ( 2 ^ N
)  =/=  0  /\  ( B  -  ( K `  ( (bits `  B )  i^i  (
0..^ N ) ) ) )  e.  ZZ )  ->  ( ( 2 ^ N )  ||  ( B  -  ( K `  ( (bits `  B )  i^i  (
0..^ N ) ) ) )  <->  ( ( B  -  ( K `  ( (bits `  B
)  i^i  ( 0..^ N ) ) ) )  /  ( 2 ^ N ) )  e.  ZZ ) )
8026, 27, 78, 79syl3anc 1218 . . . . . . . 8  |-  ( ph  ->  ( ( 2 ^ N )  ||  ( B  -  ( K `  ( (bits `  B
)  i^i  ( 0..^ N ) ) ) )  <->  ( ( B  -  ( K `  ( (bits `  B )  i^i  ( 0..^ N ) ) ) )  / 
( 2 ^ N
) )  e.  ZZ ) )
8166, 80mpbird 232 . . . . . . 7  |-  ( ph  ->  ( 2 ^ N
)  ||  ( B  -  ( K `  ( (bits `  B )  i^i  ( 0..^ N ) ) ) ) )
82 dvds2add 13585 . . . . . . . 8  |-  ( ( ( 2 ^ N
)  e.  ZZ  /\  ( A  -  ( K `  ( (bits `  A )  i^i  (
0..^ N ) ) ) )  e.  ZZ  /\  ( B  -  ( K `  ( (bits `  B )  i^i  (
0..^ N ) ) ) )  e.  ZZ )  ->  ( ( ( 2 ^ N ) 
||  ( A  -  ( K `  ( (bits `  A )  i^i  (
0..^ N ) ) ) )  /\  (
2 ^ N ) 
||  ( B  -  ( K `  ( (bits `  B )  i^i  (
0..^ N ) ) ) ) )  -> 
( 2 ^ N
)  ||  ( ( A  -  ( K `  ( (bits `  A
)  i^i  ( 0..^ N ) ) ) )  +  ( B  -  ( K `  ( (bits `  B )  i^i  ( 0..^ N ) ) ) ) ) ) )
8326, 45, 78, 82syl3anc 1218 . . . . . . 7  |-  ( ph  ->  ( ( ( 2 ^ N )  ||  ( A  -  ( K `  ( (bits `  A )  i^i  (
0..^ N ) ) ) )  /\  (
2 ^ N ) 
||  ( B  -  ( K `  ( (bits `  B )  i^i  (
0..^ N ) ) ) ) )  -> 
( 2 ^ N
)  ||  ( ( A  -  ( K `  ( (bits `  A
)  i^i  ( 0..^ N ) ) ) )  +  ( B  -  ( K `  ( (bits `  B )  i^i  ( 0..^ N ) ) ) ) ) ) )
8448, 81, 83mp2and 679 . . . . . 6  |-  ( ph  ->  ( 2 ^ N
)  ||  ( ( A  -  ( K `  ( (bits `  A
)  i^i  ( 0..^ N ) ) ) )  +  ( B  -  ( K `  ( (bits `  B )  i^i  ( 0..^ N ) ) ) ) ) )
853zcnd 10769 . . . . . . 7  |-  ( ph  ->  A  e.  CC )
8650zcnd 10769 . . . . . . 7  |-  ( ph  ->  B  e.  CC )
8743nn0cnd 10659 . . . . . . 7  |-  ( ph  ->  ( K `  (
(bits `  A )  i^i  ( 0..^ N ) ) )  e.  CC )
8876nn0cnd 10659 . . . . . . 7  |-  ( ph  ->  ( K `  (
(bits `  B )  i^i  ( 0..^ N ) ) )  e.  CC )
8985, 86, 87, 88addsub4d 9787 . . . . . 6  |-  ( ph  ->  ( ( A  +  B )  -  (
( K `  (
(bits `  A )  i^i  ( 0..^ N ) ) )  +  ( K `  ( (bits `  B )  i^i  (
0..^ N ) ) ) ) )  =  ( ( A  -  ( K `  ( (bits `  A )  i^i  (
0..^ N ) ) ) )  +  ( B  -  ( K `
 ( (bits `  B )  i^i  (
0..^ N ) ) ) ) ) )
9084, 89breqtrrd 4339 . . . . 5  |-  ( ph  ->  ( 2 ^ N
)  ||  ( ( A  +  B )  -  ( ( K `
 ( (bits `  A )  i^i  (
0..^ N ) ) )  +  ( K `
 ( (bits `  B )  i^i  (
0..^ N ) ) ) ) ) )
913, 50zaddcld 10772 . . . . . 6  |-  ( ph  ->  ( A  +  B
)  e.  ZZ )
9244, 77zaddcld 10772 . . . . . 6  |-  ( ph  ->  ( ( K `  ( (bits `  A )  i^i  ( 0..^ N ) ) )  +  ( K `  ( (bits `  B )  i^i  (
0..^ N ) ) ) )  e.  ZZ )
93 moddvds 13563 . . . . . 6  |-  ( ( ( 2 ^ N
)  e.  NN  /\  ( A  +  B
)  e.  ZZ  /\  ( ( K `  ( (bits `  A )  i^i  ( 0..^ N ) ) )  +  ( K `  ( (bits `  B )  i^i  (
0..^ N ) ) ) )  e.  ZZ )  ->  ( ( ( A  +  B )  mod  ( 2 ^ N ) )  =  ( ( ( K `
 ( (bits `  A )  i^i  (
0..^ N ) ) )  +  ( K `
 ( (bits `  B )  i^i  (
0..^ N ) ) ) )  mod  (
2 ^ N ) )  <->  ( 2 ^ N )  ||  (
( A  +  B
)  -  ( ( K `  ( (bits `  A )  i^i  (
0..^ N ) ) )  +  ( K `
 ( (bits `  B )  i^i  (
0..^ N ) ) ) ) ) ) )
947, 91, 92, 93syl3anc 1218 . . . . 5  |-  ( ph  ->  ( ( ( A  +  B )  mod  ( 2 ^ N
) )  =  ( ( ( K `  ( (bits `  A )  i^i  ( 0..^ N ) ) )  +  ( K `  ( (bits `  B )  i^i  (
0..^ N ) ) ) )  mod  (
2 ^ N ) )  <->  ( 2 ^ N )  ||  (
( A  +  B
)  -  ( ( K `  ( (bits `  A )  i^i  (
0..^ N ) ) )  +  ( K `
 ( (bits `  B )  i^i  (
0..^ N ) ) ) ) ) ) )
9590, 94mpbird 232 . . . 4  |-  ( ph  ->  ( ( A  +  B )  mod  (
2 ^ N ) )  =  ( ( ( K `  (
(bits `  A )  i^i  ( 0..^ N ) ) )  +  ( K `  ( (bits `  B )  i^i  (
0..^ N ) ) ) )  mod  (
2 ^ N ) ) )
9629a1i 11 . . . . 5  |-  ( ph  ->  (bits `  A )  C_ 
NN0 )
9768a1i 11 . . . . 5  |-  ( ph  ->  (bits `  B )  C_ 
NN0 )
98 sadaddlem.c . . . . 5  |-  C  =  seq 0 ( ( c  e.  2o ,  m  e.  NN0  |->  if (cadd ( m  e.  (bits `  A ) ,  m  e.  (bits `  B ) ,  (/)  e.  c ) ,  1o ,  (/) ) ) ,  ( n  e.  NN0  |->  if ( n  =  0 ,  (/) ,  ( n  - 
1 ) ) ) )
9996, 97, 98, 6, 1sadadd3 13678 . . . 4  |-  ( ph  ->  ( ( K `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) )  mod  ( 2 ^ N ) )  =  ( ( ( K `  ( (bits `  A )  i^i  (
0..^ N ) ) )  +  ( K `
 ( (bits `  B )  i^i  (
0..^ N ) ) ) )  mod  (
2 ^ N ) ) )
100 inss1 3591 . . . . . . . . 9  |-  ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) )  C_  (
(bits `  A ) sadd  (bits `  B ) )
101 sadcl 13679 . . . . . . . . . 10  |-  ( ( (bits `  A )  C_ 
NN0  /\  (bits `  B
)  C_  NN0 )  -> 
( (bits `  A
) sadd  (bits `  B )
)  C_  NN0 )
10229, 68, 101mp2an 672 . . . . . . . . 9  |-  ( (bits `  A ) sadd  (bits `  B ) )  C_  NN0
103100, 102sstri 3386 . . . . . . . 8  |-  ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) )  C_  NN0
104 inss2 3592 . . . . . . . . 9  |-  ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) )  C_  (
0..^ N )
105 ssfi 7554 . . . . . . . . 9  |-  ( ( ( 0..^ N )  e.  Fin  /\  (
( (bits `  A
) sadd  (bits `  B )
)  i^i  ( 0..^ N ) )  C_  ( 0..^ N ) )  ->  ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) )  e.  Fin )
10631, 104, 105mp2an 672 . . . . . . . 8  |-  ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) )  e.  Fin
107 elfpw 7634 . . . . . . . 8  |-  ( ( ( (bits `  A
) sadd  (bits `  B )
)  i^i  ( 0..^ N ) )  e.  ( ~P NN0  i^i  Fin )  <->  ( ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) )  C_  NN0  /\  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) )  e.  Fin ) )
108103, 106, 107mpbir2an 911 . . . . . . 7  |-  ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) )  e.  ( ~P NN0  i^i  Fin )
10941ffvelrni 5863 . . . . . . 7  |-  ( ( ( (bits `  A
) sadd  (bits `  B )
)  i^i  ( 0..^ N ) )  e.  ( ~P NN0  i^i  Fin )  ->  ( K `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) )  e.  NN0 )
110108, 109mp1i 12 . . . . . 6  |-  ( ph  ->  ( K `  (
( (bits `  A
) sadd  (bits `  B )
)  i^i  ( 0..^ N ) ) )  e.  NN0 )
111110nn0red 10658 . . . . 5  |-  ( ph  ->  ( K `  (
( (bits `  A
) sadd  (bits `  B )
)  i^i  ( 0..^ N ) ) )  e.  RR )
112110nn0ge0d 10660 . . . . 5  |-  ( ph  ->  0  <_  ( K `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) ) )
1131fveq1i 5713 . . . . . . . . . 10  |-  ( K `
 ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) ) )  =  ( `' (bits  |`  NN0 ) `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) )
114113fveq2i 5715 . . . . . . . . 9  |-  ( (bits  |`  NN0 ) `  ( K `  ( (
(bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) ) ) )  =  ( (bits  |`  NN0 ) `  ( `' (bits  |`  NN0 ) `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) ) )
115 fvres 5725 . . . . . . . . . 10  |-  ( ( K `  ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) ) )  e. 
NN0  ->  ( (bits  |`  NN0 ) `  ( K `  (
( (bits `  A
) sadd  (bits `  B )
)  i^i  ( 0..^ N ) ) ) )  =  (bits `  ( K `  ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) ) ) ) )
116110, 115syl 16 . . . . . . . . 9  |-  ( ph  ->  ( (bits  |`  NN0 ) `  ( K `  (
( (bits `  A
) sadd  (bits `  B )
)  i^i  ( 0..^ N ) ) ) )  =  (bits `  ( K `  ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) ) ) ) )
117108a1i 11 . . . . . . . . . 10  |-  ( ph  ->  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) )  e.  ( ~P NN0  i^i 
Fin ) )
118 f1ocnvfv2 6005 . . . . . . . . . 10  |-  ( ( (bits  |`  NN0 ) : NN0
-1-1-onto-> ( ~P NN0  i^i  Fin )  /\  ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) )  e.  ( ~P
NN0  i^i  Fin )
)  ->  ( (bits  |` 
NN0 ) `  ( `' (bits  |`  NN0 ) `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) ) )  =  ( ( (bits `  A
) sadd  (bits `  B )
)  i^i  ( 0..^ N ) ) )
11914, 117, 118sylancr 663 . . . . . . . . 9  |-  ( ph  ->  ( (bits  |`  NN0 ) `  ( `' (bits  |`  NN0 ) `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) ) )  =  ( ( (bits `  A
) sadd  (bits `  B )
)  i^i  ( 0..^ N ) ) )
120114, 116, 1193eqtr3a 2499 . . . . . . . 8  |-  ( ph  ->  (bits `  ( K `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) ) )  =  ( ( (bits `  A
) sadd  (bits `  B )
)  i^i  ( 0..^ N ) ) )
121120, 104syl6eqss 3427 . . . . . . 7  |-  ( ph  ->  (bits `  ( K `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) ) )  C_  (
0..^ N ) )
122110nn0zd 10766 . . . . . . . 8  |-  ( ph  ->  ( K `  (
( (bits `  A
) sadd  (bits `  B )
)  i^i  ( 0..^ N ) ) )  e.  ZZ )
123 bitsfzo 13652 . . . . . . . 8  |-  ( ( ( K `  (
( (bits `  A
) sadd  (bits `  B )
)  i^i  ( 0..^ N ) ) )  e.  ZZ  /\  N  e.  NN0 )  ->  (
( K `  (
( (bits `  A
) sadd  (bits `  B )
)  i^i  ( 0..^ N ) ) )  e.  ( 0..^ ( 2 ^ N ) )  <->  (bits `  ( K `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) ) )  C_  (
0..^ N ) ) )
124122, 6, 123syl2anc 661 . . . . . . 7  |-  ( ph  ->  ( ( K `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) )  e.  ( 0..^ ( 2 ^ N
) )  <->  (bits `  ( K `  ( (
(bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) ) ) ) 
C_  ( 0..^ N ) ) )
125121, 124mpbird 232 . . . . . 6  |-  ( ph  ->  ( K `  (
( (bits `  A
) sadd  (bits `  B )
)  i^i  ( 0..^ N ) ) )  e.  ( 0..^ ( 2 ^ N ) ) )
126 elfzolt2 11582 . . . . . 6  |-  ( ( K `  ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) ) )  e.  ( 0..^ ( 2 ^ N ) )  ->  ( K `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) )  <  ( 2 ^ N ) )
127125, 126syl 16 . . . . 5  |-  ( ph  ->  ( K `  (
( (bits `  A
) sadd  (bits `  B )
)  i^i  ( 0..^ N ) ) )  <  ( 2 ^ N ) )
128 modid 11753 . . . . 5  |-  ( ( ( ( K `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) )  e.  RR  /\  ( 2 ^ N
)  e.  RR+ )  /\  ( 0  <_  ( K `  ( (
(bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) ) )  /\  ( K `  ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) ) )  < 
( 2 ^ N
) ) )  -> 
( ( K `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) )  mod  ( 2 ^ N ) )  =  ( K `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) ) )
129111, 22, 112, 127, 128syl22anc 1219 . . . 4  |-  ( ph  ->  ( ( K `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) )  mod  ( 2 ^ N ) )  =  ( K `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) ) )
13095, 99, 1293eqtr2d 2481 . . 3  |-  ( ph  ->  ( ( A  +  B )  mod  (
2 ^ N ) )  =  ( K `
 ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) ) ) )
131130fveq2d 5716 . 2  |-  ( ph  ->  (bits `  ( ( A  +  B )  mod  ( 2 ^ N
) ) )  =  (bits `  ( K `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) ) ) )
132131, 120eqtr2d 2476 1  |-  ( ph  ->  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) )  =  (bits `  (
( A  +  B
)  mod  ( 2 ^ N ) ) ) )
Colors of variables: wff setvar class
Syntax hints:    -> wi 4    <-> wb 184    /\ wa 369    = wceq 1369  caddwcad 1420    e. wcel 1756    =/= wne 2620    i^i cin 3348    C_ wss 3349   (/)c0 3658   ifcif 3812   ~Pcpw 3881   class class class wbr 4313    e. cmpt 4371   `'ccnv 4860    |` cres 4863   -->wf 5435   -1-1-onto->wf1o 5438   ` cfv 5439  (class class class)co 6112    e. cmpt2 6114   1oc1o 6934   2oc2o 6935   Fincfn 7331   RRcr 9302   0cc0 9303   1c1 9304    + caddc 9306    < clt 9439    <_ cle 9440    - cmin 9616    / cdiv 10014   NNcn 10343   2c2 10392   NN0cn0 10600   ZZcz 10667   RR+crp 11012  ..^cfzo 11569    mod cmo 11729    seqcseq 11827   ^cexp 11886    || cdivides 13556  bitscbits 13636   sadd csad 13637
This theorem was proved from axioms:  ax-mp 5  ax-1 6  ax-2 7  ax-3 8  ax-gen 1591  ax-4 1602  ax-5 1670  ax-6 1708  ax-7 1728  ax-8 1758  ax-9 1760  ax-10 1775  ax-11 1780  ax-12 1792  ax-13 1943  ax-ext 2423  ax-rep 4424  ax-sep 4434  ax-nul 4442  ax-pow 4491  ax-pr 4552  ax-un 6393  ax-inf2 7868  ax-cnex 9359  ax-resscn 9360  ax-1cn 9361  ax-icn 9362  ax-addcl 9363  ax-addrcl 9364  ax-mulcl 9365  ax-mulrcl 9366  ax-mulcom 9367  ax-addass 9368  ax-mulass 9369  ax-distr 9370  ax-i2m1 9371  ax-1ne0 9372  ax-1rid 9373  ax-rnegex 9374  ax-rrecex 9375  ax-cnre 9376  ax-pre-lttri 9377  ax-pre-lttrn 9378  ax-pre-ltadd 9379  ax-pre-mulgt0 9380  ax-pre-sup 9381
This theorem depends on definitions:  df-bi 185  df-or 370  df-an 371  df-3or 966  df-3an 967  df-xor 1351  df-tru 1372  df-fal 1375  df-had 1421  df-cad 1422  df-ex 1587  df-nf 1590  df-sb 1701  df-eu 2257  df-mo 2258  df-clab 2430  df-cleq 2436  df-clel 2439  df-nfc 2577  df-ne 2622  df-nel 2623  df-ral 2741  df-rex 2742  df-reu 2743  df-rmo 2744  df-rab 2745  df-v 2995  df-sbc 3208  df-csb 3310  df-dif 3352  df-un 3354  df-in 3356  df-ss 3363  df-pss 3365  df-nul 3659  df-if 3813  df-pw 3883  df-sn 3899  df-pr 3901  df-tp 3903  df-op 3905  df-uni 4113  df-int 4150  df-iun 4194  df-disj 4284  df-br 4314  df-opab 4372  df-mpt 4373  df-tr 4407  df-eprel 4653  df-id 4657  df-po 4662  df-so 4663  df-fr 4700  df-se 4701  df-we 4702  df-ord 4743  df-on 4744  df-lim 4745  df-suc 4746  df-xp 4867  df-rel 4868  df-cnv 4869  df-co 4870  df-dm 4871  df-rn 4872  df-res 4873  df-ima 4874  df-iota 5402  df-fun 5441  df-fn 5442  df-f 5443  df-f1 5444  df-fo 5445  df-f1o 5446  df-fv 5447  df-isom 5448  df-riota 6073  df-ov 6115  df-oprab 6116  df-mpt2 6117  df-om 6498  df-1st 6598  df-2nd 6599  df-recs 6853  df-rdg 6887  df-1o 6941  df-2o 6942  df-oadd 6945  df-er 7122  df-map 7237  df-pm 7238  df-en 7332  df-dom 7333  df-sdom 7334  df-fin 7335  df-sup 7712  df-oi 7745  df-card 8130  df-cda 8358  df-pnf 9441  df-mnf 9442  df-xr 9443  df-ltxr 9444  df-le 9445  df-sub 9618  df-neg 9619  df-div 10015  df-nn 10344  df-2 10401  df-3 10402  df-n0 10601  df-z 10668  df-uz 10883  df-rp 11013  df-fz 11459  df-fzo 11570  df-fl 11663  df-mod 11730  df-seq 11828  df-exp 11887  df-hash 12125  df-cj 12609  df-re 12610  df-im 12611  df-sqr 12745  df-abs 12746  df-clim 12987  df-sum 13185  df-dvds 13557  df-bits 13639  df-sad 13668
This theorem is referenced by:  sadadd  13684
  Copyright terms: Public domain W3C validator