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

Theorem sadaddlem 12978
Description: Lemma for sadadd 12979. (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 5729 . . . . . . . . . . . 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 10133 . . . . . . . . . . . . . . . . . 18  |-  2  e.  NN
54a1i 11 . . . . . . . . . . . . . . . . 17  |-  ( ph  ->  2  e.  NN )
6 sadaddlem.3 . . . . . . . . . . . . . . . . 17  |-  ( ph  ->  N  e.  NN0 )
75, 6nnexpcld 11544 . . . . . . . . . . . . . . . 16  |-  ( ph  ->  ( 2 ^ N
)  e.  NN )
83, 7zmodcld 11267 . . . . . . . . . . . . . . 15  |-  ( ph  ->  ( A  mod  (
2 ^ N ) )  e.  NN0 )
9 fvres 5745 . . . . . . . . . . . . . . 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 12948 . . . . . . . . . . . . . . 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 2468 . . . . . . . . . . . . 13  |-  ( ph  ->  ( (bits  |`  NN0 ) `  ( A  mod  (
2 ^ N ) ) )  =  ( (bits `  A )  i^i  ( 0..^ N ) ) )
14 bitsf1o 12957 . . . . . . . . . . . . . 14  |-  (bits  |`  NN0 ) : NN0
-1-1-onto-> ( ~P NN0  i^i  Fin )
15 f1ocnvfv 6016 . . . . . . . . . . . . . 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 2480 . . . . . . . . . . 11  |-  ( ph  ->  ( K `  (
(bits `  A )  i^i  ( 0..^ N ) ) )  =  ( A  mod  ( 2 ^ N ) ) )
1918oveq2d 6097 . . . . . . . . . 10  |-  ( ph  ->  ( A  -  ( K `  ( (bits `  A )  i^i  (
0..^ N ) ) ) )  =  ( A  -  ( A  mod  ( 2 ^ N ) ) ) )
2019oveq1d 6096 . . . . . . . . 9  |-  ( ph  ->  ( ( A  -  ( K `  ( (bits `  A )  i^i  (
0..^ N ) ) ) )  /  (
2 ^ N ) )  =  ( ( A  -  ( A  mod  ( 2 ^ N ) ) )  /  ( 2 ^ N ) ) )
213zred 10375 . . . . . . . . . 10  |-  ( ph  ->  A  e.  RR )
227nnrpd 10647 . . . . . . . . . 10  |-  ( ph  ->  ( 2 ^ N
)  e.  RR+ )
23 moddifz 11260 . . . . . . . . . 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 2510 . . . . . . . 8  |-  ( ph  ->  ( ( A  -  ( K `  ( (bits `  A )  i^i  (
0..^ N ) ) ) )  /  (
2 ^ N ) )  e.  ZZ )
267nnzd 10374 . . . . . . . . 9  |-  ( ph  ->  ( 2 ^ N
)  e.  ZZ )
277nnne0d 10044 . . . . . . . . 9  |-  ( ph  ->  ( 2 ^ N
)  =/=  0 )
28 inss1 3561 . . . . . . . . . . . . . 14  |-  ( (bits `  A )  i^i  (
0..^ N ) ) 
C_  (bits `  A
)
29 bitsss 12938 . . . . . . . . . . . . . 14  |-  (bits `  A )  C_  NN0
3028, 29sstri 3357 . . . . . . . . . . . . 13  |-  ( (bits `  A )  i^i  (
0..^ N ) ) 
C_  NN0
31 fzofi 11313 . . . . . . . . . . . . . 14  |-  ( 0..^ N )  e.  Fin
32 inss2 3562 . . . . . . . . . . . . . 14  |-  ( (bits `  A )  i^i  (
0..^ N ) ) 
C_  ( 0..^ N )
33 ssfi 7329 . . . . . . . . . . . . . 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 7408 . . . . . . . . . . . . 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 5687 . . . . . . . . . . . . . . 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 5674 . . . . . . . . . . . . . . 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 5585 . . . . . . . . . . . . . 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 5869 . . . . . . . . . . . 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 10373 . . . . . . . . . 10  |-  ( ph  ->  ( K `  (
(bits `  A )  i^i  ( 0..^ N ) ) )  e.  ZZ )
453, 44zsubcld 10380 . . . . . . . . 9  |-  ( ph  ->  ( A  -  ( K `  ( (bits `  A )  i^i  (
0..^ N ) ) ) )  e.  ZZ )
46 dvdsval2 12855 . . . . . . . . 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 5729 . . . . . . . . . . . 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 11267 . . . . . . . . . . . . . . 15  |-  ( ph  ->  ( B  mod  (
2 ^ N ) )  e.  NN0 )
52 fvres 5745 . . . . . . . . . . . . . . 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 12948 . . . . . . . . . . . . . . 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 2468 . . . . . . . . . . . . 13  |-  ( ph  ->  ( (bits  |`  NN0 ) `  ( B  mod  (
2 ^ N ) ) )  =  ( (bits `  B )  i^i  ( 0..^ N ) ) )
57 f1ocnvfv 6016 . . . . . . . . . . . . . 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 2480 . . . . . . . . . . 11  |-  ( ph  ->  ( K `  (
(bits `  B )  i^i  ( 0..^ N ) ) )  =  ( B  mod  ( 2 ^ N ) ) )
6160oveq2d 6097 . . . . . . . . . 10  |-  ( ph  ->  ( B  -  ( K `  ( (bits `  B )  i^i  (
0..^ N ) ) ) )  =  ( B  -  ( B  mod  ( 2 ^ N ) ) ) )
6261oveq1d 6096 . . . . . . . . 9  |-  ( ph  ->  ( ( B  -  ( K `  ( (bits `  B )  i^i  (
0..^ N ) ) ) )  /  (
2 ^ N ) )  =  ( ( B  -  ( B  mod  ( 2 ^ N ) ) )  /  ( 2 ^ N ) ) )
6350zred 10375 . . . . . . . . . 10  |-  ( ph  ->  B  e.  RR )
64 moddifz 11260 . . . . . . . . . 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 2510 . . . . . . . 8  |-  ( ph  ->  ( ( B  -  ( K `  ( (bits `  B )  i^i  (
0..^ N ) ) ) )  /  (
2 ^ N ) )  e.  ZZ )
67 inss1 3561 . . . . . . . . . . . . . 14  |-  ( (bits `  B )  i^i  (
0..^ N ) ) 
C_  (bits `  B
)
68 bitsss 12938 . . . . . . . . . . . . . 14  |-  (bits `  B )  C_  NN0
6967, 68sstri 3357 . . . . . . . . . . . . 13  |-  ( (bits `  B )  i^i  (
0..^ N ) ) 
C_  NN0
70 inss2 3562 . . . . . . . . . . . . . 14  |-  ( (bits `  B )  i^i  (
0..^ N ) ) 
C_  ( 0..^ N )
71 ssfi 7329 . . . . . . . . . . . . . 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 7408 . . . . . . . . . . . . 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 5869 . . . . . . . . . . . 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 10373 . . . . . . . . . 10  |-  ( ph  ->  ( K `  (
(bits `  B )  i^i  ( 0..^ N ) ) )  e.  ZZ )
7850, 77zsubcld 10380 . . . . . . . . 9  |-  ( ph  ->  ( B  -  ( K `  ( (bits `  B )  i^i  (
0..^ N ) ) ) )  e.  ZZ )
79 dvdsval2 12855 . . . . . . . . 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 12881 . . . . . . . 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 10376 . . . . . . 7  |-  ( ph  ->  A  e.  CC )
8650zcnd 10376 . . . . . . 7  |-  ( ph  ->  B  e.  CC )
8743nn0cnd 10276 . . . . . . 7  |-  ( ph  ->  ( K `  (
(bits `  A )  i^i  ( 0..^ N ) ) )  e.  CC )
8876nn0cnd 10276 . . . . . . 7  |-  ( ph  ->  ( K `  (
(bits `  B )  i^i  ( 0..^ N ) ) )  e.  CC )
8985, 86, 87, 88addsub4d 9458 . . . . . 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 4238 . . . . 5  |-  ( ph  ->  ( 2 ^ N
)  ||  ( ( A  +  B )  -  ( ( K `
 ( (bits `  A )  i^i  (
0..^ N ) ) )  +  ( K `
 ( (bits `  B )  i^i  (
0..^ N ) ) ) ) ) )
913, 50zaddcld 10379 . . . . . 6  |-  ( ph  ->  ( A  +  B
)  e.  ZZ )
9244, 77zaddcld 10379 . . . . . 6  |-  ( ph  ->  ( ( K `  ( (bits `  A )  i^i  ( 0..^ N ) ) )  +  ( K `  ( (bits `  B )  i^i  (
0..^ N ) ) ) )  e.  ZZ )
93 moddvds 12859 . . . . . 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 12973 . . . 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 3561 . . . . . . . . 9  |-  ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) )  C_  (
(bits `  A ) sadd  (bits `  B ) )
101 sadcl 12974 . . . . . . . . . 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 3357 . . . . . . . 8  |-  ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) )  C_  NN0
104 inss2 3562 . . . . . . . . 9  |-  ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) )  C_  (
0..^ N )
105 ssfi 7329 . . . . . . . . 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 7408 . . . . . . . 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 5869 . . . . . . 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 10275 . . . . 5  |-  ( ph  ->  ( K `  (
( (bits `  A
) sadd  (bits `  B )
)  i^i  ( 0..^ N ) ) )  e.  RR )
112110nn0ge0d 10277 . . . . 5  |-  ( ph  ->  0  <_  ( K `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) ) )
1131fveq1i 5729 . . . . . . . . . 10  |-  ( K `
 ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) ) )  =  ( `' (bits  |`  NN0 ) `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) )
114113fveq2i 5731 . . . . . . . . 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 5745 . . . . . . . . . 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 6015 . . . . . . . . . 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 2492 . . . . . . . 8  |-  ( ph  ->  (bits `  ( K `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) ) )  =  ( ( (bits `  A
) sadd  (bits `  B )
)  i^i  ( 0..^ N ) ) )
121120, 104syl6eqss 3398 . . . . . . 7  |-  ( ph  ->  (bits `  ( K `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) ) )  C_  (
0..^ N ) )
122110nn0zd 10373 . . . . . . . 8  |-  ( ph  ->  ( K `  (
( (bits `  A
) sadd  (bits `  B )
)  i^i  ( 0..^ N ) ) )  e.  ZZ )
123 bitsfzo 12947 . . . . . . . 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 11148 . . . . . 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 11270 . . . . 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 2474 . . 3  |-  ( ph  ->  ( ( A  +  B )  mod  (
2 ^ N ) )  =  ( K `
 ( ( (bits `  A ) sadd  (bits `  B ) )  i^i  ( 0..^ N ) ) ) )
131130fveq2d 5732 . 2  |-  ( ph  ->  (bits `  ( ( A  +  B )  mod  ( 2 ^ N
) ) )  =  (bits `  ( K `  ( ( (bits `  A ) sadd  (bits `  B
) )  i^i  (
0..^ N ) ) ) ) )
132131, 120eqtr2d 2469 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 1388    = wceq 1652    e. wcel 1725    =/= wne 2599    i^i cin 3319    C_ wss 3320   (/)c0 3628   ifcif 3739   ~Pcpw 3799   class class class wbr 4212    e. cmpt 4266   `'ccnv 4877    |` cres 4880   -->wf 5450   -1-1-onto->wf1o 5453   ` cfv 5454  (class class class)co 6081    e. cmpt2 6083   1oc1o 6717   2oc2o 6718   Fincfn 7109   RRcr 8989   0cc0 8990   1c1 8991    + caddc 8993    < clt 9120    <_ cle 9121    - cmin 9291    / cdiv 9677   NNcn 10000   2c2 10049   NN0cn0 10221   ZZcz 10282   RR+crp 10612  ..^cfzo 11135    mod cmo 11250    seq cseq 11323   ^cexp 11382    || cdivides 12852  bitscbits 12931   sadd csad 12932
This theorem is referenced by:  sadadd  12979
This theorem was proved from axioms:  ax-1 5  ax-2 6  ax-3 7  ax-mp 8  ax-gen 1555  ax-5 1566  ax-17 1626  ax-9 1666  ax-8 1687  ax-13 1727  ax-14 1729  ax-6 1744  ax-7 1749  ax-11 1761  ax-12 1950  ax-ext 2417  ax-rep 4320  ax-sep 4330  ax-nul 4338  ax-pow 4377  ax-pr 4403  ax-un 4701  ax-inf2 7596  ax-cnex 9046  ax-resscn 9047  ax-1cn 9048  ax-icn 9049  ax-addcl 9050  ax-addrcl 9051  ax-mulcl 9052  ax-mulrcl 9053  ax-mulcom 9054  ax-addass 9055  ax-mulass 9056  ax-distr 9057  ax-i2m1 9058  ax-1ne0 9059  ax-1rid 9060  ax-rnegex 9061  ax-rrecex 9062  ax-cnre 9063  ax-pre-lttri 9064  ax-pre-lttrn 9065  ax-pre-ltadd 9066  ax-pre-mulgt0 9067  ax-pre-sup 9068
This theorem depends on definitions:  df-bi 178  df-or 360  df-an 361  df-3or 937  df-3an 938  df-xor 1314  df-tru 1328  df-had 1389  df-cad 1390  df-ex 1551  df-nf 1554  df-sb 1659  df-eu 2285  df-mo 2286  df-clab 2423  df-cleq 2429  df-clel 2432  df-nfc 2561  df-ne 2601  df-nel 2602  df-ral 2710  df-rex 2711  df-reu 2712  df-rmo 2713  df-rab 2714  df-v 2958  df-sbc 3162  df-csb 3252  df-dif 3323  df-un 3325  df-in 3327  df-ss 3334  df-pss 3336  df-nul 3629  df-if 3740  df-pw 3801  df-sn 3820  df-pr 3821  df-tp 3822  df-op 3823  df-uni 4016  df-int 4051  df-iun 4095  df-disj 4183  df-br 4213  df-opab 4267  df-mpt 4268  df-tr 4303  df-eprel 4494  df-id 4498  df-po 4503  df-so 4504  df-fr 4541  df-se 4542  df-we 4543  df-ord 4584  df-on 4585  df-lim 4586  df-suc 4587  df-om 4846  df-xp 4884  df-rel 4885  df-cnv 4886  df-co 4887  df-dm 4888  df-rn 4889  df-res 4890  df-ima 4891  df-iota 5418  df-fun 5456  df-fn 5457  df-f 5458  df-f1 5459  df-fo 5460  df-f1o 5461  df-fv 5462  df-isom 5463  df-ov 6084  df-oprab 6085  df-mpt2 6086  df-1st 6349  df-2nd 6350  df-riota 6549  df-recs 6633  df-rdg 6668  df-1o 6724  df-2o 6725  df-oadd 6728  df-er 6905  df-map 7020  df-pm 7021  df-en 7110  df-dom 7111  df-sdom 7112  df-fin 7113  df-sup 7446  df-oi 7479  df-card 7826  df-cda 8048  df-pnf 9122  df-mnf 9123  df-xr 9124  df-ltxr 9125  df-le 9126  df-sub 9293  df-neg 9294  df-div 9678  df-nn 10001  df-2 10058  df-3 10059  df-n0 10222  df-z 10283  df-uz 10489  df-rp 10613  df-fz 11044  df-fzo 11136  df-fl 11202  df-mod 11251  df-seq 11324  df-exp 11383  df-hash 11619  df-cj 11904  df-re 11905  df-im 11906  df-sqr 12040  df-abs 12041  df-clim 12282  df-sum 12480  df-dvds 12853  df-bits 12934  df-sad 12963
  Copyright terms: Public domain W3C validator