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

Theorem sadaddlem 12933
Description: Lemma for sadadd 12934. (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 5688 . . . . . . . . . . . 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 10089 . . . . . . . . . . . . . . . . . 18  |-  2  e.  NN
54a1i 11 . . . . . . . . . . . . . . . . 17  |-  ( ph  ->  2  e.  NN )
6 sadaddlem.3 . . . . . . . . . . . . . . . . 17  |-  ( ph  ->  N  e.  NN0 )
75, 6nnexpcld 11499 . . . . . . . . . . . . . . . 16  |-  ( ph  ->  ( 2 ^ N
)  e.  NN )
83, 7zmodcld 11222 . . . . . . . . . . . . . . 15  |-  ( ph  ->  ( A  mod  (
2 ^ N ) )  e.  NN0 )
9 fvres 5704 . . . . . . . . . . . . . . 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 12903 . . . . . . . . . . . . . . 15  |-  ( ( A  e.  ZZ  /\  N  e.  NN0 )  -> 
(bits `  ( A  mod  ( 2 ^ N
) ) )  =  ( (bits `  A
)  i^i  ( 0..^ N ) ) )
123, 6, 11syl2anc 643 . . . . . . . . . . . . . 14  |-  ( ph  ->  (bits `  ( A  mod  ( 2 ^ N
) ) )  =  ( (bits `  A
)  i^i  ( 0..^ N ) ) )
1310, 12eqtrd 2436 . . . . . . . . . . . . 13  |-  ( ph  ->  ( (bits  |`  NN0 ) `  ( A  mod  (
2 ^ N ) ) )  =  ( (bits `  A )  i^i  ( 0..^ N ) ) )
14 bitsf1o 12912 . . . . . . . . . . . . . 14  |-  (bits  |`  NN0 ) : NN0
-1-1-onto-> ( ~P NN0  i^i  Fin )
15 f1ocnvfv 5975 . . . . . . . . . . . . . 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 645 . . . . . . . . . . . . 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 2448 . . . . . . . . . . 11  |-  ( ph  ->  ( K `  (
(bits `  A )  i^i  ( 0..^ N ) ) )  =  ( A  mod  ( 2 ^ N ) ) )
1918oveq2d 6056 . . . . . . . . . 10  |-  ( ph  ->  ( A  -  ( K `  ( (bits `  A )  i^i  (
0..^ N ) ) ) )  =  ( A  -  ( A  mod  ( 2 ^ N ) ) ) )
2019oveq1d 6055 . . . . . . . . 9  |-  ( ph  ->  ( ( A  -  ( K `  ( (bits `  A )  i^i  (
0..^ N ) ) ) )  /  (
2 ^ N ) )  =  ( ( A  -  ( A  mod  ( 2 ^ N ) ) )  /  ( 2 ^ N ) ) )
213zred 10331 . . . . . . . . . 10  |-  ( ph  ->  A  e.  RR )
227nnrpd 10603 . . . . . . . . . 10  |-  ( ph  ->  ( 2 ^ N
)  e.  RR+ )
23 moddifz 11215 . . . . . . . . . 10  |-  ( ( A  e.  RR  /\  ( 2 ^ N
)  e.  RR+ )  ->  ( ( A  -  ( A  mod  ( 2 ^ N ) ) )  /  ( 2 ^ N ) )  e.  ZZ )
2421, 22, 23syl2anc 643 . . . . . . . . 9  |-  ( ph  ->  ( ( A  -  ( A  mod  ( 2 ^ N ) ) )  /  ( 2 ^ N ) )  e.  ZZ )
2520, 24eqeltrd 2478 . . . . . . . 8  |-  ( ph  ->  ( ( A  -  ( K `  ( (bits `  A )  i^i  (
0..^ N ) ) ) )  /  (
2 ^ N ) )  e.  ZZ )
267nnzd 10330 . . . . . . . . 9  |-  ( ph  ->  ( 2 ^ N
)  e.  ZZ )
277nnne0d 10000 . . . . . . . . 9  |-  ( ph  ->  ( 2 ^ N
)  =/=  0 )
28 inss1 3521 . . . . . . . . . . . . . 14  |-  ( (bits `  A )  i^i  (
0..^ N ) ) 
C_  (bits `  A
)
29 bitsss 12893 . . . . . . . . . . . . . 14  |-  (bits `  A )  C_  NN0
3028, 29sstri 3317 . . . . . . . . . . . . 13  |-  ( (bits `  A )  i^i  (
0..^ N ) ) 
C_  NN0
31 fzofi 11268 . . . . . . . . . . . . . 14  |-  ( 0..^ N )  e.  Fin
32 inss2 3522 . . . . . . . . . . . . . 14  |-  ( (bits `  A )  i^i  (
0..^ N ) ) 
C_  ( 0..^ N )
33 ssfi 7288 . . . . . . . . . . . . . 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 654 . . . . . . . . . . . . 13  |-  ( (bits `  A )  i^i  (
0..^ N ) )  e.  Fin
35 elfpw 7366 . . . . . . . . . . . . 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 887 . . . . . . . . . . . 12  |-  ( (bits `  A )  i^i  (
0..^ N ) )  e.  ( ~P NN0  i^i 
Fin )
37 f1ocnv 5646 . . . . . . . . . . . . . . 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 5633 . . . . . . . . . . . . . . 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 5544 . . . . . . . . . . . . . 14  |-  ( K : ( ~P NN0  i^i 
Fin ) --> NN0  <->  `' (bits  |` 
NN0 ) : ( ~P NN0  i^i  Fin )
--> NN0 )
4139, 40mpbir 201 . . . . . . . . . . . . 13  |-  K :
( ~P NN0  i^i  Fin ) --> NN0
4241ffvelrni 5828 . . . . . . . . . . . 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 10329 . . . . . . . . . 10  |-  ( ph  ->  ( K `  (
(bits `  A )  i^i  ( 0..^ N ) ) )  e.  ZZ )
453, 44zsubcld 10336 . . . . . . . . 9  |-  ( ph  ->  ( A  -  ( K `  ( (bits `  A )  i^i  (
0..^ N ) ) ) )  e.  ZZ )
46 dvdsval2 12810 . . . . . . . . 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 1184 . . . . . . . 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 224 . . . . . . 7  |-  ( ph  ->  ( 2 ^ N
)  ||  ( A  -  ( K `  ( (bits `  A )  i^i  ( 0..^ N ) ) ) ) )
491fveq1i 5688 . . . . . . . . . . . 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 11222 . . . . . . . . . . . . . . 15  |-  ( ph  ->  ( B  mod  (
2 ^ N ) )  e.  NN0 )
52 fvres 5704 . . . . . . . . . . . . . . 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 12903 . . . . . . . . . . . . . . 15  |-  ( ( B  e.  ZZ  /\  N  e.  NN0 )  -> 
(bits `  ( B  mod  ( 2 ^ N
) ) )  =  ( (bits `  B
)  i^i  ( 0..^ N ) ) )
5550, 6, 54syl2anc 643 . . . . . . . . . . . . . 14  |-  ( ph  ->  (bits `  ( B  mod  ( 2 ^ N
) ) )  =  ( (bits `  B
)  i^i  ( 0..^ N ) ) )
5653, 55eqtrd 2436 . . . . . . . . . . . . 13  |-  ( ph  ->  ( (bits  |`  NN0 ) `  ( B  mod  (
2 ^ N ) ) )  =  ( (bits `  B )  i^i  ( 0..^ N ) ) )
57 f1ocnvfv 5975 . . . . . . . . . . . . . 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 645 . . . . . . . . . . . . 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 2448 . . . . . . . . . . 11  |-  ( ph  ->  ( K `  (
(bits `  B )  i^i  ( 0..^ N ) ) )  =  ( B  mod  ( 2 ^ N ) ) )
6160oveq2d 6056 . . . . . . . . . 10  |-  ( ph  ->  ( B  -  ( K `  ( (bits `  B )  i^i  (
0..^ N ) ) ) )  =  ( B  -  ( B  mod  ( 2 ^ N ) ) ) )
6261oveq1d 6055 . . . . . . . . 9  |-  ( ph  ->  ( ( B  -  ( K `  ( (bits `  B )  i^i  (
0..^ N ) ) ) )  /  (
2 ^ N ) )  =  ( ( B  -  ( B  mod  ( 2 ^ N ) ) )  /  ( 2 ^ N ) ) )
6350zred 10331 . . . . . . . . . 10  |-  ( ph  ->  B  e.  RR )
64 moddifz 11215 . . . . . . . . . 10  |-  ( ( B  e.  RR  /\  ( 2 ^ N
)  e.  RR+ )  ->  ( ( B  -  ( B  mod  ( 2 ^ N ) ) )  /  ( 2 ^ N ) )  e.  ZZ )
6563, 22, 64syl2anc 643 . . . . . . . . 9  |-  ( ph  ->  ( ( B  -  ( B  mod  ( 2 ^ N ) ) )  /  ( 2 ^ N ) )  e.  ZZ )
6662, 65eqeltrd 2478 . . . . . . . 8  |-  ( ph  ->  ( ( B  -  ( K `  ( (bits `  B )  i^i  (
0..^ N ) ) ) )  /  (
2 ^ N ) )  e.  ZZ )
67 inss1 3521 . . . . . . . . . . . . . 14  |-  ( (bits `  B )  i^i  (
0..^ N ) ) 
C_  (bits `  B
)
68 bitsss 12893 . . . . . . . . . . . . . 14  |-  (bits `  B )  C_  NN0
6967, 68sstri 3317 . . . . . . . . . . . . 13  |-  ( (bits `  B )  i^i  (
0..^ N ) ) 
C_  NN0
70 inss2 3522 . . . . . . . . . . . . . 14  |-  ( (bits `  B )  i^i  (
0..^ N ) ) 
C_  ( 0..^ N )
71 ssfi 7288 . . . . . . . . . . . . . 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 654 . . . . . . . . . . . . 13  |-  ( (bits `  B )  i^i  (
0..^ N ) )  e.  Fin
73 elfpw 7366 . . . . . . . . . . . . 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 887 . . . . . . . . . . . 12  |-  ( (bits `  B )  i^i  (
0..^ N ) )  e.  ( ~P NN0  i^i 
Fin )
7541ffvelrni 5828 . . . . . . . . . . . 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 10329 . . . . . . . . . 10  |-  ( ph  ->  ( K `  (
(bits `  B )  i^i  ( 0..^ N ) ) )  e.  ZZ )
7850, 77zsubcld 10336 . . . . . . . . 9  |-  ( ph  ->  ( B  -  ( K `  ( (bits `  B )  i^i  (
0..^ N ) ) ) )  e.  ZZ )
79 dvdsval2 12810 . . . . . . . . 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 1184 . . . . . . . 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 224 . . . . . . 7  |-  ( ph  ->  ( 2 ^ N
)  ||  ( B  -  ( K `  ( (bits `  B )  i^i  ( 0..^ N ) ) ) ) )
82 dvds2add 12836 . . . . . . . 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 1184 . . . . . . 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 661 . . . . . 6  |-  ( ph  ->  ( 2 ^ N
)  ||  ( ( A  -  ( K `  ( (bits `  A
)  i^i  ( 0..^ N ) ) ) )  +  ( B  -  ( K `  ( (bits `  B )  i^i  ( 0..^ N ) ) ) ) ) )
853zcnd 10332 . . . . . . 7  |-  ( ph  ->  A  e.  CC )
8650zcnd 10332 . . . . . . 7  |-  ( ph  ->  B  e.  CC )
8743nn0cnd 10232 . . . . . . 7  |-  ( ph  ->  ( K `  (
(bits `  A )  i^i  ( 0..^ N ) ) )  e.  CC )
8876nn0cnd 10232 . . . . . . 7  |-  ( ph  ->  ( K `  (
(bits `  B )  i^i  ( 0..^ N ) ) )  e.  CC )
8985, 86, 87, 88addsub4d 9414 . . . . . 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 4198 . . . . 5  |-  ( ph  ->  ( 2 ^ N
)  ||  ( ( A  +  B )  -  ( ( K `
 ( (bits `  A )  i^i  (
0..^ N ) ) )  +  ( K `
 ( (bits `  B )  i^i  (
0..^ N ) ) ) ) ) )
913, 50zaddcld 10335 . . . . . 6  |-  ( ph  ->  ( A  +  B
)  e.  ZZ )
9244, 77zaddcld 10335 . . . . . 6  |-  ( ph  ->  ( ( K `  ( (bits `  A )  i^i  ( 0..^ N ) ) )  +  ( K `  ( (bits `  B )  i^i  (
0..^ N ) ) ) )  e.  ZZ )
93 moddvds 12814 . . . . . 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 1184 . . . . 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 224 . . . 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 12928 . . . 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 3521 . . . . . . . . 9  |-  ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) )  C_  (
(bits `  A ) sadd  (bits `  B ) )
101 sadcl 12929 . . . . . . . . . 10  |-  ( ( (bits `  A )  C_ 
NN0  /\  (bits `  B
)  C_  NN0 )  -> 
( (bits `  A
) sadd  (bits `  B )
)  C_  NN0 )
10229, 68, 101mp2an 654 . . . . . . . . 9  |-  ( (bits `  A ) sadd  (bits `  B ) )  C_  NN0
103100, 102sstri 3317 . . . . . . . 8  |-  ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) )  C_  NN0
104 inss2 3522 . . . . . . . . 9  |-  ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) )  C_  (
0..^ N )
105 ssfi 7288 . . . . . . . . 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 654 . . . . . . . 8  |-  ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) )  e.  Fin
107 elfpw 7366 . . . . . . . 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 887 . . . . . . 7  |-  ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) )  e.  ( ~P NN0  i^i  Fin )
10941ffvelrni 5828 . . . . . . 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 10231 . . . . 5  |-  ( ph  ->  ( K `  (
( (bits `  A
) sadd  (bits `  B )
)  i^i  ( 0..^ N ) ) )  e.  RR )
112110nn0ge0d 10233 . . . . 5  |-  ( ph  ->  0  <_  ( K `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) ) )
1131fveq1i 5688 . . . . . . . . . 10  |-  ( K `
 ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) ) )  =  ( `' (bits  |`  NN0 ) `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) )
114113fveq2i 5690 . . . . . . . . 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 5704 . . . . . . . . . 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 5974 . . . . . . . . . 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 645 . . . . . . . . 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 2460 . . . . . . . 8  |-  ( ph  ->  (bits `  ( K `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) ) )  =  ( ( (bits `  A
) sadd  (bits `  B )
)  i^i  ( 0..^ N ) ) )
121120, 104syl6eqss 3358 . . . . . . 7  |-  ( ph  ->  (bits `  ( K `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) ) )  C_  (
0..^ N ) )
122110nn0zd 10329 . . . . . . . 8  |-  ( ph  ->  ( K `  (
( (bits `  A
) sadd  (bits `  B )
)  i^i  ( 0..^ N ) ) )  e.  ZZ )
123 bitsfzo 12902 . . . . . . . 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 643 . . . . . . 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 224 . . . . . 6  |-  ( ph  ->  ( K `  (
( (bits `  A
) sadd  (bits `  B )
)  i^i  ( 0..^ N ) ) )  e.  ( 0..^ ( 2 ^ N ) ) )
126 elfzolt2 11103 . . . . . 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 11225 . . . . 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 1185 . . . 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 2442 . . 3  |-  ( ph  ->  ( ( A  +  B )  mod  (
2 ^ N ) )  =  ( K `
 ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) ) ) )
131130fveq2d 5691 . 2  |-  ( ph  ->  (bits `  ( ( A  +  B )  mod  ( 2 ^ N
) ) )  =  (bits `  ( K `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) ) ) )
132131, 120eqtr2d 2437 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 177    /\ wa 359  caddwcad 1385    = wceq 1649    e. wcel 1721    =/= wne 2567    i^i cin 3279    C_ wss 3280   (/)c0 3588   ifcif 3699   ~Pcpw 3759   class class class wbr 4172    e. cmpt 4226   `'ccnv 4836    |` cres 4839   -->wf 5409   -1-1-onto->wf1o 5412   ` cfv 5413  (class class class)co 6040    e. cmpt2 6042   1oc1o 6676   2oc2o 6677   Fincfn 7068   RRcr 8945   0cc0 8946   1c1 8947    + caddc 8949    < clt 9076    <_ cle 9077    - cmin 9247    / cdiv 9633   NNcn 9956   2c2 10005   NN0cn0 10177   ZZcz 10238   RR+crp 10568  ..^cfzo 11090    mod cmo 11205    seq cseq 11278   ^cexp 11337    || cdivides 12807  bitscbits 12886   sadd csad 12887
This theorem is referenced by:  sadadd  12934
This theorem was proved from axioms:  ax-1 5  ax-2 6  ax-3 7  ax-mp 8  ax-gen 1552  ax-5 1563  ax-17 1623  ax-9 1662  ax-8 1683  ax-13 1723  ax-14 1725  ax-6 1740  ax-7 1745  ax-11 1757  ax-12 1946  ax-ext 2385  ax-rep 4280  ax-sep 4290  ax-nul 4298  ax-pow 4337  ax-pr 4363  ax-un 4660  ax-inf2 7552  ax-cnex 9002  ax-resscn 9003  ax-1cn 9004  ax-icn 9005  ax-addcl 9006  ax-addrcl 9007  ax-mulcl 9008  ax-mulrcl 9009  ax-mulcom 9010  ax-addass 9011  ax-mulass 9012  ax-distr 9013  ax-i2m1 9014  ax-1ne0 9015  ax-1rid 9016  ax-rnegex 9017  ax-rrecex 9018  ax-cnre 9019  ax-pre-lttri 9020  ax-pre-lttrn 9021  ax-pre-ltadd 9022  ax-pre-mulgt0 9023  ax-pre-sup 9024
This theorem depends on definitions:  df-bi 178  df-or 360  df-an 361  df-3or 937  df-3an 938  df-xor 1311  df-tru 1325  df-had 1386  df-cad 1387  df-ex 1548  df-nf 1551  df-sb 1656  df-eu 2258  df-mo 2259  df-clab 2391  df-cleq 2397  df-clel 2400  df-nfc 2529  df-ne 2569  df-nel 2570  df-ral 2671  df-rex 2672  df-reu 2673  df-rmo 2674  df-rab 2675  df-v 2918  df-sbc 3122  df-csb 3212  df-dif 3283  df-un 3285  df-in 3287  df-ss 3294  df-pss 3296  df-nul 3589  df-if 3700  df-pw 3761  df-sn 3780  df-pr 3781  df-tp 3782  df-op 3783  df-uni 3976  df-int 4011  df-iun 4055  df-disj 4143  df-br 4173  df-opab 4227  df-mpt 4228  df-tr 4263  df-eprel 4454  df-id 4458  df-po 4463  df-so 4464  df-fr 4501  df-se 4502  df-we 4503  df-ord 4544  df-on 4545  df-lim 4546  df-suc 4547  df-om 4805  df-xp 4843  df-rel 4844  df-cnv 4845  df-co 4846  df-dm 4847  df-rn 4848  df-res 4849  df-ima 4850  df-iota 5377  df-fun 5415  df-fn 5416  df-f 5417  df-f1 5418  df-fo 5419  df-f1o 5420  df-fv 5421  df-isom 5422  df-ov 6043  df-oprab 6044  df-mpt2 6045  df-1st 6308  df-2nd 6309  df-riota 6508  df-recs 6592  df-rdg 6627  df-1o 6683  df-2o 6684  df-oadd 6687  df-er 6864  df-map 6979  df-pm 6980  df-en 7069  df-dom 7070  df-sdom 7071  df-fin 7072  df-sup 7404  df-oi 7435  df-card 7782  df-cda 8004  df-pnf 9078  df-mnf 9079  df-xr 9080  df-ltxr 9081  df-le 9082  df-sub 9249  df-neg 9250  df-div 9634  df-nn 9957  df-2 10014  df-3 10015  df-n0 10178  df-z 10239  df-uz 10445  df-rp 10569  df-fz 11000  df-fzo 11091  df-fl 11157  df-mod 11206  df-seq 11279  df-exp 11338  df-hash 11574  df-cj 11859  df-re 11860  df-im 11861  df-sqr 11995  df-abs 11996  df-clim 12237  df-sum 12435  df-dvds 12808  df-bits 12889  df-sad 12918
  Copyright terms: Public domain W3C validator