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

Theorem sadaddlem 12657
Description: Lemma for sadadd 12658. (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 5526 . . . . . . . . . . . 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 9877 . . . . . . . . . . . . . . . . . 18  |-  2  e.  NN
54a1i 10 . . . . . . . . . . . . . . . . 17  |-  ( ph  ->  2  e.  NN )
6 sadaddlem.3 . . . . . . . . . . . . . . . . 17  |-  ( ph  ->  N  e.  NN0 )
75, 6nnexpcld 11266 . . . . . . . . . . . . . . . 16  |-  ( ph  ->  ( 2 ^ N
)  e.  NN )
83, 7zmodcld 10990 . . . . . . . . . . . . . . 15  |-  ( ph  ->  ( A  mod  (
2 ^ N ) )  e.  NN0 )
9 fvres 5542 . . . . . . . . . . . . . . 15  |-  ( ( A  mod  ( 2 ^ N ) )  e.  NN0  ->  ( (bits  |`  NN0 ) `  ( A  mod  ( 2 ^ N ) ) )  =  (bits `  ( A  mod  ( 2 ^ N ) ) ) )
108, 9syl 15 . . . . . . . . . . . . . 14  |-  ( ph  ->  ( (bits  |`  NN0 ) `  ( A  mod  (
2 ^ N ) ) )  =  (bits `  ( A  mod  (
2 ^ N ) ) ) )
11 bitsmod 12627 . . . . . . . . . . . . . . 15  |-  ( ( A  e.  ZZ  /\  N  e.  NN0 )  -> 
(bits `  ( A  mod  ( 2 ^ N
) ) )  =  ( (bits `  A
)  i^i  ( 0..^ N ) ) )
123, 6, 11syl2anc 642 . . . . . . . . . . . . . 14  |-  ( ph  ->  (bits `  ( A  mod  ( 2 ^ N
) ) )  =  ( (bits `  A
)  i^i  ( 0..^ N ) ) )
1310, 12eqtrd 2315 . . . . . . . . . . . . 13  |-  ( ph  ->  ( (bits  |`  NN0 ) `  ( A  mod  (
2 ^ N ) ) )  =  ( (bits `  A )  i^i  ( 0..^ N ) ) )
14 bitsf1o 12636 . . . . . . . . . . . . . 14  |-  (bits  |`  NN0 ) : NN0
-1-1-onto-> ( ~P NN0  i^i  Fin )
15 f1ocnvfv 5794 . . . . . . . . . . . . . 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 644 . . . . . . . . . . . . 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 14 . . . . . . . . . . . 12  |-  ( ph  ->  ( `' (bits  |`  NN0 ) `  ( (bits `  A
)  i^i  ( 0..^ N ) ) )  =  ( A  mod  ( 2 ^ N
) ) )
182, 17syl5eq 2327 . . . . . . . . . . 11  |-  ( ph  ->  ( K `  (
(bits `  A )  i^i  ( 0..^ N ) ) )  =  ( A  mod  ( 2 ^ N ) ) )
1918oveq2d 5874 . . . . . . . . . 10  |-  ( ph  ->  ( A  -  ( K `  ( (bits `  A )  i^i  (
0..^ N ) ) ) )  =  ( A  -  ( A  mod  ( 2 ^ N ) ) ) )
2019oveq1d 5873 . . . . . . . . 9  |-  ( ph  ->  ( ( A  -  ( K `  ( (bits `  A )  i^i  (
0..^ N ) ) ) )  /  (
2 ^ N ) )  =  ( ( A  -  ( A  mod  ( 2 ^ N ) ) )  /  ( 2 ^ N ) ) )
213zred 10117 . . . . . . . . . 10  |-  ( ph  ->  A  e.  RR )
227nnrpd 10389 . . . . . . . . . 10  |-  ( ph  ->  ( 2 ^ N
)  e.  RR+ )
23 moddifz 10983 . . . . . . . . . 10  |-  ( ( A  e.  RR  /\  ( 2 ^ N
)  e.  RR+ )  ->  ( ( A  -  ( A  mod  ( 2 ^ N ) ) )  /  ( 2 ^ N ) )  e.  ZZ )
2421, 22, 23syl2anc 642 . . . . . . . . 9  |-  ( ph  ->  ( ( A  -  ( A  mod  ( 2 ^ N ) ) )  /  ( 2 ^ N ) )  e.  ZZ )
2520, 24eqeltrd 2357 . . . . . . . 8  |-  ( ph  ->  ( ( A  -  ( K `  ( (bits `  A )  i^i  (
0..^ N ) ) ) )  /  (
2 ^ N ) )  e.  ZZ )
267nnzd 10116 . . . . . . . . 9  |-  ( ph  ->  ( 2 ^ N
)  e.  ZZ )
277nnne0d 9790 . . . . . . . . 9  |-  ( ph  ->  ( 2 ^ N
)  =/=  0 )
28 inss1 3389 . . . . . . . . . . . . . 14  |-  ( (bits `  A )  i^i  (
0..^ N ) ) 
C_  (bits `  A
)
29 bitsss 12617 . . . . . . . . . . . . . 14  |-  (bits `  A )  C_  NN0
3028, 29sstri 3188 . . . . . . . . . . . . 13  |-  ( (bits `  A )  i^i  (
0..^ N ) ) 
C_  NN0
31 fzofi 11036 . . . . . . . . . . . . . 14  |-  ( 0..^ N )  e.  Fin
32 inss2 3390 . . . . . . . . . . . . . 14  |-  ( (bits `  A )  i^i  (
0..^ N ) ) 
C_  ( 0..^ N )
33 ssfi 7083 . . . . . . . . . . . . . 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 653 . . . . . . . . . . . . 13  |-  ( (bits `  A )  i^i  (
0..^ N ) )  e.  Fin
35 elfpw 7157 . . . . . . . . . . . . 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 886 . . . . . . . . . . . 12  |-  ( (bits `  A )  i^i  (
0..^ N ) )  e.  ( ~P NN0  i^i 
Fin )
37 f1ocnv 5485 . . . . . . . . . . . . . . 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 5472 . . . . . . . . . . . . . . 15  |-  ( `' (bits  |`  NN0 ) : ( ~P NN0  i^i  Fin ) -1-1-onto-> NN0  ->  `' (bits  |` 
NN0 ) : ( ~P NN0  i^i  Fin )
--> NN0 )
3914, 37, 38mp2b 9 . . . . . . . . . . . . . 14  |-  `' (bits  |`  NN0 ) : ( ~P NN0  i^i  Fin )
--> NN0
401feq1i 5383 . . . . . . . . . . . . . 14  |-  ( K : ( ~P NN0  i^i 
Fin ) --> NN0  <->  `' (bits  |` 
NN0 ) : ( ~P NN0  i^i  Fin )
--> NN0 )
4139, 40mpbir 200 . . . . . . . . . . . . 13  |-  K :
( ~P NN0  i^i  Fin ) --> NN0
4241ffvelrni 5664 . . . . . . . . . . . 12  |-  ( ( (bits `  A )  i^i  ( 0..^ N ) )  e.  ( ~P
NN0  i^i  Fin )  ->  ( K `  (
(bits `  A )  i^i  ( 0..^ N ) ) )  e.  NN0 )
4336, 42mp1i 11 . . . . . . . . . . 11  |-  ( ph  ->  ( K `  (
(bits `  A )  i^i  ( 0..^ N ) ) )  e.  NN0 )
4443nn0zd 10115 . . . . . . . . . 10  |-  ( ph  ->  ( K `  (
(bits `  A )  i^i  ( 0..^ N ) ) )  e.  ZZ )
453, 44zsubcld 10122 . . . . . . . . 9  |-  ( ph  ->  ( A  -  ( K `  ( (bits `  A )  i^i  (
0..^ N ) ) ) )  e.  ZZ )
46 dvdsval2 12534 . . . . . . . . 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 1182 . . . . . . . 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 223 . . . . . . 7  |-  ( ph  ->  ( 2 ^ N
)  ||  ( A  -  ( K `  ( (bits `  A )  i^i  ( 0..^ N ) ) ) ) )
491fveq1i 5526 . . . . . . . . . . . 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 10990 . . . . . . . . . . . . . . 15  |-  ( ph  ->  ( B  mod  (
2 ^ N ) )  e.  NN0 )
52 fvres 5542 . . . . . . . . . . . . . . 15  |-  ( ( B  mod  ( 2 ^ N ) )  e.  NN0  ->  ( (bits  |`  NN0 ) `  ( B  mod  ( 2 ^ N ) ) )  =  (bits `  ( B  mod  ( 2 ^ N ) ) ) )
5351, 52syl 15 . . . . . . . . . . . . . 14  |-  ( ph  ->  ( (bits  |`  NN0 ) `  ( B  mod  (
2 ^ N ) ) )  =  (bits `  ( B  mod  (
2 ^ N ) ) ) )
54 bitsmod 12627 . . . . . . . . . . . . . . 15  |-  ( ( B  e.  ZZ  /\  N  e.  NN0 )  -> 
(bits `  ( B  mod  ( 2 ^ N
) ) )  =  ( (bits `  B
)  i^i  ( 0..^ N ) ) )
5550, 6, 54syl2anc 642 . . . . . . . . . . . . . 14  |-  ( ph  ->  (bits `  ( B  mod  ( 2 ^ N
) ) )  =  ( (bits `  B
)  i^i  ( 0..^ N ) ) )
5653, 55eqtrd 2315 . . . . . . . . . . . . 13  |-  ( ph  ->  ( (bits  |`  NN0 ) `  ( B  mod  (
2 ^ N ) ) )  =  ( (bits `  B )  i^i  ( 0..^ N ) ) )
57 f1ocnvfv 5794 . . . . . . . . . . . . . 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 644 . . . . . . . . . . . . 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 14 . . . . . . . . . . . 12  |-  ( ph  ->  ( `' (bits  |`  NN0 ) `  ( (bits `  B
)  i^i  ( 0..^ N ) ) )  =  ( B  mod  ( 2 ^ N
) ) )
6049, 59syl5eq 2327 . . . . . . . . . . 11  |-  ( ph  ->  ( K `  (
(bits `  B )  i^i  ( 0..^ N ) ) )  =  ( B  mod  ( 2 ^ N ) ) )
6160oveq2d 5874 . . . . . . . . . 10  |-  ( ph  ->  ( B  -  ( K `  ( (bits `  B )  i^i  (
0..^ N ) ) ) )  =  ( B  -  ( B  mod  ( 2 ^ N ) ) ) )
6261oveq1d 5873 . . . . . . . . 9  |-  ( ph  ->  ( ( B  -  ( K `  ( (bits `  B )  i^i  (
0..^ N ) ) ) )  /  (
2 ^ N ) )  =  ( ( B  -  ( B  mod  ( 2 ^ N ) ) )  /  ( 2 ^ N ) ) )
6350zred 10117 . . . . . . . . . 10  |-  ( ph  ->  B  e.  RR )
64 moddifz 10983 . . . . . . . . . 10  |-  ( ( B  e.  RR  /\  ( 2 ^ N
)  e.  RR+ )  ->  ( ( B  -  ( B  mod  ( 2 ^ N ) ) )  /  ( 2 ^ N ) )  e.  ZZ )
6563, 22, 64syl2anc 642 . . . . . . . . 9  |-  ( ph  ->  ( ( B  -  ( B  mod  ( 2 ^ N ) ) )  /  ( 2 ^ N ) )  e.  ZZ )
6662, 65eqeltrd 2357 . . . . . . . 8  |-  ( ph  ->  ( ( B  -  ( K `  ( (bits `  B )  i^i  (
0..^ N ) ) ) )  /  (
2 ^ N ) )  e.  ZZ )
67 inss1 3389 . . . . . . . . . . . . . 14  |-  ( (bits `  B )  i^i  (
0..^ N ) ) 
C_  (bits `  B
)
68 bitsss 12617 . . . . . . . . . . . . . 14  |-  (bits `  B )  C_  NN0
6967, 68sstri 3188 . . . . . . . . . . . . 13  |-  ( (bits `  B )  i^i  (
0..^ N ) ) 
C_  NN0
70 inss2 3390 . . . . . . . . . . . . . 14  |-  ( (bits `  B )  i^i  (
0..^ N ) ) 
C_  ( 0..^ N )
71 ssfi 7083 . . . . . . . . . . . . . 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 653 . . . . . . . . . . . . 13  |-  ( (bits `  B )  i^i  (
0..^ N ) )  e.  Fin
73 elfpw 7157 . . . . . . . . . . . . 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 886 . . . . . . . . . . . 12  |-  ( (bits `  B )  i^i  (
0..^ N ) )  e.  ( ~P NN0  i^i 
Fin )
7541ffvelrni 5664 . . . . . . . . . . . 12  |-  ( ( (bits `  B )  i^i  ( 0..^ N ) )  e.  ( ~P
NN0  i^i  Fin )  ->  ( K `  (
(bits `  B )  i^i  ( 0..^ N ) ) )  e.  NN0 )
7674, 75mp1i 11 . . . . . . . . . . 11  |-  ( ph  ->  ( K `  (
(bits `  B )  i^i  ( 0..^ N ) ) )  e.  NN0 )
7776nn0zd 10115 . . . . . . . . . 10  |-  ( ph  ->  ( K `  (
(bits `  B )  i^i  ( 0..^ N ) ) )  e.  ZZ )
7850, 77zsubcld 10122 . . . . . . . . 9  |-  ( ph  ->  ( B  -  ( K `  ( (bits `  B )  i^i  (
0..^ N ) ) ) )  e.  ZZ )
79 dvdsval2 12534 . . . . . . . . 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 1182 . . . . . . . 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 223 . . . . . . 7  |-  ( ph  ->  ( 2 ^ N
)  ||  ( B  -  ( K `  ( (bits `  B )  i^i  ( 0..^ N ) ) ) ) )
82 dvds2add 12560 . . . . . . . 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 1182 . . . . . . 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 660 . . . . . 6  |-  ( ph  ->  ( 2 ^ N
)  ||  ( ( A  -  ( K `  ( (bits `  A
)  i^i  ( 0..^ N ) ) ) )  +  ( B  -  ( K `  ( (bits `  B )  i^i  ( 0..^ N ) ) ) ) ) )
853zcnd 10118 . . . . . . 7  |-  ( ph  ->  A  e.  CC )
8650zcnd 10118 . . . . . . 7  |-  ( ph  ->  B  e.  CC )
8743nn0cnd 10020 . . . . . . 7  |-  ( ph  ->  ( K `  (
(bits `  A )  i^i  ( 0..^ N ) ) )  e.  CC )
8876nn0cnd 10020 . . . . . . 7  |-  ( ph  ->  ( K `  (
(bits `  B )  i^i  ( 0..^ N ) ) )  e.  CC )
8985, 86, 87, 88addsub4d 9204 . . . . . 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 4049 . . . . 5  |-  ( ph  ->  ( 2 ^ N
)  ||  ( ( A  +  B )  -  ( ( K `
 ( (bits `  A )  i^i  (
0..^ N ) ) )  +  ( K `
 ( (bits `  B )  i^i  (
0..^ N ) ) ) ) ) )
913, 50zaddcld 10121 . . . . . 6  |-  ( ph  ->  ( A  +  B
)  e.  ZZ )
9244, 77zaddcld 10121 . . . . . 6  |-  ( ph  ->  ( ( K `  ( (bits `  A )  i^i  ( 0..^ N ) ) )  +  ( K `  ( (bits `  B )  i^i  (
0..^ N ) ) ) )  e.  ZZ )
93 moddvds 12538 . . . . . 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 1182 . . . . 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 223 . . . 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 10 . . . . 5  |-  ( ph  ->  (bits `  A )  C_ 
NN0 )
9768a1i 10 . . . . 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 12652 . . . 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 3389 . . . . . . . . . 10  |-  ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) )  C_  (
(bits `  A ) sadd  (bits `  B ) )
101 sadcl 12653 . . . . . . . . . . 11  |-  ( ( (bits `  A )  C_ 
NN0  /\  (bits `  B
)  C_  NN0 )  -> 
( (bits `  A
) sadd  (bits `  B )
)  C_  NN0 )
10229, 68, 101mp2an 653 . . . . . . . . . 10  |-  ( (bits `  A ) sadd  (bits `  B ) )  C_  NN0
103100, 102sstri 3188 . . . . . . . . 9  |-  ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) )  C_  NN0
104 inss2 3390 . . . . . . . . . 10  |-  ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) )  C_  (
0..^ N )
105 ssfi 7083 . . . . . . . . . 10  |-  ( ( ( 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 653 . . . . . . . . 9  |-  ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) )  e.  Fin
107 elfpw 7157 . . . . . . . . 9  |-  ( ( ( (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 886 . . . . . . . 8  |-  ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) )  e.  ( ~P NN0  i^i  Fin )
109108a1i 10 . . . . . . 7  |-  ( ph  ->  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) )  e.  ( ~P NN0  i^i 
Fin ) )
11041ffvelrni 5664 . . . . . . 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 )
111109, 110syl 15 . . . . . 6  |-  ( ph  ->  ( K `  (
( (bits `  A
) sadd  (bits `  B )
)  i^i  ( 0..^ N ) ) )  e.  NN0 )
112111nn0red 10019 . . . . 5  |-  ( ph  ->  ( K `  (
( (bits `  A
) sadd  (bits `  B )
)  i^i  ( 0..^ N ) ) )  e.  RR )
113111nn0ge0d 10021 . . . . 5  |-  ( ph  ->  0  <_  ( K `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) ) )
114 fvres 5542 . . . . . . . . . 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 ) ) ) ) )
115111, 114syl 15 . . . . . . . . 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 ) ) ) ) )
1161fveq1i 5526 . . . . . . . . . . 11  |-  ( K `
 ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) ) )  =  ( `' (bits  |`  NN0 ) `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) )
117116fveq2i 5528 . . . . . . . . . 10  |-  ( (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 ) ) ) )
118 f1ocnvfv2 5793 . . . . . . . . . . 11  |-  ( ( (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, 109, 118sylancr 644 . . . . . . . . . 10  |-  ( ph  ->  ( (bits  |`  NN0 ) `  ( `' (bits  |`  NN0 ) `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) ) )  =  ( ( (bits `  A
) sadd  (bits `  B )
)  i^i  ( 0..^ N ) ) )
120117, 119syl5eq 2327 . . . . . . . . 9  |-  ( ph  ->  ( (bits  |`  NN0 ) `  ( K `  (
( (bits `  A
) sadd  (bits `  B )
)  i^i  ( 0..^ N ) ) ) )  =  ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) ) )
121115, 120eqtr3d 2317 . . . . . . . 8  |-  ( ph  ->  (bits `  ( K `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) ) )  =  ( ( (bits `  A
) sadd  (bits `  B )
)  i^i  ( 0..^ N ) ) )
122104a1i 10 . . . . . . . 8  |-  ( ph  ->  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) 
C_  ( 0..^ N ) )
123121, 122eqsstrd 3212 . . . . . . 7  |-  ( ph  ->  (bits `  ( K `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) ) )  C_  (
0..^ N ) )
124111nn0zd 10115 . . . . . . . 8  |-  ( ph  ->  ( K `  (
( (bits `  A
) sadd  (bits `  B )
)  i^i  ( 0..^ N ) ) )  e.  ZZ )
125 bitsfzo 12626 . . . . . . . 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 ) ) )
126124, 6, 125syl2anc 642 . . . . . . 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 ) ) )
127123, 126mpbird 223 . . . . . 6  |-  ( ph  ->  ( K `  (
( (bits `  A
) sadd  (bits `  B )
)  i^i  ( 0..^ N ) ) )  e.  ( 0..^ ( 2 ^ N ) ) )
128 elfzolt2 10883 . . . . . 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 ) )
129127, 128syl 15 . . . . 5  |-  ( ph  ->  ( K `  (
( (bits `  A
) sadd  (bits `  B )
)  i^i  ( 0..^ N ) ) )  <  ( 2 ^ N ) )
130 modid 10993 . . . . 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 ) ) ) )
131112, 22, 113, 129, 130syl22anc 1183 . . . 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 ) ) ) )
13295, 99, 1313eqtr2d 2321 . . 3  |-  ( ph  ->  ( ( A  +  B )  mod  (
2 ^ N ) )  =  ( K `
 ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) ) ) )
