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

Theorem sadaddlem 12754
Description: Lemma for sadadd 12755. (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 5609 . . . . . . . . . . . 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 9969 . . . . . . . . . . . . . . . . . 18  |-  2  e.  NN
54a1i 10 . . . . . . . . . . . . . . . . 17  |-  ( ph  ->  2  e.  NN )
6 sadaddlem.3 . . . . . . . . . . . . . . . . 17  |-  ( ph  ->  N  e.  NN0 )
75, 6nnexpcld 11359 . . . . . . . . . . . . . . . 16  |-  ( ph  ->  ( 2 ^ N
)  e.  NN )
83, 7zmodcld 11082 . . . . . . . . . . . . . . 15  |-  ( ph  ->  ( A  mod  (
2 ^ N ) )  e.  NN0 )
9 fvres 5625 . . . . . . . . . . . . . . 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 12724 . . . . . . . . . . . . . . 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 2390 . . . . . . . . . . . . 13  |-  ( ph  ->  ( (bits  |`  NN0 ) `  ( A  mod  (
2 ^ N ) ) )  =  ( (bits `  A )  i^i  ( 0..^ N ) ) )
14 bitsf1o 12733 . . . . . . . . . . . . . 14  |-  (bits  |`  NN0 ) : NN0
-1-1-onto-> ( ~P NN0  i^i  Fin )
15 f1ocnvfv 5881 . . . . . . . . . . . . . 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 2402 . . . . . . . . . . 11  |-  ( ph  ->  ( K `  (
(bits `  A )  i^i  ( 0..^ N ) ) )  =  ( A  mod  ( 2 ^ N ) ) )
1918oveq2d 5961 . . . . . . . . . 10  |-  ( ph  ->  ( A  -  ( K `  ( (bits `  A )  i^i  (
0..^ N ) ) ) )  =  ( A  -  ( A  mod  ( 2 ^ N ) ) ) )
2019oveq1d 5960 . . . . . . . . 9  |-  ( ph  ->  ( ( A  -  ( K `  ( (bits `  A )  i^i  (
0..^ N ) ) ) )  /  (
2 ^ N ) )  =  ( ( A  -  ( A  mod  ( 2 ^ N ) ) )  /  ( 2 ^ N ) ) )
213zred 10209 . . . . . . . . . 10  |-  ( ph  ->  A  e.  RR )
227nnrpd 10481 . . . . . . . . . 10  |-  ( ph  ->  ( 2 ^ N
)  e.  RR+ )
23 moddifz 11075 . . . . . . . . . 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 2432 . . . . . . . 8  |-  ( ph  ->  ( ( A  -  ( K `  ( (bits `  A )  i^i  (
0..^ N ) ) ) )  /  (
2 ^ N ) )  e.  ZZ )
267nnzd 10208 . . . . . . . . 9  |-  ( ph  ->  ( 2 ^ N
)  e.  ZZ )
277nnne0d 9880 . . . . . . . . 9  |-  ( ph  ->  ( 2 ^ N
)  =/=  0 )
28 inss1 3465 . . . . . . . . . . . . . 14  |-  ( (bits `  A )  i^i  (
0..^ N ) ) 
C_  (bits `  A
)
29 bitsss 12714 . . . . . . . . . . . . . 14  |-  (bits `  A )  C_  NN0
3028, 29sstri 3264 . . . . . . . . . . . . 13  |-  ( (bits `  A )  i^i  (
0..^ N ) ) 
C_  NN0
31 fzofi 11128 . . . . . . . . . . . . . 14  |-  ( 0..^ N )  e.  Fin
32 inss2 3466 . . . . . . . . . . . . . 14  |-  ( (bits `  A )  i^i  (
0..^ N ) ) 
C_  ( 0..^ N )
33 ssfi 7171 . . . . . . . . . . . . . 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 7247 . . . . . . . . . . . . 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 5568 . . . . . . . . . . . . . . 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 5555 . . . . . . . . . . . . . . 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 5466 . . . . . . . . . . . . . 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 5747 . . . . . . . . . . . 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 10207 . . . . . . . . . 10  |-  ( ph  ->  ( K `  (
(bits `  A )  i^i  ( 0..^ N ) ) )  e.  ZZ )
453, 44zsubcld 10214 . . . . . . . . 9  |-  ( ph  ->  ( A  -  ( K `  ( (bits `  A )  i^i  (
0..^ N ) ) ) )  e.  ZZ )
46 dvdsval2 12631 . . . . . . . . 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 5609 . . . . . . . . . . . 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 11082 . . . . . . . . . . . . . . 15  |-  ( ph  ->  ( B  mod  (
2 ^ N ) )  e.  NN0 )
52 fvres 5625 . . . . . . . . . . . . . . 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 12724 . . . . . . . . . . . . . . 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 2390 . . . . . . . . . . . . 13  |-  ( ph  ->  ( (bits  |`  NN0 ) `  ( B  mod  (
2 ^ N ) ) )  =  ( (bits `  B )  i^i  ( 0..^ N ) ) )
57 f1ocnvfv 5881 . . . . . . . . . . . . . 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 2402 . . . . . . . . . . 11  |-  ( ph  ->  ( K `  (
(bits `  B )  i^i  ( 0..^ N ) ) )  =  ( B  mod  ( 2 ^ N ) ) )
6160oveq2d 5961 . . . . . . . . . 10  |-  ( ph  ->  ( B  -  ( K `  ( (bits `  B )  i^i  (
0..^ N ) ) ) )  =  ( B  -  ( B  mod  ( 2 ^ N ) ) ) )
6261oveq1d 5960 . . . . . . . . 9  |-  ( ph  ->  ( ( B  -  ( K `  ( (bits `  B )  i^i  (
0..^ N ) ) ) )  /  (
2 ^ N ) )  =  ( ( B  -  ( B  mod  ( 2 ^ N ) ) )  /  ( 2 ^ N ) ) )
6350zred 10209 . . . . . . . . . 10  |-  ( ph  ->  B  e.  RR )
64 moddifz 11075 . . . . . . . . . 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 2432 . . . . . . . 8  |-  ( ph  ->  ( ( B  -  ( K `  ( (bits `  B )  i^i  (
0..^ N ) ) ) )  /  (
2 ^ N ) )  e.  ZZ )
67 inss1 3465 . . . . . . . . . . . . . 14  |-  ( (bits `  B )  i^i  (
0..^ N ) ) 
C_  (bits `  B
)
68 bitsss 12714 . . . . . . . . . . . . . 14  |-  (bits `  B )  C_  NN0
6967, 68sstri 3264 . . . . . . . . . . . . 13  |-  ( (bits `  B )  i^i  (
0..^ N ) ) 
C_  NN0
70 inss2 3466 . . . . . . . . . . . . . 14  |-  ( (bits `  B )  i^i  (
0..^ N ) ) 
C_  ( 0..^ N )
71 ssfi 7171 . . . . . . . . . . . . . 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 7247 . . . . . . . . . . . . 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 5747 . . . . . . . . . . . 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 10207 . . . . . . . . . 10  |-  ( ph  ->  ( K `  (
(bits `  B )  i^i  ( 0..^ N ) ) )  e.  ZZ )
7850, 77zsubcld 10214 . . . . . . . . 9  |-  ( ph  ->  ( B  -  ( K `  ( (bits `  B )  i^i  (
0..^ N ) ) ) )  e.  ZZ )
79 dvdsval2 12631 . . . . . . . . 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 12657 . . . . . . . 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 10210 . . . . . . 7  |-  ( ph  ->  A  e.  CC )
8650zcnd 10210 . . . . . . 7  |-  ( ph  ->  B  e.  CC )
8743nn0cnd 10112 . . . . . . 7  |-  ( ph  ->  ( K `  (
(bits `  A )  i^i  ( 0..^ N ) ) )  e.  CC )
8876nn0cnd 10112 . . . . . . 7  |-  ( ph  ->  ( K `  (
(bits `  B )  i^i  ( 0..^ N ) ) )  e.  CC )
8985, 86, 87, 88addsub4d 9294 . . . . . 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 4130 . . . . 5  |-  ( ph  ->  ( 2 ^ N
)  ||  ( ( A  +  B )  -  ( ( K `
 ( (bits `  A )  i^i  (
0..^ N ) ) )  +  ( K `
 ( (bits `  B )  i^i  (
0..^ N ) ) ) ) ) )
913, 50zaddcld 10213 . . . . . 6  |-  ( ph  ->  ( A  +  B
)  e.  ZZ )
9244, 77zaddcld 10213 . . . . . 6  |-  ( ph  ->  ( ( K `  ( (bits `  A )  i^i  ( 0..^ N ) ) )  +  ( K `  ( (bits `  B )  i^i  (
0..^ N ) ) ) )  e.  ZZ )
93 moddvds 12635 . . . . . 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 12749 . . . 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 3465 . . . . . . . . . 10  |-  ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) )  C_  (
(bits `  A ) sadd  (bits `  B ) )
101 sadcl 12750 . . . . . . . . . . 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 3264 . . . . . . . . 9  |-  ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) )  C_  NN0
104 inss2 3466 . . . . . . . . . 10  |-  ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) )  C_  (
0..^ N )
105 ssfi 7171 . . . . . . . . . 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 7247 . . . . . . . . 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 5747 . . . . . . 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 10111 . . . . 5  |-  ( ph  ->  ( K `  (
( (bits `  A
) sadd  (bits `  B )
)  i^i  ( 0..^ N ) ) )  e.  RR )
113111nn0ge0d 10113 . . . . 5  |-  ( ph  ->  0  <_  ( K `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) ) )
114 fvres 5625 . . . . . . . . . 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 5609 . . . . . . . . . . 11  |-  ( K `
 ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) ) )  =  ( `' (bits  |`  NN0 ) `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) )
117116fveq2i 5611 . . . . . . . . . 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 5880 . . . . . . . . . . 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 2402 . . . . . . . . 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 2392 . . . . . . . 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 3288 . . . . . . 7  |-  ( ph  ->  (bits `  ( K `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) ) )  C_  (
0..^ N ) )
124111nn0zd 10207 . . . . . . . 8  |-  ( ph  ->  ( K `  (
( (bits `  A
) sadd  (bits `  B )
)  i^i  ( 0..^ N ) ) )  e.  ZZ )
125 bitsfzo 12723 . . . . . . . 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 10975 . . . . . 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 11085 . . . . 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 2396 . . 3  |-  ( ph  ->  ( ( A  +  B )  mod  (
2 ^ N ) )  =  ( K `
 ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) ) ) )
133132fveq2d 5612 . 2  |-  ( ph  ->  (bits `  ( ( A  +  B )  mod  ( 2 ^ N
) ) )  =  (bits `  ( K `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) ) ) )
134133, 121eqtr2d 2391 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 1379    = wceq 1642    e. wcel 1710    =/= wne 2521    i^i cin 3227    C_ wss 3228   (/)c0 3531   ifcif 3641   ~Pcpw 3701   class class class wbr 4104    e. cmpt 4158   `'ccnv 4770    |` cres 4773   -->wf 5333   -1-1-onto->wf1o 5336   ` cfv 5337  (class class class)co 5945    e. cmpt2 5947   1oc1o 6559   2oc2o 6560   Fincfn 6951   RRcr 8826   0cc0 8827   1c1 8828    + caddc 8830    < clt 8957    <_ cle 8958    - cmin 9127    / cdiv 9513   NNcn 9836   2c2 9885   NN0cn0 10057   ZZcz 10116   RR+crp 10446  ..^cfzo 10962    mod cmo 11065    seq cseq 11138   ^cexp 11197    || cdivides 12628  bitscbits 12707   sadd csad 12708
This theorem is referenced by:  sadadd  12755
This theorem was proved from axioms:  ax-1 5  ax-2 6  ax-3 7  ax-mp 8  ax-gen 1546  ax-5 1557  ax-17 1616  ax-9 1654  ax-8 1675  ax-13 1712  ax-14 1714  ax-6 1729  ax-7 1734  ax-11 1746  ax-12 1930  ax-ext 2339  ax-rep 4212  ax-sep 4222  ax-nul 4230  ax-pow 4269  ax-pr 4295  ax-un 4594  ax-inf2 7432  ax-cnex 8883  ax-resscn 8884  ax-1cn 8885  ax-icn 8886  ax-addcl 8887  ax-addrcl 8888  ax-mulcl 8889  ax-mulrcl 8890  ax-mulcom 8891  ax-addass 8892  ax-mulass 8893  ax-distr 8894  ax-i2m1 8895  ax-1ne0 8896  ax-1rid 8897  ax-rnegex 8898  ax-rrecex 8899  ax-cnre 8900  ax-pre-lttri 8901  ax-pre-lttrn 8902  ax-pre-ltadd 8903  ax-pre-mulgt0 8904  ax-pre-sup 8905
This theorem depends on definitions:  df-bi 177  df-or 359  df-an 360  df-3or 935  df-3an 936  df-xor 1305  df-tru 1319  df-had 1380  df-cad 1381  df-ex 1542  df-nf 1545  df-sb 1649  df-eu 2213  df-mo 2214  df-clab 2345  df-cleq 2351  df-clel 2354  df-nfc 2483  df-ne 2523  df-nel 2524  df-ral 2624  df-rex 2625  df-reu 2626  df-rmo 2627  df-rab 2628  df-v 2866  df-sbc 3068  df-csb 3158  df-dif 3231  df-un 3233  df-in 3235  df-ss 3242  df-pss 3244  df-nul 3532  df-if 3642  df-pw 3703  df-sn 3722  df-pr 3723  df-tp 3724  df-op 3725  df-uni 3909  df-int 3944  df-iun 3988  df-disj 4075  df-br 4105  df-opab 4159  df-mpt 4160  df-tr 4195  df-eprel 4387  df-id 4391  df-po 4396  df-so 4397  df-fr 4434  df-se 4435  df-we 4436  df-ord 4477  df-on 4478  df-lim 4479  df-suc 4480  df-om 4739  df-xp 4777  df-rel 4778  df-cnv 4779  df-co 4780  df-dm 4781  df-rn 4782  df-res 4783  df-ima 4784  df-iota 5301  df-fun 5339  df-fn 5340  df-f 5341  df-f1 5342  df-fo 5343  df-f1o 5344  df-fv 5345  df-isom 5346  df-ov 5948  df-oprab 5949  df-mpt2 5950  df-1st 6209  df-2nd 6210  df-riota 6391  df-recs 6475  df-rdg 6510  df-1o 6566  df-2o 6567  df-oadd 6570  df-er 6747  df-map 6862  df-pm 6863  df-en 6952  df-dom 6953  df-sdom 6954  df-fin 6955  df-sup 7284  df-oi 7315  df-card 7662  df-cda 7884  df-pnf 8959  df-mnf 8960  df-xr 8961  df-ltxr 8962  df-le 8963  df-sub 9129  df-neg 9130  df-div 9514  df-nn 9837  df-2 9894  df-3 9895  df-n0 10058  df-z 10117  df-uz 10323  df-rp 10447  df-fz 10875  df-fzo 10963  df-fl 11017  df-mod 11066  df-seq 11139  df-exp 11198  df-hash 11431  df-cj 11680  df-re 11681  df-im 11682  df-sqr 11816  df-abs 11817  df-clim 12058  df-sum 12256  df-dvds 12629  df-bits 12710  df-sad 12739
  Copyright terms: Public domain W3C validator