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

Theorem bitsinv1 12882
Description: There is an explicit inverse to the bits function for nonnegative integers (which can be extended to negative integers using bitscmp 12878), part 1. (Contributed by Mario Carneiro, 7-Sep-2016.)
Assertion
Ref Expression
bitsinv1  |-  ( N  e.  NN0  ->  sum_ n  e.  (bits `  N )
( 2 ^ n
)  =  N )
Distinct variable group:    n, N

Proof of Theorem bitsinv1
Dummy variables  k  x are mutually distinct and distinct from all other variables.
StepHypRef Expression
1 oveq2 6029 . . . . . . . . . . 11  |-  ( x  =  0  ->  (
0..^ x )  =  ( 0..^ 0 ) )
2 fzo0 11090 . . . . . . . . . . 11  |-  ( 0..^ 0 )  =  (/)
31, 2syl6eq 2436 . . . . . . . . . 10  |-  ( x  =  0  ->  (
0..^ x )  =  (/) )
43ineq2d 3486 . . . . . . . . 9  |-  ( x  =  0  ->  (
(bits `  N )  i^i  ( 0..^ x ) )  =  ( (bits `  N )  i^i  (/) ) )
5 in0 3597 . . . . . . . . 9  |-  ( (bits `  N )  i^i  (/) )  =  (/)
64, 5syl6eq 2436 . . . . . . . 8  |-  ( x  =  0  ->  (
(bits `  N )  i^i  ( 0..^ x ) )  =  (/) )
76sumeq1d 12423 . . . . . . 7  |-  ( x  =  0  ->  sum_ n  e.  ( (bits `  N
)  i^i  ( 0..^ x ) ) ( 2 ^ n )  =  sum_ n  e.  (/)  ( 2 ^ n
) )
8 sum0 12443 . . . . . . 7  |-  sum_ n  e.  (/)  ( 2 ^ n )  =  0
97, 8syl6eq 2436 . . . . . 6  |-  ( x  =  0  ->  sum_ n  e.  ( (bits `  N
)  i^i  ( 0..^ x ) ) ( 2 ^ n )  =  0 )
10 oveq2 6029 . . . . . . . 8  |-  ( x  =  0  ->  (
2 ^ x )  =  ( 2 ^ 0 ) )
11 2cn 10003 . . . . . . . . 9  |-  2  e.  CC
12 exp0 11314 . . . . . . . . 9  |-  ( 2  e.  CC  ->  (
2 ^ 0 )  =  1 )
1311, 12ax-mp 8 . . . . . . . 8  |-  ( 2 ^ 0 )  =  1
1410, 13syl6eq 2436 . . . . . . 7  |-  ( x  =  0  ->  (
2 ^ x )  =  1 )
1514oveq2d 6037 . . . . . 6  |-  ( x  =  0  ->  ( N  mod  ( 2 ^ x ) )  =  ( N  mod  1
) )
169, 15eqeq12d 2402 . . . . 5  |-  ( x  =  0  ->  ( sum_ n  e.  ( (bits `  N )  i^i  (
0..^ x ) ) ( 2 ^ n
)  =  ( N  mod  ( 2 ^ x ) )  <->  0  =  ( N  mod  1
) ) )
1716imbi2d 308 . . . 4  |-  ( x  =  0  ->  (
( N  e.  NN0  -> 
sum_ n  e.  (
(bits `  N )  i^i  ( 0..^ x ) ) ( 2 ^ n )  =  ( N  mod  ( 2 ^ x ) ) )  <->  ( N  e. 
NN0  ->  0  =  ( N  mod  1 ) ) ) )
18 oveq2 6029 . . . . . . . 8  |-  ( x  =  k  ->  (
0..^ x )  =  ( 0..^ k ) )
1918ineq2d 3486 . . . . . . 7  |-  ( x  =  k  ->  (
(bits `  N )  i^i  ( 0..^ x ) )  =  ( (bits `  N )  i^i  (
0..^ k ) ) )
2019sumeq1d 12423 . . . . . 6  |-  ( x  =  k  ->  sum_ n  e.  ( (bits `  N
)  i^i  ( 0..^ x ) ) ( 2 ^ n )  =  sum_ n  e.  ( (bits `  N )  i^i  ( 0..^ k ) ) ( 2 ^ n ) )
21 oveq2 6029 . . . . . . 7  |-  ( x  =  k  ->  (
2 ^ x )  =  ( 2 ^ k ) )
2221oveq2d 6037 . . . . . 6  |-  ( x  =  k  ->  ( N  mod  ( 2 ^ x ) )  =  ( N  mod  (
2 ^ k ) ) )
2320, 22eqeq12d 2402 . . . . 5  |-  ( x  =  k  ->  ( sum_ n  e.  ( (bits `  N )  i^i  (
0..^ x ) ) ( 2 ^ n
)  =  ( N  mod  ( 2 ^ x ) )  <->  sum_ n  e.  ( (bits `  N
)  i^i  ( 0..^ k ) ) ( 2 ^ n )  =  ( N  mod  ( 2 ^ k
) ) ) )
2423imbi2d 308 . . . 4  |-  ( x  =  k  ->  (
( N  e.  NN0  -> 
sum_ n  e.  (
(bits `  N )  i^i  ( 0..^ x ) ) ( 2 ^ n )  =  ( N  mod  ( 2 ^ x ) ) )  <->  ( N  e. 
NN0  ->  sum_ n  e.  ( (bits `  N )  i^i  ( 0..^ k ) ) ( 2 ^ n )  =  ( N  mod  ( 2 ^ k ) ) ) ) )
25 oveq2 6029 . . . . . . . 8  |-  ( x  =  ( k  +  1 )  ->  (
0..^ x )  =  ( 0..^ ( k  +  1 ) ) )
2625ineq2d 3486 . . . . . . 7  |-  ( x  =  ( k  +  1 )  ->  (
(bits `  N )  i^i  ( 0..^ x ) )  =  ( (bits `  N )  i^i  (
0..^ ( k  +  1 ) ) ) )
2726sumeq1d 12423 . . . . . 6  |-  ( x  =  ( k  +  1 )  ->  sum_ n  e.  ( (bits `  N
)  i^i  ( 0..^ x ) ) ( 2 ^ n )  =  sum_ n  e.  ( (bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) ( 2 ^ n ) )
28 oveq2 6029 . . . . . . 7  |-  ( x  =  ( k  +  1 )  ->  (
2 ^ x )  =  ( 2 ^ ( k  +  1 ) ) )
2928oveq2d 6037 . . . . . 6  |-  ( x  =  ( k  +  1 )  ->  ( N  mod  ( 2 ^ x ) )  =  ( N  mod  (
2 ^ ( k  +  1 ) ) ) )
3027, 29eqeq12d 2402 . . . . 5  |-  ( x  =  ( k  +  1 )  ->  ( sum_ n  e.  ( (bits `  N )  i^i  (
0..^ x ) ) ( 2 ^ n
)  =  ( N  mod  ( 2 ^ x ) )  <->  sum_ n  e.  ( (bits `  N
)  i^i  ( 0..^ ( k  +  1 ) ) ) ( 2 ^ n )  =  ( N  mod  ( 2 ^ (
k  +  1 ) ) ) ) )
3130imbi2d 308 . . . 4  |-  ( x  =  ( k  +  1 )  ->  (
( N  e.  NN0  -> 
sum_ n  e.  (
(bits `  N )  i^i  ( 0..^ x ) ) ( 2 ^ n )  =  ( N  mod  ( 2 ^ x ) ) )  <->  ( N  e. 
NN0  ->  sum_ n  e.  ( (bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) ( 2 ^ n )  =  ( N  mod  ( 2 ^ ( k  +  1 ) ) ) ) ) )
32 oveq2 6029 . . . . . . . 8  |-  ( x  =  N  ->  (
0..^ x )  =  ( 0..^ N ) )
3332ineq2d 3486 . . . . . . 7  |-  ( x  =  N  ->  (
(bits `  N )  i^i  ( 0..^ x ) )  =  ( (bits `  N )  i^i  (
0..^ N ) ) )
3433sumeq1d 12423 . . . . . 6  |-  ( x  =  N  ->  sum_ n  e.  ( (bits `  N
)  i^i  ( 0..^ x ) ) ( 2 ^ n )  =  sum_ n  e.  ( (bits `  N )  i^i  ( 0..^ N ) ) ( 2 ^ n ) )
35 oveq2 6029 . . . . . . 7  |-  ( x  =  N  ->  (
2 ^ x )  =  ( 2 ^ N ) )
3635oveq2d 6037 . . . . . 6  |-  ( x  =  N  ->  ( N  mod  ( 2 ^ x ) )  =  ( N  mod  (
2 ^ N ) ) )
3734, 36eqeq12d 2402 . . . . 5  |-  ( x  =  N  ->  ( sum_ n  e.  ( (bits `  N )  i^i  (
0..^ x ) ) ( 2 ^ n
)  =  ( N  mod  ( 2 ^ x ) )  <->  sum_ n  e.  ( (bits `  N
)  i^i  ( 0..^ N ) ) ( 2 ^ n )  =  ( N  mod  ( 2 ^ N
) ) ) )
3837imbi2d 308 . . . 4  |-  ( x  =  N  ->  (
( N  e.  NN0  -> 
sum_ n  e.  (
(bits `  N )  i^i  ( 0..^ x ) ) ( 2 ^ n )  =  ( N  mod  ( 2 ^ x ) ) )  <->  ( N  e. 
NN0  ->  sum_ n  e.  ( (bits `  N )  i^i  ( 0..^ N ) ) ( 2 ^ n )  =  ( N  mod  ( 2 ^ N ) ) ) ) )
39 nn0z 10237 . . . . . 6  |-  ( N  e.  NN0  ->  N  e.  ZZ )
40 zmod10 11192 . . . . . 6  |-  ( N  e.  ZZ  ->  ( N  mod  1 )  =  0 )
4139, 40syl 16 . . . . 5  |-  ( N  e.  NN0  ->  ( N  mod  1 )  =  0 )
4241eqcomd 2393 . . . 4  |-  ( N  e.  NN0  ->  0  =  ( N  mod  1
) )
43 oveq1 6028 . . . . . . 7  |-  ( sum_ n  e.  ( (bits `  N )  i^i  (
0..^ k ) ) ( 2 ^ n
)  =  ( N  mod  ( 2 ^ k ) )  -> 
( sum_ n  e.  ( (bits `  N )  i^i  ( 0..^ k ) ) ( 2 ^ n )  +  sum_ n  e.  ( (bits `  N )  i^i  {
k } ) ( 2 ^ n ) )  =  ( ( N  mod  ( 2 ^ k ) )  +  sum_ n  e.  ( (bits `  N )  i^i  { k } ) ( 2 ^ n
) ) )
44 fzonel 11083 . . . . . . . . . . . . 13  |-  -.  k  e.  ( 0..^ k )
4544a1i 11 . . . . . . . . . . . 12  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  ->  -.  k  e.  (
0..^ k ) )
46 disjsn 3812 . . . . . . . . . . . 12  |-  ( ( ( 0..^ k )  i^i  { k } )  =  (/)  <->  -.  k  e.  ( 0..^ k ) )
4745, 46sylibr 204 . . . . . . . . . . 11  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( ( 0..^ k )  i^i  { k } )  =  (/) )
4847ineq2d 3486 . . . . . . . . . 10  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( (bits `  N
)  i^i  ( (
0..^ k )  i^i 
{ k } ) )  =  ( (bits `  N )  i^i  (/) ) )
49 inindi 3502 . . . . . . . . . 10  |-  ( (bits `  N )  i^i  (
( 0..^ k )  i^i  { k } ) )  =  ( ( (bits `  N
)  i^i  ( 0..^ k ) )  i^i  ( (bits `  N
)  i^i  { k } ) )
5048, 49, 53eqtr3g 2443 . . . . . . . . 9  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( ( (bits `  N )  i^i  (
0..^ k ) )  i^i  ( (bits `  N )  i^i  {
k } ) )  =  (/) )
51 simpr 448 . . . . . . . . . . . . 13  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
k  e.  NN0 )
52 nn0uz 10453 . . . . . . . . . . . . 13  |-  NN0  =  ( ZZ>= `  0 )
5351, 52syl6eleq 2478 . . . . . . . . . . . 12  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
k  e.  ( ZZ>= ` 
0 ) )
54 fzosplitsn 11123 . . . . . . . . . . . 12  |-  ( k  e.  ( ZZ>= `  0
)  ->  ( 0..^ ( k  +  1 ) )  =  ( ( 0..^ k )  u.  { k } ) )
5553, 54syl 16 . . . . . . . . . . 11  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( 0..^ ( k  +  1 ) )  =  ( ( 0..^ k )  u.  {
k } ) )
5655ineq2d 3486 . . . . . . . . . 10  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( (bits `  N
)  i^i  ( 0..^ ( k  +  1 ) ) )  =  ( (bits `  N
)  i^i  ( (
0..^ k )  u. 
{ k } ) ) )
57 indi 3531 . . . . . . . . . 10  |-  ( (bits `  N )  i^i  (
( 0..^ k )  u.  { k } ) )  =  ( ( (bits `  N
)  i^i  ( 0..^ k ) )  u.  ( (bits `  N
)  i^i  { k } ) )
5856, 57syl6eq 2436 . . . . . . . . 9  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( (bits `  N
)  i^i  ( 0..^ ( k  +  1 ) ) )  =  ( ( (bits `  N )  i^i  (
0..^ k ) )  u.  ( (bits `  N )  i^i  {
k } ) ) )
59 fzofi 11241 . . . . . . . . . . 11  |-  ( 0..^ ( k  +  1 ) )  e.  Fin
60 inss2 3506 . . . . . . . . . . 11  |-  ( (bits `  N )  i^i  (
0..^ ( k  +  1 ) ) ) 
C_  ( 0..^ ( k  +  1 ) )
61 ssfi 7266 . . . . . . . . . . 11  |-  ( ( ( 0..^ ( k  +  1 ) )  e.  Fin  /\  (
(bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) )  C_  ( 0..^ ( k  +  1 ) ) )  -> 
( (bits `  N
)  i^i  ( 0..^ ( k  +  1 ) ) )  e. 
Fin )
6259, 60, 61mp2an 654 . . . . . . . . . 10  |-  ( (bits `  N )  i^i  (
0..^ ( k  +  1 ) ) )  e.  Fin
6362a1i 11 . . . . . . . . 9  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( (bits `  N
)  i^i  ( 0..^ ( k  +  1 ) ) )  e. 
Fin )
64 2nn 10066 . . . . . . . . . . . 12  |-  2  e.  NN
6564a1i 11 . . . . . . . . . . 11  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  n  e.  (
(bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) )  ->  2  e.  NN )
66 simpr 448 . . . . . . . . . . . . . 14  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  n  e.  (
(bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) )  ->  n  e.  ( (bits `  N
)  i^i  ( 0..^ ( k  +  1 ) ) ) )
6760, 66sseldi 3290 . . . . . . . . . . . . 13  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  n  e.  (
(bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) )  ->  n  e.  ( 0..^ ( k  +  1 ) ) )
68 elfzouz 11075 . . . . . . . . . . . . 13  |-  ( n  e.  ( 0..^ ( k  +  1 ) )  ->  n  e.  ( ZZ>= `  0 )
)
6967, 68syl 16 . . . . . . . . . . . 12  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  n  e.  (
(bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) )  ->  n  e.  ( ZZ>= `  0 )
)
7069, 52syl6eleqr 2479 . . . . . . . . . . 11  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  n  e.  (
(bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) )  ->  n  e.  NN0 )
7165, 70nnexpcld 11472 . . . . . . . . . 10  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  n  e.  (
(bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) )  ->  (
2 ^ n )  e.  NN )
7271nncnd 9949 . . . . . . . . 9  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  n  e.  (
(bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) )  ->  (
2 ^ n )  e.  CC )
7350, 58, 63, 72fsumsplit 12461 . . . . . . . 8  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  ->  sum_ n  e.  ( (bits `  N )  i^i  (
0..^ ( k  +  1 ) ) ) ( 2 ^ n
)  =  ( sum_ n  e.  ( (bits `  N )  i^i  (
0..^ k ) ) ( 2 ^ n
)  +  sum_ n  e.  ( (bits `  N
)  i^i  { k } ) ( 2 ^ n ) ) )
74 bitsinv1lem 12881 . . . . . . . . . 10  |-  ( ( N  e.  ZZ  /\  k  e.  NN0 )  -> 
( N  mod  (
2 ^ ( k  +  1 ) ) )  =  ( ( N  mod  ( 2 ^ k ) )  +  if ( k  e.  (bits `  N
) ,  ( 2 ^ k ) ,  0 ) ) )
7539, 74sylan 458 . . . . . . . . 9  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( N  mod  (
2 ^ ( k  +  1 ) ) )  =  ( ( N  mod  ( 2 ^ k ) )  +  if ( k  e.  (bits `  N
) ,  ( 2 ^ k ) ,  0 ) ) )
76 eqeq2 2397 . . . . . . . . . . 11  |-  ( ( 2 ^ k )  =  if ( k  e.  (bits `  N
) ,  ( 2 ^ k ) ,  0 )  ->  ( sum_ n  e.  ( (bits `  N )  i^i  {
k } ) ( 2 ^ n )  =  ( 2 ^ k )  <->  sum_ n  e.  ( (bits `  N
)  i^i  { k } ) ( 2 ^ n )  =  if ( k  e.  (bits `  N ) ,  ( 2 ^ k ) ,  0 ) ) )
77 eqeq2 2397 . . . . . . . . . . 11  |-  ( 0  =  if ( k  e.  (bits `  N
) ,  ( 2 ^ k ) ,  0 )  ->  ( sum_ n  e.  ( (bits `  N )  i^i  {
k } ) ( 2 ^ n )  =  0  <->  sum_ n  e.  ( (bits `  N
)  i^i  { k } ) ( 2 ^ n )  =  if ( k  e.  (bits `  N ) ,  ( 2 ^ k ) ,  0 ) ) )
78 simpr 448 . . . . . . . . . . . . . . 15  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  -> 
k  e.  (bits `  N ) )
7978snssd 3887 . . . . . . . . . . . . . 14  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  ->  { k }  C_  (bits `  N ) )
80 dfss1 3489 . . . . . . . . . . . . . 14  |-  ( { k }  C_  (bits `  N )  <->  ( (bits `  N )  i^i  {
k } )  =  { k } )
8179, 80sylib 189 . . . . . . . . . . . . 13  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  -> 
( (bits `  N
)  i^i  { k } )  =  {
k } )
8281sumeq1d 12423 . . . . . . . . . . . 12  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  ->  sum_ n  e.  ( (bits `  N )  i^i  {
k } ) ( 2 ^ n )  =  sum_ n  e.  {
k }  ( 2 ^ n ) )
83 simplr 732 . . . . . . . . . . . . 13  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  -> 
k  e.  NN0 )
8464a1i 11 . . . . . . . . . . . . . . 15  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  -> 
2  e.  NN )
8584, 83nnexpcld 11472 . . . . . . . . . . . . . 14  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  -> 
( 2 ^ k
)  e.  NN )
8685nncnd 9949 . . . . . . . . . . . . 13  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  -> 
( 2 ^ k
)  e.  CC )
87 oveq2 6029 . . . . . . . . . . . . . 14  |-  ( n  =  k  ->  (
2 ^ n )  =  ( 2 ^ k ) )
8887sumsn 12462 . . . . . . . . . . . . 13  |-  ( ( k  e.  NN0  /\  ( 2 ^ k
)  e.  CC )  ->  sum_ n  e.  {
k }  ( 2 ^ n )  =  ( 2 ^ k
) )
8983, 86, 88syl2anc 643 . . . . . . . . . . . 12  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  ->  sum_ n  e.  { k }  ( 2 ^ n )  =  ( 2 ^ k ) )
9082, 89eqtrd 2420 . . . . . . . . . . 11  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  ->  sum_ n  e.  ( (bits `  N )  i^i  {
k } ) ( 2 ^ n )  =  ( 2 ^ k ) )
91 simpr 448 . . . . . . . . . . . . . 14  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  -.  k  e.  (bits `  N ) )  ->  -.  k  e.  (bits `  N ) )
92 disjsn 3812 . . . . . . . . . . . . . 14  |-  ( ( (bits `  N )  i^i  { k } )  =  (/)  <->  -.  k  e.  (bits `  N ) )
9391, 92sylibr 204 . . . . . . . . . . . . 13  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  -.  k  e.  (bits `  N ) )  -> 
( (bits `  N
)  i^i  { k } )  =  (/) )
9493sumeq1d 12423 . . . . . . . . . . . 12  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  -.  k  e.  (bits `  N ) )  ->  sum_ n  e.  ( (bits `  N )  i^i  {
k } ) ( 2 ^ n )  =  sum_ n  e.  (/)  ( 2 ^ n
) )
9594, 8syl6eq 2436 . . . . . . . . . . 11  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  -.  k  e.  (bits `  N ) )  ->  sum_ n  e.  ( (bits `  N )  i^i  {
k } ) ( 2 ^ n )  =  0 )
9676, 77, 90, 95ifbothda 3713 . . . . . . . . . 10  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  ->  sum_ n  e.  ( (bits `  N )  i^i  {
k } ) ( 2 ^ n )  =  if ( k  e.  (bits `  N
) ,  ( 2 ^ k ) ,  0 ) )
9796oveq2d 6037 . . . . . . . . 9  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( ( N  mod  ( 2 ^ k
) )  +  sum_ n  e.  ( (bits `  N )  i^i  {
k } ) ( 2 ^ n ) )  =  ( ( N  mod  ( 2 ^ k ) )  +  if ( k  e.  (bits `  N
) ,  ( 2 ^ k ) ,  0 ) ) )
9875, 97eqtr4d 2423 . . . . . . . 8  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( N  mod  (
2 ^ ( k  +  1 ) ) )  =  ( ( N  mod  ( 2 ^ k ) )  +  sum_ n  e.  ( (bits `  N )  i^i  { k } ) ( 2 ^ n
) ) )
9973, 98eqeq12d 2402 . . . . . . 7  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( sum_ n  e.  ( (bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) ( 2 ^ n )  =  ( N  mod  ( 2 ^ ( k  +  1 ) ) )  <-> 
( sum_ n  e.  ( (bits `  N )  i^i  ( 0..^ k ) ) ( 2 ^ n )  +  sum_ n  e.  ( (bits `  N )  i^i  {
k } ) ( 2 ^ n ) )  =  ( ( N  mod  ( 2 ^ k ) )  +  sum_ n  e.  ( (bits `  N )  i^i  { k } ) ( 2 ^ n
) ) ) )
10043, 99syl5ibr 213 . . . . . 6  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( sum_ n  e.  ( (bits `  N )  i^i  ( 0..^ k ) ) ( 2 ^ n )  =  ( N  mod  ( 2 ^ k ) )  ->  sum_ n  e.  ( (bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) ( 2 ^ n )  =  ( N  mod  ( 2 ^ ( k  +  1 ) ) ) ) )
101100expcom 425 . . . . 5  |-  ( k  e.  NN0  ->  ( N  e.  NN0  ->  ( sum_ n  e.  ( (bits `  N )  i^i  (
0..^ k ) ) ( 2 ^ n
)  =  ( N  mod  ( 2 ^ k ) )  ->  sum_ n  e.  ( (bits `  N )  i^i  (
0..^ ( k  +  1 ) ) ) ( 2 ^ n
)  =  ( N  mod  ( 2 ^ ( k  +  1 ) ) ) ) ) )
102101a2d 24 . . . 4  |-  ( k  e.  NN0  ->  ( ( N  e.  NN0  ->  sum_
n  e.  ( (bits `  N )  i^i  (
0..^ k ) ) ( 2 ^ n
)  =  ( N  mod  ( 2 ^ k ) ) )  ->  ( N  e. 
NN0  ->  sum_ n  e.  ( (bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) ( 2 ^ n )  =  ( N  mod  ( 2 ^ ( k  +  1 ) ) ) ) ) )
10317, 24, 31, 38, 42, 102nn0ind 10299 . . 3  |-  ( N  e.  NN0  ->  ( N  e.  NN0  ->  sum_ n  e.  ( (bits `  N
)  i^i  ( 0..^ N ) ) ( 2 ^ n )  =  ( N  mod  ( 2 ^ N
) ) ) )
104103pm2.43i 45 . 2  |-  ( N  e.  NN0  ->  sum_ n  e.  ( (bits `  N
)  i^i  ( 0..^ N ) ) ( 2 ^ n )  =  ( N  mod  ( 2 ^ N
) ) )
105 id 20 . . . . . . 7  |-  ( N  e.  NN0  ->  N  e. 
NN0 )
106105, 52syl6eleq 2478 . . . . . 6  |-  ( N  e.  NN0  ->  N  e.  ( ZZ>= `  0 )
)
10764a1i 11 . . . . . . . 8  |-  ( N  e.  NN0  ->  2  e.  NN )
108107, 105nnexpcld 11472 . . . . . . 7  |-  ( N  e.  NN0  ->  ( 2 ^ N )  e.  NN )
109108nnzd 10307 . . . . . 6  |-  ( N  e.  NN0  ->  ( 2 ^ N )  e.  ZZ )
110 2z 10245 . . . . . . . 8  |-  2  e.  ZZ
111 uzid 10433 . . . . . . . 8  |-  ( 2  e.  ZZ  ->  2  e.  ( ZZ>= `  2 )
)
112110, 111ax-mp 8 . . . . . . 7  |-  2  e.  ( ZZ>= `  2 )
113 bernneq3 11435 . . . . . . 7  |-  ( ( 2  e.  ( ZZ>= ` 
2 )  /\  N  e.  NN0 )  ->  N  <  ( 2 ^ N
) )
114112, 113mpan 652 . . . . . 6  |-  ( N  e.  NN0  ->  N  < 
( 2 ^ N
) )
115 elfzo2 11074 . . . . . 6  |-  ( N  e.  ( 0..^ ( 2 ^ N ) )  <->  ( N  e.  ( ZZ>= `  0 )  /\  ( 2 ^ N
)  e.  ZZ  /\  N  <  ( 2 ^ N ) ) )
116106, 109, 114, 115syl3anbrc 1138 . . . . 5  |-  ( N  e.  NN0  ->  N  e.  ( 0..^ ( 2 ^ N ) ) )
117 bitsfzo 12875 . . . . . 6  |-  ( ( N  e.  ZZ  /\  N  e.  NN0 )  -> 
( N  e.  ( 0..^ ( 2 ^ N ) )  <->  (bits `  N
)  C_  ( 0..^ N ) ) )
11839, 105, 117syl2anc 643 . . . . 5  |-  ( N  e.  NN0  ->  ( N  e.  ( 0..^ ( 2 ^ N ) )  <->  (bits `  N )  C_  ( 0..^ N ) ) )
119116, 118mpbid 202 . . . 4  |-  ( N  e.  NN0  ->  (bits `  N )  C_  (
0..^ N ) )
120 df-ss 3278 . . . 4  |-  ( (bits `  N )  C_  (
0..^ N )  <->  ( (bits `  N )  i^i  (
0..^ N ) )  =  (bits `  N
) )
121119, 120sylib 189 . . 3  |-  ( N  e.  NN0  ->  ( (bits `  N )  i^i  (
0..^ N ) )  =  (bits `  N
) )
122121sumeq1d 12423 . 2  |-  ( N  e.  NN0  ->  sum_ n  e.  ( (bits `  N
)  i^i  ( 0..^ N ) ) ( 2 ^ n )  =  sum_ n  e.  (bits `  N ) ( 2 ^ n ) )
123 nn0re 10163 . . 3  |-  ( N  e.  NN0  ->  N  e.  RR )
124 2rp 10550 . . . . 5  |-  2  e.  RR+
125124a1i 11 . . . 4  |-  ( N  e.  NN0  ->  2  e.  RR+ )
126125, 39rpexpcld 11474 . . 3  |-  ( N  e.  NN0  ->  ( 2 ^ N )  e.  RR+ )
127 nn0ge0 10180 . . 3  |-  ( N  e.  NN0  ->  0  <_  N )
128 modid 11198 . . 3  |-  ( ( ( N  e.  RR  /\  ( 2 ^ N
)  e.  RR+ )  /\  ( 0  <_  N  /\  N  <  ( 2 ^ N ) ) )  ->  ( N  mod  ( 2 ^ N
) )  =  N )
129123, 126, 127, 114, 128syl22anc 1185 . 2  |-  ( N  e.  NN0  ->  ( N  mod  ( 2 ^ N ) )  =  N )
130104, 122, 1293eqtr3d 2428 1  |-  ( N  e.  NN0  ->  sum_ n  e.  (bits `  N )
( 2 ^ n
)  =  N )
Colors of variables: wff set class
Syntax hints:   -. wn 3    -> wi 4    <-> wb 177    /\ wa 359    = wceq 1649    e. wcel 1717    u. cun 3262    i^i cin 3263    C_ wss 3264   (/)c0 3572   ifcif 3683   {csn 3758   class class class wbr 4154   ` cfv 5395  (class class class)co 6021   Fincfn 7046   CCcc 8922   RRcr 8923   0cc0 8924   1c1 8925    + caddc 8927    < clt 9054    <_ cle 9055   NNcn 9933   2c2 9982   NN0cn0 10154   ZZcz 10215   ZZ>=cuz 10421   RR+crp 10545  ..^cfzo 11066    mod cmo 11178   ^cexp 11310   sum_csu 12407  bitscbits 12859
This theorem is referenced by:  bitsinv2  12883  bitsf1ocnv  12884
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 1661  ax-8 1682  ax-13 1719  ax-14 1721  ax-6 1736  ax-7 1741  ax-11 1753  ax-12 1939  ax-ext 2369  ax-rep 4262  ax-sep 4272  ax-nul 4280  ax-pow 4319  ax-pr 4345  ax-un 4642  ax-inf2 7530  ax-cnex 8980  ax-resscn 8981  ax-1cn 8982  ax-icn 8983  ax-addcl 8984  ax-addrcl 8985  ax-mulcl 8986  ax-mulrcl 8987  ax-mulcom 8988  ax-addass 8989  ax-mulass 8990  ax-distr 8991  ax-i2m1 8992  ax-1ne0 8993  ax-1rid 8994  ax-rnegex 8995  ax-rrecex 8996  ax-cnre 8997  ax-pre-lttri 8998  ax-pre-lttrn 8999  ax-pre-ltadd 9000  ax-pre-mulgt0 9001  ax-pre-sup 9002
This theorem depends on definitions:  df-bi 178  df-or 360  df-an 361  df-3or 937  df-3an 938  df-tru 1325  df-ex 1548  df-nf 1551  df-sb 1656  df-eu 2243  df-mo 2244  df-clab 2375  df-cleq 2381  df-clel 2384  df-nfc 2513  df-ne 2553  df-nel 2554  df-ral 2655  df-rex 2656  df-reu 2657  df-rmo 2658  df-rab 2659  df-v 2902  df-sbc 3106  df-csb 3196  df-dif 3267  df-un 3269  df-in 3271  df-ss 3278  df-pss 3280  df-nul 3573  df-if 3684  df-pw 3745  df-sn 3764  df-pr 3765  df-tp 3766  df-op 3767  df-uni 3959  df-int 3994  df-iun 4038  df-br 4155  df-opab 4209  df-mpt 4210  df-tr 4245  df-eprel 4436  df-id 4440  df-po 4445  df-so 4446  df-fr 4483  df-se 4484  df-we 4485  df-ord 4526  df-on 4527  df-lim 4528  df-suc 4529  df-om 4787  df-xp 4825  df-rel 4826  df-cnv 4827  df-co 4828  df-dm 4829  df-rn 4830  df-res 4831  df-ima 4832  df-iota 5359  df-fun 5397  df-fn 5398  df-f 5399  df-f1 5400  df-fo 5401  df-f1o 5402  df-fv 5403  df-isom 5404  df-ov 6024  df-oprab 6025  df-mpt2 6026  df-1st 6289  df-2nd 6290  df-riota 6486  df-recs 6570  df-rdg 6605  df-1o 6661  df-oadd 6665  df-er 6842  df-en 7047  df-dom 7048  df-sdom 7049  df-fin 7050  df-sup 7382  df-oi 7413  df-card 7760  df-pnf 9056  df-mnf 9057  df-xr 9058  df-ltxr 9059  df-le 9060  df-sub 9226  df-neg 9227  df-div 9611  df-nn 9934  df-2 9991  df-3 9992  df-n0 10155  df-z 10216  df-uz 10422  df-rp 10546  df-fz 10977  df-fzo 11067  df-fl 11130  df-mod 11179  df-seq 11252  df-exp 11311  df-hash 11547  df-cj 11832  df-re 11833  df-im 11834  df-sqr 11968  df-abs 11969  df-clim 12210  df-sum 12408  df-dvds 12781  df-bits 12862
  Copyright terms: Public domain W3C validator