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

Theorem bitsinv1 12909
Description: There is an explicit inverse to the bits function for nonnegative integers (which can be extended to negative integers using bitscmp 12905), 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 6048 . . . . . . . . . . 11  |-  ( x  =  0  ->  (
0..^ x )  =  ( 0..^ 0 ) )
2 fzo0 11114 . . . . . . . . . . 11  |-  ( 0..^ 0 )  =  (/)
31, 2syl6eq 2452 . . . . . . . . . 10  |-  ( x  =  0  ->  (
0..^ x )  =  (/) )
43ineq2d 3502 . . . . . . . . 9  |-  ( x  =  0  ->  (
(bits `  N )  i^i  ( 0..^ x ) )  =  ( (bits `  N )  i^i  (/) ) )
5 in0 3613 . . . . . . . . 9  |-  ( (bits `  N )  i^i  (/) )  =  (/)
64, 5syl6eq 2452 . . . . . . . 8  |-  ( x  =  0  ->  (
(bits `  N )  i^i  ( 0..^ x ) )  =  (/) )
76sumeq1d 12450 . . . . . . 7  |-  ( x  =  0  ->  sum_ n  e.  ( (bits `  N
)  i^i  ( 0..^ x ) ) ( 2 ^ n )  =  sum_ n  e.  (/)  ( 2 ^ n
) )
8 sum0 12470 . . . . . . 7  |-  sum_ n  e.  (/)  ( 2 ^ n )  =  0
97, 8syl6eq 2452 . . . . . 6  |-  ( x  =  0  ->  sum_ n  e.  ( (bits `  N
)  i^i  ( 0..^ x ) ) ( 2 ^ n )  =  0 )
10 oveq2 6048 . . . . . . . 8  |-  ( x  =  0  ->  (
2 ^ x )  =  ( 2 ^ 0 ) )
11 2cn 10026 . . . . . . . . 9  |-  2  e.  CC
12 exp0 11341 . . . . . . . . 9  |-  ( 2  e.  CC  ->  (
2 ^ 0 )  =  1 )
1311, 12ax-mp 8 . . . . . . . 8  |-  ( 2 ^ 0 )  =  1
1410, 13syl6eq 2452 . . . . . . 7  |-  ( x  =  0  ->  (
2 ^ x )  =  1 )
1514oveq2d 6056 . . . . . 6  |-  ( x  =  0  ->  ( N  mod  ( 2 ^ x ) )  =  ( N  mod  1
) )
169, 15eqeq12d 2418 . . . . 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 6048 . . . . . . . 8  |-  ( x  =  k  ->  (
0..^ x )  =  ( 0..^ k ) )
1918ineq2d 3502 . . . . . . 7  |-  ( x  =  k  ->  (
(bits `  N )  i^i  ( 0..^ x ) )  =  ( (bits `  N )  i^i  (
0..^ k ) ) )
2019sumeq1d 12450 . . . . . 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 6048 . . . . . . 7  |-  ( x  =  k  ->  (
2 ^ x )  =  ( 2 ^ k ) )
2221oveq2d 6056 . . . . . 6  |-  ( x  =  k  ->  ( N  mod  ( 2 ^ x ) )  =  ( N  mod  (
2 ^ k ) ) )
2320, 22eqeq12d 2418 . . . . 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 6048 . . . . . . . 8  |-  ( x  =  ( k  +  1 )  ->  (
0..^ x )  =  ( 0..^ ( k  +  1 ) ) )
2625ineq2d 3502 . . . . . . 7  |-  ( x  =  ( k  +  1 )  ->  (
(bits `  N )  i^i  ( 0..^ x ) )  =  ( (bits `  N )  i^i  (
0..^ ( k  +  1 ) ) ) )
2726sumeq1d 12450 . . . . . 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 6048 . . . . . . 7  |-  ( x  =  ( k  +  1 )  ->  (
2 ^ x )  =  ( 2 ^ ( k  +  1 ) ) )
2928oveq2d 6056 . . . . . 6  |-  ( x  =  ( k  +  1 )  ->  ( N  mod  ( 2 ^ x ) )  =  ( N  mod  (
2 ^ ( k  +  1 ) ) ) )
3027, 29eqeq12d 2418 . . . . 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 6048 . . . . . . . 8  |-  ( x  =  N  ->  (
0..^ x )  =  ( 0..^ N ) )
3332ineq2d 3502 . . . . . . 7  |-  ( x  =  N  ->  (
(bits `  N )  i^i  ( 0..^ x ) )  =  ( (bits `  N )  i^i  (
0..^ N ) ) )
3433sumeq1d 12450 . . . . . 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 6048 . . . . . . 7  |-  ( x  =  N  ->  (
2 ^ x )  =  ( 2 ^ N ) )
3635oveq2d 6056 . . . . . 6  |-  ( x  =  N  ->  ( N  mod  ( 2 ^ x ) )  =  ( N  mod  (
2 ^ N ) ) )
3734, 36eqeq12d 2418 . . . . 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 10260 . . . . . 6  |-  ( N  e.  NN0  ->  N  e.  ZZ )
40 zmod10 11219 . . . . . 6  |-  ( N  e.  ZZ  ->  ( N  mod  1 )  =  0 )
4139, 40syl 16 . . . . 5  |-  ( N  e.  NN0  ->  ( N  mod  1 )  =  0 )
4241eqcomd 2409 . . . 4  |-  ( N  e.  NN0  ->  0  =  ( N  mod  1
) )
43 oveq1 6047 . . . . . . 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 11107 . . . . . . . . . . . . 13  |-  -.  k  e.  ( 0..^ k )
4544a1i 11 . . . . . . . . . . . 12  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  ->  -.  k  e.  (
0..^ k ) )
46 disjsn 3828 . . . . . . . . . . . 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 3502 . . . . . . . . . 10  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( (bits `  N
)  i^i  ( (
0..^ k )  i^i 
{ k } ) )  =  ( (bits `  N )  i^i  (/) ) )
49 inindi 3518 . . . . . . . . . 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 2459 . . . . . . . . 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 10476 . . . . . . . . . . . . 13  |-  NN0  =  ( ZZ>= `  0 )
5351, 52syl6eleq 2494 . . . . . . . . . . . 12  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
k  e.  ( ZZ>= ` 
0 ) )
54 fzosplitsn 11150 . . . . . . . . . . . 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 3502 . . . . . . . . . 10  |-  ( ( N  e.  NN0  /\  k  e.  NN0 )  -> 
( (bits `  N
)  i^i  ( 0..^ ( k  +  1 ) ) )  =  ( (bits `  N
)  i^i  ( (
0..^ k )  u. 
{ k } ) ) )
57 indi 3547 . . . . . . . . . 10  |-  ( (bits `  N )  i^i  (
( 0..^ k )  u.  { k } ) )  =  ( ( (bits `  N
)  i^i  ( 0..^ k ) )  u.  ( (bits `  N
)  i^i  { k } ) )
5856, 57syl6eq 2452 . . . . . . . . 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 11268 . . . . . . . . . . 11  |-  ( 0..^ ( k  +  1 ) )  e.  Fin
60 inss2 3522 . . . . . . . . . . 11  |-  ( (bits `  N )  i^i  (
0..^ ( k  +  1 ) ) ) 
C_  ( 0..^ ( k  +  1 ) )
61 ssfi 7288 . . . . . . . . . . 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 10089 . . . . . . . . . . . 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 3306 . . . . . . . . . . . . 13  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  n  e.  (
(bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) )  ->  n  e.  ( 0..^ ( k  +  1 ) ) )
68 elfzouz 11099 . . . . . . . . . . . . 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 2495 . . . . . . . . . . 11  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  n  e.  (
(bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) )  ->  n  e.  NN0 )
7165, 70nnexpcld 11499 . . . . . . . . . 10  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  n  e.  (
(bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) )  ->  (
2 ^ n )  e.  NN )
7271nncnd 9972 . . . . . . . . 9  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  n  e.  (
(bits `  N )  i^i  ( 0..^ ( k  +  1 ) ) ) )  ->  (
2 ^ n )  e.  CC )
7350, 58, 63, 72fsumsplit 12488 . . . . . . . 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 12908 . . . . . . . . . 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 2413 . . . . . . . . . . 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 2413 . . . . . . . . . . 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 3903 . . . . . . . . . . . . . 14  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  ->  { k }  C_  (bits `  N ) )
80 dfss1 3505 . . . . . . . . . . . . . 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 12450 . . . . . . . . . . . 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 11499 . . . . . . . . . . . . . 14  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  -> 
( 2 ^ k
)  e.  NN )
8685nncnd 9972 . . . . . . . . . . . . 13  |-  ( ( ( N  e.  NN0  /\  k  e.  NN0 )  /\  k  e.  (bits `  N ) )  -> 
( 2 ^ k
)  e.  CC )
87 oveq2 6048 . . . . . . . . . . . . . 14  |-  ( n  =  k  ->  (
2 ^ n )  =  ( 2 ^ k ) )
8887sumsn 12489 . . . . . . . . . . . . 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 2436 . . . . . . . . . . 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 3828 . . . . . . . . . . . . . 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 12450 . . . . . . . . . . . 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 2452 . . . . . . . . . . 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 3729 . . . . . . . . . 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 6056 . . . . . . . . 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 2439 . . . . . . . 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 2418 . . . . . . 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 10322 . . 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 2494 . . . . . 6  |-  ( N  e.  NN0  ->  N  e.  ( ZZ>= `  0 )
)
10764a1i 11 . . . . . . . 8  |-  ( N  e.  NN0  ->  2  e.  NN )
108107, 105nnexpcld 11499 . . . . . . 7  |-  ( N  e.  NN0  ->  ( 2 ^ N )  e.  NN )
109108nnzd 10330 . . . . . 6  |-  ( N  e.  NN0  ->  ( 2 ^ N )  e.  ZZ )
110 2z 10268 . . . . . . . 8  |-  2  e.  ZZ
111 uzid 10456 . . . . . . . 8  |-  ( 2  e.  ZZ  ->  2  e.  ( ZZ>= `  2 )
)
112110, 111ax-mp 8 . . . . . . 7  |-  2  e.  ( ZZ>= `  2 )
113 bernneq3 11462 . . . . . . 7  |-  ( ( 2  e.  ( ZZ>= ` 
2 )  /\  N  e.  NN0 )  ->  N  <  ( 2 ^ N
) )
114112, 113mpan 652 . . . . . 6  |-  ( N  e.  NN0  ->  N  < 
( 2 ^ N
) )
115 elfzo2 11098 . . . . . 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 12902 . . . . . 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 3294 . . . 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 12450 . 2  |-  ( N  e.  NN0  ->  sum_ n  e.  ( (bits `  N
)  i^i  ( 0..^ N ) ) ( 2 ^ n )  =  sum_ n  e.  (bits `  N ) ( 2 ^ n ) )
123 nn0re 10186 . . 3  |-  ( N  e.  NN0  ->  N  e.  RR )
124 2rp 10573 . . . . 5  |-  2  e.  RR+
125124a1i 11 . . . 4  |-  ( N  e.  NN0  ->  2  e.  RR+ )
126125, 39rpexpcld 11501 . . 3  |-  ( N  e.  NN0  ->  ( 2 ^ N )  e.  RR+ )
127 nn0ge0 10203 . . 3  |-  ( N  e.  NN0  ->  0  <_  N )
128 modid 11225 . . 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 2444 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 1721    u. cun 3278    i^i cin 3279    C_ wss 3280   (/)c0 3588   ifcif 3699   {csn 3774   class class class wbr 4172   ` cfv 5413  (class class class)co 6040   Fincfn 7068   CCcc 8944   RRcr 8945   0cc0 8946   1c1 8947    + caddc 8949    < clt 9076    <_ cle 9077   NNcn 9956   2c2 10005   NN0cn0 10177   ZZcz 10238   ZZ>=cuz 10444   RR+crp 10568  ..^cfzo 11090    mod cmo 11205   ^cexp 11337   sum_csu 12434  bitscbits 12886
This theorem is referenced by:  bitsinv2  12910  bitsf1ocnv  12911
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-tru 1325  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-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-oadd 6687  df-er 6864  df-en 7069  df-dom 7070  df-sdom 7071  df-fin 7072  df-sup 7404  df-oi 7435  df-card 7782  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
  Copyright terms: Public domain W3C validator