133132fveq2d 5529 . 2  |-  ( ph  ->  (bits `  ( ( A  +  B )  mod  ( 2 ^ N
) ) )  =  (bits `  ( K `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) ) ) )
134133, 121eqtr2d 2316 1  |-  ( ph  ->  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) )  =  (bits `  (
( A  +  B
)  mod  ( 2 ^ N ) ) ) )
Colors of variables: wff set class
Syntax hints:    -> wi 4    <-> wb 176    /\ wa 358  caddwcad 1369    = wceq 1623    e. wcel 1684    =/= wne 2446    i^i cin 3151    C_ wss 3152   (/)c0 3455   ifcif 3565   ~Pcpw 3625   class class class wbr 4023    e. cmpt 4077   `'ccnv 4688    |` cres 4691   -->wf 5251   -1-1-onto->wf1o 5254   ` cfv 5255  (class class class)co 5858    e. cmpt2 5860   1oc1o 6472   2oc2o 6473   Fincfn 6863   RRcr 8736   0cc0 8737   1c1 8738    + caddc 8740    < clt 8867    <_ cle 8868    - cmin 9037    / cdiv 9423   NNcn 9746   2c2 9795   NN0cn0 9965   ZZcz 10024   RR+crp 10354  ..^cfzo 10870    mod cmo 10973    seq cseq 11046   ^cexp 11104    || cdivides 12531  bitscbits 12610   sadd csad 12611
This theorem is referenced by:  sadadd  12658
This theorem was proved from axioms:  ax-1 5  ax-2 6  ax-3 7  ax-mp 8  ax-gen 1533  ax-5 1544  ax-17 1603  ax-9 1635  ax-8 1643  ax-13 1686  ax-14 1688  ax-6 1703  ax-7 1708  ax-11 1715  ax-12 1866  ax-ext 2264  ax-rep 4131  ax-sep 4141  ax-nul 4149  ax-pow 4188  ax-pr 4214  ax-un 4512  ax-inf2 7342  ax-cnex 8793  ax-resscn 8794  ax-1cn 8795  ax-icn 8796  ax-addcl 8797  ax-addrcl 8798  ax-mulcl 8799  ax-mulrcl 8800  ax-mulcom 8801  ax-addass 8802  ax-mulass 8803  ax-distr 8804  ax-i2m1 8805  ax-1ne0 8806  ax-1rid 8807  ax-rnegex 8808  ax-rrecex 8809  ax-cnre 8810  ax-pre-lttri 8811  ax-pre-lttrn 8812  ax-pre-ltadd 8813  ax-pre-mulgt0 8814  ax-pre-sup 8815
This theorem depends on definitions:  df-bi 177  df-or 359  df-an 360  df-3or 935  df-3an 936  df-xor 1296  df-tru 1310  df-had 1370  df-cad 1371  df-ex 1529  df-nf 1532  df-sb 1630  df-eu 2147  df-mo 2148  df-clab 2270  df-cleq 2276  df-clel 2279  df-nfc 2408  df-ne 2448  df-nel 2449  df-ral 2548  df-rex 2549  df-reu 2550  df-rmo 2551  df-rab 2552  df-v 2790  df-sbc 2992  df-csb 3082  df-dif 3155  df-un 3157  df-in 3159  df-ss 3166  df-pss 3168  df-nul 3456  df-if 3566  df-pw 3627  df-sn 3646  df-pr 3647  df-tp 3648  df-op 3649  df-uni 3828  df-int 3863  df-iun 3907  df-disj 3994  df-br 4024  df-opab 4078  df-mpt 4079  df-tr 4114  df-eprel 4305  df-id 4309  df-po 4314  df-so 4315  df-fr 4352  df-se 4353  df-we 4354  df-ord 4395  df-on 4396  df-lim 4397  df-suc 4398  df-om 4657  df-xp 4695  df-rel 4696  df-cnv 4697  df-co 4698  df-dm 4699  df-rn 4700  df-res 4701  df-ima 4702  df-iota 5219  df-fun 5257  df-fn 5258  df-f 5259  df-f1 5260  df-fo 5261  df-f1o 5262  df-fv 5263  df-isom 5264  df-ov 5861  df-oprab 5862  df-mpt2 5863  df-1st 6122  df-2nd 6123  df-riota 6304  df-recs 6388  df-rdg 6423  df-1o 6479  df-2o 6480  df-oadd 6483  df-er 6660  df-map 6774  df-pm 6775  df-en 6864  df-dom 6865  df-sdom 6866  df-fin 6867  df-sup 7194  df-oi 7225  df-card 7572  df-cda 7794  df-pnf 8869  df-mnf 8870  df-xr 8871  df-ltxr 8872  df-le 8873  df-sub 9039  df-neg 9040  df-div 9424  df-nn 9747  df-2 9804  df-3 9805  df-n0 9966  df-z 10025  df-uz 10231  df-rp 10355  df-fz 10783  df-fzo 10871  df-fl 10925  df-mod 10974  df-seq 11047  df-exp 11105  df-hash 11338  df-cj 11584  df-re 11585  df-im 11586  df-sqr 11720  df-abs 11721  df-clim 11962  df-sum 12159  df-dvds 12532  df-bits 12613  df-sad 12642
  Copyright terms: Public domain W3C validator